LaTeX - Xwatermark-Guide PDF
LaTeX - Xwatermark-Guide PDF
x w a t e r m a r k
x w a t e r m a r k
x w a t e r m a r k
x w a t e r m a r k
The xwatermark PackageI
Version 1.5.2a
Ahmed Musa
The University of Central Lancashire, Preston, UK
Abstract
The xwatermark package puts user-supplied watermarks (graphics and/or arbitrary texts) on se-
lect pages of documents using user-friendly key-value interfaces. It has more functionality and dy-
namism than, for example, the packages draftcopy, draftwatermark, watermark, draftmark,
wallpaper. More than one (graphics and/or text) watermark can be placed jointly or independ-
ently on the same document page or on select pages. Watermarks can be placed in the page
background or foreground, and watermarks can conveniently be placed on select pages as rectan-
gular or square tiles, depending on the user’s choice. Some utility macros, namely, \xwmminipage,
\xwmcolorbox, \makecolobox and \fancypagenos are also provided by the package for handy
use in creating watermarks and for other uses. Watermarks (especially wallpapers) take their toll
on computer resources, especially speed and save stack size. The packages in the xwatermark
bundle (and beyond) have been optimized as much as currently possible. In many instances
more than one run of the document will be needed to get the watermarks on the desired pages,
especially if the user calls \lastdocpage to get the last page of the document.
• License •
This work (i. e., all the files in the xwatermark manifest) may be distributed and/or modified under
the conditions of the LATEX Project Public License (LPPL), either version 1.3 of this license or any
later version. The LPPL maintenance status of this software is ‘author-maintained’. This software
is provided ‘as it is’, without warranty of any kind, either expressed or implied, including, but not
limited to, the implied warranties of merchantability and fitness for a particular purpose.
c MMXII
Contents
1 Introduction
puts user-specified watermarks (graphics and/or arbitrary texts) on
T selectxwatermark
HE PACKAGE
pages of documents. It has more functionality and dynamism than, for example, the
packages draftcopy, draftwatermark, watermark, draftmark and wallpaper packages. The
advantages of xwatermark package over these earlier packages include:
a) Both text and graphics watermarks are admissible within any watermark item or instance.
b) The user can dynamically customize the attributes (color, position, orientation, scale, the
page(s)—first page, last page, all pages, odd pages, even pages, a particular page, and a
Page 2 of 25
The xwatermark package 29th January 2012
2 User interfaces
Note 2.1 Some of the keys are ‘option keys’, i. e., they can appear only in \documentclass or
\usepackage and not as, or in, arguments of other functions or macros. The ‘non-option keys’
are those that can’t appear in \documentclass or \usepackage but in the arguments of other
macros. If a key is a non-option key and the user submits it to \documentclass or \usepackage,
the package will alert the user. The same thing can be expected when a key is an option key and is
submitted outside of \documentclass or \usepackage. The ‘need value’ keys are keys that can’t
be called without a user-supplied value.
The package keys printwatermark and disablegeometry are option keys, and hence can be called
as follows:
Package loading
1 \RequirePackage[printwatermark,disablegeometry]{xwatermark}
2 \usepackage[printwatermark,disablegeometry]{xwatermark}
The other options may be submitted via user commands like \newwatermark and \newwallpaper.
Please see Tables 1 and 2 for a full listing of all the available package and command options. By
design, the boolean option printwatermark should not appear in the macros \newwatermark
and \newwallpaper but as a package or \documentclass option. It is disabled just before
\begin{document} and any attempt to pass it via \newwatermark or \newwallpaper thereafter
will trigger an error.
Page 3 of 25
The xwatermark package 29th January 2012
When boolean options (e. g., printwatermark and allpages) are passed without values, they are
assumed implicitly true by the package.
Note 2.2 When your watermark is not printed, first check that the option printwatermark is
true. This is one of the means to control the printing of watermarks. The others are through the
following commands (more details are available in subsection 3.5):
The option textmark implies text watermarks, for which all the font properties can be selected.
It does not apply to graphics watermarks. For graphics watermarks you need the keys: picfile
(the graphics/picture filename, with its full path but without its extension), and picfileext (the
file extension). Admissible file extensions are ps, eps, pdf, png, mps and jpeg; they should be
submitted without the dot. The extensions ps and eps are for dvi files, while the rest are for pdf
runs. Additional information is needed (see section 5)H1 .
The following points should be noted about the values of the textmark:
a) The value of the textmark may be any arbitrary multi-line text, such as
Example: textmark
5 textmark=Hello world,\\[.25\baselineskip] We’re here.
b) The value of textmark may be arbitrary (blocks of) texts or even kernel or package com-
mands, but not filenames on their own (except when submitted as values of graphics keys).
The package has a user-friendly interface for inserting graphics watermarks and wallpapers,
which does not require the user to directly employ \includegraphics.
c) The textwidth and picwidth should be properly selected to match user’s taste and the
length of the textmark. It may be set to \paperwidth or \paperheight, or any arbitrary
length. Its default value is preset to \paperheight. Sometimes it might also be necessary
to suitably select the height, whose default value is \paperwidth.
d) If the longest line of a textmark is longer than \paperwidth and/or \paperheight (depend-
ing on the orientation of the textmark), then the fontsize and the textscale (or picscale)
options will have to be suitably chosen.
The boolean options firstpage, lastpage, allpages, firstpage, oddpages and evenpages,
which specify the pages that should receive watermarks, may be replaced by any of the options
page=x, pages=x-y, pagex={x,y,z}, where ‘x’, etc., stand for any page number. If you enter,
for example, pages=0-10, all pages from 1 to 10 will receive the watermark. On the other hand,
an entry like pages=10-0 will print watermark on page 10 only. If no page-specifying option is
given and printwatermark is true, watermark will appear only on the first page and a warning
message will be entered in the transcript file. When passing page=x or pages=x-y as option to
package, don’t forget to include the equality sign (=), otherwise the option will trigger an ‘unknown
option/key’ error. The key pages expects a page range with the pages separated by a hyphen,
while pagex expects a comma-separated list of pages. For obvious reasons, the value of the key
pagex must always be given in balanced curly braces.
H1 When the options align, height, width, angle, scale, xpos, ypos and color appear without prefixes such as
pic or text, they refer to the text watermark and not the graphics watermark. The user can thus use these
options in place of textalign, textheight, textwidth, textangle, textscale, textxpos, textypos and textcolor,
respectively. However, options referring to graphics watermarks must always be prefixed with pic (e. g., picfile).
Page 4 of 25
The xwatermark package 29th January 2012
When specifying package options either in \usepackage or \documentclass (or indeed in the
macros \newwatermark, \newwallpaper, \xwmminipage, \xwmcolorbox and \fancypagenos), the
following points should be noted:
a) Multiple lines are permitted but not blank lines.
b) Extra paces between options and words are ignored.
c) Active characters (those of catcode 13) may be allowed (but see subsection 6.10 for further
comments).
d) Options are mostly order-agnostic, except graphicsoptions, whose values take precedence
over those supplied via other keys (see subsection 5.1).
The global boolean option printwatermark=true (or =false) should ideally be set when loading
the package, e. g.,
The remaining options should ideally be set dynamically using the macro \newwatermark or
\newwallpaper. These other options can be set for each page, as on the pages of the accom-
panying example files.
where hkeyvali is the list of keys and their values (called the watermark attributes) and hmarki is
the text watermark. Graphics watermarks are to be specified with their file name, file extension,
etc. The full lists of the available keys for the macro \newwatermark and others are available in
section 13.
The starred (?) variant of \newwatermark puts the watermark in the foreground instead of the
background, and the prime (’) variant is ignored, i. e., no watermark is produced (see subsec-
tion 3.5).
The macro \newwatermark can be used as in
Example: \newwatermark
11 \newwatermark[pagex={2,5,7},fontfamily=bch,color=gray!25,angle=45,scale=3,
12 xpos=0,ypos=0]{DRAFT},
where the textmark has been enclosed in curly braces as the last argument of the macro. The
options (called the watermark attributes) are expected in square brackets. The textmark (which
Page 5 of 25
The xwatermark package 29th January 2012
is ‘DRAFT’ in the above example) can also be given within square brackets, in which case the
curly braces will be empty:
Example: \newwatermark
13 \newwatermark*[page=10,fontfamily=bch,color=gray!25,angle=45,scale=3,xpos=0,
14 ypos=0,textmark=DRAFT]{}.
The option printwatermark may appear in only \usepackage or \documentclass options list,
since it is disabled at \begin{document}. However, the options firstpage, lastpage, allpages,
oddpages and evenpages, etc., which specify watermark pages, can and should appear in the
command \newwatermark. This implies that the instructions that specify watermark pages may
be issued and superseded dynamically (page by page or chapter by chapter). For small documents,
this feature may be unnecessary, but it will be useful in large documents (such as a report or book),
in which the watermark may change from chapter to chapter.
When you want the watermark on only one page of the document, you can conveniently use the
\newwatermark macro with the page option page=hnoi in the preamble of your document after
issuing
Examples: \usepackage, printwatermark
15 \usepackage[printwatermark]{xwatermark}
In this way, you don’t have to bother with locating in the source file the spot that corresponds to
the page on which you want the watermark to appear. In fact, you can collect all the watermarks
in the document preamble or in a configuration file with the command \newwatermark.
Note 3.1 Each call to \newwatermark must contain the page(s) that will receive the watermark(s),
otherwise the user will be alerted. The page specifiers are:
then there will be no problem but the outcome may be unpredictable, depending on the key that
has no value. In the above example, no watermark will be printed (not even the default mark,
which is DRAFT) because empty textmark is valid and implies that no watermark should be printed.
The absence of fontfamily in ‘fontfamily=’ will compel (LA)TEX to use an arbitrary fontfamily
that isn’t the default (the default fontfamily is phv if the key fontfamily is not passed, and cmr
otherwise).
Page 6 of 25
The xwatermark package 29th January 2012
together with printwatermark=true but you don’t want the mark on any particular page, we
can simply set \newwatermark[other keys,textmark=]{} or, to the same effect, we may set
\newwatermark[other keys]{}, where ‘other keys’ may include the page specifiersH2 . These both
imply that the text watermark for the given page is empty. This can be useful when transiting from
one watermark type to another. Moreover, since both picture and text marks can be submitted
via one and the same command \newwatermark (see subsection 3.3), this technique may be used
to empty the text watermark for the given page or range of pages. For example,
Example: \newwatermark
22 \newwatermark[allpages,fontfamily=put,color=white,fontsize=3cm,scale=1,
23 picbb=112 619 242 751,picscale=3,picfile=./graphics/myfig,picfileext=eps,
24 width=\paperheight,align=center,angle=0,xpos=0,ypos=0]{}
will print only the picture watermark, since the textmark is empty here.
Example: \newwatermark
25 \newwatermark[pages=1-2,fontfamily=put,color=white,fontsize=3cm,scale=1,
26 picbb=112 619 242 751,picscale=3,picfile={./graphics/myfig},
27 picfileext=eps,width=\paperheight,align=center,angle=0,xpos=0,
28 ypos=0]{Hello World}
However, both the picture and text marks will then share the same subset of the attributes (posi-
tion, angle, align, etc.). When text and graphics watermarks appear on the same page, the recom-
mended approach is to submit the two types of watermark by two separate calls to \newwatermark.
H2 In the case of graphics watermarks, setting \newwatermark[other keys,picfile=]{} will prompt a ‘no file’ error.
Page 7 of 25
The xwatermark package 29th January 2012
the macros \newwatermark and \dummywatermark have the same syntax and expect the same
number and types of arguments:
And when you don’t want any of your watermarks printed, you could simply issue the option
printwatermark=false or call the command \DiscardAllWatermarks. These will simply turn
all instances of \newwatermark command into \dummywatermark. In any run, you may de-
cide to use some or all of the dummy watermarks. To use all dummy watermarks, you issue
the command \UseDummyWatermarks before the instances of \dummywatermark. To again dis-
regard all subsequent dummy watermarks, which is the default state, simply call the command
\DiscardDummyWatermarks. These commands provide a convenient scheme for deciding the wa-
termarks to be printed with minimal typing. For wallpapers, there is the corresponding command
\dummywallpaper. Also, putting a prime sign (’) on \newwatermark or \newwallpaper turns the
command into a dummy mark, but only for that single instance. Subsequent \newwatermark and
\newwallpaper without primes will produce watermarks and wallpapers, respectively.
4 Wallpapers
where hkeyvali is the list of keys and their values (called the attributes) and hmarki is the text
(and not graphics) watermark. Graphics watermarks are again to be specified with their file name,
file extension, etc. The full lists of the available keys for the macro \newwallpaper are available
in Table 2.
The starred (?) variant of \newwallpaper puts the watermark in the foreground instead of the
background, and the prime (’) variant is ignored, i. e., no wallpaper is produced (see subsection 3.5).
When you get unexpected tiles, you first should consider enabling or disabling the keys squaretiles
(default true) and/or boxalign (default center). The key boxalign may assume one of the values
in the set t-l, t-r, b-l, b-r, s or top-left, top-right, bottom-left, bottom-right, center,
justified.
5 Graphics watermarks
For graphics/picture watermarks, you need the picfile (the graphics filename, with its full path
but without its extension), picfileext (the picture filename extension without the dot), picbb
(the picture bounding box), and picscale (the picture scale)H3 . Admissible file extensions are
Page 8 of 25
The xwatermark package 29th January 2012
eps, pdf, png and jpeg; the latter three, but not the first, may be used in the case of pdfTEX.
The file extension should be passed without the dot. If the file extension is not passed to package,
the package selects it automatically based on whether pdfTEX mode is running or not (normal
extensions are eps for dvi mode and pdf for pdfTEX mode). In fact, the package does search hard
on the given paths for other admissible file types with the base filename the user has specified. If
you have the graphics file in both eps and pdf-compatible formats, then you don’t have to bother
about submitting the file extension to the package: it will automatically select the appropriate file
extension, depending on the mode (pdf or dvi) in which it is running.
c) Key values submitted via graphicsoptions supersede those submitted outside it, even
if those outside graphicsoptions appear earlier than graphicsoptions in the command
\newwatermark or \newwallpaper.
d) Values submitted via graphicsoptions have only local effect, in the sense that they become
null and void outside of \newwatermark or \newwallpaper. If the user wants the key values
submitted via graphicsoptions to prevail for all subsequent watermarks and wallpapers,
then he should use the command \GraphicsOptions. Values passed via \GraphicsOptions
don’t only have global effect, but they always override those submitted via graphicsoptions.
It should be noted that \GraphicsOptions isn’t a key but a stand-alone command with the
following syntax:
where hkeyvali are admissible keys for the command \includegraphics and their user-supplied
values. The values so suggested by \GraphicsOptions override those given via the keys of the
xwatermark, including graphicsoptions. Such values remain in force until they are changed later
by another call to \GraphicsOptions.
An example follows:
Example: graphicsoptions
39 \newwallpaper[%
40 page=10,picangle=45,tilexoffset=0pt,tileyoffset=0pt,picontoptext=false,
41 boxalign=top-left,picbb=116 428 477 718,picscale=2,picfile=tabu-test1,
42 tileno=4,picfileext=pdf,graphicsoptions={clip,keepaspectratio,hiresbb}
43 ]{mypicture}
Page 9 of 25
The xwatermark package 29th January 2012
44 % or globally as
45 \GraphicsOptions{clip=true,keepaspectratio,hiresbb}
Users can suggest the possible locations of the graphics watermarks to the package by using the
command \watermarkpaths, whose syntaxes are
Here, hprei and hposti are optional arguments that apply to all the given paths. Caution should
be exercised when using these optional arguments, since when used incorrectly they can yield the
wrong path (see the example below). In the unstarred variant all the paths must be provided in
surrounding curly braces and must have no commas, otherwise the package will raise an error. The
starred (?) variant expects paths to be separated by commas. The package works hard to find your
watermark on the suggested path.
Examples: \watermarkpaths
48 \watermarkpaths{{./}{./graphics/}{./graphics/recentfiles/}}
49 \watermarkpaths?{./,./graphics/,./graphics/recentfiles/}
50 \watermarkpaths(/){{.}{./graphics}{./graphics/recentfiles}}
51 \watermarkpaths?(/){.,./graphics,./graphics/recentfiles}
52 % Note the empty balanced braces below. Without them, the first entry
53 % (which is supposed to be {./}) will be wrong:
54 \watermarkpaths[.](/){{}{/graphics}{/graphics/recentfiles}}
55 \watermarkpaths?[.](/){{},/graphics,/graphics/recentfiles}
By default, the packages works hard to preserve outer curly braces, unless and until they are
required to be removed.
The command \watermarkpaths inherits the current contents of LATEX’s \input@path command
and graphics package’s \Ginput@path (the latter takes argument from \graphicspath).
The package is set to inherit the \documentclass options, if the options apply to the package.
Therefore, some of the package options can be passed to the package via the \documentclass
options list. This is perhaps most appropriate in the case of the option printwatermark. How-
ever, package options supersede those passed via the \documentclass. For example, the option
printwatermark=true in the \documentclass options list can normally be superseded by the
option printwatermark=false in loading the xwatermark package, e. g., as in
Page 10 of 25
The xwatermark package 29th January 2012
and vice versa. It should, however, be noted that some package options and keys are restricted
either to the \documentclass and \usepackage (this applies to the so-called ‘option keys’) or to
the various user macros (in the case of ‘non-option keys’). Normally, the package will alert the
user to the wrong call of any of the options and keys.
If you don’t need the watermark on any page of your document, simply replace the option
printwatermark (=true) with printwatermark=false in \usepackage or \documentclass. If
you have specified printwatermark (=true) in the \documentclass options list but you still
don’t need the watermark on any page of your document, then you would have to use the tools of
subsection 3.5.
The watermark coordinates (specified by xpos and ypos) have their origin at the center of the page
and are with respect to the geometric center of the watermark. The default unit is millimeter,
but this can be changed on any page by changing the value of coordunit. For example,
If you discover that the watermark is wrongly positioned on the page(s) of your document, as some
users have had course to complain, the chances are that you have submitted wrong coordinates
(values of xpos and ypos) to the package or the watermark’s width (textwidth or picwidth) is
not optimal or both reasons. The package does not take responsibility for this and will normally
not warn you in this respect. Since the output file provides a direct and simple indication of the
occurrence of the anomaly, no attempt has been made in the package to warn users in this regard.
If you do not specify the keys xpos and/or ypos at all in the call to \newwatermark, their default
values will be used by the package. Also, if you list these keys without their values in the call to
\newwatermark, their default values (xpos=0 and ypos=0, which yield the center of paper) will be
assumed by the package. The default value of the watermark’s width is \paperheight, and not
\paperwidth as might be expected.
When the geometry package is loaded together with the xwatermark package, page layout scale
changes by the geometry package may result in the watermarks being positioned slightly away
from the intended position. See section 9 for further details.
Page 11 of 25
The xwatermark package 29th January 2012
should check the global and local scale and width of the watermark. It is most likely that the chosen
combination is wrong or inconsistent. Global and local package options are described in section 13.
For example, choosing scale=0.7 and width=\paperwidth may yield something unexpected. So
will mixing inconsistent global and local scales or width, or both.
Example
58 \newwatermark[evenpages,fontfamily=ptm,angle=45,scale=.7,
59 align=center,color=green,xpos=0,ypos=0]{Directorate\\[.25ex]Only}
60 \newwatermark[allpages,fontfamily=ptm,angle=45,scale=.8,align=left,
61 color=green,xpos=0,ypos=0]{Control\\[.25ex]Version}.
More complex examples are available in the example source and pdf files that shipped with this
package.
The alignment of the watermark is controlled by the keys align, textalign and boxalign. The
first two are equivalent and may be set to center, left, right or justified. The default is
center. This is particularly useful for putting arbitrary texts (that are not necessarily watermarks)
on pages of documents. The admissible values for the key boxalign are given in Table 2.
In case you need to locate the paper/page center for placing the watermark or some other material
at any position on the page, a two-line grid can be placed on the page background with the key
showpagecenter, which may be issued (dynamically for each page) with the \newwatermark macro
as follows:
Example: showpagecenter
62 \newwatermark[allpages,showpagecenter]{}
63 \newwatermark[page=1,showpagecenter=true]{}
64 \newwatermark[allpages,showpagecenter,fontfamily=ptm,angle=60,scale=.7,
65 color=brown!25!yellow!75,coordunit=cc,xpos=0,ypos=0]{Confidential!}.
If after issuing this command to get a centered grid on a page, you no longer require the grid on
the following pages, you simply issue another
Example
66 \newwatermark[pages=1-2,showpagecenter=false]{}
67 \newwatermark[page=10-\lastdocpage,showpagecenter=false,fontfamily=panr,
68 angle=60,scale=.7,color=brown!25!yellow!75,coordunit=cc,xpos=0,ypos=0]
69 {Confidential!}
Page 12 of 25
The xwatermark package 29th January 2012
Active characters (i. e., those of category 13) and expandable commands can normally be used as
values of the textmark key in the \newwatermark macro. However, such values cannot be passed
via the \documentclass or the \usepackage{xwatermark} command without first loading one of
the packages: xkvltxp, kvoptions-patch and catoptions packages. That is, the following should
work:
Example
72 \RequirePackage{catoptions}
73 \documentclass[myoption={My watermark,\\[2ex]
74 designed~by \textsc{Mr.~J\"ohnson}}]{class-file}
75 \begin{document}
76 Blackberry lily ...
77 \end{document}
In plain TEX the only active character is the tie character (i. e., \nobreakspace). However,
some packages do make some other characters active. For example, after issuing the command
\MakeShortVerb{\x}, the packages doc and shortvrb make the character x activeH4 . The user
can use such active characters in values of the textmark key without locally changing their catcode
to 11 or 12. In the case of \MakeShortVerb{\x}, you can issue \DeleteShortVerb{\x} to revert
to normal use of character x. As another example, the option turkish of the babel package uses
the equal sign (=) as active shorthand character.
Page 13 of 25
The xwatermark package 29th January 2012
The textcolor key in \xwmminipage is the color of the text. In the case of \xwmcolorbox,
four color values are expected: textcolor, fillcolor, outerframecolor and innerframecolor.
Texts with commas need to be enclosed in braces when submitted to these macros. The default
values of the keys of these macros are described in subsection 13.2.
The macros \xwmminipage and \xwmcolorbox can be nested within and among themselves, e. g.,
Example: \xwmminipage
80 \newwatermark[pagex={1,3,10},fontfamily=txtt,fontseries=m,color=red,
81 align=center,scale=0.7,angle=0,xpos=0,ypos=0]{%
82 \xwmminipage[width=\paperwidth]{%
83 \xwmminipage[width=\paperwidth,align=left,textcolor=magenta]
84 {\TeX\\[.1ex] \LaTeX}\\[1ex]
85 \xwmminipage[width=\paperwidth,align=center,textcolor=green]
86 {\TeX\\[.1ex] \LaTeX}\\[1ex]
87 \xwmminipage[width=\paperwidth,align=right,textcolor=orange]
88 {\TeX\\[.1ex] \LaTeX}%
89 }%
90 }
More complicated examples can be found in the example files. But some of the complications
found in the example files are unnecessary since several simple watermarks can be placed on the
same document page by specifying the same page number for those simple watermarks.
H5 The xwatermark package also comes with the macro \xwmshade which is similar to \xwmcolorbox, but which,
unlike \xwmcolorbox, can break neatly across pages (in the manner of the framed package). But since no watermark
is expected to break across pages, the macro \xwmshade isn’t described in this guide. Power users should still be
able to use it.
Page 14 of 25
The xwatermark package 29th January 2012
Notice here that the macro \makecolorbox calls the macro \xwmcolorbox.
Even after issuing the command \fancypagenos, you can still decide not to print the fancy
page numbers by calling the command \NoFancyPageNumbers. The complement of the command
\NoFancyPageNumbers is \FancyPageNumbers.
Page 15 of 25
The xwatermark package 29th January 2012
level’ will involve simply calling this macro within the xwatermark package whenever xwatermark
detects that the geometry package has been loaded by the user. This is what has been done in the
xwatermark package: the package has a boolean option called disablegeometry, which, if true,
invokes the command \Gm@dorg of the geometry package to disable geometry package settings
and enforce native paper layout dimensions. First the xwatermark package detects at the very
last moment of the document preamble (just before \begin{document}) if the geometry package
has been loaded by the user. If yes, and if the user has suggested disablegeometry=true in the
call to xwatermark, then xwatermark issues the command \geometry{pass}, which, as mentioned
earlier, calls \Gm@dorg.
After the effects of the geometry package are re-introduced (i. e., after setting the xwatermark
package option disablegeometry=false), it might still be necessary, depending on the user need,
to fine-tune the positions of the watermarks.
Because the geometry package stipulates that the command \Gm@dorg can be issued only in the
document preamble, the switch disablegeometry can appear as option only in \documentclass or
\usepackage{xwatermark}. But it matters not which of the two packages (geometry, xwatermark)
is loaded first. To call \Gm@dorg, the xwatermark package uses the hook \BeforeStartOfDocument
from the catoptions package. \AtBeginDocument, a native LATEX hook, is inapplicable in this
case.
Example: \newfontfamily
102 \newfontfamily{\chinese}{STFangsong} % SinoType FangSong
106 \newwatermark[allpages,fontsize=5cm,align=center,
107 color=red!75!blue!25,angle=90,xpos=-65,ypos=-38,scale=.49]
108 {=\fbox{\color{red!65}\chtext{watermark in Chinese or Japanese script}}=}
110 \newwatermark[allpages,fontsize=5cm,scale=.46,align=center,
111 angle=90,color=red!75!blue!25,xpos=-72,ypos=-38]
112 {=\fbox{\color{red!65}\Gara The different ligature}=\\[.35ex]}.
It doesn’t matter what the user declares as a fontfamily provided he/she declares it before using
it and provided the declaration is valid. It is thus possible to mix scripts in one watermark (e. g.,
Latin, Chinese, Korean, Japanese, Arabic, Russian scripts, you name it).
Page 16 of 25
The xwatermark package 29th January 2012
problem is that the default mechanisms of graphics usage add the image at every point it is to be
used, and when processed, the image appears in the output file at each such point.
See the uktug fag, version 3.20 (2010), entry number 146, page 95, for the available solutions to
this problem. As described by this reference, if the PostScript version of the file is destined for
conversion to pdf, either by a ghostscript-based mechanism such as ps2pdf or by, for example,
Acrobat Distiller, the issue is not as important, since the distillation mechanism will amalgamate
graphics objects whether or not the PostScript has them amalgamated. pdfTEX does the same
job with graphics, automatically converting multiple insertions into pointers to graphics objects.
See also the \pdfxform command and instructions about XObjects in pdfTEX user manual.
All the keys in this table are ‘option keys’, i. e., they can appear only in \documentclass or
\usepackage. If a key is an option key and it is issued in functions other than \documentclass
or \usepackage, the package will alert the user to that effect.
Option Default Meaning
defaultfirstpage, The default first page of document, when the first
1
default-first-page page hasn’t been known yet.
defaultlastpage, The default last page of document, when the last
1
default-last-page page has’t been shipped out yet.
draft false The document is in draft mode.See note 1.1
final true The document is in final mode.
This option determines whether the page layout
disablegeometry, settings by the geometry package should be dis-
false
disable-geometry abled so that the watermarks can be set more
readily by xwatermark.1.2
frontpagestyle, The style of the front page, in the sense of the
empty
front-page-style fancyhdr package.
picontoptext, The boolean that determines if picture watermark
pic-on-top-text, true is placed on top of text watermark or otherwise,
picture-on-top-text when they occur at the same location on a page.
printwatermark, The global boolean switch that determines
true
print-watermark whether watermarks should be printed or not.1.3
Continued on next page
Page 17 of 25
The xwatermark package 29th January 2012
Table 1 notes
1.1 draft and final are complementary (biboolean) options, i. e., when one is true, the other is auto-
Most of the keys in this table are ‘non-option keys’, i. e., they can’t appear in \documentclass or
\usepackage but in the arguments of the given functions. If a key is a non-option key and the user
submits it to \documentclass or \usepackage, the package will alert the user.
Option Default Meaning
\newwatermark macro
angle, textangle,
0◦ The orientation of text watermark.
text-angle
Continued on next page
Page 18 of 25
The xwatermark package 29th January 2012
Page 19 of 25
The xwatermark package 29th January 2012
Page 20 of 25
The xwatermark package 29th January 2012
Page 21 of 25
The xwatermark package 29th January 2012
Table 2 notes
2.1 The key can assume only one of the values center, left, right and justified. Any other text
alignment value is inadmissible and thus rejected by the package with a fatal error.
Page 22 of 25
The xwatermark package 29th January 2012
2.2 The options allpages, evenpages, oddpages are boolean keys, while page, pages and pagex require
values, e. g., page=x, pages=x-y and pagex={x,y,z}. If the package is loaded and none of these options is
passed to it, but the option printwatermark is true, the default watermark (DRAFT) will be printed on
the first page of the document (but only in draft mode) and a warning message logged in the transcript
file. The key pages expects a page range with the pages separated by a hyphen, while pagex expects a
list of pages that will receive the watermarks.
2.3 Both text and picture watermarks are normally put in boxes for manipulation before being typeset.
This key refers to the horizontal and vertical alignments of the box. The key can assume one of the
values t-l, t-r, b-l, b-r, s, or top-left, top-right, bottom-left, bottom-right, center, justified.
Elements of these two sets can’t be combined. When submitted as key values, the elements of both sets
are not to be separated by commas or spaces but by hyphens (e. g., one of t-l, t-r, b-l, b-r, s, or one
of top-left, top-right, bottom-left, bottom-right, center, justified).
2.4If for some reason you need other fontsizes (e. g., 10pt, 11pt or 12pt for printing text watermarks in
\normalfont), you will need to submit them as values of fontsize.
2.5 If you need normal document text, put fontseries=m, which implies medium weight and width.
2.6 The command \includegraphics is used for all graphics inclusion tasks. Users can directly pass
values to admissible options of the command \includegraphics. See subsection 5.1.
2.7 This, with its full path, must be submitted when including picture watermark.
2.8 Valid extensions are eps, pdf, png, jpeg, mps; the latter four may be used in the case of pdfT X.
E
The file extension should be passed without the dot. If the option is not passed to package, xwatermark
selects eps (in dvi mode) or pdf (in pdfTEX mode).
2.9 For some design reasons we set \paperheight as the default value of mark’s width instead of mark’s
height.
2.10 There
is no need to attach a unit to xpos or ypos; if the user does, the unit will be used in place of
coordunit.
2.11 Some of the \newwatermark keys can also be called when inserting wallpapers. If you aren’t sure if a
key is applicable, don’t worry: just try it. The package collects all inadmissible keys together and prints
them in the transcript file on each run. Normally, the user is alerted by an error message. Indeed if you
receive any failed compilation, you should first suspect that the failure is due to the use of an invalid key.
The next keys apply specifically to wallpaper watermarks.
2.12 The key can assume only one of the values center, left, right and justified.
2.13 The
key can assume one of the values t-l, t-r, b-l, b-r, s, or top-left, top-right, bottom-left,
bottom-right, center, justified. When submitted as key values, the elements are not to be separated
by commas or spaces but by hyphens (e. g., one of t-l, t-r, b-l, b-r, s, or one of top-left, top-right,
bottom-left, bottom-right, center, justified).
2.14 If tilexsize and tileysize are given and squaretiles is false, tileno is ignored.
2.15 Sometimes choosing squaretiles (i. e., setting it true) can yield an undesired outcome if textalign
and boxalign haven’t been properly selected. In such a situation, the user is advised to first experiment
with setting squaretiles to false and/or textalign and boxalign to center.
2.16 The \xwmminipage command can take verbatim material and provides a hkeyi=hvaluei alternative
to the \boxedminipage command of the boxedminipage package.
2.17 All headers and footers are as in fancyhdr package.
14 Version history
The following change history highlights significant changes that affect user utilities and interfaces;
changes of technical nature are not documented in this section. The star sign (?) on the right-hand
side of the following lists means the subject features in the package but is not reflected anywhere
in this user guide.
Version 1.5.2a[2012/02/01]
New command \xwm@stripallouterbraces introduced . . . . . . . . . . . . . . . . . . . . ?
Page 23 of 25
The xwatermark package 29th January 2012
Version 1.5.2[2011/10/20]
To match changes in ltxkeys package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ?
Version 1.5.1[2011/07/20]
Following user request, two new keys were introduced for the macro \fancypagenos . section 8
Version 1.5.0[2011/07/10]
Introduced the ltxkeys package, a highly robust and optimized module for general creation and
management of keys . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ?
Provisions for placing more than one watermark on the same page. . . . . . . . . . . section 3
Introduced wallpaper functionalities . . . . . . . . . . . . . . . . . . . . . . . . . . . . section 4
Adaptable and flexible fancy page numbers . . . . . . . . . . . . . . . . . . . . . . . . section 8
Page 24 of 25
The xwatermark package 29th January 2012
Index
Index numbers refer to page numbers.
D boxedminipage . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
\DiscardAllWatermarks . . . . . . . . . . . . . . . . . . . . . . . 4, 8 catoptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13, 16
\DiscardDummyWatermarks . . . . . . . . . . . . . . . . . . . . 4, 8 doc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
\dummywallpaper . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 draftcopy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1, 2
\dummywatermark . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4, 8 draftmark . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1, 2
draftwatermark . . . . . . . . . . . . . . . . . . . . . . . . . . 1, 2
F fancyhdr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
\fancypagenos . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 fancyvrb . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
\FancyPageNumbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 framed. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14
Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . geometry . . . . . . . . . . . . . . . . . . . . . . . . . 2, 11, 15–18
xwatermark-examples1.tex . . . . . . . . . . . . . . . . 17 graphics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
xwatermark-examples2.tex . . . . . . . . . . . . . . . . 17 graphicx . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
kvoptions-patch . . . . . . . . . . . . . . . . . . . . . . . . . . 13
G ltxkeys . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3, 24
\GraphicsOptions . . . . . . . . . . . . . . . . . . . . . . . . . . . 9, 10 shortvrb . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
graphicsoptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5, 9 wallpaper . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1, 2
watermark . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1, 2
I xcolor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3, 14
\includegraphics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 xkvltxp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
xwatermark . . . . . . . . . . . . . . 1–3, 9–11, 13–18, 23
L xwmgrid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
\lastdocpage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
S
M Size of the watermark . . . . . . . . . . . . . . . . . . . . . . . . 11
\makecolorbox . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
U
N \UseDummyWatermarks . . . . . . . . . . . . . . . . . . . . . . . . . 4, 8
\newfontfamily . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
\newwallpaper . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 W
\newwatermark . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 \watermarkpaths . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
\NoFancyPageNumbers . . . . . . . . . . . . . . . . . . . . . . . . . . 15
X
P \xwmcolorbox . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . \xwmgetpagenumber . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
babel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 \xwmminipage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Page 25 of 25