[OS X TeX] Automatic labeling for references

Alain Schremmer schremmer.alain at gmail.com
Sun Apr 6 05:09:04 CEST 2008


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

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





More information about the macostex-archives mailing list