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 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??

example:

\documentclass[answers]{exam}
\begin{document}

\begin{questions}
\question The question is here.

\begin{choices}
\choice one 
\MyCorrectSmartChoice two 
\choice three

\end{choices}
\end{questions}

\end{document}

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

Need some help on this matter. Thanks!

share|improve this question

1 Answer 1

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[answers]{exam}
% \documentclass{exam}

\usepackage{tikz}
\usetikzlibrary{calc,shapes}

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

\newcommand{\DrawSmartBox}[1][red]{%
    \tikz[overlay,remember picture]{
    \draw[#1]
      ($(bl)+(-1.75em,1em)$) rectangle
      ($(br)+(0.2em,-0.4em)$);}
}

% \MyCorrectSmartChoice:
% #1 optional argument: aspect customization
% #2 mandatory argument: the answer
\newcommand{\MyCorrectSmartChoice}[2][black]{%
  \ifprintanswers
    \CorrectChoice \tikzmark{bl}#2\tikzmark{br}\DrawSmartBox[#1]%
  \else
    \CorrectChoice #2%
  \fi
}
\CorrectChoiceEmphasis{}

\begin{document}

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

\end{document}

With answers option:

enter image description here

Without answers option:

enter image description here

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.