Discussion:
TikZ for a set complement
(too old to reply)
Art Werschulz
2009-05-06 17:11:20 UTC
Permalink
Hi.

I would like to draw a set complement using TikZ.
The picture would consist of a circle inside a rectangle, the circle
being labelled with $A$. The circle would not be colored, but the
box would be colored.

Suggestions? Thanks.
--
Art Werschulz (8-{)} "Metaphors be with you." -- bumper sticker
GCS/M (GAT): d? -p+ c++ l++ u+ P++ e--- m* s n+ h f g+ w+ t+ r-
Net: ***@dsm.fordham.edu http://www.dsm.fordham.edu/~agw
Phone: Fordham U. (212) 636-6325, Columbia U. (212) 939-7060
Kjell Magne Fauske
2009-05-06 18:35:00 UTC
Permalink
Post by Art Werschulz
Hi.
I would like to draw a set complement using TikZ.
The picture would consist of a circle inside a rectangle, the circle
being labelled with $A$.  The circle would not be colored, but the
box would be colored.
Suggestions?   Thanks.
--
Art Werschulz (8-{)}   "Metaphors be with you."  -- bumper sticker
GCS/M (GAT): d? -p+ c++ l++ u+ P++ e--- m* s n+ h f g+ w+ t+ r-
Phone:   Fordham U. (212) 636-6325, Columbia U. (212) 939-7060
How about this?

%%%
\documentclass{minimal}
\usepackage{tikz}
\begin{document}

\def\setA{(0,0) rectangle (4,4)}
\def\setB{(2,2) circle (1)}
\begin{tikzpicture}
\draw \setA;
\draw \setB node {$A$};
\begin{scope}[even odd rule]
\clip \setA \setB;
\fill[blue!50] \setA;
\end{scope}
\end{tikzpicture}
\end{document}
%%%

A similar example can be found here: http://www.texample.net/tikz/examples/venn-diagram/

- Kjell Magne Fauske
n***@gmail.com
2009-05-07 07:43:29 UTC
Permalink
Just another option. In this case you must be draw the circle after
the rectangle.

%%%%%%%%%%%%%%%
\documentclass{minimal}
\usepackage{tikz}
\begin{document}

\begin{tikzpicture}
\node[draw,rectangle,fill=blue,minimum size=4cm] (rectangle) {};
\node[draw,circle,fill=white,minimum size=2cm] () at (rectangle)
{$A$};
\end{tikzpicture}

\end{document}
%%%%%%%%%%%%%%

Ignasi

Loading...