使用 Tikz 绘制具有两个节点的维恩图?

使用 Tikz 绘制具有两个节点的维恩图?

如何创建一个维恩图,其中实体不大于下方,但文本缩放以适应;并且圆圈水平对齐?

\documentclass[a4paper, 14pt]{article}

\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
  \tikzset{venn circle/.style={draw,circle,minimum width=3cm,fill=#1,opacity=0.4}}

  \node [venn circle] (A) at (0,0) {first order logic};
  \node [venn circle] (B) at (30:2cm) {logic programming};
  \node[below] at (barycentric cs:A=1/2,B=1/2){definite clause logic};
\end{tikzpicture}  

\end{document}

venn

答案1

文本节点大小 ( text width) 与节点大小 ( ) 无关minimum width, ...,您还可以选择更改字体大小。使用所有这些:

\documentclass[a4paper, 14pt]{standalone}

\usepackage{tikz}

\begin{document}

\begin{tikzpicture}[font=\tiny]
  \tikzset{venn circle/.style={draw,circle,minimum width=3cm,
            fill=#1,text width=1cm,align=center,opacity=0.4}%
   }

  \node [venn circle] (A) at (0,0) {first order logic};
  \node [venn circle] (B) at (30:2cm) {logic programming};
  \node[below,text width=1cm,align=center,anchor=center] at (barycentric cs:A=1/2,B=1/2){definite clause logic};
\end{tikzpicture}  

\end{document}

enter image description here

如果需要两个圆水平对齐,请更改at (30:cm)at (0:2cm)

答案2

为了完整起见,还有venndiagramNicola Talbot 编写的包,可以绘制漂亮的维恩图。

\documentclass{standalone}
\usepackage{venndiagram}
\begin{document}

\begin{venndiagram2sets}
\fillACapB
\end{venndiagram2sets}

\begin{venndiagram3sets}
\fillACapCNotB
\end{venndiagram3sets}
\end{document}

enter image description here

相关内容