我可以在 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}