首先,MWE 及其输出如下。
\documentclass{article}
\usepackage{tikz}
%%%define circled command%%%%%%%%%%%%%%
\newcommand*\circled[1]{%
\tikz[baseline=(char.base)]\node[shape=circle,draw,inner sep=0.3pt,text depth=0pt,font=\normalfont,minimum size=6pt] (char) {#1};}
%%%define newcircled command%%%%%%%%%%%%
\usepackage{microtype}
\usepackage{graphics}
\newcommand*\newcircled[1]{\circled{\textls[-70]{\scalebox{0.53}[1]{#1}}}}
\begin{document}
We have circled one-digit numbers and two-digit numbers by the \verb|\circled| command as follows.
\begin{center}
\circled{0} \circled{1} \circled{2} \circled{3} \circled{4} \circled{5} \circled{6} \circled{7} \circled{8} \circled{9} \circled{10} \circled{11} \circled{12} \circled{23} \circled{68}
\end{center}
And we also have circled one-digit numbers by the \verb|\circled| command and two-digit numbers by the \verb|\newcircled| command as follows which are as desired.
\begin{center}
\circled{0} \circled{1} \circled{2} \circled{3} \circled{4} \circled{5} \circled{6} \circled{7} \circled{8} \circled{9} \newcircled{10} \newcircled{11} \newcircled{12} \newcircled{23} \newcircled{68}
\end{center}
\end{document}
显然第二行数字是符合要求的。所以我的问题是如何将\circled
和 \newcircled 命令结合用于数字或者如何生成一个命令,该命令可以原子地\circled
对一位数使用该命令,\newcircled
对两位数使用该命令?
在 @CarLaTeX 回答之后,我们可以出色的带圈数字,带两位数作为脚注,这可能是目前为止最好的。以下是 MWE 及其输出。请注意,您可以使用
LaTeX
或PDFLaTeX
但不能XeTeX
或XeLaTeX
或LuaLaTeX
来编译文件,因为microtype
包不能在XeTeX
或XeLaTeX
或中使用LuaLaTeX
。要使用XeTeX
或XeLaTeX
或LuaLaTeX
来编译文件,您可以改用fontspec
包和\addfontfeature{LetterSpace=-9.0}
命令(参见第三个解决方案)。
\documentclass{article}
\usepackage{tikz}
\usepackage{graphics}%for \scalebox
\usepackage{etoolbox}%for \ifnumcomp
\usepackage{microtype}%for \textls
%%%define circled command%%%%%%%%%%%%%%
\tikzset{circlednode/.style={
circle,
draw,
inner sep=0.1ex,
text depth=0ex,
font=\normalfont,
minimum size=1ex
}
}
\newcommand*\circled[1]{%
\ifnumcomp{#1}{>}{9}{%
% if > 9:
\tikz[baseline=(char.base)]\node[circlednode] (char) {\textls[-70]{\scalebox{0.53}[1]{#1}}};}{%
% if <= 9:
\tikz[baseline=(char.base)]\node[circlednode] (char) {#1};}%
}
%%%footnote number setting%%%%%%%%%%%%%%%
\makeatletter
%make footnote numbers be circled------------------
\renewcommand{\thefootnote}{%
\raisebox{0.25ex}{%
\scalebox{0.7}{\protect\circled{%
\arabic{footnote}}%
}%
}%
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
We have circled one-digit numbers and two-digit numbers by the \verb|\circled| command as follows.
\begin{center}
\circled{0} \circled{1} \circled{2} \circled{3} \circled{4} \circled{5} \circled{6} \circled{7} \circled{8} \circled{9} \circled{10} \circled{11} \circled{12} \circled{23} \circled{68}
\end{center}
\par We can also produce excellent circled numbers with two-digits for footnotes with the help of the \verb|\circled| command, which maybe the best so far as now.
\par Now we test the footnote numbers with two digits\footnote{Test}. Now we test the footnote numbers with two digits\footnote{Test}. Now we test the footnote numbers with two digits\footnote{Test}. Now we test the footnote numbers with two digits\footnote{Test}. Now we test the footnote numbers with two digits\footnote{Test}. Now we test the footnote numbers with two digits\footnote{Test}. Now we test the footnote numbers with two digits\footnote{Test}. Now we test the footnote numbers with two digits\footnote{Test}.Now we test the footnote numbers with two digits\footnote{Test}. Now we test the footnote numbers with two digits\footnote{Test}. Now we test the footnote numbers with two digits\footnote{Test}. Now we test the footnote numbers with two digits\footnote{Test}. Now we test the footnote numbers with two digits\footnote{Test}. Now we test the footnote numbers with two digits\footnote{Test}. Now we test the footnote numbers with two digits\footnote{Test}. Now we test the footnote numbers with two digits\footnote{Test}. Now we test the footnote numbers with two digits\footnote{Test}. Now we test the footnote numbers with two digits\footnote{Test}. Now we test the footnote numbers with two digits\footnote{Test}. Now we test the footnote numbers with two digits\footnote{Test}. Now we test the footnote numbers with two digits\footnote{Test}. Now we test the footnote numbers with two digits\footnote{Test}. Now we test the footnote numbers with two digits\footnote{Test, test, test, test, test, test, test, test, test, test, test, test, test, test, test, test, test, test, test, test, test.}.
\end{document}
答案1
使用\ifnumcomp
frometoolbox
测试数字是否大于 9:
\documentclass{article}
\usepackage{etoolbox}
\usepackage{microtype}
\usepackage{graphics}
\usepackage{tikz}
\tikzset{mynode/.style={
circle,
draw,
inner sep=0.3pt,
text depth=0pt,
font=\normalfont,
minimum size=6pt
}
}
%%%define circled command%%%%%%%%%%%%%%
\newcommand*\circled[1]{%
\ifnumcomp{#1}{>}{9}{%
% if > 9:
\tikz[baseline=(char.base)]\node[mynode] (char) {\textls[-70]{\scalebox{0.53}[1]{#1}}};}{%
% if <= 9:
\tikz[baseline=(char.base)]\node[mynode] (char) {#1};}%
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
We have circled one-digit numbers and two-digit numbers by the \verb|\circled| command as follows.
\begin{center}
\circled{0} \circled{1} \circled{2} \circled{3} \circled{4} \circled{5} \circled{6} \circled{7} \circled{8} \circled{9} \circled{10} \circled{11} \circled{12} \circled{23} \circled{68}
\end{center}
And we also have circled one-digit numbers by the \verb|\circled| command and two-digit numbers by the \verb|\circled| command as follows which are as desired.
\begin{center}
\circled{0} \circled{1} \circled{2} \circled{3} \circled{4} \circled{5} \circled{6} \circled{7} \circled{8} \circled{9} \circled{10} \circled{11} \circled{12} \circled{23} \circled{68}
\end{center}
\end{document}