Does the PGF command \foreach
provide a simple possibility to get the number of elements iterated?
It has a parameter count
to hold the current element number, so a workaround is to iterate the list once. After execution, the last count is the number of elements in #1
.
\foreach \letter [count=\n] in {#1} {}
% \n now keeps the number of elements.
Can this be achieved without iterating the whole list once?
\foreach
. I suggest changing the title to something like: “Obtaining the length of a list in tikz-pgf” – jmc Nov 29 '13 at 13:16