0

Look at this example:

%! TEX program = xelatex
\documentclass{article}
\usepackage{tikz}

\AddToHook{shipout/background}{%
    \begin{tikzpicture}[remember picture,overlay]
        \shade[left color=green,right color=red] (current page.south west) rectangle (current page.north east);
    \end{tikzpicture}%
}

\usepackage{blindtext}
\begin{document}
\blindtext[10]
\end{document}

Run it with xelatex, the rectangle is not drawn on the first page. But with pdflatex, everything is fine.

enter image description here

Is there any fix to this?

5
  • Ah sorry, I thought you had a new problem. But this is the same as in tex.stackexchange.com/q/581394/2388. Give the shade a label (you can use the same: \AddToHook{shipout/background}[jinwen/opac]... and use the rule. Feb 1 '21 at 11:08
  • @UlrikeFischer No, even with this rule, the shade on first page is still not drawn.
    – Jinwen
    Feb 1 '21 at 11:14
  • Well actually it works for me without any changes. Is your system up-to-date? There was a pgf bug which affected xelatex. Feb 1 '21 at 11:26
  • @UlrikeFischer I just got all my texlive packages updated, but the problem remains. It still occurs with xelatex.
    – Jinwen
    Feb 1 '21 at 11:44
  • I think it is a bug in xdvipdfmx, see my answer. Feb 1 '21 at 13:21
1

It works for me. But I'm on windows, and I have a newer xdvipdfmx (in texlive and miktex, my version is "Version 20210109").

If I use an older xdvipdfmx from texlive 2019 I get various errors connected to the shade and the shade is missing:

xdvipdfmx:warning: Error locating image file "pgfshade1"
xdvipdfmx:warning: Specified (image) object doesn't exist: pgfshade1
xdvipdfmx:warning: Interpreting special command uxobj (pdf:) failed.
xdvipdfmx:warning: >> at page="1" position="(-50, 742)" (in PDF)
xdvipdfmx:warning: >> xxx "pdf:uxobj @pgfshade1"

I don't see a good way to get around this. Imho the only thing you can do (if you can't get the newer binary) is to add the shade to the first page directly and not in a shipout hook:

\begin{document}
\begin{tikzpicture}[remember picture,overlay]
\shade[left color=green,right color=red] (current page.south west) rectangle (current page.north east);
\end{tikzpicture}
 ...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.