With xsim
, how to type a problem with several parts (questions) in such a way that a number of points is assigned to each part and the total number of points for the whole problem is calculated automatically. The package eqexam
offers that feature conveniently.
1 Answer
\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}
Output:
\begin{exercise}[points=2] Lorem ipsum \end{exercise}
. Also in page 10 of this manual talks about thepoints
property and in page 13 introduces a command\GetExerciseProperty{}
that can be used with points variable and give you the result you need. If you are the same person with the related question OP (and lost your password or something), your accounts can be (and should be) merged by moderators. (manual is here: mirrors.rit.edu/CTAN/macros/latex/contrib/xsim/doc/…)