How can I align the text of a node to the bottom of the rectangle shape without hard coding values? (centered horizontally but justified to the bottom)
\tikz[]{
\node[shape=rectangle, inner sep=8pt, minimum height=1.2cm, fill=black, text=white, font=\huge, text depth=-0.6cm] {test};
}\tikz[]{
\node[shape=rectangle, inner sep=8pt, minimum height=1.2cm, fill=black, text=white, font=\huge, text depth=0cm] {test};
}\tikz[]{
\node[shape=rectangle, inner sep=8pt, minimum height=1.2cm, fill=black, text=white, text depth=-0.6cm] {test};
}\tikz[]{
\node[shape=rectangle, inner sep=8pt, minimum height=1.2cm, fill=black, text=white, text depth=0cm] {test};
}
Obviously text depth
can be hard coded but I would like it to automatically work for any given font and rectangle height.
Best Answer
If the text size is smaller than the minimum height you could try to use
text height
instead ofminimum height
: