[Tex/LaTex] How to create a lined page with line numbers

line-numbering

I'd like to create a page in my LaTeX document that just consists of lines. It should look like this:

enter image description here

Additionally, I want the lines numbered. I have no idea where to start. Are there any hints?

Best Answer

This seems to work very well:

\documentclass{article}

\newlength{\linespagelength}
\newcounter{linespage}
\newcommand\linespage[2][0.4pt]{
  \newpage
  \begingroup
  \baselineskip0pt
  \setlength{\linespagelength}{\textheight}
  \setcounter{linespage}{0}
  \loop
  \addtolength{\linespagelength}{-#2}
  \stepcounter{linespage}
  \ifdim\linespagelength>0pt
  \vbox to #2{\vss\noindent\raise\dimexpr#1+1pt\relax\hbox to 0pt{%
    \arabic{linespage}
  \hss}\rule{\linewidth}{#1}}\nointerlineskip
  \repeat
  \endgroup
  \newpage
}

\usepackage{lipsum}

\begin{document}

\lipsum

\linespage[1pt]{1cm}

\lipsum

\end{document}

Tools:

  • \loop ... \if ... \repeat construct
  • we set \linespagelength to the \textwidth and we remove the height #2 from it at each step
  • we set the line of width #1 and the line number in a \vbox of the height #2