1

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}
4
  • 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
    – cgnieder
    Oct 22, 2014 at 7:34
  • Oh, that's why they didn't appear to work. Thanks.
    – alwaysask
    Oct 22, 2014 at 8:20
  • @clemens Would you make it an answer please? :)
    – yo'
    Feb 7, 2015 at 23:43
  • @yo' sure, done :)
    – cgnieder
    Feb 8, 2015 at 11:14

1 Answer 1

1

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}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.