Skip to main content

Latex Tutorial: How to Create Images, Diagrams, and Flow Charts Using Latex

This tutorial is an extension of previous video tutorial on how to use tikz for image creation in Latex. In this video I explain how to set up your document for flow chat design. This equally applies to any other image that uses similar structure.

Specifically, in this video I talk about following things:
  1. How to create a flow chart
  2. How to setup styles for reusable components of an image
  3. How to draw arrows from one component to other
  4. How to change the styles of components
  5. How to change the arrowhead for Latex arrows
  6. How to align components left, right, top, and below of each other

The code use:d in the video is here:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes,shadows,arrows}
\begin{document}
\tikzstyle{decision} = [diamond, draw, fill=blue!50]
\tikzstyle{line} = [draw, -stealth, thick]
\tikzstyle{elli}=[draw, ellipse, fill=red!50,minimum height=8mm, text width=5em, text centered]
\tikzstyle{block} = [draw, rectangle, fill=blue!50, text width=8em, text centered, minimum height=15mm, node distance=10em]
\begin{tikzpicture}
\node [block] (start) {Start};
\node [block, left of=start, xshift=-5em] (process1) {Process 1};
\node [elli, above of=start, yshift=5em] (user) {user};
\node [block, right of=start, xshift=5em] (process2) {Process 2};
\node[decision, below of=start, yshift=-5em](decision1){Process 1?};
%arrows
\path [line] (user) -- (start);
\path [line] (start) -- (decision1);
\path [line] (decision1) -| node[yshift=0.5em, xshift=10em] {yes} (process1);
\path [line] (decision1) -| node[yshift=0.5em, xshift=-10em] {no} (process2);
\end{tikzpicture}
\end{document}
The image produced by this code is :

The explanation of this code is given in the tutorial as we develop this code:


Comments

  1. Dear Dinwal,

    currently working on master thesis and as a fresher in Latex, I've already profitted a lot from your youtube tutorials. Now, I have a question which has not been answered on your blog. It's about how to generate nice graphs/diagrams from time series data driectly. In my case for example, I want to plot imports and exports of a particular country in one graph (lines, as e.g. could be obtained by using excel graphs/diagrams)from say 1990 until 2011.
    I'd appreciate a lot if you could help me out!

    Many greetings,

    Johanna

    ReplyDelete
  2. Hi!
    Thank you for a great video tutorial, you saved my day! :) I have a small question concerning the text inside the nodes. How do you make a line shift inside the nodes? I have a very simple vertical flow chart, and inside each node there is a short "heading" (e.g. Centrifugation), and I would like to have the specifications underneath (e.g. 10 minutes, 5000 rpm, 50 ml tubes) so it appears something like this:

    CENTRIFUGATION
    - 10 minutes
    - 5000 rpm
    - 50 ml tubes

    I have tried using \itemize and just \\ inside the node, but it does not work and all the text is still in one line like this "Centrifugation 10 minutes 5000 rpm 50 ml tubes."

    I would greatly appreciate your help. Thanks in advance!

    Best regards,

    Kate

    ReplyDelete
    Replies
    1. I think it should work if you put the \newline command between each of those words.

      Delete
  3. Is there a maximum number of nodes one can have in a vertical flowsheet? On my 7th box I get this error:! Undefined control sequence.
    l.284 \node

    All the other boxes above are ok, but everything stops by adding this extra node! Any tips?

    Thanks :)

    ReplyDelete
  4. Thanks for the tutorial. A nice addition would be a quick discussion of how to make a loop, ie, how to place an invisible node in the middle of an arrow.

    ReplyDelete

Post a Comment

Comments on QuickLatex are strictly moderated. As much as I hate moderation, I must fight spam. Please rest assured that if your comment is relevant I will approve it and answer.

Popular posts from this blog

LaTeX Video Tutorial: How to Create a Resume or CV (Curriculum Vitae) using LaTeX

One of the most frequent questions my colleagues ask me is how to create a Resume or Curriculum Vitae (CV), if you will, in LaTeX . I have a style file that was passed to me by a friend who found it on Internet. Since this looked good I used it and, thanks to the original contributor, I am going to share it with you all today. You will be able to download these files and create a professional Resume for yourself.  The files can be download from the linked locations: The Resume.tex file (main document) The Class file res.cls (for page setting) In the video tutorial , attached below, I have explained how to change the text for your needs. The structure of the Resume (or CV) is highly flexible and once you get hold of the basics it will be pretty straight forward for you to tweak it for your own use.  I have tried to add the basic sections that are present in most of the Resumes but you will most probably add more depending on your requirements. I am pretty sure it

How to draw Reddit Alien in LaTeX using Tikz - Video tutorial and code

If you are not a Redditor you are a lucky person. It's a one way traffic scenario with no dead end. Once you subscribe to Reddit there is no way back and it is no good being there. I am expecting my colleagues to have an intervention for my Reddit addiction soon but till then I am all here to invest (read:waste) my precious time. Since we got that out of our way, let us get back to business. Today, we are going to see how to draw a cartoon figure using LaTeX. The motivation behind this post is /r/latex on Reddit as I wanted that subreddit to have its logo drawn in LaTeX. I did not know it already was in LaTeX but it seems my work is appreciated there so I am going to contribute my 2 cents to the community. Specifically, we will learn following things in this tutorial: How to work with Colors - defining RGB colors in LaTeX. How to use multiple layers to set order of document objects (send to back, bring forward like functionality). How to use Arcs in an effective way.