LaTeX forum ⇒ Graphics, Figures & TablestikZ | 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

Postby psionman » Tue Mar 06, 2012 9:12 am

I would like to draw a black rectangle filled in light gray
  1. \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?

User avatar
localghost
Site Moderator
Posts: 9204
Joined: Fri Feb 02, 2007 12:06 pm

Postby localghost » Tue Mar 06, 2012 10:17 am

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.
  1. \filldraw[draw=black,fill=lightgray] (1.5,4) rectangle (3.5,4.5);



Thorsten
LaTeX Community Moderator
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes


¹ 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

Postby psionman » Tue Mar 06, 2012 10:22 am

Thanks, filldraw seems to give the same effect as fill. I still don't get the black outline

User avatar
localghost
Site Moderator
Posts: 9204
Joined: Fri Feb 02, 2007 12:06 pm

Postby localghost » Tue Mar 06, 2012 10:26 am

Works fine for me. For more specific help see the links in my last reply.
LaTeX Community Moderator
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes


¹ 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

Postby psionman » Wed Mar 07, 2012 9:32 pm

Here is a simple document. When I compile it I get no black outline, only the gray rectangle.
  1. \documentclass[11pt]{article}
  2. \usepackage{tikz}
  3.  
  4. \begin{document}
  5. \begin{figure}[!ht]
  6. \begin {center}
  7. \begin{tikzpicture}
  8. \filldraw[draw=black,color=lightgray] (1,1) rectangle (3,3);
  9. \end{tikzpicture}
  10. \end{center}
  11. \end{figure}
  12. \end{document}

User avatar
localghost
Site Moderator
Posts: 9204
Joined: Fri Feb 02, 2007 12:06 pm

Postby localghost » Wed Mar 07, 2012 9:39 pm

You should read more carefully what people write to you. As I suggested earlier, you need another syntax.
  1. \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
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes


¹ 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

Postby psionman » Thu Mar 08, 2012 8:30 am

Thank you localghost

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


Return to “Graphics, Figures & Tables”

Who is online

Users browsing this forum: No registered users and 9 guests