4

This question already has an answer here:

\begin{tikzpicture}[fill=gray]
    \scope
        \clip (2.7,-2.54) rectangle (-1.5,1.5)
         (0,0) circle (1)
         (1.2,0) circle (1);
         \fill (0.6,-1.04) circle (1);
    \endscope
        \draw (0,0) circle (1) (0,1)  node [text=black,above] {$A$}
              (1.2,0) circle (1) (0,1)  node [text=black,above right,shift={(1,0.01)}] {$B$}
              (0.6,-1.04) circle (1) (1.1,-0.6) node [text=black, shift={(0.6,-1.1)}] {$C$}
              (2.7,-2.54) rectangle (-1.5,1.5) node [text=black,above] {};
\end{tikzpicture}

This is the output of the above code - not quite what I want. If you understand the set notation in my question you'll understand that I want C to be filled in except for the little middle section of the diagram where A and B and C are all intersecting (i.e. I want to not shade in the region corresponding to the set whose members are common to A and B and C).

I am not smart enough to work out how to use clipping to achieve this. Please help me!

marked as duplicate by Zarko, Stefan Pinnow, barbara beeton, TeXnician, Mensch Aug 14 '17 at 13:23

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    Hi there! I recommend putting "venn" into the search box in texample.net You'll get many useful examples which should be helpful. Also, there is a tutorial on Venn diagrams on our website: tex.stackexchange.com/a/9682/11002 – yo' Aug 14 '17 at 7:39
  • Welcome to TeX.SX! – Bobyandbob Aug 14 '17 at 7:45
  • Attention all! Feel free to try to answer this question as I've set it up, but I've decided to simply insert an image of a Venn Diagram into my document for this case – Noam Hudson Aug 14 '17 at 7:46
10

You can use the vendiagram package. Its very easy to use. Do you mean something like this?

\documentclass[]{article}
\usepackage{tikz,venndiagram}

\begin{document}

\begin{venndiagram3sets}
\fillOnlyC
\fillBCapCNotA
\fillACapCNotB
\end{venndiagram3sets}
\[ C\setminus (A \cap B \cap C) \]
\end{document}

enter image description here

5

The following code should do what you want (based on http://www.texample.net/tikz/examples/venn-diagram/):

\documentclass[border=2mm]{standalone}

\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
\fill[gray] (0.6,-1.04) circle (1);
\begin{scope}
  \clip (0.6,-1.04) circle (1);
  \clip (1.2,0) circle (1);
  \fill[white] (0,0) circle (1);
\end{scope}
\draw (0,0) circle (1) (0,1) node [text=black,above] {$A$};
\draw (1.2,0) circle (1) (1,1.01) node [text=black,above right] {$B$};
\draw (0.6,-1.04) circle (1) (1.7,-1.7) node [text=black] {$C$};

\draw (2.7,-2.54) rectangle (-1.5,1.5);
\end{tikzpicture}

\end{document}

Output

  • I did not know that you can use two clip commands in the same scope. I like your answer better than mine. – crixstox Aug 14 '17 at 11:51
5

Requested Answer for C \setminus (A \cap B \cap C)

To draw enter image description here you can nest two scopes and clips as follows.

\begin{tikzpicture}
    % frame
    \draw (2.7,-2.54) rectangle (-1.5,1.5);
    % area
    \fill[gray] (0.6,-1.04) circle (1);
    \begin{scope}
        \clip (0.6,-1.04) circle (1) (1.1,-0.6);
        \begin{scope}
            \clip (0,0) circle (1);                
            \fill[white] (1.2,0) circle (1) (0,1);
        \end{scope}
    \end{scope}
    % outline
    \draw (0,0) circle (1) (0,1)  node [text=black,above] {$A$};
    \draw (1.2,0) circle (1) (0,1)  node [text=black,above right,shift={(1,0.01)}] {$B$};
    \draw (0.6,-1.04) circle (1) (1.1,-0.6) node [text=black, shift={(0.6,-1.1)}] {$C$};
\end{tikzpicture}

enter image description here


Not requested answer for C \setminus (A \cap B)

To draw enter image description here you do not need neither clipping nor the "even odd rule", just draw circle in the right order.

\begin{tikzpicture}
    % frame
    \draw (2.7,-2.54) rectangle (-1.5,1.5);
    % area
    \fill[gray] (0.6,-1.04) circle (1);
    \fill[white] (0,0) circle (1) (0,1);
    \fill[white] (1.2,0) circle (1);
    % outline
    \draw (0,0) circle (1) (0,1)  node [text=black,above] {$A$};
    \draw (1.2,0) circle (1) (0,1)  node [text=black,above right,shift={(1,0.01)}] {$B$};
    \draw (0.6,-1.04) circle (1) (1.1,-0.6) node [text=black, shift={(0.6,-1.1)}] {$C$};
\end{tikzpicture}

This gives the result.

enter image description here

  • 4
    This is not the needed drawing, I'm afraid. – egreg Aug 14 '17 at 9:03
  • @egreg How embarrassing, you are completely right! Thanks for pointing it out. I added another (now hopefully right) solution. – crixstox Aug 14 '17 at 10:30
  • Apparently the second scope it unnecessary according to this answer, which is better than mine. – crixstox Aug 14 '17 at 11:49

Not the answer you're looking for? Browse other questions tagged or ask your own question.