I made a command that prints a gray rectangle in my document. I can use this command typing:

\notes{100}, where 100 is the vertical size of the box.

\node [ draw,
    rounded corners,
    text badly centered,
    text width=\linewidth,
    minimum height=#1 mm
] (init) {};

I'm looking for a solution that fills the page to the bottom, getting the size of the \vfill.

EDIT: obviously, I need a solution that doesn't need to use some value as parameter.

  • Do you want to fill the remainder of the page after the command with the gray rectangle or print the rectangle and fill all space that is left (with whitespace)? – Mythio Mar 5 '13 at 10:39
  • 1
    Hi user13596. A tip: If you indent lines by 4 spaces, then they're marked as a code sample. You can also highlight the code and click the "code" button ({}) or select your code and hit Ctrl+K. – Claudio Fiandrino Mar 5 '13 at 10:40
  • I want to make the gray rectangle expands until the end of space. I want no blank spaces after the command. – Fabricio Pio Mar 5 '13 at 10:48

Here is a solution (using the tikzpagenodes package and the overlay and remember picture options). Note: Several compilation are needed!


  \begin{tikzpicture}[remember picture,overlay]
    \fill[gray!20,rounded corners]
    (0,0) rectangle (current page text area.south east);

  • 1
    I was about to answer exactly the same, but without [yshift=1mm]. Why is this needed? – JLDiaz Mar 5 '13 at 11:04
  • @JLDiaz This is an oversight... – Paul Gaborit Mar 5 '13 at 12:30
  • I’d add a \par to the beginning of the definition, so that \vfillgrayrectangle can be used directly following some text. (\lipsum inserts a \par automatically. Try it with \lipsum* instead.) – Qrrbrbirlbel Mar 5 '13 at 15:19
  • @Qrrbrbirlbel It's a good advice. Thanks. I edited my answer. – Paul Gaborit Mar 5 '13 at 15:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.