5

I have the following code:

\documentclass{article}

\usepackage{venndiagram}
\usepackage{multicol}

\begin{document}

\begin{figure}
\begin{multicols}{4}
\centering
    \begin{venndiagram2sets}[tikzoptions={scale=0.5}]
                    \fillA \fillB
        \end{venndiagram2sets}
        $P(A \cup B)  $
\hfill
    \begin{venndiagram2sets}[tikzoptions={scale=0.5}]
                    \fillA 
        \end{venndiagram2sets}
         $P(A) \ \ $
\hfill
    \begin{venndiagram2sets}[tikzoptions={scale=0.5}]
                    \fillB
        \end{venndiagram2sets}
        $P(B) \ \ $
\hfill
    \begin{venndiagram2sets}[tikzoptions={scale=0.5}]
                    \fillACapB
        \end{venndiagram2sets}
         $P(A \cap B)$
\end{multicols}
\end{figure}

\end{document}

It produces this picture:

enter image description here

I want to add = between the captions of the first and second images; + between the captions of the second and third; and - between the third and fourth.

That is, the caption should read: P(A \cup B) = P(A) + P(B) - P(A \cap B).

I want the symbols to align between each figure. That is, there is white space between the first two images and I want the = sign under that white space, in line with the caption. Same idea for the + and -.

How can I do this?

1 Answer 1

5

Two possible solutions using tabular:

enter image description here

\documentclass{article}
\usepackage{venndiagram}


\begin{document}

\begin{figure}
\centering
  \begin{tabular}{*{3}{c@{}c@{}}c}
    \begin{venndiagram2sets}[tikzoptions={scale=0.5}]
                    \fillA \fillB
        \end{venndiagram2sets}
        &&
    \begin{venndiagram2sets}[tikzoptions={scale=0.5}]
                    \fillA 
        \end{venndiagram2sets}
&&
    \begin{venndiagram2sets}[tikzoptions={scale=0.5}]
                    \fillB
        \end{venndiagram2sets}
&&
    \begin{venndiagram2sets}[tikzoptions={scale=0.5}]
                    \fillACapB
        \end{venndiagram2sets}\\

$P(A \cup B)  $ & = & $P(A) \ \ $ & + & $P(B) \ \ $ & - & $P(A \cap B)$\\
\end{tabular}
\end{figure}

\begin{figure}
\centering
\setlength{\tabcolsep}{2pt}
  \begin{tabular}{*{7}{c}}
    \begin{venndiagram2sets}[tikzoptions={scale=0.5}]
                    \fillA \fillB
        \end{venndiagram2sets}
        &&
    \begin{venndiagram2sets}[tikzoptions={scale=0.5}]
                    \fillA 
        \end{venndiagram2sets}
&&
    \begin{venndiagram2sets}[tikzoptions={scale=0.5}]
                    \fillB
        \end{venndiagram2sets}
&&
    \begin{venndiagram2sets}[tikzoptions={scale=0.5}]
                    \fillACapB
        \end{venndiagram2sets}\\

$P(A \cup B)  $ & = & $P(A) \ \ $ & + & $P(B) \ \ $ & - & $P(A \cap B)$\\
\end{tabular}
\end{figure}

\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .