Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am writing a document in the exam class. For question with multiple parts (a), (b),... you are supposed to use the parts environment. Using it works fine, until I add a solution to the question that also contains a parts environment.

The document compiles to the correct result, but I see LaTeX Warnings in the log (which is annoying because vim will show them to me every time!):

LaTeX Warning: Label `part@2@1' multiply defined.
LaTeX Warning: Label `part@2@2' multiply defined.
.....
LaTeX Warning: There were multiply-defined labels.

I remember that this used to work. Am I doing something wrong here?

A minimal working example would be:

\documentclass[letterpaper, 12pt, answers]{exam}
\begin{document}
\begin{questions}
\question The exam document class defines labels for parts.
\begin{parts}
\part Are these labels unique for you?
\part Why are they not unique for me?
\end{parts}

\begin{solution}
\begin{parts}
\part Maybe, I don't know.
\part That's my questions.
\end{parts}
\end{solution}
\end{questions}
\end{document}
share|improve this question
    
@PeterJansson: Please also consider viewing the tags & title when reviewing a post. See the recent plight Re-tagging when editing question! –  Werner Feb 18 '13 at 22:22
    
Are you using \label at all? If not, using \def\label#1{} in your document preamble will remove that functionality and remove the warnings. –  Werner Feb 18 '13 at 22:24
    
@Werner the package uses label/ref internally to manage its own links between its structures. –  David Carlisle Feb 18 '13 at 22:26
    
Thanks for the quick replies. @David Deactivating the label function for the whole document does not seem like an option. My documents often contain labeled equations. I also don't want to ignore all multiple label warnings, in case I really assigned the same name twice. –  Stefan Falkner Feb 19 '13 at 0:09

3 Answers 3

up vote 6 down vote accepted

Oops; this is a bug in exam.cls, which is fixed in the betatest version 2.407beta, available from my web page at

http://www-math.mit.edu/~psh/#ExamCls

Either put this version into the directory with your latex file, or else just replace the older version with this one.

This is a bug that was reported to me just a couple of months ago, which is why it's corrected in the betatest version. I hadn't anticipated that people would use a parts environment inside a solution environment (silly me!), and so the labels that are generated by the second parts environment are duplicates of the ones from the first parts environment. This new betatest version doesn't generated those labels when the parts environment is inside of a solution environment.

These labels didn't exist in much older versions of exam.cls, which is why you didn't see this problem earlier.

So: My apologies for the problem, but it's fixed in the betatest version.

share|improve this answer

I always put a solution next to the part they refer to... I don't seem to get those warnings... Don't know if that's an option for you?

\documentclass[letterpaper, 12pt, answers]{exam}
\begin{document}
\begin{questions}
\question The exam document class defines labels for parts.
\begin{parts}
\part Are these labels unique for you?
\begin{solution}
Maybe, I don't know.
\end{solution}
\part Why are they not unique for me?
\begin{solution}
That's my questions.
\end{solution}
\end{parts}

\end{questions}
\end{document}
share|improve this answer
    
Thanks for pointing out that this works. I could consider this as for short answers to those parts, but for longer answers I prefer to have the question not interrupted. –  Stefan Falkner Feb 19 '13 at 20:57

Welcome to tex.sx, it looks like you can just locally disable \label to avoid the duplicates.

\documentclass[letterpaper, 12pt, answers]{exam}
\begin{document}
\begin{questions}
\question The exam document class defines labels for parts.
\begin{parts}
\part Are these labels unique for you?
\part Why are they not unique for me?
\end{parts}

\begin{solution}
\begin{parts}\renewcommand\label[1]{}
\part Maybe, I don't know.
\part That's my questions.
\end{parts}
\end{solution}
\end{questions}
\end{document}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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