# fixed-size parallelogram nodes

Continuing Drawing parallelogram with fixed angle, width and height? , I'm still failing to understand how to get exactly the same paralellogram shape regardless of the text inside as long as the text fits. Here is an MWE:

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes}
\begin{document}
\begin{tikzpicture}[leftTiltedParallelogram/.style={very thin, trapezium, draw, minimum width=5em, minimum height=10ex, trapezium left angle=-75, trapezium right angle=75, inner sep=1pt, trapezium stretches=true, trapezium stretches body=true, align=center}]
\node[leftTiltedParallelogram] (A) {\begin{tabular}{@{}c@{}}line1\\line2\end{tabular}};
\node[leftTiltedParallelogram,anchor=west] (B) at (A.east) {\begin{tabular}{@{}c@{}}line1\\line2\\line3\end{tabular}};
\end{tikzpicture}
\end{document}


The output produced by pdflatex shows two parallelograms of different angles although the text (either two-lined or three-lined) would fit into any of the two parallelograms.

So, how to forbid TikZ to fiddle with the paralellogram size, including the angles? (In my actual tikz-picture, I have dozens of such parallelograms with two or three lines of text, and I'd like to specify their exact form once and for all without making all of them BIG.)

• How can you be sure that the text fits the exact same way with you MWE ? – BambOo Apr 9 '18 at 17:02
• @BambOo I manually determine how much, say, length, I'd need at worst (as a maximum over the lengths of all the parallelogram nodes I have). Same for the height, same for the tilt angle. Moreover, my text doesn't have to fit exactly the same way. The text simply has to fit. – user159824 Apr 9 '18 at 18:22
• I did a lot of testing (yesterday). You can get the sides to be parallel by losing the stretch options. Putting the text inside \fbox and setting inner sep=0pt showed that the shape was adding extra space. Some was coming from incircle (which can be turned off), but I couldn't track down where all of it was coming from. – John Kormylo Apr 10 '18 at 15:54
• Okay, it achieves the minimum height and width by scaling both dimensions. It does height first. The left node gets scaled more, making it wider than the minimum. The right node then gets scaled a second time to to achieve the minimum width. – John Kormylo Apr 10 '18 at 16:46

## 1 Answer

Instead of adjusting the shape to fit the text, I fit the text into a standard sized box. If you use stretching, the angles will not be 75.

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes}

\newcommand{\boxit}[1]{\parbox[c][10ex][c]{5em}{\centering #1}}
\fboxsep=0pt

\begin{document}
\begin{tikzpicture}[leftTiltedParallelogram/.style={very thin, trapezium, draw,
trapezium left angle=-75, trapezium right angle=75, inner sep=1pt,
trapezium stretches=true, trapezium stretches body=true},align=center]% not needed
\node[leftTiltedParallelogram] (A) {\boxit{\begin{tabular}{@{}c@{}}line1\\line2\end{tabular}}};
\node[leftTiltedParallelogram,anchor=west] (B) at (A.east) {\boxit{\begin{tabular}{@{}c@{}}line1\\line2\\line3\end{tabular}}};
\end{tikzpicture}
\end{document}


It occurred to me that one could greatly simplify the code used to scale trapesiums (no stretching). Compute the scale factor needed to achieve the minimum height and the scale factor to achieve the minimum width and use the larger of the two. One scale will achieve both minima.

• Thank you, John. Another feature of trapezium worth being improved is that the contents should not be rectangle-like, but trapezium-like. E.g., in the right example, line 1 should be ideally shifted to the left and line 3 to the right... But it's more a request to the package maintainer rather than to you. – user159824 Apr 11 '18 at 13:28