答案 1

答案 1

这个问题导致了一个新的方案的出现:

pst-venn

您看到我的代码并请回答我的两个问题:

\documentclass{article}
\usepackage{amsmath,amssymb,mathptmx}
\usepackage{pstricks}
\usepackage{pst-node}
\usepackage{auto-pst-pdf}
\begin{document}
\begin{pspicture}[showgrid](-3,-3)(8,8)%[linestyle=none]
  \psclip{% 
        \pscircle(0,0){3}
        \pscircle(4,0){3} }
        \pscircle[fillcolor=blue,fillstyle=solid](2,3){3}        
  \endpsclip
 \pscircle(0,0){3}
 \pscircle(4,0){3}
 \pscircle(2,3){3}
\end{pspicture}    
\end{document}

输出图片:

enter image description here

图片1:

enter image description here

其代码(使用 Ti韓國語:

\documentclass{article}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
  \fill[blue,even odd rule] (0,0) circle (3) (4,0) circle (3) (2,3) circle (3); 
\end{tikzpicture}

我的问题:

  • 如何让我的图片像图片 1 那样?我真的不知道如何给它填充颜色。

  • 完成上一个问题后)你看到 Ti图片 1 的 Z 代码?看看重要的选项even odd rule。PStricks 是否有与 Ti 相同的命令、宏……Z?

注意:我更喜欢 PStricks 而不是 TiZ,但有时我能认出 TiZ 代码更好。

如果让您感到不舒服,我很抱歉。

答案1

PSTricks 解决方案只是为了好玩!

答案 1

\documentclass[pstricks]{standalone}
\begin{document}
\begin{pspicture}(-5,-5)(5,5)
\pscustom[fillstyle=eofill,fillcolor=blue]
{ 
  \pscircle(1.5;90){3}
  \pscircle(1.5;-30){3} 
  \pscircle(1.5;210){3} 
} 
\end{pspicture} 
\end{document}

enter image description here

仅由于一个微不足道的原因,笔触颜色保留为黑色。

使用笛卡尔坐标来响应请求。

\documentclass[pstricks]{standalone}
\begin{document}
\begin{pspicture}(-5,-5)(5,5)
\pscustom[fillstyle=eofill,fillcolor=blue]
{ 
  \pscircle(0,1.5){3}
  \pscircle(1.29,-0.75){3} 
  \pscircle(-1.29,-0.75){3} 
} 
\end{pspicture} 
\end{document}

答案 2

非零缠绕规则:

\documentclass[pstricks,border=12pt]{standalone}
\begin{document}
\begin{pspicture}[showgrid=t](-3,-3)(3,3)
\pscustom[fillstyle=solid,fillcolor=red]
{
    \pscircle{1}
    \pscircle{2}
}
\end{pspicture} 
\end{document}

enter image description here

非零缠绕规则:

\documentclass[pstricks,border=12pt]{standalone}
\begin{document}
\begin{pspicture}[showgrid=t](-3,-3)(3,3)
\pscustom[fillstyle=solid,fillcolor=red]
{
    \psarcn(0,0){1}{360}{0}
    \pscircle{2}
}
\end{pspicture} 
\end{document}

enter image description here

奇偶规则:

\documentclass[pstricks,border=12pt]{standalone}
\begin{document}
\begin{pspicture}[showgrid=t](-3,-3)(3,3)
\pscustom[fillstyle=eofill,fillcolor=red]
{
    \pscircle{1}
    \pscircle{2}
}
\end{pspicture} 
\end{document}

enter image description here

答案2

以下是基于 @Thomas 的答案。差异

  • “基本”区域 I、II、...、VIII 的编号并不相同。我的编号是“N”是罗马数字“n+1”,其中二进制中的“n”是“abc”,并且该区域是 A 或非 A 与 B 或非 B 与 C 或非 C 的交集,根据 a、b、c = 0 或 1。(布尔逻辑)

  • 该宏只需要一个输入:集合的 TeX 公式。请通过添加适当的定义来丰富语法,将 TeX 数学宏转换为布尔逻辑符号,以便xintexpr

  • 我已经放弃了所有花哨的颜色定制,但如果需要,xparse virtuosos 会添加花哨的可选参数来重新安装它。

因此,这里的重点是xintexpr根据 TeX 排版公式自动计算图表中需要填充的区域。

注意\setminus必须可以带括号使用\setminus (...),也可以不带括号使用,但只能带一个字母\setminus A ok,\setminus A\cap B不 ok,因为这里对 xintexpr boolean 的翻译将天真地执行与 等同的操作and not(A) and B,而不是预期的and not(A and B)。简而言之,您必须将\setminus其视为具有最大约束优先级。

\documentclass[pstricks, border=10pt]{standalone}
\usepackage{pst-node}
\usepackage{xparse,xintexpr}

\def\KOEA{1.9,2.2}
\def\FOEA{1.4,1}

\def\KOEB{3.3,2.2}
\def\FOEB{1.2,1}

\def\KOEC{2.75,1.4}
\def\FOEC{1.4,1}

\def\KOEO{2.5,2}
\def\FOEO{2.5,2.0}

