![如何创建带有圆圈内选择字母的圆形复选框多项选择考试](https://linux22.com/image/422603/%E5%A6%82%E4%BD%95%E5%88%9B%E5%BB%BA%E5%B8%A6%E6%9C%89%E5%9C%86%E5%9C%88%E5%86%85%E9%80%89%E6%8B%A9%E5%AD%97%E6%AF%8D%E7%9A%84%E5%9C%86%E5%BD%A2%E5%A4%8D%E9%80%89%E6%A1%86%E5%A4%9A%E9%A1%B9%E9%80%89%E6%8B%A9%E8%80%83%E8%AF%95.png)
我找不到任何地方可以获取考试环境,在那里我可以进行带有圆形复选框的多项选择考试,其中选项以字母 A、B、C、D 和 E 表示,这些选项位于复选框内。请帮忙...
答案1
使用一些 Tikz 技巧就可以做到。如果您使用的是oneparcheckboxes
,您所要做的就是修改\checkboxchar
和\checkedchar
命令:
% Make checkbox character a circle with the letter
\checkboxchar{\tikz[baseline={([yshift=-.8ex]current bounding box.center)}]\node[shape=circle,minimum size=8mm,draw] at (0,0) {\thechoice};}
% Make checked box character bold WITH surd
%\checkedchar{\tikz[baseline={([yshift=-.8ex]current bounding box.center)}]\node[shape=circle,minimum size=8mm,draw] at (0,0) {} node at (0,0) {\thechoice\llap{$\surd$}};}
% Make checked box character bold
\checkedchar{\tikz[baseline={([yshift=-.8ex]current bounding box.center)}]\node[shape=circle,minimum size=8mm,draw] at (0,0) {} node at (0,0) {\thechoice};}
但这对于环境不起作用,checkboxes
因为它不使用计数器来跟踪项目。为此,您必须修改环境:
\makeatletter
\renewenvironment{checkboxes}%
{\setcounter{choice}{0}\list{\checkbox@char}%
{%
\settowidth{\leftmargin}{W.\hskip\labelsep\hskip 2.5em}%
\def\choice{%
\if@correctchoice
\color@endgroup \endgroup
\fi
\stepcounter{choice}
\item[\checked@char]
\do@choice@pageinfo
} % choice
\def\CorrectChoice{%
\if@correctchoice
\color@endgroup \endgroup
\fi
\ifprintanswers
% We can't say \choice here, because that would
% insert an \endgroup.
% 2016/05/10: We say \color@begingroup in addition to
% \begingroup in case \CorrectChoiceEmphasis involves color
% and the text exactly fills the line (which would
% otherwise create a blank line after this choice):
% 2016/05/11: We leave hmode if we're in it,
% i.e., if there's no blank line preceding this
% \CorrectChoice command. (Without this, the
% \special created by a \color{whatever} command that might
% be inserted by \CorrectChoice@Emphasis would be appended
% to the previous \choice, which could cause an extra
% (blank) line to be inserted before this \CorrectChoice.)
% Since \par and \endgraf seem to cancel \@totalleftmargin
% (for reasons I don't understand), we'll do the following:
% Motivated by the def of \leavevmode,
% \def\leavevmode{\unhbox\voidb@x}
% we will now leave hmode (if we're in hmode):
\ifhmode \unskip\unskip\unvbox\voidb@x \fi
\begingroup \color@begingroup \@correctchoicetrue
\CorrectChoice@Emphasis
\stepcounter{choice}
\item[\checked@char]
\else
\stepcounter{choice}
\item[\checked@char]
\fi
\do@choice@pageinfo
} % CorrectChoice
\let\correctchoice\CorrectChoice
\labelwidth\leftmargin\advance\labelwidth-\labelsep
\topsep=0pt
\partopsep=0pt
\checkboxeshook
}%
}%
{\if@correctchoice \color@endgroup \endgroup \fi \endlist}
\makeatother
现在来看看 MWE:
\documentclass[a4paper,12pt,answers]{exam}
\usepackage{tikz}
\makeatletter
\renewenvironment{checkboxes}%
{\setcounter{choice}{0}\list{\checkbox@char}%
{%
\settowidth{\leftmargin}{W.\hskip\labelsep\hskip 2.5em}%
\def\choice{%
\if@correctchoice
\color@endgroup \endgroup
\fi
\stepcounter{choice}
\item[\checked@char]
\do@choice@pageinfo
} % choice
\def\CorrectChoice{%
\if@correctchoice
\color@endgroup \endgroup
\fi
\ifprintanswers
% We can't say \choice here, because that would
% insert an \endgroup.
% 2016/05/10: We say \color@begingroup in addition to
% \begingroup in case \CorrectChoiceEmphasis involves color
% and the text exactly fills the line (which would
% otherwise create a blank line after this choice):
% 2016/05/11: We leave hmode if we're in it,
% i.e., if there's no blank line preceding this
% \CorrectChoice command. (Without this, the
% \special created by a \color{whatever} command that might
% be inserted by \CorrectChoice@Emphasis would be appended
% to the previous \choice, which could cause an extra
% (blank) line to be inserted before this \CorrectChoice.)
% Since \par and \endgraf seem to cancel \@totalleftmargin
% (for reasons I don't understand), we'll do the following:
% Motivated by the def of \leavevmode,
% \def\leavevmode{\unhbox\voidb@x}
% we will now leave hmode (if we're in hmode):
\ifhmode \unskip\unskip\unvbox\voidb@x \fi
\begingroup \color@begingroup \@correctchoicetrue
\CorrectChoice@Emphasis
\stepcounter{choice}
\item[\checked@char]
\else
\stepcounter{choice}
\item[\checked@char]
\fi
\do@choice@pageinfo
} % CorrectChoice
\let\correctchoice\CorrectChoice
\labelwidth\leftmargin\advance\labelwidth-\labelsep
\topsep=0pt
\partopsep=0pt
\checkboxeshook
}%
}%
{\if@correctchoice \color@endgroup \endgroup \fi \endlist}
\makeatother
% Make checkbox character a circle with the letter
\checkboxchar{\tikz[baseline={([yshift=-.8ex]current bounding box.center)}]\node[shape=circle,minimum size=8mm,draw] at (0,0) {\thechoice};}
% Make checked box character bold WITH surd
%\checkedchar{\tikz[baseline={([yshift=-.8ex]current bounding box.center)}]\node[shape=circle,minimum size=8mm,draw] at (0,0) {} node at (0,0) {\thechoice\llap{$\surd$}};}
% Make checked box character bold
\checkedchar{\tikz[baseline={([yshift=-.8ex]current bounding box.center)}]\node[shape=circle,minimum size=8mm,draw] at (0,0) {} node at (0,0) {\thechoice};}
\begin{document}
\begin{questions}
\question
Blah blah
\begin{checkboxes}\choice one
\choice two
\CorrectChoice three
\end{checkboxes}
\question
Blah blah
\begin{oneparcheckboxes}
\choice one
\choice two
\CorrectChoice three
\end{oneparcheckboxes}
\end{questions}
\end{document}
这将显示为: