I'd like to create a page in my LaTeX document that just consists of lines. It should look like this:
Additionally, I want the lines numbered. I have no idea where to start. Are there any hints?
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It only takes a minute to sign up.
Sign up to join this communityI'd like to create a page in my LaTeX document that just consists of lines. It should look like this:
Additionally, I want the lines numbered. I have no idea where to start. Are there any hints?
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\linespagelength
to the \textwidth
and we remove the height #2
from it at each step#1
and the line number in a \vbox
of the height #2
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}
\vbox
containing a rule until filling the page (\vfill
).
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}
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}
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}
Just another version using the multido
package:
\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}