4

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.

Mensch
  • 65,388
realjsk
  • 43
  • Related https://tex.stackexchange.com/a/417487/120578... but the question was not really clear there and the answer can be improved – koleygr Mar 04 '18 at 01:07
  • I know there are many way to do it. I was just wondering if xsim has a way to do it. – realjsk Mar 04 '18 at 01:13
  • In such case you can read its documentation. The page 8 of it shows a way like : \begin{exercise}[points=2] Lorem ipsum \end{exercise} . Also in page 10 of this manual talks about the points 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: http://mirrors.rit.edu/CTAN/macros/latex/contrib/xsim/doc/xsim_manual.pdf) – koleygr Mar 04 '18 at 01:44
  • I read those pages, but I still can't see how it can be done with xsim. Can you include a sample code which I can try? – realjsk Mar 04 '18 at 02:53
  • This is a diplicate of https://tex.stackexchange.com/questions/392648/ The problem is known but not yet solved, see the discussion here: https://github.com/cgnieder/xsim/issues/2 – cgnieder Mar 07 '18 at 10:36
  • I've 'reverse duped' here: this question has an answer and is I think clearer than the older one. – Joseph Wright Mar 22 '18 at 17:49

1 Answers1

2
\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:

enter image description here

koleygr
  • 20,105