我想要一个透明的前景水印,该水印对于偶数页和奇数页会有所不同,并且不会渲染底层内容(例如文本和图像),这是无效的。可以吗?
梅威瑟:
\documentclass[]{article}
\usepackage[printwatermark]{xwatermark}
\usepackage{tikz}
\usepackage{graphicx}
\usepackage{pdfpages}
\pagestyle{empty}
\usepackage{hyperref}
\hypersetup{
colorlinks=true, %set true if you want colored links
linktoc=all, %set to all if you want both sections and subsections linked
linkcolor=blue, %choose some color if you want links to stand out
}
\newsavebox\mybox
\savebox\mybox{\tikz[color=red,opacity=0.3]\node{BSFU};}
\newwatermark*[
allpages,
angle=45,
scale=12,
xpos=-20,
ypos=15
]{\usebox\mybox}
\begin{document}
\includepdf[pages=-,pagecommand={\mybox}]{output}
\end{document}
答案1
下面将使用 LaTeX 的内置 shipout 钩子为您的水印放置两个不同的框,基于 -counterpage
是偶数还是奇数。
\documentclass[]{article}
\usepackage{tikz}
\AddToHook{shipout/foreground}
{%
\put(0.5\paperwidth,-0.5\paperheight){\mywatermark}%
}
\newcommand*\mywatermark
{%
\ifodd\value{page}%
\usebox\mywatermarkboxODD
\else
\usebox\mywatermarkboxEVEN
\fi
}
\newsavebox\mywatermarkboxEVEN
\newsavebox\mywatermarkboxODD
\tikzset{mywatermark/.style={color=red,opacity=0.3,font=\huge,rotate=#1}}
\AtBeginDocument
{%
\sbox\mywatermarkboxODD
{\makebox[0pt]{\tikz\node[mywatermark=45]{BSFU};}}%
\sbox\mywatermarkboxEVEN
{\makebox[0pt]{\tikz\node[mywatermark=-45]{BSFU};}}%
}
\usepackage{duckuments}
\begin{document}
\duckument
\end{document}