Use pdfpages with pagecolor using XeTeX

pagecolorpdfpagesxetex

I am writing my Master's thesis and I have a LaTeX template for that. I'm using XeTeX compiler. When I try to include a PDF with pdfpages, I get blank pages. I'm aware of the issue with pagecolor (as described in the package's documentation section 2.5), which the template uses in a few places. However, the fix of putting the first \pagecolor command before \usepackage{pdfpages} does not seem to work for me. The minimal extract from the code looks like this:

Preamble.tex

\usepackage{xcolor}
\pagecolor{white}  
\usepackage{pdfpages}

main.tex

\RequirePackage[2020-02-02]{latexrelease} % Quick fix for https://tex.stackexchange.com/questions/581907/extra-endgroup-error
\documentclass[a4paper,twoside,11pt]{report} %openright
\input{Setup/Statics.tex}
\input{Setup/Preamble.tex}
\input{Setup/Settings.tex}

\begin{document}

\pagenumbering{roman}
\input{Frontmatter/Frontpage.tex}
\pagecolor{white}
\newgeometry{top=2.81cm, bottom=2.75cm, outer=2.5cm, inner=3.5cm}
\pagestyle{empty}
\cleardoublepage 
\input{Frontmatter/Copyright.tex}
\clearpage 
\pagestyle{main}
\input{Frontmatter/Approval.tex}
\clearpage 
\input{Frontmatter/Abstract.tex}
\clearpage 
\input{Frontmatter/Acknowledgements.tex}
\cleardoublepage 
\tableofcontents
\cleardoublepage 

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\pagenumbering{arabic}
\input{Chapters/01_Introduction.tex}
\cleardoublepage 
\input{Chapters/02_Methods.tex}
\cleardoublepage 
\input{Chapters/03_Results.tex}
\cleardoublepage 
\input{Chapters/04_Discussion.tex}
\cleardoublepage 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\printbibliography[heading=bibintoc,title={Bibliography}]
\cleardoublepage 
\appendix
\includepdf[pages=-]{Backmatter/Graphics_Engines_for_Mixed_Reality.pdf}
\input{Backmatter/Appendix.tex}
\cleartoleftpage
\input{Backmatter/Backpage.tex}

\end{document}

I have seen this similar question, but as mentioned, the fix from the documentation does not work for me, and the \nopagecolor command is not recognized (apparently it's not available on XeTeX).

What am I doing wrong here?

Best Answer

After some debugging I believe I found the reason for this issue:

  1. On 2020/10/01 LaTeX was released with a new hook management system. See https://www.latex-project.org/news/latex2e-news/ltnews32.pdf. Concerning the issue you are reporting, the relevant hooks are shipout/background and shipout/foreground.

  2. On 2020/10/14 eso-pic.sty was updated to be compliant with LaTeX's new hook management system. Since then eso-pic explicitely requests \NeedsTeXFormat{LaTeX2e}[2020-10-01}. It's not working without LaTeX's new hook management any more.

  3. Pdfpages relies on eso-pic. Internally pdfpages forwards all \includegraphics commands to eso-pic, and eso-pic stuffs them into LaTeX's new hooks. Therefore you cannot use pdfpages with a LaTeX release early than 2020/10/01 any more.

  4. But you are explicitely requesting an early LaTeX release with \RequirePackage[2020/02/02]{latexrelease}. And this is the problem.

  5. For all of you who are reading the log-files more carefully -- well, I didn't, grmpf -- it was all there:

LaTeX Warning: You have requested release `2020-10-01' of LaTeX,
               but only release `2020/02/02' is available.