# [OS X TeX] Automatic labeling for references

Peter Pagin peter.pagin at philosophy.su.se
Sat Apr 5 13:02:40 EDT 2008


Alain Schremmer wrote:
>
> On Apr 5, 2008, at 3:27 AM, Peter Pagin wrote:
>>
>>
>> Alain Schremmer wrote:
>>> 1) The package{titleref} lets me say, for instance, "We already saw
>>> in 4.5 Local Graphs that …" but only once I have put a label after
>>> \section{Local Graphs}.
>>>
>>> Is there a way to generate these labels automatically?
>>>
>>> For instance, is there a way to have a \newcommand{\CHAPTER} and a
>>> \newcommand{\SECTION} in such a way that, for instance, \SECTION
>>> writes, for instance, \section{ }\label{392} where 392 was
>>> automatically filled in given that there already were 391 labels?
>>>
>>> 2) Same question for labeling \theorem
>>>
>>> Hopeful regards.
>>> --schremmer
>> I wonder whether you would find the showlabels package of any help. I
>> find it useful when working a lot with cross references. Of course,
>> it doesn't generate labels, but would make it easier to keep track of
>> them.
>
> In Companion 2ed, showkeys is mentioned but I didn't see how that
> would help my own peculiar problem. Still, at one point I thought it
> might. I will look up showlabels too.
>
> Regards
> --schremmer
I thought a little more about it.

Why not define a new counter, \newcounter{labb},
and a new command, like \newcommand[1]{\lab}{\label{#1}\stepcounter{labb}}

Then in the document run \lab{newlabel}\thelabb. Typeset and check the
output result of \thelabb. Replace "newlabel" with that result, and
delete "\thelabb". One has to make sure to get the value from the end of
the document, even the label is put into the middle. So it is sort of
quarter-automatic. But if 391 \lab commands have been given, the next
gets the label content "392".
Maybe of no interest.

Peter

> ------------------------------------------------------------------------
>
>
> TeX FAQ: http://www.tex.ac.uk/faq
> List Reminders and Etiquette: http://www.esm.psu.edu/mac-tex/list/
> List Info: http://email.esm.psu.edu/mailman/listinfo/macosx-tex
> List Archive: http://tug.org/pipermail/macostex-archives/
> Mac-TeX Website: http://www.esm.psu.edu/mac-tex/
>
>

--

-----------------------------------------------------
Professor
Department of Philosophy, Stockholm University
106 91 Stockholm, Sweden
tel: +46-8-162813, fax: +46-8-152226
email: peter.pagin at philosophy.su.se
http://people.su.se/~ppagin/pagineng.htm