Click here to load reader

venndiagram v1.2: Drawing Simple Venn Diagramsmirror.utexas.edu/ctan/macros/latex/contrib/venndiagram/venn... · The Venn diagram en- vironments create coordinate nodes venn bottom

  • View
    220

  • Download
    0

Embed Size (px)

Text of venndiagram v1.2: Drawing Simple Venn...

venndiagram v1.2: Drawing Simple VennDiagrams

Nicola L. C. Talbothttp://www.dickimaw-books.com/

2018-06-07

The venndiagram package is provided to assist generating simple two- and three-set Venndiagrams for lectures or assignment sheets. This package requires the tikz package. As fromv1.1, this package no longer requires the intersections library.

The aim of this package is to provide very simple Venn diagrams for assignments or examquestions. If you require more complex diagrams or different layouts its simpler todirectly use the tikz package.

Contents

1 Available Commands and Environments 1

2 Examples 6

3 The Code 93.1 Initialising the Default Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103.2 Defining the key=value Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123.3 Circle Intersection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143.4 Environment Definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

Index 41

1 Available Commands and Environments

This package defines two environments:

venndiagram3sets

\begin{venndiagram3sets}[options ]

1

http://www.dickimaw-books.com/

(for two sets) and

venndiagram2sets

\begin{venndiagram2sets}[options ]

(for three sets).The optional argument options is a comma-separated list of key=value settings.

If the value contains commas or equal signs, make sure you enclose the entire value inbraces. For example:

\begin{venndiagram3sets}[tikzoptions={scale=2,thick}]

The following keys are available:

shade The name of the colour used to shade regions (default: lightgray).

labelA The label for the first set (default: $A$).

labelB The label for the second set (default: $B$).

labelC (Not available for the 2 set version.) The label for the third set (default: $C$).

labelOnlyA The label for the region given by A \ (B C ) (for 3 set version) or A \ B (for 2 setversion). (Default: empty.)

labelOnlyB The label for the region given by B \ (A C ) (for 3 set version) or B \ A (for 2 setversion). (Default: empty.)

labelOnlyC (Not available for 2 set version.) The label for the region given by C \ (A B).(Default: empty.)

labelOnlyAB (Not available for 2 set version.) The label for the region given by (A B) \ C .(Default: empty.)

labelOnlyAC (Not available for 2 set version.) The label for the region given by (A C ) \ B .(Default: empty.)

labelOnlyBC (Not available for 2 set version.) The label for the region given by (B C ) \ A.(Default: empty.)

labelABC (Not available for 2 set version.) The label for the region given by A B C . (De-fault: empty.)

labelNotABC (Not available for 2 set version.) The label for the region given by (AB C )c .(Default: empty.)

labelAB (Not available for 3 set version.) The label for the region given by A B . (Default:empty.)

2

labelNotAB (Not available for 3 set version.) The label for the region given by (A B)c .(Default: empty.)

radius The radius of each set. (Default: 1.2cm.)

hgap The horizontal gap between the outer vertical edge and the nearest set edge. (Default:0.5cm.)

vgap The vertical gap between the outer horizontal edge and the nearest set edge. (Default:0.5cm.)

overlap The overlap between the sets. (Default: 0.75cm.)

showframe This is a boolean option (default: true). If true, the surrounding rectangularframe is drawn. If false, the frame isnt drawn but still contributes to the total imagesize as a hidden path. If the value is omitted true is assumed.

tikzoptions Any options to pass to tikzpicture.

Both environments draw the outline of the sets and the rectangular outline of the encom-passing universal set. Within the Venn diagram environments commands are provided toshade various regions. (The commands have a cumulative effect, possibly drawing over eachother. The set outlines and labels are drawn at the end of the environment.) Available com-mands are as follows:

\fillA

\fillA

Shades set A.

\fillB

\fillB

Shades set B .

\fillC

\fillC

(Only for 3 set version.) Shades set C .

\fillAll

\fillAll

Shades the entire Venn diagram.

\fillNotABC

\fillNotABC

3

(Not available for 2 sets version.) Fills (AB C )c .

\fillOnlyA

\fillOnlyA

Shades set A \ (B C ) (for 3 sets version) or A \ B (for 2 sets version).

\fillOnlyB

\fillOnlyB

Shades set B \ (AC ) (for 3 sets version) or B \ A (for 2 sets version).

\fillOnlyC

\fillOnlyC

(Not available for 2 sets version.) Shades C \ (AB).

\fillNotA

\fillNotA

Shades everything except A (that is Ac ).

\fillNotB

\fillNotB

Shades everything except B (that is B c ).

\fillNotC

\fillNotC

(Not available for 2 set version.) Shades everything except C (that is C c ).

\fillNotAorB

\fillNotAorB

(Not available for 3 set version.) Shades (AB)c

\fillNotAorNotB

\fillNotAorNotB

(Not available for 3 set version.) Shades (AB)c

\fillANotB

\fillANotB

Shades A \ B .

4

\fillBNotA

\fillBNotA

Shades B \ A.

\fillANotC

\fillANotC

(Not available for 2 set version.) Shades A \C .

\fillCNotA

\fillCNotA

(Not available for 2 set version.) Shades C \ A.

\fillBNotC

\fillBNotC

(Not available for 2 set version.) Shades B \C .

\fillCNotB

\fillCNotB

(Not available for 2 set version.) Shades C \ B .

\fillACapB

\fillACapB

Shades AB . (\fillBCapA is equivalent to \fillACapB.)

\fillACapC

\fillACapC

(Not available for 2 set version.) Shades AC . (\fillCCapA is equivalent to \fillACapC.)

\fillBCapC

\fillBCapC

(Not available for 2 set version.) Shades B C . (\fillCCapB is equivalent to \fillBCapC.)

\fillACapBNotC

\fillACapBNotC

(Not available for 2 set version.) Shades A B \ C . (\fillBCapANotC is equivalent to\fillACapBNotC.)

5

\fillACapCNotB

\fillACapCNotB

(Not available for 2 set version.) Shades A C \ B . (\fillCCapANotB is equivalent to\fillACapCNotB.)

\fillBCapCNotA

\fillBCapCNotA

(Not available for 2 set version.) Shades B C \ A. (\fillCCapBNotA is equivalent to\fillBCapCNotA.)

\fillACapBCapC

\fillACapBCapC

(Not available for 2 set version.) Shades ABC . (Synonyms: \fillACapCCapB, \fillBCapACapC,\fillBCapCCapA, \fillCCapACapB, \fillCCapBCapA.)

\setpostvennhook

\setpostvennhook{cmds }

Sets the hook applied at the very end of the Venn diagram environments (after the outline andlabels are drawn but before the end of the tikzpicture environment). The Venn diagram en-vironments create coordinate nodes venn bottom left, venn top left, venn top rightand venn bottom right, which may be referenced within the environment or in the hook.

The set labels may also be referenced but only in \setpostvennhook : labelOnlyA,labelOnlyB, labelOnlyC (three set version only), labelNotABC (three set version only),labelNotAB (two set version only), labelA, labelB, labelC (three set version only), labelOnlyAB,labelOnlyAC (three set version only), labelOnlyBC (three set version only) and labelAB(two set version only).

2 Examples

1. (Three sets) AB C

\begin{venndiagram3sets}\fillA \fillB \fillC

\end{venndiagram3sets}

Produces:

6

A B

C

2. (Two sets) AB

\begin{venndiagram2sets}\fillA \fillB

\end{venndiagram2sets}

Produces:

A B

3. (Three sets) A \ (B C )

\begin{venndiagram3sets}\fillOnlyA

\end{venndiagram3sets}

Produces:

A B

C

7

4. (Two sets) AB :

\begin{venndiagram2sets}\fillACapB\end{venndiagram2sets}

A B

5. (Three sets) region labels:

\begin{venndiagram3sets}[labelOnlyA={1},labelOnlyB={2},labelOnlyC={3},labelOnlyAB={4},labelOnlyAC={5},labelOnlyBC={6},labelABC={7},labelNotABC={8}]

\end{venndiagram3sets}

Produces:

1 2

3

8

A B

C

7

4

5 6

6. Annotating the diagram:

\begin{venndiagram3sets}[labelOnlyA={1},labelOnlyB={2},labelOnlyC={3},labelOnlyAB={4},labelOnlyAC={5},labelOnlyBC={6},labelABC={7},labelNotABC={8}]

