# How to draw a filled rectangle without a border using TikZ?

Method 1:

\draw [fill=orange] (0.1,0.1) rectangle (0.2,0.2);


For the line above, by default, the filled orange rectangle will have a black border.

Method 2:

\draw [fill=orange,orange] (0.1,0.1) rectangle (0.2,0.2);


With this line, the border color will be changed to orange and thus the entire rectangle will have one color.

Unfortunately I have figure with intricate overlaps of rectangles. The borders, even though they are the same color as the fill, have finite thickness and mess up the sketch. Is there a way to get rid of the border altogether?

-
What about using \fill instead of \draw? –  Corentin Nov 13 '12 at 8:34
Thanks! That works. –  Shashank Sawant Nov 13 '12 at 8:37
@Corentin: If you post this as an answer (maybe with an easy example) Shashank can accept it an this answer won’t be “unanswered” anymore … and it will bring reputations points for both of you. –  Tobi Nov 13 '12 at 8:40
@Corentin: I agree with Tobi as that is the answer. You could also add that one case use \draw [draw=none, fill=orange] option to eliminate the black border, or even \draw [draw=orange, fill=orange]. –  Peter Grill Nov 13 '12 at 8:45
@Tobi, I will turn this into an answer, I just wanted to make sure that I add correctly understood the question. –  Corentin Nov 13 '12 at 9:04

The border of the rectangle is drawn because you are using the \draw command, which, by definition, draws the specified path (here the rectangle). The fact that you are adding the option fill=orange just tells TikZ that in addition it should fill the path with orange. Replacing \draw with \fill will do what you are expecting.

\documentclass{article}
\usepackage{tikz}

\begin{document}

\tikz \fill [orange] (0.1,0.1) rectangle (0.2,0.2);

\end{document}


As noted in the comments, another option is to use \draw [fill=orange,draw=none]. This amounts to telling TikZ to draw the path with an invisible color and fill it with orange, hence the result is the same. As drawing the path with an invisible color is maybe a little strange, it is perhaps more natural to use instead the general \path [fill=orange]. Note that \draw is simply a shortcut for \path [draw] and in a similar manner, \fill is a shortcut for \path [fill]. Similarly, you have the command \filldraw which is an abbreviation for \path [fill,draw]. In full generality, colors to use for either filling or drawing can be specified by replacing fill or draw by fill=color or draw=color in the options.

All these commands are documented in section 15 of the TikZ manual (and especially 15.3 and 15.4), with details and examples (accessible by the command texdoc tikz in a shell or here).

-
With the \fill command I think you just need to specify the colour so the fill= is unnecessary. –  Loop Space Nov 13 '12 at 10:02
You are right, it is not necessary (forgot to suppress it after copy-pasting) –  Corentin Nov 13 '12 at 10:05
Another option is the general \path [fill=orange] … In my eyes it’s counterintuitive to use \draw and then don’t draw (draw=none) but fill. –  Tobi Nov 13 '12 at 11:21
@Tobi I agree, I will update my answer to reflect this better. –  Corentin Nov 13 '12 at 11:31
@strpeter Your reason to the edit is not correct. You are confusing with the command \tikzpicture. \tikz is as valid as the corresponding tikzpicture environment –  percusse Feb 19 at 12:49