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 have the following code (stripped down from a much larger one).

(I understand that there are numerous questions (and answers including this excellent one) on relative positioning of nodes, but they do not seem to solve my problem. Before you mark my question as duplicate, please make it sure that it really addresses my issue ie. use relative positioning and not absolute positioning.)




\begin{tikzpicture}[node distance=40.0mm, auto]
  \node[state] (3) {3}; 
  \node[state] (1) [above left=of 3]  {1}; 
  \node[state] (2) [above right=of 3] {2}; 


The output looks like this.

enter image description here

I would like to move node 3 somewhat below its current position. I have tried many ways of doing this using relative positioning (and without using absolute positioning), without success. How do I do this?

share|improve this question
Is a \node (1) [above left=5cm and 1cm of 3] {1}; satisfying your problem? This way you can set the above and the left|right individually from each other. – moospit Aug 22 '14 at 5:27
@moospit Afraid not. I have already seen those answers. I am somewhat determined (perhaps for no reason), to achieve the effect using relative positioning only. – Masroor Aug 22 '14 at 5:29
As you are using \begin{tikzpicture}[node distance=40.0mm], would it be a solution to different to horizontal and vertical node spacing using \begin{tikzpicture}[node distance=40.0mm and 2cm]? (2nd value is vertical spacing) – moospit Aug 22 '14 at 5:34
@moospit Yes, that is acceptable since you do not have to carry out manual positioning for every node you put in. – Masroor Aug 22 '14 at 5:37
For this kind of diagrams, a tikz matrix approach is more suitable where you can declare row separation and column separation in the beginning itself. – Harish Kumar Aug 22 '14 at 6:03

Just to sum up the above comments and get future readers an overview about the discussed answers:



Per node distance definition:

\node (id) [below left=<x-value> and <y-value> of <reference>] {<text>};

Global distance definition:

\begin{tikzpicture}[node distance=<x-value> and <y-value>]
 \node (id) [below left=of <reference>] {<text>};
 % ...
share|improve this answer
Note that this code requires the positioning tikz library. – TonioElGringo Aug 22 '14 at 7:04
Thanks for mentioning that. Updated the answer. – moospit Aug 22 '14 at 7:15

For this kind of diagrams where you are putting many nodes relative to one another, a matrix approach would be more suited. You have to use \usetikzlibrary{matrix} and declare the nodes as the elements of a matrix. The row and column separations, node styles etc can be declared via \tikzset. You can refer to those nodes using the name of the matrix say (m) like (m-1-1) where (m-2-3) 2 is the row and 3 is the column (indices).

Here is a sample code:

\usetikzlibrary{matrix,automata}   %% load the library


  \tikzset{   %%% define the parameters for once
    mstyle/.style={column sep=4cm, row sep=6cm,nodes={state},font=\bfseries},
    line/.style={draw,very thick,blue,-latex},
  \matrix(m)[matrix of nodes,ampersand replacement=\&,mstyle]{
    1 \&  \& 2  \\
      \& 3 \&   \\
    4 \& 5 \& 6  \\
    \draw[line](m-1-1.east)-- (m-1-3.west);


enter image description here

With row sep = 2cm in \mstyle, we get

enter image description here

And with our very technique \\[2cm], we get

\matrix(m)[matrix of nodes,ampersand replacement=\&,mstyle]{
    1 \&  \& 2  \\[2cm]
      \& 3 \&   \\
    4 \& 5 \& 6  \\

enter image description here

For more details, please refer to pgfmanual, page no 654 (in my copy of v3) section 57.

However, I accept that I am not aware of how your final diagram will be. Hence, you are the better judge of choices you have.

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.