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:



<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, 2016 at 23:55
  • @Werner I added the answers to those questions in an edit.
    – Kyle
    Aug 30, 2016 at 0:20
  • 1
    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, 2016 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, 2016 at 0:33
  • 1
    @StevenB.Segletes Yes, but it will start a new page.
    – cfr
    Aug 30, 2016 at 2:52

2 Answers 2


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.


enter image description here

  • 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, 2016 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. Aug 30, 2016 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, 2016 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. Aug 30, 2016 at 3:17
  • 1
    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, 2016 at 19:25

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

enter image description here





signed: The Author}

\def\z{\stepcounter{z}\roman{z}, \ifnum\value{z}<1400 \expandafter\z\fi}
  • +1 This looks like a viable alternative, but a different approach already worked out.
    – Kyle
    Aug 30, 2016 at 19:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .