I am trying to use xsim to design a workbook for students, with a second version available for tutors. Therein will be exercises/questions/homework, however you want to call it, and their respective solutions.
From what I reviewed so far, xsim, seems to be a mostly well-suited package to achieve this. However, there is one piece of information I could not find in the documentation: How do I switch between an empty answer space/blank/box and the printed solutions?
Ideally, I want a way for the answer space to take up exactly the phantom space of the typeset solution.
Attached you find a MWE of how I want it to work, however I wish to have the procedure automated.
The following MWE produces (notice the solution/print = true
)
\documentclass{article}
\usepackage{mwe}
\usepackage{amssymb, amsmath}
\usepackage{xsim}
\usepackage{tcolorbox}
\DeclareExerciseEnvironmentTemplate{tcolorbox}
{%
\tcolorbox[
beforeafter skip = .5\baselineskip ,
title =
\textbf{\GetExerciseName~\GetExerciseProperty{counter}}%
\GetExercisePropertyT{subtitle}{ \textit{\PropertyValue}}%
]%
}
{\endtcolorbox}
\DeclareExerciseType{problem}{
exercise-env = problem ,
solution-env = answer ,
exercise-name = Problem ,
solution-name = Answer ,
exercise-template = tcolorbox ,
solution-template = tcolorbox
}
\xsimsetup{
answer/print=true
}
\begin{document}
\begin{problem}
Show that $(\mathbb{R}, +, \cdot)$ is a field.
\end{problem}
\begin{answer}
Let $a, b, c \in \mathbb{R}$ arbitrary. Then, we show the following properties:
\begin{description}
\item[Commutativity of addition] $a + b = b+ a$.
\item[Associativity of addition] $a +(b + c) = (a+b) +c$.
\item[Additive identity] $0 \in \mathbb{R}$, and $a +0 = a $.
\item[Additive inverse] for each $a \in \mathbb{R}$, there exists $-a \in \mathbb{R}$, sch that $a + (-a) = 0$.
\item[Commutativity of multiplication] $a \cdot b = b \cdot a$.
\item[Associativity of multiplications] $a \cdot (b \dot c) = (a \cdot b) \cdot c$.
\item[Multiplicative identity] $1 \in \mathbb{R}$, such that $1 \cdot a = a$.
\item[Multiplicative inverse] for each $a \in \mathbb{R}$, there exists $a^{-1}\in \mathbb{R}$, such that $a \cdot a^{-1} = 1$.
\item[Distributivity] $a\cdot (b + c) = (a \cdot b) + (a \cdot c)$.
\end{description}
These are the necessary and sufficient properties of a field, hence $(\mathbb{R}, +, \cdot)$ is a field.
\end{answer}
\end{document}
but I want an empty box with the same dimensions when answers are disabled.
Update
Ultimately, I ended up ditching xsim
, persued a different path, and came up with my own alternative solution, which is detailed in this other question and answer. However, it is still not an answer to this question.
Update
One step later than ultimately, I retuned to using xsim
. See my answer with the solution below.
xsim
package has a solution for the question.