🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.text.tex
Article #10137

Re: LaTeX question: \ref in \caption

#10137
From: Kresten Krab Thorup
Date: Tue, 04 Jun 1991 17:09
28 lines
1408 bytes
>>>>> On 3 Jun 91 15:03:30 GMT, marcus@ecrc.de (Marcus Clemente) said:

     I want to refer to a figure in the caption of another figure. LaTeX
     runs fine on the first run, but crashes the second run. Is there any
     LaTeX specialist being able to tell me how to do it?
     
     Following is a sample code as well as the output of TeX:
     
     :
     :

     \caption{another example of figure \ref{example}}


As the LaTeX manual points out, `\ref' is a so-called `fragile'
command, that must be `protected' when used in text that is written to
one of the auxillary files .aux, .toc, etc.  So. you should have
written:

     \caption{another example of figure \protect\ref{example}}


The problem is, that the macro `\ref' is expanded to early. The
`\protect' ensures, that it is not expanded until the actual
typesetting is taking place.  

/Kresten
Technical Details
Message-ID: <KRAB.91Jun4180911@eos.iesd.auc.dk>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!wuarchive!uunet!fernwood!uupsi!sunic!dkuug!iesd!iesd.auc.dk!krab

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!wuarchive!uunet!fernwood!uupsi!sunic!dkuug!iesd!iesd.auc.dk!krab
From: krab@iesd.auc.dk (Kresten Krab Thorup)
Newsgroups: comp.text.tex
Subject: Re: LaTeX question: \ref in \caption
Message-ID: <KRAB.91Jun4180911@eos.iesd.auc.dk>
Date: 4 Jun 91 17:09:11 GMT
Sender: news@iesd.auc.dk
Organization: Mathematics and Computer Science, University of Aalborg
Lines: 28
In-reply-to: marcus@ecrc.de's message of 3 Jun 91 15:03:30 GMT