# Positioning entries in a Venn diagram

I draw a Venn diagram for three sets A, B, and C. The radius of each circle is $2\sqrt{2}$, but I entered it as 2.828 because TikZ could not compile my code for the circles - such as \fill[draw=red] (-2,2) circle (2*sqrt(2));. How do I enter the radius as $2\sqrt{2}$?

The center of circle A is (-2,2), the center of circle B is (2,2), and the center of circle C is (0,-2). The points at which circle A and circle B intersect are the origin and (0,4). I want to place 2, which represents the number of elements in A, B, and C, on the vertical line between the origin and (0,4). I use the commands

\draw[overlay,name path=circle A] (-2,2) circle (2.828);,

\draw[overlay,name path=circle B] (2,2) circle (2.828);,

and

\path[name intersections={of= circle A and circle B, by=F}];

to locate one of them. TikZ locates the intersection at (0,4). How do I get TikZ to locate both of them and to call one intersection-AB1 and the other intersection-AB2? Likewise, I would like to call the intersections of circle B and circle C as intersection-BC1 and intersection-BC2, and I would like to call the intersections of circle B and circle C as intersection-AC1 and intersection-AC2. I would issue the commands

\path[name path=lineAB] (intersection-AB1) -- (intersection-AB2);,

\path[name path=lineBC] (intersection-BC1) -- (intersection-BC2);,

and

\path[name path=lineAC] (intersection-AC1) -- (intersection-AC2);,

and I would call that intersection P, and I would position 2 at P. (I don't want to have P in the Venn diagram; I will use it later to draw six other lines. Also, I don't want 2 to be above right of the location of point P; I want 2 to be typeset at the location of point P.)

In my Venn diagram, the number 5, which represents the number of elements in A and B that are not in C, is to be typeset on the line segment between intersection-AB1 and intersection-AB2. In particular, if I issue the command

\path[name intersections={of= (intersection-AB1) -- (intersection-AB2) and circle C, by=PC}];,

I want to have "5" typeset at the location halfway between PC and either intersection-AB1 or intersection-AB2 - the one outside circle C.

In my Venn diagram, there are 3 elements in A that are not in either B or C. If, for example, intersection-BC1 is the intersection of circle B and circle C that is inside circle A, I would like to draw an invisible ray from P through intersection-BC1 that intersects circle A. I would call the ray ray.PA and I would call the intersection of ray.PA and circle A the point intersection-PA and I would position 3 halfway between intersection-BC1 and intersection-PA.

One last modification to make. I don't want to use above left to position A. I want to position the label A at an angle of 120 degrees intersection-PA.

\documentclass{amsart}
\usepackage{tikz}
\usetikzlibrary{calc,angles,positioning,intersections,quotes,decorations.markings,backgrounds,patterns}

\usepackage{mathtools}

\begin{document}

\begin{tikzpicture}
\draw[overlay,name path=circle A] (-2,2) circle (2.828);
\draw[overlay,name path=circle B] (2,2) circle (2.828);
\draw[overlay,name path=circle C] (0,-2) circle (2.828);

\fill[pink!80,fill opacity=0.5,draw=red] (45:2.828) circle (2.828);
\fill[pink!80,fill opacity=0.5,draw=red] (135:2.828) circle (2.828);
\fill[pink!80,fill opacity=0.5,draw=red] (-90:2) circle (2.828);

\path[name intersections={of= circle A and circle B, by=F}];
\path[name intersections={of= circle A and circle C, by=G}];
\path[name intersections={of= circle B and circle C, by=H}];

%This positions a point, called S, halfway between the intersections of circle B and circle C.
\coordinate (S) at ($(G)!0.5!(H)$);
\draw[line width=0.1pt] (G) -- (H);

%This positions a point, called T, halfway between the intersections of circle A and circle C.
\coordinate (T) at ($(F)!0.5!(G)$);
\draw[line width=0.1pt] (F) -- (G);

%The following command puts the number 5 in the region $A \cap B$ and outside the region $A \cap B \cap C$.
\coordinate[label={5}] (A.intersect.B) at (0,2);

%These three rays start at P. They are used to position the names of the sets.
%I have to replace (0,0) with (P).
\path[overlay,name path=node A,blue,line width=0.1pt] (0,0) -- (120:6);
\path[overlay,name path=node B,blue,line width=0.1pt] (0,0) -- (60:6);
\path[overlay,name path=node C,blue,line width=0.1pt] (0,0) -- (-90:5);
\path[name intersections={of= node A and circle A, by=alpha}];
\path[name intersections={of= node B and circle B, by=beta}];
\path[name intersections={of= node C and circle C, by=gamma}];

\coordinate[label={above left:$A$}] (set A) at (alpha);
\coordinate[label={above right:$B$}] (set B) at (beta);
\coordinate[label={below:$C$}] (set C) at (gamma);

%These commands will be deleted. They label various points to more quickly see where the intersections
%F, G, and H are located.

\coordinate[label={above:$F$}] (F) at (F);
\coordinate[label={below left:$G$}] (G) at (G);
\coordinate[label={above right:$H$}] (H) at (H);
\node[outer sep=0pt,circle, fill,inner sep=1pt,label=below right:$S$] (S) at (S) {};
\node[outer sep=0pt,circle, fill,inner sep=1pt,label=above left:$T$] (T) at (T) {};
\end{tikzpicture}

\end{document}


