6

I'm new to latex and I'm trying to get this: enter image description here

After some googling I managed to get this:

enter image description here

using this code:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{tikz}
\title{FUN A3}
\author{12356}
\date{December 2017}
\setlength{\parindent}{0pt}
\begin{document}

\begin{tikzpicture}
 \tikzset{venn circle/.style={draw,circle,minimum 
 width=5.5cm,fill=#1,opacity=0.4}}

\node [venn circle = red] (A) at (0,0) {$0$};
\node [venn circle = blue] (B) at (60:4cm) {$1$};
\node [venn circle = green] (C) at (0:4cm) {$1$};
\node[left] at (barycentric cs:A=1/2,B=1/2 ) {$1$}; 
\node[below] at (barycentric cs:A=1/2,C=1/2 ) {$1$};   
\node[right] at (barycentric cs:B=1/2,C=1/2 ) {$0$};   
\node[below] at (barycentric cs:A=1/3,B=1/3,C=1/3 ){$0$};
\end{tikzpicture}  

If I write white for the coloring instead of blue or red they get transparent and I don't see any circles anymore and it would be great if someone can tell me how to make these yellow and light green colors behind my numbers in the background.

3

Just for fun ...

\documentclass[pstricks,border=1cm]{standalone}
\usepackage{auto-pst-pdf}
\begin{document}
\begin{pspicture}(-3,-3)(3,3)
\pgfforeach \iA/\iB in{90/3,210/2,330/1}{%
    \pscircle(1.2;\iA){2}%
    \rput(2;\iA){\colorbox{green!50}{$S_\iB$}}%
    \rput(!1.5 \iA\space 180 add PtoC){\colorbox{yellow}{$S_\iB$}}%
}
\rput(0,0){\colorbox{yellow}{$S_4$}}
\end{pspicture}
\end{document}

enter image description here

3
  • Hahaha no it's actually for a course called "Fundamentals of informatics" but we call it fun – user148199 Dec 21 '17 at 19:33
  • When i repleaced \documentclass{article} with \documentclass[pstricks,border=1cm]{standalone}. It won't compile, i tried merging them like this: \documentclass[pstricks,border=1cm]{standalone,article} it won't compile as well. Is there a solution for this? – user148199 Dec 21 '17 at 19:49
  • then you need \usepackage{pstricks}. This is done by standalone. And if you run pdflatex you need pdflatex --shell-escape <file>. However, the easiest way is to use xelatex – user2478 Dec 21 '17 at 19:57
4
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{tikz}
\title{FUN A3}
\author{12356}
\date{December 2017}
\setlength{\parindent}{0pt}
\begin{document}

\begin{tikzpicture}
 \tikzset{venn circle/.style={draw,circle,minimum 
 width=5.5cm}}

\node [venn circle, label={[fill=yellow]center:0}] (A) at (0,0) {};
\node [venn circle, label={[fill=yellow]center:1}] (B) at (60:4cm) {};
\node [venn circle, label={[fill=yellow]center:1}] (C) at (0:4cm) {};
\node[fill=yellow] at (barycentric cs:A=1/2,B=1/2 ) {1}; 
\node[fill=yellow] at (barycentric cs:A=1/2,C=1/2 ) {1};   
\node[fill=yellow] at (barycentric cs:B=1/2,C=1/2 ) {0};   
\node[fill=yellow] at (barycentric cs:A=1/3,B=1/3,C=1/3 ){0};
\end{tikzpicture}  
\end{document}

enter image description here

2

A PSTricks solution for emergency purpose.

\documentclass[pstricks,border=1cm]{standalone}
\begin{document}
\begin{pspicture}(-3,-3)(3,3)
    \pscircle(1.2;90){2}
    \pscircle(1.2;210){2}
    \pscircle(1.2;330){2}
    \psset{linestyle=none,fillstyle=solid}
    \psset{fillcolor=yellow}
    \rput(0,0){\psframebox{$S_4$}}
    \rput(1.5;150){\psframebox{$S_1$}}
    \rput(1.5;270){\psframebox{$S_3$}}
    \rput(1.5;30){\psframebox{$S_2$}}
    \psset{fillcolor=green!50}
    \rput(2;90){\psframebox{$S_3$}}
    \rput(2;210){\psframebox{$S_2$}}
    \rput(2;330){\psframebox{$S_1$}}
\end{pspicture}
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy