2

Question: Is there a way to customize the question numbering for questions within your own "grade range" using the exam document class and maintain the integrity of the question hyperlinks in \partialgradetable?

Edit: I just added the line \renewcommand*{\thequestion}{\the\value{question}} after \setcounter{question}{0} trying to follow an approach outlined in this post. But I still have the same issue.


The code

\documentclass[addpoints]{exam}
\usepackage[
colorlinks=true,
linkcolor=blue]{hyperref}

\begin{document}

\begin{questions}
\begingradingrange{range1}
\question A question.
\question Another questions. 
\question Yet another question.
\endgradingrange{range1}

\setcounter{question}{0}
\renewcommand*{\thequestion}{\the\value{question}}

\begingradingrange{range2}
\question A second question. 
\question Another second question.
\endgradingrange{range2}

\end{questions}

\partialgradetable{range1}

\partialgradetable{range2}

\end{document}

produces the following:

enter image description here

As can be seen, the question counter resets properly, but the hyperlink capability in the tables is destroyed. Even though the third question in range1 shows ?? in the table, if you click on the 3, then you are taken to the third question as you should be; however, if you click on the 1 or 2 in either table, then you are taken to the first or second question in range2, respectively.

Is there a way to set the counter to maintain the integrity of the question hyperlinks in the partial grade tables? That is, clicking on the 1,2,3 in the first table should take me to those questions in range1 while clicking on 1,2 in the second table should take me to those questions in range2. Of course, I'd like to also be able to set the counter to something not necessarily 0 or 1 and still have it work properly. Any ideas?

1 Answers1

1

This will display the numbers desired. I can't guarantee it will work correctly.

\documentclass[addpoints]{exam}
\usepackage[
colorlinks=true,
linkcolor=blue]{hyperref}

\newcounter{myquestion}
\renewcommand{\thequestion}{\arabic{myquestion}}

\begin{document}

\begin{questions}
\begingradingrange{range1}
\stepcounter{myquestion}%
\question A question.
\stepcounter{myquestion}%
\question Another questions. 
\stepcounter{myquestion}%
\question Yet another question.
\endgradingrange{range1}

\setcounter{myquestion}{0}

\begingradingrange{range2}
\stepcounter{myquestion}%
\question A second question.
\stepcounter{myquestion}%
\question Another second question.
\endgradingrange{range2}

\end{questions}

\partialgradetable{range1}

\partialgradetable{range2}

\end{document}

demo


Revised solution incorporating \stepcounter{myquestion} into \question. Note, \question is local to the questions environment.

\documentclass[addpoints]{exam}
\usepackage[
colorlinks=true,
linkcolor=blue]{hyperref}

\newcounter{myquestion}
\renewcommand{\thequestion}{\arabic{myquestion}}

\begin{document}

\begin{questions}
\let\oldquestion=\question
\renewcommand{\question}{\stepcounter{myquestion}\oldquestion}
\begingradingrange{range1}
\question A question.
\question Another questions. 
\question Yet another question.
\endgradingrange{range1}

\setcounter{myquestion}{0}

\begingradingrange{range2}
\question A second question.
\question Another second question.
\endgradingrange{range2}

\end{questions}

\partialgradetable{range1}

\partialgradetable{range2}

\end{document}
John Kormylo
  • 79,712
  • 3
  • 50
  • 120
  • From what I can tell, it seems to work! Since I will be creating numerous questions and several partial grade tables, is there any way to automate the use of \stepcounter{myquestion} as you have used it in your solution (I could manually do it, of course, but that will get tiresome rather quickly)? – Daniel W. Farlow Sep 08 '17 at 19:07
  • The second solution redefines \question to do that. – John Kormylo Sep 09 '17 at 01:25
  • This is fantastic! Thanks so much--fiddling with exam has really motivated me to learn more about the innards of TeX...someday maybe I too can be a wizard. Thanks again. Cheers. :-) – Daniel W. Farlow Sep 09 '17 at 02:14
  • I've toyed with the idea of writing a book titled "Secrets of the LaTeX Illuminati", – John Kormylo Sep 09 '17 at 02:33
  • If you ever decide to write it, let me know--I'll gladly be a reader. – Daniel W. Farlow Sep 09 '17 at 14:24