How can you make the matrix cell contents aligned to the top? I am using plain format with XeTeX.
\input tikz
\usetikzlibrary{matrix}
$$\hbox{I'd like for the cells to be top-aligned}\cases{
\tikzpicture[
a/.style={draw=green!50!black,text width=3.5cm,
text height=1.5cm,text depth=1.5cm,minimum size=3.5cm,
anchor=base,
inner sep=0pt,outer sep=0pt},
m/.style={matrix of nodes,inner sep=2pt,outer sep=0pt,nodes=a,
ampersand replacement=\&,row sep=0pt,column sep=0pt,draw=black!50}
]
\parindent0pt
\matrix[m] (mx) {
Hey, this is a node with a break\break and stuff\&
And another one with it. Milkshakes are yummy when the sun is shining\\
Let's see what happens; I'm trying to find the logic\&
Does it break when all these cells have different amount of text?\\
};
\draw[very thick,red!50] (mx.north)--(mx.south) (mx.west)--(mx.east);
\endtikzpicture
} \hbox{Yes it does}
$$
\bye
After @Gonzalo's comment to change text height
/depth
:
\input tikz
\usetikzlibrary{matrix}
\tikzpicture[
a/.style={draw=green!50!black,text width=3.5cm,
text height=0pt,text depth=2.5cm,minimum size=3.5cm,
anchor=base,
inner sep=0pt,outer sep=0pt},
m/.style={matrix of nodes,inner sep=2pt,outer sep=0pt,nodes=a,
ampersand replacement=\&,row sep=0pt,column sep=0pt,draw=black!50}
]
\parindent0pt
\matrix[m] (mx) {
Hey, this is a node with a break\break and stuff\&
And another one with it. Milkshakes are yummy when the sun is shining\\
Let's see what happens; I'm trying to find the logic\&
Does it break when all these cells have different amount of text?\\
};
\draw[very thick,red!50] (mx.north)--(mx.south) (mx.west)--(mx.east);
\endtikzpicture
\bye
Best Answer
A solution with matrix (version 2)