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

I am getting a weird error while trying to place a node above another node using the below= syntax.

  \node[] (node1) at (0, 0) {Node 1};
    below = 5pt of node1
  ] (node2) {Node 2};

The error message is:

Package PGF Math Error: Unknown operator 'o' or 'of' (in '5pt of node1').

How can I place nodes in relation to other nodes without getting an error message?

share|improve this question
Did you figure this out seconds after posting or did you already know and are posting it as an aid to others? – Loop Space Jan 18 '13 at 14:40
Most definitely as a reference/help to others: blog.stackoverflow.com/2011/07/… I did not find a similar question on tex.sx. – Felix Jan 18 '13 at 14:41
Ask-and-answer is most definitely fine (please see meta.tex.stackexchange.com/q/2943/86 for some site-specific comments on this), but do you think you could polish the question a little? In particular, could you post a MWE which produces the error. – Loop Space Jan 18 '13 at 14:45
Thanks for the suggestion, I've edited and added a MWE. Feel free to edit as well. – Felix Jan 18 '13 at 14:57
up vote 23 down vote accepted

The <placement>=<distance> of <node>.<anchor> syntax only works with the advanced positioning library. The parts

  • distance and
  • of <node>.<anchor> are both optional as
    • .<anchor> is too.

Depending of <placement> the anchor key of the to-be-placed node is internally set according to the following table. The third column shows the default <anchor> if the .<anchor> part is omitted. (The sans-positioning <placement> key is just a better-to-comprehend version of the anchor key.)

 <placement>    anchor        .<anchor>
 above          north         .south
 left           east          .west
 below          north         .south
 right          west          .east
 base left      base east     .base west
 base right     base west     .base east
 mid left       mid east      .mid west
 mid right      mid west      .mid east
 above left     south west    .north east
 above right    south east    .north west
 below left     north west    .south east
 below right    north east    .south west

If no <distance> is given, the value of node distance is taken.

Note that for the four bottom ones the <distance> part can consist of <vertical distance> and <horizontal distance>. (The same is true for the node distance key that is enhanced by the positioning library also.)

The on grid option sets both anchors (the one of the to-be-placed node as well as the referenced .<anchor>) to .center so that the nodes are placed in a grid.

The topics covered by the last two paragraphs are further explained in the PGF manual in section 16.5.3 “Advanced Placement Options”, pp. 185ff.

Example (with positioning library)


  \node (node1) at (0, 0) {Node 1};
  \node[below=5pt of node1] (node2) {Node 2};

Example (without positioning library)

Without the positioning library this can be achieved by combining

  • the old <placement>=<distance> and
  • the at=<node>.<opposite anchor> key,

where <opposite anchor> is the corresponding .<anchor> of the table above.

The correct anchor part is set without the positioning library, too.


  \node (node1) at (0, 0) {Node 1};
  \node[below=5pt,at=(node1.south)] (node2) {Node 2};


enter image description here

share|improve this answer
Very thorough explanation, thanks! – Felix Jan 18 '13 at 15:35

The positioning library is missing:

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.