0

I want to add a reference to an image or a table that is after the text but it seams that the compiler is not finding the label, giving me "??" as number, like the label is not existing. It works only if I put the image before the text. Why is it happening and how can I solve it?

as shown in figure \ref{text} ...

\begin{figure}[H] \centering \label{text}
    {\includegraphics[width=0.48\textwidth, keepaspectratio]{figure/image}}
    \caption[dsad]{dsad}
\end{figure}
Shika93
  • 371

1 Answers1

1

You need to set the \label after the \caption

\begin{document}
    as shown in figure \ref{text} ...

    \begin{figure}[H] 
        \centering
        \includegraphics[width=.48\textwidth]{figure/image}
        \caption[dsad]{dsad}
        \label{text}
    \end{figure}
\end{document

You can find some information about this here: https://tex.stackexchange.com/a/32326/105976

Also you don't need that extra brackets around \includegrahics, and you don't need to set keepaspectratio,when only setting the width the ratio will be the same

sporc
  • 643