# Write into bottom margin rather than break page

I have a document that is automatically generated, and I would like the last bit that always gets put onto the end to simply ignore the bottom margin.

In other words, I want my file to compile normally, unless this last bit would cross a page barrier. If that is the case, I would like to effectively extend the margin of the last page so as to avoid that last page break.

One possible solution would be to simply change the bottom margin of the last page only. But I can not figure out how to do that.

EDIT: There is nothing in the bottom margin. Also, there are multiple versions of this process, and in each version the last bit is a little different. It is usually something like:

Sincerely,

<name>

<company position>

• Do you have content in the bottom margin (like the page number and or a rule across the footer)? Would it be possible to disclose "this last bit"? – Werner Aug 29 '16 at 23:55
• @Werner I added the answers to those questions in an edit. – Kyle Aug 30 '16 at 0:20
• Is this bottom part added in the automated process as text just before \end{document}? Can it be modified to form part of a macro, say, \endgreeting that is placed just before \end{document}? The reason I'm asking this is because one could capture this final content and work with it when that part is reached within the compilation process. If there's no handle on it, one may have very little option but to always extend the last page to larger-than-normal \textheight. – Werner Aug 30 '16 at 0:24
• @Werner, I could use a macro, but I am unsure what you mean by "capture" it. I don't know much latex, the document is automatically generated in a separate programming language. Also, how would one change \textheight just for the last page? – Kyle Aug 30 '16 at 0:33
• @StevenB.Segletes Yes, but it will start a new page. – cfr Aug 30 '16 at 2:52

Here's an example of \enlargethispage{}, as employed at Change \textwidth and \textheight in mid-environment. Note that I couple it with \thispagestyle{empty}, or else the extension overwrites the page number.

\documentclass{article}
\usepackage{lipsum}
\begin{document}
\lipsum[2-17]\enlargethispage{1in}\thispagestyle{empty}
\lipsum[18]
\end{document}


• You might want to omit the empty page. We know there's nothing in the bottom margin, but there might be stuff in the top one. – cfr Aug 30 '16 at 3:05
• @cfr There is no empty page. However, I displayed pages 2 and 3 adjacently in order to emphasize the effect of the final-page extension. – Steven B. Segletes Aug 30 '16 at 3:10
• I meant that \pagestyle{empty} will destroy any header and is not needed if there is nothing in the bottom margin, as stated in the question. – cfr Aug 30 '16 at 3:15
• @cfr I see. I used \thispagestyle, as opposed to \pagestyle, but the point is, I guess, the same. I'm not sure how to conditionally remove the page number, based on the final page length that actually presents itself. – Steven B. Segletes Aug 30 '16 at 3:17
• A variation of this worked perfect for me. I just put the \enlargethispage command in my \sig command which I used via \AtEndDocument. I just made sure I added enough to the bottom margin to fit the entire signature, by finding the minimum body size inducing a new page and verifying that the last line of the body landed on that new page. – Kyle Aug 30 '16 at 19:25

I'd use \AtEndDocument to force the extra text on to the last page, something like

\documentclass{article}

\newcounter{z}

\AtEndDocument{\par\enlargethispage{\textheight}%
something

thanks

signed: The Author}
\begin{document}

\def\z{\stepcounter{z}\roman{z}, \ifnum\value{z}<1400 \expandafter\z\fi}
\z
\end{document}

• +1 This looks like a viable alternative, but a different approach already worked out. – Kyle Aug 30 '16 at 19:28