[OS X TeX] Automatic labeling for references

Alain Schremmer schremmer.alain at gmail.com
Wed Apr 9 00:11:56 CEST 2008


On Apr 8, 2008, at 6:45 AM, Matthew Leingang wrote:
> If you look inside the aux file for your book, you'll notice it  
> includes the aux files for your chapters.

  Yes

>   Inside the a chapter's aux file, you might find statements like
>
> \@writefile{toc}{\contentsline {chapter}{\numberline {6}The Axioms  
> of Probability}{6-1}{chapter.6}}

Here is the "book" aux file:

	\relax \let\TR at TitleReference\@firstoftwo
	\bibstyle{plain}
	\@input{../ChaptersEDIT/002.aux}
	\@input{../ChaptersEDIT/361.aux}
	\@input{../ChaptersEDIT/362.aux}
	\@input{../ChaptersEDIT/363.aux}
	\@writefile{toc}{\contentsline {part}{I\hspace  {1em}Power Functions} 
{95}}
	\@input{../ChaptersEDIT/364.aux}
	\@input{../ChaptersEDIT/365.aux}
	\@input{../ChaptersEDIT/366.aux}

Here is, for instance, the aux file for Chapter 3 which is file 363:

	\relax
	\bibstyle{plain}
	\@input{../ChaptersEDIT/363.aux}

> This writes TOC information to the .toc file regardless of whether  
> the file is included or not.

Here is, for instance, the first few lines of the toc file
	\contentsline {chapter}{\numberline {1}Introduction}{1}
	\contentsline {section}{\numberline {1.1}Relations}{2}
…
	\contentsline {section}{\numberline {1.8}The Fundamental Problem.}{20}
	\contentsline {chapter}{\numberline {2}Graphic Analysis}{25}
	\contentsline {section}{\numberline {2.1}Local Graphs of a Function} 
{25}
…
	\contentsline {section}{\numberline {2.9}Extremum Inputs}{48}
	\contentsline {chapter}{\numberline {3}From I-O Rule To Global Graph} 
{53}
	\contentsline {section}{\numberline {3.1}Extrapolation}{53}

Now, in order to use

		\newcounter{labb}
		\newcommand{\Section}[1]{\section{#1}\label{\thelabb}\stepcounter 
{labb}}

in order to avoid \newcounter{labb} giving different references when  
typesetting the "chapter" rootfile or the "book" rootfile, I would  
need only place in each "chapter" rootfile something like  
\addtocounter{labb}{total number of sections before the current  
chapter} just before the \include.

For instance, I would have to have at the beginning of the chapter 3  
rootfile,

	\addtocounter{labb}{17}

Now when typesetting just the "chapter" rootfile, labb will start  
with 18 just as it would when typesetting the "book" file.

While I could do that by hand—I am already doing it for \chapter and  
for \page—what I would like is a counter totallabb such that I would  
just have

	\addtocounter{labb}{\thetotallab}


>   I was saying if you wanted to automatically increment your "total  
> number of labels" command you could alter that macro to do that.

I agree but how do I do that?

> An alternative would be to augment the commands in the TOC file  
> such as
>
> \contentsline {chapter}{\numberline {6}The Axioms of Probability} 
> {6-1}{chapter.6}

  What does "{6-1}{chapter.6}" do? (Since I don't know how to get it  
I couldn't try it.)

> So why aren't you using includeonly?

When I started, I did use includeonly but , the way I do it, I just  
have to click Typeset on the "chapter" rootfile or the "book"  
rootfile to get what I want.

Regards
--schremmer




More information about the macostex-archives mailing list