Différentes sorties xelatex et lualatex (tikzpagenodes, tcolorbox et packages d'arrière-plan impliqués)
Je positionne une image en haut de la page des ouvertures de chapitre. L'image doit remplir toute la largeur de la page. Le code ci-dessous fonctionne bien avec LuaLaTeX
, mais lorsque je l'exécute avec XeLaTeX
(il doit être exécuté 3 fois pour obtenir un positionnement correct), l'image est déplacée vers le centre horizontal de la page. Pour d'autres raisons, je dois exécuter le document avec XeLaTeX
. Que dois-je changer dans le code pour exécuter avec XeLaTeX
et obtenir la sortie affichée avec LuaLaTeX
?
EDIT Changé pour utiliser un exemple d'image. L'en-tête changera pour respecter le spectacle des images ; mais l'effet de l'utilisation XeLaTeX
est le même.
\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}
Corriger la sortie avec LuaLaTeX
:

Sortie incorrecte avec XeLaTeX
:

Réponses
La valeur passée à background
l'option contents
de (stockée dans \Background@Contents
) est déjà composée dans un fichier tikzpicture
. Et l'imbrication tikzpicture
est un comportement indéfini. Voir l'implémentation de \bg@material
dans la background
v2.1, 2014/03/04 :
\newcommand\bg@material{%
\begin{tikzpicture}[remember picture,overlay,scale=\Background@Scale]
\node[
rotate=\Background@Angle,
scale=\Background@Scale,
opacity=\Background@Opacity,
anchor=\Background@NodeAnchor,
xshift=\Background@HShift,
yshift=\Background@VShift,
color=\Background@Color,
inner sep=0pt
]
at (\Background@Position) [\Background@Anchor]
{\Background@Contents};
\end{tikzpicture}}%
Une tentative brutale consiste à redéfinir \bg@material
.
% this example produces the same output with pdftex, xetex, and luatex
\documentclass{book}
\usepackage{tcolorbox}
\tcbuselibrary{skins}
\usetikzlibrary{calc, fadings}
\usepackage[pages=some]{background}
\newlength{\bleendlength}
\setlength{\bleendlength}{5mm}
\makeatletter
\renewcommand\bg@material{%
\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)$);
}%
}%
\makeatother
\begin{document}
\chapter{My first chapter}\label{cha:my-first-chapter}
\BgThispage
\end{document}
Les solutions plus agréables vont d'une meilleure redéfinition, en utilisant un autre paquet d'arrière-plan, à la fourniture d'un style de page spécial défini par \chapter
(supposons que vous souhaitiez avoir un effet d'arrière-plan similaire par page de titre de chapitre).