LaTeX Horizontal Flowchart (Workflow)


Just found an excellent source on how to draw a simple (slightly fanciful) horizontal flowchart using LaTeX (TikZ).

The output is very neat:

The code is reproduced here (in case the original source gets deleted):

\documentclass[tikz, margin=3mm]{standalone}
% for fancy looks of data storages
    node distance = 5mm and 7mm,
      start chain = going right,
 disc/.style = {shape=cylinder, draw, shape aspect=0.3,
                shape border rotate=90,
                text width=17mm, align=center, font=\linespread{0.8}\selectfont},
  mdl/.style = {shape=ellipse, aspect=2.2, draw},
  alg/.style = {draw, align=center, font=\linespread{0.8}\selectfont}
    \begin{scope}[every node/.append style={on chain, join=by -Stealth}]
\node (n1) [disc] {Training\\ data};
\node (n2) [alg]  {Learning\\ algorithm};
\node (n3) [mdl]  {Model};
\node (n4) [disc] {Test\\ data};
\node (n3) [mdl]  {Accuracy};
\node[below=of n2]  {Step 1: Training};
\node[below=of n4]  {Step 2: Tresting};

Multiline Flow Chart

For flowcharts that exceed one line (and hence require a line break), the following Tikz code is very helpful! (Source:

        \tikzset{block/.style= {draw, rectangle, align=center,minimum width=2cm,minimum height=1cm},
        rblock/.style={draw, shape=rectangle,rounded corners=1.5em,align=center,minimum width=2cm,minimum height=1cm},
        input/.style={ % requires library shapes.geometric
        trapezium left angle=60,
        trapezium right angle=120,
        minimum width=2cm,
        minimum height=1cm
        \node [rblock]  (start) {Start};
        \node [block, right =2cm of start] (acquire) {Acquire Image};
        \node [block, right =2cm of acquire] (rgb2gray) {RGB to Gray};
        \node [block, right =2cm of rgb2gray] (otsu) {Localized OTSU \\ Thresholding};
        \node [block, below right =2cm and -0.5cm of start] (gchannel) {Subtract the \\ Green Channel};
        \node [block, right =2cm of gchannel] (closing) {Morphological \\ Closing};
        \node [block, right =2cm of closing] (NN) {Sign Detection \\ Using NN};
        \node [input, right =2cm of NN] (limit) {Speed \\ Limit};
        \node [coordinate, below right =1cm and 1cm of otsu] (right) {};  %% Coordinate on right and middle
        \node [coordinate,above left =1cm and 1cm of gchannel] (left) {};  %% Coordinate on left and middle

%% paths
        \path[draw,->] (start) edge (acquire)
                    (acquire) edge (rgb2gray)
                    (rgb2gray) edge (otsu)
                    (otsu.east) -| (right) -- (left) |- (gchannel)
                    (gchannel) edge (closing)
                    (closing) edge (NN)
                    (NN) edge (limit)


How to draw polygons with angles (LaTeX Tikz)

Just learnt some amazing angle-drawing techniques using LaTeX Tikz.

Although cumbersome to code, the benefit of using LaTeX to draw diagrams is that it matches the font of your document, and is easier to customize and edit. Also, it is “vector graphics” in the sense that even if you zoom in, it is in perfect resolution.

Sample code shown below

Important: In order to use Tikz to draw angles you need to load the following packages:


Sample Tikz code for drawing the above figure (polygon angles)

\coordinate (v0) at (-2.2,1.2);
\coordinate (v1) at (0,0);
\coordinate (v2) at (2.2,1.8);
\coordinate (v3) at (0,3);

(v1) circle (2pt) node[align=left, below] {$v_1$}
-- (v2) circle (2pt) node[align=center, below, right] {$v_2$}
-- (v3) circle (2pt) node[align=left, above] {$v_3$}
-- (v0) circle (2pt) node[align=left, above, left] {$v_0$}
-- (v1);
\pic [draw, -, "$\alpha_0$", angle eccentricity=1.5] {angle = v1--v0--v3};
\pic [draw, -, "$\alpha_1$", angle eccentricity=1.5] {angle = v2--v1--v0};
\pic [draw, -, "$\alpha_2$", angle eccentricity=1.5] {angle = v3--v2--v1};
\pic [draw, -, "$\alpha_3$", angle eccentricity=1.5] {angle = v0--v3--v2};

Clearly, the code can be modified for any polygon be it triangle, pentagon, etc. Also, if you are curious how to post source code in, it is by surrounding your source code with [ code ] [/ code]. It also supports a “lang=” option, see more at