3

I am trying to make something similar to this below (drawn using another software) but in Tikz

enter image description here

Currently I use tikz/forest to make my flow diagrams. But I do not know how to make such stacked/partially overlapped rectangles to indicate many modules.

Here is MWE I have

\documentclass[12pt]{article}
\usepackage[edges]{forest}  
\usepackage[margin=1in]{geometry}
\tikzset{block/.style={draw, text width=5em , inner sep=2pt, text centered}   }  

\newcommand\set[1]{\fbox{\begin{minipage}{0.8in}\raggedright%
#1
\end{minipage}}
}

\begin{document}
\begin{forest}
for tree={forked edge,edge+={->},grow=east}
%
[\set{dsolve}
   [\set{first order ode}
       [\set{first order linear in $y'$}]         
       [\set{first order none linear in $y'$}]
   ]
   [\set{second order ode}
       [\set{type 1}]
       [\set{type 2}]
       [\set{type 3}]
   ]  
]
\end{forest}
\end{document}

Gives

enter image description here

How to makes stacked/partially covered rectangles as shown in the top image? I do not have to use forest to do this, but this is what I currently use to make flow diagrams.

I searched google but can't find one example to learn from. I found only one image that I am sure was done in tikz here

enter image description here

But the code is not shown in the above link so do not know how it was done. The above is similar to what I am trying to do.

2
  • Out of curiosity: how do you represent a flow diagram by a tree? Sounds a bit strange to me, or at least limited to certain flows.
    – MS-SPO
    Commented May 21 at 8:52
  • @MS-SPO I am open for alternative if there is a better way. But I learned this from this post
    – Nasser
    Commented May 21 at 8:55

2 Answers 2

5

Quick hack: use shadows

\documentclass[12pt]{article}
\usepackage[edges]{forest}
\usepackage[margin=1in]{geometry}
\usetikzlibrary{shadows}

\begin{document}
\begin{forest}
for tree={forked edge,edge+={->},grow=east,draw=black,text width=3cm, l sep=1cm, s sep=0.5cm, fork sep=0.5cm,fill=white}
%
[dsolve
   [first order ode
       [first order linear in $y'$]         
       [first order none linear in $y'$]
   ]
   [second order ode, double copy shadow
       [type 1]
       [type 2]
       [type 3]
   ]  
]
\end{forest}
\end{document}

enter image description here

2
  • 1
    Thanks. But this does it on each and every node in the flow diagram. I only wanted to do it some selected ones, not on everyone. Is there a way to make this shadowing effect show only on a specific node?
    – Nasser
    Commented May 21 at 8:58
  • @Nasser You can choose to which nodes you add the shadow Commented May 21 at 9:09
4

Here are a few alternatives without forest. I didn't add "decorations", like using arrows.meta, other arrow-shapes etc. by intention, which would hide the relevant parts.

  • dsolve is a regular node, using the box-style (use align option etc. as needed)
  • \pic draws some nodes, filled white
  • as far as I see, forest can't include \pics
  • as you can see e.g. here, pics are no nodes , so you need to provide some internal coordinates to access
  • the red arrow just demonstrates that you have to deliberatly ignore the nodes shape mechanisms (arrow would end there), IF you want to overlay it
  • the first shadow uses a double copy with negative xshift, while the second just uses the defaults, inspired by samcarter_is_at_topanswers.xyz answer

result

\documentclass[10pt,border=3mm,tikz]{standalone}
\usetikzlibrary{shadows}

\begin{document}
 \begin{tikzpicture}[
    box/.style={draw,fill=white,
                minimum width=1cm,minimum height=5mm},
    ovbx/.pic={\foreach \c in {0,.1,.2,.3}
                    \node[box] (X\c) at (\c,-\c) {};
                \coordinate (-WE) at (X0.west);% else name won't work
              }, 
 ]
    % ~~~ using said pic ~~~~~~~~~~~~~~~~~~
    \node[box]  (A) at (0,0) {dsolve};
    \pic        (B) at (2,0) {ovbx};
    
    \draw[->] (A) -- (B-WE) node[xshift=17mm] {pic};
    
    % ~~~ just to demo the arrows overlay ~~~~
    \draw[red,->] (.4,-.15) -- +(1,-1);
    
    % ~~~ applying a shadow ~~~~~~~
    \node[box,double copy shadow={shadow xshift=-.5ex}] (C) 
                                at (2,1) {shadow};

    \node[box,double copy shadow] (D) at (4,2) {shadow};
    
    \draw[->] (A) |- (C)  ;
    \draw[->] (C) -| (D)  ;
    
 \end{tikzpicture}

\end{document}

You must log in to answer this question.

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