2

When I currently compile my LaTeX document, I do it like this:

sketch figures/torus.sketch > figures/torus.tex
pdflatex $(DOKUMENT).tex -output-format=pdf # aux-files for makeindex / makeglossaries
makeindex $(DOKUMENT)
pdflatex $(DOKUMENT).tex -output-format=pdf # include index
pdflatex $(DOKUMENT).tex -output-format=pdf # include symbol table
make clean # remove intermediate files like *.log and *.aux

This takes about 245 seconds (over 4 minutes).

But quite often, when I compile the document the first time after many changes, it has some errors, e.g.

  • forgetting about LaTeX issues with # and _
  • forgetting curly braces { or }
  • confusing input{figures/somefile.tex} with \includegraphics{figures/somefile.png}
  • forgetting to include packages

It would really be awesome if there was a fast LaTeX syntax checker. I would let the syntax checker run before the rest. If it fails, the rest will not be executed (as I do it with a Makefile, make will stop when the first error occurs). Does a LaTeX syntax checker exist? (False-negatives are ok, but there should not be any false-positives).

Martin Thoma
  • 18,799
  • If I'm not wrong you can test the result of each command. For example, if everything was fine with pdflatex the value of $? will be zero. – Sigur Feb 09 '14 at 11:48
  • @Sigur: I'm not sure, but I think you did not understand my question. This is not a question about make, but about pdflatex. I want it to fail (if it fails) as soon as possible. Currently, it happens often that it compiles 3 minutes and then fails because of a missing }. – Martin Thoma Feb 09 '14 at 11:52
  • 2
    Does pdflatex -draftmode do what you want? It cuts away the output phase, but does all the rest. – egreg Feb 09 '14 at 11:52
  • 1
    Does http://tex.stackexchange.com/q/53771/15925 answer your question? – Andrew Swann Feb 09 '14 at 11:59
  • 1
    Maybe pdflatex -halt-on-error or -interaction=errorstopmode. – Sigur Feb 09 '14 at 11:59
  • @AndrewSwann: No, most of the time I know where to search for the error. I just want to get an information that there is an error sooner. – Martin Thoma Feb 09 '14 at 12:02
  • @egreg: I think so. I've just added an error to my document and test how fast it fails. I'll add a comment in 10 minutes or so. – Martin Thoma Feb 09 '14 at 12:03
  • 1
    I was thinking mostly of the syntonly package mentioned in at least one solution there. – Andrew Swann Feb 09 '14 at 12:03
  • I use pdflatex -halt-on-error foo.tex 1> /dev/null [[ $? -eq 1 ]] && echo "Error with pdflatex. Check TeX files." && exit on my script. – Sigur Feb 09 '14 at 12:05
  • @egreg: Neither pdflatex -halt-on-error nor pdflatex -interaction=errorstopmode nor adding -draftmode made it fail faster. – Martin Thoma Feb 09 '14 at 12:18
  • 1
    Four minutes?! How long is your document? – jub0bs Feb 09 '14 at 12:23
  • @Jubobs: about 100 A4 pages; 8330 lines of Tex (I guess about 100 TikZ images). – Martin Thoma Feb 09 '14 at 12:34
  • 1
    @moose, many tikz code could make the process slower. – Sigur Feb 09 '14 at 13:30
  • @Sigur: Yes, it certainly does. But I don't see a good alternative. I could use PDFs, but that would probably change the size of the included image (especially the size of texts within the included TikZ images). – Martin Thoma Feb 09 '14 at 13:36
  • @moose Have you considered using standalone for the images? If they are slowing things down, putting them in external files and using standalone should speed compilation significantly because you wouldn't have to recompile the tikz code for all pictures each time. – cfr Feb 10 '14 at 01:34
  • 1
    You could externalize the TikZ graphics, that could save time. See chapter 32 Externalization library in the manual. – Torbjørn T. Feb 10 '14 at 09:43

0 Answers0