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}
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}
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):
Result:
Comments:
anchor=south
(probably there exist better solutions for this aspect).(A-Node|-B_Node.west)
(see this answer of percusse)[node distance=2cm]