I am a programmer who is used to using command line tools to compile source code. One of the must-have features of these compilers is the ability to tell programmers where their errors are so they can find and fix them. Latex technically does this, but the output and log files can be hundreds of lines long, which makes it tedious and time consuming to find the one line that tells you where your error is. Is there any way to make latexmk output only compiler-style error messages to the console?

The command I use to build my tex project:

latexmk -pdf -pdflatex="pdflatex -interaction=nonstopmode" -use-make file.tex
  • 1
    Welcome! You could but it would not necessarily be very useful. I switch to running pdflatex in interactive mode when bug-hunting. That way, I get the first error and can sort that out before worrying about any second error. One error typically leads to lots more if you force it to continue. Nothing after the first one tells you much useful in most cases. – cfr Feb 1 '16 at 1:27
  • Do you not use grep? I mean, you don't really go through it yourself to find them in hundreds of lines, surely? There is also texloganalyser, of course. – cfr Feb 1 '16 at 1:28
  • Correction: maybe you can, but.... [I thought you could, but.... But now I'm not sure.] – cfr Feb 1 '16 at 1:37
  • Did you already check the LaTeX command-line option -file-line-error? It enables error messages of the form file:line:message. They are printed additionally to the default messages. – Martin Feb 1 '16 at 15:48

I don't think there is a built-in solution. But if I understand your question correctly, you could use something like this:

latexmk -pdf -pdflatex="pdflatex -file-line-error -interaction=nonstopmode" file.tex | grep "^.*:[0-9]*: .*$"

Or the even less verbose variant that just prints the message lines:

latexmk -pdf -pdflatex="pdflatex -file-line-error -interaction=nonstopmode" file.tex 2>&1 | grep "^.*:[0-9]*: .*$"
| improve this answer | |

This is not really a latexmk issue; it's about the behavior of pdflatex. No combination of options (as far as I can tell) both turns off the usual voluminous output and turns on file-line errors only. (I have a vague memory that pdflatex used to behave differently many years ago.)

The best that you can do is use some other program that analyzes the log file. One that I have found useful is pplatex/ppdflatex. This program runs pdflatex (or latex, as desired) silently, and then reports an analysis of the log file. You can configure latexmk to use it instead of pdflatex. You will, however, need to compile pplatex/ppdflatex yourself.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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