diff options
Diffstat (limited to 'Master/texmf-dist/doc/latex/xwatermark/xwatermark-guide.tex')
-rw-r--r-- | Master/texmf-dist/doc/latex/xwatermark/xwatermark-guide.tex | 1076 |
1 files changed, 591 insertions, 485 deletions
diff --git a/Master/texmf-dist/doc/latex/xwatermark/xwatermark-guide.tex b/Master/texmf-dist/doc/latex/xwatermark/xwatermark-guide.tex index 45298543936..7fc6792dc5e 100644 --- a/Master/texmf-dist/doc/latex/xwatermark/xwatermark-guide.tex +++ b/Master/texmf-dist/doc/latex/xwatermark/xwatermark-guide.tex @@ -1,547 +1,653 @@ -%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++% -% This is file xwatermark-guide.tex, the documentation for the % -% xwatermark package, version 1.4. % -% % -% (c) Ahmed Musa 2010 (a.musa@rocketmail.com) % -%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++% -\documentclass[a4paper,11pt,final]{article} -\InputIfFileExists{xwatermark-guide.cfg}{}{% - \errmessage{No file xwatermark-guide.cfg or wrong path}} -\begin{document} -\MakeShortVerb{\+} -\watermarksetup{fontfamily=phv,fontsize=11pt,fontseries=m,align=center, - height=\paperheight,width=\paperheight,angle=90,scale=1,xcoord=0,ycoord=-1, - textmark=\xtempa +\makeatletter +\documentclass[ + use-a4-paper, + use-10pt-font, + final-version, + use-UK-English, + fancy-section-headings, + frame-section-numbers, + para-abstract-style, + input-config-file, + no-hyperref-messages, + option-stack-limit=4, + inputfile=true +]{amltxdoc} + +\makeindex +\ifdefTF\newgeometry{}{% + \let\newgeometry\@gobble + \let\restoregeometry\relax } -\label{page:one} -\title{\bfseries The \texttt{\textcolor{blue}{xwatermark}} - \xcopyright{Package}{red}\kern-.25em\FootnoteB{\ding{'111}}{The \stya{xwatermark} - bundle is available at the Comprehensive \nTeX Archive Network - \citeurl{http://tug.ctan.org/tex-archive/macros/latex/contrib/xwatermark}} - \\[1ex]\large Version 1.4 +\begin{document} + +\begin{frontmatter} +\title{The \texttt{\color{blue}xwatermark} Package\titleref{t1}} +\titlenote[t1]{The package is available at + \iftogTF{pdf}{\url{\@titleurl}}{\url{\@shorttitleurl}}. } -\author{Ahmed Musa\\[1ex]University of Central Lancashire\\ - Preston PR1 2HE, United Kingdom\\[1ex] - \email{a.musa@rocketmail.com} +\version{1.5.1} +\titleurl{http://www.ctan.org/tex-archive/macros/latex/contrib/xwatermark/} +\shorttitleurl{http://www.ctan.org/} +\author{Ahmed Musa\Email{amusa22@gmail.com}\\Preston, Lancashire, UK} + +\let\abstractname\relax +\begin{abstract} +\makecolorbox[framesep=4pt, framerule=1pt, innerframecolor=red!55, + outerframecolor=ForestGreen, align=justified, fillcolor=white, + width=\textwidth, boxalign=center, height=.25cm, depth=0cm,framebox]{% + \centering\xwmcolorbox[align=center, fillcolor=white, innerframecolor=blue, outerframecolor=orange, width=.5\hsize, height=2.5mm]{\textbf{Abstract}} \\[\baselineskip] + The \pkg{xwatermark} package puts user-supplied watermarks (graphics and/or arbitrary texts) on select pages of documents using user-friendly key-value interfaces. It has more functionality and dynamism than, for example, the packages \pkg'{draftcopy, draftwatermark, watermark, draftmark, wallpaper}. More than one (graphics and/or text) watermark can be placed jointly or independently 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 rectangular or square tiles, depending on the user's choice. Some utility macros, namely, \ffx'{\xwmminipage, \xwmcolorbox, \makecolobox, \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 \pkg{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 \fx{\lastdocpage} to get the last page of the document. } -\xmaketitle[empty] +\end{abstract} +\end{frontmatter} -\ywcolorbox{framesep=5pt,framerule=2pt,framecolor=red!55!brown, - align=justified,fillcolor=gray!25,width=\hsize, - text=\xtempb -} +\vspace{4\baselineskip} -\bgroup\small\tableofcontents\egroup +\newpage -\watermarksetup{textmark={}} -\watermarksetup{fontfamily=phv,fontsize=11pt,fontseries=m,align=center, - height=\paperheight,width=\paperheight,angle=90,scale=1,xcoord=0,ycoord=-1, - textmark=\xtempc -} +\begin{xwmshade}[fillcolor=white,framecolor=orange,framerule=1pt,framesep=2pt, + width=\hsize]\tableofcontents +\end{xwmshade} + + +\docsection(sec:intro){Introduction} + +\lletter{T}{he \pkg'{xwatermark}} puts user-specified watermarks (graphics and/or arbitrary texts) on select pages of documents. It has more functionality and dynamism than, for example, the packages \pkg'{draftcopy, draftwatermark, watermark, draftmark}. The advantages of \pkg'{xwatermark} over these earlier packages include: + +\begin{enum} +\item Both text and graphics watermarks are admissible within any watermark item or instance. +\item 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 range of pages---on which the watermark should appear) of each watermark. +\item Watermarks can be placed in the background and in the foreground of document pages by simple instructions. +\item Rectangular and square wallpapers can be produced from watermarks to suit user needs without effort. +\item All the command options/keys are passed directly via user-friendly key-value interfaces, instead of being defined in the source file by several macros. There are only two main user commands: \ffx'{\newwatermark, \newwallpaper}. The user is relieved of the need to remember and deploy several different macros, except, of course, that function keys are used. The list of keys and their default values for these functions are given in \amref{sec:packageoptions}. +\end{enum} + +With the \pkg'{xcolor} (not loaded automatically by the \pkg'{xwatermark}), all colors (including \hx{white}, shades like \hx{-red!75!green!50}, and those defined within the user document) can be passed to this package. And, as mentioned above, both texts and pictures can be submitted and printed as watermarks on the same page, and on different positions. + +There are global and local package options. These are listed and explained in +\amref{sec:packageoptions}. + +Users who have since complained of not being able to conveniently place more than one watermark on the same page can now heave a sigh relieve: the current version of the package has enabled this functionality. You can now mix text and graphics watermarks and wallpapers and place as many of them as you like on the same page. This version of the package comes with an optimized looping macro and a key management system (the \pkg'{ltxkeys}) to enable several watermarks and wallpapers to be placed efficiently on the same document pages. + + +\docsection(sec:user-interface){User interfaces} + +\docsubsection{Loading the package} + +In style files the package may be loaded with \hx{\RequirePackage} and in document files with \hx{\usepackage} together with the package keys that can be passed as options. + +\Note Some of the keys are \quoted{option keys}, \ie, they can appear only in \hx{\documentclass} or \hx{\usepackage} and not as, or in, arguments of other functions or macros. The \quoted{non-option keys} are those that can't appear in \hx{\documentclass} or \hx{\usepackage} but in the arguments of other macros. If a key is a non-option key and the user submits it to \hx{\documentclass} or \hx{\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 \hx{\documentclass} or \hx{\usepackage}. The \quoted{need value} keys are keys that can't be called without a user-supplied value. + +The package keys \ffx'{printwatermark, disablegeometry} are option keys, and hence can be called as follows: + +\start'{example}[Package loading] +\RequirePackage[printwatermark,disablegeometry]{xwatermark}|label(mac:pkgload) +\usepackage[printwatermark,disablegeometry]{xwatermark} +\finish{example} + +The other options may be submitted via user commands like \ffx'{\newwatermark, \newwallpaper}. Please see \amrefrange[tab:]{globaloptions,localoptions} for a full listing of all the available package and command options. By design, the boolean option \fx{printwatermark} should not appear in the macros \ffx'{\newwatermark, \newwallpaper} but as a package or \hx{\documentclass} option. It is disabled just before \hx{\begin{document}} and any attempt to pass it via \fx{\newwatermark} or \fx{\newwallpaper} thereafter will trigger an error. + +When boolean options (\eg, \ffx'{printwatermark,allpages}) are passed without values, they are assumed implicitly \hx{true} by the package. + +\Note When your watermark is not printed, first check that the option \fx{printwatermark} is \texttt{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 \amref{sec:dummywatermarks}): + +\start+'{newmacro}[\dummywatermark, \DiscardAllWatermarks, etc] +\dummywatermark, \DiscardAllWatermarks, \UseDummyWatermarks, +\DiscardDummyWatermarks +\finish{newmacro} +\fxi*{\dummywatermark, \DiscardAllWatermarks, + \UseDummyWatermarks, \DiscardDummyWatermarks} + +The option \fx{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: \fx{picfile} (the graphics/picture filename, with its full path but without its extension), and \fx{picfileext} (the file extension). Admissible file extensions are \hhx'{ps,eps,pdf,png,mps,jpeg}; they should be submitted without the dot. The extensions \hhx'{ps,eps} are for \hx{dvi} files, while the rest are for \hx{pdf} runs. Additional information is needed (see \amref{sec:pic-watermark})\footnote{When the options \ffx'{align ,height, width, angle, scale, xpos, ypos, color} appear without prefixes such as \fx{pic} or \fx{text}, they refer to the text watermark and not the graphics watermark. The user can thus use these options in place of \ffx'{textalign,textheight,textwidth, textangle, textscale, textxpos, textypos, textcolor}, respectively. However, options referring to graphics watermarks must always be prefixed with \fx{pic} (\eg, picfile).}. + +The following points should be noted about the values of the \fx{textmark}: -\section{Introduction} - -\lletter{T}{his package} puts user-specified watermarks, pictures and/or arbitrary texts on select pages of documents. It has more functionality and dynamism than, for example, the packages \styb{draftcopy}, \styb{draftwatermark}, \styb{watermark}, and \styb{draftmark}\footnote{ These and other packages are available at the TUG CTAN website (\url{http://tug.ctan.org/cgi-bin/}).}. The advantages of \stya{xwatermark} package over these earlier packages include: both text and graphic watermarks are admissible; the user can specify his/her own watermark and color, the watermark position, orientation, the page(s) (all pages, odd pages, even pages, a particular page, and a range of pages) on which the watermark should appear; and all the options are passed directly to the package instead of being defined in the source file by several macros. Moreover, all these options can be customized for individual pages and segments of the document. This is achieved by the provision of the user-friendly \wmsetup macro, by which the user can dynamically set the watermark properties for each page or range of pages. The user is relieved of the need to remember and deploy several macros. - -With the \styb{xcolor} package (loaded by this package), all colors (including \styb{white}, shades like \styb{-red!75!green!50}, and those defined within the user document) can be passed to this package. And, as mentioned above, both texts and pictures can be submitted as watermarks to the package. - -This package uses Heiko Oberdiek's shipout hooks from the \styb{atbegshi} package. - -There are global and local package options. These are listed and explained in Appendix~\ref{sec:PackageOptions}. - -\section{User interface} -\lletter{T}{he subsections} under this section describe how the user may interface with (\ie, use) the facilities of the package. - -\subsection{Loading the package} -In the case of text watermarks, the package may be loaded with options such as in -\begin{xwverbatim} -\usepackage[ - printwatermark=true,allpages=true,fontfamily=pag, - color=gray!25,textmark=I am happy,angle=45,fontsize=5cm, - width=\paperwidth,fontseries=b,scale=0.8, - xcoord=0,ycoord=0 - ]{xwatermark} -\end{xwverbatim} -or -\begin{xwverbatim} -\usepackage[printwatermark,pages=1-4,fontfamily=phv, - fontsize=12pt,width=\paperheight,angle=55,scale=0.8, - xcoord=20,ycoord=10,color=red!55!yellow!50, - textmark=CONFIDENTIAL]{xwatermark}. -\end{xwverbatim} - -By design, the boolean option \stya{printwatermark} should not appear in the macro \wmsetup but in the statement \usepackxwm or in the \dclass options list. It is disabled before \cmdb{begin\{document\}} and any attempt to change it thereafter will trigger an error. - -When boolean options (\eg, \stya{printwatermark} and \stya{allpages}) are passed without values, they are assumed implicitly \stya{true} by the package. The option \stya{printwatermark} may be set (\stya{printwatermark} or \stya{printwatermark=false}) when invoking the package, within the options list of either \dclass or \usepackxwm. Otherwise, the package will assume it to be \stya{true}. - -The \stya{textmark} key applies to text watermarks, for which all the font properties can be selected. It does not apply to graphic watermarks. For graphic watermarks you need the keys: \stya{picfile} (the graphic/picture filename, with its full path but without its extension), and \stya{picfilex} (the file extension). Admissible file extensions are \stya{eps}, \stya{pdf}, \stya{png}, and \stya{jpeg}; they should be submitted without the dot. Additional information is needed (see section~\ref{ssec:Picture-waterma}). - -The following points should be noted about the values of the \stya{textmark} key: -\begin{itemize} -\item The value of the \stya{textmark} may be any arbitrary multiline text, such as -\begin{xwverbatim} -textmark={Hello world,\\[.25\baselineskip] We're here}, -\end{xwverbatim} -\item The value of \stya{textmark} may be arbitrary (blocks of) texts or even kernel or package commands, but not filenames on their own (except when submitted within, \eg, \cmdb{includegraphics}). -\item If the \stya{textmark}'s value contains one or more commas, then it has to be enclosed in braces (as above), otherwise \TeXL will report an error. In any case, it is always safer to enclose long mark texts in braces. However, \emph{active characters} need further special treatment (see section~\ref{sec:Active-charact}). -\item The \stya{width} (=markwidth) should be properly selected to match user's taste and the length of the \stya{textmark}. It may be set to \cmdb{paperwidth} or \cmdb{paperheight}, or any arbitrary length. Its default value is preset to \cmdb{paperheight}. Sometimes it might also be necessary to suitably select the \stya{height} (=markheight), whose default value is \cmdb{paperwidth}. -\item If the longest line of a \stya{textmark} is longer than \cmdb{paperwidth} and/or \cmdb{paperheight} (depending on the orientation of the \stya{textmark}), then the \stya{fontsize} and \stya{scale} options will have to be suitably chosen. -\end{itemize} - -The package boolean option \stya{allpages} in -\begin{xwverbatim} -\usepackage[printwatermark,allpages]{xwatermark}, -\end{xwverbatim} -which specifies the pages that should receive watermarks, may be replaced by any of the following options: -\begin{xwverbatim} -firstpage, oddpages, evenpages, page=x, pages=x-x, -\end{xwverbatim} -where \stya{x} means any page number. If you enter, for example, \stya{pages=0-10}, all pages from 1~to 10 will have watermark. On the other hand, an entry like \stya{pages=10-0} will print watermark on page 10 only. If no page-specifying option is given, watermark will appear only on the first page and a warning message will be entered in the transcript file. When passing \stya{page=x} or \stya{pages=x-x} as option to package, don't forget to include the equality sign (\stya{=}), otherwise the option will be ignored by the package and a warning message will logged in the transcript file. - -When setting package options either in \cmdb{usepackage} or \dclass (or indeed in \wmsetup, \cmda{xwminipage} or \cmda{xwcolorbox}), the following points should be noted: -\begin{itemize} +\begin{enum} +\item The value of the \fx{textmark} may be any arbitrary multi-line text, such as + +\start{example}[textmark] +textmark=Hello world,\\[.25\baselineskip] We're here. +\finish{example} + +\item The value of \fx{textmark} may be arbitrary (blocks of) texts or even kernel or package commands, 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 \hx{\includegraphics}. +\item The \ffx'{textwidth, picwidth} should be properly selected to match user's taste and the length of the \fx{textmark}. It may be set to \hx{\paperwidth} or \hx{\paperheight}, or any arbitrary length. Its default value is preset to \hx{\paperheight}. Sometimes it might also be necessary to suitably select the \fx{height}, whose default value is \hx{\paperwidth}. +\item If the longest line of a \fx{textmark} is longer than \hx{\paperwidth} and/or \hx{\paperheight} (depending on the orientation of the \fx{textmark}), then the \fx{fontsize} and the \fx{textscale} (or \fx{picscale}) options will have to be suitably chosen. +\end{enum} + +The boolean options \ffx'{firstpage,lastpage,allpages, firstpage, oddpages, evenpages}, +which specify the pages that should receive watermarks, may be replaced by any of the options \ffx{page=x, pages=x-y, pagex={x,y,z}}, where \quoted{\fx{x}}, \etcc, stand for any page number. If you enter, for example, \fx{pages=0-10}, all pages from 1~to 10 will receive the watermark. On the other hand, an entry like \fx{pages=10-0} will print watermark on page 10 only. If no page-specifying option is given and \fx{printwatermark} is true, watermark will appear only on the first page and a warning message will be entered in the transcript file. When passing \fx{page=x} or \fx{pages=x-y} as option to package, don't forget to include the equality sign (\fx{=}), otherwise the option will trigger an \quoted{unknown option/key} error. The key \fx{pages} expects a page range with the pages separated by a hyphen, while \fx{pagex} expects a comma-separated list of pages. For obvious reasons, the value of the key \fx{pagex} must always be given in balanced curly braces. + +When specifying package options either in \hx{\usepackage} or \hx{\documentclass} (or indeed in the macros \ffx'{\newwatermark, \newwallpaper, \xwmminipage,\xwmcolorbox, \fancypagenos}), the following points should be noted: + +\begin{enum} \item Multiple lines are permitted but not blank lines. \item Extra paces between options and words are ignored. -\item No active characters (those of catcode 13) are allowed (but see section~ \ref{sec:Active-charact}). -\item Options are basically order-agnostic. -\end{itemize} -Thus, \eg, the following statement -\begin{xwverbatim} -\usepackage - [ printwatermark = true, scale = 0.8, - xcoord = 0, ycoord = 0, fontfamily = pag, - allpages = true, - color = gray!25, mark = I am happy, angle = 45, - fontsize=5cm, - width = \paperwidth, fontseries = b] - {xwatermark} -\end{xwverbatim} -is equivalent to -\begin{xwverbatim} -\usepackage[printwatermark,allpages=true,fontfamily=pag, - color=gray!35,textmark=I am happy,angle=45,fontsize=5cm, - width=\paperwidth,fontseries=b,scale=0.8, - xcoord=0,ycoord=0]{xwatermark}. -\end{xwverbatim} - -\subsection{Graphic watermarks\label{ssec:Picture-waterma}} -For graphic/picture watermarks, the user can issue, \eg, -\begin{xwverbatim} -\usepackage[ - printwatermark,page=2, - picfile={.../graphicsdir/pic-file},picfilex=eps, - picbb=116 619 242 751,picscale=3,align=center,angle=0, - xcoord=0,ycoord=0 - ]{xwatermark}. -\end{xwverbatim} -For graphic and picture watermarks, you need the \stya{picfile} (the graphic filename, with its full path but without its extension), \stya{picfilex} (the picture filename extension without the dot), \stya{picbb} (the picture bounding box), and \stya{picscale} (the picture scale). Admissible file extensions are \stya{eps}, \stya{pdf}, \stya{png} and \stya{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 running or not (normal extensions are \stya{eps} for dvi mode and \stya{pdf} for \pdfTeX mode). If you have the graphic file in both \stya{eps} and \stya{pdf} 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 (\pdfTeX or dvi) in which it is running. - -\subsection{The \XWM macro} -The global boolean option \stya{printwatermark=true} (or \stya{=false}) and the one that specifies the pages to receive the watermark(s) (\eg, \stya{evenpages} and \stya{allpages}) should be set when loading the package, \eg, -\begin{xwverbatim} -\usepackage[printwatermark,evenpages]{xwatermark}, -\end{xwverbatim} -or in the \dclass options list: -\begin{xwverbatim} +\item Active characters (those of catcode~13) may be allowed (but see \amref{sec:activechar} for further comments). +\item Options are mostly order-agnostic, except \fxi{graphicsoptions}, whose values take precedence over those supplied via other keys (see \amref{sec:graphicsoptions}). +\end{enum} + + +The global boolean option \fx{printwatermark}=\hx{true} (or \hx{=false}) should ideally be set when loading the package, \eg, + +\start'{example}[Package option: printwatermark] +\usepackage[printwatermark]{xwatermark} +\finish{example} + +or in the \hx{\documentclass} options list: + +\start'{example}[Package option: printwatermark] \documentclass[a4paper,12pt,printwatermark]{article} +\usepackage{xwatermark}. +\finish{example} + +The remaining options should ideally be set dynamically using the macro \fx{\newwatermark} or \fx{\newwallpaper}. These other options can be set for each page, as on the pages of the accompanying example files. + + +\docsection(sec:newwatermarks){The \headfx{\newwatermark} macro} + +The use syntax for the command \fx{\newwatermark} is as follows + +\start{newmacro}[\newwatermark] +\newwatermark[|A(key-val)]{|A(mark)} +\newwatermark|R(*')[|A(key-val)]{|A(mark)} +\finish{newmacro} +\fxi*{\newwatermark} + +where \ang{key-val} is the list of keys and their values (called the watermark attributes) and \ang{mark} is the text watermark. Graphics watermarks are to be specified with their file name, file extension, \etcc. The full lists of the available keys for the macro \fx{\newwatermark} and others are available in \amref{sec:packageoptions}. + +The \stform of \fx{\newwatermark} puts the watermark in the foreground instead of the background, and the \pmform is ignored, \ie, no watermark is produced (see \amref{sec:dummywatermarks}). + +The macro \fx{\newwatermark} can be used as in + +\start{example}[\newwatermark] +\newwatermark[|R(pagex)={2,5,7},fontfamily=bch,color=gray!25,angle=45,scale=3, + xpos=0,ypos=0]{DRAFT}, +\finish{example} + +where the \fx{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 \fx{textmark} (which is \quoted{DRAFT} in the above example) can also be given within square brackets, in which case the curly braces will be empty: + +\start{example}[\newwatermark] +\newwatermark|R(*)[page=10,fontfamily=bch,color=gray!25,angle=45,scale=3,xpos=0, + ypos=0,textmark=DRAFT]{}. +\finish{example} + +The option \fx{printwatermark} may appear in only \fx{\usepackage} or \hx{\documentclass} options list, since it is disabled at \hx{\begin{document}}. However, the options \ffx'{firstpage, lastpage, allpages, oddpages, evenpages}, \etcc, which specify watermark pages, can and should appear in the command \fx{\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 \fx{\newwatermark} macro with the page option \mbox{\fx{page}=\ang{no}} in the preamble of your document after issuing + +\start+{example}[\usepackage,printwatermark] +\usepackage[printwatermark]{xwatermark} +\finish{example} -\usepackage[evenpages]{xwatermark}. -\end{xwverbatim} +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 \fx{\newwatermark}. -The remaining options can be set dynamically using the \wmsetup macro. These other options can be set for each page, as on the pages of the accompanying file of examples (\stya{xwatermark-examples.tex}). The macro \wmsetup can be used as in -\begin{xwverbatim} -\watermarksetup{fontfamily=bch,color=gray!25,textmark=DRAFT, - angle=45,scale=0.8,xcoord=0,ycoord=0 -}. -\end{xwverbatim} +\Note Each call to \fx{\newwatermark} must contain the page(s) that will receive the watermark(s), otherwise the user will be alerted. The page specifiers are: -The option \stya{printwatermark} should not appear in \wmsetup but in the statement \usepackxwm or in the \dclass options list. +\start'{example}[page specifiers] +page=x, pages=x-y, pagex={x,y,z}, firstpage, lastpage, allpages, +oddpages, evenpages +\finish{example} -However, the options \stya{allpages}, \stya{oddpages}, \stya{evenpages}, \etc, which specify watermark pages, can appear in \wmsetup. 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 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 \wmsetup macro with the page option \stya{page=desired page} in the preamble of your document after issuing -\begin{xwverbatim} -\usepackage[printwatermark]{xwatermark}. -\end{xwverbatim} -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. +\docsubsection{Options without values} -\subsection{Options without values} If you follow an option key with an equality sign but without a value, as in, \eg, -\begin{xwverbatim} -\watermarksetup{|color(red)fontfamily={}|color(blue),color=gray!25,|color(red)textmark={}|color(blue), - angle=45,scale=0.8,xcoord=0,ycoord=0 -}, -\end{xwverbatim} -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 \stya{DRAFT}) because the entry \stya{textmark=} is valid and implies that no watermark should be printed. The absence of fontfamily in \stya{fontfamily=} will compel \TeXL to use an arbitrary fontfamily that isn't the default (the default fontfamily is \stya{phv} if the key \stya{fontfamily} is not passed, and \stya{cmr} otherwise). -\subsection{Emptying the watermarks of some pages} +\start{example}[\newwatermark] +\newwatermark[firstpage,fontfamily=,color=gray!25,angle=45,scale=0.8, + xpos=0,ypos=0,textmark=]{}, +\finish{example} + +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 \fx{DRAFT}) because empty textmark is valid and implies that no watermark should be printed. The absence of \texttt{fontfamily} in \quoted{\fx{fontfamily=}} will compel \texorlatex to use an arbitrary \texttt{fontfamily} that isn't the default (the default \texttt{fontfamily} is \fx{phv} if the key \fx{fontfamily} is not passed, and \fx{cmr} otherwise). + + +\docsubsection{Emptying the watermarks of some pages or objects} If you issue any of the statements -\begin{xwverbatim} -allpages=true, evenpages=true, oddpages=true, pages=x-x, -page=x -\end{xwverbatim} -together with \stya{printwatermark=true} but you don't want the mark on any particular page, you can simply set \cmda{watermarksetup\{textmark=\}} or, to the same effect, \cmda{watermarksetup\{textmark=\{\}\}} on that page. In the case of picture watermarks, you will set \cmda{watermarksetup\{picfile=\{\}\}}. These both imply that the watermark for that page is empty. This can be useful when transiting from text watermarks to picture watermarks or vice versa. Some examples are available in \stya{xwatermark-examples.tex}, the example source file that shipped with this package. -\subsection{The usefulness of the \stya{\bf white} color} -If you set \stya{allpages=true} or \stya{evenpages=true} or \stya{oddpages=true} together with \stya{printwatermark=true} but you don't want the mark on any particular page, you can simply enter \stya{color=white} in the \wmsetup on that page. This applies only to text watermarks, as such a declaration has no effect on picture watermarks. This may be convenient in circumstances where you may change your mind as to whether to place a watermark on a particular page or not. In this way you don't have to set \cmda{watermarksetup\{textmark=\}} or remove (or comment out) the \wmsetup command for that (or indeed any) page. +\start{example}[page specifiers] +page=x, pages=x-y, pagex={x,y,z}, firstpage, lastpage, allpages=true, +evenpages=true, oddpages=true +\finish{example} + +together with \fx{printwatermark}=\hx{true} but you don't want the mark on any particular page, we can simply set \fx{\newwatermark[other keys,textmark=]{}} or, to the same effect, we may set \fx{\newwatermark[other keys]{}}, where \quoted{other keys} may include the page specifiers\footnote{In the case of graphics watermarks, setting \ftfx{\newwatermark[other keys,picfile=]{}} will prompt a \quoted{no file} error.}. 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 \fx{\newwatermark} (see \amref{sec:pic-text-mark}), this technique may be used to empty the text watermark for the given page or range of pages. For example, + +\start{example}[\newwatermark] +\newwatermark[allpages,fontfamily=put,color=white,fontsize=3cm,scale=1, + picbb=112 619 242 751,picscale=3,picfile=./graphics/myfig,picfileext=eps, + width=\paperheight,align=center,angle=0,xpos=0,ypos=0]{} +\finish{example} + +will print only the picture watermark, since the \fx{textmark} is empty here. + + +\docsubsection(sec:pic-text-mark){Printing both picture and text watermarks on same page} + +Both picture and text marks can be submitted and printed on the same page via one and the same \fx{\newwatermark}. For example, + +\start{example}[\newwatermark] +\newwatermark[pages=1-2,fontfamily=put,color=white,fontsize=3cm,scale=1, + picbb=112 619 242 751,picscale=3,picfile={./graphics/myfig}, + picfileext=eps,width=\paperheight,align=center,angle=0,xpos=0, + ypos=0]{Hello World} +\finish{example} + +However, both the picture and text marks will then share the same subset of the attributes (position, angle, align, \etcc). When text and graphics watermarks appear on the same page, the recommended approach is to submit the two types of watermark by two separate calls to \fx{\newwatermark}. + + +\docsubsection{The usefulness of the \headhx{white} color} + +You can deploy the white color to great effect in designing text watermarks. Also, if you set \fx{allpages}=\hx{true} or \fx{evenpages}=\hx{true} or \fx{oddpages=true} together with \fx{printwatermark}=\hx{true} but you don't want the mark on any particular page, you can simply enter \fx{color=white} in the \fx{\newwatermark} on that page. This applies only to text watermarks, as such a declaration has no effect on picture watermarks. This may be convenient in circumstances where you may change your mind as to whether to place a watermark on a particular page or not. In this way you don't have to set \fx{\newwatermark[other keys,textmark=]{}} or remove (or comment out) the \fx{\newwatermark} command for that (or indeed any) page. See also \amref{sec:dummywatermarks}. + + +\docsubsection(sec:dummywatermarks){Dummy watermarks} + +When you don't need a watermark printed, you can simply replace its \fx{\newwatermark} with \fx{\dummywatermark}, instead of commenting out the entire watermark or using \fx{color=white}. Both the macros \fx{\newwatermark} and \fx{\dummywatermark} have the same syntax and expect the same number and types of arguments: + +\start{newmacro}[\dummywatermark] +\dummywatermark[pages=12-13,fontfamily=phv,fontsize=11pt,fontseries=m, + align=center,height=\paperheight,width=\paperwidth,angle=90,scale=1, + xpos=0,ypos=-1 +]{Example} +\finish{newmacro} +\fxi*{\dummywatermark} + +And when you don't want any of your watermarks printed, you could simply issue the option \fx{printwatermark}=\hx{false} or call the command \fxi{\DiscardAllWatermarks}. These will simply turn all instances of \fx{\newwatermark} command into \fx{\dummywatermark}. In any run, you may decide to use some or all of the dummy watermarks. To use all dummy watermarks, you issue the command \fxi{\UseDummyWatermarks} before instances of \fx{\dummywatermark}. To again disregard all subsequent dummy watermarks, which is the default state, simply call the command \fxi{\DiscardDummyWatermarks}. These commands provide a convenient scheme for deciding the watermarks to be printed with minimal typing. For wallpapers, there is the corresponding command \fxi{\dummywallpaper}. Also, putting a prime sign (\RedPrime) on \fx{\newwatermark} or \fx{\newwallpaper} turns the command into a dummy mark, but only for that single instance. Subsequent \fx{\newwatermark} and \fx{\newwallpaper} without primes will produce watermarks and wallpapers. + + +\docsection(sec:wallpapers){Wallpapers} + +\docsubsection{The \headfx{\newwallpaper} macro} + +The command \fx{\newwallpaper} can be used to produce rectangular and square tiles on document pages. The use syntax for the command \fx{\newwallpaper} is + +\start{newmacro}[\newwallpaper] +\newwallpaper[|A(key-val)]{|A(mark)} +\newwallpaper|R(*')[|A(key-val)]{|A(mark)} +\finish{newmacro} +\fxi*{\newwallpaper} + +where \ang{key-val} is the list of keys and their values (called the attributes) and \ang{mark} is the text (and not graphics) watermark. Graphics watermarks are again to be specified with their file name, file extension, \etcc. The full lists of the available keys for the macro \fx{\newwallpaper} are available in \amref{tab:localoptions}. + +The \stform of \fx{\newwallpaper} puts the watermark in the foreground instead of the background, and the \pmform is ignored, \ie, no watermark is produced (see \amref{sec:dummywatermarks}). + +When you get unexpected tiles, you should consider enabling or disabling the keys \fx{squaretiles} (default \texttt{true}) and/or \fx{boxalign} (default \texttt{center}). The key \fx{boxalign} may assume one of the values in the set \ffx{t-l,t-r,b-l,b-r,s} or \ffx{top-left, top-right, bottom-left, bottom-right, center, justified}. + + +\docsection(sec:pic-watermark){Graphics watermarks} + +For graphics/picture watermarks, you need the \fx{picfile} (the graphics filename, with its full path but without its extension), \fx{picfileext} (the picture filename extension without the dot), \fx{picbb} (the picture bounding box), and \fx{picscale} (the picture scale)\footnote{These options have longer, easier to remember, names; see \amref{tab:localoptions}.}. Admissible file extensions are \fx{eps}, \fx{pdf}, \fx{png} and \fx{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 \fx{eps} for dvi mode and \fx{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 \fx{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 \texttt{dvi}) in which it is running. + + +\docsubsection(sec:graphicsoptions) + [Passing key values to \headhx{\includegraphics} directly] + {Passing key values to \headhx{\includegraphics} directly} +\fxim*{graphicsoptions} + +The \pkg'{xwatermark} uses \pkg'{graphicx}'s \hxi{\includegraphics} to insert graphics watermarks. +Users can pass valid key values to the command \hx{\includegraphics} directly via the macros \ffx'{\newwatermark,\newwallpaper}. The key to use for this purpose is \fx{graphicsoptions}. The following points should be noted in respect of the key \fx{graphicsoptions}: + +\begin{enum} +\item Values of the key \fx{graphicsoptions} must always be enclosed in curly braces, since they are expected to be more than one. +\item Only keys and values valid for the command \hx{\includegraphics} may appear in the command \fx{graphicsoptions}. Valid keys for \hx{\includegraphics} are + +\start'{example}[\includegraphics keys] +bb, bbllx, bblly, hiresbb, viewport, trim, height, width, natheight, +natwidth, totalheight, angle, origin, keepaspectratio, scale, clip, +draft, type, ext, read, command +\finish{example} + +\item Key values submitted via \fx{graphicsoptions} supersede those submitted outside it, even if those outside \fx{graphicsoptions} appear earlier than \fx{graphicsoptions} in the command \fx{\newwatermark} or \fx{\newwallpaper}. +\item Values submitted via \fx{graphicsoptions} have only local effect, in the sense that they become null and void outside of \fx{\newwatermark} or \fx{\newwallpaper}. If the user wants the key values submitted via \fx{graphicsoptions} to prevail for all subsequent watermarks and wallpapers, then he should use the command \fx{\GraphicsOptions}. Values passed via \fx{\GraphicsOptions} don't only have global effect, but they always override those submitted via \fx{graphicsoptions}. +\end{enum} + +It should be noted that \fx{\GraphicsOptions} isn't a key but a stand-alone command with the following syntax: + +\start{newmacro}[\GraphicsOptions] +\GraphicsOptions{|A(key-val)} +\finish{newmacro} +\fxi*{\GraphicsOptions} + +where \ang{key-val} are admissible keys for the command \hx{\includegraphics} and their user-supplied values. The values so suggested by \fx{\GraphicsOptions} override those given via the keys of the \pkg{xwatermark}, including \fx{graphicsoptions}. Such values remain in force until they are changed later by another call to \fx{\GraphicsOptions}. + +An example follows: + +\start{example}[graphicsoptions] +\newwallpaper[% + page=10,picangle=45,tilexoffset=0pt,tileyoffset=0pt,picontoptext=false, + boxalign=top-left,picbb=116 428 477 718,picscale=2,picfile=tabu-test1, + tileno=4,picfileext=pdf,|R(graphicsoptions)={clip,keepaspectratio,hiresbb} +]{mypicture} + +|com(or globally as) +\GraphicsOptions{clip=true,keepaspectratio,hiresbb} +\finish{example} +\fxi*{\GraphicsOptions} + +The commands \hhx'{\DeclareGraphicsExtensions, \DeclareGraphicsRule} of the \pkg'{graphics} can still be invoked before setting graphics watermarks. + + +\docsubsection{The graphics input paths} + +Users can suggest the possible locations of the graphics watermarks to the package by using the command \fx{\watermarkpaths}, whose syntaxes are + +\start{newmacro}[\watermarkpaths] +\watermarkpaths[|A(pre)]|(|A(post)|){{path-1}{path-2}...{path-n}} +\watermarkpaths|*[|A(pre)]|(|A(post)|){path-1,path-2,...,path-n} +\finish{newmacro} +\fxi*{\watermarkpaths} + +Here, \ang{pre} and \ang{post} 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 \unstform all the paths must be provided in surrounding curly braces and must have no commas, otherwise the package will raise an error. The \stform expects paths to be separated by commas. The package works hard to find your watermark on the suggested path. + +\start+{example}[\watermarkpaths] +\watermarkpaths{{./}{./graphics/}{./graphics/recentfiles/}} +\watermarkpaths|*{./,./graphics/,./graphics/recentfiles/} +\watermarkpaths|(/|){{.}{./graphics}{./graphics/recentfiles}} +\watermarkpaths|*|(/|){.,./graphics,./graphics/recentfiles} +|com(Note the empty balanced braces below. Without them, the first entry) +|com(|(which is supposed to be {./}|) will be wrong:) +\watermarkpaths[.]|(/|){{}{/graphics}{/graphics/recentfiles}} +\watermarkpaths|*[.]|(/|){{},/graphics,/graphics/recentfiles} +\finish{example} -\section{Other aspects of package architecture and use} +By default, the packages works hard to preserve outer curly braces, unless and until they are required to be removed. -\subsection{\DCL options} -The package is set to inherit the \dclass options, if the options apply to the package. Therefore, some of the package options can be passed to the package via the \dclass options list. This is perhaps most appropriate in the case of the options \stya{printwatermark}. However, package options supersede those passed via the \dclass. For example, the option \stya{printwatermark=true} in the \dclass options list can normally be superseded by the option \stya{printwatermark=false} in loading the \stya{xwatermark} package, \eg, as in -\begin{xwverbatim} +The command \fx{\watermarkpaths} inherits the current contents of \latex's \hx{\input@path} command and \pkg'{graphics}'s \hx{\Ginput@path} (the latter takes argument from \hx{\graphicspath}). + + +\docsection{Other aspects of package architecture and use} + +\docsubsection{\headhx{\documentclass} options} + +The package is set to inherit the \hx{\documentclass} options, if the options apply to the package. Therefore, some of the package options can be passed to the package via the \hx{\documentclass} options list. This is perhaps most appropriate in the case of the option \fx{printwatermark}. However, package options supersede those passed via the \hx{\documentclass}. For example, the option \fx{printwatermark}=\hx{true} in the \hx{\documentclass} options list can normally be superseded by the option \fx{printwatermark}=\hx{false} in loading the \pkg'{xwatermark}, \eg, as in + +\start{example}[package loading] \usepackage[printwatermark=false]{xwatermark}, -\end{xwverbatim} -and vice versa. +\finish{example} + +and vice versa. It should, however, be noted that some package options and keys are restricted either to the \hhx'{\documentclass,\usepackage} (this applies to the so-called \quoted{option keys}) or to the various user macros (in the case of \quoted{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 \fx{printwatermark} (=\hx{true}) with \fx{printwatermark}=\hx{false} in \hx{\usepackage} or \hx{\documentclass}. If you have specified \fx{printwatermark} (=\hx{true}) in the \hx{\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 \amref{sec:dummywatermarks}. + + +\docsubsection<Size of the watermark>{The size of the watermark} + +In the case of text watermarks, the size of the watermark is controlled by three parameters, namely, \fx{fontsize}, \fx{fontseries} and \fx{scale}. All can be set dynamically. Their default values are \fx{5cm}, \fx{b} and \fx{1}, respectively. For picture watermarks, the size is determined by \fx{picscale}. + + +\docsubsection{The coordinates of the watermark} + +The watermark coordinates (specified by \fx{xpos} and \fx{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 \hx{millimeter}, but this can be changed on any page by changing the value of \fx{coordunit}. For example, -If you don't need the watermark on any page of your document, simply replace the \stya{printwatermark(=true)} option in \cmdb{usepackage} or \dclass with the choice \stya{printwatermark=false}. If you have specified \stya{printwatermark(=true)} in the \dclass options list but you still don't need the watermark on any page of your document, then you would have to enter \stya{printwatermark=false} when loading the package. +\start+{example}[\newwatermark,coordunit] +\newwatermark[other attributes,coordunit=|R(unit of length)]{}. +\finish{example} -\subsection{The size of the watermark} -In the case of text watermarks, the size of the watermark is controlled by three parameters, namely, \stya{fontsize}, \stya{fontseries} and \stya{scale}. All can be set dynamically. Their default values are \stya{5cm}, \stya{b} and \stya{1}, respectively. For picture watermarks, the size is determined by \stya{picscale}. +Acceptable units of length include \hx{mm} (millimeter), \hx{cm} (centimeter), \hx{in} (inch), \hx{pt}~(point), \hx{bp} (big point), \hx{dd} (didot), \hx{ex} (height of small \hx{x}), \hx{pc} (pica), \hx{cc}~(cicero), and \hx{em}~(width of capital \hx{M}). -\subsection{The coordinates of the watermark} -The watermark coordinates (specified by \stya{xcoord} and \stya{ycoord}) have their origin at the center of the page and are with respect to the geometric center of the watermark. The default unit is \stya{millimeter}, but this can be changed on any page by issuing -\begin{xwverbatim} -\watermarksetup{coordunit=|color(red)unit of length|color(blue)}. -\end{xwverbatim} -Acceptable units of length include \styb{mm} (millimeter), \styb{cm} (centimeter), \styb{in} (inch), \styb{pt}~(point), \styb{bp} (big point), \styb{dd} (didot), \styb{ex} (height of small \styb{x}), \styb{pc} (pica), \styb{cc}~(cicero), \styb{em}~(width of capital \styb{M}). The unit of coordinates can also be changed by simply submitting the unit to the package with other options at each call, as in -\begin{xwverbatim} -\watermarksetup{|color(red)coordunit=pc,|color(blue)fontfamily=cmss,angle=90, - scale=1.0,textmark=-Official-,color=red!75!green!50, - xcoord=-10,ycoord=10 -}. -\end{xwverbatim} -\subsubsection{Wrong location of the watermark} -If you discover that the watermark is wrongly positioned on the page(s) of your document, the chances are that you have submitted wrong coordinates (values of \stya{xcoord} and \stya{ycoord}) to the package or the markwidth (\stya{width}) 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 this error, no attempt has been made in the package to warn users in this regard. If you do not specify the keys \stya{xcoord} and/or \stya{ycoord} at all in the call to the package, their immediate past values will be used by the package. On the other hand, if you list these keys without their values in the call to the package, their default values (\stya{xcoord=0} and \stya{ycoord=0}, which yield the center of paper) will be assumed by the package. The default value of the markwidth is \cmda{paperheight}. +\docsubsection{Wrong location of the watermark} -When the \styb{geometry} package is loaded together with \styb{xwatermark}, page layout scale changes by the \styb{geometry} package may result in the watermarks being positioned wrongly. See section~\ref{sec:Xwatermark:Geometry} for further details. +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 \fx{xpos} and \fx{ypos}) to the package or the watermark's width (\fx{textwidth} or \fx{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 \fx{xpos} and/or \fx{ypos} at all in the call to \fx{\newwatermark}, their default values will be used by the package. Also, if you list these keys without their values in the call to \fx{\newwatermark}, their default values (\fx{xpos=0} and \fx{ypos=0}, which yield the center of paper) will be assumed by the package. The default value of the watermark's width is \hx{\paperheight}, and not \hx{\paperwidth} as might be expected. -\subsection{Choice of \stya{\bf grayness}} -The grayness applies to only text watermarks and is chosen according to the scheme of the \styb{xcolor} package. The color gray is represented as \stya{gray!x}, where \stya{x} is the grayness in percentage---normally from 1 to 100. In the previous versions of the package, the \stya{grayness} was a package option associated with the color \stya{gray}; this is no longer the case. +When the \pkg'{geometry} is loaded together with the \pkg'{xwatermark}, page layout scale changes by the \pkg'{geometry} may result in the watermarks being positioned slightly away from the intended position. See \amref{sec:geometry} for further details. + + +\docsubsection{Wrong size of the watermark} + +When you discover that your text or graphics watermark is not of the size you expect, then you 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 \amref{sec:packageoptions}. For example, choosing \fx{scale=0.7} and \fx{width=\paperwidth} may yield something unexpected. So will mixing inconsistent global and local scales or width, or both. + + +\docsubsection{Breaking the watermark into lines} -\subsection{Breaking the watermark into lines} It is possible to break text watermarks into lines, as in the following examples: -\begin{xwverbatim} -\watermarksetup{fontfamily=ptm,angle=45,scale=.7, - textmark=|color(red){Directorate\\[.25ex]Only},align=center|color(blue), - color=green,xcoord=0,ycoord=0 -} -\watermarksetup{fontfamily=ptm,angle=45,scale=.8, - textmark=|color(red){Control\\[.25ex]Version},align=left|color(blue), - color=green,xcoord=0,ycoord=0 -}. -\end{xwverbatim} -More complex examples are given in the file \stya{xwatermark-examples.tex}. - -\subsubsection{The alignment of the watermark} -The alignment of the watermark is controlled by the key \stya{align}, which may be set to \stya{center}, \stya{left}, \stya{right} or \stya{justified}. The default is \stya{center}. This is particularly useful for putting arbitrary texts (that are not necessarily watermarks) on pages of documents. Examples include the watermarks on the pages of this document. The code for the watermarks on page~\pageref{page:one} is given in section~\ref{sec:colorbox}. - -\subsection{Locating the page center} -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 \stya{showcenter}, which may be issued (dynamically for each page) with the \wmsetup macro as follows: -\begin{xwverbatim} -\watermarksetup{|color(red)showcenter|color(blue)} |color(black)or - -\watermarksetup{|color(red)showcenter=true|color(blue)} |color(black)or - -\watermarksetup{|color(red)showcenter|color(blue),fontfamily=ptm,angle=60, - scale=.7,textmark=Confidential!,color=brown!25!yellow!75, - coordunit=cc,xcoord=0,ycoord=0 -}. -\end{xwverbatim} - -An example is given in the example file (\stya{xwatermark-examples.tex}). 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 -\begin{xwverbatim} -\watermarksetup{|color(red)showcenter=false|color(blue)} |color(black)or - -\watermarksetup{|color(red)showcenter=false|color(blue),fontfamily=panr,angle=60, - scale=.7,textmark=Confidential!,color=brown!25!yellow!75, - coordunit=cc,xcoord=0,ycoord=0 -}. -\end{xwverbatim} - -\subsection{Active characters}\label{sec:Active-charact} -Active characters (\ie, those of category 13) can normally be used as values of the \stya{textmark} key in the \wmsetup macro. However, such values cannot be passed via the \dclass or the \usepackxwm statement. The \styb{xkvltxp} package (or \styb{kvoptions-patch} package) can be used to obviate this problem. That is, the following should work: - -\begin{xwverbatim} -\RequirePackage{xkvltxp} -\documentclass[textmark={My watermark,\\designed~ - by \textsc{Johnson}}]{class-type} -\begin{document} -... -\end{document} -\end{xwverbatim} +\start{example} +\newwatermark[evenpages,fontfamily=ptm,angle=45,scale=.7, + align=center,color=green,xpos=0,ypos=0]{Directorate\\[.25ex]Only} -To pass active characters and expandable commands as values of \stya{textmark} to the \stya{xwatermark} package via \usepackxwm, it is necessary to first load the \styb{xkvltxp} package as above, or as follows: +\newwatermark[allpages,fontfamily=ptm,angle=45,scale=.8,align=left, + color=green,xpos=0,ypos=0]{Control\\[.25ex]Version}. +\finish{example} -\begin{xwverbatim} -\documentclass{class-type} -\usepackage{xkvltxp} -\usepackage[printwatermark,% - textmark=\textsc{Johnson's~Text}]{xwatermark} -\begin{document} -... -\end{document} -\end{xwverbatim} +More complex examples are available in the example source and \pdf files that shipped with this package. -The use of the \styb{xkvltxp} package can be sidestepped completely by passing active characters not through \dclass and \usepackxwm but instead via the \wmsetup macro, as in -\begin{xwverbatim} -\documentclass{class-type} -\usepackage[printwatermark]{xwatermark} -\watermarksetup{allpages,textmark={M\"uller's~Text}} -\begin{document} -... -\end{document} -\end{xwverbatim} +\docsubsection{The alignment of the watermark} -In fact, in this way even expandable commands can be passed to the package, as follows: +The alignment of the watermark is controlled by the keys \ffx'{align, textalign, boxalign}. The first two are equivalent and may be set to \fx{center}, \fx{left}, \fx{right} or \fx{justified}. The default is \fx{center}. This is particularly useful for putting arbitrary texts (that are not necessarily watermarks) on pages of documents. The admissible values for the key \fx{boxalign} are given in \amref{tab:localoptions}. + + +\docsubsection{Locating the page center} + +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 \fx{showpagecenter}, which may be issued (dynamically for each page) with the \fx{\newwatermark} macro as follows: + +\start{example}[showpagecenter] +\newwatermark[allpages,showpagecenter]{} +\newwatermark[page=1,showpagecenter=true]{} + +\newwatermark[allpages,showpagecenter,fontfamily=ptm,angle=60,scale=.7, + color=brown!25!yellow!75,coordunit=cc,xpos=0,ypos=0]{Confidential!}. +\finish{example} + +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 + +\start{example} +\newwatermark[pages=1-2,showpagecenter=false]{} + +\newwatermark[page=10-\lastdocpage,showpagecenter=false,fontfamily=panr, + angle=60,scale=.7,color=brown!25!yellow!75,coordunit=cc,xpos=0,ypos=0] + {Confidential!} +\finish{example} + + +\docsubsection{The last page of the document} + +You can easily obtain the last page of the document with the label \fx{xwmlastpage}, which is automatically provided by the package: the user doesn't have to insert it himself. In general, you can use the command \fx{\xwmgetpagenumber} to extract page numbers from \latex labels (even in expansion contexts). More than one run may be necessary in extracting page numbers from this command. The following example inserts the watermark from second to the last page to the last page. Note that in this example the starting page is necessarily enclosed in curly braces so as to distinguish the two hyphens that serve different purposes. + +\start{example}[\xwmgetpagenumber,\lastdocpage] +\newwatermark[pages={\lastdocpage-2}-\lastdocpage,angle=90, + scale=1,xpos=0,ypos=-1]{This is page \thepage~of~\pageref*{xwmlastpage}} +\finish{example} +\fxi*{\xwmgetpagenumber,\lastdocpage} + +The command \fx{\lastdocpage} is equivalent to \fx{\xwmgetpagenumber{xwmlastpage}}. + + +\docsubsection(sec:activechar){Active characters} + +Active characters (\ie, those of category 13) and expandable commands can normally be used as values of the \fx{textmark} key in the \fx{\newwatermark} macro. However, such values cannot be passed via the \hx{\documentclass} or the \hx{\usepackage{xwatermark}} command without first loading one of the packages: \pkg'{xkvltxp,kvoptions-patch,catoptions}. That is, the following should work: + +\start{example} +\RequirePackage{catoptions} +\documentclass[myoption={My watermark,\\[2ex] + designed~by \textsc{Mr.~J\"ohnson}}]{class-file} -\begin{xwverbatim} -\documentclass{class-type} -\usepackage[printwatermark]{xwatermark} -\newcommand*\temparg{Fran\c coise M\"uller's\endgraf Text} -\watermarksetup{allpages,textmark=\temparg} \begin{document} -... +Blackberry lily ... \end{document} -\end{xwverbatim} - -The accompanying file \stya{xwatermark-examples.tex} contains some complex examples. - -In plain \nTeX the only active character is the tie character \raisebox{-1ex}{\ \textcolor{teal}{$\widetilde{}$}\ } (that is, \cmdb{nobreakspace}). However, some packages do make some other characters active. For example, after issuing the command \cmdb{MakeShortVerb\{\textbackslash x\}}, the packages \styb{doc} and \styb{shortvrb} make the character \styb{x} active\footnote{The \styb{fancyvrb} package has, \eg, \cmdb{DefineShortVerb[key=value pairs]\{\textbackslash x\}}.}. The user can use such active characters in values of the \stya{textmark} key without locally changing their catcode to 11 (\ie, letters). In the case of \cmdb{MakeShortVerb\{\textbackslash x\}}, you can issue \cmdb{DeleteShortVerb\{\textbackslash x\}} to revert to normal use of character \styb{x}. As another example, the option \styb{turkish} of the \styb{babel} package uses the equal sign (\styb{=}) as active shorthand character. - -\section{The \XWCB and \XWMP macros}\label{sec:colorbox} -\lletter{T}{o make} it easier for users to create paragraph boxes and color boxes of texts and watermarks, the \stya{xwatermark} package provides the macros \cmda{xwcolorbox} and \cmda{xwminipage}. The macro \cmda{xwcolorbox} calls the macro \cmda{xwminipage}. The \cmda{xwminipage} macro is a \styb{minipage} environment that may be used for framing watermarks. Like the \wmsetup macro, these two macros are set with key-value lists as follows: -\begin{xwverbatim} -\xwminipage{key=value list} -\xwcolorbox{key=value list}. -\end{xwverbatim} - -The \stya{textcolor} in \cmda{xwminipage} is the color of the text. In the case of \cmda{xwcolorbox}, two color values are expected: \stya{textcolor} and \stya{fillcolor}. Texts with commas need to be enclosed in braces when submitted to these macros. The default values of the options of these macros are described in section~\ref{sec:LocalOptions}. - -These macros can call one/each other iteratively, \eg, -\begin{xwverbatim} -\watermarksetup{fontfamily=txtt,fontseries=m,color=red, - align=center,scale=0.7,angle=0,xcoord=0,ycoord=0, - textmark={% - \xwminipage{width=\paperwidth, - text={% - \xwminipage{width=\paperwidth,align=left, - textcolor=magenta,text={\TeX\\[.1ex] \LaTeX} - }% - \\[1ex] - \xwminipage{width=\paperwidth,align=center, - textcolor=green,text={\TeX\\[.1ex] \LaTeX} - }% - \\[1ex] - \xwminipage{width=\paperwidth,align=right, - textcolor=orange,text={\TeX\\[.1ex] \LaTeX}% -}}}}} -\end{xwverbatim} -which is one of the examples in the file \stya{xwatermark-examples.tex}. - -The left and right watermarks on page~\pageref{page:one} were produced with the following settings: -\begin{xwverbatim} -\watermarksetup{fontfamily=phv,fontsize=11pt, - fontseries=m,align=center,height=\paperheight, - width=\paperheight,angle=90,scale=1,xcoord=0,ycoord=-1, - textmark={% - \xwcolorbox{fillcolor=gray!55,width=\paperheight, - align=center,framesep=5pt,framerule=2pt, - framecolor=white, - text={\color{white}\framebox[2cm][c]{% - \phantom{Hello}}\hspace{1cm}\color{black}% - \textcolor{red}{\textbullet}\hspace{1cm}The marks % - on these pages were placed effortlessly % - by using the \textcolor{blue}{xwatermark} package - \hspace{1cm}\textcolor{red}{\textbullet}% - \hspace{1cm}\color{white}\framebox[2cm][c]% - {\phantom{Hello}}\rotatebox[origin=c]{90}{% - \makebox[1.4cm][c]{\phantom{Hello}}}% - }% - }% - \\[17.2cm] - \xwcolorbox{framesep=5pt,framerule=2pt, - fillcolor=gray!55,framecolor=white, - align=center,width=\paperheight, - text={% - \color{white}\framebox[2cm][c]{\phantom{Hello}}% - \hspace{1cm}\color{black}\textcolor{red}% - {\textbullet}\hspace{4.3cm}User manual for the % - \textcolor{blue}{xwatermark} package\hspace{4.3cm}% - \textcolor{red}{\textbullet}\hspace{1cm} - \color{white}\framebox[2cm][c]{\phantom{Hello}}% - \rotatebox[origin=c]{90}{% - \makebox[1.4cm][c]{\phantom{Hello}}}% - }% +\finish{example} + +In plain \tex the only active character is the tie character (\ie, \hx{\nobreakspace}). However, some packages do make some other characters active. For example, after issuing the command \hx{\MakeShortVerb{\x}}, the packages \pkg{doc} and \pkg{shortvrb} make the character \fx{x} active\footnote{The \pkg'{fancyvrb} has, \eg, \ftfx{\DefineShortVerb[key=value pairs]{\x}}.}. The user can use such active characters in values of the \fx{textmark} key without locally changing their catcode to~11 or~12. In the case of \hx{\MakeShortVerb{\x}}, you can issue \hx{\DeleteShortVerb{\x}} to revert to normal use of character \fx{x}. As another example, the option \hx{turkish} of the \pkg'{babel} uses the equal sign (\hx{=}) as active shorthand character. + + +\docsection(sec:making-boxes){Macros for creating boxes} + +To make it easier for users to create paragraph boxes and color boxes of texts and watermarks, the \pkg'{xwatermark} provides the macros \fx{\xwmcolorbox} and \fx{\xwmminipage}. The macro \fx{\xwmcolorbox} calls the macro \fx{\xwmminipage}. + + +\docsubsection(sec:minipage){The \headfx{\xwmminipage} macro} + +The \fx{\xwmminipage} macro is a \hx{minipage} environment that may be used for framing watermarks. It accepts verbatim material. Like the \fx{\newwatermark} macro, this macro is called with key-value pairs as follows (see \amref{tab:localoptions} for a full listing of the available keys): + +\start{newmacro}[\xwmminipage] +\xwmminipage[key=value list]{balanced text} +\xwmcolorbox[key=value list]{balanced text}. +\finish{newmacro} +\fxi*{\xwmminipage} + +The \fx{textcolor} key in \fx{\xwmminipage} is the color of the text. In the case of \fx{\xwmcolorbox}, four color values are expected: \ffx'{textcolor, fillcolor, outerframecolor, 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 \amref{sec:localoptions}. + +The macros \ffx'{\xwmminipage,\xwmcolorbox} can be nested within and among themselves, \eg, + +\start{example}[\xwmminipage] +\newwatermark[pagex={1,3,10},fontfamily=txtt,fontseries=m,color=red, + align=center,scale=0.7,angle=0,xpos=0,ypos=0]{% + \xwmminipage[width=\paperwidth]{% + \xwmminipage[width=\paperwidth,align=left,textcolor=magenta] + {\TeX\\[.1ex] \LaTeX}\\[1ex] + \xwmminipage[width=\paperwidth,align=center,textcolor=green] + {\TeX\\[.1ex] \LaTeX}\\[1ex] + \xwmminipage[width=\paperwidth,align=right,textcolor=orange] + {\TeX\\[.1ex] \LaTeX}% }% - }% } -\end{xwverbatim} - -\subsection{The \YWCB macro}\label{sec:ywcolormacro} -This macro has the same syntax and options as the \cmda{xwcolorbox} macro except that the resulting \styb{colorbox} is centered by using the \styb{center} environment and the markup box \cmdb{makebox[0pt][c]\{\}}. It is intended for producing \styb{colorbox}{}es such as the one for the abstract on \pageref{page:one}. The abstract was produced with the following settings: -\begin{xwverbatim} -\ywcolorbox{framesep=5pt,framerule=2pt,framecolor=red!55, - align=justified,fillcolor=gray!25,width=\hsize, - text={% - \centering\xwcolorbox{align=center,fillcolor=white, - width=.5\hsize,text={\bfseries Abstract}}\\[1ex] - The \stya{xwatermark} package enables the user ... - }% +\finish{example} + +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. + + +\docsubsection(sec:colorbox){The \headfx{\xwmcolorbox} macro} + +The macro \fx{\xwmcolorbox} provides a key-value interface to \pkg'{xcolor}'s \hx{\fcolorbox}\footnote{The \pkg'{xwatermark} also comes with the macro \fx{\xwmshade} which is similar to \fx{\xwmcolorbox}, but which, unlike \fx{\xwmcolorbox}, can break neatly across pages (in the manner of the \pkg'{framed}). But since no watermark is expected to break across pages, the macro \fx{\xwmshade} isn't described in this guide. Power users should still be able to use it.}. + +\start{newmacro}[\xwmcolorbox] +\xwmcolorbox[key=value list]{balanced text}. +\finish{newmacro} +\fxi*{\xwmcolorbox} + + +\docsubsection(sec:makecolorbox){The \headfx{\makecolorbox} macro} + +This macro has the same syntax and options as the \fx{\xwmcolorbox} macro except that the resulting \hx{colorbox} is centered by using the \hx{center} environment and the markup box \hx{\makebox[0pt][c]{}}. It is intended for producing \hx{colorbox}\unskip es such as the one for article abstracts. The user may experiment with the following settings, from which the abstract of this guide was produced: + +\start{newmacro}[\makecolorbox] +\makecolorbox[framesep=4pt,framerule=1pt,innerframecolor=red!55, + outerframecolor=ForestGreen,align=justified, + fillcolor=gray!25,width=.95\hsize,boxalign=center, + height=2.5mm,depth=0mm,framebox]{% + \centering\xwmcolorbox[align=center,fillcolor=white, + innerframecolor=blue,outerframecolor=orange,width=.5\hsize, + height=2mm]{\textbf{Abstract}}\\[\baselineskip] + The \pkg'{xwatermark} provides facilities for \ldots } -\end{xwverbatim} -Notice here that the macro \cmda{ywcolorbox} calls the macro \cmda{xwcolorbox} with its (\cmda{ywcolorbox}{}'s) \stya{framesep} and \stya{framerule}. +\finish{newmacro} +\fxi*{\makecolorbox} + +Notice here that the macro \fx{\makecolorbox} calls the macro \fx{\xwmcolorbox}. + + +\docsection(sec:fancypagenos){The \headfx{\fancypagenos} macro} + +The macro \fx{\fancypagenos}, which has the following syntax, can be used to position and format page numbers in the desired fashion. Its keys and their default values are described in \amref{tab:localoptions}. Page numbers produced by \fx{\fancypagenos} will, by default, appear in the foreground, so that they can be seen on top of watermarks. If you want the page numbers to appear in the background, then set \fx{sendtoback}=\hx{true} as one of the key-value pairs in the call to \fx{\fancypagenos}. + +\start{newmacro}[\fancypagenos] +\fancypagenos[key=value pairs] +\finish{newmacro} +\fxi*{\fancypagenos} + +Even after issuing the command \fx{\fancypagenos}, you can still decide not to print the fancy page numbers by calling the command \fxi{\NoFancyPageNumbers}. The complement of the command \fxi{\NoFancyPageNumbers} is \fxi{\FancyPageNumbers}. + + +\docsection(sec:geometry)[\headpkg{xwatermark} and \headpkg{geometry} package] + {Using \headpkg{xwatermark} with \headpkg{geometry} package} + +Because the \pkg'{geometry} changes the scale, ratio, magnification, and other native dimensions of the paper to get the needed layout right all the time, the \pkg'{geometry} may interfere with the \pkg'{xwatermark}. The only layout parameter that the \pkg'{geometry} may retain is the paper center, which, unfortunately, does not always coincide with the text center. In fact, even the \hx{\paperwidth} and \hx{\paperheight} can be changed by the user of the \pkg'{geometry}. + +Feasible solutions to this problem include setting the watermarks before loading the \pkg'{geometry}; using the \pkg'{geometry} with the option \fx{pass} in the preliminary runs, when setting the watermarks (see further details below); using \hx{true} dimensions (\eg, \fx{coordunit}=\hx{truept}); and using relative, rather than absolute, dimension units (\ie, \hhx'{em,ex}). The power-user can also experiment with the primitives \hhx'{\magnification, \mag, \magstep}. -Users may also like to consider the possible use of the \cmdb{fcolorbox} macro of the \styb{xcolor} package in setting the textmarks. +The \hx{pass} option of the \pkg'{geometry} has been available from version~4.2 of the \pkg'{geometry} onwards. It disables auto-layout and all of the \pkg'{geometry} settings except \hx{verbose} and \hx{showframe}. It can be used to determine the page layout of the \hx{\documentclass} and layouts created by other packages and manual settings. The user can also employ the option \hx{showframe} of the \pkg'{geometry} to view how the scaling factors used by the \pkg'{geometry} might change native layout dimensions. The option \hx{reset} of the \pkg'{geometry} is also useful in this regard. -\section{Using \stya{\bf xwatermark} with the \styb{\bf geometry} package} -\label{sec:Xwatermark:Geometry} -\lletter{S}{ome users} have reported an apparent ``conflict'' between the \styb{geometry} package and \stya{xwatermark}, which according to them makes it rather unpleasant to properly position the watermarks. There is actually what, for want of a better term, I may refer to as a ``mismatch'' between \styb{geometry} and \stya{xwatermark} but certainly not a conflict. The problem emanates from the \styb{geometry} package because it changes the scale, ratio, magnification, and other native dimensions of the paper to get the needed layout right all the time. The only layout parameter that the \styb{geometry} package may retain is the paper center, which, unfortunately, does not always coincide with the text center. In fact, even the paperwidth and paperheight can be changed by the user of the \styb{geometry} package. +The \pkg'{geometry} saves native \texorlatex dimensions and switches in the macro \hx{\Gm@dorg} before processing \pkg'{geometry} options. This macro is called by \pkg{geometry} when the options \hx{pass} and \hx{reset} are passed to it. Reconciling the two packages (\pkg{xwatermark,geometry}) at a \quoted{high level} will involve simply calling this macro within the \pkg'{xwatermark} whenever \pkg{xwatermark} detects that the \pkg'{geometry} has been loaded by the user. This is what has been done in the \pkg'{xwatermark}: the package has a boolean option called \fx{disablegeometry}, which, if true, invokes the command \hx{\Gm@dorg} of the \pkg'{geometry} to disable \pkg'{geometry} settings and enforce native paper layout dimensions. First the \pkg'{xwatermark} detects at the very last moment of the document preamble (just before \hx{\begin{document}}) if the \pkg'{geometry} has been loaded by the user. If yes, and if the user has suggested \fx{disablegeometry}=\hx{true} in the call to \pkg{xwatermark}, then \pkg{xwatermark} issues the command \hx{\geometry{pass}}, which, as mentioned earlier, calls \hx{\Gm@dorg}. -Reconciling the \stya{xwatermark} package with the \styb{geometry} package at the very low level requires more effort than I can afford now. The interim solution is that the user should set his/her watermarks before loading the \styb{geometry} package, or use the \styb{geometry} package with the option \styb{pass} in the preliminary runs (when setting the watermarks). The \styb{pass} option is available from version~4.2 of the \styb{geometry} package. It disables auto-layout and all of the \styb{geometry} settings except \styb{verbose} and \styb{showframe}. It can be used to determine the page layout of the \dclass and layouts created by other packages and manual settings. The user can also employ the option \styb{showframe} of the \styb{geometry} package to view how the scaling factors used by the \styb{geometry} package might change native layout dimensions. The option \styb{reset} of the \styb{geometry} package is also useful in this regard. +After the effects of the \pkg'{geometry} are re-introduced (\ie, after setting the \pkg'{xwatermark} option \fx{disablegeometry}=\hx{false}), it might still be necessary, depending on the user need, to fine-tune the positions of the watermarks. -The \styb{geometry} package saves native \TeXL dimensions and switches in the macro \cmdb{Gm@dorg} before processing \styb{geometry} package options. This macro is called by \styb{geometry} when the options \styb{pass} and \styb{reset} are passed to it. Reconciling the two packages (\stya{xwatermark} and \styb{geometry}) at a high level will involve simply calling this macro within \stya{xwatermark} whenever \stya{xwatermark} detects that the \styb{geometry} package has been loaded by the user. This is what has been done in the \stya{xwatermark} package: the package has a boolean option called \stya{dgeometry} (meaning ``disable geometry''), which, if true, invokes the command \cmdb{Gm@dorg} of the \styb{geometry} package to disable \styb{geometry} package settings and enforce native paper layout dimensions. First the \stya{xwatermark} package detects at the very last moment of the document preamble (just before \cmdb{begin\{document\}}) if the \styb{geometry} package has been loaded by the user. If yes, and if the user has set \stya{dgeometry=true} in the call to \stya{xwatermark}, then \stya{xwatermark} issues the command \cmdb{geometry\{pass\}}, which, as mentioned earlier, calls \cmdb{Gm@dorg}. +Because the \pkg'{geometry} stipulates that the command \hx{\Gm@dorg} can be issued only in the document preamble, the switch \fx{disablegeometry} can appear as option only in \hx{\documentclass} or \hx{\usepackage{xwatermark}}. But it matters not which of the two packages (\pkg{geometry, xwatermark}) is loaded first. To call \hx{\Gm@dorg}, the \pkg'{xwatermark} uses the hook \hx{\BeforeStartOfDocument} from the \pkg'{catoptions}. \hx{\AtBeginDocument}, a native \latex hook, is inapplicable in this case. -After the effects of the \styb{geometry} package are re-introduced (\ie, after setting \styb{pass=false}), it might still be necessary to fine-tune the positions of the watermarks. -Because the \styb{geometry} package stipulates that the command \cmdb{Gm@dorg} can be issued only in the document preamble, the switch \stya{dgeometry} can appear only in \usepackxwm, as in, \eg, -\begin{xwverbatim} -\usepackage[printwatermark,allpages,dgeometry]{xwatermark}, -\end{xwverbatim} -but it matters not which of the two packages (\styb{geometry} and \stya{xwatermark}) is loaded first. To call \cmdb{Gm@dorg}, the \stya{xwatermark} package uses the hook \cmdb{AtEndPreamble} from the \styb{etoolbox} package. \cmdb{AtBeginDocument}, a native \nLaTeX hook, is inapplicable in this case. +\docsection{Support for \deadunexpandable{\acro{UNICODE}} and + \deadunexpandable{\acro{UTF}} encodings} -The user should also remember that he/she can set his/her own margins without using the \styb{geometry} package, although many users find the \styb{geometry} package more convenient. +The \pkg'{xwatermark} can be used with any font encoding, provided the \fx{fontfamily} is properly declared before use. For example, with the following declarations on \XeTeX, Rembrandt Wolpert (\url{wolpert@uark.edu}) obtained some \fx{.pdf} outputs that he is willing to share with other users: -\section{Support for Unicode and UTF encodings} -\lletter{T}{he} \stya{xwatermark} package can be used with any font encoding, provided the \stya{fontfamily} is properly declared before use. For example, with the following declarations on \XeTeX, Rembrandt Wolpert (\url{wolpert@uark.edu}) obtained some {}+.pdf+ outputs that he is willing to share with other users: -\begin{xwverbatim} +\start{example}[\newfontfamily] \newfontfamily{\chinese}{STFangsong} % SinoType FangSong -\newcommand{\chtext}[1]{{\chinese \XeTeXlinebreaklocale% - "jp" \XeTeXlinebreakskip=0pt plus 1pt #1}% +\newcommand{\chtext}[1]{{\chinese \XeTeXlinebreaklocale "jp" + \XeTeXlinebreakskip=0pt plus 1pt #1}% } -\watermarksetup{fontsize=5cm,align=center, - color=red!75!blue!25,angle=90,xcoord=-65,ycoord=-38, - scale=.49,textmark={=\fbox{\color{red!65}\chtext{% - |color(red)watermark in Chinese or Japanese script|color(blue)}}=}% -} +\newwatermark[allpages,fontsize=5cm,align=center, + color=red!75!blue!25,angle=90,xpos=-65,ypos=-38,scale=.49] + {=\fbox{\color{red!65}\chtext{|color(red)watermark in Chinese or Japanese script|color(blue)}}=} \newfontfamily{\Gara}{Garamond Premier Pro} -\watermarksetup{fontsize=5cm,scale=.46,align=center, - angle=90,color=red!75!blue!25,xcoord=-72,ycoord=-38, - textmark={=\fbox{\color{red!65}\Gara The different % - ligature}=\\[.35ex]}% -}. -\end{xwverbatim} - -It doesn't matter what the user declares as a \stya{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 (\eg, Latin, Chinese, Korean, Japanese, Arabic, Russian scripts, you name it). - -\section{Further examples of use of \stya{\bf xwatermark} package} -\lletter{T}{he file} \stya{xwatermark-examples.tex}, a source file of examples of use of the \stya{xwatermark} package, together with its \stya{pdf} version, are provided with this guide in the \stya{xwatermark} bundle. - -\section{Future extension} -\lletter{C}{urrently the package} cannot put more than one watermark on the same page in a simple manner. To be able to do so, some tricks are necessary, as was done with the watermarks on the pages of this document. To position more than one mark on the same page, complicated tricks may be necessary, but are often possible. Markup boxes (especially zero-width boxes) can be handy in this respect, but the user should note the displeasure that unintended spaces can cause in boxes. It will be useful to relieve the user of such complications. This is an obvious track for extension of the package. One possible way to tackling this challenge is to accumulate the watermarks for each page before calling the shipout hooks, or loop over the watermarks (meant for the same page) within the shipout hooks, or write the watermarks to the auxiliary file and make more than one run to get them to the right pages. - -The user should note the real meanings of saved-box commands (such as \cmdb{newsavebox}, \cmdb{savebox}, and \cmdb{usebox}) before using them. They are actually bins and not all declarations made outside the bins may be visible inside them. - -There is also the issue with the \styb{geometry} package mentioned in section~\ref{sec:Xwatermark:Geometry}. - -\section{Epilogue} -\lletter{B}{ug reports} and suggestions for further improvement and extension of the package are very much welcome. - -\section{Acknowledgement} -I thank Joseph Wright (\url{joseph.wright@morningstar2.co.uk}) for his time in helping me resolve some of the challenges I encountered in coding this package---and for his continued support. - -\appendix -\section{Package options}\label{sec:PackageOptions} -\lletter{W}{e categorize} the package options into global and local. Global options are those set either in \dclass or in \usepackxwm or with the macro \wmsetup, while local options are those set with the macros \cmda{xwminipage}, \cmda{xwcolorbox} and \cmda{ywcolorbox}. - -\subsection{Global options} -The global package options are listed and described in table~\vref{tab:GlobalOptions}. - -\extrarowheight=2pt -\arrayrulecolor{yellow} -\begin{tabularx}{\linewidth}{|m{3cm}|m{2.5cm}|X|} -\caption{Global options of the package\label{tab:GlobalOptions}}\\\hline -\rowcolor{pink} -\bfseries Option&\bfseries Default&\bfseries Meaning\\\hline -\endfirsthead -\hline -\multicolumn{3}{|l|}{\emph{Continued from last page}}\\\hline -\bfseries Option&\bfseries Default&\bfseries Meaning\\\hline -\endhead -\multicolumn{3}{|r|}{\emph{Continued on next page}}\\\hline -\endfoot -\hline -\endlastfoot -+printwatermark+ & +true+ & Global boolean switch that determines whether watermark should be printed or not. This option can be passed to package as either \stya{true} or \stya{false} and can appear in the \dclass options list or \cmdb{usepackage}. If for any reason you don't want the watermark printed in any run, you can enter \stya{printwatermark=false}. If the option \styb{draft} or \styb{final} appears in the \dclass or \cmdb{usepackage}, it won't affect the printing or otherwise of the watermark. The printing of the watermark is determined by the option \stya{printwatermark}.\\\hline -+allpages+, +evenpages+, +oddpages+, +pages+,~+page+ & & These determine the pages on which the watermarks are to be printed. The options \stya{allpages}, \stya{evenpages}, \stya{oddpages} are boolean keys, while \stya{pages} and \stya{page} require values, \eg, \stya{pages=x-x} and \stya{page=x}. If the package is loaded and none of these options is passed to it, the default watermark (DRAFT) will be printed on the first page of the document and a warning message logged in the transcript file.\\\hline -+textmark+ & DRAFT & The text watermark.\\\hline -+angle+ & $45^\circ$ & The orientation of the watermark (text and/or picture). \\\hline -+scale+ & 1 & The scale of the text watermark.\\\hline -+grayness+ & 0.8 & The grayness of the text watermark. This is no longer available as an option since the grayness of the gray color can be set as a percentage (\eg, +color=gray!25+).\\\hline -+color+ & +gray+ & The color of the text watermark.\\\hline -+fontfamily+ & +cmss+ & The fontfamily of the text watermark.\\\hline -+fontsize+ & 5cm& The fontsize of the text watermark. If for some reason you need other fontsizes (\eg, 10pt, 11pt or 12pt for printing text watermarks in +\normalfont+), you will need to submit them as values of \stya{fontsize}.\\\hline -+fontseries+ & +b+ & The font series of the text watermark. If you need normal document text, put \stya{fontseries=m}, which implies medium weight and width.\\\hline -+xcoord+ & 0 & x-coordinate of watermark (with reference to the center of paper and not the text center).\\\hline -+ycoord+ & 0 & y-coordinate of watermark (coinciding with center of paper). Both \stya{xcoord} and \stya{ycoord} should be submitted without units, since the unit is set separately by \stya{coordunit}.\\\hline -+coordunit+ & +mm+ & The unit for x- and y-coordinates. \\\hline -+align+ & +center+ & Alignment of the watermark (the key can assume the value \stya{center}, \stya{left}, \stya{right} or \stya{justified}). Any other alignment value is inadmissible and thus rejected by the package with a fatal error.\\\hline -+width+ &+\paperheight+ & Width of \textbf{text} watermarks only; doesn't apply to graphic watermarks. For some design reasons we set +\paperheight+ as the default value of markwidth instead of markheight.\\\hline -+height+ & +\paperwidth+ & Height of text watermark.\\\hline -+picscale+ & 1 & Scale of picture watermark.\\\hline -+picbb+ & 0 0 100 100& The bounding box (dvi mode) or viewport (pdf mode) of the picture watermark.\\\hline -+picfile+ & & The filename of picture watermark. This, with its full path, must be submitted when including picture watermark.\\\hline -+picfilex+ & eps/pdf & The filename extension of the picture watermark. Admissible extensions are \stya{eps}, \stya{pdf}, \stya{png} and \stya{jpeg}; the latter three may be used in the case of \pdfTeX. The file extension should be passed without the dot. If the option is not passed to package, \stya{xwatermark} selects \stya{eps} (in dvi mode) or \stya{pdf} (in \pdfTeX mode). \\\hline -+showcenter+ & & Boolean that indicates if the center of the paper should be shown with a cross (and circle).\\\hline -+dgeometry+ & +false+ & The package option that determines whether the page layout settings by the \styb{geometry} package should be disabled so that the watermarks can be set more readily by \stya{xwatermark}.\\ -\end{tabularx} - -\subsection{Local options}\label{sec:LocalOptions} -Local package options are those associated with the macros \cmda{xwminipage}, \cmda{xwcolorbox} and \cmda{ywcolorbox}. They are described in table~\ref{tab:LocalOptions}. - -\begin{tabularx}{\linewidth}{|m{3cm}|m{2.5cm}|X|} -\caption{Local options of the package\label{tab:LocalOptions}}\\\hline -\rowcolor{pink} -\bfseries Option&\bfseries Default&\bfseries Meaning\\\hline -\endfirsthead -\hline -\multicolumn{3}{|l|}{\emph{Continued from last page}}\\\hline -\bfseries Option&\bfseries Default&\bfseries Meaning\\\hline -\endhead -\multicolumn{3}{|r|}{\emph{Continued on next page}}\\\hline -\endfoot -\hline -\endlastfoot -\multicolumn{3}{|>{\columncolor{gray!25}}c|}{\bf\cmda{xwminipage} macro}\\\hline -+width+ & +\paperwidth+ & Width of the boxedminipage.\\\hline -+textcolor+ & +black+ & Color of text inside boxedminipage.\\\hline -+framecolor+ & +white+ & Color of frame of boxedminipage.\\\hline -+text+ & No text passed & Text that goes inside the boxedminipage.\\\hline -+align+ & +center+ & Alignment of the text inside the boxedminipage of \cmda{xwminipage} (expected values are \stya{center}, \stya{left}, \stya{right} and \stya{justified}).\\\hline -+framesep+ & +3pt+ & +\fboxsep+ of the boxedminipage.\\\hline -+framerule+ & +0.4pt+ & +\fboxrule+ of the boxedminipage.\\\hline -\multicolumn{3}{|>{\columncolor{gray!25}}c|}{\bf\cmda{xwcolorbox} macro}\\\hline -+width+ & +\paperwidth+ & Width of the colorbox.\\\hline -+textcolor+ & +black+ & Color of text inside colorbox.\\\hline -+framecolor+ & +white+ & Color of frame of colorbox.\\\hline -+text+ & No text passed & Text that goes inside the colorbox.\\\hline -+align+ & +center+ & Alignment of the text inside the colorbox of \cmda{xwcolorbox} (expected values are \stya{center}, \stya{left}, \stya{right} and \stya{justified}).\\\hline -+framesep+ & +3pt+ & +\fboxsep+ of the colorbox.\\\hline -+framerule+ & +0.4pt+ & +\fboxrule+ of the colorbox.\\\hline -\multicolumn{3}{|>{\columncolor{gray!25}}c|}{\bf\cmda{ywcolorbox} macro}\\\hline -\multicolumn{3}{|m{\hsize-1.5cm}|}{% -The options of the macro \cmda{ywcolorbox} are the same as those of the related macro \cmda{xwcolorbox}. Refer to section~\ref{sec:ywcolormacro} for the syntax of this macro. -}\\ -\end{tabularx} +\newwatermark[allpages,fontsize=5cm,scale=.46,align=center, + angle=90,color=red!75!blue!25,xpos=-72,ypos=-38] + {=\fbox{\color{red!65}\Gara The different ligature}=\\[.35ex]}. +\finish{example} +\hxi*{\newfontfamily} + +It doesn't matter what the user declares as a \fx{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 (\eg, Latin, Chinese, Korean, Japanese, Arabic, Russian scripts, you name it). + +\docsection{Repeated graphics in a document} + +For graphics watermarks, the watermark image, or any other image that is repeated in the document, has the potential to make the processed version of the document surprisingly large. The 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 \acro{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 \texttt{PostScript} version of the file is destined for conversion to \pdf, either by a ghostscript-based mechanism such as \hx{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 \texttt{PostScript} has them amalgamated. \pdftex does the same job with graphics, automatically converting multiple insertions into pointers to graphics objects. + + +\docsection{Further examples of use of \headpkg{xwatermark} package} + +The files \files'{xwatermark-examples1,xwatermark-examples2}, source files of examples of use of the \pkg'{xwatermark} together with their \pdf versions, are provided with this guide in the \pkg{xwatermark} bundle. + + +\docsection(sec:packageoptions){Package options and macro keys} + +We categorize the package options and keys into global and local. Global options are those set either in \hx{\documentclass} or in \hx{\usepackage}, while local options are those set with the macros \ffx'{\newwatermark,\newwallpaper,\xwmminipage,\xwmcolorbox,\makecolorbox}. + + +\docsubsection(sec:globaloptions){Global options} + +The global package options are listed and described in the following \amref{tab:globaloptions}. + +\ifboolTF{amd@inputfile}{% + \InputDocument{tab-globaloptions} +}{} + + +\docsubsection(sec:localoptions){Local options} + +Local package options are those associated with the commands \ffx'{\newwatermark, \newwallpaper, \xwmminipage, \xwmcolorbox, \makecolorbox, \fancypagenos}. They are described in the following \amref{tab:localoptions}. + +\ifboolTF{amd@inputfile}{% + \InputDocument{tab-localoptions} +}{} + + +\docsection(sec:version-hist){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 \stsign 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. + +\begin{versionhist} + \begin{version}{1.5.1}{2011/07/20} + \item Following user request, two new keys were introduced for the macro \fx{\fancypagenos}. \vsecref{sec:fancypagenos} + \end{version} + \begin{version}{1.5.0}{2011/07/10} + \item Introduced the \pkg'{ltxkeys}, a highly robust and optimized module for general creation and management of keys. \vsecref* + \item Provisions for placing more than one watermark on the same page. \vsecref{sec:newwatermarks} + \item Introduced wallpaper functionalities. \vsecref{sec:wallpapers} + \item Adaptable and flexible fancy page numbers. \vsecref{sec:fancypagenos} + \end{version} +\end{versionhist} + +\newpage +\indexpreamble{Index numbers refer to page numbers.} +\indexpreambleformat{\centering} +\indexcolumns\tw@ +\printindex \end{document} + |