1

First a MWE and its output are as follows.

\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}

enter image description here

Clearly the second line of numbers are as desried. So my question is how to combine the \circled and \newcircled commands on numbers or how to produce a command which atomically uses the \circled command on one-digit numbers and the \newcircled command on two-digit numbers



After @CarLaTeX 's answer, we can have excellent circled numbers with two-digits for footnotes, which maybe the best so far as now. The following is an MWE and its output. Note that you could use LaTeX or PDFLaTeX but not XeTeX or XeLaTeX or LuaLaTeX to compile the file since the microtype package can't be used in XeTeX or XeLaTeX or LuaLaTeX. To use XeTeX or XeLaTeX or LuaLaTeX to compile the file, you can use the fontspec package and the \addfontfeature{LetterSpace=-9.0} command instead (Cf. the third solution here).

\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}

enter image description here

M. Logic
  • 4,214

1 Answers1

4

Use \ifnumcomp from etoolbox to test if the number is greater than 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}

enter image description here

CarLaTeX
  • 62,716