0

I'm trying to calculate the total number of questions and total marks based on an exam paper I'm currently writing.

My MEW:

\documentclass[10pt]{exam}

\begin{document}

\section*{Section 1}
This section has 3 questions from Question 1-3 with a total marks of 3.

\begin{questions}

\question[1] Q1

\question[1] Q2

\question[1] Q3

\section*{Section 2}
\uplevel{This section has 3 questions from Question 4-6 with a total marks of 5}

\question[]
\begin{parts}
    \part[1] Q4 Part a. 
    \part[1] Q4 Part b.
\end{parts}

\question[]
\begin{parts}
    \begin{subparts}
        \subpart[1]
        \subpart[1]
    \end{subparts}
\end{parts}

\question[1]
Q6

\end{questions}
\end{document}

I'm trying to make the following lines dyanmic.

This section has 3 questions from Question 1-3 with a total marks of 3. %Section 1

This section has 3 questions from Question 4-6 with a total marks of 5 % Section 2

So that as my paper changes in terms of questions and marks, the above lines will change reflecting the paper.

I've tried to use counters,and changed each question to aquestion and bquestion but they don't give me the desired results I want.

\newtotcounter{a} 
\setcounter{a}{0}
\newcommand{\aquestion}[0]{\stepcounter{a}\question}

\newtotcounter{b} 
\setcounter{b}{0}
\newcommand{\bquestion}[0]{\stepcounter{b}\question}

Further note*

I've also used \begingradinginrange{} \numqinrange but it doesn't give me the desired results of:

a) How many questions there are? b) What are the question numbers i.e 1-3 or 4-6 etc c) Total marks for those sections.

3

1 Answer 1

1

I found the answer I need.

This section has \numqinrange{myrange} questions from Question \firstqinrange{myrange}-\lastqinrange{myrange} with a total marks of \pointsinrange{myrange}

As long as I place the \begingradinginrange{myrange} and \endgradinginrange{myrange} I was able to make it dynamic.

Here is the full code:

\documentclass[10pt,addpoints]{exam}

\begin{document}

\section*{Section 1}
This section has \numqinrange{myrange} questions from Question \firstqinrange{myrange}-\lastqinrange{myrange} with a total marks of \pointsinrange{myrange}

\begin{questions}
    
\begingradingrange{myrange}

\question[1] Q1

\question[1] Q2

\question[1] Q3
\endgradingrange{myrange}

\section*{Section 2}
\uplevel{This section has \numqinrange{myrange1} questions from Question \firstqinrange{myrange1}-\lastqinrange{myrange1} with a total marks of \pointsinrange{myrange1}}

\begingradingrange{myrange1}
\question[]
\begin{parts}
    \part[1] Q4 Part a. 
    \part[1] Q4 Part b.
\end{parts}

\question[]
\begin{parts}
    \begin{subparts}
        \subpart[1]
        \subpart[1]
    \end{subparts}
\end{parts}

\endgradingrange{myrange1}

\end{questions}
\end{document}
2
  • 3
    Fine :) // Can you please include the required package(s) in your post, via the Edit-button? This way more people can re-use your findings later. Thanks
    – MS-SPO
    Apr 20 at 10:52
  • @MS-SPO, you can test it out and see if it work from your end :). I'm learning quiet a lot from this forum. I still have 1 problem.
    – Alan Jones
    Apr 20 at 11:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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