Autocompiling LaTeX-files under Linux

To automatically compile files under Linux there are several options available: Gummi ( is an editor that compiles the LaTeX file whenever it is modified; latexmk ( is another option.

A third option uses Linux‘ inotify, part of the Linux kernel. It tracks changes to files or directories on the filesystem level. For more information see the wikipedia entry:

Here’s a short tutorial how to get it to work under Ubuntu/Debian:

  1. Install inotify-tools using sudo apt-get install inotify-tools
  2. Run the following line from the terminal to tell inotify to watch for any changes of the TeX-file (change the name if necessary). I use a simple pdflatex here, make or arara are of course fine as well.
while true; do inotifywait -e modify autocomp1.tex && pdflatex autocomp1.tex; done

Unfortunately it does not work with TeXworks‘ built-in document viewer, it does not recognize that the PDF has been modified externally.


Uwe Ziegenhagen mag LaTeX und Python, auch gern in Kombination. Hat Dir dieser Beitrag geholfen und möchtest Du Dich dafür bedanken? Dann unterstütze doch vielleicht die Dingfabrik Köln e.V. mit einem kleinen Beitrag. Details zur Bezahlung findest Du unter Spenden für die Dingfabrik.

More Posts - Website