TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.
share|improve this question
I tried the code in QTikZ and is OK, something must be wrong with your pgf installation. – fabikw Mar 30 '11 at 15:26
That code snippet compiles without errors in my system after suitable completion. Please post the complete version (including \documentclass, relevant packages used, etc.) of the problematic code. – Gonzalo Medina Mar 30 '11 at 15:27
up vote 8 down vote accepted

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).

share|improve this answer
Funny, I tried ($ 1/3*({(vertexA)+(vertexB)+(vertexC)}) $) which doesn't work, while I thought it should. And I was under the impression that you can't nest coordinate calculations (without hiding the inner one in { }). I have to check how TikZ does the parsing in this case... – Martin Scharrer Mar 30 '11 at 16:21
"The problem is that (vertexA)+(vertexB)+(vertexC) is not a coordinate." How should anybody see this? vector + vector == vector! – Nils Mar 30 '11 at 16:48
{} is for factors, right? – Nils Mar 30 '11 at 16:49
@Nils: The {} avoids that the TeX parser is taking the included ) as end of the first (. The same is needed if you have [] inside an optional argument. However, it doesn't work here as I thought. – Martin Scharrer Mar 30 '11 at 17:21
@Nils: I know that and you know that, but does tikz know that? – Jan Hlavacek Mar 30 '11 at 17:41

Jan's answer is perfect. Another possibility is


  \coordinate(vertexA) at (0, 10);
  \coordinate (vertexB) at (5, 8);
  \coordinate(vertexC) at (2.5, 0);

  %\coordinate (centroidCellA) at  ($ 1/3*($(vertexA)+(vertexB)+(vertexC)$) $);
  \coordinate (centroidCellA) at (barycentric cs:vertexA=1 ,vertexB=1,vertexC=1); 

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.