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.

Hej,

I´ve got a problem with the following diagram. I want the intersection of all four circles to be white, not filled but transparent as there has to be a text in the intersection. I am appreciating any ideas...

Another question is, how to insert more "textboxes" filled with a white background, but leaving the intersections where they will be placed untouched.

Thank you very much! :)

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{shapes,backgrounds}
\usepackage{verbatim}
\begin{document}

\def\firstcircle{(0,0) circle (3 cm)}
\def\secondcircle{(45:2cm) circle (3 cm)}
\def\thirdcircle{(0:3cm) circle (3 cm)}
\def\fourthcircle{(-45:2cm) circle (3 cm)}

\begin{tikzpicture}
\draw \firstcircle node[below] {$$};
\draw \secondcircle node [above] {$$};
\draw \thirdcircle node [below] {$$};
\draw \fourthcircle node [below] {$$};

\node[draw,text width=2.5cm] at (1.5,0) {some text spanning three lines with automatic line breaks};

\begin{scope}[shift={(0cm,0cm)}, fill opacity=0.4]
   \fill[red] \firstcircle;
    \fill[black!30!green] \secondcircle;
    \fill[black!30!blue] \thirdcircle;
    \fill[black!30!violet] \fourthcircle;
   \draw \firstcircle node[below] {$$};
    \draw \secondcircle node [above] {$$};
    \draw \thirdcircle node [below] {$$};
    \draw\fourthcircle node[below]{$$};

 \draw \firstcircle node [anchor=south] at (current bounding box.north {Crassostrea gigas};
 \draw \secondcircle node [anchor=north] at (current bounding box.south) {Mytilus edulis};
 \draw \thirdcircle node [anchor=west] at (current bounding box.east) {Helix pomatia};
 \draw \fourthcircle node[anchor=east] at (current bounding box.west) {Loligo forbesi};     
 \end{scope}

 %    \begin{scope}
 %      \clip \firstcircle;
 %      \clip \secondcircle;
 %      \clip \thirdcircle;
 %      \fill[white]\fourthcircle;
 %    \end{scope}

 \end{tikzpicture}
 \end{document}`

Result, but intersection is still filled :(

share|improve this question
    
Welcome to TeX.SX! –  Kevin C Jan 22 at 0:55

1 Answer 1

up vote 4 down vote accepted

This is a solution. Some redundant draws are marked with %. The last 4 draws before the node for text is to redraw the outline the the white area.

enter image description here

Code

\documentclass[border=10pt]{standalone}

\usepackage{tikz}
\usetikzlibrary{shapes,backgrounds}
\usepackage{verbatim}
\begin{document}

\def\firstcircle {(0,0)    circle (3 cm)}
\def\secondcircle{(45:2cm) circle (3 cm)}
\def\thirdcircle {(0:3cm)  circle (3 cm)}
\def\fourthcircle{(-45:2cm)circle (3 cm)}

\begin{tikzpicture}
%\draw \firstcircle node[below] {$$};
%\draw \secondcircle node [above] {$$};
%\draw \thirdcircle node [below] {$$};
%\draw \fourthcircle node [below] {$$};

\begin{scope}[shift={(0cm,0cm)}, fill opacity=0.4]
    \fill[red]            \firstcircle;
    \fill[black!30!green] \secondcircle;
    \fill[black!30!blue]  \thirdcircle;
    \fill[black!30!violet]\fourthcircle;
%\end{scope}          % <-- Move the \end{scope} to here for clear labels.
%   \draw \firstcircle  node[below] {$$};
%   \draw \secondcircle node [above] {$$};
%   \draw \thirdcircle  node [below] {$$};
%   \draw\fourthcircle  node[below]{$$};
 \draw \firstcircle  node [anchor=south] at (current bounding box.north) {Crassostrea gigas};
 \draw \secondcircle node [anchor=north] at (current bounding box.south) {Mytilus edulis};
 \draw \thirdcircle  node [anchor=west] at (current bounding box.east) {Helix pomatia};
 \draw \fourthcircle node[anchor=east] at (current bounding box.west) {Loligo forbesi};     
 \end{scope}          % <-- move this line up will get a clear labels for circle names. It has opacity=0.4 currently.

 \begin{scope}
   \clip \firstcircle;
   \clip \secondcircle;
   \clip \thirdcircle;
   \fill[white]\fourthcircle;
 \end{scope}
  \draw \firstcircle;
  \draw \secondcircle;
  \draw \thirdcircle;
  \draw \fourthcircle;
  \node[draw,text width=2.5cm] at (1.5,0) {some text spanning three lines with automatic line breaks};
 \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.