6

I'm using the exam package to create a mathematics question paper. When printing answers, the \correctchoice command makes the choice letter as well as the text in the choice bold. However, it does not make any mathematic expressions bold.

Is there a way to add this to the document? I think the commands \boldmath and \unboldmath when put around the text will make both normal text and mathematic expressions bold, but I do not know how to "merge" it with the \correctchoice command.

0
7

The best solution would be to use \correctchoice as a hook and tack \boldmath and \unboldmath onto it that way using a formula of \edef and \expandafters that I've yet to grasp/memorize. See How to add a hook to a macro.

In absence of hooking, I would say

\renewcommand{\choiceshook}{%
  \ifprintanswers
    \let\oldchoice\choice
    \let\oldcorrectchoice\correctchoice
    \def\choice{\unboldmath\oldchoice}
    \def\correctchoice{\oldcorrectchoice\boldmath}
  \fi}

\noprintanswers:
enter image description here

\printanswers:
enter image description here

1
  • This works brilliantly. No need for a new command either. Thanks! – Milind Hegde Jun 12 '13 at 11:42
7

You already seem to have answers that will work, but the exam class provides a hook for customizing the correct choices. If you give the command:

\CorrectChoiceEmphasis{\bfseries\boldmath}

then you'll get what you want. The default behavior was created with the command here:

\CorrectChoiceEmphasis{\bfseries}
2
  • If I can believe my eyes, this is a much better solution than mine -- I didn't see anything like this in the manual XD – Sean Allred Jun 17 '13 at 4:27
  • 1
    @SeanAllred: It's in section 5.6 (Customizations) of examdoc.pdf. Section 5 discusses multiple choice questions. – Phil Hirschhorn Jun 17 '13 at 4:33
0

Reading the answers to this question I was able to do it.

Adding

\newcommand{\MyCorrectChoice}[1]{%
   \ifprintanswers
      \CorrectChoice \boldmath#1\unboldmath%
   \else
      \CorrectChoice #1%
   \fi
}

to the preamble fixed my problem.

2
  • What's with the optional argument? – Sean Allred Jun 12 '13 at 11:35
  • You're right, there's no need. I tried to change as little as I could of the answer from that question. I'll edit my answer now. – Milind Hegde Jun 12 '13 at 11:38

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.