5

The smartdiagram package appears to have a default convention that an arrow in a circular diagram takes the colour of the destination block. Is there a way to choose instead the colour of the source block as the colour of the arrow. For instance, in this example

\documentclass{article}
\usepackage{tikz}
\usepackage{smartdiagram}
\begin{document}
\smartdiagramset{set color list={red!50,orange!50,green!50}}
\smartdiagram[circular diagram:clockwise]{Red,Orange,Green}
\end{document}

I want the arrow from "Red" to "Orange" to be red instead of orange. In other words, I want to advance all arrow colours one step clockwise.

Is there a single key or other simple option to do this? If there isn't might I suggest it through this forum please?

7

Code

\documentclass[tikz,convert=false]{standalone}
\usepackage{smartdiagram}
\makeatletter
\smartdiagramset{
  flip arrow colors/.style={
    /tikz/diagram arrow type/.prefix code={%
      \edef\col{\@nameuse{color@\xi}}%
    }
  }
}
\makeatother
\begin{document}
\smartdiagramset{set color list={red!50,orange!50,green!50}}
\smartdiagram[circular diagram:clockwise]{Red,Orange,Green}

\smartdiagramset{flip arrow colors}
\smartdiagram[circular diagram:clockwise]{Red,Orange,Green}
\end{document}

Output

enter image description here enter image description here

  • 1
    Nice answer. But some explanations would be nice. – Thorsten Donig Aug 2 '13 at 14:28
  • @ThorstenDonig I don't have time right now, but the code for the circular diagram stores the value of the current element in \xi and and calculates the next value in \xj and defines \col in dependence of \xj. The diagram arrow type style uses the key \col (i.e. color=\col). We simply overwrite \col with the current color name before (prefix) the color=\col key is used. – Qrrbrbirlbel Aug 2 '13 at 15:37
  • Is it possible to create tree diagrams easily with smartdiagram? like this i.stack.imgur.com/v53dD.png – skan Dec 2 '16 at 23:36
  • 1
    @skan Unless the smartdiagram package got a big overhaul in the last two and a half years you are probably better of with one of the tree packages (like forest) or the in-house tree-creating mechanism of TikZ itself. – Qrrbrbirlbel Dec 5 '16 at 20:07
  • @Qrrbrbirlbel OK thanks, then I'll use forest or maybe I'll create the diagrams with an external program and export it to svg. – skan Dec 5 '16 at 21:04
6

Not really a "simple key" as requested, but no sorcery though because not so complex. There are two things to be done.

  1. A redefinition of the arrow style.

  2. Altering the sequence of the nodes.

The result could then look like this.

\documentclass[11pt]{article}
\usepackage[T1]{fontenc}
\usepackage{smartdiagram}

\smartdiagramset{arrow style=->}

\begin{document}
  \smartdiagramset{set color list={orange!50,red!50,green!50}}
  \smartdiagram[circular diagram:clockwise]{Orange,Red,Green}
\end{document}

The problem is that now clockwise is a bit irritating. This is due to the unconventional initial definition arrow style=<- for the direction of the arrows.


enter image description here

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.