In TikZ, I know that the relevant properties to control the shape and text-alignment of a node are:
minimum widthandminimum height(outer shape)- AFAIU
baselineis used to align the nodes themselves, not their contents? align(section 17.4.3)text widthandtext height(section 17.4.4), although the documentation mentions that:
I recommend using minimum size instead of text height except for special situations.
I also think that this post gives a very good example of how to use these properties with text.
But what if what if the contents I am trying to align are not text?
My example below is using a minipage, but if that doesn't change the answer completely, I would assume this could be a tabular, or includegraphics, or any other non-text contents.
As you can see the alignment of the contents is vertically centred. Given that I have specified minimum height/width, how can I specify an alignment to the top of the node, or to the bottom?
\documentclass[a4paper]{article}
\usepackage{calc}
\usepackage{tikz}
\newlength{\boxH} \setlength{\boxH}{2cm}
\newlength{\boxW} \setlength{\boxW}{5cm}
\newlength{\boxM} \setlength{\boxM}{2mm}
\begin{document}
\begin{tikzpicture}
\node[
shape=rectangle,
fill=red,
inner sep=\boxM,
minimum width=\boxW,
minimum height=\boxH,
anchor=north west
] {%
\begin{minipage}{\boxW-2\boxM}%
One line
\end{minipage}%
};
\node[
shape=rectangle,
fill=blue,
xshift=\boxW+\boxM,
inner sep=\boxM,
minimum width=\boxW,
minimum height=\boxH,
anchor=north west
] {%
\begin{minipage}{\boxW-2\boxM}%
Two\\ lines
\end{minipage}%
};
\end{tikzpicture}
\end{document}



