summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/draftwatermark
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/source/latex/draftwatermark')
-rw-r--r--Master/texmf-dist/source/latex/draftwatermark/draftwatermark.dtx583
-rw-r--r--Master/texmf-dist/source/latex/draftwatermark/draftwatermark.ins52
2 files changed, 474 insertions, 161 deletions
diff --git a/Master/texmf-dist/source/latex/draftwatermark/draftwatermark.dtx b/Master/texmf-dist/source/latex/draftwatermark/draftwatermark.dtx
index b759f29eb76..216fd1072cd 100644
--- a/Master/texmf-dist/source/latex/draftwatermark/draftwatermark.dtx
+++ b/Master/texmf-dist/source/latex/draftwatermark/draftwatermark.dtx
@@ -8,14 +8,16 @@
% a contribution to the LaTeX2e system.
% ---------------------------------------------
%
-% It may be distributed and/or modified under the conditions of the
-% LaTeX Project Public License, version 1.3. This license is at
-% https://www.latex-project.org/lppl/ and is part
-% of all distributions of LaTeX version 2005/12/01 or later.
+% This work may be distributed and/or modified under the
+% conditions of the LaTeX Project Public License, version 1.3c.
+% This license is in
+% https://www.latex-project.org/lppl/lppl-1-3c/
+% and is part of all distributions of LaTeX later than
+% 2008-05-04.
%
-% This work has the LPPL maintenance status "author-maintained".
+% This work has the LPPL maintenance status "maintained".
%
-% This program consists of the files listed in the README file
+% This program consists of the files listed in the README.md file
% included in the package.
%
%<*driver>
@@ -27,40 +29,8 @@
\usepackage{textcomp}
\usepackage{url}
\EnableCrossrefs
-
-\setcounter{IndexColumns}{2}
-\setlength{\IndexMin}{3cm}
-
-\DoNotIndex{\\}
-\DoNotIndex{\begin, \end, \begingroup, \endgroup}
-\DoNotIndex{\csname, \endcsname}
-\DoNotIndex{\if, \else, \fi}
-\DoNotIndex{\ifx, \fi}
-\DoNotIndex{\ifodd, \fi}
-\DoNotIndex{\@car, \@empty, \@ifnextchar, \@nil, \@onelevel@sanitize,
- \@tempboxa, \@tempdima, \@tempdimb, \@tfor}
-\DoNotIndex{\AddEverypageHook, \AddThispageHook, \addtolength, \author}
-\DoNotIndex{\bfseries, \box}
-\DoNotIndex{\color}
-\DoNotIndex{\DeclareBoolOption, \DeclareComplementaryOption,
- \DeclareStringOption, \def, \define@key, \dimexpr, \DisableKeyvalOption,
- \do, \documentclass, \dp}
-\DoNotIndex{\edef, \expandafter}
-\DoNotIndex{\fbox, \fontsize}
-\DoNotIndex{\hbox, \hspace, \hss, \ht}
-\DoNotIndex{\let, \lipsum}
-\DoNotIndex{\maketitle, \MyWM}
-\DoNotIndex{\newcommand, \newsavebox, \NeedsTeXFormat}
-\DoNotIndex{\PackageError, \paperheight, \paperwidth,
- \ProcessKeyvalOptions, \ProvidesPackage}
-\DoNotIndex{\relax, \RequirePackage, \rotatebox}
-\DoNotIndex{\savebox, \sbox, \scalebox, \section, \selectfont, \setkeys,
- \setlength, \sffamily, \shortstack}
-\DoNotIndex{\thepage, \title}
-\DoNotIndex{\usebox, \usepackage}
-\DoNotIndex{\vbox, \vspace, \vss}
-\DoNotIndex{\wd, \wmbox}
-
+\CodelineIndex
+\RecordChanges
\CodelineIndex
%\RecordChanges
\begin{document}
@@ -70,12 +40,47 @@
%
% \fi
%
-% \CheckSum{291}
+% \CheckSum{576}
%
% \def\filename{draftwatermark.dtx}
-% \def\fileversion{2.2}
-% \def\filedate{2020/06/29}
-% \def\docdate{2020/06/29}
+% \def\fileversion{3.0}
+% \def\filedate{2020/12/08}
+% \def\docdate{2020/12/08}
+%
+% \DoNotIndex{\\}
+% \DoNotIndex{\begin, \end, \begingroup, \endgroup}
+% \DoNotIndex{\csname, \endcsname}
+% \DoNotIndex{\if, \else, \fi}
+% \DoNotIndex{\ifx, \fi}
+% \DoNotIndex{\ifodd, \fi}
+% \DoNotIndex{\@car, \@empty, \@ifnextchar, \@ifundefined, \@nil,
+% \@onelevel@sanitize, \@tempboxa, \@tempdima, \@tempdimb, \@tfor}
+% \DoNotIndex{\AddEverypageHook, \AddThispageHook, \AddToHook, \AddToHookNext,
+% \addtolength, \author}
+% \DoNotIndex{\bfseries, \box}
+% \DoNotIndex{\color}
+% \DoNotIndex{\DeclareBoolOption, \DeclareComplementaryOption,
+% \DeclareStringOption, \def, \define@key, \depth, \dimexpr,
+% \DisableKeyvalOption, \do, \documentclass, \dp}
+% \DoNotIndex{\edef, \endinput, \expandafter}
+% \DoNotIndex{\fbox, \fontsize}
+% \DoNotIndex{\hbox, \hspace, \hss, \ht}
+% \DoNotIndex{\let, \lipsum}
+% \DoNotIndex{\maketitle, \MyWM, \MessageBreak}
+% \DoNotIndex{\newcommand, \newsavebox, \NeedsTeXFormat}
+% \DoNotIndex{\PackageError, \PackageWarningNoLine, \paperheight,
+% \paperwidth, \ProcessKeyvalOptions, \ProvidesPackage, \put}
+% \DoNotIndex{\raisebox, \relax, \RequirePackage, \RequirePackageWithOptions,
+% \rotatebox}
+% \DoNotIndex{\savebox, \sbox, \scalebox, \section, \selectfont, \setkeys,
+% \SetupKeyvalOptions, \setlength, \sffamily, \shortstack}
+% \DoNotIndex{\thepage, \title}
+% \DoNotIndex{\usebox, \usepackage}
+% \DoNotIndex{\vbox, \vspace, \vss}
+% \DoNotIndex{\wd, \wmbox}
+%
+% \setcounter{IndexColumns}{2}
+% \setlength{\IndexMin}{3cm}
%
% \newcommand*{\Lpack}[1]{\textsf {#1}} ^^A typeset a package
% \newcommand*{\Lopt}[1]{\texttt {#1}} ^^A typeset an option
@@ -97,28 +102,30 @@
% \maketitle
%
% \begin{abstract}
-% The \Lpack{draftwatermark} package extends \LaTeX\ providing a means
-% to add a watermark (typically textual and light gray, but possibly
-% more sophisticated) on the pages of a document (either on every page,
-% on the first page, or on selected pages). Typical usage may consist in
-% writing words such as ``DRAFT'' or ``CONFIDENTIAL'' across the
-% pages. The package may remind in some sense \Lpack{draftcopy} by
-% Dr.~Juergen Vollmer, but its implementation is lighter (as the reduced
-% code footprint shows) and does not rely on postscript specials, making
-% the package fully compatible with \hologo{pdfLaTeX}, \hologo{XeLaTeX}
-% and \hologo{LuaLaTeX}. The \Lpack{draftwatermark} package depends on
-% \Lpack{everypage} by the same author. Its feature set is somehow
-% restricted because the emphasis is on the simplicity of the
-% interface. For complex layouts, \Lpack{scrlayer.sty} from the
-% \emph{KOMA script} bundle may represent a valuable alternative.
+% The \Lpack{draftwatermark} package extends \hologo{LaTeX} providing a
+% means to add a watermark (typically textual and light gray, but
+% possibly more sophisticated) on the pages of a document (either on
+% every page, on the first page, or on selected pages). Typical usage
+% may consist in writing words such as ``DRAFT'' or ``CONFIDENTIAL''
+% across the pages. The package may remind in some sense
+% \Lpack{draftcopy} by Dr.~Juergen Vollmer, but its implementation is
+% lighter (as the reduced code footprint shows) and does not rely on
+% postscript specials, making the package fully compatible with
+% \hologo{pdfLaTeX}, \hologo{XeLaTeX} and \hologo{LuaLaTeX}. Its feature
+% set is somehow restricted because the emphasis is on the simplicity of
+% the interface. For complex layouts, consider \Lpack{scrlayer.sty} from
+% the \emph{KOMA script} bundle or directly using the new \hologo{LaTeX}
+% shipout hooks.
% \end{abstract}
%
% \section{Introduction}
-%
-% This package extends \LaTeX\ providing a means to add a textual, usually
-% light gray (but possibly colored) watermark on every page, the first
-% page, or selected pages of a document. Typical usage may consist in
-% writing words such as ``DRAFT'' or ``CONFIDENTIAL'' across document
+%
+% \changes{R1.0}{2006/06/30}{Initial release.}%
+% \changes{R1.1}{2012/01/06}{Many small fixes in the documentation.}
+% This package extends \hologo{LaTeX} providing a means to add a textual,
+% usually light gray (but possibly colored) watermark on every page, the
+% first page, or selected pages of a document. Typical usage may consist
+% in writing words such as ``DRAFT'' or ``CONFIDENTIAL'' across document
% pages.
%
% The package may remind in some sense \Lpack{draftcopy} by Dr.~Juergen
@@ -162,11 +169,10 @@
% other packages affecting the page building, e.g., with respect to the
% stacking order of the objects on the page. For any complex layout, or
% when the Z-ordering is important, the recommendation is to look at the
-% \Lpack{scrlayer} package in the \emph{KOMA script} bundle.
+% \Lpack{scrlayer} package in the \emph{KOMA script} bundle or to rely
+% directly on the new shipout hook mechanism provided by \hologo{LaTeX}.
+%
%
-% For the actual page building \Lpack{draftwatermark} depends on the
-% \Lpack{everypage} package by the same author.
-%
% \section{User interface}
% When loaded, \Lpack{draftwatermark} sets up a number of defaults
% (detailed later and modifiable by specific commands) and immediately
@@ -185,7 +191,8 @@
% |\usepackage[<options>]{draftwatermark}|
% \end{quote}
%
-% \DescribeMacro{\DraftwatermarkOptions}
+% \DescribeMacro{\DraftwatermarkOptions}
+% \changes{R2.0}{2020/03/08}{Introduction of a keyval option mechanism.}
% The package behavior can also be dynamically changed \emph{after the
% package is loaded} by the command |\DraftwatermarkOptions{<options>}|
% that can be used anywhere in the document source. In either case,
@@ -198,11 +205,13 @@
% command is a bit quirky, hence when specifying options with the
% |<key>=<value>| syntax, some values that are accepted by
% |\DraftwatermarkOptions| may cause issues when specifying options with
-% |\usepackage|.
-% \medskip
+% |\usepackage|. \medskip
%
% The available options are:
% \begin{itemize}
+% \changes{R1.1}{2012/01/06}{Introduce the ``stamp'', ``nostamp'' and
+% ``final'' options to control whether the watermark should actually
+% be printed.}^^A
% \item \verb!firstpageonly=true|false!\\
% If no value is provided, |true| is assumed. Default is |false|.\\
% Instructs \Lpack{draftwatermark} to only apply the watermark on the
@@ -322,21 +331,21 @@
% fact, sufficiently large to get the word ``DRAFT'', rotated at
% 45\textdegree, take about half of the page width.
%
-% Nonetheless asking for a large font may not work, if \LaTeX\ has not
-% been set up to use \emph{scalable} fonts. For this reason, the
-% recommendation is to always use \Lpack{draftwatermark} on \LaTeX\ or
-% \hologo{pdfLaTeX} together with other packages that trigger the usage of
-% fully scalable fonts (practical examples may be \Lpack{newtx} or
+% Nonetheless asking for a large font may not work, if \hologo{LaTeX} has
+% not been set up to use \emph{scalable} fonts. For this reason, the
+% recommendation is to always use \Lpack{draftwatermark} on \hologo{LaTeX}
+% or \hologo{pdfLaTeX} together with other packages that trigger the usage
+% of fully scalable fonts (practical examples may be \Lpack{newtx} or
% \Lpack{mathptmx}, etc.). An even better alternative is to use modern
% \TeX\ engines, as in \hologo{XeLaTeX} or \hologo{LuaLaTeX} with
% \Lpack{fontspec}. In any case, recall that even with scalable fonts,
-% \LaTeX\ may be unable to deal with extremely large font sizes (e.g.,
-% $\gg 5\,\mathrm{cm}$). If really large letters are required for the
-% watermark, a suitable combination of |fontsize| and |scale| may be
+% \hologo{LaTeX} may be unable to deal with extremely large font sizes
+% (e.g., $\gg 5\,\mathrm{cm}$). If really large letters are required for
+% the watermark, a suitable combination of |fontsize| and |scale| may be
% needed.
%
-% One can immediately realize when \LaTeX\ is unable to deal with the
-% package default or selected |fontsize| from two things: (i) a font
+% One can immediately realize when \hologo{LaTeX} is unable to deal with
+% the package default or selected |fontsize| from two things: (i) a font
% warning from \LaTeX; and (ii) a tiny watermark text whose size seems not
% to react to the |fontsize| option. In this case, either switch to
% scalable fonts or select a small |fontsize| (e.g., |12pt|) together with
@@ -352,21 +361,21 @@
% (e.g., |\bfseries|). In fact, it is also possible to use a command to
% include an image as the text. In case line breaks are present, the text
% is left, right, center aligned according to the |alignment| option. A
-% word of caution is necessary, though. To use \LaTeX\ commands in the
-% watermark text, please configure the latter via the
+% word of caution is necessary, though. To use \hologo{LaTeX} commands in
+% the watermark text, please configure the latter via the
% |\DraftwatermarkOptions| command. Trying to do so by passing options to
% the \Lpack{draftwatermark} package via the |\usepackage| mechanism may
-% fail due to how \LaTeX\ parses option strings. Also note that the text
-% may need to be surrounded by braces.
+% fail due to how \hologo{LaTeX} parses option strings. Also note that the
+% text may need to be surrounded by braces.
%
% If the watermark text includes line breaks, \Lpack{draftwatermark} will
% use a very thin interline space, according to the fact that the
-% multi-line text is managed by surrounding the it with a \LaTeX\
+% multi-line text is managed by surrounding the it with a \hologo{LaTeX}
% |shortstack| command.
%
-% Also, note that the watermark typesetting happens inside a \TeX\
-% group, to make sure that any parameter setting you do in the |text|
-% token list can stay local.
+% Also, note that the watermark typesetting happens inside a \TeX\ group,
+% to make sure that any parameter setting you do in the |text| token list
+% can stay local.
%
% As a further remark, observe that in order to only put a watermark on
% selected pages, an alternative to changing the |stamp| configuration
@@ -391,18 +400,21 @@
% anchoring.
%
% As a final remark, observe that the specification of the positioning
-% coordinates can be based on \LaTeX\ macros. For instance, one can set
-% the horizontal position |hpos| at |0.5\paperwidth| (for centering) or at
-% |\dimexpr\paperwidth-5mm| (for placement at the right hand side of the
-% page). Interestingly, \Lpack{draftwatermark} re-evaluates the
+% coordinates can be based on \hologo{LaTeX} macros. For instance, one can
+% set the horizontal position |hpos| at |0.5\paperwidth| (for centering)
+% or at |\dimexpr\paperwidth-5mm| (for placement at the right hand side of
+% the page). Interestingly, \Lpack{draftwatermark} re-evaluates the
% positioning coordinates on every page. This means that positions based
% on |\paperwidth| or |\paperheight| should dynamically adjust if the page
-% size is changed through the document. To some extent, this is also true
+% size is changed through the document.
+% \changes{R2.1}{2020/05/11}{Let anchor directives be re-evaluated on
+% every page.}^^A
+% To some extent, this is also true
% of the anchor options. For instance, one may set the horizontal anchor
% |hanchor| at |\ifodd\thepage r\else l\fi| causing the anchor point to
% alternate between |r| and |l| at every new page. In conjunction with a
% similarly conditional |hpos| setting, for instance
-% |\ifodd\thepage \dimexpr\paperwidth-5mm\else 5mm\fi|, this enables
+% |\ifodd\thepage \dimexpr\paperwidth-5mm \else 5mm\fi|, this enables
% interesting effects, like placing the watermark close to the right side
% of the page on odd pages and to the left side of the page on even
% pages. Obviously, this kind of setting is only applicable with the
@@ -442,8 +454,33 @@
%
% \end{sloppy}
%
-% \section{Compatibility notes for package version 2.0 and later}
+% \section{Compatibility notes}
+%
+% \subsection{Compatibility notes for package version 3.0 and later}
+%
+% \changes{R3.0}{2020/12/08}{Remove dependency on package
+% \Lpack{everypage}.}^^A
+% Version 3.0 of the package takes advantage of the new functionalities
+% introduced in \hologo{LaTeX} with the Fall 2020 release and gets rid of
+% its dependency on \Lpack{everypage}. In principle, this could result in
+% behavioral differences in corner cases.
+%
+% \changes{R3.0}{2020/12/08}{Automatically load legacy code for older
+% \hologo{LaTeX} formats.}^^A
+% For users of versions of \hologo{LaTeX} before Fall 2020,
+% \Lpack{draftwatermarks} falls back to its own legacy code base, now
+% packaged as \Lpack{draftwatermark-2x}.
%
+% It is worth remarking that there is no advantage in trying to explicitly
+% load \Lpack{draftwatermark-2x} on a modern \hologo{LaTeX} to try to get
+% the past behavior. In fact, even if the old code base uses
+% \Lpack{everypage}, on modern \hologo{LaTeX} formats, the latter tries
+% itself to rely on the new \hologo{LaTeX} functionalities rather than its
+% own legacy mechanisms.
+%
+% \subsection{Compatibility notes for package version 2.0 and later}
+%
+% \changes{R2.0}{2020/03/08}{Complete package overhaul.}
% Version 2.0 of the package is an almost complete rewrite with respect to
% version 1.2. Specifically, all the configuration mechanism has been
% overhauled, by moving to an interface based on configuration keys and
@@ -465,6 +502,8 @@
% Command |\SetWatermarkAngle{<real>}| is the same as\\
% |\DraftwatermarkOptions{angle=<real>}|.
% \item \DescribeMacro{\SetWatermarkColor}^^A
+% \changes{R1.1}{2012/01/06}{Add support for specifying color
+% of textual watermark.}^^A
% Command |\SetWatermarkColor[<model>]{<color spec>}| is the same as\\
% |\DraftwatermarkOptions{color={[<model>]{<color spec>}}}|.
% \item \DescribeMacro{\SetWatermarkLightness}^^A
@@ -478,14 +517,18 @@
% Command |\SetWatermarkScale{<real>}| is the same as\\
% |\DraftwatermarkOptions{scale=<real>}|.
% \item \DescribeMacro{\SetWatermarkHorCenter}^^A
+% \changes{R1.2}{2015/02/19}{Add support for specifying the watermark
+% horizontal position.}^^A
% Command |\SetWatermarkHorCenter{<length>}| is the same as\\
% |\DraftwatermarkOptions{hpos=<length>, hanchor=c}|.
% \item \DescribeMacro{\SetWatermarkVerCenter}^^A
+% \changes{R1.2}{2015/02/19}{Add support for specifying the watermark
+% vertical position.}^^A
% Command |\SetWatermarkVerCenter{<length>}| is the same as\\
% |\DraftwatermarkOptions{vpos=<length>, vanchor=m}|.
% \item \DescribeMacro{\SetWatermarkText}^^A
% Command |\SetWatermarkText{<text>}| is the same as\\
-% |\DraftwatermarkOptions{text=<text>}|.
+% |\DraftwatermarkOptions{text={<text>}}|.
% \end{itemize}
%
% Note that the legacy interface supports only a subset of what is
@@ -503,7 +546,7 @@
% \fi
% \begin{macrocode}
\documentclass{article}
-\usepackage[named]{xcolor}
+\usepackage[svgnames]{xcolor}
\usepackage[T1]{fontenc}
\usepackage[firstpageonly, color={[gray]{0.5}},
text=DRAFT\\COPY]{draftwatermark}
@@ -526,7 +569,6 @@
% \iffalse
%</samplecode-modern>
% \fi
-% \makeatletter \c@CodelineNo\z@ \makeatother
%
% This produces a two pages document with placeholder content, putting a
% page-centered watermark on the first page only. The watermark is made a
@@ -541,7 +583,7 @@
% \fi
% \begin{macrocode}
\documentclass{article}
-\usepackage[named]{xcolor}
+\usepackage[svgnames]{xcolor}
\usepackage[T1]{fontenc}
\usepackage[firstpage]{draftwatermark}
\usepackage{mathptmx}
@@ -567,7 +609,6 @@
% \iffalse
%</samplecode-legacy>
% \fi
-% \makeatletter \c@CodelineNo\z@ \makeatother
%
% \subsection{Things that cannot be done with the legacy interface}
%
@@ -581,7 +622,7 @@
% \fi
% \begin{macrocode}
\documentclass{article}
-\usepackage[named]{xcolor}
+\usepackage[svgnames]{xcolor}
\usepackage[T1]{fontenc}
\usepackage[firstpage, anchor=tr, color=red,
pos={\dimexpr\paperwidth-5mm, 5mm},
@@ -606,7 +647,6 @@
% \iffalse
%</samplecode-anchor>
% \fi
-% \makeatletter \c@CodelineNo\z@ \makeatother
%
% Another interesting possibility of the modern interface derives from the
% fact that the positioning and anchoring options are re-evaluated for
@@ -619,7 +659,7 @@
% \fi
% \begin{macrocode}
\documentclass{article}
-\usepackage[named]{xcolor}
+\usepackage[svgnames]{xcolor}
\usepackage[T1]{fontenc}
\usepackage[color=red, fontsize=32pt]{draftwatermark}
\usepackage{mathptmx}
@@ -650,7 +690,6 @@
% \iffalse
%</samplecode-dynamic>
% \fi
-% \makeatletter \c@CodelineNo\z@ \makeatother
%
% \subsection{Maximum freedom with a custom watermarking command}
%
@@ -662,7 +701,7 @@
% \fi
% \begin{macrocode}
\documentclass{article}
-\usepackage[named]{xcolor}
+\usepackage[svgnames]{xcolor}
\usepackage[T1]{fontenc}
\usepackage{draftwatermark}
\usepackage{mathptmx}
@@ -697,7 +736,6 @@
% \iffalse
%</samplecode-custom>
% \fi
-% \makeatletter \c@CodelineNo\z@ \makeatother
%
%
% \section{Development and support}
@@ -711,23 +749,10 @@
% requests that, from the present document, would evidently require moving
% against some fundamental design decisions.
%
-% \section{Changelog}
-%
-% \begin{description}
-% \item[1.0 - 2006/06/30] Initial version.
-% \item[1.1 - 2012/01/06] Add support for colored watermarks; options to
-% disable watermarking; many small fixes in the documentation.
-% \item[1.2 - 2015/02/19] Add support for watermark position.
-% \item[2.0 - 2020/03/08] Configuration management overhaul; introduction
-% of a legacy interface for compatibility.
-% \item[2.1 - 2020/05/11] Allow anchor information to be re-evaluated on
-% every page.
-% \item[2.2 - 2020/06/29] Make line breaks in watermark text work.
-% \end{description}
-%
% \StopEventually {}
%
% \section{Implementation}
+% \subsection{Implementation of \Lpack{draftwatermark}}
%
% Announce the name and version of the package, which requires
% \LaTeXe.
@@ -737,7 +762,277 @@
% \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{draftwatermark}%
- [2020/06/29 2.2 Put a gray textual watermark on document pages]
+ [2020/12/08 3.0 Put a gray textual watermark on document pages]
+% \end{macrocode}
+% \changes{R3.0}{2020/12/08}{Automatically load legacy code for older
+% \hologo{LaTeX} formats.}^^A
+% Depending on the actual functionalities provided by \hologo{LaTeX}
+% consider loading \Lpack{draftwatermark-2x}. If so doing, warn about this,
+% and hand over the operation to that package.
+% \begin{macrocode}
+\@ifundefined{AddToHook}{%
+ \PackageWarningNoLine{draftwatermark}{%
+ You appear to be running a version of LaTeX\MessageBreak
+ unsupported by current draftwatermark.\MessageBreak
+ Forcing fallback to `draftwatermark-2x` that\MessageBreak
+ uses an older code base}%
+ \RequirePackageWithOptions{draftwatermark-2x}%
+ \endinput}{}
+% \end{macrocode}
+%
+% Require the needed packages.
+% \begin{macrocode}
+\RequirePackage{kvoptions}
+\RequirePackage{graphicx}
+\RequirePackage{color}
+% \end{macrocode}
+%
+% Define the configuration options and default values.
+% \begin{macrocode}
+\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[c]{alignment}
+\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}
+% \end{macrocode}
+%
+% Set up some helper marcros to process the options. These should be
+% rather self-explanatory.
+% \begin{macrocode}
+\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}}
+
+% \end{macrocode}
+%
+% Process the package options\dots
+% \begin{macrocode}
+\ProcessKeyvalOptions*
+% \end{macrocode}
+%
+% \dots\, and then disable the |firstpageonly| and |firstpage| options,
+% that can only be used at the package loading time.
+% \begin{macrocode}
+\DisableKeyvalOption{draftwatermark}{firstpageonly}
+\DisableKeyvalOption{draftwatermark}{firstpage}
+
+% \end{macrocode}
+%
+% \begin{macro}{\DraftwatermarkOptions}
+% Set up a command to modify the configuration as needed.
+% \begin{macrocode}
+\newcommand\DraftwatermarkOptions[1]{\setkeys{draftwatermark}{#1}}
+
+% \end{macrocode}
+% \end{macro}
+%
+% Introduce the legacy interface.
+% \begin{macro}{\SetWatermarkAngle}
+% Legacy command to set the rotation angle for the standard watermark
+% \begin{macrocode}
+\newcommand\SetWatermarkAngle[1]{\DraftwatermarkOptions{angle=#1}}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\SetWatermarkFontSize}
+% Legacy command to set the font size for the standard watermark
+% \begin{macrocode}
+\newcommand\SetWatermarkFontSize[1]{\DraftwatermarkOptions{fontsize=#1}}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\SetWatermarkScale}
+% Legacy command to set the scale for the standard watermark
+% \begin{macrocode}
+\newcommand\SetWatermarkScale[1]{\DraftwatermarkOptions{scale=#1}}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\SetWatermarkHorCenter}
+% \begin{macro}{\SetWatermarkVerCenter}
+% Legacy commands to set the horizontal and vertical position for the
+% standard watermark, also forcing it to be centered there.
+% \begin{macrocode}
+\newcommand\SetWatermarkHorCenter[1]{%
+ \DraftwatermarkOptions{hpos=#1, hanchor=c}}
+\newcommand\SetWatermarkVerCenter[1]{%
+ \DraftwatermarkOptions{vpos=#1, vanchor=m}}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \begin{macro}{\SetWatermarkText}
+% \changes{R2.3}{2020/12/06}{Fix legacy interface to accept
+% text including commas.}^^A
+% Legacy command to set the text of the standard watermark
+% \begin{macrocode}
+\newcommand\SetWatermarkText[1]{\DraftwatermarkOptions{text={#1}}}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\SetWatermarColor}
+% \begin{macro}{\SetWatermarkLightness}
+% Legacy commands to set the color for the
+% standard watermark.
+% \begin{macrocode}
+\newcommand\SetWatermarkColor[2][]{%
+ \DraftwatermarkOptions{colormodel=#1, colorspec=#2}}
+\newcommand\SetWatermarkLightness[1]{%
+ \DraftwatermarkOptions{colormodel=gray, colorspec=#1}}
+
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\DraftwatermarkStdMark}
+% The command to generate the standard watermark
+% \changes{R2.2}{2020/06/29}{Wrap watermark text in a shortstack to make
+% line breaks possible.}
+% \begin{macrocode}
+\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
+ \shortstack[\draftwatermark@alignment]{\draftwatermark@text}%
+ \endgroup}}}
+
+% \end{macrocode}
+% \end{macro}
+%
+% The code to actually print the watermark
+% \begin{macrocode}
+\newcommand\draftwatermark@printwm[1]{%
+ \sbox\@tempboxa{\raisebox{\depth}{#1}}%
+ \setlength{\@tempdima}{\draftwatermark@hpos}%
+ \setlength{\@tempdimb}{-\draftwatermark@vpos}%
+ \edef \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
+ \edef \draftwatermark@tempa{\draftwatermark@vanchor}%
+ \@onelevel@sanitize \draftwatermark@tempa
+ \expandafter\def\expandafter\draftwatermark@tempb
+ \expandafter{\expandafter\@car \draftwatermark@tempa\@nil}%
+ \if \draftwatermark@tempb b%
+ \relax
+ \else\if \draftwatermark@tempb m%
+ \addtolength\@tempdimb{-0.5\ht\@tempboxa}%
+ \else\if \draftwatermark@tempb t%
+ \addtolength\@tempdimb{-\ht\@tempboxa}%
+ \else
+ \PackageError{draftwatermark}{%
+ Illegal anchor directive `\draftwatermark@tempb'}%
+ {Anchoring to top side.}%
+ \fi\fi\fi
+ \put(\@tempdima,\@tempdimb){\usebox\@tempboxa}%
+}
+
+% \end{macrocode}
+%
+% A wrapper to make the watermark printing conditional
+% \begin{macrocode}
+\newcommand\draftwatermark@print[1]{%
+ \ifdraftwatermark@stamp
+ \draftwatermark@printwm{#1}%
+ \fi}
+% \end{macrocode}
+%
+% \dots\, and finally the code to set up the \Lpack{everypage} hooks to
+% assure that the watermark printing commands are called when needed
+% \begin{macrocode}
+\ifdraftwatermark@firstpageonly
+ \AddToHookNext{shipout/background}{%
+ \draftwatermark@print{\draftwatermark@markcmd}}%
+\else
+ \AddToHook{shipout/background}{%
+ \draftwatermark@print{\draftwatermark@markcmd}}%
+\fi
+% \end{macrocode}
+% \iffalse
+%</draftwatermark>
+% \fi
+%
+% \subsection{Implementation of \Lpack{draftwatermark-2x}}
+%
+% Announce the name and version of the package, which requires
+% \LaTeXe.
+% \iffalse
+%<*draftwatermark-2x>
+% \fi
+% \begin{macrocode}
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{draftwatermark}%
+ [2020/12/06 2.3 Put a gray textual watermark on document pages]
% \end{macrocode}
%
@@ -749,6 +1044,11 @@
\RequirePackage{color}
% \end{macrocode}
+% Set up options and assumptions for the \Lpack{kvoptions} package
+% \begin{macrocode}
+\SetupKeyvalOptions{family=draftwatermark, prefix=draftwatermark@}
+
+% \end{macrocode}
%
% Define the configuration options and default values.
% \begin{macrocode}
@@ -879,9 +1179,11 @@
% \end{macro}
% \end{macro}
% \begin{macro}{\SetWatermarkText}
+% \changes{R2.3}{2020/12/06}{Fix legacy interface to accept
+% text including commas.}^^A
% Legacy command to set the text of the standard watermark
% \begin{macrocode}
-\newcommand\SetWatermarkText[1]{\DraftwatermarkOptions{text=#1}}
+\newcommand\SetWatermarkText[1]{\DraftwatermarkOptions{text={#1}}}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\SetWatermarColor}
@@ -985,30 +1287,31 @@
\AddEverypageHook{\draftwatermark@print{\draftwatermark@markcmd}}
\fi
% \end{macrocode}
-
-
% \iffalse
-%</draftwatermark>
+%</draftwatermark-2x>
% \fi
%
+%
% \Finale
+% \PrintChanges
+% \pagebreak[1]
% \PrintIndex
%
-%% \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 \~}
+% \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
%%% Local Variables:
diff --git a/Master/texmf-dist/source/latex/draftwatermark/draftwatermark.ins b/Master/texmf-dist/source/latex/draftwatermark/draftwatermark.ins
index 1365e64ebf6..151fcec0a01 100644
--- a/Master/texmf-dist/source/latex/draftwatermark/draftwatermark.ins
+++ b/Master/texmf-dist/source/latex/draftwatermark/draftwatermark.ins
@@ -7,12 +7,14 @@
%% a contribution to the LaTeX2e system.
%% ---------------------------------------------
%%
-%% It may be distributed and/or modified under the conditions of the LaTeX
-%% Project Public License, version 1.3. The license is at
-%% https://www.latex-project.org/lppl/ and is part of all distributions of
-%% LaTeX version 2005/12/01 or later.
+%% This work may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, version 1.3c.
+%% This license is in
+%% https://www.latex-project.org/lppl/lppl-1-3c/
+%% and is part of all distributions of LaTeX later than
+%% 2008-05-04.
%%
-%% This work has the LPPL maintenance status "author-maintained".
+%% This work has the LPPL maintenance status "maintained".
%%
%% This program consists of the files listed in the README.md file
%% included in the package.
@@ -43,35 +45,39 @@ a contribution to the LaTeX2e system.
This program consists of the files listed in the README.md file included
in the package.
-Any modified versions of this file must be renamed with new filenames distinct
-from draftwatermark.sty.
+Any modified versions of this file must be renamed with new filenames
+distinct from \outFileName.
For distribution of the original source see the terms for copying and
-modification in the file draftwatermark.dtx.
+modification in the file \inFileName.
-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
+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.)
\endpreamble
\Msg{*** Generating the LaTeX2e package files ***}
+\usedir{tex/latex/draftwatermark}
\generate{\file{draftwatermark.sty}{%
- \from{draftwatermark.dtx}{draftwatermark}}}
+ \from{draftwatermark.dtx}{draftwatermark}}}
+\generate{\file{draftwatermark-2x.sty}{%
+ \from{draftwatermark.dtx}{draftwatermark-2x}}}
\preamble
\endpreamble
\Msg{*** Generating the example files ***}
-\generate{\file{test_draftwatermark1.tex}{%
+\usedir{doc/latex/draftwatermark/examples}
+\generate{\file{test_draftwatermark-1.tex}{%
\from{draftwatermark.dtx}{samplecode-modern}}}
-\generate{\file{test_draftwatermark2.tex}{%
+\generate{\file{test_draftwatermark-2.tex}{%
\from{draftwatermark.dtx}{samplecode-legacy}}}
-\generate{\file{test_draftwatermark3.tex}{%
+\generate{\file{test_draftwatermark-3.tex}{%
\from{draftwatermark.dtx}{samplecode-anchor}}}
-\generate{\file{test_draftwatermark4.tex}{%
+\generate{\file{test_draftwatermark-4.tex}{%
\from{draftwatermark.dtx}{samplecode-dynamic}}}
-\generate{\file{test_draftwatermark5.tex}{%
+\generate{\file{test_draftwatermark-5.tex}{%
\from{draftwatermark.dtx}{samplecode-custom}}}
%\ReportTotals
@@ -84,14 +90,18 @@ necessarily be in the same archive or directory.)
\Msg{* \space\space draftwatermark.sty}
\Msg{*}
\Msg{*}
-\Msg{* To produce the documentation run draftwatermark.dtx}
-\Msg{* through LaTeX (or maybe pdfLaTeX).}
+\Msg{* To produce the documentation:
+run draftwatermark.dtx}
+\Msg{* - run draftwatermark.dtx through LaTeX}
\Msg{* Process draftwatermark.idx file by:}
\Msg{* \space\space\space\space makeindex -s gind.ist draftwatermark}
-%\Msg{* Process draftwatermark.glo file by:}
-%\Msg{* \space\space\space\space makeindex -s gglo.ist -o draftwatermark.gls
-% draftwatermark.glo}
+\Msg{* Process draftwatermark.glo file by:}
+\Msg{* \space\space\space\space makeindex -s gglo.ist -o draftwatermark.gls
+ draftwatermark.glo}
\Msg{* Re run through LaTeX the draftwatermark.dtx file as necessary}
+\Msg{* You may then want to move the test_draftwatermark*.tex files produced by}
+\Msg{* processing this ins file together with the documentation (e.g., in an}
+\Msg{* examples subdirectory}
\Msg{*}
\Msg{***********************************************************}