From 6651a05c333440b33f677d0c98225cb4c80f87e9 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Mon, 5 Mar 2012 00:57:23 +0000 Subject: xwatermark git-svn-id: svn://tug.org/texlive/trunk@25564 c570f23f-e606-0410-a88d-b1316a301751 --- .../texmf-dist/tex/latex/xwatermark/xwatermark.sty | 93 +++++++++++++++------- 1 file changed, 65 insertions(+), 28 deletions(-) (limited to 'Master/texmf-dist/tex/latex/xwatermark/xwatermark.sty') diff --git a/Master/texmf-dist/tex/latex/xwatermark/xwatermark.sty b/Master/texmf-dist/tex/latex/xwatermark/xwatermark.sty index e32d7e444f3..9c07a23545a 100644 --- a/Master/texmf-dist/tex/latex/xwatermark/xwatermark.sty +++ b/Master/texmf-dist/tex/latex/xwatermark/xwatermark.sty @@ -310,14 +310,13 @@ $Id: xwatermark.sty,v 1.5.2a 2012/02/01 09:00:00 Ahmed Musa Exp $ \robust@def*\xwm@getposition#1#2#3{% \begingroup \@defaultunits\@tempdima\dimexpr#1#3\p@\relax\@nnil - \csn@xdef{\cptremovescape#1@a}{% - \the\dimexpr0.5\paperwidth+\@tempdima\relax - }% + \edef\xwm@tempa{\the\dimexpr0.5\paperwidth+\@tempdima\relax}% \@defaultunits\@tempdima\dimexpr#2#3\p@\relax\@nnil - \csn@xdef{\cptremovescape#2@a}{% - \the\dimexpr-0.5\paperheight+\@tempdima\relax + \edef\xwm@tempb{\the\dimexpr-0.5\paperheight+\@tempdima\relax}% + \cptexpanded{\endgroup + \csn@def{\cptremovescape#1@a}{\xwm@tempa}% + \csn@def{\cptremovescape#2@a}{\xwm@tempb}% }% - \endgroup } \cptrobustify{% \fbox,\framebox,\makebox,\rotatebox,\scalebox,\raisebox @@ -459,10 +458,10 @@ $Id: xwatermark.sty,v 1.5.2a 2012/02/01 09:00:00 Ahmed Musa Exp $ \undefcs\xwm@afterlastpage \undefcs\xwm@afterl@stpage }% - \let\xwm@n@wlabel\xwm@testdef + \let\xwm@newlabel\xwm@testdef } -\robust@def*\xwm@newlabel{\xwm@n@wlabel{xwmr}} -\robust@def*\xwm@n@wlabel#1#2#3{% +\robust@def*\xwmnewlabel{\xwm@newlabel{xwmr}} +\robust@def*\xwm@newlabel#1#2#3{% \begingroup \ifcsndefFT{#1@#2}{}{% \gdef\xwm@multiplelabels{% @@ -484,6 +483,13 @@ $Id: xwatermark.sty,v 1.5.2a 2012/02/01 09:00:00 Ahmed Musa Exp $ {\global\xwm@swafalse}{\global\xwm@swatrue}% \endgroup } +% No need for \makeatletter in .xwm file since the file is read +% by this package only: +\InputIfFileExists{\jobname.xwm}{}{} +\if@filesw + \immediate\openout\xwm@wrt=\jobname.xwm + \immediate\write\xwm@wrt{\relax} +\fi \AfterLastPageOfDocument{% \if@filesw \begingroup @@ -492,7 +498,6 @@ $Id: xwatermark.sty,v 1.5.2a 2012/02/01 09:00:00 Ahmed Musa Exp $ \endgroup \fi \immediate\closeout\xwm@wrt - \InputIfFileExists{\jobname.xwm}{}{}% \if@filesw \ifx\xwm@multiplelabels\relax \ifxwm@swa @@ -526,17 +531,12 @@ $Id: xwatermark.sty,v 1.5.2a 2012/02/01 09:00:00 Ahmed Musa Exp $ {\@currentlabelname}{\@currentHref}{}}% }% \immediate\write\xwm@wrt{% - \string\xwm@newlabel{#1}{{\@currentlabel}{\thepage}% + \string\xwmnewlabel{#1}{{\@currentlabel}{\thepage}% {\@currentlabelname}{\@currentHref}{}}% }% \endgroup \@esphack } -\InputIfFileExists{\jobname.xwm}{}{} -\if@filesw - \immediate\openout\xwm@wrt=\jobname.xwm - \immediate\write\xwm@wrt{\relax} -\fi \robust@def*\DeclareWatermarkParser#1{% \begingroup \xwm@stripallouterbraces{#1}\xwm@tempa @@ -1153,7 +1153,7 @@ $Id: xwatermark.sty,v 1.5.2a 2012/02/01 09:00:00 Ahmed Musa Exp $ page=\number#1,\expandcsonce\xwm@currattrib,% \if@tempswa textmark={\expandcsonce\xwm@currmark}\fi }% - \ifcsemptyTF\xwm@tempb{}{\xwm@normdoublecomma\xwm@tempb}% + \ifcsemptyTF\xwm@tempb{}{\xwm@normalizedoublecomma\xwm@tempb}% \edef\currwatermark{% \expandcsonce\currwatermark{\number#1}{\expandcsonce\xwm@tempb}% }% @@ -1197,10 +1197,13 @@ $Id: xwatermark.sty,v 1.5.2a 2012/02/01 09:00:00 Ahmed Musa Exp $ {,\detokenize{#1}}{,\cptoxdetok\xwm@currattrib}% \ifboolTF{cpt@in}\@iden\@gobble } -\robust@def*\xwm@normdoublecomma#1{% +\robust@def*\xwm@normalizedoublecomma#1{% \def\xwm@tempa##1,,##2\xwm@@nil{% - \ifblankTF{##2}{\edef#1{\unexpanded{##1}}} - {\xwm@tempa##1,##2\xwm@@nil}% + \ifblankTF{##2}{% + \edef#1{\unexpanded{##1}}% + }{% + \xwm@tempa##1,##2\xwm@@nil + }% }% \expandafter\xwm@tempa#1,,\xwm@@nil } @@ -1257,10 +1260,9 @@ $Id: xwatermark.sty,v 1.5.2a 2012/02/01 09:00:00 Ahmed Musa Exp $ \xwm@getpagespec{oddpages}% \xwm@cnta\z@pt \cptloop - \ifodd\xwm@cnta - \xwm@addcurrmark\xwm@cnta - \fi - \advance\xwm@cnta by1 % + \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 \cptrepeat }% @@ -1442,6 +1444,8 @@ $Id: xwatermark.sty,v 1.5.2a 2012/02/01 09:00:00 Ahmed Musa Exp $ \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}{.}{}{% \ifnumcmpTF##1=\c@page{#2}{% @@ -1473,7 +1477,7 @@ $Id: xwatermark.sty,v 1.5.2a 2012/02/01 09:00:00 Ahmed Musa Exp $ \cptexpanded{\endgroup \xwm@put(\mcs{#1@textxpos@a},\mcs{#1@textypos@a}){% \quitvmode\nxp\@killglue\noindent - \cptexpandsecond{\nxp\makebox(0,0)}{[\mcs{#1@boxalign}]}{% + \nxp\makebox(0,0)[\expandcsnonce{#1@boxalign}]{% \nxp\rotatebox[origin=c]{\mcs{#1@textangle}}{% \nxp\scalebox{\mcs{#1@textscale}}{% \nxp\parbox[c][\mcs{#1@textheight}]% @@ -1516,7 +1520,7 @@ $Id: xwatermark.sty,v 1.5.2a 2012/02/01 09:00:00 Ahmed Musa Exp $ }% }% } -\newcommand*\xwm@picmark{% +\robust@def*\xwm@picmark{% \xwm@findpicfile\wmk@picfile\wmk@picfileext \xwm@getpicsize{wmk}% \cptpassexpanded{% @@ -1525,12 +1529,14 @@ $Id: xwatermark.sty,v 1.5.2a 2012/02/01 09:00:00 Ahmed Musa Exp $ bb\fi=\wmk@picbb,\pic@size,clip,\wmk@graphicsoptions, \xwm@gr@phicsoptions]{\xwm@filefound}}% }% + \cptdimdef\widthofcurrpic{\wd\xwm@boxa}% + \cptdimdef\heightofcurrpic{\ht\xwm@boxa}% + \cptdimdef\depthofcurrpic{\dp\xwm@boxa}% \xwm@makedraftbox \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}% + \ifboolTF{xwm@draft}{\xwm@draftbox{wmk}}{\copy\xwm@boxa}% }% }% }}% @@ -1824,6 +1830,37 @@ $Id: xwatermark.sty,v 1.5.2a 2012/02/01 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{% + \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}% + \let\\\cpt@csexit + \cptexpanded{\endgroup + \\\xwmwdofpic\\\xwmhtofpic\\\xwmdpofpic\\\xwmtothtofpic}% +} +% #1=optional text to be printed as watermark +% #2=sundry fixed keys +% #3=variable keys, separated by semicolon (set-1;...;set-n) +% Each set-i has the syntax +\robust@def*\repeatwatermarks{% + \cpt@teststpm{\cpt@testopt\xwm@repeatwatermarks{}}% +} +\robust@def\xwm@repeatwatermarks[#1]#2#3{% + \edef\repeat@marks{\csv@@loop\ifcpt@st*\fi}% + \def\csv@do##1{% + \ifblankTF{##1}{}{\newwatermark[#2,##1]{#1}}% + }% + \ifboolTF{cpt@pm}{}{\repeat@marks[;]{#3}}% + \undefcs\repeat@marks +} \ltxkeys@definekeys*[XWM]{boxedminipage}[xwmbmp@]{% width=\textwidth; textcolor=black; -- cgit v1.2.3