Every now and then, I write an article/report/whatever in LaTeX. Last time I had to do it, I was in a rush. So, I recalled a really nice trick I found out a while ago. This trick allows me to have a .pdf file that is updated each time I save the corresponding .tex file(s).
The main idea is to combine two very interesting tools:
All of this was true until latexmk was born. Now, you change your shell to be in the directory and you run ‘latexmk’ or ‘latexmk -pdf’ and voilà!
So, now, you might be wondering: is there a way to combine this two tool so my LaTeX file get recompiled each time I save it ?
Simple answer: yes, it is. Look at that:
$ while true; do inotifywait -e modify *.tex *.bib; latexmk -pdf; done
For those that are new to shell programming, this is just an infinite loop, inotifywait waits for the various LaTeX related files in your directory to be modified. When it happens, the latexmk command is triggered. Once the build is finished, the inotifywait is relaunched.
Of course, the inotifywait trick is not limited to latexmk and LaTex documents !
Hope you enjoyed the tricks. Since I’m always eager to discover new productivity tips, feel free to drop a comment if you have anything to share.