Path: 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: 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 >>>>> 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