SublimeText / LaTeXTools

LaTeX plugin for Sublime Text
https://latextools.readthedocs.io/
2.01k stars 364 forks source link

[xelatex][windows] Not compiling with traditional, does with basic builder #1428

Closed JacobEFO closed 5 years ago

JacobEFO commented 5 years ago

Hey LaTeXTools,

I've recently started on my master thesis, using a template which needs XeLaTeX to properly compile. However, when I try to use the "Traditioinal - LaTeX" or "LaTeX - XeLaTeX" builder, it does not properly compile my document. It however does shift its focus to the output PDF (unupdated). The log says "TraiditionalBuilder: Engine: xelatex. Invoking texify... done."

The output log can be seen here: https://pastebin.com/RNcnM9Hc

If I use the basic builder instead, it does update the PDF, but has to compile four times, which is much too cumbersome.

The top of my .tex document specifies the tex engine with: "%! TEX program = xelatex" or "%!TEX program = xelatex" or "%!TEX TS-program = xelatex"

of which neither seems to make any difference. If I delete all the files but my .tex file I try to compile, the traditional builder works as intended.

I have also tried to define "builder_settings": { "program": "xelatex" }

In the settings file, but that does not make any difference. I have also tried updating my MikTex distribution and all the corresponding packages.

If I am not using xelatex but pdflatex builder (on another document) both the simple/traditional builder and the basic builder work.

Best regards

r-stein commented 5 years ago

The main difference between the traditinal builder and the basic builder is that the traditional builder is using texify/latexmk and specifies the engine via an argument and the basic builder calls pdflatex/xelatex directly. You actually can see the used command in the sublime text console (View > Show Console). You may extract that command and execute in a terminal to check whether the PDF is updated. If this is not the case you may investigate further how to make texify to properly compile your document.

JacobEFO commented 5 years ago

Hey r-stein,

I think I figured out a part of the issue. When I try to use "Traditioinal - LaTeX" or "LaTeX - XeLaTeX" it runs the following command:

Running "'C:\Users\Jacob\AppData\Local\Programs\MiKTeX 2.9\miktex\bin\x64\texify.EXE' -b -p --engine=xetex '--tex-option="--synctex=1"' Thesis.tex"

But when I use the basic builder it runs:

Running "'C:\Users\Jacob\AppData\Local\Programs\MiKTeX 2.9\miktex\bin\x64\xelatex.EXE' -interaction=nonstopmode -synctex=1 Thesis.tex"

So I suppose, it does not automatically use the xelatex.EXE when I try to use "Traditioinal - LaTeX" or "LaTeX - XeLaTeX". Do you have any suggestions as how to solve this?

r-stein commented 5 years ago

That's exactly what I wanted to say in that sentence:

The main difference between the traditional builder and the basic builder is that the traditional builder is using texify/latexmk and specifies the engine via an argument and the basic builder calls pdflatex/xelatex directly.

It simply like that: If you want to call xelatex directly and not via texify, you will need to use the BasicBuilder.

In general I would either use the Traditional Builder or the Basic Builder. Based on this and previous issues it seems that the Basic Builder works in more situation. The "LaTeX - XeLaTeX" just uses the builder based on this setting.

JacobEFO commented 5 years ago

Hey r-stein,

Ah okay, that's just me entirely not understanding what you said then :)

The primary issue with using the "Latex - Basic Builder - XeLaTeX" is it running 4 sets of compilations, every damn time. I remain unable to actually change the builder settings to use XeLaTeX.

Asserting the "program" : "xelatex"

under the builder_settings, makes "Latex - XeLaTeX" run: Running "'C:\Users\Jacob\AppData\Local\Programs\MiKTeX 2.9\miktex\bin\x64\texify.EXE' -b -p --engine=xetex '--tex-option="--synctex=1"' Thesis.tex"

Which still invokes texify.EXE but tries to use xetex engine. I am not entirely sure, how on earth I'll make it invoke the correct xelatex.exe when using "Latex - XeLaTeX".

Do you possibly have any clues or a link to some guide?

r-stein commented 5 years ago

The traditional builder strips of the la to xelatex, because texifies --engine parameter does not support that.

You can see the corresponding source code here: https://github.com/SublimeText/LaTeXTools/blob/st3-3.15.1/builders/traditionalBuilder.py#L83-L84

You can see the source code of the builder here: https://github.com/SublimeText/LaTeXTools/blob/st3-3.15.1/builders/basicBuilder.py

The problem with the basic builder running 4 times is because it tries to make the document correct:

  1. Create the document here
  2. If necessary bibtex/biber and compile it to additional times here
  3. If necessary rerun it to get the cross references right here

You could tweak this to only run one time or just use the script builder to execute it one time.

JacobEFO commented 5 years ago

Hey r-stein,

Excellent. I made a script builder calling: "xelatex -synctex=1 -interaction=nonstopmode"

Which compiles it succesfully. It was a bit excessive having to run the basic builder every time I wanted to add a single word, and would not need to recompile my bib files etc.

But luckily it works now, which also allows me to use the LatexTools. I absolutely love it!

Edit: I did not clearly state, that I thank you for your assistance!

Edit2: Being so lightning quick made me forget to CLEARLY state how I resolved the issue. Under the LaTeXTools.sublime-settings there is "builder_settings". If you add "script_commands" with your designated LaTeX compiler command, you can use the "LaTeX - Script Builder" build option when building the LaTeX document. My builder settings are now:

    "builder_settings" : {

        // General settings:
        // See README or third-party documentation

        // (built-ins): true shows the log of each command in the output panel
        "display_log" : false,

        // Platform-specific settings:
        "osx" : {
            // See README or third-party documentation
        },

        "windows" : {
            // See README or third-party documentation
            "script_commands":
                "xelatex -synctex=1 -interaction=nonstopmode"
        },

        "linux" : {
            // See README or third-party documentation
        }
    },