[Tex/LaTex] How to nest coordinate calculations in TikZ


Why does this not work? I'm not using LaTeX and TikZ very much; I don't see it.

\coordinate (Zero)  at (0,0);
\coordinate[label=below:cell a] (vertexA) at (0, 10);
\coordinate[label={above right:cell b}, label={below right:cell c}] 
           (vertexB) at (5, 8);
\coordinate(vertexC) at (2.5, 0);
\coordinate(vertexD) at (12, 4);

\coordinate (centroidCellA) at  ($ 1/3*((vertexA)+(vertexB)+(vertexC)) $);       

I get

! Package pgf Error: No shape named (vertexA is known.

Best Answer

The syntax for coordinate calculations is


The problem is that (vertexA)+(vertexB)+(vertexC) is not a coordinate. You have to tell tikz that you want it to calculate the coordinate at (vertexA)+(vertexB)+(vertexC). This will work:

\coordinate (centroidCellA) at  ($ 1/3*($(vertexA)+(vertexB)+(vertexC)$) $);

(You can nest coordinate calculations).

Related Question