# How to label shapes in tikz?

I have a for loop in tikz which draws n circles I want to name them A, B, C...etc How do I do that? can I create a char array or something similar and use it within the label {}

also if I do

{$\x*\y$};


the labels appear as 1*1 and 1*2 how can I actually multiply to get labels as 1 and 2.

\foreach \x in {1,...,2}
\foreach \y in {1,...,2}
{
\node[regular polygon, regular polygon sides=6, draw, inner sep=\hex cm] (hex\x*\y*4) at
(\x*\pi*4.2,\y*\pi*1.6 + 0.8*\pi) {};
\node[zoneMaster] at (\x*\pi*4.2,\y*\pi*1.6 + 0.8*\pi) {};
\node[zoneMaster] [minimum size=0.7cm, fill=Black,text=White] at (\x*\pi*4.2,\y*\pi*1.6 + 0.8*\pi) {$\x*\y$};
}

-
Could you turn your snippet into a minimal working examples? This helps people to answer you. – Claudio Fiandrino Feb 21 '13 at 8:05
For the first part of your question \tikz\foreach\l[count=\x from 0]in{A,...,H}\node[circle,draw]at(\x,0){$\l$}; should show the way. Alternatively you can use \let\pgfforAlpha=\pgffor@Alpha (with the appropriate @ catcode change) and then \tikz\foreach\x in{1,...,8}\node[circle,draw]at(\x-1,0){$\pgfforAlpha{\x}$}; – Mark Wibrow Feb 21 '13 at 15:25

You could use \pgfmathsetmacro or \pgfmathtruncatemacro to compute real or integer values:

## Notes:

• The style zoneMaster was not defined so I have defined it to be an empty style.
• The macro \pi is for the greek letter of the mathematical constant, it is not a numerical value. In pgfmath you use pi for the numerical value.

## Code:

\documentclass[10pt]{article}
\usepackage{tikz}
\usetikzlibrary{shapes}

\tikzset{zoneMaster/.style={}}

\begin{document}

\begin{tikzpicture}[scale=0.75]
\foreach \x in {1,...,2}
\foreach \y in {1,...,2}
{
\pgfmathsetmacro{\X}{0.5*\x*pi*4.2}%
\pgfmathsetmacro{\Y}{\y*pi*1.6 + 0.8*pi}%
\pgfmathtruncatemacro{\Label}{\x*\y*4}%
\node[regular polygon, regular polygon sides=6, draw, inner sep=1cm] (hex\Label) at
(\X,\Y) {};
\node[zoneMaster] at (\X,\Y) {};
\node[zoneMaster] [minimum size=0.7cm, fill=black,text=white] at (\X,\Y) {$\x*\y$};
}
\end{tikzpicture}

\end{document}

-
why does \pgfmathsetmacro{} return float value? can I make it integer? – zcqwevb Feb 21 '13 at 8:13
@user494461: Use \pgfmathtruncatemacro to obtain integer values as I have done in the example for the \Label. – Peter Grill Feb 21 '13 at 8:14