Page LayoutControlling the Formatting of the last Page

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
adfohs
Posts: 2
Joined: Sun Jan 29, 2012 9:04 pm

Controlling the Formatting of the last Page

Post by adfohs »

Hello,

I have searched the forums for an answer to my problem, and I haven't come across a solution as of yet, so I apologize in advance if this matter has been resolved.

I am wanting to control the formatting of the last page of a document whose number of pages will be unknown. In particular, I want to change the margins and background image of the final page. Both I know how to control when being applied to the entire document, but I want to be able to redefine each.

Is there a way to do this? Any help anyone can offer is appreciated.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Frits
Posts: 169
Joined: Wed Feb 02, 2011 6:02 pm

Controlling the Formatting of the last Page

Post by Frits »

Create a separate .tex file, let's call it last.tex, in which the formatting of the final page is done. Then, in you main document use the \AtEndDocument{} macro, e.g.:

Code: Select all

\documentclass{article}
\AtEndDocument{\include{last}}
\begin{document}
First page
\end{document}
howtoTeX.com - Your LaTeX resource site (Tips, Tricks, Templates and more!)
Follow howtoTeX on twitter
adfohs
Posts: 2
Joined: Sun Jan 29, 2012 9:04 pm

Controlling the Formatting of the last Page

Post by adfohs »

Hey Frits,

Thanks for the response. I've tried what you've suggested, but it doesn't seem to be working. Using the concept of the \AtEndDocument command, here is the basic idea of what I'm trying to accomplish:

Code: Select all

\documentclass{article}
\usepackage{wallpaper}
\usepackage{geometry}

\AtEndDocument{
\ClearWallPaper\CenterWallPaper{1}{Last_Page_Background_Image}\newgeometry{Final_Page_Margins}
}

\begin{document}
\newgeometry{Initial margins}
\CenterWallPaper{1}{Background_Image}

Code...

\end{document}
Ideally, the code would build the document with a different set of margins for the last page and a different background image.

Any thoughts on why this isn't working?
Post Reply