使用xsim
,如何输入包含多个部分(问题)的问题,这样可以为每个部分分配一定数量的分数,并自动计算整个问题的总分数。该软件包eqexam
方便地提供了该功能。
答案1
\documentclass{article}
\usepackage[verbose]{xsim}
\usepackage{bophook}
\newcounter{pagepoints}
\DeclareExerciseEnvironmentTemplate{simple}
{\par\noindent\setcounter{pagepoints}{\numexpr\GetExerciseProperty{points}+\value{pagepoints}}{\large\bfseries\theexercise\ }
}
{[points=\GetExerciseProperty{points}]\par}
\xsimsetup{
exercise/within=section ,
exercise/the-counter = \thesection.\arabic{exercise}
,
exercise/template=simple ,
exercise/name=Example ,
solution/template=red}
\AtBeginPage{\setcounter{pagepoints}{0}}
\begin{document}
\section{Test}
\begin{exercise}[points=2]
Lorem ipsum
\end{exercise}
\begin{exercise}[points=8]
second Lorem
\end{exercise}
\vfill\hfill
[total=\thepagepoints]
\pagebreak
\begin{exercise}[points=13]
Lorem ipsum
\end{exercise}
\begin{exercise}[points=7]
second Lorem
\end{exercise}
\vfill\hfill
[total=\thepagepoints]
\end{document}
输出: