5

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}
Stefan Kottwitz
  • 231,401
user12290
  • 3,341

1 Answers1

7

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.