I need to dynamically create the ids of the nodes in TiKz with a counter, so that I can position the new nodes in terms of the previous ones. The counter is created as follows and gets increased for each new node:
\documentclass[10pt]{article}
\begin{document}
\thispagestyle{empty}
\newcounter{nojobs}\setcounter{nojobs}{0}
The definition of the command that creates the TiKz node dynamically is the following one (this command can get invoked as many times as required):
\newcommand{\job}[7]{
\stepcounter{nojobs}
\node [
regular polygon,
regular polygon sides=3,
fill=headergray,
anchor=north,
shift={(+0.0cm,+0.0cm)},
minimum width=\tipheight,
minimum height=\tipheight,
shape border rotate=90
]
(__job_\value{nojobs})
at
(__job_\the\numexpr\value{nojobs}-1\relax.south)
{};
}
The problem is that, whenever the command is invoked, LaTeX says:
! Undefined control sequence.
\job ...par \par \stepcounter {nojobs} \par \node
- Is this the correct approach for the problem? Any alternative solutions?
- Can the counter variable be used in this way?
- Can the counter variable be decreased and used in the calculation of the previous node ID?