3

I try making a simple trapez like shape using the TikZ shape library. The text inside the shape differs from its length. However, the shape should be as big as the shape with the longest text so all shapes have the same size in the end.

I try fixing some paramters like text width, but this does make short textnodes even longer ... Anyone an idea?

Here is the code:

\documentclass{article}
\usepackage{tikz,amsmath, amssymb,bm,color}
\usepackage[margin=0cm,nohead]{geometry}
\usepackage[active,tightpage]{preview}
\usetikzlibrary{shapes,arrows, matrix}
% needed for BB
\usetikzlibrary{calc}


\begin{document}
\begin{tikzpicture}
[
output/.style ={trapezium,draw,fill=none, minimum height=10mm,  
align=center, trapezium left angle=60, trapezium right angle=120, text 
width=50}
]

\matrix [row sep=1.cm,ampersand replacement=\&,  nodes in empty cells]
{
\node [output] (54) {This is a\\ long text}; \\
\node [output] (44) {short text};\\
\node [output] (44) {RQ1};\\
};

\end{tikzpicture}
\end{document}

This result in that picture:

enter image description here

Many thanks in advance for your help.

0

1 Answer 1

4

The behavior of the trapezium shape is indeed a bit counter-intuitive and has been explained by percusse in this nice answer. And sorry, my comment was really not too useful (apart from the link to percusses answer). Essentially it adjusts its size for a given content taking into account both the horizontal and vertical distances. Therefore, you could fix these issues by adding appropriate \vphantoms.

\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{shapes,arrows, matrix}
% needed for BB
\usetikzlibrary{calc}


\begin{document}
\begin{tikzpicture}
[
output/.style ={trapezium,draw,minimum height=10mm,  
align=center, trapezium left angle=60, trapezium right angle=120,
 text width=50,align=center}
]

\matrix [row sep=1.cm,ampersand replacement=\&,  nodes in empty cells]
{
\node [output] (54) {This is a\\ long text}; \\
\node [output] (44) {short text\vphantom{\begin{tabular}{c}x\\ y\end{tabular}}};\\
\node [output] (44) {RQ1\vphantom{\begin{tabular}{c}x\\ y\end{tabular}}};\\
};

\end{tikzpicture}
\end{document}

enter image description here

2
  • Oh i did not expect that the solution is a bit "tricky". However it works perfectly fone for me :) Thank you!
    – SRel
    Aug 1, 2018 at 20:27
  • @SRel I was just looking at less /usr/local/texlive/2018/texmf-dist/tex/generic/pgf/libraries/shapes/pgflibraryshapes.geometric.code.tex but gave up. This is a really lengthy code, which may or may not be improvable, but given its complexity I would like to argue that the above is the easier way to go.
    – user121799
    Aug 1, 2018 at 20:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .