xsim
我正在尝试使用基于预定义模板的一些自定义模板来编写以下文档:
\documentclass{scrartcl}%
\usepackage{lipsum}
\usepackage{xsim,mdframed}%
\xsimsetup{solution/print=true}
\DeclareExerciseEnvironmentTemplate{mtmargin}
{%
\trivlist
\item[\llap{%
\smash{%
\tabular[t]{@{}r@{\hspace{.67em}}}
{\large \sffamily \bfseries \GetExerciseProperty{counter}}
\IfExercisePropertySetT{points}{%
\tabularnewline
\sffamily \itshape (%
\printgoal{\GetExerciseProperty{points}}%
\GetExercisePropertyT{bonus-points}{+\printgoal{#1}}%
\,\XSIMtranslate{point-abbr}%
)%
}%
\endtabular
}%
}]\relax
}%
{\endtrivlist}
\DeclareExerciseEnvironmentTemplate{mtrunin-sol}{%
%\vspace{-1\baselineskip} %% LINE 1
\mdframed \noindent
{\sffamily \bfseries \XSIMmixedcase{\GetExerciseName}.\hspace{1em}}%
}
{
\endmdframed
\par \vspace{\baselineskip} %% LINE 2
}
\SetExerciseParameters{exercise}{
exercise-template=mtmargin,
solution-template=mtrunin-sol,
}
\begin{document}
\begin{exercise}[points=99]
\lipsum[1]
\end{exercise}
\begin{solution}
\lipsum[2]
\end{solution}
\begin{exercise}[points=99]
\lipsum[3]
\end{exercise}
\begin{solution}
\lipsum[4]
\end{solution}
\begin{exercise}[points=99]
\lipsum[5]
\end{exercise}
\begin{solution}
\lipsum[6]
\end{solution}
\end{document}
我在练习和解决方案之间得到了一个不必要的垂直空间,我不知道它从何而来。可以通过引入“LINE 1”(在上面的代码中已注释)轻松修复它,但这并不能仅通过创建补丁就将问题“控制住”。此外,如果我插入“LINE 2”,我得到的不是 而是\vspace{\baselineskip}
大致\vspace{2\baselineskip}
。有什么建议可以理解这种行为吗?这个问题与命令有关吗\trivlist
?
答案1
是的,它就是trivlist
。
您可以\topsep
在开始之前将其设置为零\trivlist
:
\DeclareExerciseEnvironmentTemplate{mtmargin}
{%
\setlength{\topsep}{0pt}%
\trivlist
\item[\llap{%
\smash{%
\tabular[t]{@{}r@{\hspace{.67em}}}
{\large \sffamily \bfseries \GetExerciseProperty{counter}}
\IfExercisePropertySetT{points}{%
\tabularnewline
\sffamily \itshape (%
\printgoal{\GetExerciseProperty{points}}%
\GetExercisePropertyT{bonus-points}{+\printgoal{#1}}%
\,\XSIMtranslate{point-abbr}%
)%
}%
\endtabular
}%
}]\relax
}%
{\endtrivlist}
或者使用不同的策略,无需trivlist
:
\DeclareExerciseEnvironmentTemplate{mtmargin}
{%
\noindent\makebox[0pt][r]{\smash{%
\tabular[t]{@{}r@{\hspace{.67em}}}
{\large \sffamily \bfseries \GetExerciseProperty{counter}}
\IfExercisePropertySetT{points}{%
\tabularnewline
\sffamily \itshape (%
\printgoal{\GetExerciseProperty{points}}%
\GetExercisePropertyT{bonus-points}{+\printgoal{#1}}%
\,\XSIMtranslate{point-abbr}%
)%
}%
\endtabular
}%
}%
}%
{}