diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex/etoolbox')
-rw-r--r-- | Master/texmf-dist/tex/latex/etoolbox/etoolbox.sty | 240 |
1 files changed, 157 insertions, 83 deletions
diff --git a/Master/texmf-dist/tex/latex/etoolbox/etoolbox.sty b/Master/texmf-dist/tex/latex/etoolbox/etoolbox.sty index 8cce5f241be..155446f55e3 100644 --- a/Master/texmf-dist/tex/latex/etoolbox/etoolbox.sty +++ b/Master/texmf-dist/tex/latex/etoolbox/etoolbox.sty @@ -1,26 +1,29 @@ -% $Id: etoolbox.sty,v 1.4 2008/01/24 22:25:08 lehman stable $ +% $Id: etoolbox.sty,v 1.5 2008/04/26 18:23:00 lehman stable $ -% Copyright (c) 2007--2008 Philipp Lehman, author-maintained. +% Copyright (c) 2007-2008 Philipp Lehman. % % Permission is granted to copy, distribute and/or modify this % software under the terms of the LaTeX Project Public License % (LPPL), version 1.3. % -% This software is provided `as is', without warranty of any kind, +% The LPPL maintenance status of this software is +% 'author-maintained'. +% +% This software is provided 'as 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. +% implied warranties of merchantability and fitness for a +% particular purpose. \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{etoolbox}[2008/01/24 v1.4 eTeX tools for LaTeX] +\ProvidesPackage{etoolbox}[2008/04/26 v1.5 e-TeX tools for LaTeX] \begingroup \@ifundefined{eTeXversion} {\PackageError{etoolbox} {Not running under e-TeX} {This package requires e-TeX. Try compiling the document - with\MessageBreak `elatex' instead of `latex'. When using - pdfTeX, try `pdfelatex'\MessageBreak instead of `pdflatex'. + with\MessageBreak 'elatex' instead of 'latex'. When using + pdfTeX, try 'pdfelatex'\MessageBreak instead of 'pdflatex'. This is a fatal error. I'm aborting now.}% \aftergroup\endinput} {} @@ -99,7 +102,6 @@ % {<cstoken>} -\@onlypreamble\robustify \newrobustcmd*{\robustify}[1]{% \ifundef#1% {\@latex@error{\string#1 undefined}\@ehc} @@ -120,6 +122,7 @@ \noexpand\etb@resrvda\meaning#1&}}% \etb@resrvda \etb@scantoks\endgroup\etb@resrvda}} +\@onlypreamble\robustify % {<cstoken>}{<true>}{<false>} @@ -211,21 +214,35 @@ {\@secondoftwo} {\ifcsundef{#2} {\@secondoftwo} - {\expandafter\expandafter - \expandafter\ifx - \expandafter\expandafter - \csname#1\endcsname + {\expandafter\ifx + \csname#1\expandafter\endcsname \csname#2\endcsname \expandafter\@firstoftwo \else \expandafter\@secondoftwo \fi}}} -% {<string>}{<true>}{<false>} +% {<cstoken>}{<string>}{<true>}{<false>} -\newcommand{\ifblank}[1]{% from url.sty - \etb@ifblank@i#1&&\@secondoftwo\@firstoftwo:} -\long\def\etb@ifblank@i#1#2#4#5:{#4} +\newrobustcmd{\ifdefstring}[2]{% + \ifundef#1% + {\@secondoftwo} + {\begingroup + \edef\etb@tempa{\expandafter\strip@prefix\meaning#1}% + \edef\etb@tempb{\detokenize{#2}}% + \ifx\etb@tempa\etb@tempb + \aftergroup\@firstoftwo + \else + \aftergroup\@secondoftwo + \fi + \endgroup}} + +% {<csname>}{<string>}{<true>}{<false>} + +\newrobustcmd{\ifcsstring}[2]{% + \ifcsundef{#1}% + {\@secondoftwo} + {\expandafter\ifdefstring\csname#1\endcsname{#2}}} % {<string1>}{<string2>}{<true>}{<false>} @@ -240,12 +257,20 @@ \fi \endgroup} +% {<string>}{<true>}{<false>} + +\newcommand{\ifblank}[1]{% from url.sty + \etb@ifblank@i#1&&\@secondoftwo\@firstoftwo:} +\long\def\etb@ifblank@i#1#2#4#5:{#4} + % {<name>} \newrobustcmd*{\newbool}[1]{% \expandafter\@ifdefinable\csname if#1\endcsname{% \expandafter\newif\csname if#1\endcsname}} +% {<name>} + \newrobustcmd*{\providebool}[1]{% \ifcsundef{if#1} {\expandafter\newif\csname if#1\endcsname} @@ -255,25 +280,30 @@ \else \ifx\@tempa\etb@istrue \else - \@latex@error{`\@backslashchar if#1' defined + \@latex@error{'\@backslashchar if#1' defined but not a switch}\@eha \fi \fi \endgroup}} -\edef\etb@istrue{\meaning\iftrue} -\edef\etb@isfalse{\meaning\iffalse} +% {<name>} \newrobustcmd*{\booltrue}[1]{% \ifcsundef{if#1} - {\etb@err@nobool{#1}} + {\etb@noglobal\etb@err@nobool{#1}} {\csname#1true\endcsname}} +% {<name>} + \newrobustcmd*{\boolfalse}[1]{% \ifcsundef{if#1} - {\etb@err@nobool{#1}} + {\etb@noglobal\etb@err@nobool{#1}} {\csname#1false\endcsname}} +\edef\etb@istrue{\meaning\iftrue} +\edef\etb@isfalse{\meaning\iffalse} +\protected\def\etb@noglobal{\let\relax\relax} + % {<name>}{<true}{<false>} \newcommand*{\ifbool}[1]{% @@ -297,30 +327,35 @@ \fi}} \protected\def\etb@err@nobool#1{% - \let\relax\relax - \@latex@error{Switch `\@backslashchar if#1' undefined}\@eha} + \@latex@error{Switch '\@backslashchar if#1' undefined}\@eha} % {<name>} \newrobustcmd*{\newtoggle}[1]{% \ifcsdef{etb@tgl@#1} - {\@latex@error{Toggle `#1' already defined}\@eha} + {\@latex@error{Toggle '#1' already defined}\@eha} {\cslet{etb@tgl@#1}\@secondoftwo}} +% {<name>} + \newrobustcmd*{\providetoggle}[1]{% \ifcsdef{etb@tgl@#1} {} {\cslet{etb@tgl@#1}\@secondoftwo}} +% {<name>} + \newrobustcmd*{\toggletrue}[1]{% \ifcsdef{etb@tgl@#1} {\cslet{etb@tgl@#1}\@firstoftwo} - {\etb@err@notoggle{#1}}} + {\etb@noglobal\etb@err@notoggle{#1}}} + +% {<name>} \newrobustcmd*{\togglefalse}[1]{% \ifcsdef{etb@tgl@#1} {\cslet{etb@tgl@#1}\@secondoftwo} - {\etb@err@notoggle{#1}}} + {\etb@noglobal\etb@err@notoggle{#1}}} % {<name>}{<true}{<false>} @@ -337,16 +372,15 @@ {\etb@err@notoggle{#1}\@gobbletwo}} \protected\def\etb@err@notoggle#1{% - \let\relax\relax - \@latex@error{Toggle `#1' undefined}\@eha} + \@latex@error{Toggle '#1' undefined}\@eha} % {<cstoken>}{<search>}{<true}{<false>} -\@onlypreamble\ifpatchable \newrobustcmd{\ifpatchable}{% \begingroup \@makeother\#% \etb@ifpatchable} +\@onlypreamble\ifpatchable \def\etb@ifpatchable#1#2{% \endgroup @@ -367,11 +401,11 @@ % [<prefix>]{<cstoken>}{<search>}{<replace>}{<success>}{<failure>} -\@onlypreamble\patchcmd \newrobustcmd*{\patchcmd}{% \begingroup \@makeother\#% \etb@patchcmd} +\@onlypreamble\patchcmd \newcommand{\etb@patchcmd}[4][########1]{% \etb@ifpatchable{#2}{#3} @@ -397,17 +431,17 @@ % {<cstoken>}{<code>} -\@onlypreamble\apptocmd \newrobustcmd*{\apptocmd}{% \begingroup \@makeother\#% \etb@hooktocmd\etb@apptocmd} +\@onlypreamble\apptocmd -\@onlypreamble\pretocmd \newrobustcmd*{\pretocmd}{% \begingroup \@makeother\#% \etb@hooktocmd\etb@pretocmd} +\@onlypreamble\pretocmd \long\def\etb@hooktocmd#1#2#3{% \endgroup @@ -494,19 +528,11 @@ % {<cstoken>} -\newcommand*{\undef}{} +\newrobustcmd*{\undef}[1]{\let#1\etb@undefined} % {<csname>} -\newcommand*{\csundef}{} - -\begingroup -\catcode`\%=11 - -\protected\gdef\undef#1{\let#1\etb@un%de%fi%ned} -\protected\gdef\csundef#1{\cslet{#1}\etb@un%de%fi%ned} - -\endgroup +\newrobustcmd*{\csundef}[1]{\cslet{#1}\etb@undefined} % {<cstoken>}{<code>} @@ -634,54 +660,102 @@ \newrobustcmd*{\csmugdef}[1]{% \expandafter\mugdef\csname#1\endcsname} -% {<numeral>} +% {<counter>}{<value>} -\newcommand*{\rmntonum}{} +\newrobustcmd*{\defcounter}[2]{% + \ifcsundef{c@#1}% + {\etb@noglobal\@nocounterr{#1}}% + {\csname c@#1\endcsname\numexpr#2\relax\relax}} -\begingroup -\catcode`\%=12 -\catcode`\&=14 +% {<length>}{<value>} + +\newrobustcmd*{\deflength}[2]{% + \ifundef#1% + {\etb@noglobal\etb@err@nolen{#1}}% + {#1\dimexpr#2\relax\relax}} + +\protected\def\etb@err@nolen#1{% + \@latex@error{No length '\string#1' defined}\@eha} -\gdef\rmntonum#1{\number\numexpr\etb@rti@i#10%} +% {<numeral>} -\gdef\etb@rti@i#1#2{& - \expandafter\if\expandafter%\detokenize{#2}& - +\etb@rti@ii{#1}\expandafter\relax +\newcommand{\rmntonum}[1]{% + \ifblank{#1} + {} + {\expandafter\expandafter + \expandafter\etb@rti@end + \expandafter\number + \expandafter\numexpr + \expandafter\etb@rti@prs\detokenize{#1}|\relax}} + +\def\etb@rti@prs#1#2{% + \ifx|#1% + \expandafter\@firstoftwo \else - \ifnum\etb@rti@ii{#1}<\etb@rti@ii{#2} & - +\etb@rti@ii{#2}-\etb@rti@ii{#1}& - \expandafter\expandafter\expandafter\etb@rti@i + \expandafter\@secondoftwo + \fi + {#1#2} + {\ifx|#2% + \expandafter\@firstoftwo + \else + \expandafter\@secondoftwo + \fi + {\etb@rti@chk#1+\etb@rti@num#1#2} + {\etb@rti@chk#1\etb@rti@chk#2% + \ifnum\etb@rti@num#1<\etb@rti@num#2 % + \expandafter\@firstoftwo \else - +\etb@rti@ii{#1}& - \expandafter\expandafter\expandafter\etb@rti@i - \expandafter\expandafter\expandafter#2& + \expandafter\@secondoftwo \fi + {+\etb@rti@num#2-\etb@rti@num#1\etb@rti@prs} + {+\etb@rti@num#1\etb@rti@prs#2}}}} + +\def\etb@rti@chk#1{% + \ifcsname etb@rmn@#1\endcsname + \else + \expandafter\etb@rti@brk \fi} -\endgroup +\def\etb@rti@brk#1|{+\z@|-1} +\def\etb@rti@end#1|#2\relax{\ifblank{#2}{#1}{#2}} +\def\etb@rti@num#1{\csname etb@rmn@#1\endcsname} + +\chardef\etb@rmn@i=1 +\chardef\etb@rmn@I=1 +\chardef\etb@rmn@v=5 +\chardef\etb@rmn@V=5 +\chardef\etb@rmn@x=10 +\chardef\etb@rmn@X=10 +\chardef\etb@rmn@l=50 +\chardef\etb@rmn@L=50 +\chardef\etb@rmn@c=100 +\chardef\etb@rmn@C=100 +\mathchardef\etb@rmn@d=500 +\mathchardef\etb@rmn@D=500 +\mathchardef\etb@rmn@m=1000 +\mathchardef\etb@rmn@M=1000 + +% {<numeral>}{<true>}{<false>} + +\newcommand{\ifrmnum}[1]{% + \ifblank{#1} + {\@secondoftwo} + {\expandafter\etb@ifr@prs\detokenize{#1}\relax}} -\def\etb@rti@ii#1{% - \ifcsname etb@rmn@\detokenize{#1}\endcsname - \csname etb@rmn@\detokenize{#1}\expandafter\endcsname +\def\etb@ifr@prs#1{% + \ifx\relax#1% + \expandafter\@firstoftwo \else - \expandafter\z@ + \ifcsname etb@rmn@#1\endcsname + \expandafter\expandafter + \expandafter\etb@ifr@prs + \else + \expandafter\expandafter + \expandafter\etb@ifr@brk + \fi \fi} -\def\etb@rmn@i{1} -\def\etb@rmn@v{5} -\def\etb@rmn@x{10} -\def\etb@rmn@l{50} -\def\etb@rmn@c{100} -\def\etb@rmn@d{500} -\def\etb@rmn@m{1000} - -\def\etb@rmn@I{1} -\def\etb@rmn@V{5} -\def\etb@rmn@X{10} -\def\etb@rmn@L{50} -\def\etb@rmn@C{100} -\def\etb@rmn@D{500} -\def\etb@rmn@M{1000} +\def\etb@ifr@brk#1\relax{\@secondoftwo} % {<command>}{<separator>} @@ -775,11 +849,11 @@ % {<code>} -\newcommand*{\AtEndPreamble}{\gappto\@endpreamblehook} +\newrobustcmd*{\AtEndPreamble}{\gappto\@endpreamblehook} \@onlypreamble\AtEndPreamble \newcommand*{\@endpreamblehook}{} -\patchcmd{\document} +\patchcmd\document {\endgroup} {\endgroup \let\AtEndPreamble\@firstofone @@ -787,7 +861,7 @@ \undef\@endpreamblehook} {} {\PackageInfo{etoolbox}{% - Patching \string\document\space failed.\MessageBreak + Patching \string\document\space not possible.\MessageBreak Will try to fork \string\document\@gobble}% \let\etb@document\document \def\document{% @@ -800,7 +874,7 @@ % {<code>} -\newcommand*{\AfterEndDocument}{\gappto\@afterdocumenthook} +\newrobustcmd*{\AfterEndDocument}{\gappto\@afterdocumenthook} \newcommand*{\@afterdocumenthook}{} \patchcmd\enddocument @@ -810,7 +884,7 @@ \deadcycles} {} {\PackageInfo{etoolbox}{% - Patching \string\enddocument\space failed.\MessageBreak + Patching \string\enddocument\space not possible.\MessageBreak Will try to fork \string\@@end\@gobble}% \let\etb@@end\@@end \def\@@end{% |