[comp.text] Latex figure labels

ceblair@ux1.cso.uiuc.edu (Charles Blair) (08/03/90)

   I am having trouble with references to figures in LaTeX.  I have

  \begin{figure}\label{name}
   ...
   \end{figure}

and later in the document (it's report style, if that matters) I use
\ref{name}.  What I get is the number of the section with the figure,
instead of the number of the figure, even though the caption numbers come
out ok.  Thanks for any help!

Charles Blair  (please e-mail)

clarke@hpdtl.HP.COM (Marc Clarke) (09/01/90)

> / hpdtl:comp.text / ceblair@ux1.cso.uiuc.edu (Charles Blair) / 12:30 pm  Aug  2, 1990 /
> 
>    I am having trouble with references to figures in LaTeX.  I have
> 
>   \begin{figure}\label{name}
>    ...
>    \end{figure}
> 
> and later in the document (it's report style, if that matters) I use
> \ref{name}.  What I get is the number of the section with the figure,
> instead of the number of the figure, even though the caption numbers come
> out ok.  Thanks for any help!
> 
> Charles Blair  (please e-mail)

You have to use:

\begin{figure}
...
\caption{The caption for the figure.}
\label{name}
\end{figure}

and the \label *must come after* the \caption.