I'm trying to insert a figure in a LaTeX file, but LaTeX always gives the reference number of this figure as figure 1 instead of 2, although there is already a figure 1 earlier in the document. I also can't reference this figure using ~\ref{fig:regress}
. The figure number just doesn't print.
Here's the code I used to insert the image in LaTeX:
\documentclass[11pt]{article}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{chngcntr}
\begin{document}
I'm trying to reference Figure~\ref{fig:regress} here...
\begin{figure}[htp]
\centering
\begin{subfigure}{0.8\textwidth}
\centering
\includegraphics[width=\textwidth]{im1.png}
\caption{Scatter plot fitted with straight line}
\label{fig:linfit}
\end{subfigure}%
\begin{subfigure}{0.8\textwidth}
\centering
\includegraphics[width=\textwidth]{im2.png}
\caption{Scatter plot fitted with 2nd degree polynomial}
\label{fig:quadfit}
\end{subfigure}
\end{figure}
\newpage
\begin{figure}
\ContinuedFloat
\centering
\begin{subfigure}{0.8\textwidth}
\centering
\includegraphics[width=\textwidth]{im3.png}
\caption{Scatter plot fitted with 3rd degree polynomial}
\label{fig:cubicfit}
\end{subfigure}
\caption{Scatter plots of wavelength vs. pixel position for the spectrum from night 1, fitted with polynomials of orders 1-3.} \label{fig:regress}
\end{figure}
\end{document}
I checked that I have \label
and \caption
in the right order. What's going on?
! Package caption Error: Continued `figure' after `??'.
There’s no problem when adding a separate caption to the firstfigure
environment or removing\ContinuedFloat
from the second. In every instance, the second figure’s subfigure enumeration is still(c)
. – Qrrbrbirlbel Dec 9 '12 at 0:28\caption{Scatter plots of wavelength vs. pixel position for the spectrum from night 1, fitted with polynomials of orders 1-3.} \label{fig:regress}
to just above the first subfigure, it works (except the caption is now on top of the figures). – rferdinand Dec 9 '12 at 0:49