我想在整个页面中添加颜色渐变,因为在 xelatex 中的一篇文章中,从上到下红色慢慢变成蓝色。我尝试过
\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}
我想在整个页面中创建这个渐变
答案1
删除方括号及其内容\begin{tikzpicture} ... \end{tikzpicture}
。问题是由环境引起的overlay
,但您不需要remember picture
,因此您可以将两者全部删除。
基于您的代码的 MWE:
\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}
答案2
您可以使用每个页面来代替背景。别忘了运行两次。
\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}