TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
Can you specify what TeX distribution you're using? And also what front-end or editor. – egreg May 5 '14 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 '14 at 15:51
up vote 6 down vote accepted

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

share|improve this answer
Which (at least in TeXLive) can be activated globally – daleif May 5 '14 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 '14 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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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