3

I have rotated my figure to 90 degrees using adjustbox as follows:

\begin{figure}[ht]
  \begin{adjustbox}{addcode={\begin{minipage}{\width}}{\caption{%
      My caption
      }\end{minipage}},rotate=90,center}
      \includegraphics[scale=.60]{my_figure.PNG}%
  \end{adjustbox}
  \label{fig:my_figure}
\end{figure}

Now when I want to use this figure as reference like \ref{fig:my_figure}, I am seeing ?? as the reference. I will be thankful if anyone could help me with this.

3
  • 1
    The \label command must go next to the caption, either inside the argument to \caption or just before \end{minipage}.
    – egreg
    Feb 7, 2015 at 16:59
  • you mean like {\caption{% My Caption} {\label{fig:my_label}}? Feb 7, 2015 at 17:02
  • 1
    Yes, but no additional braces around \label{fig:my_label}
    – egreg
    Feb 7, 2015 at 17:03

1 Answer 1

6

The \label is too far from \caption; more precisely, the caption is set inside a minipage, which forms a group, so what LaTeX sets up for being remembered along with \label is forgotten at \end{minipage}.

\begin{figure}[ht]

\begin{adjustbox}{
  addcode=
    {\begin{minipage}{\width}}
    {\caption{My caption}\label{fig:my_figure}\end{minipage}},
  rotate=90,
  center
}
\includegraphics[scale=.60]{my_figure.PNG}
\end{adjustbox}

\end{figure}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .