[[Mery]] > マクロ

&color(White,#5F2F2F){  ''◆目次◆''  };&br;

#contents

*マクロ [#oa5f5cea]

マクロを使うと LaTeX 環境を簡単に作ることができます.~
マクロは,メニューの [マクロ(M)] から選択または F4 キーで実行できます.~

-[[マクロリファレンス - MeryWiki:http://www.haijin-boys.com/wiki/%E3%83%9E%E3%82%AF%E3%83%AD%E3%83%AA%E3%83%95%E3%82%A1%E3%83%AC%E3%83%B3%E3%82%B9]]
-[[マクロライブラリ - MeryWiki:http://www.haijin-boys.com/wiki/%E3%83%9E%E3%82%AF%E3%83%AD%E3%83%A9%E3%82%A4%E3%83%96%E3%83%A9%E3%83%AA]]
--[[TeX文書のコンパイル - MeryWiki:http://www.haijin-boys.com/wiki/TeX%E6%96%87%E6%9B%B8%E3%81%AE%E3%82%B3%E3%83%B3%E3%83%91%E3%82%A4%E3%83%AB]]
--[[TeX数式のチェック - MeryWiki:http://www.haijin-boys.com/wiki/TeX%E6%95%B0%E5%BC%8F%E3%81%AE%E3%83%81%E3%82%A7%E3%83%83%E3%82%AF]]
-[[Meryのマクロ実験室:http://merysmacro.seesaa.net/]]
-[[まるエミュ for Mery:http://homepage3.nifty.com/kinzoku/editor/]]

**Typeset.js [#w4e337a9]

----
 (function () {
     var menu = window.CreatePopupMenu();
     menu.Add("pLaTeX (ptex2pdf)", 1, 0);
     menu.Add("pLaTeX (dvips + ps2pdf)", 2, 0);
     menu.Add("upLaTeX (ptex2pdf)", 3, 0);
     menu.Add("upLaTeX (dvips + ps2pdf)", 4, 0);
     menu.Add("pdfLaTeX", 5, 0);
     menu.Add("LuaLaTeX", 6, 0);
     menu.Add("LuaJITLaTeX", 7, 0);
     menu.Add("XeLaTeX", 8, 0);
     menu.Add("", 0, meMenuSeparator);
     menu.Add("pLaTeX (ptex2pdf) [Adobe Reader]", 11, 0);
     menu.Add("pLaTeX (dvips + ps2pdf) [Adobe Reader]", 12, 0);
     menu.Add("upLaTeX (ptex2pdf) [Adobe Reader]", 13, 0);
     menu.Add("upLaTeX (dvips + ps2pdf) [Adobe Reader]", 14, 0);
     menu.Add("pdfLaTeX [Adobe Reader]", 15, 0);
     menu.Add("LuaLaTeX [Adobe Reader]", 16, 0);
     menu.Add("LuaJITLaTeX [Adobe Reader]", 17, 0);
     menu.Add("XeLaTeX [Adobe Reader]", 18, 0);
     menu.Add("", 0, meMenuSeparator);
     menu.Add("pBibTeX", 51, 0);
     menu.Add("upBibTeX", 52, 0);
     menu.Add("BibTeX", 53, 0);
     menu.Add("BibTeXu", 54, 0);
     menu.Add("", 0, meMenuSeparator);
     menu.Add("Mendex", 61, 0);
     menu.Add("MakeIndex", 62, 0);
     menu.Add("TeXindy", 63, 0);
     menu.Add("", 0, meMenuSeparator);
     menu.Add("TeXworks", 71, 0);
     menu.Add("SumatraPDF", 72, 0);
     menu.Add("fwdsumatrapdf", 73, 0);
     menu.Add("pdfopen", 74, 0);
     menu.Add("", 0, meMenuSeparator);
     menu.Add("Quit", 99, 0);
 
     var menuItem = menu.Track(0);
     switch (menuItem) {
     case 1:
         var c = document.Path;
         var b = new ActiveXObject("Scripting.FileSystemObject").GetBaseName(document.Name);
         var cd = "cd /d " + ["\"", c, "\""].join("");
         var ptex2pdf = "ptex2pdf -l -ot \"-synctex=1 -guess-input-enc -sjis-terminal\"";
         var encoding = document.Encoding;
         if (encoding == meEncodingUTF8WithoutSignature || encoding == meEncodingUTF8WithSignature || encoding == meEncodingUTF8) {
             ptex2pdf = "ptex2pdf -l -ot \"-synctex=1 -no-guess-input-enc -kanji=utf8 -sjis-terminal\"";
         } else if (encoding == meEncodingShiftJIS) {
             ptex2pdf = "ptex2pdf -l -ot \"-synctex=1 -no-guess-input-enc -kanji=sjis -sjis-terminal\"";
         } else if (encoding == meEncodingEUC) {
             ptex2pdf = "ptex2pdf -l -ot \"-synctex=1 -no-guess-input-enc -kanji=euc -sjis-terminal\"";
         } else if (encoding == meEncodingJIS) {
             ptex2pdf = "ptex2pdf -l -ot \"-synctex=1 -no-guess-input-enc -kanji=jis -sjis-terminal\"";
         }
         ptex2pdf += " " + ["\"", b, "\""].join("");
         var cmd = "cmd /c " + cd + " && " + ptex2pdf;
         execute(cmd);
         break;
     case 2:
         var c = document.Path;
         var b = new ActiveXObject("Scripting.FileSystemObject").GetBaseName(document.Name);
         var cd = "cd /d " + ["\"", c, "\""].join("");
         var latex = "platex -synctex=1 -guess-input-enc -sjis-terminal";
         var encoding = document.Encoding;
         if (encoding == meEncodingUTF8WithoutSignature || encoding == meEncodingUTF8WithSignature || encoding == meEncodingUTF8) {
             latex = "platex -synctex=1 -no-guess-input-enc -kanji=utf8 -sjis-terminal";
         } else if (encoding == meEncodingShiftJIS) {
             latex = "platex -synctex=1 -no-guess-input-enc -kanji=sjis -sjis-terminal";
         } else if (encoding == meEncodingEUC) {
             latex = "platex -synctex=1 -no-guess-input-enc -kanji=euc -sjis-terminal";
         } else if (encoding == meEncodingJIS) {
             latex = "platex -synctex=1 -no-guess-input-enc -kanji=jis -sjis-terminal";
         }
         latex += " " + ["\"", b, "\""].join("");
         var dvips = "dvips -Ppdf -z -f" + " " + ["\"", b, ".dvi", "\""].join("") + " | convbkmk -g > " + ["\"", b, ".ps", "\""].join("");
         var ps2pdf = "ps2pdf.bat" + " " + ["\"", b, ".ps", "\""].join("");
         var cmd = "cmd /c " + cd + " && " + latex + " && " + dvips + " && " + ps2pdf;
         execute(cmd);
         break;
     case 3:
         var c = document.Path;
         var b = new ActiveXObject("Scripting.FileSystemObject").GetBaseName(document.Name);
         var cd = "cd /d " + ["\"", c, "\""].join("");
         var ptex2pdf = "ptex2pdf -l -u -ot \"-synctex=1 -no-guess-input-enc -kanji=utf8 -sjis-terminal\"" + " " + ["\"", b, "\""].join("");
         var cmd = "cmd /c " + cd + " && " + ptex2pdf;
         execute(cmd);
         break;
     case 4:
         var c = document.Path;
         var b = new ActiveXObject("Scripting.FileSystemObject").GetBaseName(document.Name);
         var cd = "cd /d " + ["\"", c, "\""].join("");
         var latex = "uplatex -synctex=1 -no-guess-input-enc -kanji=utf8 -sjis-terminal" + " " + ["\"", b, "\""].join("");
         var dvips = "dvips -Ppdf -z -f" + " " + ["\"", b, ".dvi", "\""].join("") + " | convbkmk -u > " + ["\"", b, ".ps", "\""].join("");
         var ps2pdf = "ps2pdf.bat" + " " + ["\"", b, ".ps", "\""].join("");
         var cmd = "cmd /c " + cd + " && " + latex + " && " + dvips + " && " + ps2pdf;
         execute(cmd);
         break;
     case 5:
         var c = document.Path;
         var b = new ActiveXObject("Scripting.FileSystemObject").GetBaseName(document.Name);
         var cd = "cd /d " + ["\"", c, "\""].join("");
         var pdflatex = "pdflatex -synctex=1" + " " + ["\"", b, "\""].join("");
         var cmd = "cmd /c " + cd + " && " + pdflatex;
         execute(cmd);
         break;
     case 6:
         var c = document.Path;
         var b = new ActiveXObject("Scripting.FileSystemObject").GetBaseName(document.Name);
         var cd = "cd /d " + ["\"", c, "\""].join("");
         var lualatex = "lualatex -synctex=1" + " " + ["\"", b, "\""].join("");
         var cmd = "cmd /c " + cd + " && " + lualatex;
         execute(cmd);
         break;
     case 7:
         var c = document.Path;
         var b = new ActiveXObject("Scripting.FileSystemObject").GetBaseName(document.Name);
         var cd = "cd /d " + ["\"", c, "\""].join("");
         var luajitlatex = "luajitlatex -synctex=1" + " " + ["\"", b, "\""].join("");
         var cmd = "cmd /c " + cd + " && " + luajitlatex;
         execute(cmd);
         break;
     case 8:
         var c = document.Path;
         var b = new ActiveXObject("Scripting.FileSystemObject").GetBaseName(document.Name);
         var cd = "cd /d " + ["\"", c, "\""].join("");
         var xelatex = "xelatex -synctex=1" + " " + ["\"", b, "\""].join("");
         var cmd = "cmd /c " + cd + " && " + xelatex;
         execute(cmd);
         break;
     case 11:
         var c = document.Path;
         var b = new ActiveXObject("Scripting.FileSystemObject").GetBaseName(document.Name);
         var cd = "cd /d " + ["\"", c, "\""].join("");
         var ptex2pdf = "ptex2pdf -l -ot \"-guess-input-enc -sjis-terminal\"";
         var encoding = document.Encoding;
         if (encoding == meEncodingUTF8WithoutSignature || encoding == meEncodingUTF8WithSignature || encoding == meEncodingUTF8) {
             ptex2pdf = "ptex2pdf -l -ot \"-no-guess-input-enc -kanji=utf8 -sjis-terminal\"";
         } else if (encoding == meEncodingShiftJIS) {
             ptex2pdf = "ptex2pdf -l -ot \"-no-guess-input-enc -kanji=sjis -sjis-terminal\"";
         } else if (encoding == meEncodingEUC) {
             ptex2pdf = "ptex2pdf -l -ot \"-no-guess-input-enc -kanji=euc -sjis-terminal\"";
         } else if (encoding == meEncodingJIS) {
             ptex2pdf = "ptex2pdf -l -ot \"-no-guess-input-enc -kanji=jis -sjis-terminal\"";
         }
         ptex2pdf += " " + ["\"", b, "\""].join("");
         var pdf = ["\"", b, ".pdf", "\""].join("");
         var pdfopen = "powershell -Command \"& {$pdf = \"\"" + pdf + "\"\"; $pages = (pdfinfo $pdf | Select-String \"^Pages:\"); $page = (-split $pages)[1]; pdfopen --rxi --file $pdf --page $page}\"";
         var pdfclose = "tasklist /fi \"IMAGENAME eq AcroRd32.exe\" /nh | findstr \"AcroRd32.exe\" > nul && pdfopen --rxi --file " + pdf + " && pdfclose --rxi --file " + pdf;
         var cmd = "cmd /c " + cd + " && " + pdfclose + " & " + ptex2pdf + " && " + pdfopen;
         execute(cmd);
         break;
     case 12:
         var c = document.Path;
         var b = new ActiveXObject("Scripting.FileSystemObject").GetBaseName(document.Name);
         var cd = "cd /d " + ["\"", c, "\""].join("");
         var latex = "platex -guess-input-enc -sjis-terminal";
         var encoding = document.Encoding;
         if (encoding == meEncodingUTF8WithoutSignature || encoding == meEncodingUTF8WithSignature || encoding == meEncodingUTF8) {
             latex = "platex -no-guess-input-enc -kanji=utf8 -sjis-terminal";
         } else if (encoding == meEncodingShiftJIS) {
             latex = "platex -no-guess-input-enc -kanji=sjis -sjis-terminal";
         } else if (encoding == meEncodingEUC) {
             latex = "platex -no-guess-input-enc -kanji=euc -sjis-terminal";
         } else if (encoding == meEncodingJIS) {
             latex = "platex -no-guess-input-enc -kanji=jis -sjis-terminal";
         }
         latex += " " + ["\"", b, "\""].join("");
         var dvips = "dvips -Ppdf -z -f" + " " + ["\"", b, ".dvi", "\""].join("") + " | convbkmk -g > " + ["\"", b, ".ps", "\""].join("");
         var ps2pdf = "ps2pdf.bat" + " " + ["\"", b, ".ps", "\""].join("");
         var pdf = ["\"", b, ".pdf", "\""].join("");
         var pdfopen = "powershell -Command \"& {$pdf = \"\"" + pdf + "\"\"; $pages = (pdfinfo $pdf | Select-String \"^Pages:\"); $page = (-split $pages)[1]; pdfopen --rxi --file $pdf --page $page}\"";
         var pdfclose = "tasklist /fi \"IMAGENAME eq AcroRd32.exe\" /nh | findstr \"AcroRd32.exe\" > nul && pdfopen --rxi --file " + pdf + " && pdfclose --rxi --file " + pdf;
         var cmd = "cmd /c " + cd + " && " + pdfclose + " & " + latex + " && " + dvips + " && " + ps2pdf + " && " + pdfopen;
         execute(cmd);
         break;
     case 13:
         var c = document.Path;
         var b = new ActiveXObject("Scripting.FileSystemObject").GetBaseName(document.Name);
         var cd = "cd /d " + ["\"", c, "\""].join("");
         var ptex2pdf = "ptex2pdf -l -u -ot \"-no-guess-input-enc -kanji=utf8 -sjis-terminal\"" + " " + ["\"", b, "\""].join("");
         var pdf = ["\"", b, ".pdf", "\""].join("");
         var pdfopen = "powershell -Command \"& {$pdf = \"\"" + pdf + "\"\"; $pages = (pdfinfo $pdf | Select-String \"^Pages:\"); $page = (-split $pages)[1]; pdfopen --rxi --file $pdf --page $page}\"";
         var pdfclose = "tasklist /fi \"IMAGENAME eq AcroRd32.exe\" /nh | findstr \"AcroRd32.exe\" > nul && pdfopen --rxi --file " + pdf + " && pdfclose --rxi --file " + pdf;
         var cmd = "cmd /c " + cd + " && " + pdfclose + " & " + ptex2pdf + " && " + pdfopen;
         execute(cmd);
         break;
     case 14:
         var c = document.Path;
         var b = new ActiveXObject("Scripting.FileSystemObject").GetBaseName(document.Name);
         var cd = "cd /d " + ["\"", c, "\""].join("");
         var latex = "uplatex -no-guess-input-enc -kanji=utf8 -sjis-terminal" + " " + ["\"", b, "\""].join("");
         var dvips = "dvips -Ppdf -z -f" + " " + ["\"", b, ".dvi", "\""].join("") + " | convbkmk -u > " + ["\"", b, ".ps", "\""].join("");
         var ps2pdf = "ps2pdf.bat" + " " + ["\"", b, ".ps", "\""].join("");
         var pdf = ["\"", b, ".pdf", "\""].join("");
         var pdfopen = "powershell -Command \"& {$pdf = \"\"" + pdf + "\"\"; $pages = (pdfinfo $pdf | Select-String \"^Pages:\"); $page = (-split $pages)[1]; pdfopen --rxi --file $pdf --page $page}\"";
         var pdfclose = "tasklist /fi \"IMAGENAME eq AcroRd32.exe\" /nh | findstr \"AcroRd32.exe\" > nul && pdfopen --rxi --file " + pdf + " && pdfclose --rxi --file " + pdf;
         var cmd = "cmd /c " + cd + " && " + pdfclose + " & " + latex + " && " + dvips + " && " + ps2pdf + " && " + pdfopen;
         execute(cmd);
         break;
     case 15:
         var c = document.Path;
         var b = new ActiveXObject("Scripting.FileSystemObject").GetBaseName(document.Name);
         var cd = "cd /d " + ["\"", c, "\""].join("");
         var pdflatex = "pdflatex" + " " + ["\"", b, "\""].join("");
         var pdf = ["\"", b, ".pdf", "\""].join("");
         var pdfopen = "powershell -Command \"& {$pdf = \"\"" + pdf + "\"\"; $pages = (pdfinfo $pdf | Select-String \"^Pages:\"); $page = (-split $pages)[1]; pdfopen --rxi --file $pdf --page $page}\"";
         var pdfclose = "tasklist /fi \"IMAGENAME eq AcroRd32.exe\" /nh | findstr \"AcroRd32.exe\" > nul && pdfopen --rxi --file " + pdf + " && pdfclose --rxi --file " + pdf;
         var cmd = "cmd /c " + cd + " && " + pdfclose + " & " + pdflatex + " && " + pdfopen;
         execute(cmd);
         break;
     case 16:
         var c = document.Path;
         var b = new ActiveXObject("Scripting.FileSystemObject").GetBaseName(document.Name);
         var cd = "cd /d " + ["\"", c, "\""].join("");
         var lualatex = "lualatex" + " " + ["\"", b, "\""].join("");
         var pdf = ["\"", b, ".pdf", "\""].join("");
         var pdfopen = "powershell -Command \"& {$pdf = \"\"" + pdf + "\"\"; $pages = (pdfinfo $pdf | Select-String \"^Pages:\"); $page = (-split $pages)[1]; pdfopen --rxi --file $pdf --page $page}\"";
         var pdfclose = "tasklist /fi \"IMAGENAME eq AcroRd32.exe\" /nh | findstr \"AcroRd32.exe\" > nul && pdfopen --rxi --file " + pdf + " && pdfclose --rxi --file " + pdf;
         var cmd = "cmd /c " + cd + " && " + pdfclose + " & " + lualatex + " && " + pdfopen;
         execute(cmd);
         break;
     case 17:
         var c = document.Path;
         var b = new ActiveXObject("Scripting.FileSystemObject").GetBaseName(document.Name);
         var cd = "cd /d " + ["\"", c, "\""].join("");
         var luajitlatex = "luajitlatex" + " " + ["\"", b, "\""].join("");
         var pdf = ["\"", b, ".pdf", "\""].join("");
         var pdfopen = "powershell -Command \"& {$pdf = \"\"" + pdf + "\"\"; $pages = (pdfinfo $pdf | Select-String \"^Pages:\"); $page = (-split $pages)[1]; pdfopen --rxi --file $pdf --page $page}\"";
         var pdfclose = "tasklist /fi \"IMAGENAME eq AcroRd32.exe\" /nh | findstr \"AcroRd32.exe\" > nul && pdfopen --rxi --file " + pdf + " && pdfclose --rxi --file " + pdf;
         var cmd = "cmd /c " + cd + " && " + pdfclose + " & " + luajitlatex + " && " + pdfopen;
         execute(cmd);
         break;
     case 18:
         var c = document.Path;
         var b = new ActiveXObject("Scripting.FileSystemObject").GetBaseName(document.Name);
         var cd = "cd /d " + ["\"", c, "\""].join("");
         var xelatex = "xelatex" + " " + ["\"", b, "\""].join("");
         var pdf = ["\"", b, ".pdf", "\""].join("");
         var pdfopen = "powershell -Command \"& {$pdf = \"\"" + pdf + "\"\"; $pages = (pdfinfo $pdf | Select-String \"^Pages:\"); $page = (-split $pages)[1]; pdfopen --rxi --file $pdf --page $page}\"";
         var pdfclose = "tasklist /fi \"IMAGENAME eq AcroRd32.exe\" /nh | findstr \"AcroRd32.exe\" > nul && pdfopen --rxi --file " + pdf + " && pdfclose --rxi --file " + pdf;
         var cmd = "cmd /c " + cd + " && " + pdfclose + " & " + xelatex + " && " + pdfopen;
         execute(cmd);
         break;
     case 51:
         var c = document.Path;
         var b = new ActiveXObject("Scripting.FileSystemObject").GetBaseName(document.Name);
         var cd = "cd /d " + ["\"", c, "\""].join("");
         var bibtex = "pbibtex -sjis-terminal";
         var encoding = document.Encoding;
         if (encoding == meEncodingUTF8WithoutSignature || encoding == meEncodingUTF8WithSignature || encoding == meEncodingUTF8) {
             bibtex = "pbibtex -kanji=utf8 -sjis-terminal";
         } else if (encoding == meEncodingShiftJIS) {
             bibtex = "pbibtex -kanji=sjis -sjis-terminal";
         } else if (encoding == meEncodingEUC) {
             bibtex = "pbibtex -kanji=euc -sjis-terminal";
         } else if (encoding == meEncodingJIS) {
             bibtex = "pbibtex -kanji=jis  -sjis-terminal";
         }
         bibtex += " " + ["\"", b, "\""].join("");
         var cmd = "cmd /c " + cd + " && " + bibtex;
         execute(cmd);
         break;
     case 52:
         var c = document.Path;
         var b = new ActiveXObject("Scripting.FileSystemObject").GetBaseName(document.Name);
         var cd = "cd /d " + ["\"", c, "\""].join("");
         var bibtex = "upbibtex" + " " + ["\"", b, "\""].join("");
         var cmd = "cmd /c " + cd + " && " + bibtex;
         execute(cmd);
         break;
     case 53:
         var c = document.Path;
         var b = new ActiveXObject("Scripting.FileSystemObject").GetBaseName(document.Name);
         var cd = "cd /d " + ["\"", c, "\""].join("");
         var bibtex = "bibtex" + " " + ["\"", b, "\""].join("");
         var cmd = "cmd /c " + cd + " && " + bibtex;
         execute(cmd);
         break;
     case 54:
         var c = document.Path;
         var b = new ActiveXObject("Scripting.FileSystemObject").GetBaseName(document.Name);
         var cd = "cd /d " + ["\"", c, "\""].join("");
         var bibtex = "bibtexu" + " " + ["\"", b, "\""].join("");
         var cmd = "cmd /c " + cd + " && " + bibtex;
         execute(cmd);
         break;
     case 61:
         var c = document.Path;
         var b = new ActiveXObject("Scripting.FileSystemObject").GetBaseName(document.Name);
         var cd = "cd /d " + ["\"", c, "\""].join("");
         var makeindex = "mendex -T";
         var encoding = document.Encoding;
         if (encoding == meEncodingUTF8WithoutSignature || encoding == meEncodingUTF8WithSignature || encoding == meEncodingUTF8) {
             makeindex = "mendex -U -T";
         } else if (encoding == meEncodingShiftJIS) {
             makeindex = "mendex -S -T";
         } else if (encoding == meEncodingEUC) {
             makeindex = "mendex -E -T";
         } else if (encoding == meEncodingJIS) {
             makeindex = "mendex -J -T";
         }
         makeindex += " " + ["\"", b, "\""].join("");
         var cmd = "cmd /c " + cd + " && " + makeindex;
         execute(cmd);
         break;
     case 62:
         var c = document.Path;
         var b = new ActiveXObject("Scripting.FileSystemObject").GetBaseName(document.Name);
         var cd = "cd /d " + ["\"", c, "\""].join("");
         var makeindex = "makeindex" + " " + ["\"", b, "\""].join("");
         var cmd = "cmd /c " + cd + " && " + makeindex;
         execute(cmd);
         break;
     case 63:
         var c = document.Path;
         var b = new ActiveXObject("Scripting.FileSystemObject").GetBaseName(document.Name);
         var cd = "cd /d " + ["\"", c, "\""].join("");
         var makeindex = "texindy" + " " + ["\"", b, "\""].join("");
         var cmd = "cmd /c " + cd + " && " + makeindex;
         execute(cmd);
         break;
     case 71:
         var fso = new ActiveXObject("Scripting.FileSystemObject");
         var currentTeXFile = document.FullName;
         var pdfFile = currentTeXFile.replace(new RegExp(/\.[^.]*$/), ".pdf");
         var texworks = "texworks";
 
         if (!fso.FileExists(pdfFile)) {
             var mainTeXFile = window.Prompt("Input the path to main TeX file.", pdfFile.replace(new RegExp(/\.[^.]*$/), ".tex"));
             if (mainTeXFile != "") {
                 pdfFile = mainTeXFile.replace(new RegExp(/\.[^.]*$/), ".pdf");
             }
         }
 
         var mainTeXDir = fso.GetParentFolderName(pdfFile);
         var cd = "cd /d " + ["\"", mainTeXDir, "\""].join("");
         pdfFile = ["\"", pdfFile, "\""].join("");
 
         var args = pdfFile;
         new ActiveXObject("Shell.Application").ShellExecute(texworks, args, "", "open", 1);
         break;
     case 72:
         var fso = new ActiveXObject("Scripting.FileSystemObject");
         var wshShell = new ActiveXObject("WScript.Shell");
         var mery = editor.FullName;
         var currentTeXFile = document.FullName;
         var pdfFile = currentTeXFile.replace(new RegExp(/\.[^.]*$/), ".pdf");
         var line = document.selection.GetActivePointY(mePosLogical);
         var sumatraPDF = "C:\\Program Files\\SumatraPDF\\SumatraPDF.exe";
         var existSumatraPDF = true;
 
         try {
             sumatraPDF = wshShell.RegRead("HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\SumatraPDF.exe\\");
         } catch (e) {
             if (!fso.FileExists(sumatraPDF)) {
                 sumatraPDF = window.Prompt("Input the path to SumatraPDF.exe.", "SumatraPDF.exe");
                 if (!fso.FileExists(sumatraPDF)) {
                     sumatraPDF = "SumatraPDF.exe";
                     existSumatraPDF = false;
                 }
             }
         }
 
         if (existSumatraPDF) {
             sumatraPDF = ["\"", sumatraPDF, "\""].join("");
         }
 
         if (!fso.FileExists(pdfFile)) {
             var mainTeXFile = window.Prompt("Input the path to main TeX file.", pdfFile.replace(new RegExp(/\.[^.]*$/), ".tex"));
             if (mainTeXFile != "") {
                 pdfFile = mainTeXFile.replace(new RegExp(/\.[^.]*$/), ".pdf");
             }
         }
 
         var mainTeXDir = fso.GetParentFolderName(pdfFile);
         var cd = "cd /d " + ["\"", mainTeXDir, "\""].join("");
         currentTeXFile = ["\"", currentTeXFile, "\""].join("");
         pdfFile = ["\"", pdfFile, "\""].join("");
 
         var args = "-reuse-instance " + pdfFile + " -inverse-search \"\\\"" + mery + "\\\" /l %l \\\"%f\\\"\"" + " -forward-search " + currentTeXFile + " " + line;
         new ActiveXObject("Shell.Application").ShellExecute(sumatraPDF, args, "", "open", 1);
         break;
     case 73:
         var fso = new ActiveXObject("Scripting.FileSystemObject");
         var currentTeXFile = document.FullName;
         var pdfFile = currentTeXFile.replace(new RegExp(/\.[^.]*$/), ".pdf");
         var line = document.selection.GetActivePointY(mePosLogical);
         var fwdsumatrapdf = "fwdsumatrapdf.exe";
 
         if (!fso.FileExists(pdfFile)) {
             var mainTeXFile = window.Prompt("Input the path to main TeX file.", pdfFile.replace(new RegExp(/\.[^.]*$/), ".tex"));
             if (mainTeXFile != "") {
                 pdfFile = mainTeXFile.replace(new RegExp(/\.[^.]*$/), ".pdf");
             }
         }
 
         var mainTeXDir = fso.GetParentFolderName(pdfFile);
         var cd = "cd /d " + ["\"", mainTeXDir, "\""].join("");
         currentTeXFile = ["\"", currentTeXFile, "\""].join("");
         pdfFile = ["\"", pdfFile, "\""].join("");
 
         var args = pdfFile + " " + currentTeXFile + " " + line;
         new ActiveXObject("Shell.Application").ShellExecute(fwdsumatrapdf, args, "", "open", 1);
         break;
     case 74:
         var fso = new ActiveXObject("Scripting.FileSystemObject");
         var currentTeXFile = document.FullName;
         var pdfFile = currentTeXFile.replace(new RegExp(/\.[^.]*$/), ".pdf");
         var pdfopen = "pdfopen";
 
         if (!fso.FileExists(pdfFile)) {
             var mainTeXFile = window.Prompt("Input the path to main TeX file.", pdfFile.replace(new RegExp(/\.[^.]*$/), ".tex"));
             if (mainTeXFile != "") {
                 pdfFile = mainTeXFile.replace(new RegExp(/\.[^.]*$/), ".pdf");
             }
         }
 
         var mainTeXDir = fso.GetParentFolderName(pdfFile);
         var cd = "cd /d " + ["\"", mainTeXDir, "\""].join("");
         pdfFile = ["\"", pdfFile, "\""].join("");
 
         var args = "--rxi --file " + pdfFile;
         new ActiveXObject("Shell.Application").ShellExecute(pdfopen, args, "", "open", 1);
         break;
     case 99:
         window.Quit();
         break;
     default:
         window.Quit();
         break;
     }
 
     function execute(commandLine) {
         var ok = window.Confirm(commandLine);
         if (ok) {
             document.Save();
             new ActiveXObject("WScript.Shell").Run(commandLine, 1, true);
         }
     }
 }.call(this));
----

[マクロ(M)]-[カスタマイズ(C)...]-[新規作成(N)] で Typeset.js を選択します.

[ツール(T)]-[オプション(O)...]-[キーボード] でショートカットキー (Ctrl+T) を追加して割り当てます.

----
&color(#5F9EA0,#5F9EA0){%%%                         &color(Black){''オプション''};                     &color(#DD4444,#DD4444){%%%[ &color(White){''×''}; ]%%%};%%%};&br;
  &color(Black,#EEEEEE){%%%[ 基本 ][ 表示 ][ 記号 ]%%%};''[ キーボード ]''&color(Black,#EEEEEE){%%%[ 履歴 ][ 整形 ]%%%};&br;
&br;
   カテゴリ(%%%C%%%):                  新しいキー(%%%N%%%):&br;
   &color(Black,#EEEEEE){[マクロ                 ''ᐯ'']};   %%%Ctrl+T%%%&br;
&br;
   コマンド(%%%O%%%):                  現在の割り当て:&br;
   記録/停止&br;
   実行&br;
   名前を付けて保存              現在のキー(%%%U%%%):&br;
   編集&br;
   選択&br;
   これを選択&br;
   マクロのカスタマイズ&br;
   &color(White,#1188FF){Typeset.js                };&br;
&br;
----

//*その他の便利な TeX 用マクロ [#w4fa8cd3]
//
//**[[Beta, Build: 2.0.9.3936とマクロ:http://www.haijin-boys.com/index.php?fuseaction=weblog.entryInquire&entry_id=50546e5d130fe0.87291176#comment]] [#ebdddd03]
//
//**[[テキストエディタMery用LaTeXコンパイルマクロ:http://blog.kassyi.com/2011/10/merylatex.html]] [#ffd665b4]
//
//**MeryからTeXのコンパイル&PDF生成ができるようにする (LaTeXMacro.js + makepdf.ps1) [#n2ac0dc8]
//
//-[[TexをWindowsで使う:http://blog.kassyi.com/2011/05/texwindows_05.html]]
//-[[TeXをWindowsで使う(まとめ):http://blog.kassyi.com/2011/05/texwindows.html]]

*SumatraPDF との連携 [#ra6f502f]

**forward and inverse search (SumatraPDF を前面に表示したい場合) [#deefc535]

Typeset.js を実行して

-pLaTeX (ptex2pdf)
-pLaTeX (dvips + ps2pdf)
-upLaTeX (ptex2pdf)
-upLaTeX (dvips + ps2pdf)
-pdfLaTeX
-LuaLaTeX
-LuaJITLaTeX
-XeLaTeX

を選択します.

再び Typeset.js を実行して SumatraPDF を選択します.~

**forward search (SumatraPDF を前面に表示したくない場合) [#t56d91ba]

[[SumatraPDF/fwdsumatrapdf]] の fwdsumatrapdf.exe を使用します.~

Typeset.js を実行して

-pLaTeX (ptex2pdf)
-pLaTeX (dvips + ps2pdf)
-upLaTeX (ptex2pdf)
-upLaTeX (dvips + ps2pdf)
-pdfLaTeX
-LuaLaTeX
-LuaJITLaTeX
-XeLaTeX

を選択します.

再び Typeset.js を実行して fwdsumatrapdf を選択します.~

**inverse search [#d4cfb140]

 "C:\Mery\Mery.exe" /l %l "%f"

*Adobe Reader との連携 [#s85eb63a]

Typeset.js を実行して

-pLaTeX (ptex2pdf) [Adobe Reader]
-pLaTeX (dvips + ps2pdf) [Adobe Reader]
-upLaTeX (ptex2pdf) [Adobe Reader]
-upLaTeX (dvips + ps2pdf) [Adobe Reader]
-pdfLaTeX [Adobe Reader]
-LuaLaTeX [Adobe Reader]
-LuaJITLaTeX [Adobe Reader]
-XeLaTeX [Adobe Reader]

を選択します.