The shortcomings of tikz trapezium shape have already been highlighted. I am looking for a parallelogram shape that strictly respects given angles and text width, while allowing for vertical stretching to fit the node text (I don't mind the parallelogram's width increasing to accomodate these constraints). This could be done by drawing the parallelogram using postaction on a rectangular shape if it is possible to reference the anchors of the current node in said postaction. Hence the question : how to access current node's anchors in a postaction ?
EDIT : the following code shows how parallelograms are distorted (incorrect length without stretch, incorrect angles with stretch). It also presents the approach I mentioned earlier : style parallelogram has to be passed an existing node as argument, and draws a parallelogram around that node. I would like to be able to pass it the node it is applied to, in postaction (and as I'm writing this I'm wondering if postaction is needed at all).
\documentclass{minimal}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{shapes}
\usetikzlibrary{calc}
% solution using trapezium
\tikzstyle{para} = [trapezium, trapezium left angle=60,
trapezium right angle=120, draw=black, text width = 3cm,
minimum height=.8cm]
% attempt at custom solution
\tikzset{parallelogram/.code={
\draw[red] (#1.north west)
-- ($(#1.south west)!.2!90:(#1.north west)$)
-- (#1.south east)
-- ($(#1.north east)!.2!90:(#1.south east)$)
-- cycle;
}}
\begin{document}
Para(llelogram) shape using trapezium (no stretch) :
\begin{tikzpicture}
\node[para] {with a longer text with a longer text with a longer text with a longer text};
\node[para] at (0,2) {short};
\node[para] at (0,3) {.};
\end{tikzpicture}
Para(llelogram) shape using trapezium (trapezium stretches):
\begin{tikzpicture}[trapezium stretches]
\node[para] {with a longer text with a longer text with a longer text with a longer text};
\node[para] at (0,2) {short};
\node[para] at (0,3) {.};
\end{tikzpicture}
Para(llelogram) shape using trapezium (trapezium stretches body):
\begin{tikzpicture}[trapezium stretches body]
\node[para] {with a longer text with a longer text with a longer text with a longer text};
\node[para] at (0,2) {short};
\node[para] at (0,3) {.};
\end{tikzpicture}
Custom solution proposal:
\begin{tikzpicture}
\node[rectangle, densely dotted, draw, text width=3cm] (a) at (2,1) {test};
\node[rectangle, parallelogram=a] at (6,1) {dummy};
\node[rectangle, densely dotted, draw, text width=3cm] (b) at (2,-1) {with a longer text with a longer text with a longer text with a longer text};
\node[rectangle, parallelogram=b] at (6,-1) {dummy2};
\end{tikzpicture}
\end{document}
trapezium stretches ...
both equal to false?minimal
for examples. It is not designed for this and can be very misleading in certain cases.minimal
orstandalone
had to be avoided and picked the wrong one.