Information and discussion about graphics, figures & tables in LaTeX documents.
mobearette
Posts: 5 Joined: Sat Oct 31, 2009 1:43 pm
Post
by mobearette » Sat Oct 31, 2009 2:02 pm
Hello everyone.
I have some troubles with my LaTeX homework. I should draw a venn diagram looking like this
captureex.png (19.24 KiB) Viewed 20896 times
What I did so far looks like this
blan.png (13.73 KiB) Viewed 20896 times
I suppose you see my problem; I don't know how to insert
etc on the right place.
Any ideas?
Here is my code
Code: Select all
\documentclass{article}
\usepackage{tikz}
%\usetikzlibrary{shapes,backgrounds}
\begin{document}
\pagestyle{empty}
\def\firstcircle{(0,0) circle (1.5cm)}
\def\secondcircle{(55:2cm) circle (1.5cm)}
\def\thirdcircle{(0:2cm) circle (1.5cm)}
\begin{tikzpicture}[line width=0.25pt]
\begin{scope}
\fill[red] \secondcircle;
\fill[green] \firstcircle;
\fill[blue] \thirdcircle;
\end{scope}
\begin{scope}
\clip \firstcircle;
\fill [yellow]
\secondcircle;
\end{scope}
\begin{scope}
\clip \secondcircle;
\fill [magenta] \thirdcircle;
\end{scope}
\begin{scope}
\clip \firstcircle;
\fill [cyan] \thirdcircle;
\end{scope}
\begin{scope}
\clip \firstcircle;
\clip \secondcircle;
\fill [white] \thirdcircle;
\end{scope}
\draw \firstcircle node[text=white, below] {$B$};
\draw \secondcircle node [text=white,above] {$A$};
\draw \thirdcircle node [text=white,below] {$C$};
\end{tikzpicture}
\end{document}
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide : 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook : 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ : the first book about TikZ for perfect drawings in your LaTeX thesis
localghost
Site Moderator
Posts: 9202 Joined: Fri Feb 02, 2007 12:06 pm
Post
by localghost » Sat Oct 31, 2009 2:11 pm
Just place the text as a node like you did with
A ,
B , and
C . The
pgf/tikZ manual explains that in detail.
Note: Please upload attachments to the forum server!
Best regards and welcome to the board
Thorsten¹
mobearette
Posts: 5 Joined: Sat Oct 31, 2009 1:43 pm
Post
by mobearette » Sat Oct 31, 2009 2:21 pm
localghost wrote:
Note: Please upload attachments to the forum server!
Sorry, I didn't know about this rule.
Thx for the quick anwser.
localghost
Site Moderator
Posts: 9202 Joined: Fri Feb 02, 2007 12:06 pm
Post
by localghost » Sat Oct 31, 2009 3:31 pm
mobearette wrote: Sorry, I didn't know about this rule. […]
See Board Rules.
My first reply wasn't thought out very well. So here's the detailed version. In principle you have a radial symmetric construction. Hence it is better to work with polar coordinates because placement of objects is simplified.
Code: Select all
\documentclass{article}
\usepackage{tikz}
%\usetikzlibrary{shapes,backgrounds}
\pagestyle{empty}
\def\firstcircle{(90:1.75cm) circle (2.5cm)}
\def\secondcircle{(210:1.75cm) circle (2.5cm)}
\def\thirdcircle{(330:1.75cm) circle (2.5cm)}
\begin{document}
\begin{tikzpicture}
\begin{scope}
\fill[red]\firstcircle;
\fill[green] \secondcircle;
\fill[blue] \thirdcircle;
\end{scope}
\begin{scope}
\clip \secondcircle;
\fill[yellow] \firstcircle;
\end{scope}
\begin{scope}
\clip \secondcircle;
\fill[cyan] \thirdcircle;
\end{scope}
\begin{scope}
\clip \firstcircle;
\fill[magenta] \thirdcircle;
\end{scope}
\begin{scope}
\clip \firstcircle;
\clip \secondcircle;
\fill[white] \thirdcircle;
\end{scope}
\draw \firstcircle node[text=white,above] {$A$};
\draw \secondcircle node [text=white,below left] {$B$};
\draw \thirdcircle node [text=white,below right] {$C$};
\begin{scope}[font=\small]
\node(0,0) {$A\cap B\cap C$};
\draw(30:1.5cm) node {$A\cap C$};
\draw(150:1.5cm) node {$A\cap B$};
\draw(270:1.5cm) node {$B\cap C$};
\end{scope}
\end{tikzpicture}
\end{document}
The last
scope environment consists of all the text that you want to place in this diagram.
mobearette
Posts: 5 Joined: Sat Oct 31, 2009 1:43 pm
Post
by mobearette » Sat Oct 31, 2009 4:05 pm
Thank you very much. You helped a lot.