20

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?

1
  • 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, 2013 at 22:35

5 Answers 5

11

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
14

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

7
  • Now some people just like to make others feel bad :-)....... Nice contribution. Elegant.
    – azetina
    Oct 30, 2013 at 23:46
  • @azetina Sorry. ;-)
    – egreg
    Oct 30, 2013 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, 2013 at 23:50
  • can you explain how the pageoflines section does looping? I don't understand.
    – Tim
    Mar 15, 2017 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, 2017 at 11:37
8

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

2
  • How do i remove the numbers Feb 6 at 18:13
  • 2
    Change \item by \item[]
    – Fran
    Feb 6 at 21:07
7

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

7

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}
2
  • 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, 2013 at 23:32
  • @tohecz I suppose so....
    – azetina
    Oct 30, 2013 at 23:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .