Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

global option print-solutions #103

Open
MichaelHuck opened this issue Mar 6, 2022 · 1 comment
Open

global option print-solutions #103

MichaelHuck opened this issue Mar 6, 2022 · 1 comment

Comments

@MichaelHuck
Copy link

I work with global options. My setup:

xsimsetup{
print-solutions/headings=false,
print-solutions/chapter=true
}

print-solutions/headings=false works fine
print-solutions/chapter=true does not work
I use
\printsolutions[chapter=true]
localy to print only the current chapter solutions.
My understanding of the manual is that you can set all options globally (xsimsetup) or locally.
Can you clarify why there is a difference between using these settings?
I can't see any difference in the manual.

Thanks.

@cgnieder
Copy link
Owner

You're right, the setup with \xsimsetup{ print-solutions/chapter = true } does not work. The reason is that it sets \l_xsim_printsolutions_chapter_int to the current value of the chapter counter. In the preamble this is 0

I agree that this is not obvious from the manual.

A possible solution is to add this to the \@chapter command:

\documentclass{report}
\usepackage{xsim}
\xsimsetup{print-solutions/chapter=true}

\ExplSyntaxOn

\AddToHook {cmd/@chapter/after} {
  \int_set:Nn \l_xsim_printsolutions_chapter_int { \value{chapter} }
}

\ExplSyntaxOff

\begin{document}

\chapter{A}
\begin{exercise}
  a
\end{exercise}
\begin{solution}
  a
\end{solution}

\printsolutions

\chapter{B}
\begin{exercise}
  b
\end{exercise}
\begin{solution}
  b
\end{solution}

\printsolutions

\end{document}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants