9.1 Building smart diagrams

At first, let’s focus on a quick win: getting a diagram with minimal technical effort. So, we would just need to fill in our thoughts.

The smartdiagram package makes building diagrams of various types very easy.

How to do it…

Once you have loaded the smartdiagram package, all you need is a simple command. Follow these steps:

  1. As always, begin with any document class:

  2. Load the smartdiagram package:

  3. Start the document:

  4. Define the diagram. An option in square brackets defines the type, and an argument in curly braces contains a comma-separated list of items:
    \smartdiagram[flow diagram:horizontal]{Edit,
    \LaTeX, Bib\TeX/ biber, make\-index, \LaTeX}

  5. End the document:

  6. Compile, and take a look at the output, a flowchart of a TeX workflow:


How it works…

A simple call of \smartdiagram plus arguments produced the image. The syntax of the command is as follows:

    \smartdiagram[type of diagram]{list of items}

We chose a horizontal flow diagram. Use only flow diagram to get a vertical layout. There’s a specific set of diagram types. Instead of just listing them, let’s perform some examples to take a look at the results.

There’s more…

We can play a bit with diagram type and items to get different diagrams. If there’s a root item or a central item, it’s always the first in the list.

Circular diagram

Let’s try a circular diagram. It is counterclockwise by default. Add :clockwise to the option to get a clockwise order:

    \smartdiagram[circular diagram:clockwise]{Edit,
pdf\LaTeX, Bib\TeX/ biber, make\-index, pdf\LaTeX}

The following figure shows the circular diagram:

Circular diagram

Bubble diagram

To simply present some words in the main context, you can use a bubble diagram. The first item of the list is in a central circle. All other items are placed in colored circles around it. They are slightly overlapping so as to visualize a close relation.

To get macros for more TeX logos, we will load the dtklogos package in addition, so add this to the preamble:


Alternatively, you can use the metalogo package, which gives logo commands such as \XeTeX. Combining strings by writing Lua\TeX instead would be another idea.

The smartdiagram call becomes this:

    \smartdiagram[bubble diagram]{\TeX\ engines,
\TeX\ (dvi), pdf\TeX, \XeTeX, \LuaTeX, \ConTeXt}

Bubble diagram

Constellation diagram

A slightly different form is given by a constellation diagram. In it, each item is in a colored circle connected to the center, which is again the first item:

    \smartdiagram[constellation diagram]{\TeX\ software,
Editor, Compiler, Converter, PDF Reader}

Constellation diagram

Descriptive diagram

For nicely arranging items with a description, there’s the descriptive diagram. The item is a list of small lists, as a consequence. We use additional curly braces to hide the comma within an item so that it won’t be taken as an item separator:

    \smartdiagram[descriptive diagram]{
{Style,{Define shapes, colors, shading,
and line styles for nodes and arrows}},
{Position, {Place nodes using a matrix,
relative or absolute positioning}},
{Relation, Insert edges or arrows
between selected nodes},
{Label, Add labels on edges or arrows}}

This gives us the following diagram:

Descriptive diagram

Priority descriptive diagram

If your descriptive diagram has a certain order and you would like to emphasize that order, use a priority descriptive diagram, like this:

    \smartdiagram[priority descriptive diagram]{
Develop a document structure,
Choose a document class,
Select suitable packages,
Setup the document preamble,
Write your document,
Finetune the layout}

Priority diagram

Animating a diagram

In a presentation done with the beamer class, you can easily animate such a diagram. It’s as simple as:

  • Using the beamer class
  • Using a frame environment for the diagram
  • Writing \smartdiagramanimated instead of \smartdiagram

This, applied to one of the examples you saw earlier, results in the following:

\smartdiagramanimated[circular diagram]{Edit,
pdf\LaTeX, Bib\TeX/ biber, make\-index, pdf\LaTeX}

The diagram will then be built step by step, frame by frame.

Further customization

Of course, you can set the colors and shapes of all elements. For details, refer to the smartdiagram manual, as usual via texdoc, or online at https://texdoc.org/pkg/smartdiagram.