I would like to generate the following Venn diagram:
which can be generated by the following
\documentclass[tikz,margin=0pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes,intersections}
\begin{document}
\pagestyle{empty}
\makeatletter
\tikzset{
use path for main/.code={%
\tikz@addmode{%
\expandafter\pgfsyssoftpath@setcurrentpath\csname tikz@intersect@path@name@#1\endcsname
}%
},
use path for actions/.code={%
\expandafter\def\expandafter\tikz@preactions\expandafter{\tikz@preactions\expandafter\let\expandafter\tikz@actions@path\csname tikz@intersect@path@name@#1\endcsname}%
},
use path/.style={%
use path for main=#1,
use path for actions=#1,
}
}
\makeatother
\begin{tikzpicture}
\path[name path=XCircle] (-0.8cm,0) circle (1.5cm);
\path[name path=YCircle] (0.8cm,0) circle (1.5cm);
\path[name path=WholeSet] (-2.3cm,-1.5cm) rectangle (2.3,1.5);
\begin{scope} [even odd rule]
\clip (0.8cm,0) circle (1.5cm) (-2.3cm,-1.5cm) rectangle (2.3,1.5);
\draw [use path=XCircle, fill=gray!70];
\end{scope}
\draw [use path=XCircle];
\draw [use path=YCircle];
\end{tikzpicture}
\end{document}
However, I wish to use use path
rather than directly specify the shapes, i.e., I wish to replace the line \clip (0.8cm,0) circle (1.5cm) (-2.3cm,-1.5cm) rectangle (2.3,1.5);
by something like \clip [use path=YCircle, use path=WholeSet];
. However, the line I wrote above will generate the wrong output:
My question is: How can I get even odd clipping and use path=
to work together?
use path
can't be used multiple times in one path:\draw[red,use path=YCircle, use path=WholeSet];
ony draws the last given path.