For using sqrt use an extra pair of braces

\draw[overlay,name path=circle A] (-2,2) circle ({2*sqrt(2)});


For second, specify the second intersection point also like

\path[name intersections={of= circle A and circle B, by={F,f}}];


Drawing those thin lines is up to you as I don't know which points are to be connected.

If I understand the positioning of 5 properly, you need to do this:

\draw[line width=0.1pt] (F) -- node{5} (f) ;


so that it comes midway between AB1 and AB2.

For that 120 degree query use

\coordinate[label={above:$A$}] (set A) at (alpha.120);


And again, if I understand properly, this should give you the point P:

\path[line width=0.1pt,name path=ff] (F) -- node{5} (f) ;

\path[line width=0.1pt,name path=gg] (G) -- (g);
\path[name intersections={of= ff and gg, by=P}];


And alas, I am confused reading your question. Here is the possibly incomplete code. It would have been useful if you provided a complete hand drawn diagram.

\documentclass{amsart}
\usepackage{tikz}
\usetikzlibrary{calc,angles,positioning,intersections,quotes,decorations.markings,backgrounds,patterns}

\usepackage{mathtools}

\begin{document}

\begin{tikzpicture}
\draw[overlay,name path=circle A] (-2,2) circle ({2*sqrt(2)});
\draw[overlay,name path=circle B] (2,2) circle ({2*sqrt(2)});
\draw[overlay,name path=circle C] (0,-2) circle ({2*sqrt(2)});

\fill[pink!80,fill opacity=0.5,draw=red] (45:2.828) circle (2.828);
\fill[pink!80,fill opacity=0.5,draw=red] (135:2.828) circle (2.828);
\fill[pink!80,fill opacity=0.5,draw=red] (-90:2) circle (2.828);

\path[name intersections={of= circle A and circle B, by={F,f}}];
\path[name intersections={of= circle A and circle C, by={G,g}}];
\path[name intersections={of= circle B and circle C, by={H,h}}];

%This positions a point, called S, halfway between the intersections of circle B and circle C.
\coordinate (S) at ($(G)!0.5!(H)$);
\draw[line width=0.1pt] (G) -- (H);
\draw[line width=0.1pt] (g) -- (h);
\draw[line width=0.1pt] (F) -- (g);

%This positions a point, called T, halfway between the intersections of circle A and circle C.
\coordinate (T) at ($(F)!0.5!(G)$);
\draw[line width=0.1pt] (F) -- (G);
\path[line width=0.1pt,name path=ff] (F) -- node{5} (f) ;

\path[line width=0.1pt,name path=gg] (G) -- (g);
\path[name intersections={of= ff and gg, by=P}];

\node at (P) {2};

\draw[name path=PHH] (P) -- ($(P)!6cm!0:(H)$);  Change to \path
\path[name intersections={of= PHH and circle A, by=APHH}];
\path (H) -- node{3} (APHH);

%The following command puts the number 5 in the region $A \cap B$ and outside the region $A \cap B \cap C$.
%\coordinate[label={5}] (A.intersect.B) at (0,2);

%These three rays start at P. They are used to position the names of the sets.
%I have to replace (0,0) with (P).
\path[overlay,name path=node A,blue,line width=0.1pt] (0,0) -- (120:6);
\path[overlay,name path=node B,blue,line width=0.1pt] (0,0) -- (60:6);
\path[overlay,name path=node C,blue,line width=0.1pt] (0,0) -- (-90:5);
\path[name intersections={of= node A and circle A, by=alpha}];
\path[name intersections={of= node B and circle B, by=beta}];
\path[name intersections={of= node C and circle C, by=gamma}];

\coordinate[label={above:$A$}] (set A) at (alpha.120);
\coordinate[label={above right:$B$}] (set B) at (beta);
\coordinate[label={below:$C$}] (set C) at (gamma);

%These commands will be deleted. They label various points to more quickly see where the intersections
%F, G, and H are located.

\coordinate[label={above:$F$}] (F) at (F);
\coordinate[label={below left:$G$}] (G) at (G);
\coordinate[label={above right:$H$}] (H) at (H);
\node[outer sep=0pt,circle, fill,inner sep=1pt,label=below right:$S$] (S) at (S) {};
\node[outer sep=0pt,circle, fill,inner sep=1pt,label=above left:$T$] (T) at (T) {};
\end{tikzpicture}

\end{document}


• You have been quite helpful. Thanks. I am starting to look at your suggestions now. When I type \path[name intersections={of= circle A and circle B, by={F,f}}];, how do I know which will be at the origin and which will be at (0,4)? Should I just temporarily plot the points? – Adelyn May 12 '15 at 1:11
• I understand your confusion. I left two line segments in my code but forgot to say "these line segments are misplaced." I want the location of point P to be in the middle of $A \cap B \cap C$. – Adelyn May 12 '15 at 1:13
• @Adelyn The first intersection point will be F. Here it is the upper one as you start drawing the circle from right side (angle=0). – user11232 May 12 '15 at 1:23
• @Adelyn Draw Ff and Gg Find their intersection for P. – user11232 May 12 '15 at 1:25
• @Adelyn Add \draw[name path=PHH] (P) -- ($(P)!6cm!0:(H)$); \path[name intersections={of= PHH and circle A, by=APHH}]; \path (H) -- node{3} (APHH);. Change \draw by \path to remove the line. – user11232 May 12 '15 at 15:23