# count the number of questions in examdesign

I write somes exams using the examdesign class and others using the exam class. Each has its benefits.

One feature about exam that I really like is the macro \numquestions which counts the numbers of questions (defined by \question) in the exam. I wish this feature existed for examdesign. So I am trying to add it myself. However, I am new to counters.

In examdesign questions are defined by an environment:

\begin{question}
\end{question}


and from my initial reading of counters it should be possible to define a counter that simply counts the number of times this environment is used.

Does one need redefine an environment so that it can be counted? Or can one define a counter that follows a pre-existing environment?

MWE:

\documentclass[10pt]{examdesign}
\usepackage[margin=1in]{geometry}
\usepackage{amsmath}
\SectionFont{\large\bfseries\ttfamily}
\ContinuousNumbering
\Fullpages
\NoKey
\NumberOfVersions{1}

\let\namedata\relax

\begin{document}

\begin{examtop}
This exam is worth all the marbles. It contains \thequestion\ questions.
\end{examtop}

\begin{multiplechoice}[]
\begin{question}
True?
\choice[!]{True.}
\choice{False.}
\choice{Maybe.}
\choice{Dunno.}
\end{question}
\end{multiplechoice}

\begin{question}
What is love?
Baby don't hurt me.
\end{question}

\begin{examclosing}
This exam contained \thequestion\ questions.
\end{examclosing}

\end{document}

• It seems I cannot compile the examdesign class with texlive 2017, but from its source code, it has a counter question that counts the questions. You should be able to access the value with \thequestion. In case you need this number before the last question, the totcount can help with that. – samcarter_is_at_topanswers.xyz Sep 25 '17 at 21:12
• \thequestion will just print "1". Not sure what it is counting - but it is not counting the total number of questions. – invictus Sep 25 '17 at 21:29
• Where did you put it the code? (please use @ in front of my name to ping me) – samcarter_is_at_topanswers.xyz Sep 25 '17 at 22:36
• @samcarter see the updated MWE. \thequestion is put at the beginning and the end of the exam but it makes no difference. – invictus Sep 26 '17 at 0:40

If the total number of questions is enough, you could simply define a new counter and use the etoolbox package to increase this counter for every question.

\documentclass[10pt]{examdesign}
\usepackage[margin=1in]{geometry}
\usepackage{amsmath}
\SectionFont{\large\bfseries\ttfamily}
\ContinuousNumbering
\Fullpages
\NoKey
\NumberOfVersions{1}

\let\namedata\relax

\newcounter{qcount}
\setcounter{qcount}{0}

\usepackage{etoolbox}

\begin{document}

\begin{examtop}
This exam is worth all the marbles. It contains \theqcount\ questions.
\end{examtop}

\begin{multiplechoice}[]
\begin{question}
True?
\choice[!]{True.}
\choice{False.}
\choice{Maybe.}
\choice{Dunno.}
\end{question}
\end{multiplechoice}

\begin{question}
What is love?
Baby don't hurt me.
\end{question}

• @invictus Yes, if you want this don't increment the counter for the question environment, but for multiplechoice – samcarter_is_at_topanswers.xyz Sep 26 '17 at 16:03