summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/draftwatermark/draftwatermark.sty
blob: 2b0c13b9798dc44ee5abaababa1b7dadc9adf5b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
%%
%% This is file `draftwatermark.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% draftwatermark.dtx  (with options: `draftwatermark')
%% 
%%   IMPORTANT NOTICE:
%% 
%% Copyright 2006
%% Sergio Callegari <sergio.callegari@gmail.com>
%% 
%% ---------------------------------------------
%% This file is part of the draftwatermark package,
%% a contribution to the LaTeX2e system.
%% ---------------------------------------------
%% 
%% This program consists of the files listed in the README file included
%% in the package.
%% 
%% Any modified versions of this file must be renamed with new filenames
%% distinct from draftwatermark.sty.
%% 
%% For distribution of the original source see the terms
%% for copying and modification in the file draftwatermark.dtx.
%% 
%% This generated file may be distributed as long as the
%% original source files, as listed above, are part of the
%% same distribution. (The sources need not necessarily be
%% in the same archive or directory.)
%% 
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{draftwatermark}%
  [2006/06/30 1.0 Put a gray textual watermark on document pages]
\RequirePackage{everypage}[2007/06/20]
\RequirePackage{graphicx}
\RequirePackage{color}
\newif\if@sc@wm@first
\@sc@wm@firstfalse
\newif\if@sc@wm@stamp
\@sc@wm@stamptrue
\DeclareOption{firstpage}{%
  \@sc@wm@firsttrue}
\DeclareOption{nostamp}{%
  \@sc@wm@stampfalse}
\DeclareOption{final}{%
  \@sc@wm@stampfalse}
\DeclareOption{stamp}{%
  \@sc@wm@stamptrue}
\ProcessOptions
\newlength\sc@wm@fontsize
%% defaults
\def\sc@wm@angle{45}
\def\sc@wm@colormodel{[gray]}
\def\sc@wm@colorspecs{0.8}
\def\sc@wm@scale{1}
\setlength\sc@wm@fontsize{5cm}
\def\sc@wm@text{DRAFT}
\newcommand\SetWatermarkAngle[1]{%
  \def\sc@wm@angle{#1}}
\newcommand\SetWatermarkColor{}
\def\SetWatermarkColor#1#{\sc@setWatermarkColor{#1}}
\def\sc@setWatermarkColor#1#2{%
  \def\sc@wm@colormodel{#1}%
  \def\sc@wm@colorspecs{#2}}
\newcommand\SetWatermarkLightness[1]{%
  \SetWatermarkColor[gray]{#1}}
\newcommand\SetWatermarkFontSize[1]{%
  \setlength\sc@wm@fontsize{#1}}
\newcommand\SetWatermarkScale[1]{%
  \def\sc@wm@scale{#1}}
\newcommand\SetWatermarkText[1]{%
  \def\sc@wm@text{#1}}
\newcommand\sc@watermark{%
  \setlength{\@tempdimb}{.5\paperwidth}%
  \setlength{\@tempdimc}{-.5\paperheight}%
  \put(\strip@pt\@tempdimb,\strip@pt\@tempdimc){%
    \makebox(0,0){\rotatebox{\sc@wm@angle}{%
        \scalebox{\sc@wm@scale}{%
          \expandafter\expandafter\expandafter\textcolor
          \expandafter\sc@wm@colormodel\expandafter{\sc@wm@colorspecs}{%
            \fontsize{\sc@wm@fontsize}{1.2\sc@wm@fontsize}
            \selectfont
            \sc@wm@text}}}}}}
\newcommand\sc@wm@print[1]{%
  \if@sc@wm@stamp
  \setbox\@tempboxa\vbox to \z@{%
    \vskip -1in \moveleft 1in \vbox{%
      \hbox to \z@{%
        #1\hss}}\vss}
  \dp\@tempboxa\z@
  \box\@tempboxa
  \fi}
\if@sc@wm@first
\AddThispageHook{\sc@wm@print{\sc@watermark}}
\else
\AddEverypageHook{\sc@wm@print{\sc@watermark}}
\fi
\endinput
%%
%% End of file `draftwatermark.sty'.