diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex')
-rw-r--r-- | Master/texmf-dist/tex/latex/xwatermark/xwatermark.sty | 576 |
1 files changed, 360 insertions, 216 deletions
diff --git a/Master/texmf-dist/tex/latex/xwatermark/xwatermark.sty b/Master/texmf-dist/tex/latex/xwatermark/xwatermark.sty index c9b5394e3b8..51b61741c18 100644 --- a/Master/texmf-dist/tex/latex/xwatermark/xwatermark.sty +++ b/Master/texmf-dist/tex/latex/xwatermark/xwatermark.sty @@ -1,5 +1,5 @@ %++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++% -% This is file 'xwatermark.sty', version 1.5.2b, August 2012. % +% This is file 'xwatermark.sty', version 1.5.2c, October 2012. % % % % This package puts user-specified watermarks (graphics and arbitrary % % texts) on select pages of documents. See package documentation % @@ -23,17 +23,17 @@ %++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++% \@ifpackageloaded{catoptions}{% - \@ifpackagelater{catoptions}{2012/08/01}{}{% + \@ifpackagelater{catoptions}{2012/10/14}{}{% \@latex@error{Loaded version of 'catoptions' package is - not current}\@ehc + not current}\@ehd }% }{% - \RequirePackage{catoptions}[2012/08/01]% + \RequirePackage{catoptions}[2012/10/14]% } \UseNormalCatcodes \StyleFilePurpose{A dynamic watermarking scheme} \StyleFileRCSInfo -$Id: xwatermark.sty,v 1.5.2b 2012/08/10 09:00:00 Ahmed Musa Exp $ +$Id: xwatermark.sty,v 1.5.2c 2012/10/14 09:00:00 Ahmed Musa Exp $ \ProvidesPackage{xwatermark}[\StyleFileInfo] \NeedsTeXFormat{LaTeX2e}[2011/06/27] \SetStyleFileMessages[xwm@]{info}{warn}{err} @@ -55,13 +55,44 @@ $Id: xwatermark.sty,v 1.5.2b 2012/08/10 09:00:00 Ahmed Musa Exp $ \newletcs\xwm@nil\relax \new@def*\xwm@nnil{\xwm@nil} \AtBeginShipoutInit -\newvariables{box}[xwm@box]{a,b}\relax -\newvariables{count}[xwm@]{cnta}[\z@pt] -\newvariables{if}[xwm@]{pdf,swa,swb,foregrd,wall}[false] -\newvariables{write}[xwm@]{wrt}\relax +\cptnewvariables{box}[xwm@box]{a,b}\relax +\cptnewvariables{count}[xwm@]{cnta}[\z@pt] +\cptnewvariables{if}[xwm@]{pdf,swa,swb,foregrd,wall,putmark}[false] +\xwm@putmarktrue +\cptnewvariables{write}[xwm@]{wrt}\relax \robust@def*\AtShipoutAlwaysUpperLeft#1{% \AtBeginShipout{\AtBeginShipoutUpperLeft{#1}}% } +\robust@def*\xwm@secstartpage#1{% + \begingroup + \def\do##1##2,{% + \ifx\do##1\else + \csn@gdef{xwm@secstartpage@@\romannumeral##1}{##2}% + \expandafter\do + \fi + }% + \do#1,\do\do,% + \endgroup +} +\new@def*\xwm@seclist{} +\AtEndDocument{% + \immediate\write\@auxout{% + \string\xwm@secstartpage{\xwm@seclist}% + }% +} +\robust@def*\xwm@recordsecno{% + \xdef\xwm@seclist{% + \xwm@seclist\ifx\xwm@seclist\@empty\else,\fi + {\thesection}{\thepage}% + }% +} +\edef\reserved@a{% + \def\noexpand\@seccntformat##1{% + \unexpanded\expandafter{\@seccntformat{#1}}% + \unexpanded{\protect\xwm@recordsecno}% + }% +} +\reserved@a \new@def*\xwm@boxframestack{} \robust@def*\xwm@pushboxframe{% \xdef\xwm@boxframestack{% @@ -107,7 +138,7 @@ $Id: xwatermark.sty,v 1.5.2b 2012/08/10 09:00:00 Ahmed Musa Exp $ } \robust@def*\xwm@ifxcolorloaded{% \ifcsndefTF{ver@xcolor.sty}\@iden{% - \xwm@err{'xcolor' package not loaded}\@ehc + \xwm@err{'xcolor' package not loaded}\@ehd }% } \robust@def*\xwmdefinecolor{% @@ -126,7 +157,7 @@ $Id: xwatermark.sty,v 1.5.2b 2012/08/10 09:00:00 Ahmed Musa Exp $ \@ifundefinedcolor{#2}{% \reserved@e[#1]{#2}% }{% - \xwm@err{Color name '#2' already defined}\@ehc + \xwm@err{Color name '#2' already defined}\@ehd }% } \robust@def*\xwmdefinecolorset{\cpt@testopt\xwm@definecolorset{x}} @@ -140,7 +171,7 @@ $Id: xwatermark.sty,v 1.5.2b 2012/08/10 09:00:00 Ahmed Musa Exp $ \def\xwm@tempa##1,##2,##3,##4,##5\@nil{% \ifblankTF{##4}{% \xwm@err{Incomplete color format in - \string\xwmdefinecolorset}\@ehc + \string\xwmdefinecolorset}\@ehd }{% \def\xwm@tempf{##1}% }% @@ -165,10 +196,10 @@ $Id: xwatermark.sty,v 1.5.2b 2012/08/10 09:00:00 Ahmed Musa Exp $ \expandafter\do\normalized@list;\@nil;% \ifcsemptyTF\xwm@tempe{}{% \xwm@err{Color names '\expandcsonce\xwm@tempe' multiply - \MsgBrk submitted to \string\xwmdefinecolorset}\@ehc + \MsgBrk submitted to \string\xwmdefinecolorset}\@ehd }% \ifcsemptyTF\xwm@tempc{}{% - \xwm@err{Color names '\expandcsonce\xwm@tempc' already in use}\@ehc + \xwm@err{Color names '\expandcsonce\xwm@tempc' already in use}\@ehd }% \ifcsemptyTF\xwm@tempb{}{% \cptexpandarg{\xglobal\definecolorset{rgb}{#1}{#2}} @@ -179,15 +210,21 @@ $Id: xwatermark.sty,v 1.5.2b 2012/08/10 09:00:00 Ahmed Musa Exp $ } \DefSuffixChecker\xwm@suffixcheck{*}{+}{'} \robust@def*\xwmifitemsinTF{% - \cpt@swatrue\cpt@testopt\xwm@itemsin\@ne + \xwm@swatrue\cpt@testopt\xwm@itemsin\@ne } \robust@def*\xwmifitemsinFT{% - \cpt@swafalse\cpt@testopt\xwm@itemsin\@ne + \xwm@swafalse\cpt@testopt\xwm@itemsin\@ne +} +\robust@def*\xxwmifitemsinTF{% + \xwm@swatrue\cpt@testopt\xwm@xitemsin{1}% +} +\robust@def\xwm@xitemsin[#1]#2#3{% + \cptexpandtwoargs{\xwm@itemsin[#1]}{#2}{#3}% } \robust@def\xwm@itemsin[#1]#2#3{% \ifnum\numexpr#1<\@ne \xwm@err{Invalid number '\the#1'\relax\MsgBrk - for command \string\xwmifitemsinTF}\@ehc + for command \string\xwmifitemsinTF}\@ehd \fi \lowercase{% \edef\xwm@tempa{\unexpanded{#2}}% @@ -198,28 +235,23 @@ $Id: xwatermark.sty,v 1.5.2b 2012/08/10 09:00:00 Ahmed Musa Exp $ \def\xwm@items{}% \def\csv@do##1{% \xifinsetFT{,\detokenize{##1}}{,\cptoxdetok\xwm@tempb}{}{% - \cptaddtolist[,]\xwm@items{##1}% - \pushnumber\xwm@nritems - \ifnum\xwm@nritems>\numexpr#1-1\relax - \loopbreak - \fi + \edef\xwm@items{% + \expandcsonce\xwm@items\ifx\xwm@items\@empty\else,\fi + \unexpanded{##1}% + }% + \edef\xwm@nritems{\the\numexpr\xwm@nritems+1}% + \ifnum\xwm@nritems>\numexpr#1-1\relax\loopbreak\fi }% }% \csv@@parse*[,]\xwm@tempa \csname @\ifnum\xwm@nritems>\numexpr#1-1\relax - \ifcpt@swa first\else second\fi + \ifxwm@swa first\else second\fi \else - \ifcpt@swa second\else first\fi + \ifxwm@swa second\else first\fi \fi oftwo\endcsname } -\robust@def*\x@xwmifitemsinTF{% - \cpt@swatrue\cpt@testopt\xwm@xitemsin{1}% -} -\robust@def\xwm@xitemsin[#1]#2#3{% - \cptexpandtwoargs{\xwm@itemsin[#1]}{#2}{#3}% -} \robust@def*\xwm@hyphenpagerange#1#2#3{% \xifinsetTF{\detokenize{\xwmgetpagenumber}}{\cptoxdetok{#1}}{% \xwm@swbtrue @@ -240,7 +272,7 @@ $Id: xwatermark.sty,v 1.5.2b 2012/08/10 09:00:00 Ahmed Musa Exp $ }{% \ifblankTF{#1}{% \xwm@err{Empty page range for watermark: - ^^J'\expandcsonce\currwatermark'.^^J}\@ehc + ^^J||\expandcsonce\xwm@currwatermark||.^^J}\@ehd }{% \protected@edef#3{#1}% }% @@ -250,11 +282,11 @@ $Id: xwatermark.sty,v 1.5.2b 2012/08/10 09:00:00 Ahmed Musa Exp $ \def#3{#1}\def#4{#2}% \ifinsetTF{-}{#2}{% \xwm@err{Too many hyphens in page range '#1-#2' - \MsgBrk of watermark:^^J'\expandcsonce\currwatermark'}\@ehc + \MsgBrk of watermark:^^J||\expandcsonce\xwm@currwatermark||}\@ehd }{% \ifblankTF{#1}{% \xwm@warn{No start-page in page-range of watermark: - ^^J'\expandcsonce\currwatermark'.^^JI have used the + ^^J||\expandcsonce\xwm@currwatermark||.^^JI have used the default start-page '\xwm@defaultfirstpage' instead}% \def#3{\xwm@defaultfirstpage}% @@ -264,7 +296,7 @@ $Id: xwatermark.sty,v 1.5.2b 2012/08/10 09:00:00 Ahmed Musa Exp $ }% \ifblankTF{#2}{% \xwm@warn{No end-page for page-range - of watermark:^^J'\expandcsonce\currwatermark' + of watermark:^^J||\expandcsonce\xwm@currwatermark|| ^^JI have used the default end-page '\xwm@defaultlastpage' instead}% \def#4{\xwm@defaultlastpage}% @@ -277,7 +309,7 @@ $Id: xwatermark.sty,v 1.5.2b 2012/08/10 09:00:00 Ahmed Musa Exp $ \ifnum\numexpr#1<\numexpr#2\relax\else \ifxwm@swb\else \xwm@err{Watermark start-page '#1' is greater - than end-page '#2'}\@ehc + than end-page '#2'}\@ehd \fi \fi \fi @@ -331,7 +363,7 @@ $Id: xwatermark.sty,v 1.5.2b 2012/08/10 09:00:00 Ahmed Musa Exp $ \cptexpandsecond{\def\reserved@a##1}{#1}##2##3\xwm@nil{% \def\reserved@a{##2}% \ifxTF\reserved@a\xwm@nnil{% - \cpt@err{Invalid value '#1' for textalign}\@ehc + \cpt@err{Invalid value '#1' for textalign}\@ehd \def#1{xwm@relax}% }{% \def#1{##2}% @@ -379,12 +411,12 @@ $Id: xwatermark.sty,v 1.5.2b 2012/08/10 09:00:00 Ahmed Musa Exp $ \expandafter\xwm@resa\reserved@a-\xwm@nil-% \s@expandarg\ifnullTF{\the\toks@}{}{% \xwm@err{'boxalign' has invalid or inconsistent - \MsgBrk values '#1'}\@ehc + \MsgBrk values '#1'}\@ehd }% \ifcsnullTF\xwm@tempa{}{% \ifcsnullTF\xwm@tempb{}{% \xwm@err{Invalid values '#1' for 'boxalign': - \MsgBrk possibly a mixture of styles}\@ehc + \MsgBrk possibly a mixture of styles}\@ehd }% }% \def\xwm@tempc{}% @@ -417,7 +449,7 @@ $Id: xwatermark.sty,v 1.5.2b 2012/08/10 09:00:00 Ahmed Musa Exp $ \xifblankTF{#1}{% \def\xwm@tempc{s}% }{% - \xwm@err{Invalid entries '#1' for 'boxalign'}\@ehc + \xwm@err{Invalid entries '#1' for 'boxalign'}\@ehd }% }{% \begingroup @@ -425,7 +457,7 @@ $Id: xwatermark.sty,v 1.5.2b 2012/08/10 09:00:00 Ahmed Musa Exp $ \def\siso@do##1{\advance\cpt@cnta\@ne}% \s@expandarg\siso@@loop\xwm@tempc \ifnum\cpt@cnta>2\relax - \xwm@err{More than two entries '#1' for 'boxalign'}\@ehc + \xwm@err{More than two entries '#1' for 'boxalign'}\@ehd \fi \endgroup }% @@ -433,7 +465,7 @@ $Id: xwatermark.sty,v 1.5.2b 2012/08/10 09:00:00 Ahmed Musa Exp $ \postgroupdef#1\endgroup } \robust@def*\xwm@notenddocerr{% - \xwm@err{Wrong location of end-of-document command}\@ehc + \xwm@err{Wrong location of end-of-document command}\@ehd } \robust@def*\AfterEndOfDocument{\grightaddtocs\xwm@afterenddoc} \new@def*\xwm@afterenddoc{} @@ -572,7 +604,7 @@ $Id: xwatermark.sty,v 1.5.2b 2012/08/10 09:00:00 Ahmed Musa Exp $ \cptgxaddtolist*\xwm@picfilesread{\usename{#2picfile}}% }% \aftercsname\xwm@stripallouterbracesincs{#2picfileext}% - \ifboolTF{xwm@pdf}{% + \ifdefboolTF{xwm@pdf}{% \xifinsetTF{,\usename{#2picfileext},}{,pdf,png,jpeg,jpg,mps,}{}{% \csn@def{#2picfileext}{pdf}% \ifxwm@swb\xwm@tempb{pdf}{pdf}\fi @@ -605,7 +637,7 @@ $Id: xwatermark.sty,v 1.5.2b 2012/08/10 09:00:00 Ahmed Musa Exp $ printwatermark=true; print-watermark=true/\setaliaskey{printwatermark}; allownesting=true; - showpagecenter=true/\ifboolTF{xwm@showpagecenter} + showpagecenter=true/\ifdefboolTF{xwm@showpagecenter} {\wmk@showpagecentertrue\wlp@showpagecentertrue}{}; show-page-center=true/\setaliaskey{showpagecenter}; showpapercenter=true/\setaliaskey{showpagecenter}; @@ -652,13 +684,13 @@ $Id: xwatermark.sty,v 1.5.2b 2012/08/10 09:00:00 Ahmed Musa Exp $ \ifbracedTF{##1}{% \aftercsname{\xwm@stripallouterbraces{##1}}{#1graphicsoptions} }{% - \cpt@err{Values of key 'graphicsoptions' not braced}\@ehc + \cpt@err{Values of key 'graphicsoptions' not braced}\@ehd }; GraphicsOptions=/ \ifdocstartedTF{% \xwm@err{\noexpand\GraphicsOptions is a command, not a key.\MsgBrk - Maybe you meant 'graphicsoptions'}\@ehc + Maybe you meant 'graphicsoptions'}\@ehd }{}; picontoptext=true; picture-on-top-text=true/\setaliaskey{picontoptext}; @@ -713,8 +745,7 @@ $Id: xwatermark.sty,v 1.5.2b 2012/08/10 09:00:00 Ahmed Musa Exp $ \usename{#1tmarkfalse} }{% \usename{#1tmarktrue} - }% - \letcstocsn\currwatermark{#1textmark}; + }; text-mark=DRAFT/\setaliaskey{textmark}; firstpage=true/\ifdefboolFT{#1firstpage}{}{\usename{#1minmarktrue}}; first-page=true/\setaliaskey{firstpage}; @@ -724,7 +755,7 @@ $Id: xwatermark.sty,v 1.5.2b 2012/08/10 09:00:00 Ahmed Musa Exp $ page=1/ \ifinsetTF{-}{##1}{% \xwm@err{I found '-' in '##1' for key 'page', - \MsgBrk but 'page' doesn't take page-range}\@ehc + \MsgBrk but 'page' doesn't take page-range}\@ehd }{% \ifnum\numexpr##1=\z@pt\else\usename{#1onepageonlytrue} \usename{#1minmarktrue}\fi @@ -738,7 +769,7 @@ $Id: xwatermark.sty,v 1.5.2b 2012/08/10 09:00:00 Ahmed Musa Exp $ \cptmakecs{#1pagestart}\cptmakecs{#1pageend}}; pagex={1}/ \ifbracedTF{##1}{}{% - \xwm@err{Value of key 'pagex' must be braced}\@ehc + \xwm@err{Value of key 'pagex' must be braced}\@ehd }; boxalign=/\ifblankTF{##1}{} {\aftercsname\xwm@setboxalign{#1boxalign}}; @@ -954,29 +985,31 @@ $Id: xwatermark.sty,v 1.5.2b 2012/08/10 09:00:00 Ahmed Musa Exp $ tileno,tilenumber,tile-number,number-of-tiles } \new@def*\xwm@pagespecifiers{% - page=,pages=,pagex=,firstpage,lastpage,allpages,% - oddpages,evenpages% + % '=' is needed here to create uniqueness; eg, to avoid confusing + % ',page' with ',pages'. + page=,pages=,pagex=,firstpage,lastpage,allpages,oddpages,evenpages,% + section=,sections=,sectionx=% } \robust@def*\xwm@decidedetok#1{% - \ifsingletokenTF{#1}{% + \ifntypeTF{#1}{% \ifmacroTF{#1}{% - \let\xwm@detok\cptoxdetok + \let\xwm@detoktype\cptoxdetok }{% - \let\xwm@detok\detokenize + \let\xwm@detoktype\detokenize }% }{% - \let\xwm@detok\detokenize + \let\xwm@detoktype\detokenize }% } \robust@def*\xwm@decidexp#1{% - \ifsingletokenTF{#1}{% + \ifntypeTF{#1}{% \ifmacroTF{#1}{% - \let\xwm@xp\expandcsonce + \let\xwm@exptype\expandcsonce }{% - \let\xwm@xp\unexpanded + \let\xwm@exptype\unexpanded }% }{% - \let\xwm@xp\unexpanded + \let\xwm@exptype\unexpanded }% } \robust@def*\newwatermark#1{% @@ -992,8 +1025,7 @@ $Id: xwatermark.sty,v 1.5.2b 2012/08/10 09:00:00 Ahmed Musa Exp $ }% } \robust@def*\xnewwatermark{% - \xwm@suffixcheck - {\cpt@teststpm{\cpt@testopt\cpt@xnewwatermark{}}}% + \xwm@suffixcheck{\cpt@teststpm{\cpt@testopt\cpt@xnewwatermark{}}}% } \robust@def*\xwm@ltxcmds{% \centering,\flushright,\flushleft,\raggedright,% @@ -1051,20 +1083,20 @@ $Id: xwatermark.sty,v 1.5.2b 2012/08/10 09:00:00 Ahmed Musa Exp $ }% } \robust@def\xwm@n@wwatermark[#1]#2{% - \ifboolTF{cpt@pm}{}{\xwm@n@ww@termark{#1}{#2}}% + \ifdefboolTF{cpt@pm}{}{\xwm@n@ww@termark{#1}{#2}}% } \robust@def\xwm@n@ww@termark#1#2{% \xwm@decidexp{#1}% - \edef\xwm@currattrib{\xwm@xp{#1}}% + \edef\xwm@currattrib{\xwm@exptype{#1}}% \cpt@sttrue\cpt@kvnormalize[,]\xwm@currattrib \xwm@decidexp{#2}% - \edef\xwm@currmark{\xwm@xp{#2}}% + \edef\xwm@currmark{\xwm@exptype{#2}}% \xwm@decidedetok{#2}% \xwm@swafalse - \xifinsetTF{\detokenize{\newwatermark}}{\xwm@detok{#2}}{% + \xifinsetTF{\detokenize{\newwatermark}}{\xwm@detoktype{#2}}{% \xwm@swatrue }{% - \xifinsetTF{\detokenize{\newwallpaper}}{\xwm@detok{#2}}{% + \xifinsetTF{\detokenize{\newwallpaper}}{\xwm@detoktype{#2}}{% \xwm@swatrue }{}% }% @@ -1072,10 +1104,10 @@ $Id: xwatermark.sty,v 1.5.2b 2012/08/10 09:00:00 Ahmed Musa Exp $ \ifxwm@allownesting\else \xwm@err{Nested '\string\newwatermark' or '\string\newwallpaper'\MsgBrk - while option 'allownesting' is false}\@ehc + while option 'allownesting' is false}\@ehd \fi \fi - \ifboolTF{xwm@wall}{}{% + \ifdefboolTF{xwm@wall}{}{% \xwmifitemsinFT[1]{% squaretiles,square-tiles,tilexsize,tile-xsize,% tileysize,tile-ysize,wpxoffset,wallpaper-xoffset,% @@ -1084,13 +1116,13 @@ $Id: xwatermark.sty,v 1.5.2b 2012/08/10 09:00:00 Ahmed Musa Exp $ tile-number,number-of-tiles% }{#1}{}{% \xwm@@err{'\xwm@items' not admissible for - \MsgBrk non-wallpaper watermarks}\@ehc + \MsgBrk non-wallpaper watermarks}\@ehd }% }% - \ifboolTF{xwm@allownesting}{}{% + \ifdefboolTF{xwm@allownesting}{}{% \cpt@choicefdfalse \def\csv@do##1{% - \xifinsetFT{,\detokenize{##1}}{,\xwm@detok{#2}}{}{% + \xifinsetFT{,\detokenize{##1}}{,\xwm@detoktype{#2}}{}{% \def\xwm@tempa{##1}% \cpt@choicefdtrue\loopbreak }% @@ -1101,28 +1133,28 @@ $Id: xwatermark.sty,v 1.5.2b 2012/08/10 09:00:00 Ahmed Musa Exp $ \MsgBrk The following keys are not allowed in \MsgBrk mandatory/second argument of \MsgBrk '\string\newwatermark' or '\string\newwallpaper': - ^^J||\xwm@samplemarkkeys||}\@ehc + ^^J||\xwm@samplemarkkeys||}\@ehd \fi }% - \xifinsetFT\xwm@watermarkparser{\xwm@detok{#2}}{}{% + \xifinsetFT\xwm@watermarkparser{\xwm@detoktype{#2}}{}{% \xwm@err{Watermark parser '\xwm@watermarkparser' appears in the following watermark.\MsgBrk Enclose your token - '\xwm@watermarkparser' in braces:^^J||\unexpanded{#2}||}\@ehc + '\xwm@watermarkparser' in braces:^^J||\unexpanded{#2}||}\@ehd }% - \x@xwmifitemsinTF[1]\xwm@pagespecifiers{\expandcsonce\xwm@currattrib}{% - \x@xwmifitemsinTF[2]\xwm@pagespecifiers{\expandcsonce\xwm@currattrib}{% + \xxwmifitemsinTF[1]\xwm@pagespecifiers{\expandcsonce\xwm@currattrib}{% + \xxwmifitemsinTF[2]\xwm@pagespecifiers{\expandcsonce\xwm@currattrib}{% \xwm@err{Too many page specifiers '\xwm@items' for watermark: ^^J||\expandcsonce\xwm@currattrib||}{% Only one page specifier is allowed in watermark.}% }{}% }{% \xwm@err{No page specifier for watermark: - ^^J||\expandcsonce\xwm@currmark||}\@ehc + ^^J||\expandcsonce\xwm@currmark||}\@ehd }% \ifcsnullTF\xwm@currattrib{% \ifcsnullTF\xwm@currmark{}{% \xwm@@err{No attributes for watermark: - ^^J||\expandcsonce\xwm@currmark||}\@ehc + ^^J||\expandcsonce\xwm@currmark||}\@ehd }% }{% \xwm@makecurrmark @@ -1132,150 +1164,256 @@ $Id: xwatermark.sty,v 1.5.2b 2012/08/10 09:00:00 Ahmed Musa Exp $ \expandcsonce\xwm@backlist\fi }% \expandafter\edef\reserved@a{% - \expandafter\ifdefTF\reserved@a{\expandcstwice\reserved@a}{}% - \expandcsonce\currwatermark + \expandafter\ifdefined\reserved@a\expandcstwice\reserved@a\fi + \expandcsonce\xwm@currwatermark }% - \undefcs\xwm@xp\undefcs\xwm@detok } -\robust@def*\xwm@twopagespecerr{% - \ifxwm@swa +\robust@def*\xwm@avoidtwopagespecs{% + \if\xwm@pagespecfd \xwm@err{Two page specifiers in watermark attributes: - ^^J||\cptoxdetok{\xwm@currattrib}||}\@ehc + ^^J||\cptoxdetok\xwm@currattrib||}\@ehd \else - \xwm@swatrue + \def\xwm@pagespecfd{00}% \fi } \robust@def*\xwm@addcurrmark#1{% - \begingroup - \xifinsetTF{,\detokenize{textmark}}{,\cptoxdetok\xwm@currattrib}{% - \@tempswafalse - \ifxTF\xwm@currmark\@empty{}{% - \xwm@err{Duplicate nonempty 'textmark'}\@ehc + % Local group is in effect. + % If the current mark is already on current page, ignore it. This, eg, + % avoids 'pagex={1,1,2},textmark=X' making two entries for 'X' on page 1. + \letcstocsn\reserved@a{xwm@mark@@\romannumeral#1}% + \ifx\reserved@a\xwm@currattrib\else + \xifinsetTF{\detokenize{textmark=}}{\cptoxdetok\xwm@currattrib}{% + \@tempswafalse + \ifx\xwm@currmark\@empty\else + \xwm@err{Duplicate textmark in ||\cptoxdetok\xwm@currmark||} + {I found textmark earlier in the mandotory argument of + \noexpand\newwatermark, and now I find textmark key in the + attribute list.}% + \fi + }{% + \@tempswatrue }% - }{% - \@tempswatrue - }% - \edef\xwm@tempb{% - page=\number#1,\expandcsonce\xwm@currattrib,% - \if@tempswa textmark={\expandcsonce\xwm@currmark}\fi - }% - \ifcsemptyTF\xwm@tempb{}{\xwm@normalizedoublecomma\xwm@tempb}% - \edef\currwatermark{% - \expandcsonce\currwatermark{\number#1}{\expandcsonce\xwm@tempb}% - }% - \postgroupdef\currwatermark\endgroup + \edef\xwm@tempb{% + page=\number#1,\expandcsonce\xwm@currattrib,% + \if@tempswa textmark={\expandcsonce\xwm@currmark}\fi + }% + \edef\xwm@currwatermark{% + % {<page.no>}{<curr.mark>} + \expandcsonce\xwm@currwatermark{\number#1}{\expandcsonce\xwm@tempb}% + }% + \gletcsntocs{xwm@mark@@\romannumeral#1}\xwm@currattrib + \fi } \robust@def*\xwm@getpagespec#1{% - \ifinsetTF{,#1,}{,page,pages,pagex,}{% - \def\xwm@tempa##1#1=##2,##3\xwm@nil{% - \ifblankTF{##2}{% - \xwm@warn{Key 'page/pages' has blank value; - \MsgBrk '1' used instead}\@ehc - \def\xwm@currpage{1}% - }{% - \ifstrcmpTF{#1}{pages}{% - \ifinsetTF{,}{##2}{% - \xwm@err{Key 'pages' doesn't accept comma-separated - \MsgBrk page numbers: use a hyphen}\@ehc - }{}% + \ifinsetTF{,#1,}{,page,pages,pagex,section,sections,sectionx,}{% + % \xwm@ifpagespec has shown that #1 is in \xwm@currattrib. We + % need to confirm that '#1=' is in \xwm@currattrib. + \xifinsetTF{,\detokenize{#1=}}{,\cptoxdetok\xwm@currattrib}{% + \def\xwm@tempa##1#1=##2,##3\xwm@nil{% + \ifblankTF{##2}{% + \xwm@warn{Key '#1' has an empty value; '1' assumed}\@ehd + \def\xwm@currpages{1}% }{% - \ifstrcmpTF{#1}{pagex}{% - \ifinsetTF{-}{##2}{% - \xwm@err{Key 'pagex' doesn't accept hyphen-separated - \MsgBrk page numbers: use commas}\@ehc + \ifinsetTF{,#1,}{,pages,sections,}{% + \ifinsetTF{,}{##2}{% + \xwm@err{Key '#1' doesn't accept comma-separated + \MsgBrk page numbers: use a hyphen}\@ehd }{}% - }{}% + }{% + \ifinsetTF{,#1,}{,pagex,sectionx,}{% + \ifinsetTF{-}{##2}{% + \xwm@err{Key '#1' doesn't accept hyphen-separated + \MsgBrk page numbers: use commas}\@ehd + }{}% + }{}% + }% + \def\xwm@currpages{##2}% }% - \def\xwm@currpage{##2}% + \edef\xwm@currattrib{\unexpanded{##1,##3}}% }% - \edef\xwm@currattrib{\unexpanded{##1,##3}}% + \expandafter\xwm@tempa\xwm@currattrib,\xwm@nil + }{% + \xwm@err{Key '#1' doesn't have '=' and a value}\@ehd }% - \expandafter\xwm@tempa\xwm@currattrib,\xwm@nil }{% - \def\xwm@tempa##1#1,##2\xwm@nil{% + \xwm@getpagespec@a{#1}% + }% + \kv@@normalize*\xwm@currattrib +} +\robust@def*\xwm@getpagespec@a#1{% + \xifinsetTF{,\detokenize{#1=true},}{,\cptoxdetok\xwm@currattrib,}{% + \def\xwm@tempa##1#1=true,##2\xwm@nil{% \edef\xwm@currattrib{\unexpanded{##1,##2}}% }% \expandafter\xwm@tempa\xwm@currattrib,\xwm@nil + }{% + \xifinsetTF{,\detokenize{#1=false},}{,\cptoxdetok\xwm@currattrib,}{% + \def\xwm@tempa##1#1=false,##2\xwm@nil{% + \edef\xwm@currattrib{\unexpanded{##1,##2}}% + }% + \expandafter\xwm@tempa\xwm@currattrib,\xwm@nil + }{% + \def\xwm@tempa##1#1,##2\xwm@nil{% + \edef\xwm@currattrib{\unexpanded{##1,##2}}% + }% + \expandafter\xwm@tempa\xwm@currattrib,\xwm@nil + }% }% } \robust@def*\xwm@ifpagespec#1{% - \cptexpandtwoargs\cpt@in - {,\detokenize{#1}}{,\cptoxdetok\xwm@currattrib}% - \ifboolTF{cpt@in}\@iden\@gobble + \@expandtwoargs\cpt@in{,\detokenize{#1}}{,\cptoxdetok\xwm@currattrib}% + \ifdefboolTF{cpt@in}\@iden\@gobble } \robust@def*\xwm@normalizedoublecomma#1{% - \def\xwm@tempa##1,,##2\xwm@@nil{% + \def\xwm@tempa##1,,##2\normal@nil{% \ifblankTF{##2}{% \edef#1{\unexpanded{##1}}% }{% - \xwm@tempa##1,##2\xwm@@nil + \xwm@tempa##1,##2\normal@nil }% }% - \expandafter\xwm@tempa#1,,\xwm@@nil + \expandafter\xwm@tempa#1,,\normal@nil } \robust@def*\xwm@makecurrmark{% - \edef\xwm@rsvda{\lastdocpage}% - \def\currwatermark{}% - \xwm@swafalse + \begingroup + \edef\xwm@lastpage{\lastdocpage}% + \def\xwm@currwatermark{}% + \def\xwm@pagespecfd{01}% \xwm@ifpagespec{page=}{% - \xwm@twopagespecerr + \xwm@avoidtwopagespecs \xwm@getpagespec{page}% - \xwm@addcurrmark\xwm@currpage + \xwm@addcurrmark\xwm@currpages }% \xwm@ifpagespec{pages=}{% - \xwm@twopagespecerr + \xwm@avoidtwopagespecs \xwm@getpagespec{pages}% - \xwm@hyphenpagerange\xwm@currpage\xwm@pagestart\xwm@pageend + \xwm@hyphenpagerange\xwm@currpages\xwm@pagestart\xwm@pageend \xwm@cnta\numexpr\xwm@pagestart\relax \cptloop \xwm@addcurrmark\xwm@cnta - \advance\xwm@cnta by1 % + \advance\xwm@cnta\@ne \ifnum\xwm@cnta<\numexpr\xwm@pageend+1\relax \cptrepeat }% \xwm@ifpagespec{pagex=}{% - \xwm@twopagespecerr + \xwm@avoidtwopagespecs \xwm@getpagespec{pagex}% - \def\ltxkeys@do##1{\xwm@addcurrmark{##1}}% - \ltxkeys@parse*1\xwm@currpage + \expandafter\cptfor\xwm@currpages\dofor{% + \xwm@addcurrmark{##1}% + }% }% \xwm@ifpagespec{firstpage}{% - \xwm@twopagespecerr + \xwm@avoidtwopagespecs \xwm@getpagespec{firstpage}% \xwm@addcurrmark{1}% }% \xwm@ifpagespec{lastpage}{% - \xwm@twopagespecerr + \xwm@avoidtwopagespecs \xwm@getpagespec{lastpage}% - \xwm@addcurrmark\xwm@rsvda + \xwm@addcurrmark\xwm@lastpage + }% + \xwm@ifpagespec{allpages}{% + \xwm@avoidtwopagespecs + \xwm@getpagespec{allpages}% + \xwm@cnta\@ne + \cptloop + \xwm@addcurrmark\xwm@cnta + \advance\xwm@cnta\@ne + \ifnum\xwm@cnta<\numexpr\xwm@lastpage+1\relax + \cptrepeat }% \xwm@ifpagespec{evenpages}{% - \xwm@twopagespecerr + \xwm@avoidtwopagespecs \xwm@getpagespec{evenpages}% \xwm@cnta\@ne \cptloop \ifodd\xwm@cnta\else \xwm@addcurrmark\xwm@cnta \fi - \advance\xwm@cnta by1 - \ifnum\xwm@cnta<\numexpr\xwm@rsvda+1\relax + \advance\xwm@cnta\@ne + \ifnum\xwm@cnta<\numexpr\xwm@lastpage+1\relax \cptrepeat }% \xwm@ifpagespec{oddpages}{% - \xwm@twopagespecerr + \xwm@avoidtwopagespecs \xwm@getpagespec{oddpages}% \xwm@cnta\z@pt \cptloop - \ifodd\xwm@cnta\expandafter\@iden\else\expandafter\@gobble\fi - {\xwm@addcurrmark\xwm@cnta}% - \advance\xwm@cnta by1 - \ifnum\xwm@cnta<\numexpr\xwm@rsvda+1\relax + \ifodd\xwm@cnta + \xwm@addcurrmark\xwm@cnta + \fi + \advance\xwm@cnta\@ne + \ifnum\xwm@cnta<\numexpr\xwm@lastpage+1\relax + \cptrepeat + }% + \xwm@ifpagespec{section=}{% + \xwm@avoidtwopagespecs + \xwm@getpagespec{section}% + \xwm@convertsectopage\xwm@currpages + \xwm@addcurrmark\xwm@currpages + }% + \xwm@ifpagespec{sections=}{% + \xwm@avoidtwopagespecs + \xwm@getpagespec{sections}% + \xwm@convertsectopage@hyphen\xwm@currpages + \xwm@hyphenpagerange\xwm@currpages\xwm@pagestart\xwm@pageend + \xwm@cnta\numexpr\xwm@pagestart\relax + \cptloop + \xwm@addcurrmark\xwm@cnta + \advance\xwm@cnta\@ne + \ifnum\xwm@cnta<\numexpr\xwm@pageend+1\relax \cptrepeat }% - \ifxwm@swa\else + \xwm@ifpagespec{sectionx=}{% + \xwm@avoidtwopagespecs + \xwm@getpagespec{sectionx}% + \xwm@convertsectopage\xwm@currpages + \expandafter\cptfor\xwm@currpages\dofor{% + \xwm@addcurrmark{##1}% + }% + }% + \if\xwm@pagespecfd\else \xwm@err{No page specifier in watermark attributes: - ^^J||\cptoxdetok\xwm@currattrib||}\@ehc + ^^J||\cptoxdetok\xwm@currattrib||}\@ehd \fi + \postgroupdef\xwm@currwatermark\endgroup +} +% \xwm@convertsectopage{<current.pages>} +\robust@def*\xwm@convertsectopage#1{% + \begingroup + \def\xwm@tempa{}% + \expandafter\cptfor#1\dofor{% + \letcstocsn\reserved@a{xwm@secstartpage@@\romannumeral##1}% + \ifx\reserved@a\undefined + \def\reserved@a{1}% + \fi + \xifinsetTF{,\reserved@a,}{,\xwm@tempa,}{}{% + \edef\xwm@tempa{% + \xwm@tempa\ifx\xwm@tempa\@empty\else,\fi\reserved@a + }% + }% + }% + \let#1\xwm@tempa + \postgroupdef#1\endgroup +} +% \xwm@convertsectopage@hyphen{<current.pages>} +\robust@def*\xwm@convertsectopage@hyphen#1{% + \begingroup + \def\xwm@tempa{}% + \def\csv@do##1{% + \letcstocsn\reserved@a{xwm@secstartpage@@\romannumeral##1}% + \ifx\reserved@a\undefined + \def\reserved@a{1}% + \fi + \xifinsetTF{-\reserved@a-}{-\xwm@tempa-}{}{% + \edef\xwm@tempa{% + \xwm@tempa\ifx\xwm@tempa\@empty\else-\fi\reserved@a + }% + }% + }% + \csv@@parse*[-]#1% + \let#1\xwm@tempa + \postgroupdef#1\endgroup } \robust@def*\dummywatermark#1{% \ifstrcmpTF{#1}\newwatermark{% @@ -1283,7 +1421,7 @@ $Id: xwatermark.sty,v 1.5.2b 2012/08/10 09:00:00 Ahmed Musa Exp $ {'\string\newwatermark' in front of \string\dummywatermark}% {First comment out or remove '\string\newwatermark'.}% }{% - \ifboolTF{xwm@usedummymarks}\newwatermark\xwm@dummywatermark + \ifdefboolTF{xwm@usedummymarks}\newwatermark\xwm@dummywatermark #1% }% } @@ -1293,7 +1431,7 @@ $Id: xwatermark.sty,v 1.5.2b 2012/08/10 09:00:00 Ahmed Musa Exp $ {'\string\newwallpaper' in front of \string\dummywallpaper}% {First comment out or remove '\string\newwallpaper'.}% }{% - \ifboolTF{xwm@usedummymarks}\newwallpaper\xwm@dummywatermark + \ifdefboolTF{xwm@usedummymarks}\newwallpaper\xwm@dummywatermark #1% }% } @@ -1308,18 +1446,25 @@ $Id: xwatermark.sty,v 1.5.2b 2012/08/10 09:00:00 Ahmed Musa Exp $ \global\let\newwatermark\dummywatermark \global\xwm@usedummymarksfalse } +\robust@def*\xwmsuspendwatermark{\xwm@putmarkfalse} +\robust@def*\xwmresumewatermark{\xwm@putmarktrue} +\newletcs\xwmwatermarkoff\xwmsuspendwatermark +\newletcs\xwmwatermarkon\xwmresumewatermark + \robust@def*\xwm@putbothmarks{% - \ifdefFT\xwm@watermarklist{}\xwm@textpicmark@a - \ifdefFT\xwm@wallpaperlist{}\xwm@wallpaper@a + \ifdefboolFT{xwm@putmark}{}{% + \ifdefFT\xwm@watermarklist{}\xwm@textpicmark@a + \ifdefFT\xwm@wallpaperlist{}\xwm@wallpaper@a + }% } -\chardef\xwm@nowatermark\z@pt +\chardef\xwm@nowatermarksignal\z@pt \AtBeginShipout{% - \endlinechar13\catcode13=5 - \catcode`\ =10 + \endlinechar13 \catcode13=5\relax + \catcode`\ =10\relax \catcode`\\\z@pt \catcode`\{\@ne \catcode`\}\tw@ - \ifboolTF{xwm@printwatermark}{% + \ifdefboolTF{xwm@printwatermark}{% \let\xwm@watermarklist\xwm@backwmklist \let\xwm@wallpaperlist\xwm@backwalllist \AtBeginShipoutUpperLeft{% @@ -1333,8 +1478,8 @@ $Id: xwatermark.sty,v 1.5.2b 2012/08/10 09:00:00 Ahmed Musa Exp $ \xwm@putbothmarks }% }{% - \ifnum\xwm@nowatermark<\@ne - \pushnumber\xwm@nowatermark + \ifnum\xwm@nowatermarksignal<\@ne + \edef\xwm@nowatermarksignal{\the\numexpr\xwm@nowatermarksignal+1}% \xwm@info{'printwatermark=false': no watermark printed}% \fi }% @@ -1400,10 +1545,10 @@ $Id: xwatermark.sty,v 1.5.2b 2012/08/10 09:00:00 Ahmed Musa Exp $ } \robust@def*\xwm@textpicmark@a{% \ifcsnullTF\xwm@watermarklist{% - \ifboolTF{xwm@foregrd}{}{% + \ifdefboolTF{xwm@foregrd}{}{% \ifdefboolFT{xwm@printwatermark}{}{% - \ifboolTF{xwm@draft}{% - \ifboolTF{wmk@showpagecenter}{}{% + \ifdefboolTF{xwm@draft}{% + \ifdefboolTF{wmk@showpagecenter}{}{% \ifnumcmpFT\c@page=\@ne{}{% \cptexpandargonce{\ltxkeys@setkeys[XWM]{watermark}}% \xwm@perpagewmkstate @@ -1446,21 +1591,19 @@ $Id: xwatermark.sty,v 1.5.2b 2012/08/10 09:00:00 Ahmed Musa Exp $ }{% [\ltxkeys@keynames]{\expandcsnonce{xwm@perpage#2state}}% }% - \edef\currwatermark{\unexpanded{#3}}% + \edef\xwm@currwatermark{\unexpanded{#3}}% \ifblankTF{#3}{}{\ltxkeys@setkeys[XWM]{#1}{#3}}% } \robust@def*\xwm@processmarks#1#2{% -%\edef\tempa{\expandcsonce{#1}} -%\show\tempa \def\xwm@pr@cessmarks##1##2{% - \ifstrcmpTF{##1}{.}{}{% + \ifstrcmpTF{##1}{\@nil}{}{% \ifnumcmpTF##1=\c@page{#2}{% \edef#1{\expandcsonce#1\unexpanded{{##1}{##2}}}% }% \xwm@pr@cessmarks }% }% - \cptexpandsecondonce{\def#1{}\xwm@pr@cessmarks}{#1}{.}{}% + \cptexpandsecondonce{\def#1{}\xwm@pr@cessmarks}{#1}{\@nil}{}% } \ltxkeys@disablekeys*[XWM]{main}{printwatermark,disablegeometry} \BeforeStartOfDocument{% @@ -1482,7 +1625,7 @@ $Id: xwatermark.sty,v 1.5.2b 2012/08/10 09:00:00 Ahmed Musa Exp $ \edef\xwm@curralign{\expandcsnonce{#1@textalign}}% \cptexpanded{\endgroup \xwm@put(\mcs{#1@textxpos@a},\mcs{#1@textypos@a}){% - \quitvmode\nxp\@killglue\noindent + \nxp\leavevmode\nxp\@killglue\noindent \nxp\makebox(0,0)[\expandcsnonce{#1@boxalign}]{% \nxp\rotatebox[origin=c]{\mcs{#1@textangle}}{% \nxp\scalebox{\mcs{#1@textscale}}{% @@ -1496,7 +1639,7 @@ $Id: xwatermark.sty,v 1.5.2b 2012/08/10 09:00:00 Ahmed Musa Exp $ \nxp\fontseries\mcs{#1@fontseries}% \nxp\fontsize\mcs{#1@fontsize}\mcs{#1@fontsize@a}% \nxp\selectfont - \quitvmode + \nxp\leavevmode \nxp\begin{\xwm@curralign}% \mcs{#1@textmark}% \nxp\end{\xwm@curralign}% @@ -1508,18 +1651,19 @@ $Id: xwatermark.sty,v 1.5.2b 2012/08/10 09:00:00 Ahmed Musa Exp $ }% \@killglue\normalcolor } -\robust@def*\xwm@getpicsize#1{% +% See also \xwmgetpicturesize. +\robust@def*\xwm@getgrafsize#1{% \ifcsnnullTF{#1@picwidth}{% \ifcsnnullTF{#1@picheight}{% \edef\pic@size{scale=\cptmakecs{#1@picscale}}% }{% \xwm@err{You have supplied picture height - but not width}\@ehc + but not width}\@ehd }% }{% \ifcsnnullTF{#1@picheight}{% \xwm@err{You have supplied picture width - but not height}\@ehc + but not height}\@ehd }{% \edef\pic@size{width=\cptmakecs{#1@picwidth},% height=\cptmakecs{#1@picheight}}% @@ -1528,12 +1672,13 @@ $Id: xwatermark.sty,v 1.5.2b 2012/08/10 09:00:00 Ahmed Musa Exp $ } \robust@def*\xwm@picmark{% \xwm@findpicfile\wmk@picfile\wmk@picfileext - \xwm@getpicsize{wmk}% + \xwm@getgrafsize{wmk}% \cptpassexpanded{% \setbox\xwm@boxa=\hbox{% - \noexpand\includegraphics[\ifxwm@pdf viewport\else - bb\fi=\wmk@picbb,\pic@size,clip,\wmk@graphicsoptions, - \xwm@gr@phicsoptions]{\xwm@filefound}}% + \noexpand\includegraphics[\ifxwm@pdf viewport\else + bb\fi=\wmk@picbb,\pic@size,clip,\wmk@graphicsoptions,% + \xwm@gr@phicsoptions]{\xwm@filefound}% + }% }% \cptdimdef\widthofcurrpic{\wd\xwm@boxa}% \cptdimdef\heightofcurrpic{\ht\xwm@boxa}% @@ -1542,7 +1687,7 @@ $Id: xwatermark.sty,v 1.5.2b 2012/08/10 09:00:00 Ahmed Musa Exp $ \xwm@put(\wmk@picxpos@a,\wmk@picypos@a){% \rotatebox[origin=c]\wmk@picangle{% \cptexpandsecond{\makebox(0,0)}{[\wmk@boxalign]{% - \ifboolTF{xwm@draft}{\xwm@draftbox{wmk}}{\copy\xwm@boxa}% + \ifdefboolTF{xwm@draft}{\xwm@draftbox{wmk}}{\copy\xwm@boxa}% }% }% }}% @@ -1568,7 +1713,7 @@ $Id: xwatermark.sty,v 1.5.2b 2012/08/10 09:00:00 Ahmed Musa Exp $ \newcommand*\xwm@textpicmark@c{% \xwm@getposition\wmk@textxpos\wmk@textypos\wmk@coordunit \xwm@getposition\wmk@picxpos\wmk@picypos\wmk@coordunit - \ifboolTF{wmk@picontoptext}{% + \ifdefboolTF{wmk@picontoptext}{% \ifdefboolFT{wmk@tmark}{}{\xwm@textbox{wmk}}% \ifdefboolFT{wmk@pmark}{}\xwm@picmark }{% @@ -1601,7 +1746,7 @@ $Id: xwatermark.sty,v 1.5.2b 2012/08/10 09:00:00 Ahmed Musa Exp $ \robust@def*\xwm@w@term@rkpaths#1(#2)#3{% \cpt@useemptytrue \def\xwm@tempa{#3}% - \ifboolTF{cpt@st}{% + \ifdefboolTF{cpt@st}{% \ifbracedTF{#3}{\xwm@stripallouterbraces{#3}\xwm@tempa}{}% \def\csv@do##1{% \ifbracedTF{##1}{% @@ -1616,13 +1761,13 @@ $Id: xwatermark.sty,v 1.5.2b 2012/08/10 09:00:00 Ahmed Musa Exp $ \xifinsetFT{,}{\cptoxdetok\xwm@tempa}{}{% \xwm@err{Input path '#3' contains comma: \MsgBrk Commas can appear only in the argument - \MsgBrk of star (*) variant of \string\watermarkpaths}\@ehc + \MsgBrk of star (*) variant of \string\watermarkpaths}\@ehd }% \def\tsv@do##1{% \ifbracedTF{##1}{% \cptexpandarg{\grightaddtocs\xwm@inputpath}{{#1\@iden##1#2}}% }{% - \xwm@err{Input path '##1' needs outer braces}\@ehc + \xwm@err{Input path '##1' needs outer braces}\@ehd }% }% \tsv@@parse*\xwm@tempa @@ -1664,7 +1809,7 @@ $Id: xwatermark.sty,v 1.5.2b 2012/08/10 09:00:00 Ahmed Musa Exp $ }% }% \tsv@@loop*\xwm@inputpath - \ifboolTF{cpt@choicefd}% + \ifdefboolTF{cpt@choicefd}% } \robust@def*\xwm@nofileerr#1#2{% \message{% @@ -1693,7 +1838,7 @@ $Id: xwatermark.sty,v 1.5.2b 2012/08/10 09:00:00 Ahmed Musa Exp $ \robust@def*\xwm@findpicfile#1#2{% \let\xwm@filefound\@empty \edef\xwm@filegiven{#1.#2}% - \ifboolTF{xwm@pdf}{% + \ifdefboolTF{xwm@pdf}{% \xwm@f@ndpicfile{#1}{#2}{pdf,png,jpeg,mps}% }{% \xwm@f@ndpicfile{#1}{#2}{eps,ps}% @@ -1713,8 +1858,8 @@ $Id: xwatermark.sty,v 1.5.2b 2012/08/10 09:00:00 Ahmed Musa Exp $ }% \csv@@loop[,]{#3}% }% - \ifboolTF{xwm@swb}{}{% - \ifboolTF{xwm@swa}{% + \ifdefboolTF{xwm@swb}{}{% + \ifdefboolTF{xwm@swa}{% \xwm@warn{File '\xwm@filegiven' doesn't exist \MsgBrk on given path(s) '\xwm@inputpath', \MsgBrk but I have found \xwm@filefound'}% @@ -1725,7 +1870,7 @@ $Id: xwatermark.sty,v 1.5.2b 2012/08/10 09:00:00 Ahmed Musa Exp $ }% } \robust@def*\xwm@wallpaper@c{% - \ifboolTF{wlp@picontoptext}{% + \ifdefboolTF{wlp@picontoptext}{% \xwm@textwallpaper \xwm@picwallpaper }{% @@ -1736,13 +1881,12 @@ $Id: xwatermark.sty,v 1.5.2b 2012/08/10 09:00:00 Ahmed Musa Exp $ } \robust@def*\xwm@textwallpaper{% \ifdefboolFT{wlp@tmark}{}{% - \ifboolTF{wlp@squaretiles}\xwm@sqtexttiles\xwm@texttiles + \ifdefboolTF{wlp@squaretiles}\xwm@sqtexttiles\xwm@texttiles }% } \robust@def*\xwm@picwallpaper{% \ifdefboolFT{wlp@pmark}{}{% - \ifboolTF{wlp@squaretiles}% - \xwm@sqpictiles\xwm@pictiles + \ifdefboolTF{wlp@squaretiles}\xwm@sqpictiles\xwm@pictiles }% } \robust@def*\xwm@dotiling{\xwm@makedraftbox\xwm@dotiling@a} @@ -1756,8 +1900,7 @@ $Id: xwatermark.sty,v 1.5.2b 2012/08/10 09:00:00 Ahmed Musa Exp $ \xwm@put(\tilex,\xwm@tempa){\rotatebox[origin=c] \xwm@currangle{% \cptexpandsecond{\makebox(0,0)}{[\wlp@boxalign]}{% - \ifboolTF{xwm@draft} - {\xwm@draftbox{wlp}}{\copy\xwm@boxa}% + \ifdefboolTF{xwm@draft}{\xwm@draftbox{wlp}}{\copy\xwm@boxa}% }% }}% \cptdimadd\tilex{\wlp@tilexsize+\wlp@tilexoffset}% @@ -1768,7 +1911,7 @@ $Id: xwatermark.sty,v 1.5.2b 2012/08/10 09:00:00 Ahmed Musa Exp $ \robust@def*\xwm@toofewtiles#1{% \ifnum\numexpr#1<4\relax \xwm@err{Too few square wallpapers '#1'; - \MsgBrk minimum expected: 4}\@ehc + \MsgBrk minimum expected: 4}\@ehd \fi } \robust@def*\xwm@texttiles{% @@ -1836,21 +1979,23 @@ $Id: xwatermark.sty,v 1.5.2b 2012/08/10 09:00:00 Ahmed Musa Exp $ \ifmmode\copy\@tempboxa\else\unhcopy\@tempboxa\fi \endgroup } -\robust@def*\xwmgetpicdim{\cpt@testopt\xwm@getpicdim{}} -\robust@def*\xwm@getpicdim[#1]#2{% +\robust@def*\xwmgetpicturesize{\cpt@testopt\xwm@getpicsize{}} +\robust@def*\xwm@getpicsize[#1]#2{% \begingroup \edef\Ginput@path{% \usecsifdef\Ginput@path\usecsifdef\xwm@inputpath \usecsifdef\input@path }% \setbox\xwm@boxa=\hbox{\includegraphics[#1]{#2}}% - \cptdimdef\xwmwdofpic{\wd\xwm@boxa}% - \cptdimdef\xwmhtofpic{\ht\xwm@boxa}% - \cptdimdef\xwmdpofpic{\dp\xwm@boxa}% - \cptdimdef\xwmtothtofpic{\ht\xwm@boxa+\dp\xwm@boxa}% + % See also \widthofcurrpic. + \cptdimdef\widthofpic{\wd\xwm@boxa}% + \cptdimdef\heightofpic{\ht\xwm@boxa}% + \cptdimdef\depthofpic{\dp\xwm@boxa}% + \cptdimdef\totalheightofpic{\ht\xwm@boxa+\dp\xwm@boxa}% \let\\\cpt@csexit \cptexpanded{\endgroup - \\\xwmwdofpic\\\xwmhtofpic\\\xwmdpofpic\\\xwmtothtofpic}% + \\\widthofpic\\\heightofpic\\\depthofpic\\\totalheightofpic + }% } % #1=optional text to be printed as watermark % #2=sundry fixed keys @@ -1860,12 +2005,11 @@ $Id: xwatermark.sty,v 1.5.2b 2012/08/10 09:00:00 Ahmed Musa Exp $ \cpt@teststpm{\cpt@testopt\xwm@repeatwatermarks{}}% } \robust@def\xwm@repeatwatermarks[#1]#2#3{% - \edef\repeat@marks{\csv@@loop\ifcpt@st*\fi}% + \edef\cpt@tempa{\csv@@loop\ifcpt@st*\fi}% \def\csv@do##1{% \ifblankTF{##1}{}{\newwatermark[#2,##1]{#1}}% }% - \ifboolTF{cpt@pm}{}{\repeat@marks[;]{#3}}% - \undefcs\repeat@marks + \ifdefboolTF{cpt@pm}{}{\cpt@tempa[;]{#3}}% } \ltxkeys@definekeys*[XWM]{boxedminipage}[xwmbmp@]{% width=\textwidth; @@ -1894,7 +2038,7 @@ $Id: xwatermark.sty,v 1.5.2b 2012/08/10 09:00:00 Ahmed Musa Exp $ \xifstrcmpTF\xwmbmp@innerpos{t}{% \vtop }{% - \ifboolTF{mmode}{% + \ifdefboolTF{mmode}{% \vcenter }{% \@pboxswtrue $\vcenter |$ @@ -2146,7 +2290,7 @@ $Id: xwatermark.sty,v 1.5.2b 2012/08/10 09:00:00 Ahmed Musa Exp $ \color{\fad@boxcolor}% \chardef\icol\z@pt \cptdotimes\@tempcnta{% - \pushnumber\icol + \cptpushnumber\icol \colbox{\scalebox\fad@scale {\xwmstrut\fad@height\fad@depth \usename{fade@\romannumeral\icol}}}% @@ -2203,7 +2347,7 @@ $Id: xwatermark.sty,v 1.5.2b 2012/08/10 09:00:00 Ahmed Musa Exp $ \xwm@gethfoffset\pgn@hfoffsetleft\pgn@hfoffsetright \fancyhfoffset[R,L]\xwm@hfoffset \AtBeginShipout{% - \ifboolTF{pgn@sendtoback}{% + \ifdefboolTF{pgn@sendtoback}{% \AtBeginShipoutUpperLeft{% \xwm@f@ncyp@genos }% @@ -2214,7 +2358,7 @@ $Id: xwatermark.sty,v 1.5.2b 2012/08/10 09:00:00 Ahmed Musa Exp $ }% }% } -\newswitch{xwm@fancy} +\cptnewswitch{xwm@fancy} \robust@def*\xwm@f@ncypagenos{% \def\pgn@textmark{% \begingroup @@ -2222,14 +2366,14 @@ $Id: xwatermark.sty,v 1.5.2b 2012/08/10 09:00:00 Ahmed Musa Exp $ \pgn@format{\normalfont\pgn@style}% \endgroup }% - \switchtrue{xwm@fancy}% + \cptswitchtrue{xwm@fancy}% \xwm@textbox{pgn}% - \switchfalse{xwm@fancy}% + \cptswitchfalse{xwm@fancy}% } \robust@def*\xwm@f@ncyp@genos{% \ifboolFT{pgn@showpagenos}{}{% \ifnumcmpTF\c@page=\@ne{% - \ifboolTF{pgn@showonpageone}\xwm@f@ncypagenos\relax + \ifdefboolTF{pgn@showonpageone}\xwm@f@ncypagenos\relax }{% \xwm@f@ncypagenos }% @@ -2239,13 +2383,13 @@ $Id: xwatermark.sty,v 1.5.2b 2012/08/10 09:00:00 Ahmed Musa Exp $ \begingroup \def\temp@err{% \xwm@err{Only digits (without units) are allowed\MsgBrk - in the values of 'hfoffsetleft' and 'hfoffsetright'}\@ehc + in the values of 'hfoffsetleft' and 'hfoffsetright'}\@ehd }% \xifblankTF{#1}{}{% - \x@xwmifitemsinTF\xwm@allowedcoordunits{#1}\temp@err{}% + \xxwmifitemsinTF\xwm@allowedcoordunits{#1}\temp@err{}% }% \xifblankTF{#2}{}{% - \x@xwmifitemsinTF\xwm@allowedcoordunits{#2}\temp@err{}% + \xxwmifitemsinTF\xwm@allowedcoordunits{#2}\temp@err{}% }% \def\xwm@tempc##1##2{% \xifblankTF{##1}{\def##2{1}}{\def##2{##1}}% |