Macro/投稿/76

http://sakura.qp.land.to/?Macro%2F%C5%EA%B9%C6%2F76


Top > Macro > 投稿 > 76

upLaTeX (ptex2pdf) または LuaLaTeX でタイプセット → PDF を表示

  • ページ: Macro/投稿
  • 作者: sai
  • カテゴリー: js
  • 投稿日: 2015-10-27 (火) 00:00:00

メッセージ

upLaTeX (ptex2pdf) でタイプセット → SumatraPDF で表示

  • pdfupLaTeXS.js
      0
      1
      2
      3
      4
      5
      6
      7
      8
      9
     10
     11
     12
     13
     14
     15
     16
     17
     18
     19
     20
     21
     22
     23
     24
     25
     26
     27
     28
     29
     30
     31
     32
     33
     34
     35
     36
     37
     38
    
    (function () {
        var fso = new ActiveXObject("Scripting.FileSystemObject");
        var wshShell = new ActiveXObject("WScript.Shell");
        var sakuraEditor = Editor.ExpandParameter("$S");
        var currentTeXFile = Editor.ExpandParameter("$F");
        var suffix = /\.[^.]*$/;
        var pdfFile = currentTeXFile.replace(suffix, ".pdf");
        var line = Editor.ExpandParameter("$y");
        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 = Editor.InputBox("Input the path to SumatraPDF.exe.", "SumatraPDF.exe", 255);
                if (!fso.FileExists(sumatraPDF)) {
                    sumatraPDF = "rundll32 shell32,ShellExec_RunDLL SumatraPDF";
                    existSumatraPDF = false;
                }
            }
        }
     
        if (existSumatraPDF) {
            sumatraPDF = ["\"", sumatraPDF, "\""].join("");
        }
     
        var mainTeXDir = fso.GetParentFolderName(pdfFile);
        var cd = "cd /d " + ["\"", mainTeXDir, "\""].join("");
        currentTeXFile = ["\"", currentTeXFile, "\""].join("");
        var ptex2pdf = "ptex2pdf -u -l -ot \"-no-guess-input-enc -kanji=utf8 -synctex=1\"" + " \"" + fso.GetBaseName(["\"", pdfFile.replace(suffix, ".tex"), "\""].join("")) + "\"";
        pdfFile = ["\"", pdfFile, "\""].join("");
        var args = sumatraPDF + " -reuse-instance " + pdfFile + " -inverse-search \"\\\"" + sakuraEditor + "\\\" -X=%c -Y=%l \\\"%f\\\"\"" + " -forward-search " + currentTeXFile + " " + line;
        var cmd = "cmd /c " + cd + " && " + ptex2pdf + " && echo " + args + " | cmd";
     
        Editor.StatusMsg(cmd, 0);
        Editor.FileSave();
        Editor.ExecCommand(cmd, 0x81);
    }.call(this));
    

upLaTeX (ptex2pdf) でタイプセット → TeXworks で表示

  • pdfupLaTeXT.js
      0
      1
      2
      3
      4
      5
      6
      7
      8
      9
     10
     11
     12
     13
     14
     15
     16
     17
    
    (function () {
        var fso = new ActiveXObject("Scripting.FileSystemObject");
        var currentTeXFile = Editor.ExpandParameter("$F");
        var suffix = /\.[^.]*$/;
        var pdfFile = currentTeXFile.replace(suffix, ".pdf");
        var line = Editor.ExpandParameter("$y");
        var texworks = "texworks";
     
        var mainTeXDir = fso.GetParentFolderName(pdfFile);
        var cd = "cd /d " + ["\"", mainTeXDir, "\""].join("");
        var ptex2pdf = "ptex2pdf -u -l -ot \"-no-guess-input-enc -kanji=utf8 -synctex=1\"" + " \"" + fso.GetBaseName(["\"", pdfFile.replace(suffix, ".tex"), "\""].join("")) + "\"";
        var args = "synctex view -i \"" + line + ":0:" + currentTeXFile + "\" -o \"" + pdfFile + "\" -x \"" + texworks + " --position=%{page+1} \"%{output}\"\"";
        var cmd = "cmd /c " + cd + " && " + ptex2pdf + " && echo " + args + " | cmd";
     
        Editor.StatusMsg(cmd, 0);
        Editor.FileSave();
        Editor.ExecCommand(cmd, 0x81);
    }.call(this));
    

