# Symmetric difference

> The elements in exactly one of A and B, shaded with the even-odd fill rule. A Venn and Euler diagrams example with its LaTeX source.

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

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

Tags: venn, symmetric difference, sets

## Source

```latex
\begin{tikzpicture}[thick]
  \fill[blue!25, even odd rule] (-0.75,0) circle (1.4) (0.75,0) circle (1.4);
  \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[above left] at (2.8,-1.9) {$U$};
  \node[below] at (0,-1.9) {$A \mathbin{\triangle} 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]
  \fill[blue!25, even odd rule] (-0.75,0) circle (1.4) (0.75,0) circle (1.4);
  \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[above left] at (2.8,-1.9) {$U$};
  \node[below] at (0,-1.9) {$A \mathbin{\triangle} B$};
\end{tikzpicture}
\end{document}
```
