[OS X TeX] Automatic labeling for references

Alain Schremmer schremmer.alain at gmail.com
Sun Apr 6 11:49:57 EDT 2008


On Apr 6, 2008, at 1:47 AM, Peter Pagin wrote:

> Alain Schremmer wrote:
>>
>>         \renewcommand\theTitleReference[2]{\bfseries{#1}\ \emph{#2}}
>> 	\newcommand{\MYsection}[1]{\section{#1}\label{\thesection}}
>>
> The drawback with it is that if you move a section (to before or  
> after another), it will get a new label. Then if you have cross  
> references to it in your text, they will after the change go to the  
> wrong section.

I agree that

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

is a lot better.

The only problem I have is that I am writing chapters included in a  
"book" rootfile and that each chapter also has a dedicated "chapter"  
root file for typesetting just the chapter and then of course  
\newcounter{labb} gives different references when typesetting the  
"chapter" rootfile or the "book" rootfile.

To avoid this, I would need only place in each "book" rootfile  
something like \addtocounter{labb}{total number of sections before  
the current chapter} just before the \include.

I actually do that, by hand, for "total number of chapters before the  
current chapter"—but that is easy to maintain—and "total number of  
pages before the current chapter"—but that is not critical—(so that  
neither really needs to be automated).

But I have no idea about how to get "total number of sections before  
the current chapter" other than by hand.

Grateful regards
--schremmer




More information about the MacOSX-TeX mailing list