0

I'm trying to visualize and describe the steps of the process with a TikZ flowchart. I would like to make the solution as scalable as possible, it would be perfect to have some data structure associated with each step of the process based on which the flowchart would be created. Something similar to the list:

\begin{process}
   \item[short_description, output, long_details]
   \item[short_description, output, long_details]
\end{process}

That would result in something like this:

enter image description here

Ideally with flowchart wrapping (but let's solve the problem one step at a time...)

So far I was able to sort out the plotting of a single-line sequence of connected blocks, but I am stuck trying to introduce some data structure over which to iterate. What would be the best approach to build this kind of data structure in TeX?

\documentclass[10pt]{report}

\usepackage{blindtext}
\usepackage[a4paper, margin={1in}]{geometry}

\usepackage{tikz}
\usetikzlibrary{positioning}
\usetikzlibrary{shapes.geometric, arrows}

\tikzstyle{block} = [rectangle, minimum width=2cm, minimum height=1cm, align=center, text centered, text width=2cm, draw=black]
\tikzstyle{arrow} = [thick,->,>=stealth]


\begin{document}

\begin{tikzpicture}[node distance=1cm]

% Create a sequence of blocks  with arrows
\foreach \x [remember=\x as \lastx (initially 0)] in {0,...,5}{
    \if\x0
        \node (n\x) [block]  {n\x};
    \else 
        \node (n\x) [block, right = of n\lastx]  {n\x};
        \draw [arrow] (n\lastx) -- (n\x) node[midway, above]() {$s(\lastx)$};
    \fi
}

\end{tikzpicture}

\hfill

Long description:
\begin{enumerate} 
    \item [n0] Long description of what n0 does
    \item [n1] Long description of what n1 does

\end{enumerate}

\end{document}

1 Answer 1

1

I'm not sure if this is exactly what you want, but here is a possibility using the chains library. Define a macro \process that takes a comma-separated list for an argument. Each entry should have the form <short desc>/<input>/<long description>. Note that the arrows are input arrows, not output arrows, so the first is ignored. It was easier to do it this way because of the way the join option works with chains.

The first chain is the flowchart with joins; the second has the descriptions.

enter image description here

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{chains, arrows.meta, quotes}

\tikzset{block/.style={draw, minimum width=2cm, minimum height=1cm}}

\newcommand{\process}[1]{
    \begin{tikzpicture}[start chain=1, start chain=2, node distance=1mm and 1cm,
            every join/.style={thick, -Stealth}]
        \node[on chain=2] at (-1,-.7){}; 
        \foreach \S/\O/\L in {#1}{
            \node[on chain=1, block, join=by "\O"]{\S};
            \node[on chain=2 going {below=of \tikzchainprevious.south west, anchor=north west}]{\S\;\L};
        }
    \end{tikzpicture}
}

\begin{document}

\process{
    n0/ignored/Long description of what n0 does,
    n1/$s(0)$/Long description of what n1 does,
    n2/$s(1)$/Long description of what n2 does,
    n3/$s(2)$/Long description of what n3 does
}

\end{document}

You must log in to answer this question.

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