I have four venn-diagrams on the same line but the captions are not aligned because of the setdifference symbol. Is there a way to manually override this and force the rectangles to align?
\documentclass{article}
\usepackage{tikz}
\usepackage[margin=1.1in]{geometry}
\def \setA{ (0,0) circle (1cm) node {$A$}}
\def \setB{ (1.5,0) circle (1cm) node {$B$}}
\def \myrectangle{ (-2, -1.5) rectangle (3.5, 1.5) }
\begin{document}
\begin{center}
%Union of A and B
\begin{tikzpicture}[scale=0.7]
\draw \myrectangle node[below left]{$U$};
\fill[gray] (0,0) circle (1cm);
\fill[gray] (1.5,0) circle (1cm);
\draw \setA;
\draw \setB;
\node [below=.1cm] at (.1,-1.5) {$A \cup B$};
\end{tikzpicture} \
%Intersection of A and B
\begin{tikzpicture}[scale=0.7]
\draw \myrectangle node[below left]{$U$};
\begin{scope}
\clip \setA ;
\fill[gray] \setB ;
\end{scope}
\draw \setA;
\draw \setB;
\node [below=.1cm] at (.1,-1.5) {$A \cap B$};
\end{tikzpicture} \
%Difference of A and B
\begin{tikzpicture}[scale=0.7]
\draw \myrectangle node[below left]{$U$};
\fill[gray] (0,0) circle (1cm);
\begin{scope}
\clip \setA ;
\fill[white] \setB ;
\end{scope}
\draw \setA;
\draw \setB;
\node [below=.1cm] at (.1,-1.5) {$A \setminus B$};
\end{tikzpicture} \
%Complement of A
\begin{tikzpicture}[scale=0.7]
\fill[gray] (-1.5,-1.5) rectangle (1.5,1.5);
\fill[white] (0,0) circle (1cm);
\draw (-1.5,-1.5) rectangle (1.5,1.5) node[below left]{$U$};
\draw \setA;
\node [below=.1cm] at (.1,-1.5) {$A^C$};
\end{tikzpicture}
\end{center}
\end{document}
Notice on the output how the first, second, and last ones are aligned but not the third.
! LaTeX Error: Missing \begin{document}.
If I add `\begin{document) the output looks like this so not on one line as you show.baseline
to the picture options:\begin{tikzpicture}[scale=0.7,baseline]
baseline=
for eachtikzpicture
. Moreover, you can anchor your caption nodes by setting theanchor=base
key. You also might look in the TikZmatrix
construction for such stuff.