7

I am a new LaTeX user. I already searched through the topic and I have not found an answer yet. I am using the exercise package to build a large Multiple Choice math question set complete with an answer key and full explanations. This is the format of a typical Multiple Choice question:

\item \(\frac{19^2+19}{19}\)

\begin{enumerate}[(A)] % (A), (B), (C), (D),(E)

\item   396

\item  361

\item  38

\item  21

\item  20 

\end{enumerate}

\textbf{Explanation}\par

We may simplify the fraction by separating it into two fractions as follows:\par

\(\frac{19^{2}+19}{19}\)=\(\frac{19^2}{19}+\frac{19}{19}=19+1=20\)\par

\textbf{Answer:E}\par

The number of questions has grown beyond 50 and I have started getting the following error:

! LaTeX Error: Counter too large.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.418 \item I
             f $x=\sqrt{5}{-37}$, then which of the following must be true?
? 

I may be doing something wrong with the alphalph package, so kindly help me resolve this problem. If I were to use the following command, what do I write instead of \thesection and section.

\renewcommand{\thesection}{\alphalph{\value{section}}}

Sorry if this question has already been answered before.

Htown
  • 71
  • 2
    Welcome to TeX.SX! Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with \documentclass{...} and ending with \end{document}. –  Sep 25 '15 at 20:48
  • I don't understand why you redefine \thesection. The problem is \theenumi which is in your case restricted (probably) to the value of 26 at most, unless redefined. Are you using the enumerate package? –  Sep 25 '15 at 20:52
  • Yes, I am using the enumerate package. – Htown Sep 25 '15 at 20:55
  • Christian - Same error again. Just a note that this worked OK for 50 questions, so this error may not be related to \theenumi. Also, I am not looking to change the formatting. \item already gives me a question number - I am only looking to allow it to continue numbering the questions to 200 or so. – Htown Sep 25 '15 at 21:21

2 Answers2

11

This is a short hack, for enumerate package using \AlphAlph as counter output format. (The \foreach is just the loop to generate 50 \item )

In a normal setup, enumerate[(A)] can use only the 26 characters of the Latin alphabet such that \Alph{enumi} would fail if the enumi counter has a value of 27 or greater. To prevent this, the [(A)] output must be changed to use \AlphAlph{\value{enumi}} (for example)

\documentclass{article}

\usepackage{alphalph}
\usepackage{enumerate}
\usepackage{pgffor}


\begin{document}

\renewcommand{\theenumi}{\AlphAlph{\value{enumi}}}

\begin{enumerate} 
\foreach \x in {1,...,50} {%
  \item Question \x 
}
\end{enumerate}
\end{document}

enter image description here

Improved version with enumitem

\documentclass{article}

\usepackage{alphalph}
\usepackage{enumitem}

\makeatletter
\newcommand{\AlphAlphFmt}[1]{\@alphfmt{#1}}  % Define the \AlphAlph wrapper for enumitem 
\newcommand{\@alphfmt}[1]{\AlphAlph{\value{#1}}}  % Internal representation 
\AddEnumerateCounter{\AlphAlphFmt}{\@alphfmt}{AAA} % Register this new format
\makeatother

\newlist{mcenum}{enumerate}{2}
\setlist[mcenum,1]{label={(\AlphAlphFmt*)}}


\usepackage{pgffor}
\usepackage{multicol}

\begin{document}

\begin{multicols}{2}
\begin{mcenum}
\foreach \x in {1,...,60} {%
  \item Question \x 
}
\end{mcenum}
\end{multicols}

\end{document}

enter image description here

  • I'll try a solution with the more flexible enumitem package –  Sep 25 '15 at 21:06
  • Christian - Thanks for the help. I am getting the same error again. Just a note that the existing set up worked OK for 50 questions, so this error may not be related to \theenumi. Also, I am not looking to change the formatting. \item already gives me a question number - I am only looking to allow it to continue numbering the questions to 200 or so. – Htown Sep 25 '15 at 21:25
  • @Htown: The formatting is one thing. If you use Alpha formatting, you will get troubles. Unless you do not show your setup it's not really possible to provide help. The question number is just for the example here, not for production –  Sep 25 '15 at 21:26
  • The file is too long - about 700 lines. How do I upload on here for your review? – Htown Sep 25 '15 at 21:34
  • @Htown: It would be sufficient if you cut some of the questions -- I can put easily dummy questions (the questions themselves aren't the problem, it's the way the enumi counter should be typeset) –  Sep 25 '15 at 21:36
  • May I try emailing the code to you on the address provided on your profile? Or would it be OK to post the code here unformatted? – Htown Sep 25 '15 at 21:44
  • @Htown: You mail it to me... I'll stay online for at least one additional hour to find a solution –  Sep 25 '15 at 21:44
  • Just sent you an email on your profile email address. – Htown Sep 25 '15 at 21:50
  • @Htown: Yes, I received it. I'll look into that file right now –  Sep 25 '15 at 21:52
  • @Htown: You are using nested enumerates, i.e. \begin{enumerate} \item ... \begin{enumerate}... This might fail. And I've run into too deeply nested enumerates, i.e. it seems that there is some \end{enumerate} missing, causing the whole trouble. In order to check this, some questions should be removed and stored back later on –  Sep 25 '15 at 22:07
  • Thanks! Yes, the missing \end{enumerate} was the problem! – Htown Sep 25 '15 at 22:14
  • An unrelated question - Is there a way to automatically store the answer key and explanations in two separate sections toward the end of the document? So, the question set, then the answer key , and then the full explanations – Htown Sep 25 '15 at 22:19
  • @Htown: That's a totally different question, but the options answerdelayed etc. could help –  Sep 25 '15 at 22:26
  • thanks again. Bear with me - These questions are not really exercises, so what if I wanted to remove the text "Exercise 1" in the PDF document. Perhaps replace it with "Set 1" or something similar. – Htown Sep 25 '15 at 22:30
  • @Htown: \renewcommand{\ExerciseName}{Set} in the preamble, I assume. –  Sep 25 '15 at 23:15
  • 1
    Thanks again Christian. Suppose I want to remove the term "Exercise" completely. How would you change the command? Second, you seem to suggest that nested enumerates are not the best way to handle such question sets. What is a better, perhaps more efficient alternative? – Htown Sep 25 '15 at 23:54
  • @Htown: The nesting issue isn't no more a problem since we've detected that a \end{enumerate} was missing. However, the advantages of exercise isn't use here at all: Keep a question (Exercise) in a an Exercise environment and an Answer in an Answer environment and it can be decided later on if the Exercises are shown, or append the answers at the end. Your're using \textbf{Answer:} and this will be always there. I am also not sure about the Explanation part -- is this meant for your students as some kind of hints? Where should it go to? –  Sep 26 '15 at 09:24
0

Similar, one can use for the exam package

\usepackage{alphalph}
\renewcommand{\thepartno}{\alphalph{\value{partno}}}

where partno is the counter number.