3

I would like to embed some small tikz textcircled numbers within equation lines. In the following example things starts to not be centered when the natural number exceeds 9. How should I modify my \numcircledtikzscriptsize macro which I took from the question Good way to make \textcircled numbers?

\documentclass[a4paper]{article}
\usepackage{amsmath}
\usepackage{array}
\usepackage{tikz}

\newcommand*\numcircledtikzscriptsize[1]{\tikz[baseline=(char.base)]{\node[shape=circle,draw,inner sep=0.5pt] (char) {\scriptsize \bf #1};}}

\begin{document}
\begin{equation*}
\begin{tabular}[t]{cl}
\tikz \node[inner sep=-1.8pt,fill=white,circle] {\numcircledtikzscriptsize{1}};&$y\leq x+1$\\
\tikz \node[inner sep=-1.8pt,fill=white,circle] {\numcircledtikzscriptsize{2}};&$y\leq x+1$\\
\tikz \node[inner sep=-1.8pt,fill=white,circle] {\numcircledtikzscriptsize{3}};&$y\leq x+1$\\
\tikz \node[inner sep=-1.8pt,fill=white,circle] {\numcircledtikzscriptsize{3}};&$y\leq x+1$\\
\tikz \node[inner sep=-1.8pt,fill=white,circle] {\numcircledtikzscriptsize{4}};&$y\leq x+1$\\
\tikz \node[inner sep=-1.8pt,fill=white,circle] {\numcircledtikzscriptsize{5}};&$y\leq x+1$\\
\tikz \node[inner sep=-1.8pt,fill=white,circle] {\numcircledtikzscriptsize{6}};&$y\leq x+1$\\
\tikz \node[inner sep=-1.8pt,fill=white,circle] {\numcircledtikzscriptsize{7}};&$y\leq x+1$\\
\tikz \node[inner sep=-1.8pt,fill=white,circle] {\numcircledtikzscriptsize{8}};&$y\leq x+1$\\
\tikz \node[inner sep=-1.8pt,fill=white,circle] {\numcircledtikzscriptsize{9}};&$y\leq x+1$\\
\tikz \node[inner sep=-1.8pt,fill=white,circle] {\numcircledtikzscriptsize{10}};&$y\leq x+1$\\
\tikz \node[inner sep=-1.8pt,fill=white,circle] {\numcircledtikzscriptsize{11}};&$y\leq x+1$\\
\tikz \node[inner sep=-1.8pt,fill=white,circle] {\numcircledtikzscriptsize{12}};&$y\leq x+1$\\
\end{tabular}
\end{equation*}
\end{document}

enter image description here

4

You are doing the nodes settings twice (E.g. inner sep=-1.8pt), which just makes things very messy. You should use your \numcircledtikzscriptsize as is:

\documentclass[a4paper]{article}
\usepackage{amsmath}
\usepackage{array}
\usepackage{tikz}

\newcommand*\numcircledtikzscriptsize[1]{\tikz[baseline=(char.base)]{\node[shape=circle,draw,inner sep=0.5pt] (char) {\scriptsize \bfseries #1};}}
\begin{document}
\begin{equation*}
    \begin{tabular}[t]{cl}
        \numcircledtikzscriptsize{1}  & $y\leq x+1$ \\
        \numcircledtikzscriptsize{12} & $y\leq x+1$ \\
    \end{tabular}
\end{equation*}
\end{document}

Centered

Also you could use \phantom to set the "max" size, and make them all the same height like so:

\newcommand*\numcircledtikzscriptsize[1]{\tikz[baseline=(char.base)]{\node[shape=circle,draw,inner sep=1pt] (char) {\scriptsize\phantom{77}};\node at (char){\bfseries\scriptsize #1};}}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.