Skip to content
William Blum edited this page Oct 21, 2017 · 7 revisions

Welcome to the latexdaemon wiki!

LaTeXDaemon simplifies and accelerate your LaTeX processing workflow. It runs silently in the background and automatically recompiles your document whenever it is changed, so you can concentrate on editing your document and avoid back and forth trips between your editor and the LaTeX command prompt. Secondly it significantly accelerates the overall compilation time of your document by pre-compiling the preamble: the section of your LaTeX source that loads external packages with \usepackage{...}. The tool works by silently monitoring your documents using efficient OS-based file system notifications. All your document files are monitored including dependencies such as auxiliary .tex files or .gif/.pdf graphics. The tool uses very little OS resources and only triggers a LaTeX recompilation when necessary. In particular preamble compilation only occurs if the preamble part of the .tex document is altered.

Quick start

Command line usage

Launching the program with no parameter gives you access to a command prompt REPL. Type help to see the list of commands available. For command-line usage information just type:

latexdaemon.exe --help

Running pdflatex

To run as a daemon with the pdflatex engine start the program as follows:

latexdaemon.exe  --ini=pdflatex mydocument.tex

Latex+dvips compilation worfklow

If your your latex document produces Postscript outputs, for instance using the pstricks package, you can configure the daemon to automatically convert the .dvi output to .ps each time the .dvi file is recreated:

latexdaemon.exe --ini=latex --afterjob=dvips

This tells the daemon to launch 'dvips' whenever the latex processing has successfully created the .dvi file. You can then open the generated postscript with Ghostview (if you have it installed) by typing command vs at the prompt. (Note: Ghostview will refresh automatically whenever the .ps file gets updated, without having to manually click on the Ghostview window).

Using the Beamer package

Beamer is a very nice Latex package that provides a document class for generating slides. Since its source code is large it takes quite a while to compile a document which loads this package. This can easily gets annoying especially when you are working on your document and while editing you want to have a quick preview of the slides. LatexDaemon solves this problem: the preamble being precompiled by LatexDaemon, the compilation of your slides becomes very fast! There is, however, a small incompatibility between the beamer package and the precompilation mode of LatexDaemon (at least under the Miktex 2.5 distribution) that needs to be fixed in order to make things work: If you are producing your document with latex + dvips then you need to perform the following modification in the file pgfsys-dvips.def from the package pgf (used by beamer) located in C:\Program Files\MiKTeX 2.5\tex\generic\pgf\systemlayer.

Line number 18 of this file containing

\def\pgf@sys@postscript@object#1{\special{! #1}}

should be replaced by the following lines:

\ifx\textsuperscript\@undefined
    \def\pgf@sys@postscript@object#1{\special{! #1}}
\else
    \def\pgf@sys@postscript@object#1{\AtBeginDvi{\special{! #1}}}
\fi

If you are using pdflatex instead of latex then the pdflatex compilation will fail (due a problem with beamer/pgf). There is no known fix at the moment.

Preamble

In a LaTeX document, the "preamble" refers to the section of code preceding the \begin{document}. For a TeX document, it refers to the section of code declaring all the \def macros and commands used in the rest of the document. LateXDaemon supports two kinds of preambles: external and internal.

  1. In external mode, you need to define all your Latex preamble commands in a separate file named with the extension .pre. If such file is present, LaTeXDaemon will treat it as the preamble and precompile it for you. When you make further changes to your document, LaTeXDaemon then only needs to recompile the main content of the document (for LaTeX document this is all the content within \begin{document} and \end{document}) to produce the final output. If the preamble file changes, then a full recompilation will occur. Optionally, you can include this preamble in your main .tex document so that you can still compile it with the standard tex tool chain as well as with latexdaemon.

  2. In internal mode, the preamble is automatically extracted from the main .tex file and there is no need to create a separate preamble file. This is the recommended usage as it's totally transparent and does not require any modification of your document. This mode, however, only works with LaTex (not with TeX) since it requires the present of \begin{document} marker to automatically detect the preamble

Auxiliary files

By default, LaTeXDaemon stores auxiliary files in a TexAux folder, this can be overridden with the -aux-directory command-line argument.

Running post-processing commands

You can use the -afterjob switch to specific a command to run when the latex compilation succeeds. So far the supported commands are:

  • dvips run dvips on the output dvi file
  • dvipng run dvipng on the output dvi file
  • dvips2pdf run dvips followed by ps2pdf
  • custom run a custom command line specified with the '-custom' option
  • rest (default) do nothing."

For example, if you run latexdaemon with the following options:

latexdaemon -afterjob=custom -custom="\"C:\Path with spaces\custom.cmd\"" c:\test\myfile.tex

Then after each compilation of myfile.tex the script custom.cmd will be called by latexdaemon with the following command:

"C:\Path with spaces\custom.cmd" c:\test\myfile.tex

An example of custom script file is provided here.