# How can I reference figure*'s subfigure? [duplicate]

I'm writing a paper to submit a conference.

However, I am having some problems fixing non-resolved references in latex.

\begin{figure*}[ht!]

\begin{subfigure}[b]{0.3\linewidth}

\includegraphics[width=1\linewidth]{fig/toy}

\vspace*{-1cm} % for cosmetic change

\label{fig:toynetwork_example}

\caption{A toy network}

\end{subfigure}%

\begin{subfigure}[b]{0.3\linewidth}

\includegraphics[width=1\linewidth]{fig/exampleProcedure13}

\vspace*{-1cm} % for cosmetic change

\label{fig:firstIterationFin}

\caption{After first iteration}

\end{subfigure}

\begin{subfigure}[b]{0.3\linewidth}

\vspace*{-0.4cm} % for cosmetic change

\end{subfigure}%

\begin{subfigure}[b]{0.3\linewidth}

\includegraphics[width=1\linewidth]{fig/proposed_influence_matrix}

\vspace*{-0.4cm} % for cosmetic change

\label{fig:proposed_influence_matrix}

\caption{Influence matrix}

\end{subfigure}%

\hspace*{0.2cm}

\vspace*{0.3cm} % for cosmetic change

\begin{subfigure}[b]{0.3\linewidth}

\includegraphics[width=1\linewidth]{fig/proposed_update_order}

\vspace*{-0.4cm} % for cosmetic change

\label{fig:proposed_update_order}

\caption{Update order}

\end{subfigure}%

\caption{Example network}

\label{fig:example_network_procedure}

\end{figure*}


The PDF file shows ?? rather than the reference.

Can you help me?

## migrated from stackoverflow.comJul 21 '15 at 21:44

This question came from our site for professional and enthusiast programmers.

• What is the reference that you are missing? Or is all of them? In addition, try placing the label command just after the includegraphics command. – arodrisa Jul 21 '15 at 6:08
• Welcome to TeX.sx! Your post was migrated here from Stack Overflow. Please register on this site, too, and make sure that both accounts are associated with each other (by using the same OpenID), otherwise you won't be able to comment on or accept answers or edit your question. – Werner Jul 22 '15 at 0:24

The \label must go after or inside the \caption command. It cannot be placed before. This is because \caption increments the relevant counter, which is what \label hooks onto. If you put the \label first, there is nothing onto which it might hook.

For example, turning your code into a (semi-)Minimal Working Example by adding a preamble and substituting standard images:

Code:

\documentclass{article}
\usepackage{graphicx,subcaption}

\begin{document}

\ref{fig:example_network_procedure}
\ref{fig:firstIterationFin}
\ref{fig:proposed_influence_matrix}
\ref{fig:proposed_update_order}
\ref{fig:toynetwork_example}

\begin{figure*}[ht!]
\begin{subfigure}[t]{0.3\linewidth}
\includegraphics[width=1\linewidth]{example-image-a}

\caption{A toy network\label{fig:toynetwork_example}}
\end{subfigure}
\begin{subfigure}[t]{0.3\linewidth}
\includegraphics[width=1\linewidth]{example-image-a}

\caption{After first iteration}\label{fig:firstIterationFin}
\end{subfigure}
\begin{subfigure}[t]{0.3\linewidth}
\includegraphics[width=1\linewidth]{example-image-a}

\end{subfigure}

\begin{subfigure}[t]{0.3\linewidth}
\includegraphics[width=1\linewidth]{example-image-a}

\caption{Influence matrix\label{fig:proposed_influence_matrix}}
\end{subfigure}
\begin{subfigure}[t]{0.3\linewidth}
\includegraphics[width=1\linewidth]{example-image-a}

\caption{Update order}\label{fig:proposed_update_order}
\end{subfigure}

\caption{Example network}
\label{fig:example_network_procedure}
\end{figure*}

\end{document}