# tikz — How to create rectangle around two nodes which are located diagonally to each other?

I want to have a rectangle that encircles A, AC, and C like the yellow one encircling B, BC, and C (I similarly want one encircling A, AB, and B), but I can't find any way of doing this. When I try like I did for B, BC, and C, the rectangle becomes huge

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes,backgrounds,shapes.misc, positioning,shapes.geometric,arrows,matrix,fit,calc}
\tikzset{
buffer/.style={
isosceles triangle,
isosceles triangle apex angle=66,
shape border rotate=90,
fill=blue!20,
node distance=5cm,
rounded corners=60pt,
opacity=0.6,
minimum height=6cm
}
}
\begin{document}

\begin{tikzpicture}

\tikzset{venn circle/.style={draw,circle,minimum width=9mm,fill=#1,opacity=0.6}}

\node at (0,0) {A};
\node (ABC) at (0,-2        ) {ABC};
\node (B) at (-2,-3) {B};
\node (AB) at (-1,-1.5) {AB};
\node (AC) at (1,-1.5) {AC};
\node (BC) at (0,-3) {BC};
\node (C) at (2,-3) {C};

\node[buffer]at (0,-1.9){};

\node[draw, thick, rounded corners = 2.5ex, fit=(B) (C),inner sep=3mm, opacity =    0.6, fill = yellow](FIt1) {};

\node[venn circle = green, thick] at (0,0) {A};
\node (ABC) at (0,-2        ) {ABC};
\node[venn circle = green, thick] (B) at (-2,-3) {B};
\node (AB) at (-1,-1.5) {AB};
\node (AC) at (1,-1.5) {AC};
\node (BC) at (0,-3) {BC};
\node[venn circle = green, thick]  (C) at (2,-3) {C};

\end{tikzpicture}
\end{document}


A subquestion I have is whether or not an outline line can be made here to make a black line around the yellow, red, and blue shapes

\begin{tikzpicture}[font=\sffamily\sansmath]

\tikzset{venn circle/.style={circle,minimum width=9mm,fill=#1,opacity=0.6}}

\node at (0,0) {A};
\node (ABC) at (0,-2        ) {ABC};
\node (B) at (-2,-3) {B};
\node (AB) at (-1,-1.5) {AB};
\node (AC) at (1,-1.5) {AC};
\node (BC) at (0,-3) {BC};
\node (C) at (2,-3) {C};

\node[buffer]at (0,-1.9){};

\draw [line width=35pt,opacity=0.6,blue,line cap=round,rounded corners] (A.center) -- (AC.center) -- (C.center);
\draw [line width=35pt,opacity=0.6,yellow,line cap=round,rounded corners] (C.center) -- (BC.center) -- (B.center);
\draw [line width=35pt,opacity=0.6,red,line cap=round,rounded corners] (A.center) -- (AB.center) -- (B.center);

\node[venn circle = green, thick] at (0,0) {A};
\node (ABC) at (0,-2        ) {ABC};
\node[venn circle = green, thick] (B) at (-2,-3) {B};
\node (AB) at (-1,-1.5) {AB};
\node (AC) at (1,-1.5) {AC};
\node (BC) at (0,-3) {BC};
\node[venn circle = green, thick]  (C) at (2,-3) {C};

\end{tikzpicture}


I was able to obtain the following picture:

For it I reduce your code significantly, see if this is useful for you.

\documentclass{article}
\usepackage{tikz}

\usetikzlibrary{arrows,backgrounds,calc,fit,matrix,positioning,
shapes,shapes.geometric,shapes.misc}
\pgfdeclarelayer{foreground}
\pgfdeclarelayer{background}
\pgfsetlayers{background,%
main,%
foreground%
}

\begin{document}
\begin{tikzpicture}[
venn circle/.style = {circle, draw, thick, fill=#1,
minimum width=9mm, opacity=0.6},
buffer/.style = {
isosceles triangle,
isosceles triangle apex angle=66,
shape border rotate=90,
fill=blue!20, opacity=0.6,
node distance=5cm,
rounded corners=60pt,
minimum height=6cm},
frames/.style args = {#1/#2}{minimum height=#1,
minimum width=#2+\pgfkeysvalueof{/pgf/minimum height},
draw, rounded corners=5mm, fill=yellow, opacity=0.6,
sloped},
]
\begin{pgfonlayer}{foreground}
\node (A) [venn circle = green]  at (0,0)    {A};
\node (B) [venn circle = green]  at (-2,-3)  {B};
\node (C) [venn circle = green]  at (2,-3)   {C};
\node (ABC) at (0,-2) {ABC};
\node (AB) at (-1,-1.5) {AB};
\node (AC) at (1,-1.5) {AC};
\node (BC) at (0,-3) {BC};
\end{pgfonlayer}
\begin{pgfonlayer}{main}
\path   let \p1 = ($(C.center)-(A.center)$),
\n1 = {veclen(\y1,\x1)} in
(A) --
node[frames=11mm/\n1] {} (C);
\path   let \p1 = ($(B.center)-(C.center)$),
\n1 = {veclen(\y1,\x1)} in
(B) --
node[frames=11mm/\n1] {} (C);
\end{pgfonlayer}
\begin{pgfonlayer}{background}
\node[buffer]at (0,-1.9){};
\end{pgfonlayer}
\end{tikzpicture}
\end{document}


Edit: In the first version of my answer I miss the point of question. Thanks to @Alenanno, who pointed me to this, I renew it (regardless, that probably the question is duplicate ... it has serve at least as my exercise :-)

• I think he meant A, AC and C, so a diagonal rectangle. But there are other answers like this on the site. – Alenanno Mar 3 '16 at 23:46
• Thanks! This is basically what I was looking for. I realize now it's sort of a duplicate, but I wasn't able to find those examples previously, so thanks, Alennanno – jjdd Mar 4 '16 at 1:13
• @jjdd, I didn't look before, that Alenanno give link to question where is also mine answer ... anyway, beside to your basic problem, I significantly change your original MWE. Only I didn't tuch in it is your style for buffer. – Zarko Mar 4 '16 at 1:30
• I added a secondary question in my original post. Would you by any chance know off the top of your head if it's possible? – jjdd Mar 4 '16 at 1:31
• @hm, if you ask for something different, would be better to as a new question. Frankly said, I do not understand what is new problem. What you like to color? – Zarko Mar 4 '16 at 1:34