main
members
work
about me
avatar
Paul(admin)
post

LaTeX: Wrong figure numbers in subfloat

Post replyCan't edit post
Watch topicCan't delete post
Tuesday, August 4 2009, 16:14
I've been puzzled by some incorrect figure numbers in my LaTeX document recently. I have a figure, 2, with two subfigures, 2a and 2b, but when referencing them, I get figures 1a and 1b.
It turned out you have to put the \label commands in the correct order, like so:
\begin{figure}[b]
\caption{Detail of cameras on a Nokia N95 smartphone}
\label{fig:cameras}
\centering
\subfloat[User camera located above screen]{
\label{fig:user_camera}
\includegraphics{images/front_camera.png}}
\hspace{2cm}
\subfloat[Perspective camera on backside of device]{
\label{fig:perspective_camera}
\includegraphics{images/back_camera.png}}
\end{figure}
Also, make sure that \caption always precedes \label as Luke Maciak suggests.
Note that as Matthias mentions in the comments below, you may have to put the \caption and \label after the \subfloats. I haven't determined yet when one or the other should be done, but just remember that moving them around may resolve your problem.
Rating:
Actions:Post replyWatch topic
Matthias: Thanks for your post! I had a similar...Post reply Show 2 comments
Graham: Matthias- that has allowed me to heave a...

More updates

Click here to read more news items.
Members have extra privileges. You can login or register.
© 2005–2017 P. F. Lammertsma
No members currently online; 340 hits today by 117 unique users