## LaTeX forum ⇒ Graphics, Figures & Tables ⇒ tikZ | Filled Rectangle with Border Topic is solved

Information and discussion about graphics, figures & tables in LaTeX documents.
psionman
Posts: 30
Joined: Thu Nov 10, 2011 3:33 pm

### tikZ | Filled Rectangle with Border

I would like to draw a black rectangle filled in light gray
\fill[draw=black,color=lightgray] (1.5,4) rectangle (3.5,4.5);

This fills it, but doesn't draw the outline.

What should I do?

localghost
Site Moderator
Posts: 9204
Joined: Fri Feb 02, 2007 12:06 pm
Please get used to always providing a minimal example to give an adequate problem description.
psionman wrote:[…] What should I do?

Read the pgf/tikZ user guide, which suggests another approach.
\filldraw[draw=black,fill=lightgray] (1.5,4) rectangle (3.5,4.5);

Thorsten
LaTeX Community Moderator

¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1

psionman
Posts: 30
Joined: Thu Nov 10, 2011 3:33 pm
Thanks, filldraw seems to give the same effect as fill. I still don't get the black outline

localghost
Site Moderator
Posts: 9204
Joined: Fri Feb 02, 2007 12:06 pm
Works fine for me. For more specific help see the links in my last reply.
LaTeX Community Moderator

¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1

psionman
Posts: 30
Joined: Thu Nov 10, 2011 3:33 pm
Here is a simple document. When I compile it I get no black outline, only the gray rectangle.
\documentclass[11pt]{article}\usepackage{tikz} \begin{document}   \begin{figure}[!ht]     \begin {center}       \begin{tikzpicture}         \filldraw[draw=black,color=lightgray] (1,1) rectangle (3,3);       \end{tikzpicture}     \end{center}   \end{figure}\end{document}

localghost
Site Moderator
Posts: 9204
Joined: Fri Feb 02, 2007 12:06 pm
You should read more carefully what people write to you. As I suggested earlier, you need another syntax.
\filldraw[draw=black,fill=lightgray] (1.5,4) rectangle (3.5,4.5);

Pay special attention to the options and compare with your version.

And by the way, you should not use the center environment here due to unwanted vertical space. Simply replace by the \centering command.
LaTeX Community Moderator

¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1

psionman
Posts: 30
Joined: Thu Nov 10, 2011 3:33 pm
Thank you localghost

I apologise for causing your ire; I really did not see the difference. I do now and appreciate your help