Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

\AddEverypageHook works at the start of a page. How can I add a hook to the every last part of a page right before a pagebreak?

Essentially I want to watermark the pages BUT I want to do it after the page contents have been created but immediately before the pagebreak. The "watermark"(not a watermark but just similar concept) will depend on macro values set(like \thepage) so it can't happen at the very end of the document.

share|improve this question
    
Perhaps the turnthepage will be of interest. –  jon Jul 16 '12 at 0:43
add comment

2 Answers

Have you checked out Martin Schroder's everyshi package? Quoting from the introductory section of the package's user guide:

This package provides the hooks \EveryShipout and \AtNextShipout whose arguments are executed after the output routine has constructed \box255, and before \shipout is called.

An example application for this package would be a package for adding text to the bottom of each page. Such a package does exist: prelim2e.

Another application is a package for adding pictures to every page: esopic.

share|improve this answer
add comment

You could just use a footer to specify this content, which makes fancyhdr. The following MWE defines a page style mystyle that sets some text /stuff just outside the text block beyond the last line:

enter image description here

\documentclass{article}
\usepackage{fancyhdr}% http://ctan.org/pkg/fancyhdr
\usepackage{lipsum}% http://ctan.org/pkg/lipsum
\fancypagestyle{mystyle}{%
  \fancyhf{}% Clear header/footer
  \renewcommand{\headrulewidth}{0pt}% No header rule
  \renewcommand{\footrulewidth}{0pt}% No footer rule
  \fancyfoot[R]{\smash{\makebox[\linewidth][r]{\raisebox{\footskip}{\rlap{\hspace{2em}%
    /stuff
  }}}}}%
}
\AtEndDocument{\thispagestyle{plain}}% Last page should be plain
\pagestyle{plain}% Plain page style throughout
\begin{document}
\lipsum[1-15]
\pagestyle{mystyle}% Switch to mystyle page style
\lipsum[16-30]
\end{document}

mystyle is activated using \pagestyle{mystyle} and deactivated using a different page style. To remove mystyle from the last page, use a different page style \AtEndDocument.

If there's no unprocessed floats at the end of the document, this should be sufficient. Otherwise, one could use something like pageslts to access the "very last page." Additionally, the footer can be made conditional to only display content in certain locations.

The actual footer is set in a right-aligned \linewidth-width box, raised by \footskip to elevate it above the regular footer. Additionally, it's shifted 2em to the right, and then set with a right overlap to left-align it in the margin.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.