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.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have something drawn as a tikzpicture:

  \node[above] at (8,13) {$...$};
  \filldraw[fill=white!20] (2,0) rectangle (6,12);
  \draw (2,4) -- (2,12); \draw (2,12) -- (6,12); \draw (6,12) -- (6,4);
  \draw [dashed] (6,3) -- (1,3);

Now I would like to draw a non-transparent white rectangle which hides a part of the picture, so that what is under the rectangle becomes invisible or less visible (e.g. gray). Does anyone know how to do it?

share|improve this question
\draw (2,4) -- (2,12); ... is not useful after \filldraw ... – Alain Matthes Aug 15 '12 at 16:11
up vote 7 down vote accepted

You can simply move the \filldraw command to be after what you want hidden, and control the opacity with fill opacity=<opacity>:

enter image description here

If you want what is underneath to be complely hidden, adding fill opacity=1.0 captures the specific intent (even though it is the default).


  • I changed the color to yellow!20 to make the effect clearer in the image here. Replacing this with fill=white will give you the desired result.



\foreach \OpacitySetting in {1.0, 0.95, 0.75}{%
\draw [blue, ultra thick] (0,2) -- (4,2);
\filldraw[fill=yellow!20, fill opacity=\OpacitySetting] (1,0) rectangle (3,4) 
    node [above left, text opacity=1.0]  {opacity=\OpacitySetting};
share|improve this answer
Thank you... How can I do not show the edges of the rectangle? – SoftTimur Aug 15 '12 at 16:49
@SoftTimur \draw draws just the edge of the rectangle, \fill just fills the rectangle without drawing the edge, while \filldraw does both. In other words, replace \filldraw with \fill. – Torbjørn T. Aug 15 '12 at 16:57

Your Answer


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.