The -file-line-error command line flag for tex, latex, etc., is very effective. When you have a large project with plenty of files, the error message indicates very clearly not only the line number, but also the name of the file in which it occurred.

Unfortunately, this flag does nothing for warnings. What's the most effective way to find the name of the file in which under- or over- full warnings occur? Ideally, this could be done without resorting to an IDE.

The answers provided to the following questions are neat and related:


The problem becomes difficult when you have several levels of nesting and large log files (mine range between 5,000 and 30,000 lines, with lots of mostly useless information.)

A file open in indicated in the log by (filename, while a file close is indicated by ). Now, suppose you have a main file which inputs section files, each of which inputs several subsection files, each of which inputs tables and figures.

Suppose that you see an overfull message in line 17,432 in your log file, which says that the error occurred at input line 182. You have two options:

  • search for line 182 in all files that make your project
  • do a backward search in your log file, carefully balancing open and close parenthesis until you find which of the input files was active at line 17,432 of the log file.

Here is an actual excerpt from my .log file. Note that there are many open and close parenthesis in it which are not related to file inclusion. Also observe that input line numbers are missing from the last message in this excerpt.

21983 LaTeX Font Info:    Font shape `T1/ptm/bx/n' in size  not available
21984 (Font)              Font shape `T1/ptm/b/n' tried instead on input line 21.
21986 Overfull \hbox (9.91599pt too wide) in paragraph at lines 14--22
21987 \T1/ptm/m/n/10 (\T1/ptm/b/n/10 N\T1/ptm/m/n/10 umber of \T1/ptm/b/n/10 I\T1/ptm
21988 /m/n/10 nstance \T1/ptm/b/n/10 V\T1/ptm/m/n/10 ariables), \T1/ptm/b/n/10 MTE  \
21989 T1/ptm/m/n/10 (\T1/ptm/b/n/10 M\T1/ptm/m/n/10 u\T1/ptm/b/n/10 t\T1/ptm/m/n/10 a
21990 bility (\T1/ptm/b/n/10 E\T1/ptm/m/n/10 xplicit)),
21991  []
21994 Underfull \vbox (badness 10000) has occurred while \output is active []
  • (never too late to the party) I happen to be the author of script that precisely does all the "backward search in your log file, carefully balancing open and close parenthesis" and then pretty-prints the errors and warnings on the console. give it a look: github.com/guillaumesalagnac/latex-compile
    – Gyom
    Nov 15, 2019 at 14:04

2 Answers 2


What's the most effective way to find the name of the file in which under- or over- full warnings occur?

Search the .log file for the string erfull (either in text editor or command-line tool). This will give you all the overfull and underfull box warnings. The warnings will tell you which lines in the source file the error came from, and the log file will also indicate which PDF page the error occurred on.

As you read through the log file you can see each inputted subfile as it is opened. The warnings that occur after each filename pertain to the line numbers in that file.

I have concocted a example to demonstrate this, which I hope will not be too confusing. The file below is structured like so:

  • Main file includes section.tex

    • section.tex inputs table1.tex
    • section.tex inputs subsection.tex

      • subsection.tex inputs table2.tex

Both of the table files create egregious box overflows.

The first erfull warning in the main .log file is this:

  (./section.tex (./table1.tex)
Overfull \hbox (3524.03448pt too wide in paragraph at lines 12-11

Looking at the generated subfiles section.tex and table1.tex, we can see that the overfull tabular environment in table1.tex starts on line 12 of table1.tex. This is the source of the 12 at the beginning of the page range in the warning.

table1 is input into section.tex, on line 11 of section.tex. This is the source of the 11 in the warning page range.

So the log message may be translated as follows:

I opened the file section.tex. Then I input the file table1.tex. When I input the file, I found an overfull \hbox somewhere between line 12 of table1.tex and line 11 of section.tex.

So to answer your question, how to find the name of the file in which the under- or overfull box occurs, it is in the file most recently referenced in the log file before the warning.

Here is the example:



a & b & c & \lipsum[1]\\















  • Indeed, I can retrieve the line number, but not the name of the file in which the warning occurred.
    – Yossi Gil
    Mar 25, 2015 at 17:50
  • Not true. If the error is in a file that is \input to the main document, the warning will occur just after the log file shows that file being input. Mar 25, 2015 at 17:52
  • OK, will edit the question to make this clearer.
    – Yossi Gil
    Mar 25, 2015 at 17:57
  • I suppose I am basically saying that your option #2 is the answer. Mar 25, 2015 at 19:51
  • My log files do not contain any occureces of erfull. Using pdflatex from TeXLive 2019.
    – MaxPowers
    Jan 16, 2020 at 12:20

@AndrewCashner's answer lead me to an answer that works for me.

  1. Open the file with vi, vim, or gvim
  2. Locate the warning (this should be easy)
  3. Type `A)' to add an open parenthesis at the end of the current line in the log file.
  4. The editor's showmatch function will take you to the line in the log file which presents the file most recently referenced in the log file before the warning.

Here is an AWK script that could help a bit.

#!/usr/bin/gawk -f
  for (i = 1; i <= NF; i++) 
  print top()": " $0
function word(s) {
  if (s ~ /^[(][^()]+$/) 
function letters(s, i) {
  for (i = 1; i <= length(s); i++)
function letter(s) {
  if (s == "(")
  else if (s == ")")
function push(s) { stack[++sp] = s; }
function pop() { return stack[sp--];} 
function top(j) {
  for (j = sp; j >0; j--)
    if (stack[j] != "" )
      return stack[j] ;
  print "Sorry; I got confused - not sure what can be done"
  exit 1

The script reads a .log file, and prints it to the standard output prefixing each log line with the name of the input file that generated it. Pipe the output through grep as described here and you could get a reasonable approximation of -file-line-error.

The script tries to balance parentheses in the input so as to figure out the current active file name. However, if for some reason, TeX prints blurbs out text with unbalanced parentheses, e.g.,

 Underfull \hbox (badness 2065) in paragraph at lines 69--70
 [][]\EU2/lmr/m/n/10 With \EU2/lmr/bx/n/10 pro-to-types \EU2/lmr/m/n/10 (object-
 based, but not object-

the script is guaranteed to be confused.


You must log in to answer this question.

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