带交叉点的圆圈周围的方框

带交叉点的圆圈周围的方框

我想创建一个带有三个相交圆的矩形框:

\documentclass[a4paper,11pt,fleqn]{scrartcl}
\usepackage{pgf,tikz}
\usetikzlibrary{arrows,shadows,decorations.pathreplacing,intersections,positioning,fit,calc,backgrounds}

\def\firstcircle{(0,0) circle (1.5cm)}
\def\secondcircle{(60:2.1cm) circle (1.5cm)}
\def\thirdcircle{(0:2.1cm) circle (1.5cm)}

\begin{document}
\begin{figure}[H]
\centering
\begin{tikzpicture}
\begin{scope}
\clip \firstcircle;
\clip \secondcircle;
\fill[red] \thirdcircle;
\end{scope}
\node (firstcircle)   {};
\node (secondcircle)  {};
\node (thirdcircle)  {};
\draw[name=first] \firstcircle node[below] (A) {$A$};
\draw[name=second] \secondcircle node [above] (B) {$B$};
\draw[name=third] \thirdcircle node [below] (C) {$C$};
\node (box) [fit=(firstcircle)(secondcircle)(thirdcircle), inner sep=1cm,draw,rounded corners] {};
\end{tikzpicture}
\end{figure}
\end{document}

在此处输入图片描述

我的问题是:矩形应该围绕所有圆圈。

答案1

像这样:

在此处输入图片描述

我显著地改变了你的代码,圆圈被绘制为节点:

\documentclass[a4paper,11pt,fleqn]{scrartcl}
\usepackage{pgf,tikz}
\usetikzlibrary{arrows,shadows,decorations.pathreplacing,intersections,positioning,fit,calc,backgrounds}

\def\firstcircle{(0,0) circle (1.5cm)}
\def\secondcircle{(60:2.1cm) circle (1.5cm)}
\def\thirdcircle{(0:2.1cm) circle (1.5cm)}

\begin{document}
\begin{figure}%[H]
\centering
    \begin{tikzpicture}[
    C/.style = {circle, draw, minimum size=30mm},% C as circle, minimum size is circle diameter
    F/.style = {draw, rounded corners, inner sep=1cm}% F as fit node
                        ]
\node (first)   [C] at (0,0)    {$A$};
\node (second)  [C] at (60:2.1) {$B$};
\node (third)   [C] at ( 0:2.1) {$B$};
\node (box) [F, fit=(first)(second)(third)] {};
\begin{scope}
\clip \firstcircle;
\clip \secondcircle;
\fill[red] \thirdcircle;
\end{scope}
\end{tikzpicture}
\end{figure}
\end{document}

相关内容