0

What is the difference between a PGF node's anchor and a PGF node's deferred anchor? the TikZ & PGF manual for version 3.0.1a describes the command \deferredanchor{〈name〉}{〈code〉} thus (p. 1037):

This command declares an anchor named 〈name〉. It works like \anchor. However, unlike for anchors declared by \anchor, 〈name〉 will not be expanded during the shape declaration (i.e. not during \pgfdeclareshape). Rather, the 〈name〉 is expanded when the node is actually used (with \pgfnode or more likely with \node). This may be useful if the anchor name is context dependent (depending, for example, on the value of a key).

I'll repeat:

unlike for anchors declared by \anchor, 〈name〉 will not be expanded during the shape declaration

However the description of the \anchor{〈name〉}{〈code〉} command reads (p. 1036):

Unlike for saved anchors, the 〈code〉 will not be executed each time a node is declared. Rather, the 〈code〉 is only executed when the anchor is specifically requested; either for anchoring the node during its creation or as a position in the shape referenced later on.

So what's the difference? Neither command is executed when the node is declared, but rather when it is explicitly requested upon creation or use.

  • 1
    For packages such as tqft, there are nodes with various number of anchors (see page 11 of its manual). This is where \deferredanchor kicks in. – Symbol 1 Jul 23 '17 at 13:07
  • @Symbol1: Sorry, I don't get it. Also, why does the description for the \deferredanchor command I quoted above says: 'unlike for anchors declared by \anchor, 〈name〉 will not be expanded during the shape declaration'? Are anchors expanded during shape declaration? And why does the description for the \anchor command I quoted above says: 'the 〈code〉 will not be executed each time a node is declared.' How many times is a node declared? Only once, no? – Evan Aad Jul 23 '17 at 13:15
  • 2
    You see: the difference is that anchors has fixed name while deferredanchors has its name finalized when a node is created. However, I have to say that I cannot find any usage in my local tex library. (tqft uses different approach) You might want to forget this macro. – Symbol 1 Jul 23 '17 at 13:26
1

Say, you have a shape that has n-many extensions (can't think of a better example now other than regular polygon with varying sides) with different shapes, say, a triangle a circular and something else.

You can't create an anchor for triangle if the shape doesn't have a triangle extension or if there are more than 1 triangles you can't compute it during the definition time. Hence for cases like these, there is an option to defer until the user requests for them. It is very unlikely that you will ever need them.

So what's the difference? Neither command is executed when the node is declared, but rather when it is explicitly requested upon creation or use.

\anchor is well-defined but not prepared. \deferredanchor is not even defined until expanded. Because its name still can depend on what is requested.

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.