# Tikz - parametrically set node text

I want to have a circle of nodes in tikz, and the text in each node needs to come from an array. How do I achieve this? The following does not work.

\documentclass{article}
\usepackage{tikz}
\begin{document}
\fontsize{14}{21}\selectfont
\tikzstyle{line} = [draw, -stealth, thick]
\begin{tikzpicture}[every node/.append style={circle, text height=2ex, text depth=.25ex, text width=1.5em, text centered, draw=black!80, inner sep=0pt},>=stealth',auto,thick]
\def\names{A, B, C, D, E, F, G, H}
\foreach \a in {1,2,...,8}{
\draw (\a*360/8: 4cm) node (\a) {\names[\a]};
}
\end{tikzpicture}
\end{document}

• This is solved, sorry for the trouble. – user22209 Aug 13 '15 at 2:06

Eventhough you can use a two-variable loop (as you did in your answer), I'd also like to mention the possibility to work with just one variable and use the count=<macro> option (I also changed \tikzstyle for the more appropriate \tikzset):

\documentclass{article}
\usepackage{tikz}

\tikzset{
line/.style={
draw,
-stealth,
thick
}
}

\begin{document}

\fontsize{14}{21}\selectfont
\begin{tikzpicture}[
every node/.append style={
circle,
text height=2ex,
text depth=.25ex,
text width=1.5em,
align=center,
draw=black!80,
inner sep=0pt
},
>=stealth',
auto,
thick
]
\foreach \t [count=\a] in {A,...,H}
{
\draw (\a*360/8: 4cm) node (\a) {\t};
}
\end{tikzpicture}

\end{document}


Done with a new array.

\documentclass{article}
\usepackage{tikz}