The following flowchart was made in PowerPoint, and it describes the input and output of a function.
As you can see, the diagram is quite intuitive: a set of files are piped into "Function", and it returns a data structure "Struct".
I am trying to draw it using TikZ.
My approach was to draw the first two blocks using nodes and then create the "Struct" shape using a node and a bunch of lines inside a scope environment, so that the node and the lines remain grouped together as a single shape.
I managed to draw and connect the first two blocks. However, I am having trouble to place and connect the "Struct" shape in the diagram. I was expecting that the scope environment would behave like a node, and gave this instruction:
\begin{scope}[right of=function]
But this is what I got:
- Is it possible to make scope environment behave like a node?
- If so, how can I accomplish this?
- Otherwise, what alternatives do I have?
Code:
\documentclass[border=5pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{
shapes.geometric,
arrows,
shadows
}
\usepackage{varwidth}
\usepackage{enumitem}
\usepackage{courier}
\renewcommand*\familydefault{\ttdefault}
\begin{document}
\begin{tikzpicture}[node distance=5cm]
\tikzset{
files/.style = {
rectangle,
fill=white,
draw=black,
minimum width=3cm,
minimum height=1.5cm
},
function/.style = {
rectangle,
fill=white,
draw=black,
minimum width=3cm,
minimum height=1.5cm,
text centered
},
box/.style = {
rectangle,
fill=white,
draw=black,
minimum width=2cm,
minimum height=0.5cm
},
arrow/.style={
->,
>=latex,
},
}
% Input
\node (files) [files, drop shadow] {
\begin{varwidth}{3cm}
\begin{itemize}[noitemsep, leftmargin=*]
\item{file1.dat}
\item{file2.dat}
\item{file3.dat}
\item{file4.dat}
\end{itemize}
\end{varwidth}
};
% Function
\node (function) [function, right of=files, drop shadow] {Function};
% Output
\begin{scope}[right of=function]
\draw (0,0) -- (0,1) node[above, box, drop shadow] {Struct};
\draw (-1.5,-1) -- (-1.5,0) -- (1.5,0) -- (1.5,-1);
\draw (-0.5,-1) -- (-0.5,0);
\draw (0.5,-1) -- (0.5,0);
\end{scope}
% Arrows
\draw [arrow] (files) -- (function);
\end{tikzpicture}
\end{document}
fit
library. Or you could use apic
. It is probably easiest to draw the complicated thing first and then put the simple things to the left, rather than drawing the simple things first and trying to put the complicated thing to the right. You can do the latter, but you're making yourself more work ;).