5

I am trying to use two ExerciseTypes 'exercise' and 'question' using xsim. Both the ExerciseTypes will be used to display 'exercises' and 'questions' in different sections of a book and their answers separately at the end of the book. How to use ExerciseType 'exercise' for the desired purpose has been described by @cgnieder here. I have adopted the code as below:

    \DeclareExerciseEnvironmentTemplate{exercise-temp}{%
    \par\noindent
    \textbf{\GetExerciseProperty{counter}}%
    \GetExercisePropertyT{subtitle}{ \textit{#1}} %
}{\par}

\newcommand\printsectionexercises{%
    \ForEachUsedExerciseByType{%
        \ifnum\ExercisePropertyGet{exercise}{##2}{chapter-value}=\value{chapter}
        \ifnum\ExercisePropertyGet{exercise}{##2}{section-value}=\value{section}
        \XSIMprint{exercise}{exercise}{##2}%
        \fi
        \fi
    }%
}

\newcommand\printexercisesolutions{%
    \def\currentchapter{}%
    \def\currentsection{}%
    \def\lastchapter{}%
    \def\lastsection{}%
    \ForEachUsedExerciseByType{%
        \let\lastchapter\currentchapter
        \let\lastsection\currentsection
        \edef\currentchapter{\ExercisePropertyGet{exercise}{##2}{chapter-value}}%
        \edef\currentsection{\ExercisePropertyGet{exercise}{##2}{section-value}}%
        \ifx\lastchapter\currentchapter\else
        \section*{Chapter \ExercisePropertyGet{exercise}{##2}{chapter}}
        \fi
        \ifx\lastsection\currentsection\else
        \subsection*{Exercise \ExercisePropertyGet{exercise}{##2}{section}}
        \fi
        \XSIMprint{solution}{exercise}{##2}%
    }%
}

\xsimsetup{
    exercise/template = exercise-temp ,
    solution/template = exercise-temp ,
    exercise/within = section ,
    exercise/the-counter = \arabic{exercise}. ,
    exercise/print = false
}

To print an 'exercise', I use

\subsection*{Exercise \thesection}
\printsectionexercises

And to provide 'answer' to all the exercises at the end of the book, I use

\printexercisesolutions

The above codes give the desired result.

Next, I am trying to adopt the above code for the other ExerciseType 'question' as below:

    \DeclareExerciseEnvironmentTemplate{question-temp}{%
    \par\noindent
    \textbf{\GetExerciseProperty{counter}}%
    \GetExercisePropertyT{subtitle}{ \textit{#1}} %
}{\par}

\DeclareExerciseType{question}{
    exercise-env = question ,
    solution-env = answer ,
    exercise-name = \XSIMtranslate{Question} ,
    exercises-name = \XSIMtranslate{Questions} ,
    solution-name = \XSIMtranslate{Answer} ,
    solutions-name = \XSIMtranslate{Answers} ,
    exercise-template = question-temp ,
    solution-template = question-temp ,
    exercise-heading = \subsection* ,
    solution-heading = \subsection*
}

\newcommand{\printsectionquestions}{%
    \ForEachUsedExerciseByType{%
        \ifnum\ExercisePropertyGet{question}{##2}{chapter-value}=\value{chapter}
        \ifnum\ExercisePropertyGet{question}{##2}{section-value}=\value{section}
        \XSIMprint{question}{question}{##2}%
        \fi
        \fi
    }%
}

\newcommand{\printquestionsolutions}{%
    \def\currentchapter{}%
    \def\currentsection{}%
    \def\lastchapter{}%
    \def\lastsection{}%
    \ForEachUsedExerciseByType{%
        \let\lastchapter\currentchapter
        \let\lastsection\currentsection
        \edef\currentchapter{\ExercisePropertyGet{question}{##2}{chapter-value}}%
        \edef\currentsection{\ExercisePropertyGet{question}{##2}{section-value}}%
        \ifx\lastchapter\currentchapter\else
        \section*{Chapter \ExercisePropertyGet{question}{##2}{chapter}}
        \fi
        \ifx\lastsection\currentsection\else
        \subsection*{Question \ExercisePropertyGet{question}{##2}{section}}
        \fi
        \XSIMprint{answer}{question}{##2}%
    }%
}

\xsimsetup{
    exercise/template = question-temp ,
    solution/template = question-temp ,
    exercise/within = section ,
    exercise/the-counter = \arabic{question}. ,
    exercise/print = false
}

To print the 'question', I am using

\subsection*{Question \thesection}
\printsectionquestions

And to print the 'answer' to the questions at the end, I'm using

\printquestionsolutions

But the above codes for 'question' is not giving results similar to the corresponding code for 'exercise'.

Question: The result of the code for 'question' is different from that of the 'exercise' in the following two ways:

  1. The heading of the question set (for example, 'Question 1.1' in the following screenshot) appears below the question set while it should appear above: enter image description here
  2. The collection of answers at the end displays only the headings of the question sets (as in the following screenshot) but does not display the corresponding answers: enter image description here

I would be grateful if someone could help with the above problems. I am new to latex so please bear with me.

The complete code for ExerciseType 'Question' is as below:

    \documentclass[fontsize=11pt]{book}
    
    \usepackage{xsim}
    
    %%For 'Questions'%%
    
    \DeclareExerciseEnvironmentTemplate{question-temp}{%
        \par\noindent
        \textbf{\GetExerciseProperty{counter}}%
        \GetExercisePropertyT{subtitle}{ \textit{#1}} %
    }{\par}
    
    \DeclareExerciseType{question}{
        exercise-env = question ,
        solution-env = answer ,
        exercise-name = \XSIMtranslate{Question} ,
        exercises-name = \XSIMtranslate{Questions} ,
        solution-name = \XSIMtranslate{Answer} ,
        solutions-name = \XSIMtranslate{Answers} ,
        exercise-template = question-temp ,
        solution-template = question-temp ,
        exercise-heading = \subsection* ,
        solution-heading = \subsection*
    }
    
    \newcommand{\printsectionquestions}{%
        \ForEachUsedExerciseByType{%
            \ifnum\ExercisePropertyGet{question}{##2}{chapter-value}=\value{chapter}
            \ifnum\ExercisePropertyGet{question}{##2}{section-value}=\value{section}
            \XSIMprint{question}{question}{##2}%
            \fi
            \fi
        }%
    }
    
    \newcommand{\printquestionsolutions}{%
        \def\currentchapter{}%
        \def\currentsection{}%
        \def\lastchapter{}%
        \def\lastsection{}%
        \ForEachUsedExerciseByType{%
            \let\lastchapter\currentchapter
            \let\lastsection\currentsection
            \edef\currentchapter{\ExercisePropertyGet{question}{##2}{chapter-value}}%
            \edef\currentsection{\ExercisePropertyGet{question}{##2}{section-value}}%
            \ifx\lastchapter\currentchapter\else
            \section*{Chapter \ExercisePropertyGet{question}{##2}{chapter}}
            \fi
            \ifx\lastsection\currentsection\else
            \subsection*{Question \ExercisePropertyGet{question}{##2}{section}}
            \fi
            \XSIMprint{answer}{question}{##2}%
        }%
    }
    
    \xsimsetup{
        exercise/template = question-temp ,
        solution/template = question-temp ,
        exercise/within = section ,
        exercise/the-counter = \arabic{question}. ,
        exercise/print = false
    }
    
    \begin{document}
    
    \mainmatter
    
    \chapter{Chapter on Cat}
    
    \section{Cat-1}
    
    SOME TEXT...
    
    \begin{question}
        Question 1 in Section 1.1 in Chapter 1
    \end{question}
    \begin{answer}
        Answer of Question 1 in Section 1.1 in Chapter 1
    \end{answer}
    
    \begin{question}
        Question 2 in Section 1.1 in Chapter 1
    \end{question}
    \begin{answer}
        Answer of Question 2 in Section 1.1 in Chapter 1
    \end{answer}
    
    \subsection*{Question \thesection}
        \printsectionquestions
    
    \section{Cat-2}
    
    SOME TEXT...
    
    \begin{question}
        Question 1 in Section 1.2 in Chapter 1
    \end{question}
    \begin{answer}
        Answer of Question 1 in Section 1.2 in Chapter 1
    \end{answer}
    
    \begin{question}
        Question 2 in Section 1.2 in Chapter 1
    \end{question}
    \begin{answer}
        Answer of Question 2 in Section 1.2 in Chapter 1
    \end{answer}
    
    \subsection*{Question \thesection}
    \printsectionquestions
    
    \chapter{Chapter on Dog}
    
    \section{Dog-1}
    
    SOME TEXT...
    
    \begin{question}
        Question 1 in Section 2.1 in Chapter 2
    \end{question}
    \begin{answer}
        Answer of Question 1 in Section 2.1 in Chapter 2
    \end{answer}
    
    \begin{question}
        Question 2 in Section 2.1 in Chapter 2
    \end{question}
    \begin{answer}
        Answer of Question 2 in Section 2.1 in Chapter 2
    \end{answer}
    
    \subsection*{Question \thesection}
    \printsectionquestions
    
    \section{Dog-2}
    
    SOME TEXT...
    
    \begin{question}
        Question 1 in Section 2.2 in Chapter 2
    \end{question}
    \begin{answer}
        Answer of Question 1 in Section 2.2 in Chapter 2
    \end{answer}
    
    \begin{question}
        Question 2 in Section 2.2 in Chapter 2
    \end{question}
    \begin{answer}
        Answer of Question 2 in Section 2.2 in Chapter 2
    \end{answer}
    
    \subsection*{Question \thesection}
    \printsectionquestions
    
    \chapter*{\underline{Answers to Questions}}
    
    \printquestionsolutions
    
    \end{document}

EDIT: Finally, I want something like the following using 'exercise' and 'question' in the same file:

enter image description here

2
  • 1
    Welcome to TeX.SE!
    – Mensch
    Jul 16 at 11:44
  • 1
    This is a good question. I hope it gets a similarly good answer.
    – cfr
    Jul 17 at 1:15

1 Answer 1

3

Some of the configurations that xsim provides may be puzzling.

First, options like exercise/print used in \xsimsetup{exercise/print=false} are per-exercise-type. That means, the general form of exercise/print is <env name>/print. So, to set for exercise type question, you need to set

\xsimsetup{
    question/template = question-temp ,
    answer/template = question-temp ,
    question/within = section ,
    question/the-counter = \arabic{question}. ,
    question/print = false
}

This explains Question 1

  1. The heading of the question set (for example, 'Question 1.1' in the following screenshot) appears below the question set while it should appear above:

because with original setting \xsimsetup{exercise/print=false}, only exercises of type exercise are not printed, exercises of (new) type problem are still printed, by default. See also package manual (v0.21, 2022/02/12),

8.2. Environment Options & Hooks

For each exercise type there are the following options for both environments, the environments’ names are the module names for the options (here using the “exercise” type):

Therefore what actually happened for Question 1 is, problem environments are printed immediately, and \printsectionquestions prints nothing.

Even more puzzling, the first mandatory argument of \XSIMprint must be one of "exercise" or "solution". Thus \XSIMprint{answer}{question}{##2} won't print anything, without any error thrown.

This explains Question 2.

Full and updated example

\documentclass[fontsize=11pt]{book}

\usepackage{xsim}

%%For 'Questions'%%

\DeclareExerciseEnvironmentTemplate{question-temp}{%
    \par\noindent
    \textbf{\GetExerciseProperty{counter}}%
    \GetExercisePropertyT{subtitle}{ \textit{#1}} %
}{\par}

\DeclareExerciseType{question}{
    exercise-env = question ,
    solution-env = answer ,
    exercise-name = \XSIMtranslate{Question} ,
    exercises-name = \XSIMtranslate{Questions} ,
    solution-name = \XSIMtranslate{Answer} ,
    solutions-name = \XSIMtranslate{Answers} ,
    exercise-template = question-temp ,
    solution-template = question-temp ,
    exercise-heading = \subsection* ,
    solution-heading = \subsection*
}

\newcommand{\printsectionquestions}{%
  % ##1 type, ##2 id, ...
  \ForEachUsedExerciseByType{%
    \ifstrequal{question}{##1}{%
        \ifnum\ExercisePropertyGet{##1}{##2}{chapter-value}=\value{chapter}\relax
          \ifnum\ExercisePropertyGet{##1}{##2}{section-value}=\value{section}\relax
              \XSIMprint{exercise}{##1}{##2}%
          \fi
        \fi
    }{}%
  }%
}

\newcommand{\printquestionsolutions}{%
    \def\currentchapter{}%
    \def\currentsection{}%
    \def\lastchapter{}%
    \def\lastsection{}%
    \ForEachUsedExerciseByType{%
        \ifstrequal{question}{##1}{%
            \let\lastchapter\currentchapter
            \let\lastsection\currentsection
            \edef\currentchapter{\ExercisePropertyGet{##1}{##2}{chapter-value}}%
            \edef\currentsection{\ExercisePropertyGet{##1}{##2}{section-value}}%
            \ifx\lastchapter\currentchapter\else
                \section*{Chapter \ExercisePropertyGet{##1}{##2}{chapter}}
            \fi
            \ifx\lastsection\currentsection\else
                \subsection*{Question \ExercisePropertyGet{##1}{##2}{section}}
            \fi
            \XSIMprint{solution}{##1}{##2}%
        }{}%
    }%
}

\xsimsetup{
    question/template = question-temp ,
    answer/template = question-temp ,
    question/within = section ,
    question/the-counter = \arabic{question}. ,
    question/print = false
}

\begin{document}

\mainmatter

\chapter{Chapter on Cat}

\section{Cat-1}

SOME TEXT...

\begin{question}
    Question 1 in Section 1.1 in Chapter 1
\end{question}
\begin{answer}
    Answer of Question 1 in Section 1.1 in Chapter 1
\end{answer}

MORE TEXT...

\begin{question}
    Question 2 in Section 1.1 in Chapter 1
\end{question}
\begin{answer}
    Answer of Question 2 in Section 1.1 in Chapter 1
\end{answer}

\subsection*{Question \thesection}
    \printsectionquestions

\section{Cat-2}

SOME TEXT...

\begin{question}
    Question 1 in Section 1.2 in Chapter 1
\end{question}
\begin{answer}
    Answer of Question 1 in Section 1.2 in Chapter 1
\end{answer}

MORE TEXT...

\begin{question}
    Question 2 in Section 1.2 in Chapter 1
\end{question}
\begin{answer}
    Answer of Question 2 in Section 1.2 in Chapter 1
\end{answer}

\subsection*{Question \thesection}
\printsectionquestions

\chapter{Chapter on Dog}

\section{Dog-1}

SOME TEXT...

\begin{question}
    Question 1 in Section 2.1 in Chapter 2
\end{question}
\begin{answer}
    Answer of Question 1 in Section 2.1 in Chapter 2
\end{answer}

\begin{question}
    Question 2 in Section 2.1 in Chapter 2
\end{question}
\begin{answer}
    Answer of Question 2 in Section 2.1 in Chapter 2
\end{answer}

\subsection*{Question \thesection}
\printsectionquestions

\section{Dog-2}

SOME TEXT...

\begin{question}
    Question 1 in Section 2.2 in Chapter 2
\end{question}
\begin{answer}
    Answer of Question 1 in Section 2.2 in Chapter 2
\end{answer}

\begin{question}
    Question 2 in Section 2.2 in Chapter 2
\end{question}
\begin{answer}
    Answer of Question 2 in Section 2.2 in Chapter 2
\end{answer}

\subsection*{Question \thesection}
\printsectionquestions

\chapter*{\underline{Answers to Questions}}

\printquestionsolutions

\end{document}
Chapter on Cat Chapter on Dog Answers to Questions
Chapter on Cat Chapter on Dog Answers to Questions

Update: using two exercise types at the same

Apart from the generalization \printSectionExerEnvsOfType and \printSoluEnvsOfType, also note the \def\lastsection{} added inside \ifx\lastchapter\currentchapter\else...\fi, in \printSoluEnvsOfType, the generalized form of the \printquestionsolutions in my previous example.

\documentclass[fontsize=11pt]{book}

\usepackage{xsim}

%%For 'Questions'%%

\DeclareExerciseEnvironmentTemplate{question-temp}{%
    \par\noindent
    \textbf{\GetExerciseProperty{counter}}%
    \GetExercisePropertyT{subtitle}{ \textit{#1}} %
}{\par}

\DeclareExerciseType{question}{
    exercise-env = question ,
    solution-env = answer ,
    exercise-name = \XSIMtranslate{Question} ,
    exercises-name = \XSIMtranslate{Questions} ,
    solution-name = \XSIMtranslate{Answer} ,
    solutions-name = \XSIMtranslate{Answers} ,
    exercise-template = question-temp ,
    solution-template = question-temp ,
    exercise-heading = \subsection* ,
    solution-heading = \subsection*
}

\newcommand{\printSectionExerEnvsOfType}[1]{%
  % ##1 type, ##2 id, ...
  \ForEachUsedExerciseByType{%
    \ifstrequal{#1}{##1}{%
        \ifnum\ExercisePropertyGet{##1}{##2}{chapter-value}=\value{chapter}\relax
          \ifnum\ExercisePropertyGet{##1}{##2}{section-value}=\value{section}\relax
%              \texttt{<##1><##2>}\par
              \XSIMprint{exercise}{##1}{##2}%
          \fi
        \fi
    }{}%
  }%
}

\newcommand{\printsectionexercises}{%
  \printSectionExerEnvsOfType{exercise}%
}

\newcommand{\printsectionquestions}{%
  \printSectionExerEnvsOfType{question}%
}

\newcommand{\printSoluEnvsOfType}[1]{%
    \def\currentchapter{}%
    \def\currentsection{}%
    \def\lastchapter{}%
    \def\lastsection{}%
    \ForEachUsedExerciseByType{%
        \ifstrequal{#1}{##1}{%
            \let\lastchapter\currentchapter
            \let\lastsection\currentsection
            \edef\currentchapter{\ExercisePropertyGet{##1}{##2}{chapter-value}}%
            \edef\currentsection{\ExercisePropertyGet{##1}{##2}{section-value}}%
            \ifx\lastchapter\currentchapter\else
                \section*{Chapter \ExercisePropertyGet{##1}{##2}{chapter}}
                \def\lastsection{}%
            \fi
            \ifx\lastsection\currentsection\else
                \subsection*{Question \ExercisePropertyGet{##1}{##2}{section}}
            \fi
            \XSIMprint{solution}{##1}{##2}%
        }{}%
    }%
}

\newcommand{\printexercisesolutions}{%
  \printSoluEnvsOfType{exercise}%
}

\newcommand{\printquestionsolutions}{%
  \printSoluEnvsOfType{question}%
}

\xsimsetup{
    % for exercise type 'exercise'
    exercise/template = question-temp ,
    solution/template = question-temp ,
    exercise/within = section ,
    exercise/the-counter = \arabic{exercise}. ,
    exercise/print = false,
    % for exercise type 'question'
    question/within = section ,
    question/the-counter = \arabic{question}. ,
    question/print = false,
}

\begin{document}

\mainmatter

\chapter{Chapter on Cat}

\section{Cat-1}

SOME TEXT...

\begin{exercise}
    Exercise 1 in Section 1.1 in Chapter 1
\end{exercise}
\begin{solution}
    Solution of Exercise 1 in Section 1.1 in Chapter 1
\end{solution}

MORE TEXT...

\begin{exercise}
    Exercise 2 in Section 1.1 in Chapter 1
\end{exercise}
\begin{solution}
    Solution of Exercise 2 in Section 1.1 in Chapter 1
\end{solution}

\subsection*{Exercise \thesection}
\printsectionexercises

\section{Cat-2}

SOME TEXT...

\begin{question}
    Question 1 in Section 1.2 in Chapter 1
\end{question}
\begin{answer}
    Answer of Question 1 in Section 1.2 in Chapter 1
\end{answer}

MORE TEXT...

\begin{question}
    Question 2 in Section 1.2 in Chapter 1
\end{question}
\begin{answer}
    Answer of Question 2 in Section 1.2 in Chapter 1
\end{answer}

\subsection*{Question \thesection}
\printsectionquestions

\chapter{Chapter on Dog}

\section{Dog-1}

SOME TEXT...

\begin{exercise}
    Exercise 1 in Section 2.1 in Chapter 2
\end{exercise}
\begin{solution}
    Solution of Exercise 1 in Section 2.1 in Chapter 2
\end{solution}

\begin{exercise}
    Exercise 2 in Section 2.1 in Chapter 2
\end{exercise}
\begin{solution}
    Solution of Exercise 2 in Section 2.1 in Chapter 2
\end{solution}

\subsection*{Exercise \thesection}
\printsectionexercises

\section{Dog-2}

SOME TEXT...

\begin{question}
    Question 1 in Section 2.2 in Chapter 2
\end{question}
\begin{answer}
    Answer of Question 1 in Section 2.2 in Chapter 2
\end{answer}

\begin{question}
    Question 2 in Section 2.2 in Chapter 2
\end{question}
\begin{answer}
    Answer of Question 2 in Section 2.2 in Chapter 2
\end{answer}

\subsection*{Question \thesection}
\printsectionquestions

\chapter*{\underline{Solutions to Exercises}}
\printexercisesolutions

\chapter*{\underline{Solutions to Questions}}
\printquestionsolutions

\end{document}
Chap 1 Chap 2
Chap 1 Chap 2
Solutions to Exercises Solutions to Questions
Solutions to exercises Solutions to questions

Attempt: Quicker \printSectionExerEnvsOfType and \printSoluEnvsOfType.

The new loop macro \ForEachUsedExerciseByIDOfType{<type>}{<loop body>} is quicker than both \ForEachUsedExerciseByID{<loop body>} and \ForEachUsedExerciseByType{<loop body>} because the new one won't loop through the internal list of (all declared) exercise types.

\ExplSyntaxOn
% #1: type, #2: loop body
\NewDocumentCommand \ForEachUsedExerciseByIDOfType {m +m}
  {
    \tl_set_eq:NN \XSIMtmp \ExerciseType
    \xsim_foreach_exercise_id_of_type:nnn {used} {#1} {#2}
    \tl_set_eq:NN \ExerciseType \XSIMtmp
    \tl_clear:N \XSIMtmp
  }

\xsim_verbose:n
  { Defining~ loop~ macro~ \xsim_foreach_exercise_id_of_type:nnn } 
% #1: boolean property, #2: type, #3: loop body
\cs_new_protected:Npn \xsim_foreach_exercise_id_of_type:nnn #1#2#3
  {
    \cs_set:cn {__xsim_loop_item:nnnnnn} {#3}
    \xsim_foreach_exercise_id:n
      {
        % type, id, boolean property (i.e., used, printed)
        \__xsim_deliver_exercise_details:nnn {#2} {##1} {#1}
      }
  }
\ExplSyntaxOff

\newcommand{\printSectionExerEnvsOfType}[1]{%
  % ##1 type, ##2 id, ...
  \ForEachUsedExerciseByIDOfType{#1}{%
    \ifnum\ExercisePropertyGet{##1}{##2}{chapter-value}=\value{chapter}\relax
      \ifnum\ExercisePropertyGet{##1}{##2}{section-value}=\value{section}\relax
        \XSIMprint{exercise}{##1}{##2}%
      \fi
    \fi
  }%
}

\newcommand{\printSoluEnvsOfType}[1]{%
  \def\currentchapter{}%
  \def\currentsection{}%
  \def\lastchapter{}%
  \def\lastsection{}%
  \ForEachUsedExerciseByIDOfType{#1}{%
    \let\lastchapter\currentchapter
    \let\lastsection\currentsection
    \edef\currentchapter{\ExercisePropertyGet{##1}{##2}{chapter-value}}%
    \edef\currentsection{\ExercisePropertyGet{##1}{##2}{section-value}}%
    \ifx\lastchapter\currentchapter\else
      \section*{Chapter \ExercisePropertyGet{##1}{##2}{chapter}}
      \def\lastsection{}%
    \fi
    \ifx\lastsection\currentsection\else
      \subsection*{Question \ExercisePropertyGet{##1}{##2}{section}}
    \fi
    \XSIMprint{solution}{##1}{##2}%
  }%
}
15
  • Thank you very much for your solution. It works perfectly but when I combine this code with that of the ExerciseType 'exercise' and use both 'exercise' and 'question' in the same file, it does not work. Can you please help me combine both the codes in the same file?
    – Aarone
    Sep 12 at 15:36
  • @Aarone In both \printsectionquestions and \printquestionsolutions, I used \ifstrequal{question}{##1}{<true code>}{<false code>} to filter out exercises and solutions belonging to non-question type(s). You can alter these places to achieve what you want. Sep 12 at 16:06
  • 1
    Please see the edit. I've added a picutre to show how the final pdf should look.
    – Aarone
    Sep 13 at 18:13
  • 1
    @Aarone Really? For example \printsectionexercises is defined by \newcommand{\printsectionexercises}{% \printSectionExerEnvsOfType{exercise}% }. Try this way: copy the whole second example in my answer, paste it in a new tex file, then compile. Sep 15 at 10:26
  • 1
    @Aarone I just checked the second example with TeX Live 2019 on overleaf. What's really undefined is \ForEachUsedExerciseByOrder, which was added in xsim v0.21 2022/02/12. You can safely replace it with the previous \ForEachUsedExerciseByType. Sep 15 at 19:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .