Consider the following LaTeX manuscript featuring a PGF path consisting of two successive diagonal line segments intercepted by a rectangular text node.

      \pgfnode{rectangle}{center}{Hello world}{}{\pgfusepath{stroke}}

The resulting image is


Why is the second line segment not drawn?

If I now change the node's stroke instruction to fill, the following image results:


Where has the first line segment gone?

  • 1
    97.3 The Line-To Path Operation (\pgfpathlineto{<coordinatei>) "This command extends the current path in a straight line to the given <coordinate>. If this command is given at the beginning of path without any other path construction command given before (in particular without a move-to operation), the TEX file may compile without an error message, but a viewer application may display an error message when trying to render the picture." or do not display the line. – Bobyandbob Jul 23 '17 at 19:16
  • I would really suggest that you read about the timer concept before going about these. Without those details, you won't be satisfied with any answer. – percusse Jul 23 '17 at 19:18
  • @Bobyandbob: But the line-to operation is not given at the beginning of a path, but in the middle of it. – Evan Aad Jul 23 '17 at 19:22
  • @percusse: Where can I read about it? – Evan Aad Jul 23 '17 at 19:22
  • 1
    section .96.5.2 – percusse Jul 23 '17 at 20:01

The internals are a bit convoluted but since node is using \pgfusepath all the soft path collected until that point is used and deleted.

And since there is no moveto operation at the beginning of the next path it is not drawn. Check for example


which draws nothing if it is left commented.

| improve this answer | |
  • So the node become part of the first part of the path? – Evan Aad Jul 24 '17 at 7:08
  • @EvanAad No, node path was added to the already waiting list of paths to be drawn and triggered already accumulated path to be used which includes also the line drawn before it. – percusse Jul 24 '17 at 7:20
  • Would you say that it is better to keep path building and node creation separated? Is there any circumstance where it would make sense to intertwine them? – Evan Aad Jul 24 '17 at 7:23
  • @EvanAad I don't think that is the right way of thinking about this. There is no separation. you just add things to the current path and whenever you are ready you give a draw, fill etc. directive and the low level postscript creates objects. There is no conceptual difference in the eyes of lowlevel whether it's node or not. – percusse Jul 24 '17 at 7:39
  • I've done some experimenting, and I feel like the node does become part of the ambient path. Unfortunately there's not enough space in this comment to list my experiment, so I'll add it to my original post and then delete it. You can see it by looking at the delta between the revisions. – Evan Aad Jul 24 '17 at 8:25

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.