You’ll notice the $(PREVIEW_CONTINUOUSLY) where the -pvc option should be. The all task creates the target file “article.pdf” using latexmk. PHONY : clean # -bibtex also removes the. PHONY rule keeps make from processing a file named "watch" or "clean".PHONY : watch # Set the PREVIEW_CONTINUOUSLY variable to -pvc to switch latexmk into the preview continuously mode watch : PREVIEW_CONTINUOUSLY=- pvc watch : article. Latexmk -quiet -bibtex $(PREVIEW_CONTINUOUSLY ) -f -pdf -pdflatex = "pdflatex -synctex=1 -interaction=nonstopmode" -use-make article.tex # -quiet suppresses most status messages (). # -pvc (preview continuously) watches the directory for changes.
# -synctex=1 is required to jump between the source PDF and the text editor. # -interaction=nonstopmode keeps the pdflatex backend from stopping at a # missing file reference and interactively asking you for an alternative. # -use-make tells latexmk to call make for generating missing files. # -pdflatex="" tells latexmk to call a specific backend with specific options. pdf # MAIN LATEXMK RULE # -pdf tells latexmk to generate a PDF instead of DVI. It # should always be the "all" rule, so that "make" and "make all" are identical.
# makefile # File adapted from this stackoverflow question: # The first rule in a Makefile is the one executed by default ("make"). make clean removes all files produced using the LaTeX compilation process, including the resulting PDF.make watch compiles the document and watches for changes using the latexmk -pvc command, and.make compiles the document, but does not watch for changes,.The makefile I propose is an adapted version from this stackoverflow post. The commands applied here, however, are basic and should be self explanatory. If you want to have a quick introduction to make, I strongly recommend Mike Bostocks beautiful blog post on it. I know that makefiles often look scary due to their seemingly obscure syntax, but actually they are easy to set up and will spare you a lot of work. Utilizing this knowledge with makefiles is easy. Jump between the IDE (Sublime Text 3 with LatexTools) and the PDF Viewer (Skim) using the Synctex feature Use the Power of make with latexmk Using it with Sublime Text and the LaTeXTools Plugin along with a Skim even allows to jump between source and compiled PDF using the enabled synctex feature. And as a big plus, it is independent of your editor choice. This is exactly the behavior I was looking for. Latexmk -quiet -bibtex -pvc -f -pdf -pdflatex = "pdflatex -synctex=1 -interaction=nonstopmode" article.tex
Compile LaTeX Projects using LatexmkĬonsider the following LaTeX document article.tex: Even better, latexmk is shipped per default with the most popular LaTeX distributions, so you should have it installed already. Turns out, it doesn’t matter which editor you use, you can simply incorporate latexmk to achieve this functionality. Since I do all my coding in Sublime Text, I looked for a similar workflow for that editor. Unfortunately, using Textmate began to feel likewise. Once I got used to this convenience, compiling LaTeX documents by hand felt like a chore. If you use a PDF viewer that supports SyncTeX, such as Skim, you can even jump to the current position of the cursor from the TeX document to the PDF and vice versa. Simply put the watch on the project master file and it will also look for changes in the associated files.
This also works with LaTeX projects consisting of multiple files. The watch document command of Textmate previews changes when saving the document It recompiles the document as soon as it is saved. It’s core is the neat Watch Document feature of Textmate, which compiles the document and looks for changes.
This Blog post by Jannis Hermanns basically defined my workflow since then. I’ve been using Textmate to write and compile my LaTeX Documents since 2007. It works for Unix-based systems, such as OSX or Linux.
This post describes how to achieve this behavior with any editor. The Watch Document functionality of Textmate automatically compiles Tex documents when saved.