1

I use the exercise package for typesetting exercises and questions. After a new part the (sub)question counter is reseted. I would to avoid this but I don't know how.

MVE

\documentclass[11pt]{article}
\usepackage{exercise}

\begin{document}

\begin{Exercise}
\ExePart{Second part}
\Question ABCD
\Question EFGH
\ExePart{Second part}
\Question IJK
\end{Exercise}


\end{document}

1 Answer 1

3

The \Question command eventually executes \@@@Question, which starts up a \list, with parameters \usecounter{Question} and this resets the counter to 0. Also \@InitExePart does the resetting; we need to cope with both.

\documentclass[11pt]{article}
\usepackage{exercise}
\usepackage{etoolbox}

\makeatletter
\patchcmd{\@InitExePart}{\setcounter{Question}{0}}{}{}{}
\patchcmd{\@@@Question}{\usecounter}{\nonresettingusecounter}{}{}
\def\nonresettingusecounter#1{%
  \@nmbrlisttrue
  \def\@listctr{#1}%
}
\makeatother

\begin{document}

\begin{Exercise}
\ExePart{First part}
\Question ABCD
\Question EFGH
\ExePart{Second part}
\Question IJK
\end{Exercise}

\end{document}

enter image description here

You must log in to answer this question.

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