2

I would like to use the tag level (1,2,3) in xsim, but not only in exclusive manner, but as multiple tags, so that an exercise can have the tag level 1 and 2. So that, collecting later all level 2 exercises of my .tex or the level 1 exercises, I will have the same question in both chapters. (I want to ask some of the basic questions in a later chapter again for revision.)

Is the only possibility, that I create a tag 1 and a tag 2 and a tag 3? Or is there a possibility to write something like

\begin{exercise}[level=1,level=2]

If I do that now 1 is just overwritten by 2, so it will only be printed in chapter 2.

MWE:

\documentclass{article}
\usepackage{xsim}

\DeclareExerciseCollection{foo-easy}
\DeclareExerciseCollection{foo-medium}
\DeclareExerciseTagging{level}

\usepackage{filecontents,lipsum}
\begin{filecontents*}{foo.tex}
\begin{exercise}[level=1]
  foo one \lipsum[4]
\end{exercise}
\begin{solution}
  foo one \lipsum[4]
\end{solution}
\begin{exercise}[level=2]
  foo two \lipsum[4]
\end{exercise}
\begin{solution}
  foo two \lipsum[4]
\end{solution}
\begin{exercise}[level=1]
  foo three \lipsum[4]
\end{exercise}
\begin{solution}
  foo three \lipsum[4]
\end{solution}
\end{filecontents*}

\begin{document}

\collectexercises{foo-easy}
\xsimsetup{level=1}
\input{foo.tex}
\collectexercisesstop{foo-easy}
% collection `foo-easy' now contains all exercises of file `foo.tex' tagged
% with `level=1' but only if I don't add a 'level=2' as suggested above

\collectexercises{foo-medium}
\xsimsetup{level=2}
\input{foo.tex}
\collectexercisesstop{foo-medium}
% collection `foo-medium' now contains all exercises of file `foo.tex'
% tagged with `level=2' and only those, but I would like to add certain level 1 exercises as well

\section{Easy}
\printcollection{foo-easy}

\section{Medium}
\printcollection{foo-medium}

\end{document}
3

You can assign multiple values to a tagging class by using a comma-separated list:

\begin{exercise}[level={1,2}]

Using this for the third exercise in your MWE I get the following:

enter image description here

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.