summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/draftwatermark
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2020-03-14 20:58:33 +0000
committerKarl Berry <karl@freefriends.org>2020-03-14 20:58:33 +0000
commit86c4a85462ebc0a28401a2a0879cd8f34dd8836c (patch)
treeaf35d471e945fad0a933d153683dccd1d0467a30 /Master/texmf-dist/tex/latex/draftwatermark
parent4fa8c3a104fae65f1e4b1d040b290a441c22a4f5 (diff)
draftwatermark (14mar20)
git-svn-id: svn://tug.org/texlive/trunk@54298 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/draftwatermark')
-rw-r--r--Master/texmf-dist/tex/latex/draftwatermark/draftwatermark.sty236
1 files changed, 170 insertions, 66 deletions
diff --git a/Master/texmf-dist/tex/latex/draftwatermark/draftwatermark.sty b/Master/texmf-dist/tex/latex/draftwatermark/draftwatermark.sty
index dc47435ac35..35e165f0af5 100644
--- a/Master/texmf-dist/tex/latex/draftwatermark/draftwatermark.sty
+++ b/Master/texmf-dist/tex/latex/draftwatermark/draftwatermark.sty
@@ -8,7 +8,7 @@
%%
%% IMPORTANT NOTICE:
%%
-%% Copyright 2006
+%% Copyright 2006, 2020
%% Sergio Callegari <sergio.callegari@gmail.com>
%%
%% ---------------------------------------------
@@ -32,79 +32,183 @@
%%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{draftwatermark}%
- [2015/02/19 1.2 Put a gray textual watermark on document pages]
+ [2020/03/14 2.0 Put a gray textual watermark on document pages]
+
+\RequirePackage{kvoptions}
\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@hcenter
-\newlength\sc@wm@vcenter
-\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@hcenter{.5\paperwidth}
-\setlength\sc@wm@vcenter{.5\paperheight}
-\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}}
+
+\DeclareBoolOption[false]{firstpageonly}
+\define@key{draftwatermark}{firstpage}[true]{%
+ \csname draftwatermark@firstpageonly#1\endcsname}
+\DeclareBoolOption[true]{stamp}
+\DeclareComplementaryOption{nostamp}{stamp}
+\DeclareComplementaryOption{final}{stamp}
+\DeclareStringOption[45]{angle}
+\DeclareStringOption[1]{scale}
+\DeclareStringOption[DRAFT]{text}
+\DeclareStringOption[0.5\paperwidth]{hpos}
+\DeclareStringOption[0.5\paperheight]{vpos}
+\DeclareStringOption[0.25\paperwidth]{fontsize}
+\DeclareStringOption[gray]{colormodel}
+\DeclareStringOption[0.8]{colorspec}
+\DeclareStringOption[c]{hanchor}
+\DeclareStringOption[m]{vanchor}
+\DeclareStringOption[\DraftwatermarkStdMark]{markcmd}
+\define@key{draftwatermark}{pos}{%
+ \draftwatermark@processpos #1\@nil}
+\define@key{draftwatermark}{anchor}{%
+ \draftwatermark@processanchor{#1}}
+\define@key{draftwatermark}{color}{%
+ \draftwatermark@processcolor #1\@nil}
+
+\def\draftwatermark@processpos#1,#2\@nil{%
+ \def\draftwatermark@hpos{#1}%
+ \def\draftwatermark@vpos{#2}}
+
+\def\draftwatermark@processanchor#1{%
+ \def\draftwatermark@tempa{#1}
+ \@onelevel@sanitize \draftwatermark@tempa
+ \expandafter \@tfor \expandafter \draftwatermark@tempb
+ \expandafter :\expandafter =\draftwatermark@tempa
+ \do
+ {%
+ \if \draftwatermark@tempb l%
+ \def \draftwatermark@hanchor{l}%
+ \else \if \draftwatermark@tempb c%
+ \def \draftwatermark@hanchor{c}%
+ \else \if \draftwatermark@tempb r%
+ \def \draftwatermark@hanchor{r}%
+ \else \if \draftwatermark@tempb t%
+ \def \draftwatermark@vanchor{t}%
+ \else \if \draftwatermark@tempb m%
+ \def \draftwatermark@vanchor{m}%
+ \else \if \draftwatermark@tempb b%
+ \def \draftwatermark@vanchor{b}
+ \else
+ \PackageError{draftwatermark}{%
+ Illegal anchor directive `\draftwatermark@tempb'}%
+ {Directive has been ingnored.}%
+ \fi\fi\fi\fi\fi\fi
+ }}
+
+\def\draftwatermark@processcolor{%
+ \@ifnextchar[
+ \draftwatermark@processcolor@ii\draftwatermark@processcolor@i}
+
+\def\draftwatermark@processcolor@i#1\@nil{%
+ \def\draftwatermark@colormodel{}%
+ \def\draftwatermark@colorspec{#1}}
+
+\def\draftwatermark@processcolor@ii[#1]#2\@nil{%
+ \def\draftwatermark@colormodel{#1}%
+ \def\draftwatermark@colorspec{#2}}
+
+\ProcessKeyvalOptions*
+\DisableKeyvalOption{draftwatermark}{firstpageonly}
+\DisableKeyvalOption{draftwatermark}{firstpage}
+
+\newcommand\DraftwatermarkOptions[1]{\setkeys{draftwatermark}{#1}}
+
+\newcommand\SetWatermarkAngle[1]{\DraftwatermarkOptions{angle=#1}}
+\newcommand\SetWatermarkFontSize[1]{\DraftwatermarkOptions{fontsize=#1}}
+\newcommand\SetWatermarkScale[1]{\DraftwatermarkOptions{scale=#1}}
\newcommand\SetWatermarkHorCenter[1]{%
- \setlength\sc@wm@hcenter{#1}}
+ \DraftwatermarkOptions{hpos=#1, hanchor=c}}
\newcommand\SetWatermarkVerCenter[1]{%
- \setlength\sc@wm@vcenter{#1}}
-\newcommand\SetWatermarkText[1]{%
- \def\sc@wm@text{#1}}
-\newcommand\sc@watermark{%
- \setlength{\@tempdimb}{\sc@wm@hcenter}%
- \setlength{\@tempdimc}{-\sc@wm@vcenter}%
- \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
+ \DraftwatermarkOptions{vpos=#1, vanchor=m}}
+\newcommand\SetWatermarkText[1]{\DraftwatermarkOptions{text=#1}}
+\newcommand\SetWatermarkColor[2][]{%
+ \DraftwatermarkOptions{colormodel=#1, colorspec=#2}}
+\newcommand\SetWatermarkLightness[1]{%
+ \DraftwatermarkOptions{colormodel=gray, colorspec=#1}}
+
+\newcommand\DraftwatermarkStdMark{%
+ \rotatebox{\draftwatermark@angle}{%
+ \scalebox{\draftwatermark@scale}{%
+ \begingroup
+ \ifx\draftwatermark@colormodel\@empty
+ \color{\draftwatermark@colorspec}%
+ \else
+ \color[\draftwatermark@colormodel]{\draftwatermark@colorspec}%
+ \fi
+ \setlength{\@tempdima}{\draftwatermark@fontsize}%
+ \fontsize{\@tempdima}{1.2\@tempdima}\selectfont
+ \draftwatermark@text
+ \endgroup}}}
+
+\newcommand\draftwatermark@printwm[1]{%
+ \sbox\@tempboxa{#1}%
+ \setlength{\@tempdima}{\draftwatermark@hpos}%
+ \setlength{\@tempdimb}{\draftwatermark@vpos}%
+ \let \draftwatermark@tempa \draftwatermark@hanchor
+ \@onelevel@sanitize \draftwatermark@tempa
+ \expandafter\def\expandafter\draftwatermark@tempb
+ \expandafter{\expandafter\@car \draftwatermark@tempa\@nil}
+ \if \draftwatermark@tempb r%
+ \addtolength\@tempdima{-\wd\@tempboxa}%
+ \else\if \draftwatermark@tempb c%
+ \addtolength\@tempdima{-0.5\wd\@tempboxa}%
+ \else\if \draftwatermark@tempb l%
+ \relax
+ \else
+ \PackageError{draftwatermark}{%
+ Illegal anchor directive `\draftwatermark@tempb'}%
+ {Anchoring to left side.}%
+ \fi\fi\fi
+ \let \draftwatermark@tempa \draftwatermark@vanchor
+ \@onelevel@sanitize \draftwatermark@tempa
+ \expandafter\def\expandafter\draftwatermark@tempb
+ \expandafter{\expandafter\@car \draftwatermark@tempa\@nil}
+ \if \draftwatermark@tempb b%
+ \addtolength\@tempdimb{-\ht\@tempboxa}%
+ \addtolength\@tempdimb{-\dp\@tempboxa}%
+ \else\if \draftwatermark@tempb m%
+ \addtolength\@tempdimb{-0.5\ht\@tempboxa}%
+ \addtolength\@tempdimb{-0.5\dp\@tempboxa}%
+ \else\if \draftwatermark@tempb t%
+ \relax
+ \else
+ \PackageError{draftwatermark}{%
+ Illegal anchor directive `\draftwatermark@tempb'}%
+ {Anchoring to top side.}%
+ \fi\fi\fi
+ \vbox to 0pt {
+ \vspace*{-1in}%
+ \vspace*{\@tempdimb}%
+ \hbox to 0pt {%
+ \hspace*{-1in}%
+ \hspace*{\@tempdima}%
+ \usebox\@tempboxa
+ \hss}%
+ \vss}}
+
+\newcommand\draftwatermark@print[1]{%
+ \ifdraftwatermark@stamp
+ \draftwatermark@printwm{#1}%
\fi}
-\if@sc@wm@first
-\AddThispageHook{\sc@wm@print{\sc@watermark}}
+\ifdraftwatermark@firstpageonly
+ \AddThispageHook{\draftwatermark@print{\draftwatermark@markcmd}}
\else
-\AddEverypageHook{\sc@wm@print{\sc@watermark}}
+ \AddEverypageHook{\draftwatermark@print{\draftwatermark@markcmd}}
\fi
+
+%% \CharacterTable
+%% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
+%% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
+%% Digits \0\1\2\3\4\5\6\7\8\9
+%% Exclamation \! Double quote \" Hash (number) \#
+%% Dollar \$ Percent \% Ampersand \&
+%% Acute accent \' Left paren \( Right paren \)
+%% Asterisk \* Plus \+ Comma \,
+%% Minus \- Point \. Solidus \/
+%% Colon \: Semicolon \; Less than \<
+%% Equals \= Greater than \> Question mark \?
+%% Commercial at \@ Left bracket \[ Backslash \\
+%% Right bracket \] Circumflex \^ Underscore \_
+%% Grave accent \` Left brace \{ Vertical bar \|
+%% Right brace \} Tilde \~}
\endinput
%%
%% End of file `draftwatermark.sty'.