4

I have four questions related to the creation of diagrams in the smartdiagram environment in LaTex that I was not able to find Internet sources for or resolve them myself:

1) How to label the diagram?

2) How to make the frames long enough so they don't break up the words? (Lengthy words used for illustration)

3) How to place description of a step not immediately following the words "Step X" but using a break?

4) Currently, my diagram is too long ad it seems that the only way to improve it is to include a break that would start the second half on the next line. How to create an arrow that connects the first line's last object with the second line's first object? Something like this:

enter image description here

This is what I have right now:

enter image description here

\documentclass[12pt]{article}
\usepackage{smartdiagram}
\usesmartdiagramlibrary{additions}
\begin{document} 
\begin{center}
\smartdiagramset{uniform color list=white!60!black for 6 items,
    back arrow disabled=true, module minimum width=2cm,
    module minimum height=2cm,
    module x sep=3cm,
    text width=2cm,
    additions={
        additional item offset=0.5cm,
        additional item width=2cm,
        additional item height=2cm,
        additional item text width=3cm
      }
    }
    \smartdiagram[flow diagram:horizontal]{Step 1 refrigeration, Step 2 presidentially, Step 3 constitution, Step 4 etc, Step 5 etc, Step 6 etc} 
\end{center}


\end{document}

I have some problems with the offered solution. Please see the attached screenshotenter image description here:

Code for the last screenshot:

\begin{center}
    \smartdiagramset{
        uniform color list=white!60!black for 6 items,
        back arrow disabled=true,
        module minimum width=2cm,
        module minimum height=2cm,
        module x sep=4cm,
        text width=3cm,
        additions={
            additional item offset=20mm,
            additional item width=2cm,
            additional item height=2cm,
            additional item text width=3cm,
            additional item shadow=drop shadow,
            additional item bottom color=white!60!black,
            additional item border color=gray,
            additional arrow color=gray,
        }}
        \smartdiagramadd[flow diagram:horizontal]{
            Step 1\\ I have soe issues with the solution, Step 2\\ Can the boxes get wider to include moe words per line?, Step 3\\
        }{
        below of module1/Step 4 Not sure why the arrows are now curvy,below of module2/Step 5 In the second half couldn't start with a new line,below of module3/Step 6
    }
    \smartdiagramconnect{->}{additional-module1/additional-module2,additional-module2/additional-module3}
    \begin{tikzpicture}[remember picture,overlay]% modified from p. 47 of manual
    \draw[additional item arrow type] (module3) |- ([yshift=-10mm]module1.south) -- (additional-module1);
    \end{tikzpicture}
    \vspace{40mm}\par

\end{center}
  • this probably isn't a useful observation, but something to be thought about (and i have no idea whether smartdiagram supports it. if it's necessary to split steps into two lines, and the number of steps doesn't completely fill both lines, it would seem a nice idea to split the string in half and flush the second line to the right. i think the flow would appear more logical. – barbara beeton Jun 2 '16 at 16:59
  • Can you clarify the question #4? – Alenanno Jun 2 '16 at 18:47
  • I just have updated the question. – Olga Jun 2 '16 at 19:29
  • 1
    Your code cannot be compiled without error. Please fix it and test code before posting it. (Even when I 'know' it works, I'm often wrong! I imagine I'm not alone in this ....] – cfr Jun 2 '16 at 20:59
  • Why don't you provide the code for the new screen shot? – cfr Jun 4 '16 at 20:42
6

In general, I think smartdiagram is a very nice package and useful if you want a diagram which it is designed to produce. However, the ease of use has an obvious trade-off: it is inevitably less flexible than using TikZ directly. It is not like using a library, say, where you can integrate the additional functionality with regular TikZ code.

However, it is possible to modify the diagram to satisfy some of your desiderata without too much hackery in this case by abusing the idea of an additional module (as the manual itself demonstrates on page 20, for a different kind of diagram).

  \smartdiagramadd[flow diagram:horizontal]{
    Step 1 refrigeration, Step 2 presidentially, Step 3 constitution
  }{
    below of module1/Step 4 etc.,below of module2/Step 5 etc.,below of module3/Step 6 etc.
  }
  \smartdiagramconnect{->}{additional-module1/additional-module2,additional-module2/additional-module3}

This gets us 3 modules in the top row and 3 'additional' modules in the bottom row, with arrows connecting the modules on the bottom row.

For the arrow between the top and bottom row, we need - or, at least, it certainly seems easiest - to resort to TikZ by using a modified version of the \smaartdiagramconnect command directly.

  \begin{tikzpicture}[remember picture,overlay]% modified from p. 47 of manual
    \draw[additional item arrow type] (module3) |- ([yshift=-10mm]module1.south) -- (additional-module1);
  \end{tikzpicture}

The result of this addresses your fourth question.

hackery

The width of the modules can be increased with, for example

    module x sep=4cm,
    text width=3cm,

with a matching setting for the additional modules

       additional item text width=3cm,

The main modules can be broken following the Step No. straightforwardly

          Step 1\\refrigeration, Step 2\\presidentially, Step 3\\constitution

but note that this will not work for the additional modules and attempting to break a line there will give an error.

The result addresses your second and third questions (partially in the case of the third due to the complications which result from addressing your fourth question).

hackery + customisation

As I say, if you want finer-grained control, then it will be easier not to restrict yourself within smartdiagram's confines. It is not designed to be all-things to all-users - there's already TikZ for that!

The trick to labelling the diagram is to understand that it is necessary to manually compensate for the space taken by the additional modules since these officially take no space at all.

\begin{figure}
  \centering
   ...
  \vspace{40mm}\par
  \caption{My diagram}\label{fig:diag}
\end{figure}

This addresses the first question and the cumulative result is shown below.

