add tag
topnush
I have some simple code to draw colored circles (thanks to samcarter).  I would like to number them with the numbers 1,2,3,... written in the center of the circles. How can you do that?

```
\documentclass{beamer}

\beamertemplatenavigationsymbolsempty
\setbeamersize{text margin left=10mm,text margin right=5mm}
\setbeamertemplate{frametitle}[default][center]
\usepackage{tikz}

\newcommand{\tikzcircle}[2][red]{\tikz[baseline=-0.5ex]{\fill[{#1},radius=#2] (0,0) circle ;}\hspace{0pt}}%

\def\numcolors{10}
\def\numdots{20}

\pgfmathparse{1/\numcolors}%
\definecolorseries{foo}{hsb}{step}{red!90!black}{\pgfmathresult,0,0}
\resetcolorseries[\numcolors]{foo}%
\pgfmathsetseed{2}

\begin{document}
\begin{frame}
\foreach \x in {1,...,\numdots}{%
\pgfmathrandominteger{\myran}{1}{\numcolors}%
\tikzcircle[{foo!![\myran]}]{8pt}%
}%
\end{frame}
\end{document}`
```
Top Answer
samcarter
You could add the number as a tikz node.

Caveats:

- I had to force the `rgb` colour model for xcolor, otherwise the node had a problem with my hsb colours...

- I'm setting a `minimum width` to make sure there is enough room for 2 digits, this value needs to be adjusted if you want to use more circles. It also means that even without number, the circle will have a certain minimal size. If you don't like this, you can remove the `minimal width` key, but then you need to make sure that our circles are big enough.


```
\documentclass[xcolor={rgb}]{beamer}

\beamertemplatenavigationsymbolsempty
\setbeamersize{text margin left=10mm,text margin right=5mm}
\setbeamertemplate{frametitle}[default][center]
\usepackage{tikz}

\newcommand{\tikzcircle}[3][red]{\tikz[baseline=-0.5ex]{\node[draw={#1}, fill={#1}, circle,text width=#2,minimum width=2.5em,text=black,align=center] at (0,0) {#3};}\hspace{0pt}}%


\def\numcolors{10}
\def\numdots{20}

\pgfmathparse{1/\numcolors}%
\definecolorseries{foo}{hsb}{step}{red!90!black}{\pgfmathresult,0,0}
\resetcolorseries[\numcolors]{foo}%
\pgfmathsetseed{2}

\begin{document}
\begin{frame}
\foreach \x in {1,...,\numdots}{%
\pgfmathrandominteger{\myran}{1}{\numcolors}%
\tikzcircle[{foo!![\myran]}]{12pt}{\x}% 
}%

\tikzcircle[cyan]{12pt}{}% 
\end{frame}
\end{document}
```

![Screen Shot 2020-09-09 at 17.03.37.png](/image?hash=174a02efc848da8f6ec13a78346757f3342093a8ddaf902d60cd5d1bccd91502)

Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.