# Tikz specify bottom part of the node

I would like to know if it is possible to align the bottom part of a node with a specific point. I already have a code, but it has two problems: first the alignement is not perfect, I don't know why, and also the code is not very natural to write (maybe a library already do the math for me?).

Goal: align the C box like that, without the error (and possibly with a nice code):

MWE:

\documentclass[tikz]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{positioning}
\usetikzlibrary{fit}
\usetikzlibrary{decorations.pathmorphing}

\begin{document}
\begin{tikzpicture}[
box/.style={
rounded corners,
minimum width=2cm,
align=center,
fill=red!50!white,
},
]%
\node[box] (A) {$A$};
\node[box, below=of A] (B) {$B$\\multiline};
\path let \p1=($(A.north)-(B.south)$) in node[box, right=of A.north east,anchor=north west, minimum height={\y1}, inner sep=0pt] (C) {$C$};
\end{tikzpicture}%
\end{document}

• I got an error because you have a non-ASCII character in your code, but otherwise the approach is fine I think. – user194703 Apr 14 '20 at 19:54

## Edit 1:

If you are really annoyed with the 0.01411cm of extra space that is generated, you can use the following to draw the box C without borders:

\node[box,fit=(A)(B), right=of A.north east,anchor=north west,inner sep=-\pgflinewidth/2,outer sep=\pgflinewidth/2, draw=none] (C) {$C$};

Or the following with the default border (line width=0.4pt) thickness:

\node[box,fit=(A)(B), right=of A.north east,anchor=north west,inner sep=-\pgflinewidth,outer sep=\pgflinewidth, draw=blue] (C) {$C$}; 

Note: rounding will probably occur as we are talking about very tiny numbers and pdf viewers uses whole pixels so you might feel it is not perfect to the precision of the pixel.

Here is a MWE:

\documentclass[tikz]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{positioning}
\usetikzlibrary{fit}
\usetikzlibrary{decorations.pathmorphing}

\begin{document}
\begin{tikzpicture}[
box/.style={
rounded corners,
minimum width=2cm,
align=center,
fill=red!50!white,
},
]%
\node[box] (A) {$A$};
\node[box, below=of A] (B) {$B$\\multiline};
\node[box,fit=(A)(B), right=of A.north east,anchor=north west,inner sep=-\pgflinewidth/2,outer sep=\pgflinewidth/2, draw=none] (C) {$C$};
\node[box,fit=(A)(B), right=of C.north east,anchor=north west,inner sep=-\pgflinewidth,outer sep=\pgflinewidth, draw=blue] (D) {With border};
\end{tikzpicture}%
\end{document}


## Original:

Use the fit option as you have imported it.

\documentclass[tikz, border=1cm]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{positioning}
\usetikzlibrary{fit}
\usetikzlibrary{decorations.pathmorphing}

\begin{document}
\begin{tikzpicture}[
box/.style={
rounded corners,
minimum width=2cm,
align=center,
fill=red!50!white,
},
]%
\node[box] (A) {$A$};
\node[box, below=of A] (B) {$B$\\multiline};
\node[box,fit=(A)(B), right=of A.north east,anchor=north west, inner sep=0pt] (C) {$C$};
\end{tikzpicture}%
\end{document}

• Oh, it's possible to fit that way?! Amazing, thanks! But there is still this strange thin space below, that appears if you remove the border of the image, any idea why? – tobiasBora Apr 14 '20 at 19:57
• @tobiasBora, I have updated the answer, please, have a look at it. – M. Al Jumaily Apr 14 '20 at 22:31
• Great thanks a lot! – tobiasBora Apr 15 '20 at 6:38