Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I understand that I can control interline spacing in LaTeX in a number of ways. The commands like \baselineskip, \baselinestretch, \linespread come in handy in controlling the interline spacing. Each has its own speciality and circumstances of usage, as we can find in these discussions (A, B, C).

If want to go for a ready made solution for controlling line spacing, packages like setspace come in quite handy (built-in commands like \onehalfspacing or \setstretch for more finer controls).

Anyway, my problem is a bit different. I have some text (both in paragraph and list mode) which I want to fill up exactly one page. To complicate the scenario, it may even contain equations and graphics. (Let us leave aside floats.)

If I want to solve the problem statically, all I will have to is to play with some value of \baselineskip (or \setstretch) until satisfied. While this works good for most of the cases, I will have to go through the process again when I want to delete or add some texts.

Would it be possible to have a dynamic value for \baselineskip or \setstretch so that my text always fills up one page? (Definitely within reasonable limits.)

Another idea will be to use a number of \vfills between some pieces of texts. But I think that this technique is usable for cover pages only.

I am not putting here an MWE. I think that one is not applicable.


The problem is not a theoretical one, I am preparing some kind of handout which I want to fill-up exactly one page.

share|improve this question
    
Do you want to adjust the line spacing within paragraphs? Or will adjusting space between paragraphs, and between text and equations etc. be enough? –  Ian Thompson Nov 29 '13 at 12:49
    
@IanThompson Adjusting space only between paragraphs (and text and equations) may produce disproportionate results. I am looking for something which adjusts spaces all over the page, you know what I mean. –  Masroor Nov 29 '13 at 12:51
1  
Please, in real document, adjust the inter-line space as little as possible, if even. There're people who seriously hate it. I have to claim that I do it myself, because I'm too lazy dealing with underfull pages by <3pt or so. –  tohecz Nov 29 '13 at 13:29
    
Is it an option to adjust the margins instead? E.g. you could automatically choose margins that precisely center your material on the page, with the dimensions of the text block determined by its length. (The TeXbook has several sample macros in this spirit, if I recall correctly.) –  alexis Nov 29 '13 at 21:26
1  
in addition to what's been suggested, if you always have exactly one page, and the amount of text decreases, you might want to consider using a larger type size so that the blank background doesn't overwhelm the type. but i can't think of a way to do that automatically. –  barbara beeton Nov 29 '13 at 22:21

4 Answers 4

up vote 19 down vote accepted

You can add stretchability to \baselineskip:

\documentclass{article}
\usepackage[pass,showframe]{geometry} % just to show the page is filled up
\usepackage{kantlipsum}

