1

According to section 101.5.3 (Command for Declaring New Shapes) of chapter 101 (Nodes and Shapes) of the TikZ & PGF manual for version 3.0.1a (p. 1034), the following code-snippet is the definition of PGF's built-in coordinate node shape.

\pgfdeclareshape{coordinate}{%
    \savedanchor\centerpoint{%
        \pgf@x=.5\wd\pgfnodeparttextbox%
        \pgf@y=.5\ht\pgfnodeparttextbox%
        \advance\pgf@y by -.5\dp\pgfnodeparttextbox%
    }
    \anchor{center}{\centerpoint}
    \anchorborder{\centerpoint}
}

Note the use of the macro \pgfnodeparttextbox. This macro is created automatically by PGF and stores the textbox (a simple TeX box) of the coordinate's label. This textbox is placed such that its lower left corner coincides with the text anchor. If no such anchor is explicitly defined, it is at the origin by default (this is stated in the bottom of p. 1036).

Therefore, I would expect the center of the node to be located at .5(W,H), where W is \pdfnodeparttextbox's width, and H is \pdfnodeparttextbox's total height, i.e. <label height> + <label depth>. However according to the above code, the \pgf@y of the center of the node is at .5*(<label height> - <label depth>).

  • It depends on whether you start measuring from the baseline or the lower left corner of the box. It is very likely to be baseline. – Symbol 1 Jul 23 '17 at 10:55
  • @Symbol1: Isn't \ht the distance from the baseline to the top of the textbox? This is what I gather from this answer. – Evan Aad Jul 23 '17 at 11:11
  • 1
    I guess I should write an answer. – Symbol 1 Jul 23 '17 at 11:30
  • \pgfnodeparttextbox is expected to be an empty box in a coordinate, so all dimensions are 0pt. – Mark Wibrow Jul 24 '17 at 16:14
  • @MarkWibrow: So what is all this needlessly convoluted code for? – Evan Aad Jul 24 '17 at 16:18
2

The manual says

This anchor (text) is used upon creation of a node to determine the lower left corner of the text label (within the private coordinate system of the shape). By default, the text anchor is at the origin, but you may change this.

This is not saying that the lower left corner will coincide the text, the origin. The preceding paragraph might makes more sense if it reads

This anchor (text) is used upon creation of a node to determine the position of the text label (within the private coordinate system of the shape). By default, the text anchor is at the origin, but you may change this.

or

This anchor (text) is used upon creation of a node to determine the left endpoint of the baseline of the text label (within the private coordinate system of the shape). By default, the text anchor is at the origin, but you may change this.


As @percusse suggested in the comment in your another question, you should not take the explanation in the manual too seriously. It might happen that the author changed the implementation but forgot to update counterpart in the manual. Reading the source code you may learn more.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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