7

I am using the exam template and wonder how to count the total number of questions and the total number of marks to provide the totals on a cover sheet (before declaring them)?

Here is what I have. I am sure it is easy, but was not able to find an example or the right commands in the documentation...

Can anybody help?

\documentclass[11pt]{exam}
\RequirePackage{amssymb, amsfonts, amsmath, latexsym, verbatim, xspace, setspace}
\RequirePackage{tikz, pgflibraryplotmarks}
\usepackage[margin=1in]{geometry}

\begin{document} 

% some hearder and student info here, excluded for simplicity

% instructions
\textbf{Instructions:}

% how to count questions and marks to give the totals on a cover sheet?
This exam contains XXX questions, \numpages pages (including the cover) for the total of XXX marks.

\begin{questions}
% Basic question
\addpoints
\question[10] Differentiate $f(x)=x^2$ with respect to $x$.
% Basic question
\addpoints
\question[10] Differentiate $f(x)=x^3$ with respect to $x$.
\end{questions}

\end{document}
1
  • 2
    try : This exam contains \numquestions{} questions, \numpages{} pages (including the cover) for the total of \numpoints{} marks.
    – touhami
    Commented Sep 26, 2015 at 8:15

1 Answer 1

7

Section 4.7 of the exam document reveals that there are some commands as

\numquestions, \numpages, \numpoints amongst others which just print the value of the relevant counter at the end of the document. exam uses a totcounter - like approach.

Note: \numquestions questions will print 2questions, i.e. either use \numquestions{} questions (as proposed by touhami) or \numquestions\ questions to provide the necessary explicit space.

\documentclass[11pt]{exam}
\RequirePackage{amssymb, amsfonts, amsmath, latexsym, verbatim, xspace, setspace}
\RequirePackage{tikz, pgflibraryplotmarks}
\usepackage[margin=1in]{geometry}

\begin{document} 

% some hearder and student info here, excluded for simplicity

% instructions
\textbf{Instructions:}

% how to count questions and marks to give the totals on a cover sheet?
This exam contains \numquestions\ questions, \numpages\ pages (including the cover) for the total of \numpoints\ marks.

\begin{questions}
% Basic question
\addpoints
\question[10] Differentiate $f(x)=x^2$ with respect to $x$.
% Basic question
\addpoints
\question[10] Differentiate $f(x)=x^3$ with respect to $x$.
\end{questions}

\end{document}

enter image description here

3
  • Thanks! I think it is worth pointing out that, at least in my experimentation, \addpoints is only needed once, and must be before the first question you want to add the points of. Is that correct?
    – kcrisman
    Commented Oct 6, 2017 at 0:38
  • @kcrisman: This depends on the setup, I would say
    – user31729
    Commented Oct 6, 2017 at 19:06
  • Can you be more specific? Do you mean the version of the package, or ... ?
    – kcrisman
    Commented Oct 7, 2017 at 1:34

You must log in to answer this question.

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