1

I have six subfigures (i.e. Figure 1a, 1b, 1c, etc.) and I'd like to reference both the subfigures and the main figure (i.e. Figure 1), in the text. In this example, \ref{fig: lattice_strain} should refer to Figure 1, and \ref{fig: Fe_Lat_Strain} should be Figure 1a. Instead I get [??] appear in the body of the text. I'd appreciate any help!

Example:

Figure \ref{fig: lattice_strain} illustrates the change in the measured lattice strain with engineering strain and time for several Fe (\ref{fig: Fe_Lat_Strain}, M$_{23}$C$_{6}$ (\ref{fig: M_Lat_Strain}) and Nb(N, C) (\ref{fig: N_Lat_Strain} precipitate reflections in the loading direction.

\begin{figure}[h]
\captionsetup[subfloat]{labelfont=bf}
\begin{minipage}{\linewidth}
\centering
\subfloat[]{\label{fig: Fe_Lat_Strain}\includegraphics[scale=1]{Fe_Lat_Strain}} 
\centering
\subfloat[]{\label{fig: M_Lat_Strain}\includegraphics[scale=1]{M_Lat_Strain}} 
\centering
\subfloat[]{\label{fig: N_Lat_Strain}\includegraphics[scale=1]{N_Lat_Strain}} 
\end{minipage}\par\smallskip
\begin{minipage}{\linewidth}
\centering
\subfloat[]{\label{fig: Fe_Lat_Time}\includegraphics[scale=1]{Fe_Lat_Time}} 
\centering
\subfloat[]{\label{fig: M_Lat_Time}\includegraphics[scale=1]{M_Lat_Time}} 
\centering
\subfloat[]{\label{fig: N_Lat_Time}\includegraphics[scale=1]{N_Lat_Time}} 
\end{minipage}
\label{fig: lattice_strain}
\caption{(a--c)...(d-f)...} 
\end{figure}
  • 3
    Hi, welcome. The \label always has to be placed after (or within) the \caption. – Torbjørn T. Jun 14 '18 at 17:49
  • Thank you! I just realized that mistake after submitting this – Maria M. Jun 14 '18 at 18:01
1

In addition to following @TorbjørnT's advice and placing the \label instruction after the associated \caption instruction, you should look into simplifying the code considerably, e.g., by getting rid of the two minipage "wrappers" and by omitting all 6 \centering instructions. Next, set sensible (relative) widths for the images and separate the subfigures visually by issuing \hfill directives.

enter image description here

\documentclass[demo]{article} % remove 'demo' option in real document
\usepackage{subfig,graphicx}
\begin{document}
Figure \ref{fig:lattice_strain} \dots 
(\ref{fig:Fe_Lat_Strain}), 
M$_{23}$C$_{6}$ (\ref{fig:M_Lat_Strain}), 
and Nb(N, C) (\ref{fig:N_Lat_Strain}) \dots

\begin{figure}[h]
\captionsetup[subfloat]{labelfont=bf}

\subfloat[]{\label{fig:Fe_Lat_Strain}\includegraphics[width=0.3\textwidth]{Fe_Lat_Strain}} 
\hfill
\subfloat[]{\label{fig:M_Lat_Strain}\includegraphics[width=0.3\textwidth]{M_Lat_Strain}} 
\hfill
\subfloat[]{\label{fig:N_Lat_Strain}\includegraphics[width=0.3\textwidth]{N_Lat_Strain}} 

\smallskip

\subfloat[]{\label{fig:Fe_Lat_Time}\includegraphics[width=0.3\textwidth]{Fe_Lat_Time}} 
\hfill
\subfloat[]{\label{fig:M_Lat_Time}\includegraphics[width=0.3\textwidth]{M_Lat_Time}} 
\hfill
\subfloat[]{\label{fig:N_Lat_Time}\includegraphics[width=0.3\textwidth]{N_Lat_Time}} 

\caption{(a--c) \dots\ (d--f) \dots} 
\label{fig:lattice_strain}
\end{figure}
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.