# How do I align a third node below the exact middle of a horizontal line between two nodes situated above?

I have found these two answers which are similar to mine. However, my problem requires me to adjust the vertical distance between a horizontal line and the north point of a node, due to the different number of rows used in my diagram. In other words, I need to exactly align the middle of a horizontal connector with the north point of a node below. I need to do more work amending the vertical spacing, but that can wait until my current problem is solved.

I am currently trying to construct a diagram of data flow that, in some cases, has two sets of data contributing to a single cleaned set of data. So this is a series of lines-between-two-nodes-on-the-same-horizontal-plane and vertical-arrow-to-outcome-dataset. This is in a chapter of my dissertation, with the chapter being called by

\include{Chapters/ChapterName}


I know how to find the mid-point of the line between two nodes, e.g.

($(TopLeft.east) !.5! (TopRight.west)$) -- (Below.north);


where the code specifies the mid-point of the line from which to draw.

But how do I position Below so I don't have to do some type of offset from TopLeft or TopRight? Currently I am doing this type of specification for Below':

    \node[rectangle, rounded corners, below left = .5cm and -.5cm of TopRight] (BL) {My below \\ node};


I'm spending a lot of time trying (and often failing) to get the north point of Below exactly below the mid-point defined in the line between TopLeft and TopRight. As you can see, I've been trying to wrangle this with below left and below right measurements. And these become incorrect every time I adjust the text in the box(es) above as it changes the relative positioning of the boxes. So I have the start of the arrow correctly positioned on the half-way point of the horizontal lines, I have the arrow correctly connecting to the north point of the node below, but I can't get the position of that latter node correct relative to the mid-point of the horizontal connecting line above it.

Basically, north should be on the same y-coordinate as the mid-point of the line connecting the two nodes above it.

I'm using a special document class, but this should work for any general Latex class. The boxes below will look weird because my real node text is much longer in every case.

\documentclass{article}
\usepackage[english]{babel}
\usepackage{amsmath,amsthm,amssymb}
\usepackage{amsfonts}
\usepackage[a4paper,layout=a4paper,
bindingoffset=4cm,left=0cm,right=2cm,
head=2.5cm, bmargin=2cm]{geometry}      %get the page layout right
%\usepackage[none]{hyphenat}                        %turn off hypenation globally
\usepackage{microtype}                              %better typesetting, affects justification and punctuation
\usepackage{verbatim}
\usepackage{graphicx}
\usepackage{url}                                    % typeset URL's reasonably
\usepackage[round]{natbib}                          % default bracket type is round
\usepackage{listings}
\usepackage{booktabs}                               %typeset tables better
\usepackage{multirow}                               %allow merge look across table rows
%\usepackage{placeins}                              %fix table floats!
\RequirePackage[l2tabu, orthodox]{nag}
\usepackage[table]{xcolor}                                 % must be imported BEFORE tikz
\usepackage{tikz}                                   %write flowcharts etc
\usetikzlibrary{arrows, shapes, chains, fit, backgrounds, calc, decorations.pathreplacing, matrix, calligraphy, positioning}
\usepackage{hyperref}
\usepackage{cleveref}                             %sensible cross-referencing *****MUST BE PLACED AFTER HYPERREF PACKAGE IF THAT PACKAGE IS USED*****
\usepackage[flushleft]{threeparttable}
\usepackage[inline, shortlabels]{enumitem}
\usepackage{tikzlings}
%\usepackage{forest}
\usepackage{array}
%\usepackage{spreadtab} % can't get this to work
\usepackage{rotating}

\begin{document}

\begin{figure}[htbp]
\centering
\begin{tikzpicture}[every node/.style=draw, align=center, arrow/.style={thick, -stealth}, font=\footnotesize]
\node[rectangle, rounded corners] (SAS) {BOX 1 has quite a bit of text \\ across 2 rows};

\node[rectangle, rounded corners, above left = .5cm and .1cm of SAS] (PD) {Box 2 has less text than Box 1};
\node[rectangle, rounded corners, above right = .5cm and .1cm of SAS] (TAS) {Box 3 has similar length to 2};

\node[rectangle, rounded corners, right = .8cm of SAS] (SLS) {Box 4 has this length};
\node[rectangle, rounded corners, below left = .5cm and -.5cm of SLS] (SLC) {Box 5 smaller than box 1 \\ and is 2 rows};
\node[rectangle, rounded corners, below = .7cm of SLC] (SWA) {Box 6 is back to 1 row};

\node[rectangle, rounded corners, below = .7cm of SWA] (HHS) {Box 7 has about the same amount \\ of text as box 1};
\node[rectangle, rounded corners, below = .7cm of HHS] (SPH) {Box 8 just 1 row};

\node[rectangle, rounded corners, right = .8 of SPH] (SRI) {Box 9 is in \\ two rows again};
\node[rectangle, rounded corners, below right = .7cm and -1.6cm of SPH] (CIS) {Box 10 is one row};

\node[rectangle, rounded corners, right = .8cm of CIS] (EI) {Box 11 has two \\ rows};

\draw[solid] (PD.east) -- (TAS.west);
\draw[arrow] ($(PD.east) !.5! (TAS.west)$) -- (SAS.north);
\draw[solid] (SAS.east) -- (SLS.west);
\draw[arrow] ($(SAS.east) !.5! (SLS.west)$) -- (SLC.north);
\draw[arrow] (SLC.south) -- (SWA.north);
\draw[arrow] (SWA.south) -- (HHS.north);
\draw[arrow] (HHS.south) -- (SPH.north);
\draw[solid] (SPH.east) -- (SRI.west);
\draw[arrow] ($(SPH.east) !.5! (SRI.west)$) -- (CIS.north);
\draw[solid] (CIS.east) -- (EI.west);

