[OS X TeX] when does TOC get written

Aaron Jackson jackson at msrce.howard.edu
Sat Apr 2 00:08:17 EST 2005


On Apr 1, 2005, at 11:56 PM, Jeff Genung wrote:

> OK, head scratching question --- Say I have a document main.tex that 
> has
> inputs for three other documents that are each a chapter. There is 
> also a
> TOC called main.toc that is created by main.tex. I have to run main.tex
> through twice to get the TOC to shuffle out correctly. The question is 
> why?
> and how does tex know that it's the second time through, and needs to 
> write
> to main.toc.? Because I can open main.toc and change it and then tex
> main.tex and my changes to the TOC are there, but the second time 
> through
> they are over written. So how does it know that its the second time 
> through?

Not as much of a catch 22 as you might think.  The first time you run 
tex it makes a .toc file with a lot of \contentslines commands ***from 
the current run***.  The second time you run tex it uses the existing  
.toc file to generate the table of contents.   However, if the .toc 
file exists the "first time" you run tex, it uses this to generate a  
table of contents in your document, which may result in an incorrect 
toc.  That is why you should always run tex twice so the toc is 
correct.  (I think it is necessary to run tex three times to make sure 
that all references and end notes are also correct).

Aaron


--------------------- Info ---------------------
Mac-TeX Website: http://www.esm.psu.edu/mac-tex/
           & FAQ: http://latex.yauh.de/faq/
TeX FAQ: http://www.tex.ac.uk/faq
List Post: <mailto:MacOSX-TeX at email.esm.psu.edu>





More information about the MacOSX-TeX mailing list