My problem is debugging a large LaTeX project (a book) with several input files. The line of each error is referred to the current input file, but the name of the file is lost in the previous compilation messages, and it is painstacking to find it. Is there any way to tell LaTeX to prefix error lines with the name of the file?

While writing, I found a similar question, unfortunately unanswered.

  • Can you specify what TeX distribution you're using? And also what front-end or editor.
    – egreg
    May 5, 2014 at 11:50
  • The distribution is "Tex Live", system is Linux, editor is emacs, I compile from command line. The answer of Davide Carlisle here below solved the problem for this distribution. Thank you.
    – Gherardo
    May 5, 2014 at 15:51

2 Answers 2


web2c tex has a command line argument:

$ tex err
This is TeX, Version 3.1415926 (TeX Live 2013)
! Undefined control sequence.
l.4 \zzz

? x
No pages of output.
Transcript written on err.log.

$ tex -file-line-error err
This is TeXk, Version 3.1415926 (TeX Live 2013)
./err.tex:4: Undefined control sequence.
l.4 \zzz

  • Which (at least in TeXLive) can be activated globally
    – daleif
    May 5, 2014 at 11:22
  • Thanks a lot. Of course the option -file-line-error can be given to latex as well... This solved completely the problem.
    – Gherardo
    May 5, 2014 at 15:48

Since you work with the terminal, you can globally enable the -file-line-error option by doing

sudo emacs $(kpsewhich texmf.cnf)

(of course use the editor you like best; if sudo is not the way to do system maintenance on your system, you surely know how to gain suitable privileges) and appending

file_line_error_style = t

to the file that opens. If the TeX distribution is the “vanilla” one, the file should be


while on a Debian provided one the opened file should be


where instructions about where to add a new texmf.cnf file with that line will appear. If you have already created a /etc/texmf.d/texmf.cnf file, then append the line to that one.

Alternatively, set the file_line_error_style variable in the environment; for instance, add

export file_line_error_style=t

to your .bashrc or .profile.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .