有没有办法创建一个枚举列表,其中有一个在切换布尔值时会被圈起来的项目?
我想用它来创建多项选择题测试和解决方案。
答案1
pifont
这是有关包等的快速而肮脏的解决方案\ding{172}
,但是数字的大小并不相同!
\documentclass{article}
\newif\ifcircle
\circletrue
\usepackage{pifont}
\usepackage{enumitem}
\makeatletter
\def\ctext#1{%
\ifcircle %
\ding{\the\numexpr\value{#1}+171}%
\else
\arabic{#1}%
\fi
}
\AddEnumerateCounter{\ctext}{\@ctext}{Second}
\makeatother
\begin{document}
\begin{enumerate}[label={\ctext*}]
\circlefalse
\item First \circletrue
\item Anotherone
\end{enumerate}
\end{document}
和一个 Ti钾Z 解决方案(目前Baseline还未运行)
\documentclass{article}
\newif\ifcircle
\circletrue
\usepackage{tikz}
\usepackage{enumitem}
\newcommand{\drawcircled}[2][0.25cm]{%
\begin{tikzpicture}[node distance=5mm]
\coordinate [xshift=2mm,yshift=2mm] (A) (0,0);%
\draw (A) circle[radius=#1];%
\node (Q) at (A) {#2};%
\end{tikzpicture}%
}
\newcommand{\drawuncircled}[2][0.25cm]{%
\begin{tikzpicture}%
\coordinate [xshift=2mm,yshift=-2mm] (B) (0,0);%
\draw [white] (B) circle[radius=#1];%
\node (B) at (B) {#2};%
\end{tikzpicture}%
}
\makeatletter
\def\ctext#1{%
\bfseries%
\ifcircle %
\protect\drawcircled{\number\value{#1}}%
\else
\protect\drawuncircled{\number\value{#1}}%
\fi
}
\AddEnumerateCounter{\ctext}{\@ctext}{Foo}
\makeatother
\begin{document}
\begin{enumerate}[label={\ctext*}]
\circlefalse%
\item First \circletrue%
\item Anotherone
\item A
\item B
\item C
\item D
\item E
\item F
\item G
\item H
\item I
\item J
\end{enumerate}
\end{document}
答案2
我发现 TeX 命令 \llap 在覆盖某些内容或在页边空白处做标记时非常有用。这种情况的解决方案可能类似于以下代码。注释的两行用于将 \bigcirc 替换为 Tikz 圆圈。长度等应根据字体进行调整。
\documentclass{article}
\parindent=0pt
\renewcommand{\theenumi}{\alph{enumi}}
\def\Correct{\strut\llap{\Large$\bigcirc$\rule{4pt}{0pt}}}
% \usepackage{tikz}
% \def\Correct{\strut\llap{\raisebox{-5pt}{\tikz\draw[thick](0,0)circle(0.3);}\rule{2pt}{0pt}}}
%%%%%%%
\begin{document}
1. Question?
\begin{enumerate}
\item Answer 1
\item\Correct Answer 2
\item Answer 3
\end{enumerate}
\end{document}