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.

6
  • Related tex.stackexchange.com/a/417487/120578... but the question was not really clear there and the answer can be improved
    – koleygr
    Mar 4, 2018 at 1:07
  • I know there are many way to do it. I was just wondering if xsim has a way to do it.
    – realjsk
    Mar 4, 2018 at 1: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: mirrors.rit.edu/CTAN/macros/latex/contrib/xsim/doc/…)
    – koleygr
    Mar 4, 2018 at 1: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 4, 2018 at 2:53
  • This is a diplicate of tex.stackexchange.com/questions/392648 The problem is known but not yet solved, see the discussion here: github.com/cgnieder/xsim/issues/2
    – cgnieder
    Mar 7, 2018 at 10:36

1 Answer 1

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

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .