Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I want pure white fill so that upper most circle becomes incomplete. But black shade comes in the figure. Is there any easier way to do this?

enter image description here

\documentclass{article}

\usepackage{tikz}

\begin{document}
\begin{figure}
\begin{center}
\begin{tikzpicture}[scale=1.0, ,transform shape]
\node [draw, thick, minimum size=1cm, circle] at (0,0) {};
\node [draw, thick, minimum size=1cm, circle] at (1,0) {};
\node [draw, thick, minimum size=1cm, circle] at (2,0) {};
\node [draw, thick, minimum size=1cm, circle] at (-1,0) {};

\node [draw, thick, minimum size=1cm, circle] at (1.5,-0.85) {};
\node [draw, thick, minimum size=1cm, circle] at (0.5,-0.85) {};
\node [draw, thick, minimum size=1cm, circle] at (-0.5,-0.85) {};

\node [draw, thick, minimum size=1cm, circle] at (1.5,0.85) {};
\node [draw, thick, minimum size=1cm, circle] at (0.5,0.85) {};
\node [draw, thick, minimum size=1cm, circle] at (-0.5,0.85) {};

\node [draw, thick, minimum size=1cm, circle] at (1.0,2*0.85) {};
\shade[fill=white!20!white, draw=white!40!black](-1.5,2.0)--(2.5,2.0)--(2.5,2.5)--(-1.5,2.5);

\draw[dotted,thin](-1.5,-2)--(-1.5,2.0)--(2.5,2.0)--(2.5,-2)--(-1.5,-2);

\end{tikzpicture}
\end{center}
\caption{hhhhhhhhh}
\label{figspahre}
\end{figure}

\end{document}
share|improve this question
1  
as an aside, see should-i-use-center-or-centering-for-figures-and-tables –  cmhughes Oct 21 '12 at 15:50
add comment

1 Answer 1

up vote 9 down vote accepted

Replace

\shade[fill=white!20!white, draw=white!40!black]-1.5,2.0)-`-(2.5,2.0)--(2.5,2.5)--(-1.5,2.5);

by

\draw[draw=none,fill=white!20](-1.5,2.0)--(2.5,2.0)--(2.5,2.5)--(-1.5,2.5);

If you want the rectangle above, use

\draw[draw=white!40!black,fill=white!20](-1.5,2.0)--(2.5,2.0)--(2.5,2.5)--(-1.5,2.5) -- cycle;

Other possible commands are \fill and \filldraw.

Code

\documentclass[twoside]{article}
\usepackage{graphicx}
\usepackage{tikz}

\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}[scale=1.0, ,transform shape]
\node [draw, thick, minimum size=1cm, circle] at (0,0) {};
\node [draw, thick, minimum size=1cm, circle] at (1,0) {};
\node [draw, thick, minimum size=1cm, circle] at (2,0) {};
\node [draw, thick, minimum size=1cm, circle] at (-1,0) {};

\node [draw, thick, minimum size=1cm, circle] at (1.5,-0.85) {};
\node [draw, thick, minimum size=1cm, circle] at (0.5,-0.85) {};
\node [draw, thick, minimum size=1cm, circle] at (-0.5,-0.85) {};

\node [draw, thick, minimum size=1cm, circle] at (1.5,0.85) {};
\node [draw, thick, minimum size=1cm, circle] at (0.5,0.85) {};
\node [draw, thick, minimum size=1cm, circle] at (-0.5,0.85) {};

\node [draw, thick, minimum size=1cm, circle] at (1.0,2*0.85) {};
\draw[draw=none,fill=white!20](-1.5,2.0)--(2.5,2.0)--(2.5,2.5)--(-1.5,2.5);

\draw[dotted,thin](-1.5,-2)--(-1.5,2.0)--(2.5,2.0)--(2.5,-2)--(-1.5,-2);

\end{tikzpicture}
\caption{hhhhhhhhh}
\label{figspahre}
\end{figure}

\end{document}

enter image description here

Side notes:

The color description of white!20!white is meaningless. It says 20% of white mixed with 80% of white.

Instead of using white!20!white... \end{center}, use \centering. This will remove some unwanted white space.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.