upLaTeX (ptex2pdf) でタイプセット → Adobe Acrobat Reader DC で表示

  • pdfupLaTeXA.js
      0
      1
      2
      3
      4
      5
      6
      7
      8
      9
     10
     11
     12
     13
     14
     15
     16
     17
    
    (function () {
        var currentTeXFile = Editor.ExpandParameter("$F");
        var suffix = /\.[^.]*$/;
        var pdfFile = currentTeXFile.replace(suffix, ".pdf");
        var line = Editor.ExpandParameter("$y");
        var c = Editor.ExpandParameter("$e");
        var b = Editor.ExpandParameter("$g");
        var cd = "cd /d " + ["\"", c, "\""].join("");
        var ptex2pdf = "ptex2pdf -u -l -ot \"-no-guess-input-enc -kanji=utf8 -synctex=1\"" + " " + ["\"", b, "\""].join("");
        var pdf = ["\"", b, ".pdf", "\""].join("");
        var pdfopen = "synctex view -i \"" + line + ":0:" + currentTeXFile + "\" -o \"" + pdfFile + "\" -x \"pdfopen --r15 --file \"%{output}\" --page %{page+1}\"";
        var pdfclose = "tasklist /fi \"IMAGENAME eq AcroRd32.exe\" /nh | findstr \"AcroRd32.exe\" > nul && pdfopen --r15 --file " + pdf + " && pdfclose --r15 --file " + pdf;
        var cmd = "cmd /c " + cd + " && " + pdfclose + " & " + ptex2pdf + " && " + pdfopen;
     
        Editor.StatusMsg(cmd, 0);
        Editor.FileSave();
        Editor.ExecCommand(cmd, 0x81);
    }.call(this));
    

LuaLaTeX でタイプセット → SumatraPDF で表示

  • LuaLaTeXS.js
      0
      1
      2
      3
      4
      5
      6
      7
      8
      9
     10
     11
     12
     13
     14
     15
     16
     17
     18
     19
     20
     21
     22
     23
     24
     25
     26
     27
     28
     29
     30
     31
     32
     33
     34
     35
     36
     37
     38
    
    (function () {
        var fso = new ActiveXObject("Scripting.FileSystemObject");
        var wshShell = new ActiveXObject("WScript.Shell");
        var sakuraEditor = Editor.ExpandParameter("$S");
        var currentTeXFile = Editor.ExpandParameter("$F");
        var suffix = /\.[^.]*$/;
        var pdfFile = currentTeXFile.replace(suffix, ".pdf");
        var line = Editor.ExpandParameter("$y");
        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 = Editor.InputBox("Input the path to SumatraPDF.exe.", "SumatraPDF.exe", 255);
                if (!fso.FileExists(sumatraPDF)) {
                    sumatraPDF = "rundll32 shell32,ShellExec_RunDLL SumatraPDF";
                    existSumatraPDF = false;
                }
            }
        }
     
        if (existSumatraPDF) {
            sumatraPDF = ["\"", sumatraPDF, "\""].join("");
        }
     
        var mainTeXDir = fso.GetParentFolderName(pdfFile);
        var cd = "cd /d " + ["\"", mainTeXDir, "\""].join("");
        currentTeXFile = ["\"", currentTeXFile, "\""].join("");
        var lualatex = "lualatex -synctex=1" + " \"" + fso.GetBaseName(["\"", pdfFile.replace(suffix, ".tex"), "\""].join("")) + "\"";
        pdfFile = ["\"", pdfFile, "\""].join("");
        var args = sumatraPDF + " -reuse-instance " + pdfFile + " -inverse-search \"\\\"" + sakuraEditor + "\\\" -X=%c -Y=%l \\\"%f\\\"\"" + " -forward-search " + currentTeXFile + " " + line;
        var cmd = "cmd /c " + cd + " && " + lualatex + " && echo " + args + " | cmd";
     
        Editor.StatusMsg(cmd, 0);
        Editor.FileSave();
        Editor.ExecCommand(cmd, 0x81);
    }.call(this));
    

