Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm in the middle of a "drop a file here and compile it using Latex" project. I have a dropbox and I would like to drop a .tex file in a specific folder and have a script that compiles It for me. I'm on MAC OS X (Snow Leopard). Can you point me on a .sh script or an Automator one (a Tutorial would be good too) that compile my documents into a PDF using pdflatex?

How could I handle the latex document dependencies like .sty, images, whatever?

share|improve this question
I was trying to do the same thing but it is not working, apple.stackexchange.com/questions/145180/… By any chance is your Automator script publicly available? –  Sergio Parreiras Sep 13 at 23:14

1 Answer 1

up vote 2 down vote accepted

You want to use latexmk, which is a perl script that automatically handles latex document dependencies and figures out how many times to call pdflatex, bibtex, etc to fully compile the document. You want something like:

latexmk -pdf paper

where paper.tex is the main .tex file for your document. This will compile paper.tex to paper.pdf, calling everything it needs to on the way. There are two ways to do the automated recompile you want:

  1. The UNIX-y way: open a terminal, call latexmk -pdf -pvc paper and leave the terminal window open. This doesn't quite do what you want but rather puts latexmk into continuous update mode. Whenever you save any of the files that paper.tex depends on, it will automatically recompile in the background.

  2. The more Mac-y way: create a folder action that calls latexmk -pdf on .tex files whenever they get saved to your dropbox folder. I don't have an Applescript that does it, but it should be straightforward to modify the add - new item alert.scpt that comes with Snow Leopard to do exactly this.

share|improve this answer
I'm trying something similar with XeLaTeX - which also does not require to do many passes but it is not working. I hope it is appropriated to ask if you have any insight on this similar problem apple.stackexchange.com/questions/145180/… –  Sergio Parreiras Sep 13 at 23:11

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.