Stretching a framebox over the whole page
Update 2011/09/16
Herbert is right with his approach to use two nodes and v/hfill. Here my TikZ solution based on this idea:
\documentclass{scrartcl}
\usepackage{capt-of}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{lipsum}
\begin{document}
\lipsum[1]% dummy text
\par\noindent
\tikz[overlay,remember picture]\coordinate (image-start);
\par
\vfill
\null\hfill
\tikz [overlay,remember picture] \draw (0,0) rectangle ([yshift=\ht\strutbox-\fboxsep]image-start);
\newpage
\end{document}
You can use TikZ for this.
There is the special node current page
which gives you the corners of the current page as points of the compass. You can get the lower right corner of the textarea by subtracting the margins. This needs the remember picture
and overlay
option on the picture and also needs two compiler runs to produce the correct result.
Unfortunately TikZ doesn't provide a special node for the text area itself, but I found some code posted by Sven Köhler which defines such a node.
\documentclass{scrartcl}
\usepackage{tikz}
\usepackage{lipsum}
\newcommand{\currentsidemargin}{%
\ifodd\value{page}%
\oddsidemargin%
\else%
\evensidemargin%
\fi%
}
\begin{document}
\lipsum[1]% dummy text
\par\bigskip \noindent
Notes:\\
\begin{tikzpicture}[overlay,remember picture]
% Helper nodes
\path (current page.north west) ++(\hoffset, -\voffset)
node[anchor=north west, shape=rectangle, inner sep=0, minimum width=\paperwidth, minimum height=\paperheight]
(pagearea) {};
\path (pagearea.north west) ++(1in+\currentsidemargin,-1in-\topmargin-\headheight-\headsep)
node[anchor=north west, shape=rectangle, inner sep=0, minimum width=\textwidth, minimum height=\textheight]
(textarea) {};
% Framebox
\draw (0,0) rectangle (textarea.south east);
\end{tikzpicture}
\newpage
\end{document}
Stumbling across How to define a figure size so that it consumes the rest of a page?, I learned a much simpler answer to this problem, avoiding "big machinery" like TikZ or pstricks: the space remaining on the page can be calculated with the primitives \pagegoal
and \pagetotal
. Thus
\def\restofpage{\dimexpr\pagegoal-\pagetotal-\baselineskip\relax}
is the height of the remainder of the page. Therefore,
\documentclass[paper=a8]{scrartcl}
\def\restofpage{\dimexpr\pagegoal-\pagetotal-\baselineskip\relax}
\begin{document}
sometext
\medskip
\framebox[\textwidth]{\parbox{\textwidth}{somemoretext\par\vspace{\restofpage}}}
\end{document}
produces the desired output:
Note that \framebox
puts its argument in an \hbox
(cf. e.g. this answer) so the \parbox
is in fact necessary.
run it with xelatex
\documentclass{article}
\usepackage{pst-node}
\begin{document}
sometext
\rnode[lt]{A}{somemoretext}
\vfill
~\hfill\rnode[rb]{B}{~}
\psframe(A)(B)
\clearpage
foo
\end{document}