dreeves dreeves - 7 days ago 4x
LaTeX Question

Don't make me manually abort a LaTeX compile when there's an error

As suggested here,

is a handy way to continually compile your document whenever the source changes. But often when you're working on a document you'll end up with errors and then
will panic and wait for user input before continuing. That can get very annoying, especially recently when I hacked up something to compile
directly from an etherpad document, which saves continuously as you type.

Is there a setting for
to make it just abort with an error message if it can't compile? Or, if necessary, how would I set up some kind of Expect script to auto-dismiss LaTeX's complaints?

(I had thought
's option
would do the trick but apparently not.)

Bonus question: Skim on Mac OSX is a nice pdf viewer that autorefreshes when the pdf changes (unlike Preview), except that whenever there's a latex error it makes you reconfirm that you want autorefreshing. Texniscope doesn't have this problem, but I had to ditch Texniscope for other reasons. Is there a way to make Skim always autorefresh, or is there another viewer that gets this right?

ADDED: Mini-tutorial on
based on the answer to this question:

  1. Get
    here: http://www.phys.psu.edu/~collins/software/latexmk-jcc/

  2. Add the following to your

    $pdflatex = 'pdflatex -interaction=nonstopmode';

    (For OS X with Skim)

    $pdf_previewer = "open -a /Applications/Skim.app";

  3. While editing your source file,
    , run the following in a terminal:

    latexmk -pvc -pdf foo.tex

  4. Use Skim or another realtime pdf viewer to view foo.pdf. For Skim, just look at the “Sync” tab in Skim’s preferences and set it up for your editor.

Voila! Hitting save on
will now cause
to refresh without touching a thing.


With MikTeX, pdflatex has this command-line option:

  -interaction=MODE               Set the interaction mode; MODE must be one
                                  of: batchmode, nonstopmode, scrollmode,

Edit suggested by @9999years:

Those values are equivalent to a set of LaTeX \commands that provide the same functionality.

From TeX usage tips:

The modes make TeX behave in the following way:

  • errorstopmode stops on all errors, whether they are about errors in the source code or non-existent files.

  • scrollmode doesn't stop on errors in the source but requests input when a more serious error like like a missing file occurs.

  • In the somewhat misnamed nonstopmode, TeX does not request input after serious errors but stops altogether.

  • batchmode prevents all output in addition to that (intended for use in automated scripts). In all cases, all errors are written to the log file (yourtexfile.log).