Latex logo

LaTeX is a great system for producing pretty docs.
But using it on Windows can be a little clunky.

Fortunately, MiKTeX brings it to Windows, but you still have to jump through some hoops. Most notably when using BibTex, you need to run pdflatex.exe three times (!) for it to fully resolve all references. Once it has, it thanks you by littering a bunch of temporary files all over the shop.

So I put together this script that can be run from a Sublime build system by hitting ctrl-b.
Along side the editor, try Sumatra PDF which has automatic reloading and updates super fast.

cd /d %~d1%~p1

pdflatex.exe "%~nx1"
bibtex.exe "%~d1%~p1%~n1.aux"
pdflatex.exe "%~nx1"
pdflatex.exe "%~nx1"

"C:\Program Files\SumatraPDF\SumatraPDF.exe" -reuse-instance "%~d1%~p1%~n1.pdf"

The Sublime build system I use to call the script is then simply:

    "cmd": ["<path to script>/build-latex.bat", "$file"]

On Windows, custom Sublime build system files live here, mine is called Latex.sublime-build:

%userprofile%\AppData\Roaming\Sublime Text 2\Packages\User

I personally also include the following afterwards to delete the temp files.
Obviously you do this bit at your own risk. Don't blame me if you lose your prized temp files.

del *.aux
del *.bbl
del *.blg
del *.log
del *.toc