# TikZ node changes size based on text length even after setting minimum width and height

I have a trapezium node in TikZ that I would like to maintain consistent dimensions no matter how many times it is called in the \tikzpicture.

\documentclass[10pt]{article}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}

\tikzstyle{object} = [draw, trapezium, trapezium left angle=70, trapezium right angle=-70, minimum width=3cm, minimum height=1cm, text centered, draw=black]

\begin{document}

\begin{tikzpicture}[node distance=2cm]
\node(n1)[object]{a};
\node(n2)[object, right of=n1, xshift=1cm]{ab};
\node(n3)[object, right of=n2, xshift=1cm]{abc};
\end{tikzpicture}

\end{document}


Setting the minimum height and width seems to be the go-to for a lot of questions related to this topic but it has unexpected results on my end.

The trapeziums are of different dimensions from each other and seem to grow in height the less character it has inside of them. Why does the node keep getting taller with fewer characters? What is it trying to accommodate? I would expect to get taller to house more texts by trying to keep the width constant.

% Same as before
\tikzstyle{object} = [draw, trapezium, trapezium left angle=70, trapezium right angle=-70, text width=3cm, text height=1cm, text centered, draw=black]
% Same as before


Using text height and text width instead of the minimum variants has the text off-center even after using text centered. Using both of them simultaneously results in the same image.

I have also tried setting inner sep to various values but that does not work as well. Any solution is appreciated.

• Try text depth=<value>, where value is a length established by trial to put the content of the node where you want. Apr 25 at 20:40
• Related, maybe Apr 25 at 20:58
• text depth changes the trapezium size in the second attempt and does not work for the first attempt. trapezium stretches=false does not stop the trapezium from stretching like I have hoped it would. Apr 25 at 21:37

Setting text width and text height should cause TikZ to use a \parbox, but evidently does not use [c].

\documentclass[10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}

\tikzset{object/.style={draw, trapezium, trapezium left angle=70, trapezium right angle=-70, draw=black, inner sep=0pt}}

\begin{document}

\begin{tikzpicture}[node distance=2cm]
\node(n1)[object]{\parbox[c][1cm][c]{3cm}{\centering a}};
\node(n2)[object, right=1cm] at (n1.east) {\parbox[c][1cm][c]{3cm}{\centering ab}};
\node(n3)[object, right=1cm] at (n2.east) {\parbox[c][1cm][c]{3cm}{\centering abc}};
\node[draw=red,minimum width=3cm, minimum height=1cm] at (n1.center){};
\node[draw=red,minimum width=3cm, minimum height=1cm] at (n2.center){};
\node[draw=red,minimum width=3cm, minimum height=1cm] at (n3.center){};
\end{tikzpicture}

\end{document}


• Thank you for the answer. Is there any way to do this with \tikzstyle and without specifying the \parbox... for every time the node is invoked? Wouldn't stating the \parbox every time decrease the maintainability of the document? Apr 26 at 22:27
• Aside from \tikzstyle being obsolete, there doesn't seem to be keyword for centering vertically. Note that text height=text depth doesn't quite center either due to the difference between \ht\strutbox and \dp\strutbox. You could simplify by creating a new command for the \parbox. Apr 27 at 4:01
• On further reflection, text width probably uses \parbox, but text height and text depth probably use \raisebox. Apr 27 at 4:10