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.

I'm trying to use the afterpage package to automatically insert text at the top of each page (please see my other question Section reminders at the top of each page?) but I'm having trouble.

Sometimes I get unlucky and a list environment starts just before a page break. The first \item doesn't appear until just after the page break. When this happens, LaTeX gives me a "missing \item" error message because \afterpage is inserting text right after the start of a list environment.

Here is a minimal example that emulates the problem I'm seeing:

\documentclass{article}
\usepackage{afterpage}
\begin{document}
\afterpage{afterpage-stuff}
before list
\begin{itemize}
\clearpage
\item an item
\end{itemize}
after list
\end{document}

If I remove that \clearpage, then everything works as expected.

Is there something I can pass to \afterpage that would temporarily reset TeX's state so that I can safely insert some vertical mode material (e.g., a minipage) at the top of the next page without interfering with environments that span pages?

share|improve this question

1 Answer 1

up vote 6 down vote accepted
\afterpage{\hbox{afterpage-stuff}}

gets rid of the error but it depends what you want the spacing to be....

This does allow vertical material for example

\afterpage{\hbox{%
\parbox{\textwidth}{afterpage-stuff

some more}}}
share|improve this answer
    
that worked beautifully, thank you! –  Richard Hansen Apr 8 '12 at 23:54

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.