我正在排版竞赛试卷,我想满足多项选择题的一个非常具体的要求:五个选项,每个选项都有大写字母选项标签,所有选项都位于大小相同的圆圈中,标签位于圆圈的中心,并且所有选项都与问题文本悬挂缩进对齐。我花了一段时间,但到目前为止,我已经结合了以下主题中的(优秀、详细和干净的)解决方案:
因此我有以下 MWE:
\documentclass[preview, class=exam,varwidth=true]{standalone}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{tikz}
\newcommand*\circled[1]{\tikz[baseline=(char.base)]{%
\node[shape=circle, draw, minimum size=1.5em, inner sep=0pt, label={center:#1}, thick] (char) {#1};}}
\renewcommand\choicelabel{%
\circled{\thechoice}}
\renewcommand{\questionshook}{%
\settowidth{\leftmargin}{0pt}}
\renewcommand{\choiceshook}{%
\settowidth{\leftmargin}{W.\hskip\labelsep\hskip 0em}}
\begin{document}
\begin{questions}
\begin{EnvUplevel}
Welcome to the competition.
\end{EnvUplevel}
\question This is an example of a question.
\begin{choices}
\choice This is Choice A.
\choice This is Choice B.
\choice This is Choice C.
\choice This is Choice D.
\choice This is Choice E.
\end{choices}
\end{questions}
\end{document}
问题是,圆圈现在似乎超出了问题文本的悬挂缩进,并且有点太靠左了,如我添加的黑线所示mspaint
。我希望圆圈的左边缘重合恰恰带有问题文本的悬挂缩进;我该如何做呢?
答案1
这是建议。我只更改了
\renewcommand{\choiceshook}{\settowidth{\leftmargin}{\circled{W}.\hskip\labelsep\hskip 0em}}
更改缩进。非常感谢 Torbjørn T. 指出我之前误读了一个要求。
\documentclass[preview, class=exam,varwidth=true]{standalone}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{tikz}
\newcommand*\circled[1]{\tikz[baseline=(char.base)]{%
\node[shape=circle, draw, minimum size=1.5em, inner sep=0pt , thick] (char) {#1};}}
\renewcommand\choicelabel{\circled{\Alph{choice}}}
\renewcommand{\questionshook}{%
\settowidth{\leftmargin}{0pt}}
\renewcommand{\choiceshook}{\settowidth{\leftmargin}{\circled{W}.\hskip\labelsep\hskip 0em}}
\begin{document}
\begin{questions}
\begin{EnvUplevel}
Welcome to the competition.
\end{EnvUplevel}
\question This is an example of a question.
\begin{choices}
\choice This is Choice A.
\choice This is Choice B.
\choice This is Choice C.
\choice This is Choice D.
\choice This is Choice E.
\end{choices}
\end{questions}
\end{document}