# 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? Nov 13, 2012 at 8:34
• @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, 2012 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]. Nov 13, 2012 at 8:45
• @Tobi, I will turn this into an answer, I just wanted to make sure that I add correctly understood the question. Nov 13, 2012 at 9:04
• @PeterGrill Thanks! That works alright as well. Nov 13, 2012 at 9:32

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. Nov 13, 2012 at 10:02
• You are right, it is not necessary (forgot to suppress it after copy-pasting) Nov 13, 2012 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, 2012 at 11:21
• @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 Feb 19, 2015 at 12:49
• @percusse: Yes, you are right I was confusing the two but I do not like this notation neither... ;) Feb 19, 2015 at 18:55

To avoid some confusion from the selected answer, another option is to use path

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