I would like to make any solution box span the whole text width for any question/part/subpart/subsubpart.
\documentclass{exam}
\renewcommand{\solutiontitle}{\noindent\textbf{\underline{Answer:}}\par\noindent}
\printanswers
\begin{document}
\begin{questions}
\question Some question.
\begin{parts}
\part some part
\begin{solution}
I need this solution box to span the whole text width.
\end{solution}
\begin{subparts}
\subpart another question
\begin{solution}
I need this solution box to span the whole text width.
\end{solution}
\end{subparts}
\end{parts}
\end{questions}
\end{document}
Best Answer
In order to make the solution box as wide as the textwidth, you can enclose it in a
\fullwidth{<solution>}
command or use theEnvFullwidth
environment. Details on this are discussed in theexam
documentation:The following MWE demonstrates the usage of the
\fullwidth
command as well as theEnvFullwidth
environment:To apply the changes globally, you could define your own solutions environment as follows:
To remove the vertical white space that is present in the two above shown examples when commenting out
\printanswers
we can use command\ifprintanswers
as described in section 8.8 of the manual:Here is a short MWE that introduces a new environment
widesolution
that is full width only when\printanswers
is used. Otherwise thewidesolutions
environment is equal to thesolutions
environment and therefore does not cause any additional white space if\printanswers
is not used: