I've just read this post linked in the xsim_manual on p.71 example 35 and i've some troubles to adapt it to my goal.
I want to add an environment resolution
for each exercises of my database. This environment will contain the complete solution of an exercise. With equations, pictures, tikz schemes,... In the post linked, the goal is to write a shortsolution
environment and to use the normal command for the resolution. But i prefer to keep the regular solution
environment for short solutions because it allows me to define some options inside of my documents and it's this environment that i'll use more often.
Unfortunately, i'm facing an issue when i add some long stuff inside the resolution environment. In particular, double vertical line |
around a vector (for a norm) create the following error :
! File ended while scanning use of \__tl_rescan:NNw.
Can you help me to fix this ? My attempts are :
- Using double vertical lines
|
around my vector ; - Let an exercise be free of resolution without problem. I can't write a complete computer resolution for each exercises i've computed now.
- Keep the regular
solution
environment as it is.
The code below is a MWE :
\documentclass{article}
\usepackage{amsmath}
\usepackage{xsim}
\usepackage{environ}
%%Adapted from https://texwelt.de/fragen/23968/xsim-ubung-losung-zusatzlich-kurzlosung
\DeclareExerciseProperty{resolution}
% we'll use a description list for the resolutions:
\newcommand\printresolutions{%
\begin{description}
\ForEachUsedExerciseByType{%
\def\ExerciseType{##1}%
\def\ExerciseID{##2}%
\GetExercisePropertyT{resolution}
{%
\item[Résolution ##3]
####1%
}%
}%
\end{description}
}
\NewEnviron{resolution}{\SetExpandedExerciseProperty{resolution}{\expandonce{\BODY}}}
\begin{document}
\section{My section}
\begin{exercise}
Foo exercise with no resolution
\end{exercise}
\begin{solution}
Foo solution with no resolution.
\end{solution}
\begin{exercise}
Bar exercise with a resolution
\end{exercise}
\begin{resolution}
This is the resolution of my \textbf{bar} exercise.
\begin{equation*}
||\vec{F}|| %%here is the trouble
\end{equation*}
\end{resolution}
\begin{solution}
This is a solution for bar
\end{solution}
\printsolutions
\section{Resolutions}
\printresolutions
\end{document}
environ
– you can also use\NewDocumentEnvironment{resolution}{+b}{\SetExerciseProperty{resolution}{#1}}{}
)|
where i wrote the comment. I've just updated.