I've been making tikz pictures for a while now, and there seem to be a number of different ways to position nodes within a diagram. Absolute coordinates, east/west, left/right, the $ $ things, minimum distance... Although I can find enough information on the internet to somehow get stuff to work, I'm having trouble seeing the big picture. Can anybody explain how all these different methods for node positioning work together, and how the computer actually figures out where the nodes should go?

  • 8
    Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. Perhaps Chapter 16.5 of the TikZ/PGF Manual would be a good starting point to get a systematic overview of how node positioning works?
    – Herr K.
    Commented Sep 27, 2013 at 3:33
  • 1
    You need to differentiate a few things: 1a. The at (<somewhere>) part (or as a key) which hasn’t much to do with nodes. 1b. Absolute and relative (+/++) coordinates which have nothing to do with nodes. 2. The anchors (with the anchor option or internally with above left or right). 3a. Positioning with the deprecated … of options (which internally specifies an at and a transformation). 3b. Positioning with the positioning library and its …=… of … options and the node distance key (which internally specifies an at, an anchor and a transformation). Commented Sep 27, 2013 at 12:09

1 Answer 1


You need to differentiate a few things:

  1. The at (<somewhere) part (or as a key: at={(<somewhere>)}).

    The <somewhere> can be any coordinate specification that is allowed by TikZ.

    This may be an explicit coordinate like

    • (1, 2),
    • (30: 4) or
    • <another node>.<with an anchor>.

    This may also be an implicit coordinate like

    • (xyz cs: x=1, y=2),
    • (xyz polar cs: angle=30, radius=4) or
    • (node cs: name=<another node>, anchor=<with an anchor>).

    The concept of coordinate system and their version (explicit vs implicit) are explained in section 13.2 “Coordinate Systems” on pp. 123ff. of the PGF manual.

    The at part can also be any arbitrary calculations with calc’s $…$ notion which is explained in section 13.5 “Coordinate Calculations” on pp. 134ff. of the PGF manual.

    Furthermore, you can give options at the begin of the coordinate specification which transform the specified coordinate, oftentimes, these are options like scale, shift, xscale and so on. These are the same options that can also be given on a path or a scope.

    But this has nothing specifically to do with nodes because every coordinate on a path can be given in one of the mentioned ways.

    If the node has no specified at part, the current position on the path is used (which is the origin at the start of the path).

    So, the two following paths do the same:

    \path ( 3, 2) coordinate (a)
        + ( 1, 0) coordinate (b)
        + ( 0, 1) coordinate (c)
        + (-1, 0) coordinate (d)
        + ( 0,-1) coordinate (e);
    \coordinate (a) at   (3, 2)
     coordinate (b) at + (right:1)
     coordinate (c) at + (   up:1)
     coordinate (d) at + ( left:1)
     coordinate (e) at + ( down:1);
  2. The anchor=<anchor> option (default: center).

    This specifies a point of the node itself that shall be placed at the at.

    Options like above left and right (from here on called the <somewhere> keys) internally set the anchor (above left sets anchor=south east, right sets anchor=west). If a length is given with this option (above left=1cm) a transformation in that direction is added. With our example, this means that the .south east anchor of the node is placed one centimeter away from the at part in the direction above left (135°).

  3. The <somewhere> of=<another node without an anchor> options (which are deprecated).

    This key simply combine the <somewhere> keys with the at part. You could also write:

    at=(<another node without an anchor>),% the `.center` anchor is used anyway
    <somewhere>=<node distance>

    where <node distance> is the node distance set by the node distance key.

    They also set the anchor to .center but you can change that, of course, if you just use the anchor key after the <somewhere> of keys.

  4. The <somewhere> keys that are enhanced/improved with the positioning library (should really be a default library if you work with a “noded” diagram).

    If the value includes the text of, some magic will happen (otherwise it’s just an ordinary <somewhere>=<dimension> key-value pair, I think).

    I believe the magic is already explained in another answer of mine. In summary: the at part is set (possibly specified with an anchor if an anchor-less node name is given), the anchor is set (which is always center if the on grid option is set), a transformation is also applied (which is dependent of the content of the node distance key (with or without and) and the actual direction (“<somewhere>”)).

  5. The pos key, yet another magical thing.

    If the pos key is used on a node, the node is positioned along a (part of a) path. This is already explained in section 16.8 “Placing Nodes on a Line or Curve Explicitly” in pp. 190ff. of the PGF manual.

    In the same section, the related keys auto and swap as well as sloped and allow upside down are explained and short-cuts for the pos key are listed.

    Section 16.9 “Placing Nodes on a Line or Curve Implicitly” on pp. 193f. explain how that all plays in role if you use the node before the target of a path operator.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .