2

Using xsim, I have defined two custom exercise types, meditation and thoughtexperiment. They seem to work right, except for custom numbering. I'm trying to get meditation to appear as Meditation Question 13.4.7.1 (if it's in section 13.4.7, of course), and thoughtexperiment to appear as Thought Experiment Question 13-1 (-2, -3, etc) if it's chapter 13.

But I appear to be doing it wrong, as both of these appear as nothing more than 1, 2, 3, etc.

What am I doing wrong?

Using TexLive 2020 and XeLaTeX on Ubuntu.

MWE:

\documentclass[11pt,fleqn,letterpaper,twoside,openright,spanish]{book}
\usepackage{xsim}

% SET UP THE 'xsim' PACKAGE \xsimsetup{ exercise/print = true, print-solutions/headings = false, }

% DEFINE CUSTOM EXERCISE TYPE: MEDITATIONS \DeclareExerciseType{meditation}{% exercise-env = medquest , solution-env = medans , exercise-name = Meditation Question , solution-name = Meditation Answer , exercise-template = default , solution-template = default , the-counter = \thesection.\arabic{medquest}, }

% DEFINE CUSTOM EXERCISE TYPE: THOUGHT EXPERIMENTS \DeclareExerciseType{thoughtexperiment}{% exercise-env = thoughtexpquest , solution-env = thoughtexpans , exercise-name = Thought Experiment Question , solution-name = Thought Experiment Answer , exercise-template = default , solution-template = default , the-counter = \thechapter-\arabic{thoughtexpquest}, }

% DOCUMENT BEGINS \begin{document}

\setcounter{chapter}{13}

\section{Meditative stuff}

Text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text.

% EXERCISES: MEDITATIONS \begin{medquest} What is the sound of one hand clapping? \end{medquest} % \begin{medans} If you have to answer, you shouldn't ask! \end{medans}

\begin{medquest} What walks on three legs? \end{medquest} % \begin{medans} A lame dog. \end{medans}

% EXERCISES: THOUGHT EXPERIMENTS \section{Thoughtful stuff}

Text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text.

\begin{thoughtexpquest} Imagine LaTeX were easy. \end{thoughtexpquest} % \begin{thoughtexpans} Yay! \end{thoughtexpans}

% PRINT ANSWERS \newpage \printsolutionstype{meditation}

\newpage \printsolutionstype{thoughtexperiment}

\end{document}

1 Answers1

2

In v0.20 (and newer) your example does what you expect it to. Also, undefined parameters do through an error if used.

Prior to v0.20 the-counter is not a parameter that can be set in \DeclareExerciseType. Up to and including v0.19b xsim just ignores such settings.

Instead, the-counter is an option and to be set in \xsimsetup for the corresponding exercise type (and after the definition of the type):

\xsimsetup{
  medquest/the-counter = \thesection.\arabic{medquest} ,
  thoughtexpquest/the-counter = \thechapter-\arabic{thoughtexpquest}
}

Alternatively one can do the classic thing and redefine the corresponding commands:

\renewcommand*\themedquest{\thesection.\arabic{medquest}}
\renewcommand*\thethoughtexpquest{thechapter-\arabic{thoughtexpquest}}

BTW and I don't know if you're aware of this: you are setting exercise/print = true which would only affect the exercise type exercise so it does nothing in your MWE. The same for your unused commands like \printexercises which will only print exercises of type exercise because you've chosen \XSIMprint{exercise}. They are superfluous in the MWE.

cgnieder
  • 66,645
  • The addition to \xsimsetup you mention produces an error for me: LaTeX3 Error: The key 'xsim/medquest/the-counter' is unknown and is being(LaTeX3) ignored. }. I'll be updating my MWE in a sec. – Gil Williams Jan 04 '21 at 09:26
  • Good catch ẁith exercise/print = true. Much appreciated! – Gil Williams Jan 04 '21 at 09:27
  • @GilWilliams Please undo the change to your question as it makes my answer nonsense… you need to set the option after you declare the new type, of course – cgnieder Jan 04 '21 at 09:40
  • My apologies - that didn't occur to me! I've restored the question to its original state as much as I can. Quite right about where I'm trying to declare the new code - didn't think I could use \xsimsetup more than once. All is working now, much obliged! – Gil Williams Jan 04 '21 at 09:48
  • @GilWilliams thanks :) I added a hint about the order – cgnieder Jan 04 '21 at 09:50
  • A bit off-topic, but I notice you put spaces before all your commas, here and in the manual. What's the advantage of that? – Gil Williams Jan 04 '21 at 10:02
  • @GilWilliams no advantage. I just find it easier to read. Spaces ar trimmed around values so they don't matter at the beginning or end of a value. – cgnieder Jan 04 '21 at 10:04