\end{tikzpicture}
\caption{Process used to construct data.}
\label{fig:SPOutline}
\end{figure}

\end{document}


Your flow chart you can draw on the following way:

\documentclass[table]{article}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
calc,
positioning}

\begin{document}
\begin{figure}[htbp]
\centering
\begin{tikzpicture}[
every node/.style = {draw, rounded corners,
font=\footnotesize, align=center},
arrow/.style = {thick, -Stealth},
]
\node (SAS) {BOX 1 has quite a bit of text \\ across 2 rows};
\node (PD)  [above  left = 5mm and 1mm of SAS]  {Box 2 has less text than Box 1};
\node (TAS) [above right = 5mm and 1mm of SAS]  {Box 3 has similar length to 2};
%
\node (SLS) [right = 8mm of SAS]    {Box 4 has this length};
\node (SLC) [below = 5mm of $(SAS.south east)!0.5!(SLS.south west)$]
{Box 5 smaller than box 1 \\ and is 2 rows};
\node (SWA) [below = 7mm of SLC]    {Box 6 is back to 1 row};

\node (HHS) [below = 7mm of SWA]    {Box 7 has about the same amount \\ of text as box 1};
\node (SPH) [below = 7mm of HHS]    {Box 8 just 1 row};

\node (SRI) [right = 8mm of SPH]     {Box 9 is in \\ two rows again};
\node (CIS) [below = 7mm of $(SPH.south east)!0.5!(SRI.south west)$]   {Box 10 is one row};

\node (EI)  [right = 8mm of CIS]    {Box 11 has two \\ rows};

\draw[solid] (PD.east) -- (TAS.west);
\draw[arrow] ($(PD.east) !.5! (TAS.west)$) -- (SAS.north);
\draw[solid] (SAS.east) -- (SLS.west);
\draw[arrow] ($(SAS.east) !.5! (SLS.west)$) -- (SLC.north);
\draw[arrow] (SLC.south) -- (SWA.north);
\draw[arrow] (SWA.south) -- (HHS.north);
\draw[arrow] (HHS.south) -- (SPH.north);
\draw[solid] (SPH.east) -- (SRI.west);
\draw[arrow] ($(SPH.east) !.5! (SRI.west)$) -- (CIS.north);
\draw[solid] (CIS.east) -- (EI.west);
\end{tikzpicture}
\caption{Process used to construct data.}
\label{fig:SPOutline}
\end{figure}
\end{document}


However, i would more prefer the following flowchart:

where are employed TikZ library chains and his macro join=by ...:

\documentclass[table]{article}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
calc, chains,
positioning}

\begin{document}
\begin{figure}[htbp]
\centering
\begin{tikzpicture}[
arr/.style = {semithick, -Stealth},
node distance = 7mm and 8mm,
N/.style = {draw, rounded corners, text width=#1,
font=\footnotesize, align=center},
N/.default = 12em,
start chain
]
\begin{scope}[nodes={N, on chain=going below, join=by arr}]
\node (SAS) {BOX 1 has quite a bit of text \\ across 2 rows};
\node (SLC) {Box 5 smaller than box 1 \\ and is 2 rows};
\node (SWA) {Box 6 is back to 1 row};
\node (HHS) {Box 7 has about the same amount \\ of text as box 1};
\node (SPH) {Box 8 just 1 row};
\node (CIS) {Box 10 is one row};
\end{scope}
\node (PD)  [N,above  left=of SAS.north]  {Box 2 has less text than Box 1};
\node (TAS) [N,above right=of SAS.north]  {Box 3 has similar length to 2};
\draw[arr]  (PD)  -| ([xshift=-1em] SAS.north);
\draw[arr]  (TAS) -| ([xshift=+1em] SAS.north);
%
\node (SLS) [N=8em, right=of SAS]    {Box 4 has this length};
\draw[arr]  (SLS.south) -- ++ (0,-4mm) -|  ([xshift=+1em] SLC.north) ;
%
\node (SRI) [N=8em, right=of SPH]     {Box 9 is in \\ two rows again};
\draw[arr]  (SRI.south) -- ++ (0,-2mm) -|  ([xshift=+1em] CIS.north) ;
%
\node (EI)  [N=8em,right = 8mm of CIS]    {Box 11 has two \\ rows};

\draw[arr] (CIS) -- (EI);
\end{tikzpicture}
\caption{Process used to construct data.}
\label{fig:SPOutline}
\end{figure}
\end{document}

• The first one is exactly what I wanted (these are data structures and they are being operated on together to construct the following data structure). Also, thanks for cleaning up the node structure text! – Michelle Mar 20 at 19:09

You can actually position a node below the calculated center of two other nodes:

\documentclass[tikz]{standalone}
\usetikzlibrary{calc, positioning}

\begin{document}
\begin{tikzpicture}

\node[draw] (n1) at (-5,0) {Node 1};
\node[draw] (n2) at (5,0) {Node 2};

\node[draw, below = 1cm of {$(n1) !.5! (n2)$}] {Node 3};

\end{tikzpicture}
\end{document}
`