[[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]]
-[[Meryのマクロ実験室:http://merysmacro.seesaa.net/]]
-[[まるエミュ for Mery:http://homepage3.nifty.com/kinzoku/editor/]]

**pdfpLaTeX.js [#w4e337a9]

----
 function main()
 {
   var fso = new ActiveXObject("Scripting.FileSystemObject");
   var c = document.Path;
   var b = fso.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 += " " + "-jobname=" + ["\"", b, "\""].join("") + " " + ["\"", b, "\""].join("");
   var dvipdfm = "dvipdfmx" + " " + ["\"", b, "\""].join("");
   var cmd = "cmd /c " + cd + " && " + latex + " && " + dvipdfm;
 
   var ok = window.Confirm(cmd);
   if (ok) {
     document.Save();
     new ActiveXObject("WScript.Shell").Run(cmd, 1, true);
   }
 }
 
 main();
----

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

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

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

**pdfpLaTeX2.js [#ia1c6201]

----
 function main()
 {
   var fso = new ActiveXObject("Scripting.FileSystemObject");
   var c = document.Path;
   var b = fso.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 += " " + "-jobname=" + ["\"", b, "\""].join("") + " " + ["\"", 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;
 
   var ok = window.Confirm(cmd);
   if (ok) {
     document.Save();
     new ActiveXObject("WScript.Shell").Run(cmd, 1, true);
   }
 }
 
 main();
----

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

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

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

**pdfupLaTeX.js [#cca95ce9]

----
 function main()
 {
   var fso = new ActiveXObject("Scripting.FileSystemObject");
   var c = document.Path;
   var b = fso.GetBaseName(document.Name);
   var cd = "cd /d " + ["\"", c, "\""].join("");
   var latex = "uplatex -synctex=1 -no-guess-input-enc -kanji=utf8" + " " + ["\"", b, "\""].join("");
   var dvipdfm = "dvipdfmx" + " " + ["\"", b, "\""].join("");
   var cmd = "cmd /c " + cd + " && " + latex + " && " + dvipdfm;
 
   var ok = window.Confirm(cmd);
   if (ok) {
     document.Save();
     new ActiveXObject("WScript.Shell").Run(cmd, 1, true);
   }
 }
 
 main();
----

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

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

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

**pdfupLaTeX2.js [#s6641f74]

----
 function main()
 {
   var fso = new ActiveXObject("Scripting.FileSystemObject");
   var c = document.Path;
   var b = fso.GetBaseName(document.Name);
   var cd = "cd /d " + ["\"", c, "\""].join("");
   var latex = "uplatex -synctex=1 -no-guess-input-enc -kanji=utf8" + " " + ["\"", 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;
 
   var ok = window.Confirm(cmd);
   if (ok) {
     document.Save();
     new ActiveXObject("WScript.Shell").Run(cmd, 1, true);
   }
 }
 
 main();
----

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

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

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

**pdfLaTeX.js [#a177f996]

----
 function main()
 {
   var fso = new ActiveXObject("Scripting.FileSystemObject");
   var c = document.Path;
   var b = fso.GetBaseName(document.Name);
   var cd = "cd /d " + ["\"", c, "\""].join("");
   var pdflatex = "pdflatex -synctex=1" + " " + ["\"", b, "\""].join("");
   var cmd = "cmd /c " + cd + " && " + pdflatex;
 
   var ok = window.Confirm(cmd);
   if (ok) {
     document.Save();
     new ActiveXObject("WScript.Shell").Run(cmd, 1, true);
   }
 }
 
 main();
----

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

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

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

**LuaLaTeX.js [#a56da2a2]

----
 function main()
 {
   var fso = new ActiveXObject("Scripting.FileSystemObject");
   var c = document.Path;
   var b = fso.GetBaseName(document.Name);
   var cd = "cd /d " + ["\"", c, "\""].join("");
   var lualatex = "lualatex -synctex=1" + " " + ["\"", b, "\""].join("");
   var cmd = "cmd /c " + cd + " && " + lualatex;
 
   var ok = window.Confirm(cmd);
   if (ok) {
     document.Save();
     new ActiveXObject("WScript.Shell").Run(cmd, 1, true);
   }
 }
 
 main();
----

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

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

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

**LuaJITLaTeX.js [#yfd8173e]

----
 function main()
 {
   var fso = new ActiveXObject("Scripting.FileSystemObject");
   var c = document.Path;
   var b = fso.GetBaseName(document.Name);
   var cd = "cd /d " + ["\"", c, "\""].join("");
   var luajitlatex = "luajitlatex -synctex=1" + " " + ["\"", b, "\""].join("");
   var cmd = "cmd /c " + cd + " && " + luajitlatex;
 
   var ok = window.Confirm(cmd);
   if (ok) {
     document.Save();
     new ActiveXObject("WScript.Shell").Run(cmd, 1, true);
   }
 }
 
 main();
----

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

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

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

**XeLaTeX.js [#x3721d4b]

----
 function main()
 {
   var fso = new ActiveXObject("Scripting.FileSystemObject");
   var c = document.Path;
   var b = fso.GetBaseName(document.Name);
   var cd = "cd /d " + ["\"", c, "\""].join("");
   var xelatex = "xelatex -synctex=1" + " " + ["\"", b, "\""].join("");
   var cmd = "cmd /c " + cd + " && " + xelatex;
 
   var ok = window.Confirm(cmd);
   if (ok) {
     document.Save();
     new ActiveXObject("WScript.Shell").Run(cmd, 1, true);
   }
 }
 
 main();
----

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

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

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

**pBibTeX.js [#qbbeae1b]

----
 function main()
 {
   var fso = new ActiveXObject("Scripting.FileSystemObject");
   var c = document.Path;
   var b = fso.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;
 
   var ok = window.Confirm(cmd);
   if (ok) {
     document.Save();
     new ActiveXObject("WScript.Shell").Run(cmd, 1, true);
   }
 }
 
 main();
----

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

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

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

**upBibTeX.js [#v9f70ec9]

----
 function main()
 {
   var fso = new ActiveXObject("Scripting.FileSystemObject");
   var c = document.Path;
   var b = fso.GetBaseName(document.Name);
   var cd = "cd /d " + ["\"", c, "\""].join("");
   var bibtex = "upbibtex" + " " + ["\"", b, "\""].join("");
   var cmd = "cmd /c " + cd + " && " + bibtex;
 
   var ok = window.Confirm(cmd);
   if (ok) {
     document.Save();
     new ActiveXObject("WScript.Shell").Run(cmd, 1, true);
   }
 }
 
 main();
----

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

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

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

**Mendex.js [#ff7fca42]

----
 function main()
 {
   var fso = new ActiveXObject("Scripting.FileSystemObject");
   var c = document.Path;
   var b = fso.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;
 
   var ok = window.Confirm(cmd);
   if (ok) {
     document.Save();
     new ActiveXObject("WScript.Shell").Run(cmd, 1, true);
   }
 }
 
 main();
----

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

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

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

**TeXworks.js [#a5baaf50]

----
 function main()
 {
   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 = texworks + " " + pdfFile;
   var cmd = "cmd /c " + cd + " && echo " + args + " | cmd";
   new ActiveXObject("WScript.Shell").Run(cmd, 1, true);
 }
 
 main();
----

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

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

----
&color(Black,#5F9EA0){%%% &color(White){''オプション''};                                             &color(Black,#CC3333){%%%[  ''&color(White){✕};''  ]%%%}; %%%};&br;
  &color(Black,#EEEEEE){%%%[ 基本 ][ 表示 ][ 記号 ]%%%};''[ キーボード ]''&color(Black,#EEEEEE){%%%[ 履歴 ][ 整形 ]%%%};&br;
&br;
   カテゴリ(%%%C%%%):                  新しいキー(%%%N%%%):&br;
   &color(Black,#EEEEEE){[マクロ                 ▼]};   %%%Ctrl+Alt+O%%%&br;
&br;
   コマンド(%%%O%%%):                  現在の割り当て:&br;
   記録/停止&br;
   実行&br;
   名前を付けて保存              現在のキー(%%%U%%%):&br;
   編集&br;
   選択&br;
   これを選択&br;
   マクロのカスタマイズ&br;
   pdfpLaTeX.js&br;
   pdfpLaTeX2.js&br;
   pdfupLaTeX.js&br;
   pdfupLaTeX2.js&br;
   pdfLaTeX.js&br;
   LuaLaTeX.js&br;
   LuaJITLaTeX.js&br;
   XeLaTeX.js&br;
   pBibTeX.js&br;
   upBibTeX.js&br;
   Mendex.js&br;
   &color(White,#1188FF){TeXworks.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]

***SumatraPDF.js [#r19c8de4]
----
 function main()
 {
   var fso = new ActiveXObject("Scripting.FileSystemObject");
   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 mainTeXDir;
   var cd;
   var cmd;
   var args;
 
   if (!fso.FileExists(sumatraPDF)) {
     sumatraPDF = "C:/Program Files (x86)/SumatraPDF/SumatraPDF.exe";
     if (!fso.FileExists(sumatraPDF)) {
       sumatraPDF = window.Prompt("Input the path to SumatraPDF.exe.", "SumatraPDF.exe");
       if (!fso.FileExists(sumatraPDF)) {
         sumatraPDF = "SumatraPDF.exe";
       }
     }
   }
 
   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");
     }
   }
 
   mainTeXDir = fso.GetParentFolderName(pdfFile);
   cd = "cd /d " + ["\"", mainTeXDir, "\""].join("");
   currentTeXFile = ["\"", currentTeXFile, "\""].join("");
   pdfFile = ["\"", pdfFile, "\""].join("");
 
   args = sumatraPDF + " -reuse-instance " + pdfFile + " -inverse-search \"\\\"" + mery + "\\\" /l %l \\\"%f\\\"\"" + " -forward-search " + currentTeXFile + " " + line;
   cmd = "cmd /c " + cd + " && echo " + args + " | cmd";
   new ActiveXObject("WScript.Shell").Run(cmd, 1, true);
 }
 
 main();
----

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

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

***fwdsumatrapdf.js [#a81d6b86]
----
 function main()
 {
   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 = "C:/w32tex/NDde/Binary/fwdsumatrapdf.exe";
   var mainTeXDir;
   var cd;
   var cmd;
   var args;

   if (!fso.FileExists(fwdsumatrapdf)) {
     fwdsumatrapdf = window.Prompt("Input the path to fwdsumatrapdf.exe.", "fwdsumatrapdf.exe");
     if (!fso.FileExists(fwdsumatrapdf)) {
       fwdsumatrapdf = "fwdsumatrapdf.exe";
     }
   }
 
   fwdsumatrapdf = ["\"", fwdsumatrapdf, "\""].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");
     }
   }
 
   mainTeXDir = fso.GetParentFolderName(pdfFile);
   cd = "cd /d " + ["\"", mainTeXDir, "\""].join("");
   currentTeXFile = ["\"", currentTeXFile, "\""].join("");
   pdfFile = ["\"", pdfFile, "\""].join("");
 
   args = fwdsumatrapdf + " " + pdfFile + " " + currentTeXFile + " " + line;
   cmd = "cmd /c " + cd + " && " + args;
   new ActiveXObject("WScript.Shell").Run(cmd, 1, true);
 }
 
 main();
----
**inverse search [#d4cfb140]

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

*Adobe Reader との連携 [#efc77172]

**pdfpLaTeXA.js [#h14da8ca]

----
 function main()
 {
   var fso = new ActiveXObject("Scripting.FileSystemObject");
   var c = document.Path;
   var b = fso.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 += " " + "-jobname=" + ["\"", b, "\""].join("") + " " + ["\"", b, "\""].join("");
   var dvipdfm = "dvipdfmx" + " " + ["\"", 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 + " & " + latex + " && " + dvipdfm + " && " + pdfopen;
 
   var ok = window.Confirm(cmd);
   if (ok) {
     document.Save();
     new ActiveXObject("WScript.Shell").Run(cmd, 1, true);
   }
 }
 
 main();
----

**pdfpLaTeX2A.js [#gd894185]

----
 function main()
 {
   var fso = new ActiveXObject("Scripting.FileSystemObject");
   var c = document.Path;
   var b = fso.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 += " " + "-jobname=" + ["\"", b, "\""].join("") + " " + ["\"", 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;
 
   var ok = window.Confirm(cmd);
   if (ok) {
     document.Save();
     new ActiveXObject("WScript.Shell").Run(cmd, 1, true);
   }
 }
 
 main();
----

**pdfupLaTeXA.js [#hdc45060]

----
 function main()
 {
   var fso = new ActiveXObject("Scripting.FileSystemObject");
   var c = document.Path;
   var b = fso.GetBaseName(document.Name);
   var cd = "cd /d " + ["\"", c, "\""].join("");
   var latex = "uplatex -no-guess-input-enc -kanji=utf8" + " " + ["\"", b, "\""].join("");
   var dvipdfm = "dvipdfmx" + " " + ["\"", 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 + " & " + latex + " && " + dvipdfm + " && " + pdfopen;
 
   var ok = window.Confirm(cmd);
   if (ok) {
     document.Save();
     new ActiveXObject("WScript.Shell").Run(cmd, 1, true);
   }
 }
 
 main();
----

**pdfupLaTeX2A.js [#r820202a]

----
 function main()
 {
   var fso = new ActiveXObject("Scripting.FileSystemObject");
   var c = document.Path;
   var b = fso.GetBaseName(document.Name);
   var cd = "cd /d " + ["\"", c, "\""].join("");
   var latex = "uplatex -no-guess-input-enc -kanji=utf8" + " " + ["\"", 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;
 
   var ok = window.Confirm(cmd);
   if (ok) {
     document.Save();
     new ActiveXObject("WScript.Shell").Run(cmd, 1, true);
   }
 }
 
 main();
----

**pdfLaTeXA.js [#u17bbe76]

----
 function main()
 {
   var fso = new ActiveXObject("Scripting.FileSystemObject");
   var c = document.Path;
   var b = fso.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;
 
   var ok = window.Confirm(cmd);
   if (ok) {
     document.Save();
     new ActiveXObject("WScript.Shell").Run(cmd, 1, true);
   }
 }
 
 main();
----

**LuaLaTeXA.js [#k5350e5c]

----
 function main()
 {
   var fso = new ActiveXObject("Scripting.FileSystemObject");
   var c = document.Path;
   var b = fso.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;
 
   var ok = window.Confirm(cmd);
   if (ok) {
     document.Save();
     new ActiveXObject("WScript.Shell").Run(cmd, 1, true);
   }
 }
 
 main();
----

**LuaJITLaTeXA.js [#occ79e7c]

----
 function main()
 {
   var fso = new ActiveXObject("Scripting.FileSystemObject");
   var c = document.Path;
   var b = fso.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;
 
   var ok = window.Confirm(cmd);
   if (ok) {
     document.Save();
     new ActiveXObject("WScript.Shell").Run(cmd, 1, true);
   }
 }
 
 main();
----

**XeLaTeXA.js [#hbb42785]

----
 function main()
 {
   var fso = new ActiveXObject("Scripting.FileSystemObject");
   var c = document.Path;
   var b = fso.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;
 
   var ok = window.Confirm(cmd);
   if (ok) {
     document.Save();
     new ActiveXObject("WScript.Shell").Run(cmd, 1, true);
   }
 }
 
 main();
----