I'm writing a large book (with 11 chapters included separately in the base document, PaP.tex), and when I typeset I get the following output in the Console (and .log file):

(./PaP.aux (./PaPCh1.aux) (./PaPCh2.aux) (./PaPCh3.aux) (./PaPCh4.aux)
(./PaPCh5.aux) (./PaPCh6.aux) (./PaPCh7.aux) (./PaPCh8.aux) (./PaPCh9.aux)
(./PaPCh10.aux) (./PaPCh11.aux
! Undefined control sequence.
l.171 \cit

Clearly, I mis-entered \cite, dropping the "e" somewhere in the large book.

If I click Go to error I go to line 171 on the base document (PaP.tex) which does not contain the error. I guessed that because the error was listed after PaPCh11.aux (Chapter 11) it would be in that chapter, but again, no luck... certainly not on line 171 of Chapter 11.

I'm reduced to going through every chapter and searching for every "\cit" (or "\cit ") to see if it appears in each chapter. This is a horrendously tedious process, given I have over 800 citation references.

What is the fastest, most-efficient way to find the errant \cit in my large, composite set of files?

  • 1
    The error is in the aux file PaPCh11.aux, so a malformed .aux. Delete it and try again – Phelype Oleinik Feb 12 at 0:33

As Phelype says the error is on line 171 (almost certainly the last line) of PaPCh11.aux as that file is re-created every time you run latex, you can delete it and just run latex again.

By far the most common way to corrupt an aux file leaving a partly written command is to kill the latex job either by a key shortcut such as control-c or by killing the terminal window (x icon at top right in Windows) If you get a tex error, allow tex to finish cleanly and complete any file writing by typing x to the ? error prompt. If you kill the process any files currently open for writing may get corrupted with unfinished lines (due to system dependent cached file writing out of the control of TeX).

Note that TeX logs a ( and the file name when it inputs a file and ) when the end of file is reached so

! Undefined control sequence.
l.171 \cit

unambiguously points to line 171 of PaPCh11.aux


I have another thought. Did you mean that if you search for \cit, the editor will show you \cite together which you don't want. However when you write \cite, it often follows a par of curl bracket {...}. Then you can just search for \cit{ in your source file to find this error.

  • 2
    Good point. I actually tried that in the .tex files, but not where I should have: in the .aux file. Nevertheless: +1. – David G. Stork Feb 12 at 1:22
  • 2
    although you would not find this error, as (as shown in the error message) there is no { here. you could do grep '\\cit[^e]' * to find all occurrences of \cit not followed by e in all files in the current directory (grep is standard on linux and available for windows, or similar search tools exist) – David Carlisle Feb 12 at 8:37
  • @DavidCarlisle: I use Mac OS, and not UNIX, but that's a good idea. – David G. Stork Feb 12 at 16:25
  • @DavidG.Stork Mac OS has the terminal app, which gives you a command line. – Teepeemm Feb 12 at 23:37
  • @Teepeemm: Yes, thanks (though I try to avoid Terminal). – David G. Stork Feb 13 at 0:44

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.