Graphics, Figures & TablesCircle and Rectangle in Tikz

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
coachbennett1981
Posts: 274
Joined: Fri Feb 05, 2010 10:15 pm

Circle and Rectangle in Tikz

Post by coachbennett1981 »

I am working on contructing a circle and square together in one figure (See code:) however, when I use the plots for B(-2,0), D(-2,-2), C(2,0) and E(2,-2). The rectangle does not come out with 90 degree angles for D and E. Is there a way to fix this?


Nick

Code: Select all

\documentclass[12pt]{exam}
\usepackage{xcolor}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usetikzlibrary{calc,through,backgrounds}
\begin{document}
\begin{tikzpicture}[scale=2]
  \coordinate [label=below:$O$] (O) at (0,0);
  \coordinate [label=left:$B$] (B) at (-2,0);
  \coordinate [label=right:$C$] (C) at (2,0);
  \coordinate [label=below:$A$] (A) at (0,-2);
 [b] \coordinate [label=left:$D$] (D) at (-1.96,-2);
  \coordinate [label=left: $E$] (E) at (1.95,-2);[/b]
  \node[draw,circle through=(B)] at (O) {};
  \filldraw[black](A) circle (1pt);
  \filldraw[black](B) circle (1pt);
  \filldraw[black](O) circle (1pt);
  \filldraw[black](C) circle (1pt);
  \draw (B)--(D)--(E)--(C);
  \draw (B)--(O)--(C);
\end{tikzpicture}

\end{document}


Any help is appreciated

Nick
Last edited by coachbennett1981 on Mon Jun 28, 2010 2:38 am, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

torbjorn t.
Posts: 162
Joined: Wed Jun 17, 2009 10:18 pm

Re: Circle and Rectangle in Tikz

Post by torbjorn t. »

The coordinates for D and E are (-1.96,-2) and (1.95,-2), respectively, so naturally the angles will not be 90°. Change these to (-2,-2) and (2,-2), and it should be correct.
coachbennett1981
Posts: 274
Joined: Fri Feb 05, 2010 10:15 pm

Re: Circle and Rectangle in Tikz

Post by coachbennett1981 »

I did that before, but I printed a picture to be sure because it looked off when on screen.. At least we are on the same page with the coordinates.
Post Reply