更新于 20190319 我正在使用该命令\pagenumbering{gobble}
来隐藏目录中的页码(我只想显示标题)。问题是它确实隐藏了目录中的页码,但我现在只在目录中看到草稿水印,并且草稿水印从所有后续页面中消失。一旦我删除该行\pagenumbering{gobble}
,草稿水印就会再次出现在所有页面上,但我在目录中有页码。
我怎样才能绕过这个问题,并同时在所有页面上显示草稿水印并在目录中抑制页码(仅标题)?
这是我的代码
\documentclass[10pt, a3paper]{article}
\newcommand{\projecttitle}{Example}
\usepackage{tikz}
\usepackage[printwatermark]{xwatermark}
\usepackage{pdfpages}
\usepackage{pdflscape}
\usepackage{geometry}
\geometry{
a3paper,
left=23mm,
top=15mm,
right=10mm,
bottom=15mm,
headheight=38pt,
includeheadfoot,
showframe=false
}
\newsavebox\mybox
\savebox\mybox{\scalebox{20}{\tikz[color=gray!1000,opacity=0.3]\node{DRAFT};}}
\newwatermark*[allpages,angle=45]{\usebox\mybox}
\begin{document}
\tableofcontents \thispagestyle{fancy}
\addtocontents{toc}{\protect\thispagestyle{empty}}
\pagenumbering{gobble}
\newpage
\thispagestyle{empty}
\includepdf[scale=1.000, trim=0cm 0cm 0.0cm 2cm, pagecommand= {\begin{tikzpicture}[remember picture, overlay] \node [anchor=west] at (-0.2, 0) {\parbox{\linewidth}{\section{Section 1}}}; \end{tikzpicture}}]{any_pdf_image.pdf}
\newpage
\thispagestyle{empty}
\includepdf[scale=1.000, trim=0cm 0cm 0.0cm 2cm, pagecommand= {\begin{tikzpicture}[remember picture, overlay] \node [anchor=west] at (-0.2, 0) {\parbox{\linewidth}{\section{Section 2}}}; \end{tikzpicture}}]{any_pdf_image.pdf}
\newpage
\thispagestyle{empty}
\includepdf[scale=1.000, trim=0cm 0cm 0.0cm 2cm, pagecommand= {\begin{tikzpicture}[remember picture, overlay] \node [anchor=west] at (-0.2, 0) {\parbox{\linewidth}{\section{Section 3}}}; \end{tikzpicture}}]{any_pdf_image.pdf}
\end{document}
答案1
如果您只是用 添加水印eso-pic
,就不会出现这样的问题。(我改变了水印的外观,使其更明显,但您可以轻松地将其改回来。)
\documentclass{article}
\usepackage{eso-pic}
\usepackage{tikz}
\usepackage{lipsum}
\begin{document}
\pagenumbering{gobble}
\tableofcontents
\clearpage
\AddToShipoutPictureBG{\begin{tikzpicture}[overlay,remember picture]
\node[gray,opacity=0.3,scale=8,font=\sffamily,rotate=45] at (current page.center){DRAFT};
\end{tikzpicture}}
\foreach \X in {1,...,20}
{\section{Section \X}
\lipsum[\X]}
\end{document}
答案2
我使用“background”包解决了这个问题。感谢大家的帮助,我所做的就是:
\usepackage[pages=all]{background} % in the preamble
..............
\backgroundsetup{contents={DRAFT}, color=gray!1000, opacity=0.3, angle=45, scale=23} % right before \begin{document}