TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using the exam class (with the addpoints option) to create assignments, and I want to create some bonus questions. I have a customized question format that looks like this:

\qformat{Question \thequestion: [\totalpoints]}

which works fine for regular questions.

However, the \totalpoints command doesn't return a value for bonus questions, and so those questions are incorrectly marked as having 0 points.

I hacked this by redefining \qformat (before the bonus questions) to be

\qformat{Question \thequestion: [\totalbonuspoints]}

which works fine. But I'd rather have a single designation that works for all question (bonus or not). How might I do that ?

note: I could have used \thepoints in the definition, but some of my questions have parts, and so \totalpoints is needed to add up the points.

share|improve this question
up vote 11 down vote accepted

Looking at the source of exam.cls there is a if@bonus that you can use to test if you are typesetting a bonus or a regular question. Hacking a bit you can do something like

    [\totalbonuspoints\ bonus points]
    [\totalpoints\ points]

\qformat{Question \thequestion: \thetotalpoints \hfill}
share|improve this answer
oh that is neat. worked like a charm. Thanks ! – Suresh Sep 3 '10 at 5:24

The betatest version of exam.cls creates the command \bonusqformat that does for bonus questions what the command \qformat does for regular questions. You can get a copy of version 2.318beta of exam.cls from this web page. Using that version of exam.cls, you can say

\qformat{Question \thequestion: [\totalpoints]\hfill}
\bonusqformat{Question \thequestion: [\totalbonuspoints]\hfill}


\qformat{Question \thequestion:\dotfill [\totalpoints]}
\bonusqformat{Bonus Question \thequestion:\dotfill [\totalbonuspoints]}

or whatever other variant you like.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.