# Array indexing does not work for the node label

There is something I cannot understand. I'm using array indexing and it works for determining the radius of the circles and to positioning the nodes. However it does not work as the node content.

\documentclass{standalone}
\usepackage{color}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}

\begin{tikzpicture}
\foreach \x/\a [count=\n] in {0/15,1/345,2/345,3/345}

\end{tikzpicture}
\end{document}


• Why don't you use simply {\n} as label?
– Red
Sep 24, 2013 at 9:17
• ups, I did not realized that would be a solution in the Minimal Working Example (MWE) I prepared. In my real situation I do need to access the vector.
– Sik
Sep 24, 2013 at 9:28
• If you need to count the items in the list, you may want to use the count option of the foreach loop. Sep 24, 2013 at 9:36
• The node content is not a TikZ/pgf formula. You may use \pgfmathparse{...} then \pgfmathresult... Sep 24, 2013 at 9:37
• The solutions offered here work only for numeric arrays. To anybody from the future, if you are looking for a way to index an array for arbitrary content, see: tex.stackexchange.com/q/551501/69346 Jul 21, 2020 at 10:53

Please don't use color with TikZ!! It already loads xcolor.

Paul Gaborit already gave you the answer that a brace pair doesn't necessarily mean a math operation. Here it is just put inside a text box and TikZ doesn't evaluate it. You can either go parsing the math inside a \pgfextra{...} and use \pgfmathresult or you can explicitly define more variables that use the loop variable via evaluate key.

\documentclass[tikz]{standalone}
\usetikzlibrary{calc}
\begin{document}

\begin{tikzpicture}