# [Tex/LaTex] How to draw a filled rectangle without a border using TikZ

tikz-pgf

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?

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).