Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

\newcommand{\notes}[1]{
\begin{minipage}{0.974\linewidth}
\centering
\begin{tikzpicture}
\node [ draw,
    gray!20,
    rectangle,
    fill=gray!20,
    rounded corners,
    text badly centered,
    text width=\linewidth,
    minimum height=#1 mm
] (init) {};
\end{tikzpicture}
\end{minipage}
\par
}

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.

share|improve this question
    
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. –  user13596 Mar 5 '13 at 10:48
add comment

1 Answer

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

\documentclass{article}
\usepackage{tikz}
\usepackage{tikzpagenodes}
\usepackage{lipsum}

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

\begin{document}
\lipsum[1-2]
\vfillgrayrectangle
\lipsum[3]
\vfillgrayrectangle
\lipsum[5-8]
\vfillgrayrectangle
\lipsum[2]
\vfillgrayrectangle
\lipsum[4]
\vfillgrayrectangle
\end{document}
share|improve this answer
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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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