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.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to create an alternative to CorrectChoice. That when [answers] command is used it will highlight the correct answer and be printed with the question together. I have seen this command by this link How to box the correct answer in Exam class?. it created a command MyCorrectSmartChoice I am thinking on if the [answers] command will not be included, how will the function(puting the correct answer inside the box) of this particular command be hidden??



\question The question is here.

\choice one 
\MyCorrectSmartChoice two 
\choice three



Then if the [answers] command will be used, it will be emphasized?

Need some help on this matter. Thanks!

share|improve this question

The exam class offers a conditional \ifprintanswers which is explained in the exam documentation section 8.5 Changes depending on whether or not solutions are being printed. So you could change the definition of \MyCorrectSmartChoice in the linked question as follows:

% \documentclass{exam}


\newcommand{\tikzmark}[1]{\tikz[overlay,remember picture] \node (#1) {};}

    \tikz[overlay,remember picture]{
      ($(bl)+(-1.75em,1em)$) rectangle

% \MyCorrectSmartChoice:
% #1 optional argument: aspect customization
% #2 mandatory argument: the answer
    \CorrectChoice \tikzmark{bl}#2\tikzmark{br}\DrawSmartBox[#1]%
    \CorrectChoice #2%


\question What's the question? 
 \choice How should I know?
 \MyCorrectSmartChoice[thick,rounded corners,red]{What's $6\times7$?}


With answers option:

enter image description here

Without answers option:

enter image description here

share|improve this answer

Your Answer


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.