# How can I limit the maximum number of lines in a page?

My university's masters thesis template which I have to follow, limits the maximum number lines per page to 25 lines.

I used setspace package which is available in the revision of my question but it didn't help me. Also, I used the lines option of the geometry package as proposed in the answers but it does not set the line spacing. Instead it omits the content after the specified line number and consequently, the rest of the page will be remained. Here is the second code I used with geometry option.

\documentclass[a4paper,11pt,twoside,openany]{book}
\usepackage{lipsum}
\RequirePackage[top=35mm, outer=35mm, inner=25mm, lines=22]{geometry}
\begin{document}
\lipsum[1-10]
\end{document}


## 3 Answers

First, let us see how to show the edges of the margins (showframe option), the numbers of lines (with lineno package and \linenumbers command) and \the\textheightof the MWE:

\documentclass[11pt,a4paper,twoside,openany]{book}
\usepackage[lmargin=25mm,rmargin=35mm,tmargin=35mm, bmargin=35mm,showframe]{geometry}
\usepackage{lineno}
\usepackage{lipsum}
\begin{document}
\linenumbers
THE TEXT HEIGHT: \the\textheight\\

\lipsum[1-10]
\end{document}


There are 47 lines in roughly 646pt with the desired margins. The goal is obtain 22 lines without change the text height. Right?

Solution 1. Use the \setstretch{2.2} (need the setspace package)

\documentclass[11pt,a4paper,twoside,openany]{book}
\usepackage[lmargin=25mm,rmargin=35mm,tmargin=35mm, bmargin=35mm,showframe]{geometry}

\usepackage{setspace}
\setstretch{2.2}

\usepackage{lineno}
\usepackage{lipsum}
\begin{document}
\linenumbers
THE TEXT HEIGHT: \the\textheight\\

\lipsum[1-10]
\end{document}


Solution 2: set \baselineskip at 29pt in the body of the document

\documentclass[11pt,a4paper,twoside,openany]{book}
\usepackage[lmargin=25mm,rmargin=35mm,tmargin=35mm, bmargin=35mm,showframe]{geometry}

\usepackage{lineno}
\usepackage{lipsum}

\begin{document}

\baselineskip=29pt % not in the preamble

\linenumbers
THE TEXT HEIGHT: \the\textheight\\ %646pt

\lipsum[1-10]
\end{document}


Solution 3: fix \linespread to 2.2 in the preamble

\documentclass[11pt,a4paper,twoside,openany]{book}
\usepackage[lmargin=25mm,rmargin=35mm,tmargin=35mm, bmargin=35mm,showframe]{geometry}
\linespread{2.2}

\usepackage{lineno}
\usepackage{lipsum}
\begin{document}
\linenumbers
THE TEXT HEIGHT: \the\textheight\\

\lipsum[1-10]
\end{document}


In solution 1,2 and 3: the ouput is the same:

Solution 4. Use the grid package with the options lines and baseline. Only useful if you are a fan of the grid format and the package limitations are not a problem in your document.

\documentclass[11pt,a4paper,twoside,openany]{book}
\usepackage[lmargin=25mm,rmargin=35mm,tmargin=35mm, bmargin=35mm,showframe]{geometry}
\usepackage[baseline=29.35pt,lines=22]{grid}

\usepackage{lineno}
\usepackage{lipsum}
\begin{document}
\linenumbers
THE TEXT HEIGHT: \the\textheight\\

\lipsum[1-10]
\end{document}


Use lines option in geometry package. The following is taken from its documentation on page 16.

If you don't know how to display the documentation, type texdoc geometry on your terminal (Linux) or DOS prompt (MS Windows).

• It doesn't work when I define margins? \RequirePackage[top=35mm, bottom=25mm, outer=35mm, inner=25mm, lines=22]{geometry}  – Enthusiastic Engineer Oct 11 '14 at 17:36
• I am using bidi xelatex package. – Enthusiastic Engineer Oct 11 '14 at 17:37
• @EnthusiasticStudent - Note that the excerpted examples in this answer specify the options top (or tmargin) and lines but not the bottom margin as well. (If top and bottom are both specified, lines is calculated directly, and any lines option is irrelevant.) – Mico Oct 11 '14 at 17:57
• I tried this. The lines code does not change the vertical space between the lines. Instead it omits the lines after #22 and the remaining space is white. For instance, half of the page will be white! – Enthusiastic Engineer Oct 11 '14 at 20:08
• @EnthusiasticStudent: It is better if you add your current code to the bottom of your question so anybody here can use it to reproduce your problem. – kiss my armpit Oct 11 '14 at 20:23

You can do this with setspace and geometry but you must use the spacing command before loading geometry. This still has a rather large margin at the bottom so it is probably best to allow geometry to figure the top and bottom margin and just specify a ratio if you do it this way:

\documentclass[a4paper,11pt,twoside,openany]{book}
\usepackage{setspace}
\doublespacing
\RequirePackage[vmarginratio=1:2, outer=35mm, inner=25mm, lines=22]{geometry}
\usepackage{lipsum}
\begin{document}
\lipsum[1-10]
\end{document}


stdpage apparently lets you specify a standard number of lines per page and will space them out. However, unless you want your thesis to look as if typed on a typewriter, this is probably not a good option.