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.

to me the following MWE should work:

\documentclass[a4paper,11pt]{article}

\usepackage{xunicode}% for XeTex!
\usepackage{fontspec}% for XeTex!
\usepackage{xltxtra} % for XeTex!

\usepackage[french]{babel}
\usepackage{tikz}
\usetikzlibrary{positioning}

\defaultfontfeatures{Scale=MatchLowercase}
\setromanfont[Mapping=tex−text]{Linux Libertine O}
\setsansfont [Mapping=tex−text]{Linux Biolinum O}
\setmonofont [Mapping=tex−text]{Inconsolata}

\begin{document}
\begin{figure}[ht]
\centering
\begin{tikzpicture}
[note/.style={draw,black,circle,inner sep=2mm},
label distance=-1mm,label position=below left,
double distance=.5mm]
\node[note,double]      (C)  [label=Do   ] {};
\node[note,left=of C]   (F)  [label=Fa   ] {};
\node[note,right=of C]  (G)  [label=Sol  ] {};
\node[note,right=of G]  (D)  [label=Ré   ] {};

\node[note,above=of F]  (A)  [label=La   ] {};
\node[note,right=of A]  (E)  [label=Mi   ] {};
\node[note,right=of E]  (B)  [label=Si   ] {};
\node[note,right=of B]  (Fd) [label= Fa♯] {};

\node[note,above=of A]  (Cd) [label= Do♯] {};
\node[note,right=of Cd] (Gd) [label=Sol♯] {};
\node[note,right=of Gd] (Dd) [label= Ré♯] {};
\node[note,right=of Dd] (Ad) [label= La♯] {};

%\draw (F)  -- (C)  -- (G)  -- (D);
%\draw (A)  -- (E)  -- (B)  -- (Fd);
%\draw (Cd) -- (Gd) -- (Dd) -- (Ad);
%
%\draw (F) -- (A)  -- (Cd);
%\draw (C) -- (E)  -- (Gd);
%\draw (G) -- (B)  -- (Dd);
%\draw (D) -- (Fd) -- (Ad);

\begin{scope}[fill=black!50]
\filldraw (C) -- (E)  -- (G) -- cycle; % DOM
\filldraw (A) -- (Cd) -- (E) -- cycle; % LAm
\end{scope}

\draw[dashed] (Cd.north) -- +(0cm ,6mm );
\draw[dashed] (Gd.north) -- +(0cm ,6mm );
\draw[dashed] (Dd.north) -- +(0cm ,6mm );
\draw[dashed] (Ad.north) -- +(0cm ,6mm );
\draw[dashed] (F.south)  -- +(0cm ,-6mm);
\draw[dashed] (C.south)  -- +(0cm ,-6mm);
\draw[dashed] (G.south)  -- +(0cm ,-6mm);
\draw[dashed] (D.south)  -- +(0cm ,-6mm);
\draw[dashed] (F.west)   -- +(-6mm,0cm );
\draw[dashed] (A.west)   -- +(-6mm,0cm );
\draw[dashed] (Cd.west)  -- +(-6mm,0cm );
\draw[dashed] (Ad.east)  -- +(6mm ,0cm );
\draw[dashed] (Fd.east)  -- +(6mm ,0cm );
\draw[dashed] (D.east)   -- +(6mm ,0cm );
\end{tikzpicture}
\end{figure}
\end{document}

But I do not get the desired result, that is 2 filled triangles with black!50. Instead I get this : Cayley graph

Any reason why? Do you get the same result?

share|improve this question
    
You can try \filldraw (C.center) -- (E.center) -- (G.center) -- cycle; –  Alain Matthes Jul 31 '12 at 7:25
add comment

2 Answers

up vote 5 down vote accepted

enter image description here

\documentclass[a4paper,11pt]{article}

\usepackage{xunicode}% for XeTex!
\usepackage{fontspec}% for XeTex!
\usepackage{xltxtra} % for XeTex!

\usepackage[french]{babel}
\usepackage{tikz}
\usetikzlibrary{positioning}

\defaultfontfeatures{Scale=MatchLowercase}
\setromanfont[Mapping=tex−text]{Linux Libertine O}
\setsansfont [Mapping=tex−text]{Linux Biolinum O}
\setmonofont [Mapping=tex−text]{Inconsolata}

\begin{document}
\begin{figure}[ht]
\centering
\begin{tikzpicture}
[note/.style={draw,black,circle,inner sep=2mm},
label distance=-1mm,label position=below left,
double distance=.5mm]
\node[note,double]      (C)  [label=Do   ] {};
\node[note,left=of C]   (F)  [label=Fa   ] {};
\node[note,right=of C]  (G)  [label=Sol  ] {};
\node[note,right=of G]  (D)  [label=Ré   ] {};

