diff options
Diffstat (limited to 'Master/texmf-dist/source/latex/oberdiek/ltxcmds.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/oberdiek/ltxcmds.dtx | 436 |
1 files changed, 399 insertions, 37 deletions
diff --git a/Master/texmf-dist/source/latex/oberdiek/ltxcmds.dtx b/Master/texmf-dist/source/latex/oberdiek/ltxcmds.dtx index 4da0aa4a7db..02d1c671384 100644 --- a/Master/texmf-dist/source/latex/oberdiek/ltxcmds.dtx +++ b/Master/texmf-dist/source/latex/oberdiek/ltxcmds.dtx @@ -25,7 +25,7 @@ % ltxcmds.sty, ltxcmds.pdf, ltxcmds.ins, ltxcmds.drv, % ltxcmds-test1.tex, ltxcmds-test-gobble.tex, % ltxcmds-test-ifempty.tex, ltxcmds-test-zapspace.tex, -% ltxcmds-test-ifboxempty.tex. +% ltxcmds-test-ifboxempty.tex, ltxcmds-test-nextchar.tex. % % Distribution: % CTAN:macros/latex/contrib/oberdiek/ltxcmds.dtx @@ -65,6 +65,7 @@ % TDS:doc/latex/oberdiek/test/ltxcmds-test-ifempty.tex % TDS:doc/latex/oberdiek/test/ltxcmds-test-zapspace.tex % TDS:doc/latex/oberdiek/test/ltxcmds-test-ifboxempty.tex +% TDS:doc/latex/oberdiek/test/ltxcmds-test-nextchar.tex % TDS:source/latex/oberdiek/ltxcmds.dtx % %<*ignore> @@ -82,7 +83,7 @@ \input docstrip.tex \Msg{************************************************************************} \Msg{* Installation} -\Msg{* Package: ltxcmds 2011/03/16 v1.18 LaTeX kernel commands for general use (HO)} +\Msg{* Package: ltxcmds 2011/04/14 v1.19 LaTeX kernel commands for general use (HO)} \Msg{************************************************************************} \keepsilent @@ -118,7 +119,7 @@ and the derived files ltxcmds.sty, ltxcmds.pdf, ltxcmds.ins, ltxcmds.drv, ltxcmds-test1.tex, ltxcmds-test-gobble.tex, ltxcmds-test-ifempty.tex, ltxcmds-test-zapspace.tex, - ltxcmds-test-ifboxempty.tex. + ltxcmds-test-ifboxempty.tex, ltxcmds-test-nextchar.tex. \endpreamble \let\MetaPrefix\DoubleperCent @@ -134,6 +135,7 @@ and the derived files \file{ltxcmds-test-ifempty.tex}{\from{ltxcmds.dtx}{test-ifempty}}% \file{ltxcmds-test-zapspace.tex}{\from{ltxcmds.dtx}{test-zapspace}}% \file{ltxcmds-test-ifboxempty.tex}{\from{ltxcmds.dtx}{test-ifboxempty}}% + \file{ltxcmds-test-nextchar.tex}{\from{ltxcmds.dtx}{test-nextchar}}% } \catcode32=13\relax% active space @@ -160,7 +162,7 @@ and the derived files %<*driver> \NeedsTeXFormat{LaTeX2e} \ProvidesFile{ltxcmds.drv}% - [2011/03/16 v1.18 LaTeX kernel commands for general use (HO)]% + [2011/04/14 v1.19 LaTeX kernel commands for general use (HO)]% \documentclass{ltxdoc} \usepackage{holtxdoc}[2011/02/04] \usepackage{zref-savepos} @@ -172,7 +174,7 @@ and the derived files %</driver> % \fi % -% \CheckSum{2029} +% \CheckSum{2312} % % \CharacterTable % {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z @@ -193,7 +195,7 @@ and the derived files % \GetFileInfo{ltxcmds.drv} % % \title{The \xpackage{ltxcmds} package} -% \date{2011/03/16 v1.18} +% \date{2011/04/14 v1.19} % \author{Heiko Oberdiek\\\xemail{heiko.oberdiek at googlemail.com}} % % \maketitle @@ -250,6 +252,23 @@ and the derived files % and a space is not gobbled afterwards. Macro \cs{ltx@minusone} % is available since version 2010/12/12 v1.15. % +% \subsection{Scratch registers} +% +% Following the conventions of \hologo{plainTeX} and \hologo{LaTeX} +% the first ten registers are free to use. Even numbered registers +% are for local, odd numbered for global use. +% +% \begin{declcs}{ltx@(Loc,Glob)(Toks,Dimen,Skip)(A,B,C,D,E)} +% \end{declcs} +% The name consists of the prefix \cs{ltx@}, then +% \texttt{Loc} or \texttt{Glob} for local or global usage follows. +% The register type is given by \texttt{Toks} for token register, +% \texttt{Dimen} for dimen register and \texttt{Skip} for skip +% register. As last part the registers are numbered from \texttt{A} +% to \texttt{E}. Example: \cs{ltx@LocToksA}. +% +% Since 2011/04/14 v1.19. +% % \subsection{Argument killers} % % \begin{declcs}{ltx@gobble} \M{1} \TO\\ @@ -442,7 +461,7 @@ and the derived files % % Note that the file name used in \cs{ProvidesFile} and % \cs{ltx@iffileloaded} must match. For example, if \TeX's -% default extension \xext{.tex} was given in the first command, +% default extension \xext{tex} was given in the first command, % then it must also specified in the latter command and vice versa. % % \subsubsection{Version date check} @@ -477,12 +496,32 @@ and the derived files % it will be initialized as empty macro before. Due to a bug \meta{addition} % must not contain \cs{par} before version 2010/10/25 v1.9. % -% \subsection{Macro \cs{ltx@ifnextchar}} +% \subsection{Next character detection} % % \begin{declcs}{ltx@ifnextchar} \M{char} \M{yes} \M{no} % \end{declcs} % If next character is \meta{char} then \meta{yes} is called, % otherwise \meta{no}. The character is not removed. +% Spaces are silently removed when looking for \meta{char} +% as \hologo{LaTeX}'s version \cs{kernel@ifnextchar} does. +% But there are also small differences: +% \begin{itemize} +% \item The space can be used as \meta{char}. In this case +% optional spaces before \meta{char} are not supported of course. +% \item If the optional space is a command that is a character +% (defined by \cs{let} or \cs{futurelet}), then +% \cs{kernel@ifnextchar} breaks with an \hologo{TeX} error. +% \cs{ltx@ifnextchar} silently removes this token as +% optional space. +% \end{itemize} +% Since 2010/03/01 v1.3. +% +% \begin{declcs}{ltx@ifnextchar@nospace} \M{char} \M{yes} \M{no} +% \end{declcs} +% Macro \cs{ltx@ifnextchar@nospace} behaves like +% macro \cs{ltx@ifnextchar} with the exception that +% optional spaces are not supported before \meta{char}. +% Since 2011/04/14 v1.19. % % \subsection{\cs{ltx@leavevmode}, \cs{ltx@mbox}} % @@ -647,7 +686,7 @@ and the derived files \fi \expandafter\x\csname ver@ltxcmds.sty\endcsname \ProvidesPackage{ltxcmds}% - [2011/03/16 v1.18 LaTeX kernel commands for general use (HO)]% + [2011/04/14 v1.19 LaTeX kernel commands for general use (HO)]% % \end{macrocode} % % \begin{macrocode} @@ -736,6 +775,165 @@ and the derived files % \end{macrocode} % \end{macro} % +% \subsection{Scratch registers} +% +% \begin{macro}{\ltx@LocToksA} +% \begin{macrocode} +\toksdef\ltx@LocToksA=0 % +% \end{macrocode} +% \end{macro} +% \begin{macro}{\ltx@LocToksB} +% \begin{macrocode} +\toksdef\ltx@LocToksB=2 % +% \end{macrocode} +% \end{macro} +% \begin{macro}{\ltx@LocToksC} +% \begin{macrocode} +\toksdef\ltx@LocToksC=4 % +% \end{macrocode} +% \end{macro} +% \begin{macro}{\ltx@LocToksD} +% \begin{macrocode} +\toksdef\ltx@LocToksD=6 % +% \end{macrocode} +% \end{macro} +% \begin{macro}{\ltx@LocToksE} +% \begin{macrocode} +\toksdef\ltx@LocToksE=8 % +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\ltx@GlobToksA} +% \begin{macrocode} +\toksdef\ltx@GlobToksA=1 % +% \end{macrocode} +% \end{macro} +% \begin{macro}{\ltx@GlobToksB} +% \begin{macrocode} +\toksdef\ltx@GlobToksB=3 % +% \end{macrocode} +% \end{macro} +% \begin{macro}{\ltx@GlobToksC} +% \begin{macrocode} +\toksdef\ltx@GlobToksC=5 % +% \end{macrocode} +% \end{macro} +% \begin{macro}{\ltx@GlobToksD} +% \begin{macrocode} +\toksdef\ltx@GlobToksD=7 % +% \end{macrocode} +% \end{macro} +% \begin{macro}{\ltx@GlobToksE} +% \begin{macrocode} +\toksdef\ltx@GlobToksE=9 % +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\ltx@LocDimenA} +% \begin{macrocode} +\dimendef\ltx@LocDimenA=0 % +% \end{macrocode} +% \end{macro} +% \begin{macro}{\ltx@LocDimenB} +% \begin{macrocode} +\dimendef\ltx@LocDimenB=2 % +% \end{macrocode} +% \end{macro} +% \begin{macro}{\ltx@LocDimenC} +% \begin{macrocode} +\dimendef\ltx@LocDimenC=4 % +% \end{macrocode} +% \end{macro} +% \begin{macro}{\ltx@LocDimenD} +% \begin{macrocode} +\dimendef\ltx@LocDimenD=6 % +% \end{macrocode} +% \end{macro} +% \begin{macro}{\ltx@LocDimenE} +% \begin{macrocode} +\dimendef\ltx@LocDimenE=8 % +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\ltx@GlobDimenA} +% \begin{macrocode} +\dimendef\ltx@GlobDimenA=1 % +% \end{macrocode} +% \end{macro} +% \begin{macro}{\ltx@GlobDimenB} +% \begin{macrocode} +\dimendef\ltx@GlobDimenB=3 % +% \end{macrocode} +% \end{macro} +% \begin{macro}{\ltx@GlobDimenC} +% \begin{macrocode} +\dimendef\ltx@GlobDimenC=5 % +% \end{macrocode} +% \end{macro} +% \begin{macro}{\ltx@GlobDimenD} +% \begin{macrocode} +\dimendef\ltx@GlobDimenD=7 % +% \end{macrocode} +% \end{macro} +% \begin{macro}{\ltx@GlobDimenE} +% \begin{macrocode} +\dimendef\ltx@GlobDimenE=9 % +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\ltx@LocSkipA} +% \begin{macrocode} +\skipdef\ltx@LocSkipA=0 % +% \end{macrocode} +% \end{macro} +% \begin{macro}{\ltx@LocSkipB} +% \begin{macrocode} +\skipdef\ltx@LocSkipB=2 % +% \end{macrocode} +% \end{macro} +% \begin{macro}{\ltx@LocSkipC} +% \begin{macrocode} +\skipdef\ltx@LocSkipC=4 % +% \end{macrocode} +% \end{macro} +% \begin{macro}{\ltx@LocSkipD} +% \begin{macrocode} +\skipdef\ltx@LocSkipD=6 % +% \end{macrocode} +% \end{macro} +% \begin{macro}{\ltx@LocSkipE} +% \begin{macrocode} +\skipdef\ltx@LocSkipE=8 % +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\ltx@GlobSkipA} +% \begin{macrocode} +\skipdef\ltx@GlobSkipA=1 % +% \end{macrocode} +% \end{macro} +% \begin{macro}{\ltx@GlobSkipB} +% \begin{macrocode} +\skipdef\ltx@GlobSkipB=3 % +% \end{macrocode} +% \end{macro} +% \begin{macro}{\ltx@GlobSkipC} +% \begin{macrocode} +\skipdef\ltx@GlobSkipC=5 % +% \end{macrocode} +% \end{macro} +% \begin{macro}{\ltx@GlobSkipD} +% \begin{macrocode} +\skipdef\ltx@GlobSkipD=7 % +% \end{macrocode} +% \end{macro} +% \begin{macro}{\ltx@GlobSkipE} +% \begin{macrocode} +\skipdef\ltx@GlobSkipE=9 % +% \end{macrocode} +% \end{macro} +% +% % \subsection{Argument killers} % % \begin{macro}{\ltx@gobble} @@ -1339,8 +1537,8 @@ and the derived files \fi \fi \begingroup - \toks0\expandafter{#1#2}% - \xdef#1{\the\toks0}% + \ltx@LocToksA\expandafter{#1#2}% + \xdef#1{\the\ltx@LocToksA}% \endgroup } % \end{macrocode} @@ -1357,23 +1555,23 @@ and the derived files \fi \fi \begingroup - \toks0\expandafter{\LTXcmds@gtemp#2}% - \xdef\LTXcmds@gtemp{\the\toks0}% + \ltx@LocToksA\expandafter{\LTXcmds@gtemp#2}% + \xdef\LTXcmds@gtemp{\the\ltx@LocToksA}% \endgroup \let#1\LTXcmds@gtemp } % \end{macrocode} % \end{macro} % -% \subsection{Macro \cs{ltx@ifnextchar}} +% \subsection{Next character detection} % % \begin{macro}{\ltx@ifnextchar} % \begin{macrocode} \long\def\ltx@ifnextchar#1#2#3{% \begingroup \let\LTXcmds@CharToken= #1\relax - \toks\ltx@zero{#2}% - \toks\ltx@two{#3}% + \ltx@LocToksA{\endgroup#2}% + \ltx@LocToksB{\endgroup#3}% \futurelet\LTXcmds@LetToken\LTXcmds@ifnextchar } % \end{macrocode} @@ -1382,39 +1580,62 @@ and the derived files % \begin{macrocode} \def\LTXcmds@ifnextchar{% \ifx\LTXcmds@LetToken\LTXcmds@CharToken - \expandafter\endgroup\the\toks\expandafter\ltx@zero + \the\expandafter\ltx@LocToksA \else \ifx\LTXcmds@LetToken\LTXcmds@SpaceToken \expandafter\expandafter\expandafter\LTXcmds@@ifnextchar \else - \expandafter\endgroup\the\toks - \expandafter\expandafter\expandafter\ltx@two + \the\expandafter\expandafter\expandafter\ltx@LocToksB \fi \fi } % \end{macrocode} % \end{macro} % \begin{macro}{\LTXcmds@@ifnextchar} -% \begin{macrocode} -\begingroup - \def\x#1{\endgroup - \def\LTXcmds@@ifnextchar#1{% - \futurelet\LTXcmds@LetToken\LTXcmds@ifnextchar - }% - }% -\x{ } +% \cs{futurelet} does not distinguish between a +% character and a command that is a character +% (defined by using \cs{let} or \cs{futurelet}). +% Therefore the space is catched by \cs{romannumeral} +% with negative character constant that gobbles one +% optional space. +% \begin{macrocode} +\def\LTXcmds@@ifnextchar{% + \expandafter\futurelet + \expandafter\LTXcmds@LetToken + \expandafter\LTXcmds@ifnextchar + \romannumeral-`\.% +} % \end{macrocode} % \end{macro} % \begin{macro}{\LTXcmds@SpaceToken} % \begin{macrocode} -\begingroup - \def\x#1{\endgroup - \let\LTXcmds@SpaceToken= #1% - }% -\x{ } +\ltx@firstofone{\let\LTXcmds@SpaceToken= } % % \end{macrocode} % \end{macro} % +% \begin{macro}{\ltx@ifnextchar@nospace} +% \begin{macrocode} +\long\def\ltx@ifnextchar@nospace#1#2#3{% + \begingroup + \let\LTXcmds@CharToken= #1\relax + \ltx@LocToksA{\endgroup#2}% + \ltx@LocToksB{\endgroup#3}% + \futurelet\LTXcmds@LetToken\LTXcmds@ifnextchar@nospace +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\LTXcmds@ifnextchar@nospace} +% \begin{macrocode} +\def\LTXcmds@ifnextchar@nospace{% + \the + \ifx\LTXcmds@LetToken\LTXcmds@CharToken + \expandafter\ltx@LocToksA + \else + \expandafter\ltx@LocToksB + \fi +} +% \end{macrocode} +% \end{macro} % \subsection{\cs{ltx@leavevmode}, \cs{ltx@mbox}} % % \begin{macro}{\ltx@leavevmode} @@ -1828,7 +2049,7 @@ $ \next \expandafter\ifx\csname RequirePackage\endcsname\relax \input ltxcmds.sty\relax \else - \RequirePackage{ltxcmds}[2011/03/16]% + \RequirePackage{ltxcmds}[2011/04/14]% \fi \catcode`\@=11 % \def\msg#{\immediate\write16}% @@ -2015,7 +2236,7 @@ X=% \expandafter\ifx\csname RequirePackage\endcsname\relax \input ltxcmds.sty\relax \else - \RequirePackage{ltxcmds}[2011/03/16]% + \RequirePackage{ltxcmds}[2011/04/14]% \fi \def\msg#{\immediate\write16} \def\TestY{\Y} @@ -2135,7 +2356,7 @@ X=% \expandafter\ifx\csname RequirePackage\endcsname\relax \input ltxcmds.sty\relax \else - \RequirePackage{ltxcmds}[2011/03/16]% + \RequirePackage{ltxcmds}[2011/04/14]% \fi \def\msg#{\immediate\write16} \def\space{ } @@ -2209,7 +2430,7 @@ X=% \expandafter\ifx\csname RequirePackage\endcsname\relax \input ltxcmds.sty\relax \else - \RequirePackage{ltxcmds}[2011/03/16]% + \RequirePackage{ltxcmds}[2011/04/14]% \fi \def\msg#{\immediate\write16} % make box 0 void @@ -2292,7 +2513,141 @@ X=% \csname @@end\endcsname\end %</test-ifboxempty> % \end{macrocode} - +% +% \subsection{Test for next character detection} +% +% \begin{macrocode} +%<*test-nextchar> +\catcode`\{=1 % +\catcode`\}=2 % +\catcode`\#=6 % +\catcode`\@=11 % +\begingroup\expandafter\expandafter\expandafter\endgroup +\expandafter\ifx\csname RequirePackage\endcsname\relax + \input ltxcmds.sty\relax + \input eolgrab.sty\relax +\else + \RequirePackage{ltxcmds}[2011/04/14]% + \RequirePackage{eolgrab}[2011/01/12]% +\fi +\def\msg#{\immediate\write16} +\begingroup + \def\x#1{% + \endgroup + \let\TestSpaceToken= #1\relax + }% +\x{ } +\def\TestSpace{ } +\begingroup + \lccode32=65 % space -> A +\lowercase{% + \endgroup + \def\TestSpaceA{ }% +} +\def\TestCatch{% + \eolgrab\@TestCatch +} +\def\@TestCatch#1{% + \begingroup + \def\x{#1}% + \ifx\x\ltx@empty + \else + \ltx@onelevel@sanitize\x + \errmessage{Unparsed stuff on line [\x]}% + \fi + \endgroup +} +\def\TestCmdM#1{% + \TestCheckType{M}% + \TestCatch +} +\def\TestCmdOM[#1]#2{% + \TestCheckType{O}% + \TestCatch +} +\def\TestCheckType#1{% + \if\TestCmdType#1\relax + \else + \errmessage{Wrong type #1, expected: \TestCmdType}% + \fi +} +\def\TestCmd#1{% + \def\TestCmdType{#1}% + \ltx@ifnextchar[\TestCmdOM\TestCmdM +} +\def\TestCmdExp#1{% + \expandafter\TestCmd\expandafter#1% +} +\outer\def\TestOuter{} +\TestCmd O[o]{m} +\TestCmd M{m} +\TestCmd O [o]{m} +\TestCmd M {m} +\def\x#1{\def\x{#1#1}}\x{ } +\TestCmdExp O\x[o]{m} +\TestCmdExp M\x{m} +\def\x#1{\def\x{#1#1#1#1}}\x{ } +\TestCmdExp O\x[o]{m} +\TestCmdExp M\x{m} +\def\x{\TestSpaceToken} +\TestCmdExp O\x[o]{m} +\TestCmdExp M\x{m} +\def\x{\TestSpaceToken\TestSpaceToken\TestSpaceToken} +\TestCmdExp O\x[o]{m} +\TestCmdExp M\x{m} +\TestCmd M\TestSpace +\TestOuter +\TestCmd M \TestSpace +\TestOuter +% +\def\TestCmd#1{% + \def\TestCmdType{#1}% + \ltx@ifnextchar@nospace[\TestCmdOM\TestCmdM +} +\TestCmd O[o]{m} +\TestCmd M{m} +\TestCmd M [ +\TestOuter +\TestCmd M {m} +\TestOuter +% +\def\TestCmd#1{% + \def\TestCmdType{#1}% + \ltx@ifnextchar(\TestCmdPM\TestCmdM +} +\def\TestCmdPM(#1)#2{% + \TestCheckType{P}% + \TestCatch +} +\TestCmd P(p){m} +\TestCmd M{m} +\TestCmd P (p){m} +\TestCmd M {m} +% +\def\TestCmd#1{% + \def\TestCmdType{#1}% + \ltx@ifnextchar{ }\TestCmdSM\TestCmdM +} +\def\TestCmdSM#1#{% + \TestCheckType{S}% + \begingroup + \let\x= #1\relax + \ifx\x\TestSpaceToken + \else + \errmessage{unexpected space token: \meaning#1}% + \fi + \endgroup + \def\TestCmdType{M}% + \TestCmdM +} +\TestCmd S {m} +\TestCmd M{m} +\tracingmacros=1 +\def\x#1{\def\x{#1#1}}\x{ } +\TestCmdExp S\x{m} +\csname @@end\endcsname\end +%</test-nextchar> +% \end{macrocode} % % \section{Installation} % @@ -2360,6 +2715,7 @@ X=% % test/ltxcmds-test-ifempty.tex & doc/latex/oberdiek/test/ltxcmds-test-ifempty.tex\\ % test/ltxcmds-test-zapspace.tex & doc/latex/oberdiek/test/ltxcmds-test-zapspace.tex\\ % test/ltxcmds-test-ifboxempty.tex & doc/latex/oberdiek/test/ltxcmds-test-ifboxempty.tex\\ +% test/ltxcmds-test-nextchar.tex & doc/latex/oberdiek/test/ltxcmds-test-nextchar.tex\\ % ltxcmds.dtx & source/latex/oberdiek/ltxcmds.dtx\\ % \end{tabular}^^A % }^^A @@ -2677,6 +3033,12 @@ X=% % \item % \cs{ltx@ifclasslater} fixed. % \end{Version} +% \begin{Version}{2011/04/14 v1.19} +% \item +% \cs{ltx@ifnextchar}: detection of optional spaces modified. +% \item +% \cs{ltx(Loc,Glob)(Toks,Dimen,Skip)(A,B,C,D,E)} added. +% \end{Version} % \end{History} % % \PrintIndex |