2

I am trying to solve the problem of finding A compliment, and to do that I need to shade everything that is outside of my circle A. However I am having lots of trouble to do that, if some one can show me how or point me in the right directions, I would really appreciate it:

\documentclass[12pt]{article}

\usepackage{graphicx}
\usepackage{fullpage}
\usepackage{tikz} 

\def \setA { (-11,-5) circle (1cm) }
\def \setB { (-9.5,-5) circle (1cm) }
\def \setC { (-12 ,-8) circle (1cm) }
\def \rectangle { (-15,-10) rectangle (-5,-3) } 

\begin{document}

        \title{ \bfseries Statistics and Probability for Engineers \\ Assignment \#1 }

        \maketitle

        \begin{enumerate}

            \item   
                \begin{enumerate}

                \item 

                    \begin{tikzpicture}
                    \draw \rectangle ;
                    \draw \setA node[below left] {$A$};
                    \draw \setB node[below left] {$B$};
                    \draw \setC node[below left] {$C$};

                    \clip \setB
                    \clip \setC

                    \fill[gray] \rectangle

                    \end{tikzpicture}





                \end{enumerate}

        \end{enumerate}


\end{document}
  • A light grey colour, and I want to shade in everything except for the circle A – CivilSigma Sep 19 '15 at 5:29
  • Yea , except also the intersection of A and B, so that little area in between them! – CivilSigma Sep 19 '15 at 5:31
  • Yes please :) . – CivilSigma Sep 19 '15 at 5:32
2

May be like this?

\documentclass[12pt]{article}
\usepackage{tikz}

\def \setA { (-11,-5) circle (1cm) }
\def \setB { (-9.5,-5) circle (1cm) }
\def \setC { (-12 ,-8) circle (1cm) }
\def \rectangle { (-15,-10) rectangle (-5,-3) }

\begin{document}
   \begin{tikzpicture}
   \draw[fill=olive!20] \rectangle ;
   \fill[white] \setA;
   \draw[fill=olive!20] \setB node[below left] {$B$};
   \draw \setA node[below left] {$A$};
   \draw \setC node[below left] {$C$};
   \end{tikzpicture}

\end{document}

enter image description here

To fill the intersection, you may use \clip:

\documentclass[12pt]{article}
\usepackage{tikz}

\def \setA { (-11,-5) circle (1cm) }
\def \setB { (-9.5,-5) circle (1cm) }
\def \setC { (-12 ,-8) circle (1cm) }
\def \rectangle { (-15,-10) rectangle (-5,-3) }

\begin{document}
   \begin{tikzpicture}
   \draw \rectangle ;
   \draw \setA node[below left] {$A$}
   \setB node[below left] {$B$};
   \draw \setC node[below left] {$C$};
   \clip \setB;
   \fill[olive] \setA;
   \end{tikzpicture}

\end{document}

enter image description here

  • @CivilSigma Use \clip. See the edit. – user11232 Sep 19 '15 at 16:02
  • Thank you very much Harish! You've made learning this sooo much easier than all the tutorials I've found online to draw venn diagrams! – CivilSigma Sep 19 '15 at 16:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.