admin管理员组

文章数量:1355529

what I would like to achieve are the following

  • the choice label should be without a dot (for example "A The first choice" instead of "A. The first choice");
  • I would like the correct choice (not the choice label) to be underlined and highlighted in green.

Here is the basic code

\documentclass[answers]{exam}
\usepackage{xcolor}

\begin{document}

\begin{questions}
\question My first question with multiple choices.

\begin{choices}

\choice The first choice
\choice The second choice
\choice The third choice
\CorrectChoice The fourth choice

\end{choices}

\end{questions}

\end{document}

Any help?

Thanks in advance


update 1 following the answer by @samcarter_is_at_topanswers.xyz

I would love to have something like that


Update 2:

I've searched around and maybe I found a solution that might work for what I want to achieve.

The only problem is that both hl and ul are beyond the text.

Any help to solve this problem?

\documentclass[answers]{exam}
\usepackage{xcolor}
\usepackage{soulpos}
\usepackage{ragged2e}
\usepackage{showframe}

\ulposdef{\hlul}{%
    \rlap{\textcolor{green}{\rule[-0.75ex]{\ulwidth}{2.5ex}}}%
    \rule[-0.3ex]{\ulwidth}{.1ex}%
}

\renewcommand \thechoice{\Alph{choice}}
\renewcommand \choicelabel{\color{black} \textnormal \thechoice}
\CorrectChoiceEmphasis{\color{black} \bfseries \itshape}

\begin{document}
    
\begin{questions}

\question My first question with multiple choices.
\begin{choices}
\choice The first choice
\choice The second choice
\choice The third choice
\CorrectChoice \hlul{The fourth choice}
\end{choices}

\end{questions}

\hlul{It is a test}

\end{document}

what I would like to achieve are the following

  • the choice label should be without a dot (for example "A The first choice" instead of "A. The first choice");
  • I would like the correct choice (not the choice label) to be underlined and highlighted in green.

Here is the basic code

\documentclass[answers]{exam}
\usepackage{xcolor}

\begin{document}

\begin{questions}
\question My first question with multiple choices.

\begin{choices}

\choice The first choice
\choice The second choice
\choice The third choice
\CorrectChoice The fourth choice

\end{choices}

\end{questions}

\end{document}

Any help?

Thanks in advance


update 1 following the answer by @samcarter_is_at_topanswers.xyz

I would love to have something like that


Update 2:

I've searched around and maybe I found a solution that might work for what I want to achieve.

The only problem is that both hl and ul are beyond the text.

Any help to solve this problem?

\documentclass[answers]{exam}
\usepackage{xcolor}
\usepackage{soulpos}
\usepackage{ragged2e}
\usepackage{showframe}

\ulposdef{\hlul}{%
    \rlap{\textcolor{green}{\rule[-0.75ex]{\ulwidth}{2.5ex}}}%
    \rule[-0.3ex]{\ulwidth}{.1ex}%
}

\renewcommand \thechoice{\Alph{choice}}
\renewcommand \choicelabel{\color{black} \textnormal \thechoice}
\CorrectChoiceEmphasis{\color{black} \bfseries \itshape}

\begin{document}
    
\begin{questions}

\question My first question with multiple choices.
\begin{choices}
\choice The first choice
\choice The second choice
\choice The third choice
\CorrectChoice \hlul{The fourth choice}
\end{choices}

\end{questions}

\hlul{It is a test}

\end{document}

Share Improve this question edited yesterday LastBorn asked Mar 30 at 18:27 LastBornLastBorn 1219 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

You can use

  • \renewcommand{\choicelabel}{\thechoice{}} to remove the period at the end of the label
  • \CorrectChoiceEmphasis{\color{green}} to highlight the correct choice in green

\documentclass[answers]{exam}
\usepackage{xcolor}

\CorrectChoiceEmphasis{\color{green}}
\renewcommand{\choicelabel}{\textcolor{black}{\thechoice{}}}

\begin{document}

\begin{questions}
\question My first question with multiple choices.

\begin{choices}

\choice The first choice
\choice The second choice
\choice The third choice
\CorrectChoice The fourth choice

\end{choices}

\end{questions}

\end{document}


If you compile with lualatex, you could add an underline like this:

% !TeX TS-program = lualatex

\documentclass[answers]{exam}
\usepackage{xcolor}
\usepackage{lua-ul}
\usepackage{luacolor}
\LuaULSetHighLightColor{green}

\makeatletter
\CorrectChoiceEmphasis{\@highLight\@underLine}
\renewcommand{\choicelabel}{\textcolor{black}{\highLight[white]{\underLine[color=white]{\thechoice{}}}}}
\makeatother

\begin{document}

\begin{questions}
\question My first question with multiple choices.

\begin{choices}

\choice The first choice
\choice The second choice
\choice The third choice
\CorrectChoice The fourth choice
\choice test

\end{choices}
\end{questions}
\end{document}

本文标签: Customizing label and choice of exam package in LaTexStack Overflow