Let us consider this code which uses the exam class.
\documentclass{exam}
%\printanswers
\begin{document}
\begin{questions}
\question Why do we get undefined references warning in this case?
\begin{solution}
\begin{enumerate}
\item\label{enu:l}This will not give the answer.
\item And neither this one. This one~(\ref{enu:l}) did not give
the answer either.
\end{enumerate}
\end{solution}
\end{questions}
\end{document}
The label is being defined and used inside the solution. However, it generates an undefined references warning when the answers are not being printed.
LaTeX Warning: Reference `enu:l' on page 1 undefined on input line 12. ............... ............... LaTeX Warning: There were undefined references.
But common sense dictates that since the label is being defined and used inside the solution, we should not get the warning message depending on whether the solution is being printed or not.
Or if a phantom output of the solution is being generated to leave space for it, we should not get the warning. It is being processed, is not it?
Then why do we still get the warning?
A bug perhaps? Or a feature? (Perhaps not.)
.aux
file, but the solution text in main file is read. Hence the warning. Check the.aux
file with and without\printanswers
line. Is it a bug? I am not sure.If printanswers is true, we print the solution using a TheSolution environment. If printanswers is false and cancelspace is false, we insert lined vertical space equal to the optional argument (the default value of which is 0pt).