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:
\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\pagestyle{empty}
\begin{document}
\begin{tikzpicture}
\def\bigrectangle{(-2,-2) rectangle (3,2)}
\def\firstcircle{(0,0) circle (1)}
\def\secondcircle{(1,0) circle (1)}
% fill rectangle and conjunction
\scope
\clip \firstcircle \secondcircle \bigrectangle;
\fill[blue] \bigrectangle;
\endscope
% fill conjunction white
\scope
\clip \secondcircle;
\fill[white] \firstcircle;
\endscope
% outline
\draw \firstcircle (0,1) node [text=black,above] {$p$}
\secondcircle (1,1) node [text=black,above] {$q$}
\bigrectangle node [text=black,above] {$U$};
\end{tikzpicture}
\end{document}
This is the result:
scope
blocks at all? You can get the same output with just\fill[blue!20] \bigrectangle; \fill[white] \firstcircle \secondcircle;