Graphics, Figures & TablesVenn Diagram help

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
Roseli_Ap_Leandro
Posts: 3
Joined: Mon May 15, 2017 5:25 pm

Venn Diagram help

Post by Roseli_Ap_Leandro »

How can I draw a rectangle around a Venn Diagram: A \cap B, A \cup B, etc? Thanks

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
TikZ book
User avatar
Stefan Kottwitz
Site Admin
Posts: 10314
Joined: Mon Mar 10, 2008 9:44 pm

Venn Diagram help

Post by Stefan Kottwitz »

Hi,

perhaps show the code that you are using, and some of us could add the rectangle. For now, nobody knows how the diagram is actually made. I just assume it's done in TikZ. So one could use the fit library, or ad it manually.

Stefan
LaTeX.org admin
Roseli_Ap_Leandro
Posts: 3
Joined: Mon May 15, 2017 5:25 pm

Venn Diagram help

Post by Roseli_Ap_Leandro »

The code...

Code: Select all

\begin{figure}[h]
% 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}
\draw[filled] \firstcircle node {$A$}
\secondcircle node {$B$};
\node[anchor=south] at (current bounding box.north) {$A \cup B$};
\end{tikzpicture}

\caption{Representação gráfica de operações com conjuntos}

\label{fig1}

\end{figure}
Last edited by Stefan Kottwitz on Tue May 16, 2017 12:32 am, edited 1 time in total.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10314
Joined: Mon Mar 10, 2008 9:44 pm

Venn Diagram help

Post by Stefan Kottwitz »

The easiest way is \fbox:

Code: Select all

\fbox{\begin{tikzpicture}
    \draw[filled] \firstcircle node {$A$}
    \secondcircle node {$B$};
    \node[anchor=south] at (current bounding box.north) {$A \cup B$};
    \end{tikzpicture}}
Stefan
LaTeX.org admin
Post Reply