Table to fill page with x number of rows

I borrowed some code from exam.cls and slightly modified it to define a \myruledpage command with two mandatory arguments; the first one gives the length of the first column of rules, and the second one controls the separation between rules; a simple example:

\documentclass{article}
\usepackage[paperheight=10cm]{geometry}% just for the example
\makeatletter
% Code taken from exam.cls and modified
\newlength\linefillheight
\newlength\linefillthickness
\setlength\linefillheight{.25in}
\setlength\linefillthickness{0.1pt}

\newcommand\linefill[1]{\leavevmode
    \rule{#1}{\linefillthickness}\ \leaders\hrule height \linefillthickness \hfill\kern\z@}

\newcommand\fillwithlines[2]{%
  \begingroup
  \ifhmode
    \par
  \fi
  \hrule height \z@
  \nobreak
  \setbox0=\hbox to \hsize{\hskip \@totalleftmargin
          \vrule height \linefillheight depth \z@ width \z@
          \linefill{#2}}%
  % We use \cleaders (rather than \leaders) so that a given
  % vertical space will always produce the same number of lines
  % no matter where on the page it happens to start:
  \cleaders \copy0 \vskip #1 \hbox{}%
  \endgroup
}
\makeatother

\newcommand\myruledpage[2]{%
  \setlength\linefillheight{#2}
  \fillwithlines{\stretch{1}}{#1}
\newpage}

\begin{document}

\myruledpage{3cm}{1cm}
\myruledpage{5cm}{10pt}
\myruledpage{.5\textwidth}{4pt}

\end{document}

enter image description here

Tags:

Tables