Graphics, Figures & TablesTikz and Filldraw

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

Tikz and Filldraw

Post by coachbennett1981 »

Good morning,

I am drawing a figure for someone and I am having difficulty with filldraw. Here is the figure:

Code: Select all



\documentclass[12pt]{exam}
\usepackage{tikz}
\usetikzlibrary{calc,through,backgrounds}

\begin{document}


\begin{tikzpicture}[scale=.75]
  \coordinate [label=below:$O$] (O) at (0,0);
  \coordinate [label=left:$C$] (C) at (-2,0);
  \coordinate [label=right:$B$] (B) at (2,0);
  \coordinate [label=below:$A$] (A) at (0,-2);
  \coordinate [label=left:$D$] (D) at (-2,4);
  \coordinate [label=right: $E$] (E) at (2,4);
  \node[draw,circle through=(B)] at (O) {};
  \filldraw[fill=gray] (B) arc (0:180:2) (A);
  \filldraw[black](A) circle (1pt);
  \filldraw[black](B) circle (1pt);
  \filldraw[black](O) circle (1pt);
  \filldraw[black](C) circle (1pt);
  \draw (D)--(C)--(B)--(E);
  \draw (D)--(E);
  \draw (0,4.3) node {14 ft};
\end{tikzpicture}

\end{document}

How can I shade just the square, not the circle. Any help is appreciated.

Nick
Last edited by coachbennett1981 on Tue May 17, 2011 11:50 am, edited 1 time in total.

Recommended reading 2024:

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

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

mas
Posts: 226
Joined: Thu Dec 04, 2008 4:39 am

Tikz and Filldraw

Post by mas »

Drawing the square with a fill parameter first, and then drawing the circle with a different fill colour should work for you. I just moved the lines around in your snippet and obtained the result.

Code: Select all

\documentclass[12pt]{exam}
\usepackage{tikz}
\usetikzlibrary{calc,through,backgrounds}

\begin{document}

\begin{tikzpicture}[scale=.75]
  \coordinate [label=below:$O$] (O) at (0,0);
  \coordinate [label=left:$C$] (C) at (-2,0);
  \coordinate [label=right:$B$] (B) at (2,0);
  \coordinate [label=below:$A$] (A) at (0,-2);
  \coordinate [label=left:$D$] (D) at (-2,4);
  \coordinate [label=right: $E$] (E) at (2,4);
  \draw[fill=gray] (D)--(C)--(B)--(E);
  \node[draw,circle through=(B)] at (O) {};
  \filldraw[fill=white] (B) arc (0:180:2) (A);
  \filldraw[black](A) circle (1pt);
  \filldraw[black](B) circle (1pt);
  \filldraw[black](O) circle (1pt);
  \filldraw[black](C) circle (1pt);
  \draw (D)--(E);
  \draw (0,4.3) node {14 ft};
\end{tikzpicture}

\end{document}
If it is not what you intended, maybe I misunderstood your question.

Regards.

OS: Debian/GNU Linux; LaTeX System : TeXLive; Editor : Vim
coachbennett1981
Posts: 274
Joined: Fri Feb 05, 2010 10:15 pm

Re: Tikz and Filldraw

Post by coachbennett1981 »

That is perfect.. You made it look easy..
Post Reply