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.

In the following, i want only outer edges. I can use fill=white to remove unwanted circle portion. How to remove unwanted edges of rectangle?

\documentclass[a4paper]{article}

\usepackage{tikz}


\begin{document}
  \begin{tikzpicture}
        \draw (0,0) circle [radius=2cm];
        \draw[fill=white] (0,1) rectangle (3,2);
  \end{tikzpicture}

\end{document}

enter image description here

When i have

  \begin{tikzpicture}
        \draw (0,0) circle [radius=2cm];
        \draw[fill=white] (0,1) rectangle (3,2);
        \path[fill=white] (0,0) circle [radius=2cm];
  \end{tikzpicture}

the circle is not thick.

share|improve this question

3 Answers 3

up vote 5 down vote accepted

The usual solution is to \clip a path, but in this case you can simply draw the circle after and use fill=white with fill opacity=1. As you want only the outer edges you can "fill" in the rectangle afterwards making an adjustment for the width of the line:

enter image description here

Code:

\documentclass[a4paper]{article}

\usepackage{tikz}
\usetikzlibrary{calc}

\begin{document}
  \begin{tikzpicture}[ultra thick]
        \draw (0,1) rectangle (3,2);
        \draw [fill opacity=1, fill=white] (0,0) circle [radius=2cm];
        \draw [draw=none,fill=white, fill opacity=1] 
                ($(0,1)+(0.5\pgflinewidth,0.5\pgflinewidth)$) rectangle ($(3,2)-(0.5\pgflinewidth,0.5\pgflinewidth)$);
  \end{tikzpicture}
share|improve this answer
    
I do not want the circle portion also. I want only outer edges. –  sandu May 13 at 4:54
    
@sandu: See updated solution. –  Peter Grill May 13 at 5:18

Here is a one-liner:

\documentclass[tikz,border=5pt]{standalone}

\begin{document}
  \begin{tikzpicture}[ultra thick]
        \draw[fill=olive!30] (3,2) -- (0,2) arc (-270:25:2cm) -| (3,2) --cycle;        
  \end{tikzpicture}
\end{document}

enter image description here

share|improve this answer

If I may, a clip method

enter image description here

Code

\documentclass[border=10pt]{standalone}%[a4paper]{article}

\usepackage{tikz}

\begin{document}
\begin{tikzpicture}[ultra thick]
\draw (0,0) circle [radius=2cm];
\draw[fill=white] (0,1) rectangle (3,2);
\begin{scope}
\clip [] (0,0) circle [radius=2cm-0.5\pgflinewidth]; 
\fill[white]  (0,0) circle [radius=2cm];
\end{scope}
\end{tikzpicture}

\end{document}
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.