Document ClassesTotal Points at Top of each Question

Information and discussion about specific document classes and how to create your own document classes.
Post Reply
g_theonion
Posts: 2
Joined: Thu Feb 28, 2013 6:13 am

Total Points at Top of each Question

Post by g_theonion »

I'm writing with the exam document class, and want it to automatically calculate the total points for questions for which there are multiple parts. Not all questions have parts, so I can "add" those up myself. Can I just type:

Code: Select all

\question[99]
Why is this question worth so many points?

\question[\totalpoints]
\begin{parts}
\part[5]
How old are you?
\part[5]
Why?
\end{parts}
And expect to automatically get 10 at the top of the question? This seems to (maybe) be working the first time I compile the document, but then each time I edit it and recompile, the point total keeps getting bigger and bigger.
Any suggestions?

Thanks,
G
Last edited by localghost on Thu Feb 28, 2013 10:03 am, edited 2 times in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

alainremillard
Posts: 45
Joined: Fri Mar 16, 2012 8:22 pm

Total Points at Top of each Question

Post by alainremillard »

Hi

first of all, it will be a lot easier to help you if you provide a Infominimal working example.

Two solutions for you.
  1. The add up occur because \totalpoints count all the points in the question and the questions before. To avoid this problem, simply add \noaddpoints before \question and \addpoints after.

    Code: Select all

    \noaddpoints
    \question[\totalpoints]
    \addpoints
    This also solve an other issue. In your code, you could not remove your first question without getting an error, with this fix you could.
  2. Use the \qformat command from the exam class, see section 4.4 of the exam manual. This command allows you to customize your question style, but the text of the question will start on the next line. Here is a Infominimal working example, you can visualize it by clicking on "Open in writeLaTeX"

    Code: Select all

    \documentclass[addpoints]{exam}
    
    \begin{document}
    
    \begin{questions}
    
    \qformat{Question \thequestion{} : \totalpoints{} \points \hfill}
    
    \question[99]
    Question without parts
    
    \question
    Question with parts
    \begin{parts}
    \part[5] first part
    \part[5] second part
    \end{parts}
    
    \end{questions}
    
    \end{document}

Regards
Alain Rémillard
g_theonion
Posts: 2
Joined: Thu Feb 28, 2013 6:13 am

Re: Total Points at Top of each Question

Post by g_theonion »

Thank you, the second method works well. I can have multiple-part and no-part questions in any order or combination, and get the point totals for each question automatically at the top of each question.
Post Reply