diff options
author | Karl Berry <karl@freefriends.org> | 2009-12-19 17:01:00 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2009-12-19 17:01:00 +0000 |
commit | 833fac303840a0d9e1e98aef77414e044b7cff6d (patch) | |
tree | d7da8612dce3689c72401bd0ae07fafff1792d3b /Master/texmf-dist/tex | |
parent | 05b1ed95f0b136394141a265d80a6f953b7a900b (diff) |
xwatermark update (18dec09)
git-svn-id: svn://tug.org/texlive/trunk@16450 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex')
-rw-r--r-- | Master/texmf-dist/tex/latex/xwatermark/keyreader.sty | 113 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/xwatermark/xwatermark.sty | 149 |
2 files changed, 177 insertions, 85 deletions
diff --git a/Master/texmf-dist/tex/latex/xwatermark/keyreader.sty b/Master/texmf-dist/tex/latex/xwatermark/keyreader.sty new file mode 100644 index 00000000000..1de651a1221 --- /dev/null +++ b/Master/texmf-dist/tex/latex/xwatermark/keyreader.sty @@ -0,0 +1,113 @@ +%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++% +% This is file 'keyreader.sty', version 0.1. % +% % +% This package reads multiple keys to be defined by xkeyval.sty. % +% % +% This work may be distributed and/or modified under the conditions % +% of the LaTeX Project Public License, either version 1.3 of this % +% license or any later version. The latest version of this license % +% is in http://www.latex-project.org/lppl.txt and version 1.3 or later % +% is part of all distributions of LaTeX version 2005/12/01 or later. % +% % +% The LPPL maintenance status of this software is 'author-maintained'. % +% % +% This software is provided 'as it is', without warranty of any kind, % +% either expressed or implied, including, but not limited to, the % +% implied warranties of merchantability and fitness for a particular % +% purpose. % +% % +% Copyright (c) 2009 Ahmed Musa (a.musa@rocketmail.com). % +%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++% +\begingroup +\catcode064=11% @ +\catcode123=01% { +\catcode125=02% } +\def\x{\endgroup + \edef\kr@restorecodeatend{% + \catcode035=\the\catcode035\relax + \catcode064=\the\catcode064\relax + \catcode123=\the\catcode123\relax + \catcode125=\the\catcode125\relax + }% +} +\x +\catcode035=06% # +\catcode064=11% @ +\catcode123=01% { +\catcode125=02% } +\def\kr@ensurecode#1#2{% + \edef\kr@restorecodeatend{% + \kr@restorecodeatend + \catcode#1=\the\catcode#1\relax + }% + \catcode#1=#2\relax +} +\AtEndOfPackage{\kr@restorecodeatend} +\kr@ensurecode{044}{12}% , +\kr@ensurecode{059}{12}% ; +\kr@ensurecode{038}{03}% & +\ProvidesPackage{keyreader}% + [2009/12/15 v0.1 Read keys for the xkeyval package (AM)] +\NeedsTeXFormat{LaTeX2e}[1996/12/01] +\RequirePackage{xkeyval}[2008/08/13] +\newcommand\kr@warn[1]{\PackageWarningNoLine{keyreader}{#1}} +\newcommand\kr@err[1]{\PackageError{keyreader}{#1}{\@ehc}} +\define@cmdkey[KV]{keyreader}[kr@]{parser}[;]{} +\define@cmdkey[KV]{keyreader}[kr@]{keyprefix}[KV]{} +\define@cmdkey[KV]{keyreader}[kr@]{keyfamily}[fam]{} +\define@cmdkey[KV]{keyreader}[kr@]{macroprefix}[mp@]{} +\DeclareOptionX*{\kr@warn{Unknown option '\CurrentOption' ignored}} +\ExecuteOptionsX[KV]<keyreader>{parser,keyprefix,keyfamily,macroprefix} +\ProcessOptionsX*[KV]<keyreader>\relax +\@ifdefinable\krsetup{% + \def\krsetup#1{\setkeys[KV]{keyreader}{#1}}% +} +\long\def\ifblank#1{\kr@ifblank#1&&\@secondoftwo\@firstoftwo:} +\long\def\kr@ifblank#1#2#4#5:{#4} +\@ifdefinable\stopread{% + \long\def\stopread#1&{\long\def\kr@remainder{#1}}% +} +\def\kr@allist{} +\gdef\kr@define@key#1,#2,#3,#4&{% + \edef\kr@keytype{#1}% + \edef\kr@key{#2}% + \edef\kr@default{#3}% + \def\kr@func{#4}% + \ifcase\number\kr@keytype\relax + \or + \edef\x{\noexpand\define@key[\kr@keyprefix]{\kr@keyfamily}% + {\kr@key}[\kr@default]{\expandafter\noexpand\kr@func}% + }\x + \or + \edef\x{\noexpand\define@cmdkey[\kr@keyprefix]{\kr@keyfamily}% + [\kr@macroprefix]{\kr@key}[\kr@default]{\expandafter\noexpand\kr@func}% + }\x + \or + \edef\x{\noexpand\define@boolkey[\kr@keyprefix]{\kr@keyfamily}% + [\kr@macroprefix]{\kr@key}[\kr@default]{\expandafter\noexpand\kr@func}% + }\x + \or + \ifx\kr@allist\@empty + \kr@err{'\string\kr@allist' is empty: choicekey can't be defined. + \MessageBreak You need to first define '\string\kr@allist' + \MessageBreak as a nonempty set}% + \fi + \edef\x{\noexpand\define@choicekey*[\kr@keyprefix]{\kr@keyfamily}{\kr@key}% + [\noexpand\kr@val\noexpand\kr@nr]{\kr@allist}[\kr@default]% + {\expandafter\noexpand\kr@func}% + }\x + \else + \kr@err{Unknown key type/identifier '\kr@keytype'}% + \fi +} +\newcount\kr@cnta +\newcommand\define@keylist[1]{% + \kr@cnta=\z@\relax\romannumeral-`\q\expandafter\kr@readlist#1;&} +\expandafter\def\expandafter\kr@readlist\expandafter#\expandafter 1\kr@parser#2&{% + \ifblank{#1}{}{% + \ifx#1\stopread\stopread#2&\kr@cnta=1\relax\else\kr@define@key#1&\fi + }% + \ifnum\kr@cnta=\z@\ifblank{#2}{}{\kr@readlist#2&}\fi +} + +\endinput
\ No newline at end of file diff --git a/Master/texmf-dist/tex/latex/xwatermark/xwatermark.sty b/Master/texmf-dist/tex/latex/xwatermark/xwatermark.sty index 653ab50f239..bce397e73a3 100644 --- a/Master/texmf-dist/tex/latex/xwatermark/xwatermark.sty +++ b/Master/texmf-dist/tex/latex/xwatermark/xwatermark.sty @@ -2,9 +2,8 @@ % This is file 'xwatermark.sty', version 1.3. % % % % This package puts user-specified watermarks (graphics and arbitrary % -% texts) on select pages of documents. It is more general than, eg, the % -% packages 'draftwatermark', 'watermark' and 'draftmark'. See package % -% documentation for further details. % +% texts) on select pages of documents. See package documentation % +% for further details. % % % % This work may be distributed and/or modified under the conditions % % of the LaTeX Project Public License, either version 1.3 of this % @@ -77,7 +76,7 @@ $Id: xwatermark.sty,v 1.3 2009/10/27 09:00:00 Ahmed Musa Exp $ \ProvidesPackage{xwatermark}[\filedate\space\fileversion\space\filedesc] \NeedsTeXFormat{LaTeX2e}[1996/12/01] -\RequirePackage{etextools}[2009/09/30] +\RequirePackage{etoolbox}[2009/08/06] \RequirePackage{ltxnew}[2009/07/22] \newrobustcmd\xwm@info[1]{\PackageInfo{xwatermark}{#1\@gobble}} \newrobustcmd\xwm@warn[1]{\PackageWarningNoLine{xwatermark}{#1}} @@ -133,26 +132,26 @@ $Id: xwatermark.sty,v 1.3 2009/10/27 09:00:00 Ahmed Musa Exp $ \RequirePackage{fix-cm} \RequirePackage{graphicx} \RequirePackage{xkeyval}[2008/08/13] -\RequirePackage{atbegshi} -\RequirePackage{picture} +\RequirePackage{atbegshi}[2008/07/31] +\RequirePackage{picture}[2008/11/26] \@ifpackageloaded{xcolor}{% \xwm@info{You have loaded 'xcolor' package\MessageBreak with options that possibly differ\MessageBreak - from those of 'xwatermark' package} + from those used in 'xwatermark' package} }{% - \RequirePackage[dvipsnames*,svgnames*,x11names*,table,hyperref]{xcolor} + \RequirePackage[table,hyperref]{xcolor}[2007/01/21] \xwm@info{'xcolor' package loaded with\MessageBreak - options 'dvipsnames', 'svgnames',\MessageBreak - 'x11names', 'table', 'hyperref'} + options 'table', 'hyperref'} } \RequirePackage{xifthen}[2009/04/17] -\RequirePackage{ifpdf} \RequirePackage{boxedminipage} \xwm@dimdef{\xwm@xcoord@a}{\z@} \xwm@dimdef{\xwm@ycoord@a}{\z@} \xwm@numdef{\xwm@minmark}{\z@} \xwm@numdef{\xwm@c@printmark}{\z@} \new\let\xwm@papercenter\relax +\newtoggle{pdf} +\ifundef\pdfoutput{}{\unless\ifnum\pdfoutput<1\toggletrue{pdf}\fi} \define@boolkey[XWM]{xwatermark}[xwm@]{printwatermark}[true]{% \ifxwm@printwatermark\xwm@minmark=\@ne\fi} \define@boolkeys[XWM]{xwatermark}[xwm@bool@]{onepageonly,% @@ -169,14 +168,14 @@ $Id: xwatermark.sty,v 1.3 2009/10/27 09:00:00 Ahmed Musa Exp $ \AtEndPreamble{% \ifxwm@dgeometry \ifcsdef{geometry}{% - \geometry{pass} + \geometry{pass}% \xwm@info{I've detected that you've loaded the\MessageBreak 'geometry' package. To avoid scale changes by\MessageBreak 'geometry', I have disabled its features.\MessageBreak You should set your watermarks before using\MessageBreak - 'geometry'}}{} + 'geometry'}}{}% \fi - } + }% } \define@choicekey*+[XWM]{xwatermark}{align}[\xwm@val\xwm@nr]% {center,right,left,justified}[center]{% @@ -194,16 +193,14 @@ $Id: xwatermark.sty,v 1.3 2009/10/27 09:00:00 Ahmed Musa Exp $ } \define@cmdkey[XWM]{xwatermark}[xwm@]{page}[1]{% \xwm@bool@onepageonlytrue - \xwm@minmark=1\relax + \xwm@minmark=\@ne\relax } \define@key[XWM]{xwatermark}{pages}[1-1]{% \xwm@bool@prangetrue \xwm@pagerange{#1}% - \xwm@minmark=1\relax + \xwm@minmark=\@ne\relax } -\ifpdf\new\def\xwm@picfilex{pdf}\else\new\def\xwm@picfilex{eps}\fi -\define@cmdkey[XWM]{xwatermark}[xwm@]{picscale}[1]{} -\define@cmdkey[XWM]{xwatermark}[xwm@]{picbb}[0 0 100 100]{} +\iftoggle{pdf}{\new\def\xwm@picfilex{pdf}}{\new\def\xwm@picfilex{eps}} \define@cmdkey[XWM]{xwatermark}[xwm@]{picfile}[]{% \ifstrempty{#1}{\xwm@bool@pmarkfalse}{% \xwm@bool@pmarktrue @@ -217,25 +214,21 @@ $Id: xwatermark.sty,v 1.3 2009/10/27 09:00:00 Ahmed Musa Exp $ \ifthenelse{\equal{\xwm@picfilex}{pdf}\OR\equal{\xwm@picfilex}{png} \OR\equal{\xwm@picfilex}{jpeg}\OR\equal{\xwm@picfilex}{eps}}{}{% \xwm@err{File extension \xwm@picfilex\space inadmissible}} - \ifpdf + \iftoggle{pdf}{% \ifthenelse{\isempty{\xwm@picfilex}\OR\equal{\xwm@picfilex}{eps}}% {\def\xwm@picfilex{pdf}}{}% - \else + }{% \ifthenelse{\isempty{\xwm@picfilex}\OR\equal{\xwm@picfilex}{pdf}% \OR\equal{\xwm@picfilex}{png}\OR\equal{\xwm@picfilex}{jpeg}}% {\def\xwm@picfilex{eps}}{}% - \fi + }% } -\define@cmdkey[XWM]{xwatermark}[xwm@]{color}[gray!25]{} -\define@cmdkey[XWM]{xwatermark}[xwm@]{fontfamily}[bch]{} -\define@cmdkey[XWM]{xwatermark}[xwm@]{angle}[45]{} -\define@cmdkey[XWM]{xwatermark}[xwm@]{scale}[1]{} -\define@cmdkey[XWM]{xwatermark}[xwm@]{coordunit}[mm]{} -\define@cmdkey[XWM]{xwatermark}[xwm@]{fontsize}[5cm]{} -\define@cmdkey[XWM]{xwatermark}[xwm@]{fontseries}[b]{} -\define@cmdkey[XWM]{xwatermark}[xwm@]{height}[\paperwidth]{} -\define@cmdkey[XWM]{xwatermark}[xwm@]{width}[\paperheight]{} -\define@cmdkeys[XWM]{xwatermark}[xwm@]{xcoord,ycoord}[\z@] +\RequirePackage[parser=;,macroprefix=xwm@,keyprefix=XWM, + keyfamily=xwatermark]{keyreader} +\define@keylist{2,color,gray!25,;2,fontfamily,bch,;2,angle,45,; + 2,scale,1,;2,coordunit,mm,;2,fontsize,5cm,;2,fontseries,b,; + 2,height,\paperwidth,;2,width,\paperheight,;2,xcoord,\z@,; + 2,ycoord,\z@,;2,picscale,1,;2,picbb,0 0 100 100,;} \presetkeys[XWM]{xwatermark}{tmark,angle,scale,color, textmark,fontfamily,fontsize,fontseries,coordunit, align,height,width,xcoord,ycoord,picscale,picbb}{} @@ -243,12 +236,13 @@ $Id: xwatermark.sty,v 1.3 2009/10/27 09:00:00 Ahmed Musa Exp $ \ExecuteOptionsX[XWM]<xwatermark>{printwatermark} \ProcessOptionsX*[XWM]<xwatermark>\relax \newrobustcmd\watermarksetup[1]{\setkeys[XWM]{xwatermark}{#1}} -\def\xwm@nolateoptions{printwatermark,allpages,evenpages,oddpages,% - firstpage,page,pages} +\def\xwm@nolateoptions{printwatermark} \AtBeginDocument{% \@for\@mem:=\xwm@nolateoptions\do{% + \expandafter\edef\expandafter\@mem\expandafter{\expandafter + \expandafter\expandafter\zap@space\expandafter\@mem\space\@empty}% \key@ifundefined[XWM]{xwatermark}{\@mem}{}{% - \disable@keys[XWM]{xwatermark}{\@mem}% + \xwm@disable@keys[XWM]{xwatermark}{\@mem}% }% }% } @@ -259,7 +253,7 @@ $Id: xwatermark.sty,v 1.3 2009/10/27 09:00:00 Ahmed Musa Exp $ \xwm@dimdef{\xwm@ycoord@a}{-0.5\paperheight+ \number\xwm@ycoord\xwm@coordunit}% }\@tempa% -}% +} \unless\ifxwm@printwatermark \xwm@info{printwatermark=false: no watermark printed} \fi @@ -301,21 +295,13 @@ $Id: xwatermark.sty,v 1.3 2009/10/27 09:00:00 Ahmed Musa Exp $ \ifxwm@allpages \xwm@insert@mark@a \else\ifxwm@firstpage - \ifnum\c@page=\@ne - \xwm@insert@mark@a - \fi + \ifnum\c@page=\@ne\xwm@insert@mark@a\fi \else\ifxwm@oddpages - \ifodd\c@page - \xwm@insert@mark@a - \fi + \ifodd\c@page\xwm@insert@mark@a\fi \else\ifxwm@evenpages - \ifodd\c@page\else - \xwm@insert@mark@a - \fi + \unless\ifodd\c@page\xwm@insert@mark@a\fi \else\ifxwm@bool@onepageonly - \ifnum\c@page=\number\xwm@page - \xwm@insert@mark@a - \fi + \ifnum\c@page=\number\xwm@page\xwm@insert@mark@a\fi \else\ifxwm@bool@prange \ifthenelse{\(\c@page=\xwm@pagestart\OR\c@page=\xwm@pageend\) \OR\(\c@page>\xwm@pagestart\AND\c@page<\xwm@pageend\)}{% @@ -333,32 +319,29 @@ $Id: xwatermark.sty,v 1.3 2009/10/27 09:00:00 Ahmed Musa Exp $ \fi }% \ifxwm@printwatermark - \AtBeginShipout{\AtBeginShipoutUpperLeft{\xwm@insertmark}} - \xwm@info{Option 'printwatermark=true': watermark printed} + \AtBeginShipout{\AtBeginShipoutUpperLeft{\xwm@insertmark}}% + \xwm@info{Option 'printwatermark=true': watermark printed}% \fi -\define@cmdkey[XWM]{minipage}[mp@]{width}[\paperwidth]{} -\define@cmdkey[XWM]{minipage}[mp@]{textcolor}[black]{} -\define@cmdkey[XWM]{minipage}[mp@]{framecolor}[white]{} -\define@cmdkey[XWM]{minipage}[mp@]{framesep}[3pt]{} -\define@cmdkey[XWM]{minipage}[mp@]{framerule}[.4pt]{} -\define@cmdkey[XWM]{minipage}[mp@]{text}[No text passed.]{} -\define@key[XWM]{minipage}{align}[center]{% - \begingroup - \protected@edef\@tempa{#1}% - \def\@tempb{center}% - \ifx\@tempa\@tempb +\krsetup{keyfamily=minipage,macroprefix=mp@} +\define@keylist{2,width,\paperwidth,;2,textcolor,black,; + 2,framecolor,white,;2,framesep,3pt,;2,framerule,0.4pt,; + 2,text,No text passed.,} +\define@cmdkey[XWM]{minipage}[mp@]{align}[center]{% + \protected@edef\mp@align{\mp@align}% + \def\@tempa{center}% + \ifx\mp@align\@tempa \gdef\mp@align{\centering}% \else - \def\@tempb{right}% - \ifx\@tempa\@tempb + \def\@tempa{right}% + \ifx\mp@align\@tempa \gdef\mp@align{\flushright}% \else - \def\@tempb{left}% - \ifx\@tempa\@tempb + \def\@tempa{left}% + \ifx\mp@align\@tempa \gdef\mp@align{\flushleft}% \else - \def\@tempb{justified}% - \ifx\@tempa\@tempb + \def\@tempa{justified}% + \ifx\mp@align\@tempa \global\let\mp@align\relax \else \xwm@err{Inadmissible value '#1' for minipage's align} @@ -366,7 +349,6 @@ $Id: xwatermark.sty,v 1.3 2009/10/27 09:00:00 Ahmed Musa Exp $ \fi \fi \fi - \endgroup } \presetkeys[XWM]{minipage}{align,width,textcolor,text,framesep, framerule,framecolor}{}% @@ -383,17 +365,14 @@ $Id: xwatermark.sty,v 1.3 2009/10/27 09:00:00 Ahmed Musa Exp $ \end{boxedminipage}\relax \removelastskip \endgroup -}% -\define@cmdkey[XWM]{colorbox}[cb@]{width}[\textwidth]{} -\define@cmdkey[XWM]{colorbox}[cb@]{textcolor}[black]{} -\define@cmdkey[XWM]{colorbox}[cb@]{fillcolor}[yellow!55]{} -\define@cmdkey[XWM]{colorbox}[cb@]{framecolor}[white]{} -\define@cmdkey[XWM]{colorbox}[cb@]{text}[No text passed.]{} -\define@cmdkey[XWM]{colorbox}[cb@]{framesep}[3\p@]{} -\define@cmdkey[XWM]{colorbox}[cb@]{framerule}[0.4\p@]{} -\define@choicekey*+[XWM]{colorbox}{align}[\cb@val\cb@nr]% +} +\krsetup{keyfamily=colorbox,macroprefix=cb@} +\define@keylist{2,width,\textwidth,;2,textcolor,black,; + 2,fillcolor,yellow!55,;2,framecolor,white,; + 2,text,No text passed.,;2,framesep,3\p@,;2,framerule,0.4\p@,} +\define@choicekey*+[XWM]{colorbox}{align}[\val\nr]% {center,right,left,justified}[center]{% - \protected@edef\cb@align{\cb@val} + \protected@edef\cb@align{\val} }{% \xwm@err{Inadmissible value '#1' for colorbox's align} } @@ -414,7 +393,7 @@ $Id: xwatermark.sty,v 1.3 2009/10/27 09:00:00 Ahmed Musa Exp $ \newcommand\ywcolorbox[1]{% \setkeys[XWM]{colorbox}{#1}% \color{\cb@framecolor}% - \begin{center} + \begin{center}% \makebox[\z@][c]{% \colorbox{\cb@fillcolor}{\relax \xwminipage{framesep=\cb@framesep,framerule=\cb@framerule, @@ -423,26 +402,25 @@ $Id: xwatermark.sty,v 1.3 2009/10/27 09:00:00 Ahmed Musa Exp $ }\relax }% }% - \end{center} + \end{center}% \removelastskip\normalcolor }% \new\def\xwm@insertpic{\begingroup \protected@edef\@tempa{\endgroup% - \ifpdf + \iftoggle{pdf}{% \noexpand\IfFileExists{\xwm@picfile.\xwm@picfilex}{% \noexpand\includegraphics[viewport=\xwm@picbb,scale=\xwm@picscale]% {\xwm@picfile.\xwm@picfilex}% }{\xwm@err{No file \xwm@picfile.\xwm@picfilex\space or wrong path}}% - \else + }{% \noexpand\IfFileExists{\xwm@picfile.\xwm@picfilex}{% \noexpand\includegraphics[bb=\xwm@picbb,scale=\xwm@picscale]% {\xwm@picfile.\xwm@picfilex}% }{\xwm@err{No file \xwm@picfile.\xwm@picfilex\space or wrong path}}% - \fi% + }% }\@tempa% } -% Patch for xkeyval.sty: -\renewrobustcmd\XKV@disable@keys[1]{% +\newrobustcmd\xwm@dis@ble@keys[1]{% \XKV@checksanitizeb{#1}\XKV@tempa \XKV@for@o\XKV@tempa\XKV@tempa{% \XKV@ifundefined{\XKV@header\XKV@tempa}{% @@ -463,5 +441,6 @@ $Id: xwatermark.sty,v 1.3 2009/10/27 09:00:00 Ahmed Musa Exp $ }% }% } +\newcommand\xwm@disable@keys{\XKV@testoptb\xwm@dis@ble@keys} \endinput |