xsim:无法获取自定义练习类型以使用自定义编号

xsim:无法获取自定义练习类型以使用自定义编号

使用 xsim,我定义了两种自定义练习类型,meditationthoughtexperiment。除了自定义编号外,它们似乎工作正常。我试图让它meditation显示为Meditation Question 13.4.7.1(当然,如果它在第 13.4.7 节中),并thoughtexperiment让它显示为Thought Experiment Question 13-1-2,,-3等等)如果它是第 13 章。

但我似乎做错了,因为这两者看起来都只不过是1、、等等23

我究竟做错了什么?

在 Ubuntu 上使用 TexLive 2020 和 XeLaTeX。

梅威瑟:

\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

在 v0.20(及更新版本)中,您的示例按预期运行。此外,如果使用未定义的参数,则会导致错误。

在 v0.20 之前版本中the-counter不是可以在 中设置的参数\DeclareExerciseType。 直到 v0.19b 版本xsim都忽略了此类设置。

相反,the-counter是一个选项,并设置\xsimsetup为相应的练习类型(和类型的定义):

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

或者,也可以做经典的事情并重新定义相应的命令:

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

顺便说一句,我不知道您是否意识到这一点:您正在设置exercise/print = truewhich 只会影响练习类型exercise,因此它不会在您的 MWE 中执行任何操作。对于您未使用的命令,例如\printexerciseswhich 也一样,只会打印类型的练习,exercise因为您选择了\XSIMprint{exercise}。它们在 MWE 中是多余的。

相关内容