[Tex/LaTex] Forcing a Document into a Single page

page-breaking

I've been using TeX for a while, so when I suggested my company compile its daily newsletter using LaTex, rather than an hour and a half of someone's time, I got tasked with actual implementation. I'm near done, but because the data is generated dynamically – I'm not sure exactly how much text is going to be generated an placed into each article. I've use \vspace{\fill} to strategically deal with an undersized newsletter – but I can't figure out what to do in the case of an oversized one.

Is there a way to force TeX to compile into a single page, every time? I mean, I'd rather (honest to god) just have the text cut off the way it does horizontally.

I found this this incredibly similar question, and tried everything listed there. I've looked into samepage, but that environment just breaks the page anyway after a while. Additionally, \parbox was suggested – but when I wrapped the whole document in that, an overfull box it just caused it to break the page before. needspace will do the same thing.

I've been developing this process over the last few days, periodically breaking to spend hours searching the Google Box or StackExchange for answers, to no avail. Anyone?

Best Answer

If you're happy just truncating the bottom of the content, then you can force into a minipage:

\documentclass{article}
\usepackage{lipsum}
\begin{document}
\begin{minipage}[t][0pt]{\linewidth}
\lipsum[1-100]
\end{minipage}
\end{document}

But notice how I set the height of the minipage to zero. This makes it stay on page one.

Is your company really going to be impressed with LaTeX if you truncate things?

Provided that you know your newsletter is never going to be longer than 2-3 pages. There is probably a way you work around this. I'm thinking that you don't set the height of the minipage, save its height to a minipage, the run latex again reading in the value of the minipage's height and set the height of the document's page to the same value. I'm not sure I know how to do such an elaborate work-around, but I'm sure if you post a question

How do I define the dimensions of a page to accommodate its contents: even if unusually large?

someone will come up with an interesting solution. Of course, such a solution only makes sense if the newsletter is something only posted electronically and not printed.

OR

If you know the contents are only be slightly larger than the page, you can use graphicx package and rescale the box so it does in fact fit on the page.

For example:

\documentclass{article}
\usepackage{graphicx}
\usepackage{calc}
%% for demo purposes only
\usepackage{showframe}
\usepackage{lipsum}
\begin{document}
\noindent\scalebox{.94}{%
\begin{minipage}[t]{1.06\linewidth}
\lipsum[1-6]
\end{minipage}}
\end{document}

This is a document for which \enlargethispage wouldn't suffice. But by selecting appropriate values for the scale factor and the \linewidth (I chose near reciprocals), you can get something fairly decent looking.

Related Question