1

I'm writing a book which includes exercises spreaded through its chapters. To typeset the exercises I'm using the exsheets package. I want to make an appendix with all the solutions listed per chapter (and I've been aware this wasn't possible, according to Exsheets: how do I print the 'solutions' on the same line?).

I've seen that the newest version of exsheets has a chapter-hook option that, according to the manual (found at http://ctan.mirrors.hoobly.com/macros/latex/contrib/exsheets/exsheets_en.pdf.):

[chapter-hook = {code}] Adds "code" to the list of solutions every time solutions from a new chapter are printed (before the solutions of the corresponding chapter are printed).

The problem is that it's the only mention of chapter-hook the author makes, with no particular examples, so I don't even know where to put the option.

I've tried with the following:

\chapter{Grouped Exercises I}
\begin{question}
    Integrate $\int \cos{x}\ \mathrm{d}x$
\end{question}
\begin{solution}
    $\sin{x} + C$
\end{solution}
% ...
% more code here
% ...
\appendix
\chapter{Solutions to exercises}
\printsolutions[all,chapter-hook={Chapter}]

but when compiling with pdfLaTeX, it throws the error:

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! LaTeX error: "kernel/key-choice-unknown"
! 
! Key 'exsheets/exsheets_print_solutions/chapter-hook' accepts only a fixed
! set of choices.
! 
! See the LaTeX3 documentation for further information.
! 
! For immediate help type H <return>.
!...............................................  

l.6 \printsolutions[all,chapter-hook={Chapter}]

What to do? How's the correct way of using chapter-hook option under these circumstances?

Thanks in advance!

7
  • Welcome to TeX.SX! Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}.
    – user31729
    Jun 1, 2014 at 8:33
  • There is no exercise environment in exsheets, as far as I know and understood the manual, it should rather read \begin{question}...\end{question}. Furthermore you do not use any mathematical mode for your math question
    – user31729
    Jun 1, 2014 at 9:02
  • exsheets uses LaTeX3 syntax, I am not familiar with that, but looking into the code and using the error message, there is possibly a bug, where chapter-hook is treated as a choice-key whereas it is intended to be a command-key.
    – user31729
    Jun 1, 2014 at 9:04
  • @cgnieder: Perhaps you can provide some help?
    – user31729
    Jun 1, 2014 at 9:17
  • I updated the linked question with an example for section-hook @ChristianHupfer users only get notified in comments if they already have commented on a question/answer. It's easier to ping me in chat.
    – cgnieder
    Jun 1, 2014 at 10:39

1 Answer 1

2

Are you using TeX Live? The new options were introduced in version 0.13 (2014/05/11) which is not part of TL2013 (it was published after the freeze I believe). You either have to update exsheets manually or wait for TL2014 (or use the pretest version).

Either way: below is an example how the option could be used.

enter image description here

\documentclass{scrbook}
\usepackage{exsheets}[2014/05/11]
\SetupExSheets{
  counter-within = chapter
}
\DeclareQuestionProperty{chapter-number}

\newcommand*\diff[1]{\mathop{}\!\mathrm{d}#1}

\begin{document}

\chapter{Some Chapter}\label{ch:foo}
\section{foo}
\section{Grouped Exercises I}
\begin{question}
  \SetQuestionProperties{chapter-number=\ref{ch:foo}}
  Integrate $\int \cos x \diff{x}$.
\end{question}
\begin{solution}
    $\sin x + C$
\end{solution}

\chapter{Some Other Chapter}\label{ch:bar}
\section{bar}
\section{Grouped Exercises II}
\begin{question}
  \SetQuestionProperties{chapter-number=\ref{ch:bar}}
  Integrate $\int \sin x \diff{x}$.
\end{question}
\begin{solution}
    $-\cos x + C$
\end{solution}

\appendix
\SetupExSheets{
  chapter-hook =
    \section*{Exercises from chapter~\GetQuestionProperty{chapter-number}{\CurrentQuestionID}}
}

\chapter{Solutions to exercises}
\printsolutions

\end{document}
9
  • No, I'm using MiKTeX 2.9, and I've just installed the package lately. What's the procedure for installing a package manually? Jun 1, 2014 at 18:07
  • Oh, I've just checked the version of exsheets I have installed and it's 0.12. Jun 1, 2014 at 18:14
  • @logo_writer I believe MiKTeX has something like a package manager. There is a question about this somewhere on the page. It should be easy to find.
    – cgnieder
    Jun 1, 2014 at 18:14
  • @logo_writer so does my answer answer your question or not?
    – cgnieder
    Jun 1, 2014 at 19:35
  • Did you manage to update?
    – cgnieder
    Jun 1, 2014 at 19:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .