[OS X TeX] Automatic labeling for references

Peter Pagin peter.pagin at philosophy.su.se
Sun Apr 6 07:47:55 CEST 2008


Hi Alain,

Alain Schremmer wrote:
>
> On Apr 5, 2008, at 2:55 AM, Jan Anderssen wrote:
>> Hi,
>>
>> On Apr 5, 2008, at 1:04 AM, George Gratzer wrote:
>>
>>> Could you not just simply define a command to do this?
>>
>> I considered the other way easier for two reasons:
>>
>> 1) Personal lack of knowledge: I'm not sure how to write such a 
>> command. Say I wanted the first three words of the title, 
>> capitalized, prefixed with sec:, subsec:, chap: ..., for instance 
>> \section{A novel approach to something old} would become \section{A 
>> novel approach to something old}\label{sec:ANovelApproach}. I would 
>> probably try something like this
>>
>> \newcommand{\mysection}[1]{\section{#1}\label{sec: 
>> **reformatted/shortened version of #1**}}
>>
>> but I just don't know enough about actual tex programming to do any 
>> string manipulation to get that result. Is there an easy way?
>
> On Apr 5, 2008, at 1:02 PM, Peter Pagin wrote:
>
>
>> 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}}
>
>
> I finally got what I wanted (I hope) which was to refer to sections.
>
> 1) I am using the counter \section for labeling so that I always know 
> what the labe is—if only from looking at the toc.
>
> 2) Then
>
>         \renewcommand\theTitleReference[2]{\bfseries{#1}\ \emph{#2}}   
>         \newcommand{\MYsection}[1]{\section{#1}\label{\thesection}}
>
> 3) If I type in the source \MYsection{This and That}
>
> the pdf reads 4.11 This and That
>
> and if I later write in the source
>
>     We already saw in section  \titleref{4.11} one way to do this.
>
> the pdf will read
>
>     We already saw in section 4.11 This and That one way to do this
I thought at first of a solution like this, but then discarded it in 
favor of what I suggested. 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. If you are prepared to accept to change this 
manually or never move sections, then this is a good solution for you.

Best,
Peter
>
> bold faced with "This and That" emphasized.
>
> (I used showkeys to check on the effect of what I was doing when I 
> didn't get an error.)
>
> Very grateful regards to all
> --schremmer
>
>
> ------------------------------------------------------------------------
>
>  
> -------------------------- Helpful Info --------------------------
> 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/
>
>   

-- 







More information about the macostex-archives mailing list