6

I have the following LaTeX-Code:

\documentclass{article}
\usepackage[pdftex,active,tightpage]{preview}
\setlength\PreviewBorder{2mm}
\usepackage{tikz}
\usetikzlibrary{shapes, calc, shapes,snakes} 
\usepackage{amsmath,amssymb}

\begin{document}
\begin{preview}
\begin{tikzpicture}[thick]
    \newcommand\XC{4}
    \newcommand\ALPHA{30}

    \newcommand\XB{{(\XC*(cos(\ALPHA)*cos(\ALPHA) - sin(\ALPHA)*sin(\ALPHA)) + \XC)*0.5}}
    \newcommand\YB{{sqrt(cos(\ALPHA)*\XC*cos(\ALPHA)*\XC - (\XC*(cos(\ALPHA)*cos(\ALPHA) - sin(\ALPHA)*sin(\ALPHA)) + \XC)*0.5*(\XC*(cos(\ALPHA)*cos(\ALPHA) - sin(\ALPHA)*sin(\ALPHA)) + \XC)*0.5)}}

    \newcommand\XBo{{(\XB)+4}}
    \newcommand\YBo{{\YB}}
    \newcommand\XBp{{\XB*0.5}}
    \newcommand\YBp{{\YB*0.5}}

    % Draw the triangle
    \draw[fill=gray!10]  (0,    0) coordinate (A) 
        -- (\XB,\YB) coordinate (C) 
        -- (\XC,  0) coordinate (B) 
        -- (0,    0);

    % Draw nodes
    \node at (A)[anchor=north] {A};
    \node at (B)[anchor=north] {B};
    \node at (C)[anchor=south] {C};

    % Draw edge text
    \node (c) at ($(A)!0.5!(B)$) [below] {c};
    \node (b) at ($(A)!0.5!(C)$) [above] {b};
    \node (a) at ($(B)!0.6!(C)$) [right] {a};


    % draw alpha
    \draw[fill=green!30] (0,0) -- (0:0.75cm) arc (0:\ALPHA:.75cm);
    \coordinate[label=right:$\alpha$] (Alpha) at (0.25,0.15);

    % draw beta
    \begin{scope}[shift={(\XC, 0)}]
        \draw[fill=red!30] (0,0) -- (-180:0.50cm) arc (180:{180-(90-\ALPHA)}:0.5cm);
        \draw (150:0.35cm) node {$\beta$};
    \end{scope}

    % draw gamma
    \begin{scope}[shift={(\XB, \YB)}]
        \draw[fill=blue!30] (0,0) -- ({180+\ALPHA}:0.5cm) arc ({180+\ALPHA}:{180+\ALPHA+90}:0.5cm);
        \draw (-0.1, -0.05) node[below] {$\gamma$};
    \end{scope}


    % shifted alpha
    \begin{scope}[shift={(4,0)}]
        \draw[fill=green!30] (0,0) -- (0:0.5cm) arc (0:\ALPHA:.5cm);
    \end{scope}

    % shifted gamma
    \begin{scope}[shift={(4, 0)},rotate=180]
        \draw[fill=blue!30] (0,0) -- ({180+\ALPHA}:0.5cm) arc ({180+\ALPHA}:{180+\ALPHA+90}:0.5cm);
    \end{scope}

    \begin{scope}[shift={(3.13,-0.5)}]
        \draw[dashed,red]  (0,    0)  -- (\XB,\YB);
    \end{scope}

    \draw[dashed, color=red] (-1, 0) -- (6, 0);
    \draw  (0,    0) coordinate (X) 
        -- (\XB,\YB) coordinate (Y) 
        -- (\XC,  0) coordinate (Z) 
        -- (0,    0);
\end{tikzpicture}
\end{preview}
\end{document}

That produces:

enter image description here

When you look close at the horizontal red dashed line, you can see a black line from the green angle. I would like to get rid of it without changing anything else in the image

I know, it comes from this line:

\draw[fill=green!30] (0,0) -- (0:0.5cm) arc (0:\ALPHA:.5cm);

I could get rid of the line, if I changed the code to this:

\draw[fill=green!30] (0:0.5cm) arc (0:\ALPHA:.5cm);

But then I get this:

enter image description here

The green background disappeared. How can I get green background, but not the black line?

Martin Thoma
  • 18,799
  • Do you want a black line between the purple and the green areas (under the diagonal red line)? – Jake Feb 13 '13 at 18:54
  • I don't care about this line ... ah! You think about mirroring it, don't you? That's a nice work-around! But do you also know how to draw only the ending line? – Martin Thoma Feb 13 '13 at 19:01
  • 3
    Yes, exactly. If you use \draw[fill=green!30] (0:0.5cm) arc (0:\ALPHA:.5cm) -- (0,0); you'll get the green background without the horizontal line, but the black diagonal will be drawn twice (once by the green sector, once by the purple). If you want just the green background and the arc line, you'll have to use two paths: \path[fill=green!30] (0,0) -- (0:0.5cm) arc (0:\ALPHA:.5cm); \draw (0:0.5cm) arc (0:\ALPHA:.5cm); – Jake Feb 13 '13 at 19:05
  • So, \path was what I was looking for. Don't you want to post your comment as an answer? – Martin Thoma Feb 13 '13 at 19:20
  • Glad it helps. There's already quite a nice answer about filling without drawing at http://tex.stackexchange.com/questions/82530/how-to-draw-a-filled-rectangle-without-a-border-using-tikz, so I think it's best if we just close this as a duplicate. It'll make it easier for others to find the other answer, and it's good to avoid duplication of answers. – Jake Feb 13 '13 at 19:23
  • Ok. I voted for closing this question. Thanks for your help! – Martin Thoma Feb 13 '13 at 19:39

0 Answers0