Problem:
Two minor issues which I have not been able to solve.
- How do I fill the intersection for the second figure (on the right)?
- How do I create "padding" or more "air" around the circles in each box?
Additional issue:
Why is the rectangle for figure 2 higher than figure 1? The code is identical for the two boxes.
Minimal Working Example (MWE):
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{backgrounds,positioning,calc}
\usepackage{float}
\usepackage{showframe}
\begin{document}
\begin{figure}[H]
\centering
\begin{minipage}[t]{0.45\textwidth}
\begin{tikzpicture}[show background rectangle]
% Sets colors for cirlces
\colorlet{circle edge}{black}
\colorlet{circle area}{gray!50}
% Sets style for filled and outline
\tikzset{
filled/.style={fill=circle area, thick,inner sep=0pt},
outline/.style={draw=circle edge, thick,inner sep=0pt}}
% The circles
\node (secondcircle) [circle,filled,text width=3cm] {};
\node (firstcircle) [circle,filled,left=-1cm of secondcircle,outline,text width=3cm] {};
\draw [outline] (secondcircle) circle (1.5cm);
% The labels
\node at ([xshift=-0.15cm]firstcircle) {$A$};
\node at ([xshift=0.4cm]secondcircle) {$B$};
\end{tikzpicture}
\caption{$\mathbf{A} \cup \mathbf{B}$}
\label{fig:venncup}
\end{minipage}
\hspace{0.02\linewidth}
\begin{minipage}[t]{0.45\textwidth}
\begin{tikzpicture}[show background rectangle]
% Sets colors for cirlces
\colorlet{circle edge}{black}
\colorlet{circle area}{gray!50}
% Sets style for filled and outline
\tikzset{
filled/.style={fill=circle area, thick,inner sep=0pt},
outline/.style={draw=circle edge, thick,inner sep=0pt}}
% The circles
\node (secondcircle) [circle,fill=white,text width=3cm] {};
\node (firstcircle) [circle,left=-1cm of secondcircle,outline,text width=3cm] {};
\draw [outline] (secondcircle) circle (1.5cm);
% The labels
\node at ([xshift=-0.15cm]firstcircle) {$A$};
\node at ([xshift=0.4cm]secondcircle) {$B$};
\end{tikzpicture}
\caption{$\mathbf{A} \cap \mathbf{B}$}
\label{fig:venncap}
\end{minipage}
\end{figure}
\end{document}
Current output:
Desired output:
Fill the intersection on the second figure (one to the right) and to "shrink" the circles in order to add space around them.