我最近从 TeXLive 2019 更新到了 TeXLive 2020。将代码从这链接(仅稍作修改)不再起作用。它终止并显示以下错误:
LaTeX Error: Something's wrong--perhaps a missing \item.
完整 mwe:
\documentclass{scrartcl}
\usepackage{xsim}
\usepackage{environ}
\usepackage{enumitem}
\xsimsetup{
exercise/template = default,
exercise/name = Aufgabe,
solution/name = Lösung,
}
% from https://texwelt.de/fragen/23968/xsim-ubung-losung-zusatzlich-kurzlosung
\DeclareExerciseProperty{shortsolution}
\newcommand\printshortsolutions{%
\begin{description}[leftmargin=3cm, style=sameline]
\ForEachUsedExerciseByType{%
\def\ExerciseType{##1}%
\def\ExerciseID{##2}%
\GetExercisePropertyT{shortsolution}%
{%
\item[Kurzlösung ##3] ####1%
}%
}%
\end{description}
}
\NewEnviron{shortsolution}{\SetExpandedExerciseProperty{shortsolution}{\expandonce{\BODY}}}
\begin{document}
\begin{exercise}
This is the exercise
\end{exercise}
\begin{shortsolution}
This is the shortsolution
\end{shortsolution}
\begin{solution}
The Solution
\end{solution}
% works only without this line
\printshortsolutions
\printallsolutions
\end{document}
我认为命令的语法肯定发生了变化,xsim
但我无法在文档中发现它们。
答案1
从 0.19 版(2020/03/16)开始,和xsim
仅在本地设置,以允许嵌套不同类型的练习。因此,不能再在练习之外使用。解决方案是移动\ExerciseType
\ExerciseID
\Set(Expanded)ExerciseProperty
\begin{shortsolution}
This is the shortsolution
\end{shortsolution}
在练习中。
下面的代码演示了这一点,并且摆脱了environ
——不再需要了。
\documentclass{scrartcl}
\usepackage{xsim}
\usepackage{enumitem}
\xsimsetup{
exercise/template = default,
exercise/name = Aufgabe,
solution/name = Lösung,
}
\DeclareExerciseProperty{shortsolution}
\newcommand*\printshortsolutions{%
\begin{description}[leftmargin=3cm, style=sameline]
\ForEachUsedExerciseByType{%
\def\ExerciseType{##1}%
\def\ExerciseID{##2}%
\GetExercisePropertyT{shortsolution}%
{%
\item[Kurzlösung ##3] ####1%
}%
}%
\end{description}
}
\NewDocumentEnvironment{shortsolution}{b}
{\SetExpandedExerciseProperty{shortsolution}{#1}}
{}
\begin{document}
\begin{exercise}
This is the exercise
\begin{shortsolution}
This is the shortsolution
\end{shortsolution}
\end{exercise}
\begin{solution}
The Solution
\end{solution}
\printshortsolutions
\printallsolutions
\end{document}