TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

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

For final distribution, certain appendix includes the pdfpages package. However, appendices should be skipped for normal "draft" versions, or while working on individual chapters.

I am having problems figuring out which file is referring a particular pdfpages counter in these draft versions. Not including the pdfpages package in the preamble results in the following error: (once per chapter), even though there are no uncommented references to any \includepdf* commands` (in desperation, I have commented out the ones in the not-to-be-compiled appendixes)

! LaTeX Error: No counter 'AM@survey' defined.

How would you find out the source of this error? After grepping the files repeatedly, I can find no reference to the package.


The Makefile included with the style package did not recurse into subdirectories to remove outdated files when invoking target 'clean'. After fixing this, everything works as expected. Notifying maintainer, and flogging myself for not noticing earlier.

share|improve this question

closed as too localized by yo', diabonas, barbara beeton, Werner, Kurt Jan 9 '13 at 23:43

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

look in the log each time tex opens a file it shows ( and the file path, once it stops reading the file it outputs ) so by matching () you can see which file is being processed, that's the classic way, these days there is also -file-line-error command line argument which makes it show file name as well as line number in error messages – David Carlisle Jan 9 '13 at 21:16
Perhaps unrelated but... Remember to delete all aux files before compiling again when removing/adding packages. – JLDiaz Jan 9 '13 at 21:16
Thanks JLDiaz - always using "make clean pdflatex" just in case. @David Carlisle, see comment to tohecz's answer: I still can't find the culprit... – tucuxi Jan 9 '13 at 21:41
You mention you have separate files for each chapter. Also one .aux per chapter. This suggests that you use \include for the chapters in the main file. Try changing those for \input. – JLDiaz Jan 9 '13 at 21:56
This is complicated to carry out, as the \includes are being moderated by an \includeonly, which is the one that actually receives the list of files to compile... it is a rather involved styling package widely used around my institution. – tucuxi Jan 9 '13 at 22:06

Each file when read on input is enclosed in parentheses, starting with the file name. Parentheses should be used for no other purpose in the log file so it should be possible to track the behaviour. For example, this is a part of one log file:

Document Class: article 2005/09/16 v1.4f Standard LaTeX document class

It shows that the message Document Class ... is printed during the reading of the file article.cls, and that the file size10.clo is input from article.cls as well.

share|improve this answer
The error seems to be embedded into each chapter's .aux file, with no indication of which style or header included which lines within the .aux. There is a large block of \setcounter at the top of each these .aux files; and one of these counters (AM@survey) only works if the pdfpages package was included in the preamble, even though there is no mention of includepdf anywhere in the files being compiled (!!). – tucuxi Jan 9 '13 at 21:43
Remove all these aux files and do a fresh clean compilation. That should solve your issue. – yo' Jan 9 '13 at 22:07
checked the supplied Makefile; it turns out the .aux removal was not recursive. Sorry for wasting your time, and thanks for pointing me to the problem. – tucuxi Jan 9 '13 at 22:10

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