Do not force me to manually abort LaTeX compilation when an error occurs

As suggested here , latexmk is a convenient way to constantly compile your document every time you change the source. But often, when you work on a document, you will get errors, and then latex will panic and wait for user input before continuing. This can be very annoying, especially recently when I hacked something to compile latex directly from an etherpad document, which is saved continuously as you type.

Is there a parameter for latex or latexmk so that it just interrupts with an error message if it cannot compile? Or, if necessary, how do I configure some kind of Expect script to automatically dismiss LaTeX complaints?

(I thought pdflatex -halt-on-error option -halt-on-error do the trick, but apparently not.)

Bonus question: Skim on Mac OSX is a good PDF viewer that automatically recovers when a PDF changes (unlike Preview), except that whenever a latex error occurs, you confirm that you want to restore automatically. Texniscope does not have this problem, but I had to abandon Texniscope for other reasons . Is there a way to make Skim always autorefresh, or is there another viewer who gets this right?




ADDED: a latexmk mini tutorial based on the answer to this question:

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

  • Add the following to your ~/.latexmkrc file:

     $pdflatex = 'pdflatex -interaction=nonstopmode'; 

    (for OS X with Skim)

     $pdf_previewer = "open -a /Applications/Skim.app"; 
  • When editing the source file foo.tex run the following in the terminal:

     latexmk -pvc -pdf foo.tex 
  • Use Skim or another live viewer to view foo.pdf. For Skim, just browse the β€œSync” tab in the Skims settings and configure it for your editor.

Voila! Pressing save foo.tex now calls foo.pdf to update without touching a thing.

+60
automation prompt latex expect
Apr 10 '09 at 20:20
source share
4 answers

With MikTeX, pdflatex has this command line option:

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



Edit proposed by @ 9999 years:

These values ​​are equivalent to the set of LaTeX \commands , which provide the same functionality.

From Tips for Using TeX :

TeX operating modes behave as follows:

  • errorstopmode dwells on all errors, regardless of whether they are related to errors in the source code or non-existent files.

  • scrollmode does not stop at errors in the source, but requests input when a more serious error, for example, as a missing file.

  • In a slightly incorrect name, nonstopmode TeX does not ask for input after serious errors, but it stops completely.

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

+37
Apr 10 '09 at 20:28
source share

You can also put \nonstopmode or \batchmode at the very beginning of your tex file; then it will work with any version of TeX, not just pdflatex . For more information about these and related teams see the Very Good Link to TeX (Raw) Teams by David Bausum . The team from the debugging family is especially interesting.

+5
Oct 20 '11 at 13:14
source share

Another possible hack is simply:

 yes x | latexmk source.tex 

You can always create an alias for 'yes x | latexmk' if you intend to use this variant of the lots. The main advantage of this, which I can see above the other offers, is that it is very fast when you sometimes want latex to drive yourself like that.

Mehmet

+4
Jul 21 '10 at 11:30
source share

The \batchmode command may also be executed.

0
Jul 21 2018-10-21T00:
source share



All Articles