TransWikia.com

How to display the correct choice in red color in exam class?

TeX - LaTeX Asked by user61681 on February 14, 2021

 documentclass{exam}
   printanswers
    begin{document}
    begin{questions}
    question Sample Question 1
    begin{choices}
    choice Option1
    choice Option2
    choice Option3
    correctchoice Option4
    end{choices}
    question Sample Question 2
    begin{choices}
    choice Option1
    choice Option2
    correctchoice Option3
    choice Option4
    end{choices}
    end{questions}
    end{document}

With the printanswerscommand, correct choice gets bold. Instead of making it bold, is it possible to display the correct choice in red color font? Any help will be highly appreciated. Thanks.

One Answer

The class provides the macro CorrectChoiceEmphasis for that (section 5.7 of the manual). The default definition is

CorrectChoiceEmphasis{bfseries}

so you can write

usepackage{xcolor}
CorrectChoiceEmphasis{color{red}bfseries}

for boldface, red text (or remove bfseries if you only want the text in red).

documentclass{exam}

usepackage{xcolor}
CorrectChoiceEmphasis{color{red}bfseries}

printanswers

begin{document}

begin{questions}

question Sample Question 1
begin{choices}
choice Option1
choice Option2
choice Option3
correctchoice Option4
end{choices}

question Sample Question 2
begin{choices}
choice Option1
choice Option2
    correctchoice Option3
choice Option4
end{choices}

end{questions}

end{document}

enter image description here

Correct answer by campa on February 14, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP