# tikz center node below 2 other nodes

I want to create a node below 2 other node but place it exactly in the middle of the two nodes. Here's what I have so far...

     \documentclass[12pt]{article}
\thispagestyle{empty}
\usepackage{tikz}
\usepackage{amsfonts}

\begin{document}
\begin{center}
\begin{tikzpicture}[node distance=3cm]
\node (top)          {$\top$};
\node (node1)   [below left of=top]       {\{node1\}};
\node (node2)      [left of=node1] {\{node2\}};
\node (node3) [below right of=top] {\{node3\}};
\node (node4)[right of=node3]         {\{node4\}};
\node (node1node2) [below right of=node2]        {\{node2 , node1\}};
\node (node4node3) [below right of=node3]        {\{node3, node4\}};
\node (bot)   [below left of = node4node3]  {$\bot$};
\draw (top)    -- (node1);
\draw (top)    -- (node2);
\draw (top)    -- (node3);
\draw (top)    -- (node4);
\draw (node4)    -- (node4node3);
\draw (node3)    -- (node4node3);
\draw (node2)    -- (node1node2);
\draw (node1)    -- (node1node2);
\draw (node1node2)    -- (bot);
\draw (node4node3)    -- (bot);

\end{tikzpicture}
\end{center}
\end{document}


The node "bot" is almost but not exactly in the middle of nodes "node1node2" and "node3node4". It should be at the bottom of the picture at the center

-
Welcome! You should provide a complete MWE, for us just copy-paste to reproduce your problem. –  cacamailg May 31 '13 at 21:32
Welcome to TeX.SX! Please add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. –  Jubobs May 31 '13 at 21:40
allright I edited the question. When you compile you will see that the node "bot" on the bottom of the picture is almost but not exactly in the middle AND below nodes "node1node2" and "node4node3" –  polofan May 31 '13 at 22:07

Firstly, I'm not sure of what you want. I understand that you want the last node "bot" in the middle of (node1node2) and (node4node3) but before I would like to know if you want a symmetric graph.

In this case you need to write \node (node4node3) [below left of=node4] instead of \node (node4node3) [below right of=node3].

If the graph is symmetric then the middle is below (top) and there is no problem to place (bot).

If the graph is not symmetric first you can use Peter's method with the libraries calc and positioning but I think you need to avoid the old way to place the nodes. Explanation : Instead of below left of=top you need to write below left= of top.

/tikz/above left (no value) Does the same as anchor=south east. Note that giving both above and left options does not have the same effect as above left, rather only the last left “wins.” Actually, this option also takes an ⟨offset⟩ parameter, but using this parameter without using the positioning library is deprecated. (The positioning library changes the meaning of this parameter to something more sensible.)

The result is not the same because the node distance is not the distance between the centers of the nodes. If you want the same result, you need to use the option on grid.

To get the middle of two nodes, you can avoid the library calc with

  \path (A) -- node [below= 3cm] {$\bot$} (B);


My solution

\documentclass[11pt]{scrartcl}
\usepackage{tikz}
\usetikzlibrary{positioning}

\begin{document}

\begin{center}
\begin{tikzpicture}[node distance=3cm,on grid]
\draw[help lines] (-6,-9) grid (6,1);
\node (top)          {$\top$};
\node (node1)      [below left=  of top]             {\{node1\}};
\node (node2)      [left=        of node1]           {\{node2\}};
\node (node3)      [below right= of top]             {\{node3\}};
\node (node4)      [right=       of node3]           {\{node4\}};
\node (node1node2) [below right= of node2]           {\{node2 , node1\}};
\node (node4node3) [below right= of node3]           {\{node3, node4\}};
\path (node1node2) -- node (bot) [text=red,below=3cm] {$\bot$} (node4node3);
\draw (top)         edge (node1)
edge (node2)
edge (node3)
edge (node4);
\draw (node1node2)  edge (bot)
edge (node1)
edge (node2);
\draw (node4node3)  edge (bot)
edge (node3)
edge (node4);

\end{tikzpicture}
\end{center}
\end{document}


With the next code the graph is symmetric

\begin{center}
\begin{tikzpicture}[node distance=3cm,on grid]
...
\node (node4node3) [below left=  of node4]           {\{node3, node4\}};
...
\end{tikzpicture}
\end{center}


without 'on gridand with the defaultnode distance

\documentclass[11pt]{scrartcl}
\usepackage{tikz}
\usetikzlibrary{positioning}

\begin{document}
\begin{center}
\begin{tikzpicture}
\draw[help lines] (-6,-9) grid (6,1);
\node (top)          {$\top$};
\node (node1)      [below left=  of top]             {\{node1\}};
\node (node2)      [left=        of node1]           {\{node2\}};
\node (node3)      [below right= of top]             {\{node3\}};
\node (node4)      [right=       of node3]           {\{node4\}};
\node (node1node2) [below right= of node2]           {\{node2 , node1\}};
\node (node4node3) [below right= of node3]           {\{node3, node4\}};
\path (node1node2) -- node (bot) [text=red,below=1cm] {$\bot$} (node4node3);
\draw (top)         edge (node1)
edge (node2)
edge (node3)
edge (node4);
\draw (node1node2)  edge (bot)
edge (node1)
edge (node2);
\draw (node4node3)  edge (bot)
edge (node3)
edge (node4);

\end{tikzpicture}
\end{center}
\end{document}


Remarks, complements

To place a node between two others nodes there is two methods :

1)   \begin{tikzpicture}
\node  (a) {a}  ;
\node  (b) at (4,2) {b};
\path   (a) -- node {m} (b);
%  or \path (a) -- (b) node[midway]{m};
% or pos =.5  instead of midway
\end{tikzpicture}

2)    \begin{tikzpicture} % with calc library
\node  (a) {a}  ;
\node  (b) at (4,2) {b};
\node   at ($(a)!0.5!(b)$) {m};
\end{tikzpicture}


The choice of the method depends of the way used to create the graphs ( with absolute coordinates, with the positioning library or without, with the possibility to scale , if you need to add several nodes)

  \begin{tikzpicture}
\node  (a) {a}  ;
\node  (b) at (8,0) {b};
\path (a) -- (b) node[pos=.25]{c} node[pos=.5]{d} node[pos=.75]{e};
\end{tikzpicture}


If you need to place a node below the middle. It's interesting to use the positioning library except if you need to scale the picture.

Without the positioning library, 5 signifies 5 pt in \path (a) -- node[below=5] {m} (b); but with the positioning library 5 signifies 5 cm

If you need to scale the picture, it's interesting to use the calc library and to avoid positioning. Example :

 \node at ($(a)!0.5!(b)+(0,-1)$) {m};


With this method, you can use scale=2

-
yes you were right I meant that the graph should be symmetric. I used your second solution and it works now thanks ;) –  polofan Jun 1 '13 at 8:04

You can use tikz's calc library to compute the midpoint of the two nodes:

  \coordinate (CENTER) at ($(node1node2)!0.5!(node4node3)$);
\node (bot)   [red,below of = CENTER]  {$\bot$};


Alternatively, as per Jake's suggestion you can use tikz's positioning library (align with the calc) library and then you don't need to create a temporary coordinate:

\node (bot) [red,below = of $(node1node2)!0.5!(node4node3)$]  {$\bot$};


## Code:

 \documentclass[12pt]{article}
\thispagestyle{empty}
\usepackage{tikz}
\usepackage{amsfonts}
\usetikzlibrary{calc,positioning}

\begin{document}
\begin{center}
\begin{tikzpicture}[node distance=3cm]
\node (top)          {$\top$};
\node (node1)   [below left of=top]       {\{node1\}};
\node (node2)      [left of=node1] {\{node2\}};
\node (node3) [below right of=top] {\{node3\}};
\node (node4)[right of=node3]         {\{node4\}};
\node (node1node2) [below right of=node2]        {\{node2 , node1\}};
\node (node4node3) [below right of=node3]        {\{node3, node4\}};
\node (bot) [red,below = of $(node1node2)!0.5!(node4node3)$]  {$\bot$};
\draw (top)    -- (node1);
\draw (top)    -- (node2);
\draw (top)    -- (node3);
\draw (top)    -- (node4);
\draw (node4)    -- (node4node3);
\draw (node3)    -- (node4node3);
\draw (node2)    -- (node1node2);
\draw (node1)    -- (node1node2);
\draw (node1node2)    -- (bot);
\draw (node4node3)    -- (bot);

\end{tikzpicture}
\end{center}
\end{document}

-
Preferable is to use below left= of top with the on grid option. Actually there is only one example in the pgfmanual with right of= ... in the section about automata` –  Alain Matthes Jun 1 '13 at 7:12