LuaLaTeX でタイプセット → TeXworks で表示

  • LuaLaTeXT.js
      0
      1
      2
      3
      4
      5
      6
      7
      8
      9
     10
     11
     12
     13
     14
     15
     16
     17
    
    (function () {
        var fso = new ActiveXObject("Scripting.FileSystemObject");
        var currentTeXFile = Editor.ExpandParameter("$F");
        var suffix = /\.[^.]*$/;
        var pdfFile = currentTeXFile.replace(suffix, ".pdf");
        var line = Editor.ExpandParameter("$y");
        var texworks = "texworks";
     
        var mainTeXDir = fso.GetParentFolderName(pdfFile);
        var cd = "cd /d " + ["\"", mainTeXDir, "\""].join("");
        var lualatex = "lualatex -synctex=1" + " \"" + fso.GetBaseName(["\"", pdfFile.replace(suffix, ".tex"), "\""].join("")) + "\"";
        var args = "synctex view -i \"" + line + ":0:" + currentTeXFile + "\" -o \"" + pdfFile + "\" -x \"" + texworks + " --position=%{page+1} \"%{output}\"\"";
        var cmd = "cmd /c " + cd + " && "+ lualatex + " && echo " + args + " | cmd";
     
        Editor.StatusMsg(cmd, 0);
        Editor.FileSave();
        Editor.ExecCommand(cmd, 0x81);
    }.call(this));
    

LuaLaTeX でタイプセット → Adobe Acrobat Reader DC で表示

  • LuaLaTeXA.js
      0
      1
      2
      3
      4
      5
      6
      7
      8
      9
     10
     11
     12
     13
     14
     15
     16
     17
    
    (function () {
        var currentTeXFile = Editor.ExpandParameter("$F");
        var suffix = /\.[^.]*$/;
        var pdfFile = currentTeXFile.replace(suffix, ".pdf");
        var line = Editor.ExpandParameter("$y");
        var c = Editor.ExpandParameter("$e");
        var b = Editor.ExpandParameter("$g");
        var cd = "cd /d " + ["\"", c, "\""].join("");
        var lualatex = "lualatex -synctex=1" + " " + ["\"", b, "\""].join("");
        var pdf = ["\"", b, ".pdf", "\""].join("");
        var pdfopen = "synctex view -i \"" + line + ":0:" + currentTeXFile + "\" -o \"" + pdfFile + "\" -x \"pdfopen --r15 --file \"%{output}\" --page %{page+1}\"";
        var pdfclose = "tasklist /fi \"IMAGENAME eq AcroRd32.exe\" /nh | findstr \"AcroRd32.exe\" > nul && pdfopen --r15 --file " + pdf + " && pdfclose --r15 --file " + pdf;
        var cmd = "cmd /c " + cd + " && " + pdfclose + " & " + lualatex + " && " + pdfopen;
     
        Editor.StatusMsg(cmd, 0);
        Editor.FileSave();
        Editor.ExecCommand(cmd, 0x81);
    }.call(this));
    


URL B I U SIZE Black Maroon Green Olive Navy Purple Teal Gray Silver Red Lime Yellow Blue Fuchsia Aqua White

リロード   新規 編集 凍結 差分 添付 複製 名前変更   ホーム 一覧 単語検索 最終更新 バックアップ リンク元   ヘルプ   最終更新のRSS
Last-modified: 2015-10-27 (火) 22:52:46 (1089d)