I know there are many threads on Venn diagrams with tikz, however I could not find this specific case. I would like to fill the complement of the disjunction of p and q. Graphically, this would be everything in the rectangle except for the two circles (which should be white). I have a working example, where I first fill the rectangle and the conjunction of p and q, and then fill of white the conjunction. However, this seems unnecessarily artificial, so I feel there probably is a better way of doing it. (It's done implicitly here but my tikz is not very good so I am not understanding clearly. Moreover it looks like overkill for what I need)

My code:



\def\bigrectangle{(-2,-2) rectangle (3,2)}
\def\firstcircle{(0,0) circle (1)}
\def\secondcircle{(1,0) circle (1)}

% fill rectangle and conjunction
    \clip \firstcircle \secondcircle \bigrectangle;
    \fill[blue] \bigrectangle;

% fill conjunction white
    \clip \secondcircle;
    \fill[white] \firstcircle;

% outline
\draw \firstcircle (0,1) node [text=black,above] {$p$}
      \secondcircle (1,1) node [text=black,above] {$q$}
      \bigrectangle node [text=black,above] {$U$};



This is the result:

Looks right but code is weird

  • Why are you using the scope blocks at all? You can get the same output with just \fill[blue!20] \bigrectangle; \fill[white] \firstcircle \secondcircle;
    – Thruston
    May 15 '17 at 11:34

enter image description here




You can change colors, labels, etcetera, easily as described in the package documentation.

  • 1
    While this works for 2 sets, it does not seem to work for 3 sets, does anyone know another method except for \fillNotAorBorC ?
    – PolkaDot
    Aug 3 '20 at 10:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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