# Box around circle with intersection

I want to create a rectangle Box with three intersected circles:

\documentclass[a4paper,11pt,fleqn]{scrartcl}
\usepackage{pgf,tikz}

\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}


My Problem is: The rectangle should go around all cirles.

• your question isn't very clear, the code shown produces the error ! LaTeX Error: Unknown float option 'H'. and it isn't clear how you want to change the output, which has intersecting circles already. Apr 17, 2017 at 11:21
• The code works fine. But the rectangle ist not aound all circles. It is only in the first circle Apr 17, 2017 at 11:23
• well if that is the question put that in the question:-) Apr 17, 2017 at 11:24
• The problem is that your nodes (firstcircle), (secondcircle) etc are just nodes of minimum size at the origin. Add some text to them and you'll see it. You have to make nodes with circle shape to make the fit thing work. Apr 17, 2017 at 11:48

Like this:

I significantly change your code, circle are drawn as nodes:

\documentclass[a4paper,11pt,fleqn]{scrartcl}
\usepackage{pgf,tikz}

\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}

• @David, glad to hear this. Happy TeX-ing. Apr 17, 2017 at 11:49