19

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?

  • I'm not sure at which moment you copied my code. Please make sure you have the one that is there now. The previous version had a small bug. – yo' Oct 30 '13 at 22:35
10

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
12

Two versions: \pageoflines{1cm} is without numbers; with \pageofnumberedlines you get tiny numbers in the margin.

\documentclass{article}

% to show the page frame
\usepackage{xcolor,showframe}
\renewcommand*\ShowFrameColor{\color{red}}
\renewcommand*\ShowFrameLinethickness{.2pt}
% don't show the margin par space (not needed for the macros)
\setlength{\marginparsep}{10cm}

% No numbers (easy)
\newcommand{\pageoflines}[1]{%
  \clearpage
  \begingroup\offinterlineskip
  \hrule height 0pt
  \vskip-\topskip
  \leaders\vbox to #1{\vfill\hbox to\hsize{\hrulefill}}\vfill
  \endgroup
  \clearpage}

% Numbers (a bit more difficult)
\newcommand{\pageofnumberedlines}[1]{%
  \clearpage
  \begingroup\offinterlineskip
  \count255=\vsize \dimen0=#1
  \divide\count255 by \dimen0
  \mathchardef\howmany=\count255
  \count255=0
  \loop\ifnum\count255<\howmany
    \advance\count255 by 1
    \hbox to\hsize{%
      \vrule height#1 width 0pt 
      \llap{\scriptsize\number\count255\space\space}%
      \hrulefill
    }
  \repeat
  \endgroup
  \clearpage
}

\begin{document}
\pageoflines{1cm}
\pageofnumberedlines{1cm}
\end{document}

enter image description here

  • Now some people just like to make others feel bad :-)....... Nice contribution. Elegant. – azetina Oct 30 '13 at 23:46
  • @azetina Sorry. ;-) – egreg Oct 30 '13 at 23:47
  • 1
    But don't worry, one day, one day I will learn more and with inspiration from all of you here in TX.SX I will be able to share more elaborate and concise contributions to the OP's. :-) – azetina Oct 30 '13 at 23:50
  • can you explain how the pageoflines section does looping? I don't understand. – Tim Mar 15 '17 at 18:37
  • 1
    @Tim The leaders here are vertical leaders: stack vertically copies of the \vbox containing a rule until filling the page (\vfill). – egreg Mar 16 '17 at 11:37
6

It is only a sketch. One can change margins, vertical skips, numbering, etc.

\documentclass{article}


\def\lrule{\rule{0.95\textwidth}{0.2pt}}
\newcount\linecount
\linecount0
\def\Lrule{\advance\linecount by1\null\makebox[0.05\textwidth]{\the\linecount} \hfill\lrule\endgraf}

\pagestyle{empty}
\begin{document}

\Lrule\Lrule\Lrule\Lrule\Lrule\Lrule\Lrule\Lrule\Lrule\Lrule
\Lrule\Lrule\Lrule\Lrule\Lrule\Lrule\Lrule\Lrule\Lrule\Lrule
\Lrule\Lrule\Lrule\Lrule\Lrule\Lrule\Lrule\Lrule\Lrule\Lrule

\end{document}

enter image description here

5

Just another version using the multido package:

enter image description here

\documentclass{article}
\usepackage{multido}
\newcounter{linenum}
\renewcommand{\thelinenum}{\arabic{linenum}}
\newcommand{\numline}[1]{%
    \multido{}{#1}{%
    \refstepcounter{linenum}%
    \leavevmode\llap{\thelinenum~}\hrulefill\\[1ex]%
    }
}
\setlength{\parindent}{0pt}
\begin{document}
\numline{50}
\end{document}
  • well, I think you can use dozens of packages to create multiple lines. The real problem is determining how many lines you want ;) – yo' Oct 30 '13 at 23:32
  • @tohecz I suppose so.... – azetina Oct 30 '13 at 23:42
5

A simple customizable approach with \foreach to print simple \hrules:

\documentclass[a4paper]{article}
\usepackage[margin=2.5cm]{geometry}
\usepackage{pgffor}
\pagestyle{empty}
\begin{document}
\foreach \lineas in {1, 2, ...,21}{~\hrule~\\[2em]}% 
\end{document}

MWE

Or enumerated dotted lines:

\documentclass[a4paper]{article}
\usepackage[margin=2.5cm]{geometry}
\usepackage{pgffor}
\pagestyle{empty}
\begin{document}
\begin{enumerate}
\itemsep1.1em
\foreach \puntos in {1, 2, ...,24}{\item \dotfill}%
\end{enumerate}
\end{document}

MWE

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.