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 am currently trying to improve the images of some basic geometry articles in Wikipedia. One image I have improved is the of an Arbelos (en).

This is the LaTeX-Code:

\documentclass{article}
\usepackage[pdftex,active,tightpage]{preview}
\setlength\PreviewBorder{2mm}
\usepackage{tikz}

\begin{document}
\begin{preview}
\begin{tikzpicture}

    % Draw A
    \coordinate[label=left:$A$]  (A) at (0,0);

    \begin{scope}[shift={(4,0)}]
        % big half-circle from A to B
        \draw[thick,fill=green!30] (0,0) -- (0:4cm) arc (0:180:4cm);

        % Draw D
        \coordinate[label=below:$D$] (D) at (2,0);

        % Perpendicular CD
        \draw[thick] (2,0) -- node[] {} (2,3.47);

        % Draw C
        \coordinate[label=above:$C$] (C) at (2,3.47);
    \end{scope}

    \begin{scope}[shift={(3,0)}]
        % Crop circle AD from the big green circle AB
        % This is the one I would like to be transparent
        \draw[thick,fill=white] (0,0) -- (0:3cm) arc (0:180:3cm);

        % Draw B
        \coordinate[label=below:$B$] (B) at (5,0);
    \end{scope}

    % Circle DB - should also be transparent
    \draw[thick,fill=white] (7,0) -- (8cm,0) arc (0:180:1cm);

    % Cirlce CD
    \draw[thick] (6,1.735) circle (1.735cm);

    % I have to draw this one, as "arc" doesn't completely 
    % draw the line AB
    \draw[thick] (0,0) -- node[] {} (8,0);
  \end{tikzpicture}
\end{preview}
\end{document}

It is working and looks like that:

enter image description here

Looks fine, except that the two circles AD and DB are white, not transparent. Take a look at the SVG for that: File:Arbelos-tikz.svg. How can I overwrite the green filled circle with transparent / crop this part out of the green circle?

(If it is possible to make this piece of LaTeX-Code simpler, please let me know.)

share|improve this question
add comment

4 Answers

up vote 13 down vote accepted

Maybe this?

\documentclass{standalone}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
\draw[fill=green](-1,0) arc (180:0:1) arc (0:180:0.3) arc (0:180:0.7);
\end{tikzpicture}
\end{document}

enter image description here

share|improve this answer
    
looks like part of your Batman work :) –  cmhughes Jul 12 '12 at 15:05
    
@cmhughes Heheh, indeed this is the supplementary batarang accessories. –  percusse Jul 12 '12 at 15:07
    
@percusse: Very nice! Thank you very much! I still need the rest of the picture (the lines AB and CD, the points A, B, C, D, the circle CD and the margin), so it's not that short, but now its much better than my previous version. I've published the LaTeX-Source Code on commons.wikimedia.org/wiki/File:Arbelos-tikz.svg –  moose Jul 12 '12 at 15:16
1  
@moose Ah, of course but I knew that you can simply replace the relevant part. By the way, great work on Wiki. –  percusse Jul 12 '12 at 15:19
add comment

Just to add an tkz-euclide answer. I am sure Altermondus can improve this answer.

\documentclass{standalone}
\usepackage{tkz-euclide}
\usetkzobj{all}
\begin{document}
\begin{tikzpicture}[scale=2]
\tkzInit[xmin=-1,xmax=6,ymax=5,ymin=-1] \tkzClip
\def\a{0.75}
\tkzDefPoint(0,0){A}            \tkzDefPoint(5,0){B}
\tkzDefMidPoint(A,B)            \tkzGetPoint{M1}
\tkzCalcLength[cm](A,B)         \tkzGetLength{dAB}
\pgfmathsetmacro{\r}{\a*\dAB} 
\tkzInterLC[R](A,B)(A,\r cm)    \tkzGetPoints(D)

\tkzDefLine[orthogonal=through D](A,D)
\tkzInterLC(D,tkzPointResult)(M1,A) \tkzGetFirstPoint{C}

\tkzDefMidPoint(D,C)            \tkzGetPoint{M2}

\draw[thick,fill=green!30!](A) arc (180:0:\dAB/2) arc (0:180:\dAB/2-\r/2) arc (0:180:\r/2);
\tkzDrawCircle[thick](M2,D)
\tkzDrawSegments[thick](A,B C,D)

\tkzLabelPoints[below](A,B,D) \tkzLabelPoints[above right](C)
\end{tikzpicture}
\end{document}

enter image description here

The pros of doing it this way is that you can move A and B around, and everything still works. The point D is defined as \a * length of AB. So to get D closer you B you would increase a. Where 0<a<1. The major difference is that nothing is hardcoded here, everything is related to the first two points.

share|improve this answer
2  
Pretty! Now you are a pro with tkz-euclide. –  Alain Matthes Jul 12 '12 at 17:11
    
@Altermundus, there is a problem in the code. Try to set a<0.5 , then the point C is under segment AB. I know you can then use \tkzGetSecondPoint, but is there an more automatic approach ? (I might post this as a new question) –  N3buchadnezzar Jul 12 '12 at 17:30
    
No an automatic approach is actually impossible. –  Alain Matthes Jul 12 '12 at 20:01
add comment

enter image description here

\documentclass[border=2pt]{standalone}

\usepackage{pstricks}

\begin{document}
\begin{pspicture}(-1,0)(1,1)
    \pscustom[fillstyle=solid,fillcolor=green,linejoin=1,linewidth=0.4pt]
    {
        \psarc(0,0){1}{0}{180}
        \psarcn(-0.3,0){0.7}{180}{0}
        \psarcn(0.7,0){0.3}{180}{0}
        \closepath
    }
\end{pspicture}
\end{document}

We can distinguish the transparent regions from the opaque ones by not viewing the image perpendicularly. Instead view it by placing your eyes near any edge of your screen.

share|improve this answer
add comment

There is the evenodd rule which can be used:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{svg.path}
\special{background rgb .5 .5 0} % needs XeTeX
\begin{document}
\begin{tikzpicture}
  \filldraw[fill=lime,even odd rule] svg
    "M0,0 a1,1 0 0 1 100,0 h-100 a1,1 0 0 1 80,0 1,1 0 0 1 20,0";
\end{tikzpicture}
\end{document}

enter image description here

Also note that

<?xml version="1.0" standalone="no"?>
<svg xmlns="http://www.w3.org/2000/svg"
  viewBox="0 -51 100 100">
  <path fill="lime" fill-rule="evenodd" stroke="black"
    d="M0,0 a1,1 0 0 1 100,0 h-100 a1,1 0 0 1 80,0 1,1 0 0 1 20,0" />
</svg>

enter image description here

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.