Macro/投稿/76 のバックアップ差分(No.4)




  • 追加された行はこの色です。
  • 削除された行はこの色です。
* upLaTeX (ptex2pdf) でタイプセット → PDF を表示 [#xd5f62f8]
-ページ: [[Macro/投稿]]
-作者: sai
-カテゴリー: js
-投稿日: 2014-01-22 (水) 15:00:00
-投稿日: 2014-01-27 (月) 00:00:00

** メッセージ [#i8617bec]
*** upLaTeX (ptex2pdf) でタイプセット → SumatraPDF で表示 [#h2a7a17c]
-pdfupLaTeXS.js
#code(javascript){{
(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=1 -Y=%l \\\"%f\\\"\"" + " -forward-search " + currentTeXFile + " " + line;
    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 で表示 [#jb0f261f]
-pdfupLaTeXT.js
#code(javascript){{
(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 texworks = "powershell -Command \"& {$$line = \"\"\"" + line + "\"\"\"; $$src = \"\"\"" + currentTeXFile + "\"\"\"; $$pdf = \"\"\"" + pdfFile + "\"\"\"; $$param = $$line + \"\"\":0:\"\"\" + $$src; $$pageInfo = (synctex view -i $$param -o $$pdf | Select-String \"^Page:\"); $$page = ($$pageInfo -split \"\"\":\"\"\")[1]; texworks --position=$$page $$pdf}\"";
    var cmd = "cmd /c " + cd + " && " + ptex2pdf + " && " + texworks;
    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 Reader で表示 [#o5a184dd]
-pdfupLaTeXA.js
#code(javascript){{
(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 = "powershell -Command \"& {$$line = \"\"\"" + line + "\"\"\"; $$src = \"\"\"" + currentTeXFile + "\"\"\"; $$pdf = \"\"\"" + pdfFile + "\"\"\"; $$param = $$line + \"\"\":0:\"\"\" + $$src; $$pageInfo = (synctex view -i $$param -o $$pdf | Select-String \"^Page:\"); $$page = ($$pageInfo -split \"\"\":\"\"\")[1]; pdfopen --rxi --file $$pdf --page $$page}\"";
    var pdfopen = "synctex view -i \"" + line + ":0:" + currentTeXFile + "\" -o \"" + pdfFile + "\" -x \"pdfopen --rxi --file \"%{output}\" --page %{page+1}\"";
    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;

    Editor.StatusMsg(cmd, 0);
    Editor.FileSave();
    Editor.ExecCommand(cmd, 0x81);
}.call(this));
}}
----

#comment



    ホーム 一覧 単語検索 最終更新 バックアップ リンク元   ヘルプ   最終更新のRSS