With one of the recent updates, LatexTools now supports Okular under Linux. This makes it eventually useful for my setup of writing tools.

The fact that LatexTools provides the pdf viewer with the pdf file as it is being generated, however, remains problematic for my workflow.

Okular updates the file contents as they change. Until the file is fully compiled, therefore, it cannot display anything. Effectively, you cannot compile your document in the background while reading it in the viewer at the same time.

Is there any simple solution that forces LatexTools to "release" only complete pdf files instead of changing the exact file that is used for preview?


I found a satisfying solution. The gist of the idea is to compile the tex-file with a temporary jobname like "temp" using latexMk. After completion, copy or rename the produced temp.pdf and temp.synctex.gz file to match the original document name.

LatexTools enables this by customizing the build settings in LaTeXTools.sublime-settings (Preferences -> Package Settings -> LaTeXTools -> Settings – User).

First, change the original setting

"builder": "traditional"


"builder": "script"

Then, under "builder_settings", find you operating system. The according entry should not contain anything. For Linux, change

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


"linux" : {
            "script_commands": [
                "latexmk -pdf -pdflatex=\"pdflatex -interaction=nonstopmode -shell-escape\" -f -jobname=temp $file_name",
                "cp temp.pdf $file_base_name.pdf",
                "cp temp.log $file_base_name.log",
                "cp temp.synctex.gz $file_base_name.synctex.gz"

Notice, that latexmk must be installed and accessible from bash for this to work. Depending on your document, the necessary parameters for latexmk might differ. For example, you might want to remove -shell-escape for security reasons.

The only drawback of this solution is that the cleanup function of LatexTools (Ctrl-l, backspace) does not remove the temp files.


The easiest way to deal with this is just to turn off Okular's automatic reloading, which can be done by going to Settings -> Configure Okular and unchecking Reload document on file change. With that setting unchecked, LaTeXTools will build your document and only update Okular once the compilation is complete.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.