1

I am using TikZ to set the page background, but changing the opacity doesn't seem to work on the title page. Here is a minimal working example.

\documentclass{article}

\usepackage{tikz}

\AddToHook{shipout/background}{\tikz[remember picture,overlay]{\draw[opacity=0.2,line width=10pt](0,0)--(\paperwidth,0)}}

\title{Title}

\begin{document}

\maketitle

\clearpage

\null

\end{document}

I am using XeLaTeX as the compiler. Any insights or solutions would be greatly appreciated.

4
  • 1
    xelatex does some strange things with opacities, for example in beamer this can mess up the order in which overlays are uncovered. Your example works fine if you would use lualatex instead (or pdflatex). Commented Jun 12 at 10:41
  • @samcarter_is_at_topanswers.xyz Thank you for the suggestion. However, one of the main reasons I use XeLaTeX is that LuaLaTeX compiles too slowly. Commented Jun 12 at 10:44
  • Normally they are both pretty slow. If you can identify what makes lualatex so much slower in your case, maybe fixing this would be easier. Commented Jun 12 at 10:46
  • Does it always compile slowly? It will be slower the first time you use it, but if it isn't much faster after that, something is wrong. Not just per document. It should be faster unless you've installed new fonts, for example. If not, it might mean there's a problem causing it to keep rebuilding its database, say.
    – cfr
    Commented Jun 12 at 13:51

1 Answer 1

3

This is not the correct way to use shipout/background. It may happen to work, but it's not the method documented in ltshipout-doc. The hook expects commands valid inside a picture environment.

However, the opacity is incorrect with XeTeX regardless. If your example reflects your actual usage, you could use shipout/foreground instead. Or just use a paler colour if printing onto white paper or not printing at all.

If not - if you actually need opacity and need the page content printed on top - you need to change the order in the hook to get opacity configured correctly with XeTeX.

\documentclass{article}

\usepackage{tikz}

\AddToHook{shipout/background}[line]{%
  \put (-5,-10) {%
    \tikz{\draw[opacity=.2,line width=10pt](0,0)--(\paperwidth,0)}%
  }%
}
\DeclareHookRule{shipout/background}{pgfrcs}{>}{line}

\title{Title}

\begin{document}

  \maketitle
  
  \clearpage
  
  \null
  
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .