Allow printcollection to filter by tags
mschneiderwng opened this issue · comments
mschneiderwng commented
I have exercises about some topic. Some are optional, some are mandatory. I would like to print the mandatory first, then the optional. The current workflow is as follows:
\documentclass[a4paper]{article}
\usepackage[use-aux=false]{xsim}
\DeclareExerciseTagging{optional}
\DeclareExerciseCollection[topics=algebra, optional=true]{algebra-optional}
\DeclareExerciseCollection[topics=algebra, optional=false]{algebra-mandatory}
\xsimsetup{collect}
\begin{filecontents}{exercises.tex}
\begin{exercise}[topics=algebra, optional=true]
a algebra question 1 optional=true
\end{exercise}
\begin{exercise}[topics=calculus, optional=false]
calculus question 1 optional=false
\end{exercise}
\begin{exercise}[topics=algebra, optional=false]
algebra question 2 optional=false
\end{exercise}
\end{filecontents}
\begin{document}
% collect
\collectexercises{algebra-mandatory}
\input{exercises.tex}
\collectexercisesstop{algebra-mandatory}
\collectexercises{algebra-optional}
\input{exercises.tex}
\collectexercisesstop{algebra-optional}
\section{Mandatory}
\printcollection{algebra-mandatory}
\section{Optional}
\printcollection{algebra-optional}
\end{document}
Would it be possible to add a filter to \printcollection
, such that the interface something like in the following example?
\documentclass[a4paper]{article}
\usepackage[use-aux=false]{xsim}
\DeclareExerciseTagging{optional}
\DeclareExerciseCollection[topics=algebra]{algebra}
\xsimsetup{collect}
\begin{filecontents}{exercises.tex}
\begin{exercise}[topics=algebra, optional=true]
a algebra question 1 optional=true
\end{exercise}
\begin{exercise}[topics=calculus, optional=false]
calculus question 1 optional=false
\end{exercise}
\begin{exercise}[topics=algebra, optional=false]
algebra question 2 optional=false
\end{exercise}
\end{filecontents}
\begin{document}
\collectexercises{algebra}
\input{exercises.tex}
\collectexercisesstop{algebra}
\section{Mandatory}
\printcollection[filter={optional=false}]{algebra}
\section{Optional}
\printcollection[filter={optional=true}]{algebra}
\end{document}