%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++% % 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 } \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 } \author{Ahmed Musa\\[1ex]University of Central Lancashire\\ Preston PR1 2HE, United Kingdom\\[1ex] \email{a.musa@rocketmail.com} } \xmaketitle[empty] \ywcolorbox{framesep=5pt,framerule=2pt,framecolor=red!55!brown, align=justified,fillcolor=gray!25,width=\hsize, text=\xtempb } \bgroup\small\tableofcontents\egroup \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 } \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} \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} \documentclass[a4paper,12pt,printwatermark]{article} \usepackage[evenpages]{xwatermark}. \end{xwverbatim} 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} The option \stya{printwatermark} should not appear in \wmsetup but in the statement \usepackxwm or in the \dclass options list. 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. \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} 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. \section{Other aspects of package architecture and use} \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} \usepackage[printwatermark=false]{xwatermark}, \end{xwverbatim} and vice versa. 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. \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}. \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}. 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. \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. \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} 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: \begin{xwverbatim} \documentclass{class-type} \usepackage{xkvltxp} \usepackage[printwatermark,% textmark=\textsc{Johnson's~Text}]{xwatermark} \begin{document} ... \end{document} \end{xwverbatim} 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} In fact, in this way even expandable commands can be passed to the package, as follows: \begin{xwverbatim} \documentclass{class-type} \usepackage[printwatermark]{xwatermark} \newcommand*\temparg{Fran\c coise M\"uller's\endgraf Text} \watermarksetup{allpages,textmark=\temparg} \begin{document} ... \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}}}% }% }% }% } \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 ... }% } \end{xwverbatim} Notice here that the macro \cmda{ywcolorbox} calls the macro \cmda{xwcolorbox} with its (\cmda{ywcolorbox}{}'s) \stya{framesep} and \stya{framerule}. Users may also like to consider the possible use of the \cmdb{fcolorbox} macro of the \styb{xcolor} package in setting the textmarks. \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. 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. 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}. 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. 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. \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} \newfontfamily{\chinese}{STFangsong} % SinoType FangSong \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)}}=}% } \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} \end{document}