# examples for some options for the 'solutions' environment?

Can anyone give an example of how to use the 'pre-hook', 'post-hook', 'pre-body-hook' and 'post-body-hook' options for the solutions environment of the exsheets package please?

They don't seem to do anythig for me no matter what I added after the '=' sign so I presume I'm not using them right. There are no examples in the documentation for these 4 options. I included an MWE for convenience and to show how I tried to use those options. Any other MWE will do.

\documentclass{article}
\usepackage{exsheets}

\begin{document}

\begin{question}
Q1-foo
\end{question}
\begin{solution}[ pre-hook = , post-hook = , pre-body-hook = , post-body-hook = ]
S1-foo
\end{solution}

\begin{question}
Q2-foo
\end{question}
\begin{solution}
S2-foo
\end{solution}

\printsolutions
\end{document}

• The hooks are not saved for a solution, only the body itself is. The hooks work fine as you see when you add the option print to the list Oct 22, 2014 at 7:34
• Oh, that's why they didn't appear to work. Thanks. Oct 22, 2014 at 8:20
– yo'
Feb 7, 2015 at 23:43
• @yo' sure, done :) Feb 8, 2015 at 11:14

The manual should probably make this clearer: the contents of the hooks is typeset when a solution is typeset, i.e., when the option solution/print is set to true. However, they are not saved as a part of the solution.

\documentclass{article}
\usepackage{exsheets}

\begin{document}

\begin{question}
Q1-foo
\end{question}
\begin{solution}[print, pre-hook =a , post-hook =x , pre-body-hook =A , post-body-hook = X]
S1-foo
\end{solution}

\begin{question}
Q2-foo
\end{question}
\begin{solution}[print]
S2-foo
\end{solution}

\printsolutions

\SetupExSheets{
solution/pre-hook =a ,
solution/post-hook =x ,
solution/pre-body-hook =A ,
solution/post-body-hook = X
}
\printsolutions

\end{document}


The thought behind those hooks was to allow things like this:

\documentclass{article}
\usepackage{exsheets,mdframed}

\SetupExSheets{
solution/pre-hook = \mdframed ,
solution/post-hook = \endmdframed
}

\begin{document}

\begin{question}
Q1-foo
\end{question}
\begin{solution}
S1-foo
\end{solution}

\begin{question}
Q2-foo
\end{question}
\begin{solution}
S2-foo
\end{solution}

\printsolutions

\end{document}