The following code gives one good solution for displaying numbers in cricle but it would be better to have the possibility to control the size of the circle. Why ? In the example below you will see that the three numbers in circle do not look pretty when they are ine the same context : in the same paragraph or in one list like in the following code.
So I would like to us the first optional argument so as to do the following things :
- If the first optional argument is 0, then the diameter of the circle is the current automatic one.
- If the first optional argument is one natural number n <> 0, then the diameter of the circle is n times one character width.
- In other case, one error must be raised.
Here is the code to modify...
% Source : http://tex.stackexchange.com/questions/7032/good-way-to-make-pgftextcircled-numbers
\documentclass{article}
\usepackage{enumitem}
\usepackage{tikz}
\newcommand{\pgftextcircled}[2][0]{
\setbox0=\hbox{#2}%
\dimen0\wd0%
\divide\dimen0 by 2%
\begin{tikzpicture}[baseline=(a.base)]%
\useasboundingbox (-\the\dimen0,0pt) rectangle (\the\dimen0,1pt);
\node[
circle,
draw,
outer sep=0pt,
inner sep=0.1ex
] (a) {#2};
\end{tikzpicture}
}
\begin{document}
\begin{description}
\item[Automatic width :] \pgftextcircled{0} , \pgftextcircled{63} , \pgftextcircled{733}
\item[Width = 2 :] \pgftextcircled[2]{0} , \pgftextcircled[2]{63} , \pgftextcircled[2]{733}
\item[Width = 3 :] \pgftextcircled[3]{0} , \pgftextcircled[3]{63} , \pgftextcircled[3]{733}
\end{description}
Lets' try in one list :
\begin{enumerate}[label=\protect{\pgftextcircled[2]{\arabic*}}]
\item Item n°1
\item Item n°2
\item Item n°3
\item Item n°4
\item Item n°5
\item Item n°6
\item Item n°7
\item Item n°8
\item Item n°9
\item Item n°10
\item Item n°11
\item Item n°12
\end{enumerate}
\end{document}
\wd\nodebox\dimexpr\wd\nodebox*#1redefines\wd\nodeboxto be equal to\dimexpr\wd\nodebox*#1. Isn't it ? One secund question.hbox to \wd\nodebox{\hss#2\hss}defines one box of width\wd\nodeboxand content\hss#2\hsswhere\hsshelps to centralize the text. Isn' it ? – projetmbc Nov 05 '11 at 14:23