I have to include page-specific content multiple times per page (DM codes to be specific) in a LaTeX document. To that end I use a combination of storebox and everypage such that content is typeset once and referenced multiple times in the resulting PDF:
\documentclass[a4paper]{article}
\usepackage[pagestyles,extramarks]{titlesec}
\usepackage{everypage}
\usepackage{storebox}
\AtBeginDocument{{}} % due to https://tex.stackexchange.com/a/141540
\newpagestyle{mypagestyle}{%
\sethead[%
][%
\usestorebox{\mybox}%
][%
]{%
}{%
\usestorebox{\mybox}%
}{%
}%
\setfoot[%
][%
\usestorebox{\mybox}%
][%
]{%
}{%
\usestorebox{\mybox}%
}{%
}%
}
\pagestyle{mypagestyle}
\AddEverypageHook{\storebox{\mybox}{some page-specific stuff repeated multiple times on that page}}
\begin{document}
Page 1
\clearpage
Page 2
\end{document}
This works fine for any version prior to 2020. However, texlive 2020 introduced native hooks, making the everypage package obsolete. Since that version, the approach above results in:
! Undefined control sequence.
<argument> \pdfrefxform \mybox
Using the new hooks directly, i.e., \AddToHook{shipout/before}{stuff}, gives the same error. Using xsavebox instead of storebox would work fine, but xsavebox is way slower such that it is not an alternative.
Does anyone has an idea how to make storebox work with texlive 2020?
\usepackage{everypage-1x}instead. The usedshipout/backgroundhook to emulateeverypageis too late for your code to have any effect (and is limited in a group scope). It would be the correct code for placing additional information on a page, but not for altering actual contents of the page box. – Skillmon Jan 17 '21 at 10:47\AtBeginDocument[storebox]{{}}to fix thestoreboxbug, instead of just doing\AtBeginDocument{{}}after loading the package. – Skillmon Jan 17 '21 at 10:51everypage-1xis discouraged. Is there an easy way to hook into early enough with the new hook mechanism? – moepi Jan 17 '21 at 11:16everypage-1xabove. If you want a working example withxsavebox, replacestoreboxby that (saveboxwas never mentioned by me here, although I know about the connection between both packages). Why I need aneverypagehook (or similar): it has to be done within apagestyle. I cannot fire that macros by hand on every page. Please consider my example code in my original question for reference. – moepi Jan 17 '21 at 13:22