3

I am using SmartDiagram with an additional module in a figure environment. However the additional module is being drawn outside the bounds of the figure environment:

Overlap example

How do I get the figure so it does not overlap the text?

Here is the current code I have:

\documentclass{article}
\usepackage{smartdiagram}
\usesmartdiagramlibrary{additions}
\begin{document}
Some lines of text: these should be above the diagram.
\begin{figure}[h]
    \centering
    \smartdiagramset{
     circular distance=36mm,
     text width=35mm,
     module minimum width=35mm,
     module minimum height=15mm,
     module shape=rectangle,
     arrow tip=to,
     uniform arrow color=true,
     arrow color=gray!50!black,
     border color=black,
     uniform color list=white for 6 items,
     additions={
       additional item offset=15mm,
       additional item text width=35mm,
       additional item height=15mm,
       additional item shape=rectangle,
       additional item border color=black,
       additional item shadow=drop shadow,
       additional arrow color=gray!50!black,
     }
    }
    \smartdiagramadd[circular diagram:clockwise]{
            {Second Box (2)}, 
            {Third Box (3)}, 
            {Fourth Box (4)}, 
            {Fifth Box (5)}, 
            {Sixth Box (6)}
        }{
            above of module1/{First Box (1)
        }
    }
    \smartdiagramconnect{-to}{additional-module1/module1}   
    \caption{Example diagram.}
\end{figure}
\end{document}
2
  • Apparently, the “above of module” box is ignored by the bounding box computations.
    – egreg
    Commented May 19, 2016 at 21:43
  • @egreg This is expected. The additions are added in a picture which uses the overlay option. (Page 7 of the manual.) However, the solution suggested is misleading, at best.
    – cfr
    Commented May 19, 2016 at 23:34

1 Answer 1

2

The additions are added in a separate tikzpicture environment which uses the options remember picture, overlay. Consequently, these items do not update the bounding box, as explained on page 7 of the manual. The suggestion there is to use a minipage. However, in this case, it seems just as easy to do without.

Rather than use the h specifier, I'd use a center environment and \captionof, if a caption is required. That is, if you really do not want the figure to float. If you do want it to float, if necessary, then simply use figure with \centering as in your original example.

Either way, you need to manually leave space for the additional module in the diagram. For example:

\documentclass{article}
\usepackage{smartdiagram,capt-of}
\usesmartdiagramlibrary{additions}
\begin{document}
Some lines of text: these should be above the diagram.
\begin{center}
  \vskip 30mm\par
  \smartdiagramset{
    circular distance=36mm,
    text width=35mm,
    module minimum width=35mm,
    module minimum height=15mm,
    module shape=rectangle,
    arrow tip=to,
    uniform arrow color=true,
    arrow color=gray!50!black,
    border color=black,
    uniform color list=white for 6 items,
    additions={
      additional item offset=15mm,
      additional item text width=35mm,
      additional item height=15mm,
      additional item shape=rectangle,
      additional item border color=black,
      additional item shadow=drop shadow,
      additional arrow color=gray!50!black,
    }
  }
  \smartdiagramadd[circular diagram:clockwise]{
    {Second Box (2)},
    {Third Box (3)},
    {Fourth Box (4)},
    {Fifth Box (5)},
    {Sixth Box (6)}
  }{
    above of module1/{First Box (1)
    }
  }
  \smartdiagramconnect{-to}{additional-module1/module1}
  \captionof{figure}{Example diagram.}
\end{center}
\end{document}

produces

skip to compensate

2
  • Thank you, adding the \vskip 30mm\par was all it needed. Commented May 20, 2016 at 1:26
  • Yes. It is a bit of a pain, but it is pretty much inevitable given the way the additions get added. overlay is overlaid over whatever is there, text or not. So you have to make sure it overlays empty space.
    – cfr
    Commented May 20, 2016 at 2:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .