4

Similar Question #1: How do I ask LaTeX to exactly fill up a page?

Similar Question #2: Fill up a page by equations, and then switch to onecolumn

I need to create a number of pages that should be one page in length with the same format. The format is one column at the top of the page followed by two columns to the bottom of the page. Each page will contain different wording and pictures.

I have looked at How do I ask LaTeX to exactly fill up a page? and think it is an elegant way to make the text fit to one page. However, I have not been able to use the same type of technique with two columns.

Here is the simplest example of the page being filled without columns:

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

\begin{document}

\addtolength{\baselineskip}{\fill}

\kant*[1]

\kant[2-3]

\end{document}

Simple Example of Page Being Filled w/out Columns

If I add columns then the page fills only by expanding the first paragraph and not the paragraphs in the columns.

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

\begin{document}

\addtolength{\baselineskip}{\fill}

\kant*[1]

\begin{multicols}{2}
\kant[2-3]
\end{multicols}

\end{document}

Example of Page Being Filled w/ Columns

It is possible that Fill up a page by equations, and then switch to onecolumn has the solution to my issue. However, my understanding of LaTex at this moment is not sufficient to comprehend whether or not a solution exists there.

I have played with numerous variations of the code below, but could not get it working on columns:

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

I would deeply appreciate any help in getting the text in the columns along with the other text to expand so that the page is nicely filled.

  • For the fill in \baselineskip, do you only want the multicol environment spaced out, or do you want both one and two-column regions equally spaced? I believe the former is easier to achieve than the latter. – Karl Hagen Feb 2 at 23:43
2

The reason it won't fill to the end of the page is that multicol calculates the necessary height without the extra fill when balancing the columns and outputs those columns to that height, so there's no extra space to fill.

This solution patches multicol\s balancing routine to force the column height, by default, to fill all the remaining room in on the page. I've not tested this with edge cases, so I don't know how robust it will prove. One drawback to this approach is that you won't see any fill in the \baselineskip of the one-column paragraph above, since the 2-column section gobbles all the remaining space.

As a manual work-around for that, I also added an optional parameter to let you explicitly specify the space for the column, but you'll no longer get it going to the bottom of the text area unless you tweak it precisely. Also, if you uncomment the commented \addtolength command, the bottom of the multicols columns will be pushed slightly below the bottom of the text area.

\documentclass{article}
\usepackage[pass,showframe]{geometry}
\usepackage{kantlipsum}
\usepackage{multicol}
\usepackage{xparse,xpatch}

\makeatletter

\newlength{\fillcol@height}
\let\fill@columns\balance@columns

\xpatchcmd{\fill@columns}{\vfuzz\z@
  \setbox\count@\vbox to\dimen@}
{\vfuzz\z@
  \ifdim\fillcol@height>\z@ \else
    \fillcol@height\@colroom
  \fi
  \setbox\count@\vbox to\fillcol@height}{}{}

\NewDocumentEnvironment{fillcols}{m o}{
  \IfValueT{#2}{\setlength{\fillcol@height}{#2}}
  \renewcommand{\balance@columns}{\fill@columns}
  \begin{multicols}{#1}
  \addtolength{\baselineskip}{\fill}
}{
  \end{multicols}
}
\makeatother

\begin{document}
%\addtolength{\baselineskip}{\fill}

\kant*[1]

\begin{fillcols}{2}
\kant[2-3]
\end{fillcols}

\end{document}

Result:

enter image description here

  • Karl, thank you so much for this solution and explanation. Both are greatly appreciated. – Paul Feb 3 at 22:25

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.