I want to have a file with exercises and at the end of the file, I want to print the exercises sorted by level (a tag i created with xsim).
Below what do not work, for obvious reason, \printcollection
works with a collection, not with a tag, but I cannot figure out how to handle collections, without writing it for every exercise).
Connected question: is it possible to define the level by a number (eg. 1
, 2
or 3
) and print a the corresponding number of $\star$
in the exercise-header
?
\documentclass{article}
\usepackage[no-files]{xsim}
\DeclareExerciseTagging{level}
\DeclareExerciseTagging{nom}
\DeclareExerciseEnvironmentTemplate{custom}
{
\par\bigskip
\noindent\sffamily\textbf
{%
\XSIMmixedcase {\GetExerciseName}\nobreakspace
\GetExerciseProperty{counter}%
\IfExercisePropertySetT{level}
{ (\GetExerciseProperty{level}) }%
\IfExercisePropertySetT{nom}
{ {\itshape\GetExerciseProperty{nom}} }%
}\par\noindent%
}
{\par\medskip}
\DeclareExerciseType{exo}{
exercise-env= exo ,
solution-env = soln ,
exercise-name = \XSIMtranslate{exercise} ,
exercises-name = \XSIMtranslate{exercises} ,
solution-name = \XSIMtranslate{solution} ,
solutions-name = \XSIMtranslate{solutions} ,
exercise-template = custom ,
solution-template = custom ,
exercise-heading = \subsection* ,
solution-heading = \subsection*
}
\xsimsetup{
level ={$\star$,$\star\star$, $\star\star\star$} ,
solution/print=true,
soln/print=true,
}
\begin{document}
Le cours...
\begin{exo}[nom=Suite de Syracuse]
Exercice 1 - pas de niveau
\end{exo}
Le cours...
\begin{exo}[level=$\star$, nom = Suite de Fibonacci]
Exercice 2 - niveau 1
\end{exo}
Une remarque ....
\begin{exo}[level=$\star\star$]
Exercice 3 - niveau 2
\end{exo}
\begin{exo}[level=$\star$]
Exercice 4 - niveau 1
\end{exo}
Et on termine par quelque chose de plus difficile
\begin{exo}[level=$\star\star\star$]
Exercice 5 - très dur - niveau 3
\end{exo}
Fin du cours.
\newpage
Feuille exercice
%\FeuilleExercices
Exercices simples
\printcollection{level=$\star$}
Exercices medians
\printcollection{level=$\star\star$}
Exercices complexes
\printcollection{level=$\star\star\star$}
\end{document}