8

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?

2 Answers2

17

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

(./PaPCh11.aux
! Undefined control sequence.
l.171 \cit

unambiguously points to line 171 of PaPCh11.aux

David Carlisle
  • 757,742
12

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.

Syvshc
  • 1,328
  • 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 '21 at 01: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 '21 at 08:37
  • @DavidCarlisle: I use Mac OS, and not UNIX, but that's a good idea. – David G. Stork Feb 12 '21 at 16:25
  • @DavidG.Stork Mac OS has the terminal app, which gives you a command line. – Teepeemm Feb 12 '21 at 23:37
  • @Teepeemm: Yes, thanks (though I try to avoid Terminal). – David G. Stork Feb 13 '21 at 00:44
  • Depending on your editor, regular expressions might be supported there as well. Grep is far from the only place where you can use them – Ingmar Feb 13 '21 at 04:01