GeneralProblem with citing figures, citations are displayed incorre

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
Phanixis
Posts: 7
Joined: Mon Sep 15, 2008 6:53 pm

Problem with citing figures, citations are displayed incorre

Post by Phanixis »

I am writing a paper using the optics letters template below:

http://www.photonics.umd.edu/umd/index.html

In it, I am citing several figures that appear within the paper, like this

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

Later on I cite the figure using \ref{fig}.

In the text, the citation does not appear as "figure 1", but instead appears as "1" bounded by a red box. I have been trying to correct this by searching the .sty files my document is using, but I cannot identify the cause. Does anyone know why LaTex is doing this, or how to fix it?

Thanks for the help.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Problem with citing figures, citations are displayed incorre

Post by localghost »

Phanixis wrote:[…] Does anyone know why LaTex is doing this, or how to fix it? […]
You always have to use a caption to create an anchor for reference.

Code: Select all

\begin{figure}[!ht]
  \rule{4cm{3cm}
  \caption{Dummy figure}\label{fig:dummy}
\end{figure}
Note that the label always come after the caption. Now the reference to the given label should work.


Best regards
Thorsten¹
Phanixis
Posts: 7
Joined: Mon Sep 15, 2008 6:53 pm

Re: Problem with citing figures, citations are displayed incorre

Post by Phanixis »

I didn't show it in my example, but my caption does appear before my label statement. I double checked this an it is definitely not the cause of my problem.

Also, the problem isn't that LaTex is unable to find the correct figure, its that it is not displaying the caption properly. I almost suspect that somewhere in one of the packages /ref has been redefined to bound the citation number by boxes instead of writting the word "figure" in front of the citation number.
Post Reply