0

I want to add color gradient in whole page as from top to bottom red color slowly becomes blue in a article in xelatex. class I tried thus

\documentclass{article}
\usepackage[dvipsnames]{xcolor}
\usepackage{background}
\usepackage{blindtext}
\backgroundsetup{
scale=1,
angle=0,
opacity=1,
contents={\begin{tikzpicture}[remember picture,overlay]
    \path [left color =red,middle color = blue, right color = Blue] (current page.south west)rectangle (current page.north east);
    \end{tikzpicture}}}
\begin{document}
 ABC

\end{document}

But it compiles thus enter image description here

I want to create this gradient through entire page

1
  • Remove the arguments of your \begin{tikzpicture} ... \end{tikzpicture} environment. The problem is caused by overlay but you don't need remember picture so you can remove both.
    – Nico
    May 7, 2020 at 13:56

2 Answers 2

2

Remove the square bracket and its contents of your \begin{tikzpicture} ... \end{tikzpicture} environment. The problem is caused by overlay but you don't need remember picture so you can remove both.

MWE based on your code:

\documentclass{article}
\usepackage[dvipsnames]{xcolor}
\usepackage{background}
\usepackage{blindtext}
\backgroundsetup{
scale=1,
angle=0,
opacity=1,
contents={\begin{tikzpicture}
    \path [left color =red,middle color = blue, right color = Blue] (current page.south west)rectangle (current page.north east);
    \end{tikzpicture}}}
\begin{document}
 ABC
\end{document}

enter image description here

1

You could use everypage instead of backgrounds. Don't forget to run it twice.

\documentclass{article}
\usepackage[dvipsnames]{xcolor}
\usepackage{tikz}
\usepackage{everypage}
\usepackage{blindtext}
\AddEverypageHook{\begin{tikzpicture}[remember picture,overlay]
    \path [left color =red,middle color = blue, right color = Blue] (current page.south west)rectangle (current page.north east);
    \end{tikzpicture}}
\begin{document}
 ABC

\end{document}

You must log in to answer this question.

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