Functional Block diagram

Thu 28 March 2019

How to make a block diagram with \(\text{\LaTeX}\)?

This article is mainly inspired by tex example.

Here is an example with tikz resulting in the following figure:

The code:

\documentclass{article}
\usepackage[landscape,margin=1cm]{geometry}

\usepackage{tikz}
\usetikzlibrary{shapes,arrows}
\begin{document}


\tikzstyle{block}=[draw,fill=red!20,rectangle,minimum height=3em,minimum width=3em]
\tikzstyle{sum}=[draw,fill=red!20,circle,node distance=3em]
\tikzstyle{input}=[coordinate]
\tikzstyle{output}=[coordinate]
\tikzstyle{pinstyle}=[pin edge={to-,thin,black}]

\begin{tikzpicture}[auto,node distance=8em,>=latex']

    \node[input,name=input]{};
    \node[block,right of=input](first){First block};
    \draw[draw,->](input) -- node{}(first);

    % increase node distance to avoid overlap
    \node[block,right of=first,node distance=15em](second){Block with math and long text: $\int$};
    \draw[->](first) -- (second);

    % second input
    \node[sum,right of=second,node distance=12em](circle0){X};
    \node[input,above of=circle0](input0){second input};
    \draw[->](second) -- node{$+$}(circle0);
    \draw[->](input0) -- node{$++$}(circle0);

    % nominal block
    \node[block,right of=circle0,name=useless,node distance=14em,pin={[pinstyle]above:Upward entry},pin={[pinstyle]below:Other entry}]{Useless block};
    \draw[->](circle0) -- node{something written} (useless);

    \node[block,right of=useless](last){Last};
    \draw[->,dashed](useless) -- node[name=dashed]{}(last);

    % output1
    \node[output,right of=last,node distance=4em](shadow){};
    \node[output,right of=shadow,node distance=4em](output){};
    \draw[->](last) -- node{out}(output);

    % feedback
    \node[block,below of=dashed](feedback){};
    \draw[->](shadow) |- (feedback);


    %  second circle
    \node[sum,left of=feedback,node distance=6em](circle1){$+$};
    \draw[->](feedback) -- (circle1);
    \draw[->](circle1) -| node{ugly}(circle0);

    \node[input,below of=circle1,node distance=2em](input2){};
    \draw[->](input2) -- (circle1);

\end{tikzpicture}
\end{document}

Related articles (or not):

Category: LaTeX Tagged: LaTeX how to