我尝试将 exsheets 转换为 xsim,但无法实现 runin。我只是从手册中复制了 runin 模板(http://ftp.math.purdue.edu/mirrors/ctan.org/macros/latex/contrib/xsim/doc/xsim_manual.pdf),但我无法编译它(错误:失控参数?{par \vspace {\baselineskip} \Needspace*{...})。有人知道为什么或如何实现 runin 吗?
这是我的源代码
\documentclass[11pt, a4paper, parskip=full]{scrartcl}
\renewcommand\thesection{\Alph{section}}
\usepackage{xsim}
\xsimsetup{%
exercise/within = subsection ,
exercise/the-counter = \thesubsection.\arabic{exercise}
}
\usepackage{needspace}
\DeclareExerciseEnvironmentTemplate{runin}
{%
\par\vspace{\baselineskip}
\Needspace*{2\baselineskip}
\noindent
\textbf{\XSIMmixedcase{\GetExerciseName}~\GetExerciseProperty{counter}}%
\GetExercisePropertyT{subtitle}{ \textit{#1}} % <<< notice the space
\IfInsideSolutionF{%
\GetExercisePropertyT{points}{%
\marginpar{%
\printgoal{\PropertyValue}%
\GetExercisePropertyT{bonus-points}{+\printgoal{\PropertyValue}}%
\,\IfExerciseGoalSingularTF{points}
{\XSIMtranslate{point}}
{\XSIMtranslate{points}}%
}% }%
}% }
{}
\DeclareExerciseType{problem}{
exercise-env = exercise ,
solution-env = solution ,
exercise-name = Aufgabe ,
solution-name = Aufgabe ,
exercise-template = runin ,
solution-template = runin
}
\begin{document}
\selectlanguage{ngerman}
\section{Aufgaben}
\subsection{subsection}
\begin{exercise}[subtitle=test]
Was ist 1 mal 1?
\end{exercise}
\begin{solution}
1 mal 1 ist 1. siehe \ref{abba}
\end{solution}
\begin{exercise}
Was ist 2 mal 2?
\end{exercise}
\begin{solution}
2 mal 2 ist 4.
\end{solution}
\section{Schwere Aufgaben}
\subsection{subsection}
\begin{exercise}
Was ist 3 mal 3?
\end{exercise}
\subsection{subsection}
\begin{solution}
3 mal 3 ist 9.
\end{solution}
\begin{exercise}
Was ist 4 mal 4?
\end{exercise}
\begin{solution}
4 mal 4 ist 16.
\end{solution}
Lösungen
\printsolutions
\end{document}
答案1
正如xsim
手动的(第 29 页),runin
样式可通过样式文件获取layouts
。使用命令加载此样式文件\loadxsimstyle{layouts}
足以在文档中使用该样式。
梅威瑟:
\documentclass[11pt, a4paper, parskip=full]{scrartcl}
\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage{xsim}
\loadxsimstyle{layouts}
\xsimsetup{%
exercise/within = subsection ,
exercise/the-counter = \thesubsection.\arabic{exercise}
}
\SetExerciseParameters{exercise}{
exercise-name = Aufgabe ,
solution-name = Aufgabe ,
exercise-template = runin ,
solution-template = runin
}
\renewcommand\thesection{\Alph{section}}
\begin{document}
\section{Aufgaben}
\subsection{subsection}
\begin{exercise}[subtitle=test]
Was ist 1 mal 1?
\end{exercise}
\begin{solution}
1 mal 1 ist 1.
\end{solution}
\begin{exercise}
Was ist 2 mal 2?
\end{exercise}
\begin{solution}
2 mal 2 ist 4.
\end{solution}
\section{Schwere Aufgaben}
\subsection{subsection}
\begin{exercise}
Was ist 3 mal 3?
\end{exercise}
\subsection{subsection}
\begin{solution}
3 mal 3 ist 9.
\end{solution}
\begin{exercise}
Was ist 4 mal 4?
\end{exercise}
\begin{solution}
4 mal 4 ist 16.
\end{solution}
Lösungen
\printsolutions
\end{document}
结果:
请注意,原始代码导致的错误是由复制粘贴错误引起的:最后三行中的所有右括号都\DeclareExerciseEnvironmentTemplate
应该放在单独的行上,现在其中两个被%
其他括号行的行尾字符意外注释掉。