I am positioning an image on the top of the page of chapter openings. The image should fill all the page width. The code below is working fine with LuaLaTeX, but when I run it with XeLaTeX (it should be run 3 times to get proper positioning) the image is moved to the horizontal centre of the page.
For other reasons, I have to run the document with XeLaTeX. What should I change in the code to run with XeLaTeX and obtain the output shown with LuaLaTeX?
EDIT Changed to use an example image. The header will change to respect the images show; but the effect of useing XeLaTeX is the same.
\documentclass{book}
%%% Include image in chapter opening
\RequirePackage{tikzpagenodes}
%%% fill rectangle with image uisng tcolorbox
%%% https://tex.stackexchange.com/a/219424/2483
\RequirePackage{tcolorbox}
\tcbuselibrary{skins}
\usetikzlibrary{calc}
\usetikzlibrary{fadings}
%%% For the background
%%% https://tex.stackexchange.com/a/86702/2483
\usepackage[pages=some]{background}
\newlength{\bleendlength}
\setlength{\bleendlength}{5mm}
\newcommand{\chapimage}[1]{%
\backgroundsetup{scale=1,placement=top,contents={
\tikz[remember picture,overlay] {%
\path[fill overzoom image=example-image-a, fill image opacity=1, path fading=east, fading angle=-30]
($(current page.north west)+(-\bleendlength, \bleendlength)$)
rectangle
($(current page.north east)+(\bleendlength, -6cm)$);
}
}
}
}
\begin{document}
\chapter{My first chapter}
\label{cha:my-first-chapter}
\chapimage{}\BgThispage
\end{document}


eso-pic. But know I have a similar error when I introduced thecroppackage. See my question link – TeXtnik Aug 18 '20 at 14:45