TextMate2メモ(4) LaTeX Bundleの変更(別バージョン)

TextMateのLaTeX bundleで,LaTeXの実行を指示している箇所が texmate.py にあるので,そこを直接修正することで uplatex での組版ができるようにした。具体的には,pdflatexが選択されているときは,これをptex2pdfで置き換え,また,latexが選択されているときは,これをuplatexで置き換えた。また,latexのあとは,dviをpdfに変換するのだが,dvi2psとps2pdfの組合せの代わりに,dvipdfmxを使うように変更した。具体的は変更は以下の通り。

編集するファイルは,
~/Library/Application Support/TextMate/Managed/Bundles/latex.tmbundle/Support/bin/texmate.py
補助的な関数の定義のあと,914行目からメインのルーティンが始まる。command の種類によって,様々な処理を行うようになっているが,メインは command が latex の場合。そこで,途中の
elif command == 'latex':
以下のブロック(1044行目あたり以降)を次のように書き換えた。

    elif command == 'latex':
        engine_options = construct_engine_options(typesetting_directives,
                                                  tm_engine_options, synctex)
        if engine == 'latex':
            engine = 'uplatex'
            engine_options = "-shell-escape -synctex=1 -interaction=nonstopmode"
        elif engine == 'pdflatex':
            engine = 'ptex2pdf'
            engine_options = "-u -l -ot \"-interaction=nonstopmode -synctex=1 -file-line-error -shell-escape\" "

        command = "{} {}".format(engine, engine_options)
        status = run_latex(command, filename, cache_filename, verbose)
        tex_status, fatal_error, number_errors, number_warnings = status
        number_runs = 1

        if engine == 'latex':
        #    call("dvips {0}.dvi -o '{0}.ps'".format(file_without_suffix),
        #         shell=True)
        #    call("ps2pdf '{}.ps'".format(file_without_suffix), shell=True)
            call("dvipdfmx {0}.dvi", shell=True)
        if tm_autoview and number_errors < 1 and not suppress_viewer:
            viewer_status = run_viewer(
                viewer, filepath, pdffile_path,
                number_errors > 1 or number_warnings > 0 and
                tm_preferences['latexKeepLogWin'],
                'pdfsync' in packages or synctex, line_number)

コメントを残す

メールアドレスが公開されることはありません。