获取 (A 交集 B) 并集 (A 并集 B)^补集的维恩图

获取 (A 交集 B) 并集 (A 并集 B)^补集的维恩图

在此处输入图片描述

这是我现在的维恩图。我希望​​它看起来像这样。 在此处输入图片描述

这是我目前所拥有的

    \documentclass[12pt]{article}

    \usepackage{amsmath}
    \usepackage[margin=0.5in]{geometry}
    \usepackage{tikz}
    \setlength\parindent{0pt}
    \begin{tikzpicture}[line width = 2pt] % For some thicker lines
    
% Local variables to position the circles and bounding box
    \coordinate (X) at (-0.44\textwidth,-0.15\textheight);
    \coordinate (Y) at (+0.44\textwidth,+0.15\textheight);
    \coordinate (A) at (-0.7in,0);
    \coordinate (B) at (+0.7in,0);

    % To shade the correct part of the Venn diagram
    \begin{scope}
      \clip
        (B) circle (1in);
      \fill
        [gray!50] (A) circle (1in);
    \end{scope}

    \begin{scope}
      \clip
      
    \end{scope}

    \draw (X) rectangle (Y) node[below left] {\huge $U$};
    \draw (A) circle (1in)  node {\huge $A$}; % Draw a cirle of radius 1in at A
    \draw (B) circle (1in)  node {\huge $B$}; % Draw a cirle of radius 1in at B
  \end{tikzpicture}
  \centerline{Venn diagram of}
  \centerline{$(A \cap B) \cup (A \cup B)^c $}

我如何解决它?

答案1

简短的代码如下pstricks

\documentclass[svgnames, border=6pt]{standalone}
\usepackage{pst-eucl}

\begin{document}

\begin{pspicture}(-5.5,-2.5)(5.5,2.5)
\psset{fillstyle=solid}
\psframe[fillstyle=solid, fillcolor=Gainsboro](-5.5,-2.5)(5.5,2.5)
\pstGeonode[PointSymbol=none, PointName=](-1.5,0){A}(1.5,0){B}(-1.5,2){C}(1.5,2){D}
\psset{fillcolor=white}
\pscircle(A){2}\pscircle(B){2}
\rput(A){$A$}\rput(B){$B$}
\pstInterCC{A}{C}{B}{D}{M}{N}
\pscustom[fillcolor=LemonChiffon]{\pstArcOAB{B}{M}{N}\pstArcOAB{A}{N}{M}}
\end{pspicture}

\end{document} 

在此处输入图片描述

答案2

Nicola Talbot 提供的软件包venndiagram让这项任务变得简单。

\documentclass{article}
\usepackage{venndiagram}

\begin{document}
\begin{venndiagram2sets}[labelNotAB=U]
\fillNotAorB\fillACapB
\end{venndiagram2sets}

Venn diagram of $(A \cap B) \cup (A \cup B)^c $
\end{document}

在此处输入图片描述

答案3

您的另一个起点。

在此处输入图片描述

\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage[margin=1in]{geometry}
\usepackage{tikz,lipsum}
\usetikzlibrary{backgrounds}
\setlength\parindent{0pt}
\begin{document}
\lipsum[1]
    
\begin{figure}[h]
\centering
\begin{tikzpicture}[line width=2pt] 
\def\r{1.5}
\def\cirR{(.65*\r,0) circle(\r)}
\def\cirL{(-.65*\r,0) circle(\r)}
\begin{scope}\clip \cirL;
\fill[gray!50] \cirR;
\end{scope}
\draw \cirL node{$A$} \cirR node{$B$};
\begin{scope}[on background layer]
\draw[fill=yellow!50]
([xscale=2,yscale=1.5]current bounding box.south west) rectangle ([xscale=2,yscale=1.5]current bounding box.north east)
node[below left]{$U$};
\end{scope}
\end{tikzpicture}
\caption{Venn diagram of $(A \cap B) \cup (A \cup B)^c $};
\end{figure}
\lipsum[2]
\end{document}  

答案4

首先给出一个粗鲁的解决方案:

\documentclass{article}
\usepackage{geometry}
\usepackage{tikz}

\begin{document}
    \begin{tikzpicture}[line width = 2pt,
every node/.append style = {font=\huge}
                        ] % For some thicker lines
    \coordinate (X) at (-0.44\textwidth,-0.15\textheight);
    \coordinate (Y) at (+0.44\textwidth,+0.15\textheight);
    \coordinate (A) at (-0.7in,0);
    \coordinate (B) at (+0.7in,0);
% rectangle
    \draw[fill=gray!50] (X) rectangle (Y) node[below left] {$U$};
% circles
    \draw[fill=white] (A) circle (1in)  node    {$A$}; % Draw a cirle of radius 1in at A
    \draw[fill=white] (B) circle (1in)  node    {$B$}; % Draw a cirle of radius 1in at B
% To shade the correct part of the Venn diagram
    \begin{scope}
      \clip
        (B) circle (1in);
      \draw[fill=gray!50] 
        (A) circle (1in);
    \end{scope}
    \draw (B) circle (1in); % Draw a cirle of radius 1in at B
%
    \node[below, align=center, font=\large] at (current bounding box.south)
        {Venn diagram of\\
         $(A \cap B) \cup (A \cup B)^c $};
  \end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容