Align the baselines of two nodes placed side by side
You should just \smash
the [b]
aseline of those words/phrases:
\documentclass{article}
\usepackage{tikz,amsmath}
\begin{document}
\usetikzlibrary{positioning,calc}
\tikzstyle{block} = [draw, rectangle, minimum height=1cm, minimum width=1cm, outer sep=0pt]
\begin{tikzpicture}
\node [block,align=center](A) {\shortstack{double \\ type}};
\node [block,align=center,right=1.5cm of A](B) {\shortstack{\smash[b]{single} \\ type}};
\end{tikzpicture}
\end{document}
amsmath
provides the extended version of \smash
.
Another method is to use the \NextLine
macro instead of \\
. This eliminates the need to go back and change things just because you changed the text:
References
- How to make mdframed ignore descenders in last line
Code:
\documentclass[crop,tikz, border=2pt]{standalone}
\begin{document}
%% https://tex.stackexchange.com/a/51406/4301
\newcommand*{\IgnodeDescenders}{-\dimexpr\dp\strutbox+\baselineskip}
\newcommand*{\NextLine}{\strut\\[\IgnodeDescenders]}
\usetikzlibrary{positioning,calc}
\tikzstyle{block} = [draw, rectangle, minimum height=1cm, minimum width=1cm, outer sep=0pt]
\begin{tikzpicture}
\node [block,align=center](A) {\shortstack{double\NextLine type}};
\node [block,align=center,right=1.5cm of A](B) {\shortstack{single\NextLine type}};
\end{tikzpicture}
\end{document}
This is discussed at length in the pgfmanual on p. 65. The upshot is that you can add a suitable text depth
.
\documentclass[crop,tikz]{standalone}
\begin{document}
\usetikzlibrary{positioning,calc}
\tikzset{block/.style={draw, rectangle, minimum height=1cm, minimum width=1cm,
outer sep=0pt,text height=3ex,text depth=.25ex}}
\begin{tikzpicture}
\node [block,align=center](A) { double \\ type };
\node [block,align=center,right=1.5cm of A](B) {single \\ type };
\draw[red] (A.west) -- (B.east);
\end{tikzpicture}
\end{document}
The red line is only to guide the eye.