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

In the PGF/TikZ manual, sometimes I see the option right of=somenode instead of right=of somenode. They look very similar, but the effects are different. The distance between nodes positioned with the latter option is boundary-to-boundary, as stated in the manual. However, with the first option, it seems that the distance is shorter. I couldn't find any explanation of the first option in the manual.

My question is: what is the difference between the two options? Is there any explanation in the manual that I missed?

share|improve this question
A bookkeeping comment: in the v2.10 manual the deprecated above right of= appears on page 192 in the last example of /tikz/swap. – equaeghe Oct 14 '12 at 9:26
up vote 91 down vote accepted

The right of key isn't described in the manual at all (at least I couldn't find it). In fact, those keys are deprecated. The file pgf/frontendlayer/tikz/tikz.code.tex contains the following code:

% The following are deprecated:
\tikzoption{above of}{\tikz@of{#1}{90}}%
\tikzoption{below of}{\tikz@of{#1}{-90}}%
\tikzoption{left of}{\tikz@of{#1}{180}}%
\tikzoption{right of}{\tikz@of{#1}{0}}%
\tikzoption{above left of}{\tikz@of{#1}{135}}%
\tikzoption{below left of}{\tikz@of{#1}{-135}}%
\tikzoption{above right of}{\tikz@of{#1}{45}}%
\tikzoption{below right of}{\tikz@of{#1}{-45}}%
    \expandafter\tikz@extract@node@dist\tikz@node@distance and\pgf@stop%

That is, the center of the new node is placed node distance away from the center anchor of the old node (where only the first number in node distance is used). You can see why this option is deprecated if you try a wide node:

  \node (a) {loooooooooooooooooooooooooooooong};
  \node[right of=a,font=\bfseries,blue] (b) {node b};

example of incorrect positioning

On the other hand right=of would measure the node distance (defaulting to 1cm) from the east anchor of node a to the west anchor of node b:

example of correct positioning

Note that in order to use the right=of ⟨node⟩ syntax, you need to include the TikZ library positioning via \usetikzlibrary{positioning}.

share|improve this answer
Excellent answer. Thank you! – Truong Jan 21 '11 at 5:34
Tip for others new to TikZ like me, "include the TikZ library positioning" requires \usetikzlibrary{positioning} as opposed to something such as \usepackage{tikz-positioning} – Pat Jan 21 '13 at 4:15
@Pat: I added that bit of information to the answer. – Caramdir Jan 21 '13 at 7:12
By default, positioning measures the distance between the borders of the nodes. But, with the on grid option, it measures the distance between the centers of the nodes. – Paul Gaborit Jul 19 '14 at 7:33
WARNING: Using the positioning library will render your images unscalable (if no explicitly nodes are present). This is a huge drawback if tikz is used with tikzscale and should therefore be mentioned... – Dux Feb 22 at 9:57

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.