0

When compiling the MWE below with PDFLatex the linear-gradient color background appears, however when compiled in XeLatex the background is white.

  • (NB: using [fill] produces the salmon color background)
  • The linear-gradient is produced with tikz with \path (\node` also experiences the effect).
  • The tex file has previously compiled in XeLatex correctly, so perhaps my local configuration is incorrect (it is a recent reinstall of MikTex and TexStudio) or perhaps a tikz issue.
  • The compilation is via TeXstudio's built-in commands. MiKTeX Console has updated to the latest packages.
pdflatex --version MiKTeX-pdfTeX 4.16 (MiKTeX 23.10)
xelatex --version MiKTeX-XeTeX 4.10 (MiKTeX 23.10)
TeXstudio TeXstudio 4.0.2 (git 4.0.2)
Compiled with xelatex Compiled with pdflatex
enter image description here enter image description here

MWE:

\documentclass[a4paper]{article}
\usepackage[left=0.9cm, right=0.9cm, vmargin=0.75cm]{geometry}

\usepackage{tikz}

\definecolor{backgroundcolor}{HTML}{00264B}

% -- Background color:
\usepackage{background}
\backgroundsetup{
scale=1,
opacity=1,
angle=0,
contents={\begin{tikzpicture}[overlay]
        \path [fill, top color = backgroundcolor, middle color = backgroundcolor, bottom color = backgroundcolor!50] (-10.5,9.9) rectangle (10.5,15) {};
  \end{tikzpicture}}
}


\begin{document}
\section{Section head}
xxxxxxxxxxxxxxxxxxxxxxxxxx
\end{document}

Some related Xelatex tikz color issues:

2
  • your document errors. Oct 9, 2023 at 18:03
  • Thanks @UlrikeFischer - I've removed the \node line and cropped the thumbnails (the outcome remains as reported).
    – pds
    Oct 9, 2023 at 18:13

2 Answers 2

1

It will work if there is second page. If you have only one page you can force the creation of the shading object by storing it once in a box:

\documentclass[a4paper]{article}
\usepackage[left=0.9cm, right=0.9cm, vmargin=0.75cm]{geometry}

\usepackage{tikz}

\definecolor{backgroundcolor}{HTML}{00264B}

% -- Background color:
\usepackage{background}
\backgroundsetup{
scale=1,
opacity=1,
angle=0,
contents={\begin{tikzpicture}[overlay]
        \path [fill, top color = backgroundcolor, middle color = backgroundcolor, bottom color = backgroundcolor!50] (-10.5,9.9) rectangle (10.5,15) {};
  \end{tikzpicture}}
}


\begin{document}
\section{Section head}
xxxxxxxxxxxxxxxxxxxxxxxxxx 

\setbox0\hbox{\begin{tikzpicture}
        \path [fill, top color = backgroundcolor, middle color = backgroundcolor, bottom color = backgroundcolor!50] (-10.5,9.9) rectangle (10.5,15) {};
  \end{tikzpicture}}

\end{document}
0

As a workaround, it is possible to overlay an image file with its own linear-gradient (0% alpha to 35% alpha-white). E.g. the header's linear-gradient becomes:

\path [fill=backgroundcolor] (-10.5,9.9) rectangle (10.5,15); # fixed color
\node [inner sep=0pt] (russell) at (-8.7,13.5) {\includegraphics{linear_gradient.pdf}}; # gradient overlay

You must log in to answer this question.

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