\newcommand{\addstretch}[1]{\addtolength{#1}{\fill}}

\flushbottom

\begin{document}

\addstretch{\baselineskip}
\addstretch{\abovedisplayskip}
\addstretch{\abovedisplayshortskip}
\addstretch{\belowdisplayskip}
\addstretch{\belowdisplayshortskip}
\setlength{\parskip}{0pt}

\kant*[1]
\begin{equation}
E=mc^2
\end{equation}
\kant[2-3]

\newpage

\kant*[1]
\begin{equation}
E=mc^2
\end{equation}
\kant[2]

\newpage

\end{document}

Using \fill overrides the \vfil inserted by \newpage.

enter image description here

It's easy to make a onepage environment:

\newenvironment{onepage}
  {\newpage\flushbottom
   \addstretch{\baselineskip}
   \addstretch{\abovedisplayskip}
   \addstretch{\abovedisplayshortskip}
   \addstretch{\belowdisplayskip}
   \addstretch{\belowdisplayshortskip}
   \setlength{\parskip}{0pt}}
  {\newpage}

Here's the complete code with the environment:

\documentclass{article}
\usepackage[pass,showframe]{geometry} % just to show the page is filled up
\usepackage{kantlipsum}

\newcommand{\addstretch}[1]{\addtolength{#1}{\fill}}
\newenvironment{onepage}
  {\newpage\flushbottom
   \addstretch{\baselineskip}
   \addstretch{\abovedisplayskip}
   \addstretch{\abovedisplayshortskip}
   \addstretch{\belowdisplayskip}
   \addstretch{\belowdisplayshortskip}
   \setlength{\parskip}{0pt}}
  {\newpage}

\begin{document}

\begin{onepage}
\kant*[1]
\begin{equation}
E=mc^2
\end{equation}
\kant[2-3]
\end{onepage}

\begin{onepage}
\kant*[1]
\begin{equation}
E=mc^2
\end{equation}
\kant[2]
\end{onepage}

\end{document}
share|improve this answer
    
Works like a charm. Nothing to do with your solution, but your file as it is produces this error message, (/usr/share/texmf-texlive/tex/latex/expl3/l3file.sty) ! Undefined control sequence. <argument> \ExplFileName l.30 ...e}{\ExplFileVersion}{\ExplFileDescription}. Anything from my version of LaTeX? Tested with lipsum. It is like a new toy for a child to see how the spaces adjust. –  Masroor Nov 29 '13 at 14:21
    
@MMA Since kantlipsum uses expl3, the error message probably means you have to update your TeX distribution. –  egreg Nov 29 '13 at 14:23

Just hope @egreg never sees this result

\documentclass{article}

\def\a{one two three four five six}
\def\b{\a\a\a\a\a\par\a\a\a\a\a\a\a\a\a\a\a}

\flushbottom
\begin{document}
\setlength\baselineskip{\fill}
\setlength\lineskip{\fill}
\setlength\parskip{\fill}

\b\b

\end{document}
share|improve this answer
    
Are you sure you even need \flushbottom? raggedbottom only adds some fil which is infinitely smaller than your fill anyway ;-) –  Stephan Lehmke Nov 29 '13 at 13:15
1  
Well I started off timid (with finite stretch) but I got brave before posting:-) –  David Carlisle Nov 29 '13 at 13:16
    
@DavidCarlisle Spent some time watching (playing actually) how the space adjusts when I add or delete texts. What do you do when get two acceptable solutions? –  Masroor Nov 29 '13 at 14:18
3  
@MMA If you get two acceptable solutions, and one is mine, then the obvious course of action is surely to accept mine:-) –  David Carlisle Nov 29 '13 at 14:20
1  
@MMA oh no you gave it to egreg:( –  David Carlisle Dec 2 '13 at 9:54

Try this example:

\documentclass[a4paper]{article}

\usepackage{etoolbox,lipsum}

\patchcmd\newpage{\vfil}{}{}{}

\flushbottom

\begin{document}

\baselineskip \the\baselineskip plus .1pt


\lipsum[1]

\lipsum[2]

\end{document}

enter image description here

\flushbottom makes LaTeX fill the page to the bottom on a page break. The patch to \newpage is neccessary to make it work also for a one-page document.

The modification of \baselineskip is probably not as elegant as it could be and will vanish on font switches. You probably know more about modifying it properly than I do.

Note that \parskip has 1pt of stretchability, so interline space stretches 1/10 the amount of inter-paragraph space.

share|improve this answer
1  
only 1pt?, so timid:-) –  David Carlisle Nov 29 '13 at 13:12
    
@DavidCarlisle Not my decision, it's in the LaTeX sources. So I kept it for compatibility reasons ;-) –  Stephan Lehmke Nov 29 '13 at 13:14
    
@StephanLehmke Are not the inter-paragraph spaces a bit out of proportion? –  Masroor Nov 29 '13 at 14:08
    
Well of course this depends on the amount of material on the page. If you require the page to be filled up completely, the space has to go somewhere. Of course, if you are using equations and suchlike, there will be more "stretch points". For instance, \displayskip has 3pt of stretchability, so the space around equations will stretch three times as much as the inter-paragraph space. The plus .1pt component I put in \baselinestretch only fixes the relation of stretchability to 1:10. You get a different relation by using a different value. –  Stephan Lehmke Nov 29 '13 at 14:49
    
@MMA If you use \baselineskip \the\baselineskip plus .5pt the inter-paragraph space is "only" double the inter-line space. –  Stephan Lehmke Nov 29 '13 at 15:00

Making \baselineskip stretchable is overkill, and it is typographically poor practice unless you're only generating a single page. If you have multiple pages, a flexible baselineskip will change the amount of black on the page which looks unpleasant, even for small changes.

You can use \vfill in any context, but I would recommend using as light a touch as possible: \flushbottom will ensure bottom-aligned text, suppressing the \vfil that is otherwise inserted at the bottom of the page and leaving you free to use \vfil for your own vertical space (or to exercise finer control with expressions like 10pt plus 1fil).

I suggest you identify all places in your content where it's ok to add a bit of stretch, and arrange to have a \vfil in each one. That way the regular interlinear space (\baselineskip) can stay constant. Lists and the like already introduce stretchable space, but you may need to tweak that in order to get the whitespace to be evenly distributed.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.