diff options
author | Karl Berry <karl@freefriends.org> | 2012-10-24 23:28:23 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2012-10-24 23:28:23 +0000 |
commit | 62e28014398695138e40690330baaff56a9b3b83 (patch) | |
tree | e94452a5d2f826b056e168f899bf668891ea44da /Master/texmf-dist/tex/latex/venndiagram | |
parent | 08704ece89438d6c40c2e673c25c38906294712a (diff) |
new latex package venndiagram (24oct12)
git-svn-id: svn://tug.org/texlive/trunk@28069 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/venndiagram')
-rw-r--r-- | Master/texmf-dist/tex/latex/venndiagram/venndiagram.sty | 584 |
1 files changed, 584 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/venndiagram/venndiagram.sty b/Master/texmf-dist/tex/latex/venndiagram/venndiagram.sty new file mode 100644 index 00000000000..d761b27e09d --- /dev/null +++ b/Master/texmf-dist/tex/latex/venndiagram/venndiagram.sty @@ -0,0 +1,584 @@ +%% +%% This is file `venndiagram.sty', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% venndiagram.dtx (with options: `venndiagram.sty,package') +%% +%% venndiagram.dtx +%% Copyright 2012 Nicola Talbot +%% +%% This work may be distributed and/or modified under the +%% conditions of the LaTeX Project Public License, either version 1.3 +%% of this license of (at your option) any later version. +%% The latest version of this license is in +%% http://www.latex-project.org/lppl.txt +%% and version 1.3 or later is part of all distributions of LaTeX +%% version 2005/12/01 or later. +%% +%% This work has the LPPL maintenance status `maintained'. +%% +%% The Current Maintainer of this work is Nicola Talbot. +%% +%% This work consists of the files venndiagram.dtx and venndiagram.ins and the derived file venndiagram.sty. +%% +%% \CharacterTable +%% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z +%% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z +%% Digits \0\1\2\3\4\5\6\7\8\9 +%% Exclamation \! Double quote \" Hash (number) \# +%% Dollar \$ Percent \% Ampersand \& +%% Acute accent \' Left paren \( Right paren \) +%% Asterisk \* Plus \+ Comma \, +%% Minus \- Point \. Solidus \/ +%% Colon \: Semicolon \; Less than \< +%% Equals \= Greater than \> Question mark \? +%% Commercial at \@ Left bracket \[ Backslash \\ +%% Right bracket \] Circumflex \^ Underscore \_ +%% Grave accent \` Left brace \{ Vertical bar \| +%% Right brace \} Tilde \~} +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{venndiagram}[2012/10/24 v1.0 (NLCT) Venn diagrams] +\RequirePackage{xkeyval} +\RequirePackage{tikz} +\RequirePackage{etoolbox} +\usetikzlibrary{intersections} +\newcommand*{\@venn@label@A}{$A$} +\newcommand*{\@venn@label@B}{$B$} +\newcommand*{\@venn@label@C}{$C$} +\newcommand*{\@venn@shade}{lightgray} +\newcommand*{\@venn@label@OnlyA}{} +\newcommand*{\@venn@label@OnlyB}{} +\newcommand*{\@venn@label@OnlyC}{} +\newcommand*{\@venn@label@OnlyAB}{} +\newcommand*{\@venn@label@OnlyAC}{} +\newcommand*{\@venn@label@OnlyBC}{} +\newcommand*{\@venn@label@ABC}{} +\newcommand*{\@venn@label@NotABC}{} +\newcommand*{\@venn@label@NotAB}{} +\newcommand*{\@venn@label@AB}{} +\newcommand*{\@venn@radius}{1.2cm} +\newcommand*{\@venn@hgap}{0.5cm} +\newcommand*{\@venn@vgap}{0.5cm} +\newcommand*{\@venn@overlap}{0.75cm} +\newcommand*{\@venn@tikzoptions}{} +\newlength\@venn@Ax +\newlength\@venn@Ay +\newlength\@venn@Bx +\newlength\@venn@By +\newlength\@venn@Cx +\newlength\@venn@Cy +\newlength\@venn@w +\newlength\@venn@h +\define@key{venn}{shade}{\def\@venn@shade{#1}} +\define@key{venn}{labelA}{\def\@venn@label@A{#1}} +\define@key{venn}{labelB}{\def\@venn@label@B{#1}} +\define@key{venn}{labelC}{\def\@venn@label@C{#1}} +\define@key{venn}{labelOnlyA}{\def\@venn@label@OnlyA{#1}} +\define@key{venn}{labelOnlyB}{\def\@venn@label@OnlyB{#1}} +\define@key{venn}{labelOnlyC}{\def\@venn@label@OnlyC{#1}} +\define@key{venn}{labelOnlyAB}{\def\@venn@label@OnlyAB{#1}} +\define@key{venn}{labelOnlyAC}{\def\@venn@label@OnlyAC{#1}} +\define@key{venn}{labelOnlyBC}{\def\@venn@label@OnlyBC{#1}} +\define@key{venn}{labelABC}{\def\@venn@label@ABC{#1}} +\define@key{venn}{labelNotABC}{\def\@venn@label@NotABC{#1}} +\define@key{venn}{labelAB}{\def\@venn@label@AB{#1}} +\define@key{venn}{labelNotAB}{\def\@venn@label@NotAB{#1}} +\define@key{venn}{radius}{\def\@venn@radius{#1}} +\define@key{venn}{hgap}{\def\@venn@hgap{#1}} +\define@key{venn}{vgap}{\def\@venn@vgap{#1}} +\define@key{venn}{overlap}{\def\@venn@overlap{#1}} +\define@key{venn}{tikzoptions}{\def\@venn@tikzoptions{#1}} + +\newenvironment{venndiagram3sets}[1][]% +{% + \disable@keys{venn}{labelAB,labelNotAB}% + \setkeys{venn}{#1}% + \pgfmathsetlength{\@venn@Cx}{\@venn@hgap + 2*\@venn@radius + -0.5*\@venn@overlap}% + \pgfmathsetlength{\@venn@Cy}{\@venn@vgap+\@venn@radius}% + \pgfmathsetlength{\@venn@Ax}{\@venn@hgap+\@venn@radius}% + \pgfmathsetlength{\@venn@Ay}{\@venn@Cy + + (\@venn@radius - 0.5*\@venn@overlap)*1.73205}% + \pgfmathsetlength{\@venn@Bx}{\@venn@hgap+3*\@venn@radius + -\@venn@overlap}% + \setlength{\@venn@By}{\@venn@Ay}% + \pgfmathsetlength{\@venn@w}{2*\@venn@hgap+4*\@venn@radius + -\@venn@overlap}% + \pgfmathsetlength{\@venn@h}{2*\@venn@vgap+4*\@venn@radius + -\@venn@overlap}% + \def\fillA{\path[fill=\@venn@shade] (\@venn@Ax,\@venn@Ay) + circle (\@venn@radius);}% + \def\fillB{\path[fill=\@venn@shade] (\@venn@Bx,\@venn@By) + circle (\@venn@radius);}% + \def\fillC{\path[fill=\@venn@shade] (\@venn@Cx,\@venn@Cy) + circle (\@venn@radius);}% + \def\fillAll{\path[fill=\@venn@shade] (0,0) + rectangle (\@venn@w,\@venn@h);}% + \def\fillNotA{\path[fill=\@venn@shade,even odd rule] + (0,0) rectangle (\@venn@w,\@venn@h) + (\@venn@Ax,\@venn@Ay) circle (\@venn@radius);}% + \def\fillNotB{\path[fill=\@venn@shade,even odd rule] + (0,0) rectangle (\@venn@w,\@venn@h) + (\@venn@Bx,\@venn@By) circle (\@venn@radius);}% + \def\fillNotC{\path[fill=\@venn@shade,even odd rule] + (0,0) rectangle (\@venn@w,\@venn@h) + (\@venn@Cx,\@venn@Cy) circle (\@venn@radius);}% + \def\fillOnlyA{% + \begin{scope} + \path[name path=A] (\@venn@Ax,\@venn@Ay) circle (\@venn@radius); + \path[name path=BC] (\@venn@Bx,\@venn@By) circle (\@venn@radius) + (\@venn@Cx,\@venn@Cy) circle (\@venn@radius); + \path[name intersections={of=A and BC,name=ABintersect}] + (ABintersect-1) ; + \pgfgetlastxy{\@venn@AB@xi}{\@venn@AB@yi} + \path (ABintersect-2); + \pgfgetlastxy{\@venn@AB@xii}{\@venn@AB@yii} + \pgfmathparse{atan2(\@venn@AB@xi-\@venn@Ax,\@venn@AB@yi-\@venn@Ay)} + \let\@venn@start@i=\pgfmathresult + \pgfmathparse{360+atan2(\@venn@AB@xii-\@venn@Ax,\@venn@AB@yii-\@venn@Ay)} + \let\@venn@end@i=\pgfmathresult + \path[name path=B] (\@venn@Bx,\@venn@By) circle (\@venn@radius); + \path[name path=C] (\@venn@Cx,\@venn@Cy) circle (\@venn@radius); + \path[name intersections={of=B and C,name=BCintersect}] + (BCintersect-1); + \pgfgetlastxy{\@venn@BC@x}{\@venn@BC@y} + \pgfmathparse{atan2(\@venn@AB@xii-\@venn@Cx, \@venn@AB@yii-\@venn@Cy)} + \let\@venn@start@ii=\pgfmathresult + \pgfmathparse{atan2(\@venn@BC@x-\@venn@Cx, \@venn@BC@y-\@venn@Cy)} + \let\@venn@end@ii=\pgfmathresult + \pgfmathparse{atan2(\@venn@BC@x-\@venn@Bx, \@venn@BC@y-\@venn@By)} + \let\@venn@start@iii=\pgfmathresult + \pgfmathparse{atan2(\@venn@AB@xi-\@venn@Bx, \@venn@AB@yi-\@venn@By)-360} + \let\@venn@end@iii=\pgfmathresult + \path[fill=\@venn@shade] (ABintersect-1) + arc[radius=\@venn@radius, + start angle=\@venn@start@i,end angle=\@venn@end@i] + arc[radius=\@venn@radius, + start angle=\@venn@start@ii,end angle=\@venn@end@ii] + arc[radius=\@venn@radius, + start angle=\@venn@start@iii,end angle=\@venn@end@iii] + -- cycle; + \end{scope} + }% + \def\fillOnlyB{% + \begin{scope} + \path[name path=B] (\@venn@Bx,\@venn@By) circle (\@venn@radius); + \path[name path=AC] (\@venn@Ax,\@venn@Ay) circle (\@venn@radius) + (\@venn@Cx,\@venn@Cy) circle (\@venn@radius); + \path[name intersections={of=B and AC,name=BAintersect,sort by=B}] + (BAintersect-1); + \pgfgetlastxy{\@venn@BA@xi}{\@venn@BA@yi} + \path (BAintersect-4); + \pgfgetlastxy{\@venn@BA@xii}{\@venn@BA@yii} + \pgfmathparse{atan2(\@venn@BA@xi-\@venn@Bx,\@venn@BA@yi-\@venn@By)} + \let\@venn@start@i=\pgfmathresult + \pgfmathparse{atan2(\@venn@BA@xii-\@venn@Bx,\@venn@BA@yii-\@venn@By)} + \let\@venn@end@i=\pgfmathresult + \path[name path=A] (\@venn@Ax,\@venn@Ay) circle (\@venn@radius); + \path[name path=C] (\@venn@Cx,\@venn@Cy) circle (\@venn@radius); + \path[name intersections={of=A and C,name=ACintersect}] + (ACintersect-2); + \pgfgetlastxy{\@venn@AC@x}{\@venn@AC@y} + \pgfmathparse{atan2(\@venn@BA@xii-\@venn@Cx, \@venn@BA@yii-\@venn@Cy)} + \let\@venn@start@ii=\pgfmathresult + \pgfmathparse{atan2(\@venn@AC@x-\@venn@Cx, \@venn@AC@y-\@venn@Cy)} + \let\@venn@end@ii=\pgfmathresult + \pgfmathparse{atan2(\@venn@AC@x-\@venn@Ax, \@venn@AC@y-\@venn@Ay)} + \let\@venn@start@iii=\pgfmathresult + \pgfmathparse{atan2(\@venn@BA@xi-\@venn@Ax, \@venn@BA@yi-\@venn@Ay)} + \let\@venn@end@iii=\pgfmathresult + \path[fill=\@venn@shade] (BAintersect-1) + arc[radius=\@venn@radius, + start angle=\@venn@start@i,end angle=\@venn@end@i] + arc[radius=\@venn@radius, + start angle=\@venn@start@ii,end angle=\@venn@end@ii] + arc[radius=\@venn@radius, + start angle=\@venn@start@iii,end angle=\@venn@end@iii] + -- cycle ; + \end{scope} + }% + \def\fillOnlyC{% + \begin{scope} + \path[name path=C] (\@venn@Cx,\@venn@Cy) circle (\@venn@radius); + \path[name path=BA] (\@venn@Bx,\@venn@By) circle (\@venn@radius) + (\@venn@Ax,\@venn@Ay) circle (\@venn@radius); + \path[name intersections={of=C and BA,name=CBintersect,sort by=C}] + (CBintersect-1); + \pgfgetlastxy{\@venn@CB@xi}{\@venn@CB@yi} + \path (CBintersect-4); + \pgfgetlastxy{\@venn@CB@xii}{\@venn@CB@yii} + \pgfmathparse{atan2(\@venn@CB@xi-\@venn@Cx,\@venn@CB@yi-\@venn@Cy)} + \let\@venn@start@i=\pgfmathresult + \pgfmathparse{atan2(\@venn@CB@xii-\@venn@Cx,\@venn@CB@yii-\@venn@Cy)-360} + \let\@venn@end@i=\pgfmathresult + \path[name path=B] (\@venn@Bx,\@venn@By) circle (\@venn@radius); + \path[name path=A] (\@venn@Ax,\@venn@Ay) circle (\@venn@radius); + \path[name intersections={of=B and A,name=BAintersect}] + (BAintersect-2); + \pgfgetlastxy{\@venn@BA@x}{\@venn@BA@y} + \pgfmathparse{atan2(\@venn@CB@xii-\@venn@Ax, \@venn@CB@yii-\@venn@Ay)} + \let\@venn@start@ii=\pgfmathresult + \pgfmathparse{atan2(\@venn@BA@x-\@venn@Ax, \@venn@BA@y-\@venn@Ay)} + \let\@venn@end@ii=\pgfmathresult + \pgfmathparse{atan2(\@venn@BA@x-\@venn@Bx, \@venn@BA@y-\@venn@By)} + \let\@venn@start@iii=\pgfmathresult + \pgfmathparse{atan2(\@venn@CB@xi-\@venn@Bx, \@venn@CB@yi-\@venn@By)} + \let\@venn@end@iii=\pgfmathresult + \path[fill=\@venn@shade] (CBintersect-1) + arc[radius=\@venn@radius, + start angle=\@venn@start@i,end angle=\@venn@end@i] + arc[radius=\@venn@radius, + start angle=\@venn@start@ii,end angle=\@venn@end@ii] + arc[radius=\@venn@radius, + start angle=\@venn@start@iii,end angle=\@venn@end@iii] + -- cycle; + \end{scope} + }% + \def\fillNotABC{% + \begin{scope} + \path[name path=A] (\@venn@Ax,\@venn@Ay) circle (\@venn@radius); + \path[name path=B] (\@venn@Bx,\@venn@By) circle (\@venn@radius); + \path[name path=C] (\@venn@Cx,\@venn@Cy) circle (\@venn@radius); + \path[name intersections={of=A and B,name=ABintersect}] + (ABintersect-1); + \pgfgetlastxy{\@venn@AB@x}{\@venn@AB@y} + \path[name intersections={of=A and C,name=ACintersect}] + (ACintersect-1); + \pgfgetlastxy{\@venn@AC@x}{\@venn@AC@y} + \path[name intersections={of=C and B,name=CBintersect}] + (CBintersect-1); + \pgfgetlastxy{\@venn@CB@x}{\@venn@CB@y} + \pgfmathparse{atan2(\@venn@AB@x-\@venn@Ax, \@venn@AB@y-\@venn@Ay)} + \let\@venn@start@i=\pgfmathresult + \pgfmathparse{atan2(\@venn@AC@x-\@venn@Ax, \@venn@AC@y-\@venn@Ay)+360} + \let\@venn@end@i=\pgfmathresult + \pgfmathparse{atan2(\@venn@AC@x-\@venn@Cx,\@venn@AC@y-\@venn@Cy)} + \let\@venn@start@ii=\pgfmathresult + \pgfmathparse{atan2(\@venn@CB@x-\@venn@Cx,\@venn@CB@y-\@venn@Cy)+360} + \let\@venn@end@ii=\pgfmathresult + \pgfmathparse{atan2(\@venn@CB@x-\@venn@Bx,\@venn@CB@y-\@venn@By)} + \let\@venn@start@iii=\pgfmathresult + \pgfmathparse{atan2(\@venn@AB@x-\@venn@Bx,\@venn@AB@y-\@venn@By)} + \let\@venn@end@iii=\pgfmathresult + \path[fill=\@venn@shade] + (0,0) rectangle (\@venn@w,\@venn@h) + (ABintersect-1) + arc[radius=\@venn@radius, + start angle=\@venn@start@i,end angle=\@venn@end@i] + arc[radius=\@venn@radius, + start angle=\@venn@start@ii,end angle=\@venn@end@ii] + arc[radius=\@venn@radius, + start angle=\@venn@start@iii,end angle=\@venn@end@iii] + -- cycle; + \end{scope} + }% + \def\fillANotB{% + \begin{scope} + \clip (\@venn@Ax,\@venn@Ay) circle (\@venn@radius); + \path[fill=\@venn@shade,even odd rule] + (\@venn@Ax,\@venn@Ay) circle (\@venn@radius) + (\@venn@Bx,\@venn@By) circle (\@venn@radius); + \end{scope} + }% + \def\fillBNotA{% + \begin{scope} + \clip (\@venn@Bx,\@venn@By) circle (\@venn@radius); + \path[fill=\@venn@shade,even odd rule] + (\@venn@Bx,\@venn@By) circle (\@venn@radius) + (\@venn@Ax,\@venn@Ay) circle (\@venn@radius); + \end{scope} + }% + \def\fillANotC{% + \begin{scope} + \clip (\@venn@Ax,\@venn@Ay) circle (\@venn@radius); + \path[fill=\@venn@shade,even odd rule] + (\@venn@Ax,\@venn@Ay) circle (\@venn@radius) + (\@venn@Cx,\@venn@Cy) circle (\@venn@radius); + \end{scope} + }% + \def\fillCNotA{% + \begin{scope} + \clip (\@venn@Cx,\@venn@Cy) circle (\@venn@radius); + \path[fill=\@venn@shade,even odd rule] + (\@venn@Cx,\@venn@Cy) circle (\@venn@radius) + (\@venn@Ax,\@venn@Ay) circle (\@venn@radius); + \end{scope} + }% + \def\fillBNotC{% + \begin{scope} + \clip (\@venn@Bx,\@venn@By) circle (\@venn@radius); + \path[fill=\@venn@shade,even odd rule] + (\@venn@Bx,\@venn@By) circle (\@venn@radius) + (\@venn@Cx,\@venn@Cy) circle (\@venn@radius); + \end{scope} + }% + \def\fillCNotB{% + \begin{scope} + \clip (\@venn@Cx,\@venn@Cy) circle (\@venn@radius); + \path[fill=\@venn@shade,even odd rule] + (\@venn@Cx,\@venn@Cy) circle (\@venn@radius) + (\@venn@Bx,\@venn@By) circle (\@venn@radius); + \end{scope} + }% + \def\fillACapB{% + \begin{scope} + \clip (\@venn@Ax,\@venn@Ay) circle (\@venn@radius); + \path[fill=\@venn@shade] + (\@venn@Bx,\@venn@By) circle (\@venn@radius); + \end{scope} + }% + \let\fillBCapA\fillACapB + \def\fillACapC{% + \begin{scope} + \clip (\@venn@Ax,\@venn@Ay) circle (\@venn@radius); + \path[fill=\@venn@shade] + (\@venn@Cx,\@venn@Cy) circle (\@venn@radius); + \end{scope} + }% + \let\fillCCapA\fillACapC + \def\fillBCapC{% + \begin{scope} + \clip (\@venn@Bx,\@venn@By) circle (\@venn@radius); + \path[fill=\@venn@shade] + (\@venn@Cx,\@venn@Cy) circle (\@venn@radius); + \end{scope} + }% + \let\fillCCapB\fillBCapC + \def\fillACapBNotC{% + \begin{scope} + \clip (\@venn@Ax,\@venn@Ay) circle (\@venn@radius); + \clip (\@venn@Bx,\@venn@By) circle (\@venn@radius); + \path[fill=\@venn@shade,even odd rule] + (\@venn@Bx,\@venn@By) circle (\@venn@radius) + (\@venn@Cx,\@venn@Cy) circle (\@venn@radius); + \end{scope} + }% + \let\fillBCapANotC\fillACapBNotC + \def\fillACapCNotB{% + \begin{scope} + \clip (\@venn@Ax,\@venn@Ay) circle (\@venn@radius); + \clip (\@venn@Cx,\@venn@Cy) circle (\@venn@radius); + \path[fill=\@venn@shade,even odd rule] + (\@venn@Cx,\@venn@Cy) circle (\@venn@radius) + (\@venn@Bx,\@venn@By) circle (\@venn@radius); + \end{scope} + }% + \let\fillCCapANotB\fillACapCNotB + \def\fillBCapCNotA{% + \begin{scope} + \clip (\@venn@Bx,\@venn@By) circle (\@venn@radius); + \clip (\@venn@Cx,\@venn@Cy) circle (\@venn@radius); + \path[fill=\@venn@shade,even odd rule] + (\@venn@Cx,\@venn@Cy) circle (\@venn@radius) + (\@venn@Ax,\@venn@Ay) circle (\@venn@radius); + \end{scope} + }% + \let\fillCCapBNotA\fillBCapCNotA + \def\fillACapBCapC{% + \begin{scope} + \clip (\@venn@Ax,\@venn@Ay) circle (\@venn@radius); + \clip (\@venn@Cx,\@venn@Cy) circle (\@venn@radius); + \path[fill=\@venn@shade] + (\@venn@Bx,\@venn@By) circle (\@venn@radius); + \end{scope} + }% + \let\fillACapCCapB\fillACapBCapC + \let\fillBCapACapC\fillACapBCapC + \let\fillBCapCCapA\fillACapBCapC + \let\fillCCapACapB\fillACapBCapC + \let\fillCCapBCapA\fillACapBCapC + \ifdefempty{\@venn@tikzoptions}% + {% + \def\@venn@dobegin{\begin{tikzpicture}}% + }% + {% + \edef\@venn@dobegin{\noexpand\begin{tikzpicture}% + [\expandonce\@venn@tikzoptions]}% + }% + \@venn@dobegin + \path (0,0) coordinate (venn bottom left) + (0,\@venn@h) coordinate (venn top left) + (\@venn@w,\@venn@h) coordinate (venn top right) + (\@venn@w,0) coordinate (venn bottom right); +}% +{% + \draw (0,0) rectangle (\@venn@w,\@venn@h); + \draw (\@venn@Ax,\@venn@Ay) circle (\@venn@radius); + \draw (\@venn@Bx,\@venn@By) circle (\@venn@radius); + \draw (\@venn@Cx,\@venn@Cy) circle (\@venn@radius); + \draw (\@venn@Ax,\@venn@Ay) node[above,left] (labelOnlyA) {\@venn@label@OnlyA}; + \draw (\@venn@Bx,\@venn@By) node[above,right] (labelOnlyB) {\@venn@label@OnlyB}; + \draw (\@venn@Cx,\@venn@Cy) node[below] (labelOnlyC) {\@venn@label@OnlyC}; + \draw (\@venn@vgap,\@venn@hgap) node (labelNotABC) {\@venn@label@NotABC}; + \draw (\@venn@Ax,\@venn@Ay+\@venn@radius) + node[below] (labelA) {\@venn@label@A}; + \draw (\@venn@Bx,\@venn@By+\@venn@radius) + node[below] (labelB) {\@venn@label@B}; + \draw (\@venn@Cx,\@venn@vgap) node[above] (labelC) {\@venn@label@C}; + \draw (\@venn@Cx,0.5*\@venn@h) node (labelABC) {\@venn@label@ABC}; + \draw (\@venn@Cx,\@venn@Ay) node[above] (labelOnlyAB) {\@venn@label@OnlyAB}; + \draw (\@venn@Ax,\@venn@Ay) ++(-60:\@venn@radius-0.5*\@venn@overlap) + node[below left] (labelOnlyAC) {\@venn@label@OnlyAC}; + \draw (\@venn@Bx,\@venn@By) ++(-120:\@venn@radius-0.5*\@venn@overlap) + node[below right] (labelOnlyBC) {\@venn@label@OnlyBC}; + \@postvennhook + \end{tikzpicture} +} +\newcommand*{\@postvennhook}{} +\newcommand*{\setpostvennhook}[1]{\def\@postvennhook{#1}} +\newenvironment{venndiagram2sets}[1][]% +{% + \disable@keys{venn}{labelABC,labelOnlyC,labelOnlyAC,labelOnlyBC,% + labelNotABC,labelC,labelOnlyAB}% + \setkeys{venn}{#1}% + % Calculate centre of A + \pgfmathsetlength{\@venn@Ax}{\@venn@hgap+\@venn@radius}% + \pgfmathsetlength{\@venn@Ay}{\@venn@vgap+\@venn@radius}% + \pgfmathsetlength{\@venn@Bx}{\@venn@hgap+3*\@venn@radius + -\@venn@overlap}% + \setlength{\@venn@By}{\@venn@Ay}% + \pgfmathsetlength{\@venn@w}{2*\@venn@hgap+4*\@venn@radius + -\@venn@overlap}% + \pgfmathsetlength{\@venn@h}{2*\@venn@vgap+2*\@venn@radius}% + \def\fillA{\path[fill=\@venn@shade] (\@venn@Ax,\@venn@Ay) + circle (\@venn@radius);}% + \def\fillB{\path[fill=\@venn@shade] (\@venn@Bx,\@venn@By) + circle (\@venn@radius);}% + \def\fillAll{\path[fill=\@venn@shade] (0,0) + rectangle (\@venn@w,\@venn@h);}% + \def\fillOnlyA{% + \begin{scope} + \path[name path=A] (\@venn@Ax,\@venn@Ay) circle (\@venn@radius); + \path[name path=B] (\@venn@Bx,\@venn@By) circle (\@venn@radius); + \path[name intersections={of=A and B,name=ABintersect}] + (ABintersect-1) ; + \pgfgetlastxy{\@venn@AB@xi}{\@venn@AB@yi} + \path (ABintersect-2); + \pgfgetlastxy{\@venn@AB@xii}{\@venn@AB@yii} + \pgfmathparse{atan2(\@venn@AB@xi-\@venn@Ax,\@venn@AB@yi-\@venn@Ay)} + \let\@venn@start@i=\pgfmathresult + \pgfmathparse{360+atan2(\@venn@AB@xii-\@venn@Ax,\@venn@AB@yii-\@venn@Ay)} + \let\@venn@end@i=\pgfmathresult + \pgfmathparse{atan2(\@venn@AB@xii-\@venn@Bx, \@venn@AB@yii-\@venn@By)} + \let\@venn@start@ii=\pgfmathresult + \pgfmathparse{atan2(\@venn@AB@xi-\@venn@Bx, \@venn@AB@yi-\@venn@By)-360} + \let\@venn@end@ii=\pgfmathresult + \path[fill=\@venn@shade] (ABintersect-1) + arc[radius=\@venn@radius, + start angle=\@venn@start@i,end angle=\@venn@end@i] + arc[radius=\@venn@radius, + start angle=\@venn@start@ii,end angle=\@venn@end@ii] + -- cycle; + \end{scope} + }% + \def\fillOnlyB{% + \begin{scope} + \path[name path=A] (\@venn@Ax,\@venn@Ay) circle (\@venn@radius); + \path[name path=B] (\@venn@Bx,\@venn@By) circle (\@venn@radius); + \path[name intersections={of=A and B,name=ABintersect}] + (ABintersect-1) ; + \pgfgetlastxy{\@venn@AB@xi}{\@venn@AB@yi} + \path (ABintersect-2); + \pgfgetlastxy{\@venn@AB@xii}{\@venn@AB@yii} + \pgfmathparse{atan2(\@venn@AB@xi-\@venn@Bx,\@venn@AB@yi-\@venn@By)} + \let\@venn@start@i=\pgfmathresult + \pgfmathparse{atan2(\@venn@AB@xii-\@venn@Bx,\@venn@AB@yii-\@venn@By)} + \let\@venn@end@i=\pgfmathresult + \pgfmathparse{atan2(\@venn@AB@xii-\@venn@Ax, \@venn@AB@yii-\@venn@Ay)} + \let\@venn@start@ii=\pgfmathresult + \pgfmathparse{atan2(\@venn@AB@xi-\@venn@Ax, \@venn@AB@yi-\@venn@Ay)} + \let\@venn@end@ii=\pgfmathresult + \path[fill=\@venn@shade] (ABintersect-1) + arc[radius=\@venn@radius, + start angle=\@venn@start@i,end angle=\@venn@end@i] + arc[radius=\@venn@radius, + start angle=\@venn@start@ii,end angle=\@venn@end@ii] + -- cycle; + \end{scope} + }% + \def\fillNotA{\path[fill=\@venn@shade,even odd rule] + (0,0) rectangle (\@venn@w,\@venn@h) + (\@venn@Ax,\@venn@Ay) circle (\@venn@radius);}% + \def\fillNotB{\path[fill=\@venn@shade,even odd rule] + (0,0) rectangle (\@venn@w,\@venn@h) + (\@venn@Bx,\@venn@By) circle (\@venn@radius);}% + \def\fillNotAorB{% + \begin{scope} + \path[clip] + (0,0) rectangle (\@venn@w,\@venn@h) + (\@venn@Bx,\@venn@By) circle (\@venn@radius) + ; + \path[fill=\@venn@shade,even odd rule] + (0,0) rectangle (\@venn@w,\@venn@h) + (\@venn@Ax,\@venn@Ay) circle (\@venn@radius) + ; + \end{scope} + }% + \def\fillNotAorNotB{% + \path[fill=\@venn@shade,nonzero rule] + (0,0) rectangle (\@venn@w,\@venn@h) + (\@venn@Ax,\@venn@Ay) circle (\@venn@radius) + (0,0) rectangle (\@venn@w,\@venn@h) + (\@venn@Bx,\@venn@By) circle (\@venn@radius) + ; + }% + \def\fillANotB{% + \begin{scope} + \clip (\@venn@Ax,\@venn@Ay) circle (\@venn@radius); + \path[fill=\@venn@shade,even odd rule] + (\@venn@Ax,\@venn@Ay) circle (\@venn@radius) + (\@venn@Bx,\@venn@By) circle (\@venn@radius); + \end{scope} + }% + \def\fillBNotA{% + \begin{scope} + \clip (\@venn@Bx,\@venn@By) circle (\@venn@radius); + \path[fill=\@venn@shade,even odd rule] + (\@venn@Bx,\@venn@By) circle (\@venn@radius) + (\@venn@Ax,\@venn@Ay) circle (\@venn@radius); + \end{scope} + }% + \def\fillACapB{% + \begin{scope} + \clip (\@venn@Ax,\@venn@Ay) circle (\@venn@radius); + \path[fill=\@venn@shade] + (\@venn@Bx,\@venn@By) circle (\@venn@radius); + \end{scope} + }% + \let\fillBCapA\fillACapB + \ifdefempty{\@venn@tikzoptions}% + {% + \def\@venn@dobegin{\begin{tikzpicture}}% + }% + {% + \edef\@venn@dobegin{\noexpand\begin{tikzpicture}% + [\expandonce\@venn@tikzoptions]}% + }% + \@venn@dobegin + \path (0,0) coordinate (venn bottom left) + (0,\@venn@h) coordinate (venn top left) + (\@venn@w,\@venn@h) coordinate (venn top right) + (\@venn@w,0) coordinate (venn bottom right); +}% +{% + \draw (venn bottom left) rectangle (\@venn@w,\@venn@h); + \draw (\@venn@Ax,\@venn@Ay) circle (\@venn@radius); + \draw (\@venn@Bx,\@venn@By) circle (\@venn@radius); + \draw (\@venn@Ax,\@venn@Ay) node[above,left] (labelOnlyA) + {\@venn@label@OnlyA}; + \draw (\@venn@Bx,\@venn@By) node[above,right] (labelOnlyB) + {\@venn@label@OnlyB}; + \draw (\@venn@vgap,\@venn@hgap) node (labelNotAB) {\@venn@label@NotAB}; + \draw (\@venn@Ax,\@venn@Ay+\@venn@radius) + node[below] (labelA) {\@venn@label@A}; + \draw (\@venn@Bx,\@venn@By+\@venn@radius) + node[below] (labelB) {\@venn@label@B}; + \draw (0.5*\@venn@w,0.5*\@venn@h) node (labelAB) {\@venn@label@AB}; + \@postvennhook + \end{tikzpicture} +} +\endinput +%% +%% End of file `venndiagram.sty'. |