使用 tikz 在一页中显示许多维恩图

使用 tikz 在一页中显示许多维恩图

我想在一页纸上画六个图形,以解释集合的包含和交集。

我想到了 3 行,每行 2 个数字。我正在尝试以下方法:

\documentclass{preamble}

\begin{document}
\pagestyle{empty}

\newcommand{\circumference}[3]{(#1,#2) circle (#3cm)}

\begin{table}[h] \centering
\begin{tabular}{cc}

\begin{tikzpicture}

\draw \circumference{0}{0}{1.5} node [below left]{$A$};
\draw \circumference{0}{0}{3} node [above right] at (2.1,2.4){$B$};
\draw node at (0,-4) {$A \contained B \equiv \forall x [A(x) \to B(x)]$};

\end{tikzpicture}

&

\begin{tikzpicture}

\draw \circumference{7}{-1.5}{1.5} node [left] {$A$};
\draw \circumference{9}{-1.5}{1.5} node [right] {$B$};
\draw [fill] \circumference{8}{-1.5}{0.025};
\draw node at (8,-4) {$A \between B \equiv \exists x [A(x) \land B(x)]$};

\end{tikzpicture}

\\

\begin{tikzpicture}

\draw \circumference{0}{-1}{1.5} node [left] {$A$};
\draw \circumference{2}{-1}{1.5} node [right] {$B$};
\draw \circumference{1}{-1}{2};
\draw node at (1,-4) {$A \cap B \contained C \equiv \forall x [A(x) \land B(x) \to C(x)]$};

\end{tikzpicture}

&

$ \forall x [A(x) \lor B(x) \contained C(x)]$

\end{tabular}
\end{table}
\end{document}

这里我故意没有完成,因为我想知道这是否是最好的方法。我是否应该使用其他环境或将图表视为图形,以便我可以用相应的公式标记它们?此外,我所做的还有更优雅的方法吗?

谢谢。任何建议都会有用。

编辑我做了以下更改:

\documentclass{preamble}

\begin{document}
\pagestyle{empty}

\def\radius{1.5}

\newcommand{\ellipse}[4]{(#1,#2) ellipse (#3cm and #4cm)}
\newcommand{\circumference}[3]{(#1,#2) circle (#3cm)}

\begin{figure}[h] \centering \captionsetup[subfigure]{labelformat=empty} 
\begin{tabular}{cc}
\subfloat[{$A \subseteq B \equiv \forall x [A(x) \to B(x)]$}]{\begin{tikzpicture}

\draw \circumference{0}{0}{\radius} node at (45:2) {$A$};
\draw \ellipse{0}{0}{3}{2} node at (45:2.8) {$B$};

\end{tikzpicture}
}
&
\subfloat[{$A \between B \equiv \exists x [A(x) \land B(x)]$}]{

\begin{tikzpicture}

\draw \circumference{-1}{0}{\radius} node at (150:2.7) {$A$};
\draw \circumference{1}{0}{\radius} node at (30:2.7) {$B$};
\draw [fill] \circumference{0}{0}{0.025};

\end{tikzpicture}
}

\\

\subfloat[{$A \cap B \subseteq C \equiv \forall x [A(x) \land B(x) \to C(x)]$}]{
\begin{tikzpicture}
\draw \circumference{-1}{0}{\radius} node at (150:2.7) {$A$};
\draw \circumference{1}{0}{\radius} node at (30:2.7) {$B$};
\draw \ellipse{0}{0}{1}{2} node at (63:2.1) {$C$};
\end{tikzpicture}
}

&

\subfloat[{$ A \cup B \subseteq C \equiv \forall x [A(x) \lor B(x) \to C(x)]$}]{
\begin{tikzpicture}
\draw \circumference{-1}{0}{\radius} node at (150:2.6) {$A$};
\draw \circumference{1}{0}{\radius} node at (30:2.6) {$B$};
\draw \ellipse{0}{0}{3}{2.5} node at (63:2.8) {$C$};
\end{tikzpicture}
}

\\

\subfloat[{$ A \subseteq B \cup C \equiv \forall x [A(x) \to B(x) \lor C(x)] $}]{
\begin{tikzpicture}
\draw \circumference{-1}{0}{\radius} node at (150:2.7) {$B$};
\draw \circumference{1}{0}{\radius} node at (30:2.7) {$C$};
\draw \ellipse{0}{0}{1.5}{0.8} node at (45:1.4) {$A$};
\end{tikzpicture}
}

&

\subfloat[{$ A \subseteq B \cap C \equiv \forall x [A(x) \to B(x) \land C(x)]$}]{
\begin{tikzpicture}
\draw \circumference{-1}{0}{\radius} node at (150:2.7) {$B$};
\draw \circumference{1}{0}{\radius} node at (30:2.7) {$C$};
\draw \ellipse{0}{0}{0.35}{0.65} node at (92:0.835) {$A$};
\end{tikzpicture}
}


\end{tabular}
\end{figure}


\end{document}

我想知道以下问题是否有最佳解决方案:

  • 我想在圆和椭圆外用字母 A、B、C 标记集合自动地,与集合边界保持适当距离。

  • 省略号现在略有不同。有什么方法可以修复它们吗?

  • 我的新命令真的有用吗\circumference\ellipse还有更好的选择吗?

总之,我认为这不是编写代码的正确方法。你能帮助我吗?

我尝试定义如下命令

\def\firstcircle{(0,0) circle (1.5cm)}
\def\secondcircle{(0:2cm) circle (1.5cm)}

或者

% some coordinates for the center of the circles
\coordinate (ceni);
\coordinate[xshift=\radius] (cenii);

% the circles
\draw (ceni) circle (\radius);
\draw (cenii) circle (\radius);

但我真的想不出任何东西。另外,我找不到有关的任何文档(ceni)。它是用来做什么的?

坐标放在哪里最好(0,0)

最后,我可以轻松地复制粘贴我的代码,这样我就不必添加 4 个空格“ ”来将其可视化?

答案1

我认为您的问题可能被认为“主要基于观点”。无论如何,我可能会这样做。使用表格的想法很棒,但也许使用子图作为其单元格是合理的,并将数学关系放在子标题中而不是 s 的节点中tikzpicture。而且这个网站上已经有不少关于维恩图的问题和答案,所以您可能会从中得到启发。

\documentclass{article} % I do not have preamble.cls
\usepackage{tikz}
\newcommand{\contained}{\ensuremath{\supset}} % <- I made this up
\newcommand{\between}{\ensuremath{\in}} % <- I made this up

\usepackage{subfig}
\begin{document}
\pagestyle{empty}

\newcommand{\circumference}[3]{(#1,#2) circle (#3cm)}

\begin{figure}[h] \centering
\begin{tabular}{cc}
\subfloat[{$A \contained B \equiv \forall x [A(x) \to B(x)]$}]{\begin{tikzpicture}

\draw \circumference{0}{0}{1.5} node [below left]{$A$};
\draw \circumference{0}{0}{3} node [above right] at (2.1,2.4){$B$};
%\draw node at (0,-4) {};

\end{tikzpicture}
}
&
\subfloat[{$A \between B \equiv \exists x [A(x) \land B(x)]$}]{\begin{tikzpicture}

\draw \circumference{7}{-1.5}{1.5} node [left] {$A$};
\draw \circumference{9}{-1.5}{1.5} node [right] {$B$};
\draw [fill] \circumference{8}{-1.5}{0.025};
%\draw node at (8,-4) {$A \between B \equiv \exists x [A(x) \land B(x)]$};

\end{tikzpicture}}
\\
\subfloat[{$A \cap B \contained C \equiv \forall x [A(x) \land B(x) \to C(x)]$}]{\begin{tikzpicture}
\draw \circumference{0}{-1}{1.5} node [left] {$A$};
\draw \circumference{2}{-1}{1.5} node [right] {$B$};
\draw \circumference{1}{-1}{2};
%\draw node at (1,-4) {$A \cap B \contained C \equiv \forall x [A(x) \land B(x) \to C(x)]$};
\end{tikzpicture}}
&
\subfloat[{$ \forall x [A(x) \lor B(x) \contained C(x)]$}]{
}
\end{tabular}
\caption{Various Venn diagrams.}
\end{figure}
\end{document}

在此处输入图片描述

相关内容