13

I'm modified the following code from this post to add a couple of vertical watermarks on a page. However, the code places these watermarks on every page.

Is there a way to restrict watermarking to the first page or certain pages of my amsbook?

\documentclass{amsbook}
\usepackage{graphicx}
\usepackage{eso-pic}

\makeatletter
\AddToShipoutPicture{%
\setlength{\@tempdimb}{.5\paperwidth}%
\setlength{\@tempdimc}{.5\paperheight}%
\setlength{\unitlength}{1pt}%
\protect{\put(\strip@pt\@tempdimb,\strip@pt\@tempdimc){%
\makebox(-515,0){\rotatebox{90}{\textcolor[gray]{0.90}%
   {\Huge Draft:  \today}}}
\makebox(515,0){\rotatebox{270}{\textcolor[gray]{0.90}%
   {\Huge  Draft:  \today}}}}}}
\makeatother

\begin{document}

Hi
\newpage
Hi, again.

\end{document}
user02138
  • 1,801
  • 3
  • 19
  • 27
  • a quick solution for those using draftwatermark: \usepackage[firstpage]{draftwatermark} \SetWatermarkText{Draft} \SetWatermarkScale{1} – GlabbichRulz Aug 06 '18 at 12:45

5 Answers5

12

The background package allows you to do this easily; simply use the some package option together with the \BgThispage command for those pages which should exhibit the watermark; the package also allows you to control all the aspects of the watermark (opacity, color, scale, placement, etc.). A little example:

\documentclass{amsbook}
\usepackage{graphicx}
\usepackage[some]{background}

\SetBgScale{1}
\SetBgContents{\parbox{10cm}{%
  \Huge Draft:  \today\\[14cm]\rotatebox{180}{\Huge Draft:  \today}}}
\SetBgColor{gray}
\SetBgAngle{270}
\SetBgOpacity{0.2}

\begin{document}

Hi\BgThispage
\newpage
Hi, again.

\end{document}
Gonzalo Medina
  • 505,128
7

You can use directly atbegshi

\documentclass{amsbook}
\usepackage{graphicx,color}
\usepackage{atbegshi,picture}

\AtBeginShipoutNext{\AtBeginShipoutUpperLeft{%
\setlength{\unitlength}{1pt}%
\protect{\put(.5\paperwidth,-.5\paperheight){%
\makebox(-515,0){\rotatebox{90}{\textcolor[gray]{0.90}%
   {\Huge Draft:  \today}}}%
\makebox(515,0){\rotatebox{270}{\textcolor[gray]{0.90}%
   {\Huge  Draft:  \today}}}}}}}

\begin{document}

Hi
\newpage
Hi, again.

\end{document}

A simpler code, that avoids guessing the number 515 is

\AtBeginShipoutNext{\AtBeginShipoutUpperLeft{%
  \Huge
  \put(1cm,-.5\paperheight){%
    \rotatebox[origin=c]{90}{\textcolor[gray]{0.90}{Draft: \today}}}%
  \put(\dimexpr\paperwidth-1cm-\ht\strutbox\relax,-.5\paperheight){%
    \rotatebox[origin=c]{270}{\textcolor[gray]{0.90}{Draft: \today}}}%
}}

Or, with eso-pic,

\documentclass{amsbook}
\usepackage{graphicx}
\usepackage{eso-pic,picture}

\AddToShipoutPicture{%
\setlength{\unitlength}{1pt}%
\protect{\put(.5\paperwidth,.5\paperheight){%
\makebox(-515,0){\rotatebox{90}{\textcolor[gray]{0.90}%
   {\Huge Draft:  \today}}}%
\makebox(515,0){\rotatebox{270}{\textcolor[gray]{0.90}%
   {\Huge  Draft:  \today}}}}}\ClearShipoutPictureBG}

\begin{document}

Hi
\newpage
Hi, again.

\end{document}

Note that the picture package allows for directly using dimensions in the picture commands.

egreg
  • 1,121,712
3

Here is a command that I use frequently for watermarks. It also uses eso-pic. It puts the contents at the center of the text block.

  • \WaterMark{<picture>} - puts watermark on ever page (can be stopped with \ClearShipoutPictureBG)

  • \WaterMark*{<picture>} - puts watermark on single page

It is also useful if you want to put a logo watermark on every page (use Gimp to downtone the picture)

\documentclass{article}
\usepackage{graphicx}
\usepackage{eso-pic}
\makeatletter
\newcommand\WaterMark{%
    \@ifstar{\@WaterMarkS}{\@watermark}}
\newcommand\@WaterMark[1]{%
    \AddToShipoutPictureBG{\AtTextCenter{\NullGrphBox{#1}}}}
\newcommand\@WaterMarkS[1]{%
    \AddToShipoutPictureBG*{\AtTextCenter{\NullGrphBox{#1}}}}
\newcommand\NullGrphBox[1]{%
    \parbox[c]{0pt}{\makebox[0pt][c]{#1}}}
\makeatother

\newcommand\draftpictA{%
    \setlength{\unitlength}{1mm}%
    \begin{picture}(0,0)(0,0)
        \makebox(-180,0){\rotatebox{90}{\textcolor[gray]{0.10}%
            {\Huge Draft:  \today}}}
        \makebox(180,0){\rotatebox{270}{\textcolor[gray]{0.10}%
            {\Huge  Draft:  \today}}}
    \end{picture}}

\newcommand\draftpictB{%
     \rotatebox[origin=c]{60}{\scalebox{15}{%
        \textcolor[gray]{0.90}{\textbf{DRAFT}}}}}

\begin{document}
\WaterMark*{\draftpictB}
Hi
\newpage
Hi, again.
\newpage
xx
\end{document}
Danie Els
  • 19,694
2

I recommended to use pdftk for such things. If watermark.pdf is the (LaTeX generated) watermark (1 page) with an additional empty page and mydocument.pdf is the (may be LaTeX generated) own document, you can can "watermark" it:

pdftk mydocument.pdf multibackground watermark.pdf output mydocumentwatermark.pdf
Micha
  • 2,869
0

I use the following, which does what I want, and seems to satisfy your needs as well:

 \usepackage{eso-pic,graphicx}
  \definecolor{LtGrey}{rgb}{0.975,0.975,0.975}

  \AddToShipoutPicture{%
  \AtTextCenter{%
  \makebox(0,0)[c]{\resizebox{\textwidth}{!}{%
   \rotatebox{45}{\textsf{\textbf{\color{LtGrey}DRAFT}}}}}
 }
}

If you want the 'draft' watermark on the first page only, simply use the asterisk as shown below:

 \AddToShipoutPicture*{%