请帮帮我,我正在打一本书
\documentclass[x11names]{article}
% Set operations illustrated with Venn diagrams
% Author: Uwe Ziegenhagen
% This is an expanded version of an example provided by T. Tantau
\usepackage{amssymb}
\usepackage{tikz}
\usetikzlibrary{backgrounds}
%%%<
\usepackage{verbatim}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\setlength\PreviewBorder{5pt}%
%%%>
\begin{document}
% Definition of circles
\def\firstcircle{(0,0) circle (1.5cm)}
\def\secondcircle{(0:2cm) circle (1.5cm)}
\colorlet{circle edge}{blue!50}
\colorlet{circle area}{blue!20}
\tikzset{filled/.style={fill=circle area, draw=circle edge, thick},
outline/.style={draw=circle edge, thick}}
\setlength{\parskip}{5mm}
% Set A or B
\begin{tikzpicture}[framed]
\draw[filled] \firstcircle node {$A$}
\secondcircle node {$B$};
\node[anchor=south] at (current bounding box.north) {$A \cup B$};
\end{tikzpicture}
\end{document}
答案1
和往常一样,谷歌你的朋友。 看看这个典型例子这是我搜索到的第一个结果。这里的主要技巧是使用极坐标来展开圆。
如果您不喜欢极坐标,可以添加笛卡尔坐标,这可以更方便地将数字和其他装饰放置在近似于“适当”的位置。
\documentclass{文章} \usepackage{tikz} \usetikzlibrary{形状,背景} \开始{文档} \def\firstcircle{(135:1.2) 圆 (2)} \def\secondcircle{(45:1.2) 圆 (2)} \def\thirdcircle{(-90:1.2) 圆 (2)} \开始{tikzpicture} \tikzset{帮助行/.style={color=blue!20}} \draw[thin,help lines] (-4.5,-4.5) 网格 (4.5,4.5); \draw[ultra thin,step=.5,help lines] (-4.5,-4.5)网格(4.5,4.5); \draw[thick] (-4.5,0) -- (4.5,0); % x 坐标 \draw[thick] (0,-4) -- (0,4.5); % y 轴 \foreach \x in {-4,...,4} { \draw [thick] (\x,0) -- (\x,-0.2); } \foreach \y in {-4,...,4} { \draw [thick] (0,\y) -- (-0.2,\y); } \foreach \x in {-4,-3,...,4} { \node [anchor=north,text=blue] at (\x,-0.2) {\x}; } \foreach \y in {-4,-3,...,4} { \node [anchor=east,text=blue] at (-0.2,\y) {\y}; } \foreach \x in {-3.5,-3,...,3.5} {\draw [细线帮助线] (\x,0) -- (\x,-0.1);} \foreach \y in {-3.5,-3,...,3.5} {\draw [细线帮助线] (0,\y) -- (-0.1,\y);} \绘制\第一个圆; \绘制\第二个圆; \绘制\第三圆; \节点位于(0,0){2}; \节点位于(0,1.5){9}; \节点位于(1,-0.5){4}; \节点位于(-1,-0.5){5}; \节点位于(-2,1.5){10}; \节点位于(2,1.5){6}; \node 在(2,-3){$\mathbf L$}; \node 在 (-2,3) {$\mathbf M$}; \node 在(2,3){$\mathbf N$}; \节点位于(3,-1){11}; \节点位于(-3,-1){23}; \节点位于(-3,-3){13}; \节点位于(3,3){13}; \node 在 (-3,3) {$\mathbf U$}; \结束{tikzpicture} \结束{文档}
答案2
\documentclass[border=2mm,tikz]{standalone}
\usepackage{bm}
\begin{document}
\begin{tikzpicture}[thick]
\draw (2.7,-2.54) rectangle (-1.5,1.5) node[below right] {$\bm{U}$};
\draw (0,0) circle (1) node[above,shift={(0,1)}] {$\bm{M}$};
\draw (1.2,0) circle (1) node[above,shift={(0,1)}] {$\bm{N}$};
\draw (.6,-1.04) circle (1) node[shift={(1.1,-.6)}] {$\bm{L}$};
\node at (.6,-.4) {2};
\node at (1.2,-.7) {4};
\node at (0,-.7) {5};
\node at (1.4,.2) {6};
\node at (.6,.3) {9};
\node at (-.2,.2) {10};
\node at (2.2,-1.2) {11};
\node at (-1,-2.2) {12};
\node at (2.4,1.2) {13};
\node at (.3,-1.5) {16};
\node at (1,-1.4) {21};
\node at (-1.2,-1.5) {23};
\end{tikzpicture}
\end{document}
答案3
Thruston 建议的 venndiagram 包非常适合绘制这些图表,我相信还有其他方法可以做到这一点。话虽如此,如果您无法理解该包中移动或删除标签的方法,或者您是 TikZ 新手,您可以随时采用手动方法(作为起点,这种方法更容易理解)。
该代码背后的基本思想是三个圆圈,然后在它们之间放置一些标签的节点,xshift
并yshift
在必要时使用这些节点来调整位置。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{backgrounds,calc}
\begin{document}
\begin{tikzpicture}[venncircle/.style={draw, circle, minimum size=15em, align=center}, node distance=12.5em, framed]
\node[venncircle] (circle1) {10};
\node[venncircle, right of=circle1] (circle2) {6};
\node (MN) at ($(circle1)!0.5!(circle2)$){9};
\node[venncircle, below of=MN, yshift=3em] (circle3) {}; %yshift value by pythagoras
\node (ML) at ($(circle1)!0.5!(circle3)$){5};
\node (NL) at ($(circle2)!0.5!(circle3)$){4};
\node (MNL) at ($(MN)!0.3!(circle3)$){2};
\node (Lleft) [below of=ML, yshift=5em] {16};
\node (Lright) [below of=NL, yshift=5em] {21};
\node (outbotrightnum) [right of=circle3, yshift=1.5em, xshift=-2em] {11};
\node (outtoprightnum) [above right of=circle2, yshift=-2.5em, xshift=-1em] {13};
\node (outbotleftnum) [below left of=circle3, yshift=3em, xshift=-4em]{12};
\node (outtopleftnum) [left of=circle3, yshift=1.5em]{23};
\node (U)[above left of=circle1, xshift=2em, yshift=-1em]{\textbf{\textit{U}}};
\node (M)[above of=circle1, yshift=-4em]{\textbf{\textit{M}}};
\node (N)[above of=circle2, yshift=-4em]{\textbf{\textit{N}}};
\node (L)[below right of=circle3, yshift=2.5em, xshift=-2.5em]{\textbf{\textit{L}}};
\end{tikzpicture}
\end{document}
由此得出,
标签(数字和字母)位置的任何更改都必须由您自己进行,但它们确实与您提供的图片相似。