[OS X TeX] Re: "! LaTeX Error: No counter 'a' defined."

John B. Thoo jthoo at yccd.edu
Thu Dec 23 01:57:42 CET 2010


Thanks, Peter D and Martin C, for your replies.

On Dec 22, 2010, at 12:00 PM, <macosx-tex-request at email.esm.psu.edu> <macosx-tex-request at email.esm.psu.edu> wrote:

> ------------------------------
> 
> Message: 2
> Date: Wed, 22 Dec 2010 11:05:16 +0100
> From: Peter Dyballa <Peter_Dyballa at Web.DE>
> 
> I think lshort describes the use of the \include* statements. Cross
> references can be "kept intact" with latexmk, I think...

Thanks for the reference lshort [1].  The document [1, p. 14] seems to indicate that I'm using \include and \includeonly correctly.  Please let me know if I'm misreading it.

[1] <http://www.ctan.org/tex-archive/info/lshort/english/lshort.pdf>


> ------------------------------
> 
> Message: 3
> Date: Wed, 22 Dec 2010 14:39:42 +0100
> From: Martin Costabel <costabel at wanadoo.fr>
> 
> I think you exposed a fundamental bug in LaTeX. It is so basic that I
> suspect it will be called a "feature", and it is probably well known:
> 
> You cannot use \newcounter in files that are included using \include.
> 
> The workaround is to remove the \newcounter command from the included
> file and place it into the master file. In your case, remove (or
> comment) the lines
> 
>     \newcounter{a}
>     \newcounter{b}
>     \newcounter{temp}
> 
> in the file ch_numthry.tex and place them in the master file just before
> the line
> 
>   \include{ch_numthry}
> 
> This will typeset identically to what you (wanted to) get, without the
> error.
> 
> The reason for the breakage is that latex writes all \setcounter
> commands into the *.aux files. This is reasonable, in principle. But
> when you use \includeonly, only the *.aux files of the not included
> files are read, so the \setcounter commands are read, without the
> corresponding \newcounter commands, which are not in the *.aux file: Crash!

Your fix works marvelously.  Thanks very much.


> Here is a really minimal example:
> 
> %%%% file counterbug.tex, this is the master file
> %%%% typeset, then uncomment the \includeonly line to see the bug
> \documentclass{book}
> %\includeonly{null}
> \begin{document}
> \include{counter}
> \include{null}
> \end{document}
> %%%% end counterbug.tex
> 
> %%%% file counter.tex
> \newcounter{a}
> \setcounter{a}{0}
> %%%% end counter.tex

Wow, that is a very minimal example! :-)

Thanks again, everyone.

---John.

-----------------------------------------------------------------------
Pascal's wager
<http://www.catholic.com/thisrock/2003/0303fea1.asp>

-------------- next part --------------
----------- Please Consult the Following Before Posting -----------
TeX FAQ: http://www.tex.ac.uk/faq
List Reminders and Etiquette: http://email.esm.psu.edu/mac-tex/
List Archive: http://tug.org/pipermail/macostex-archives/
TeX on Mac OS X Website: http://mactex-wiki.tug.org/
List Info: http://email.esm.psu.edu/mailman/listinfo/macosx-tex



More information about the macostex-archives mailing list