\NewDocumentCommand{\EreignisA}{sO{cyan}!O{0.8}}{%
\IfBooleanTF{#1}{%
\psellipse[fillstyle=solid,fillcolor=#2,opacity=#3](\KOEA)(\FOEA)}{%
\psellipse(\KOEA)(\FOEA)}%
}

\NewDocumentCommand{\EreignisB}{sO{cyan}!O{0.8}}{%
\IfBooleanTF{#1}{%
\psellipse[fillstyle=solid,fillcolor=#2,opacity=#3](\KOEB)(\FOEB)}{%
\psellipse(\KOEB)(\FOEB)}%
}

\NewDocumentCommand{\EreignisC}{sO{cyan}!O{0.8}}{%
\IfBooleanTF{#1}{%
\psellipse[fillstyle=solid,fillcolor=#2,opacity=#3](\KOEC)(\FOEC)}{%
\psellipse(\KOEC)(\FOEC)}%
}

\NewDocumentCommand{\EreignisOmega}{sO{cyan}!O{0.8}}{%
\IfBooleanTF{#1}{%
\psellipse[fillstyle=solid,fillcolor=#2,opacity=#3](\KOEO)(\FOEO)}{%
\psellipse(\KOEO)(\FOEO)}%
}

\NewDocumentCommand{\EndeEllipsen}{sm}{%
\EreignisOmega%
\pnodes(0.25,3.75){Omega}(0.25,0.25){A}(4.75,3.75){B}(4.75,0.25){C}(2.5,-0.5){E}
\pnodes(0.7,3.36){MOmega}(0.85,1.55){MA}(4,3){MB}(3.8,0.75){MC}
\EreignisA
\EreignisB
\EreignisC
\rput[t](E){#2}%
\IfBooleanF{#1}{%
\rput(Omega){$\Omega$}\pcline[nodesepA=0.25](Omega)(MOmega)
\rput(A){$A$}\pcline[nodesepA=0.25](A)(MA)
\rput(B){$B$}\pcline[nodesepA=0.25](B)(MB)
\rput(C){$C$}\pcline[nodesepA=0.2](C)(MC)
}%
}

\NewDocumentCommand{\codeclip}{m}{%
\pscustom[linestyle=none]{%
 \code{/clip /eoclip load def}%
  \psframe(-\maxdimen,-\maxdimen)(\maxdimen,\maxdimen)
  #1
  }%
}

%\ExplSyntaxOn
% We could use some automated macro creation but well
% 000
\NewDocumentCommand{\arealI}{O{cyan}!O{0.8}}{%
\psclip{%
\codeclip{%
  \EreignisA
}%
\codeclip{%
  \EreignisB
}%
\codeclip{%
  \EreignisC
}%
}%
\EreignisOmega*[#1][#2]%
\endpsclip
}%
% 001
\NewDocumentCommand{\arealII}{O{cyan}!O{0.8}}{%
\psclip{%
\codeclip{%
  \EreignisA
}%
\codeclip{%
  \EreignisB
}%
}%
\EreignisC*[#1][#2]%
\endpsclip
}
% 010
\NewDocumentCommand{\arealIII}{O{cyan}!O{0.8}}{%
\psclip{%
\codeclip{%
  \EreignisA
}%
\codeclip{%
  \EreignisC
}%
}%
\EreignisB*[#1][#2]%
\endpsclip
}
% 011
\NewDocumentCommand{\arealIV}{O{cyan}!O{0.8}}{%
\psclip{%
\codeclip{%
  \EreignisB
  \EreignisC
}%
\codeclip{%
  \EreignisA
}%
}%
\EreignisB*[#1][#2]%
\EreignisC*[#1][#2]%
\endpsclip
}
% 100
\NewDocumentCommand{\arealV}{O{cyan}!O{0.8}}{%
\psclip{%
\codeclip{%
  \EreignisB
}%
\codeclip{%
  \EreignisC
}%
}%
\EreignisA*[#1][#2]%
\endpsclip
}
% 101
\NewDocumentCommand{\arealVI}{O{cyan}!O{0.8}}{%
\psclip{%
\codeclip{%
  \EreignisA
  \EreignisC
}%
\codeclip{%
  \EreignisB
}%
}%
\EreignisA*[#1][#2]%
\EreignisC*[#1][#2]%
\endpsclip
}
% 110
\NewDocumentCommand{\arealVII}{O{cyan}!O{0.8}}{%
\psclip{%
\codeclip{%
  \EreignisA
  \EreignisB
}%
\codeclip{%
  \EreignisC
}%
}%
\EreignisA*[#1][#2]%
\EreignisB*[#1][#2]%
\endpsclip
}
% 111
\NewDocumentCommand{\arealVIII}{O{cyan}!O{0.8}}{%
\psclip{%
\codeclip{%
  \EreignisA
  \EreignisB
}%
\codeclip{%
  \EreignisA
  \EreignisC
}%
\codeclip{%
  \EreignisB
  \EreignisC
}%
}%
\EreignisA*[#1][#2]%
\EreignisB*[#1][#2]%
\EreignisC*[#1][#2]%
\endpsclip
}
%\ExplSyntaxOff

%\xintverbosetrue
\makeatletter
\newcommand\VennFromTeX[1]{%
    \VennFromTeX@main #1%
}%
\def\VennFromTeX@main$#1${%
    \begingroup
        \xintglobaldefstrue
        \def\overline##1{!(##1)}% or not(##1)
        \def\cap{&&}% or 'and'
        \def\cup{||}% or 'or'
        \def\oplus{ 'xor' }%
        \def\setminus##1{\ifx(##1&&!(\else &&!(##1)\fi}%
        \let\bigl\empty
        \let\bigr\empty
        % ....
        % (add above all needed extra definitions: \let\Bigl\empty etc...) 
    \xintdeffunc MyBool(A, B, C) := #1;% #1 must use A, B, C only
    \endgroup
    % we could make a loop here (using \@Roman), but let's stay simple
    % I trust xparse experts can wrap this up in macros allowing to customize
    % the colors
% ATTENTION THAT THESE \arealI...VIII ARE NOT THE SAME AS IN @THOMAS ANSWER
    \xintifboolexpr{MyBool(0, 0, 0)}{\arealI[cyan][0.8]}{}%
    \xintifboolexpr{MyBool(0, 0, 1)}{\arealII[cyan][0.8]}{}%
    \xintifboolexpr{MyBool(0, 1, 0)}{\arealIII[cyan][0.8]}{}%
    \xintifboolexpr{MyBool(0, 1, 1)}{\arealIV[cyan][0.8]}{}%
    \xintifboolexpr{MyBool(1, 0, 0)}{\arealV[cyan][0.8]}{}%
    \xintifboolexpr{MyBool(1, 0, 1)}{\arealVI[cyan][0.8]}{}%
    \xintifboolexpr{MyBool(1, 1, 0)}{\arealVII[cyan][0.8]}{}%
    \xintifboolexpr{MyBool(1, 1, 1)}{\arealVIII[cyan][0.8]}{}%
    \EndeEllipsen{$#1$}%
}%
\makeatother

\begin{document}

%testing if I, II, ..., VIII are as expected
% \makeatletter
% \xintFor*#1in{\xintSeq{0}{7}}\do{%
% \begin{pspicture}(0,-1)(5,4)
% \rput(2,0){\the\numexpr1+#1}
% \@nameuse{areal\@Roman{\numexpr1+#1}}[cyan][0.8]
% \EndeEllipsen{}
% \end{pspicture}
% }%
% \end{document}


\begin{pspicture}(0,-1)(5,4)
\VennFromTeX{$A\cap B\cap C$}%
\end{pspicture}

\begin{pspicture}(0,-1)(5,4)
\VennFromTeX{$A\cap (B\cup C)$}
\end{pspicture}

\begin{pspicture}(0,-1)(5,4)
\VennFromTeX{$(\overline{A}\cap \overline{B})\cup C$}
\end{pspicture}

\begin{pspicture}(0,-1)(5,4)
\VennFromTeX{$\overline{A}\setminus (B\cap C)$}
\end{pspicture}

\begin{pspicture}(0,-1)(5,4)
\VennFromTeX{$(\overline{A}\setminus B)\cap C$}
\end{pspicture}

\begin{pspicture}(0,-1)(5,4)
\VennFromTeX{$(A\setminus B)\cup (B\cap C)$}
\end{pspicture}

\begin{pspicture}(0,-1)(5,4)
\VennFromTeX{$\bigl((A\cap B)\cup (A\cap C)\bigr)\setminus(A\cap B\cap C)$}
\end{pspicture}

\begin{pspicture}(0,-1)(5,4)
\VennFromTeX{$A\oplus B\oplus C$}
\end{pspicture}

\end{document}

生产

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here



这是生成全部 256 个维恩图的代码。只需将其插入上述文档的正文中,别忘了添加\usepackage{xintbinhex}到序言中。

% generating all graphics

% 0<= n <= 255 has eight binary digits
% abcdefgh
% a=1 -> region VIII is included (A cap B cap C)
% b=1 -> region VII is included
% ...
% h=1 -> region I is included (\overline{A}\cap \overline{B} \cap \overline{C})
% We want also to describe the region as a formula...
% We could use 8 \xintFor loops #1, ..., #8, but then
% we still need to convert #1*7 to binary, #2*6, #3*5 etc...
% I thus use xintbinhex per convenience but \ifodd would be enough
% As I use xintbinhex, I also use a single \xintFor* loop

%\def\gobbleone#1{}%
\def\gobbletwo#1#2{}%
\xintFor* #1 in {\xintSeq{0}{255}}:
{%
   \xintDigitsOf\xintDecToBin{\the\numexpr256+#1\relax}\to\Regions
   % due to leading 1 there will be a shift of indexing in \Regions
   \edef\x{\xintifboolexpr{\Regions{\the\numexpr9-0}}% 000
              {\unexpanded{\allowbreak\cup
                           \overline{A}\cap\overline{B}\cap\overline{C}}}%
              {}%
           \xintifboolexpr{\Regions{9-1}}%  001
              {\unexpanded{\allowbreak\cup \overline{A}\cap\overline{B}\cap C}}%
              {}%
           \xintifboolexpr{\Regions{9-2}}%  010
              {\unexpanded{\allowbreak\cup \overline{A}\cap B \cap\overline{C}}}%
              {}%
           \xintifboolexpr{\Regions{9-3}}% 011
              {\unexpanded{\allowbreak\cup \overline{A} \cap B \cap C}}%
              {}%
           \xintifboolexpr{\Regions{9-4}}% 100
              {\unexpanded{\allowbreak\cup A\cap \overline{B}\cap \overline{C}}}%
              {}%
           \xintifboolexpr{\Regions{9-5}}% 101
              {\unexpanded{\allowbreak\cup A\cap \overline{B}\cap C}}%
              {}%
           \xintifboolexpr{\Regions{9-6}}% 110
              {\unexpanded{\allowbreak\cup A\cap B\cap \overline{C}}}%
              {}%
           \xintifboolexpr{\Regions{9-7}}% 111
              {\unexpanded{\allowbreak\cup A\cap B \cap C}}%
              {}%
    }%
   \xintifForFirst{\def\x{\emptyset}}
                  {\oodef\x{\expandafter\gobbletwo\x}}%
   \begin{pspicture}(0,-2)(5,4)
   % I will leave here each Region as individual call, so a color can
   % be added by modifying this code
    \xintifboolexpr{\Regions{9-0}}{\arealI[cyan][0.8]}{}%
    \xintifboolexpr{\Regions{9-1}}{\arealII[cyan][0.8]}{}%
    \xintifboolexpr{\Regions{9-2}}{\arealIII[cyan][0.8]}{}%
    \xintifboolexpr{\Regions{9-3}}{\arealIV[cyan][0.8]}{}%
    \xintifboolexpr{\Regions{9-4}}{\arealV[cyan][0.8]}{}%
    \xintifboolexpr{\Regions{9-5}}{\arealVI[cyan][0.8]}{}%
    \xintifboolexpr{\Regions{9-6}}{\arealVII[cyan][0.8]}{}%
    \xintifboolexpr{\Regions{9-7}}{\arealVIII[cyan][0.8]}{}%
    \EndeEllipsen{\parbox{4cm}{\centering$\x$}}%
   \end{pspicture}%
}%

缺陷:集合的描述是原子事件的不相交并集。可能有一些规范的较短描述,但我从未真正考虑过。例如,其中一个图表将表示 $\Omega\setminus A$,但这不是它被图例化的方式。

这个例子的实现方式如下(在文档的第 16 页,没有其他内容,即它对应于循环中的 #1 = 15,15=1111 表示保留原子事件 0=000、1=001、2=010、3=011,它是 Omega 中 A 的补码。

enter image description here



现在4 组

这次,使用 TikZ 代码(我既不懂 PSTricks 也不懂 TikZ,只能通过复制预先存在的绘图说明来生存;在这种情况下,我从https://tex.stackexchange.com/a/100091/4686由@JohnHammersley 于 2013 年创作。

首先,我包含所有原子事件的图像,这些事件是代码中的宏接下来引用的区域\Atomic...。(这是为了在准备答案时进行检查)

enter image description here

这是 的代码 \VennFromTeX,将其用作\VennFromTeX{$ set formula with A, B, C, D $}。与上面针对三个集合的说明相同。(人们可能希望扩大语法,例如,允许使用U\Omega并在 xintexpr 中将其定义为1,类似地\emptyset可以将其定义为0)。

\documentclass[12pt, tikz, border=10pt]{standalone}

\usepackage{tikz} 

\usetikzlibrary{positioning,shapes.geometric}

\usepackage{xintexpr}% for \VennFromTeX


% For drawing
\def\firstellip{(-1.6, 0) ellipse [x radius=3cm, y radius=1.5cm, rotate=-50]}
\def\secondellip{(-0.3, 1cm) ellipse [x radius=3cm, y radius=1.5cm, rotate=-50]}
\def\thirdellip{(0.3, 1cm) ellipse [x radius=3cm, y radius=1.5cm, rotate=50]}
\def\fourthellip{(1.6, 0) ellipse [x radius=3cm, y radius=1.5cm, rotate=50]}

\def\bounding{(-5,-3) rectangle (5,4)}

% Elementary sets
% ABCD
% abcd a, b, c, d in {0, 1}
\def\Atomic{% 0000
        \begin{scope}[even odd rule]% exterior
            \clip \firstellip (-5,-5) rectangle (5,5);
            \clip \secondellip (-5,-5) rectangle (5,5);
            \clip \thirdellip (-5,-5) rectangle (5,5);
            \clip \fourthellip (-5,-5) rectangle (5,5);
        \fill[yellow] \bounding;
        \end{scope}
}%
\def\Atomici{% 0001
        \begin{scope}[even odd rule]% fourth ellipse corner
            \clip \firstellip (-5,-5) rectangle (5,5);
            \clip \secondellip (-5,-5) rectangle (5,5);
            \clip \thirdellip (-5,-5) rectangle (5,5);
        \fill[yellow] \fourthellip;
        \end{scope}
}%
\def\Atomicii{% 0010
        \begin{scope}[even odd rule]% third ellipse corner
            \clip \firstellip (-5,-5) rectangle (5,5);
            \clip \secondellip (-5,-5) rectangle (5,5);
            \clip \fourthellip (-5,-5) rectangle (5,5);
        \fill[yellow] \thirdellip;
        \end{scope}
}%
\def\Atomiciii{% 0011
        \begin{scope}[even odd rule]%
            \clip \firstellip (-5,-5) rectangle (5,5);
            \clip \secondellip (-5,-5) rectangle (5,5);
            \clip \fourthellip;
        \fill[yellow] \thirdellip;
        \end{scope}
}%
\def\Atomiciv{% 0100
        \begin{scope}[even odd rule]% second ellipse corner
            \clip \firstellip (-5,-5) rectangle (5,5);
            \clip \thirdellip (-5,-5) rectangle (5,5);
            \clip \fourthellip (-5,-5) rectangle (5,5);
        \fill[yellow] \secondellip;
        \end{scope}
}%
\def\Atomicv{% 0101
        \begin{scope}[even odd rule]%
            \clip \firstellip (-5,-5) rectangle (5,5);
            \clip \thirdellip (-5,-5) rectangle (5,5);
            \clip \fourthellip;
        \fill[yellow] \secondellip;
        \end{scope}
}%
\def\Atomicvi{% 0110
        \begin{scope}[even odd rule]%
            \clip \firstellip (-5,-5) rectangle (5,5);
            \clip \thirdellip;
            \clip \fourthellip (-5,-5) rectangle (5,5);
        \fill[yellow] \secondellip;
        \end{scope}
}%
\def\Atomicvii{% 0111
        \begin{scope}[even odd rule]%
            \clip \firstellip (-5,-5) rectangle (5,5);
            \clip \thirdellip;
            \clip \fourthellip;
        \fill[yellow] \secondellip;
        \end{scope}
}%
\def\Atomicviii{% 1000
        \begin{scope}[even odd rule]%
            \clip \secondellip (-5,-5) rectangle (5,5);
            \clip \thirdellip (-5,-5) rectangle (5,5);
            \clip \fourthellip (-5,-5) rectangle (5,5);
        \fill[yellow] \firstellip;
        \end{scope}
}%
\def\Atomicix{% 1001
        \begin{scope}[even odd rule]%
            \clip \secondellip (-5,-5) rectangle (5,5);
            \clip \thirdellip (-5,-5) rectangle (5,5);
            \clip \fourthellip;
        \fill[yellow] \firstellip;
        \end{scope}
}%
\def\Atomicx{% 1010
        \begin{scope}[even odd rule]%
            \clip \secondellip (-5,-5) rectangle (5,5);
            \clip \thirdellip;
            \clip \fourthellip (-5,-5) rectangle (5,5);
        \fill[yellow] \firstellip;
        \end{scope}
}%
\def\Atomicxi{% 1011
        \begin{scope}[even odd rule]%
            \clip \secondellip (-5,-5) rectangle (5,5);
            \clip \thirdellip;
            \clip \fourthellip;
        \fill[yellow] \firstellip;
        \end{scope}
}%
\def\Atomicxii{% 1100
        \begin{scope}[even odd rule]%
            \clip \secondellip;
            \clip \thirdellip (-5,-5) rectangle (5,5);
            \clip \fourthellip (-5,-5) rectangle (5,5);
        \fill[yellow] \firstellip;
        \end{scope}
}%
\def\Atomicxiii{% 1101
        \begin{scope}[even odd rule]%
            \clip \secondellip;
            \clip \thirdellip (-5,-5) rectangle (5,5);
            \clip \fourthellip;
        \fill[yellow] \firstellip;
        \end{scope}
}%
\def\Atomicxiv{% 1110
        \begin{scope}[even odd rule]%
            \clip \secondellip;
            \clip \thirdellip;
            \clip \fourthellip (-5,-5) rectangle (5,5);
        \fill[yellow] \firstellip;
        \end{scope}
}%
\def\Atomicxv{% 1111
        \begin{scope}[even odd rule]%
            \clip \secondellip;
            \clip \thirdellip;
            \clip \fourthellip;
        \fill[yellow] \firstellip;
        \end{scope}
}%

\makeatletter
\newcommand\VennFromTeX[1]{\VennFromTeX@main #1}%

\def\VennFromTeX@main$#1${%
    \begingroup
        \xintglobaldefstrue
        \def\overline##1{!(##1)}% or not(##1)
        \def\cap{&&}% or 'and'
        \def\cup{||}% or 'or'
        \def\oplus{ 'xor' }%
        \def\setminus##1{\ifx(##1&&!(\else &&!(##1)\fi}%
        \let\bigl\empty
        \let\bigr\empty
        % ....
        % (add above all needed extra definitions: \let\Bigl\empty etc...) 
    \xintdeffunc MyBool(A, B, C, D) := #1;% #1 must use A, B, C, Donly
    \endgroup
    \begin{tikzpicture}

    \xintFor* ##1 in {01}:
    {%
      \xintFor* ##2 in {01}:
      {%
        \xintFor* ##3 in {01}:
        {%
          \xintFor* ##4 in {01}:
          {%
             \xintifboolexpr{MyBool(##1, ##2, ##3, ##4)}
             {\csname
               Atomic\romannumeral\numexpr##1*8+##2*4+##3*2+##4\endcsname}%
             {}%
           }%
         }%
       }%
    }%
    \draw \bounding;

    % \fill[white] \firstellip;
    % \fill[white] \secondellip;
    % \fill[white] \thirdellip;
    % \fill[white] \fourthellip;

    \draw \firstellip node [label={[xshift=-2cm, yshift=-0.9cm]$A$}] {};
    \draw \secondellip node [label={[xshift=-2.1cm, yshift=2.1cm]$B$}] {};
    \draw \thirdellip node [label={[xshift=2.1cm, yshift=2.1cm]$C$}] {};
    \draw \fourthellip node [label={[xshift=2cm, yshift=-0.9cm]$D$}] {};

    \draw \bounding node [label=below left:$U$] {};

    \draw (0, 0) node [yshift=+4.4cm] {$#1$};

    \end{tikzpicture}
}%
\makeatother
\begin{document}

% \xintverbosetrue

\VennFromTeX{$A\cap B\cap C\cap D$}

\VennFromTeX{$(A\cap B)\cup (C\cap D)$}

\VennFromTeX{$(\overline{A}\cup\overline{B})\cap(\overline{C}\cup\overline{D})$}

% attention to use parentheses for disambiguating \setminus 

\VennFromTeX{$(A\cup B \cup C) \setminus(B\cup C\cup D)$}

\VennFromTeX{$(A\cup B \cup C) \cap (B\cup C\cup D)$}

\VennFromTeX{$((A\setminus (B\cup C\cup D)) \cup B\cap C\cap
  D)\setminus (A\cap B\cap C\cap D)$}

\end{document}

\setminus请仔细阅读有关输入中使用的警告。

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

最后

enter image description here

答案3

\documentclass[pstricks]{standalone}
\begin{document}
\begin{pspicture}(-5,-5)(5,5)
  \pscustom[fillstyle=eofill,fillcolor=blue,linecolor=blue]{% 
    \pscircle(1.5;90){3}
    \pscircle(1.5;-30){3} 
    \pscircle(1.5;210){3} 
} 
\end{pspicture} 
\end{document}

enter image description here

其他一些简单的例子:

\documentclass[pstricks]{standalone}
\usepackage{pstricks}
\begin{document}
\begin{pspicture}(-3.2,-3.2)(3.2,3.2)
  \pscircle[fillstyle=solid,fillcolor=blue!40](0,0){3}
  \psclip{\pscircle(-1,0.5){1.5}% these object(s) will clip
          \pscircle(1,0.5){1.5}}
    \pscircle[fillstyle=solid,fillcolor=red!40](0,-1){1.5}% from this object
  \endpsclip
  \pscircle(-1,0.5){1.5}% to get the clipped circle lines
  \pscircle(0,-1){1.5}
  \pscircle(1,0.5){1.5}
\end{pspicture}

\begin{pspicture}(-3.2,-3.2)(3.2,3.2)
  \pscircle[fillstyle=solid,fillcolor=blue!40](0,0){3}
  \psclip{\pscircle(-1,0.5){1.5}}
    \pscircle[fillstyle=solid,fillcolor=red!40](0,-1){1.5}
    \pscircle[fillstyle=solid,fillcolor=red!40](1,0.5){1.5}
  \endpsclip
  \pscircle(-1,0.5){1.5}
  \pscircle(0,-1){1.5}
  \pscircle(1,0.5){1.5}
\end{pspicture}

\begin{pspicture}(-3.2,-3.2)(3.2,3.2)
  \pscircle[fillstyle=solid,fillcolor=blue!40](0,0){3}
  \psclip{\pscircle(0,-1){1.5}}
    \pscircle[fillstyle=solid,fillcolor=red!40](-1,0.5){1.5}
    \pscircle[fillstyle=solid,fillcolor=red!40](1,0.5){1.5}
  \endpsclip
  \pscircle(-1,0.5){1.5}
  \pscircle(0,-1){1.5}
  \pscircle(1,0.5){1.5}
\end{pspicture}

\begin{pspicture}(-3.2,-3.2)(3.2,3.2)
  \pscircle[fillstyle=solid,fillcolor=blue!40](0,0){3}
  \psclip{\pscircle(0,-1){1.5}}
    \pscircle[fillstyle=solid,fillcolor=red!40](1,0.5){1.5}
  \endpsclip
  \pscircle[fillstyle=solid,fillcolor=red!40](-1,0.5){1.5}
  \pscircle(0,-1){1.5}
  \pscircle(1,0.5){1.5}
\end{pspicture}

\end{document}

enter image description here enter image description here

答案4

按照此定义,每个表面都可以被着色。

\documentclass[pstricks]{standalone}
\usepackage{pst-node}
\usepackage{xparse,xintexpr}

\def\radiusK{\xinttheiexpr[6] 2*sqrt(3)/3\relax}

\def\KOEA{2.5,2}
\def\FOEA{\radiusK,\radiusK}

\def\KOEB{2,1}
\def\FOEB{\radiusK,\radiusK}

\def\KOEC{3,1}
\def\FOEC{\radiusK,\radiusK}

\def\KOEO{2.5,1.375}
\def\FOEO{2.5,2.5}

%uncomment the following lines to have ellipses
%\def\KOEA{1.9,2.2}
%\def\FOEA{1.4,1}
%
%\def\KOEB{3.3,2.2}
%\def\FOEB{1.2,1}
%
%\def\KOEC{2.75,1.4}
%\def\FOEC{1.4,1}
%
%\def\KOEO{2.5,2}
%\def\FOEO{2.5,2.0}

\NewDocumentCommand{\EreignisA}{sO{cyan}!O{0.8}}{%
\IfBooleanTF{#1}{%
\psellipse[fillstyle=solid,fillcolor=#2,opacity=#3](\KOEA)(\FOEA)}{%
\psellipse(\KOEA)(\FOEA)}%
}

\NewDocumentCommand{\EreignisB}{sO{cyan}!O{0.8}}{%
\IfBooleanTF{#1}{%
\psellipse[fillstyle=solid,fillcolor=#2,opacity=#3](\KOEB)(\FOEB)}{%
\psellipse(\KOEB)(\FOEB)}%
}

\NewDocumentCommand{\EreignisC}{sO{cyan}!O{0.8}}{%
\IfBooleanTF{#1}{%
\psellipse[fillstyle=solid,fillcolor=#2,opacity=#3](\KOEC)(\FOEC)}{%
\psellipse(\KOEC)(\FOEC)}%
}

\NewDocumentCommand{\EreignisOmega}{sO{cyan}!O{0.8}}{%
\IfBooleanTF{#1}{%
\psellipse[fillstyle=solid,fillcolor=#2,opacity=#3](\KOEO)(\FOEO)}{%
\psellipse(\KOEO)(\FOEO)}%
}

\NewDocumentCommand{\EndeEllipsen}{sm}{%
\EreignisOmega%
\pnodes(0.25,3.75){Omega}(0.25,0.25){A}(4.75,3.75){B}(4.75,0.25){C}(2.5,-0.5){E}
\pnodes(0.7,3.36){MOmega}(0.85,1.55){MA}(4,3){MB}(3.8,0.75){MC}
\EreignisA
\EreignisB
\EreignisC
\rput[t](E){#2}%
\IfBooleanF{#1}{%
\rput(Omega){$\Omega$}\pcline[nodesepA=0.25](Omega)(MOmega)
\rput(A){$A$}\pcline[nodesepA=0.25](A)(MA)
\rput(B){$B$}\pcline[nodesepA=0.25](B)(MB)
\rput(C){$C$}\pcline[nodesepA=0.2](C)(MC)
}%
}

\NewDocumentCommand{\codeclip}{m}{%
\pscustom[linestyle=none]{%
 \code{/clip /eoclip load def}%
  \psframe(-\maxdimen,-\maxdimen)(\maxdimen,\maxdimen)
  #1
  }%
}

\NewDocumentCommand{\arealI}{O{cyan}!O{0.8}}{%
\psclip{%
\codeclip{%
  \EreignisA
}%
\codeclip{%
  \EreignisB
}%
\codeclip{%
  \EreignisC
}%
}%
\EreignisOmega*[#1][#2]%
\endpsclip
}

\NewDocumentCommand{\arealII}{O{cyan}!O{0.8}}{%
\psclip{%
\codeclip{%
  \EreignisB
  \EreignisC
}%
\codeclip{%
  \EreignisC
}%
}%
\EreignisA*[#1][#2]%
\endpsclip
}

\NewDocumentCommand{\arealIII}{O{cyan}!O{0.8}}{%
\psclip{%
\codeclip{%
  \EreignisA
  \EreignisB
  \EreignisC
}%
\codeclip{%
  \EreignisC
}%
}%
\EreignisA*[#1][#2]%
\endpsclip
}

\NewDocumentCommand{\arealIV}{O{cyan}!O{0.8}}{%
\psclip{%
\codeclip{%
  \EreignisA
  \EreignisC
}%
\codeclip{%
  \EreignisC
}%
}%
\EreignisB*[#1][#2]%
\endpsclip
}

\NewDocumentCommand{\arealV}{O{cyan}!O{0.8}}{%
\psclip{%
\codeclip{%
  \EreignisA
  \EreignisB
  \EreignisC
}%
\codeclip{%
  \EreignisB
}%
}%
\EreignisA*[#1][#2]%
\endpsclip
}

\NewDocumentCommand{\arealVI}{O{cyan}!O{0.8}}{%
\psclip{\EreignisB}
        \psclip{\EreignisC}%
                \EreignisA*[#1][#2]%
        \endpsclip
\endpsclip
}

\NewDocumentCommand{\arealVII}{O{cyan}!O{0.8}}{%
\psclip{%
\codeclip{%
  \EreignisA
  \EreignisB
  \EreignisC
}%
\codeclip{%
  \EreignisA
}%
}%
\EreignisC*[#1][#2]%
\endpsclip
}

\NewDocumentCommand{\arealVIII}{O{cyan}!O{0.8}}{%
\psclip{%
\codeclip{%
  \EreignisA
  \EreignisB
}%
\codeclip{%
  \EreignisB
}%
}%
\EreignisC*[#1][#2]%
\endpsclip
}

\begin{document}


\begin{pspicture}[shift=-4](0,-1)(5,4)
\arealI
\EndeEllipsen*{$A\setminus C$}
\end{pspicture}

\begin{pspicture}[shift=-4](0,-1)(5,4)
\arealVI
\EndeEllipsen*{$A\cap B\cap C$}
\end{pspicture}

\begin{pspicture}[shift=-4](0,-1)(5,4)
\arealIII
\arealV
\arealVI
\EndeEllipsen*{$A\cap (B\cup C)$}
\end{pspicture}

\begin{pspicture}[shift=-4](0,-1)(5,4)
\arealI
\EreignisC*%
\EndeEllipsen*{$(\overline{A}\cap \overline{B})\cup C$}
\end{pspicture}

\begin{pspicture}[shift=-4](0,-1)(5,4)
\arealI
\arealIV
\arealVIII
\EndeEllipsen*{$\overline{A}\setminus (B\cap C)$}
\end{pspicture}

\begin{pspicture}[shift=-4](0,-1)(5,4)
\arealVIII
\EndeEllipsen*{$(\overline{A}\setminus B)\cap C$}
\end{pspicture}

\begin{pspicture}[shift=-4](0,-1)(5,4)
\arealII
\arealV
\arealVI
\arealVII
\EndeEllipsen*{$(A\setminus B)\cup (B\cap C)$}
\end{pspicture}

\begin{pspicture}[shift=-4](0,-1)(5,4)
\arealIII
\arealV
\EndeEllipsen*{$\bigl((A\cap B)\cup (A\cap C)\bigr)\setminus(A\cap B\cap C)$}
\end{pspicture}


\end{document} 

也许您想检查一下这个。

\documentclass[pstricks]{standalone}
\usepackage{pst-node}
\usepackage{xparse,xintexpr}

%\def\radiusK{\xinttheiexpr[6] 2*sqrt(3)/3\relax}
%
%\def\KOEA{2.5,2}
%\def\FOEA{\radiusK,\radiusK}
%
%\def\KOEB{2,1}
%\def\FOEB{\radiusK,\radiusK}
%
%\def\KOEC{3,1}
%\def\FOEC{\radiusK,\radiusK}
%
%\def\KOEO{2.5,1.375}
%\def\FOEO{2.5,2.5}

%uncomment the following lines to have ellipses
\def\KOEA{1.9,2.2}
\def\FOEA{1.4,1}

\def\KOEB{3.3,2.2}
\def\FOEB{1.2,1}

\def\KOEC{2.75,1.4}
\def\FOEC{1.4,1}

\def\KOEO{2.5,2}
\def\FOEO{2.5,2.0}

\NewDocumentCommand{\EreignisA}{sO{cyan}!O{0.8}}{%
\IfBooleanTF{#1}{%
\psellipse[fillstyle=solid,fillcolor=#2,opacity=#3](\KOEA)(\FOEA)}{%
\psellipse(\KOEA)(\FOEA)}%
}

\NewDocumentCommand{\EreignisB}{sO{cyan}!O{0.8}}{%
\IfBooleanTF{#1}{%
\psellipse[fillstyle=solid,fillcolor=#2,opacity=#3](\KOEB)(\FOEB)}{%
\psellipse(\KOEB)(\FOEB)}%
}

\NewDocumentCommand{\EreignisC}{sO{cyan}!O{0.8}}{%
\IfBooleanTF{#1}{%
\psellipse[fillstyle=solid,fillcolor=#2,opacity=#3](\KOEC)(\FOEC)}{%
\psellipse(\KOEC)(\FOEC)}%
}

\NewDocumentCommand{\EreignisOmega}{sO{cyan}!O{0.8}}{%
\IfBooleanTF{#1}{%
\psellipse[fillstyle=solid,fillcolor=#2,opacity=#3](\KOEO)(\FOEO)}{%
\psellipse(\KOEO)(\FOEO)}%
}

\NewDocumentCommand{\EndeEllipsen}{sm}{%
\EreignisOmega%
\pnodes(0.25,3.75){Omega}(0.25,0.25){A}(4.75,3.75){B}(4.75,0.25){C}(2.5,-0.5){E}
\pnodes(0.7,3.36){MOmega}(0.85,1.55){MA}(4,3){MB}(3.8,0.75){MC}
\EreignisA
\EreignisB
\EreignisC
\rput[t](E){#2}%
\IfBooleanF{#1}{%
\rput(Omega){$\Omega$}\pcline[nodesepA=0.25](Omega)(MOmega)
\rput(A){$A$}\pcline[nodesepA=0.25](A)(MA)
\rput(B){$B$}\pcline[nodesepA=0.25](B)(MB)
\rput(C){$C$}\pcline[nodesepA=0.2](C)(MC)
}%
}

\NewDocumentCommand{\codeclip}{m}{%
\pscustom[linestyle=none]{%
 \code{/clip /eoclip load def}%
  \psframe(-\maxdimen,-\maxdimen)(\maxdimen,\maxdimen)
  #1
  }%
}

\NewDocumentCommand{\arealI}{O{cyan}!O{0.8}}{%
\psclip{%
\codeclip{%
  \EreignisA
}%
\codeclip{%
  \EreignisB
}%
\codeclip{%
  \EreignisC
}%
}%
\EreignisOmega*[#1][#2]%
\endpsclip
}

\NewDocumentCommand{\arealII}{O{cyan}!O{0.8}}{%
\psclip{%
\codeclip{%
  \EreignisB
  \EreignisC
}%
\codeclip{%
  \EreignisC
}%
}%
\EreignisA*[#1][#2]%
\endpsclip
}

\NewDocumentCommand{\arealIII}{O{cyan}!O{0.8}}{%
\psclip{%
\codeclip{%
  \EreignisA
  \EreignisB
  \EreignisC
}%
\codeclip{%
  \EreignisC
}%
}%
\EreignisA*[#1][#2]%
\endpsclip
}

\NewDocumentCommand{\arealIV}{O{cyan}!O{0.8}}{%
\psclip{%
\codeclip{%
  \EreignisA
  \EreignisC
}%
\codeclip{%
  \EreignisC
}%
}%
\EreignisB*[#1][#2]%
\endpsclip
}

\NewDocumentCommand{\arealV}{O{cyan}!O{0.8}}{%
\psclip{%
\codeclip{%
  \EreignisA
  \EreignisB
  \EreignisC
}%
\codeclip{%
  \EreignisB
}%
}%
\EreignisA*[#1][#2]%
\endpsclip
}

\NewDocumentCommand{\arealVI}{O{cyan}!O{0.8}}{%
\psclip{\EreignisB}
        \psclip{\EreignisC}%
                \EreignisA*[#1][#2]%
        \endpsclip
\endpsclip
}

\NewDocumentCommand{\arealVII}{O{cyan}!O{0.8}}{%
\psclip{%
\codeclip{%
  \EreignisA
  \EreignisB
  \EreignisC
}%
\codeclip{%
  \EreignisA
}%
}%
\EreignisC*[#1][#2]%
\endpsclip
}

\NewDocumentCommand{\arealVIII}{O{cyan}!O{0.8}}{%
\psclip{%
\codeclip{%
  \EreignisA
  \EreignisB
}%
\codeclip{%
  \EreignisB
}%
}%
\EreignisC*[#1][#2]%
\endpsclip
}

\begin{document}


\begin{pspicture}[shift=-4](0,-1)(5,4)
\arealI
\EndeEllipsen{$A\setminus C$}
\end{pspicture}

\begin{pspicture}[shift=-4](0,-1)(5,4)
\arealVI
\EndeEllipsen{$A\cap B\cap C$}
\end{pspicture}

\begin{pspicture}[shift=-4](0,-1)(5,4)
\arealIII
\arealV
\arealVI
\EndeEllipsen{$A\cap (B\cup C)$}
\end{pspicture}

\begin{pspicture}[shift=-4](0,-1)(5,4)
\arealI
\EreignisC*%
\EndeEllipsen{$(\overline{A}\cap \overline{B})\cup C$}
\end{pspicture}

\begin{pspicture}[shift=-4](0,-1)(5,4)
\arealI
\arealIV
\arealVIII
\EndeEllipsen{$\overline{A}\setminus (B\cap C)$}
\end{pspicture}

\begin{pspicture}[shift=-4](0,-1)(5,4)
\arealVIII
\EndeEllipsen{$(\overline{A}\setminus B)\cap C$}
\end{pspicture}

\begin{pspicture}[shift=-4](0,-1)(5,4)
\arealII
\arealV
\arealVI
\arealVII
\EndeEllipsen{$(A\setminus B)\cup (B\cap C)$}
\end{pspicture}

\begin{pspicture}[shift=-4](0,-1)(5,4)
\arealIII
\arealV
\EndeEllipsen{$\bigl((A\cap B)\cup (A\cap C)\bigr)\setminus(A\cap B\cap C)$}
\end{pspicture}


\end{document} 

在 xint-package 的帮助下,使用 xintFor 和 xintForpair,你可以编写

\VennIII{(2,red),(4,cyan),(6,magenta),(8,green)}{Text}%

所以每个表面都会有自己的颜色,或者你写

\VennIII[blue](0.5){2,4,6,8}{Text}%

并且全部变为蓝色,不透明度为 0.5。

\documentclass[pstricks]{standalone}
\usepackage{pst-node}
\usepackage{xparse,xintexpr}

\def\KOEA{1.9,2.2}
\def\FOEA{1.4,1}

\def\KOEB{3.3,2.2}
\def\FOEB{1.2,1}

\def\KOEC{2.75,1.4}
\def\FOEC{1.4,1}

\def\KOEO{2.5,2}
\def\FOEO{2.5,2.0}

\NewDocumentCommand{\EreignisA}{sO{cyan}!O{0.8}}{%
\IfBooleanTF{#1}{%
\psellipse[fillstyle=solid,fillcolor=#2,opacity=#3](\KOEA)(\FOEA)}{%
\psellipse(\KOEA)(\FOEA)}%
}

\NewDocumentCommand{\EreignisB}{sO{cyan}!O{0.8}}{%
\IfBooleanTF{#1}{%
\psellipse[fillstyle=solid,fillcolor=#2,opacity=#3](\KOEB)(\FOEB)}{%
\psellipse(\KOEB)(\FOEB)}%
}

\NewDocumentCommand{\EreignisC}{sO{cyan}!O{0.8}}{%
\IfBooleanTF{#1}{%
\psellipse[fillstyle=solid,fillcolor=#2,opacity=#3](\KOEC)(\FOEC)}{%
\psellipse(\KOEC)(\FOEC)}%
}

\NewDocumentCommand{\EreignisOmega}{sO{cyan}!O{0.8}}{%
\IfBooleanTF{#1}{%
\psellipse[fillstyle=solid,fillcolor=#2,opacity=#3](\KOEO)(\FOEO)}{%
\psellipse(\KOEO)(\FOEO)}%
}

\NewDocumentCommand{\EndeEllipsen}{sm}{%
\EreignisOmega%
\pnodes(0.25,3.75){Omega}(0.25,0.25){A}(4.75,3.75){B}(4.75,0.25){C}(2.5,-0.5){E}
\pnodes(0.7,3.36){MOmega}(0.85,1.55){MA}(4,3){MB}(3.8,0.75){MC}
\EreignisA
\EreignisB
\EreignisC
\rput[t](E){#2}%
\IfBooleanF{#1}{%
\rput(Omega){$\Omega$}\pcline[nodesepA=0.25](Omega)(MOmega)
\rput(A){$A$}\pcline[nodesepA=0.25](A)(MA)
\rput(B){$B$}\pcline[nodesepA=0.25](B)(MB)
\rput(C){$C$}\pcline[nodesepA=0.2](C)(MC)
}%
}

\NewDocumentCommand{\codeclip}{m}{%
\pscustom[linestyle=none]{%
 \code{/clip /eoclip load def}%
  \psframe(-\maxdimen,-\maxdimen)(\maxdimen,\maxdimen)
  #1
  }%
}

%\ExplSyntaxOn
\NewDocumentCommand{\arealI}{O{cyan}!O{0.8}}{%
\psclip{%
\codeclip{%
  \EreignisA
}%
\codeclip{%
  \EreignisB
}%
\codeclip{%
  \EreignisC
}%
}%
\EreignisOmega*[#1][#2]%
\endpsclip
}

\NewDocumentCommand{\arealII}{O{cyan}!O{0.8}}{%
\psclip{%
\codeclip{%
  \EreignisB
  \EreignisC
}%
\codeclip{%
  \EreignisC
}%
}%
\EreignisA*[#1][#2]%
\endpsclip
}

\NewDocumentCommand{\arealIII}{!O{cyan}!O{0.8}}{%
\psclip{%
\codeclip{%
  \EreignisA
  \EreignisB
  \EreignisC
}%
\codeclip{%
  \EreignisC
}%
}%
\EreignisA*[#1][#2]%
\endpsclip
}

\NewDocumentCommand{\arealIV}{O{cyan}!O{0.8}}{%
\psclip{%
\codeclip{%
  \EreignisA
  \EreignisC
}%
\codeclip{%
  \EreignisC
}%
}%
\EreignisB*[#1][#2]%
\endpsclip
}

\NewDocumentCommand{\arealV}{O{cyan}!O{0.8}}{%
\psclip{%
\codeclip{%
  \EreignisA
  \EreignisB
  \EreignisC
}%
\codeclip{%
  \EreignisB
}%
}%
\EreignisA*[#1][#2]%
\endpsclip
}

\NewDocumentCommand{\arealVI}{O{cyan}!O{0.8}}{%
\psclip{\EreignisB}%
        \psclip{\EreignisC}%
                \EreignisA*[#1][#2]%
        \endpsclip
\endpsclip
}

\NewDocumentCommand{\arealVII}{O{cyan}!O{0.8}}{%
\psclip{%
\codeclip{%
  \EreignisA
  \EreignisB
  \EreignisC
}%
\codeclip{%
  \EreignisA
}%
}%
\EreignisC*[#1][#2]%
\endpsclip
}

\NewDocumentCommand{\arealVIII}{O{cyan}!O{0.8}}{%
\psclip{%
\codeclip{%
  \EreignisA
  \EreignisB
}%
\codeclip{%
  \EreignisB
}%
}%
\EreignisC*[#1][#2]%
\endpsclip
}
%\ExplSyntaxOff

\NewDocumentCommand{\VIIIarea}{O{cyan}O{0.8}m}{%
\xintifboolexpr{#3=1}{\arealI[#1][#2]}{}%
\xintifboolexpr{#3=2}{\arealII[#1][#2]}{}%
\xintifboolexpr{#3=3}{\arealIII[#1][#2]}{}%
\xintifboolexpr{#3=4}{\arealIV[#1][#2]}{}%
\xintifboolexpr{#3=5}{\arealV[#1][#2]}{}%
\xintifboolexpr{#3=6}{\arealVI[#1][#2]}{}%
\xintifboolexpr{#3=7}{\arealVII[#1][#2]}{}%
\xintifboolexpr{#3=8}{\arealVIII[#1][#2]}{}%
}

\NewDocumentCommand{\VennIII}{oD(){0.8}m!g}{%
\IfValueTF{#1}%
    {%
        \xintFor ##1 in {#3}\do {\VIIIarea[#1][#2]{##1}}%
    }%
    {%
        \xintForpair ##1##2 in {#3}\do {\VIIIarea[##2][#2]{##1}}%
    }%
\EndeEllipsen{\IfValueT{#4}{#4}}%
}

\begin{document}

\begin{pspicture}(0,-1)(5,4)
\VennIII{(2,red),(4,cyan),(6,magenta),(8,green)}{Text}%
\end{pspicture}

\begin{pspicture}(0,-1)(5,4)
\VennIII[orange]{6}{$A\cap B\cap C$}%
\end{pspicture}

\begin{pspicture}(0,-1)(5,4)
\VennIII[cyan]{3,5,6}{$A\cap (B\cup C)$}
\end{pspicture}

\begin{pspicture}(0,-1)(5,4)
\VennIII[magenta](0.5){1,5,6,7}{$(\overline{A}\cap \overline{B})\cup C$}
\end{pspicture}

\begin{pspicture}(0,-1)(5,4)
\VennIII[green](0.2){1,4,8}{$\overline{A}\setminus (B\cap C)$}
\end{pspicture}

\begin{pspicture}(0,-1)(5,4)
\VennIII[cyan]{8}{$(\overline{A}\setminus B)\cap C$}
\end{pspicture}

\begin{pspicture}(0,-1)(5,4)
\VennIII(1){(2,cyan),(5,orange),(6,green),(7,magenta)}{$(A\setminus B)\cup (B\cap C)$}
\end{pspicture}

\begin{pspicture}(0,-1)(5,4)
\VennIII[cyan]{3,5}{$\bigl((A\cap B)\cup (A\cap C)\bigr)\setminus(A\cap B\cap C)$}
\end{pspicture}


\end{document} 

enter image description here

相关内容