[Tex/LaTex] align node bottom edges vertically

nodespositioningtikz-pgfvertical alignment

I would like to draw a diagram with boxes of different heights such that the bottom of each box is on the same height. Additionally, I would like to connect the nodes by horizontal arrows. My approach is to use relative positioning (positioning library).

Here is a MWE that illustrates the problem:

\documentclass{article}
\usepackage[english]{babel}
\usepackage{tikz,pgfplots}
\usetikzlibrary{positioning}

\tikzset{ % from http://tex.stackexchange.com/a/49909/78282
    flowbox/.style={
        rectangle, rounded corners, minimum width=1cm, minimum height=1cm,text centered, draw=black
    },
    stdarrow/.style={->,>=stealth}
}

\begin{document}
\begin{tikzpicture}[node distance=1cm]
    \node[center,flowbox] (A) {A};
    \node[flowbox,right=of A] (B) {\tikz \draw (0,0)--(0,3);};
    \draw [stdarrow] (A) -- (B);
\end{tikzpicture}
\end{document}

first version
Note that here, the nodes are centered vertically, the arrow is as I want it.

My idea was to use the base for relative positioning:

\documentclass{article}
\usepackage[english]{babel}
\usepackage{tikz,pgfplots}
\usetikzlibrary{positioning}

\tikzset{ % from http://tex.stackexchange.com/a/49909/78282
    flowbox/.style={
        rectangle, rounded corners, minimum width=1cm, minimum height=1cm,text centered, draw=black
    },
    stdarrow/.style={->,>=stealth}
}

\begin{document}
\begin{tikzpicture}[node distance=1cm]
    \node[flowbox] (A) {A};
    \node[flowbox, base right=of A] (B) {\tikz \draw (0,0)--(0,3);};
    \draw [stdarrow] (A) -- (B);
\end{tikzpicture}
\end{document}

second version
The problem is that here, the bottom of the second box is higher than that of the first one (since it takes the text as a reference) and the arrow is not horizontal. As I said, I would like to have the bottom edges of the two boxes on the same horizontal height and the arrow starting from the vertical center of box A going horizontal to the right. How is this feasible?

Best Answer

The following code should give the desired result (comments below):

\documentclass{article}
\usepackage{tikz,pgfplots}
\usetikzlibrary{positioning}

\tikzset{ % from https://tex.stackexchange.com/a/49909/78282
    flowbox/.style={
        rectangle, rounded corners, minimum width=1cm, minimum height=1cm,text centered, draw=black
    },
    stdarrow/.style={->,>=stealth}
}

\begin{document}
\begin{tikzpicture}[node distance=2cm]
    \coordinate (A-Coord) at (0,0);
    \coordinate[right=of A-Coord] (B-Coord);
    \node[flowbox, anchor=south] (A-Node) at (A-Coord) {A};
    \node[flowbox, anchor=south] (B-Node) at (B-Coord) {\tikz \draw (0,0)--(0,3);};
    \draw [stdarrow] (A-Node.east) -- (A-Node-|B-Node.west);
\end{tikzpicture}

\end{document}

Result:

enter image description here

Comments:

  • To adjust the placing, I defined two coordinates and the node option anchor=south (probably there exist better solutions for this aspect).
  • To force the arrow to be horizontal, I used a orthogonal coordinate system identifier (A-Node|-B_Node.west) (see this answer of percusse)
  • To keep the spacing, I had to adjust the node distance [node distance=2cm]