# Set difference

> A minus B: the part of A outside B is shaded. A Venn and Euler diagrams example with its complete LaTeX source, ready to copy or open in TeXeR.

A Venn and Euler diagrams example in the TeXeR TikZ library: https://texer.org/library/set-diagrams/set-difference

Package: [Venn and Euler diagrams](https://texer.org/library/set-diagrams.md), on CTAN at https://ctan.org/pkg/pgf.

Tags: venn, difference, complement, sets

## Source

```latex
\begin{tikzpicture}[thick]
  \begin{scope}
    \clip (-0.75,0) circle (1.4);
    \fill[orange!35] (-3,-2) rectangle (3,2);
    \fill[white] (0.75,0) circle (1.4);
  \end{scope}
  \draw (-0.75,0) circle (1.4) (0.75,0) circle (1.4);
  \draw (-2.8,-1.9) rectangle (2.8,1.9);
  \node at (-1.95,1.3) {$A$};
  \node at (1.95,1.3) {$B$};
  \node[below] at (0,-1.9) {$A \setminus B$};
\end{tikzpicture}
```

## As a complete document

The same example in a document that compiles on its own with pdfLaTeX:

```latex
\documentclass[margin=3mm]{standalone}
\usepackage{tikz}
\usepackage{xcolor}
\usepackage{amsmath}
\usepackage{amssymb}

\begin{document}
\begin{tikzpicture}[thick]
  \begin{scope}
    \clip (-0.75,0) circle (1.4);
    \fill[orange!35] (-3,-2) rectangle (3,2);
    \fill[white] (0.75,0) circle (1.4);
  \end{scope}
  \draw (-0.75,0) circle (1.4) (0.75,0) circle (1.4);
  \draw (-2.8,-1.9) rectangle (2.8,1.9);
  \node at (-1.95,1.3) {$A$};
  \node at (1.95,1.3) {$B$};
  \node[below] at (0,-1.9) {$A \setminus B$};
\end{tikzpicture}
\end{document}
```
