3

I like to draw the following picture:

enter image description here

It is generated with following code:

    \documentclass[12pt,tikz,border=3mm]{standalone}
    %    \usepackage{zfc-book-standalone}
    \usetikzlibrary{arrows.meta,positioning,shapes}
    %---------------------------------------------------------------%
            \begin{document}
    \begin{tikzpicture}[
    node distance = 0mm and 0mm,
L/.style = {line width=1mm, draw=gray,
            arrows={-Stealth[fill=gray,inset=0pt,length=0pt 1.2,angle'=90]},
            },
T/.style 2 args = {name=n#1,
                   draw=#2, fill=#2!20,% draw and fill color
            trapezium, 
            trapezium stretches body,
            trapezium left angle=105, trapezium right angle=75,
            inner sep=0mm, outer sep=0mm, 
            text width=33mm, text height=4mm,
            rotate=-15,
                   }
                        ]
%-------- 
\node[T={1}{teal}]                          {}  (0,0); 
\node[T={2}{teal},  below right=of n1.bottom left corner,
            anchor=top left corner]  {};
\node[T={3}{teal},  below right=of n2.bottom left corner,
            anchor=top left corner]  {};
%-------- 
\node[T={4}{cyan},  trapezium left angle=75, trapezium right angle=105,
            text height=3mm, %text width=33mm + 2.8977/2 mm,
            rotate=30,
            below left =of n3.bottom right corner,
            anchor=top right corner]         {};
%-------- 
    \foreach \i [count=\xi from 4]  in {5,6,7}
\node[T={\i}{teal},below right=of n\xi.bottom left corner,
            anchor=top left corner]  {};
%-------- 
    \foreach \i in {1,2,...,7}
\draw[L,shorten <=11mm,shorten >=11mm]    
            \ifnum\i=4
(n4.east) -- (n4.west)
            \else
(n\i.west) -- (n\i.east)
            \fi;          
%--------
\draw[red,ultra thin]   (n1.top  left corner) |- (n7.bottom  left corner)
                        (n1.top right corner) |- (n7.bottom right corner);
%----------------
    \end{tikzpicture}
            \end{document}

I read all relevant questions here, but didn't find solution, hot to determine angles in trapezium such that left shapes border will be aligned (see discrepancy pointed out with red line on the left of stack).

Questions: Is there a way, beside guessing, to determine left and right trapezium for given rotate angle, trapezium width and height in such a way, that left (and right) shape borders are aligned, i.e. lie on vertical line?

Edit: After reading again Drawing parallelogram with fixed angle, width and height?, as suggest 'percusse' I realise, that if I change in above MWE minimum width and height with fixed measures obtained by text width and text height, I solve most of problems: enter image description here

Still open is the following question:

How to determine text width, that it will be independent from text height?

  • Sorry, isn't simpler to draw double lines (with a adequate double distance? – Claudio Fiandrino Sep 12 '14 at 13:36
  • Did you also consider this one ? tex.stackexchange.com/questions/106969 – percusse Sep 12 '14 at 13:40
  • 'Claudio Fiandrino', probably it is, but how to gives names to line for later use for anchors of other nodes and lines (omitted in MWE)? – Zarko Sep 12 '14 at 13:45
  • Giving coordinates at the beginning and/or end of the paths. See the for instance the very elegant Alain's example. Of course, to put things at the middle of the path, you always have the pos key. – Claudio Fiandrino Sep 12 '14 at 13:49
  • percusse, I read answer in given link. I will read it again, maybe I missed something in it. In first reading I didn't see/figured out an algorithm which can I use to calculate angles for left and right border line for given rotating angle, shape width and hight. I'm very sure, that it exist., but it is very well hidden from me ... – Zarko Sep 12 '14 at 14:50
4

Why not just draw this directly? This gives:

enter image description here

and the code is even simpler:

\documentclass[12pt,tikz,border=3mm]{standalone}
\usetikzlibrary{arrows.meta,positioning,shapes}
\begin{document}

\begin{tikzpicture}[scale=0.5,T/.style={draw=#1,fill=#1!20},
      L/.style = {line width=1mm, draw=gray,
                  arrows={-Stealth[fill=gray,inset=0pt,length=0pt 1.2,angle'=90]}}]
   \draw[T=teal](0,10)--(8,9)--(8,6)--(0,7)--cycle;
   \draw[T=cyan](8,6)--(8,5)--(0,4)--(0,5)--cycle;
   \draw[T=teal](0,4)--(8,3)--(8,0)--(0,1)--cycle;
   \foreach \ht in {9,8,3,2} {
     \draw[teal] (0,\ht)--++(8,-1);
   }
   \foreach \ht in {1.25,2.25,3.25,7.25,8.25,9.25} {
      \draw[L](2,\ht)--++(4,-0.5);
   }
   \draw[L](6,5.25)--++(-4,-0.5);
   \draw[step=5mm] (0,0) grid (10);

   \draw[red](0,0)--(0,10);% for comparing the LHS
\end{tikzpicture}

\end{document}

Of course, if this is part of something more general then this might not be appropriate...and perhaps I have made poor guesses for your dimensions, but it looks close to what you want for your MWE.

In terms of "trapeziums with general angles", I would use the calc library to compute and then plot the corresponding coordinates in the same way.

  • On the end I like to have similar picture. And, yes, this solve only a part of the problem. For further elements on picture I like to have names of drawn shapes: for easier puts arrows in it, add callouts shapes with comments, for simple adds lines with measures between particular shape etc. Of course, all this can be done with absolute coordinates, but how to - after some months - ad some elements to picture, where you have forest of hundreds manually set absolute coordinates? That was reasons, why I start to explore behaviours of trapezium shapes ... and stuck very quickly. Anyway, thank you – Zarko Sep 12 '14 at 14:43
  • @Zarko But you don't need to manually set the coordinates: calculate them using calc. It can handle cos, sin etc. Will modify for proof-of-concept if I have time over the weekend. – Andrew Sep 12 '14 at 14:46
  • @ZAndrew of course not. Most of them can be easy calculate even without calc package, it is quit elementary geometry. The problem can be easy solved on your way, of I can gives a name to drawn shape and determine on it the anchors north, south, ... north west, south west, etc which I like to use in further elements in picture. During weekend I will also investigated for other possibilities – Zarko Sep 12 '14 at 15:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.