LaTeX: referencing figures within enumerate environment

  • Context: LaTeX 
  • Thread starter Thread starter arboretum
  • Start date Start date
  • Tags Tags
    Latex
Click For Summary
SUMMARY

The discussion addresses the issue of referencing figures within an enumerate environment in LaTeX. The original code incorrectly associates the figure label with the enumerate counter instead of the figure counter, resulting in inaccurate figure references. The solution provided involves placing the \label command inside the \caption argument of the figure environment, ensuring that the figure reference correctly corresponds to the figure number rather than the enumerate item number.

PREREQUISITES
  • Familiarity with LaTeX document preparation system
  • Understanding of figure and enumerate environments in LaTeX
  • Knowledge of LaTeX commands such as \label and \caption
  • Basic experience with compiling LaTeX documents
NEXT STEPS
  • Explore advanced LaTeX referencing techniques
  • Learn about the \numberwithin command for custom numbering
  • Investigate LaTeX packages that enhance figure management, such as caption or subcaption
  • Study best practices for organizing LaTeX documents with multiple environments
USEFUL FOR

LaTeX users, technical writers, and researchers who need to manage figures and references effectively in their documents.

arboretum
Messages
2
Reaction score
0
I've not been able to find any sort of answer to this using google, but perhaps it's because the searches I've used have not been specific enough, so I apologize for bringing it up if this is answered on every LaTeX-oriented website. In any case, here's my setup:

Code:
\begin{enumerate}
\item (first item---blah blah blah)

\item (second item---blah blah blah)
...
...
...
\item (tenth item---blah blah blah)
% this is the first figure in the file
\begin{figure}[!h]
    \includegraphics{yourmomlookslikeacow.eps}
    \label{fig:momcow}
    \caption{Your mother resembles a bovine}
\end{figure}

\item (eleventh item---blah blah blah)

\item (twelfth item) As we can see in Figure~\ref{fig:momcow}, your 
mother looks like a cow.
\end{enumerate}

What will happen is that yourmomlookslikeacow.eps will be the first figure in the file and will have a caption that says "Figure 1: Your mother resembles a bovine" as it should, but when I reference the figure in item #12, it will say "As we can see in Figure 10, your mother looks like a cow." For some reason, the label seems to associate itself with the value of the enumi counter at item #10 instead of the figure counter at figure #1. Even if I wanted to have something like "See Figure 10.1" by using \numberwithin{figure}{enumi}, all that would happen is that my caption would be modified properly, but my reference would still say "Figure 10."

I think one way of fixing this would be to end the enumerate environment, place in the code for the figure, then restart the enumerate environment at the appropriate number, but that seems clunkier and less good-programmingly good than simply writing "Figure~1" in my code when I want Figure 1. I'd really appreciate your help, and I want to point out that I don't have any beef with your mother, I just don't feel like using foo and bar.
 
Physics news on Phys.org
Hi arboretum,

Put the label inside the caption argument:

Code:
\begin{enumerate}
\item (first item---blah blah blah)

\item (second item---blah blah blah)
...
...
...
\item (tenth item---blah blah blah)
% this is the first figure in the file
\begin{figure}[!h]
    \includegraphics{yourmomlookslikeacow.eps}   
    \caption{\label{fig:momcow} Your mother resembles a bovine}
\end{figure}

\item (eleventh item---blah blah blah)

\item (twelfth item) As we can see in Figure~\ref{fig:momcow}, your 
mother looks like a cow.
\end{enumerate}
 

Similar threads

  • · Replies 5 ·
Replies
5
Views
5K
  • · Replies 5 ·
Replies
5
Views
7K
  • · Replies 2 ·
Replies
2
Views
6K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 11 ·
Replies
11
Views
4K
  • · Replies 1 ·
Replies
1
Views
6K
  • · Replies 4 ·
Replies
4
Views
5K
Replies
10
Views
11K
  • · Replies 6 ·
Replies
6
Views
18K