final result

Complete code:

\documentclass[12pt]{article}
\usepackage{smartdiagram}
\usesmartdiagramlibrary{additions}
\begin{document}
\begin{figure}
  \centering
  \smartdiagramset{
    uniform color list=white!60!black for 6 items,
    back arrow disabled=true,
    module minimum width=2cm,
    module minimum height=2cm,
    module x sep=4cm,
    text width=3cm,
    additions={
      additional item offset=20mm,
      additional item width=2cm,
      additional item height=2cm,
      additional item text width=3cm,
      additional item shadow=drop shadow,
      additional item bottom color=white!60!black,
      additional item border color=gray,
      additional arrow color=gray,
    }}
  \smartdiagramadd[flow diagram:horizontal]{
    Step 1\\refrigeration, Step 2\\presidentially, Step 3\\constitution
  }{
    below of module1/Step 4 etc.,below of module2/Step 5 etc.,below of module3/Step 6 etc.
  }
  \smartdiagramconnect{->}{additional-module1/additional-module2,additional-module2/additional-module3}
  \begin{tikzpicture}[remember picture,overlay]% modified from p. 47 of manual
    \draw[additional item arrow type] (module3) |- ([yshift=-10mm]module1.south) -- (additional-module1);
  \end{tikzpicture}
  \vspace{40mm}\par
  \caption{My diagram}\label{fig:diag}
\end{figure}
\end{document}

EDIT

To respond to the queries in comments ...

\caption{} can only be used in a float. However, the caption or capt-of package can be used to provide \captionof{<float type>}{<caption>} outside floats.

Adding

\usepackage{caption}

to the preamble, we can modify the diagram to replace figure with center, removing \centering and then write

\captionof{figure}{My diagram}\label{fig:diag}

rather than the \caption{My diagram}... line above.

non-floating diagram

EDIT EDIT

Regarding the problem with the newly posted code, the minimum height of both standard and additional modules must be increased to accommodate the additional height of the text. Otherwise, the modules are improperly aligned.

I found that using

module minimum height=25mm,

and

additional item height=25mm,

rather than the original 2cm was sufficient when I compiled the code. However, I cannot reproduce the result shown in your screenshot in terms of the additional spacing.

Here is the code I used

\documentclass[12pt]{article}
\usepackage{smartdiagram,caption}
\usesmartdiagramlibrary{additions}
\begin{document}
\begin{center}
    \smartdiagramset{
        uniform color list=white!60!black for 6 items,
        back arrow disabled=true,
        module minimum width=2cm,
        module minimum height=25mm,
        module x sep=4cm,
        text width=3cm,
        additions={
            additional item offset=20mm,
            additional item width=2cm,
            additional item height=25mm,
            additional item text width=3cm,
            additional item shadow=drop shadow,
            additional item bottom color=white!60!black,
            additional item border color=gray,
            additional arrow color=gray,
        }}
        \smartdiagramadd[flow diagram:horizontal]{
            Step 1\\ I have soe issues with the solution, Step 2\\ Can the boxes get wider to include moe words per line?, Step 3\\
        }{
        below of module1/Step 4 Not sure why the arrows are now curvy,below of module2/Step 5 In the second half couldn't start with a new line,below of module3/Step 6
    }
    \smartdiagramconnect{->}{additional-module1/additional-module2,additional-module2/additional-module3}
    \begin{tikzpicture}[remember picture,overlay]% modified from p. 47 of manual
    \draw[additional item arrow type] (module3) |- ([yshift=-10mm]module1.south) -- (additional-module1);
    \end{tikzpicture}
    \vspace{45mm}\par
    \captionof{figure}{My other diagram}\label{fig:otherdiag}
\end{center}
\end{document}

with the following result

increased heights for alignment

Another option, as you suggest, is to modify the width of the nodes rather than the height.

Using

    ...
    module minimum height=20mm,
    module x sep=4.75cm,
    text width=38mm,
    additions={
        additional item width=2cm,
        additional item height=20mm,
        additional item text width=38mm,
        ...

does the job. It is necessary to increase the distance between the nodes, in addition to increasing the width of the nodes to avoid their overlapping.

In that case, of course, the additional vertical space below the diagram can be left as it was.

...
\vspace{40mm}\par
\captionof{figure}{Another version of my other diagram}\label{fig:anotherdiag}
...

wider nodes

As will be seen, whether the height or the width is increased, the line spacing is much closer in my results than it appears to be in yours. Presumably you've omitted the code from your example which is responsible for the increase. This is why it is so important to include a complete minimal example which actually reproduces the issue when compiled. When people have to guess how to complete your code, they do not always complete it in the right wrong way to reproduce the problem.

That said, if you are using setspace or a class which increases line spacing or have increased the line spacing manually (never a good idea) or have altered the default height of rows in tabulars or anything similar, that is probably responsible for the issue.

|improve this answer|||||
  • Can I label the diagram without the float option? When I remove '\begin{figure}' and '\end{figure}', the '\caption' option returns error. – Olga Jun 4 '16 at 17:27
  • @Olga Load caption or capt-of and then use \captionof{figure}{<my label text>}\label{fig:mylabel}. – cfr Jun 4 '16 at 19:19
  • I implemented your solution, however, there is too much space between the lines of text. Please check an updated version in a a second. Is it possible to only keep the space between "Step X" and the text? – Olga Jun 4 '16 at 19:22
  • @Olga Please see edits above. But you've not provided the code responsible for the spacing so that probably has nothing to do with smartdiagram. – cfr Jun 4 '16 at 22:09
  • Is it possible to create tree diagrams easily with smartdiagram? like this i.stack.imgur.com/v53dD.png – skan Dec 2 '16 at 23:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.