我试图将水印显示为背景层,以便读者可以选择是否查看背景。我使用的是LuaLaTeX
和xwatermark
包。当我编译脚本时,背景和图层都不会出现。这是我的脚本的 MWE:
\documentclass[12pt,a4paper]{report}
\usepackage[no-math]{fontspec}
\setmainfont{ArnoPro-Regular}
\usepackage{polyglossia}
\setdefaultlanguage{english}
\disablehyphenation
\usepackage[
hmarginratio = 1:1,
left = 3cm,
right = 2cm,
top = 3cm,
bottom = 2cm,
headheight = 15pt
]{geometry}
\usepackage{amsmath, amsthm, amssymb, amsfonts}
\usepackage[table]{xcolor}
\definecolor{rowgrey}{rgb}{.9,.9,.9}
\definecolor{heavengreen}{rgb}{.8901,.9568,.8941}
\definecolor{greeen}{HTML}{7cc576}
\definecolor{gold}{HTML}{f9ad81}
\definecolor{smoofie}{HTML}{fff7ea}
\usepackage{pgfcore}
\usepackage[printwatermark,watermarkparser=|]{xwatermark}
\usepackage{tikz}
\usetikzlibrary{backgrounds}
\usepackage{afterpage}
\usepackage{graphicx}
\usepackage{lipsum}
\usepackage[tikz]{ocgx2}
\begin{document}
\begin{titlepage}
\pagecolor{smoofie}\afterpage{\nopagecolor}
\begin{center}
\vspace*{4cm}
\begin{tikzpicture}
\draw[line width=2mm,draw=greeen] (0,0) circle (4cm);
\draw[line width=2mm,draw=gold] (0,0) circle (2cm);
\end{tikzpicture}
\end{center}
\end{titlepage}
\begin{ocg}{Background}{background}{true}
\newwatermark[pages=1-5,angle=0,scale=2,xpos=0cm,ypos=0cm]{%
\begin{tikzpicture}[opacity=.2]
\fill [heavengreen] (-12,-5) rectangle (7,15);
\draw[line width=2mm,draw=greeen,fill=heavengreen] (0,0) circle (4cm);
\draw[line width=2mm,draw=gold] (0,0) circle (2cm);
\end{tikzpicture}%
}
\end{ocg}
\sloppy
\lipsum[1-12]
\end{document}
答案1
图层应该在水印内部定义,而不是相反:
\newwatermark[pages=1-5,angle=0,scale=2,xpos=0cm,ypos=0cm]{%
\begin{ocg}{Background}{background}{true}%
\begin{tikzpicture}[opacity=.2]
\fill [heavengreen] (-12,-5) rectangle (7,15);
\draw[line width=2mm,draw=greeen,fill=heavengreen] (0,0) circle (4cm);
\draw[line width=2mm,draw=gold] (0,0) circle (2cm);
\end{tikzpicture}%
\end{ocg}%
}