Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I want to write a macro that uses TikZ to create a photo like this:

example.

But, finally I came up with something like this:

TikZ Picture

As you see, the problem is that the arrows go to the wrong side of the end circle (they always go to the right side). Here is the source code of my example:

\documentclass[11pt]{scrartcl}
\usepackage[utf8]{inputenc}  
\usepackage{tikz}
\usetikzlibrary{calc} 
\makeatletter 
\@namedef{color@1}{red!40}
\@namedef{color@2}{green!40}   
\@namedef{color@3}{blue!40} 
\@namedef{color@4}{cyan!40}  
\@namedef{color@5}{magenta!40} 
\@namedef{color@6}{yellow!40}    

\newcommand{\graphitemize}[1]{%
\begin{tikzpicture}[every node/.style={align=center}]  

\foreach \gritem [count=\xi] in {#1}  {\global\let\maxgritem\xi}  

\foreach \gritem [count=\xi] in {#1}
{% 
\pgfmathtruncatemacro{\angle}{360/\maxgritem*\xi}
\edef\col{\@nameuse{color@\xi}}
\node[circle,
     ultra thick,
     draw=white,
     fill opacity=.5,
     fill=\col,
     minimum size=3cm] (satellite\xi) at (\angle:4cm) {\gritem };
}%

\foreach \gritem [count=\xi] in {#1}
{% 
\pgfmathsetmacro{\xj}{mod(\xi, \maxgritem) + 1}
\edef\col{\@nameuse{color@\xi}}
\draw[<-,line width=.5cm,opacity=.5,\col] (satellite\xj) to[bend left] (satellite\xi);
}%
\end{tikzpicture}  
}%

\begin{document}

\graphitemize{Phase 1,Phase 2, Phase 3, Phase 4}

\end{document} 

Note that I adapted the code from Altermundus answer to this question. How can I fix the end position of the arrows?

share|improve this question
2  
You should wrap your \draw command for the arrows in \begin{scope}[opacity=.5,transparency group] ... \end{scope} to make sure that the arrow lines and arrow tips have the same colour. Also, note that fill opacity=0.5 also makes the text semitransparent in your nodes, so you should set text opacity=1 after fill opacity. Lastly, if there are no objects behind the graph, you might as well just choose lighter colours, instead of using transparency. –  Jake Apr 23 '12 at 8:20
1  
Indeed, instead of opacity=.5,\col you can use \col\relax!0.5. –  percusse Apr 23 '12 at 8:21
1  
I don't know if we have a canonical "What are legal TikZ node names" or not, but maybe we should! In the meantime, here's a similar situation: tex.stackexchange.com/a/28242/86 –  Loop Space Apr 23 '12 at 8:29
    
@AndrewStacey I read percusse's answer after your comment :( –  Alain Matthes Apr 23 '12 at 8:59

1 Answer 1

up vote 11 down vote accepted

The problem comes from the math operation mod(\xi, \maxgritem) + 1. TikZ is giving the result with a number with decimal point such as 1.0, 2.0 etc. and later since you use it in the node naming it becomes satellite1.0,satellite2.0. Coincidentally, this means that the arrow shoud go to the node border at zero angle, hence the weird right side tracking.

You can fix it easily by replacing the operation line with

\pgfmathtruncatemacro{\xj}{mod(\xi, \maxgritem) + 1)} 
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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