环境中的点exercise
似乎正好与练习名称和标签的线对齐,如下所示
我如何将其向上留出如下
这种对齐是的典型行为exsheets
。我还希望点括号和文本的格式如上所示。
还有一件事,通过使用包括、、、、和以及和(在标题模板中) ,提供了明确的选项来exsheets
定制点。这些在中的等价物是什么?\SetupExSheets[points]{<options>}
<options>
format
number-format
bonus-format
separate-bonus
pre-bonus
post-bonus
points-pre-code
points-post-code
xsim
\documentclass{book}
\usepackage{xsim}
\begin{document}
\begin{exercise}[subtitle=\rule{1.07\textwidth}{0.3pt}, points=5, bonus-points=1]
Something written here
\end{exercise}
\end{document}
答案1
我与exsheets
默认布局形成对比,只是xsim
使用 a\subsection*
后跟 a\marginpar
作为点。为了改变这一点,你必须定义自己的布局模板。手册中有几个例子可以帮助你入门。下面我展示了另一个例子。我还添加了规则,虽然我猜你在问题中只用了它来演示垂直对齐……
\documentclass{article}
\usepackage{xsim}
\usepackage{needspace,lipsum}
\makeatletter
\DeclareExerciseEnvironmentTemplate{custom}{%
\par\vspace{3.25ex plus 1ex minus .2ex}
\Needspace*{3\baselineskip}%
\noindent\normalfont\large
\textbf{\XSIMmixedcase{\GetExerciseName}\nobreakspace\GetExerciseProperty{counter}}%
\IfInsideSolutionF{%
\GetExercisePropertyT{subtitle}{ {\normalfont\itshape\PropertyValue}}%
}%
\normalsize
\GetExercisePropertyT{points}{%
\marginpar{%
(%
\printgoal{\PropertyValue}%
\GetExercisePropertyT{bonus-points}{~[+\printgoal{\PropertyValue}]}%
)%
}%
}%
\hrulefill % << delete this line if you don't want the rule
\par\vspace{1.5ex plus .2ex}
\@afterindentfalse\@afterheading
}
{}
\makeatother
\xsimsetup{
exercise/template = custom ,
solution/template = custom
}
\begin{document}
\begin{exercise}[points=5, bonus-points=1]
\lipsum[4]
\end{exercise}
\end{document}
从上面的例子来看,得到图中的解决方案 aa 应该不太难——假设编号遵循文档的分段:
\documentclass{article}
\usepackage{xsim,xcolor,needspace}
% filler text:
\usepackage{lipsum}
\makeatletter
\DeclareExerciseEnvironmentTemplate{custom}{%
\par\vspace{3.25ex plus 1ex minus .2ex}
\Needspace*{3\baselineskip}%
\noindent\normalfont\normalsize
\textcolor{blue}{%
\textbf{\XSIMmixedcase{\GetExerciseName}\nobreakspace\GetExerciseProperty{counter}}%
}%
\IfInsideSolutionF{%
\GetExercisePropertyT{subtitle}{ {\normalfont\itshape\PropertyValue}}%
}%
\normalsize
\GetExercisePropertyT{points}{%
\marginpar{%
(%
\printgoal{\PropertyValue}%
\GetExercisePropertyT{bonus-points}{~[+\printgoal{\PropertyValue}]}%
)%
}%
}%
\par\vspace{1.5ex plus .2ex}
\@afterindentfalse\@afterheading
}
{}
\makeatother
\xsimsetup{
exercise/the-counter = \thesubsection.(\Alph{exercise}) ,
exercise/template = custom ,
exercise/name = Question ,
solution/template = custom
}
\begin{document}
\section{Foo}
\subsection{Bar}
\begin{exercise}[points=5, bonus-points=1]
\lipsum[4]
\end{exercise}
\begin{exercise}[points=2, bonus-points=3]
\lipsum[4]
\end{exercise}
\end{document}