1

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}
\adjustimage{width=1.2\textwidth,center}{myfigure}
\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{adjustbox}
\usepackage{graphicx,float}
\usepackage{epstopdf}
\usepackage{caption}
\usepackage{pdflscape}
\begin{document}
In picture reference \ref{figure1} works, instead in picture \ref{figure2} does not 
\noindent\adjustimage{width=1.2\textwidth,center,caption={mycaption1},label={figure1},figure}{myfigure1}
\begin{figure}[H]
        \adjustimage{width=1.2\textwidth,center}{myfigure2}
        \label{figure2}
        \caption{mycaption2}
\end{figure} 
\end{document}
  • 1
    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
2

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.
See the caption package documentation for explanation.

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

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.