\node[note,above=of F]  (A)  [label=La   ] {};
\node[note,right=of A]  (E)  [label=Mi   ] {};
\node[note,right=of E]  (B)  [label=Si   ] {};
\node[note,right=of B]  (Fd) [label= Fa♯] {};

\node[note,above=of A]  (Cd) [label= Do♯] {};
\node[note,right=of Cd] (Gd) [label=Sol♯] {};
\node[note,right=of Gd] (Dd) [label= Ré♯] {};
\node[note,right=of Dd] (Ad) [label= La♯] {};

%\draw (F)  -- (C)  -- (G)  -- (D);
%\draw (A)  -- (E)  -- (B)  -- (Fd);
%\draw (Cd) -- (Gd) -- (Dd) -- (Ad);
%
%\draw (F) -- (A)  -- (Cd);
%\draw (C) -- (E)  -- (Gd);
%\draw (G) -- (B)  -- (Dd);
%\draw (D) -- (Fd) -- (Ad);

\begin{scope}[fill=black!50]
\filldraw[opacity=.5] (C.center) -- (E.center)  -- (G.center) -- cycle; % DOM
\filldraw[opacity=.5]  (A.center) -- (Cd.center) -- (E.center) -- cycle; % LAm
\end{scope}

\draw[dashed] (Cd.north) -- +(0cm ,6mm );
\draw[dashed] (Gd.north) -- +(0cm ,6mm );
\draw[dashed] (Dd.north) -- +(0cm ,6mm );
\draw[dashed] (Ad.north) -- +(0cm ,6mm );
\draw[dashed] (F.south)  -- +(0cm ,-6mm);
\draw[dashed] (C.south)  -- +(0cm ,-6mm);
\draw[dashed] (G.south)  -- +(0cm ,-6mm);
\draw[dashed] (D.south)  -- +(0cm ,-6mm);
\draw[dashed] (F.west)   -- +(-6mm,0cm );
\draw[dashed] (A.west)   -- +(-6mm,0cm );
\draw[dashed] (Cd.west)  -- +(-6mm,0cm );
\draw[dashed] (Ad.east)  -- +(6mm ,0cm );
\draw[dashed] (Fd.east)  -- +(6mm ,0cm );
\draw[dashed] (D.east)   -- +(6mm ,0cm );
\end{tikzpicture}
\end{figure}
\end{document}
share|improve this answer
    
Nice! I still don't get why it doesn't work without pointing to centers, but if it works, I buy :) –  EEva Jul 31 '12 at 7:42
add comment

This issue comes up pretty often so maybe a little explanation would be suitable. When fill command is issued on open paths, TikZ automatically connects the last received point of the path with the first point of the path and fills that region (as if --cycle; is put). So

\begin{tikzpicture}
\filldraw[fill=blue!10, draw=red,thick] (0,0) -- (1,1) -- (1,0);
\end{tikzpicture}

gives

enter image description here

When we use fill on a line, it still closes the path but the result is a line again so we don't see anything regarding the fill.

\begin{tikzpicture}
\filldraw[fill=blue!10, draw=red,thick] (0,0) -- (1,1) -- (1,0);
\end{tikzpicture}

enter image description here

Now when we connect node shapes, TikZ kicks in a slightly complicated border shape calculation mechanism and it connects only the collinear points on both nodes' border, in other words it doesn't use the nodes coordinates but calculates the border locations

\begin{tikzpicture}
\node[circle,draw] (a) at (0,0) {a};
\node[draw] (b) at (1,2) {b};
\draw[draw=red,thick] (0,0) -- (1,2) ;
\draw[draw=blue,ultra thick] (a) -- (b) ;
\end{tikzpicture}

enter image description here

So continuing this path to another node gives us:

\begin{tikzpicture}
\node[circle,draw] (a) at (0,0) {a};
\node[draw] (b) at (1,2) {b};
\node[draw] (c) at (2,0) {c};
\draw[draw=red,thick] (0,0) -- (1,2) -- (2,0);
\draw[draw=blue,ultra thick] (a) -- (b) --(c);
\end{tikzpicture}

enter image description here

Hence, if we use nodes as coordinates we obtain two disjoint lines but when we use coordinates we get a continuous path. So, when a fill is issued on these paths, the first one creates two filled lines which are obviously invisible, but the second one behaves as expected.

\begin{tikzpicture}
\node[circle,draw] (a) at (0,0) {a};
\node[draw] (b) at (1,2) {b};
\node[draw] (c) at (2,0) {c};
\draw[fill=blue!10,draw=red,thick] (0,0) -- (1,2) -- (2,0);
\draw[fill=black!10,draw=blue,ultra thick] (a) -- (b) --(c);
\end{tikzpicture}

enter image description here

That's why using (node.center) works but (node) doesn't since anchors are also fixed coordinates while node shapes are usually not (except if the node is a \coordinate which has the node shape of a point.)

share|improve this answer
add comment

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.