[Tex/LaTex] Uninformative error message when using AUCTeX

auctexemacserrors

I often have this error when using AUCTeX:

TeX-error: Error occured after last TeX file closed

However, when running for instance pdflatex on the command line, I have a proper error message. But the line number information is not always useful, especially if multiple files are included. I'd like to be able to see the error in Emacs.

Best Answer

AUCTeX 11.89

Starting from this version of AUCTeX, the option TeX-file-line-error enables by default the file:line:error messages that solve the problem. Thus, from this version you shouldn't run anymore into this kind of problems. I also suggest to revert any change to LaTeX-command-style, in order to be sure to use the default value.

See below for previous versions.


AUCTeX 11.88 or earlier

Instead of editing the texmf.cnf file you can just add -file-line-error option to your TeX processor. To do this add the following code to your .emacs:

(setq LaTeX-command-style '(("" "%(PDF)%(latex) -file-line-error %S%(PDFout)")))

See also the AUCTeX FAQ:

8. Why does TeX-next-error (C-c `) fail?

When writing the log file, TeX puts information related to a file, including error messages, between a pair of parentheses. AUCTeX determines the file where the error happened by parsing the log file and counting the parentheses. This can fail when there are other, unbalanced parentheses present.

As a workaround you can activate so-called file:line:error messages for the log file. (Those are are easier to parse, but may lack some details.) Either you do this in the configuration of your TeX system (consult its manual to see where this is) or you add a command line switch to the (la)tex call, e.g. by customizing LaTeX-command-style or TeX-command-list.

Note: already answered here.

Related Question