![如何为特殊项目 enumi 和 enumii 在 \item 周围画一个圆圈!](https://linux22.com/image/318393/%E5%A6%82%E4%BD%95%E4%B8%BA%E7%89%B9%E6%AE%8A%E9%A1%B9%E7%9B%AE%20enumi%20%E5%92%8C%20enumii%20%E5%9C%A8%20%5Citem%20%E5%91%A8%E5%9B%B4%E7%94%BB%E4%B8%80%E4%B8%AA%E5%9C%86%E5%9C%88%EF%BC%81.png)
我可以在 enumi 的某些部分周围画圆圈,但是我不能在 enumii 的某些部分周围画圆圈。
\documentclass{article}
\usepackage{refcount}
\usepackage{tikz}
\usetikzlibrary{shapes.misc}
\usetikzlibrary{calc}
\tikzset{
every round node/.style={
draw,
shape=rounded rectangle,
rounded rectangle arc length=180,
inner sep=+.333em,
text depth=+.1ex},
light/.style={fill=none, text=black},
dark/.style={fill=black, text=white}}
\newcommand{\round}[2][]{%
\tikz[baseline]
\node[
every round node,
anchor=base,
#1]{$#2$};}
\begin{document}
\begin{enumerate}
\item\label{1} blabla
\pgfmathtruncatemacro{\Result}{\getrefnumber{1}+1}
\item[\round{\Result}] Step one
\addtocounter{enumi}{1}
\item Step two
\begin{enumerate}
\item\label{2} blabla
%\pgfmathtruncatemacro{\Result}{\getrefnumber{2}+1}!!!! IT IS NOT WORK HERE.
\item[\round{\Result}] Step one
\item blalblabla
\end{enumerate}
\item Step three
\end{enumerate}
\end{document}
答案1
这是一个非常简单的解决方案,只需更新\labelenumi
或\labelenumii
每次你想要一个圆圈,然后将其改回来(\circled
从这里,做了一些小调整)。
\documentclass{article}
\usepackage{refcount}
\usepackage{tikz}
\newcommand*\circled[1]{
\tikz[baseline=(char.base)]{
\node[shape=circle,draw,inner sep=0pt] (char) {#1\strut}
}\kern-3pt
}
\let\oldlabelenumi=\labelenumi
\let\oldlabelenumii=\labelenumii
\begin{document}
\begin{enumerate}
\item\label{1} blabla
\item Step one
\addtocounter{enumi}{1}
\renewcommand{\labelenumi}{\circled{\oldlabelenumi}}
\item Step two
\renewcommand{\labelenumi}{\oldlabelenumi}
\begin{enumerate}
\item\label{2} blabla
\renewcommand{\labelenumii}{\circled{\oldlabelenumii}}
\item Step one
\renewcommand{\labelenumii}{\oldlabelenumii}
\item blalblabla
\end{enumerate}
\item Step three
\end{enumerate}
\end{document}
答案2
这是一个粗暴的方法,使用两个命令
\newcommand{\resulti}{\refstepcounter{enumi}\round{\theenumi}}
\newcommand{\resultii}{\refstepcounter{enumii}\round{\theenumii}}
然后使用
\item[\resulti] Step one
对于外部枚举和
\item[\resultii] Step one
第一个内部的。
代码:
\documentclass{article}
\usepackage{refcount}
\usepackage{tikz}
\usetikzlibrary{shapes.misc}
\usetikzlibrary{calc}
\tikzset{
every round node/.style={
draw,
shape=rounded rectangle,
rounded rectangle arc length=180,
inner sep=+.333em,
text depth=+.1ex},
light/.style={fill=none, text=black},
dark/.style={fill=black, text=white}}
\newcommand{\round}[2][]{%
\tikz[baseline]
\node[
every round node,
anchor=base,
#1]{#2};}
\newcommand{\resulti}{\refstepcounter{enumi}\round{\theenumi}}
\newcommand{\resultii}{\refstepcounter{enumii}\round{\theenumii}}
\begin{document}
\begin{enumerate}
\item\label{1} blabla
%\pgfmathtruncatemacro{\Result}{\getrefnumber{1}+1}
\item[\resulti] Step one
%\addtocounter{enumi}{1}
\item Step two
\begin{enumerate}
\item\label{2} blabla
%\pgfmathtruncatemacro{\Result}{\getrefnumber{2}+1}!!!! IT IS NOT WORK HERE.
\item[\resultii] Step one
\item blalblabla
\end{enumerate}
\item Step three
\end{enumerate}
\end{document}