# Figure labels and references with \adjustimage

I am wondering why this command works:

\noindent\adjustimage{width=1.2\textwidth,center,caption={mycaption},label={mylabel},figure}{mylabel}


and I got references working correctly, and instead with this code I get the document compiled, but references do not work (question marks appear):

\begin{figure}
\label{mylabel}
\caption{mycaption}
\end{figure}


In there any way to modify the above code in order to have references working?

I add a minimal code that allow compilation:

\documentclass[a4paper,11pt]{article}
\usepackage{graphicx,float}
\usepackage{epstopdf}
\usepackage{caption}
\usepackage{pdflscape}
\begin{document}
In picture reference \ref{figure1} works, instead in picture \ref{figure2} does not
\begin{figure}[H]
\label{figure2}
\caption{mycaption2}
\end{figure}
\end{document}

• Could you pease make your example code compilable by adding the documentclass as well as the relevant packages? How/where is \adjustimage defined? – leandriis Oct 17 at 13:53
• \adjustimage is part of the adjustbox package; I have added a minimal code that allow compilation, maybe all packages are not really needed (I am using pdflatex with .eps images) – hardhu Oct 17 at 14:25
• Thanks a lot, since I am pretty new in the use of adjustbox package I was misleaded in the search for a solution – hardhu Oct 17 at 14:46

As explained in Why does an environment's label have to appear after the caption?, the \label must, well, appear after the \caption. In this case the caption package even issues a warning
Package caption Warning: \label without proper reference on input line 11.

Unrelated: in a TeX distribution which is not completely outdated it is not necessary to load the epstopdf package.