11

This is what I would like to achieve:

enter image description here

My MWE is below:

\documentclass{article}
\pagestyle{empty}

\usepackage{lmodern}

\usepackage{smartdiagram}
\usetikzlibrary{shapes.geometric}
\usetikzlibrary{positioning}

\tikzstyle{every picture}+=[remember picture]

\smartdiagramset{%
circular distance=40mm,
font=\normalsize,
text width=20mm,
module minimum width=30mm,
module minimum height=30mm,
module shape=diamond,
arrow tip=to,
%uniform arrow color=true,
arrow color=gray!50!black,
border color=black,
set color list={white,white,white,white,white,white}
}

\tikzstyle{mystyle}=[align=center,fill=white,drop shadow,draw,thick,circle,overlay,minimum width=20mm,text width=25mm]

\begin{document}
~\vfill
\smartdiagram[circular diagram]{a, b, c, d, e, f}
\tikz \node (a) [mystyle,above=10mm of module1] {Start}; 
\tikz \node (b) [mystyle,right=10mm of module6] {Finish};
\begin{tikzpicture}[overlay,>=to]
\path[->,gray!50!black,line width=3pt,fill=gray!50!black] (a) edge (module1);
\path[->,gray!50!black,line width=3pt,fill=gray!50!black] (module6) edge (b);
\end{tikzpicture}
\vfill
\end{document}

I would achieve a similar result in a more intuitive way. As you can see I needed to go inside smartdiagram.sty to know how the nodes were named, and then I need to use the overlay. Moreover, suggestions for start and finish are welcome.

cacamailg
  • 8,405

1 Answers1

11

With version 0.3 (already sent on CTAN and thus available on TeXLive in few days) of the package to create such a diagram is a bit easier.

The code:

\documentclass[12pt]{article} 
\usepackage{smartdiagram}
\usesmartdiagramlibrary{additions} % library to create annotations 
\usetikzlibrary{shapes.geometric}
\begin{document} 
\begin{center}
\smartdiagramset{%
 circular distance=40mm,
 text width=20mm,
 module minimum width=30mm,
 module minimum height=30mm,
 module shape=diamond,
 arrow tip=to,
 uniform arrow color=true,
 arrow color=gray!50!black,
 border color=black,
 uniform color list=white for 6 items, % new key to make colors uniform easily
 circular final arrow disabled=true, % new key to remove the final arrow
 additions={
   additional item offset=15mm,
   additional item shape=circle,
   additional item border color=black,
   additional item shadow=drop shadow,
   additional arrow color=gray!50!black,
 }
}
\smartdiagramadd[circular diagram]{a, b, c, d, e, f}{
above of module1/Start,right of module6/End}
\smartdiagramconnect{-to}{additional-module1/module1}
\smartdiagramconnect{-to}{module6/additional-module2}
\end{center}
\end{document}

The result:

enter image description here

This method does not suffer anymore of the limitation on the number of additions that can be added.


First version

First of all a disclaimer: the solution I provide works if and only if one has to add just a start and an end to the diagrams.

It provides a new command \smartdiagramadd able to set the usual diagram plus the start/end: it receives 3 arguments:

  1. type of diagram
  2. list of elements in the diagram
  3. position/text of the start, position/text of the end (for example: above/Start,right/End).

It can be used as:

\smartdiagramadd[circular diagram]{a, b, c, d, e, f}{above/Start,right/End}

Moreover, the solution allows to customize the distance of the start/end modules by means of two new keys:

\pgfkeys{/smart diagram/.cd,
  add start module offset/.initial=10mm,
  add start module offset/.get=\addstartmodoffset,
  add start module offset/.store in=\addstartmodoffset,
  add end module offset/.initial=10mm,
  add end module offset/.get=\addendmodoffset,
  add end module offset/.store in=\addendmodoffset,
}

They should be used always within \smartdiagramset; for example:

\smartdiagramset{add end module offset=20mm}

Now, the code:

\documentclass{article}
\pagestyle{empty}

\usepackage{lmodern}

\usepackage{smartdiagram} \usetikzlibrary{shapes.geometric} \usetikzlibrary{positioning}

\pgfkeys{/smart diagram/.cd, add start module offset/.initial=10mm, add start module offset/.get=\addstartmodoffset, add start module offset/.store in=\addstartmodoffset, add end module offset/.initial=10mm, add end module offset/.get=\addendmodoffset, add end module offset/.store in=\addendmodoffset, }

\smartdiagramset{% circular distance=40mm, font=\normalsize, text width=20mm, module minimum width=30mm, module minimum height=30mm, module shape=diamond, arrow tip=to, uniform arrow color=true, arrow color=gray!50!black, border color=black, set color list={white,white,white,white,white,white} }

\tikzset{module start-end/.style={ align=center, fill=white, drop shadow, draw, thick, circle, minimum width=20mm, text width=25mm} }

\NewDocumentCommand{\smartdiagramadd}{r[] m m}{ \tikzstyle{every picture}+=[remember picture] \smartdiagram[#1]{#2} \begin{tikzpicture}[overlay] \foreach \smitem [count=\xi] in {#2} {\global\let\numitems\xi} \StrCut{#3}{,}\startdiagram\enddiagram % start \StrCut{\startdiagram}{/}\pos\textitem \node (module1-start) [module start-end,\pos=\addstartmodoffset of module1] {\textitem}; \path[->,gray!50!black,line width=3pt,fill=gray!50!black] (module1-start) edge (module1); % end \StrCut{\enddiagram}{/}\pos\textitem \node (module\numitems-end) [module start-end,\pos=\addendmodoffset of module\numitems] {\textitem}; \path[->,gray!50!black,line width=3pt,fill=gray!50!black] (module\numitems) edge (module\numitems-end); \end{tikzpicture} }

\begin{document} \begin{center} \smartdiagramset{add end module offset=20mm} \smartdiagramadd[circular diagram]{a, b, c, d, e, f}{above/Start,right/End} \end{center} \end{document}

which gives (similar to the picture provided by the OP, but the end module is far):

enter image description here

Disclaimer

This solution just work with smartdiagram version 0.2 which already loads xstring, otherwise the package should be loaded separately.

  • 2
    This is a wonderful improvement for the package: thanks cacamailg. I even realize that in order to have an uniform color also for the modules a new key should be added (similar to what happens for arrows) because the actual solution is not practicable (set a whole list of white). These will be the next things implemented :) – Claudio Fiandrino Mar 17 '13 at 11:15
  • Thanks. The solution can still be improved. For example, I would like to have an open circular diagram, this is, between a and f no arrow. A new key, e.g., \smartdiagramaddnode for adding nodes above, below, in between two nodes would be good. Also, if you want to add a new arrow for an node outside the circle, there is no easy way to do it. – cacamailg Mar 17 '13 at 11:52
  • @cacamailg: there's always room for improvements :) I think the open circular diagram can be easily done; something more difficult can be the \smartdiagramaddnode (are you think about it for some annotations?), but in principle could be addressed, even if I think in between two nodes may require a bit of work. However, to keep clear the site is always better ask one question at a time. – Claudio Fiandrino Mar 17 '13 at 18:22
  • Yes. I was just giving you ideas to improve your package :P. – cacamailg Mar 17 '13 at 21:49
  • @ClaudioFiandrino I have a problem where I can't seem to put text on top of the arrows, are you able to help me? – 3kstc Jan 10 '19 at 03:08