\setpostvennhook{

\draw[

\draw[

The pgf package reversed the order of arguments of atan2 in v3.0, which messes things upa bit. In the event that there are users with older versions of pgf, backward-compatibility isrequired. Add a switch to determine which syntax to use.

\ifvennoldpgf If true use old syntax.

6 \newif\ifvennoldpgf

Try to determine this setting.

7 \ifdef\pgfversion8 {9 \def\@[email protected]#1.#2\@[email protected]@checkversion{%

10 \ifnum#1

\@[email protected]@OnlyAC Sets A and C but not B :24 \newcommand*{\@[email protected]@OnlyAC}{}

\@[email protected]@OnlyBC Sets B and C but not A:25 \newcommand*{\@[email protected]@OnlyBC}{}

\@[email protected]@ABC Intersection of sets A, B and C :26 \newcommand*{\@[email protected]@ABC}{}

\@[email protected]@NotABC Everything except A, B or C :27 \newcommand*{\@[email protected]@NotABC}{}

\@[email protected]@NotAB Everything except A or B (two set version only):28 \newcommand*{\@[email protected]@NotAB}{}

\@[email protected]@AB Intersection of A and B (two set version only):29 \newcommand*{\@[email protected]@AB}{}

Now the default dimensions of the diagrams.

\@[email protected] The radius of the sets.30 \newcommand*{\@[email protected]}{1.2cm}

\@[email protected] The horizontal distance between the edge of the diagram and the outer edge of the nearestset.

31 \newcommand*{\@[email protected]}{0.5cm}

\@[email protected] % The vertical distance between the edge of the diagram and the33 % outer edge of the nearest set.34 \newcommand*{\@[email protected]}{0.5cm}

\@[email protected] The size of the set overlap.35 \newcommand*{\@[email protected]}{0.75cm}

\@[email protected] Any options to be passed to the tikzpicture environment.36 \newcommand*{\@[email protected]}{}

Lengths to store the centres of the sets and the overall width and height of the diagram.

\@[email protected] The x-coordinate of set A:37 \newlength\@[email protected]

\@[email protected] The y-coordinate of set A:38 \newlength\@[email protected]

\@[email protected] The x-coordinate of set B :39 \newlength\@[email protected]

11

\@[email protected] The y-coordinate of set B :

40 \newlength\@[email protected]

\@[email protected] The x-coordinate of set C :

41 \newlength\@[email protected]

\@[email protected] The y-coordinate of set C :

42 \newlength\@[email protected]

\@[email protected] The width of the entire Venn diagram.

43 \newlength\@[email protected]

\@[email protected] The height of the entire Venn diagram.

44 \newlength\@[email protected]

3.2 Defining the key=value Options

Now define the keys for the optional argument of venndiagram2sets and venndiagram3sets.They are all in the family venn.

shade Option to set the shading.

45 \[email protected]{venn}{shade}{\def\@[email protected]{#1}}

labelA Option to set the label for set A.

46 \[email protected]{venn}{labelA}{\def\@[email protected]@A{#1}}

labelB Option to set the label for set B .

47 \[email protected]{venn}{labelB}{\def\@[email protected]@B{#1}}

labelC Option to set the label for set C .

48 \[email protected]{venn}{labelC}{\def\@[email protected]@C{#1}}

Now for the region labels.

labelOnlyA Option to set the label for only set A.

49 \[email protected]{venn}{labelOnlyA}{\def\@[email protected]@OnlyA{#1}}

labelOnlyB Option to set the label for only set B .

50 \[email protected]{venn}{labelOnlyB}{\def\@[email protected]@OnlyB{#1}}

labelOnlyC Option to set the label for only set C .

51 \[email protected]{venn}{labelOnlyC}{\def\@[email protected]@OnlyC{#1}}

labelOnlyAB Option to set the label for the intersection of A and B .

52 \[email protected]{venn}{labelOnlyAB}{\def\@[email protected]@OnlyAB{#1}}

12

labelOnlyAC Option to set the label for the intersection of A and C .

53 \[email protected]{venn}{labelOnlyAC}{\def\@[email protected]@OnlyAC{#1}}

labelOnlyBC Option to set the label for the intersection of B and C .

54 \[email protected]{venn}{labelOnlyBC}{\def\@[email protected]@OnlyBC{#1}}

labelABC Option to set the label for the intersection of A, B and C . (Three set version only)

55 \[email protected]{venn}{labelABC}{\def\@[email protected]@ABC{#1}}

labelNotABC Option to set the label for the region outside the three sets. (Three set version only)

56 \[email protected]{venn}{labelNotABC}{\def\@[email protected]@NotABC{#1}}

labelAB Option to set the label for the intersection of A and B . (Two set version only)

57 \[email protected]{venn}{labelAB}{\def\@[email protected]@AB{#1}}

labelNotAB Option to set the label for the region outside the two sets. (Two set version only)

58 \[email protected]{venn}{labelNotAB}{\def\@[email protected]@NotAB{#1}}

Now for the dimension options.

radius Option to set the radius.

59 \[email protected]{venn}{radius}{\def\@[email protected]{#1}}

hgap Option to set the horizontal gap between the outer edge of the diagram and the nearest setedge.

60 \[email protected]{venn}{hgap}{\def\@[email protected]{#1}}

vgap Option to set the vertical gap between the outer edge of the diagram and the nearest set edge.

61 \[email protected]{venn}{vgap}{\def\@[email protected]{#1}}

overlap Option to set the set overlap.

62 \[email protected]{venn}{overlap}{\def\@[email protected]{#1}}

showframe Draw the frame outline.

63 \[email protected]{venn}[venn]{showframe}[true]{}64 \vennshowframetrue

Finally the option to set the information to pass to the tikzpicture environment.

tikzoptions

65 \[email protected]{venn}{tikzoptions}{\def\@[email protected]{#1}}

13

3.3 Circle Intersection

Previously commands like \fillOnlyA used pgf path operations to compute the intersectionpoints of the circles, but the code didnt work properly when the co-ordinate system has beenscaled. Version 1.1 changes this to calculate the co-ordinates in a more low-level way. Wehave two circles centred on (ax , ay ) and (bx ,by ) both with radius r . This gives the equations:

(x ax )2 + (y ay )2 = r 2 (1)(x bx )2 + (y by )2 = r 2 (2)

Combining:(x ax )2 (x bx )2 + (y ay )2 (y by )2 = 0 (3)

Re-arranging gives the equation of the chord between the two points of intersection:

x(bx ax )+ y(by ay ) =b2x a2x +b2y a2y

2

Special cases:

1. bx = ax (circles vertically stacked):

y(by ay ) =b2y a2y

2

Rearranging gives y = 12 (by +ay ). Substituting into (1):

(x ax )2 +(

1

2(by +ay )ay

)2= r 2

(x ax )2 + 14

(by ay )2 = r 2

x2 2xax +a2x +(by ay )2

4 r 2 = 0

This is a quadratic equation in x with solutions given by

x = ax

a2x (

a2x +(by ay )2

4 r 2

)= ax

r 2 1

4(by ay )2

If r 2 < 14 (by ay )2 then no solution exists (circles dont overlap). If r 2 = 14 (by ay )2 thentheres only one point of intersection.

2. by = ay (circles horizontally aligned):

x(bx ax ) =b2x a2x

2

14

Rearranging gives x = 12 (bx +ax ). Substituting into (1):(bx +ax

2ax

)2+ (y ay )2 = r 2

1

4(bx ax )2 + (y ay )2 = r 2

y2 2y ay +a2y +1

4(bx ax )2 r 2 = 0

This is a quadratic equation in y with solutions given by

y = ay

a2y (

a2y +(bx ax )2

4 r 2

)= ay

r 2 1

4(bx ax )2

If r 2 < 14 (bx ax )2 then no solution exists (circles dont overlap). If r 2 = 14 (bx ax )2 thentheres only one point of intersection.

The general case has the chord given by equation (3), which can be rewritten in the formy = mx + c where

m = ax bxby ay

c =b2x a2x +b2y a2y

2(by ay )Substituting into equation (1):

(x ax )2 + ((mx + c)ay )2 = r 2

Rearranging:

(1+m2)x2 +2x(mc ax ay m)+a2x + c2 2ay c +a2y r 2 = 0

This is a quadratic solution in x with solutions given by

x =(mc ax ay m)

(mc ax ay m)2 (1+m2)(a2x + c2 2ay c +a2y r 2)

1+m2Provide command to compute the intersection of two circles of the same radius (given by

\@[email protected]

\@[email protected] The four arguments are ax , ay , bx and by (the centre co-ordinates in lengths). The results arestored in \@[email protected]@[email protected], \@[email protected]@[email protected], \@[email protected]@[email protected] and\@[email protected]@[email protected] The number of intersects (0, 1 or 2) is stored in \@[email protected]@n.66 \newcommand*{\@[email protected]}[4]{%67 \ifdim#1=#3\relax

15

Case 1 (ax = bx ). Compute y = 12 (by +ay ).68 \pgfmathsetlength{\@[email protected]@[email protected]}{0.5*(#4+#2)}%69 \setlength{\@[email protected]@[email protected]}{\@[email protected]@[email protected]}%

Compute r 2 14 (by ay )270 \pgfmathsetlength{\[email protected]}{#4-#2}%71 \pgfmathsetlength{\[email protected]}{\@[email protected]*\@[email protected]*\[email protected]*\[email protected]}%72 \setlength{\@[email protected]@[email protected]}{#1}%73 \setlength{\@[email protected]@[email protected]}{#1}%74 \ifdim\[email protected]=0pt\relax

One point of intersection.

75 \def\@[email protected]@n{1}%76 \else77 \ifdim\[email protected]>0pt\relax

Two points of intersection.

78 \def\@[email protected]@n{2}%79 \pgfmathsetlength{\[email protected]}{sqrt(\[email protected])}%80 \addtolength{\@[email protected]@[email protected]}{\[email protected]}%81 \addtolength{\@[email protected]@[email protected]}{-\[email protected]}%82 \else

No intersection.

83 \def\@[email protected]@n{0}%84 \fi85 \fi86 \else87 \ifdim#2=#4\relax

Case 2 (ay = by ). Compute x = 12 (bx +ax )88 \pgfmathsetlength{\@[email protected][email protected]@x}{0.5*(#3+#1)}%89 \setlength{\@[email protected]@[email protected]}{\@[email protected]@[email protected]}%

Compute r 2 14 (bx ax )290 \setlength{\[email protected]}{#3}%91 \addtolength{\[email protected]}{-#1}%92 \pgfmathsetlength{\[email protected]}{\@[email protected]*\@[email protected] -0.25*\[email protected]*\[email protected]}%94 \setlength{\@[email protected]@[email protected]}{#2}%95 \setlength{\@[email protected]@[email protected]}{#2}%96 \ifdim\[email protected]=0pt\relax

One point of intersection.

97 \def\@[email protected]@n{1}%98 \else99 \ifdim\[email protected]>0pt\relax

Two points of intersection.

100 \def\@[email protected]@n{2}%101 \pgfmathsetlength{\[email protected]}{sqrt(\[email protected])}%102 \addtolength{\@[email protected]@[email protected]}{\[email protected]}%

16

103 \addtolength{\@[email protected]@[email protected]}{-\[email protected]}%104 \else

No intersection.

105 \def\@[email protected]@n{0}%106 \fi107 \fi108 \else

General case. Convert all lengths to scalar to reduce chances of exceeding max dimension.Using inches to ensure more reasonable values.

109 \pgfmathparse{#1/72.27}\let\@[email protected]\pgfmathresult110 \pgfmathparse{#2/72.27}\let\@[email protected]\pgfmathresult111 \pgfmathparse{#3/72.27}\let\@[email protected]\pgfmathresult112 \pgfmathparse{#4/72.27}\let\@[email protected]\pgfmathresult113 \pgfmathparse{\@[email protected]/72.27}\let\@[email protected]\pgfmathresult114 \pgfmathparse{\@[email protected]*\@[email protected]}\let\@[email protected]@sq\pgfmathresult115 \pgfmathparse{\@[email protected]*\@[email protected]}\let\@[email protected]@sq\pgfmathresult116 \pgfmathparse{\@[email protected]*\@[email protected]}\let\@[email protected]@sq\pgfmathresult117 \pgfmathparse{\@[email protected]*\@[email protected]}\let\@[email protected]@sq\pgfmathresult118 \pgfmathparse{\@[email protected]*\@[email protected]}\let\@[email protected]@sq\pgfmathresult

Set

c =b2x a2x +b2y a2y

2(by ay )119 \pgfmathparse{0.5*(\@[email protected]@sq-\@[email protected]@sq+\@[email protected]@sq-\@[email protected]@sq)120 /(\@[email protected]\@[email protected])}%121 \let\@[email protected]\pgfmathresult

Set

m = ax bxby ay

122 \pgfmathparse{(\@[email protected]\@[email protected])/(\@[email protected]\@[email protected])}%123 \let\@[email protected]\pgfmathresult

Compute (1+m2).124 \pgfmathparse{1+\@[email protected]*\@[email protected]}%125 \let\@[email protected]@[email protected]@sq\pgfmathresult

Computemc ax ay m = m(c ay )ax

126 \pgfmathparse{\@[email protected]*(\@[email protected]\@[email protected])-\@[email protected]}%127 \let\@[email protected]\pgfmathresult

Denote this value b and now compute

b2 (1+m2)(a2x +a2y + c2 2ay c r 2)

128 \pgfmathparse{\@[email protected]*\@[email protected] - \@[email protected]@[email protected]@sq130 *(\@[email protected]@sq+\@[email protected]@sq+\@[email protected]*\@[email protected]

17

131 -2*\@[email protected]*\@[email protected]\@[email protected]@sq)}%132 \let\@[email protected]\pgfmathresult133 \setlength\[email protected]{\pgfmathresult in}%134 \ifdim\[email protected]=0pt\relax

One point of intersection.

135 \def\@[email protected]@n{1}%

x1 = b1+m2

136 \pgfmathparse{-\@[email protected]/\@[email protected]@[email protected]@sq}%137 \setlength{\@[email protected]@[email protected]}{\pgfmathresult in}%138 \setlength{\@[email protected]@[email protected]}{\@[email protected]@[email protected]}%

y1 = mx1 + c139 \pgfmathparse{\pgfmathresult*\@[email protected]+c}%140 \setlength{\@[email protected]@[email protected]}{\pgfmathresult in}%141 \setlength{\@[email protected]@[email protected]}{\@[email protected]@[email protected]}%142 \else143 \ifdim\[email protected]>0pt\relax

Two points of intersection.

144 \def\@[email protected]@n{2}%145 \pgfmathsqrt{\@[email protected]}%146 \let\@[email protected]\pgfmathresult

First point.

147 \pgfmathparse{(-\@[email protected]+\@[email protected])/\@[email protected]@[email protected]@sq}%148 \setlength{\@[email protected]@[email protected]}{\pgfmathresult in}%149 \pgfmathparse{\pgfmathresult*\@[email protected]+\@[email protected]}%150 \setlength{\@[email protected]@[email protected]}{\pgfmathresult in}%

Second point.

151 \pgfmathparse{(-\@[email protected]\@[email protected])/\@[email protected]@[email protected]@sq}%152 \setlength{\@[email protected]@[email protected]}{\pgfmathresult in}%153 \pgfmathparse{\pgfmathresult*\@[email protected]+\@[email protected]}%154 \setlength{\@[email protected]@[email protected]}{\pgfmathresult in}%155 \else

No intersection.

156 \def\@[email protected]@n{0}%157 \fi158 \fi159 \fi160 \fi161 }

\@[email protected]@[email protected] \newlength\@[email protected]@[email protected]

\@[email protected]@[email protected] \newlength\@[email protected]@[email protected]

18

\@[email protected]@[email protected]

164 \newlength\@[email protected]@[email protected]

\@[email protected]@[email protected]

165 \newlength\@[email protected]@[email protected]

3.4 Environment Definitions

venndiagram3sets Environment to draw Venn diagram with three sets.

166 \newenvironment{venndiagram3sets}[1][]%167 {%

Disable the keys that arent applicable.

168 \[email protected]{venn}{labelAB,labelNotAB}%

Set the key values given in the optional argument.

169 \setkeys{venn}{#1}%

Calculate centre of set C

170 \pgfmathsetlength{\@[email protected]}{\@[email protected] + 2*\@[email protected] -0.5*\@[email protected]}%172 \pgfmathsetlength{\@[email protected]}{\@[email protected]+\@[email protected]}%

Calculate centre of set A

173 \pgfmathsetlength{\@[email protected]}{\@[email protected]+\@[email protected]}%174 \pgfmathsetlength{\@[email protected]}{\@[email protected] + (\@[email protected] - 0.5*\@[email protected])*1.73205}%

Calculate centre of set B

176 \pgfmathsetlength{\@[email protected]}{\@[email protected]+3*\@[email protected] -\@[email protected]}%178 \setlength{\@[email protected]}{\@[email protected]}%

Compute dimensions of entire diagram

179 \pgfmathsetlength{\@[email protected]}{2*\@[email protected]+4*\@[email protected] -\@[email protected]}%181 \pgfmathsetlength{\@[email protected]}{2*\@[email protected]+4*\@[email protected] -\@[email protected]}%

Define filling commands. Fill all of set A:

183 \def\fillA{\path[fill=\@[email protected]] (\@[email protected],\@[email protected])184 circle (\@[email protected]);}%

Fill all of set B :

185 \def\fillB{\path[fill=\@[email protected]] (\@[email protected],\@[email protected])186 circle (\@[email protected]);}%

Fill all of set C :

187 \def\fillC{\path[fill=\@[email protected]] (\@[email protected],\@[email protected])188 circle (\@[email protected]);}%

19

Fill everything:

189 \def\fillAll{\path[fill=\@[email protected]] (0,0)190 rectangle (\@[email protected],\@[email protected]);}%

Fill everything except set A:

191 \def\fillNotA{\path[fill=\@[email protected],even odd rule]192 (0,0) rectangle (\@[email protected],\@[email protected])193 (\@[email protected],\@[email protected]) circle (\@[email protected]);}%

Fill everything except set B :

194 \def\fillNotB{\path[fill=\@[email protected],even odd rule]195 (0,0) rectangle (\@[email protected],\@[email protected])196 (\@[email protected],\@[email protected]) circle (\@[email protected]);}%

Fill everything except set C :

197 \def\fillNotC{\path[fill=\@[email protected],even odd rule]198 (0,0) rectangle (\@[email protected],\@[email protected])199 (\@[email protected],\@[email protected]) circle (\@[email protected]);}%

Fill only set A.

200 \let\fillOnlyA\@[email protected]@threesets

Fill only set B :

201 \let\fillOnlyB\@[email protected]@threesets

Fill only set C :

202 \let\fillOnlyC\@[email protected]@threesets

Fill everything except A, B or C .

203 \let\fillNotABC\@[email protected]@threesets

Fill A but not B

204 \def\fillANotB{%205 \begin{scope}206 \clip (\@[email protected],\@[email protected]) circle (\@[email protected]);207 \path[fill=\@[email protected],even odd rule]208 (\@[email protected],\@[email protected]) circle (\@[email protected])209 (\@[email protected],\@[email protected]) circle (\@[email protected]);210 \end{scope}211 }%

Fill B but not A

212 \def\fillBNotA{%213 \begin{scope}214 \clip (\@[email protected],\@[email protected]) circle (\@[email protected]);215 \path[fill=\@[email protected],even odd rule]216 (\@[email protected],\@[email protected]) circle (\@[email protected])217 (\@[email protected],\@[email protected]) circle (\@[email protected]);218 \end{scope}219 }%

Fill A but not C

220 \def\fillANotC{%

20

221 \begin{scope}222 \clip (\@[email protected],\@[email protected]) circle (\@[email protected]);223 \path[fill=\@[email protected],even odd rule]224 (\@[email protected],\@[email protected]) circle (\@[email protected])225 (\@[email protected],\@[email protected]) circle (\@[email protected]);226 \end{scope}227 }%

Fill C but not A

228 \def\fillCNotA{%229 \begin{scope}230 \clip (\@[email protected],\@[email protected]) circle (\@[email protected]);231 \path[fill=\@[email protected],even odd rule]232 (\@[email protected],\@[email protected]) circle (\@[email protected])233 (\@[email protected],\@[email protected]) circle (\@[email protected]);234 \end{scope}235 }%

Fill B but not C

236 \def\fillBNotC{%237 \begin{scope}238 \clip (\@[email protected],\@[email protected]) circle (\@[email protected]);239 \path[fill=\@[email protected],even odd rule]240 (\@[email protected],\@[email protected]) circle (\@[email protected])241 (\@[email protected],\@[email protected]) circle (\@[email protected]);242 \end{scope}243 }%

Fill C but not B

244 \def\fillCNotB{%245 \begin{scope}246 \clip (\@[email protected],\@[email protected]) circle (\@[email protected]);247 \path[fill=\@[email protected],even odd rule]248 (\@[email protected],\@[email protected]) circle (\@[email protected])249 (\@[email protected],\@[email protected]) circle (\@[email protected]);250 \end{scope}251 }%

Fill A intersect B

252 \def\fillACapB{%253 \begin{scope}254 \clip (\@[email protected],\@[email protected]) circle (\@[email protected]);255 \path[fill=\@[email protected]]256 (\@[email protected],\@[email protected]) circle (\@[email protected]);257 \end{scope}258 }%

Define a synonym:

259 \let\fillBCapA\fillACapB

Fill A intersect C

260 \def\fillACapC{%

21

261 \begin{scope}262 \clip (\@[email protected],\@[email protected]) circle (\@[email protected]);263 \path[fill=\@[email protected]]264 (\@[email protected],\@[email protected]) circle (\@[email protected]);265 \end{scope}266 }%

Define a synonym:

267 \let\fillCCapA\fillACapC

Fill B intersect C

268 \def\fillBCapC{%269 \begin{scope}270 \clip (\@[email protected],\@[email protected]) circle (\@[email protected]);271 \path[fill=\@[email protected]]272 (\@[email protected],\@[email protected]) circle (\@[email protected]);273 \end{scope}274 }%

Define a synonym:

275 \let\fillCCapB\fillBCapC

Fill A intersect B but not C

276 \def\fillACapBNotC{%277 \begin{scope}278 \clip (\@[email protected],\@[email protected]) circle (\@[email protected]);279 \clip (\@[email protected],\@[email protected]) circle (\@[email protected]);280 \path[fill=\@[email protected],even odd rule]281 (\@[email protected],\@[email protected]) circle (\@[email protected])282 (\@[email protected],\@[email protected]) circle (\@[email protected]);283 \end{scope}284 }%

Define a synonym:

285 \let\fillBCapANotC\fillACapBNotC

Fill A intersect C but not B

286 \def\fillACapCNotB{%287 \begin{scope}288 \clip (\@[email protected],\@[email protected]) circle (\@[email protected]);289 \clip (\@[email protected],\@[email protected]) circle (\@[email protected]);290 \path[fill=\@[email protected],even odd rule]291 (\@[email protected],\@[email protected]) circle (\@[email protected])292 (\@[email protected],\@[email protected]) circle (\@[email protected]);293 \end{scope}294 }%

Define a synonym:

295 \let\fillCCapANotB\fillACapCNotB

Fill B intersect C but not A

296 \def\fillBCapCNotA{%

22

297 \begin{scope}298 \clip (\@[email protected],\@[email protected]) circle (\@[email protected]);299 \clip (\@[email protected],\@[email protected]) circle (\@[email protected]);300 \path[fill=\@[email protected],even odd rule]301 (\@[email protected],\@[email protected]) circle (\@[email protected])302 (\@[email protected],\@[email protected]) circle (\@[email protected]);303 \end{scope}304 }%

Define a synonym:

305 \let\fillCCapBNotA\fillBCapCNotA

Fill the intersection of all three sets

306 \def\fillACapBCapC{%307 \begin{scope}308 \clip (\@[email protected],\@[email protected]) circle (\@[email protected]);309 \clip (\@[email protected],\@[email protected]) circle (\@[email protected]);310 \path[fill=\@[email protected]]311 (\@[email protected],\@[email protected]) circle (\@[email protected]);312 \end{scope}313 }%

Define synonyms:

314 \let\fillACapCCapB\fillACapBCapC315 \let\fillBCapACapC\fillACapBCapC316 \let\fillBCapCCapA\fillACapBCapC317 \let\fillCCapACapB\fillACapBCapC318 \let\fillCCapBCapA\fillACapBCapC

Start the tikzpicture environment.319 \ifdefempty{\@[email protected]}%320 {%321 \def\@[email protected]{\begin{tikzpicture}}%322 }%323 {%324 \edef\@[email protected]{\noexpand\begin{tikzpicture}%325 [\expandonce\@[email protected]]}%326 }%327 \@[email protected]

coordinates of the Venn diagram corners

328 \path (0,0) coordinate (venn bottom left)329 (0,\@[email protected]) coordinate (venn top left)330 (\@[email protected],\@[email protected]) coordinate (venn top right)331 (\@[email protected],0) coordinate (venn bottom right);332 }%

End environment code:

333 {%

Draw outlines

334 \ifvennshowframe

23

335 \draw (0,0) rectangle (\@[email protected],\@[email protected]);336 \else337 \path (0,0) rectangle (\@[email protected],\@[email protected]);338 \fi339 \draw (\@[email protected],\@[email protected]) circle (\@[email protected]);340 \draw (\@[email protected],\@[email protected]) circle (\@[email protected]);341 \draw (\@[email protected],\@[email protected]) circle (\@[email protected]);

Draw labels

342 \draw (\@[email protected],\@[email protected]) node[above,left] (labelOnlyA) {\@[email protected]@OnlyA};343 \draw (\@[email protected],\@[email protected]) node[above,right] (labelOnlyB) {\@[email protected]@OnlyB};344 \draw (\@[email protected],\@[email protected]) node[below] (labelOnlyC) {\@[email protected]@OnlyC};

Region labels

345 \draw (\@[email protected],\@[email protected]) node (labelNotABC) {\@[email protected]@NotABC};346 \draw (\@[email protected],\@[email protected]+\@[email protected])347 node[below] (labelA) {\@[email protected]@A};348 \draw (\@[email protected],\@[email protected]+\@[email protected])349 node[below] (labelB) {\@[email protected]@B};350 \draw (\@[email protected],\@[email protected]) node[above] (labelC) {\@[email protected]@C};351 \draw (\@[email protected],0.5*\@[email protected]) node (labelABC) {\@[email protected]@ABC};352 \draw (\@[email protected],\@[email protected]) node[above] (labelOnlyAB) {\@[email protected]@OnlyAB};353 \draw (\@[email protected],\@[email protected]) ++(-60:\@[email protected]*\@[email protected])354 node[below left] (labelOnlyAC) {\@[email protected]@OnlyAC};355 \draw (\@[email protected],\@[email protected]) ++(-120:\@[email protected]*\@[email protected])356 node[below right] (labelOnlyBC) {\@[email protected]@OnlyBC};357 \@postvennhook358 \end{tikzpicture}359 }

\@postvennhook Hook called just before the end of the tikzpicture environment.360 \newcommand*{\@postvennhook}{}

\setpostvennhook User interface to set the post hook.361 \newcommand*{\setpostvennhook}[1]{\def\@postvennhook{#1}}

\@[email protected]@threesets \fillOnlyA is set to this for the three set version. Reimplemented in v1.1 to use new circleintersect code.

362 \newcommand*\@[email protected]@threesets{%

Get the intersection points between A and B .

363 \@[email protected]omputecircleintersects{\@[email protected]}{\@[email protected]}{\@[email protected]}{\@[email protected]}%

If there arent two points of intersection, then the circles dont overlap.

364 \ifnum\@[email protected]@n=2\relax

We need the point thats furthest from C .

365 \pgfmathsetlength{\[email protected]}{\@[email protected]\@[email protected]@[email protected]}%366 \pgfmathsetlength{\[email protected]}{\@[email protected]\@[email protected]@[email protected]}%367 \pgfmathsetlength{\[email protected]}{\[email protected]*\[email protected]+\[email protected]*\[email protected]}%368 \pgfmathsetlength{\[email protected]}{\@[email protected]\@[email protected]@[email protected]}%

24

369 \pgfmathsetlength{\[email protected]}{\@[email protected]\@[email protected]@[email protected]}%370 \pgfmathsetlength{\[email protected]}{\[email protected]*\[email protected]+\[email protected]*\[email protected]}%371 \ifdim\[email protected]>\[email protected] \pgfmathsetlength{\[email protected]}{\@[email protected]@[email protected]\@[email protected]}%373 \pgfmathsetlength{\[email protected]}{\@[email protected]@[email protected]\@[email protected]}%374 \edef\@[email protected]@[email protected]{\the\@[email protected]@[email protected]}%375 \edef\@[email protected]@[email protected]{\the\@[email protected]@[email protected]}%376 \else377 \pgfmathsetlength{\[email protected]}{\@[email protected]@[email protected]\@[email protected]}%378 \pgfmathsetlength{\[email protected]}{\@[email protected]@[email protected]\@[email protected]}%379 \edef\@[email protected]@[email protected]{\the\@[email protected]@[email protected]}%380 \edef\@[email protected]@[email protected]{\the\@[email protected]@[email protected]}%381 \fi

Compute the initial angle of the first arc.

382 \ifvennoldpgf383 \pgfmathatantwo{\[email protected]}{\[email protected]}%384 \else385 \pgfmathatantwo{\[email protected]}{\[email protected]}%386 \fi387 \let\@[email protected]@[email protected]\pgfmathresult

Compute the intersection between A and C .

388 \@[email protected]{\@[email protected]}{\@[email protected]}{\@[email protected]}{\@[email protected]}%

Need the point furthest from B .

389 \pgfmathsetlength{\[email protected]}{\@[email protected]\@[email protected]@[email protected]}%390 \pgfmathsetlength{\[email protected]}{\@[email protected]\@[email protected]@[email protected]}%391 \pgfmathsetlength{\[email protected]}{\[email protected]*\[email protected]+\[email protected]*\[email protected]}%392 \pgfmathsetlength{\[email protected]}{\@[email protected]\@[email protected]@[email protected]}%393 \pgfmathsetlength{\[email protected]}{\@[email protected]\@[email protected]@[email protected]}%394 \pgfmathsetlength{\[email protected]}{\[email protected]*\[email protected]+\[email protected]*\[email protected]}%395 \ifdim\[email protected]>\[email protected] \pgfmathsetlength{\[email protected]}{\@[email protected]@[email protected]\@[email protected]}%397 \pgfmathsetlength{\[email protected]}{\@[email protected]@[email protected]\@[email protected]}%398 \edef\@[email protected]@[email protected]@x{\the\@[email protected]@[email protected]}%399 \edef\@[email protected]@[email protected]@y{\the\@[email protected]@[email protected]}%400 \else401 \pgfmathsetlength{\[email protected]}{\@[email protected]@[email protected]\@[email protected]}%402 \pgfmathsetlength{\[email protected]}{\@[email protected]@[email protected]\@[email protected]}%403 \edef\@[email protected]@[email protected]@x{\the\@[email protected]@[email protected]}%404 \edef\@[email protected]@[email protected]@y{\the\@[email protected]@[email protected]}%405 \fi

Compute the end angle of the first arc.

406 \ifvennoldpgf407 \pgfmathatantwo{\[email protected]}{\[email protected]}%408 \else409 \pgfmathatantwo{\[email protected]}{\[email protected]}%410 \fi411 \let\@[email protected]@[email protected]\pgfmathresult

25

412 \pgfmathadd{\@[email protected]@[email protected]}{360}%413 \let\@[email protected]@[email protected]\pgfmathresult

Compute the start angle of the second arc.

414 \pgfmathsetlength{\[email protected]}{\@[email protected]@[email protected]@x-\@[email protected]}%415 \pgfmathsetlength{\[email protected]}{\@[email protected]@[email protected]@y-\@[email protected]}%416 \ifvennoldpgf417 \pgfmathatantwo{\[email protected]}{\[email protected]}%418 \else419 \pgfmathatantwo{\[email protected]}{\[email protected]}%420 \fi421 \let\@[email protected]@[email protected]\pgfmathresult

Compute the intersection between B and C .

422 \@[email protected]{\@[email protected]}{\@[email protected]}{\@[email protected]}{\@[email protected]}%

Need the point closest to A.

423 \pgfmathsetlength{\[email protected]}{\@[email protected]\@[email protected]@[email protected]}%424 \pgfmathsetlength{\[email protected]}{\@[email protected]\@[email protected]@[email protected]}%425 \pgfmathsetlength{\[email protected]}{\[email protected]*\[email protected]+\[email protected]*\[email protected]}%426 \pgfmathsetlength{\[email protected]}{\@[email protected]\@[email protected]@[email protected]}%427 \pgfmathsetlength{\[email protected]}{\@[email protected]\@[email protected]@[email protected]}%428 \pgfmathsetlength{\[email protected]}{\[email protected]*\[email protected]+\[email protected]*\[email protected]}%429 \ifdim\[email protected]

Compute the end angle of the third arc.

454 \pgfmathsetlength{\[email protected]}{\@[email protected]@[email protected]\@[email protected]}%455 \pgfmathsetlength{\[email protected]}{\@[email protected]@[email protected]\@[email protected]}%456 \ifvennoldpgf457 \pgfmathatantwo{\[email protected]}{\[email protected]}%458 \else459 \pgfmathatantwo{\[email protected]}{\[email protected]}%460 \fi461 \let\@[email protected]@[email protected]\pgfmathresult462 \pgfmathsubtract{\@[email protected][email protected]@angle}{360}%463 \let\@[email protected]@[email protected]\pgfmathresult

Fill path

464 \path[fill=\@[email protected]] (\@[email protected]@[email protected],\@[email protected]@[email protected])465 arc[radius=\@[email protected],start angle=\@[email protected]@[email protected],466 end angle=\@[email protected]@[email protected]]467 arc[radius=\@[email protected],start angle=\@[email protected]@[email protected],468 end angle=\@[email protected]@[email protected]]469 arc[radius=\@[email protected],start angle=\@[email protected]@[email protected],470 end angle=\@[email protected]@[email protected]] -- cycle;471 \else472 \fillOnlyA473 \fi474 }%

\@[email protected]@threesets \fillOnlyB is set to this for the three set version. Reimplemented in v1.1 to use new circleintersect code.

475 \newcommand*\@[email protected]@threesets{%

Get the intersection points between B and A.

476 \@[email protected]{\@[email protected]}{\@[email protected]}{\@[email protected]}{\@[email protected]}%

If there arent two points of intersection, then the circles dont overlap.

477 \ifnum\@[email protected]@n=2\relax

We need the point thats furthest from C .

478 \pgfmathsetlength{\[email protected]}{\@[email protected]\@[email protected]@[email protected]}%479 \pgfmathsetlength{\[email protected]}{\@[email protected]\@[email protected]@[email protected]}%480 \pgfmathsetlength{\[email protected]}{\[email protected]*\[email protected]+\[email protected]*\[email protected]}%481 \pgfmathsetlength{\[email protected]}{\@[email protected]\@[email protected]@[email protected]}%482 \pgfmathsetlength{\[email protected]}{\@[email protected]\@[email protected]@[email protected]}%483 \pgfmathsetlength{\[email protected]}{\[email protected]*\[email protected]+\[email protected]*\[email protected]}%484 \ifdim\[email protected]>\[email protected] \pgfmathsetlength{\[email protected]}{\@[email protected]@[email protected]\@[email protected]}%486 \pgfmathsetlength{\[email protected]}{\@[email protected]@[email protected]\@[email protected]}%487 \edef\@[email protected]@[email protected]{\the\@[email protected]@[email protected]}%488 \edef\@[email protected]@[email protected]{\the\@[email protected]@[email protected]}%489 \else490 \pgfmathsetlength{\[email protected]}{\@[email protected]@[email protected]\@[email protected]}%491 \pgfmathsetlength{\[email protected]}{\@[email protected]@[email protected]\@[email protected]}%

27

492 \edef\@[email protected]@[email protected]{\the\@[email protected]@[email protected]}%493 \edef\@[email protected]@[email protected]{\the\@[email protected]@[email protected]}%494 \fi

Compute the initial angle of the first arc.

495 \ifvennoldpgf496 \pgfmathatantwo{\[email protected]}{\[email protected]}%497 \else498 \pgfmathatantwo{\[email protected]}{\[email protected]}%499 \fi500 \let\@[email protected]@[email protected]\pgfmathresult

Compute the intersection between B and C .

501 \@[email protected]{\@[email protected]}{\@[email protected]}{\@[email protected]}{\@[email protected]}%

Need the point furthest from A.

502 \pgfmathsetlength{\[email protected]}{\@[email protected]\@[email protected]@[email protected]}%503 \pgfmathsetlength{\[email protected]}{\@[email protected]\@[email protected]@[email protected]}%504 \pgfmathsetlength{\[email protected]}{\[email protected]*\[email protected]+\[email protected]*\[email protected]}%505 \pgfmathsetlength{\[email protected]}{\@[email protected]\@[email protected]@[email protected]}%506 \pgfmathsetlength{\[email protected]}{\@[email protected]\@[email protected]@[email protected]}%507 \pgfmathsetlength{\[email protected]}{\[email protected]*\[email protected]+\[email protected]*\[email protected]}%508 \ifdim\[email protected]>\[email protected] \pgfmathsetlength{\[email protected]}{\@[email protected]@[email protected]\@[email protected]}%510 \pgfmathsetlength{\[email protected]}{\@[email protected]@[email protected]\@[email protected]}%511 \edef\@[email protected]@[email protected]@x{\the\@[email protected]@[email protected]}%512 \edef\@[email protected]@[email protected]@y{\the\@[email protected]@[email protected]}%513 \else514 \pgfmathsetlength{\[email protected]}{\@[email protected]@[email protected]\@[email protected]}%515 \pgfmathsetlength{\[email protected]}{\@[email protected]@[email protected]\@[email protected]}%516 \edef\@[email protected]@[email protected]@x{\the\@[email protected]@[email protected]}%517 \edef\@[email protected]@[email protected]@y{\the\@[email protected]@[email protected]}%518 \fi

Compute the end angle of the first arc.

519 \ifvennoldpgf520 \pgfmathatantwo{\[email protected]}{\[email protected]}%521 \else522 \pgfmathatantwo{\[email protected]}{\[email protected]}%523 \fi524 \let\@[email protected]@[email protected]\pgfmathresult

Compute the start angle of the second arc.

525 \pgfmathsetlength{\[email protected]}{\@[email protected]@[email protected]@x-\@[email protected]}%526 \pgfmathsetlength{\[email protected]}{\@[email protected]@[email protected]@y-\@[email protected]}%527 \ifvennoldpgf528 \pgfmathatantwo{\[email protected]}{\[email protected]}%529 \else530 \pgfmathatantwo{\[email protected]}{\[email protected]}%531 \fi532 \let\@[email protected]@[email protected]\pgfmathresult

28

Compute the intersection between A and C .

533 \@[email protected]{\@[email protected]}{\@[email protected]}{\@[email protected]}{\@[email protected]}%

Need the point closest to A.

534 \pgfmathsetlength{\[email protected]}{\@[email protected]\@[email protected]@[email protected]}%535 \pgfmathsetlength{\[email protected]}{\@[email protected]\@[email protected][email protected]@y}%536 \pgfmathsetlength{\[email protected]}{\[email protected]*\[email protected]+\[email protected]*\[email protected]}%537 \pgfmathsetlength{\[email protected]}{\@[email protected]\@[email protected]@[email protected]}%538 \pgfmathsetlength{\[email protected]}{\@[email protected]\@[email protected]@[email protected]}%539 \pgfmathsetlength{\[email protected]}{\[email protected]*\[email protected]+\[email protected]*\[email protected]}%540 \ifdim\[email protected]

573 \path[fill=\@[email protected]]574 (\@[email protected]@[email protected],\@[email protected]@[email protected])575 arc[radius=\@[email protected],start angle=\@[email protected]@[email protected],576 end angle=\@[email protected]@[email protected]]577 arc[radius=\@[email protected],start angle=\@[email protected]@[email protected],578 end angle=\@[email protected]@[email protected]]579 arc[radius=\@[email protected],start angle=\@[email protected]@[email protected],580 end angle=\@[email protected]@[email protected]] -- cycle;581 \else582 \fillOnlyB583 \fi584 }%

\@[email protected]@threesets \fillOnlyC is set to this for the three set version. Reimplemented in v1.1 to use new circleintersect code.

585 \newcommand*\@[email protected]@threesets{%

Get the intersection points between C and B .586 \@[email protected]{\@[email protected]}{\@[email protected]}{\@[email protected]}{\@[email protected]}%

If there arent two points of intersection, then the circles dont overlap.587 \ifnum\@[email protected]@n=2\relax

We need the point thats furthest from A.588 \pgfmathsetlength{\[email protected]}{\@[email protected]\@[email protected]@[email protected]}%589 \pgfmathsetlength{\[email protected]}{\@[email protected]\@[email protected]@[email protected]}%590 \pgfmathsetlength{\[email protected]}{\[email protected]*\[email protected]+\[email protected]*\[email protected]}%591 \pgfmathsetlength{\[email protected]}{\@[email protected]\@[email protected]@[email protected]}%592 \pgfmathsetlength{\[email protected]}{\@[email protected]\@[email protected]@[email protected]}%593 \pgfmathsetlength{\[email protected]}{\[email protected]*\[email protected]+\[email protected]*\[email protected]}%594 \ifdim\[email protected]>\[email protected] \pgfmathsetlength{\[email protected]}{\@[email protected]@[email protected]\@[email protected]}%596 \pgfmathsetlength{\[email protected]}{\@[email protected]@[email protected]\@[email protected]}%597 \edef\@[email protected]@[email protected]{\the\@[email protected]@[email protected]}%598 \edef\@[email protected]@[email protected]{\the\@[email protected]@[email protected]}%599 \else600 \pgfmathsetlength{\[email protected]}{\@[email protected]@[email protected]\@[email protected]}%601 \pgfmathsetlength{\[email protected]}{\@[email protected]@[email protected]\@[email protected]}%602 \edef\@[email protected]@[email protected]{\the\@[email protected]@[email protected]}%603 \edef\@[email protected]@[email protected]{\the\@[email protected]@[email protected]}%604 \fi

Compute the initial angle of the first arc.605 \ifvennoldpgf606 \pgfmathatantwo{\[email protected]}{\[email protected]}%607 \else608 \pgfmathatantwo{\[email protected]}{\[email protected]}%609 \fi610 \let\@[email protected]@[email protected]\pgfmathresult

Compute the intersection between C and A.611 \@[email protected]{\@[email protected]}{\@[email protected]}{\@[email protected]}{\@[email protected]}%

30

Need the point furthest from B .

612 \pgfmathsetlength{\[email protected]}{\@[email protected]\@[email protected]@[email protected]}%613 \pgfmathsetlength{\[email protected]}{\@[email protected]\@[email protected]@[email protected]}%614 \pgfmathsetlength{\[email protected]}{\[email protected]*\[email protected]+\[email protected]*\[email protected]}%615 \pgfmathsetlength{\[email protected]}{\@[email protected]\@[email protected]@[email protected]}%616 \pgfmathsetlength{\[email protected]}{\@[email protected]\@[email protected]@[email protected]}%617 \pgfmathsetlength{\[email protected]}{\[email protected]*\[email protected]+\[email protected]*\[email protected]}%618 \ifdim\[email protected]>\[email protected] \pgfmathsetlength{\[email protected]}{\@[email protected]@[email protected]\@[email protected]}%620 \pgfmathsetlength{\[email protected]}{\@[email protected]@[email protected]\@[email protected]}%621 \edef\@[email protected]@[email protected]@x{\the\@[email protected]@[email protected]}%622 \edef\@[email protected]@[email protected]@y{\the\@[email protected]@[email protected]}%623 \else624 \pgfmathsetlength{\[email protected]}{\@[email protected]@[email protected]\@[email protected]}%625 \pgfmathsetlength{\[email protected]}{\@[email protected]@[email protected]\@[email protected]}%626 \edef\@[email protected]@[email protected]@x{\the\@[email protected]@[email protected]}%627 \edef\@[email protected]@[email protected]@y{\the\@[email protected]@[email protected]}%628 \fi

Compute the end angle of the first arc.

629 \ifvennoldpgf630 \pgfmathatantwo{\[email protected]}{\[email protected]}%631 \else632 \pgfmathatantwo{\[email protected]}{\[email protected]}%633 \fi634 \let\@[email protected]@[email protected]\pgfmathresult635 \pgfmathsubtract{\@[email protected]@[email protected]}{360}%636 \let\@[email protected]@[email protected]\pgfmathresult

Compute the start angle of the second arc.

637 \pgfmathsetlength{\[email protected]}{\@[email protected]@[email protected]@x-\@[email protected]}%638 \pgfmathsetlength{\[email protected]}{\@[email protected]@[email protected]@y-\@[email protected]}%639 \ifvennoldpgf640 \pgfmathatantwo{\[email protected]}{\[email protected]}%641 \else642 \pgfmathatantwo{\[email protected]}{\[email protected]}%643 \fi644 \let\@[email protected]@[email protected]\pgfmathresult

Compute the intersection between B and A.

645 \@[email protected]{\@[email protected]}{\@[email protected]}{\@[email protected]}{\@[email protected]}%

Need the point closest to C .

646 \pgfmathsetlength{\[email protected]}{\@[email protected]\@[email protected]@[email protected]}%647 \pgfmathsetlength{\[email protected]}{\@[email protected]\@[email protected]@[email protected]}%648 \pgfmathsetlength{\[email protected]}{\[email protected]*\[email protected]+\[email protected]*\[email protected]}%649 \pgfmathsetlength{\[email protected]}{\@[email protected]\@[email protected]@[email protected]}%650 \pgfmathsetlength{\[email protected]}{\@[email protected]\@[email protected]@[email protected]}%651 \pgfmathsetlength{\[email protected]}{\[email protected]*\[email protected]+\[email protected]*\[email protected]}%652 \ifdim\[email protected]

654 \pgfmathsetlength{\[email protected]}{\@[email protected]@[email protected]\@[email protected]}%655 \edef\@[email protected]@[email protected]@x{\the\@[email protected]@[email protected]}%656 \edef\@[email protected]@[email protected]@y{\the\@[email protected]@[email protected]}%657 \else658 \pgfmathsetlength{\[email protected]}{\@[email protected]@[email protected]\@[email protected]}%659 \pgfmathsetlength{\[email protected]}{\@[email protected]@[email protected]\@[email protected]}%660 \edef\@[email protected]@[email protected]@x{\the\@[email protected]@[email protected]}%661 \edef\@[email protected]@[email protected]@y{\the\@[email protected]@[email protected]}%662 \fi

Compute the end angle of the second arc.

663 \ifvennoldpgf664 \pgfmathatantwo{\[email protected]}{\[email protected]}%665 \else666 \pgfmathatantwo{\[email protected]}{\[email protected]}%667 \fi668 \let\@[email protected]@[email protected]\pgfmathresult

Compute the start angle of the third arc.

669 \pgfmathsetlength{\[email protected]}{\@[email protected]@[email protected]@x-\@[email protected]}%670 \pgfmathsetlength{\[email protected]}{\@[email protected]@[email protected]@y-\@[email protected]}%671 \ifvennoldpgf672 \pgfmathatantwo{\[email protected]}{\[email protected]}%673 \else674 \pgfmathatantwo{\[email protected]}{\[email protected]}%675 \fi676 \let\@[email protected]@[email protected]\pgfmathresult

Compute the end angle of the third arc.

677 \pgfmathsetlength{\[email protected]}{\@[email protected]@[email protected]\@[email protected]}%678 \pgfmathsetlength{\[email protected]}{\@[email protected]@[email protected]\@[email protected]}%679 \ifvennoldpgf680 \pgfmathatantwo{\[email protected]}{\[email protected]}%681 \else682 \pgfmathatantwo{\[email protected]}{\[email protected]}%683 \fi684 \let\@[email protected]@[email protected]\pgfmathresult

Fill path

685 \path[fill=\@[email protected]] (\@[email protected]@[email protected],\@[email protected]@[email protected])686 arc[radius=\@[email protected],start angle=\@[email protected]@[email protected],687 end angle=\@[email protected]@[email protected]]688 arc[radius=\@[email protected],start angle=\@[email protected]@[email protected],689 end angle=\@[email protected]@[email protected]]690 arc[radius=\@[email protected],start angle=\@[email protected]@[email protected],691 end angle=\@[email protected]@[email protected]] -- cycle;692 \else693 \fillOnlyC694 \fi695 }%

32

\@[email protected]@threesets \fillNotABC is set to this for the three set version. Reimplemented in v1.1 to use new circleintersect code.

696 \newcommand*\@[email protected]@threesets{%

Get the intersection points between A and B .

697 \@[email protected]{\@[email protected]}{\@[email protected]}{\@[email protected]}{\@[email protected]}%

If there arent two points of intersection, then the circles dont overlap.

698 \ifnum\@[email protected]@n=2\relax

We need the point thats furthest from C .

699 \pgfmathsetlength{\[email protected]}{\@[email protected]\@[email protected]@[email protected]}%700 \pgfmathsetlength{\[email protected]}{\@[email protected]\@[email protected]@[email protected]}%701 \pgfmathsetlength{\[email protected]}{\[email protected]*\[email protected]+\[email protected]*\[email protected]}%702 \pgfmathsetlength{\[email protected]}{\@[email protected]\@[email protected]@[email protected]}%703 \pgfmathsetlength{\[email protected]}{\@[email protected]\@[email protected]@[email protected]}%704 \pgfmathsetlength{\[email protected]}{\[email protected]*\[email protected]+\[email protected]*\[email protected]}%705 \ifdim\[email protected]>\[email protected] \pgfmathsetlength{\[email protected]}{\@[email protected]@[email protected]\@[email protected]}%707 \pgfmathsetlength{\[email protected]}{\@[email protected]@[email protected]\@[email protected]}%708 \edef\@[email protected]@[email protected]{\the\@[email protected]@[email protected]}%709 \edef\@[email protected]@[email protected]{\the\@[email protected]@[email protected]}%710 \else711 \pgfmathsetlength{\[email protected]}{\@[email protected]@[email protected]\@[email protected]}%712 \pgfmathsetlength{\[email protected]}{\@[email protected]@[email protected]\@[email protected]}%713 \edef\@[email protected]@[email protected]{\the\@[email protected]@[email protected]}%714 \edef\@[email protected]@[email protected]{\the\@[email protected]@[email protected]}%715 \fi

Compute the initial angle of the first arc.

716 \ifvennoldpgf717 \pgfmathatantwo{\[email protected]}{\[email protected]}%718 \else719 \pgfmathatantwo{\[email protected]}{\[email protected]}%720 \fi721 \let\@[email protected]@[email protected]\pgfmathresult

Compute the intersection between A and C .

722 \@[email protected]{\@[email protected]}{\@[email protected]}{\@[email protected]}{\@[email protected]}%

We need the point thats furthest from B .

723 \pgfmathsetlength{\[email protected]}{\@[email protected]\@[email protected]@[email protected]}%724 \pgfmathsetlength{\[email protected]}{\@[email protected]\@[email protected]@[email protected]}%725 \pgfmathsetlength{\[email protected]}{\[email protected]*\[email protected]+\[email protected]*\[email protected]}%726 \pgfmathsetlength{\[email protected]}{\@[email protected]\@[email protected]@[email protected]}%727 \pgfmathsetlength{\[email protected]}{\@[email protected]\@[email protected]@[email protected]}%728 \pgfmathsetlength{\[email protected]}{\[email protected]*\[email protected]+\[email protected]*\[email protected]}%729 \ifdim\[email protected]>\[email protected] \pgfmathsetlength{\[email protected]}{\@[email protected]@[email protected]\@[email protected]}%731 \pgfmathsetlength{\[email protected]}{\@[email protected]@[email protected]\@[email protected]}%732 \edef\@[email protected]@[email protected]@x{\the\@[email protected]@[email protected]}%

33

733 \edef\@[email protected]@[email protected]@y{\the\@[email protected]@[email protected]}%734 \else735 \pgfmathsetlength{\[email protected]}{\@[email protected]@[email protected]\@[email protected]}%736 \pgfmathsetlength{\[email protected]}{\@[email protected]@[email protected]\@[email protected]}%737 \edef\@[email protected]@[email protected]@x{\the\@[email protected]@[email protected]}%738 \edef\@[email protected]@[email protected]@y{\the\@[email protected]@[email protected]}%739 \fi

Compute the end angle of the first arc.

740 \ifvennoldpgf741 \pgfmathatantwo{\[email protected]}{\[email protected]}%742 \else743 \pgfmathatantwo{\[email protected]}{\[email protected]}%744 \fi745 \let\@[email protected]@[email protected]\pgfmathresult746 \pgfmathadd{\@[email protected]@[email protected]}{360}%747 \let\@[email protected]@[email protected]\pgfmathresult

Compute the start angle of the second arc.

748 \pgfmathsetlength{\[email protected]}{\@[email protected]@[email protected]@x-\@[email protected]}%749 \pgfmathsetlength{\[email protected]}{\@[email protected]@[email protected]@y-\@[email protected]}%750 \ifvennoldpgf751 \pgfmathatantwo{\[email protected]}{\[email protected]}%752 \else753 \pgfmathatantwo{\[email protected]}{\[email protected]}%754 \fi755 \let\@[email protected]@[email protected]\pgfmathresult

Compute the intersection between C and B .

756 \@[email protected]{\@[email protected]}{\@[email protected]}{\@[email protected]}{\@[email protected]}%

We need the point thats furthest from A.

757 \pgfmathsetlength{\[email protected]}{\@[email protected]\@[email protected]@[email protected]}%758 \pgfmathsetlength{\[email protected]}{\@[email protected]\@[email protected]@[email protected]}%759 \pgfmathsetlength{\[email protected]}{\[email protected]*\[email protected]+\[email protected]*\[email protected]}%760 \pgfmathsetlength{\[email protected]}{\@[email protected]\@[email protected]@[email protected]}%761 \pgfmathsetlength{\[email protected]}{\@[email protected]\@[email protected]@[email protected]}%762 \pgfmathsetlength{\[email protected]}{\[email protected]*\[email protected]+\[email protected]*\[email protected]}%763 \ifdim\[email protected]>\[email protected] \pgfmathsetlength{\[email protected]}{\@[email protected]@[email protected]\@[email protected]}%765 \pgfmathsetlength{\[email protected]}{\@[email protected]@[email protected]\@[email protected]}%766 \edef\@[email protected]@[email protected]@x{\the\@[email protected]@[email protected]}%767 \edef\@[email protected]@[email protected]@y{\the\@[email protected]@[email protected]}%768 \else769 \pgfmathsetlength{\[email protected]}{\@[email protected]@[email protected]\@[email protected]}%770 \pgfmathsetlength{\[email protected]}{\@[email protected]@[email protected]\@[email protected]}%771 \edef\@[email protected]@[email protected]@x{\the\@[email protected]@[email protected]}%772 \edef\@[email protected]@[email protected]@y{\the\@[email protected]@[email protected]}%773 \fi

Compute the end angle of the second arc.

34

774 \ifvennoldpgf775 \pgfmathatantwo{\[email protected]}{\[email protected]}%776 \else777 \pgfmathatantwo{\[email protected]}{\[email protected]}%778 \fi779 \let\@[email protected]@[email protected]\pgfmathresult780 \pgfmathadd{\@[email protected]@[email protected]}{360}%781 \let\@[email protected]@[email protected]\pgfmathresult

Compute the start angle of the third arc.

782 \pgfmathsetlength{\[email protected]}{\@[email protected]@[email protected]@x-\@[email protected]}%783 \pgfmathsetlength{\[email protected]}{\@[email protected]@[email protected]@y-\@[email protected]}%784 \ifvennoldpgf785 \pgfmathatantwo{\[email protected]}{\[email protected]}%786 \else787 \pgfmathatantwo{\[email protected]}{\[email protected]}%788 \fi789 \let\@[email protected]@[email protected]\pgfmathresult

Compute the end angle of the third arc.

790 \pgfmathsetlength{\[email protected]}{\@[email protected]@[email protected]\@[email protected]}%791 \pgfmathsetlength{\[email protected]}{\@[email protected]@[email protected]\@[email protected]}%792 \ifvennoldpgf793 \pgfmathatantwo{\[email protected]}{\[email protected]}%794 \else795 \pgfmathatantwo{\[email protected]}{\[email protected]}%796 \fi797 \let\@[email protected]@[email protected]\pgfmathresult

Fill path

798 \path[fill=\@[email protected],even odd rule]799 (0,0) rectangle (\@[email protected],\@[email protected])800 (\@[email protected]@[email protected],\@[email protected]@[email protected])801 arc[radius=\@[email protected],start angle=\@[email protected]@[email protected],802 end angle=\@[email protected]@[email protected]]803 arc[radius=\@[email protected],start angle=\@[email protected]@[email protected],804 end angle=\@[email protected]@[email protected]]805 arc[radius=\@[email protected],start angle=\@[email protected]@[email protected],806 end angle=\@[email protected]@[email protected]]807 -- cycle;808 \else809 \path[fill=\@[email protected],even odd rule]810 (0,0) rectangle (\@[email protected],\@[email protected])811 (\@[email protected],\@[email protected]) circle (\@[email protected])812 (\@[email protected],\@[email protected]) circle (\@[email protected])813 (\@[email protected],\@[email protected]) circle (\@[email protected]);%814 \fi815 }%

venndiagram2sets

35

816 \newenvironment{venndiagram2sets}[1][]%817 {%

Disable the keys that arent applicable.

818 \[email protected]{venn}{labelABC,labelOnlyC,labelOnlyAC,labelOnlyBC,%819 labelNotABC,labelC,labelOnlyAB}%

Set the key values given in the optional argument.

820 \setkeys{venn}{#1}%

Calculate centre of A

821 \pgfmathsetlength{\@[email protected]}{\@[email protected]+\@[email protected]}%822 \pgfmathsetlength{\@[email protected]}{\@[email protected]+\@[email protected]}%

Calculate centre of B

823 \pgfmathsetlength{\@[email protected]}{\@[email protected]+3*\@[email protected] -\@[email protected]}%825 \setlength{\@[email protected]}{\@[email protected]}%

Compute dimensions of entire diagram

826 \pgfmathsetlength{\@[email protected]}{2*\@[email protected]+4*\@[email protected] -\@[email protected]}%828 \pgfmathsetlength{\@[email protected]}{2*\@[email protected]+2*\@[email protected]}%

Define filling commands

829 \def\fillA{\path[fill=\@[email protected]] (\@[email protected],\@[email protected])830 circle (\@[email protected]);}%831 \def\fillB{\path[fill=\@[email protected]] (\@[email protected],\@[email protected])832 circle (\@[email protected]);}%833 \def\fillAll{\path[fill=\@[email protected]] (0,0)834 rectangle (\@[email protected],\@[email protected]);}%

Fill only set A

835 \let\fillOnlyA\@[email protected]@twosets

Fill only set B

836 \let\fillOnlyB\@[email protected]@twosets

Fill everything except A

837 \def\fillNotA{\path[fill=\@[email protected],even odd rule]838 (0,0) rectangle (\@[email protected],\@[email protected])839 (\@[email protected],\@[email protected]) circle (\@[email protected]);}%

Fill everything except B

840 \def\fillNotB{\path[fill=\@[email protected],even odd rule]841 (0,0) rectangle (\@[email protected],\@[email protected])842 (\@[email protected],\@[email protected]) circle (\@[email protected]);}%

Fill everything except A or B ((AB)c )843 \def\fillNotAorB{%844 \begin{scope}845 \path[clip]846 (0,0) rectangle (\@[email protected],\@[email protected])847 (\@[email protected],\@[email protected]) circle (\@[email protected])

36

848 ;849 \path[fill=\@[email protected],even odd rule]850 (0,0) rectangle (\@[email protected],\@[email protected])851 (\@[email protected],\@[email protected]) circle (\@[email protected])852 ;853 \end{scope}854 }%

Fill not A or not B ((AB)c )855 \def\fillNotAorNotB{%856 \path[fill=\@[email protected],nonzero rule]857 (0,0) rectangle (\@[email protected],\@[email protected])858 (\@[email protected],\@[email protected]) circle (\@[email protected])859 (0,0) rectangle (\@[email protected],\@[email protected])860 (\@[email protected],\@[email protected]) circle (\@[email protected])861 ;862 }%

Fill A but not B (same as only A for two sets).

863 \let\fillANotB\fillOnlyA

Fill B but not A (same as only B for two sets).

864 \let\fillBNotA\fillOnlyB

Fill A intersect B

865 \def\fillACapB{%866 \begin{scope}867 \clip (\@[email protected],\@[email protected]) circle (\@[email protected]);868 \path[fill=\@[email protected]]869 (\@[email protected],\@[email protected]) circle (\@[email protected]);870 \end{scope}871 }%

Define synonym:

872 \let\fillBCapA\fillACapB

Start the tikzpicture environment.873 \ifdefempty{\@[email protected]}%874 {%875 \def\@[email protected]{\begin{tikzpicture}}%876 }%877 {%878 \edef\@[email protected]{\noexpand\begin{tikzpicture}%879 [\expandonce\@[email protected]]}%880 }%881 \@[email protected]

coordinates of the Venn diagram corners

882 \path (0,0) coordinate (venn bottom left)883 (0,\@[email protected]) coordinate (venn top left)884 (\@[email protected],\@[email protected]) coordinate (venn top right)885 (\@[email protected],0) coordinate (venn bottom right);886 }%

37

End environment code

887 {%

Draw outlines

888 \ifvennshowframe889 \draw (venn bottom left) rectangle (\@[email protected],\@[email protected]);890 \else891 \path (venn bottom left) rectangle (\@[email protected],\@[email protected]);892 \fi893 \draw (\@[email protected],\@[email protected]) circle (\@[email protected]);894 \draw (\@[email protected],\@[email protected]) circle (\@[email protected]);

Draw labels

895 \draw (\@[email protected],\@[email protected]) node[above,left] (labelOnlyA)896 {\@[email protected]@OnlyA};897 \draw (\@[email protected],\@[email protected]) node[above,right] (labelOnlyB)898 {\@[email protected]@OnlyB};

Region labels

899 \draw (\@[email protected],\@[email protected]) node (labelNotAB) {\@[email protected]@NotAB};900 \draw (\@[email protected],\@[email protected]+\@[email protected])901 node[below] (labelA) {\@[email protected]@A};902 \draw (\@[email protected],\@[email protected]+\@[email protected])903 node[below] (labelB) {\@[email protected]@B};904 \draw (0.5*\@[email protected],0.5*\@[email protected]) node (labelAB) {\@[email protected]@AB};905 \@postvennhook906 \end{tikzpicture}907 }

\@[email protected]@twosets \fillOnlyA is set to this for the two set version. Reimplemented in v1.1 to use new circleintersect code.

908 \newcommand*\@[email protected]@twosets{%

Get the intersection points between A and B .

909 \@[email protected]{\@[email protected]}{\@[email protected]}{\@[email protected]}{\@[email protected]}%

If there arent two points of intersection, then the circles dont overlap.

910 \ifnum\@[email protected]@n=2\relax

Compute the start angle for the first arc.

911 \pgfmathsetlength{\[email protected]}{\@[email protected]@[email protected]\@[email protected]}%912 \pgfmathsetlength{\[email protected]}{\@[email protected]@[email protected]\@[email protected]}%913 \ifvennoldpgf914 \pgfmathatantwo{\[email protected]}{\[email protected]}%915 \else916 \pgfmathatantwo{\[email protected]}{\[email protected]}%917 \fi918 \let\@[email protected]@[email protected]\pgfmathresult

Compute the end angle for the first arc.

919 \pgfmathsetlength{\[email protected]}{\@[email protected]@[email protected]\@[email protected]}%920 \pgfmathsetlength{\[email protected]}{\@[email protected]@[email protected]\@[email protected]}%

38

921 \ifvennoldpgf922 \pgfmathatantwo{\[email protected]}{\[email protected]}%923 \else924 \pgfmathatantwo{\[email protected]}{\[email protected]}%925 \fi926 \let\@[email protected]@[email protected]\pgfmathresult927 \pgfmathadd{\@[email protected]@[email protected]}{360}%928 \let\@[email protected]@[email protected]\pgfmathresult

Compute the start angle for the second arc.

929 \pgfmathsetlength{\[email protected]}{\@[email protected]@[email protected]\@[email protected]}%930 \pgfmathsetlength{\[email protected]}{\@[email protected]@[email protected]\@[email protected]}%931 \ifvennoldpgf932 \pgfmathatantwo{\[email protected]}{\[email protected]}%933 \else934 \pgfmathatantwo{\[email protected]}{\[email protected]}%935 \fi936 \let\@[email protected]@[email protected]\pgfmathresult

Compute the end angle for the second arc.

937 \pgfmathsetlength{\[email protected]}{\@[email protected]@[email protected]\@[email protected]}%938 \pgfmathsetlength{\[email protected]}{\@[email protected]@[email protected]\@[email protected]}%939 \ifvennoldpgf940 \pgfmathatantwo{\[email protected]}{\[email protected]}%941 \else942 \pgfmathatantwo{\[email protected]}{\[email protected]}%943 \fi944 \let\@[email protected]@[email protected]\pgfmathresult945 \pgfmathadd{\@[email protected]@[email protected]}{360}%946 \let\@[email protected]@[email protected]\pgfmathresult

Fill the path

947 \path[fill=\@[email protected]]948 (\@[email protected]@[email protected],\@[email protected]@[email protected])949 arc[radius=\@[email protected],start angle=\@[email protected]@[email protected],950 end angle=\@[email protected]@[email protected]]951 arc[radius=\@[email protected],start angle=\@[email protected]@[email protected],952 end angle=\@[email protected]@[email protected]]953 -- cycle;954 \else955 \fillOnlyA956 \fi957 }%

\@[email protected]@twosets \fillOnlyB is set to this for the two set version. Reimplemented in v1.1 to use new circleintersect code.

958 \newcommand*\@[email protected]@twosets{%

Get the intersection points between A and B .

959 \@[email protected]{\@[email protected]}{\@[email protected]}{\@[email protected]}{\@[email protected]}%

39

If there arent two points of intersection, then the circles dont overlap.

960 \ifnum\@[email protected]@n=2\relax

Compute the start angle for the first arc.

961 \pgfmathsetlength{\[email protected]}{\@[email protected]@[email protected]\@[email protected]}%962 \pgfmathsetlength{\[email protected]}{\@[email protected]@[email protected]\@[email protected]}%963 \ifvennoldpgf964 \pgfmathatantwo{\[email protected]}{\[email protected]}%965 \else966 \pgfmathatantwo{\[email protected]}{\[email protected]}%967 \fi968 \let\@[email protected]@[email protected]\pgfmathresult

Compute the end angle for the first arc.

969 \pgfmathsetlength{\[email protected]}{\@[email protected]@[email protected]\@[email protected]}%970 \pgfmathsetlength{\[email protected]}{\@[email protected]@[email protected]\@[email protected]}%971 \ifvennoldpgf972 \pgfmathatantwo{\[email protected]}{\[email protected]}%973 \else974 \pgfmathatantwo{\[email protected]}{\[email protected]}%975 \fi976 \let\@[email protected]@[email protected]\pgfmathresult977 % \pgfmathadd{\@[email protected]@[email protected]}{360}%978 % \let\@[email protected]@[email protected]\pgfmathresult

Compute the start angle for the second arc.

979 \pgfmathsetlength{\[email protected]}{\@[email protected]@[email protected]\@[email protected]}%980 \pgfmathsetlength{\dimen[email protected]}{\@[email protected]@[email protected]\@[email protected]}%981 \ifvennoldpgf982 \pgfmathatantwo{\[email protected]}{\[email protected]}%983 \else984 \pgfmathatantwo{\[email protected]}{\[email protected]}%985 \fi986 \let\@[email protected]@[email protected]\pgfmathresult

Compute the end angle for the second arc.

987 \pgfmathsetlength{\[email protected]}{\@[email protected]@[email protected]\@[email protected]}%988 \pgfmathsetlength{\[email protected]}{\@[email protected]@[email protected]\@[email protected]}%989 \ifvennoldpgf990 \pgfmathatantwo{\[email protected]}{\[email protected]}%991 \else992 \pgfmathatantwo{\[email protected]}{\[email protected]}%993 \fi994 \let\@[email protected]@[email protected]\pgfmathresult995 % \pgfmathadd{\@[email protected]@[email protected]}{360}%996 % \let\@[email protected]@[email protected]\pgfmathresult

Fill the path

997 \path[fill=\@[email protected]]998 (\@[email protected]@[email protected],\@[email protected]@[email protected])999 arc[radius=\@[email protected],start angle=\@[email protected]@[email protected],

40

1000 end angle=\@[email protected]@[email protected]]1001 arc[radius=\@[email protected],start angle=\@[email protected]@[email protected],1002 end angle=\@[email protected]@[email protected]]1003 -- cycle;1004 \else1005 \fillOnlyB1006 \fi1007 }%

Index

Numbers written in italic refer to the page where the corresponding entry is described; num-bers underlined refer to the code line of the definition; numbers in roman refer to the codelines where the entry is used.

Eenvironments:

venndiagram2sets . . . 1venndiagram3sets . . . 1

F\fillA . . . . . . . . . . . . . . . . 3\fillACapB . . . . . . . . . . . . 5\fillACapBCapC . . . . . . . . 6\fillACapBNotC . . . . . . . . 5\fillACapC . . . . . . . . . . . . 5\fillACapCNotB . . . . . . . . 5\fillAll . . . . . . . . . . . . . . 3\fillANotB . . . . . . . . . . . . 4\fillANotC . . . . . . . . . . . . 4\fillB . . . . . . . . . . . . . . . . 3

\fillBCapC . . . . . . . . . . . . 5\fillBCapCNotA . . . . . . . . 5\fillBNotA . . . . . . . . . . . . 4\fillBNotC . . . . . . . . . . . . 5\fillC . . . . . . . . . . . . . . . . 3\fillCNotA . . . . . . . . . . . . 4\fillCNotB . . . . . . . . . . . . 5\fillNotA . . . . . . . . . . . . . 4\fillNotABC . . . . . . . . . . . 3\fillNotAorB . . . . . . . . . . 4\fillNotAorNotB . . . . . . . 4\fillNotB . . . . . . . . . . . . . 4\fillNotC . . . . . . . . . . . . . 4\fillOnlyA . . . . . . . . . . . . 3\fillOnlyB . . . . . . . . . . . . 3

\fillOnlyC . . . . . . . . . . . . 4

Ppgf package . . . . . . . . . . . 9, 13

S\setpostvennhook . . . . . . 6

Ttikz package . . . . . . . . . . . . 1

Vvenndiagram2sets (envi-

ronment) . . . . . . . . . . 1venndiagram3sets (envi-

ronment) . . . . . . . . . . 1

41

Available Commands and EnvironmentsExamplesThe CodeInitialising the Default ValuesDefining the key=value OptionsCircle IntersectionEnvironment Definitions

Index