In the text of a solution, I would like to make a reference to a figure which is inside the solution environment as well, but it is not working. The code is as simple as:
\begin{solution}
\begin{figure}
\includegraphics{sample.jpg}
\label{fig}
\end{figure}
As you can see in figure (\ref{fig})...
\end{solution}
And I always get a (??) in the output. Why is the referencing failing?
\captionbefore the\labelwithin thefigureenvironment. – Werner Aug 28 '23 at 17:35