diff options
author | Karl Berry <karl@freefriends.org> | 2011-12-21 23:43:42 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2011-12-21 23:43:42 +0000 |
commit | 96d75501059aaba75f35e407391703be9cf3b21f (patch) | |
tree | 5bc7357d078ee23aab948474cc9edfc1fd043589 /Master | |
parent | e9250f00ffb6069748594707c033a97104a3c7b9 (diff) |
ltxtools 0.0.1a (19dec11)
git-svn-id: svn://tug.org/texlive/trunk@24897 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rw-r--r-- | Master/texmf-dist/doc/latex/ltxtools/README | 34 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/ltxtools/ltxtools-base.sty | 5786 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/ltxtools/ltxtools-doc.sty | 1318 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/ltxtools/ltxtools-environ.sty | 137 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/ltxtools/ltxtools-incluput.sty | 193 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/ltxtools/ltxtools-index.sty | 597 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/ltxtools/ltxtools-review.sty | 1043 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/ltxtools/ltxtools-trace.sty | 282 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/ltxtools/ltxtools.sty | 5122 |
9 files changed, 9404 insertions, 5108 deletions
diff --git a/Master/texmf-dist/doc/latex/ltxtools/README b/Master/texmf-dist/doc/latex/ltxtools/README index 59e42388eab..2b4eb1153a8 100644 --- a/Master/texmf-dist/doc/latex/ltxtools/README +++ b/Master/texmf-dist/doc/latex/ltxtools/README @@ -2,16 +2,35 @@ This is the README file for the ltxtools package. VERSION -Version 0.0.1, September 2011 +Version 0.0.1a, December 2011 + +AUTHOR + +(c) Ahmed Musa (amusa22@gmail.com) SUMMARY -The ltxtools package provides several LaTeX API tools. +The ltxtools bundle provides several LaTeX API and document +formatting tools. The packages currently included in the bundle are: + +1. ltxtools - The interface for loading other packages + in the bundle. +2. ltxtools-base - The core of general API tools. +3. ltxtools-trace - General code tracing utilities. +4. ltxtools-environ - Environments whose bodies are collected + for processing. A version of the 'environ' + package that requires no auxiliary commands + for the environments being defined. +5. ltxtools-doc - Document formatting commands and tools. +6. ltxtools-review - Document review and editing tools. +7. ltxtools-index - Document indexing utilities. + +Each package can be loaded independently. LICENSE -Copyright (c) 2011 Ahmed Musa. +Copyright (c) 2011 Ahmed Musa This software is author-maintained. Permission is granted to copy, distribute and/or modify this software under the terms of the @@ -21,12 +40,3 @@ expressed or implied, including, but not limited to, the implied warranties of merchantability and fitness for any particular purpose. -AUTHOR - -Ahmed Musa (amusa22@gmail.com) - - -RELEASE NOTES - -The user guide is not yet complete, but some of my packages -require the tools in ltxtools.
\ No newline at end of file diff --git a/Master/texmf-dist/tex/latex/ltxtools/ltxtools-base.sty b/Master/texmf-dist/tex/latex/ltxtools/ltxtools-base.sty new file mode 100644 index 00000000000..185c3e686e6 --- /dev/null +++ b/Master/texmf-dist/tex/latex/ltxtools/ltxtools-base.sty @@ -0,0 +1,5786 @@ +%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++% +% % +% This is file 'ltxtools-base.sty', version 0.0.1, December 2011. % +% % +% This package and accompanying files 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) 2011 Ahmed Musa (amusa22@gmail.com). % +% % +%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++% + +\@ifpackageloaded{catoptions}{% + \@ifpackagelater{catoptions}{2011/12/10}{}{% + \@latex@error{Loaded version of catoptions package is + not current}\@ehc + }% +}{% + \RequirePackage{catoptions}[2011/12/10]% +} +\UseNormalCatcodes +\StyleFilePurpose{The base/core of ltxtools packages (AM)} +\StyleFileRCSInfo +$Id: ltxtools-base.sty,v 0.0.1 2011/12/12 09:00:00 Ahmed Musa Exp $ +\ProvidesPackage{ltxtools-base}[\StyleFileInfo] +\NeedsTeXFormat{LaTeX2e}[2011/06/27] +\ifdefTF\LTS@err{}{% + \SetStyleFileMessages[LTS@]{info}{warn}{err}% +} +\ifdefTF\LTS@verbosewarn{}{% + \robust@def*\LTS@verbosewarn#1{\ifLTS@verbose\LTS@warn{#1}\fi}% + \robust@def*\LTS@verboseinfo#1{\ifLTS@verbose\LTS@info{#1}\fi}% +} +\catcode`\&=\thr@@ +\loadifnotloaded{ltxkeys}[2011/12/12] +\cptnewvariables{if}[LTS@]{st,pl,cl,rt,pm,lt,verbose}[false] +\cptnewvariables{dimen}[LTS@]{dima,dimb} +\def\@empty{} +\new@def\LTS@car#1#2\car@nil{#1} +\new@def\LTS@cartwo#1#2#3\car@nil{#1#2} +\new@def\LTS@cartworev#1#2#3\car@nil{#2#1} +\new@def\LTS@cdr#1#2\cdr@nil{#2} +\new@def\LTS@cdrtwo#1#2#3\cdr@nil{#3} +\new@def\LTS@carcube#1#2#3#4\car@nil{#1#2#3} +\newletcs\LTS@nil\relax +\new@def*\LTS@nnil{\LTS@nil} +\long\def\@firstofone#1{#1} +\long\def\@firstoftwo#1#2{#1} +\long\def\@secondoftwo#1#2{#2} +\long\def\@firstofthree#1#2#3{#1} +\long\def\@secondofthree#1#2#3{#2} +\long\def\@thirdofthree#1#2#3{#3} +\long\def\@gobbleone#1{} +\long\def\@gobbletwo#1#2{} +\long\def\@gobblethree#1#2#3{} +\long\def\@gobblefour#1#2#3#4{} +\letcsntocs{LTS@0of1}\@gobbleone +\letcsntocs{LTS@1of1}\@firstofone +\letcsntocs{LTS@1of2}\@firstoftwo +\letcsntocs{LTS@2of2}\@secondoftwo +\newletcs\ltsfi\fi +\newletcs\ltselse\else +\new@def\ltsafterfi#1\ltsfi{\fi#1} +\new@def\ltsaftertest@i#1\ltselse#2\ltsfi{\fi#1} +\new@def\ltsaftertest@ii#1\ltselse#2\ltsfi{\fi#2} +\new@def\ltsafterfifi@i#1\ltsfi#2\ltsfi{\fi\fi#1} +\new@def\ltsafterfifi@ii#1\ltsfi#2\ltsfi{\fi\fi#2} +\robust@def*\csnaftergroup{\aftercsname\aftergroup} +\robust@def*\csnendgroup{\aftercsname\endgroup} +\robust@def\iftokennilTF#1{% + \edef\reserved@a{\unexpanded{#1}}% + \ifx\reserved@a\@nnil + \expandafter\iofii\else\expandafter\iiofii\fi +} +\robust@def*\ifsentinelTF#1{% + \edef\reserved@a{\unexpanded{#1}}% + \ifx\reserved@a\currsentinel + \expandafter\iofii\else\expandafter\iiofii\fi +} +\robust@def*\LTS@detokenize@trimspaces#1{% + \expandafter\cpttrimspaces\expandafter{\detokenize{#1}}% +} +\newletcs\ltsdetoktrim\LTS@detokenize@trimspaces +\robust@def*\usecsrelax#1{\ifdefTF#1{#1\let#1\relax}{}} +\robust@def*\usecsnrelax#1{\ifcsndefTF{#1}{#1\letcsntocs{#1}\relax}{}} +\new@def*\realmeaning#1{% + \ifsingletokenTF{#1}{% + \ifdefTF{#1}{\expandafter\strip@prefix\meaning#1}{undefined}% + }{% + '\ltsdetoktrim{#1}' isn't one token% + }% +} +\robust@def*\sanitizecs#1{\edef#1{\realmeaning#1}} +\new@edef*\LTS@hashchar{\string#} +% Eg, \toks@\expandafter\expandafter +% \expandafter{\ltssupergobble 3ab11cd}: +\newcommand*\ltssupergobble[1]{% + \romannumeral-`\q\expandafter\@gobble\romannumeral-`\q + \expandafter\LTS@supergobble + \romannumeral\the\numexpr#1000{m\endcsname}% +} +\newcommand*\LTS@supergobble[1]{% + \csname LTS@superg@bble#1\LTS@supergobble +} +\newcommand*\LTS@superg@bblem[1]{\endcsname} + +\new@def*\newcomment{% + \begingroup + \def\comment@envir{newcomment}% + \def\do##1{\catcode`##1=12\relax}% + \dospecials + \endlinechar`\^^M\catcode`\^^M=12\relax + \LTS@commentloop +} +\new@def*\LTS@commentend{% + \ifx\@currenvir\comment@envir + \let\endnewcomment\relax + \def\next{\endgroup\end{newcomment}}% + \else + \let\next\endgroup + \fi + \next +} +\begingroup +\catcode`\^^M=12 % +\endlinechar\m@one% +\robust@gdef*\LTS@commentloop#1^^M{% + \def\comment@stuff{#1}% + \ifx\comment@stuff\endnewcomment + \let\next\LTS@commentend + \else + \ifx\comment@stuff\end@newcomment + \let\next\LTS@commentend + \else + \ifx\comment@stuff\end@comment + \def\next{\@latex@error + {Bad end for \string\newcomment}\@ehc}% + \else + \let\next\LTS@commentloop + \fi + \fi + \fi + \next +} +\endgroup +\begingroup +\catcode`\{=12 +\catcode`\}=12 +\catcode`\!=0 +\catcode`\[=1 +\catcode`\]=2 +\catcode`\\=12 +!gdef!end@newcomm@nt[\endnewcomment] +!gdef!end@newcomment[\end{newcomment}] +!gdef!end@comment[\end{comment}] +!endgroup + +% \advancenr <nr> <optional 'by'> <no> <spr> +% <nr> can be \chardef'd, \countdef'd, or a macro. +% <spr> = space or \relax if 'no' is a literal number. +% Eg, \chardef\elt=1 +% \advancenr\elt by 12 % +% This isn't meant for dimensions. +\robust@def*\advancenr#1{% + \ifcounterTF{#1}\advance\LTS@advancenr@a#1% +} +\robust@def*\LTS@advancenr@a#1#2{% + \begingroup + \toks@{}\@tempcnta\z@pt + \def\LTS@advancenr@b##1{% + \ifcondTF\if##1y\fi{% + \LTS@advancenr@c + }{% + \LTS@err{'b##1' not a number or 'by'}\@ehc + }% + }% + \def\LTS@advancenr@c{% + \futurelet\@let@token\LTS@advancenr@d + }% + \def\LTS@advancenr@d{% + \ifcondTF\ifx\@let@token\@sptoken\fi{% + \LTS@advancenr@e + }{% + \ifcondTF\ifx\@let@token\relax\fi{% + \LTS@advancenr@e + }{% + \LTS@advancenr@f + }% + }% + }% + \def\LTS@advancenr@e{% + \ifnumcmpTF\@tempcnta=\z@pt{% + \LTS@err{No number after 'by'}\@ehc + }{% + \LTS@advancenr@g{0}% + }% + }% + \def\LTS@advancenr@f##1{% + \advance\@tempcnta\@ne + \ifinsetTF{##1}{0123456789}{% + \toks@\expandafter{\the\toks@##1}% + \LTS@advancenr@c + }{% + \LTS@advancenr@g{##1}% + }% + }% + \def\LTS@advancenr@g##1{% + \edef#1{\the\numexpr\ifdefTF#1{#1+}{}\the\toks@+##1}% + \postgroupdef#1\endgroup + }% + \ifcondTF\if#2b\fi{% + \LTS@advancenr@b + }{% + \LTS@advancenr@f{#2}% + }% +} +\ltxkeys@definekeys*[LTS]{multido}[ltsmd@]{% + counter=\nr; + start=0; + step=1; + for=1; + repeat=1/\setaliaskey{for}; +} +% Eg, +% \ltsmultido[counter=\ncolr,start=1,step=1,for=2]{% +% \csn@edef{x@\romannumeral\ncolr}{\number\ncolr}} +\robust@def*\ltsmultido{\cpt@teststopt\LTS@multido{}} +\robust@def*\LTS@multido[#1]#2#{% + \iflacus#2\dolacus + \expandafter\cptgobbletorelax + \fi + \ifboolTF{cpt@st}{% + \ltxkeys@launchkeys[LTS]{multido}{#1}% + }{% + \cptexpanded{\ltxkeys@launchkeys[LTS]{multido}{\expandcsonce{#1}}}% + }% + \ifnum\ltsmd@for=\z@pt + \expandafter\cptgobbletorelax + \fi + \expandafter\ifescapedTF\expandafter{\ltsmd@counter}{}{% + \LTS@err{\noexpand\ltsmultido counter must be escaped}\@ehc + }% + \expandafter\ifcounterTF\expandafter{\ltsmd@counter}{% + \let\ltsmd@sw\cptswtrue + \ltsmd@counter\ltsmd@start\relax + }{% + \let\ltsmd@sw\cptswfalse + \expandafter\edef\ltsmd@counter{\number\ltsmd@start}% + }% + \cptloop + #2\relax + \if\ltsmd@sw + \advance\ltsmd@counter\ltsmd@step\relax + \else + \expandafter\edef\ltsmd@counter + {\the\numexpr\ltsmd@counter+\ltsmd@step}% + \fi + \ifnum\ltsmd@counter>\ltsmd@for\relax\else + \cptrepeat + \cpt@relax +} + +\robust@def*\ltssetlength#1#2{% + \@defaultunits#1=\dimexpr#2\unitlength\relax\@nnil +} +\robust@def*\ltsmultiput(#1,#2){% + \ltssetlength\@xdim{#1}% + \ltssetlength\@ydim{#2}% + \cpt@testopt\LTS@multiput{[0,0]}% +} +\robust@def\LTS@multiput[#1,#2]#3#{\LTS@m@ltiput[#1,#2]{#3}} +\robust@def\LTS@m@ltiput[#1,#2]#3#4{% + \@killglue\noindent + \begingroup + \@multicnt#3\relax + \ltssetlength\LTS@dima{#1}% + \ltssetlength\LTS@dimb{#2}% + \cptwhilenum\@multicnt>\z@pt\do{% + \raise\@ydim\hb@xt@\z@pt{\kern\@xdim #4\hss}% + \advance\@multicnt\m@one + \advance\@xdim\LTS@dima + \advance\@ydim\LTS@dimb + }% + \endgroup + \ignorespaces +} +% Call \ltssetupstrcmp to define \ifstrcmpTF if \pdfstrcmp or +% \pdf@strcmp didn't exist: +\new@def*\ltssetupstrcmp{% + \let\ltssetupstrcmp\relax + \long\def\LTS@str@car##1##2\LTS@str@carnil{##1}% + \newcommand\LTS@ifstrcmp@a[3]{% + \expandafter\cptswapbracefirst\expandafter{% + \LTS@str@car##2\LTS@str@carnil + }{% + \expandafter##1\expandafter{\LTS@str@car##3\LTS@str@carnil}% + }% + }% + \newcommand\LTS@ifstrcmp@b[3]{% + \expandafter\cptswapbracefirst\expandafter{##1##2}% + {\expandafter\expandafter\expandafter\@gobble + \expandafter\ifstrcmpTF\expandafter{##1##3}}% + }% + \newcommand\ifstrcmpTF[4]{% + \romannumeral0% + \ifnullTF{##1}{% + \ifnullTF{##2}{ ##3}{ ##4}% + }{% + \ifnullTF{##2}{ ##4}{% + \ifbracedTF{##1}{% + \ifbracedTF{##2}{% + \LTS@ifstrcmp@a\ifstrcmpTF{##1}{##2}{% + \LTS@ifstrcmp@b\@gobble{##1}{##2}{##3}{##4}% + }{ ##4}% + }{ ##4}% + }{% + \ifbracedTF{##2}{ ##4}{% + \ifleadspaceTF{##1}{% + \ifleadspaceTF{##2}{% + \LTS@ifstrcmp@b\@gobblespace{##1}{##2}{##3}{##4}% + }{ ##4}% + }{% + \ifleadspaceTF{##2}{ ##4}{% + \LTS@ifstrcmp@a\ifxTF{##1}{##2}{% + \LTS@ifstrcmp@b\@gobble{##1}{##2}{##3}{##4}% + }{ ##4}% + }% + }% + }% + }% + }% + }% + }% +} +% \ltspushcmds<idcmd>{<cmda>,<cmdb>,...}<counter> +% \ltspopcmds<idcmd> +% Eg, \ltspushcmds\x{\y,\z}\cnta (down) +% \ltspushcmds\x{\y,\z}\cnta (down) +% \ltspopcmds\x (up) +% \ltspopcmds\x (up) +\robust@def*\ltspushcmds#1#2#3{\LTS@ppcmds\m@one#1{#2}#3} +\robust@def*\ltspopcmds#1{\LTS@ppcmds\@ne#1\relax\relax} +\newcommand*\LTS@ppcmds[4]{% + \ifcondTF\ifnum#1=1\fi{% + \cptexpanded{% + \def\noexpand\reserved@a####1####{% + ####1\gdef\noexpandcsn{\cptremovescape#2@stack}% + }% + \noexpand\reserved@a\expandcsnonce{\cptremovescape#2@stack}% + }% + }{% + \global\advance#4\@ne + \begintoksgroup + \toks1{}% + \def\LTS@tempa##1{\noexpandcsn{\cptremovescape##1@\romannumeral#4}}% + \cptfor#3\dofor{% + \cptexpanded{% + \toks@{\the\toks@\let\LTS@tempa{##1}\noexpand##1}% + \toks1{\the\toks1\let\noexpand##1\LTS@tempa{##1}% + \let\LTS@tempa{##1}\noexpand\LTS@undefined}% + }% + }% + \csn@xdef{\cptremovescape#2@stack}{% + \the\toks1\global\advance#4\m@one + \ifcsndefTF{\cptremovescape#2@stack}{% + {\expandcsnonce{\cptremovescape#2@stack}}% + }{{}}% + }% + \endtoksgroup + }% +} +\def\ltsmakeallother{% + \begintoksgroup + \@tempcnta=0 + \loop + \toks0\expandafter{\the\toks\expandafter + 0\expandafter\catcode\number\@tempcnta=12 % + }% + \advance\@tempcnta 1 + \ifnum\@tempcnta<256 + \repeat + \endtoksgroup +} +\cptnewvariables{read}[LTS@]{infile} +\cptnewvariables{write}[LTS@]{outfile} +% File transfer: +% #1: receiving filename +\new@def*\ltscopytoendcopy#1{% + \IfFileExists{#1}{% + \LTS@err{File '#1' already exists}\@ehc + }{}% + \immediate\openout\LTS@outfile=#1 % + \begingroup + \@tempcnta\z@pt + \edef\endcopy{\@backslashchar endcopy}% + \LTS@copytoend@setup\LTS@copytoend@do +} +\def\LTS@copytoend@setup{% + \def\do##1{\catcode`##1=12}% + \dospecials + \catcode`\|=12 + \obeylines% +} +\def\LTS@copytoend@removespace{% + \expandafter\futurelet\expandafter\next + \expandafter\LTS@copytoend@ifspace\string +} +\def\LTS@copytoend@ifspace{% + \ifx\next\@sptoken\expandafter\LTS@copytoend@gobblespace + \else\expandafter\LTS@copytofile\fi +} +\newcsndef*{LTS@copytoend@gobblespace} {\LTS@copytofile} +\robust@def*\LTS@copytofile#1\LTS@nil{% + \immediate\write\LTS@outfile{#1}% +} + +\begingroup +\obeylines% +% User: don't reposition left brace or put comment +% sign at end of next line: +\gdef\LTS@copytoend@do#1 + {\def\next{#1}% + \ifx\next\endcopy% + \let\next=\endgroup% + \else% + \ifnum\@tempcnta=\z@pt% + \LTS@copytoend@removespace#1\LTS@nil% + \else% + \LTS@copytofile#1\LTS@nil% + \fi% + \let\next=\LTS@copytoend@do% + \fi% + \@tempcnta\@ne% + \next% +}% +\gdef\ltstransferfiles#1#2{% + \begingroup% + \let\do\@makeother% + \dospecials% + \catcode`\|=12 % + \obeylines % + \def^^M{}% + \IfFileExists{#1}{% + \IfFileExists{#2}{% + \LTS@err{File '#2' already exists}\@ehc + }{}% + }{% + \LTS@err{File '#1' doesn't exist}\@ehc + }% + \immediate\openin\LTS@infile=#1 % + \immediate\openout\LTS@outfile=#2 % + \loop% + \read\LTS@infile to\data% + \ifeof\LTS@infile% + \@tempswafalse% + \else + \immediate\write\LTS@outfile{\data}% + \@tempswatrue% + \fi% + \if@tempswa% + \repeat% + \closein\LTS@infile% + \immediate\closeout\LTS@outfile% + \endgroup% +}% +\endgroup + +\robust@def*\preservebracedefQ#1#2{% + \def\preserve@prefix{#1}% + \def\preserve@delimiter{#2}% +} +\preservebracedefQ\relax\@nil +\robust@def*\preservebracedef#1{% + \LTS@preservebrace@setup\reserved@a#1.% +} +\robust@def*\PreserveBraceDef#1#2{% + \LTS@preservebrace@setup + \long\edef\preserve@after{\unexpanded{#1}}% + \afterassignment\preserve@after + \reserved@a#2.% +} +\robust@def*\LTS@preservebrace@setup{% + \cptexpandsecondonce{\def\reserved@a##1##2}% + \preserve@delimiter{% + \preserve@prefix\edef##1{% + \unexpanded\expandafter{\cpt@removetodot##2}% + }% + }% +} +% */' -> don't define, otherwise attempt to define: +\robust@def*\ltsmaybedef{\LTS@teststpm\LTS@maybedef} +\robust@def*\LTS@maybedef#1{% + \ifboolTF{cpt@st}\@firstoftwo{% + \ifboolTF{cpt@pm}\iofii\iiofii + }{% + \@gobble + }{% + \new@def#1% + }% +} +% Get the default optional argument of a LaTeX command: +\robust@def*\getdefaultoptarg#1{% + \begingroup + \edef\LTS@tempa##1{% + \def##1####1\cptoxdetok{\@backslashchar#1}####2&% + }% + \LTS@tempa\LTS@tempa{% + \ifblankTF{##2}{% + \endgroup\def\@optarg{}% + }{% + \xifinsetTF{\cptoxdetok{\@backslashchar#1}}{##2}{% + \edef\LTS@tempa####1{% + \def####1########1\cptoxdetok{\@backslashchar#1}&% + }% + \LTS@tempa\LTS@tempa{\endgroup + \def\@optarg{####1}% + \cptscantokens\@optarg + }% + \LTS@tempa##2&% + }{% + \endgroup\def\@optarg{}% + }% + }% + }% + \edef\LTS@tempb##1{##1\cptoxdetok{\@backslashchar#1}&}% + \LTS@tempb{\expandafter\LTS@tempa\meaning#1}% +} +% Eg, \edef\x{\ltsifcase{4}{1{X}2{Y}3{Z}}[No match]} +% #3 is not optional because of the need for expandability, +% and we don't want to use expandable \@testopt (unlike +% in \cptifstreqcase of catoptions package). If #3 is nil, then +% submit it as '[]'. +\new@def*\ltsifcase#1#2[#3]{% + \LTS@ifcase{#1}#2{#1}{#3}\cpt@nnil +} +\new@def*\LTS@ifcase#1#2#3{% + \ifstrcmpTF{#1}{#2}{% + #3\cpt@removetonnil + }{% + \LTS@ifcase{#1}% + }% +} +% Eg, \ltsifincase[,](\def\x{No match}) +% {4}{{a,1,b}{\def\x{X}}{c,2,d}{\def\x{Y}}} +\robust@def*\ltsifincase{\cpt@testopt\LTS@ifincase,} +\robust@def*\LTS@ifincase[#1]{\cpt@testpnopt{\LTS@ifinc@se{#1}}{}} +\robust@def*\LTS@ifinc@se#1(#2)#3#4{% + \begintoksgroup + \def\LTS@tempa##1##2{% + \xifinsetTF{#1#3#1}{#1##1#1}{% + \toks@{##2}\cpt@removetonnil + }{% + \LTS@tempa + }% + }% + \LTS@tempa#4{#3}{#2}\cpt@nnil + \endtoksgroup +} +\new@def\ltstrimsuffix#1#2{% + \begingroup + \ifblankTF{#2}{% + \LTS@err{Invalid blank suffix for \string\ltstrimsuffix}\@ehc + }{% + \ltsifmacroTF{#1}{}{\cpt@notcserr{#1}}% + }% + \defpass\LTS@tempa{% + \xifinsetFT{\detokenize{#2}&}{\cptoxdetok{#1}&}{}{% + \def\reserved@a####1#2{% + \edef#1{\unexpanded{####1}}% + \LTS@tempa + }% + \expandafter\reserved@a#1% + }% + }% + \postgroupdef#1\endgroup +} +\new@def\ltstrimprefix#1#2{% + \begingroup + \ifblankTF{#2}{% + \LTS@err{Invalid blank prefix for \string\ltstrimprefix}\@ehc + }{% + \ltsifmacroTF{#1}{}{\cpt@notcserr{#1}}% + }% + \defpass\LTS@tempa{% + \xifinsetFT{&\detokenize{#2}}{&\cptoxdetok{#1}}{}{% + \def\reserved@a#2####1&{% + \edef#1{\unexpanded{####1}}% + \LTS@tempa + }% + \expandafter\reserved@a#1&% + }% + }% + \postgroupdef#1\endgroup +} +% If one of the listed files is already loaded, do #2: +\robust@def*\ifoneloadedTF#1#2{% + \begingroup + \cpt@choicefdfalse + \gdef\ltspkgcls{}% + \cptdocommalist{#1}{% + \ifcsndefTF{ver@##1.sty}{% + \loopbreak\gdef\ltspkgcls{##1}% + }{}% + }% + \expandafter\endgroup + \ifcpt@choicefd\ltsafterfi#2\ltsfi +} +\robust@def*\LTS@split@at#1#2{% + \def\reserved@a##1#1##2\LTS@nil{% + \def\mpt{#1}\def\lpt{##1}\def\rpt{##2}% + }% + \expandafter\reserved@a#2\LTS@nil +} +% \ifx ... \LTS@texdie{I am exiting now}\stop\fi +\robust@def\LTS@texdie#1#2\fi{\fi\immediate\write16{#1}\batchmode#2} +\robust@def*\LTS@emergencystop{% + \immediate\write\sixt@@n{OK, I'm exiting now.}% + \interactionmode\z@pt\stop +} +% \let assignment, including subsidiaries of commands +% with optional arguments: +\robust@def*\ltsfulllet#1#2{% + \def\reserved@e##1##2{% + \LTS@stfalse\LTS@cltrue\LTS@ifonetoken{##1}{}{##2}% + }% + \reserved@e{#1}{% + \LTS@err{Multiple or blank arguments '\detokenize{#1}'}\@ehc + }% + \reserved@e{#2}{% + \LTS@err{Multiple or blank arguments '\detokenize{#2}'}\@ehc + \@gobble + }% + \let#1=#2% + \ifdefFT#2{}{% + \ifcsndefTF{\string#2}{% + \letcsntocsn{\string#1}{\string#2}% + }{% + \ifcsndefFT{\cptgobblescape#2\@space}{}{% + \letcsntocsn{\cptgobblescape#1\@space} + {\cptgobblescape#2\@space}% + \ifcsndefFT{\string#2\@space}{}{% + \letcsntocsn{\string#1\@space}{\string#2\@space}% + }% + }% + }% + }% +} +\newletcsset{% + \ifstremptyTF\ifnullTF,\ifstremptyFT\ifnullFT, + \oifstremptyTF\oifnullTF,\oifstremptyFT\oifnullFT, + \xifstremptyTF\xifnullTF,\xifstremptyFT\ifnullFT +} +\robust@def*\LTS@suffixerr#1#2#3{% + \if\detokenize{#1#2}\relax + \LTS@err{Invalid suffix '#1' to command '\string#3'}\@ehc + \fi +} +\robust@def*\LTS@blankargerr#1#2{% + \LTS@err{Invalid blank/empty argument to command + '\string#1'}\@ehc +} +% Get the last element of a csv list: +% #1: parser, #2: csv list +\robust@def*\ltsgetlastcsv#1#2{% + \cpt@ch@cklistparser{#1}% + \def\rest{}% + \def\LTS@getlastcsv##1#1##2#1{% + \ifx##2\noboundary + \edef\last{\unexpanded{##1}}% + \expandafter\cpt@removetonnil + \else + \edef\rest{\csliststack#1\rest\unexpanded{##1}}% + \expandafter\LTS@getlastcsv + \fi + ##2#1% + }% + \LTS@getlastcsv#2#1\noboundary#1\noboundary#1\cpt@nnil +} +% Get the last element of a tsv list: +\robust@def*\ltsgetlasttsv#1{% + \def\rest{}% + \LTS@getlasttsv#1\noboundary\noboundary\cpt@nnil +} +\robust@def*\LTS@getlasttsv#1#2{% + \ifx#2\noboundary + \edef\last{\unexpanded{#1}}% + \expandafter\cpt@removetonnil + \else + \edef\rest{\expandcsonce\rest\unexpanded{#1}}% + \expandafter\LTS@getlasttsv + \fi + #2% +} +\robust@def*\ltsifstringcase{\LTS@testst\LTS@ifstringcase} +\robust@def\LTS@ifstringcase#1#2:{% + \ifblankTF{#2}{% + \LTS@blankargerr\ifstringcase{second}% + }{% + \LTS@testopt{\LTS@ifstringcase@a{#1}#2}{}% + }% +} +\robust@def\LTS@ifstringcase@a#1#2[#3]{% + \ifLTS@st + \let\LTS@ifstringcase@b\ifstrcmpTF + \else + \let\LTS@ifstringcase@b\ifstreqTF + \fi + \def\LTS@ifstringcase@c##1##2##3\LTS@nil{% + \LTS@ifstringcase@b{#1}{##1}{##2}{% + \ifnullTF{##3}{#3}{% + \LTS@ifstringcase@c##3\LTS@nil + }% + }% + }% + \LTS@ifstringcase@c#2\LTS@nil +} +\robust@def\ltsifstringcases#1#2:{% + \ifblankTF{#2}{% + \LTS@blankargerr\ifstringcases{second}% + }{% + \LTS@testopt{\LTS@ifstringcases{#1}#2}{}% + }% +} +\long\def\LTS@ifstringcases#1#2[#3]{% + \begingroup + \toks@{}% + \long\def\LTS@tempa##1##2{% + \ifstrcmpTF{##1}{\LTS@nil}{% + \oifblankFT{\the\toks@}{}{\toks@{#3}}% + }{% + \ifstrcmpTF{#1}{##1}{% + \toks@\expandafter{\the\toks@##2}% + \LTS@tempa + }{% + \LTS@tempa + }% + }% + }% + \LTS@tempa#2\LTS@nil\LTS@nil + \expandafter\endgroup\the\toks@\relax +} +\robust@def\ltsifmembercases#1#2:{% + \ifblankTF{#2}{% + \LTS@blankargerr\ifmembercases{second}% + }{% + \LTS@testopt{\LTS@ifmembercases{#1}#2}{}% + }% +} +\robust@def\LTS@ifmembercases#1#2[#3]{% + \begingroup + \toks@{}% + \long\def\LTS@tempa##1##2{% + \ifstrcmpTF{##1}{\LTS@nil}{% + \oifblankFT{\the\toks@}{}{\toks@{#3}}% + }{% + \ifinsetTF{,#1,}{,##1,}{% + \toks@\expandafter{\the\toks@##2}% + \LTS@tempa + }{% + \LTS@tempa + }% + }% + }% + \LTS@tempa#2\LTS@nil\LTS@nil + \expandafter\endgroup\the\toks@\relax +} +\robust@def\ltsifnumcase{% + \let\LTS@ifnumcase@b\LTS@ifnumcase + \LTS@ifnumcase@a +} +\robust@def\LTS@ifnumcase@a#1#2:{% + \LTS@suffixerr{*}{#1}\ltsifnumcase + \ifblankTF{#2}{% + \LTS@blankargerr\ltsifnumcase{second}% + }{% + \LTS@testopt{\LTS@ifnumcase@b{#1}#2}{}% + }% +} +\robust@def\LTS@ifnumcase#1#2[#3]{% + \def\LTS@ifnumcase@c##1##2##3\LTS@nil{% + \ifnumcmpTF#1=##1{% + ##2% + }{% + \ifnullTF{##3}{% + #3% + }{% + \LTS@ifnumcase@c##3\LTS@nil + }% + }% + }% + \LTS@ifnumcase@c#2\LTS@nil +} +\robust@def\ltsifnumcases{% + \let\LTS@ifnumcase@b\LTS@ifnumcases + \LTS@ifnumcase@a +} +\robust@def\LTS@ifnumcases#1#2[#3]{% + \begingroup + \toks@{}% + \long\def\LTS@tempa##1##2{% + \ifstrcmpTF{##1}{\LTS@nil}{% + \oifblankFT{\the\toks@}{}{\toks@{#3}}% + }{% + \ifnumcmpTF#1=##1{% + \toks@\expandafter{\the\toks@##2}% + \LTS@tempa + }{% + \LTS@tempa + }% + }% + }% + \LTS@tempa#2\LTS@nil\LTS@nil + \expandafter\endgroup\the\toks@\relax +} +% Putting > or < before = +\new@def*\LTS@numcasse@setcmptor#1#2#3\@nil{% + \romannumeral + \ifstrcmpTF{#1}={% + \ifstrcmpTF{#2}<{0<=#3}{% + \ifstrcmpTF{#2}>{0>=#3}{0 #1#2#3}% + }% + }{0 #1#2#3}% +} +\new@def*\LTS@docasseelse#1\endif{#1} +\new@def*\LTS@docassecbk#1#2\endif{#1} +\new@def*\LTS@gobbletoendif#1\endif{} +\new@def*\LTS@ifnumcassecmp#1#2{% + \expandafter\expandafter\expandafter + \ltsifnumcasse@eqin\LTS@numcasse@setcmptor#2\@nil=\@nil{% + \cptbexpandnext{\ltsifnumcasse@dimwitheq{#1}} + {\LTS@numcasse@setcmptor#2\@nil}\@nil + }{% + \ifdim#1pt#2pt % + }% +} +\new@def*\ltsifnumcasse@eqin#1=#2\@nil{% + \ltsifblankTF{#2}\@secondoftwo{% + \ltsifblankTF{#1}\@secondoftwo\@firstoftwo + }% +} +\new@def*\ltsifnumcasse@dimwitheq#1#2=#3\@nil{% + \unless\ifdim#1pt\if<#2>\else<\fi#3pt +} +% Eg, +% \edef\foo{% +% \ltsifnumcasse{5}% <- number to test +% {<=1}{less than or equal to 1} +% {<=3}{less than or equal to 3} +% {=4}{equal 4} +% {=>5}{greater than or equal to 5} +% \elseif +% no match% +% \endif +% } +\new@def*\ltsifnumcasse#1#2{% + \ifstrcmpTF{#2}\elseif\LTS@docasseelse{% + \ifstrcmpTF{#2}\endif{}{% + \LTS@ifnumcassecmp{#1}{#2}% + \expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi + \LTS@docassecbk{\ltsifnumcasse@i{#1}}% + }% + }% +} +\new@def*\ltsifnumcasse@i#1#2{\ltsifnumcasse{#1}} +\let\ltsifcassethen\iffalse +\new@def*\ltsifcassenumcmp#1#2\ltsifcassethen{\LTS@ifcassenumcmp{#1}{#2}} +\new@def*\ltsifcassecmdcmp#1#2\ltsifcassethen{\ifx#1#2} +\new@def*\ltsifcassestrcmp#1#2\ltsifcassethen{% + \ifnum\pdfstrcmp{\detokenize{#1}}{\detokenize{#2}}=\z@pt +} +% Eg, +% \edef\x{% +% \ltsifcasse\ltsifcassenumcmp{3.14}% <- number to test +% {<=2}{less than or equal to 2} +% {=<3}{less than or equal to 3} +% {=>4}{greater than or equal to 4} +% {<10}{less than 10} +% \elseif +% no match +% \endif +% } +% Comparator commands are \ltsifcassenumcmp, \ltsifcassecmdcmp +% and \ltsifcassestrcmp. +% #1=comparator command, #2=testtoken1 +\new@def*\ltsifcasse#1#2{% + \ifstrcmpTF{#1}\elseif{% + \LTS@gobbletoendif + }{% + \ifstrcmpTF{#1}\endif{}{% + \ifstrcmpTF{#2}\elseif{% + \LTS@gobbletoendif + }{% + \ifstrcmpTF{#2}\endif{}{% + \ltsifcasse@i{#1}{#2}% + }% + }% + }% + }% +} +\new@def*\ltsifcasse@i#1#2#3{% + \ifstrcmpTF{#3}\elseif{% + \LTS@docasseelse + }{% + \ifstrcmpTF{#3}\endif{}{% + #1{#2}{#3}\ltsifcassethen + \expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi + {\LTS@docassecbk}{\ltsifcasse@ii{#1}{#2}}% + }% + }% +} +\new@def*\ltsifcasse@ii#1#2#3{\ltsifcasse@i{#1}{#2}} +% \dkreplicate <nr>{<callback>} +\newcommand*\dkreplicate[1]{% + \csname LTS@repl\expandafter\LTS@replicate + \romannumeral\number\number#1000q\endcsname +} +\long\def\LTS@replicate#1#2\endcsname#3{#1\endcsname{#3}#2} +\long\def\LTS@replm#1#2{#1\csname LTS@repl#2\endcsname{#1}} +\let\LTS@replq\@gobble + +\def\reserved@a#1{% + \new@def\LTS@ifleadspace##1\@nil#1##2\@nil\@nil{\ltsifblankFT{##2}}% + \new@def\ltsifleadspace##1{% + \LTS@ifleadspace\@nil##1\@nil#1\@nil\@nil + }% + \new@def\LTS@iftrailspace##1#1\@nil##2\@nil#1{\ltsifblankFT{##2}}% + \new@def\ltsiftrailspace##1{% + \LTS@iftrailspace##1\@nil#1\@nil\@nil#1% + }% +} +\reserved@a{ } +\robust@def*\ltsmakecsn#1#2{% + \ifblankTF{#1}{}{% + \edef#2{\cpttrimspaces{#1}}% + \edef#2{\expandafter\cptgobblescape#2}% + }% +} +\ltsmakecsn{\\}\@backslashchar +\robust@def*\ltsgetcsname{\LTS@testst\LTS@getcsname} +\new@def*\LTS@getcsname#1#2{% + \begingroup + \ifcsnullTF#1{% + \edef#2{\ifLTS@st{}\fi}% + }{% + \escapechar\m@one + \ifLTS@st + \edef#2{{\expandafter\string#1}}% + \else + \edef#2{\expandafter\string#1}% + \fi + }% + \postgroupdef#2\endgroup +} +\robust@def*\ltsemptify{% + \cpt@checkoptprefix{\LTS@teststcl\LTS@emptify}% +} +\def\LTS@emptify#1{% + \LTS@long@or@relax\LTS@global@or@relax + \glob@lrel@x\l@ngrel@x\def#1{}% +} +\robust@def*\ltsemptifycsset{% + \cpt@checkoptprefix{\LTS@testplcl\LTS@emptifycsset}% +} +\robust@def*\ltsemptifycsset@{% + \LTS@plfalse\LTS@clfalse\LTS@emptifycsset +} +\new@def*\LTS@emptifycsset#1{% + \LTS@global@or@relax + \def\csv@do##1{% + \ifLTS@pl + \glob@lrel@x\cptemptifycsn{##1}% + \else + \ltsensurescape{##1}% + \glob@lrel@x\def##1{}% + \fi + }% + \csv@@parse[,]{#1}% +} +\new@def\ltsswapbracetwo#1#2{{#2}{#1}} +\new@def\ltsswapbracefirst#1#2{#2{#1}} +\newletcs\ltspassarg\ltsswapbracefirst +\new@def\ltsswapbracesecond#1#2{{#2}#1} +\new@def\ltsswapfirstthird#1#2#3{#3{#2}{#1}} +\new@edef*\LTS@istrue{\string\iftrue} +\new@edef*\LTS@isfalse{\string\iffalse} + +% \ltsinputfiles[x]{a,b}[tex]{if file exists}: +\robust@def*\ltsinputfiles{\cpt@testopt\LTS@Inp@tFiles{}} +\def\LTS@Inp@tFiles[#1]#2{\cpt@testopt{\LTS@Inp@tF@les[#1]#2}{tex}} +\def\LTS@Inp@tF@les[#1]#2[#3]#4{% + \begingroup + \toks@{}% + \def\csv@do##1{% + \toks@\expandafter{\the\toks@\InputIfFileExists{#1##1.#3}% + {#4}{\@missingfileerror{#1##1}{#3}}}% + }% + \edef\LTS@tempa{\cptzapspaces{#2}}% + \csv@@loop*[,]\LTS@tempa + \expandafter\endgroup\the\toks@ +} +\robust@def\ltssafefullexpand#1{% + \begingroup + \ltssafeactivesedef\reserved@a{\endgroup#1}\reserved@a +} +\robust@def\ltssafeexpandarg#1#2{% + \begingroup + \ltssafeactivesedef\reserved@a{\endgroup\unexpanded{#1}{#2}}% + \reserved@a +} +\robust@def\ltssafeexpandsecond#1#2{% + \begingroup + \ltssafeactivesedef\reserved@a{\endgroup\unexpanded{#1}#2}% + \reserved@a +} +\robust@def\ltsexpandargs#1#2#3#4\LTS@nil{% + \cptpassexpanded{% + \ifcase#1\relax + \unexpanded{#2}{#3}% + \or + \unexpanded{#2#3}{#4}% + \or + \unexpanded{#2}{#3}{#4}% + \or + \unexpanded{#2}{#3}\unexpanded{#4}% + \else + \LTS@err{Unknown expansion type '\string#1' for + \string\ltsexpandargs}{I expected your first argument + '\string#1' to \string\ltsexpandargs\MsgBrk to be + in the interval [0,3].}% + \fi + }% +} +\robust@def*\ltssafeexpandtwoargs#1#2#3{% + \begingroup + \ltssafeactivesedef\reserved@a{\endgroup\noexpand#1{#2}{#3}}% + \reserved@a +} +\robust@def*\expanddetoktwoargs#1#2#3{% + \cptexpandtwoargs#1{\cptoxdetok{#2}}{\cptoxdetok{#3}}% +} +%% Ulrich Diez: +\new@def*\ltsstepexpandarg#1{% + 0\csname @space\expandafter\LTS@stepexpandarg + \romannumeral\number\number#1000D\endcsname +} +\new@def*\LTS@stepexpandarg#1{% + \if#1m\expandafter\expandafter + \csname endcsname\expandafter\LTS@stepexpandarg\fi +} +%%-- + +\robust@def*\ltsStepExpandArg{\LTS@testopt\LTS@StepExpandArg{}} +\robust@def*\LTS@StepExpandArg[#1]#{% + \begingroup + \edef\LTS@tempa{\endgroup\unexpanded{#1}}% + \expandafter\LTS@tempa\romannumeral\ltsstepexpandarg +} +\robust@def*\ltsnameidef#1#2#3{% + \expandafter\def\csname#1\expandafter + \endcsname\expandafter{\romannumeral\ltsstepexpandarg{#2}#3}% +} +\robust@def*\ltsnamejdef#1#{\romannumeral\LTS@namejdef{#1}} +\new@def*\LTS@namejdef#1#2#3#{\LTS@n@mejdef{#1}{#2}{#3}} +\newcommand\LTS@n@mejdef[5]{% + \expandafter\cptswap\expandafter{% + \csname#2\expandafter\cptswap\expandafter{\expandafter{% + \romannumeral\ltsstepexpandarg{#4}#5% + }}{\endcsname #3}% + }{0 #1}% +} +\new@def*\ltsexpandtimes#1{% + \expandafter\LTS@expandtimes\expandafter + {\romannumeral\number#1000}% +} +\new@def*\LTS@expandtimes#1#2{% + \ifnullTF{#1}{% + \unexpanded{#2}% + }{% + \expandafter\ifnullTF\expandafter{\@gobble#1}{% + \unexpanded\expandafter{#2}% + }{% + \expandafter\ltsswapbracefirst\expandafter{#2}% + {\expandafter\LTS@expandtimes\expandafter{\@gobble#1}}% + }% + }% +} +\new@def*\ltsprotectedtokens#{% + \ifx\protect\@typeset@protect + \LTS@protectedtoken\@firstofone\fi + \ifx\protect\@unexpandable@protect + \LTS@protectedtoken\ltsunexpandable\fi + \ifx\protect\noexpand + \LTS@protectedtoken\unexpanded\fi + \ifx\protect\string + \LTS@protectedtoken\detokenize\fi + \relax\@firstofone +} +\new@def*\LTS@protectedtoken#1#2\relax\@firstofone{\fi#1} +\new@def\ltsunexpandable#1{\unexpanded{\ltsprotectedtokens{#1}}} +\new@def\ltsneverexpand#1{% + \unexpanded{\unexpanded{\unexpanded{\unexpanded{% + \unexpanded{\unexpanded{\unexpanded{\unexpanded{#1}}}}}}}}% +} + +% Reverse condition. Eg, turn \iffoundTF into \iffoundFT, +% \iffoundFT into \iffoundTF, \iffoundT to \iffoundF, etc. +% If there is no 'TF' (or 'T' or 'F') at end of csname, +% then use \unless: +\new@def*\revcond#1{% + \LTS@revcond@b{#1}\LTS@cartworev{TF}{% + \LTS@revcond@c{#1}\LTS@cdrtwo{FT}% + }{% + \LTS@revcond@b{#1}\LTS@cartworev{FT}{% + \LTS@revcond@c{#1}\LTS@cdrtwo{TF}% + }{% + \LTS@revcond@b{#1}\LTS@car{T}{% + \LTS@revcond@c{#1}\LTS@cdr{F}% + }{% + \LTS@revcond@b{#1}\LTS@car{F}{% + \LTS@revcond@c{#1}\LTS@cdr{T}% + }{% + \unless#1% + }% + }% + }% + }% +} +\def\LTS@revcond@a#1{% + \expandafter\expandafter\expandafter\directreverse + \expandafter\expandafter\expandafter + {\cptremovescape{#1}}% +} +\new@def*\LTS@revcond@b#1#2#3{% + \expandafter\ifstrcmpTF\expandafter{\romannumeral0\expandafter#2% + \romannumeral0\LTS@revcond@a{#1}\car@nil}{#3}% +} +\new@def*\LTS@revcond@c#1#2#3{% + \usename{\expandafter\expandafter\expandafter\directreverse + \expandafter\expandafter\expandafter{\expandafter#2\romannumeral0% + \LTS@revcond@a{#1}\cdr@nil}#3}% +} +\robust@def*\ifonetokenTF{% + \cpt@checkoptprefix{\LTS@teststcl\LTS@ifonetoken}% +} +\robust@def*\LTS@ifonetoken#1{% + \begingroup + \ifbracedTF{#1}{% + \aftergroup\@secondoftwo + }{% + \def\reserved@a##1\LTS@nil{% + \def\reserved@a{% + \csnaftergroup{LTS@\s@expandarg\ifnullTF{\@gobble##1}12of2}% + }% + \ifLTS@cl + \ifblankTF{##1}{\aftergroup\@secondoftwo}{\reserved@a}% + \else + \ifblankTF{##1}{\aftergroup\@firstoftwo}{\reserved@a}% + \fi + }% + \ifLTS@st\expandafter\expandafter\fi\reserved@a#1\LTS@nil + }% + \endgroup +} +\robust@def*\ifonetokenFT#1{\ifonetokenTF{#1}\iiofii\iofii} +\robust@def*\ifonetoken#1\do#2{% + \LTS@stfalse\LTS@cltrue + \LTS@ifonetoken{#1}{#2}{% + \LTS@err{More than one token in '\detokenize{#1}'}\@ehc + }% +} +\new@def*\ifboxvoidTF#1{% + \usename{@\ifvoid#1\@empty first\else second\fi ftwo}% +} +\new@def*\ifboxvoidFT#1{\usename{LTS@\ifboxvoidTF{#1}21of2}} +\new@def*\ifdefinedTF#1{% + \usename{LTS@\iflacus#1\dolacus2\else + \ifdefined#11\else2\fi\fi of2}% +} +\new@def*\ifdefinedFT#1{\usename{LTS@\ifdefinedTF{#1}21of2}} +% Eg, +% \ifmoduloTF{4}{6}{true}{false} +% \ifmoduloTF{4}{20}{true}{false} +\new@def*\ifmoduloTF#1#2{% + \ifnumcmpTF((#2)/(#1))*(#1)-(#2)=\z@pt +} +\let\then\iffalse +\new@def*\ifnnum#1\then{% + \ifdim\LTS@ptlt\LTS@ptgt\LTS@pteq#1pt% + \cpt@removetonnil<=>\cpt@nnil\@space +} +\new@def*\LTS@ptlt#1<{#1pt<} +\new@def*\LTS@ptgt#1>{#1pt>} +\new@def*\LTS@pteq#1={#1pt=} +\new@def*\realnumcmp{TT\fi\ifnum\ltsrealnums} +\new@def*\ltsrealnums#1\then{% + \dimexpr\LTS@dptlt\LTS@dptgt\LTS@dpteq#1pt% + \cpt@removetonnil<=>\cpt@nnil\@space +} +\new@def*\LTS@dptlt#1<{#1pt<\dimexpr} +\new@def*\LTS@dptgt#1>{#1pt>\dimexpr} +\new@def*\LTS@dpteq#1={#1pt=\dimexpr} +\begingroup +\catcode`\Y=12 +\catcode`\Z=12 +\lccode`\Y=`\p +\lccode`\Z=`\t +\lowercase{% + \defpass\x{\endgroup + \new@def*\LTS@ifinteger@a##1.##2YZ{% + \expandafter\ifx\expandafter\\\romannumeral0% + \ifnum##2>\z@pt\else\expandafter\@gobble\fi + \LTS@ifinteger@b\@space\\\cpt@removetonnil\cpt@nnil + }% + }% +} +\new@def\LTS@ifinteger@b#1\cpt@nnil{\noexpand\cpt@nnil} +\new@def\LTS@ifinteger#1\then{% + \expandafter\LTS@ifinteger@a + \the\dimexpr\LTS@mminus\LTS@pplus#1\p@ + \cpt@removetonnil+-\cpt@nnil\relax +} +\def\LTS@mminus#1-{#1\p@-} +\def\LTS@pplus#1+{#1\p@+} +\new@def\ifintegerTF#1#{% + \usename{LTS@\LTS@ifinteger#1\then1\else2\fi of2}% +} +\new@def\LTS@IfInteger#1\then{% + \begingroup + \toks@{}% + \LTS@integerparse{#1}{-}% + \toks@\expandafter{\expandafter}\expandafter + \LTS@integerparse\expandafter{\the\toks@}{+}% + \defpass\LTS@tempa{% + \xifinsetFT{\p@\p@\LTS@nil}{\the\toks@\LTS@nil}{}{% + \def\LTS@tempb####1\p@\LTS@nil{% + \toks@{####1}% + \LTS@tempa + }% + \expandafter\LTS@tempb\the\toks@\LTS@nil + }% + }% + \edef\LTS@tempa{\the\dimexpr\the\toks@}% + \expandafter\endgroup\expandafter\LTS@ifinteger + \expandafter\rem@pt\LTS@tempa\then +} +\new@def\LTS@integerparse#1#2{% + \def\LTS@tempa##1#2##2\LTS@nil{% + \ifblankTF{##2}{% + \toks@\expandafter{\the\toks@##1\p@}% + }{% + \ifstrcmpTF{#2}{##2}{% + \toks@\expandafter{\the\toks@##1\p@}% + }{% + \toks@\expandafter{\the\toks@##1\p@#2}% + \LTS@tempa##2#2\LTS@nil + }% + }% + }% + \LTS@tempa#1\LTS@nil +} +\new@def\IfIntegerTF#1#{% + \LTS@ifinteger#1\then + \expandafter\iofii\else\expandafter\iiofii\fi +} +\newletcs\ltsifnumtest\ifnnum +\newcommand*\ltssortnumlt{\LTS@sort\LTS@sortnumlt} +\newcommand*\ltssortnumgt{\LTS@sort\LTS@sortnumgt} +\newcommand*\ltssortalpha{\LTS@sort\LTS@sortalpha} +\newcommand\LTS@sort[2]{% + \iflacus#2\dolacus + \expandafter\iofii\else\expandafter\iiofii\fi + {}{% + \LTS@sortbegin#1{}#2\LTS@nnil\LTS@sortbegin + }% +} +\def\ifLTS@sortnil#1{% + \expandafter\ifx\expandafter\LTS@nnil\cpt@car#1\car@nil + \expandafter\iofii\else\expandafter\iiofii\fi +} +\def\LTS@sortbegin#1#2#3#4\LTS@sortbegin{% + \ifLTS@sortnil{#4}{% + \sortendfmt{#3}\LTS@sort#1{#2}% + }{% + \LTS@sortdo#1{#2}{#3}#4\LTS@sortdo + }% +} +\def\LTS@sortdo#1#2#3#4#5\LTS@sortdo{% + #1{#3}{#4}{\LTS@sortresult#1{#2}{#5}}% +} +\def\LTS@sortresult#1#2#3#4#5{% + \ifLTS@sortnil{#3}{% + \sortoutputfmt{#4}\LTS@sort#1{#2{#5}}% + }{% + \LTS@sortbegin#1{#2{#5}}{#4}#3\LTS@sortbegin + }% +} +\def\LTS@sortnumlt#1#2#3{% + \ltsifnumtest#1<#2\then + \expandafter\iofii\else\expandafter\iiofii\fi + {#3{#1}{#2}}{#3{#2}{#1}}% +} +\def\LTS@sortnumgt#1#2#3{% + \ltsifnumtest#1>#2\then + \expandafter\iofii\else\expandafter\iiofii\fi + {#3{#1}{#2}}{#3{#2}{#1}}% +} +\def\LTS@sortalpha#1#2#3{% + \ifnum\cpt@pdfstrcmp{#1}{#2}<\z@pt + \expandafter\iofii\else\expandafter\iiofii\fi + {#3{#1}{#2}}{#3{#2}{#1}}% +} + +\robust@def*\ifonedefTF{% + \begingroup\def\casenr{0}\LTS@testpl\LTS@ifonedef +} +\robust@def*\ifonedefFT{% + \begingroup\def\casenr{1}\LTS@testpl\LTS@ifonedef +} +\robust@def*\LTS@ifonedef#1{% + \cpt@choicefdfalse + \def\csv@do##1{% + \usename{if\ifLTS@pl csn\fi defFT}{##1}{}{% + \cpt@choicefdtrue\loopbreak + }% + }% + \csv@@parse[,]{#1}% + \LTS@onecase +} +\robust@def*\ifonetrueTF{% + \begingroup + \def\casenr{0}% + \LTS@testst{\LTS@testopt\LTS@ifonetrue{}}% +} +\robust@def*\ifonetrueFT{% + \begingroup + \def\casenr{1}% + \LTS@testst{\LTS@testopt\LTS@ifonetrue{}}% +} +\robust@def*\LTS@ifonetrue[#1]#2{% + \cpt@choicefdfalse + \edef\reserved@a{\ifLTS@st*\fi}% + \def\csv@do##1{% + \uselivecsn{if#1##1}% + \cpt@choicefdtrue\loopbreak + \fi + }% + \expandafter\csv@@parse\reserved@a[#1]{#2}% + \LTS@onecase +} +\robust@def*\LTS@onecase{% + \edef\next##1##2##3{% + \ifcase\casenr + ##11##22##32\or##12##21##32\or##11##20##31\or + ##10##21##31% + \fi + }% + \csnendgroup{LTS@\next\ifcpt@choicefd\else{\fi of}}% +} +\new@def*\ifcsndefeqTF#1#2{% + \ifcsndefFT{#1}\@secondoftwo + {\ifcsndefFT{#2}\@secondoftwo + {\aftercsname\ifxTF{#1\aftercsname}{#2}}}% +} +\new@def*\ifcsndefeqFT#1#2{\usename{LTS@\ifcsndefeqTF{#1}{#2}21of2}} +\robust@def*\LTS@notdefinable{% + \PackageError{ltxtools}% + {Command '\@backslashchar\LTS@rsvda' or + '\@backslashchar\@qend\LTS@rsvda' already defined}% + {Command '\@backslashchar\LTS@rsvda' already defined, + or name '\@backslashchar\@qend\LTS@rsvda' illegal.}% +} +\robust@def*\ltssaveprimitive#1#2{% + \begingroup + \cpt@swafalse + \edef\LTS@tempa{\string#1}% + \edef\LTS@tempb{\meaning#1}% + \ifx\LTS@tempa\LTS@tempb + \cpt@swatrue + \else + \edef\LTS@tempb{\meaning#2}% + \ifx\LTS@tempa\LTS@tempb\else\LTS@saveprimitive#1#2\fi + \fi + \expandafter\endgroup\ifcpt@swa\let#2#1\fi +} +\robust@def*\LTS@saveprimitive#1#2{% + \def\LTS@tempb##1#1##2##3\edef{\edef\LTS@tempb{##2}\edef}% + \LTS@tempb + \nullfont{select font nullfont}% + \topmark{\string\topmark:}% + \firstmark{\string\firstmark:}% + \botmark{\string\botmark:}% + \splitfirstmark{\string\splitfirstmark:}% + \splitbotmark{\string\splitbotmark:}% + #1{\string#1}% + \edef\LTS@tempa{\expandafter\strip@prefix\meaning\LTS@tempb}% + \edef\LTS@tempb{\meaning#1}% + \ifx\LTS@tempa\LTS@tempb + \cpt@swatrue + \else + \@latex@error{Command \noexpand#1 no longer a primitive}\@ehc + \fi +} +\robust@def*\LTS@badargerr#1#2{% + \LTS@err{Bad '\string#2' argument for command '\string#1'}{% + Bad '\string#2' argument for command '\string#1'.\MsgBrk + You need to look again at user instruction\MsgBrk + for command '\string#1'. + }% +} +\newletcs\ifpackageloadedTF\@ifpackageloaded +\newletcs\ifclassloadedTF\@ifclassloaded +\new@def*\ifpackageloadedFT#1{\ifpackageloadedTF{#1}\iiofii\iofii} +\new@def*\ifclassloadedFT#1{\ifclassloadedTF{#1}\iiofii\iofii} +\new@def*\LTS@ifclasscurr{\LTS@ifpkg@cls@curr\@clsextension} +\new@def*\LTS@ifpackagecurr{\LTS@ifpkg@cls@curr\@pkgextension} +\new@def*\LTS@ifpkg@cls@curr#1#2#3{% + \usename{LTS@\ifnum\cptsevenxp\@parse@version + \usename{ver@#2.#1}//00\@nil<\expandafter + \@parse@version#3//00\@nil2\else1\fi of2}% +} +\new@def*\ifclasscurrentTF{\LTS@ifloadedcurr{class}} +\new@def*\ifpackagecurrentTF{\LTS@ifloadedcurr{package}} +\newletcs\ifpkgcurrTF\ifpackagecurrentTF +\new@def*\LTS@ifloadedcurr#1#2#3{% + \usename{if#1loadedTF}{#2}{% + \usename{LTS@if#1curr}{#2}{#3}{% + \@firstoftwo + }{% + \LTS@err{Loaded version of #2 package is not current}% + {You need a higher version of #2 package:\MsgBrk + The version of #2 package available on your TeX\MsgBrk + installation is lower than you require.}% + \@secondoftwo + }% + }{% + \@secondoftwo + }% +} +\new@def*\ifpackagecurrentFT#1{\ifpackagecurrentTF{#1}\iiofii\iofii} +\new@def*\ifclasscurrentFT#1{\ifclasscurrentTF{#1}\iiofii\iofii} +\robust@def*\NeedPackage#1{\LTS@testopt{\LTS@needpackage{#1}}{}} +\newletcs\needpackage=\NeedPackage +\robust@def*\LTS@needpackage#1[#2]{% + \iflacus#2\dolacus + \LTS@err{No date given for package '#1'}\@ehc + \fi + \def\reserved@a##1/##2/##3/##4\@nil{% + \ifcase0\ifnum##1<1983 1 \fi\ifnum##2<1 1 \fi\ifnum##3<1 1\fi + \relax\else + \LTS@err{Invalid package date '#2'}\@ehc + \fi + }% + \reserved@a#2///\@nil + \edef\reserved@a{% + \ifx\documentclass\@twoclasseserror\noexpand\usepackage + \else\noexpand\RequirePackage\fi + }% + \cptexpanded{\LTS@testopt{\LTS@needp@ckage{#1}{#2}% + \expandcsonce\reserved@a}}{}% +} +\robust@def*\LTS@needp@ckage#1#2#3[#4]{% + \ifpackagecurrentTF{#1}{#2}{}{#3[#4]{#1}[#2]}% +} +\newcommand*\ltsremoveouterbraces[1]{% + \romannumeral\ifstrcmpTF{#1}{all}{% + \LTS@r@movebraces + }{% + \expandafter\LTS@removeouterbraces + \expandafter{\romannumeral#1000}% + }% +} +\newcommand\LTS@removeouterbraces[2]{% + \ifnullTF{#1}{0 #2}{% + \expandafter\ifnullTF\expandafter{\@gobble#2}{% + \ifbracedTF{#2}{% + \expandafter\ltsswapbracefirst\expandafter{\@iden#2}% + {\expandafter\LTS@removeouterbraces\expandafter{\@gobble#1}}% + }{0 #2}% + }{0 #2}% + }% +} +\newcommand\LTS@r@movebraces[1]{% + \expandafter\ifnullTF\expandafter{\@gobble#1}{% + \ifbracedTF{#1}{% + \expandafter\LTS@r@movebraces\expandafter{\@iden#1}% + }{0 #1}% + }{0 #1}% +} + +% Eg, \stripbracesinarg{St\"o{\ss}er} +\newcommand*\stripbracesinarg[1]{% + \romannumeral + \LTS@stripbracesinarg\strip@nil#1\strip@nil +} +\new@def\LTS@stripbracesinarg#1\strip@nil#2#3\strip@nil{% + \iflacus#3\dolacus + \expandafter\@firstoftwo + \else + \expandafter\@secondoftwo + \fi + {0 #1#2}{\LTS@stripbracesinarg#1#2\strip@nil#3\strip@nil}% +} + +\robust@def*\ltsensuremacro#1{% + \ifmacroTF{#1}{}{\cpt@notcserr{#1}}% +} +\robust@def*\ltsensurescape#1{% + \ifescapedTF{#1}{}{\cpt@notescapederr{#1}}% +} +\robust@def*\ltsensurenoscape#1{% + \ifescapedTF{#1}{\cpt@isescapederr{#1}}{}% +} +\robust@def*\ltsensurescape@csset#1#2{% + \cptdocommalist{#2}{% + \usename{LTS@ensure\ifnullTF{#1}{}{no}scape}{##1}% + }% +} +\robust@def\ltsifnextchar#1#2#3{% + \LTS@ifn@xtchar\bgroup + {\LTS@ifn@xtchar{#1}{#2}{#3}}% + {\LTS@ifnextchar{#1}{#2}{#3}}% +} +\new@def\LTS@ifnextchar#1#2#3#4{% + \csname LTS@\if\detokenize{#1#4}1\else2\fi of2\endcsname + {#2}{#3}#4% +} +\newcsndef{LTS@ifnextch} {\futurelet\next\LTS@ifn@@tchar} +\new@def\LTS@ifn@xtchar#1#2#3{% + \begingroup + \let\reserved@a=#1\toks@{#2}\toks1{#3}% + \futurelet\next\LTS@ifn@@tchar +} +\new@def*\LTS@ifn@@tchar{% + \ifx\next\@sptoken + \let\LTS@next\LTS@ifnextch + \else + \ifx\next\reserved@a + \edef\LTS@next{\endgroup\the\toks@}% + \else + \edef\LTS@next{\endgroup\the\toks1}% + \fi + \fi + \LTS@next +} +\robust@def*\nogobblespaceifnextchar#1#2#3{% + \begingroup + \let\reserved@a=#1\toks@{#2}\toks1{#3}% + \futurelet\next\LTS@nogobblespaceifnext +} +\new@def*\LTS@nogobblespaceifnext{% + \cptpassexpanded{\endgroup + \ifxTF\next\reserved@a{\the\toks@}{\the\toks1}% + }% +} +\robust@def*\LTS@ifchar#1#2#3{% + \ltsifnextchar#1{\begingroup\defpass\x#1{\endgroup#2}}{#3}% +} +\robust@def*\LTS@ifstar{\LTS@ifchar*} +\robust@def*\LTS@ifplus{\LTS@ifchar+} +\robust@def*\LTS@ifclam{\LTS@ifchar!} +\robust@def*\LTS@ifdot{\LTS@ifchar.} +\robust@def*\LTS@ifright{\LTS@ifchar>} +\robust@def*\LTS@ifleft{\LTS@ifchar<} +\robust@def*\LTS@ifprime{\LTS@ifchar'} +\robust@def*\ifnextisbrack#1#2{\ltsifnextchar[{#1}{#2}} +\robust@def*\ifnextisparen#1#2{\ltsifnextchar({#1}{#2}} +\robust@def*\ifnextisleftang#1#2{\ltsifnextchar<{#1}{#2}} +\robust@def*\LTS@testst#1{\LTS@ifstar{\LTS@sttrue#1}{\LTS@stfalse#1}} +\robust@def*\LTS@testpl#1{\LTS@ifplus{\LTS@pltrue#1}{\LTS@plfalse#1}} +\robust@def*\LTS@testcl#1{\LTS@ifclam{\LTS@cltrue#1}{\LTS@clfalse#1}} +\robust@def*\LTS@testpm#1{\LTS@ifprime{\LTS@pmtrue#1}{\LTS@pmfalse#1}} +\robust@def*\LTS@testrt#1{\LTS@ifright{\LTS@rttrue#1}{\LTS@rtfalse#1}} +\robust@def*\LTS@testlt#1{\LTS@ifleft{\LTS@lttrue#1}{\LTS@ltfalse#1}} +\robust@def*\LTS@teststpl#1{\LTS@testst{\LTS@testpl{#1}}} +\robust@def*\LTS@teststplcl#1{\LTS@testst{\LTS@testpl{\LTS@testcl{#1}}}} +\robust@def*\LTS@teststplpm#1{\LTS@testst{\LTS@testpl{\LTS@testpm{#1}}}} +\robust@def*\LTS@teststclpm#1{\LTS@testst{\LTS@testcl{\LTS@testpm{#1}}}} +\robust@def*\LTS@teststcl#1{\LTS@testst{\LTS@testcl{#1}}} +\robust@def*\LTS@teststpm#1{\LTS@testst{\LTS@testpm{#1}}} +\robust@def*\LTS@testplcl#1{\LTS@testpl{\LTS@testcl{#1}}} +\robust@def*\LTS@testopt#1#2{\ifnextisbrack{#1}{#1[{#2}]}} +\robust@def*\LTS@teststopt#1#2{\LTS@testst{\LTS@testopt{#1}{#2}}} +\robust@def*\LTS@testltopt#1#2{\ifnextisleftang{#1}{#1<{#2}>}} +\robust@def*\LTS@testpnopt#1#2{\ifnextisparen{#1}{#1({#2})}} +\new@def*\LTS@Test@pt#1{\usename{LTS@\ifnullTF{#1}12of2}} +\new@def*\LTS@IfBrack#1#2#3{\LTS@IfBr@ck#1&[&{#2}{#3{#1}}} +\new@def*\LTS@IfBr@ck#1[#2#{\LTS@Test@pt{#1#2}} +\new@def*\LTS@TestOpt#1#2#3{\LTS@IfBr@ck#1&[&{#2#1}{#2[{#3}]{#1}}} +\new@def*\LTS@IfStar#1#2#3{\LTS@IfSt@r#1&*&{#2}{#3{#1}}} +\new@def*\LTS@IfSt@r#1*#2#{\LTS@Test@pt{#1#2}} +\new@def*\LTS@IfPlus#1#2#3{\LTS@IfPl@s#1&+&{#2}{#3{#1}}} +\new@def*\LTS@IfPl@s#1+#2#{\LTS@Test@pt{#1#2}} +\robust@def\ltsifnextchars#1#2#3{% + \begingroup + \long\def\special@car{\futurelet\next\special@car@a}% + \long\def\special@car@a##1##2\car@nil{% + \ifx\next\temp@bgroup\toks@{{##1}}\else\toks@{##1}\fi + }% + \let\temp@bgroup\bgroup + \let\bgroup\LTS@undefined + \def\LTS@tempa{#1}\def\LTS@tempb{#2}% + \def\LTS@tempc{#3}\def\LTS@tempd{}% + \LTS@ifnextchars@a +} +\def\LTS@ifnextchars@a{\futurelet\next\LTS@ifnextchars@b} +\def\LTS@ifnextchars@b{% + \ifxTF\next\@sptoken{% + \afterassignment\LTS@ifnextchars@a\let\next= % + }{% + \LTS@ifnextchars@c + }% +} +\def\LTS@ifnextchars@c#1{% + \ifx\next\temp@bgroup\toks1{{#1}}\else\toks1{#1}\fi + \expandafter\special@car\LTS@tempa\car@nil + \xifstrcmpTF{\the\toks@}{\the\toks1}{% + \edef\LTS@tempd{\expandcsonce\LTS@tempd\the\toks@}% + \toks@\cptthreexp{\expandafter\cpt@cdr\LTS@tempa\cdr@nil}% + \edef\LTS@tempa{\the\toks@}% + \ifcsnullTF\LTS@tempa{% + \cptthreexp\endgroup\expandafter\LTS@tempb\LTS@tempd + }{% + \LTS@ifnextchars@a + }% + }{% + \edef\LTS@tempd{\expandcsonce\LTS@tempd\the\toks1}% + \cptthreexp\endgroup\expandafter\LTS@tempc\LTS@tempd + }% +} +\robust@def*\ltsgetbasechars{\LTS@teststopt\LTS@getbasechars{1}} +\robust@def*\LTS@getbasechars[#1]#2#3{% + \begingroup + \def#3{}\@tempcnta\z@ + \cptexpandarg + \cpttfor{\ifboolTF{LTS@st}\cptoxdetok\detokenize{#2}}\dofor{% + \edef#3{#3##1}% + \advance\@tempcnta\@ne + \ifnum\@tempcnta>#1\relax + \edef#3{#3\string\ETC}% + \forbreaktrue + \fi + }% + \postgroupdef#3\endgroup +} +% Eg, \ltstypeoutaligned[;]{xx,aa;yy,bb} +\robust@def*\ltstypeoutaligned{\cpt@testopt\LTS@typeoutaligned{20}} +\robust@def*\LTS@typeoutaligned[#1]#2{% + \begingroup + \def\\{ }% + \ltsdocsvlist[;]{#2}{% + \@tempcnta\z@pt + \def\LTS@tempb{}% + \def\reserved@a####1,####2,####3\LTS@nil{% + \expandafter + \cpttfor\detokenize{####1}% + \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\dofor{% + \advance\@tempcnta\@ne + \ifnum\@tempcnta>#1\relax + \typeout{\LTS@tempb ####2}% + \forbreaktrue + \else + \edef\LTS@tempb{\LTS@tempb########1}% + \fi + }% + }% + \reserved@a##1,,\LTS@nil + }% + \endgroup +} +\robust@def*\ltsgetpackagenames{% + \AtBeginDocument{% + \let\ltsgetpackagenames\relax + \begingroup + \def\LTS@tempb{% + \def\\{ }\@tempcnta\z@pt + \def\LTS@tempa{}% + \def\siso@do####1{% + \advance\@tempcnta\@ne + \ifnum\@tempcnta>20\relax + \typeout{\LTS@tempa\ifcsnullTF\reserved@f{}{[\reserved@f]}}% + \loopbreaktrue + \else + \edef\LTS@tempa{\LTS@tempa####1}% + \fi + }% + \expandafter\siso@@loop\expandafter{\filename@base + \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\}% + }% + \typeout{^^J *** Package List ***}% + \def\csv@do##1{% + \filename@parse{##1}% + \ifx\filename@ext\@pkgextension + \ifcsndefTF{\filename@base}{% + \edef\reserved@e{\expandafter\meaning + \csname\filename@base\endcsname}% + \xifinsetTF{\detokenize{macro:}}\reserved@e{% + \edef\reserved@f{\expandafter\strip@prefix\reserved@e}% + }{% + \let\reserved@f\reserved@e + }% + }{% + \def\reserved@f{}% + }% + \LTS@tempb + \fi + }% + \csv@@loop*[,]\@filelist + \typeout{ **************^^J}% + \endgroup + }% +} +\cptonlypreamble{\ltsgetpackagenames} +% Eg, +% \begingroup +% \catcode`\;=13 +% \catcode`\,=13 +% \gdef\y{a , ,b, c, ,} +% \gdef\z{x ; ;y; z; ;} +% \endgroup +% \ltsdeclarelistparser\alistparser{,} +% \ltsdeclarelistparser\blistparser{;} +% ! -> expand and execute the processor. +% \def\do#1{#1} +% \edef\x{\cptexpandbracenext{\alistparser!}{\y}\do} +% +% Nesting is possible: +% \def\@do#1{#1} +% \def\do#1{|#1|\cptexpandbracenext{\blistparser!}\z\@do} +% \edef\x{\cptexpandbracenext{\alistparser!}\y\do} +\robust@def*\ltsdeclarelistparser#1#2{% + \cptexpandbracenext{\ltssetupnormalizer{#1}}{\string#2}% + \begingroup + \def\elta##1{\noexpandcsn{\cptgobblescape#1@list@aux@##1}}% + \def\eltb{\noexpand\romannumeral-`\noexpand\q% + \noexpandcsn{\cptgobblescape#1@list@normalizer}% + }% + \def\eltc##1{\noexpand\expandafter\elta{b}\noexpand + \expandafter##1\eltb{########1}#2\noexpand\parselist@nil#2% + \noexpand\parselist@nnil + }% + \cptexpanded{\endgroup + \def\noexpand#1####1{% + \noexpand\ifstrcmpTF{####1}{!}{\elta{a}}{\eltc{+}}% + }% + \def\elta{a}####1{\eltc{!}}% + \def\elta{b}####1####2#2####3\noexpand\parselist@nnil####4{% + \noexpand\ifstrcmpTF{####2}\noexpand\listbreak{}{% + \noexpand\ifstrcmpTF{####2}\noexpand\parselist@nil{}{% + \noexpand\ifstrcmpTF{####1}{!}{% + ####4{####2}% + }{% + \noexpand\unexpanded{####4{####2}}% + }% + \elta{b}{####1}####3\noexpand\parselist@nnil{####4}% + }% + }% + }% + }% +} +% Dynamic, arbitrary parser, list normalizer: +\robust@def*\ltssetupnormalizer#1#2{% + \begingroup + \lccode`\~=`#2% + \lowercase{\endgroup + \csn@def{\cptgobblescape#1@list@normalizer}##1{% + \unexpanded\expandafter{\romannumeral-`\q + \usename{\cptgobblescape#1@activeparser}#2##1#2~\LTS@nil}% + }% + \csn@def{\cptgobblescape#1@activeparser}##1~##2\LTS@nil{% + \ifblankTF{##2} + {\usename{\cptgobblescape#1@spaceparser}##1 #2\LTS@nil} + {\usename{\cptgobblescape#1@activeparser}##1#2##2\LTS@nil}% + }% + }% + \csn@def{\cptgobblescape#1@spaceparser}##1 #2##2\LTS@nil{% + \ifblankTF{##2} + {\usename{\cptgobblescape#1@parserspace}##1#2 \LTS@nil} + {\usename{\cptgobblescape#1@spaceparser}##1#2##2\LTS@nil}% + }% + \csn@def{\cptgobblescape#1@parserspace}##1#2 ##2\LTS@nil{% + \ifblankTF{##2} + {\usename{\cptgobblescape#1@doubleparser}##1#2#2\LTS@nil} + {\usename{\cptgobblescape#1@parserspace}##1#2##2\LTS@nil}% + }% + \csn@def{\cptgobblescape#1@doubleparser}##1#2#2##2\LTS@nil{% + \ifblankTF{##2} + {\ifblankTF{##1}{}{\expandafter\noexpand\@gobble##1}} + {\usename{\cptgobblescape#1@doubleparser}##1#2##2\LTS@nil}% + }% +} +% \ltsforcsvlist[<parser>]{<list>}{<callback>} +% \ltsforcsvlist*[<parser>]<listcmd>{<callback>} +% \ltsdocsvlist[<parser>]{<list>} +% \ltsdocsvlist*[<parser>]<listcmd> +% For \ltsdocsvlist, first define \def\ltsdo<param>\ltsdo{<dfn>}. +% General list parsers. Preserve braces and accept arbitrary parser. +% Use '#1' in <callback> for current item on horizontal level 1, +% ##1 on horizontal level 2, etc. Nesting of the loops +% gives rise to vertical levels. Use \csvbreak or \loopbreak +% to break out of the loop on any level. Loop breaks are vertical +% level dependent: eg, breaking level 1 doesn't affect other +% active levels. An empty list is executed once. +\robust@def*\ltsforcsvlist{\def\do@def{01}\LTS@teststopt\LTS@forcsvlist,} +\robust@def*\ltsdocsvlist{\def\do@def{00}\LTS@teststopt\LTS@docsvlist,} +\robust@def*\LTS@docsvlist[#1]#2{\LTS@forcsvlist[#1]{#2}{}} +\robust@def*\LTS@forcsvlist[#1]#2#3{% + \pushfunctions\ltsforcsvlist + {\LTS@csvdo,\LTS@csvact,\ifloopbreak,\do@def}\cpt@csvdepth + \cpt@stchoose{LTS@st}{#2}\LTS@csvarg\ltsforcsvlist + \if\do@def\else\def\LTS@csvact##1{#3}\fi + \def\LTS@csvdo##1#1{% + \s@expandarg\ifcsvbreakTF{\@gobble##1}\loopbreak\relax + \ifboolTF{loopbreak}{% + \gobble@to@sentinel\cpt@csvnil#1% + }{% + \edef\LTS@csvarg{\unexpanded\expandafter{\@gobble##1}}% + \ifcseqTF\LTS@csvarg\cpt@csvnnil{}{% + \ifswitchTF{do@def}{% + \expandafter\ltsdo\LTS@csvarg\ltsdo + }{% + \s@expandarg\LTS@csvact\LTS@csvarg\relax + }% + \LTS@csvdo.% + }% + }% + }% + \csv@@normalize*[#1]\LTS@csvarg + \loopbreakfalse + \expandafter\LTS@csvdo\expandafter.\LTS@csvarg#1\cpt@csvnil#1% + \popfunctions\ltsforcsvlist\cpt@csvdepth + \ifnum\cpt@csvdepth=\z@pt\undefcs\ltsdo\fi +} +\cptnewvariables{if}{lastfox}[false] +\newcommand*\LTS@foxnil{\LTS@foxnil} +% \foxloop[<parser>]{<list>}{<callback>} +% \foxloop*[<parser>]{<listcmd>}{<callback>} +% 1. You can use \currfox<level>, \nextfox<level>, and +% \currfoxnr<level> within <callback> to access the current +% element of <list>, the next element of <list>, and +% the serial number of the current item, respectively, at +% various levels of nesting. <level> is given in roman numerals, +% eg, \currfoxi, \currfoxii. +% 2. You can use \foxlevel to access the level/depth of nesting. +% 3. You can inset \csvbreak as an element of <list> to break +% out of the loop. Similarly, you can use \loopbreak within +% <callback> to break out of the loop. +% 4. You can insert \csvpause as an element of <list> to pause +% the loop. +\robust@def*\foxloop{% + \LTS@testst{\LTS@testopt\LTS@fox@@a{,}}% +} +\robust@def*\LTS@fox@@a[#1]{% + \cpt@checklistparser{#1}\relax + \usename{LTS@fox@\ifLTS@st b\else a\fi}[#1]% +} +\robust@def*\LTS@fox@a[#1]#2{% + \declarefoxlistparser{#1}% + \LTS@fox@@b{#2}% +} +\robust@def*\LTS@fox@b[#1]#2{% + \declarefoxlistparser{#1}% + \expandafter\LTS@fox@@b\expandafter{#2}% +} +\robust@def*\declarefoxlistparser#1{% + \long\def\LTS@fox@@b##1##2{% + \pushfunctions\foxloop{% + \getnextfox,\LTS@foxrema,\foxparser,\LTS@fox@@d,% + \currfox,\nextfox,\currfoxnr,\iflastfox,\ifloopbreak + }\cpt@csvdepth + \pushnumber\foxlevel + \def\foxparser{#1}% + \long\def\LTS@foxrema####1\LTS@foxnil#1{% + \long\edef\foxremainder{\unexpanded{####1}}% + \ifcsemptyTF\foxremainder\relax + {\cpt@trimparsers[#1]\foxremainder}% + }% + \chardef\currfoxnr\z@pt + \def\getnextfox####1#1####2\getnextfox{% + \edef\nextfox{\expandcsonce{\cpt@removetodot####1}}% + \ifxTF\nextfox\LTS@foxnil{% + \lastfoxtrue + \let\nextfox\@empty + \letcsntocs{nextfox\romannumeral\cpt@csvdepth}\@empty + }{% + \lastfoxfalse + \letcsntocs{nextfox\romannumeral\cpt@csvdepth}\nextfox + }% + }% + \def\LTS@fox@@c####1####2{% + \getnextfox.####1\getnextfox + ####2\relax + \ifboolTF{loopbreak}{}{% + \LTS@fox@@d.####1\LTS@fox@@d{####2}% + }% + }% + \long\def\LTS@fox@@d####1#1####2\LTS@fox@@d####3{% + \edef\currfox{\expandcsonce{\cpt@removetodot####1}}% + \letcsntocs{currfox\romannumeral\cpt@csvdepth}\currfox + \edef\currfoxnr{\the\numexpr\currfoxnr+1}% + \letcsntocs{currfoxnr\romannumeral\cpt@csvdepth}\currfoxnr + \ifxTF\currfox\LTS@foxnil{}{% + \ifxTF\currfox\cpt@csvbreak{% + \LTS@foxrema####2% + }{% + \ifxTF\currfox\cpt@csvpause{% + \message{^^J! List pause: + ^^JType x or X to quit, or <RETURN> to proceed^^J}% + {\endlinechar-1\global\read-1 to\@gtempa}% + \lowercase\expandafter{\expandafter\def\expandafter + \@gtempa\expandafter{\@gtempa}}% + \xifstrcmpTF\@gtempa{x}{% + \LTS@foxrema####2% + }{% + \LTS@fox@@c{####2}{####3}% + }% + }{% + \LTS@fox@@c{####2}{####3}% + }% + }% + }% + }% + \loopbreakfalse\lastfoxfalse + \cpt@stfalse\cpt@csvnormalize[#1]{##1}% + \expandafter\LTS@fox@@d\expandafter + .\normalized@list#1\LTS@foxnil#1\LTS@fox@@d{##2}% + \popfunctions\foxloop\cpt@csvdepth + \popnumber\foxlevel + }% +} +% For use with comma-lists, where nesting isn't needed: +% \cfoxloop{<commalist>}<fn> +\robust@def\cfoxloop#1#2{% + \chardef\currfoxnr\z@pt + \edef\foxlevel{\ifdefTF\foxlevel{\the\numexpr\foxlevel+1}{1}}% + \ifnum\foxlevel>\@ne + \LTS@err{\noexpand\cfoxloop shouldn't be nested}\@ehc + \fi + \def\fox@do##1,{% + \edef\currfox{\expandcsonce{\@gobble##1}}% + \ifcseqTF\currfox\cpt@nnil{}{% + \ifboolTF{loopbreak}{% + \defpass\reserved@a####1\cpt@nil,{% + \s@expandarg\cptdoremainder{\@gobble##1,####1}% + }% + }{% + \defpass\reserved@a####1,{% + \edef\nextfox{\expandcsonce{\@gobble####1}}% + \edef\currfoxnr{\the\numexpr\currfoxnr+1}% + \ifcseqFT\nextfox\cpt@nnil{}{% + \lastfoxtrue\let\nextfox\@empty + }% + \expandafter#2\expandafter{\currfox}% + \fox@do####1,% + }.% + }% + }% + }% + \edef\reserved@a{\cptcommanormalize{#1}}% + \loopbreakfalse\lastfoxfalse + \expandafter\fox@do\expandafter.\reserved@a,\cpt@nil,% + \undefcs\foxlevel +} +\new@def*\LTS@csnalloc#1{\usename{new#1\aftercsname}} +\providerobust@def*\csnnewif{\LTS@csnalloc{if}} +\robust@def*\csnnewtoks{\LTS@csnalloc{toks}} +\robust@def*\csnnewcount{\LTS@csnalloc{count}} +\robust@def*\csnnewdimen{\LTS@csnalloc{dimen}} +\robust@def*\csnnewskip{\LTS@csnalloc{skip}} +\robust@def*\csnnewmuskip{\LTS@csnalloc{muskip}} +\robust@def*\csnnewbox{\LTS@csnalloc{box}} +\robust@def*\csnnewwrite{\LTS@csnalloc{write}} +\robust@def*\csnnewread{\LTS@csnalloc{read}} +\robust@def*\LTS@createtwincmds#1{% + \begingroup\escapechar92\relax\expandafter\endgroup + \if\expandafter\LTS@car\string#1x\car@nil\@backslashchar\else + \LTS@err{Non-escaped command name '\detokenize{#1}'}\@ehc + \fi + \ifcsdefinable#1\relax + \ifcsndefinable{No\cptremovescape{#1}}\relax +} +\robust@def*\CreateTwinBooleanCommands#1#2{% + \LTS@createtwincmds{#1}% + \ifcsndefinable{if\cptremovescape{#2}}{% + \csnnewif{\cptremovescape{#2}}% + }% + \def#1{\gletcsntocs{if\cptremovescape{#2}}\iftrue}% + \csn@def{No\cptremovescape{#1}}{% + \gletcsntocs{if\cptremovescape{#2}}\iffalse + }% + \usename{No\cptremovescape{#1}}% +} +\robust@def*\CreateTwinSwitchCommands#1#2{% + \LTS@createtwincmds{#1}% + \def#1{\global\let#2\cptswtrue}% + \csn@def{No\cptremovescape{#1}}{\global\let#2\cptswfalse}% + \usename{No\cptremovescape{#1}}% +} +% Eg, \CreateTwinNumberCommands\StrictCheck\strict. +% This gives two commands: +% \StrictCheck -> \strict=1 +% \NoStrictCheck -> \strict=0 +\robust@def*\CreateTwinNumberCommands#1#2{% + \LTS@createtwincmds{#1}% + \def#1{\global\chardef#2\@ne}% + \csn@def{No\cptremovescape{#1}}{\global\chardef#2\z@pt}% + \usename{No\cptremovescape{#1}}% +} +\CreateTwinSwitchCommands\ExpandPrimitives\LTS@expprim +\CreateTwinSwitchCommands\WrapQuotes\LTS@wq +\CreateTwinSwitchCommands\ConvertInputToLowercase\LTS@lwc +\CreateTwinSwitchCommands\StrictHashCheck\stricthashcheck +\robust@def*\LTS@detok@zap#1{% + \ltsensuremacro{#1}% + \edef#1{\s@expandarg\cptzapspaces{\detokenize\expandafter{#1}}}% +} +\new@def*\LTS@global@or@relax{% + \ifLTS@cl\let\glob@lrel@x\global\else\let\glob@lrel@x\relax\fi +} +\newletcs\glob@lrel@x\relax +\new@def*\LTS@long@or@relax{% + \ifLTS@st\let\l@ngrel@x\relax\else\let\l@ngrel@x\long\fi +} +\robust@def*\ltssetupsafeactivesedef{% + \let\ltssetupsafeactivesedef\relax + \begingroup\begingroup + \lccode`\Z=`\# % + \lowercase{\endgroup + \cpttfor Z!"$&'()*+,-./:;<=>?[]^_`|~\dofor{% + \catcode`##1\string=\active + }% + }% + \everyeof{\noexpand}% + \begingroup + \lccode`\Z=`\# % + \lowercase{\endgroup + \xdef\ltssafeactives + {\scantokens{\unexpanded{Z!"$&'()*+,-./:;<=>?[]^_`|~}}}% + }% + \gdef\ltssafeactivesedef##1##2{% + \begingroup + \expandafter\cpttfor\ltssafeactives\dofor{% + \ifnum\catcode`####1\string=\active\edef####1{\string####1}\fi + }% + \edef##1{##2}% + \postgroupdef##1\endgroup + }% + \endgroup +} +\robust@def*\ltsreversetokens{\LTS@testst\LTS@reverse} +\new@def*\LTS@reverse#1#2{% + \begingroup + \def\LTS@tempa##1\reverse@nil{% + \def\LTS@tempa####1####2{% + \expandafter\ifxTF\cpt@car####2\car@nil + \endreverse{####1}{\LTS@tempa{####2####1}}% + }% + \toks@\expandafter{\romannumeral0\LTS@tempa{}##1\@space\endreverse}% + }% + \ifLTS@st\expandafter\expandafter\fi + \LTS@tempa#2\reverse@nil + \cptexpandsecond\endgroup + {\edef\noexpand#1{\noexpand\unexpanded{\the\toks@}}}% +} +\newletcs\endreverse\end +\new@def\directreverse#1{\LTS@directreverse{}#1\endreverse} +\new@def\LTS@directreverse#1#2{% + \expandafter\ifxTF\cpt@car#2\car@nil\endreverse{% + \if@test\expandafter\@iden\else\expandafter\unexpanded\fi{#1}% + }{% + \LTS@directreverse{#2#1}% + }% +} +\new@def\robustreverse#1{\LTS@robustreverse{}.#1\endreverse} +\new@def\LTS@robustreverse#1#2\endreverse{% + \LTS@r@bustreverse{#1}% + {\expandafter\ifleftbracedTF\expandafter + {\cpt@removetodot#2}}#2\endreverse +} +\new@def\LTS@r@bustreverse#1#2.#3{% + \expandafter\ifxTF\cpt@car#3\car@nil\endreverse{% + \if@test\expandafter\@iden\else\expandafter\unexpanded\fi{#1}% + }{% + #2{\LTS@robustreverse{{#3}#1}}{\LTS@robustreverse{#3#1}}.% + }% +} +% Create a delimiter for command 'Rabfe' (which means 'remove all but +% first undelimited element'): +\robust@def*\DeclareRabfeDelimiter{\LTS@testst\LTS@DeclareRabfeDelimiter} +\robust@def*\LTS@DeclareRabfeDelimiter#1{% + \ifLTS@st + \long\def\ltsgetfirstelement##1##2#1{{##1}}% + \else + \long\def\ltsgetfirstelement##1##2#1{##1}% + \fi +} +\DeclareRabfeDelimiter{\LTS@nil} +% One advantage of \removeallbutfirstelement is that delimiters +% (ie, sentinels) can be replicated in its argument. +% Eg, #1 with two delimiters: +% \LTS@DeclareRabfeDelimiter\LTS@nil +% \edef\x{\removeallbutfirstelement{xyz\LTS@nil\LTS@nil}} +\new@def\removeallbutfirstelement#1{% + \romannumeral-`\q + \expandafter\expandafter\expandafter\ifnullTF + \expandafter\expandafter\expandafter{% + \expandafter\@gobble\ltsgetfirstelement#1}{% + \expandafter\@firstofone\expandafter{% + \ltsgetfirstelement#1}% + }{% + \expandafter\expandafter\expandafter\@gobblefour + \expandafter\removeallbutfirstelement + \expandafter{\ltsgetfirstelement#1}% + }% +} +\robust@def*\ltsremoveleadparser{\LTS@testopt\LTS@remleadparser{,}} +\new@def\LTS@remleadparser[#1]#2{% + \ltsensuremacro{#2}% + \begingroup + \def\reserved@a#1{\futurelet\next\reserved@d}% + \@namedef{reserved@b} {\reserved@a#1}% + \def\reserved@d{% + \ifx\next\@sptoken + \expandafter\reserved@b + \else + \ifx#1\next + \cptthreexp\reserved@a + \else + \cptthreexp\reserved@c + \fi + \fi + }% + \def\reserved@c##1\LTS@nil{\endgroup\edef#2{\unexpanded{##1}}}% + \expandafter\reserved@a\expandafter#1#2\LTS@nil +} +\robust@def*\ltsremtrailparser{\LTS@testopt\LTS@remtrailparser{,}} +\robust@def*\LTS@remtrailparser[#1]#2{% + \begingroup + \ltsensuremacro{#2}% + \defpass\LTS@rsvda{% + \despacecontent#2% + \xifinsetFT{#1&}{\expandcsonce#2&}{}{% + \def\LTS@rsvdb####1#1&{% + \edef#2{\unexpanded{####1}}% + \LTS@rsvda + }% + \expandafter\LTS@rsvdb#2&% + }% + }% + \postgroupdef#2\endgroup +} +\robust@def*\ltsremoveparser{\LTS@testopt\LTS@remparser{,}} +\robust@def*\LTS@remparser[#1]#2{% + \LTS@remleadparser[#1]#2% + \LTS@remtrailparser[#1]#2% +} +% We re-implement xkeyval's \@selective@sanitize to admit +% even \bgroup in the token list, and to remove some trivial +% steps: +\robust@def*\selectivesanitize{\LTS@testopt\LTS@selectivesanitize\@M} +\robust@def*\LTS@selectivesanitize[#1]#2#3{% + \ltsensuremacro{#3}% + \begingroup + \cpt@cnta#1\advance\cpt@cnta\@ne + \let\temp@bgroup\bgroup + \let\bgroup\cpt@undefined + \cptexpandsecond + {\LTS@s@lectivesanitize#3}{{\detokenize{#2}}{\expandcsonce#3}}% + \postgroupdef#3\endgroup +} +\robust@def*\LTS@s@lectivesanitize#1#2#3{% + \def\LTS@i{\futurelet\next\LTS@ii}% + \def\LTS@ii{% + \expandafter\LTS@iii\meaning\next\LTS@nil + \ifx\next\end + \let\cmd\@gobbleone + \else + \ifx\next\@sptoken + \edef#1{\expandcsonce#1\@space}% + \lowercase{\def\cmd} {\LTS@i}% + \else + \let\cmd\LTS@iv + \fi + \fi + \cmd + }% + \def\LTS@iii##1##2\LTS@nil{% + \if##1\@backslashchar\let\next\relax\fi + }% + \def\LTS@iv##1{% + \toks@\expandafter{#1}\toks1{##1}% + \ifx\next\temp@bgroup + \advance\cpt@cnta\m@one + \ifnum\cpt@cnta>\z@pt + \begingroup + \cptexpandsecond\LTS@s@lectivesanitize + {\noexpandcsn{\string#1}{#2}{\the\toks1}}% + \edefpass#1{\endgroup\toks1{\expandcsnonce{\string#1}}}% + \fi + \edef#1{\the\toks@{\the\toks1}}% + \advance\cpt@cnta\@ne + \else + \edef#1{\expandafter\string\the\toks1}% + \expandafter\cpt@in\expandafter{#1}{#2}% + \edef#1{\the\toks@\ifcpt@in#1\else\the\toks1\fi}% + \fi + \LTS@i + }% + \def#1{}\LTS@i#3\end +} +\robust@def*\ltschecksanitya#1#2{\ltschecksanity{,}{#1}#2} +\robust@def*\ltschecksanityb#1#2{\ltschecksanity{,.=}{#1}#2} +\robust@def*\ltschecksanityc#1#2{\ltschecksanity{,;}{#1}#2} +\robust@def*\ltschecksanityd#1#2{\ltschecksanity{,;:|-=}{#1}#2} +\robust@def*\ltschecksanity#1#2#3{% + \cpt@checkfalse + \def\tsv@do##1{% + \ifboolTF{cpt@check}{}{% + \LTS@ch@cksanity{##1}{#2}% + }% + }% + \tsv@@parse{#1}% + \ifboolTF{cpt@check}{% + \edef#3{\unexpanded{#2}}% + \selectivesanitize[1]{#1}#3% + }{}% +} +\robust@def*\LTS@ch@cksanity#1#2{% + \ifbelongFT{#1}{#2}{}{% + \defpass\reserved@a##1#1##2\LTS@nil{% + \ifblankTF{##2}{\cpt@checktrue\loopbreak}{}% + }% + #2#1\LTS@nil + }% +} +\robust@def*\ltsensureothersanity#1#2{% + \begingroup + \edef#2{\unexpanded{#1}}% + \LTS@scantoksb#2% + \postgroupdef#2\endgroup +} +\robust@def*\ltsfiltermergecsv{% + \begingroup + \let\LTS@parse\csv@@parse + \cpt@checkoptprefix + {\LTS@teststplcl{\LTS@testopt\LTS@filtermergelists,}}% +} +\robust@def*\ltsfiltermergekv{% + \begingroup + \let\LTS@parse\kv@@parse + \cpt@checkoptprefix + {\LTS@teststplcl{\LTS@testopt\LTS@filtermergelists,}}% +} +\robust@def*\LTS@filtermergelists[#1]#2#3#4{% + \edef\temp@do{\noexpandcsn{% + \ifxTF\LTS@parse\csv@@parse{csv}{kv}@do}% + }% + \ifLTS@pl + \ifcsndefTF{#2}{% + \letcstocsn\LTS@tempa{#2}% + }{% + \def\LTS@tempa{}% + }% + \else + \ifdefTF{#2}{% + \let\LTS@tempa#2% + }{% + \def\LTS@tempa{}% + }% + \fi + \cpt@stchoose{LTS@st}{#3}\LTS@tempb\LTS@filtermergelists + \cptdeclarefilter{#4}% + \cpt@useemptyfalse + \def\LTS@tempf##1{\csliststack#1\LTS@tempa\unexpanded{##1}}% + \expandafter\def\temp@do##1{% + \edef\LTS@tempb{\unexpanded{##1}}% + \cpt@swatrue + \cpt@usefilter\LTS@tempb\LTS@tempc + \let\LTS@tempd\LTS@tempa + \def\LTS@tempa{}% + \expandafter\def\temp@do####1{% + \edef\LTS@tempd{\unexpanded{####1}}% + \cpt@usefilter\LTS@tempd\LTS@tempe + \ifx\LTS@tempc\LTS@tempe + \cpt@swafalse + \edef\LTS@tempa{\LTS@tempf{##1}}% + \else + \edef\LTS@tempa{\LTS@tempf{####1}}% + \fi + }% + \ifcsnullTF\LTS@tempd{}{\LTS@parse*[#1]\LTS@tempd}% + \ifdefboolFT{cpt@swa}{}{\edef\LTS@tempa{\LTS@tempf{##1}}}% + }% + \ifcsnullTF\LTS@tempb{}{% + \ifcsnullTF\LTS@tempa{% + \let\LTS@tempa\LTS@tempb + }{% + \LTS@parse*[#1]\LTS@tempb + }% + }% + \cptpassexpanded{% + \ifLTS@cl\global\fi + \let\ifLTS@pl\cptmakecs{#2}\else\noexpand#2\fi + \noexpand\LTS@tempa + }% + \ifboolTF{LTS@cl}\endgroup{% + \ifboolTF{LTS@pl}{% + \expandafter\postgroupdef\csname#2\endcsname\endgroup + }{% + \postgroupdef#2\endgroup + }% + }% +} +\robust@def*\ltsfiltermergecsva#1{% + \begingroup + \let\LTS@parse\csv@@parse + \LTS@sttrue + \LTS@ifstringcase{#1}% + {fff}{\LTS@stfalse\LTS@plfalse\LTS@clfalse}% + {tff}{\LTS@sttrue\LTS@plfalse\LTS@clfalse}% + {ttf}{\LTS@sttrue\LTS@pltrue\LTS@clfalse}% + {ttt}{\LTS@sttrue\LTS@pltrue\LTS@cltrue}% + {ftt}{\LTS@stfalse\LTS@pltrue\LTS@cltrue}% + {fft}{\LTS@stfalse\LTS@plfalse\LTS@cltrue}% + {tft}{\LTS@sttrue\LTS@plfalse\LTS@cltrue}:% + [\LTS@err{No match for \string\ltsfiltermergecsva}\@ehc]% + \LTS@filtermergelists +} +\robust@def*\oneelementfiltermerge{% + \LTS@teststcl{\LTS@testopt\LTS@oneelemfiltermerge,}% +} +\robust@def*\LTS@oneelemfiltermerge[#1]#2#3#4{% + \begingroup + \cpt@stchoose{LTS@st}{#3}\LTS@tempa\oneelementfiltermerge + \cptdeclarefilter{#4}% + \despacecontent\LTS@tempa + \cpt@usefilter\LTS@tempa\LTS@tempb + \ifdefTF#2{}{\def#2{}}% + \oifinset@sp@TF#1\LTS@tempb#2{}{% + \ifLTS@cl\global\fi + \edef#2{\csliststack#1#2\expandcsonce\LTS@tempb}% + }% + \postgroupdef#2\endgroup +} +\robust@def*\ltsfiltermergetsv{\LTS@testcl\LTS@filtermergetokens} +\robust@def*\LTS@filtermergetokens#1#2#3{% + \ifblankTF{#1}{% + \LTS@err{Invalid blank first argument of + \string\ltsfiltermergetsv}\@ehc + }{% + \if\detokenize{#1[}% + \LTS@err{Command \noexpand\ltsfiltermergetsv expects + no parser}\@ehc + \fi + }% + \begingroup + \let\ifLTS@mergecl\ifLTS@cl + \cptdeclarefilter{#3}% + \ifdefTF{#1}{}{\def#1{}}% + \def\tsv@do##1{% + \def\LTS@tempa{##1}% + \cpt@swatrue + \cpt@usefilter\LTS@tempa\LTS@tempb + \def\tsv@do####1{% + \def\LTS@tempc{####1}% + \cpt@usefilter\LTS@tempc\LTS@tempd + \ifx\LTS@tempb\LTS@tempd + \cpt@swafalse + \edef#1{\expandcsonce#1\expandcsonce\LTS@tempa}% + \else + \edef#1{\expandcsonce#1\expandcsonce\LTS@tempc}% + \fi + }% + \cptexpandargonce{\def#1{}\tsv@@parse}{#1}% + \ifcpt@swa + \edef#1{\expandcsonce#1\expandcsonce\LTS@tempa}% + \fi + }% + \ifblankTF{#2}{}{% + \ifcsnullTF#1{% + \edef#1{\unexpanded{#2}}% + }{% + \tsv@@parse{#2}% + }% + }% + \ifLTS@mergecl + \globalize#1\endgroup + \else + \cptpassacross#1\endgroup + \fi +} +\robust@def*\ltsfilterremovecsv{% + \begingroup + \let\LTS@parse\csv@@parse + \cpt@checkoptprefix + {\LTS@teststplcl{\LTS@testopt\LTS@filterremoveelements{,}}}% +} +\robust@def*\ltsfilterremovekv{% + \begingroup + \let\LTS@parse\kv@@parse + \cpt@checkoptprefix + {\LTS@teststplcl{\LTS@testopt\LTS@filterremoveelements{,}}}% +} +\robust@def*\LTS@filterremoveelements[#1]#2#3#4{% + \cpt@checklistparser{#1}\relax + \begingroup + \edef\temp@do + {\noexpandcsn{\ifxTF\LTS@parse\csv@@parse{csv}{kv}@do}}% + \letcstocsn\LTS@normalize + {cpt@\ifxTF\LTS@parse\csv@@parse{csv}{kv}normalize}% + \ifLTS@pl + \ifcsndefTF{#2}{}{\cptemptifycsn{#2}}% + \letcstocsn\LTS@tempa{#2}% + \else + \ifdefTF{#2}{}{\def#2{}}% + \let\LTS@tempa#2% + \fi + \cpt@stchoose{LTS@st}{#3}\LTS@tempb\LTS@filterremoveelements + \ifcsnullTF\LTS@tempb{} + {\cpt@sttrue\LTS@normalize[#1]\LTS@tempb}% + \cptdeclarefilter{#4}% + \def\LTS@tempd{}% + \expandafter\def\temp@do##1{% + \edef\LTS@tempa{\unexpanded{##1}}% + \cpt@usefilter\LTS@tempa\LTS@tempc + \oifinset@sp@TF#1\LTS@tempc\LTS@tempb{}{% + \edef\LTS@tempd{\csliststack#1\LTS@tempd\unexpanded{##1}}% + }% + }% + \ifcsnullTF\LTS@tempa{}{\LTS@parse*[#1]\LTS@tempa}% + \cptpassexpanded{% + \ifLTS@cl\global\fi + \let\ifLTS@pl\cptmakecs{#2}\else\noexpand#2\fi + \noexpand\LTS@tempd + }% + \ifboolTF{LTS@cl}\endgroup{\postgroupdef#2\endgroup}% +} +\robust@def*\ltspurgeelements{% + \LTS@testst{% + \let\ifLTS@purgest\ifLTS@st + \begingroup + \@makeother{\#}% + \LTS@testopt{\expandafter\endgroup\LTS@p@rgeelements}{,}% + }% +} +\robust@def*\LTS@purgeelements{% + \LTS@err{Use \noexpand\ltspurgeelements instead}\@ehc +} +\robust@def*\LTS@p@rgeelements[#1]#2#3{% + \cpt@checklistparser{#1}\relax + \begingroup + \def\csv@do##1{% + \ifblankTF{##1}{}{% + \def\LTS@tempb####1#1##1#1####2\LTS@nil{####1#1####2\purge@nil}% + \def\LTS@tempc####1#1\purge@nil####2\purge@nil{% + \ifx#1####1\@empty\else####1\fi + }% + \def\LTS@tempa{% + \cptthreexp\LTS@tempc\expandafter\LTS@tempb\expandafter + #1\detokenize\expandafter{#3}#1\purge@nil#1##1#1\LTS@nil + }% + \expandafter\edef\expandafter#3\expandafter{\LTS@tempa}% + }% + }% + \ifblankTF{#2}{}{\cptexpandarg{\csv@@loop[#1]}{\detokenize{#2}}}% + \postgroupdef#3\endgroup + \LTS@remparser[#1]#3% + \ifboolTF{LTS@purgest}{}{\LTS@scantoks@hash#3}% + \undefcs\ifLTS@purgest +} +\robust@def*\ltsfilterdeletetokens{\LTS@teststcl\LTS@deletetokens} +\robust@def*\LTS@deletetokens#1#2#3{% + \let\ifLTS@fdelcl\ifLTS@cl + \begingroup + \cptdeclarefilter{#3}% + \def\siso@do##1{% + \edef\LTS@tempa{\unexpanded{##1}}% + \cpt@usefilter\LTS@tempa\LTS@tempc + \edef\LTS@tempa{\expandcsonce\LTS@tempc}% + \cptexpandsecond{% + \def\LTS@tempb####1}{\expandcsonce\LTS@tempa}####2####3\LTS@nil{% + \edef\LTS@tempb{\unexpanded{####2}}% + \ifxTF\LTS@nnil\LTS@tempb{}{% + \cptexpandsecond{\def\LTS@tempb########1}{% + \expandcsonce\LTS@tempa}########2\LTS@nil{% + \edef#1{\unexpanded{########1########2}}% + }% + \expandafter\LTS@tempb#1\LTS@nil + }% + }% + \cptexpandsecond\LTS@tempb + {\expandcsonce#1\expandcsonce\LTS@tempa}{\LTS@nil}\LTS@nil + }% + \ifboolTF{LTS@st}{% + \expandafter\siso@@loop\expandafter{#2}% + }{% + \siso@@loop{#2}% + }% + \postgroupdef#1\endgroup + \ifLTS@fdelcl\globalize#1\fi + \undefcs\ifLTS@fdelcl +} +\robust@def*\simpledeletetokens#1#2{% + \def\siso@do##1{% + \def\LTS@tempa####1##1####2####3\LTS@nil{% + \edef\LTS@tempa{\unexpanded{####2}}% + \ifx\LTS@nnil\LTS@tempa\else + \def\LTS@tempa########1##1########2\LTS@nil{% + \edef#1{\unexpanded{########1########2}}% + }% + \expandafter\LTS@tempa#1\LTS@nil + \fi + }% + \expandafter\LTS@tempa#1##1{\LTS@nil}\LTS@nil + }% + \expandafter\siso@@loop\expandafter{#2}% +} +\robust@def*\DeclareVerbatimDelimiter#1{% + \ifsingletokenFT{#1}{% + \LTS@err{Verbatim delimiter isn't a single token}\@ehc + }{% + \def\LTS@v@rbatimstore##1#1##2#1{% + \endgroup + \LTS@v@rb@timstore{##2}% + }% + }% +} +\robust@def*\LTS@v@rb@timst@re{% + \begingroup + \@sanitize\obeyspaces + \LTS@v@rbatimstore +} +\robust@def*\verbatimstore#1{% + \long\def\LTS@v@rb@timstore##1{\def#1{##1}}% + \LTS@v@rb@timst@re +} +\robust@def*\ltsretokenize{\LTS@testst\LTS@retokenize} +\robust@def\LTS@retokenize#1#2{% + \begingroup + \edef\LTS@tempa{\unexpanded{#2}}% + \ifLTS@st + \def\LTS@ret@kenize##1\LTS@nil{\protected@edef#1{##1}}% + \else + \def\LTS@ret@kenize##1\LTS@nil{\edef#1{\unexpanded{##1}}}% + \fi + \cpteveryscan + \everyeof{\LTS@nil}% + \expandafter\LTS@ret@kenize\scantokens\expandafter{\LTS@tempa}% + \relax\postgroupdef#1\endgroup +} +\robust@def*\LTS@scantoksa#1{% + \begingroup + \edef#1{\long\def\string#1{\detokenize\expandafter{#1}}}% + \cpteveryscan + \scantokens\expandafter{#1}\relax + \postgroupdef#1\endgroup +} +\robust@def*\LTS@scantoks@hash#1{% + \begingroup + \edef#1{\long\def\string#1{\detokenize\expandafter{#1}}}% + \catcode`\#=6\relax\cpteveryscan + \scantokens\expandafter{#1}\relax + \postgroupdef#1\endgroup +} +\robust@def*\LTS@scantoksb#1{% + \begingroup + \def\siso@do##1{\catcode`##1\string=12\relax}% + \siso@@loop{=,;|-+?><}% + \LTS@scantoksa#1% + \postgroupdef#1\endgroup +} +\robust@def*\LTS@scantoksc{\LTS@testplcl\LTS@sc@ntoksc} +\robust@def\LTS@sc@ntoksc#1{% + \cptdocommalist{#1}{% + \ifboolTF{LTS@pl}{% + \expandafter\ltsensuremacro\csname ##1\endcsname + \letcstocsn\reserved@e{##1}% + }{% + \ltsensuremacro{##1}% + \let\reserved@e##1% + }% + \LTS@scantoksa\reserved@e + \cptpassexpanded{% + \ifLTS@cl\global\fi\let\ifLTS@pl + \cptmakecs{##1}\else\unexpanded{##1}\fi + \noexpand\reserved@e + }% + }% +} +\robust@def*\LTS@scantoksd#1#2{% + \cptexpandsecond{#1\cpteveryscan\scantokens}{% + {#2}% + \everyeof{\the\everyeof}% + \noexpand\endlinechar\the\endlinechar\relax + \catcode`\noexpand\@=\the\catcode`\@\relax + \catcode`\noexpand\ =\the\catcode`\ \relax + \catcode`\noexpand\\=\the\catcode`\\\relax + \catcode`\noexpand\{=\the\catcode`\{\relax + \catcode`\noexpand\}=\the\catcode`\}\relax + }% +} +\providecommand*\newbool{\ltsnewbool} +\providecommand*\setbool{\ltssetbool} +\providecommand*\booltrue{\ltsbooltrue} +\providecommand*\boolfalse{\ltsboolfalse} +\providecommand*\setbooltrue{\ltssetbooltrue} +\providecommand*\setboolfalse{\ltssetboolfalse} +\robust@def*\ltsnewbool#1{\cpt@swatrue\LTS@testopt{\LTS@newbool{#1}}{false}} +\robust@def*\defbool#1{\cpt@swafalse\LTS@testopt{\LTS@newbool{#1}}{false}} +\new@def*\LTS@newbool#1[#2]{% + \ifinsetFT{,}{#1}{}{% + \begingroup + \edef\LTS@tempa{\ifcpt@swa'\string\ltsnewbool' + \else'\string\ltsdefbool'\fi}% + \edef\LTS@tempb{\ifcpt@swa'\string\NewBooleans' + \else'\string\DefBooleans'\fi}% + \LTS@err{Command \LTS@tempa\@space doesn't accept list}% + {Please submit only one boolean to \LTS@tempa\MsgBrk + at a time. You may consider using\LTS@tempb\MsgBrk + if you really want to define a set of booleans.}% + \endgroup + }% + \ltsensurenoscape{#1}% + \LTS@badboolname{#1}% + \ifboolTF{cpt@swa}{% + \ifcsndefinable{if#1}\relax + \LTS@getboolstate\ltsnewbool{#2}% + }{% + \ifcsndefFT{if#1}{}{% + \LTS@verbosewarn{Boolean '\@backslashchar if#1' redefined}% + }% + \LTS@getboolstate\ltsdefbool{#2}% + }% + \csnnewif{#1}% + \usename{#1\LTS@boolval}% +} +\robust@def*\NewBooleans{\cpt@swatrue\LTS@testopt\LTS@NewBooleans{}} +\robust@def*\DefBooleans{\cpt@swafalse\LTS@testopt\LTS@NewBooleans{}} +\robust@def*\LTS@NewBooleans[#1]#2{% + \LTS@testopt{\LTS@B@oleans{#1}{#2}}{false}% +} +\new@def*\LTS@B@oleans#1#2[#3]{% + \cptexpandsecond\LTS@getboolstate + {\ifboolTF{cpt@swa}\NewBooleans\DefBooleans}{#3}% + \cptdocommalist{#2}{% + \ltsensurenoscape{##1}% + \LTS@badboolname{#1##1}% + \ifboolTF{cpt@swa}{% + \ifcsndefinable{if#1##1}\relax + }{% + \ifcsndefFT{if#1##1}{}{% + \LTS@verbosewarn{Boolean '\@backslashchar if#1##1' + redefined}% + }% + }% + \csnnewif{#1##1}% + \usename{#1##1\LTS@boolval}% + }% +} +\robust@def*\ltssetbool#1#2{% + \ifcsndefFT{if#1}{% + \LTS@noboolerr{#1}% + }{% + \LTS@getboolstate\ltssetbool{#2}% + \csname#1\LTS@boolval\endcsname + }% +} +\robust@def*\ltssetbooltrue#1{% + \ifcsndefFT{if#1}{\LTS@noboolerr{#1}}{\usename{#1true}}% +} +\newletcs\ltsbooltrue\ltssetbooltrue +\robust@def*\ltssetboolfalse#1{% + \ifcsndefFT{if#1}{\LTS@noboolerr{#1}}{\usename{#1false}}% +} +\newletcs\ltsboolfalse\ltssetboolfalse +\robust@def*\LTS@noboolerr#1{% + \LTS@err{Boolean/switch '\string#1' is undefined}% + {You need to first define the boolean/switch '\string#1'.}% +} +\robust@def*\LTS@boolnameerr#1{% + \LTS@err{'\string\if#1' not valid as a boolean/switch}% + {Invalid boolean/switch name '\string#1'.}% +} +\new@def*\LTS@boolvalerr#1#2{% + \LTS@err{Invalid boolean/switch value '#2' in \string#1}% + {Valid boolean/switch values are \LTS@validboolvalues.}% +} +\new@def*\LTS@validboolvalues{true,false} +\robust@def*\AddValidBooleanValues#1{% + \ltsfiltermergecsv![,]\LTS@validboolvalues{#1}\nofilter +} +\robust@def*\RemoveValidBooleanValues#1{% + \ltsfilterremovecsv!\LTS@validboolvalues{#1}\nofilter +} +\robust@def*\LTS@getboolstate#1#2{% + \lowercase{% + \edef\LTS@boolval{\cpttrimspaces{#2}}% + }% + \xifinsetTF{,\LTS@boolval,}{,\LTS@validboolvalues,}{}{% + \LTS@boolvalerr{#1}{#2}% + }% +} +\robust@def*\LTS@badboolname#1{% + \begingroup + \xifstrcmpTF{\expandafter\LTS@cartwo\string#1xx\car@nil}{if}{% + \LTS@boolnameerr{if}% + }{% + \edef\LTS@tempa{\s@expandarg\cpttrimspaces{\cptrm-`\q#1}}% + \cptexpandsecondonce{\def\reserved@a##1,}\LTS@tempa,##2\LTS@nil{% + \ifblankTF{##2}{}{\s@expandarg\LTS@boolnameerr\LTS@tempa}% + }% + \reserved@a ,x,on,off,tog,bool,switch,#1,\LTS@nil + }% + \endgroup +} +\providecommand*\newswitch[1]{\cpt@swatrue\LTS@testopt{\LTS@newswitch#1}{false}} +\robust@def*\defswitch#1{\cpt@swafalse\LTS@testopt{\LTS@newswitch#1}{false}} +\robust@def*\LTS@newswitch#1[#2]{% + \ifinsetFT{,}{#1}{}{% + \begingroup + \edef\LTS@tempa{\ifcpt@swa'\string\newswitch' + \else'\string\defswitch'\fi}% + \edef\LTS@tempb{\ifcpt@swa'\string\NewSwitches' + \else'\string\DefSwitches'\fi}% + \LTS@err{Command \LTS@tempa\@space doesn't accept list}% + {Please submit only one switch to \LTS@tempa\MsgBrk + at a time. You may consider using\LTS@tempb\MsgBrk + if you really want to define a set of switches.}% + \endgroup + }% + \ltsensurenoscape{#1}% + \LTS@badboolname{#1}% + \ifboolTF{cpt@swa}{% + \ifcsndefinable{#1}\relax + \LTS@getboolstate\newswitch{#2}% + }{% + \ifcsndefFT{#1}{}{% + \LTS@verbosewarn{Switch '\@backslashchar#1' redefined}% + }% + \LTS@getboolstate\defswitch{#2}% + }% + \letcsntocsn{#1}{cpt\LTS@boolval}% +} +\robust@def*\makenewswitches{\LTS@testopt\LTS@makenewswitch{}} +\newletcs\makenewswitch\makenewswitches +\robust@def*\LTS@makenewswitch[#1]#2{% + \LTS@testopt{\LTS@m@kenewswitch{#1}{#2}}{false}% +} +\def\LTS@m@kenewswitch#1#2[#3]{% + \LTS@getboolstate\makenewswitches{#3}% + \cptdocommalist{#2}{% + \ifcsndefTF{ifsw#1##1}{% + \LTS@err{Switch '#1##1' already exists}\@ehc + }{% + \csn@edef{ifsw#1##1}{% + \noexpand\if\s@expandarg\ifstrcmpTF\LTS@boolval{true}{00}{01}% + }% + \csn@def{sw#1##1true}{\csn@def{ifsw#1##1}{\if00}}% + \csn@def{sw#1##1false}{\csn@def{ifsw#1##1}{\if01}}% + }% + }% +} +\robust@def*\NewSwitches{\cpt@swatrue\LTS@testopt\LTS@NewSwitches{}} +\robust@def*\DefSwitches{\cpt@swafalse\LTS@testopt\LTS@NewSwitches{}} +\robust@def*\LTS@NewSwitches[#1]#2{% + \LTS@testopt{\LTS@Sw@tches{#1}{#2}}{false}% +} +\new@def*\LTS@Sw@tches#1#2[#3]{% + \cptexpandsecond\LTS@getboolstate + {\ifboolTF{cpt@swa}\NewSwitches\DefSwitches}{#3}% + \cptdocommalist{#2}{% + \ltsensurenoscape{##1}% + \LTS@badboolname{#1##1}% + \ifboolTF{cpt@swa}{% + \ifcsndefinable{#1##1}\relax + }{% + \ifcsndefFT{#1##1}{}{% + \LTS@verbosewarn{Switch '\@backslashchar#1##1' redefined}% + }% + }% + \letcsntocsn{#1##1}{cptsw\LTS@boolval}% + }% +} +\robust@def*\NewTogs{\cpt@swatrue\LTS@testopt\LTS@NewTogs{}} +\robust@def*\DefTogs{\cpt@swafalse\LTS@testopt\LTS@NewTogs{}} +\new@def*\LTS@NewTogs[#1]#2{\LTS@testopt{\LTS@NewT@gs[#1]{#2}}{false}} +\new@def*\LTS@NewT@gs[#1]#2[#3]{% + \cptexpandsecond\LTS@getboolstate + {\ifcpt@swa\NewTogs\else\DefTogs\fi}{#3}% + \cptdocommalist{#2}{% + \ltsensurenoscape{##1}% + \cptpassexpanded{\ifcpt@swa\newtog\else\deftog\fi}{#1##1}% + \usename{settog\LTS@boolval}{#1##1}% + }% +} +\robust@def*\NewToks{\cpt@swatrue\LTS@testopt\LTS@NewToks{}} +\robust@def*\DefToks{\cpt@swafalse\LTS@testopt\LTS@NewToks{}} +\new@def*\LTS@NewToks[#1]#2{% + \cptdocommalist{#2}{% + \ltsensurenoscape{##1}% + \ifboolTF{cpt@swa}{% + \ifcsndefinable{#1##1}\relax + }{% + \ifcsndefFT{#1##1}{}{% + \LTS@verbosewarn{Token register '\@backslashchar + #1##1' redefined}% + }% + }% + \csnnewtoks{#1##1}% + }% +} +\robust@def*\NewCounts{\cpt@swatrue\LTS@testopt\LTS@NewCounts{}} +\robust@def*\DefCounts{\cpt@swafalse\LTS@testopt\LTS@NewCounts{}} +\new@def*\LTS@NewCounts[#1]#2{\LTS@testopt{\LTS@N@wCounts[#1]#2}{}} +\new@def*\LTS@N@wCounts[#1]#2[#3]{% + \cptdocommalist{#2}{% + \ltsensurenoscape{##1}% + \ifboolTF{cpt@swa}{% + \ifcsndefinable{#1##1#3}\relax + }{% + \ifcsndefFT{#1##1#3}{}{% + \LTS@verbosewarn{Counter register '\@backslashchar + #1##1#3' redefined}% + }% + }% + \csnnewcount{#1##1#3}% + }% +} +\robust@def*\NewCounters{\cpt@swatrue\LTS@testopt\LTS@NewCounters{}} +\robust@def*\DefCounters{\cpt@swafalse\LTS@testopt\LTS@NewCounters{}} +\new@def*\LTS@NewCounters[#1]#2{\LTS@testopt{\LTS@N@wCounters[#1]#2}{}} +\new@def*\LTS@N@wCounters[#1]#2[#3]{% + \cptdocommalist{#2}{% + \ltsensurenoscape{##1}% + \ifboolTF{cpt@swa}{% + \ifcsndefinable{#1##1#3}\relax + }{% + \ifcsndefFT{#1##1#3}{}{% + \LTS@verbosewarn{Counter register '\@backslashchar + #1##1#3' redefined}% + }% + }% + \@definecounter{#1##1#3}% + }% +} +\newletcs\NewNumbers\NewCounters +\robust@def*\NewDimens{\cpt@swatrue\LTS@testopt\LTS@NewDimens{}} +\robust@def*\DefDimens{\cpt@swafalse\LTS@testopt\LTS@NewDimens{}} +\new@def*\LTS@NewDimens[#1]#2{% + \cptdocommalist{#2}{% + \ltsensurenoscape{##1}% + \ifboolTF{cpt@swa}{% + \ifcsndefinable{#1##1}\relax + }{% + \ifcsndefFT{#1##1}{}{% + \LTS@verbosewarn{Dimension register '\@backslashchar + #1##1' redefined}% + }% + }% + \csnnewdimen{#1##1}% + }% +} +\robust@def*\NewBoxes{\cpt@swatrue\LTS@testopt\LTS@NewBoxes{}} +\robust@def*\DefBoxes{\cpt@swafalse\LTS@testopt\LTS@NewBoxes{}} +\new@def*\LTS@NewBoxes[#1]#2{% + \cptdocommalist{#2}{% + \ltsensurenoscape{##1}% + \ifboolTF{cpt@swa}{% + \ifcsndefinable{#1##1}\relax + }{% + \ifcsndefFT{#1##1}{}{% + \LTS@verbosewarn{Box register '\@backslashchar + #1##1' redefined}% + }% + }% + \csnnewbox{#1##1}% + }% +} +\robust@def*\NewSkips{\cpt@swatrue\LTS@testopt\LTS@NewSkips{}} +\robust@def*\DefSkips{\cpt@swafalse\LTS@testopt\LTS@NewSkips{}} +\new@def*\LTS@NewSkips[#1]#2{% + \cptdocommalist{#2}{% + \ltsensurenoscape{##1}% + \ifboolTF{cpt@swa}{% + \ifcsndefinable{#1##1}\relax + }{% + \ifcsndefFT{#1##1}{}{% + \LTS@verbosewarn{Skip register '\@backslashchar + #1##1' redefined}% + }% + }% + \csnnewskip{#1##1}% + }% +} +\newletcs\NewLengths\NewSkips +\newletcs\DefLengths\DefSkips +\robust@def*\NewMuskips{\cpt@swatrue\LTS@testopt\LTS@NewMuskips{}} +\robust@def*\DefMuskips{\cpt@swafalse\LTS@testopt\LTS@NewMuskips{}} +\new@def*\LTS@NewMuskips[#1]#2{% + \cptdocommalist{#2}{% + \ltsensurenoscape{##1}% + \ifboolTF{cpt@swa}{% + \ifcsndefinable{#1##1}\relax + }{% + \ifcsndefFT{#1##1}{}{% + \LTS@verbosewarn{\noexpand\muskip register '\@backslashchar + #1##1' redefined}% + }% + }% + \csnnewmuskip{#1##1}% + }% +} +\robust@def*\NewWrites{\cpt@swatrue\LTS@testopt\LTS@NewWrites{}} +\robust@def*\DefWrites{\cpt@swafalse\LTS@testopt\LTS@NewWrites{}} +\new@def*\LTS@NewWrites[#1]#2{% + \cptdocommalist{#2}{% + \ltsensurenoscape{##1}% + \ifboolTF{cpt@swa}{% + \ifcsndefinable{#1##1}\relax + }{% + \ifcsndefFT{#1##1}{}{% + \LTS@verbosewarn{Write stream '\@backslashchar + #1##1' redefined}% + }% + }% + \csnnewwrite{#1##1}% + }% +} +\robust@def*\NewReads{\cpt@swatrue\LTS@testopt\LTS@NewReads{}} +\robust@def*\DefReads{\cpt@swafalse\LTS@testopt\LTS@NewReads{}} +\new@def*\LTS@NewReads[#1]#2{% + \cptdocommalist{#2}{% + \ltsensurenoscape{##1}% + \ifboolTF{cpt@swa}{% + \ifcsndefinable{#1##1}\relax + }{% + \ifcsndefFT{#1##1}{}{% + \LTS@verbosewarn{Read stream '\@backslashchar + #1##1' redefined}% + }% + }% + \csnnewread{#1##1}% + }% +} +\robust@def*\checknewcommands{% + \cpt@checkoptprefix{\LTS@teststpl\LTS@checknewcmds}% +} +\new@def*\LTS@checknewcmds#1{% + \begingroup + \edef\LTS@tempa{\ifLTS@st*\fi}% + \def\csv@do##1{% + \usename{ifcs\ifLTS@pl n\fi definable}{##1}\relax + }% + \expandafter\csv@@parse\LTS@tempa[,]{#1}% + \endgroup +} +\new@def*\LTS@post@prefixerr#1{% + \LTS@err{Bad prefixes for command '\string#1'} + {You have wrongly prefixed command '\string#1'\MsgBrk + with both star sign and exclamation mark.\MsgBrk + You have to choose one of them. The star expands\MsgBrk + the arguments once, while the exclamation mark\MsgBrk + expands the arguments fully.}% +} +\robust@def*\postgroup{\LTS@teststcl\LTS@postgroup} +\new@def\LTS@postgroup#1{% + \ifLTS@st + \ifLTS@cl + \LTS@post@prefixerr\postgroup + \else + \edef\LTS@tempa{\unexpanded{#1}}% + \expandallonce\LTS@tempa + \fi + \else + \ifLTS@cl + \if\detokenize{#1*}% + \LTS@post@prefixerr\postgroup + \fi + \let\next\@firstofone + \else + \let\next\unexpanded + \fi + \fi + \advance\@tempcnta\@ne + \csn@xdef{LTS@aft@rgroup@\romannumeral\@tempcnta}{% + \gundefcsn{LTS@aft@rgroup@\romannumeral\@tempcnta}% + \ifboolTF{LTS@st}{\@firstofone\LTS@tempa\@gobble}\next{#1}% + }% + \csnaftergroup{LTS@aft@rgroup@\romannumeral\@tempcnta}% +} +\robust@def*\minorpostgroup{\LTS@testst\LTS@minorpostgroup} +\new@def\LTS@minorpostgroup#1{% + \advance\@tempcnta\@ne + \csn@xdef{LTS@aft@rgroup@\romannumeral\@tempcnta}{% + \gundefcsn{LTS@aft@rgroup@\romannumeral\@tempcnta}% + \ifboolTF{LTS@st}\@firstofone\unexpanded{#1}% + }% + \csnaftergroup{LTS@aft@rgroup@\romannumeral\@tempcnta}% +} +\robust@def*\postassignment{\LTS@teststcl\LTS@postassignment} +\robust@def\LTS@postassignment#1{% + \begingroup + \ifboolTF{LTS@st}{% + \ifboolTF{LTS@cl}{% + \LTS@post@prefixerr\postassignment + }{% + \edef\LTS@tempa{\unexpanded{#1}}% + \expandallonce\LTS@tempa + }% + }{% + \ifboolTF{LTS@cl}{% + \if\detokenize{#1*}% + \LTS@post@prefixerr\postassignment + \fi + \let\next\@firstofone + }{% + \let\next\unexpanded + }% + }% + \advance\@tempcnta\@ne + \csn@xdef{LTS@p@stassignment@\romannumeral\@tempcnta}{% + \gundefcsn{LTS@p@stassignment@\romannumeral\@tempcnta}% + \ifboolTF{LTS@st}{\@firstofone\LTS@tempa\@gobble}\next{#1}% + }% + \aftercsname{\endgroup\afterassignment} + {LTS@p@stassignment@\romannumeral\@tempcnta}% +} +\robust@def*\minorpostassignment{\LTS@testst\LTS@minorpostassignment} +\robust@def\LTS@minorpostassignment#1{% + \begingroup + \advance\@tempcnta\@ne + \csn@xdef{LTS@p@stassignment@\romannumeral\@tempcnta}{% + \gundefcsn{LTS@p@stassignment@\romannumeral\@tempcnta}% + \ifdefboolTF{LTS@st}\@iden\unexpanded{#1}% + }% + \aftercsname{\endgroup\afterassignment} + {LTS@p@stassignment@\romannumeral\@tempcnta}% +} +\robust@def*\LTS@undef{\LTS@testcl\LTS@und@f} +\new@def*\LTS@und@f#1{% + \LTS@global@or@relax + \cptfor#1\dofor{% + \ifsingletoken@sp@TF{##1}{% + \ltsensurescape{##1}% + \glob@lrel@x\undefcs##1% + }{% + \cpt@notonetokenerr{##1}% + }% + }% +} +\newletcs\undefcslist\undefcsset +\robust@def*\ltsundefcslist{% + \cpt@checkoptprefix{\LTS@teststplcl{\cpt@testopt\LTS@undefcslist{,}}}% +} +\new@def*\LTS@undefcslist[#1]#2{% + \LTS@global@or@relax + \edef\reserved@a{\ifLTS@st*\fi}% + \def\csv@do##1{% + \ifLTS@pl + \glob@lrel@x\undefcsn{##1}% + \else + \glob@lrel@x\undefcs##1% + \fi + }% + \expandafter\csv@@parse\reserved@a[#1]{#2}% +} +\robust@def*\declarepackagecmd{\LTS@testopt\LTS@declarepkgcmd{}} +\new@def\LTS@declarepkgcmd[#1]#2{% + \ltsensurescape{#2}% + \ifdefTF#2{% + \letcsntocs{Saved\cptremovescape#2}#2% + \cptpassexpanded{% + \AtTagEndPackage{% + \let\noexpand#2\noexpandcsn{Saved\cptremovescape#2}% + \gundefcs\noexpandcsn{Saved\cptremovescape#2}% + }% + }% + }{% + \AtTagEndPackage{\gundefcs#2}% + }% + #1\def#2% +} +\robust@def*\declaredocumentcmd{\LTS@testopt\LTS@declaredoccmd{}} +\new@def\LTS@declaredoccmd[#1]#2{% + \ltsensurescape{#2}% + \ifcsdefinable#2\relax + \ifinstylefileTF{% + \cptpassexpanded{% + \ltsAtBeginDocument{% + \let\noexpand#2\noexpandcsn{Saved\cptremovescape#2}% + \gundefcs\noexpandcsn{Saved\cptremovescape#2}% + }% + }% + \postassignment{% + \letcsntocs{Saved\cptremovescape#2}#2% + \gundefcs#2% + }% + }{}% + #1\def#2% +} +\robust@def*\LTS@providedef{\LTS@teststcl{\LTS@pr@videdef\relax}} +\robust@def*\LTS@providerobustdef{\LTS@teststcl{\LTS@pr@videdef\protected}} +\new@def\LTS@pr@videdef#1#2{% + \LTS@long@or@relax\LTS@global@or@relax + \ltsensurescape{#2}% + \ifdefTF#2{% + \LTS@verboseinfo{Command '\string#2' already defined: + \MsgBrk Not redefined}% + \minorpostassignment{\gundefcs\pr@v@de}% + }{% + \minorpostassignment{% + \gletcs#2\pr@v@de + \gletcsntocs{LTS@test@\cptremovescape#2}#2% + \gundefcs\pr@v@de + }% + }% + \glob@lrel@x\l@ngrel@x#1\def\pr@v@de +} +\new@def\testprovidedcommand#1{% + \ltsensurescape{#1}% + \begingroup + \ifmacroFT#1{% + \aftergroup\@secondoftwo + }{% + \csnaftergroup{LTS@\cptthreexp + \ifxTF\usename{LTS@test@\cptremovescape#1}#112of2}% + }% + \endgroup +} +\robust@def*\LTS@reviewcommandhandler#1{% + \LTS@verboseinfo{% + Previously 'provided' definition of '\string#1'\MsgBrk + is retained. Your new definition was ignored\MsgBrk + }% +} +\robust@def*\reviewcommand{\LTS@testopt\LTS@revcommand{}} +\new@def\LTS@revcommand[#1]#2#3{% + \testprovidedcommand#2{% + \LTS@reviewcommandhandler{#2}% + }{% + #1\def#2{#3}% + }% +} +% #1: list of comma-separated command pairs: +\robust@def*\newprovidedcommands#1{% + \def\reserved@e##1##2\LTS@nil{% + \ifdefTF{##2}{% + \LTS@providerobustdef*##1{##2}% + }{% + \cpt@notdeferr{##2}% + }% + }% + \def\csv@do##1{\reserved@e##1\LTS@nil}% + \csv@@parse[,]{#1}% +} +\new@def*\ifrelaxTF#1{% + \ifdefinedTF{#1}% + {\usename{LTS@\expandafter\ifxTF\cpt@car#1\car@nil + \relax12of2}}\@secondoftwo +} +\new@def*\ifcsnrelaxTF#1{% + \ifcsnameFT{#1}\@secondoftwo + {\usename{LTS@\aftercsname\expandafter\ifxTF\cpt@car#1\car@nil + \relax12of2}}% +} +\def\ifcsnrelaxFT#1{\usename{LTS@\ifcsnrelaxTF{#1}21of2}} +\new@def*\ifdefaxTFN#1{% + \ifdefinedTF{#1}% + {\usename{LTS@\expandafter\ifxTF\cpt@car#1\car@nil + \relax21of3}}\@thirdofthree +} +\new@def*\ifcsndefaxTFN#1{% + \ifcsnameTF{#1}% + {\usename{LTS@\expandafter\ifxTF\csname#1\endcsname + \relax21of3}}\@thirdofthree +} +\robust@def*\ifargifTF#1{% + \usename{LTS@\ifnum\pdfstrcmp + {\expandafter\LTS@carcube\string#1xxx\car@nil}% + {\string\if}=\z@pt1\else2\fi of2}% +} +\robust@def*\LTS@detokenize{\LTS@testst\LTS@det@kenize} +\robust@def*\LTS@det@kenize#1#2{% + \edef#2{\detokenize{#1}}% + \ifLTS@st + \simpleexpandarg\ifargifTF#2{% + \LTS@err{'\@backslashchar if' not valid}\@ehc + }{% + \LTS@scantoksa#2% + \edef#2{\cpttxdetok#2}% + }% + \fi +} +\new@def*\LTS@detokdespace{\LTS@testpl\LTS@det@kdespace} +\new@def\LTS@det@kdespace#1{% + \ifboolTF{LTS@pl}{% + \edef\LTS@resa{\detokenize{#1}}% + \despacecontent\LTS@resa + }{% + \ifdefTF{#1}{}{% + \LTS@err{Command '\string#1' is undefined}{Command + '\string\LTS@detokdespace' doesn't accept undefined + \MsgBrk commands when submitted without the '+' prefix.}% + }% + \ifargifTF{#1}{% + \LTS@err{Invalid argument '\string#1' for command\MsgBrk + '\string\LTS@detokdespace'}{Command '\string\LTS@detokdespace' + doesn't accept '\@backslashchar if'\MsgBrk when submitted + without the '+' prefix.}% + }{% + \edef#1{\cptoxdetok{#1}}% + \despacecontent#1% + }% + }% +} +\robust@def*\ifltxprotectTF#1{% + \begingroup + \ifmacroFT#1{% + \aftergroup\@secondoftwo + }{% + \edef\LTS@tempa##1{\def##1####1\string\protect####2&}% + \LTS@tempa\LTS@tempa{% + \csnaftergroup{LTS@\ifblankTF{##2}21of2}% + }% + \edef\LTS@tempb##1{##1\realmeaning#1\string\protect&}% + \LTS@tempb\LTS@tempa + }% + \endgroup +} +\robust@def*\ifltxprotectFT#1{% + \ifltxprotectTF{#1}\iiofii\iofii +} +\robust@def*\ifcsnltxprotectTF{\aftercsname\ifltxprotectTF} +\robust@def*\ifetexprotectedTF#1{% + \begingroup + \edef\LTS@tempa##1{\def##1####1\string\protected####2&}% + \LTS@tempa\LTS@tempa{% + \csnaftergroup{LTS@\ifblankTF{##2}21of2}% + }% + \edef\LTS@tempb##1{##1\meaning#1\string\protected&}% + \LTS@tempb\LTS@tempa + \endgroup +} +\robust@def*\ifetexprotectedFT#1{% + \ifetexprotectedTF{#1}\iiofii\iofii +} +\robust@def*\ifcsnprotectedTF{\aftercsname\ifetexprotectedTF} +\robust@def*\apptocs{% + \cpt@checkoptprefix{\LTS@teststplcl{\LTS@hooktomac{>}}}% +} +\robust@def*\preptocs{% + \cpt@checkoptprefix{\LTS@teststplcl{\LTS@hooktomac{<}}}% +} +\robust@def\LTS@hooktomac#1#2#3{% + \ifLTS@st\let\@expandb\expandcsonce\else\let\@expandb\unexpanded\fi + \cpt@getmacroprefix{#2}% + \ifLTS@pl + \let\@ifdef\ifcsndefFT\let\@expanda\expandcsnonce + \def\LTS@i##1{\def\@def####1{\aftercsname##1{####1}}}% + \else + \let\@ifdef\ifdefFT\let\@expanda\expandcsonce + \def\LTS@i##1{\def\@def####1{##1####1}}% + \fi + \ifLTS@cl\LTS@i\xdef\else\LTS@i\edef\fi + \@ifdef{#2}{% + \macroprefix\@def{#2}{\@expandb{#3}}% + }{% + \ifx#1>% + \macroprefix\@def{#2}{\@expanda{#2}\@expandb{#3}}% + \else + \macroprefix\@def{#2}{\@expandb{#3}\@expanda{#2}}% + \fi + }% + \LTS@undef!{\@ifdef,\@def,\@expanda,\@expandb,\LTS@i}% +} +\robust@def*\ltsuaddtolist{\chardef\LTS@addnr\z@pt\LTS@addtolist} +\robust@def*\ltsaddtolist{\chardef\LTS@addnr\@ne\LTS@addtolist} +\robust@def*\ltsxaddtolist{\chardef\LTS@addnr\tw@\LTS@addtolist} +\robust@def*\LTS@addtolist#1{% + \ifx#1*% + \LTS@err{Star (*) isn't valid as suffix to + \noexpand\ltsaddtolist or \string\ltslistadd}% + \fi + \LTS@testplcl{\LTS@testlt{\LTS@testopt\LTS@addt@list{,}}}% + #1% +} +\new@def*\LTS@addt@list[#1]{% + \edef\parser{\detokenize{#1}}% + \ifLTS@cl\let\@def\xdef\else\let\@def\edef\fi + \ifLTS@pl\expandafter\aftercsname\fi\LTS@addt@l@st +} +\robust@def\LTS@addt@l@st#1#2{% + \ifcase\LTS@addnr + \let\@expand\unexpanded + \or + \let\@expand\expandcsonce + \else + \let\@expand\@iden + \fi + \begingroup + \toks@{\endgroup + \ifdefFT{#1}{% + \@def#1{\@expand{#2}}% + }{% + \ifcsnullTF#1{% + \@def#1{\@expand{#2}}% + }{% + \ifboolTF{LTS@lt}{% + \@def#1{\@expand{#2}\parser\expandcsonce{#1}}% + }{% + \@def#1{\expandcsonce{#1}\parser\@expand{#2}}% + }% + }% + }% + }% + \usename{% + \ifnum\LTS@addnr=\z@pt\else\ifnum\LTS@addnr=\@ne o\else x\fi\fi + ifblankTF% + }{#2}{\ifcpt@useempty\the\toks@\else\endgroup\fi}{\the\toks@}% + \undefcs\@expand\undefcs\@def + \chardef\LTS@addnr\@ne +} +\robust@def*\ltslistadd#1{% + \LTS@plfalse\LTS@clfalse\LTS@ltfalse\chardef\LTS@addnr\z@pt + \LTS@addt@list[#1]% +} +\robust@def*\ltsolistadd#1{% + \LTS@plfalse\LTS@clfalse\LTS@ltfalse\chardef\LTS@addnr\@ne + \LTS@addt@list[#1]% +} +\robust@def*\ltsxlistadd#1{% + \LTS@plfalse\LTS@clfalse\LTS@ltfalse\chardef\LTS@addnr\tw@ + \LTS@addt@list[#1]% +} +\robust@def*\ltsaddtolistexpanded{% + \LTS@testcl{\LTS@testopt\LTS@addtolistexpanded{,}}% +} +\robust@def*\LTS@addtolistexpanded[#1]#2#3{% + \ifsingletokenTF{#2}{}{\cpt@notonetokenerr{#2}}% + \begingroup + \toks@{\endgroup + \ifdefTF#2{% + \usename{protected@\ifLTS@cl x\else e\fi def}% + #2{#2\ifcsnullTF{#2}{}{#1}#3}% + }{% + \usename{protected@\ifLTS@cl x\else e\fi def}#2{#3}% + }% + }% + \oifblankTF{#3}{\ifcpt@useempty\the\toks@\else\endgroup\fi} + {\the\toks@}% +} +\ifpkgcurrTF{atveryend}{2010/03/24}{}{% + \RequirePackage{atveryend}[2010/03/24]% +} +\robust@def*\LTS@notprerr{% + \LTS@err{You have issued a preamble command here}% + {Move shown command to document preamble.}% +} +\robust@def*\LTS@notenderr{% + \LTS@err{You've called an \noexpand\enddocument + command\MsgBrk at the wrong place}{% + Move command to before \string\enddocument. + }% +} +\robust@def*\ltsAtBeginDocument{\AtBeginDocument} +\robust@def*\ltsBeforeBeginDocument{% + \grightaddtocs\LTS@beforedocstart +} +\new@def*\LTS@beforedocstart{} +\leftaddtocs\document{% + \endgroup + \let\ltsBeforeBeginDocument\@firstofone + \LTS@beforedocstart + \let\ltsBeforeBeginDocument\LTS@notprerr + \gundefcs\LTS@beforedocstart + \begingroup +} +\robust@def*\ltsAfterBeginDocument{% + \grightaddtocs\LTS@afterdocstart +} +\new@def*\LTS@afterdocstart{} +\robust@def*\ltsAfterAfterBeginDocument{% + \grightaddtocs\LTS@afterafterdocstart +} +\new@def*\LTS@afterafterdocstart{} +\rightaddtocs\document{% + \let\ltsAfterBeginDocument\@firstofone + \LTS@afterdocstart + \let\ltsAfterBeginDocument\LTS@notprerr + \gundefcs\LTS@afterdocstart + \let\ltsAfterAfterBeginDocument\@firstofone + \LTS@afterafterdocstart + \let\ltsAfterAfterBeginDocument\LTS@notprerr + \gundefcs\LTS@afterafterdocstart + \ignorespaces +} +\ltsBeforeBeginDocument{\let\ltsAtBeginDocument\@firstofone} +\robust@def*\ltsAtEndDocument{\AtEndDocument} +\robust@def*\ltsBeforeLastPage{\grightaddtocs\LTS@beforelastpage} +\new@def*\LTS@beforelastpage{} +\ltsAtEndDocument{% + \let\LTS@bef@relastpage\AtVeryEnd@BeforeClearDocumentHook + \def\AtVeryEnd@BeforeClearDocumentHook{% + \let\ltsBeforeLastPage\@firstofone + \LTS@beforelastpage\LTS@bef@relastpage + \let\ltsBeforeLastPage\LTS@notenderr + \LTS@undef!{\LTS@beforelastpage,\LTS@bef@relastpage}% + }% +} +\robust@def*\ltsAfterLastPage{\grightaddtocs\LTS@afterlastpage} +\new@def*\LTS@afterlastpage{} +\ltsAtEndDocument{% + \let\LTS@afterl@stpage\AtVeryEnd@AfterLastShipoutHook + \def\AtVeryEnd@AfterLastShipoutHook{% + \let\ltsAfterLastPage\@firstofone + \LTS@afterlastpage\LTS@afterl@stpage + \let\ltsAfterLastPage\LTS@notenderr + \LTS@undef!{\LTS@afterlastpage,\LTS@afterl@stpage}% + }% +} +\robust@def*\ltsAfterEndDocument{\grightaddtocs\LTS@afterenddoc} +\new@def*\LTS@afterenddoc{} +\AtEndOfPackage{\newletcs\AtTagEndOfDocument\ltsAfterEndDocument} +\ltsAtEndDocument{% + \let\LTS@aft@renddoc\AtVeryEnd@AtVeryEndDocumentHook + \def\AtVeryEnd@AtVeryEndDocumentHook{% + \let\ltsAfterEndDocument\@firstofone + \LTS@afterenddoc\LTS@aft@renddoc + \let\ltsAfterEndDocument\LTS@notenderr + \LTS@undef!{\LTS@afterenddoc,\LTS@aft@renddoc}% + }% +} +\robust@def*\ltsAtEndPackage{\AtEndOfPackage} +\robust@def*\ltsBeforeEndPackage{% + \gleftaddtocsn{\@currname.\@currext-h@@k}% +} +\robust@def*\ltsAfterEndPackage{% + \grightaddtocsn{\@currname.\@currext-LTS@hook}% +} +\let\ltsAtEndClass\ltsAtEndPackage +\let\ltsBeforeEndClass\ltsBeforeEndPackage +\let\ltsAfterEndClass\ltsAfterEndPackage +\leftaddtocs\@popfilename{% + \usename{\@currname.\@currext-LTS@hook}% + \gundefcsn{\@currname.\@currext-LTS@hook}% +} +\robust@def\AtTagEndPackage#1{\AtEndOfPackage{\ltsAfterEndPackage{#1}}} +\newletcs\ltsAtTagEndPackage\AtTagEndPackage +\robust@def\afterpackageloaded#1{% + \LTS@after@cls@pkg@loaded{#1}\@pkgextension +} +\robust@def\afterclassloaded#1{% + \LTS@after@cls@pkg@loaded{#1}\@clsextension +} +\robust@def\LTS@after@cls@pkg@loaded#1#2#3{% + \edef\LTS@tempa{\expandafter\ifxTF\cpt@car#2\car@nil + \@pkgextension{sty}{cls}}% + \cptexpanded{% + \ltsAfterAfterBeginDocument{% + \noexpand\ifcsndefTF{ver@#1.\LTS@tempa}{}{% + \LTS@warn{Package '#1' was never loaded}% + }% + }% + }% + \ifcsndefTF{ver@#1.\LTS@tempa}{% + #3\relax + }{% + \grightaddtocsn{#1.\LTS@tempa-LTS@hook}{#3}% + }% +} +\robust@def*\LTS@preamblecmdhook{} +\robust@def*\preamblecommands{\LTS@testpl\LTS@preamblecmds} +\new@def*\LTS@preamblecmds#1{% + \begingroup + \def\@cmd{\preamblecommands}% + \let\@ifnopattern\ifnopattern + \LTS@pkgpreamplecmd{#1}\LTS@preamblecmdhook{% + \cptpassexpanded{% + \grightaddtocs\LTS@preamblecmdhook + {\LTS@dopreamble\@expand\LTS@tempa}% + }% + }% + \endgroup +} +\robust@def*\AddPreambleCommands#1{% + \def\csv@do##1{% + \ltsfiltermergetsv!\LTS@preamblecmdhook + {\LTS@dopreamble{##1}}\nofilter + }% + \csv@@parse[,]{#1}% +} +\robust@def*\RemovePreambleCommands#1{% + \def\csv@do##1{% + \ltsfilterdeletetokens!\LTS@preamblecmdhook + {\LTS@dopreamble{##1}}\nofilter + }% + \csv@@parse[,]{#1}% +} +\robust@def*\packagecommands{\LTS@testpl\LTS@packagecmds} +\robust@def*\LTS@packagecmds#1{% + \begingroup + \toks@{}% + \def\@cmd{\packagecommands}% + \def\@ifnopattern##1\in##2{\ifnopattern##2\in{##1}}% + \LTS@pkgpreamplecmd{#1}\LTS@packagecmderr{% + \@after\ifparamacroTF\LTS@tempa{% + \def\@prepto{\preptoparamcs}% + }{% + \def\@prepto{\leftaddtocs}% + }% + \cptexpandarg{\toks@}{\the\toks@\@prepto\@expand\LTS@tempa + {\LTS@packagecmderr{\@expand\LTS@tempa}}\relax\relax}% + }% + \expandafter\endgroup\the\toks@ +} +\robust@def*\LTS@pkgpreamplecmd#1#2#3{% + \ifLTS@pl + \def\@scape{\simpleexpandarg\ltsensurenoscape}% + \let\@after\aftercsname + \let\@expand\noexpandcsn + \else + \def\@scape{\simpleexpandarg\ltsensurescape}% + \let\@after\expandafter + \let\@expand\expandcsonce + \fi + \def\csv@do##1{% + \def\LTS@tempa{##1}% + \@after\ifonetoken\LTS@tempa\do{% + \@scape\LTS@tempa + \@after\ifdefTF\LTS@tempa{% + \@after\@ifnopattern\LTS@tempa\in{#2}{#3}{}% + }{% + \LTS@warn{Command '\@after\string\LTS@tempa' undefined: + \MsgBrk ignored by \expandcsonce\@cmd}% + }% + }% + }% + \csv@@parse{#1}% +} +\robust@def*\LTS@dopreamble#1{% + \gdef#1{\LTS@err{'\string#1' is a preamble command}% + {Move command '\string#1' to document preamble.}}% +} +\ltsAfterBeginDocument{% + \LTS@preamblecmdhook + \gletcs\LTS@dopreamble\@gobbleone +} +\robust@def*\LTS@packagecmderr#1{% + \ifinstylefileTF{}{% + \LTS@err{Command '\detokenize{#1}' issued outside style file}% + {The command '\detokenize{#1}' is available only + in style files.}% + }% +} +\robust@def*\ltsparsemacro{\LTS@testst\LTS@parsemacro} +\robust@def*\LTS@parsemacro#1#2#3{% + \let\ifLTS@noxpst\ifLTS@st + \begingroup + \def\LTS@tempd##1{% + \cptemptify\LTS@resa + \edef\LTS@tempb{\cptoxdetok{#3}##1&}% + \edef\LTS@tempc####1{\def####1########1##1########2&}% + \LTS@tempc\LTS@tempc{% + \ifblankTF{####2}{% + \edef\LTS@resa{\expandcsonce\LTS@resa####1}% + }{% + \edef\LTS@resa{\expandcsonce\LTS@resa####1\detokenize{#2}##1}% + \LTS@tempc####2&% + }% + }% + \expandafter\LTS@tempc\LTS@tempb + \edef#3{\expandcsonce\LTS@resa}% + }% + \edef\LTS@tempa{\cptoxdetok{#1}}% + \def\tsv@do##1{\LTS@tempd{##1}}% + \tsv@@parse*\LTS@tempa + \postgroupdef#3\endgroup + \ifLTS@noxpst\LTS@scantoksa#3\fi + \undefcs\ifLTS@noxpst +} +\robust@def*\ltsnoexpandparse#1{\ltsparsemacro*\@backslashchar\noexpand#1} +\robust@def*\ltsNoexpandParse#1{% + \let\ifLTS@noxpst\ifLTS@st + \begingroup + \cptemptify\LTS@resa + \def\LTS@tempd##1{\edef\LTS@resa{\expandcsonce\LTS@resa + \noexpand\noexpand\unexpanded{##1}}}% + \def\tsv@do##1{% + \ifmacroTF{##1}{% + \LTS@tempd{##1}% + }{% + \edef\LTS@tempb{\detokenize{##1}}% + \edef\LTS@tempc{\expandafter\LTS@car\LTS@tempb x\car@nil}% + \ifxTF\LTS@tempc\@backslashchar{% + \LTS@tempd{##1}% + }{% + \edef\LTS@resa{\expandcsonce\LTS@resa\unexpanded{##1}}% + }% + }% + }% + \tsv@@parse*{#1}% + \edef#1{\expandcsonce\LTS@resa}% + \postgroupdef#1\endgroup + \ifLTS@noxpst\LTS@scantoksa#1\fi + \undefcs\ifLTS@noxpst +} +\robust@def*\ltsdespacecommalist#1#2{% + \LTS@stfalse\LTS@despacecsvlist[,]{#1}% + \let#2=\despaced@list +} +\robust@def*\ltsdespacecsvlist{% + \LTS@testst{\LTS@testopt\LTS@despacecsvlist{,}}% +} +\robust@def*\LTS@despacecsvlist[#1]#2{% + \cpt@stchoose{LTS@st}{#2}\despaced@list\LTS@despacecsvlist + \ifcsnullTF\despaced@list{}{% + \xifinsetTF{\detokenize{#1}}{\cptoxdetok\despaced@list}{% + \cpt@sttrue\cpt@csvnormalize[#1]\despaced@list + }{% + \edef\despaced@list + {\simpleexpandarg\cpttrimspaces\despaced@list}% + }% + }% + \ifboolTF{LTS@st}{\let#2=\despaced@list}{}% +} +\robust@def*\ltsdespacexcsvlist{% + \LTS@teststpm{\LTS@testopt\LTS@despacexcsvlist,}% +} +\robust@def*\LTS@despacexcsvlist[#1]{% + \LTS@testopt{\LTS@d@spacexcsvlist#1}{#1}% +} +\robust@def*\LTS@d@spacexcsvlist#1[#2]#3{% + \let\ifxdespm\ifLTS@pm + \cpt@stchoose{LTS@st}{#3}\reserved@e\LTS@d@spacexcsvlist + \def\despaced@list{}% + \ifcsnullTF\reserved@e{}{% + \def\csv@do##1{% + \ifboolTF{xdespm}{% + \cpt@sttrue\cpt@csvnormalize[#2]{##1}% + \ltslistadd#1\despaced@list{##1}% + }{% + \edef\reserved@e{\cpttrimspaces{##1}}% + \ltsolistadd{#1}\despaced@list\reserved@e + }% + }% + \csv@@parse*[#1]\reserved@e + }% + \ifboolTF{LTS@st}{\let#3=\despaced@list}{}% + \undefcs\ifxdespm +} +\robust@def*\ltsdespacetsvlist#1#2{% + \ltsensuremacro{#2}% + \def#2{}% + \def\tsv@do##1{\rightaddtocs#2{##1}}% + \tsv@@parse{#1}% +} +\robust@def*\ltsdespacextsvlist#1#2{% + \ltsensuremacro{#2}% + \def#2{}% + \def\tsv@do##1{% + \ltsdespacetsvlist{##1}\reserved@e + \cptexpandargonce{\rightaddtocs#2}\reserved@e + }% + \tsv@@parse{#1}% +} +\robust@def*\ltssetmanytolength#1#2{% + \cptfor#1\dofor{##1=\dimexpr#2\relax\relax}% +} +\newletcs\ltssetmanytodim\ltssetmanytolength +\robust@def*\ltsdefmanyascs#1#2{% + \cptfor#1\dofor{\def##1{#2}}% +} +\robust@def*\ltsletmanytocs#1#2{% + \cptfor#1\dofor{\let##1=#2}% +} +\robust@def*\ltsnewletmanytocs#1#2{% + \cptfor#1\dofor{\newletcs##1=#2}% +} +\robust@def*\ltsnewletcs{\LTS@testst\LTS@newletcs} +\new@def*\LTS@newletcs#1{% + \cpt@ifeql{\LTS@n@wletcs{#1}}{\LTS@n@wletcs{#1}}% +} +\new@def*\LTS@n@wletcs#1#2{% + \ifdefTF#1{% + \ifLTS@st + \ifdefTF#2{% + \let#1=#2% + \LTS@verboseinfo{Command '\string#1' redefined}% + }{% + \LTS@err{Command '\string#2' undefined}% + {I can't let '\string#1' to undefined '\string#2'.}% + }% + \else + \LTS@err{Command '\string#1' already defined}% + {I can't assign defined '\string#1' to '\string#2'.}% + \fi + }{% + \ifdefTF#2{\let#1=#2}{% + \LTS@err{Command '\string#2' undefined}% + {I can't let '\string#1' to undefined '\string#2'.}% + }% + }% +} +\new@def*\LTS@newletcsnerr#1#2{% + \begingroup + \def\LTS@tempa{\ifcpt@swa\string#2\else\noexpandcsn{#2}\fi}% + \LTS@err{% + Command '\LTS@tempa' is already defined + }{% + Command '\LTS@tempa' is defined: You may use the starred + \MsgBrk version of \noexpand#1 for this type of assignment. + }% + \endgroup +} +\new@def*\newletcstocs{% + \LTS@err{% + Command '\string\newletcstocs' is undefined + }{% + Command '\string\newletcstocs' is undefined. You can use + \string\newletcs,\MsgBrk but this can't assign control + sequence names.\MsgBrk Perhaps you meant to use + \string\newletcsntocs, or\MsgBrk\noexpand\newletcstocsn + or \string\newletcsntocsn. + }% +} +\robust@def*\newletcsntocs{\LTS@teststcl\LTS@newletcsntocs} +\new@def*\LTS@newletcsntocs#1#2{% + \LTS@global@or@relax + \ifLTS@st + \glob@lrel@x\letcsntocs{#1}#2% + \else + \ifcsndefFT{#1}% + {\glob@lrel@x\letcsntocs{#1}#2}% + {\cpt@swafalse\LTS@newletcsnerr\newletcsntocs{#1}}% + \fi +} +\robust@def*\newletcstocsn{\LTS@teststcl\LTS@newletcstocsn} +\new@def*\LTS@newletcstocsn#1#2{% + \ltsensurescape{#1}% + \LTS@global@or@relax + \def\reserved@e{\begingroup\expandafter\endgroup\expandafter + \glob@lrel@x\expandafter\let\expandafter#1\csname#2\endcsname}% + \ifLTS@st + \reserved@e + \else + \ifdefFT{#1}\reserved@e{% + \cpt@swatrue\LTS@newletcsnerr\newletcstocsn{#1}% + }% + \fi +} +\robust@def*\newletcsntocsn{\LTS@teststcl\LTS@newletcsntocsn} +\new@def*\LTS@newletcsntocsn#1#2{% + \LTS@global@or@relax + \def\reserved@e{\begingroup\expandafter\endgroup\expandafter + \glob@lrel@x\expandafter\let\csname#1\aftercsname\endcsname{#2}}% + \ifLTS@st + \reserved@e + \else + \ifcsndefFT{#1}\reserved@e{% + \cpt@swafalse\LTS@newletcsnerr\newletcsntocsn{#1}% + }% + \fi +} +\robust@def*\provideletcsntocs{\LTS@testcl\LTS@provideletcsntocs} +\new@def*\LTS@provideletcsntocs#1#2{% + \LTS@global@or@relax + \ifcsndefTF{#1}{}{\glob@lrel@x\letcsntocs{#1}#2}% +} +\robust@def*\provideletcstocsn{\LTS@testcl\LTS@provideletcstocsn} +\new@def*\LTS@provideletcstocsn#1#2{% + \LTS@global@or@relax + \ifdefTF#1{}{% + \begingroup\expandafter\endgroup\expandafter\glob@lrel@x + \expandafter\let\expandafter#1\csname#2\endcsname + }% +} +\robust@def*\provideletcsntocsn{\LTS@testcl\LTS@provideletcsntocsn} +\def\LTS@provideletcsntocsn#1#2{% + \LTS@global@or@relax + \ifcsndefTF{#1}{}{% + \begingroup\expandafter\endgroup\expandafter\glob@lrel@x + \expandafter\let\csname#1\aftercsname\endcsname{#2}% + }% +} +\new@def*\provideletcstocs{% + \LTS@err{'\string\provideletcstocs' is undefined}% + {Command '\string\provideletcstocs' is undefined. + Perhaps you meant \MsgBrk to use \string\provideletcsntocs, + or \noexpand\provideletcstocsn or \string\provideletcsntocsn.}% +} +\robust@def*\ltsnumexpr{% + \cpt@checkoptprefix{\LTS@testplcl{\LTS@numexpr{num}}}% +} +\robust@def*\ltsdimexpr{% + \cpt@checkoptprefix{\LTS@testplcl{\LTS@numexpr{dim}}}% +} +\robust@def*\ltsglueexpr{% + \cpt@checkoptprefix{\LTS@testplcl{\LTS@numexpr{glue}}}% +} +\robust@def*\ltsmuexpr{% + \cpt@checkoptprefix{\LTS@testplcl{\LTS@numexpr{mu}}}% +} +\new@def*\LTS@numexpr#1#2{% + \if\detokenize{#2*}% + \LTS@err{Invalid suffix to '\string\ltsdimexpr' or + '\string\ltsnumexpr'}{Star (*) not valid as suffix to + '\string\ltsdimexpr' and '\string\ltsnumexpr'.}% + \fi + \LTS@global@or@relax + \ifboolTF{LTS@pl}{% + \cptexpandsecond{\LTS@n@mexpr{#1}}{\noexpandcsn{#2}}% + }{% + \LTS@n@mexpr{#1}{#2}% + }% +} +\new@def*\LTS@n@mexpr#1#2#3{% + \ltsensurescape@notempty{#2}{#3}% + \ifdefTF{#2}{% + \glob@lrel@x#2=\usename{#1expr}#3\relax + }{% + \begingroup + \LTS@getorderincsvlist[,](\nr){#1}{num,dim,glue,mu}% + \edef\LTS@tempa{\ifcase\nr\relax + count\or dimen\or skip\or muskip\fi}% + \usename{new\LTS@tempa}#2\relax + \endgroup + \glob@lrel@x#2=\usename{#1expr}#3\relax + }% +} +\robust@def*\ltsnumdef{% + \cpt@checkoptprefix{\LTS@testplcl{\LTS@numdef{num}}}% +} +\robust@def*\ltsdimdef{% + \cpt@checkoptprefix{\LTS@testplcl{\LTS@numdef{dim}}}% +} +\robust@def*\ltsgluedef{% + \cpt@checkoptprefix{\LTS@testplcl{\LTS@numdef{glue}}}% +} +\robust@def*\ltsmudef{% + \cpt@checkoptprefix{\LTS@testplcl{\LTS@numdef{mu}}}% +} +\new@def*\LTS@numdef#1#2{% + \if\detokenize{*#2}% + \LTS@err{Invalid suffix to '\string\ltsdimdef' or + '\string\ltsnumdef'}{Star (*) not valid as suffix to + '\string\ltsdimdef' and '\string\ltsnumdef'.}% + \fi + \LTS@global@or@relax + \ifboolTF{LTS@pl}{% + \cptexpandsecond{\LTS@num@def{#1}}{\noexpandcsn{#2}}% + }{% + \LTS@num@def{#1}{#2}% + }% +} +\new@def*\LTS@num@def#1#2#3{% + \ltsensurescape@notempty{#2}{#3}% + \glob@lrel@x\edef#2{\the\usename{#1expr}#3\relax}% +} +\robust@def*\ltsensurescape@notempty#1#2{% + \ltsensurescape{#1}% + \ifblankFT{#2}{}{% + \LTS@err{Argument '\string#2' is empty}% + {Empty argument '\string#2' is invalid.\MsgBrk + I expected a nonempty argument here.}% + }% +} +\robust@def*\ifexistinTF{\LTS@testst{\LTS@testopt\LTS@ifexistinTF,}} +\robust@def*\LTS@ifexistinTF[#1]#2\in#3{% + \begingroup + \edef\reserved@e{\ifboolTF{LTS@st}\cptoxdetok\detokenize{#2}}% + \despacecontent\reserved@e + \edef\reserved@f{\ifboolTF{LTS@st}\cptoxdetok\detokenize{#3}}% + \cpt@sttrue\cpt@csvnormalize[#1]\reserved@f + \edef\x{\detokenize{#1}}% + \cptexpandtwoargs{\endgroup\ifinsetTF} + {\x\reserved@e\x}{\x\reserved@f\x}% +} +\robust@def\ifpresentTF#1\in#2#{\ifinsetTF{#1}{#2}} +\robust@def*\ifpresentinTF{\LTS@testst{\LTS@testopt\LTS@ifpresentinTF,}} +\robust@def*\LTS@ifpresentinTF[#1]#2\in#3{% + \begingroup + \edef\reserved@e{\ifboolTF{LTS@st}\cptoxdetok\detokenize{#2}}% + \despacecontent\reserved@e + \edef\reserved@f{\ifboolTF{LTS@st}\cptoxdetok\detokenize{#3}}% + \cpt@choicefdfalse + \def\csv@do##1{% + \def\reserved@a{##1}% + \ifx\reserved@a\reserved@e\cpt@choicefdtrue\loopbreak\fi + }% + \csv@@parse*[;]\reserved@f + \ifboolTF{cpt@choicefd} + {\endgroup\@firstoftwo}{\endgroup\@secondoftwo}% +} +\robust@def*\ifendwithTF#1#2{% + \ifblankTF{#2}\@secondoftwo{% + \begingroup + \edef\LTS@tempa{\s@expandarg\cpttrimspace{\detokenize{#1}}}% + \edef\LTS@tempb{\s@expandarg\cpttrimspace{\detokenize{#2}}}% + \let\endwith\relax + \cptexpandtwoargs\cpt@in{\LTS@tempb\endwith}{\LTS@tempa\endwith}% + \csnendgroup{@\ifcpt@in first\else second\fi oftwo}% + }% +} +\robust@def*\ifbeginwithTF#1#2{% + \ifblankTF{#2}\@secondoftwo{% + \begingroup + \edef\LTS@tempa{\s@expandarg\cpttrimspace{\detokenize{#1}}}% + \edef\LTS@tempb{\s@expandarg\cpttrimspace{\detokenize{#2}}}% + \let\begwith\relax + \cptexpandtwoargs\cpt@in{\begwith\LTS@tempb}{\begwith\LTS@tempa}% + \csnendgroup{@\ifcpt@in first\else second\fi oftwo}% + }% +} +\robust@def*\in@detok#1#2{% + \cptexpandtwoargs\cpt@in{\detokenize{#1}}{\detokenize{#2}}% +} +\newletcs\ifmemberTF\ifinsetTF +\newletcs\ifmemberFT\ifinsetFT +\robust@def*\ifbelongTF#1#2{% + \cptexpandtwoargs\ifinsetTF{\detokenize{#1}}{\detokenize{#2}}% +} +\robust@def*\ifbelongFT#1#2{\ifbelongTF{#1}{#2}\iiofii\iofii} +\robust@def*\oifbelongTF#1#2{\cptexpandtwoargsonce\ifbelongTF{#1}{#2}} +\robust@def*\oifbelongFT#1#2{\cptexpandtwoargsonce\ifbelongFT{#1}{#2}} +\robust@def*\xifbelongTF#1#2{\cptexpandtwoargs\ifbelongTF{#1}{#2}} +\robust@def*\xifbelongFT#1#2{\cptexpandtwoargs\ifbelongFT{#1}{#2}} +\new@def*\ifdraftTF{\usename{LTS@\ifboolTF{LTS@draft}12of2}} +\new@def*\ifdraftFT{\usename{LTS@\ifdraftTF21of2}} +\new@def*\iffinalTF{\usename{LTS@\ifboolTF{LTS@final}12of2}} +\new@def*\iffinalFT{\usename{LTS@\iffinalTF21of2}} +\robust@def*\LTS@starorlong#1{% + \LTS@ifstar + {\def\l@ngrel@x{\relax}#1}{\def\l@ngrel@x{\long}#1}% +} +\robust@def*\LTS@starornone#1{% + \LTS@ifstar + {\let\l@ngrel@x\relax\def\star@none{*}#1}% + {\let\l@ngrel@x\long\def\star@none{}#1}% +} +\new@def*\ValidCommandPrefixes{\relax\long\global\protected} +\robust@def*\newfunction{% + \begingroup + \def\inrenew{01}% + \LTS@starorlong\LTS@newfunction@a +} +\robust@def*\renewfunction{% + \begingroup + \def\inrenew{00}% + \LTS@starorlong\LTS@newfunction@a +} +\robust@def*\LTS@newfunction@a#1#{% + \def\LTS@tempa##1##2[##3][##4]##5\LTS@nil{% + \begingroup + \@tempcnta\z@pt + \def\comma{,}% + \cpttfor##2\dofor{% + \def\reserved@a{####1}% + \ifx\reserved@a\comma\advance\@tempcnta\@ne\fi + \ifnum\@tempcnta>\@ne\forbreaktrue\fi + }% + \expandafter\endgroup\ifnum\@tempcnta>\@ne + \LTS@err{Double comma in sentinel while defining + \detokenize{##1}}\@ehc + \else + \def\cmd{##1}\def\prefix@sentinel{##2}% + \fi + \edef\param@default{% + \ifstrcmpTF{##3}\LTS@nil{}{[##3]}% + \ifstrcmpTF{##4}\LTS@nil{}{[\unexpanded{##4}]}% + }% + }% + \LTS@tempa#1[{\LTS@nil}][{\LTS@nil}]\LTS@nil + \if\inrenew + \oifdefTF\cmd{% + \LTS@verboseinfo{Command '\expandafter\string\cmd' redefined + \MsgBrk\on@line}% + }{% + \LTS@warn{Command '\expandafter\string\cmd' was previously + undefined\MsgBrk but now defined with \string\renewfunction}% + }% + \let\ifcsdefinable\rc@ifcsdefinable + \fi + \def\reserved@a##1,##2##3\LTS@nil{% + \def\prefix{##1}% + \if##2,\def\currsentinel{}\else\def\currsentinel{##2}\fi + }% + \expandafter\reserved@a\prefix@sentinel,,\LTS@nil + \let\LTS@rsvda\prefix + \simpledeletetokens\LTS@rsvda\ValidCommandPrefixes + \ifx\LTS@rsvda\@empty\else + \LTS@err{Illegal prefixes '\expandcsonce\LTS@rsvda' + for command '\expandcsonce\cmd'}\@ehc + \fi + \expandafter\expandafter\expandafter\LTS@testopt\expandafter + \expandafter\expandafter{\expandafter\expandafter\expandafter + \LTS@newfunction@c\expandafter\cmd\expandafter}\expandafter + 0\param@default +} +\robust@def*\LTS@newfunction@c#1[#2]{% + \ifnextisbrack{\LTS@newfunction@e#1[#2]}{\LTS@newfunction@d#1[#2]}% +} +\robust@def\LTS@newfunction@d#1[#2]#3{% + \toks@{}% + \ifcsdefinable#1{\LTS@newfunction@f#1\@ne{#2}{#3}}% +} +\robust@def\LTS@newfunction@e#1[#2][#3]#4{% + \ifcsdefinable#1{% + \expandafter\cpt@in\expandafter\protected\expandafter{\prefix}% + \edef\LTS@tempa{% + \ifcpt@in\LTS@testopt\else\unexpanded{\@protected@testopt#1}\fi + \noexpandcsn{\string#1}\unexpanded{{#3}}% + }% + \cptexpandarg\toks@{% + \l@ngrel@x\prefix\def\noexpand#1{\expandcsonce\LTS@tempa}% + }% + \aftercsname\LTS@newfunction@f{\string#1}\tw@{#2}{#4}% + }% +} +\robust@def\LTS@newfunction@f#1#2#3{% + \ifx#2\tw@ + \gdef\@gtempa##11{[####1]}% + \else + \gletcs\@gtempa\@gobble + \fi + \expandafter\LTS@newfunction@g\expandafter{\number#3}#1% +} +\robust@def\LTS@newfunction@g#1#2{% + \defpass\reserved@a##1#1##2##{% + \edef\reserved@a{% + \endgroup\the\toks@\l@ngrel@x\prefix + \unexpanded{\expandafter\def\expandafter#2\@gtempa}% + }% + \s@expandarg\cptswap\currsentinel{\reserved@a##1#1}% + }% + 0##1##2##3##4##5##6##7##8##9###1% +} +\cptnewvariables{if}[LTS@]{global,protected} +\robust@def*\ltsglobal{\LTS@globaltrue} +\robust@def*\ltsprotected{\LTS@protectedtrue} +\robust@def*\LTS@global@protected{% + \ifLTS@global + \LTS@globalfalse + \let\LTS@tempa\global + \else + \let\LTS@tempa\@empty + \fi + \ifLTS@protected + \LTS@protectedfalse\protected + \fi + \LTS@tempa +} +\robust@def*\ltsnewcommand{\cpt@starorlong\LTS@newcommand} +\robust@def*\LTS@newcommand#1{\LTS@testopt{\LTS@n@wcommand#1}0} +\robust@def*\LTS@n@wcommand#1[#2]{% + \ifnextisbrack{\LTS@xargdef@a#1{#2}}{\LTS@argdef@a#1{#2}}% +} +\robust@def\LTS@argdef@a#1#2{% + \LTS@testpnopt{\LTS@argdef@b{#1}{#2}}{}% +} +\robust@def\LTS@argdef@b#1#2(#3)#4{% + \def\LTS@tempd{#3}% + \ifcsdefinable#1{\LTS@yargdef#1\@ne{#2}{#4}}% +} +\robust@def\LTS@xargdef@a#1#2[#3]{% + \LTS@testpnopt{\LTS@xargdef@b{#1}{#2}{#3}}{}% +} +\robust@def\LTS@xargdef@b#1#2#3(#4)#5{% + \def\LTS@tempd{#4}% + \ifcsdefinable#1{% + \ifLTS@global\global\fi + \ifLTS@protected\protected\fi + \expandafter\def\expandafter#1\expandafter{% + \expandafter\@protected@testopt\expandafter#1% + \csname\string#1\endcsname{#3}% + }% + \aftercsname\LTS@yargdef{\string#1}\tw@{#2}{#5}% + }% +} +\robust@def\LTS@yargdef#1#2#3{% + \ifnum#2=\tw@ + \def\LTS@tempb##11{[####1]}% + \else + \let\LTS@tempb\@gobble + \fi + \expandafter\LTS@zargdef\expandafter{\number#3}#1% +} +\robust@def\LTS@zargdef#1#2{% + \begingroup + \def\LTS@tempa##1#1##2##{% + \def\LTS@tempc{\LTS@global@protected\l@ngrel@x}% + \cptexpandsecond{\expandafter\endgroup\LTS@tempc + \expandafter\def\expandafter#2\LTS@tempb##1#1}{\elt{#1}}% + }% + \@tempcnta\z@pt + \loop + \advance\@tempcnta\@ne + \csn@def{d\number\@tempcnta}{}% + \ifnum\@tempcnta<9\relax + \repeat + \ifx\LTS@tempd\@empty\else + \@tempcnta\z@pt + \def\do##1##2{% + \ifstrcmpTF{##1}\zargdef@nil{}{% + \advance\@tempcnta\@ne + \ifnum\@tempcnta>#1\relax + \LTS@err{Number of delimiters exceeds + number of parameters}\@ehc + \fi + \ifinsetTF{,##1,}{,1,2,3,4,5,6,7,8,9,}{}{% + \LTS@err{Invalid delimiter syntax: + \MsgBrk no digit [1-9] found before delimiter}\@ehc + }% + \csn@def{d##1}{##2}\do + }% + }% + \expandafter\do\LTS@tempd\zargdef@nil\zargdef@nil + \fi + \ifx\LTS@tempb\@gobble\else + \expandafter\ifx\csname d1\endcsname\@empty\else + \LTS@err{Argument one of command \string#2 is + \MsgBrk already delimited by '[]'}\@ehc + \fi + \fi + \def\elt##1{\expandcsnonce{d##1}}% + \edef\LTS@tempc{0####1\ifx\LTS@tempb\@gobble\elt1\fi + ####2\elt2####3\elt3####4\elt4####5\elt5####6\elt6% + ####7\elt7####8\elt8####9\elt9% + }% + \expandafter\LTS@tempa\LTS@tempc###1% +} +\robust@def*\ltsrenewcommand{\cpt@starorlong\LTS@renewcommand} +\robust@def*\LTS@renewcommand#1{% + \ifdefTF{#1}{}{% + \LTS@warn{Command '\string#1' was previously undefined + \MsgBrk but now defined with \string\ltsrenewcommand}% + }% + \let\ifcsdefinable\rc@ifcsdefinable + \LTS@newcommand#1% +} +\robust@def*\ltsneedcommand{\LTS@starornone\LTS@needcommand} +\new@def*\LTS@needcommand#1{% + \ltsensurescape{#1}% + \ifdefTF{#1} + {\expandafter\ltscheckcommand\star@none} + {\expandafter\newcommand\star@none}% + {#1}% +} +\new@def*\ltscheckcommand{\cpt@starorlong\LTS@checkcommand} +\new@def*\LTS@checkcommand#1#2#{\LTS@ch@ckcommand#1{#2}} +\new@def\LTS@ch@ckcommand#1#2#3{% + \letcsntocs{\string\reserved@a}\relax + \renew@command\reserved@a#2{#3}% + \@ifundefined{\string\reserved@a}{% + \LTS@ch@ckc@mmand#1\reserved@a + }{% + \expandafter\LTS@ch@ckc@mmand + \csname\string#1\expandafter\endcsname + \csname\string\reserved@a\endcsname + }% +} +\new@def*\LTS@ch@ckc@mmand#1#2{% + \ifx#1#2\else + \LTS@verbosewarn{% + Previous definition of '\string#1'\MsgBrk + doesn't match your new definition.\MsgBrk + I haven't redefined '\string#1'}% + \fi +} +\AtEndOfPackage{% + \preamblecommands{% + \ltscheckcommand,\LTS@checkcommand, + \LTS@ch@ckc@mmand,\LTS@ch@ckcommand + }% +} +\robust@def*\ltsfindcommand{\LTS@testst\LTS@findcommand} +\robust@def*\LTS@findcommand#1#2{% + \let\ifLTS@findcmdst\ifLTS@st + \ifsingletokenTF{#1}{}{% + \cpt@notonetokenerr{#1}% + }% + \undefcs\LTS@savcmd + \ifdefFT{#1}{}{% + \let\LTS@savcmd#1% + \LTS@info{Command '\string#1' is defined in one of + \MsgBrk the previously loaded packages; + \MsgBrk I will still try to find it among the + \MsgBrk suggested packages}% + }% + \def\LTS@pkgs@a{}% + \def\LTS@pkgs@b{}% + \cptdocommalist{#2}{% + \undefcs#1% + \xifinsetTF{,##1,}{,\LTS@pkgs@b,}{}{% + \edef\LTS@pkgs@b{\csliststack,\LTS@pkgs@b##1}% + \RequirePackage{##1}% + \ifdefFT{#1}{}{% + \edef\LTS@pkgs@a{\csliststack,\LTS@pkgs@a##1}% + \ifLTS@findcmdst\loopbreak\fi + }% + }% + }% + \ifcsemptyTF\LTS@pkgs@a{% + \typeout{** Command '\string#1' is not defined in + ^^Jone of the suggested packages}% + }{% + \typeout{** Command '\string#1' is defined in package(s): + ^^J\LTS@pkgs@a^^J}% + }% + \ifdefFT\LTS@savcmd{}{% + \let#1\LTS@savcmd + }% + \undefcsset{\ifLTS@findcmdst,\LTS@pkgs@a,\LTS@pkgs@b,\LTS@savcmd}% +} +\robust@def*\ifinlistTF{% + \@tempswatrue + \LTS@testst{\LTS@testopt\LTS@ifinlista{,}}% +} +\robust@def*\ifinlistFT{% + \@tempswafalse + \LTS@testst{\LTS@testopt\LTS@ifinlista{,}}% +} +\robust@def\LTS@ifinlista[#1]#2#3{% + \begingroup + \def\reserved@e##1#1#2#1##2\LTS@nil{\endgroup + \ifboolTF{@tempswa}{% + \ifblankTF{##2}\iofii\iiofii + }{% + \ifblankTF{##2}\iiofii\iofii + }% + }% + \ifboolTF{LTS@st}{% + \ltsensurescape{#3}% + \expandafter\reserved@e\expandafter + }{% + \reserved@e + }% + #1#3#1#2#1\LTS@nil +} +\robust@def\ifinlistbTF#1#2#3#4{% + \if\LTS@lwc\LTS@sttrue\else\LTS@stfalse\fi + \LTS@pltrue + \LTS@checkchoice[\val\nr]{#1}{#2}{#3}{#4}% +} +\robust@def\ifinlistbFT#1#2#3#4{\ifinlistbTF{#1}{#2}{#4}{#3}} +\robust@def\oifinlistbTF#1#2#3#4{% + \if\LTS@lwc\LTS@sttrue\else\LTS@stfalse\fi + \LTS@pltrue + \cptexpandsecond{\LTS@checkchoice[\val\nr]}% + {{\expandcsonce{#1}}{\expandcsonce{#2}}}{#3}{#4}% +} +\robust@def\oifinlistbFT#1#2#3#4{\oifinlistbTF{#1}{#2}{#4}{#3}} +\robust@def\xifinlistbTF#1#2#3#4{% + \if\LTS@lwc\LTS@sttrue\else\LTS@stfalse\fi + \LTS@pltrue + \cptexpandsecond + {\LTS@checkchoice[\val\nr]}{{#1}{#2}}{#3}{#4}% +} +\robust@def\xifinlistbFT#1#2#3#4{\xifinlistbTF{#1}{#2}{#4}{#3}} +\new@def*\LTS@nochoice@handler#1#2{% + \LTS@err{% + Value '\expandcsonce{#1}' is not in list ^^J'\expandcsonce{#2}' + }{% + You have submitted an invalid value '\expandcsonce{#1}'\MsgBrk + for your key or test parameter. Value '\expandcsonce{#1}'\MsgBrk + is not in list:^^J'\expandcsonce{#2}'. + }% +} +\robust@def*\ltscheckchoice{\LTS@teststpl\LTS@checkchoice} +\robust@def*\LTS@checkchoice{\LTS@testopt\LTS@ch@ckchoice{}} +\robust@def*\LTS@ch@ckchoice[#1]#2#3{% + \cpt@choicefdfalse + \begingroup + \ifLTS@st\lowercase{\fi + \ifblankTF{#1}{% + \def\LTS@tempa{\endgroup\LTS@ch@@@choice\LTS@nil{#2}{#3}}% + }{% + \def\LTS@tempa{\endgroup\LTS@ch@@kchoice#1\LTS@nil{#2}{#3}}% + }% + \ifLTS@st}\fi\LTS@tempa +} +\robust@def*\LTS@ch@@kchoice#1#2\LTS@nil#3#4{% + \ifblankTF{#2}% + {\LTS@ch@@@choice#1{#3}{#4}}{\LTS@ch@@@@hoice#1#2{#3}{#4}}% +} +\robust@def*\LTS@ch@@@choice#1#2#3{% + \begingroup + \def\LTS@tempc{#1}% + \ifx\LTS@tempc\LTS@nnil + \cptemptify\LTS@tempc + \else + \def\LTS@tempc{\def#1{#2}}% + \fi + \cptexpandtwoargs\cpt@in{,\detokenize{#2},}{,\detokenize{#3},}% + \usename{cpt@choicefd\ifcpt@in true\else false\fi}% + \LTS@ch@@@@@oice\LTS@nochoice@handler{#2}{#3}% +} +\robust@def*\LTS@ch@@@@hoice#1#2#3#4{% + \def#1{#3}\def#2{-1}% + \begingroup + \LTS@scantoksa#1% + \cpt@cnta\z@pt + \def\LTS@tempc{}% + \def\csv@do##1{% + \def\LTS@tempb{##1}% + \LTS@scantoksa\LTS@tempb + \ifx#1\LTS@tempb + \edef\LTS@tempc{% + \def\noexpand#1{\unexpanded{##1}}% + \def\noexpand#2{\the\cpt@cnta}% + }% + \cpt@choicefdtrue\loopbreak + \fi + \advance\cpt@cnta\@ne + }% + \csv@@parse[,]{#4}% + \LTS@ch@@@@@oice\LTS@nochoice@handler{#3}{#4}% +} +\robust@def\LTS@ch@@@@@oice#1#2#3{% + \NoConvertInputToLowercase + \ifboolTF{cpt@choicefd}{% + \ifboolTF{LTS@pl}{% + \rightaddtocs\LTS@tempc\@firstoftwo + }{% + \rightaddtocs\LTS@tempc\@firstofone + }% + }{% + \ifboolTF{LTS@pl}{% + \rightaddtocs\LTS@tempc\@secondoftwo + }{% + \rightaddtocs\LTS@tempc{#1{#2}{#3}\@gobbleone}% + }% + }% + \expandafter\endgroup\LTS@tempc +} +\robust@def*\LTS@notpresent@handler#1#2{% + \LTS@verboseinfo{None of the tokens '\detokenize{#1}' + is found in '\detokenize{#2}'}% +} +\robust@def*\ltslowercasecontent#1{% + \ltsifmacroTF{#1}{% + \expandafter\if\expandafter\LTS@lwc\expandafter + \lowercase\expandafter{\expandafter\fi\expandafter\def + \expandafter#1\expandafter{#1}\if\LTS@lwc}\fi + }{% + \cpt@notcserr{#1}% + }% +} +\robust@def*\ltsgetorderincsvlist{% + \LTS@testst{\LTS@testopt\LTS@getorderincsvlist{,}}% +} +\robust@def*\LTS@getorderincsvlist[#1]{% + \LTS@testpnopt{\LTS@g@torderincsvlist#1}\LTS@order +} +\robust@def*\LTS@g@torderincsvlist#1(#2)#3#4{% + \def#2{-1}% + \begingroup + \ifboolTF{LTS@st}{% + \edef\LTS@tempa{\simpleexpandarg\cpttrimspaces{#3}}% + \let\LTS@tempb=#4% + }{% + \edef\LTS@tempa{\cpttrimspaces{#3}} + \edef\LTS@tempb{\unexpanded{#4}}% + }% + \ltslowercasecontent\LTS@tempa + \ltslowercasecontent\LTS@tempb + \edef\LTS@tempa{\cptoxdetok\LTS@tempa}% + \edef\LTS@tempb{\cptoxdetok\LTS@tempb}% + \cpt@cnta\z@pt\def\LTS@tempc{}% + \def\csv@do##1{% + \def\LTS@tempb{##1}% + \ifx\LTS@tempb\LTS@tempa + \edef\LTS@tempc{\def\noexpand#2{\the\cpt@cnta}}% + \loopbreak + \fi + \advance\cpt@cnta\@ne + }% + \csv@@parse*[,]\LTS@tempb + \NoConvertInputToLowercase + \expandafter\endgroup\LTS@tempc +} +\robust@def*\ifoneincommalistTF#1#2{% + \if\LTS@lwc\LTS@sttrue\else\LTS@stfalse\fi + \LTS@pltrue + \LTS@ch@ckpresence[\val\nr]{#1}{#2}% +} +\robust@def*\ltscheckpresence{\LTS@teststpl\LTS@checkpresence} +\robust@def*\LTS@checkpresence{\LTS@testopt\LTS@ch@ckpresence{}} +\new@def*\LTS@ch@ckpresence[#1]#2#3{% + \cpt@choicefdfalse + \begingroup + \ifLTS@st\lowercase{\fi + \ifblankTF{#1}{% + \def\LTS@tempa{\endgroup\LTS@ch@@@presence\LTS@nil{#2}{#3}}% + }{% + \def\LTS@tempa{\endgroup\LTS@ch@@kpresence#1\LTS@nil{#2}{#3}}% + }% + \ifLTS@st}\fi\LTS@tempa +} +\new@def*\LTS@ch@@kpresence#1#2\LTS@nil#3#4{% + \ifblankTF{#2}% + {\LTS@ch@@@presence#1{#3}{#4}}% + {\LTS@ch@@@@resence#1#2{#3}{#4}}% +} +\new@def*\LTS@ch@@@presence#1#2#3{% + \begingroup + \def\LTS@tempc{#1}% + \ifxTF\LTS@nnil\LTS@tempc{% + \def\LTS@tempc{}% + }{% + \def\LTS@tempc{\def#1{#3}}% + }% + \edef\LTS@tempa{\detokenize{#3}}% + \cpt@sttrue\cpt@csvnormalize[,]\LTS@tempa + \def\csv@do##1{% + \xifinsetFT{,\detokenize{##1},}{,\LTS@tempa,}{}{% + \edef\LTS@tempc{\def\noexpand#1{\unexpanded{##1}}}% + \cpt@choicefdtrue\loopbreak + }% + }% + \csv@@parse[,]{#2}% + \LTS@ch@@@@@oice\LTS@notpresent@handler{#2}{#3}% +} +\new@def*\LTS@ch@@@@resence#1#2#3#4{% + \def#1{}\def#2{-1}% + \begingroup + \cpt@cnta\z@pt\def\LTS@tempc{}% + \def\csv@do##1{% + \xifinsetFT{,\detokenize{##1},}{,\detokenize{#4},}{}{% + \edef\LTS@tempc{% + \def\noexpand#1{\unexpanded{##1}}% + \def\noexpand#2{\the\cpt@cnta}% + }% + \cpt@choicefdtrue\loopbreak + }% + \advance\cpt@cnta\@ne + }% + \csv@@parse[,]{#3}% + \LTS@ch@@@@@oice\LTS@notpresent@handler{#3}{#4}% +} +% \ifmanyincsvlistTF[parser](no.){sublist}{mainlist} +% Check if the no. of elements of parser-separated list +% '#3' found in #4 is equal or greater than '#2'. #4 +% is the main list. If the test is true, \itemspresent returns +% all the elements found and \noofitems returns the number +% of elements found: +\ifcsdefinable\itemspresent\relax +\ifcsdefinable\noofitems\relax +\robust@def*\ifmanyincsvlistTF{% + \LTS@testopt\LTS@ifmanyincsvlistTF{,}% +} +\robust@def*\LTS@ifmanyincsvlistTF[#1]{% + \LTS@testpnopt{\LTS@ifm@nyincsvlistTF#1}{1}% +} +\robust@def*\LTS@ifm@nyincsvlistTF#1(#2)#3#4{% + \begingroup + \if\LTS@lwc\lowercase{\fi + \edef\LTS@tempa{\unexpanded{#3}}% + \edef\LTS@tempb{\unexpanded{#4}}% + \if\LTS@lwc}\fi + \cpt@sttrue\cpt@csvnormalize[#1]\LTS@tempb + \def\LTS@tempc{}\cpt@cnta\z@pt + \def\csv@do##1{% + \edef\x{\detokenize{#1}}% + \xifinsetFT{\detokenize{#1##1#1}}{\x\cptoxdetok\LTS@tempb\x}{% + \edef\LTS@tempc{\csliststack,\LTS@tempc\unexpanded{##1}}% + \advance\cpt@cnta\@ne + \ifnum\cpt@cnta>\numexpr#2-1\relax\loopbreak\fi + }% + }% + \csv@@parse*[#1]\LTS@tempa + \ifnum\cpt@cnta>\numexpr#2-1\relax + \gletcs\itemspresent\LTS@tempc + \xdef\noofitems{\the\cpt@cnta}% + \else + \gdef\itemspresent{}\gdef\noofitems{-1}% + \fi + \NoConvertInputToLowercase + \csnendgroup{LTS@\ifnumcmpTF\cpt@cnta>\numexpr#2-1{1}2of2}% +} +% \ifmanyintsvlistTF(no){sublist}{mainlist} +% Check if the no. of elements of tsv list #2 +% found in #3 is equal or greater than '#1'. #3 +% is the main list. If the test is true, \itemspresent returns +% all the elements found and \noofitems returns the number +% of elements found: +\robust@def*\ifmanyintsvlistTF{% + \LTS@testpnopt\LTS@ifmanyintsvlistTF{1}% +} +\robust@def*\LTS@ifmanyintsvlistTF(#1)#2#3{% + \begingroup + \if\LTS@lwc\lowercase{\fi + \edef\LTS@tempa{\unexpanded{#2}}% + \edef\LTS@tempb{\unexpanded{#3}}% + \if\LTS@lwc}\fi + \def\LTS@tempc{}\cpt@cnta\z@pt + \def\tsv@do##1{% + \xifinsetFT{\detokenize{##1}}{\cptoxdetok\LTS@tempb}{}{% + \edef\LTS@tempc{\csliststack,\LTS@tempc\unexpanded{##1}}% + \advance\cpt@cnta\@ne + \ifnum\cpt@cnta>\numexpr#1-1\relax\loopbreak\fi + }% + }% + \tsv@@parse*\LTS@tempa + \ifnum\cpt@cnta>\numexpr#1-1\relax + \gletcs\itemspresent\LTS@tempc + \xdef\noofitems{\the\cpt@cnta}% + \else + \gdef\itemspresent{}\gdef\noofitems{-1}% + \fi + \NoConvertInputToLowercase + \csnendgroup{LTS@\ifnumcmpTF\cpt@cnta>\numexpr#1-1{1}2of2}% +} +\robust@def*\LTS@undeftogerr#1{% + \LTS@err{Toggle '#1' undefined}% + {You need to first define toggle '#1' before use.}% +} +\providecommand*\newtog[1]{\cpt@swatrue\LTS@testopt{\LTS@newtog{#1}}{false}} +\robust@def*\deftog#1{\cpt@swafalse\LTS@testopt{\LTS@newtog{#1}}{false}} +\new@def*\LTS@newtog#1[#2]{% + \begingroup + \ifinsetFT{,}{#1}{}{% + \edef\x{\ifcpt@swa'\string\newtog'\else'\string\deftog'\fi}% + \edef\y{\ifcpt@swa'\string\NewTogs'\else'\string\DefTogs'\fi}% + \LTS@err{Command \x doesn't accept list}{% + Please submit only one toggle to \x at a time. + \MsgBrk You can use \y to define a set of togs. + }% + }% + \endgroup + \ltsensurenoscape{#1}% + \ifboolTF{cpt@swa}{% + \ifcsndefFT{cpt@tog@#1}{}{% + \LTS@err{Toggle '#1' already defined}% + {Please provide a new toggle or use '\string\deftog'.}% + }% + \LTS@getboolstate\newtog{#2}% + }{% + \ifcsndefFT{cpt@tog@#1}{}{% + \LTS@verbosewarn{Toggle '#1' redefined}% + }% + \LTS@getboolstate\deftog{#2}% + }% + \letcsntocsn{cpt@tog@#1}{@\cptstrcmp + {\LTS@boolval}{true}{first}{second}oftwo}% +} +\providecommand*\providetog[1]{% + \ifcsndefTF{cpt@tog@#1}{% + \LTS@verboseinfo{Toggle '#1' already defined.\MsgBrk + Not redefined}% + }{% + \letcsntocs{cpt@tog@#1}\@secondoftwo + }% +} +\providecommand*\requiretog[1]{% + \aftercsname\ltsneedcommand{cpt@tog@#1}[2]{##2}% +} +\newtog{pdf}[false] +\newletcs\ifpdfTF\@secondoftwo +\newletcs\ifpdfFT\@firstoftwo +\ifdefTF\pdfoutput{% + \ifnumcmpTF\pdfoutput<\@ne{}{% + \settogtrue{pdf}% + \let\ifpdfTF\@firstoftwo + \let\ifpdfFT\@secondoftwo + }% +}{} +\new@def*\ltssavecs#1{% + \ltsensurescape{#1}% + \ifcsndefTF{saved\cptgobblescape#1}{% + \LTS@err{\noexpand#1 already saved. You've to restore + \MsgBrk it or undefine '\noexpandcsn{saved\cptgobblescape#1}' + before\MsgBrk you can save \noexpand#1 again}\@ehc + }{% + \ifdefTF#1{% + \letcsntocs{saved\cptgobblescape#1}#1% + \ifcsndefFT{\string#1}{}{% + \letcsntocsn{@saved\cptgobblescape#1}{\string#1}% + }% + \ifcsndefFT{\cptgobblescape#1\@space}{}{% + \letcsntocsn{@@saved\cptgobblescape#1}% + {\cptgobblescape#1\@space}% + }% + \ifcsndefFT{\string#1\@space}{}{% + \letcsntocsn{@@@saved\cptgobblescape#1}{\string#1\@space}% + }% + }{% + \LTS@err{Undefined '\string#1' couldn't be saved\on@line}% + {You can't restore undefined commands. So why save\MsgBrk + undefined '\string#1' here?}% + }% + }% +} +\new@def*\ltsrestorecs#1{% + \ltsensurescape{#1}% + \ifcsndefTF{saved\cptgobblescape#1}{% + \letcstocsn#1{saved\cptgobblescape#1}% + \gundefcsn{saved\cptgobblescape#1}% + \ifcsndefFT{@saved\cptgobblescape#1}{}{% + \letcsntocsn{\string#1}{@saved\cptgobblescape#1}% + \gundefcsn{@saved\cptgobblescape#1}% + }% + \ifcsndefFT{@@saved\cptgobblescape#1}{}{% + \letcsntocsn{\cptgobblescape#1\@space}% + {@@saved\cptgobblescape#1}% + \gundefcsn{@@saved\cptgobblescape#1}% + }% + \ifcsndefFT{@@@saved\cptgobblescape#1}{}{% + \letcsntocsn{\string#1\@space}{@@@saved\cptgobblescape#1}% + \gundefcsn{@@@saved\cptgobblescape#1}% + }% + }{% + \LTS@err{No saved version of '\string#1' is available:\MsgBrk + '\string#1' couldn't be restored\on@line + }{% + Unsaved '\string#1' can't be restored.\MsgBrk + Note that each call to \noexpand\ltsrestorecs + undefines the saved command. + }% + }% +} +\providecommand*\input@path{} +\robust@def*\InputFileOnce{% + \ltssavecs\input@path + \LTS@testst{\LTS@testpl{\LTS@testopt\LTS@inputfileonce{.}}}% +} +\new@def*\LTS@inputfileonce[#1]#2{% + \ifblankTF{#1}{}{\grightaddtocs\input@path{{#1/}}}% + \ifboolTF{LTS@st}{% + \LTS@inp@tfileonce{#2}% + }{% + \ifcsndefTF{#2@LTS@read}{% + \ifLTS@verbose + \LTS@info{File '#2' already read:\MsgBrk + File '#2' wasn't read again}% + \fi + }{% + \LTS@inp@tfileonce{#2}% + }% + }% +} +\def\LTS@inp@tfileonce#1{% + \def\reserved@a##1##2{% + \IfFileExists{#1}{##1\@filef@und##2}% + }% + \ifboolTF{LTS@pl}{% + \reserved@a\include + }{% + \reserved@a\@@input + }{% + \letcsntocs{#1@LTS@read}\relax + \ltsrestorecs\input@path + }{% + \typein[\@gtempa]{^^J! File '\string#1' does not exist. + ^^JEnter filename or 'x' and <return> to continue.}% + \def\reserved@a{x}% + \ifxTF\@gtempa\reserved@a{% + \ltsrestorecs\input@path + }{% + \cptexpandarg{\LTS@inputfileonce[]}\@gtempa + }% + }% +} +\new@def*\ltsxcounttokens#1{% + \long\def\ltsxcounttokens##1{% + \the\numexpr\expandafter + \LTS@xcounttokens##1#1\cpt@nnil\cpt@nnil\relax + }% +} +\ltsxcounttokens{ } +\new@def\LTS@xcounttokens#1{% + \expandafter\ifxTF\cpt@car#1\car@nil + \cpt@nnil{0\cpt@removetonnil}{1+\LTS@xcounttokens}% +} +\robust@def*\ltscountalltokens#1{% + \def\ltscountalltokens##1{% + \def\nr{\m@one}% + \def\@counttokens{\futurelet\@let@token\LTS@countalltokens}% + \expandafter\@counttokens##1#1\cpt@nnil + }% +} +\ltscountalltokens{ } +\robust@def*\LTS@countalltokens{% + \ifxTF\@let@token\cpt@nnil\cpt@removetonnil{% + \edef\nr{\the\numexpr\nr+1}% + \afterassignment\@counttokens + \let\@let@token= % + }% +} +\robust@def*\ltscounttokens{\LTS@testst\LTS@counttokens} +\robust@def\LTS@counttokens#1{% + \begingroup + \def\nr{0}\def\emp{0}\def\spo{0}% + \def\siso@do##1{% + \ifx\@empty##1\@empty + \edef\emp{\the\numexpr\emp+1}% + \edef\nr{\the\numexpr\nr+1}% + \else + \ifx##1\@sptoken + \edef\spo{\the\numexpr\spo+1}% + \edef\nr{\the\numexpr\nr+1}% + \else + \edef\nr{\the\numexpr\nr+1}% + \fi + \fi + }% + \ifboolTF{LTS@st}{% + \expandafter\siso@@loop\expandafter{#1}% + }{% + \siso@@loop{#1}% + }% + \cptpassexpanded{% + \endgroup + \def\noexpand\nonempty{\nr}% + \def\noexpand\nr{{\nr}{\emp}{\spo}}% + }% +} +\newcommand*\ltscountargs[1]{% + \protected\def\ltscountargs##1{% + \begingroup + \@tempcnta\z@pt\@tempcntb\z@pt\cpt@cnta\z@pt + \def\end@countargs{\end@countargs}% + \def\LTS@countargs@a{\futurelet\next\LTS@countargs@c}% + \def\LTS@countargs@b####1{\LTS@countargs@a}% + \expandafter\LTS@countargs@a##1#1\end@countargs + }% +} +\ltscountargs{ } +\def\LTS@countargs@c{% + \ifxTF\next\end@countargs{% + \edef\next{% + \endgroup + \edef\noexpand\argcount{\the\numexpr\the\@tempcnta-1}% + \edef\noexpand\spacecount{\the\numexpr\the\@tempcntb-1}% + \edef\noexpand\nonspacecount{\the\cpt@cnta}% + }% + \expandafter\next\@gobble + }{% + \advance\@tempcnta\@ne + \ifxTF\next\@sptoken{% + \advance\@tempcntb\@ne + \afterassignment\LTS@countargs@a\let\next= % + }{% + \advance\cpt@cnta\@ne + \LTS@countargs@b + }% + }% +} +\robust@def*\macronizetokens{% + \begingroup + \@makeother{\#}% + \endlinechar\m@one + \LTS@testopt\LTS@macronize{}% +} +\robust@def*\LTS@macronize[#1]#2#3{% + \toks0{#3}% + \scantokens{\toks1{#3}}% + \xifstrcmpTF{\the\toks0}{\the\toks1}{}{% + \LTS@err{I can't macronize unscannable tokens: + ^^J^^J||\detokenize{#3}||}\@ehc + }% + \endgroup + \begingroup + \LTS@twohashcheck{#3}{}{% + \LTS@err{Illegal nested parameters in: + ^^J^^J\detokenize{#3}}\@ehc + }% + \edef\reserved@e{\detokenize{#3}}% + \chardef\nr@b\z@pt + \xifinsetFT\LTS@hashchar\reserved@e{}{% + \def\nr@a{1}% + \cptwhilenum\nr@a<10\do{% + \cptexpandtwoargs\cpt@in{\LTS@hashchar\nr@a}{\reserved@e}% + \ifcpt@in\let\nr@b\nr@a\fi + \pushnumber\nr@a + }% + \ifnum\nr@b>\z@pt + \cptemptify#2\def\nr@a{1}% + \cptwhilenum\nr@a<\numexpr\nr@b+1\do{% + \edef#2{\expandcsonce#2\LTS@hashchar\nr@a}% + \pushnumber\nr@a + }% + \fi + }% + \edef#2{#1\def\string#2#2{\reserved@e}}% + \LTS@scantoksd\endgroup#2% +} +\robust@def*\ifmeaningTF#1#2{% + \begingroup + \ifdefFT{#1}{% + \endgroup\@secondoftwo + }{% + \edef\LTS@tempa{\realmeaning{#1}}% + \edef\LTS@tempb{\detokenize{#2}}% + \csnendgroup{LTS@\ifxTF\LTS@tempa\LTS@tempb12of2}% + }% +} +\robust@def*\ifactivecharTF#1{% + \begingroup + \ltsifmacroTF{#1}{% + \edef\LTS@tempa{\string#1}% + \def\LTS@tempb{#1}% + \edef\LTS@tempb{\realmeaning\LTS@tempb}% + \csnaftergroup{LTS@\ifxTF\LTS@tempa\LTS@tempb12of2}% + }{% + \aftergroup\@secondoftwo + }% + \endgroup +} +\robust@def*\ltsifmacroTF#1{% + \begingroup + \edef\LTS@tempa##1{\def##1####1\detokenize{macro}:####2&}% + \LTS@tempa\LTS@tempa{% + \csnaftergroup{LTS@\ifblankTF{##2}21of2}% + }% + \edef\LTS@tempb##1{##1\detokenize{macro}:&}% + \LTS@tempb{\expandafter\LTS@tempa\meaning#1}% + \endgroup +} +\robust@def*\ltsifmacroFT#1{\ltsifmacroTF{#1}\iiofii\iofii} +\robust@def*\ifparamacroTF#1{% + \begingroup + \edef\LTS@tempa##1{\def##1####1\detokenize{macro}:####2->####3&}% + \LTS@tempa\LTS@tempa{% + \csnaftergroup{LTS@\ifblankTF{##2}21of2}% + }% + \edef\LTS@tempb##1{##1\detokenize{macro}:->&}% + \LTS@tempb{\expandafter\LTS@tempa\meaning#1}% + \endgroup +} +\robust@def*\ifparamacroFT#1{\ifparamacroTF{#1}\iiofii\iofii} +\robust@def*\ifcsnparamacroTF{\aftercsname\ifparamacroTF} +\robust@def*\ifprefmacroTF#1{% + \begingroup + \ifmacroFT{#1}{% + \aftergroup\@secondoftwo + }{% + \edef\LTS@tempa##1{\def##1####1\detokenize{macro}:####2&}% + \LTS@tempa\LTS@tempa{% + \csnaftergroup{LTS@\ifblankTF{##1}21of2}% + }% + \edef\LTS@tempb##1{##1\detokenize{macro}:&}% + \LTS@tempb{\expandafter\LTS@tempa\meaning#1}% + }% + \endgroup +} +\robust@def*\ifprefmacroFT#1{\ifprefmacroTF{#1}\iiofii\iofii} +\robust@def*\ifprimitiveTF#1{% + \begingroup + \ltsifmacroTF{#1}{% + \endgroup\@secondoftwo + }{% + \def\LTS@tempa##1##2&{% + \csnendgroup{LTS@\if##1\@backslashchar1\else2\fi of2}% + }% + \expandafter\LTS@tempa\meaning#1&% + }% +} +\robust@def*\ifprimitiveFT#1{\ifprimitiveTF{#1}\iiofii\iofii} +\robust@def\ifpatternTF#1#2{% + \begingroup + \edef\LTS@tempa##1{\def##1####1\detokenize{#1}####2&}% + \LTS@tempa\LTS@tempa{% + \csnaftergroup{LTS@\ifblankTF{##2}21of2}% + }% + \edef\LTS@tempb##1{##1\detokenize{#1}&}% + \LTS@tempb{\expandafter\LTS@tempa\meaning#2}% + \endgroup +} +\robust@def*\ifpatternFT#1#2{\ifpatternTF{#1}{#2}\iiofii\iofii} +\robust@def*\ifnopattern#1\in#2{\ifpatternFT{#1}{#2}} +\robust@def*\ifscannableTF#1{% + \begingroup + \edef\LTS@rsvda##1{% + \def##1####1\detokenize{macro}:####2->####3&{% + ####1\def\string\LTS@rsvda####2{####3}% + }% + \edef##1{##1\meaning#1&}% + }% + \LTS@rsvda\LTS@rsvda + \makeatletter\everyeof{\noexpand}\endlinechar\m@one + \scantokens\expandafter{\LTS@rsvda}\relax + \csnendgroup{LTS@\expandafter\ifxTF\cpt@car#1\car@nil + \LTS@rsvda12of2}% +} +\robust@def*\ifscannableFT#1{\ifscannableTF{#1}\iiofii\iofii} +\robust@def*\delimitmacro#1#2{% + \ifsingletokenTF{#2}{}{% + \LTS@err{Delimiter '\detokenize{#2}' is more than + one token}\@ehc + }% + \ifscannableTF#1{% + \begingroup + \edef\LTS@tempa##1{% + \def##1####1\detokenize{macro:}####2->####3&{% + ####1\def\string#1####2\string#2{####3}% + }% + \edef##1{##1\meaning#1&}% + }% + \LTS@tempa\LTS@tempa + \LTS@scantoksd\endgroup\LTS@tempa + }{% + \LTS@err{Your \noexpand#1 isn't scannable}{% + Sorry, I can't delimit the last parameter of your\MsgBrk + command \noexpand#1: it isn't scannable. + }% + }% +} +\robust@def*\LTS@stepdownhash{% + \begingroup + \@makeother{\#}% + \endlinechar\m@one + \LTS@st@pdownhash +} +\robust@def*\LTS@st@pdownhash#1#2{% + \xifinsetTF{\detokenize{##}}{\detokenize{#1}}{% + \edef\LTS@rsvda##1{##1\detokenize{#1##}&}% + \edef\LTS@rsvdb##1{\def##1####1\detokenize{##}####2&}% + \LTS@rsvdb\LTS@rsvdb{% + \ifblankTF{##2}{% + \toks@\expandafter{\the\toks@##1}% + }{% + \cptpassexpanded{\toks@{\the\toks@##1\LTS@hashchar}}% + \LTS@rsvdb##2&% + }% + }% + \LTS@rsvda{\toks@{}\LTS@rsvdb}% + \edef#2{\the\toks@}% + }{% + \edef#2{\detokenize{#1}}% + }% + \postgroupdef#2\endgroup +} +\robust@def*\LTS@stepuphash{% + \begingroup + \@makeother{\#}% + \endlinechar\m@one + \LTS@st@puphash +} +\robust@def*\LTS@st@puphash#1#2{% + \xifinsetTF{\LTS@hashchar}{\detokenize{#1}}{% + \edef\LTS@rsvda##1{##1\detokenize{#1}\LTS@hashchar&}% + \edef\LTS@rsvdb##1{\def##1####1\LTS@hashchar####2&}% + \LTS@rsvdb\LTS@rsvdb{% + \ifblankTF{##2}{% + \toks@\expandafter{\the\toks@##1}% + }{% + \cptpassexpanded{\toks@{\the\toks@##1\LTS@hashchar\LTS@hashchar}}% + \LTS@rsvdb##2&% + }% + }% + \LTS@rsvda{\toks@{}\LTS@rsvdb}% + \edef#2{\the\toks@}% + }{% + \edef#2{\detokenize{#1}}% + }% + \postgroupdef#2\endgroup +} +\robust@def*\LTS@onehashcheck#1{% + \begingroup + \edef\LTS@rsvda##1{\def##1####1\LTS@hashchar####2&}% + \LTS@rsvda\LTS@rsvda{% + \csnaftergroup{LTS@\ifblankTF{##2}12of2}% + }% + \edef\LTS@rsvdb##1{##1\detokenize{#1}\LTS@hashchar&}% + \LTS@rsvdb\LTS@rsvda + \endgroup +} +\robust@def*\LTS@twohashcheck#1{% + \begingroup + \edef\LTS@rsvda##1{\def##1####1\detokenize{##}####2&}% + \LTS@rsvda\LTS@rsvda{% + \csnendgroup{LTS@\ifblankTF{##2}12of2}% + }% + \edef\LTS@rsvdb##1{##1\detokenize{#1}\detokenize{##}&}% + \LTS@rsvdb\LTS@rsvda +} +\robust@def*\robustifycs{\LTS@testopt\LTS@robustifycs{}} +\robust@def*\LTS@robustifycs[#1]#2{% + \ifdefFT{#2}{% + \cpt@notdeferr{#2}% + }{% + \ltsifmacroTF{#2}{% + \ifetexprotectedTF{#2}{% + \LTS@verboseinfo + {Protected command '\string#2' not re-protected}% + }{% + \ifltxprotectTF{#2}{% + \letcstocsn\LTS@rsvda{\cptgobblescape#2\@space}% + \cpt@swatrue + }{% + \let\LTS@rsvda#2\cpt@swafalse + }% + \ifparamacroTF\LTS@rsvda{% + \ifscannableTF\LTS@rsvda{% + \begingroup + \edef\LTS@rsvdb##1{% + \def##1####1\detokenize{macro}:####2->####3&{% + #1\protected####1\def\string\LTS@rsvda####2{####3}% + }% + \edef##1{##1\meaning\LTS@rsvda&}% + }% + \LTS@rsvdb\LTS@rsvdb + \LTS@scantoksd\endgroup\LTS@rsvdb + \let#2\LTS@rsvda + }{% + \LTS@err{Command '\string#2' can't be made robust}% + {Command '\string#2' isn't retokenizable.}% + \cpt@swafalse + }% + }{% + \protected#1\edef#2{\expandcsonce\LTS@rsvda}% + }% + \ifcpt@swa + \ifcsndefTF{\string#2\@space}{}% + {\undefcsn{\cptgobblescape#2\@space}}% + \fi + }% + }{% + \LTS@err{Command '\string#2' isn't a macro}% + {Command '\string#2' can't be made robust.}% + }% + }% +} +\robust@def*\robustifycsn{\LTS@testopt\LTS@robustifycsn{}} +\robust@def*\LTS@robustifycsn[#1]#2{% + \cptexpandarg{\robustifycs[#1]}{\noexpandcsn{#2}}% +} +\robust@def*\robustifycsset{\LTS@testopt\LTS@robustifycsset{}} +\robust@def*\LTS@robustifycsset[#1]#2{% + \def\csv@do##1{% + \ltsensuremacro{##1}% + \robustifycs[#1]{##1}% + }% + \csv@@parse[,]{#2}% +} +\new@def*\LTS@hookfail#1#2{% + \LTS@warn{Hooking to command '\string#1' failed:\MsgBrk#2}% +} +% [<prefix>]{<cmd1>}{<cmd2>}{<success>}{<failure>} +\robust@def*\apptoparamcs{% + \long\def\setarg##1##2{##1##2}% + \begingroup\@makeother{\#}\LTS@hooktoparamcs +} +\robust@def*\preptoparamcs{% + \let\setarg\cptswap + \begingroup\@makeother{\#}\LTS@hooktoparamcs +} +\newcommand\LTS@hooktoparamcs[3][]{% + \endgroup + \ifdefFT{#2}{% + \LTS@hookfail{#2}{Command isn't defined or is relaxed}% + \@secondoftwo + }{% + \ltsifmacroTF{#2}{% + \ifparamacroTF{#2}{% + \ifscannableTF{#2}{% + \LTS@twohashcheck{#3}{% + \ifblankTF{#1}{% + \LTS@h@oktoparamcs{#2}{#3}% + }{% + \LTS@h@oktoparamcs[#1]{#2}{#3}% + }% + \@firstoftwo + }{% + \LTS@hookfail{#2}{Nested commands or parameters}% + \@secondoftwo + }% + }{% + \LTS@hookfail{#2}{Macro can't be retokenized\MsgBrk + safely after patching}% + \@secondoftwo + }% + }{% + \LTS@onehashcheck{#3}{% + \LTS@verboseinfo{Macro '\string#2' patched successfully}% + \ifetexprotectedTF{#2}\protected\relax + #1\edef#2{\setarg{\expandcsonce#2}{\unexpanded{#3}}}% + \LTS@verboseinfo{Macro '\string#2' patched successfully}% + \@firstoftwo + }{% + \LTS@hookfail{#2}{Command is a parameterless macro + \MsgBrk but you're hooking with a parametered macro}% + \@secondoftwo + }% + }% + }{% + \LTS@hookfail{#2}{Command isn't a macro}% + \@secondoftwo + }% + }% +} +\newcommand\LTS@h@oktoparamcs[3][]{% + \begingroup + \edef\LTS@tempa##1{% + \def##1####1\detokenize{macro}:####2->####3&{% + #1####1\def\string#2####2{\setarg{####3}{\detokenize{#3}}}% + }% + \edef##1{##1\meaning#2&}% + }% + \LTS@tempa\LTS@tempa + \LTS@scantoksd\endgroup\LTS@tempa +} +\robust@def*\TracingPatchesOn{\let\LTS@tracepatches\cptswtrue} +\robust@def*\TracingPatchesOff{\let\LTS@tracepatches\cptswfalse} +% [<prefix>]{<cmd>}{<search>}{<replace>} +\robust@def*\simplecmdpatch{% + \begingroup + \@makeother{\#}% + \endlinechar\m@one + \LTS@testopt\LTS@simplecmdpatch{####1}% +} +\new@def*\LTS@simplecmdpatch[#1]#2#3#4{% + \if\LTS@tracepatches + \typeout{^^J** Debugging patches: command '\string#2'}% + \fi + \endgroup + \begingroup + \edef\LTS@tempa##1##2{% + \def##1####1\detokenize{macro:}####2->####3&{% + #1\def\string#2####2{##2####3&}% + }% + \def##2####1\detokenize{#3}####2&{####1\detokenize{#4}####2}% + \edef##1{##1\meaning#2&}% + }% + \LTS@tempa\LTS@tempa\LTS@tempb + \catcode`\#=6\relax\makeatletter + \LTS@scantoksd\endgroup\LTS@tempa +} +% [<prefix>]{<cmd>}{<search>}{<replace>}{<success>}{<failure>} +\robust@def*\patchcs{% + \LTS@ifstar\LTS@patchcs@b\LTS@patchcs@a +} +\robust@def*\LTS@patchcs@a{% + \let\LTS@hashcheckorno\LTS@twohashcheck + \begingroup + \@makeother{\#}\endlinechar\m@one + % If \LTS@testopt uses a different definition of + % \@ifnextchar, the number of hash characters here + % would have to change; it will most likely become 8: + \LTS@testopt\LTS@patchcs{####1}% +} +\robust@def*\LTS@patchcs@b{% + \if\stricthashcheck + \LTS@err{Patching failed: you can't use the star (*) + \MsgBrk variant while strict hash check is in force. + \MsgBrk Relax strict hash check with + '\string\NoStrictHashCheck'}\@ehc + \fi + \let\LTS@hashcheckorno\ifblankFT + \begingroup + \@makeother{\#}\endlinechar\m@one + \LTS@testopt\LTS@patchcs{####1}% +} +\new@def*\LTS@patchcs[#1]#2#3#4{% + \if\LTS@tracepatches + \typeout{^^J** Debugging patches: command '\string#2'}% + \fi + \LTS@hashcheckorno{#4}{% + \LTS@p@tchcs{#1}{#2}{#3}{#4}% + }{% + \endgroup + \LTS@patchdebug{--}{Nested parameters}% + \@secondoftwo + }% +} +\new@def*\LTS@p@tchcs#1#2#3#4{% + \LTS@ifpatchable{#2}{#3}{#4}{% + \LTS@patchdebug{++}{Command is patchable}% + \LTS@patchdebug{==}{Patching has begun}% + \begingroup + \edef\LTS@tempa##1##2{% + \def##1####1\detokenize{macro:}####2->####3&{% + #1\def\string#2####2{##2####3&}% + }% + \def##2####1\detokenize{#3}####2&{####1\detokenize{#4}####2}% + \edef##1{##1\meaning#2&}% + }% + \LTS@tempa\LTS@tempa\LTS@tempb + \LTS@scantoksd\endgroup\LTS@tempa + \LTS@patchdebug{==}{Patching completed successfully}% + \@firstoftwo + }{% + \LTS@patchdebug{--}{Patching couldn't be completed}% + \@secondoftwo + }% +} +\new@def*\LTS@patchdebug#1#2{% + \if\LTS@tracepatches + \typeout{[debug] #1 #2}% + \fi +} +\robust@def*\LTS@ifpatchable#1#2#3{% + \endgroup + \ifdefswitchTF{stricthashcheck}{% + \LTS@patchdebug{==}{'stricthashcheck' set true}% + % If #3 is macronizable, then it is scannable. + % Macronizing doesn't accept nested hash, but + % we're already in strict mode here. + \macronizetokens\LTS@rsvda{#3}% + \LTS@patchdebug{++}{No illegal nested parameters in command}% + }{}% + \ifdefFT{#1}{% + \LTS@patchdebug{--}{Command not defined}% + \@secondoftwo + }{% + \LTS@patchdebug{++}{Command is defined}% + \ltsifmacroTF{#1}{% + \LTS@patchdebug{++}{Command is a macro}% + \ifscannableTF{#1}{% + \LTS@patchdebug{++}{Macro can be retokenized safely + after patching}% + \LTS@hashcheckorno{#2}{% + \LTS@patchdebug{++}{No nested parameters in command + or 'stricthashcheck' is false}% + \ifpatternTF{#2}{#1}{% + \LTS@patchdebug{++}{Requested search pattern found}% + \@firstoftwo + }{% + \LTS@patchdebug{--}{Requested search pattern not found}% + \@secondoftwo + }% + }{% + \LTS@patchdebug{--}{Nested commands or parameters}% + \@secondoftwo + }% + }{% + \LTS@patchdebug{--}{Macro can't be retokenized + safely after patching}% + \@secondoftwo + }% + }{% + \LTS@patchdebug{--}{Command isn't a macro}% + \@secondoftwo + }% + }% +} +\robust@def*\ifpatchableTF{\begingroup\LTS@ifpatchable} +\robust@def*\reverseexpansion#1#2{% + \ifnum#2=\@ne + \LTS@err{Invalid expansion order '\string#2' for + '\string\reverseexpansion'}{Why not just use + '\string\expandafter' here instead\MsgBrk of + '\string\reverseexpansion'?}% + \expandafter\@gobbleone + \fi + \ifcase\numexpr#2-2\relax + \def\LTS@rsvda{2,2}% + \or + \def\LTS@rsvda{3,4,4}% + \or + \def\LTS@rsvda{4,6,8,8}% + \else + \LTS@err{Invalid expansion order \string#2} + {Number '\string#2' of '\string\reverseexpansion' + is too large.}% + \expandafter\@gobble + \fi + \def\csv@do##1{% + \LTS@sttrue\LTS@expandoneahead#1{##1}% + }% + \csv@@loop*[,]\LTS@rsvda +} +\robust@def*\expandoneahead{\LTS@testst\LTS@expandoneahead} +\robust@def\LTS@expandoneahead#1#2{% + \begingroup + \ltsmakecsn{\{}\lb\ltsmakecsn{\}}\rb + \toks@{}% + \@tempcnta\m@one + \def\LTS@i{\futurelet\next\LTS@iv}% + \def\LTS@ii{\afterassignment\LTS@i\let\next= }% + \def\LTS@iii##1{% + \ifnum\@tempcnta<#2\relax + \ifx##1\bgroup\relax + \toks@\expandafter{\the\expandafter + \toks@\expandafter\expandafter\lb}% + \else + \ifx##1\egroup\relax + \toks@\expandafter{\the\expandafter\toks@ + \expandafter\expandafter\rb}% + \else + \toks@\expandafter{\the\toks@\expandafter##1}% + \fi + \fi + \else + \ifx##1\bgroup + \toks@\expandafter{\the\expandafter\toks@\lb}% + \else + \ifx##1\egroup + \toks@\expandafter{\the\expandafter\toks@\rb}% + \else + \toks@\expandafter{\the\toks@##1}% + \fi + \fi + \fi + }% + \def\LTS@iv{% + \advance\@tempcnta\@ne + \ifx\next\end + \let\cmd\@gobbleone + \else + \ifx\next\@sptoken + \toks@\expandafter{\the\toks@ \expandafter\@space}% + \let\cmd\LTS@ii + \else + \ifx\next\bgroup + \LTS@iii\bgroup\let\cmd\LTS@ii + \else + \ifx\next\egroup + \LTS@iii\egroup\let\cmd\LTS@ii + \else + \let\cmd\LTS@v + \fi + \fi + \fi + \fi + \cmd + }% + \def\LTS@v##1{\LTS@iii##1\LTS@i}% + \ifdefboolFT{LTS@st}{}\expandafter\LTS@i#1\end + \edef\LTS@resa{\the\toks@}% + \postgroupdef\LTS@resa\endgroup + \LTS@scantoksa\LTS@resa + \ifLTS@st\let#1\LTS@resa\fi +} +\robust@def*\expandallonce{\LTS@testopt\LTS@expandallonce\@M} +\robust@def*\LTS@expandallonce[#1]#2{% + \begingroup + \let\temp@bgroup\bgroup + \let\bgroup\LTS@undefined + \cpt@cnta#1\relax\advance\cpt@cnta\@ne + \LTS@exp@ndallonce#2% + \postgroupdef#2\endgroup + \NoExpandPrimitives +} +\new@def*\LTS@exp@ndallonce#1{% + \def\LTS@i{\futurelet\next\LTS@ii}% + \def\LTS@ii{% + \expandafter\LTS@iii\meaning\next\LTS@nil + \ifx\next\end + \let\cmd\@gobbleone + \else + \ifx\next\@sptoken + \edef#1{\expandcsonce#1\@space}% + \csn@def{cmd} {\LTS@i}% + \else + \let\cmd\LTS@iv + \fi + \fi + \cmd + }% + \def\LTS@iii##1##2\LTS@nil{\if##1\@backslashchar\let\next\relax\fi}% + \def\LTS@iv##1{% + \toks@\expandafter{#1}\toks1{##1}% + \ifx\next\temp@bgroup + \advance\cpt@cnta\m@one + \ifnum\cpt@cnta>\z@pt + \begingroup + \aftercsname\edef{\string#1}{\the\toks1}% + \aftercsname\LTS@exp@ndallonce{\string#1}% + \toks1\cptsevenxp{\usename{\string#1}}% + \edefpass#1{\endgroup\toks1{\the\toks1}}% + \fi + \edef#1{\the\toks@{\the\toks1}}% + \advance\cpt@cnta\@ne + \else + \edef#1{\the\toks1}% + \LTS@exp@nd@llonce#1% + \edef#1{\the\toks@\expandcsonce#1}% + \fi + \LTS@i + }% + \expandafter\cptemptify\expandafter#1\expandafter\LTS@i#1\end +} +\robust@def*\LTS@exp@nd@llonce#1{% + \begingroup + \oifmacroTF#1{% + \edef#1{\noexpand\expandcsonce\expandcsonce#1} + }{% + \edef\LTS@rsvda{\cptsevenxp\LTS@car\cptoxdetok{#1}x\car@nil}% + \ifxTF\LTS@rsvda\@backslashchar{% + \simpleexpandarg\ifprimitiveTF{#1}{% + \if\LTS@expprim + \edef#1{\expandcsonce#1}% + \else + \edef#1{\noexpand\noexpand\expandcsonce#1}% + \fi + }{% + \edef#1{\noexpand\noexpand\expandcsonce#1}% + }% + }{% + \edef#1{\expandcsonce#1}% + }% + }% + \postgroupdef#1\endgroup +} +\new@def*\CurrentPackageOrClass{\@cls@pkg\@space'\@currname'} +\new@def*\LTS@parsedate#1/#2/#3 v#4\LTS@nil{#1/#2/#3} +\robust@def*\LTS@notloadederr#1{% + \ifcsndefTF{ver@#1.\@pkgextension}{}{% + \LTS@err{Package '#1' wasn't loaded} + {Document has begun and package '#1' wasn't loaded. + \MsgBrk You wanted package '#1' loaded.}% + }% +} +\new@def*\LTS@notloaded{} +\robust@def*\ensurepackageloaded#1{% + \def\csv@do##1{% + \grightaddtocs\LTS@notloaded{\LTS@doloaded{##1}}% + }% + \csv@@parse[,]{#1}% +} +\ltsAtBeginDocument{% + \let\LTS@doloaded\LTS@notloadederr + \LTS@notloaded + \gletcs\LTS@doloaded\@gobbleone +} +\robust@def*\QuotationMarks#1{% + \begingroup + \ifinsetTF,{#1}{% + \def\LTS@tempa##1,##2\LTS@nil{% + \ifblankTF{##2}{% + \LTS@err{Unbalanced quotation marks '#1'}\@ehc + }{% + \protected@xdef\LTS@lquote{% + {\ltsprotectedtokens{\normalcolor\normalfont}##1}}% + \protected@xdef\LTS@rquote{% + {\ltsprotectedtokens{\normalcolor\normalfont}##2}}% + }% + }% + \LTS@tempa#1\LTS@nil + }{% + \LTS@err{I can't find comma in quotation marks '#1'}\@ehc + }% + \endgroup +} +\cptchardef\LTS@quotednr@a\z@pt +\cptchardef\LTS@quotednr@b\z@pt +\QuotationMarks{`,'} +\new@def*\ApplyToQuotes#1{% + \ifnumcmpTF\LTS@quotednr@b>\z@pt{% + \LTS@err{You haven't called '\string\ApplyNilToQuotes'\MsgBrk + since you last called '\string\ApplyToQuotes'}\@ehc + \@gobbleone + }{% + \gdef\LTS@quotefmt{#1}% + }% + \let\LTS@quotednr@b\@ne +} +\new@def*\ApplyNilToQuotes{% + \gletcs\LTS@quotefmt\@firstofone + \chardef\LTS@quotednr@b\z@pt +} +\ApplyNilToQuotes +\new@def*\LTS@quotewhile{\cpt@choicefdfalse\LTS@quoteloop} +\new@def*\LTS@quoteloop#1{% + \ifboolTF{cpt@choicefd}{% + \LTS@quoteend + }{% + \ifx#1\LTS@quoterepeat\LTS@quoterepeat\fi + \ifx#1\LTS@quotenext\cpt@choicefdtrue\fi + }% + \LTS@quoteloop +} +\new@def*\LTS@quoterepeat#1\LTS@quoteloop{\fi} +\new@def*\LTS@quoteend#1\LTS@quoterepeat{} +\robust@def*\quoted{% + \pushnumber\LTS@quotednr@a + \ifnumcmpTF\LTS@quotednr@a>\tw@{% + \cpt@toodeep\quoted\tw@ + }{% + \begingroup + \@makeother{\#}% + \LTS@testst\LTS@quoted + }% +} +\new@def*\LTS@quoted#1{% + \def\LTS@quotearg{{\LTS@quotefmt{#1}}}% + \gletcsntocs{ifLTS@st@\romannumeral\LTS@quotednr@a}\ifLTS@st + \def\LTS@tempa{% + \ifLTS@st@i + \protected@edef\lquote{\LTS@lquote}% + \protected@edef\rquote{\LTS@rquote}% + \else + \protected@edef\lquote{\LTS@lquote\LTS@lquote}% + \protected@edef\rquote{\LTS@rquote\LTS@rquote}% + \fi + }% + \def\LTS@tempb##1##2{% + \ifnum\LTS@quotednr@a>\@ne + \LTS@tempa + \else + \protected@edef\lquote{##1\LTS@lquote}% + \protected@edef\rquote{##2\LTS@rquote}% + \fi + }% + \ifLTS@st + \LTS@tempb\LTS@lquote\LTS@rquote + \else + \LTS@tempb{}{}% + \fi + \def\popnumber{\noexpand\popnumber\noexpand}% + \protected@edef\rquote{\rquote\popnumber\LTS@quotednr@a}% + \futurelet\LTS@quotenext\LTS@qu@ted +} +\new@def*\LTS@qu@ted{% + \def\LTS@quotefnt{\footnote\footnotetext\footnotemark\mpfootnotemark}% + \def\LTS@quote@a{% + \if\LTS@wq + \expandafter\LTS@quotewhile\LTS@quotefnt\LTS@quoterepeat + \ifcpt@choicefd + \protected@xdef\LTS@qu@t@d####1####2{% + \lquote\expandcsonce\LTS@quotearg\unskip####1{####2}\rquote + }% + \else + \protected@xdef\LTS@qu@t@d####1{% + \lquote\expandcsonce\LTS@quotearg\unskip####1\rquote}% + \fi + \else + \protected@xdef\LTS@qu@t@d{% + \lquote\expandcsonce\LTS@quotearg\rquote\unskip}% + \fi + }% + \protected@edef\LTS@tempa{,;:.!?\expandcsonce\LTS@quotefnt}% + \expandafter\LTS@quotewhile\LTS@tempa\LTS@quoterepeat + \ifcpt@choicefd + \expandafter\LTS@quote@a + \else + \protected@xdef\LTS@qu@t@d{\lquote\expandcsonce\LTS@quotearg\rquote}% + \fi + \expandafter\endgroup\LTS@qu@t@d +} +\robust@def*\MakeQuoteCommand{\LTS@testst\LTS@MakeQuoteCommand} +\robust@def*\LTS@MakeQuoteCommand#1{% + \begingroup + \lccode`\~=`#1% + \lowercase{\endgroup + \newcsnedef*{\string~@quote}{\the\catcode`~}% + \ifLTS@st + \ifdefFT~{}{\letcsntocs{\string~@@quote}~}% + \let~\quoted + \else + \newletcs~\quoted + \fi + \catcode`#1=\active + }% +} +\robust@def*\DeleteQuoteCommand#1{% + \begingroup + \lccode`\~=`#1% + \lowercase{\endgroup + \ifcsndefTF{\string~@@quote}{% + \letcstocsn~{\string~@@quote}% + }{% + \gletcs~\LTS@undefined + }% + \catcode`#1=\usename{\string~@quote}% + }% +} +\robust@def*\nameabbrev#1#2{% + \begingroup + \ltsensurescape{#1}% + \ltsmakecsn#1\LTS@tempa + \expandafter\LTS@testopt\expandafter + {\expandafter\LTS@nameabbrev\expandafter{\LTS@tempa}{#2}}{}% +} +\new@def*\LTS@nameabbrev#1#2[#3]{% + \ifblankTF{#3}{% + \LTS@err{Empty abbreviation for name '\noexpandcsn{#1}'}\@ehc + }{% + \newcsnpgdef*{#1long}{#2\sspace}% + \newcsnpgdef*{#1short}{#3\sspace}% + \newcsnpgdef*{#1first}{#2~(#3)\sspace}% + }% + \newcsnpgdef*{#1}{% + \ifnamedefTF{nameabbrev@#1}{% + #3\sspace + }{% + \csn@gdef{nameabbrev@#1}{}% + \usename{#1first}\sspace + }% + }% + \endgroup +} +\newletcs\killifdocstarted\@iden +\ltsAfterAfterBeginDocument{% + \LTS@scantoksa\LTS@sspaceexceptions + \let\killifdocstarted\@gobble +} +\robust@def*\LTS@sspacewhile{\cpt@choicefdfalse\LTS@sspaceloop} +\robust@def*\LTS@sspaceloop#1{% + \ifboolTF{cpt@choicefd}{% + \LTS@sspaceend + }{% + \ifx#1\LTS@sspacerepeat\LTS@sspacerepeat\fi + \ifx#1\LTS@sspacenext\cpt@choicefdtrue\fi + }% + \LTS@sspaceloop +} +\robust@def\LTS@sspacerepeat#1\LTS@sspaceloop{\fi} +\robust@def\LTS@sspaceend#1\LTS@sspacerepeat{} +\robust@def*\LTS@sspaceexceptions{% + \},.'/?;:!~-)\ \/\bgroup\egroup\sspace\nobreak\penalty + \@sptoken\@space\@xobeysp\footnote\footnotemark +} +\robust@def*\sspace{\begingroup\futurelet\LTS@sspacenext\LTS@sspace} +\robust@def*\LTS@sspace{% + \killifdocstarted{\LTS@scantoksa\LTS@sspaceexceptions}% + \expandafter\LTS@sspacewhile\LTS@sspaceexceptions\LTS@sspacerepeat + \expandafter\endgroup + \ifcpt@choicefd\else\expandafter\@space\fi +} +% Verbatim \sspace: +\robust@def*\verbsspace{% + \ifnum\catcode`\ =\active\else\expandafter\sspace\fi +} +\robust@def*\AddSspaceExceptions#1{% + \ltsfiltermergetsv!\LTS@sspaceexceptions{#1}\nofilter +} +\robust@def*\RemoveSspaceExceptions#1{% + \ltsfilterdeletetokens!\LTS@sspaceexceptions{#1}\nofilter +} + +\robust@def*\ltscountspacesincs{% + \begingroup + \catcode\endlinechar=12 + \LTS@countspacesincs +} +\def\LTS@countspacesincs#1{% + \lccode`\ `\^^S\relax + \catcode\endlinechar=9 + \scantokens{\LTS@c@untspacesincs{#1}{ignoring}}% + \catcode\endlinechar=10 + \scantokens{\LTS@c@untspacesincs{#1}{counting}}% + \endgroup +} +\def\LTS@c@untspacesincs#1#2{% + \@tempcnta\z@pt + \toks@{##1}% + \lowercase{% + \toks1\expandafter{\detokenize{ }}% + \expandafter\def\expandafter\LTS@tempa\the + \expandafter\toks@\the\toks1##2\@nil{% + \ifblankTF{##2}{}{% + \advance\@tempcnta\@ne + \LTS@tempa##2\@nil + }% + }% + \expandafter\LTS@tempa\detokenize{#1 }\@nil + }% + \typeout{^^J\unexpanded{#1}}% + \typeout{Number of spaces, + #2 end-of-line characters: \the\@tempcnta.}% +} +% Eg, +% \ifboolevalTF{% +% not ( eval { \ifdefFT\xa } and eval { \ifcsemptyTF\xa } ) +% or ( eval { \ifdefFT\xb } or eval { \ifxTF\xa\xb } ) +% }{% +% \def\x{T}% +% }{% +% \def\x{F}% +% } +\cptnewcounts{LTS@evalcnt} +\robust@def*\ifboolevalTF#1{% + \begingroup + \let\LTS@eval@neg\cptswfalse + \LTS@evalcnt\z@pt + \LTS@eval@beg + \LTS@eval@bgroup#1(\eval@nil + \LTS@eval@end + \LTS@eval@@end +} +\robust@def*\LTS@eval@beg{% + \begingroup + \let\LTS@eval@neg\cptswfalse + \LTS@evalcnt\z@pt +} +\robust@def*\LTS@eval@end{% + \LTS@eval@@end\LTS@eval@true\LTS@eval@false +} +\robust@def*\LTS@eval@@end{% + \csnendgroup{LTS@\ifnum\LTS@evalcnt<\z@pt2\else1\fi of2}% +} +\robust@def*\LTS@eval@true{% + \advance\LTS@evalcnt\if\LTS@eval@neg\m@one\else\z@pt\fi + \let\LTS@eval@neg\cptswfalse +} +\robust@def*\LTS@eval@false{% + \advance\LTS@evalcnt\if\LTS@eval@neg\z@pt\else\m@one\fi + \let\LTS@eval@neg\cptswfalse +} +\robust@def\LTS@eval@bgroup#1(#2\eval@nil{% + \LTS@eval@egroup#1)\eval@nil + \ifblankTF{#2}{}{% + \LTS@eval@beg + \LTS@eval@bgroup#2\eval@nil + }% +} +\robust@def\LTS@eval@egroup#1)#2\eval@nil{% + \LTS@eval@and#1and\eval@nil + \ifblankTF{#2}{}{% + \LTS@eval@end + \LTS@eval@egroup#2\eval@nil + }% +} +\robust@def\LTS@eval@and#1and#2\eval@nil{% + \LTS@eval@or#1or\eval@nil + \ifblankTF{#2}{}{% + \LTS@evalcnt\ifnum\LTS@evalcnt<\z@pt\m@one\else\z@pt\fi + \LTS@eval@and#2\eval@nil + }% +} +\robust@def\LTS@eval@or#1or#2\eval@nil{% + \LTS@eval@not#1not\eval@nil + \ifblankTF{#2}{}{% + \LTS@evalcnt\ifnum\LTS@evalcnt<\z@pt\z@pt\else\@ne\fi + \LTS@eval@or#2\eval@nil + }% +} +\robust@def\LTS@eval@not#1not#2\eval@nil{% + \LTS@eval@do#1eval\eval@nil + \ifblankTF{#2}{}{% + \let\LTS@eval@neg\cptswtrue + \LTS@eval@not#2\eval@nil + }% +} +\robust@def\LTS@eval@do#1eval#2\eval@nil{% + \ifblankTF{#1}{}{% + \LTS@err{Invalid 'eval' test expression} + {The invalid test part is: '\detokenize{#1}'}% + }% + \ifblankTF{#2}{}{\LTS@eval@do@a#2\eval@nil}% +} +\robust@def\LTS@eval@do@a#1#2\eval@nil{% + \ignorespaces#1\LTS@eval@true\LTS@eval@false + \LTS@eval@do#2\eval@nil +} +% Eg, +% \@tempcnta\z@pt\@tempswatrue +% \ltswhileexpr{\if@tempswa}{% +% \advance\@tempcnta\@ne +% \ifnum\@tempcnta>3\relax\@tempswafalse\fi +% } +% or +% \ltswhileexpr{eval{\ifboolTF{@tempswa}}}{% +% \advance\@tempcnta\@ne +% \ifnum\@tempcnta>3\relax\@tempswafalse\fi +% } +\robust@def*\ltswhileexpr#1#2{% + \edef\reserved@a{\cpttrimspaces{#1}}% + \xifinsetTF{\relax\detokenize{eval}}{\relax\cptoxdetok\reserved@a}{% + \LTS@whileexpr@a{#1}{#2}% + }{% + \LTS@whileexpr@b{#1}{#2}% + }% +} +\robust@def*\LTS@whileexpr@a#1#2{% + \ifboolevalTF{#1}{#2\LTS@whileexpr@a{#1}{#2}}{}% +} +\robust@def*\LTS@whileexpr@b#1#2{% + #1 \expandafter\iofii\else\expandafter\iiofii\fi + {#2\LTS@whileexpr@b{#1}{#2}}{}% +} +\packagecommands{% + \packagecommands,\AtEndOfPackage, + \ltsAtEndPackage,\AtEndOfClass,\ltsAtEndClass, + \ltsBeforeEndPackage,\ltsBeforeEndClass,\ltsAfterEndPackage, + \ltsAfterEndClass,\ifclasscurrentTF,\ifclasscurrentFT +} +\preamblecommands{% + \preamblecommands,\ltsBeforeBeginDocument,\ensurepackageloaded, + \needpackage +} + +\endinput + +%%% End of file ltxtools-base.sty %%% diff --git a/Master/texmf-dist/tex/latex/ltxtools/ltxtools-doc.sty b/Master/texmf-dist/tex/latex/ltxtools/ltxtools-doc.sty new file mode 100644 index 00000000000..de7902ea380 --- /dev/null +++ b/Master/texmf-dist/tex/latex/ltxtools/ltxtools-doc.sty @@ -0,0 +1,1318 @@ +%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++% +% % +% This is file 'ltxtools-doc.sty', version 0.0.1, December 2011. % +% % +% This package and accompanying files 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) 2011 Ahmed Musa (amusa22@gmail.com). % +% % +%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++% + +\@ifpackageloaded{ltxtools}{% + \@ifpackagelater{ltxtools}{2011/11/12}{}{% + \@latex@error{Loaded version of ltxtools package is + not current}\@ehc + }% +}{% + \RequirePackage{ltxtools}[2011/12/12]% +} +\UseNormalCatcodes +\StyleFilePurpose{Macros and interfaces for document body (AM)} +\StyleFileRCSInfo +$Id: ltxtools-doc.sty,v 0.0.1 2011/12/12 09:00:00 Ahmed Musa Exp $ +\ProvidesPackage{ltxtools-doc}[\StyleFileInfo] +\NeedsTeXFormat{LaTeX2e}[2011/06/27] +\cptloadpackages{% + ltxkeys||2011/12/10; +} +\robust@def*\useshortdoccmds{% + \let\useshortdoccmds\relax + \def\do##1##2,{% + \ifnot@nil{##1}{% + \ifdefTF{##1}{% + \ifx##1##2\else + \LTS@err{Command '\string##1' already exists:\MsgBrk + it can't be redefined by \string\useshortdoccmds}\@ehc + \fi + }{% + \let##1=##2% + }% + \do + }% + }% + \expandafter\do\LTS@shortdoccmds,\@nil,% +} +\begingroup +\endlinechar=-1 +\robust@gdef*\LTS@shortdoccmds{% + \cmdtext\ltscmdtext, + \fx\ltsfx,\ffx\ltsffx,\ffxi\ltsffxi,\ffxim\ltsffxim, + \ftffx\ltsftffx,\hx\ltshx,\hhx\ltshhx, + \fthhx\ltsfthhx,\ftfx\ltsftfx,\ftfxx\ltsftfxx,\fxim\ltsfxim, + \fxi\ltsfxi,\fxis\ltsfxis,\hxim\ltshxim,\hxi\ltshxi,\hxis\ltshxis, + \dummyfxim\ltsdummyfxim,\dummyfxi\ltsdummyfxi,\aidx\ltsaidx, + \aidxm\ltsaidxm,\aidxs\ltsaidxs,\bidx\ltsbidx,\bidxm\ltsbidxm, + \bidxs\ltsbidxs,\aiidx\ltsaiidx,\aiidxm\ltsaiidxm,\aiidxs\ltsaiidxs, + \files\ltsfiles,\file\ltsfiles,\headpkg\ltsheadpkg,\emphlist\ltsemphlist, + \quotedlist\ltsquotedlist,\pkg\ltspkg,\pkgm\ltspkgm,\pkgg\ltspkgg, + \pkgnoidx\ltspkgnoidx,\pkgs\ltspkgs, + \headquoted\ltsheadquoted,\headfx\ltsheadfx,\headhx\ltsheadhx, + \noteenv\ltsnoteenv,\endnoteenv\endltsnoteenv +} +\endgroup + +\robust@def*\LTS@sanitize{% + \let\do\@makeother + \do\\\do\$\do\&\do\#\do\^\do\_\do\%\do\~% +} +\robust@def*\ltshref{% + \begingroup + \LTS@sanitize\@makeother\|% + \expandafter\endgroup\LTS@href@a +} +\robust@def*\LTS@href@a#1{% + \edef\LTS@tempa{\cptzapspaces{#1}}% + \LTS@href@b +} +\robust@def*\LTS@href@b#1{\href{\LTS@tempa}{#1}} + +\robust@def*\LTS@writefile#1#2{% + \ifblankTF{#2}{}{% + \if@filesw + \@bsphack + \immediate\write#1{\unexpanded{#2}}% + \if@nobreak\ifvmode\nobreak\fi\fi + \@esphack + \fi + }% +} +\robust@def*\ltsensurecomma{% + \ltsifnextchar,{}{\LTS@err{Don’t forget comma}}% +} +\robust@def*\ltsmakecs#1{\texttt{\char'134\unskip#1}} +\robust@def*\ltsnohyphens{\hyphenpenalty\@M\exhyphenpenalty\@M} +\robust@def*\ltsdefinecolor{% + \let\reserved@e\definecolor + \LTS@testopt\LTS@definecolor{}% +} +\robust@def*\ltscolorlet{% + \let\reserved@e\colorlet + \LTS@testopt\LTS@definecolor{}% +} +\robust@def*\LTS@definecolor[#1]#2{% + \@ifundefinedcolor{#2}{% + \reserved@e[#1]{#2}% + }{% + \LTS@err{Color name '#2' already defined}\@ehc + }% +} +% Usage of colors defined via \ltsdefinecolorset: +% eg, \color{<head>green<tail>}, where <head>->x, <tail>->1. +\robust@def*\ltsprovidecolorset{% + \begingroup + \let\inprovide\cptswtrue + \LTS@testopt\LTS@definecolorset{x}% +} +\robust@def*\ltsdefinecolorset{% + \begingroup + \let\inprovide\cptswfalse + \LTS@testopt\LTS@definecolorset{x}% +} +\robust@def*\LTS@definecolorset[#1]{% + \cpt@testpnopt{\LTS@d@finecolorset{#1}}{1}% +} +\robust@def*\LTS@d@finecolorset#1(#2)#3{% + \ifcsndefTF{ver@xcolor.sty}{}{% + \LTS@err{'xcolor' package not loaded}\@ehc + }% + \cptemptifycsset{\LTS@tempb,\LTS@tempc,\LTS@tempd,\LTS@tempe}% + \def\LTS@tempa##1,##2,##3,##4,##5\@nil{% + \ifblankTF{##4}{% + \LTS@err{Incomplete color format in \string\ltsdefinecolorset}\@ehc + }{% + \def\reserved@e{##1}% + }% + }% + \def\csv@do##1{% + \LTS@tempa##1,,,,\@nil + \xifinsetTF{,\reserved@e,}{,\LTS@tempd,}{% + \edef\LTS@tempe{\csliststack,\LTS@tempe\reserved@e}% + }{% + \edef\LTS@tempd{\csliststack,\LTS@tempd\reserved@e}% + \@ifundefinedcolor{#1\reserved@e#2}{% + \edef\LTS@tempb{\csliststack;\LTS@tempb##1}% + }{% + \if\inprovide\else + \edef\LTS@tempc{\csliststack{;\@space}\LTS@tempc#1\reserved@e#2}% + \fi + }% + }% + }% + \csv@@parse[;]{#3}% + \ifcsemptyTF\LTS@tempe{}{% + \LTS@err{Color names '\expandcsonce\LTS@tempe' multiply + \MsgBrk submitted to \string\ltsdefinecolorset}\@ehc + }% + \ifcsemptyTF\LTS@tempc{}{% + \LTS@err{Color names '\LTS@tempc' already in use}\@ehc + }% + \ifcsemptyTF\LTS@tempb{}{% + \cptexpandarg{\xglobal\definecolorset{rgb}{#1}{#2}} + {\expandcsonce\LTS@tempb}% + }% + \endgroup +} +\robust@def*\startrecurrentlist#1{% + \gdef\recurlistnr{#1}% + \simplecmdpatch\@item{% + \if@nmbrlist\refstepcounter\@listctr\fi + }{% + \if@nmbrlist + \refstepcounter\@listctr + \ifnum\csname c@\@listctr\endcsname>#1% + \advance\csname c@\@listctr\endcsname-#1% + \fi + \fi + }% +} +\robust@def*\@endrecurlist#1{% + \simplecmdpatch\@item{% + \if@nmbrlist + \refstepcounter\@listctr + \ifnum\csname c@\@listctr\endcsname>#1% + \advance\csname c@\@listctr\endcsname-#1% + \fi + \fi + }{% + \if@nmbrlist\refstepcounter\@listctr\fi + }% +} +\robust@def*\endrecurrentlist{% + \ifdefTF\recurlistnr{}{% + \ltxmsg@err{'\string\startrecurrentlist' wasn't called before + \MsgBrk'\string\endrecurrentlist'}\@ehc + }% + \simpleexpandarg\@endrecurlist\recurlistnr + \gundefcs\recurlistnr +} + +% Eg, \uppercasefirstletter{ 0a ahmed musa } +\new@def*\LTS@nouppercaselist{a,an,any,and,or,not,for,from, + if,the,then,them,they,he,she,will,would,shall} +\robust@def*\AddToNoUppercaseList#1{% + \ltsfiltermergecsv[,]\LTS@nouppercaselist{#1}\nofilter +} +\new@def*\uppercasefirstletter#1{% + \begingroup + \@tempcnta\z@pt + \let\LTS@tempa\@empty + \expandafter\upp@rcasefirstletter\romannumeral-`\q#1 \@nil +} +\new@def*\upp@rcasefirstletter#1 #2\@nil{% + \oifinset@sp@TF,{#1}\LTS@nouppercaselist{% + \ifnum\@tempcnta=\z@pt + \upp@rc@sefirletter#1\@nil + \else + \LTS@tempa#1% + \fi + }{% + \upp@rc@sefirletter#1\@nil + }% + \advance\@tempcnta\@ne + \ifblankTF{#2}{% + \endgroup + }{% + \let\LTS@tempa\@space + \upp@rcasefirstletter#2 \@nil + }% +} +\new@def*\upp@rc@sefirletter#1#2\@nil{\uppercase{\LTS@tempa#1}#2} + +\AtBeginDocument{\newcounter{LTS@notecnt}[section]} +% For use where \@currentlabel is needed: +\robust@def*\ltsnoteenv{\cpt@testst\LTS@noteenv} +\robust@def*\LTS@noteenv{% + \let\if@notest\ifcpt@st + \stepcounter{LTS@notecnt}% + \protected@edef\@currentlabel{\thesection.\theLTS@notecnt}% + \def\@currentlabelname{note}% + \def\@currentHref{note.\@currentlabel}% + \smallbreak + \textbf{Note~\thesection.\theLTS@notecnt}\enskip + \nobreak\@nobreaktrue +} +\robust@def*\endltsnoteenv{% + \finalhyphendemerits\z@pt + \if@notest\unskip\textbullet\fi + \medbreak\@ignoretrue +} +\robust@def*\ltsnote{% + \stepcounter{LTS@notecnt}% + \smallbreak + \textbf{Note~\thesection.\theLTS@notecnt}\enskip + \nobreak\@nobreaktrue +} +\newenvironment{indentednote}{% + \stepcounter{LTS@notecnt}% + \protected@edef\@currentlabel{\thesection.\theLTS@notecnt}% + \def\@currentlabelname{note}% + \def\@currentHref{note.\@currentlabel}% + \nobreak\@nobreaktrue + \list{}{\listparindent1.5em\relax + \itemindent\listparindent\rightmargin\leftmargin + \parsep\z@pt\relax + \ifcsndefTF{ver@amverbatim.sty}{% + \vbleftmargin\leftmargin + \vbrightmargin\rightmargin + }{}% + }% + \item\hspace*{-\itemindent}% + \textbf{Note~\thesection.\theLTS@notecnt}\enskip +}{% + \endlist\medskip\@ignoretrue +} + +\patchcs\@afterheading + {\clubpenalty \@clubpenalty} + {\clubpenalties 2 \@clubpenalty 0}{}{} +\gnewletcs\rsv@afterheading\@afterheading +\lastlinefit500 +\robust@def*\docsection{% + \begingroup + \LTS@testst{\LTS@section\section}% +} +\robust@def*\docsubsection{% + \begingroup + \LTS@testst{\LTS@section\subsection}% +} +\robust@def*\docsubsubsection{% + \begingroup + \LTS@testst{\LTS@section\subsubsection}% +} +\robust@def*\docparagraph{% + \begingroup + \LTS@testst{\LTS@section\paragraph}% +} +\robust@def*\LTS@section#1{% + \edef\LTS@tempa{\noexpand#1\ifLTS@st*\fi}% + \cpt@testpnopt\LTS@s@ction{}% +} +\robust@def*\LTS@s@ction(#1){% + \cpt@testltopt{\LTS@s@cti@n{#1}}{}% +} +\robust@def*\LTS@s@cti@n#1<#2>{% + \xdef\@afterheading{% + \ifblankTF{#1}{}{\unexpanded{\label{#1}}}% + \ifblankTF{#2}{}{\unexpanded{\ltsaidxm*{#2}}}% + \expandcsonce\@afterheading + \gletcs\noexpand\@afterheading\noexpand\rsv@afterheading + }% + \expandafter\endgroup\LTS@tempa +} +\new@def*\ltsreddots#1#2{% + \begin{center}% + \def\tempa{\textcolor{red}{\vrule height1ex depth0pt width1ex}}% + \tempa\hspace{#1cm}{#2}\hspace{#1cm}\tempa + \end{center}% +} +\ltxkeys@definekeys*[LTS]{citation}[ctt@]{% + width/\hsize; + author//; + textcolor/black; + fonttype/\normalfont; + leftmargin/\leftmargin; + rightmargin/\rightmargin; + preskip/0ex +} +\ltsprotected\ltsnewcommand\ltscitation[2][]{% + \ltxkeys@launchkeys[LTS]{citation}{#1}% + \begingroup + \sbox\@tempboxa{% + \ctt@fonttype + \textit{\textcolor{\ctt@textcolor}{\ctt@author}}% + }% + \list{}{% + \setlength\leftmargin{\ctt@leftmargin}% + \setlength\rightmargin{\ctt@leftmargin}% + }% + \vspace*{\ctt@preskip}% + \item\relax\ignorespaces + \ctt@fonttype\textcolor{\ctt@textcolor}{#2}% + \hspace*{\fill}\nolinebreak[1]% + \quad\hspace*{\fill}\finalhyphendemerits\z@pt\relax + \usebox{\@tempboxa}% + \endlist + \bigskip + \endgroup + \@ignoretrue +} +\new@def*\fnquote@finalstrut#1{% + \unskip + \ifhmode + \nobreak + \vrule\@width\z@\@height\z@\@depth\dp#1% + \fi +} +\newenvironment{ltsfnquote}[1][0pt]{% + \begin{list}{}{% + \vspace*{-#1}% + \setmanytolength{\topsep,\parskip,\partopsep,\itemsep}{0em}% + }% + \item\relax +}{% + \fnquote@finalstrut\strutbox + \end{list}% +} +\ltxkeys@definekeys*[LTS]{ltsshade}[ltsshd@]{% + width/\hsize; + leftadjust/0em; + indent/0em; + fillcolor/gray!25; + framecolor/black; + framesep/3\p@; + framerule/0.4\p@ +} +\robust@def*\LTS@shadedenv{% + \def\FrameCommand{% + \clubpenalty\@m\widowpenalty\@m + \noindent\kern\ltsshd@leftadjust + \fboxrule\ltsshd@framerule\fboxsep\ltsshd@framesep + \fcolorbox{\ltsshd@framecolor}{\ltsshd@fillcolor}% + }% + \parindent\z@pt\finalhyphendemerits\z@pt + \dimensionexpr\dimen@{\ltsshd@width-(\ltsshd@framesep + +\ltsshd@framerule+\ltsshd@indent)}% + \MakeFramed{\hsize\dimen@\FrameRestore\@setminipage}% +} +\newcommand\ltsframeshade[1][]{% + \ifcsndefTF{ver@framed.sty}{% + \ltxkeys@launchkeys[LTS]{ltsshade}{#1}% + \LTS@shadedenv + }{% + \ltxmsg@err{'framed' package not loaded}\@ehc + }% +} +\robust@def*\endltsframeshade{\endMakeFramed\@ignoretrue} +\robust@def*\ltsframewithtitle{\LTS@testst\LTS@framewithtitle} +\robust@def*\LTS@framewithtitle{% + \vskip.5\baselineskip + \begin{ltsframeshade}[width=\fwt@width,fillcolor=\fwt@color, + framesep=\fwt@framesep,framerule=\fwt@framerule, + framecolor=\fwt@framecolor]% + \ifLTS@st\else + \textcolor{\fwt@titlecolor}{\fwt@format{\fwt@title}}% + \\[\fwt@titlevskip]% + \fi + \endgraf +} +\def\endframewithtitle{% + \end{ltsframeshade}\ignorespaces\@ignoretrue +} +\newcommand*\lipsumnopar[2][1]{{\def\lips@par{ }\lipsum[#1-#2]}} +\robust@def*\LTS@lipsumcolors{% + black,red,blue,green,purple,cyan,violet,orange% +} +\robust@def*\AddLipsumColors#1{% + \ltsfiltermergecsv[,]\LTS@lipsumcolors{#1}\nofilter +} +\robust@def*\ltslipsum{% + \ifcsndefTF{ver@lipsum.sty}{% + \ifcsndefTF{ver@xcolor.sty}{% + \LTS@testopt{\LTS@lipsum}{1}% + }{% + \ltxmsg@err{'xcolor' package not loaded}\@ehc + }% + }{% + \ltxmsg@err{'lipsum' package not loaded}\@ehc + }% +} +\robust@def*\LTS@lipsum[#1]{% + \pushnumber\LTS@lipsumnr + \begingroup + \@tempcnta\z@pt + \def\currcolor{}% + \def\do##1,{% + \iftokennilTF{##1}{% + \ifcsemptyTF\currcolor{% + \expandafter\do\LTS@lipsumcolors,\@nil,% + }{}% + }{% + \advance\@tempcnta by1 + \let\next\do + \ifnum\@tempcnta=\LTS@lipsumnr + \def\currcolor{##1}% + \def\next####1\@nil,{}% + \fi + \next + }% + }% + \expandafter\do\LTS@lipsumcolors,\@nil,% + \noindent\textcolor{\currcolor}{\lipsum[#1]}% + \endgroup + \smallskip +} +\new@def*\LTS@baselineskip{} +\newenvironment{ltssidetoks}[2][\marginparwidth]{% + \xdef\LTS@baselineskip{\the\dimexpr#2{\LTS@baselineskip}}% + \list{}{\leftmargin-#1}% + \nobreak\@nobreaktrue + \vspace{.5ex}% + \item[]\relax +}{% + \endgraf\nobreak\@nobreaktrue + \def\reserved@a##1##{##1\gdef\LTS@baselineskip}% + \advance\baselineskip-\expandafter\reserved@a\LTS@baselineskip + \endlist + \removelastskip +} + +\robust@def*\srefsetup#1{% + \ltxkeys@launchkeys[LTS]{ltsref}{#1}% +} +% Examples: +% \sref[sec:]{y,x,z} +% \sref*[sec:]{y,x,z} +% \srefrange[sec:]{y,x,z} +% \sref will list all the references in ascending order; +% \srefrange will list only the smallest and largest references, +% joined with a hyphen; \sref* is equivalent to \srefrange. +\robust@def*\sref{% + \begingroup + \let\LTS@inrefrng\cptswfalse + \cpt@teststopt\LTS@ref@a{}% +} +\robust@def*\srefrange{% + \begingroup + \let\LTS@inrefrng\cptswtrue + \LTS@testopt\LTS@ref@a{}% +} +\robust@def*\LTS@ref@a[#1]{% + \ifcsndefTF{ver@hyperref.sty}{}{% + \ltxmsg@warn{Package 'hyperref' not loaded: + \MsgBrk'\noexpand\sref' and '\noexpand\srefrange' can't + \MsgBrk extract reference name automatically}% + }% + \if\LTS@inrefrng\else + \ifcpt@st + \let\LTS@inrefrng\cptswtrue + \fi + \fi + \def\refbase{#1}\LTS@ref@b +} +\robust@def*\LTS@ref@b#1{% + \edef\x{\s@expandarg\cpttrimspace{\cptrm-`\q#1}}% + \ifcsemptyTF\x{}{% + \cptexpandarg\LTS@ref@c\x + }% +} +\robust@def*\LTS@ref@c#1{% + \ifcsemptyTF\refbase{% + \def\LTS@reflist{#1}% + }{% + \def\LTS@reflist{}% + \cptfor#1\dofor{% + \edef\LTS@reflist{\csliststack,\LTS@reflist\refbase##1}% + }% + }% + \def\LTS@tempa##1,##2,##3\@nil{% + \ifblankTF{##2}{% + \edef\LTS@tempa{\cpttrimspace{##1}}% + \ifdefTF\autoref\autoref\ref\LTS@tempa + }{% + \expandafter\LTS@ref@d\expandafter{\LTS@reflist}% + }% + }% + \expandafter\LTS@tempa\LTS@reflist,,\@nil + \endgroup +} +\robust@def*\LTS@ref@d#1{% + \let\ifnumtest\ifnnum + \def\LTS@reflist{}\def\LTS@r@flist{}% + \def\putref##1{% + \def\reserved@a####1##1####2####3\LTS@nil{% + \ref{####2}% + }% + \expandafter\reserved@a\LTS@r@flist\LTS@nil + }% + \def\do##1{% + \edef\LTS@reflist{\LTS@reflist{\LTS@getrefnum{##1}}}% + \edef\LTS@r@flist{\LTS@r@flist\LTS@getrefnum{##1}{##1}}% + \ifnumcmpTF\indrisnr>\@ne{% + \ifboolFT{lastindris}{}{% + \ifswitchTF{LTS@inrefrng}{% + \LTS@setrefrange\LTS@reflist + }{% + \def\sortoutputfmt####1{####1,}% + \def\sortendfmt####1{####1}% + \edef\LTS@reflist{\s@expandarg\ltssortnumlt\LTS@reflist}% + \def\do####1{% + \ifnum\indrisnr>\@ne + \iflastindris + \xifstrcmpTF\LTS@lastrefsep{and}{ and }{, }% + \else + ,\@space + \fi + \fi + \putref{####1}% + }% + \indrisloop*\LTS@reflist\do + }% + }% + }{% + \LTS@getrefname{##1}\if@tempswa s~\fi + }% + }% + \indrisloop{#1}\do +} +\def\LTS@setrefrange#1{% + \def\sortoutputfmt##1{{##1}}% + \def\sortendfmt##1{{##1}}% + \edef#1{\s@expandarg\ltssortnumlt#1}% + \def\LTS@tempa##1##2\LTS@nil{% + \putref{##1}% + \xifstrcmpTF\LTS@refrangesep{--}{--}{% + ~% + \ifnum\indrisnr=\tw@ and\else\LTS@refrangesep\fi + ~% + }% + \def\reverse####1####2{% + \expandafter\ifx\expandafter\LTS@nnil\cpt@car####2\car@nil + \expandafter\iofii\else\expandafter\iiofii\fi + {####1}{% + \expandafter\reverse\expandafter{% + \romannumeral-`\q\ifblankTF{####1}{{####2}}{{####2}####1}% + }% + }% + }% + \edef\LTS@tempb{\reverse{}##2\LTS@nnil}% + \def\LTS@tempa####1####2\LTS@nil{% + \putref{####1}% + }% + \expandafter\LTS@tempa\LTS@tempb\LTS@nil + }% + \expandafter\LTS@tempa#1\LTS@nil +} + +\def\LTS@getrefnum#1{% + \ifcsndefTF{r@#1}{% + \expandafter\expandafter\expandafter + \cpt@car\csname r@#1\endcsname\car@nil + }{% + 00% + }% +} +\def\LTS@getrefname#1{% + \@tempswafalse + \ifcsndefFT{r@#1}{}{% + \expandafter\expandafter\expandafter\LTS@getrefname@a + \csname r@#1\endcsname{}{}{}{}\LTS@nil + }% +} +\def\LTS@getrefname@a#1#2#3#4#5\LTS@nil{% + \ifblankTF{#4}{}{\LTS@getrefname@b#4.\LTS@nil}% +} +\def\LTS@getrefname@b#1.#2\LTS@nil{% + \ifcsndefTF{LTS@#1refname}{% + \@tempswatrue + \csname LTS@#1refname\endcsname + }{% + \ifcsndefTF{#1name}{% + \@tempswatrue + \cptexpanded{\cptsevenxp\cpttrimspaces + \cptthreexp{\csname#1name\endcsname}}% + }{}% + }% +} +\ltxkeys@definekeys*[LTS]{ltsref}[LTS@]{% + equationrefname/Equation/\def\equationautorefname{#1}; + footnoterefname/footnote/\def\footnoteautorefname{#1}; + itemrefname/item/\def\itemautorefname{#1}; + figurerefname/Figure/\def\figureautorefname{#1}; + tablerefname/Table/\def\tableautorefname{#1}; + partrefname/Part/\def\partautorefname{#1}; + appendixrefname/Appendix/\def\appendixautorefname{#1}; + chapterrefname/chapter/\def\chapterautorefname{#1}; + sectionrefname/section/\def\sectionautorefname{#1}; + subsectionrefname/subsection/\def\subsectionautorefname{#1}; + subsubsectionrefname/subsubsection/\def\subsubsectionautorefname{#1}; + paragraphrefname/paragraph/\def\paragraphautorefname{#1}; + subparagraphrefname/subparagraph/\def\subparagraphautorefname{#1}; + noterefname/note/\def\noteautorefname{#1}; + tablenoterefname/table note/\csndef*{table noteautorefname}{#1}; + FancyVerbLinerefname/line/\def\FancyVerbLineautorefname{#1}; + macrolinerefname/macro line/\csndef*{macro lineautorefname}{#1}; + theoremrefname/Theorem/\def\theoremautorefname{#1}; + pagerefname/page/\def\pageautorefname{#1}; + lastrefsep/and/\trim@@spaces{#1}\LTS@lastrefsep; + refrangesep/to/\trim@@spaces{#1}\LTS@refrangesep; +} +\def\setupcrefformat{% + \docommalist{algorithm,appendix,chapter,corollary,definition, + enumi,equation,example,figure,footnote,lemma,line,note,part, + proposition,remark,result,section,table,theorem + }{% + \crefformat{##1}{####2##1~####1####3}% + }% +} +\robust@def*\printcommalist{\cpt@testst\lts@printcommalist} +\robust@def*\lts@printcommalist#1{% + \cpt@stchoose{cpt@st}{#1}\lts@tempa\printcommalist + \def\do##1{% + \ifnum\indrisnr>\@ne + \iflastindris\@space and\@space\else,\@space\fi + \fi + ##1% + }% + \indrisloop*\lts@tempa\do +} +\robust@def*\ltsnobreakitem{\cpt@teststopt\lts@nobreakitem} +\robust@def*\lts@nobreakitem[#1]#2{% + \item~\nopagebreak\\[-\baselineskip]% + \ifcpt@st + \centerline{\includegraphics[#1]{#2}}% + \else + #2% + \fi +} +\newtog{normallongtable} +\AfterStartOfDocument{% + \ifdefTF\LT@start{% + \patchcs\LT@start + {\vfil\break} + {\iftogTF{normallongtable}{\vfil\break}{}} + {\LTS@info{Patching of \noexpand\longtable succeeded}} + {\LTS@warn{Patching of \noexpand\longtable failed}}% + \patchcs\LT@start + {\penalty\z@} + {\iftogTF{normallongtable}{\penalty\z@}{}} + {\LTS@info{Patching of \noexpand\longtable succeeded}} + {\LTS@warn{Patching of \noexpand\longtable failed}}% + }{}% +} +\robust@def\ltsnewfootnote#1{\newcsndef*{LTS@footnote@#1}} +\newcommand*\usefootnote[1]{% + \footnote{\uselivecsn{LTS@footnote@#1}}% + \AtEndDocument{\letcsntocs{LTS@footnote@#1}\relax}% +} +\AtBeginDocument{\newcounter{LTS@ltablenotecnt}[table]} +\new@def\ltablenotehead#1{\noalign{\LTS@ltablenotehead{#1}}} +\robust@def*\LTS@ltablenotehead{% + \def\ltnotehead{00}% + \LTS@teststopt\LTS@ltablenote{}% +} +\new@def*\LTS@ltablenoteshook{} +\robust@def*\ltablenote{% + \def\ltnotehead{01}% + \LTS@teststopt\LTS@ltablenote{}% +} +\robust@def*\LTS@ltablenote[#1]#2{% + \unskip + \ifblankTF{#1}{}{\label{#1}}% + \begin{LTS@uselt@blenote}{#2}\end{LTS@uselt@blenote}% +} +\robust@def\newltablenote#1{\newcsndef*{LTS@ltablenote@id@#1}} +\robust@def*\useltablenote{% + \def\ltnotehead{01}\LTS@teststopt\LTS@useltablenote{}% +} +\robust@def*\LTS@useltablenote[#1]#2{% + \unskip + \ifcsndefTF{LTS@ltablenote@id@#2}{% + \ifblankTF{#1}{}{\label{#1}}% + \begin{LTS@uselt@blenote}% + {\usename{LTS@ltablenote@id@#2}}% + \end{LTS@uselt@blenote}% + \AtEndDocument{\letcsntocs{LTS@ltablenote@id@#2}\relax}% + }{% + \LTS@err{Table note '#2' is undefined}\@ehc + }% +} +\cptnewvariables{dimen}{ltnotenrwidth}[14pt] +\newenvironment{LTS@uselt@blenote}[1]{% + \if\ltnotehead\else + \stepcounter{LTS@ltablenotecnt}% + \ifcsndefTF{ver@hyperref.sty}{% + \protected@edef\@currentlabel{\thetable.\theLTS@ltablenotecnt}% + \def\@currentlabelname{tablenote}% + \def\@currentHref{table note.\@currentlabel}% + }{% + \let\hyperlink\@secondoftwo + \let\hypertarget\@secondoftwo + }% + \@killglue + \hyperlink{hy@ltablenote\thetable.\theLTS@ltablenotecnt}{% + \textsuperscript{% + \ifnum\theLTS@ltablenotecnt=1 See note~\fi + \thetable.\theLTS@ltablenotecnt + }% + }% + \fi + \xdef\LTS@ltablenoteshook{% + \noindent + \expandcsonce\LTS@ltablenoteshook + \if\ltnotehead + \unexpanded{{\noexpand\normalfont\small#1}}% + \endgraf + \else + \ifLTS@st\else\endgraf\fi + \noexpand\makebox[\the\ltnotenrwidth]\ifLTS@st[r]\else[l]\fi{% + \noexpand + \hypertarget{hy@ltablenote\thetable.\theLTS@ltablenotecnt}{% + \noexpand\textsuperscript{\noexpand + \textcolor{blue}{\thetable.\theLTS@ltablenotecnt}% + }% + }% + \ifLTS@st\else\hfill\fi + }% + \unexpanded{#1}% + \fi + }% +}{% + \@ignoretrue +} +\robust@def*\printltablenotes{% + \begingroup + \clubpenalty\@m\widowpenalty\@m + \finalhyphendemerits\z@pt + \ifdim\parindent=0pt + \leftskip=20pt + \else + \leftskip=\parindent + \fi + \rightskip=\leftskip + \let\ltsfx\ltsftfx + \let\fx\ltsfx + \footnotesize + \endgraf + \centerline{\textbf{Table \thetable\ notes}}% + \endgraf\nobreak\@nobreaktrue + \removelastskip\noindent + \ifcsndefTF{ver@hyperref.sty}{}{% + \let\hyperlink\@secondoftwo + \let\hypertarget\@secondoftwo + }% + \LTS@ltablenoteshook + \endgraf + \endgroup +} +\AfterStartOfDocument{% + \def\LTS@tempa{\ifcsemptyTF\LTS@ltablenoteshook{}\printltablenotes}% + \ifdefTF\longtable{% + \edef\longtable{% + \gdef\noexpand\LTS@ltablenoteshook{}% + \expandcsonce\longtable + }% + \edef\endlongtable{% + \expandcsonce\endlongtable + \expandcsonce\LTS@tempa + }% + }{% + \edef\tabular{% + \gdef\noexpand\LTS@ltablenoteshook{}% + \expandcsonce\tabular + }% + \edef\endtabular{% + \expandcsonce\endtabular + \expandcsonce\LTS@tempa + }% + }% + \ifdefTF\Hy@chapterstring + {\@onelevel@sanitize\Hy@chapterstring}{}% +} + +\new@def*\titleurltext{} +\robust@def*\titleurl#1{% + \ifblankTF{#1}{% + \cpt@err{Empty title url}\@ehc + }% + \def\titleurltext{#1}% + \ifpdfTF{}{% + \def\reserved@a##1/##2/##3/##4\LTS@nil{% + \def\titleurltext{##1/##2/##3/}% + }% + \reserved@a#1///\LTS@nil + }% +} +\robust@def*\LTS@titaurefcnterr#1#2{% + \LTS@err{#1 reference counter too large: > \number#2}\@ehc +} +\robust@def*\LTS@titaureflabel#1#2#3{% + \ifcsndefTF{LTS@titaunote@#2}{% + \ifnum\usename{LTS@titaunote@#2}=#3\relax + \else + \LTS@warn{#1 references may be inconsistent}% + \fi + }{% + \csn@xdef{LTS@titaunote@#2}{#3}% + }% +} +\new@def*\LTS@gettitaunotenr#1{% + \ifcsndefFT{LTS@titaunote@#1}{0}{\usename{LTS@titaunote@#1}}% +} +\new@def*\LTS@savenotes#1#2#3#4{% + \def\LTS@s@venotes##1\sep##2\LTS@nil##3{% + \def\nextnote{##2}% + \edef\reserved@a{% + \let\if\intitle\unexpanded{\intitle\cptswtrue}\else + \unexpanded{\intitle\cptswfalse}\fi + }% + \def\reserved@b{\grightaddtocsn{LTS@#1noteshook}}% + \expandafter\reserved@b\expandafter{% + \reserved@a + \advance\usename{LTS@#1notenr}\@ne + \immediate\write\@auxout{% + \string\LTS@titaureflabel{#1}{##3}{\the\usename{LTS@#1notenr}}% + }% + \def\thefootnote{% + \makebox[1em][l]{% + \if\intitle + \ifcase\usename{LTS@#1notenr}\or#2\or#3\or#4\else + \LTS@titaurefcnterr{Title}{3}\fi + \else + \ifnum\usename{LTS@#1notenr}>20\relax + \LTS@titaurefcnterr{Author}{20}% + \else + \the\usename{LTS@#1notenr}% + \fi + \fi + }% + }% + \footnotetext{##1}% + }% + }% + \AtEndDocument{% + \ifcsndefFT{LTS@#1reftotal}{}{% + \ifnum\usename{LTS@#1reftotal}=\usename{LTS@#1notetotal}\relax + \else + \LTS@err{Number of #1 references not equal to + \MsgBrk number of #1 notes}\@ehc + \fi + }% + }% +} +\cptchardef\LTS@titlereftotal=0 +\cptchardef\LTS@titlenotetotal=0 +\cptchardef\LTS@authorreftotal=0 +\cptchardef\LTS@authornotetotal=0 +\new@def*\LTS@checknotes#1#2#3{% + \ifblankTF{#2}{% + \ifblankTF{#3}{}{% + \LTS@err{Empty #1 references with nonempty #1 notes}\@ehc + }% + }{% + \ifblankTF{#3}{% + \LTS@err{Empty #1 notes with nonempty #1 references}\@ehc + }{}% + }% + \def\LTS@tempb##1##2##3{% + ##3\z@pt + \def\LTS@tempc####1##1####2\LTS@nil{% + \ifblankTF{####2}{% + \advance##3\@ne + }{% + \advance##3\@ne + \LTS@tempc####2\LTS@nil + }% + }% + \LTS@tempc##2##1\LTS@nil + }% + \LTS@tempb,{#2}\@tempcnta + \LTS@tempb\sep{#3}\@tempcntb + \ifnum\@tempcnta=\@tempcntb\else\ltsafterfi + \LTS@err{Number of #1 references doesn't match + \MsgBrk that of #1 notes}\@ehc + \ltsfi + \csnnumadd!{LTS@#1notetotal}\@tempcnta +} +\robust@def*\LTS@gettitaureftotal#1#2{% + \cptelementcount[,]{#2}% + \csnnumadd!{LTS@#1reftotal}\cptelemnr +} +\cptnewvariables{count}[LTS@]{titlenotenr} +% Eg, \titleref{a1,a2} +\robust@def*\titleref#1{% + \LTS@gettitaureftotal{title}{#1}% + \unskip + \textsuperscript{% + \cptfor#1\dofor{% + \ifcase\LTS@gettitaunotenr{##1}\or\ding{'111}% + \or,\ding{'110}\or,\ding{'112}\else + \LTS@titaurefcnterr{Title}{3}\fi\hss + }% + }% +} +% \titlenote[a1,a2]{xxx\sep yyy} +% or \titlenote[a1]{xxx} and \titlenote[a2]{yyy} +\robust@def*\titlenotes{\LTS@testopt\LTS@titlenotes{}} +\newletcs\titlenote\titlenotes +\robust@def*\LTS@titlenotes[#1]#2{% + \ifcsndefTF{ver@pifont.sty}{}{% + \@latex@error{Package 'pifont' not loaded}\@ehc + }% + \begingroup + \LTS@checknotes{title}{#1}{#2}% + \let\intitle\cptswtrue + \LTS@savenotes{title}{\ding{'111}}{\ding{'110}}{\ding{'112}}% + \def\nextnote{#2\sep}% + \cptfor#1\dofor{% + \expandafter\LTS@s@venotes\nextnote\LTS@nil{##1}% + }% + \endgroup +} +\cptnewvariables{count}[LTS@]{authornotenr} +% Eg, \authorref{a1,a2,a3} +\robust@def*\authorref#1{% + \LTS@gettitaureftotal{author}{#1}% + \unskip + \textsuperscript{% + \def\do##1{% + \edef\reserved@a{\LTS@gettitaunotenr{##1}}% + \ifnum\reserved@a>20\relax + \LTS@titaurefcnterr{Author}{20}% + \else + \reserved@a\iflastfox\else,\fi + \fi + \hss + }% + \cfoxloop{#1}\do + }% +} +% Eg, \authornotes[a1,a2]{xxx\sep yyy} +\robust@def*\authornotes{\LTS@testopt\LTS@authornotes{}} +\newletcs\authornote\authornotes +\robust@def*\LTS@authornotes[#1]#2{% + \begingroup + \LTS@checknotes{author}{#1}{#2}% + \cpt@swafalse + \let\intitle\cptswfalse + \LTS@savenotes{author}{}{}{}% + \def\nextnote{#2\sep}% + \cptfor#1\dofor{% + \expandafter\LTS@s@venotes\nextnote\LTS@nil{##1}% + }% + \endgroup +} +% New footnote numbering scheme: +\ltxkeys@definekeys[LTS]{ltsfn}[LTS@]{% + fnmarkwidth/1.4em; + fnmarknrmax/9/ + \ifnum#1>9\relax + \def\LTS@fnmarkwidth{1.5em}% + \else + \ifnum#1>99\relax + \def\LTS@fnmarkwidth{2.5em}% + \fi + \fi; +} +\robust@def*\setfnnrwidth#1{% + \ltxkeys@launchkeys[LTS]{ltsfn}{#1}% +} +\cptnewvariables{count}[LTS@]{fncnta,fncntb} +\LTS@fncnta\@ne +\LTS@fncntb\z@pt +\robust@def*\LTS@fnsymbool#1{% + \begingroup + \let\s\ensuremath + \ifcase#1\or\ding{'110}\or\s\dagger\or\s\ddagger\or + \s\mathsection\or\s\mathparagraph\or\s{||}\or\ding{'111}\or + \ding{'122}\or\ding{'106}\or\ding{'121}\or\ding{'112}\or + \ding{'113}\or\ding{'114}\or\s\bullet\else + \@ctrerr\fi + \endgroup +} +\new@def*\lts@verbatimmatcmdhook{} +\robust@def*\ltsverbatimmatcmds#1{% + \ltsfiltermergecsv[,]\lts@verbatimmatcmdhook{#1}\nofilter +} +\ltsverbatimmatcmds{\iflacus,\dolacus,\then} +\robust@def*\ltsfootnote#1{% + \ifcsndefTF{ver@pifont.sty}{}{% + \@latex@error{Package 'pifont' not loaded}\@ehc + }% + \ifcsndefTF{ver@hyperref.sty}{}{% + \let\hyperlink\@secondoftwo + \let\hypertarget\@secondoftwo + }% + \global\advance\LTS@fncntb\@ne + \ifnum\LTS@fncntb>\LTS@fnmarknrmax\relax + \LTS@fncntb\@ne + \global\advance\LTS@fncnta\@ne + \fi + \unskip + \hyperlink{hy@ltsfn\number\LTS@fncnta\number\LTS@fncntb}{% + \textsuperscript{% + \LTS@fnsymbool{\number\LTS@fncnta}\number\LTS@fncntb + }% + }% + \begingroup + \def\thefootnote{% + \ltsprotectedtokens{\hypertarget}% + {hy@ltsfn\number\LTS@fncnta\number\LTS@fncntb}{% + \hb@xt@\LTS@fnmarkwidth{\LTS@fnsymbool + {\number\LTS@fncnta}\number\LTS@fncntb\hss}% + }% + }% + \cptexpandbracenext\cptletmanytocs\lts@verbatimmatcmdhook\relax + \footnotetext{#1}% + \endgroup +} +%% Creating and listing tags in document. +% \begin{document} +% \ltstags{Physics}% Ignored: no section +% \section{Einstein} +% Double tag entry in the same section takes only one: +% \ltstags{Physics, Mathematics, Physics} +% \section{D. E. Knuth} +% \ltstags{Computer Science, Art, Physics} +% \section{Riemann} +% \ltstags{Mathematics, Art} +% \noprinttags{Computer Science, Literature} +% \ltsprinttags +% \end{document} +\new@def*\lts@taghook{} +\robust@def*\ltstags#1{% + \iflacus#1\dolacus\else + \ifnum\c@section=\z@pt\else + \docommalist{#1}{% + \oifinsetTF{##1}\lts@taghook{% + \def\reserved@a####1##1####2####3\@nil{% + \xifinsetTF{\cptoxdetok{\expandafter{\the\c@section}}}% + {\detokenize{####2}}{}{% + \xdef\lts@taghook{####1;##1{####2{\the\c@section}};####3}% + }% + }% + \expandafter\reserved@a\lts@taghook\@nil + }{% + \xdef\lts@taghook{\cptliststack;\lts@taghook##1{{\the\c@section}}}% + }% + }% + \fi + \fi +} +\def\ltsignoretags#1{% + \cptfiltermergecsv\lts@tagignore{#1}\nofilter +} +\robust@def*\ltsprinttags{% + \ifx\protect\@typeset@protect + \def\csv@do##1{% + \defpass\LTS@tempa####1####{% + \defpass\LTS@tempa########1\@nil{% + \oifinset@sp@TF,{####1}\lts@tagignore{}{% + \def\LTS@tempb{########1}% + \cptnumbersort\LTS@tempb<% + \cptexpandbracenext\lts@formattagsecnos\LTS@tempb + \ltstagnameformat{####1}: % + See section\ifnum\LTS@tempc=\@ne\else s\fi~% + \def\do################1{% + \ifnum\indrisnr>\@ne + \iflastindris\@space and\@space\else,\@space\fi + \fi + ################1% + }% + \indrisloop*\LTS@tempb\do + \ltstagseparator + }% + }% + }% + ##1\@nil + }% + \csv@@parse*[;]\lts@taghook + \else + \@latex@error{Wrong location of '\string\ltsprinttags'}\@ehc + \fi +} +\robust@def*\lts@formattagsecnos#1{% + \begingroup + \@tempcnta\z@pt + \def\LTS@tempb{}% + \def\do##1##2\@nil{% + \ifblankTF{##1}{% + \do##2\@nil + }{% + \advance\@tempcnta\@ne + \edef\LTS@tempb{\cptliststack,\LTS@tempb##1}% + \ifnot@nil{##2}{\do##2\@nil}% + }% + }% + \do#1{\@nil}\@nil + \cptexpanded{\endgroup + \def\noexpand\LTS@tempb{\LTS@tempb}% + \def\noexpand\LTS@tempc{\number\@tempcnta}% + }% +} +\newletcsset{\ltstag=\ltstags,\noprinttags=\ltsignoretags, + \ltstagseparator=\newline,\ltstagnameformat=\textit} + +%% Footnotes at end of paragraphs. +% \begin{ltsparnotes} +% xyz\ltsparnote{This is a paragraph note.} abc. +% \end{ltsparnotes} +\newletcs\ltsparnotesnosep\medbreak +\def\defineparnoteskeys{% + \ltxkeys@declarekeys*[PNT]{parnotes}[lts@pnt]{% + cmd/notecolor/black; + cmd/noteformat/\@firstofone; + cmd/notefont/\footnotesize; + cmd/markformat/\@firstofone; + cmd/vskip/\medskipamount; + cmd/interskip/.5em; + }% +} +\protected\def\declareparnotesformat#1{% + \ifdefTF\PNT@parnotes@notecolor{}\defineparnoteskeys + \ltxkeys@setkeys[PNT]{parnotes}{#1}% +} +\newcommand*\lts@pnthook{} +\newcount\lts@pntcnta +\robust@def*\ltsparnote#1{% + \ifdefTF\PNT@parnotes@notecolor{}{% + \LTS@err{You haven't called the command + \MsgBrk'\string\defineparnoteskeys'}\@ehc + }% + \ifxTF\protect\@typeset@protect{% + \global\advance\lts@pntcnta\@ne + \xdef\lts@pnthook{% + \expandcsonce\lts@pnthook + \begingroup + \noindent + \expandcsonce\lts@pntnotefont + \noexpand\color{\lts@pntnotecolor}% + \expandcsonce\lts@pntmarkformat{% + \noexpand\textsuperscript{\number\lts@pntcnta}% + }% + \expandcsonce\lts@pntnoteformat{\unexpanded{~#1}}% + \noexpand\hspace{\lts@pntinterskip}% + \endgroup + }% + \ifvmode\else\unskip\fi + \lts@pntmarkformat{\textsuperscript{\number\lts@pntcnta}}% + }{}% +} +\protected\def\lts@pntprint{% + \lts@pnthook + \global\lts@pntcnta\z@ + \gdef\lts@pnthook{}% + \lts@pntorigpar + \vspace{\lts@pntvskip}% + \@afterindentfalse\@afterheading +} +\newenvironment{ltsparnotes}{% + \let\lts@pntorigpar\par + \def\par{% + \lts@pntorigpar + \ifxTF\lts@pnthook\@empty{}{% + \vspace{\lts@pntvskip}% + \parskip\z@ + \lts@pntprint + }% + }% +}{% + \ifxTF\lts@pnthook\@empty{}{% + \lts@pntorigpar + \vspace{\lts@pntvskip}% + \parskip\z@ + \lts@pntprint + }% + \lts@pntorigpar + % \par returns to its default definition outside the 'parnotes' + % environment. + \@ignoretrue +} +%% Define counters that have the property that they're printed only +% when/if they're called more than once in a run. +% Eg, +% \DefineDiscCounterKeys +% \DefineDiscCounters[numbertype=\arabic]{counterone,countertwo} +% \begin{document} +% \begin{enumerate} +% \item \showcounterone \showcounterone \showcounterone \resetcounterone +% \item \showcounterone[numbertype=\arabic] +% \showcounterone[numbertype=\alph]\showcounterone[numbertype=\Alph]% +% \resetcounterone +% \item \showcounterone \resetcounterone +% \end{enumerate} +\def\DefineDiscCounterKeys{% + \ltxkeys@declarekeys*[DC]{disccount}[disc@]{% + cmd/format/\@firstofone; + cmd/numbertype/\arabic/ + \ifescapedTF{##1}{% + \xifinsetTF{,\detokenize{##1},}{% + ,\detokenize{\arabic,\alph,\Alph},% + }{}{% + \@latex@error{Invalid number type '\detokenize{##1}'}\@ehc + }% + }{% + \@latex@error{Number type '\detokenize{##1}' must be escaped}\@ehc + }; + }% +} +\newcounter{disccounter@aux} +\AtBeginDocument{% + \ifdefTF\disccounter@hook{}{\def\disccounter@hook{}}% +} +\newcommand*\discc@unter@aux{\the\numexpr\thedisccounter@aux-20000\relax} +\robust@def*\DefineDiscCounters{\cpt@testopt\disc@definecounters{}} +\robust@def*\disc@definecounters[#1]#2{% + \ifdefTF\DC@disccount@format{}{% + \LTS@err{You haven't called the command + \MsgBrk'\string\DefineDiscCounterKeys'}\@ehc + }% + \cptexpandargonce{\ltxkeys@setkeys[DC]{disccount}}{#1}% + \setcounter{disccounter@aux}{0}% + \docommalist{#2}{% + \newcounter{##1}% + \expandafter\newcommand\csname show##1\endcsname[1][]{% + \stepcounter{##1}% + \stepcounter{disccounter@aux}% + \cptexpandargonce{\ltxkeys@setkeys[DC]{disccount}}{####1}% + \xifinsetTF{,##1@reset@\discc@unter@aux,}% + {,\disccounter@hook,}{}{\disc@format{\disc@numbertype{##1}}}% + }% + \csn@def{reset##1}{% + \ifnum\csname c@##1\endcsname=\@ne + \xifinsetTF{,##1@reset@\discc@unter@aux,}{,\disccounter@hook,}{}{% + \xdef\disccounter@hook{% + \ifcsemptyTF\disccounter@hook{}{\disccounter@hook,}% + ##1@reset@\discc@unter@aux + }% + }% + \fi + \setcounter{##1}{0}% + }% + }% +} +\AtEndDocument{% + \if@filesw + \immediate\write\@auxout{% + \gdef\string\disccounter@hook{\disccounter@hook}% + }% + \else + \@latex@warning@no@line{File '\jobname.aux' not open}% + \fi +} +\newcommand*\discbraced[1]{{\tt\string{#1\string}}} +\robust@def*\ltsgarbagetext{\cpt@testopt\lts@garbagetext{5}} +\robust@def*\lts@garbagetext[#1]{% + \begingroup + \chardef\nr1 + \loop + \noindent Some sample text here. Some more sample text. + And more sample text. + \pushnumber\nr + \ifnum\nr<#1\relax + \repeat + \endgroup +} + +\endinput diff --git a/Master/texmf-dist/tex/latex/ltxtools/ltxtools-environ.sty b/Master/texmf-dist/tex/latex/ltxtools/ltxtools-environ.sty new file mode 100644 index 00000000000..978b8143a3e --- /dev/null +++ b/Master/texmf-dist/tex/latex/ltxtools/ltxtools-environ.sty @@ -0,0 +1,137 @@ +%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++% +% % +% This is file 'ltxtools-environ.sty', version 0.0.1, December 2011. % +% % +% This package and accompanying files 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) 2011 Ahmed Musa (amusa22@gmail.com). % +% % +%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++% + +\@ifpackageloaded{catoptions}{}{\RequirePackage{catoptions}[2011/12/12]} +\@ifpackageloaded{ltxtools}{}{\RequirePackage{ltxtools}[2011/12/12]} +\UseNormalCatcodes +\StyleFilePurpose{Collect and execute environment body (AM)} +\StyleFileRCSInfo +$Id: ltxtools-environ.sty,v 0.0.1 2011/12/12 09:00:00 Ahmed Musa Exp $ +\ProvidesPackage{ltxtools-environ}[\StyleFileInfo] +\NeedsTeXFormat{LaTeX2e}[2011/06/27] + +% \newenviron, \renewenviron {<name>}{<start>}<body>{<end>}. +% Collect environment body in \envbody: +\new@def*\AlwaysTrimEnvEntries{\global\LTS@alwaystrimtrue} +\new@def*\trimenvspaces{% + \ifboolTF{LTS@alwaystrim}\cpttrimspaces\unexpanded +} +\new@def*\everyeoenv#1{\ltsfiltermergetsv\LTS@everyeoenv{#1}\nofilter} +\everyeoenv{\@ignoretrue} +\robust@def*\newenviron{\cpt@starorlong\LTS@newenviron} +\robust@def*\LTS@newenviron#1{% + \edef\LTS@tempa{\trimenvspaces{#1}}% + \cptexpandarg\cpt@testopt + {\LTS@n@wenviron{\expandcsonce\LTS@tempa}}0% +} +\robust@def*\LTS@n@wenviron#1[#2]{% + \cpt@ifbrack + {\LTS@n@wenv@ron#1[#2]} + {\LTS@n@wenv@r@n{#1}{[#2]}}% +} +\robust@def*\LTS@n@wenv@ron#1[#2][#3]{\LTS@n@wenv@r@n{#1}{[#2][{#3}]}} +\robust@def*\renewenviron{\cpt@starorlong\LTS@renewenviron} +\robust@def*\LTS@renewenviron#1{% + \edef\LTS@tempa{\trimenvspaces{#1}}% + \ifcsndefTF\LTS@tempa{} + {\@latex@error{Environment #1 is undefined}\@ehc}% + \letcsntocs\LTS@tempa\relax + \letcsntocs{end\LTS@tempa}\relax + \expandafter\LTS@newenviron\expandafter{\LTS@tempa}% +} +\robust@def\LTS@n@wenv@r@n#1#2#3#4{% + \ifcsndefTF{#1}{}{\letcsntocsn{#1}{end#1}}% + \aftercsname\new@command{#1}#2{% + \edef\LTS@beforebody{\trimenvspaces{#3}}% + \LTS@collectbody + }% + \l@ngrel@x\csn@edef{end#1}{% + \begingroup + \defpass\noexpand\x{\endgroup\trimenvspaces{#4}}% + }% +} +\robust@def*\LTS@collectbody{% + \begingroup + \toks@{}% + \everyeof{\end{EOF}\relax}% + \LTS@coll@ctbody +} +\robust@def\LTS@coll@ctbody#1\end#2{% + \toks1{% + \cptexpanded{% + \toks@{\the\toks@\trimenvspaces{#1}% + \noexpand\end{\expandcsonce\LTS@tempa}}% + }% + \LTS@coll@ctbody + }% + \edef\LTS@tempa{\trimenvspaces{#2}}% + \ifxTF\LTS@tempa\@currenvir{% + \edef\LTS@tempb{\LTS@pushbegin#1\begin\end\cpt@relax}% + \if@csemptyTF\LTS@tempb{% + \cptexpandsecond\endgroup{% + \edef\noexpand\envbody{\noexpand\unexpanded{% + \the\toks@\ifblankTF{#1}{}{\trimenvspaces{#1}}% + }}% + \unexpanded{% + \LTS@beforebody\relax\LTS@everyeoenv + \ifboolTF{LTS@alwaystrim}\@ignoretrue\relax + }% + \noexpand\end{\LTS@tempa}% + }% + }{% + \the\toks1 + }% + }{% + \oifstrcmpTF{\LTS@tempa}{document}{% + \expandafter\endgroup\expandafter + \@checkend\expandafter{\LTS@tempa}% + }{% + \oifstrcmpTF{\LTS@tempa}{EOF}{% + \expandafter\endgroup\expandafter + \@checkend\expandafter{\LTS@tempa}% + }{% + \the\toks1 + }% + }% + }% +} +\new@def\LTS@pushbegin#1\begin#2{% + \expandafter\ifxTF\cpt@car#2x\car@nil\end{% + \@gobble + }{% + \expandafter\swapbracefirst\expandafter + {\romannumeral-`\q\cptoxdetok\LTS@tempa} + {\expandafter\ifstrcmpTF\expandafter + {\detokenize\expandafter{\romannumeral-`\q + \trimenvspaces{#2}}}}{% + x\cptgobbletorelax + }{% + \LTS@pushbegin + }% + }% +} +\XDeclareBooleanOption{alwaystrim}[true](LTS@){}{} +\XDeclareOption*{\LTS@warn{Unknown option '\CurrentOption' ignored}} +\XExecuteOptions{alwaystrim} +\XProcessOptions*\relax + +\endinput diff --git a/Master/texmf-dist/tex/latex/ltxtools/ltxtools-incluput.sty b/Master/texmf-dist/tex/latex/ltxtools/ltxtools-incluput.sty new file mode 100644 index 00000000000..b7262a4979b --- /dev/null +++ b/Master/texmf-dist/tex/latex/ltxtools/ltxtools-incluput.sty @@ -0,0 +1,193 @@ +%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++% +% This is file ltxtools-incluput.sty, version 0.0.1, December 2011. % +% % +% It can be used to input standalone subsidiary documents without % +% also including their preamble and/or postamble. Files can be % +% 'inputted' or 'included'. % +% % +% If you enter 'persistent=false' in the call to the package, % +% you would have to put \let\documentclass\ltxtools-incluput at the top % +% of every file to be included in the main document, otherwise enter it % +% only in the first file to be input. % +% % +% Use the 'nested' option to input documents that themselves input % +% other documents. % +% % +% 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. % +% % +% Copyright (c) 2011 Ahmed Musa (a.musa@rocketmail.com). % +% % +%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++% + +\@ifpackageloaded{ltxtools}{% + \@ifpackagelater{ltxtools}{2011/12/12}{}{% + \@latex@error{Loaded version of ltxtools package is + not current}\@ehc + }% +}{% + \RequirePackage{ltxtools}[2011/12/12]% +} +\@ifpackageloaded{ltxkeys}{% + \@ifpackagelater{ltxkeys}{2011/12/12}{}{% + \@latex@error{Loaded version of ltxkeys package is + not current}\@ehc + }% +}{% + \RequirePackage{ltxkeys}[2011/12/12]% +} +\UseNormalCatcodes +\StyleFilePurpose{Input standalone documents (AM)} +\StyleFileRCSInfo +$Id: ltxtools-incluput.sty,v 0.0.1 2011/12/12 09:00:00 Ahmed Musa Exp $ +\ProvidesPackage{ltxtools-incluput}[\StyleFileInfo] +\NeedsTeXFormat{LaTeX2e}[2011/06/27] +\SetStyleFileMessages[inclp@]{info}{warn}{err} +\ifx\documentclass\@twoclasseserror\else + \inclp@err{Package 'ltxtools-incluput' can't be loaded + \MsgBrk outside document preamble}\@ehc +\fi +\AfterStartOfDocument{% + \ifoneloadedTF{% + docmute,standalone,fileimport-filedate + }{% + \inclp@err{Package 'ltxtools-incluput' can't be used + \MsgBrk with package '\ltspkgcls'}\@ehc + \expandafter\endinput + }% + \ifinclp@useincluput + \gletcs\documentclass\incluput + \incluputtrue + \else + \incluputfalse + \fi +} +\cptnewbools{incluput} +\def\inclp@gobblepreamble{% + \begingroup + \everyeof{\begin{EOF}\relax}% + \inclp@g@bblepreamble +} +\long\def\inclp@g@bblepreamble#1\begin#2{% + \ifstrcmpTF{#2}{document}{% + \endgroup + \ifinclp@persistent\else + \let\documentclass\@twoclasseserror + \fi + \inclp@afterpreamble + }{% + \ifstrcmpTF{#2}{EOF}{% + \endgroup\endinput + }{% + \inclp@g@bblepreamble + }% + }% +} +\let\inclp@document\document +\let\inclp@enddocument\enddocument +\let\inclp@afterbegindoc\relax +\def\inclp@beforeenddoc{% + \let\enddocument\inclp@enddocument + \ifinclp@persistent\else + \incluputfalse + \fi + \begingroup +} +\def\inclp@afterpreamble{% + \inclp@afterbegindoc + \def\enddocument{% + \inclp@beforeenddoc + \endinput + \aftergroup\ignorespaces + }% + \ignorespaces +} +\newletcs\incluput\inclp@gobblepreamble +\ltxkeys@boolkey[KV]{incluput}[inclp@]{useincluput}[true]{} +\ltxkeys@boolkey[KV]{incluput}[inclp@]{persistent}[true]{% + \ifinclp@persistent + \def\document{% + \inclp@document + \let\documentclass\incluput + }% + \fi +} +\ltxkeys@boolkey[KV]{incluput}[inclp@]{nested}[true]{% + \ifinclp@nested + \let\inclp@afterbegindoc\begingroup + \let\inclp@beforeenddoc\relax + \else + \inclp@info{Option 'nested' is false}% + \fi +} +\ltxkeys@declareoption*{% + \inclp@warn{Unknown option '#3' with value '#4' ignored}% +} +\ltxkeys@executeoptions[KV]<incluput>{persistent,useincluput=false} +\ltxkeys@processoptions*[KV]<incluput>\relax +\providecommand*\input@path{} +\robust@def*\InputDocument{% + \let\inclp@input\@@input + \inclp@inputdocument +} +\robust@def*\IncludeDocument{% + \let\inclp@input\include + \inclp@inputdocument +} +\robust@def*\inclp@inputdocument{% + \ifinclp@persistent\else + \inclp@warn{Option 'persistent' is false.\MsgBrk + If you don't want to set 'persistent=true',\MsgBrk + then you must put '\detokenize{\let\documentclass\incluput}'% + \MsgBrk at the top of each document to input, + \MsgBrk ie, before the \string\documentclass + }% + \fi + \gletcs\inclp@inputpath\input@path + \let\inclp@newgeometry\newgeometry + \let\inclp@restoregeometry\restoregeometry + \let\newgeometry\@gobble + \let\restoregeometry\relax + \cpt@teststopt\inclp@inputfile{.}% +} +\new@def*\inclp@inputfile[#1]#2{% + \ifblankTF{#1}{}{% + \edef\input@path{\expandcsonce\input@path{#1/}}% + }% + \ifboolTF{cpt@st}{% + \inclp@inp@tfile{#2}% + }{% + \ifcsndefTF{#2@readx}{% + \inclp@info{File '#2' already read:\MsgBrk + File '#2' wasn't read again}% + }{% + \inclp@inp@tfile{#2}% + }% + }% +} +\new@def*\inclp@inp@tfile#1{% + \IfFileExists{#1}{% + \inclp@input\@filef@und + \letcsntocs{#1@readx}\noboundary + \inclp@afterfileinput + }{% + \typein[\answer]{^^J! File '\string#1' does not exist. + ^^JEnter filename or 'x' and <return> to continue.}% + \def\reserved@a{x}% + \ifxTF\answer\reserved@a{% + \inclp@afterfileinput + }{% + \cptexpandarg{\inclp@inputfile[]}\answer + }% + }% +} +\new@def*\inclp@afterfileinput{% + \gletcs\input@path\inclp@inputpath + \let\newgeometry\inclp@newgeometry + \let\restoregeometry\inclp@restoregeometry +} + +\endinput diff --git a/Master/texmf-dist/tex/latex/ltxtools/ltxtools-index.sty b/Master/texmf-dist/tex/latex/ltxtools/ltxtools-index.sty new file mode 100644 index 00000000000..11687978088 --- /dev/null +++ b/Master/texmf-dist/tex/latex/ltxtools/ltxtools-index.sty @@ -0,0 +1,597 @@ +%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++% +% This is file 'ltxtools-index.sty', version 0.0.1, December 2011. % +% % +% This package and accompanying files 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) 2011 Ahmed Musa (amusa22@gmail.com). % +%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++% + +\@ifpackageloaded{ltxtools}{% + \@ifpackagelater{ltxtools}{2011/12/12}{}{% + \@latex@error{Loaded version of ltxtools package is + not current}\@ehc + }% +}{% + \RequirePackage{ltxtools}[2011/12/12]% +} +\UseNormalCatcodes +\StyleFilePurpose{Macros and interfaces for index-related tasks (AM)} +\StyleFileRCSInfo +$Id: ltxtools-index.sty,v 0.0.1 2011/12/12 09:00:00 Ahmed Musa Exp $ +\ProvidesPackage{ltxtools-index}[\StyleFileInfo] +\NeedsTeXFormat{LaTeX2e}[2011/06/27] +\loadifnotloaded{ltxtools-doc}[2011/12/12] +\cptloadpackages{% + ltxkeys||2011/12/12; + xcolor|table,dvipsnames,hyperref|2007/01/21; +} +\ltsprovidecolorset[x](1){% + green,0.00,0.59,0.00;brown,0.50,0.25,0.00; + teal,0.00,0.82,0.82;magenta,0.44,0.00,0.87; + purple,0.50,0.00,0.25 +} +\cptnewvariables{if}[LTS@]{mainidx,noidx} +\ltxkeys@declarekeys*(cmd)[LTS]{ltxtools-index}[LTS@]{% + stylecolor/xgreen1; + cmdcolor/xmagenta1; + speccolor/xteal1; + texcolor/Maroon; + macrocolor/blue; + examplecolor/teal; +} +\ltxkeys@declarekeys*(bool)[LTS]{ltxtools-index}[LTS@]{% + fancypages/true; +} +\ltxkeys@declareoption*{% + \ltxkeys@getpvalnopad + \ltxmsg@warn{Unknown option '\CurrentKey' with + value '\InnocentVal' ignored}% +} +%\ltxkeys@executeoptions[LTS]<ltxtools-index>{}\relax +\ltxkeys@processoptions*[LTS]<ltxtools-index>\relax +\ltsAtBeginDocument{% + \ltscolorlet{ltsmacrocolor}{\LTS@macrocolor}% + \ltscolorlet{ltsspeccolor}{\LTS@speccolor}% + \ltscolorlet{ltstexcolor}{\LTS@texcolor}% + \ltscolorlet{ltscmdcolor}{\LTS@cmdcolor}% + \ltscolorlet{ltsstylecolor}{\LTS@stylecolor}% + \ltscolorlet{ltsdoccolor}{black}% +} +\robust@def*\ltsdonotindex#1{% + \cptexpandarg{\ltsfiltermergecsv\LTS@donotindex@hook} + {\detokenize{#1}}\nofilter +} +\ltsdonotindex{\begingroup,\endgroup,\bgroup,\egroup} +\ltsdonotindex{\def,\edef,\xdef,\global,\long,\let,\newcommand} +\ltsdonotindex{\expandafter,\noexpand,\unexpanded,\string,\csname} +\ltsdonotindex{\if,\ifcase,\else,\fi,\or,\relax,\iftrue,\iffalse} +\ltsdonotindex{draft,final,true,false} + +\robust@def*\ltsdollar{\ifmmode\mathdollar\else\texttt{\char`\$}\fi} +\robust@def*\ltsleftbrace{\ifmmode\lbrace\else\texttt{\char`\{}\fi} +\robust@def*\ltsrightbrace{\ifmmode\rbrace\else\texttt{\char`\}}\fi} +\robust@def*\ltsunderscore{% + \ifmmode\nfss@text{\textunderscore}\else\texttt{\char`\_}\fi +} +\robust@def*\ltstypeset{% + \begingroup\LTS@sanitize\LTS@testcl\LTS@typeset +} +\robust@def*\LTS@typeset#1#2{% + \edef\LTS@tempa{\detokenize{#2}}% + \ifLTS@cl + \edef\LTS@tempa{\s@expandarg\cptzapspaces\LTS@tempa}% + \else + \despacecontent\LTS@tempa + \fi + \texttt{\textcolor{#1}{\expandcsonce\LTS@tempa}}% + \endgroup +} +\robust@def*\ltscmdtypeset{% + \begingroup + \LTS@sanitize\LTS@testcl\LTS@cmdtypeset +} +\robust@def*\LTS@cmdtypeset#1{% + \edef\reserved@a{\ifLTS@cl!\fi}% + \expandafter\endgroup\expandafter + \ltstypeset\reserved@a{ltscmdcolor}{#1}% +} +\robust@def*\ltscmdfamily{\color{ltscmdcolor}\ttfamily} +\robust@def*\ltscmdtext{\begingroup\LTS@sanitize\LTS@cmdtext} +\robust@def*\LTS@cmdtext#1{\endgroup\textcolor{ltscmdcolor}{\texttt{#1}}} +\new@def*\ltsheadquoted#1{\ltsneverexpand{\quoted{#1}}} +\new@def*\ltsheadfx#1{\ltsneverexpand{\ltsfx{#1}}} +\new@def*\ltsheadhx#1{\ltsneverexpand{\ltshx{#1}}} +\new@def*\quotedfxx#1{{\NoWrapQuotes\quoted{\ftfxx{#1}}}}% \quotedFx +\new@def*\quotedfx{% + \begingroup + \@makeother{\#}\LTS@quotedfx +} +\new@def*\LTS@quotedfx#1{% + \NoWrapQuotes\quoted{\ltsftfx{#1}}% + \endgroup +} +\new@def*\quotedhx{% + \begingroup + \@makeother{\#}\LTS@quotedhx +} +\new@def*\LTS@quotedhx#1{% + \NoWrapQuotes\quoted{\ltsfthx{#1}}% + \endgroup +} +\robust@def*\ltsfx{% + \def\LTS@currcolor{ltscmdcolor}% + \begingroup + \LTS@sanitize\LTS@teststcl\LTS@fx +} +\robust@def\LTS@fx#1{% + \edef\LTS@tempb{\detokenize{#1}}% + \ifLTS@cl + \let\LTS@tempa\cptzapspaces + \else + \ifLTS@st + \let\LTS@tempa\cptzapspaces + \else + \let\LTS@tempa\cpttrimspace + \fi + \fi + \cptexpanded{% + \noexpand\textcolor{\LTS@currcolor}% + {\noexpand\texttt{\s@expandarg\LTS@tempa\LTS@tempb}}% + }% + \endgroup +} +\robust@def*\ampfx#1#{% + \def\LTS@currcolor{ltscmdcolor}% + \amp@fx{#1}% +} +\robust@def\amp@fx#1#2{% + \begingroup + \edef\LTS@tempb{\detokenize{#2}}% + \def\test##1##2{\ifinsetTF{##2}{##1}}% + \cptifcasse\test{#1} + {!}{\let\LTS@tempa\cptzapspaces} + {*}{\let\LTS@tempa\cptzapspaces} + \elseif + \let\LTS@tempa\cpttrimspace + \endif + \cptexpanded{% + \noexpand\textcolor{\LTS@currcolor}% + {\noexpand\texttt{\s@expandarg\LTS@tempa\LTS@tempb}}% + }% + \endgroup +} +\robust@def*\ltsftfx{% + \@tempswatrue + \def\LTS@currcolor{ltscmdcolor}% + \LTS@teststcl\LTS@footfx +} +\robust@def*\ltsfthx{% + \@tempswatrue + \def\LTS@currcolor{ltstexcolor}% + \LTS@teststcl\LTS@footfx +} +\robust@def*\ltsftfxx{% + \@tempswafalse + \def\LTS@currcolor{ltscmdcolor}% + \LTS@teststcl\LTS@footfx +} +\robust@def*\LTS@footfx#1{% + \edef\LTS@tempb{\detokenize{#1}}% + \ifLTS@cl + \let\LTS@tempa\cptzapspaces + \else + \ifLTS@st + \let\LTS@tempa\cptzapspaces + \else + \let\LTS@tempa\cpttrimspace + \if@tempswa + \LTS@footfxparse\LTS@tempb + \fi + \fi + \fi + \cptexpanded{% + \noexpand\textcolor{\LTS@currcolor}% + {\noexpand\texttt{\s@expandarg\LTS@tempa\LTS@tempb}}% + }% +} +\robust@def*\LTS@footfxparse#1{% + \begingroup + \s@expandarg\cpt@pophash#1#1% + \LTS@putspaceafter#1\cpt@leftbracechar + \edef\x##1{##1\expandcsonce{#1}\@space\LTS@nil}% + \edef\y##1{\def##1####1\@space####2\LTS@nil}% + \y\y{% + \ifblankTF{##2}{% + \toks@\expandafter{\the\toks@##1}% + }{% + \if\@backslashchar\cpt@car##1x\car@nil + \toks@\expandafter{\the\toks@##1}% + \else + \ltsgetlasttsv{##1}% + \if\last\cpt@leftbracechar + \toks@\expandafter{\the\toks@##1}% + \else + \cptexpanded{\toks@{\the\toks@\unexpanded{##1}\@space}}% + \fi + \fi + \y##2\LTS@nil + }% + }% + \x{\toks@{}\y}% + \edef#1{\the\toks@}% + \postgroupdef#1\endgroup +} +\robust@def\LTS@putspaceafter#1#2{% + \begingroup + \toks@{}% + \xifinsetTF{#2}{\detokenize\expandafter{#1}}{% + \edef\x##1{##1\detokenize\expandafter{#1}#2\LTS@nil}% + \edef\y##1{\def##1####1#2####2\LTS@nil}% + \y\y{% + \ifblankTF{##2}{% + \toks@\expandafter{\the\toks@##1}% + }{% + \cptexpanded{\toks@{\the\toks@##1#2\@space}}% + \y##2\LTS@nil + }% + }% + \x{\toks@{}\y}% + }{% + \toks@\expandafter{\detokenize\expandafter{#1}}% + }% + \edef#1{\the\toks@}% + \postgroupdef#1\endgroup +} +\robust@def*\ltsifcsvfinal{% + \ifnum\indrisnr>\@ne + \iflastindris + \ifLTS@pm\@space and\else,\fi\@space + \else + ,\@space + \fi + \fi +} +\robust@def*\ltsffx{% + \LTS@teststclpm{% + \def\LTS@currcolor{ltscmdcolor}% + \begingroup\LTS@sanitize\expandafter\endgroup\LTS@ffx + }% +} +\robust@def*\LTS@ffx#1{% + \def\do##1{% + \ltsifcsvfinal + \edef\LTS@tempa{\s@expandarg\cpttrimspace{\detokenize{##1}}}% + \texttt{\textcolor{\LTS@currcolor}{\LTS@tempa}}% + }% + \indrisloop{#1}\do +} +\robust@def*\ltsftffx{% + \LTS@teststclpm{% + \def\LTS@currcolor{ltscmdcolor}% + \LTS@ftffx + }% +} +\robust@def*\ltsfthhx{% + \LTS@teststclpm{% + \def\LTS@currcolor{ltstexcolor}% + \LTS@ftffx + }% +} +\robust@def*\LTS@ftffx#1{% + \edef\LTS@tempa{\detokenize{#1}}% + \s@expandarg\cpt@pophash\LTS@tempa\LTS@tempa + \expandafter\LTS@ffx\expandafter{\LTS@tempa}% +} +\robust@def*\ltshx{% + \def\LTS@currcolor{ltstexcolor}% + \begingroup\LTS@sanitize\LTS@teststclpm\LTS@fx +} +\robust@def*\ltshhx{% + \LTS@teststclpm{% + \def\LTS@currcolor{ltstexcolor}% + \begingroup\LTS@sanitize\expandafter\endgroup\LTS@ffx + }% +} +% Indexing command syntax: +% * (star) -> print #1 only in index, else print also at place of call. +% ' (prime) -> zap spaces, else trim spaces. +\robust@def*\LTS@fxidx#1#2#3{% + \usename{LTS@mainidx#1}% + \let\LTS@texttt\texttt + \def\LTS@currcolor{#2}% + \LTS@teststclpm{\begingroup\LTS@sanitize\usename{LTS@fxi@#3}}% +} +\robust@def*\ltsfxim{\LTS@fxidx{true}{ltscmdcolor}{a}} +\newletcs\ltsffxim\ltsfxim +\robust@def*\ltsfxi{\LTS@fxidx{false}{ltscmdcolor}{a}} +\newletcs\ltsffxi\ltsfxi +\robust@def*\ltsfxis{\LTS@fxidx{false}{ltscmdcolor}{b}} +\robust@def*\ltshxim{\LTS@fxidx{true}{ltstexcolor}{a}} +\robust@def*\ltshxi{\LTS@fxidx{false}{ltstexcolor}{a}} +\robust@def*\ltshxis{\LTS@fxidx{false}{ltstexcolor}{b}} +\robust@def*\LTS@zaportrim#1{% + \begingroup + \edef\x##1{##1{\detokenize{#1}}}% + \xdef\zaportrim@res{% + \ifboolTF{LTS@cl}{\x\cptzapspaces}{\x\cpttrimspace}% + }% + \endgroup +} +\robust@def*\LTS@fxi@a#1{\LTS@fxi@b{#1}{}} +\robust@def*\LTS@fxi@b#1#2{% + \endgroup + \edef\LTS@tempb{\s@expandarg\cpttrimspace{\detokenize{#2}}}% + \def\do##1{% + \LTS@zaportrim{##1}% + \ifLTS@st\else + \ltsifcsvfinal + \cptexpandsecond\textcolor + {{\LTS@currcolor}{\LTS@texttt{\zaportrim@res}}}% + \fi + \cptexpanded{\LTS@indexentry{}{\zaportrim@res}{\LTS@tempb}}% + }% + \indrisloop{#1}\do +} +\robust@def*\ltsdummyfxim{\LTS@teststclpm\LTS@dummyfxi} +\robust@def*\ltsdummyfxi{\LTS@teststclpm\LTS@dummyfxi} +\robust@def*\LTS@dummyfxi#1{} +\robust@def*\LTS@aidx#1#2#3{% + \usename{LTS@mainidx#1}% + \let\LTS@texttt\@iden + \def\LTS@currcolor{#2}% + \LTS@teststclpm{% + \begingroup + \LTS@sanitize + \usename{LTS@fxi@#3}% + }% +} +\robust@def*\ltsaidx{\LTS@aidx{false}{ltsdoccolor}{a}} +\robust@def*\ltsaidxm{\LTS@aidx{true}{ltsdoccolor}{a}} +% Index entries with |see reference ('s' refers to 'see'); +% 'm' -> main (with \underbar): +\robust@def*\ltsaidxs{\LTS@aidx{false}{ltsdoccolor}{b}} +\robust@def*\ltsbidx{\LTS@aidx{false}{ltsspeccolor}{a}} +\robust@def*\ltsbidxm{\LTS@aidx{true}{ltsspeccolor}{a}} +\robust@def*\ltsbidxs{\LTS@aidx{false}{ltsspeccolor}{b}} +% Italicize or apply something to the first word. +% Because of the need to sort the entries, it is usually +% more difficult to apply something to the first word. +% Eg, \ltsaiidxs[\emph,Choice keys]{nominations xxx \emph{yyy}}{zzz} +\robust@def*\ltsaiidx{\LTS@aiidx{false}{ltsdoccolor}{a}} +\robust@def*\ltsaiidxm{\LTS@aiidx{true}{ltsdoccolor}{a}} +\robust@def*\ltsaiidxs{\LTS@aiidx{false}{ltsdoccolor}{b}} +\robust@def*\LTS@aiidx#1#2#3{% + \usename{LTS@mainidx#1}% + \def\LTS@currcolor{#2}% + \LTS@teststclpm{\cpt@testopt{\usename{LTS@fxii@#3}}{}}% +} +\robust@def*\LTS@fxii@a[#1]#2{\LTS@fxii@b[#1]{#2}{}} +\robust@def*\LTS@fxii@b[#1]#2#3{% + \begingroup + \def\reserved@a##1,##2,##3\LTS@nil{% + \def\format{##1}\def\mainentry{##2}% + }% + \reserved@a#1,,\LTS@nil + \def\getfirstword##1 ##2\LTS@nil{% + \def\firstword{##1}\def\rmwords{##2}% + }% + \edef\LTS@tempb{\cpttrimspace{#3}}% + \def\do##1{% + \edef\LTS@tempc{\cpttrimspace{##1}}% + \cptthreexp\getfirstword\expandafter\LTS@tempc\@space\LTS@nil + \ifLTS@st\else + \ltsifcsvfinal + \cptexpandsecond\textcolor{{\LTS@currcolor}{\LTS@tempc}}% + \fi + \cptexpanded{\LTS@iindexentry{\mainentry}{\LTS@tempc}{\LTS@tempb}}% + }% + \indrisloop{#2}\do + \endgroup +} +\robust@def*\ltsfiles{\LTS@files@a{false}{b}} +\newletcs\ltsfile\ltsfiles +\robust@def*\ltsfilesm{\LTS@files@a{true}{b}} +\robust@def*\ltsfiless{\LTS@files@a{false}{c}} +\robust@def*\LTS@files@a#1#2{% + \usename{LTS@mainidx#1}% + \LTS@teststclpm{% + \begingroup + \LTS@sanitize + \cpt@testopt{\usename{LTS@files@#2}}{tex}% + }% +} +\robust@def*\LTS@files@b[#1]#2{\LTS@files@c[#1]{#2}{}} +\robust@def*\LTS@files@c[#1]#2#3{% + \endgroup + \def\LTS@currcolor{ltsstylecolor}% + \edef\LTS@tempb{\s@expandarg\cptzapspaces{\detokenize{#1}}}% + \edef\LTS@tempa{\s@expandarg\cptzapspaces{\detokenize{#2}}}% + \def\do##1{% + \ifLTS@st\else + \ltsifcsvfinal + \cptexpanded{\ltstypeset{ltsstylecolor}{##1.\LTS@tempb}}% + \fi + \cptexpanded{\LTS@indexentry{Files}{##1.\LTS@tempb}{#3}}% + }% + \indrisloop*\LTS@tempa\do +} +\robust@def*\ltsemphlist{% + \LTS@teststpm{\begingroup\LTS@sanitize\LTS@emph\emph}% +} +\robust@def*\ltsquotedlist{% + \LTS@teststpm{\begingroup\LTS@sanitize\LTS@emph\quoted}% +} +\robust@def*\LTS@emph#1#2{% + \xdef\@gtempa{\ifLTS@st*\fi}% + \endgroup + \def\do##1{% + \ltsifcsvfinal + \edef\LTS@tempa{\s@expandarg\cpttrimspace{##1}}% + #1{\LTS@tempa}% + }% + \expandafter\indrisloop\@gtempa{#2}\do +} +\new@def*\ltsheadpkg#1{\ltsneverexpand{\ltspkg{#1}}} +\robust@def*\ltspkgnoidx{% + \LTS@mainidxfalse\LTS@noidxtrue + \LTS@teststclpm\LTS@pkg@a +} +\newletcs\ltspkgg=\ltspkgnoidx +\robust@def*\ltspkg{% + \LTS@mainidxfalse\LTS@noidxfalse + \LTS@teststclpm\LTS@pkg@a +} +\robust@def*\ltspkgm{% |underbar + \LTS@mainidxtrue\LTS@noidxfalse + \LTS@teststclpm\LTS@pkg@a +} +\robust@def*\ltspkgs{% |see + \LTS@mainidxfalse\LTS@noidxfalse + \LTS@teststclpm\LTS@pkg@b +} +\robust@def*\LTS@pkg@a#1{\LTS@pkg@b{#1}{}} +\robust@def*\LTS@pkg@b#1#2{% + \edef\LTS@tempa{\s@expandarg\cptzapspaces{\detokenize{#1}}}% + \edef\LTS@tempb{\s@expandarg\cptzapspaces{\detokenize{#2}}}% + \def\LTS@currcolor{ltsstylecolor}% + \def\do##1{% + \ifLTS@st\else + \ltsifcsvfinal + \textcolor{ltsstylecolor}{\texttt{##1}}% + \fi + \ifLTS@noidx\else + \cptexpanded{\LTS@indexentry{Packages}{##1}{\LTS@tempb}}% + \fi + \let\LTS@tempc\indrisnr + }% + \indrisloop*\LTS@tempa\do + \ifLTS@st\else + \ifLTS@pm\@space package\ifnum\LTS@tempc>1 s\fi\fi + \fi +} +\robust@def*\LTS@indremovescape#1{% + \ifblankTF{#1}{\cpt@isblankerr\LTS@indremovescape}{}% + \let\LTS@putbs\cptswfalse + \edef\LTS@tempa{\s@expandarg\cpttrimspace{\detokenize{#1}}}% + \if\@backslashchar\expandafter\LTS@car\LTS@tempa x\car@nil + \let\LTS@putbs\cptswtrue + \edef\LTS@remscape@res{\expandafter\@gobble\LTS@tempa}% + \else + \let\LTS@remscape@res\LTS@tempa + \fi +} +\robust@def*\ifindexthis#1{% + \LTS@indremovescape{#1}% + \xifinsetTF{,\cptoxdetok\LTS@tempa,}{,\LTS@donotindex@hook,}% + \@gobble\@iden +} +\robust@def*\LTS@decidebackslash#1{% + \if\LTS@putbs + \def#1{\texttt{\symbol{'134}}}% + \else + \def#1{}% + \fi +} +\ifcsdefinable\LTS@currcolor\relax +\AfterStartOfDocument{% + \newletcs\LTS@indexcmd\index +} +\robust@def*\LTS@indexentry#1#2#3{% + \begingroup + \ifindexthis{#2}{% + \let\idxitem@a\LTS@remscape@res + \ifLTS@mainidx + \ifblankTF{#3}{}{% + \ltxmsg@err{Main index entry can't have '|see'}\@ehc + }% + \fi + \ifboolTF{LTS@cl}\LTS@detok@zap\despacecontent\idxitem@a + \LTS@decidebackslash\idxbs@a + \ifblankTF{#3}{}{% + \LTS@indremovescape{#3}% + \let\idxitem@b\LTS@remscape@res + \LTS@decidebackslash\idxbs@b + }% + \let\x\noexpand + \cptexpanded{% + \x\LTS@indexcmd{\ifblankTF{#1}{}{#1>}% + \idxitem@a=\x\textcolor{\LTS@currcolor}% + {\x\texttt{\idxbs@a\idxitem@a}}% + \ifLTS@mainidx|underbar\fi + \ifblankTF{#3}{}{% + |see{\x\texttt{\x\textcolor{\LTS@currcolor}% + {\idxbs@b\idxitem@b}}}% + }% + }% + }% + }% + \endgroup +} +\robust@def*\LTS@iindexentry#1#2#3{% + \ifindexthis{#2}{% + \cptexpanded{% + \noexpand\LTS@indexcmd{% + \ifblankTF{#1}{}{#1>}% + #2=\noexpand\textcolor{\LTS@currcolor}{% + \format{\firstword}% + \ifx\rmwords\@empty\else\@space\rmwords\fi + }% + \ifLTS@mainidx|underbar\fi + \ifblankTF{#3}{}{% + |see{\noexpand\textcolor{\LTS@currcolor}{#3}}% + }% + }% + }% + }% +} +\robust@def*\LTS@helv{\fontfamily{phv}\selectfont\color{blue}} +\robust@def\ltsindexpreamble#1{\long\def\LTS@idxpreamble{#1}} +\cptemptify\LTS@idxpreamble +\robust@def*\ltsindexpreambleformat#1{\long\def\LTS@idxpreamblefmt{#1}} +\newletcs\LTS@idxpreamblefmt\relax +\cptnewvariables{count}{ltsindexcolumns}[2] +\AfterStartOfDocument{% + \renewenvironment{theindex}{% + \begin{multicols}{\ltsindexcolumns}% + [\vspace{2\baselineskip}\centerline{\indexname}% + \LTS@idxpreamblefmt\LTS@idxpreamble][5\baselineskip]% + \addcontentsline{toc}{section}{Index}% + \ifLTS@fancypages\pagestyle{fancyplain}\fi + \def\indexspace{\endgraf\vskip5\p@\@plus\p@\@minus\p@}% + \def\@idxitem{% + \endgraf\vskip-.5\baselineskip\@plus\p@\@minus\p@ + \hangindent40\p@ + }% + \patchcs\endtrivlist{% + \if@newlist + \@noitemerr + \global\@newlistfalse + \fi + }{% + \if@newlist + \ltxmsg@warn{Nested center environment possibly + occurred\on@line}% + \global\@newlistfalse + \fi + }{}{}% + \let\item\@idxitem + \small + }{% + \end{multicols}% + \@ignoretrue + }% +} + +\endinput diff --git a/Master/texmf-dist/tex/latex/ltxtools/ltxtools-review.sty b/Master/texmf-dist/tex/latex/ltxtools/ltxtools-review.sty new file mode 100644 index 00000000000..9f944ef33d5 --- /dev/null +++ b/Master/texmf-dist/tex/latex/ltxtools/ltxtools-review.sty @@ -0,0 +1,1043 @@ +%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++% +% % +% This is file 'reviewtools.sty', version 0.0.1, December 2011 % +% % +% This package and accompanying files 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) 2011 Ahmed Musa (a.musa@rocketmail.com). % +% % +%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++% + +\@ifpackageloaded{catoptions}{% + \@ifpackagelater{catoptions}{2011/12/12}{}{% + \@latex@error{Loaded version of catoptions package is + not current}\@ehc + }% +}{% + \RequirePackage{catoptions}[2011/12/12]% +} +\UseNormalCatcodes +\StyleFilePurpose{Multipurpose document review tools (AM)} +\StyleFileRCSInfo +$Id: reviewtools.sty,v 0.0.1 2011/12/12 09:00:00 Ahmed Musa Exp $ +\ProvidesClass{reviewtools}[\StyleFileInfo] +\NeedsTeXFormat{LaTeX2e}[2011/06/27] +\SetStyleFileMessages[rvt@]{info}{warn}{err} +\cptloadpackages{% + ltxkeys||2011/09/10; + graphicx||1999/02/16; + bigfoot||2006/07/15; + xcolor|table,dvipsnames,hyperref|2007/01/21; + marginfix||2010/08/18; + amsmath; + amssymb||2002/01/22; + ltxtools-environ||2010/05/20; +} +\DeclareNewFootnote[plain]{default} +\DeclareNewFootnote[plain]{B}[alph] +% Footnote type 1: +\MakeSortedPerPage[1]{footnoteB} +\setlength{\skip\footinsB}{2\p@ minus 1\p@} +\newcounter{rvt@altfoota} +\renewcommand*\thervt@altfoota{\Alph{rvt@altfoota}} +\MakeSortedPerPage[1]{rvt@altfoota} +% Footnote type 2: +\WithSuffix\def\footnotedefault'{% + \refstepcounter{rvt@altfoota}% + \Footnotedefault{\thervt@altfoota}% +} +\newcounter{rvt@altfootb} +\renewcommand*\thervt@altfootb{\roman{rvt@altfootb}} +% Footnote type 3: +\MakeSortedPerPage[1]{rvt@altfootb} +\WithSuffix\def\footnotedefault*{% + \refstepcounter{rvt@altfootb}% + \Footnotedefault{\thervt@altfootb}% +} +\newletcs\footnotewithsymbol\Footnote +\everyeoenv{\ignorespacesafterend} +\new@def*\PrintNotes{\global\rvt@printnotestrue} +\new@def*\NoPrintNotes{\global\rvt@printnotesfalse} +\newletcs\rvt@nil\relax +\new@def*\rvt@nnil{\rvt@nil} +\newcommand\rvt@startfile[2][\jobname]{% + \begingroup + \makeatletter + \if@filesw + \expandafter\newwrite\csname rvtf@#2\endcsname + \immediate\openout\csname rvtf@#2\endcsname=#1.#2\relax + \else + \rvt@warn{\string\nofiles: can't start file #1.#2}% + \fi + \@nobreakfalse + \endgroup + \AtEndDocument{% + \if@filesw\closeout\csname rvtf@#2\endcsname\fi + }% +} +\newcommand\rvt@writefile[3][\jobname]{% + \if@filesw + \ifcsndefTF{rvtf@#2}{% + \rvt@writetofile{\usename{rvtf@#2}}{}{#3}% + }{% + \rvt@err{File #1.#2 not open}\@ehc + }% + \else + \rvt@warn{\string\nofiles: can't write to file #1.#2}% + \fi +} +\new@def*\rvt@verbfileheader#1{% + \edef\reserved@c{\noexpandcsn{rvtf@#1}}% + \immediate\write\reserved@c{% + \@percentchar\@percentchar\space + Notes file `\jobname.\rvt@verbfile'^^J% + \@percentchar\@percentchar\space generated by the + `rvtwriteverb' environment^^J% + \@percentchar\@percentchar\space from source `\jobname' on + \number\year/\two@digits\month/\two@digits\day.^^J% + \@percentchar\@percentchar + }% +} +\edef\@percentchar{\expandafter\@gobble\string\%} +% Package options: +\ltxkeys@definekeys*[RVT]{revtools}[rvt@]{% + showreviewer/true; + shownotetype/true; + printnotes/true; + final/true; + draft/true/\ifboolTF{rvt@draft}{\setaliaskey{final}[false]}{}; + writenotes/true; + notecolor/ForestGreen; + deletecolor/BurntOrange; + deletedcolor/pink; + addcolor/red; + wipcolor/purple; + \needvalue{reviewer}/Rev?; + verbfileext/vbm/ + \cptstripallouterbraces{#1}\rvt@verbfileext + \edef\rvt@verbfileext{\s@expandarg\cpttrimspaces\rvt@verbfileext}; + openverbfile/true/ + \ifrvt@openverbfile + \rvt@startfile\rvt@verbfileext + \rvt@verbfileheader\rvt@verbfileext + \fi; +} +\ltxkeys@optionkeys[RVT]{revtools}{openverbfile,verbfileext} +\ltxkeys@declareoption*{\rvt@warn{Unknown option '\CurrentOption' ignored}} +\ltxkeys@executeoptions[RVT]<revtools>{shownotetype,printnotes,final} +\ltxkeys@processoptions*[RVT]<revtools>\relax +\robust@def*\rvtoptions#1{\ltxkeys@setkeys[RVT]{revtools}{#1}} +\ltxkeys@reservekeyprefix*{RVT} +\ltxkeys@reservemacroprefix*{rvt@} +\ltxkeys@reservekeyfamily*{revtools} + +\new@def*\rvt@optprinthook{} +\robust@def*\rvtoptprint#1{% + \ltsfiltermergecsv\rvt@optprinthook{#1}\nofilter +} + +% Optional print 'opt2' and 'opt3' only: +% \rvtoptprint{opt2,opt3} + +% 'opt1' will be ignored, while 'opt2' and 'opt3' will +% be printed even as they appear inside ignored command +% or environment ('opt1'): + +% Nested optional print command: +% \rvtoptcmd{opt1}{...\rvtoptcmd{opt2}{...\rvtoptcmd{opt3}{...}}} + +% Nested optional print environment: +% \rvtbegin{rvtopt}{opt1} +% ... +% \rvtbegin{rvtopt}{opt2}% +% ... +% \rvtbegin{rvtopt}{opt3}% +% ... +% \rvtend{rvtopt}{opt3}% +% ... +% \rvtend{rvtopt}{opt2}% +% ... +% \rvtend{rvtopt}{opt1} + +\newcommand\rvtoptcmd[2]{% + \oifinset@sp@TF,{#1}\rvt@optprinthook{% + #2\relax + }{% + \long\def\reserved@a##1\rvtoptcmd##2##3##4\rvt@nil{% + \edef\reserved@a{\unexpanded{##3}}% + \ifcseqTF\reserved@a\rvt@nnil{}{% + \rvtoptcmd{##2}{##3}% + }% + }% + \reserved@a#2\rvtoptcmd{\rvt@nil}{\rvt@nil}\rvt@nil + }% +} +\def\rvtnewenvironment{\cpt@starorlong\rvt@newenvironment} +\def\rvt@newenvironment#1{\cpt@testopt{\rvt@newenva#1}0} +\def\rvt@newenva#1[#2]{% + \cpt@ifbrack{\rvt@newenvb{#1}{#2}}{\rvt@newenv{#1}{[#2]}}% +} +\def\rvt@newenvb#1#2[#3]{\rvt@newenv{#1}{[#2][{#3}]}} +\def\rvtrenewenvironment{\@star@or@long\rvt@renewenvironment} +\def\rvt@renewenvironment#1{% + \@ifundefined{#1}{% + \@latex@error{Environment #1 undefined}\@ehc + }{}% + \expandafter\let\csname#1\endcsname\relax + \expandafter\let\csname rvtend#1\endcsname\relax + \rvt@newenvironment{#1}% +} +\long\def\rvt@newenv#1#2#3#4{% + \@ifundefined{#1}{\letcsntocsn{#1}{rvtend#1}}{}% + \aftercsname\new@command{#1}#2{#3}% + \l@ngrel@x\csn@def{rvtend#1}{#4}% +} +\newletcs\rvtbegin\begin +\new@def*\rvtend#1{% + \csname rvtend#1\endcsname\@checkend{#1}% + \expandafter\endgroup\if@endpe\@doendpe\fi + \rvt@gobbletoend +} +\new@def\rvt@gobbletoend#1#{\@gobble} +\rvtnewenvironment{rvtopt}[1]{% + \oifinset@sp@TF,{#1}\rvt@optprinthook{}{% + \begingroup + \toks@{}% + \long\def\rvt@processbody##1\rvtend##2##3{% + \def\reserved@a{##2}% + \ifcseqTF\reserved@a\@currenvir{% + \ifstrcmpTF{##3}{#1}{% + \edef\rvt@tempa{\the\toks@}% + \postgroupdef\rvt@tempa\endgroup + \ifcseqTF\rvt@tempa\@empty{% + \expandafter\endgroup\if@endpe\@doendpe\fi + }{% + \long\def\reserved@a####1\rvtbegin{\rvtbegin}% + \expandafter\reserved@a\rvt@tempa + \expandafter\endgroup\if@endpe\@doendpe\fi + }% + }{% + \toks@\expandafter{\the\toks@##1\rvtend{##2}{##3}}% + \rvt@processbody + }% + }{% + \toks@\expandafter{\the\toks@##1\rvtend{##2}{##3}}% + \rvt@processbody + }% + }% + \rvt@processbody + }% +}{} + +\robust@def*\rvtdefinecolor{% + \let\reserved@e\definecolor + \cpt@testopt\rvt@definecolor{}% +} +\robust@def*\rvtcolorlet{% + \let\reserved@e\colorlet + \cpt@testopt\rvt@definecolor{}% +} +\robust@def*\rvt@definecolor[#1]#2{% + \@ifundefinedcolor{#2}{% + \reserved@e[#1]{#2}% + }{% + \rvt@err{Color name '#2' already defined}\@ehc + }% +} +% Eg, +% \rvtdefinecolorset[x](0){green,0,0.50,0;blue,0,0.50,0.25} +% To use colors defined via \rvtdefinecolorset: +% eg, \color{<head>green<tail>}, where, eg, <head> is 'x' and <tail> '0'. +% When xwatermark package is loaded, this becomes redundant, but why +% load xwatermark just for this? +\robust@def*\rvtdefinecolorset{\cpt@testopt\rvt@definecolorset{x}} +\robust@def*\rvt@definecolorset[#1]{% + \cpt@testpnopt{\rvt@d@finecolorset{#1}}{1}% +} +\robust@def*\rvt@d@finecolorset#1(#2)#3{% + \ifcsndefTF{ver@xcolor.sty}{% + \begingroup + \cptemptifycsset{\rvt@tempb,\rvt@tempc,\rvt@tempd,\rvt@tempe}% + \def\rvt@tempa##1,##2,##3,##4,##5\@nil{% + \ifx\noboundary##4\noboundary + \rvt@err{Incomplete color format in + \string\rvtdefinecolorset}\@ehc + \else + \def\reserved@a{##1}% + \fi + }% + \def\csv@do##1{% + \rvt@tempa##1,,,,\@nil + \xifinsetTF{,\reserved@a,}{,\rvt@tempd,}{% + \edef\rvt@tempe{\csliststack,\rvt@tempe\reserved@a}% + }{% + \edef\rvt@tempd{\csliststack,\rvt@tempd\reserved@a}% + \@ifundefinedcolor{#1\reserved@a#2}{% + \edef\rvt@tempb{\csliststack;\rvt@tempb##1}% + }{% + \edef\rvt@tempc{\csliststack;\rvt@tempc#1\reserved@a#2}% + }% + }% + }% + \csv@@parse[;]{#3}% + \ifcsemptyTF\rvt@tempe{}{% + \rvt@err{Color names '\expandcsonce\rvt@tempe' multiply + \MsgBrk submitted to \string\rvtdefinecolorset}\@ehc + }% + \ifcsemptyTF\rvt@tempc{}{% + \rvt@err{Color names '\rvt@tempc' already in use}\@ehc + }% + \ifcsemptyTF\rvt@tempb{}{% + \cptexpandarg{\xglobal\definecolorset{rgb}{#1}{#2}} + {\expandcsonce\rvt@tempb}% + }% + \endgroup + }{% + \rvt@err{'xcolor' package not loaded}\@ehc + }% +} +\rvtdefinecolorset[rvt](0){% + green1,0,0.50,0;green2,0,0.50,0.25;green3,0.65,1,0.65; + blue1,0,0,1;blue2,0,0,0.63;blue3,0,0.50,1;blue4,0,0.50,0.75; + orange1,1,0.50,0;orange2,1,0.50,0.25;orange3,1,0.55,0.33 +} + +% Write verbatim to file '\jobname.verbfileext': +% \begin{rvtverbfilewrite} ... \end{rvtverbfilewrite} +\begingroup +\endlinechar-1 +\begingroup +\catcode`\^^M=13 +\catcode`\^^L=13\let^^L\relax +\catcode`\^^I=13 +\new@gdef*\rvtverbfilewrite{ + \ifrvt@openverbfile\else + \rvt@err{Writing to nonexistent/unopened file?} + {Can't write to unopened verbatim file.}% + \fi + \edef\reserved@c{\noexpandcsn{rvtf@\rvt@verbfileext}} + \let\do\@makeother\dospecials + \edef\E{\@backslashchar end\string{\@currenvir\string}} + \edef\reserved@b{ + \def\noexpand\reserved@b####1\E####2\E####3\relax + } + \reserved@b{ + \ifx\relax##3\relax + \immediate\write\reserved@c{##1} + \else + \edef^^M{\noexpand\end{\@currenvir}} + \ifx\relax##1\relax + \else + \immediate\write\reserved@c{##1} + \fi + \ifx\relax##2\relax + \else + \@latex@warning{Ignoring text `##2' % + after \string\end{\@currenvir}} + \fi + \fi + ^^M + } + \catcode`\^^L=13 + \let\L\rvt@undefined + \def^^L{\@ifundefined L^^J^^J^^J} + \catcode`\^^I=13 + \let\I\rvt@undefined + \def^^I{\@ifundefined I\@space\@space} + \catcode`\^^M=13 + \edef^^M##1^^M{\noexpand\reserved@b##1\E\E\relax} +} +\endgroup +\begingroup +\new@gdef*\endrvtwriteverb{ + \def\T##1##2##3{ + \ifx##1\rvt@undefined\else + \rvt@warn{##2 has been converted to blank ##3} + \fi + } + \T\L{Form Feed}{line} + \T\I{Tab}{space} + \immediate\write\@unused{} +} +\endgroup +\endgroup + +\newcommand\rvt@writetofile[3]{% + \begingroup + \let\thepage\relax + \let\label\@gobble + #2% + \let\protect\@unexpandable@protect + \protected@edef\rvt@tempa{\immediate\write#1{#3}}% + \rvt@tempa + \endgroup + \if@nobreak\ifvmode\nobreak\fi\fi +} +\newcommand\rvtfootnote[2][black]{\unskip + \long\def\@makefntext##1{\rule\z@\footnotesep\parindent1em\noindent + \hb@xt@2em{\hss\@textsuperscript + {\normalfont\textcolor{#1}{\@thefnmark}}}% + \hspace{2\p@}\ignorespaces\textcolor{#1}{##1}% + }% + \def\@makefnmark{% + \hbox{\@textsuperscript{\normalfont\textcolor{#1}{\@thefnmark}}}% + }% + \footnote{#2}% +} +\AtBeginDocument{% + \ifrvt@writenotes + \rvt@startfile{rvt}% + \rvt@writefile{rvt}{% + \string\begin{center}^^J\string\bfseries\space + Review notes in file\space\jobname.tex + ^^J\string\end{center}^^J\string\par\string\medskip^^J% + }% + \fi +} +\newcommand\rvt@notefile[3]{% + \ifboolTF{rvt@writenotes}{% + \rvt@writefile{rvt}{% + \string\noindent + {\string\bfseries\@space#1\string~\the\c@section.\arabic{#3}}% + \string\enskip\unexpanded{#2} (page\string~\the\c@page). + \string\par\string\medskip^^J% + }% + }{}% +} +\new@def*\rvt@r@viewer{% + \ifboolTF{rvt@showreviewer}{\textit{\rvt@reviewer}}{}% +} +\newcommand*\rvt@notefootnote[1][\rvt@notecolor]{% + \long\def\@makefntext##1{% + \rule\z@\footnotesep\parindent1em\noindent + \hb@xt@0em{\hss\@textsuperscript{\normalfont\color{#1}\@thefnmark}}% + \hspace{2\p@}\color{#1}\ignorespaces##1% + }% + \def\@makefnmark{\hbox{\@textsuperscript + {\normalfont\color{#1}\@thefnmark}}}% +} +\robust@def*\rvt@refstepcounter#1#2#3{% + \stepcounter{#1}% + \protected@edef\@currentlabel{\thesection.\usename{the#1}}% + \def\@currentlabelname{#2}% + \def\@currentHref{#3.\@currentlabel}% +} +\newcounter{rvt@notecnt}[section] +\robust@def*\rvtshortnote{\cpt@ifstar\rvt@shortnote\rvt@sh@rtnote} +\newcommand*\rvt@shortnote[2][]{% + \let\next\relax + \ifrvt@printnotes + \ifrvt@final + \def\next + {\rvt@err{Can't write 'shortnote*' if 'final'}\@ehc}% + \else + \def\next{\rvt@shortnotebody{#1}{#2}}% + \fi + \fi + \next +} +\newcommand*\rvt@sh@rtnote[2][]{% + \ifboolFT{rvt@printnotes}{}{\rvt@shortnotebody{#1}{#2}}% +} +\newcommand*\rvt@shortnotebody[2]{% + \begingroup + \rvt@refstepcounter{rvt@notecnt}{note}{note}% + \rvt@notefootnote[\rvt@notecolor]% + \color{\rvt@notecolor}% + \noindent + \finalhyphendemerits\z@pt + \rvt@notebmark + \textbf{Note~\thesection.\thervt@notecnt}\enskip + \ignorespaces#2~\rvt@r@viewer\relax + \rvt@noteemark + \ifblankTF{#1}{}{\footnote'{#1}}% + \rvt@notefile{Note}{\string\ignorespaces#2}{rvt@notecnt}% + \endgroup +} +\robust@def*\rvt@notebmark{% + \marginpar{% + \edef\rvt@tempa{\ifrvt@shownotetype Notes\fi}% + \begin{picture}(0,0)% + \sffamily\color{\rvt@notecolor}% + \put(0,0){\rotatebox{-90}{\small$\blacktriangleright$\rvt@tempa}}% + \end{picture}% + }% +} +\robust@def*\rvt@noteemark{% + \marginpar{% + \begin{picture}(0,0)% + \sffamily\color{\rvt@notecolor}% + \put(12,0){\rotatebox{90}{\small$\blacktriangleright$}}% + \end{picture}% + }% +} + +\newenviron{rvtlongnote}[1][]{% + \ifboolFT{rvt@printnotes}{}{\rvt@longnotebody{#1}}% +}{} +\newenviron{rvtlongnote*}[1][]{% + \let\next\relax + \ifrvt@printnotes + \ifrvt@final + \def\next{\rvt@err{Can't print longnote* if 'final'}\@ehc}% + \else + \def\next{\rvt@longnotebody{#1}}% + \fi + \fi + \next +}{} +\newcommand*\rvt@longnotebody[1]{% + \begingroup + \rvt@refstepcounter{rvt@notecnt}{note}{note}% + \rvt@notefootnote[\rvt@notecolor]% + \color{\rvt@notecolor}% + \medskip\noindent + \rvt@longnotebmark + \textbf{Note~\thesection.\thervt@notecnt}% + \endgraf\noindent\finalhyphendemerits\z@pt + \ignorespaces\envbody~\rvt@r@viewer\relax + \rvt@longnoteemark + \ifblankTF{#1}{}{\footnote'{#1}}% + \rvt@notefile{Note}{\string\ignorespaces\envbody}{rvt@notecnt}% + \endgroup +} +\robust@def*\rvt@longnotebmark{% + \marginpar{% + \sffamily\color{\rvt@notecolor}% + \edef\rvt@tempa{\ifrvt@shownotetype Notes start\fi}% + \begin{picture}(0,0)% + \put(0,0){\rotatebox{-90}{\small$\blacktriangleright$\rvt@tempa}}% + \end{picture}% + }% +} +\robust@def*\rvt@longnoteemark{% + \marginpar{% + \sffamily\color{\rvt@notecolor}% + \edef\rvt@tempa{\ifrvt@shownotetype Notes end\fi}% + \begin{picture}(0,0)% + \put(10,0){\rotatebox{90}{\small$\blacktriangleright$\rvt@tempa}}% + \end{picture}% + }% +} + +\newcounter{rvt@marginnotecnt} +\MakeSortedPerPage{rvt@marginnotecnt} +\robust@def*\rvtshortmarginnote{% + \cpt@ifstar\rvt@shortmarginnote\rvt@sh@rtmarginnote +} +\robust@def*\rvt@shortmarginnote#1{% + \let\next\relax + \ifrvt@printnotes + \ifrvt@final + \def\next{\rvt@err{Can't print shortmarginnote* if 'final'}\@ehc}% + \else + \def\next{\rvt@marginnotebody{#1}}% + \fi + \fi + \next + \rvt@notefile{Note}{#1}{rvt@marginnotecnt}% +} +\robust@def*\rvt@sh@rtmarginnote#1{% + \ifrvt@printnotes\rvt@marginnotebody{#1}\fi + \rvt@notefile{Note}{#1}{rvt@marginnotecnt}% +} +\newenviron{rvtmarginnote*}{% + \let\next\relax + \ifrvt@printnotes + \ifrvt@final + \def\next{\rvt@err{Can't print marginnote* if 'final'}\@ehc}% + \else + \def\next{\rvt@marginnotebody{\envbody}}% + \fi + \fi + \next + \rvt@notefile{Note}{\envbody}{rvt@marginnotecnt}% +}{} +\newenviron{rvtmarginnote}{% + \ifrvt@printnotes + \def\next{\rvt@marginnotebody{\envbody}}% + \else + \let\next\relax + \fi + \next + \rvt@notefile{Note}{\envbody}{rvt@marginnotecnt}% +}{} +\newenviron{rvtMarginNote}{% + \ifrvt@printnotes + \rvt@marginnotebody\envbody + \fi + \rvt@notefile{Note}{\envbody}{rvt@marginnotecnt}% +}{} +\robust@def*\rvt@marginnotebody#1{% + \begingroup + \rvt@refstepcounter{rvt@marginnotecnt}{margin note}{margin note}% + \fboxsep=1\p@\fboxrule=0.4\p@\relax + \marginpar[\sffamily\color{\rvt@notecolor}\small\raggedleft + \fbox{\thervt@marginnotecnt}~#1]{\sffamily\color{\rvt@notecolor}% + \small\raggedright\fbox{\thervt@marginnotecnt}~#1}% + \endgroup +} +\newcounter{rvt@deletecnt}[section] +\robust@def*\rvtshortdelete{% + \cpt@ifstar\rvt@shortdelete\rvt@sh@rtdelete +} +\newcommand\rvt@shortdelete[2][]{% + \let\next\relax + \ifrvt@printnotes + \ifrvt@final + \def\next{\rvt@err{Can't write shortdelete* if 'final'}\@ehc}% + \else + \def\next{\rvt@deletebody{#1}{#2}}% + \fi + \else + \def\next{}% + \fi + \next +} +\newcommand\rvt@sh@rtdelete[2][]{% + \ifrvt@printnotes + \rvt@deletebody{#1}{#2}% + \fi +} +\newenviron{rvtdelete*}[1][]{% + \let\next\relax + \ifrvt@printnotes + \ifrvt@final + \def\next{\rvt@err{Can't print delete* if 'final'}\@ehc}% + \else + \def\next{\rvt@deletebody{#1}{\envbody}}% + \fi + \fi + \next + \rvt@notefile{Delete}{\envbody}{rvt@deletecnt}% +}{} +\newenviron{rvtdelete}[1][]{% + \ifrvt@printnotes + \rvt@deletebody{#1}{\envbody}% + \fi + \rvt@notefile{Delete}{\envbody}{rvt@deletecnt}% +}{} +\robust@def*\rvt@deletebody#1#2{% + \begingroup + \rvt@refstepcounter{rvt@deletecnt}{delete}{delete}% + \rvt@notefootnote[\rvt@deletecolor]% + \rvt@deletebmark + \sffamily\rvt@deletecolor\ignorespaces + #2\xifblankTF{#1}{}{\footnote'{#1}}% + \rvt@deleteemark + \endgroup +} +\robust@def*\rvt@deletebmark{% + \marginpar{% + \sffamily\rvt@deletecolor + \ifrvt@shownotetype\def\rvt@note{Delete}\else\def\rvt@note{}\fi + \begin{picture}(0,0)% + \put(0,0){\rotatebox{-90}{\small$\blacktriangleright$\rvt@note}}% + \end{picture}% + }% +} +\robust@def*\rvt@deleteemark{\marginpar{\sffamily\rvt@deletecolor + \begin{picture}(0,0)% + \put(4,0){\rotatebox{90}{\small$\blacktriangleright$\rvt@r@viewer}}% + \end{picture}}% +} +\newcounter{rvt@deletedcnt}[section] +\robust@def*\rvtshortdeleted{% + \cpt@ifstar\rvt@shortdeleted\rvt@sh@rtdeleted +} +\newcommand\rvt@shortdeleted[2][]{% + \let\next\relax + \ifrvt@printnotes + \ifrvt@final + \def\next{\rvt@err{Can't write shortdeleted* if 'final'}\@ehc}% + \else + \def\next{\rvt@deletedbody{#1}{#2}}% + \fi + \fi + \next +} +\newcommand\rvt@sh@rtdeleted[2][]{% + \ifrvt@printnotes + \rvt@deletedbody{#1}{#2}% + \fi +} +\newenviron{rvtdeleted*}[1][]{% + \let\next\relax + \ifrvt@printnotes + \ifrvt@final + \def\next{\rvt@err{Can't print deleted* if 'final'}\@ehc}% + \else + \def\next{\rvt@deletedbody{#1}{\envbody}}% + \fi + \fi + \next + \rvt@notefile{Deleted}{\envbody}{rvt@deletedcnt}% +}{} +\newenviron{rvtdeleted}[1][]{% + \ifrvt@printnotes + \rvt@deletedbody{#1}{\envbody}% + \fi + \rvt@notefile{Deleted}{\envbody}{rvt@deletedcnt}% +}{} +\robust@def*\rvt@deletedbody#1#2{% + \begingroup + \rvt@refstepcounter{rvt@deletedcnt}{deleted}{deleted}% + \rvt@notefootnote[\rvt@deletedcolor]% + \rvt@deletedbmark + \sffamily\rvt@deletedcolor\ignorespaces + #2\xifblankTF{#1}{}{\footnote'{#1}}% + \rvt@deletedemark + \endgroup +} +\robust@def*\rvt@deletedbmark{% + \marginpar{% + \sffamily\rvt@deletedcolor + \ifrvt@shownotetype\def\rvt@note{Deleted}\else\def\rvt@note{}\fi + \begin{picture}(0,0)% + \put(0,0){\rotatebox{-90}{\small$\blacktriangleright$\rvt@note}}% + \end{picture}% + }% +} +\robust@def*\rvt@deletedemark{% + \marginpar{% + \sffamily\rvt@deletedcolor + \begin{picture}(0,0)% + \put(4,0){\rotatebox{90}{\small$\blacktriangleright$% + \rvt@r@viewer}}% + \end{picture}% + }% +} +\newcounter{rvt@addcnt}[section] +\robust@def*\rvtshortadd{% + \cpt@ifstar\rvt@shortadd\rvt@sh@rtadd +} +\newcommand\rvt@shortadd[2][]{% + \let\next\relax + \ifrvt@printnotes + \ifrvt@final + \def\next{\rvt@err{Can't print shortadd* if 'final'}\@ehc}% + \else + \def\next{\rvt@addbody{#1}{#2}}% + \fi + \else + \def\next{}% + \fi + \next + \rvt@notefile{Add}{#2}{rvt@addcnt}% +} +\newcommand\rvt@sh@rtadd[2][]{% + \ifrvt@printnotes + \rvt@addbody{#1}{#2}% + \fi + \rvt@notefile{Add}{#2}{rvt@addcnt}% +} +\newenviron{rvtadd*}[1][]{% + \let\next\relax + \ifrvt@printnotes + \ifrvt@final + \def\next{\rvt@err{Can't print add* if 'final'}\@ehc}% + \else + \def\next{\rvt@addbody{#1}{\envbody}}% + \fi + \else + \def\next{}% + \fi + \next + \rvt@notefile{Add}{\envbody}{rvt@addcnt}% +}{} +\newenviron{rvtadd}[1][]{% + \ifrvt@printnotes\rvt@addbody{#1}{\envbody}\fi + \rvt@notefile{Add}{\envbody}{rvt@addcnt}% +}{} +\robust@def*\rvt@addbody#1#2{% + \begingroup + \rvt@refstepcounter{rvt@addcnt}{add}{add}% + \rvt@notefootnote[\rvt@addcolor]% + \rvt@addbmark + \sffamily\rvt@addcolor\ignorespaces + #2\xifblankTF{#1}{}{\footnote'{#1}}% + \rvt@addemark + \endgroup +} +\robust@def*\rvt@addbmark{% + \marginpar{% + \sffamily\rvt@addcolor + \ifrvt@shownotetype\def\rvt@note{Add}\else\def\rvt@note{}\fi + \begin{picture}(0,0)% + \put(0,0){\rotatebox{-90}{\small$\blacktriangleright$\rvt@note}}% + \end{picture}% + }% +} +\robust@def*\rvt@addemark{% + \marginpar{% + \sffamily\rvt@addcolor + \begin{picture}(0,0)% + \put(4,0){\rotatebox{90}{\small$\blacktriangleright$ + \rvt@r@viewer}}% + \end{picture}% + }% +} +\newcounter{rvt@finalizedcnt}[section] +\robust@def*\rvtfinalizedfrom{% + \cpt@ifstar\rvt@finalizedfrom\rvt@fin@lizedfrom +} +\newcommand\rvt@finalizedfrom[2][]{% + \let\next\relax + \ifrvt@printnotes + \ifrvt@final + \def\next{\rvt@err{Can't print finalizedfrom* if 'final'}\@ehc}% + \else + \def\next{\rvt@finalizedfrombody{#1}{#2}}% + \fi + \fi + \next + \rvt@notefile{Finalized From}{#2}{rvt@finalizedcnt}% +} +\newcommand\rvt@fin@lizedfrom[2][]{% + \ifrvt@printnotes + \rvt@finalizedfrombody{#1}{#2}% + \fi + \rvt@notefile{Finalized From}{#2}{rvt@finalizedcnt}% +} +\robust@def\rvt@finalizedfrombody#1#2{% + \begingroup + \rvt@refstepcounter{rvt@finalizedcnt}{finalized from}{finalized from}% + \rvt@notefootnote[\rvt@wipcolor]% + \rvt@finfrombmark\rvt@finfromemark + \sffamily\rvt@wipcolor\ignorespaces + \ignorespaces#2\xifblankTF{#1}{}{\footnote'{#1}}% + \endgroup +} +\newcommand*\rvt@finfrombmark{% + \marginpar{% + \sffamily\rvt@wipcolor + \begin{picture}(0,0)% + \put(5,0){\rotatebox{-90}{\small$\blacktriangleright$% + Finalized from here}}% + \end{picture}% + }% +} +\newcommand*\rvt@finfromemark{% + \marginpar{% + \sffamily\rvt@wipcolor + \begin{picture}(0,0)% + \put(0,0){\rotatebox{-90}{\small(\rvt@r@viewer)}}% + \end{picture}% + }% +} +\robust@def*\rvtfinalizedto{% + \cpt@ifstar\rvt@finalizedto\rvt@fin@lizedto +} +\newcommand\rvt@finalizedto[2][]{% + \let\next\relax + \ifrvt@printnotes + \ifrvt@final + \def\next{\rvt@err{Can't print finalizedto* if 'final'}\@ehc}% + \else + \def\next{\rvt@finalizedtobody{#1}{#2}}% + \fi + \fi + \next + \rvt@notefile{Finalized To}{#2}{rvt@finalizedcnt}% +} +\newcommand\rvt@fin@lizedto[2][]{% + \ifrvt@printnotes + \rvt@finalizedtobody{#1}{#2}% + \fi + \rvt@notefile{Finalized To}{#2}{rvt@finalizedcnt}% +} +\robust@def\rvt@finalizedtobody#1#2{% + \begingroup + \rvt@refstepcounter{rvt@finalizedcnt}{finalized to}{finalized to}% + \rvt@notefootnote[\rvt@wipcolor]% + \rvt@finalizedtobmark\rvt@finalizedtoemark + \sffamily\rvt@wipcolor\ignorespaces + \ignorespaces#2\xifblankTF{#1}{}{\footnote'{#1}}% + \endgroup +} +\newcommand*\rvt@finalizedtobmark{% + \marginpar{% + \sffamily\rvt@wipcolor + \begin{picture}(0,0)% + \put(0,0){\rotatebox{90}{\small$\blacktriangleright$% + Finalized to here}}% + \end{picture}% + }% +} +\robust@def*\rvt@finalizedtoemark{% + \marginpar{% + \sffamily\rvt@wipcolor + \begin{picture}(0,0)% + \put(4,0){\rotatebox{90}{\small\p@blacktrig(\rvt@r@viewer)}}% + \end{picture}% + }% +} +% wip = work in progress +\newcounter{rvt@wipcnt}[section] +\robust@def*\rvtwipfrom{\cpt@ifstar\rvt@wipfrom\rvt@wipfr@m} +\newcommand\rvt@wipfrom[2][]{% + \let\next\relax + \ifrvt@printnotes + \ifrvt@final + \def\next{\rvt@err{Can't print wipfrom* if 'final'}\@ehc}% + \else + \def\next{\rvt@wipfrombody{#1}{#2}}% + \fi + \fi + \next + \rvt@notefile{WIP From}{#2}{rvt@wipcnt}% +} +\newcommand\rvt@wipfr@m[2][]{% + \ifrvt@printnotes + \rvt@wipfrombody{#1}{#2}% + \fi + \rvt@notefile{WIP From}{#2}{rvt@wipcnt}% +} +\robust@def*\rvt@wipfrombody#1#2{% + \begingroup + \rvt@refstepcounter{rvt@wipcnt}{wip from}{wip from}% + \rvt@notefootnote[\rvt@wipcolor]% + \rvt@wipfrombmark\rvt@wipfromemark% + \sffamily\rvt@wipcolor\ignorespaces + \ignorespaces#2\xifblankTF{#1}{}{\footnote'{#1}}% + \endgroup +} +\newcommand*\rvt@wipfrombmark{% + \marginpar{% + \sffamily\rvt@wipcolor + \begin{picture}(0,0)% + \put(5,0){\rotatebox{-90}{\small$\blacktriangleright$% + WIP start}}% + \end{picture}% + }% +} +\newcommand*\rvt@wipfromemark{% + \marginpar{% + \sffamily\rvt@wipcolor + \begin{picture}(0,0)% + \put(0,0){\rotatebox{-90}{\small(\rvt@r@viewer)}}% + \end{picture}% + }% +} +\robust@def*\rvtwipto{\cpt@ifstar\rvt@wipto@a\rvt@wipto@b} +\newcommand*\rvt@wipto@a[2][]{% + \let\next\relax + \ifrvt@printnotes + \ifrvt@final + \def\next{\rvt@err{Can't print wipto* if 'final'}\@ehc}% + \else + \def\next{\rvt@wiptobody{#1}{#2}}% + \fi + \fi + \next + \rvt@notefile{WIP To}{#2}{rvt@wipcnt}% +} +\newcommand\rvt@wipto@b[2][]{% + \ifrvt@printnotes + \rvt@wiptobody{#1}{#2}% + \fi + \rvt@notefile{WIP To}{#2}{rvt@wipcnt}% +} +\robust@def*\rvt@wiptobody#1#2{% + \begingroup + \rvt@refstepcounter{rvt@wipcnt}{wip to}{wip to}% + \rvt@notefootnote[\rvt@wipcolor]% + \rvt@wiptobmark\rvt@wiptoemark + \sffamily\rvt@wipcolor\ignorespaces + \ignorespaces#2\xifblankTF{#1}{}{\footnote'{#1}}% + \endgroup +} +\robust@def*\rvt@wiptobmark{% + \marginpar{% + \sffamily\rvt@wipcolor + \begin{picture}(0,0)% + \put(0,0){\rotatebox{90}{\small$\blacktriangleright$WIP end}}% + \end{picture}% + }% +} +\robust@def*\rvt@wiptoemark{% + \marginpar{% + \sffamily\rvt@wipcolor + \begin{picture}(0,0)% + \put(5,0){\rotatebox{90}{\small\p@blacktrig(\rvt@r@viewer)}}% + \end{picture}% + }% +} +\robust@def*\rvt@edittext{% + \ifboolTF{cpt@st}\rvt@edittext@a\rvt@edittext@b +} +\robust@def*\rvt@edittext@a#1{% + \let\next\relax + \ifrvt@printnotes + \ifrvt@final + \def\next{\rvt@err{Can't print edit-mark* if 'final'}\@ehc}% + \else + \def\next{% + \begingroup + \small\fboxrule.4\p@\fboxsep1.5\p@ + \textcolor{rvtgreen10}{\fbox{#1}}% + \endgroup + }% + \fi + \else + \ifhmode + \def\next{\unskip\unkern}% + \fi + \fi + \next +} +\robust@def*\rvt@edittext@b#1{% + \ifrvt@printnotes + \small\textcolor{rvtgreen10}{\fboxrule.4\p@\fboxsep1.5\p@\fbox{#1}}% + \else + \ifhmode\unskip\unkern\fi + \fi +} +\robust@def*\rvtpheromone{\cpt@testst{\rvt@edittext{$\clubsuit$}}} +\robust@def*\rvtedit{\cpt@testst{\rvt@edittext{Edit}}} +\robust@def*\rvtedited{\cpt@testst{\rvt@edittext{Edited}}} +\robust@def*\rvtpauseedit{\cpt@testst{\rvt@edittext{Paused editing here}}} +\robust@def*\rvtdiscuss{\cpt@testst{\rvt@edittext{Discuss}}} +\robust@def*\rvttodiscuss{\cpt@testst{\rvt@edittext{To be discussed}}} +\robust@def*\rvtaddtext{\cpt@testst{\rvt@edittext{Add text here}}} +\robust@def*\rvtaddtextbyauthor#1{% + \cpt@testst{\rvt@edittext{Add text here:~\textcolor{blue}{#1}}}% +} +\robust@def*\rvtadddescription{% + \cpt@testst{\rvt@edittext{Add description here}}% +} +\robust@def*\rvtadddescriptionbyauthor#1{% + \cpt@testst{\rvt@edittext{Add description + here:~\textcolor{blue}{#1}}}% +} +\newletcs\rvtaddbyauthor\rvtadddescriptionbyauthor +\robust@def*\rvttoaddtext{% + \cpt@testst{\rvt@edittext{Text to be added here}}% +} +\robust@def*\rvteditbyauthor#1{% + \cpt@testst{\rvt@edittext{Edit:~\textcolor{blue}{#1}}}% +} +\robust@def*\rvtflag#1{% + \ifrvt@printnotes + \endgraf + \makebox[\z@][l]{% + \kern-\marginparwidth\small\color{purple}% + \fboxrule.4pt\fboxsep1pt\relax + \fbox{$\clubsuit$}\enskip#1% + }% + \fi +} + +\endinput diff --git a/Master/texmf-dist/tex/latex/ltxtools/ltxtools-trace.sty b/Master/texmf-dist/tex/latex/ltxtools/ltxtools-trace.sty new file mode 100644 index 00000000000..46b04a2f528 --- /dev/null +++ b/Master/texmf-dist/tex/latex/ltxtools/ltxtools-trace.sty @@ -0,0 +1,282 @@ +%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++% +% % +% This is file 'ltxtools-trace.sty', version 0.0.1, December 2011. % +% % +% This package and accompanying files 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) 2011 Ahmed Musa (amusa22@gmail.com). % +% % +%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++% +% COMMENTS % +% The 'trace' package must be loaded last among all loaded packages, % +% to avoid problems that might arise if some of the LaTeX commands it % +% redefines are later redefined by other packages. In contrast, the % +% 'ltxtools-trace' package can be loaded any time. Also, the counter % +% \tracinggrade can be changed dynamically to enable or disable % +% \tracingonline and \tracingifs. % +% % +% \tracinggrade (default = 3) accepts the following user values: % +% <=1 -> no tracing online, no tracing ifs; % +% >1 -> tracing ifs % +% >2 -> tracing online % +% % +% Package option 'tracingall' will trace even font selections. % +% % +% '\ltsbegingroup ... \ltsendgroup' can be used to trace group mismatch. % +%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++% + +\ProvidesPackage{ltxtools-trace}[2011/12/12 v0.0.1 Tracing LaTeX code] +\NeedsTeXFormat{LaTeX2e}[2011/06/27] +\edef\reserved@a{% + \noexpand\AtEndOfPackage{\catcode\number`\&=\number\catcode`\&}% +} +\reserved@a +\newcommand*\LTS@defcmds{} +\catcode`\&=3 +\protected\def\LTS@defcmds#1#2{% + \begingroup + \toks@{}% + \def\reserved@e##1 &{\reserved@f##1&}% + \def\reserved@f##1&##2{% + \unexpanded\expandafter{\romannumeral-`\q\noexpand##1}% + }% + \edef\LTS@tempa{\reserved@e#1& &}% + \def\reserved@a{if}% + \edef\LTS@tempb{\ifx\LTS@tempa\reserved@a if\fi}% + \def\do##1,{% + \ifnot@nil{##1}{% + \edef\LTS@tempc{\reserved@e##1& &}% + \edef\reserved@a{\expandafter\expandafter\expandafter + \@car\expandafter\string\LTS@tempc\@nil}% + \ifx\reserved@a\@backslashchar + \@latex@error{'\detokenize{##1}' isn't a command name}\@ehc + \fi + \expandafter\@ifdefinable\csname\LTS@tempb\LTS@tempc\endcsname{% + \ifx\LTS@tempa\@empty\else + \def\reserved@a{cmd}% + \ifx\LTS@tempa\reserved@a\else + \toks@\expandafter{\the\expandafter\toks + \expandafter0\expandafter\noexpand + \csname new\LTS@tempa\expandafter\endcsname\csname + \LTS@tempb\LTS@tempc\endcsname + }% + \fi + \fi + }% + \do + }% + }% + \do#2,\@nil,% + \expandafter\endgroup\the\toks@ +} +\LTS@defcmds{if}{LTS@tracesw,LTS@tracingall} +\LTS@defcmds{count}{LTS@grouplevel,LTS@grouptype,tracinggrade, + LTS@tracedepth} +\LTS@defcmds{cmd}{ltsbegingroup,ltsendgroup,trace, + LTS@traceon,LTS@traceoff,LTS@tracedefs,showcsn, + starttracingall,stoptracingall} +\let\starttracingall\LTS@tracingalltrue +\let\stoptracingall\LTS@tracingallfalse +\DeclareOption{logonly}{\tracinggrade\tw@} +\DeclareOption{notraceifs}{\tracinggrade\@ne} +\DeclareOption{traceall}{\LTS@tracingalltrue} +\DeclareOption{tracingall}{\LTS@tracingalltrue} +\tracinggrade\thr@@ +\ProcessOptions\relax + +\protected\def\ltsbegingroup{% + \begingroup + \LTS@grouplevel\currentgrouplevel + \LTS@grouptype\currentgrouptype +} +\protected\def\ltsendgroup{% + \ifnum\LTS@grouptype=\currentgrouptype + \ifnum\LTS@grouplevel=\currentgrouplevel\else + \LTS@err{There is a group level mismatch}\@ehc + \aftergroup\showgroups + \fi + \else + \LTS@err{There is a group type mismatch}\@ehc + \aftergroup\showgroups + \fi + \endgroup +} +\protected\def\LTS@traceon{% + \tracingstats2 + \tracingpages1 + \tracinglostchars1 + \tracingparagraphs1 + \errorcontextlines\maxdimen + \tracingoutput1 + \showboxbreadth\maxdimen + \showboxdepth\maxdimen + \errorstopmode + \tracingrestores1 + \tracingonline\ifnum\tracinggrade>2 1 \else0 \fi + \tracinggroups1 + \tracingifs\ifnum\tracinggrade>1 1 \else0 \fi + \tracingassigns1 + \tracingmacros2 + \tracingcommands2 +} +\protected\def\LTS@traceoff{% + \tracingassigns0 + \tracingcommands0 + \tracingmacros0 + \tracingrestores0 + \tracingpages0 + \tracingoutput0 + \showboxbreadth-1 + \showboxdepth-1 + \tracingstats1 + \tracingparagraphs0 + \tracingifs0 + \tracinggroups0 +} +\protected\def\LTS@tracedefs{% + % Tracing 'fp' evaluations may lead to stack overflow. + % Hence, they shouldn't be traced: + \def\FPeval##1##2{% + \ifLTS@tracesw\LTS@traceoff\fi + \FP@eval{##1}{##2}% + \ifLTS@tracesw\LTS@traceon\fi + } + \def\calc@open({% + \begingroup + \ifLTS@tracingall\else + \ifLTS@tracesw\LTS@traceoff\fi + \fi + \aftergroup\calc@initB + \begingroup\aftergroup\calc@initB + \calc@pre@scan + }% + \def\define@newfont{% + \begingroup + \ifLTS@tracingall\else + \ifLTS@tracesw\LTS@traceoff\fi + \fi + \let\typeout\@font@info + \escapechar-1 + \expandafter\expandafter\expandafter\split@name + \expandafter\string\font@name\@nil + \try@load@fontshape + \expandafter\ifx\csname\curr@fontshape\endcsname\relax + \wrong@fontshape\else\extract@font\fi + \endgroup + }% + \frozen@everymath={% + \ifLTS@tracingall\else + \ifLTS@tracesw\LTS@traceoff\fi + \fi + \check@mathfonts + \ifLTS@tracingall\else + \ifLTS@tracesw\LTS@traceon\fi + \fi + \the\everymath + }% + \frozen@everydisplay={% + \ifLTS@tracingall\else + \ifLTS@tracesw\LTS@traceoff\fi + \fi + \check@mathfonts + \ifLTS@tracingall\else + \ifLTS@tracesw\LTS@traceon\fi + \fi + \the\everydisplay + }% + \def\maybe@ic@{% + \ifdim\fontdimen\@ne\font>\z@ + \else + \ifLTS@tracingall\else + \ifLTS@tracesw\LTS@traceoff\fi + \fi + \@tempswatrue + \expandafter\@tfor\expandafter\reserved@a + \expandafter:\expandafter=\nocorrlist\do\t@st@ic + \if@tempswa\sw@slant\fi + \ifLTS@tracingall\else + \ifLTS@tracesw\LTS@traceon\fi + \fi + \fi + }% + \protected\def\selectfont{% + \ifLTS@tracingall\else + \ifLTS@tracesw\LTS@traceoff\fi + \fi + \ifx\f@linespread\baselinestretch\else + \set@fontsize\baselinestretch\f@size\f@baselineskip + \fi + \xdef\font@name{% + \csname\curr@fontshape/\f@size\endcsname + }% + \pickup@font + \font@name + \size@update + \enc@update + \ifLTS@tracingall\else + \ifLTS@tracesw\LTS@traceon\fi + \fi + }% +} +\def\LTS@tracestack{} +\def\LTS@tracepush{% + \global\advance\LTS@tracedepth\@ne + \def\reserved@a{\romannumeral\LTS@tracedepth\endcsname}% + \expandafter\let\csname ifLTS@tracesw@\reserved@a\ifLTS@tracesw + \expandafter\let\csname ifLTS@tracest@\reserved@a\ifLTS@tracest + \edef\LTS@tracestack{% + \let\noexpand\ifLTS@tracesw\expandafter\noexpand + \csname ifLTS@tracesw@\reserved@a + \let\noexpand\ifLTS@tracest\expandafter\noexpand + \csname ifLTS@tracest@\reserved@a + {\unexpanded\expandafter{\LTS@tracestack}}% + }% +} +\def\LTS@tracepop{% + \def\reserved@a##1##{##1\gdef\LTS@tracestack}% + \expandafter\reserved@a\LTS@tracestack + \global\advance\LTS@tracedepth-1 +} +\newcommand*\trace{} +% \begin{trace}*...\end{trace}. +% Star (*) -> stop run at end of trace. +\protected\def\trace{% + \@ifstar{\let\ifLTS@tracest\iftrue\LTS@trace} + {\let\ifLTS@tracest\iffalse\LTS@trace}% +} +\protected\def\LTS@trace{% + \LTS@tracepush + \ifLTS@tracesw + \expandafter\@gobble + \else + \expandafter\@firstofone + \fi + {% + \typeout{^^J+++++++++ Tracing start +++++++++ + ^^J\@spaces Ignore the next 5 lines:}% + \LTS@traceswtrue + \LTS@tracedefs + \LTS@traceon + }% +} +\protected\def\endtrace{% + \LTS@traceoff + \LTS@traceswfalse + \ifLTS@tracest\expandafter\stop\fi + \LTS@tracepop +} +\protected\def\showcsn#1{\expandafter\show\csname#1\endcsname} + +\endinput diff --git a/Master/texmf-dist/tex/latex/ltxtools/ltxtools.sty b/Master/texmf-dist/tex/latex/ltxtools/ltxtools.sty index f3ece20a3ea..d0ffcb0b3a5 100644 --- a/Master/texmf-dist/tex/latex/ltxtools/ltxtools.sty +++ b/Master/texmf-dist/tex/latex/ltxtools/ltxtools.sty @@ -1,6 +1,6 @@ %++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++% % % -% This is file 'ltxtools.sty', version 0.0.1, September 2011. % +% This is file 'ltxtools.sty', version 0.0.1a, December 2011. % % % % This package and accompanying files may be distributed and/or % % modified under the conditions of the LaTeX Project Public License, % @@ -20,5109 +20,36 @@ % % %++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++% -\@ifpackageloaded{catoptions}{}{\RequirePackage{catoptions}[2011/07/07]} +\@ifpackageloaded{catoptions}{% + \@ifpackagelater{catoptions}{2011/12/12}{}{% + \@latex@error{Loaded version of catoptions package is + not current}\@ehc + }% +}{% + \RequirePackage{catoptions}[2011/12/12]% +} \UseNormalCatcodes -\StyleFilePurpose{A collection of (La)TeX utilities} +\StyleFilePurpose{A collection of (La)TeX utilities (AM)} \StyleFileRCSInfo -$Id: ltxtools.sty,v 0.0.1 2011/09/20 09:00:00 Ahmed Musa Exp $ +$Id: ltxtools.sty,v 0.0.1a 2011/12/12 09:00:00 Ahmed Musa Exp $ \ProvidesPackage{ltxtools}[\StyleFileInfo] -\NeedsTeXFormat{LaTeX2e}[2005/12/01] +\NeedsTeXFormat{LaTeX2e}[2011/06/27] \SetStyleFileMessages[LTS@]{info}{warn}{err} -\catcode`\&=\thr@@ \robust@def*\LTS@verbosewarn#1{\ifLTS@verbose\LTS@warn{#1}\fi} \robust@def*\LTS@verboseinfo#1{\ifLTS@verbose\LTS@info{#1}\fi} -\newvariables{if}[LTS@]{st,pl,cl,rt,pm,lt,verbose}[false] -\def\@empty{} -\new@def\LTS@car#1#2\car@nil{#1} -\new@def\LTS@cartwo#1#2#3\car@nil{#1#2} -\new@def\LTS@cartworev#1#2#3\car@nil{#2#1} -\new@def\LTS@cdr#1#2\cdr@nil{#2} -\new@def\LTS@cdrtwo#1#2#3\cdr@nil{#3} -\new@def\LTS@carcube#1#2#3#4\car@nil{#1#2#3} -\newletcs\LTS@nil\relax -\new@def*\LTS@nnil{\LTS@nil} -\long\def\@firstofone#1{#1} -\long\def\@firstoftwo#1#2{#1} -\long\def\@secondoftwo#1#2{#2} -\long\def\@firstofthree#1#2#3{#1} -\long\def\@secondofthree#1#2#3{#2} -\long\def\@thirdofthree#1#2#3{#3} -\long\def\@gobbleone#1{} -\long\def\@gobbletwo#1#2{} -\long\def\@gobblethree#1#2#3{} -\long\def\@gobblefour#1#2#3#4{} -\letcsntocs{LTS@0of1}\@gobbleone -\letcsntocs{LTS@1of1}\@firstofone -\letcsntocs{LTS@1of2}\@firstoftwo -\letcsntocs{LTS@2of2}\@secondoftwo -\def\strip@prefix#1>{} -\new@def*\realmeaning#1{\expandafter\strip@prefix\meaning#1} -\robust@def*\sanitizecs#1{\edef#1{\realmeaning#1}} -\new@edef*\LTS@hashchar{\string#} - -\robust@def*\preservebracedefQ#1#2{% - \def\preserve@prefix{#1}% - \def\preserve@delimiter{#2}% -} -\preservebracedefQ\relax\@nil -\robust@def*\preservebracedef#1{% - \cpt@presbr@setup\reserved@a#1.% -} -\robust@def*\PreserveBraceDef#1#2{% - \cpt@presbr@setup - \long\edef\preserve@after{\unexpanded{#1}}% - \afterassignment\preserve@after - \reserved@a#2.% -} -\robust@def*\cpt@presbr@setup{% - \cptexpandsecondonce{\def\reserved@a##1##2}% - \preserve@delimiter{% - \preserve@prefix\edef##1{% - \unexpanded\expandafter{\cpt@removetodot##2}% - }% - }% -} - -\robust@def*\getdefaultoptarg#1{% - \begingroup - \edef\LTS@tempa##1{% - \def##1####1\cptoxdetok{\@backslashchar#1}####2&% - }% - \LTS@tempa\LTS@tempa{% - \ifblankTF{##2}{% - \endgroup\def\@optarg{}% - }{% - \xifinsetTF{\cptoxdetok{\@backslashchar#1}}{##2}{% - \edef\LTS@tempa####1{% - \def####1########1\cptoxdetok{\@backslashchar#1}&% - }% - \LTS@tempa\LTS@tempa{\endgroup - \def\@optarg{####1}% - \cptscantokens\@optarg - }% - \LTS@tempa##2&% - }{% - \endgroup\def\@optarg{}% - }% - }% - }% - \edef\LTS@tempb##1{##1\cptoxdetok{\@backslashchar#1}&}% - \LTS@tempb{\expandafter\LTS@tempa\meaning#1}% -} -% \ifx ... \LTS@texdie{I am exiting now}\stop\fi -\robust@def\LTS@texdie#1#2\fi{\fi\immediate\write16{#1}\batchmode#2} -\robust@def*\LTS@emergencystop{% - \immediate\write\sixt@@n{OK, I'm exiting now.}% - \interactionmode\z@pt\stop -} -\robust@def*\ltsensurecomma{\cpt@ifnextchar,{}{\LTS@err{Don’t forget comma}}} -\robust@def*\LTS@nohyphens{\hyphenpenalty\@M\exhyphenpenalty\@M} -\robust@def*\ltsfulllet#1#2{% - \def\reserved@e##1##2{% - \LTS@stfalse\LTS@cltrue\LTS@ifonetoken{##1}{}{##2}% - }% - \reserved@e{#1}{% - \LTS@err{Multiple or blank arguments '\detokenize{#1}'}\@ehc - }% - \reserved@e{#2}{% - \LTS@err{Multiple or blank arguments '\detokenize{#2}'}\@ehc - \@gobble - }% - \let#1=#2% - \ifdefFT#2{}{% - \ifcsndefTF{\string#2}{% - \letcsntocsn{\string#1}{\string#2}% - }{% - \ifcsndefFT{\cptgobblescape#2\@space}{}{% - \letcsntocsn{\cptgobblescape#1\@space} - {\cptgobblescape#2\@space}% - \ifcsndefFT{\string#2\@space}{}{% - \letcsntocsn{\string#1\@space}{\string#2\@space}% - }% - }% - }% - }% -} -\robust@def*\newletcsset{% - \cpt@ifstar - {\let\LTS@let\ltsfulllet\LTS@newletcsset}% - {\let\LTS@let\let\LTS@newletcsset}% -} -\robust@def*\LTS@newletcsset#1{% - \def\reserved@f##1##2\LTS@nil{% - \ifblankFT{##2}{}{% - \LTS@err{The partner of command '\string##1' is void}{% - \noexpand\newletcsset error. - }% - }% - \ifdefTF{##1}{% - \cpt@isdeferr{##1}% - }{% - \LTS@let##1=##2% - }% - }% - \def\csv@do##1{% - \ifblankTF{##1}{}{% - \reserved@f##1\LTS@nil - }% - }% - \csv@@parse[,]{#1}% -} -\robust@def\LTS@checkoptprefix#1#2#3#4{% - \def\LTS@checkopt@a{% - \ifstrcmpTF{#4}{+}{% - \ifstrcmpTF{#2#3}{*!}{% - #1#2#4#3% - }{% - \ifstrcmpTF{#2#3}{!*}{#1#3#4#2}{#1#2#3#4}% - }% - }{% - \LTS@checkopt@b - }% - }% - \def\LTS@checkopt@b{% - \ifstrcmpTF{#4}{!}{% - \ifstrcmpTF{#2#3}{*+}{% - #1#2#3#4% - }{% - \ifstrcmpTF{#2#3}{+*}{#1#3#2#4}{#1#2#3#4}% - }% - }{% - \LTS@checkopt@c - }% - }% - \def\LTS@checkopt@c{% - \ifstrcmpTF{#3}{*}{% - \ifstrcmpTF{#2}{+}{% - \ifsingletokenTF{#4}{#1#3#2#4}{#1#3#2{#4}}% - }{% - \ifstrcmpTF{#2}{!}{% - \ifsingletokenTF{#4}{#1#3#2#4}{#1#3#2{#4}}% - }{% - \ifsingletokenTF{#4}{#1#2#3#4}{#1#2#3{#4}}% - }% - }% - }{% - \LTS@checkopt@d - }% - }% - \def\LTS@checkopt@d{% - \ifstrcmpTF{#3}{+}{% - \ifstrcmpTF{#2}{*}{% - \ifsingletokenTF{#4}{#1#2#3#4}{#1#2#3{#4}}% - }{% - \ifstrcmpTF{#2}{!}{% - \ifsingletokenTF{#4}{#1#3#2#4}{#1#3#2{#4}}% - }{% - \ifsingletokenTF{#4}{#1#2#3#4}{#1#2#3{#4}}% - }% - }% - }{% - \LTS@checkopt@e - }% - }% - \def\LTS@checkopt@e{% - \ifsingletokenTF{#4}{% - \long\def\@gtempa{#4}% - }{% - \long\def\@gtempa{{#4}}% - }% - \LTS@checkopt@f - }% - \def\LTS@checkopt@f{% - \ifsingletokenTF{#3}{% - \ifsingletokenTF{#2}{% - \LTS@checkopt@g{#1#2#3}% - }{% - \LTS@checkopt@g{#1{#2}#3}% - }% - }{% - \ifsingletokenTF{#2}{% - \LTS@checkopt@g{#1#2{#3}}% - }{% - \LTS@checkopt@g{#1{#2}{#3}}% - }% - }% - }% - \def\LTS@checkopt@g##1{% - \begingroup - \long\edef\x{\endgroup\unexpanded{##1}}% - \expandafter\x\@gtempa - }% - \ifstrcmpTF{#4}{*}{% - \ifstrcmpTF{#2#3}{+!}{% - #1#4#2#3% - }{% - \ifstrcmpTF{#2#3}{!+}{% - #1#4#3#2% - }{% - \ifsingletokenTF{#2}{% - \ifsingletokenTF{#3}{#1#2#3#4}{#1#2{#3}#4}% - }{% - \ifsingletokenTF{#3}{#1{#2}#3#4}{#1{#2}{#3}#4}% - }% - }% - }% - }{% - \LTS@checkopt@a - }% -} -\robust@def*\LTS@suffixerr#1#2#3{% - \if\detokenize{#1#2}\relax - \LTS@err{Invalid suffix '#1' to command '\string#3'}\@ehc - \fi -} -\robust@def*\LTS@blankargerr#1#2{% - \LTS@err{Invalid blank/empty argument to command - '\string#1'}\@ehc -} -% #1: parser, #2: csv list -\robust@def*\getlastcsv#1#2{% - \cpt@ch@cklistparser{#1}% - \def\rest{}% - \def\LTS@getlastcsv##1#1##2#1{% - \ifx##2\noboundary - \edef\last{\unexpanded{##1}}% - \expandafter\cpt@removetonnil - \else - \edef\rest{\csliststack#1\rest\unexpanded{##1}}% - \expandafter\LTS@getlastcsv - \fi - ##2#1% - }% - \LTS@getlastcsv#2#1\noboundary#1\noboundary#1\cpt@nnil -} -\robust@def*\getlasttsv#1{% - \def\rest{}% - \LTS@getlasttsv#1\noboundary\noboundary\cpt@nnil -} -\robust@def*\LTS@getlasttsv#1#2{% - \ifx#2\noboundary - \edef\last{\unexpanded{#1}}% - \expandafter\cpt@removetonnil - \else - \edef\rest{\expandcsonce\rest\unexpanded{#1}}% - \expandafter\LTS@getlasttsv - \fi - #2% -} -\robust@def*\ifstringcase{\LTS@testst\LTS@ifstringcase} -\robust@def\LTS@ifstringcase#1#2:{% - \ifblankTF{#2}{% - \LTS@blankargerr\ifstringcase{second}% - }{% - \LTS@testopt{\LTS@ifstringcase@a{#1}#2}{}% - }% -} -\robust@def\LTS@ifstringcase@a#1#2[#3]{% - \ifLTS@st - \let\LTS@ifstringcase@b\ifstrcmpTF - \else - \let\LTS@ifstringcase@b\ifstreqTF - \fi - \def\LTS@ifstringcase@c##1##2##3\LTS@nil{% - \LTS@ifstringcase@b{#1}{##1}{##2}{% - \ifnullTF{##3}{#3}{% - \LTS@ifstringcase@c##3\LTS@nil - }% - }% - }% - \LTS@ifstringcase@c#2\LTS@nil -} -\robust@def\ifstringcases#1#2:{% - \ifblankTF{#2}{% - \LTS@blankargerr\ifstringcases{second}% - }{% - \LTS@testopt{\LTS@ifstringcases{#1}#2}{}% - }% -} -\long\def\LTS@ifstringcases#1#2[#3]{% - \begingroup - \toks@{}% - \long\def\LTS@tempa##1##2{% - \ifstrcmpTF{##1}{\LTS@nil}{% - \oifblankFT{\the\toks@}{}{\toks@{#3}}% - }{% - \ifstrcmpTF{#1}{##1}{% - \toks@\expandafter{\the\toks@##2}% - \LTS@tempa - }{% - \LTS@tempa - }% - }% - }% - \LTS@tempa#2\LTS@nil\LTS@nil - \expandafter\endgroup\the\toks@\relax -} -\robust@def\ifmembercases#1#2:{% - \ifblankTF{#2}{% - \LTS@blankargerr\ifmembercases{second}% - }{% - \LTS@testopt{\LTS@ifmembercases{#1}#2}{}% - }% -} -\robust@def\LTS@ifmembercases#1#2[#3]{% - \begingroup - \toks@{}% - \long\def\LTS@tempa##1##2{% - \ifstrcmpTF{##1}{\LTS@nil}{% - \oifblankFT{\the\toks@}{}{\toks@{#3}}% - }{% - \ifinsetTF{,#1,}{,##1,}{% - \toks@\expandafter{\the\toks@##2}% - \LTS@tempa - }{% - \LTS@tempa - }% - }% - }% - \LTS@tempa#2\LTS@nil\LTS@nil - \expandafter\endgroup\the\toks@\relax -} -\robust@def\ifnumcase{% - \let\LTS@ifnumcase@b\LTS@ifnumcase - \LTS@ifnumcase@a -} -\robust@def\LTS@ifnumcase@a#1#2:{% - \LTS@suffixerr{*}{#1}\ifnumcase - \ifblankTF{#2}{% - \LTS@blankargerr\ifnumcase{second}% - }{% - \LTS@testopt{\LTS@ifnumcase@b{#1}#2}{}% - }% -} -\robust@def\LTS@ifnumcase#1#2[#3]{% - \def\LTS@ifnumcase@c##1##2##3\LTS@nil{% - \ifnumcmpTF#1=##1{% - ##2% - }{% - \ifnullTF{##3}{% - #3% - }{% - \LTS@ifnumcase@c##3\LTS@nil - }% - }% - }% - \LTS@ifnumcase@c#2\LTS@nil -} -\robust@def\ifnumcases{% - \let\LTS@ifnumcase@b\LTS@ifnumcases - \LTS@ifnumcase@a -} -\robust@def\LTS@ifnumcases#1#2[#3]{% - \begingroup - \toks@{}% - \long\def\LTS@tempa##1##2{% - \ifstrcmpTF{##1}{\LTS@nil}{% - \oifblankFT{\the\toks@}{}{\toks@{#3}}% - }{% - \ifnumcmpTF#1=##1{% - \toks@\expandafter{\the\toks@##2}% - \LTS@tempa - }{% - \LTS@tempa - }% - }% - }% - \LTS@tempa#2\LTS@nil\LTS@nil - \expandafter\endgroup\the\toks@\relax -} - -%% David Kastrup: -\newcommand*\ltsreplicate[1]{% - \csname LTS@repl\expandafter\LTS@replicate - \romannumeral\number\number#1 000q\endcsname -} -\long\def\LTS@replicate#1#2\endcsname#3{#1\endcsname{#3}#2} -\long\def\LTS@replm#1#2{#1\csname LTS@repl#2\endcsname{#1}} -\let\LTS@replq\@gobble -%%-- - -\new@def*\useifnotempty#1{% - \ifdefinedTF#1{% - \ifcsnullTF{#1}{}{#1}% - }{% - \cpt@notdeferr{#1}% - }% -} -\robust@def*\makecsn#1#2{% - \ifblankTF{#1}{}{% - \edef#2{\cpttrimspaces{#1}}% - \edef#2{\expandafter\cptgobblescape#2}% - }% -} -\makecsn{\\}\@backslashchar -\robust@def*\get@csname{\LTS@testst\LTS@getcsname} -\new@def*\LTS@getcsname#1#2{% - \begingroup - \ifcsnullTF#1{% - \edef#2{\ifLTS@st{}\fi}% - }{% - \escapechar\m@one - \ifLTS@st - \edef#2{{\expandafter\string#1}}% - \else - \edef#2{\expandafter\string#1}% - \fi - }% - \postgroupdef#2\endgroup -} -\robust@def*\ltsemptify{% - \LTS@checkoptprefix{\LTS@teststcl\LTS@emptify}% -} -\def\LTS@emptify#1{% - \is@long@or@relax\is@global@or@relax - \glob@lrel@x\l@ngrel@x\def#1{}% -} -\robust@def*\ltsemptifycsset{% - \LTS@checkoptprefix{\LTS@testplcl\LTS@emptifycsset}% -} -\robust@def*\ltsemptifycsset@{% - \LTS@plfalse\LTS@clfalse\LTS@emptifycsset -} -\new@def*\LTS@emptifycsset#1{% - \is@global@or@relax - \def\csv@do##1{% - \ifLTS@pl - \glob@lrel@x\emptifycsn{##1}% - \else - \LTS@ensurescape{##1}% - \glob@lrel@x\def##1{}% - \fi - }% - \csv@@parse[,]{#1}% -} -\new@def\swapbracetwo#1#2{{#2}{#1}} -\new@def\swapbracefirst#1#2{#2{#1}} -\new@def\swapbracesecond#1#2{{#2}#1} -\new@def\swapfirstthird#1#2#3{#3{#2}{#1}} -\new@edef*\LTS@istrue{\string\iftrue} -\new@edef*\LTS@isfalse{\string\iffalse} - -% \ltsinputfiles[x]{a,b}[tex]{if file exists}: -\robust@def*\ltsinputfiles{\cpt@testopt\LTS@Inp@tFiles{}} -\def\LTS@Inp@tFiles[#1]#2{\cpt@testopt{\LTS@Inp@tF@les[#1]#2}{tex}} -\def\LTS@Inp@tF@les[#1]#2[#3]#4{% - \begingroup - \toks@{}% - \def\csv@do##1{% - \toks@\expandafter{\the\toks@\InputIfFileExists{#1##1.#3}% - {#4}{\@missingfileerror{#1##1}{#3}}}% - }% - \edef\LTS@tempa{\cptzapspaces{#2}}% - \csv@@loop*[,]\LTS@tempa - \expandafter\endgroup\the\toks@ -} -\robust@def\safefullexpand#1{% - \begingroup - \LTS@safeactivesedef\reserved@a{\endgroup#1}\reserved@a -} -\robust@def\safeexpandarg#1#2{% - \begingroup - \LTS@safeactivesedef\reserved@a{\endgroup\unexpanded{#1}{#2}}% - \reserved@a -} -\robust@def\safeexpandsecond#1#2{% - \begingroup - \LTS@safeactivesedef\reserved@a{\endgroup\unexpanded{#1}#2}% - \reserved@a -} -\robust@def\ltsexpandargs#1#2#3#4\LTS@nil{% - \cptpassexpanded{% - \ifcase#1\relax - \unexpanded{#2}{#3}% - \or - \unexpanded{#2#3}{#4}% - \or - \unexpanded{#2}{#3}{#4}% - \or - \unexpanded{#2}{#3}\unexpanded{#4}% - \else - \LTS@err{Unknown expansion type '\string#1' for - \string\ltsexpandargs}{I expected your first argument - '\string#1' to \string\ltsexpandargs\MsgBrk to be - in the interval [0,3].}% - \fi - }% -} -\robust@def*\safeexpandtwoargs#1#2#3{% - \begingroup - \LTS@safeactivesedef\reserved@a{\endgroup\noexpand#1{#2}{#3}}% - \reserved@a -} -\robust@def*\expanddetoktwoargs#1#2#3{% - \cptexpandtwoargs#1{\cptoxdetok{#2}}{\cptoxdetok{#3}}% -} - -%% Ulrich Diez: -\new@def*\stepexpandarg#1{% - 0\csname @space\expandafter\LTS@stepexpandarg - \romannumeral\number\number#1000D\endcsname -} -\new@def*\LTS@stepexpandarg#1{% - \if#1m\expandafter\expandafter - \csname endcsname\expandafter\LTS@stepexpandarg\fi -} -%%-- - -\robust@def*\StepExpandArg{\LTS@testopt\LTS@StepExpandArg{}} -\robust@def*\LTS@StepExpandArg[#1]#{% - \begingroup - \edef\LTS@tempa{\endgroup\unexpanded{#1}}% - \expandafter\LTS@tempa\romannumeral\stepexpandarg -} -\robust@def*\nameidef#1#2#3{% - \expandafter\def\csname#1\expandafter - \endcsname\expandafter{\romannumeral\stepexpandarg{#2}#3}% -} -\robust@def*\namejdef#1#{\romannumeral\LTS@namejdef{#1}} -\new@def*\LTS@namejdef#1#2#3#{\LTS@n@mejdef{#1}{#2}{#3}} -\newcommand\LTS@n@mejdef[5]{% - \expandafter\cptswap\expandafter{% - \csname#2\expandafter\cptswap\expandafter{\expandafter{% - \romannumeral\stepexpandarg{#4}#5% - }}{\endcsname #3}% - }{0 #1}% -} -\new@def*\ltsexpandtimes#1{% - \expandafter\LTS@expandtimes\expandafter - {\romannumeral\number#1000}% -} -\new@def*\LTS@expandtimes#1#2{% - \ifnullTF{#1}{% - \unexpanded{#2}% - }{% - \expandafter\ifnullTF\expandafter{\@gobble#1}{% - \unexpanded\expandafter{#2}% - }{% - \expandafter\swapbracefirst\expandafter{#2}% - {\expandafter\LTS@expandtimes\expandafter{\@gobble#1}}% - }% - }% -} - -% Reserve condition. Eg, turn \iffoundTF to \iffoundFT, -% \iffoundFT to \iffoundTF, \iffoundT to \iffoundF, etc. -% If there is no 'TF' (or 'T' or 'F') at end of csname, -% then use \unless: -\new@def*\revcond#1{% - \LTS@revcond@b{#1}\LTS@cartworev{TF}{% - \LTS@revcond@c{#1}\LTS@cdrtwo{FT}% - }{% - \LTS@revcond@b{#1}\LTS@cartworev{FT}{% - \LTS@revcond@c{#1}\LTS@cdrtwo{TF}% - }{% - \LTS@revcond@b{#1}\LTS@car{T}{% - \LTS@revcond@c{#1}\LTS@cdr{F}% - }{% - \LTS@revcond@b{#1}\LTS@car{F}{% - \LTS@revcond@c{#1}\LTS@cdr{T}% - }{% - \unless#1% - }% - }% - }% - }% -} -\def\LTS@revcond@a#1{% - \expandafter\expandafter\expandafter\directreverse - \expandafter\expandafter\expandafter - {\cptremovescape{#1}}% -} -\new@def*\LTS@revcond@b#1#2#3{% - \expandafter\ifstrcmpTF\expandafter{\romannumeral0\expandafter#2% - \romannumeral0\LTS@revcond@a{#1}\car@nil}{#3}% -} -\new@def*\LTS@revcond@c#1#2#3{% - \usename{\expandafter\expandafter\expandafter\directreverse - \expandafter\expandafter\expandafter{\expandafter#2\romannumeral0% - \LTS@revcond@a{#1}\cdr@nil}#3}% -} -\robust@def*\ifonetokenTF{% - \LTS@checkoptprefix{\LTS@teststcl\LTS@ifonetoken}% -} -\robust@def*\LTS@ifonetoken#1{% - \begingroup - \ifbracedTF{#1}{% - \aftergroup\@secondoftwo - }{% - \def\reserved@a##1\LTS@nil{% - \def\reserved@a{% - \aftercsname\aftergroup{LTS@\expandafter\ifnullTF - \expandafter{\@gobble##1}12of2}% - }% - \ifLTS@cl - % Strictly one token: - \ifblankTF{##1}{\aftergroup\@secondoftwo}{\reserved@a}% - \else - % Nil or one token: - \ifblankTF{##1}{\aftergroup\@firstoftwo}{\reserved@a}% - \fi - }% - \ifLTS@st\expandafter\expandafter\fi\reserved@a#1\LTS@nil - }% - \endgroup -} -\robust@def*\ifonetokenFT#1{\ifonetokenTF{#1}\@secondoftwo\@firstoftwo} -\robust@def*\ifonetoken#1\do#2{% - \LTS@stfalse\LTS@cltrue - \LTS@ifonetoken{#1}{#2}{% - \LTS@err{More than one token in '\detokenize{#1}'}\@ehc - }% -} -\new@def*\ifboxvoidTF#1{% - \usename{@\ifvoid#1\@empty first\else second\fi ftwo}% -} -\new@def*\ifboxvoidFT#1{\usename{LTS@\ifboxvoidTF{#1}21of2}} -\new@def\LTS@csnifx@a#1\or#2\fi\@@nil{\fi#1} -\new@def\LTS@csnifx@b#1\fi\@@nil{\fi#1} -\new@def\LTS@csnifx@c#1#2#3#4{% - \ifcase\numexpr#1\relax - \LTS@csnifx@a - \ifcsnameTF{#3}% - {\usename{ifx#2\cptthreexp}\usename{#3}{#4}}% - {\usename{ifx#2}{#4}\LTS@undefined}% - \or - \LTS@csnifx@b - \ifcsnameTF{#4}% - {\usename{ifx#2\cptthreexp}\usename{#4}{#3}}% - {\usename{ifx#2}{#3}\LTS@undefined}% - \fi\@@nil -} -%% Eg, \csifxcsnTF\x{y}{T}{F}, \csnifxcsTF{y}\x{T}{F} -\newcommand*\csnifxcsTF[2]{\LTS@csnifx@c0{TF}{#1}{#2}} -\newcommand*\csnifxcsFT[2]{\LTS@csnifx@c0{FT}{#1}{#2}} -\newcommand*\csifxcsnTF[2]{\LTS@csnifx@c1{TF}{#1}{#2}} -\newcommand*\csifxcsnFT[2]{\LTS@csnifx@c1{FT}{#1}{#2}} -\newcommand*\csnifxcsnTF[2]{\aftercsname\csifxcsnTF{#1}{#2}} -\newcommand*\csnifxcsnFT[2]{\aftercsname\csifxcsnFT{#1}{#2}} - -\new@def*\ifdefinedTF#1{% - \usename{LTS@\ifdefined#1\@empty1\else2\fi of2}% -} -\new@def*\ifdefinedFT#1{\usename{LTS@\ifdefinedTF{#1}21of2}} - -\let\then\iffalse -\new@def*\ifnnum#1\then{% - \ifdim\LTS@ptlt\LTS@ptgt\LTS@pteq#1pt\cpt@removetonnil<=>\cpt@nnil -} -\new@def*\LTS@ptlt#1<{#1pt<} -\new@def*\LTS@ptgt#1>{#1pt>} -\new@def*\LTS@pteq#1={#1pt=} -\new@def*\realnumcmp{TT\fi\ifnum\realnums} -\new@def*\realnums#1\then{% - \dimexpr\LTS@dptlt\LTS@dptgt\LTS@dpteq#1pt% - \cpt@removetonnil<=>\cpt@nnil\@space -} -\new@def*\LTS@dptlt#1<{#1pt<\dimexpr} -\new@def*\LTS@dptgt#1>{#1pt>\dimexpr} -\new@def*\LTS@dpteq#1={#1pt=\dimexpr} -\begingroup -\catcode`\Y=12 -\catcode`\Z=12 -\lccode`\Y=`\p -\lccode`\Z=`\t -\lowercase{% - \defpass\x{\endgroup - \new@def*\LTS@ifinteger@a##1.##2YZ{% - \expandafter\ifx\expandafter\\\romannumeral0% - \ifnum##2>\z@pt\else\expandafter\@gobble\fi - \LTS@ifinteger@b\@space\\\cpt@removetonnil\cpt@nnil - }% - }% -} -\new@def\LTS@ifinteger@b#1\cpt@nnil{\noexpand\cpt@nnil} -\new@def\LTS@ifinteger#1\then{% - \expandafter\LTS@ifinteger@a - \the\dimexpr\LTS@mminus\LTS@pplus#1\p@ - \cpt@removetonnil+-\cpt@nnil\relax -} -\def\LTS@mminus#1-{#1\p@-} -\def\LTS@pplus#1+{#1\p@+} -\new@def\ifintegerTF#1#{% - \usename{LTS@\LTS@ifinteger#1\then1\else2\fi of2}% -} -\new@def\LTS@IfInteger#1\then{% - \begingroup - \toks@{}% - \LTS@integerparse{#1}{-}% - \toks@\expandafter{\expandafter}% - \expandafter\LTS@integerparse\expandafter{\the\toks@}{+}% - \defpass\LTS@tempa{% - \xifinsetFT{\p@\p@\LTS@nil}{\the\toks@\LTS@nil}{}{% - \def\LTS@tempb####1\p@\LTS@nil{% - \toks@{####1}% - \LTS@tempa - }% - \expandafter\LTS@tempb\the\toks@\LTS@nil - }% - }% - \edef\LTS@tempa{\the\dimexpr\the\toks@}% - \expandafter\endgroup\expandafter\LTS@ifinteger - \expandafter\rem@pt\LTS@tempa\then -} -\new@def\LTS@integerparse#1#2{% - \def\LTS@tempa##1#2##2\LTS@nil{% - \ifblankTF{##2}{% - \toks@\expandafter{\the\toks@##1\p@}% - }{% - \ifstrcmpTF{#2}{##2}{% - \toks@\expandafter{\the\toks@##1\p@}% - }{% - \toks@\expandafter{\the\toks@##1\p@#2}% - \LTS@tempa##2#2\LTS@nil - }% - }% - }% - \LTS@tempa#1\LTS@nil -} -\new@def\IfIntegerTF#1#{% - \LTS@ifinteger#1\then - \expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi -} -\robust@def*\ifonedefTF{% - \begingroup\def\case@nr{0}\LTS@testpl\LTS@ifonedef -} -\robust@def*\ifonedefFT{% - \begingroup\def\case@nr{1}\LTS@testpl\LTS@ifonedef -} -\robust@def*\LTS@ifonedef#1{% - \cpt@choicefdfalse - \def\csv@do##1{% - \usename{if\ifLTS@pl csn\fi defFT}{##1}{}{% - \cpt@choicefdtrue\loopbreak - }% - }% - \csv@@parse[,]{#1}% - \LTS@onecase -} -\robust@def*\ifonetrueTF{% - \begingroup - \def\case@nr{0}% - \LTS@testst{\LTS@testopt\LTS@ifonetrue{}}% -} -\robust@def*\ifonetrueFT{% - \begingroup - \def\case@nr{1}% - \LTS@testst{\LTS@testopt\LTS@ifonetrue{}}% -} -\def\LTS@ifonetrue[#1]#2{% - \cpt@choicefdfalse - \edef\reserved@a{\ifLTS@st*\fi}% - \def\csv@do##1{% - \uselivecsn{if#1##1}% - \cpt@choicefdtrue\loopbreak - \fi - }% - \expandafter\csv@@parse\reserved@a[#1]{#2}% - \LTS@onecase -} -\robust@def*\LTS@onecase{% - \edef\next##1##2##3{% - \ifcase\case@nr - ##11##22##32\or##12##21##32\or##11##20##31\or - ##10##21##31% - \fi - }% - \aftercsname\endgroup{LTS@\next\ifcpt@choicefd\else{\fi of}}% -} -\new@def*\ifcsndefeqTF#1#2{% - \ifcsndefFT{#1}\@secondoftwo - {\ifcsndefFT{#2}\@secondoftwo - {\aftercsname\ifxTF{#1\aftercsname}{#2}}}% -} -\new@def*\ifcsndefeqFT#1#2{\usename{LTS@\ifcsndefeqTF{#1}{#2}21of2}} -\robust@def*\LTS@notdefinable{% - \PackageError{ltxtools}% - {Command '\@backslashchar\LTS@rsvda' or - '\@backslashchar\@qend\LTS@rsvda' already defined}% - {Command '\@backslashchar\LTS@rsvda' already defined, - or name '\@backslashchar\@qend\LTS@rsvda' illegal.}% -} -\robust@def*\LTS@saveprimitive#1#2{% - \begingroup - \cpt@swafalse - \edef\LTS@tempa{\string#1}% - \edef\LTS@tempb{\meaning#1}% - \ifx\LTS@tempa\LTS@tempb - \cpt@swatrue - \else - \edef\LTS@tempb{\meaning#2}% - \ifx\LTS@tempa\LTS@tempb\else\LTS@s@veprimitive#1#2\fi - \fi - \expandafter\endgroup\ifcpt@swa\let#2#1\fi -} -\robust@def*\LTS@s@veprimitive#1#2{% - \def\LTS@tempb##1#1##2##3\edef{\edef\LTS@tempb{##2}\edef}% - \LTS@tempb - \nullfont{select font nullfont}% - \topmark{\string\topmark:}% - \firstmark{\string\firstmark:}% - \botmark{\string\botmark:}% - \splitfirstmark{\string\splitfirstmark:}% - \splitbotmark{\string\splitbotmark:}% - #1{\string#1}% - \edef\LTS@tempa{\expandafter\strip@prefix\meaning\LTS@tempb}% - \edef\LTS@tempb{\meaning#1}% - \ifx\LTS@tempa\LTS@tempb - \cpt@swatrue - \else - \@latex@error{Command \noexpand#1 no longer a primitive}\@ehc - \fi -} -\robust@def*\LTS@badargerr#1#2{% - \LTS@err{Bad '\string#2' argument for command '\string#1'}{% - Bad '\string#2' argument for command '\string#1'.\MsgBrk - You need to look again at user instruction\MsgBrk - for command '\string#1'. - }% -} -\newletcs\ifpackageloadedTF\@ifpackageloaded -\newletcs\ifclassloadedTF\@ifclassloaded -\new@def*\ifpackageloadedFT#1{\ifpackageloadedTF{#1}\@secondoftwo\@firstoftwo} -\new@def*\ifclassloadedFT#1{\ifclassloadedTF{#1}\@secondoftwo\@firstoftwo} -\new@def*\LTS@ifclasscurr{\LTS@ifpkg@cls@curr\@clsextension} -\new@def*\LTS@ifpackagecurr{\LTS@ifpkg@cls@curr\@pkgextension} -\new@def*\LTS@ifpkg@cls@curr#1#2#3{% - \usename{LTS@\ifnum\cptsevenxp\@parse@version - \usename{ver@#2.#1}//00\@nil<\expandafter - \@parse@version#3//00\@nil2\else1\fi of2}% -} -\new@def*\ifclasscurrentTF{\LTS@ifloadedcurr{class}} -\new@def*\ifpackagecurrentTF{\LTS@ifloadedcurr{package}} -\let\ifpkgcurrTF\ifpackagecurrentTF -\new@def*\LTS@ifloadedcurr#1#2#3{% - \usename{if#1loadedTF}{#2}{% - \usename{LTS@if#1curr}{#2}{#3}{% - \@firstoftwo - }{% - \LTS@err{Loaded version of #2 package is not current}% - {You need a higher version of #2 package:\MsgBrk - The version of #2 package available on your TeX\MsgBrk - installation is lower than you require.}% - \@secondoftwo - }% - }{% - \@secondoftwo - }% -} -\new@def*\ifpackagecurrentFT#1{\ifpackagecurrentTF{#1}\@secondoftwo\@firstoftwo} -\new@def*\ifclasscurrentFT#1{\ifclasscurrentTF{#1}\@secondoftwo\@firstoftwo} -% #1: package name -% #2: package date (mandatory) -\new@def*\NeedPackage#1#2{% - \ifx\documentclass\@twoclasseserror - \def\reserved@a{\usepackage}% - \else - \def\reserved@a{\RequirePackage}% - \fi - \cptexpanded{\LTS@testopt{\LTS@needpackage{#1}{#2}% - \expandcsonce\reserved@a}}{}% -} -\newletcs\needpackage=\NeedPackage -% #3: \usepackage or \RequirePackage; -% #4: options, if any -\robust@def*\LTS@needpackage#1#2#3[#4]{% - % If the package has been loaded and is current, don't - % reload: - \ifpackagecurrentTF{#1}{#2}{}{#3[#4]{#1}[#2]}% -} -\newcommand*\removeouterbraces[1]{% - \romannumeral\ifstrcmpTF{#1}{all}{% - \LTS@r@movebraces - }{% - \expandafter\LTS@removeouterbraces - \expandafter{\romannumeral#1000}% - }% -} -\newcommand\LTS@removeouterbraces[2]{% - \ifnullTF{#1}{0 #2}{% - \expandafter\ifnullTF\expandafter{\@gobble#2}{% - \ifbracedTF{#2}{% - \expandafter\swapbracefirst - \expandafter{\@iden#2}% - {\expandafter\LTS@removeouterbraces\expandafter{\@gobble#1}}% - }{0 #2}% - }{0 #2}% - }% -} -\newcommand\LTS@r@movebraces[1]{% - \expandafter\ifnullTF\expandafter{\@gobble#1}{% - \ifbracedTF{#1}{% - \expandafter\LTS@r@movebraces\expandafter{\@iden#1}% - }{0 #1}% - }{0 #1}% -} -\robust@def*\LTS@ensuremacro#1{% - \ifmacroTF{#1}{}{\cpt@notcserr{#1}}% -} -\robust@def*\LTS@ensurescape#1{% - \ifescapedTF{#1}{}{\cpt@notescapederr{#1}}% -} -\robust@def*\LTS@ensurenoscape#1{% - \ifescapedTF{#1}{\cpt@isescapederr{#1}}{}% -} -\robust@def*\LTS@ensurescape@csset#1#2{% - \docommalist{#2}{% - \usename{LTS@ensure\ifnullTF{#1}{}{no}scape}{##1}% - }% -} -\robust@def\LTS@ifnextchar#1#2#3{% - \LTS@ifn@@tchar\bgroup - {\LTS@ifn@@tchar{#1}{#2}{#3}}% - {\LTS@ifn@xtchar{#1}{#2}{#3}}% -} -\new@def\LTS@ifn@xtchar#1#2#3#4{% - \csname LTS@\if\detokenize{#1#4}1\else2\fi of2\endcsname - {#2}{#3}#4% -} -\newcsndef{LTS@ifnextch} {\futurelet\next\LTS@ifn@@tch@r} -\new@def\LTS@ifn@@tchar#1#2#3{% - \begingroup - \let\reserved@a=#1\toks@{#2}\toks1{#3}% - \futurelet\next\LTS@ifn@@tch@r -} -\new@def*\LTS@ifn@@tch@r{% - \ifx\next\@sptoken - \let\LTS@next\LTS@ifnextch - \else - \ifx\next\reserved@a - \edef\LTS@next{\endgroup\the\toks@}% - \else - \edef\LTS@next{\endgroup\the\toks1}% - \fi - \fi - \LTS@next -} -\robust@def*\NoGobbleSpaceIfnextchar#1#2#3{% - \begingroup - \let\reserved@a=#1\toks@{#2}\toks1{#3}% - \futurelet\next\LTS@nogobblespaceifnext -} -\new@def*\LTS@nogobblespaceifnext{% - \cptpassexpanded{\endgroup - \ifxTF\next\reserved@a{\the\toks@}{\the\toks1}% - }% -} -\robust@def*\LTS@ifchar#1#2#3{% - \LTS@ifnextchar - #1{\begingroup\defpass\x#1{\endgroup#2}}{#3}% -} -\robust@def*\LTS@ifstar{\LTS@ifchar*} -\robust@def*\LTS@ifplus{\LTS@ifchar+} -\robust@def*\LTS@ifclam{\LTS@ifchar!} -\robust@def*\LTS@ifdot{\LTS@ifchar.} -\robust@def*\LTS@ifright{\LTS@ifchar>} -\robust@def*\LTS@ifleft{\LTS@ifchar<} -\robust@def*\LTS@ifprime{\LTS@ifchar'} -\robust@def*\ifnextisbrack#1#2{\LTS@ifnextchar[{#1}{#2}} -\robust@def*\ifnextisparen#1#2{\LTS@ifnextchar({#1}{#2}} -\robust@def*\ifnextisleftang#1#2{\LTS@ifnextchar<{#1}{#2}} -\robust@def*\LTS@testst#1{\LTS@ifstar{\LTS@sttrue#1}{\LTS@stfalse#1}} -\robust@def*\LTS@testpl#1{\LTS@ifplus{\LTS@pltrue#1}{\LTS@plfalse#1}} -\robust@def*\LTS@testcl#1{\LTS@ifclam{\LTS@cltrue#1}{\LTS@clfalse#1}} -\robust@def*\LTS@testpm#1{\LTS@ifprime{\LTS@pmtrue#1}{\LTS@pmfalse#1}} -\robust@def*\LTS@testrt#1{\LTS@ifright{\LTS@rttrue#1}{\LTS@rtfalse#1}} -\robust@def*\LTS@testlt#1{\LTS@ifleft{\LTS@lttrue#1}{\LTS@ltfalse#1}} -\robust@def*\LTS@teststpl#1{\LTS@testst{\LTS@testpl{#1}}} -\robust@def*\LTS@teststplcl#1{\LTS@testst{\LTS@testpl{\LTS@testcl{#1}}}} -\robust@def*\LTS@teststplpm#1{\LTS@testst{\LTS@testpl{\LTS@testpm{#1}}}} -\robust@def*\LTS@teststcl#1{\LTS@testst{\LTS@testcl{#1}}} -\robust@def*\LTS@teststpm#1{\LTS@testst{\LTS@testpm{#1}}} -\robust@def*\LTS@testplcl#1{\LTS@testpl{\LTS@testcl{#1}}} -\robust@def*\LTS@testopt#1#2{\ifnextisbrack{#1}{#1[{#2}]}} -\robust@def*\LTS@testltopt#1#2{\ifnextisleftang{#1}{#1<{#2}>}} -\robust@def*\LTS@testpnopt#1#2{\ifnextisparen{#1}{#1({#2})}} -\new@def*\LTS@Test@pt#1{\usename{LTS@\ifnullTF{#1}12of2}} -\new@def*\LTS@IfBrack#1#2#3{\LTS@IfBr@ck#1&[&{#2}{#3{#1}}} -\new@def*\LTS@IfBr@ck#1[#2#{\LTS@Test@pt{#1#2}} -\new@def*\LTS@TestOpt#1#2#3{\LTS@IfBr@ck#1&[&{#2#1}{#2[{#3}]{#1}}} -\new@def*\LTS@IfStar#1#2#3{\LTS@IfSt@r#1&*&{#2}{#3{#1}}} -\new@def*\LTS@IfSt@r#1*#2#{\LTS@Test@pt{#1#2}} -\new@def*\LTS@IfPlus#1#2#3{\LTS@IfPl@s#1&+&{#2}{#3{#1}}} -\new@def*\LTS@IfPl@s#1+#2#{\LTS@Test@pt{#1#2}} -% Look ahead for many characters: -\robust@def\ltsifnextchars#1#2#3{% - \begingroup - \long\def\special@car{\futurelet\next\special@car@a}% - \long\def\special@car@a##1##2\car@nil{% - \ifx\next\temp@bgroup\toks@{{##1}}\else\toks@{##1}\fi - }% - \let\temp@bgroup\bgroup - \let\bgroup\LTS@undefined - \def\LTS@tempa{#1}\def\LTS@tempb{#2}% - \def\LTS@tempc{#3}\def\LTS@tempd{}% - \LTS@ifnextchars@a -} -\def\LTS@ifnextchars@a{\futurelet\next\LTS@ifnextchars@b} -\def\LTS@ifnextchars@b{% - \ifxTF\next\@sptoken{% - \afterassignment\LTS@ifnextchars@a\let\next= % - }{% - \LTS@ifnextchars@c - }% -} -\def\LTS@ifnextchars@c#1{% - \ifx\next\temp@bgroup\toks1{{#1}}\else\toks1{#1}\fi - \expandafter\special@car\LTS@tempa\car@nil - \xifstrcmpTF{\the\toks@}{\the\toks1}{% - \edef\LTS@tempd{\expandcsonce\LTS@tempd\the\toks@}% - \toks@\cptthreexp{\expandafter\cpt@cdr\LTS@tempa\cdr@nil}% - \edef\LTS@tempa{\the\toks@}% - \ifcsnullTF\LTS@tempa{% - \cptthreexp\endgroup\expandafter\LTS@tempb\LTS@tempd - }{% - \LTS@ifnextchars@a - }% - }{% - \edef\LTS@tempd{\expandcsonce\LTS@tempd\the\toks1}% - \cptthreexp\endgroup\expandafter\LTS@tempc\LTS@tempd - }% -} -\robust@def*\ltscommanormalize#1#2{% - \let\LTS@inkv\cptswfalse - \edef#2{\comma@kv@normalize{#1}}% -} -\robust@def*\ltskvnormalize#1#2{% - \let\LTS@inkv\cptswtrue - \edef#2{\comma@kv@normalize{#1}}% -} -\begingroup -\catcode`\!=13 -\uccode`\~=`\,% -\uccode`\!=`\=% -\uppercase{\endgroup - \def\comma@kv@normalize#1{% - \unexpanded\expandafter{\romannumeral-`\q - \LTS@activecomma,#1,~\LTS@nil}% - }% - \def\LTS@activecomma#1~#2\LTS@nil{% - \ifblankTF{#2}{% - \ifcondTF\if\LTS@inkv\fi{% - \LTS@activeequal#1!\LTS@nil - }{% - \LTS@spacecomma#1 ,\LTS@nil - }% - }{% - \LTS@activecomma#1,#2\LTS@nil - }% - }% -} -\defpass\LTS@tempa#1{% - \begingroup - \uccode`\~=`\=% - \uppercase{\endgroup - \def\LTS@activeequal##1~##2\LTS@nil{% - \ifblankTF{##2}{% - \LTS@spacecomma##1#1,\LTS@nil - }{% - \LTS@activeequal##1=##2\LTS@nil - }% - }% - }% - \def\LTS@spacecomma##1#1,##2\LTS@nil{% - \ifblankTF{##2}{% - \LTS@commaspace##1,#1\LTS@nil - }{% - \LTS@spacecomma##1,##2\LTS@nil - }% - }% - \def\LTS@commaspace##1,#1##2\LTS@nil{% - \ifblankTF{##2}{% - \ifcondTF\if\LTS@inkv\fi{% - \LTS@spaceequal##1#1=\LTS@nil - }{% - \LTS@doublecomma##1,,\LTS@nil - }% - }{% - \LTS@commaspace##1,##2\LTS@nil - }% - }% - \def\LTS@spaceequal##1#1=##2\LTS@nil{% - \ifblankTF{##2}{% - \LTS@equalspace##1=#1\LTS@nil - }{% - \LTS@spaceequal##1=##2\LTS@nil - }% - }% - \def\LTS@equalspace##1=#1##2\LTS@nil{% - \ifblankTF{##2}{% - \LTS@doublecomma##1,,\LTS@nil - }{% - \LTS@equalspace##1=##2\LTS@nil - }% - }% -}{ } -\def\LTS@doublecomma#1,,#2\LTS@nil{% - \ifblankTF{#2}{% - \ifcondTF\if\LTS@inkv\fi{% - \LTS@doubleequal#1==\LTS@nil - }{% - \LTS@remleadcomma#1\LTS@nil - }% - }{% - \LTS@doublecomma#1,#2\LTS@nil - }% -} -\def\LTS@doubleequal#1==#2\LTS@nil{% - \ifblankTF{#2}{% - \LTS@remleadcomma#1\LTS@nil - }{% - \LTS@doubleequal#1=#2\LTS@nil - }% -} -\def\LTS@commaequalerr#1,=#2\LTS@nil{% - \ifblankTF{#2}{}{% - \LTS@err{There is ',=' in your key-value list}\@ehc - }% -} -\new@def*\LTS@remleadcomma,#1\LTS@nil{\noexpand#1} - -% !! Enter in manual. Preserves braces. Takes arbitrary parser. -% General list parser. Use '#1' in <callback> for current -% item on level 1, ##1 on level 2, etc: -% \ltsdocsvlist[<parser>]<list>{<callback>} -% \ltsdocsvlist*[<parser>]<listcmd>{<callback>} -\robust@def*\ltsdocsvlist{\cpt@teststopt\lts@docsvlist,} -\robust@def*\lts@docsvlist[#1]#2#3{% - \pushfunctions\ltsdocsvlist - {\cpt@csvdo,\cpt@csvact,\ifloopbreak}\cpt@csvdepth - \cpt@stchoose{cpt@st}{#2}\cpt@csvarg\ltsdocsvlist - \def\cpt@csvact##1{#3}% - \def\cpt@csvdo##1#1{% - \ifcsvbreakTF{##1}\loopbreak\relax - \ifboolTF{loopbreak}{% - \gobble@to@sentinel\cpt@csvnil#1% - }{% - \edef\cpt@csvarg{\unexpanded\expandafter{\@gobble##1}}% - \ifxTF\cpt@csvarg\cpt@csvnil{}{% - \expandafter\cpt@csvact\expandafter{\cpt@csvarg}\relax - \cpt@csvdo.% - }% - }% - }% - \loopbreakfalse - \cpt@sttrue\cpt@csvnormalize[#1]\cpt@csvarg - \expandafter\cpt@csvdo\expandafter.\cpt@csvarg#1\cpt@csvnil#1% - \popfunctions\ltsdocsvlist\cpt@csvdepth -} - -% !! Enter in manual: -\robust@def*\commacsvloop{% - \let\LTS@nmlz\cptswfalse - \let\LTS@inkv\cptswfalse - \cpt@testst\LTS@commaparse -} -\robust@def*\commacsvparse{% - \let\LTS@nmlz\cptswtrue - \let\LTS@inkv\cptswfalse - \cpt@testst\LTS@commaparse -} -\robust@def*\commakvloop{% - \let\LTS@nmlz\cptswfalse - \let\LTS@inkv\cptswtrue - \cpt@testst\LTS@commaparse +\cptloadpackages{% + ltxtools-base||2011/12/12; } -\robust@def*\commakvparse{% - \let\LTS@nmlz\cptswtrue - \let\LTS@inkv\cptswtrue - \cpt@testst\LTS@commaparse +\robust@def*\LTS@inputmodule{\LTS@testopt\LTS@inp@tmodule{}} +\robust@def*\LTS@inp@tmodule[#1]#2{% + \AfterProcessOptions{\RequirePackage[#1]{ltxtools-#2}}% } -\robust@def*\LTS@commaparse#1{% - \cpt@stchoose{cpt@st}{#1}\LTS@tempa\LTS@commaparse - \pushfunctions\LTS@commaparse - {\ifloopbreak,\sav@comma@do}\cpt@csvdepth - \ifdefTF\comma@do{% - \let\sav@comma@do\comma@do - }{% - \cpt@notdeferr\comma@do +\robust@def*\ltsdeclaremodules#1{% + \XDeclareCommandOptions{#1}(LTS@){% + \cptexpandbracenext{\LTS@inputmodule[##1]}\cpt@curropt }% - \ifdefswitchTF{LTS@nmlz}{% - \edef\LTS@tempa{\s@expandarg\comma@kv@normalize\LTS@tempa}% - \ifdefswitchTF{LTS@inkv}{% - \expandafter\LTS@commaequalerr\LTS@tempa,=\LTS@nil - }{}% - }{}% - \loopbreakfalse - \let\currsentinel\cpt@commanil - \expandafter\LTS@c@mmaparse\LTS@tempa,\cpt@commanil,% - \popfunctions\LTS@commaparse\cpt@csvdepth - \undefcs\comma@do -} -\robust@def*\LTS@c@mmaparse#1,{% - \ifsentinelTF{#1}{}{% - \ifcsvbreakTF{#1}\loopbreak\relax - \ifboolTF{loopbreak}{% - \gobble@to@sentinel\cpt@commanil,% - }{% - \sav@comma@do{#1}\relax\LTS@c@mmaparse - }% - }% -} -\newvariables{if}{lastfox}[false] -\newcommand*\LTS@foxnil{\LTS@foxnil} - -% \foxloop[<parser>]{<list>}{<callback>} -% \foxloop*[<parser>]{<listcmd>}{<callback>} -% You can use \currfox<level>, \nextfox<level>, and -% \currfoxnr<level> within <callback> to access the current -% element of <list>, the next element of <list>, and -% the serial number of the current item, respectively, at -% various levels of nesting. <level> is given in roman numerals, -% eg, \currfoxi, \currfoxii. -% You can inset \csvbreak as an element of <list> to break -% out of the loop. Similarly, you can use \loopbreak within -% <callback> to break out of the loop. -% You can insert \csvpause as an element of <list> to pause the loop. -\robust@def*\foxloop{% - \LTS@testst{\LTS@testopt\LTS@fox@@a{,}}% -} -\robust@def*\LTS@fox@@a[#1]{% - \cpt@checklistparser{#1}\relax - \usename{LTS@fox@\ifLTS@st b\else a\fi}[#1]% -} -\robust@def*\LTS@fox@a[#1]#2{% - \declarefoxlistparser{#1}% - \LTS@fox@@b{#2}% -} -\robust@def*\LTS@fox@b[#1]#2{% - \declarefoxlistparser{#1}% - \expandafter\LTS@fox@@b\expandafter{#2}% -} -\robust@def*\declarefoxlistparser#1{% - % ##1 -> list; ##2 -> callback: - \long\def\LTS@fox@@b##1##2{% - \pushfunctions\foxloop{% - \getnextfox,\LTS@foxrema,\foxparser,\LTS@fox@@d,% - \currfox,\nextfox,\currfoxnr,\iflastfox,\ifloopbreak - }\cpt@csvdepth - \pushnumber\foxdepth - \def\foxparser{#1}% - \long\def\LTS@foxrema####1\LTS@foxnil#1{% - \long\edef\foxremainder{\unexpanded{####1}}% - \ifcsemptyTF\foxremainder\relax - {\cpt@trimparsers[#1]\foxremainder}% - }% - \chardef\currfoxnr\z@ - \def\getnextfox####1#1####2\getnextfox{% - \edef\nextfox{\expandcsonce{\cpt@removetodot####1}}% - \ifxTF\nextfox\LTS@foxnil{% - \lastfoxtrue - \let\nextfox\@empty - \letcsntocs{nextfox\romannumeral\cpt@csvdepth}\@empty - }{% - \lastfoxfalse - \letcsntocs{nextfox\romannumeral\cpt@csvdepth}\nextfox - }% - }% - \def\LTS@fox@@c####1####2{% - \getnextfox.####1\getnextfox - ####2\relax - % Rather than evaluate \iflastfox here for every item, - % let \ifx\currfox\LTS@foxnil terminate the loop. - \ifboolTF{loopbreak}{}{% - \LTS@fox@@d.####1\LTS@fox@@d{####2}% - }% - }% - \long\def\LTS@fox@@d####1#1####2\LTS@fox@@d####3{% - \edef\currfox{\expandcsonce{\cpt@removetodot####1}}% - \letcsntocs{currfox\romannumeral\cpt@csvdepth}\currfox - \edef\currfoxnr{\the\numexpr\currfoxnr+1}% - \letcsntocs{currfoxnr\romannumeral\cpt@csvdepth}\currfoxnr - \ifxTF\currfox\LTS@foxnil{}{% - \ifxTF\currfox\cpt@csvbreak{% - \LTS@foxrema####2% - }{% - \ifxTF\currfox\cpt@csvpause{% - \message{^^J! List pause: - ^^JType x or X to quit, or <RETURN> to proceed^^J}% - {\endlinechar-1\global\read-1 to\@gtempa}% - \lowercase\expandafter{\expandafter\def\expandafter - \@gtempa\expandafter{\@gtempa}}% - \xifstrcmpTF\@gtempa{x}{% - \LTS@foxrema####2% - }{% - \LTS@fox@@c{####2}{####3}% - }% - }{% - \LTS@fox@@c{####2}{####3}% - }% - }% - }% - }% - \loopbreakfalse\lastfoxfalse - \cpt@stfalse\cpt@csvnormalize[#1]{##1}% - \expandafter\LTS@fox@@d\expandafter - .\normalized@list#1\LTS@foxnil#1\LTS@fox@@d{##2}% - \popfunctions\foxloop\cpt@csvdepth - \popnumber\foxdepth - }% -} -\new@def*\ltsprotectedtokens#{% etoolbox - \ifx\protect\@typeset@protect - \LTS@protectedtoken\@firstofone\fi - \ifx\protect\@unexpandable@protect - \LTS@protectedtoken\LTS@unexpandable\fi - \ifx\protect\noexpand - \LTS@protectedtoken\unexpanded\fi - \ifx\protect\string - \LTS@protectedtoken\detokenize\fi - \@firstofone -} -\new@def*\LTS@protectedtoken#1#2\@firstofone{\fi#1} -\new@def\LTS@unexpandable#1{\unexpanded{\ltsprotectedtokens{#1}}} -\new@def\LTS@neverexpand#1{% - \unexpanded{\unexpanded{\unexpanded{\unexpanded{% - \unexpanded{\unexpanded{\unexpanded{\unexpanded{#1}}}}}}}}% -} -\new@def*\LTS@csnalloc#1{\usename{new#1\aftercsname}} -\providerobust@def*\csnnewif{\LTS@csnalloc{if}} -\robust@def*\csnnewtoks{\LTS@csnalloc{toks}} -\robust@def*\csnnewcount{\LTS@csnalloc{count}} -\robust@def*\csnnewdimen{\LTS@csnalloc{dimen}} -\robust@def*\csnnewskip{\LTS@csnalloc{skip}} -\robust@def*\csnnewmuskip{\LTS@csnalloc{muskip}} -\robust@def*\csnnewbox{\LTS@csnalloc{box}} -\robust@def*\csnnewwrite{\LTS@csnalloc{write}} -\robust@def*\csnnewread{\LTS@csnalloc{read}} -\robust@def*\LTS@createtwincmds#1{% - \begingroup\escapechar92\relax\expandafter\endgroup - \if\expandafter\LTS@car\string#1x\car@nil\@backslashchar\else - \LTS@err{Non-escaped command name '\detokenize{#1}'}\@ehc - \fi - \ifcsdefinable#1\relax - \ifcsndefinable{No\cptremovescape{#1}}\relax -} -\robust@def*\CreateTwinBooleanCommands#1#2{% - \LTS@createtwincmds{#1}% - \ifcsndefinable{if\cptremovescape{#2}}{% - \csnnewif{\cptremovescape{#2}}% - }% - \def#1{\gletcsntocs{if\cptremovescape{#2}}\iftrue}% - \csn@def{No\cptremovescape{#1}}{% - \gletcsntocs{if\cptremovescape{#2}}\iffalse - }% - \usename{No\cptremovescape{#1}}% -} -\robust@def*\CreateTwinSwitchCommands#1#2{% - \LTS@createtwincmds{#1}% - \def#1{\global\let#2\cptswtrue}% - \csn@def{No\cptremovescape{#1}}{\global\let#2\cptswfalse}% - \usename{No\cptremovescape{#1}}% -} -% Eg, \CreateTwinNumberCommands\StrictCheck\strict -\robust@def*\CreateTwinNumberCommands#1#2{% - \LTS@createtwincmds{#1}% - \def#1{\global\chardef#2\@ne}% - \csn@def{No\cptremovescape{#1}}{\global\chardef#2\z@pt}% - \usename{No\cptremovescape{#1}}% -} -\CreateTwinSwitchCommands\ExpandPrimitives\LTS@expprim -\CreateTwinSwitchCommands\WrapQuotes\LTS@wq -\CreateTwinSwitchCommands\ConvertInputToLowercase\LTS@lwc -\CreateTwinSwitchCommands\StrictHashCheck\stricthashcheck -\robust@def*\LTS@detok@zap#1{% - \LTS@ensuremacro{#1}% - \edef#1{\s@expandarg\cptzapspaces{\detokenize\expandafter{#1}}}% -} -\new@def*\is@global@or@relax{% - \ifLTS@cl\let\glob@lrel@x\global\else\let\glob@lrel@x\relax\fi -} -\let\glob@lrel@x\relax -\new@def*\is@long@or@relax{% - \ifLTS@st\let\l@ngrel@x\relax\else\let\l@ngrel@x\long\fi -} -\begingroup -\endlinechar\m@one -\def\siso@do#1{\catcode`#1\string=\active} -\siso@@loop{!"$&'()*+,-./:;<=>?[]^_|~} -\new@gdef\LTS@safeactivesedef#1#2{% - \begingroup - \def\siso@do##1{% - \ifnum\catcode`##1\string=\active\edef##1{\string##1}\fi - }% - \siso@@loop{!"$&'()*+,-./:;<=>?[]^_|~}% - \cptexpandsecond\endgroup - {\edef\noexpand#1{\noexpand\unexpanded{#2}}}% -} -\endgroup - -\robust@def*\reversetokens{\LTS@testst\LTS@reverse} -\new@def*\LTS@reverse#1#2{% - \begingroup - \def\LTS@tempa##1\reverse@nil{% - \def\LTS@tempa####1####2{% - \expandafter\ifxTF\cpt@car####2\car@nil - \endreverse{####1}{\LTS@tempa{####2####1}}% - }% - \toks@\expandafter{\romannumeral0\LTS@tempa{}##1\@space\endreverse}% - }% - \ifLTS@st\expandafter\expandafter\fi - \LTS@tempa#2\reverse@nil - \cptexpandsecond\endgroup - {\edef\noexpand#1{\noexpand\unexpanded{\the\toks@}}}% -} -\newletcs\endreverse\end -\new@def\directreverse#1{\LTS@directreverse{}#1\endreverse} -\new@def\LTS@directreverse#1#2{% - \expandafter\ifxTF\cpt@car#2\car@nil\endreverse{% - \if@test\expandafter\@iden\else\expandafter\unexpanded\fi{#1}% - }{% - \LTS@directreverse{#2#1}% - }% -} -\new@def\robustreverse#1{\LTS@robustreverse{}.#1\endreverse} -\new@def\LTS@robustreverse#1#2\endreverse{% - \LTS@r@bustreverse{#1}% - {\expandafter\ifleftbracedTF\expandafter{\cpt@removetodot#2}}#2\endreverse -} -\new@def\LTS@r@bustreverse#1#2.#3{% - \expandafter\ifxTF\cpt@car#3\car@nil\endreverse{% - \if@test\expandafter\@iden\else\expandafter\unexpanded\fi{#1}% - }{% - #2{\LTS@robustreverse{{#3}#1}}{\LTS@robustreverse{#3#1}}.% - }% -} - -% Create a delimiter for command Rabfe (meaning 'Remove all but -% first undelimited element'): -\robust@def*\DeclareRabfeDelimiter{\LTS@testst\LTS@DeclareRabfeDelimiter} -\robust@def*\LTS@DeclareRabfeDelimiter#1{% - \ifLTS@st - \long\def\ltsgetfirstelement##1##2#1{{##1}}% - \else - \long\def\ltsgetfirstelement##1##2#1{##1}% - \fi -} -\DeclareRabfeDelimiter{\LTS@nil} - -% Eg, #1 with two delimiters: -% \LTS@DeclareRabfeDelimiter\LTS@nil -% \edef\x{% -% \removeallbutfirstelement{xyz\LTS@nil\LTS@nil}} -% -\new@def\removeallbutfirstelement#1{% Ulrich Diez - \romannumeral-`\q - \expandafter\expandafter\expandafter\ifnullTF - \expandafter\expandafter\expandafter{% - \expandafter\@gobble\ltsgetfirstelement#1}{% - \expandafter\@firstofone\expandafter{% - \ltsgetfirstelement#1}% - }{% - \expandafter\expandafter\expandafter\@gobblefour - \expandafter\removeallbutfirstelement - \expandafter{\ltsgetfirstelement#1}% - }% -} - -\robust@def*\remleadparser{\LTS@testopt\LTS@remleadparser{,}} -\new@def\LTS@remleadparser[#1]#2{% - \LTS@ensuremacro{#2}% - \begingroup - \def\reserved@a#1{\futurelet\next\reserved@d}% - \@namedef{reserved@b} {\reserved@a#1}% - \def\reserved@d{% - \ifx\next\@sptoken - \expandafter\reserved@b - \else - \ifx#1\next - \cptthreexp\reserved@a - \else - \cptthreexp\reserved@c - \fi - \fi - }% - \def\reserved@c##1\LTS@nil{\endgroup\edef#2{\unexpanded{##1}}}% - \expandafter\reserved@a\expandafter#1#2\LTS@nil -} -\robust@def*\remtrailparser{\LTS@testopt\LTS@remtrailparser{,}} -\robust@def*\LTS@remtrailparser[#1]#2{% - \begingroup - \LTS@ensuremacro{#2}% - \let\trimpr@nil\relax - \defpass\LTS@rsvda{% - \despacecontent#2% - \xifinsetFT{#1\trimpr@nil}{\expandcsonce#2\trimpr@nil}{}{% - \def\LTS@rsvdb####1#1\trimpr@nil{% - \edef#2{\unexpanded{####1}}% - \LTS@rsvda - }% - \expandafter\LTS@rsvdb#2\trimpr@nil - }% - }% - \postgroupdef#2\endgroup -} -\robust@def*\ltsremoveparser{\LTS@testopt\LTS@remparser{,}} -\robust@def*\LTS@remparser[#1]#2{% - \LTS@remleadparser[#1]#2% - \LTS@remtrailparser[#1]#2% -} - -\robust@def*\SelectiveSanitize{\LTS@testopt\s@lectivesanitize\@M} -\robust@def*\s@lectivesanitize[#1]#2#3{% - \LTS@ensuremacro{#3}% - \begingroup - \cpt@cnta#1\advance\cpt@cnta\@ne - \let\temp@bgroup\bgroup - \let\bgroup\@undefined - \cptexpandsecond - {\s@l@ctivesanitize#3}{{\detokenize{#2}}{\expandcsonce#3}}% - \postgroupdef#3\endgroup -} -\robust@def*\s@l@ctivesanitize#1#2#3{% - \def\LTS@i{\futurelet\next\LTS@ii}% - \def\LTS@ii{% - \expandafter\LTS@iii\meaning\next\LTS@nil - \ifx\next\end - \let\cmd\@gobbleone - \else - \ifx\next\@sptoken - \edef#1{\expandcsonce#1\@space}% - \lowercase{\def\cmd} {\LTS@i}% - \else - \let\cmd\LTS@iv - \fi - \fi - \cmd - }% - \def\LTS@iii##1##2\LTS@nil{% - \if##1\@backslashchar\let\next\relax\fi - }% - \def\LTS@iv##1{% - \toks@\expandafter{#1}\toks1{##1}% - \ifx\next\temp@bgroup - \advance\cpt@cnta\m@one - \ifnum\cpt@cnta>\z@pt - \begingroup - \cptexpandsecond\s@l@ctivesanitize - {\noexpandcsn{\string#1}{#2}{\the\toks1}}% - \edefpass#1{\endgroup\toks1{\expandcsnonce{\string#1}}}% - \fi - \edef#1{\the\toks@{\the\toks1}}% - \advance\cpt@cnta\@ne - \else - \edef#1{\expandafter\string\the\toks1}% - \expandafter\cpt@in\expandafter{#1}{#2}% - \edef#1{\the\toks@\ifcpt@in#1\else\the\toks1\fi}% - \fi - \LTS@i - }% - \def#1{}\LTS@i#3\end -} -\robust@def*\LTS@checksanitya#1#2{\LTS@checksanity{,}{#1}#2} -\robust@def*\LTS@checksanityb#1#2{\LTS@checksanity{,.=}{#1}#2} -\robust@def*\LTS@checksanityc#1#2{\LTS@checksanity{,;}{#1}#2} -\robust@def*\LTS@checksanityd#1#2{\LTS@checksanity{,;:|-=}{#1}#2} -\robust@def*\LTS@checksanity#1#2#3{% - \cpt@checkfalse - \def\tsv@do##1{% - \ifboolTF{cpt@check}{}{% - \LTS@ch@cksanity{##1}{#2}% - }% - }% - \tsv@@parse{#1}% - \ifboolTF{cpt@check}{% - \edef#3{\unexpanded{#2}}% - \SelectiveSanitize[1]{#1}#3% - }{}% -} -\robust@def*\LTS@ch@cksanity#1#2{% - \ifbelongFT{#1}{#2}{}{% - \defpass\reserved@a##1#1##2\LTS@nil{% - \ifblankTF{##2}{\cpt@checktrue\loopbreak}{}% - }% - #2#1\LTS@nil - }% -} -\robust@def*\LTS@ensureothersanity#1#2{% - \begingroup - \edef#2{\unexpanded{#1}}% - \LTS@scantoksb#2% - \postgroupdef#2\endgroup -} - -% #1 : optional parser -% #2 : a control sequence or name (+ -> name) of original list -% #3 : new list to merge with #2 (* -> #3 is a macro) -% #4 : filter (use \nofilter when there isn't a filter) -\robust@def*\ltsfiltermergecsv{% - \begingroup - \let\LTS@parse\csv@@parse - \LTS@checkoptprefix - {\LTS@teststplcl{\LTS@testopt\LTS@filtermergelists{,}}}% -} -\robust@def*\ltsfiltermergekv{% - \begingroup - \let\LTS@parse\kv@@parse - \LTS@checkoptprefix - {\LTS@teststplcl{\LTS@testopt\LTS@filtermergelists,}}% -} -\robust@def*\LTS@filtermergelists[#1]#2#3#4{% - \edef\temp@do - {\noexpandcsn{\ifxTF\LTS@parse\csv@@parse{csv}{kv}@do}}% - \def\LTS@tempa{}% - \ifLTS@pl - \ifcsndefTF{#2}{\letcstocsn\LTS@tempa{#2}}{}% - \else - \ifdefTF{#2}{\let\LTS@tempa#2}{}% - \fi - \cpt@stchoose{LTS@st}{#3}\LTS@tempb\LTS@filtermergelists - \cptdeclarefilter{#4}% - \cpt@useemptyfalse - \def\LTS@tempf##1{\csliststack#1\LTS@tempa\unexpanded{##1}}% - \expandafter\def\temp@do##1{% - \edef\LTS@tempb{\unexpanded{##1}}% - % csv/kv loops don't use cpt@swa. So it is safe - % to use it here: - \cpt@swatrue - \cpt@usefilter\LTS@tempb\LTS@tempc - \let\LTS@tempd\LTS@tempa - \def\LTS@tempa{}% - \expandafter\def\temp@do####1{% - \edef\LTS@tempd{\unexpanded{####1}}% - \cpt@usefilter\LTS@tempd\LTS@tempe - \ifx\LTS@tempc\LTS@tempe - \cpt@swafalse - \edef\LTS@tempa{\LTS@tempf{##1}}% - \else - \edef\LTS@tempa{\LTS@tempf{####1}}% - \fi - }% - \ifcsnullTF\LTS@tempd{}{\LTS@parse*[#1]\LTS@tempd}% - \ifdefboolFT{cpt@swa}{}{\edef\LTS@tempa{\LTS@tempf{##1}}}% - }% - \ifcsnullTF\LTS@tempb{}{\LTS@parse*[#1]\LTS@tempb}% - \cptpassexpanded{% - \ifLTS@cl\global\fi - \let\ifLTS@pl\cptmakecs{#2}\else\noexpand#2\fi - \noexpand\LTS@tempa - }% - % If cl is true, then global assignment has already been done: - \ifboolTF{LTS@cl}\endgroup{% - \ifboolTF{LTS@pl}{% - \expandafter\postgroupdef\csname#2\endcsname\endgroup - }{% - \postgroupdef#2\endgroup - }% - }% -} -\robust@def*\filter@merge@csv#1{% - \begingroup - \let\LTS@parse\csv@@parse - \LTS@sttrue - \LTS@ifstringcase{#1}% - {fff}{\LTS@stfalse\LTS@plfalse\LTS@clfalse}% - {tff}{\LTS@sttrue\LTS@plfalse\LTS@clfalse}% - {ttf}{\LTS@sttrue\LTS@pltrue\LTS@clfalse}% - {ttt}{\LTS@sttrue\LTS@pltrue\LTS@cltrue}% - {ftt}{\LTS@stfalse\LTS@pltrue\LTS@cltrue}% - {fft}{\LTS@stfalse\LTS@plfalse\LTS@cltrue}% - {tft}{\LTS@sttrue\LTS@plfalse\LTS@cltrue}:% - [\LTS@err{No match for \string\filter@merge@csv}\@ehc]% - \LTS@filtermergelists -} - -% #1: parser -% #2: new single element, in a macro or otherwise; -% #3: old list (in a macro); -% #4: filter (a macro); -% We want to filter #2 before entering the result in #3: -\robust@def*\singleelementfiltermerge{% - \LTS@testcl{\LTS@testopt\LTS@sefm,}% -} -\robust@def*\LTS@sefm[#1]#2#3#4{% - \cptdeclarefilter{#4}% - \cpt@usefilter{#2}\reserved@a - \edef\reserved@a{\simpleexpandarg\cpttrimspace\reserved@a}% - \ifdefTF#3{}{\def#3{}}% - \xifinsetTF{#1\cptoxdetok\reserved@a#1}{#1\cptoxdetok#3#1}{}{% - \ifLTS@cl\global\fi - \edef#3{\csliststack#1#3\expandcsonce\reserved@a}% - }% -} -% #1 : control sequence of old (non-separated) list -% #2 : new update (a non-separated list) -% #3 : filter (use \nofilter when there isn't a filter) -\robust@def*\ltsfiltermergetsv{\LTS@testcl\LTS@filtermergetokens} -\robust@def*\LTS@filtermergetokens#1#2#3{% - \begingroup - \let\ifLTS@mergecl\ifLTS@cl - \cptdeclarefilter{#3}% - \ifdefTF{#1}{}{\emptify#1}% - \def\LTS@tempa{#2}% - \LTS@tfor@b\LTS@tempa\LTS@tempa{% - \cpt@swatrue - \cpt@usefilter\LTS@tempa\LTS@tempb - \let\LTS@tempc#1\emptify#1% - \LTS@tfor@b\LTS@tempc\LTS@tempc{% - \cpt@usefilter\LTS@tempc\LTS@tempd - \ifx\LTS@tempb\LTS@tempd - \cpt@swafalse - \edef#1{\expandcsonce#1\expandcsonce\LTS@tempa}% - \else - \edef#1{\expandcsonce#1\expandcsonce\LTS@tempc}% - \fi - }% - \ifcpt@swa\edef#1{\expandcsonce#1\expandcsonce\LTS@tempa}\fi - }% - \ifLTS@mergecl - \globalize#1\endgroup - \else - \cptpassacross#1\endgroup - \fi -} -% #1 : optional list parser; -% #2 : control sequence (or, if +, cs name) of csv list; -% #3 : non-contiguous sublist to remove -% ('*' implies that this is a control sequence); -% #4 : filter (use \nofilter when there isn't a filter); -\robust@def*\filterremovecsv{% - \begingroup - \let\LTS@parse\csv@@parse - \LTS@checkoptprefix - {\LTS@teststplcl{\LTS@testopt\LTS@filterremoveelements{,}}}% -} -\robust@def*\filterremovekv{% - \begingroup - \let\LTS@parse\kv@@parse - \LTS@checkoptprefix - {\LTS@teststplcl{\LTS@testopt\LTS@filterremoveelements{,}}}% -} -\robust@def*\LTS@filterremoveelements[#1]#2#3#4{% - \cpt@checklistparser{#1}\relax - \begingroup - \edef\temp@do - {\noexpandcsn{\ifxTF\LTS@parse\csv@@parse{csv}{kv}@do}}% - \letcstocsn\LTS@normalize - {cpt@\ifxTF\LTS@parse\csv@@parse{csv}{kv}normalize}% - \ifLTS@pl - \ifcsndefTF{#2}{}{\emptifycsn{#2}}% - \letcstocsn\LTS@tempa{#2}% - \else - \ifdefTF{#2}{}{\def#2{}}% - \let\LTS@tempa#2% - \fi - \cpt@stchoose{LTS@st}{#3}\LTS@tempb\LTS@filterremoveelements - \ifcsnullTF\LTS@tempb{} - {\cpt@sttrue\LTS@normalize[#1]\LTS@tempb}% - \cptdeclarefilter{#4}% - \def\LTS@tempd{}% - \expandafter\def\temp@do##1{% - \edef\LTS@tempa{\unexpanded{##1}}% - \cpt@usefilter\LTS@tempa\LTS@tempc - \oifinset@sp@TF#1\LTS@tempc\LTS@tempb{}{% - \edef\LTS@tempd{\csliststack#1\LTS@tempd\unexpanded{##1}}% - }% - }% - \ifcsnullTF\LTS@tempa{}{\LTS@parse*[#1]\LTS@tempa}% - \cptpassexpanded{% - \ifLTS@cl\global\fi - \let\ifLTS@pl\cptmakecs{#2}\else\noexpand#2\fi - \noexpand\LTS@tempd - }% - \ifboolTF{LTS@cl}\endgroup{\postgroupdef#2\endgroup}% -} - -% \purgeelements is faster than \filterremoveelements but it -% first detokenizes the tokens. It thus isn't as versatile. -% Also inherent leading and trailing spaces may cause -% problems in the removal of elements. It is handy in -% cleaning \@unusedoptionlist. -% #1: optional parser; -% #2: noncontiguous sublist; -% #3: container of original list -\robust@def*\purgeelements{% - \LTS@testst{% - \let\ifLTS@purgest\ifLTS@st - \begingroup - \@makeother{\#}% - \LTS@testopt{\expandafter\endgroup\LTS@p@rgeelements}{,}% - }% -} -% The parameter character '#' must be innocent when -% calling \purgeelements: -\robust@def*\LTS@purgeelements{% - \LTS@err{Use \noexpand\purgeelements instead}\@ehc -} -\robust@def*\LTS@p@rgeelements[#1]#2#3{% - \cpt@checklistparser{#1}\relax - \begingroup - \def\csv@do##1{% - \ifblankTF{##1}{}{% - \def\LTS@tempb####1#1##1#1####2\LTS@nil{####1#1####2\purge@nil}% - \def\LTS@tempc####1#1\purge@nil####2\purge@nil{% - \ifx#1####1\@empty\else####1\fi - }% - \def\LTS@tempa{% - \cptthreexp\LTS@tempc\expandafter\LTS@tempb\expandafter - #1\detokenize\expandafter{#3}#1\purge@nil#1##1#1\LTS@nil - }% - \expandafter\edef\expandafter#3\expandafter{\LTS@tempa}% - }% - }% - \ifblankTF{#2}{}{\cptexpandarg{\csv@@loop[#1]}{\detokenize{#2}}}% - \postgroupdef#3\endgroup - \LTS@remparser[#1]#3% - \ifboolTF{LTS@purgest}{}{\LTS@scantoks@hash#3}% - \undefcs\ifLTS@purgest -} -% #1 : container of original (non-separated) tokens -% #2 : non-separated members to delete (* -> a macro) -% #2 : filter -\robust@def*\filterdeletetokens{\LTS@teststcl\LTS@deletetokens} -\robust@def*\LTS@deletetokens#1#2#3{% - \let\ifLTS@fdelcl\ifLTS@cl - \begingroup - \cptdeclarefilter{#3}% - \def\siso@do##1{% - \edef\LTS@tempa{\unexpanded{##1}}% - \cpt@usefilter\LTS@tempa\LTS@tempc - \edef\LTS@tempa{\expandcsonce\LTS@tempc}% - \cptexpandsecond{% - \def\LTS@tempb####1}{\expandcsonce\LTS@tempa}####2####3\LTS@nil{% - \edef\LTS@tempb{\unexpanded{####2}}% - \ifxTF\LTS@nnil\LTS@tempb{}{% - \cptexpandsecond{\def\LTS@tempb########1}{% - \expandcsonce\LTS@tempa}########2\LTS@nil{% - \edef#1{\unexpanded{########1########2}}% - }% - \expandafter\LTS@tempb#1\LTS@nil - }% - }% - \cptexpandsecond\LTS@tempb - {\expandcsonce#1\expandcsonce\LTS@tempa}{\LTS@nil}\LTS@nil - }% - \ifboolTF{LTS@st}{% - \expandafter\siso@@loop\expandafter{#2}% - }{% - \siso@@loop{#2}% - }% - \postgroupdef#1\endgroup - \ifLTS@fdelcl\globalize#1\fi - \undefcs\ifLTS@fdelcl -} -% #1 : container of original (non-separated) tokens -% #2 : non-separated members to delete -\robust@def*\simpledeletetokens#1#2{% - \def\siso@do##1{% - \def\LTS@tempa####1##1####2####3\LTS@nil{% - \edef\LTS@tempa{\unexpanded{####2}}% - \ifx\LTS@nnil\LTS@tempa\else - \def\LTS@tempa########1##1########2\LTS@nil{% - \edef#1{\unexpanded{########1########2}}% - }% - \expandafter\LTS@tempa#1\LTS@nil - \fi - }% - \expandafter\LTS@tempa#1##1{\LTS@nil}\LTS@nil - }% - \expandafter\siso@@loop\expandafter{#2}% -} -\robust@def*\DeclareVerbatimDelimiter#1{% - \ifsingletokenFT{#1}{% - \LTS@err{Verbatim delimiter isn't a single token}\@ehc - }{% - \def\LTS@v@rbatimstore##1#1##2#1{% - \endgroup - \LTS@v@rb@timstore{##2}% - }% - }% -} -\robust@def*\LTS@v@rb@timst@re{% - \begingroup - \@sanitize\obeyspaces - \LTS@v@rbatimstore -} -\robust@def*\verbatimstore#1{% - \long\def\LTS@v@rb@timstore##1{\def#1{##1}}% - \LTS@v@rb@timst@re -} -\robust@def*\ltsretokenize{\LTS@testst\LTS@retokenize} -\robust@def\LTS@retokenize#1#2{% - \begingroup - \edef\LTS@tempa{\unexpanded{#2}}% - \ifLTS@st - \def\LTS@ret@kenize##1\LTS@nil{\protected@edef#1{##1}}% - \else - \def\LTS@ret@kenize##1\LTS@nil{\edef#1{\unexpanded{##1}}}% - \fi - \cpteveryscan - \everyeof{\LTS@nil}% - \expandafter\LTS@ret@kenize\scantokens\expandafter{\LTS@tempa}% - \relax\postgroupdef#1\endgroup -} -\robust@def*\LTS@scantoksa#1{% - \begingroup - \edef#1{\long\def\string#1{\detokenize\expandafter{#1}}}% - \cpteveryscan - \scantokens\expandafter{#1}\relax - \postgroupdef#1\endgroup -} -\robust@def*\LTS@scantoks@hash#1{% - \begingroup - \edef#1{\long\def\string#1{\detokenize\expandafter{#1}}}% - \catcode`\#=6\relax\cpteveryscan - \scantokens\expandafter{#1}\relax - \postgroupdef#1\endgroup -} -\robust@def*\LTS@scantoksb#1{% - \begingroup - \def\siso@do##1{\catcode`##1\string=12\relax}% - \siso@@loop{=,;|-+?><}% - \LTS@scantoksa#1% - \postgroupdef#1\endgroup -} -\robust@def*\LTS@scantoksc{\LTS@testplcl\LTS@sc@ntoksc} -\robust@def\LTS@sc@ntoksc#1{% - \def\comma@do##1{% - \ifboolTF{LTS@pl}{% - \expandafter\LTS@ensuremacro\csname ##1\endcsname - \letcstocsn\reserved@e{##1}% - }{% - \LTS@ensuremacro{##1}% - \let\reserved@e##1% - }% - \LTS@scantoksa\reserved@e - \cptpassexpanded{% - \ifLTS@cl\global\fi\let\ifLTS@pl - \cptmakecs{##1}\else\unexpanded{##1}\fi - \noexpand\reserved@e - }% - }% - \commacsvparse{#1}% -} -\robust@def*\LTS@scantoksd#1#2{% - \cptexpandsecond{#1\cpteveryscan\scantokens}{% - {#2}% - \everyeof{\the\everyeof}% - \noexpand\endlinechar\the\endlinechar\relax - \catcode`\noexpand\@=\the\catcode`\@\relax - \catcode`\noexpand\ =\the\catcode`\ \relax - \catcode`\noexpand\\=\the\catcode`\\\relax - \catcode`\noexpand\{=\the\catcode`\{\relax - \catcode`\noexpand\}=\the\catcode`\}\relax - }% -} -\providecommand*\newbool{\ltsnewbool} -\providecommand*\setbool{\ltssetbool} -\providecommand*\booltrue{\ltsbooltrue} -\providecommand*\boolfalse{\ltsboolfalse} -\providecommand*\setbooltrue{\ltssetbooltrue} -\providecommand*\setboolfalse{\ltssetboolfalse} -\robust@def*\ltsnewbool#1{\cpt@swatrue\LTS@testopt{\LTS@newbool{#1}}{false}} -\robust@def*\defbool#1{\cpt@swafalse\LTS@testopt{\LTS@newbool{#1}}{false}} -\new@def*\LTS@newbool#1[#2]{% - \ifinsetFT{,}{#1}{}{% - \begingroup - \edef\LTS@tempa{\ifcpt@swa'\string\ltsnewbool' - \else'\string\ltsdefbool'\fi}% - \edef\LTS@tempb{\ifcpt@swa'\string\NewBooleans' - \else'\string\DefBooleans'\fi}% - \LTS@err{Command \LTS@tempa\@space doesn't accept list}% - {Please submit only one boolean to \LTS@tempa\MsgBrk - at a time. You may consider using\LTS@tempb\MsgBrk - if you really want to define a set of booleans.}% - \endgroup - }% - \LTS@ensurenoscape{#1}% - \LTS@badboolname{#1}% - \ifboolTF{cpt@swa}{% - \ifcsndefinable{if#1}\relax - \LTS@getboolstate\ltsnewbool{#2}% - }{% - \ifcsndefFT{if#1}{}{% - \LTS@verbosewarn{Boolean '\@backslashchar if#1' redefined}% - }% - \LTS@getboolstate\ltsdefbool{#2}% - }% - \csnnewif{#1}% - \usename{#1\LTS@boolval}% -} -\robust@def*\NewBooleans{\cpt@swatrue\LTS@testopt\LTS@NewBooleans{}} -\robust@def*\DefBooleans{\cpt@swafalse\LTS@testopt\LTS@NewBooleans{}} -\robust@def*\LTS@NewBooleans[#1]#2{% - \LTS@testopt{\LTS@B@oleans{#1}{#2}}{false}% -} -\new@def*\LTS@B@oleans#1#2[#3]{% - \cptexpandsecond\LTS@getboolstate - {\ifboolTF{cpt@swa}\NewBooleans\DefBooleans}{#3}% - \def\comma@do##1{% - \LTS@ensurenoscape{##1}% - \LTS@badboolname{#1##1}% - \ifboolTF{cpt@swa}{% - \ifcsndefinable{if#1##1}\relax - }{% - \ifcsndefFT{if#1##1}{}{% - \LTS@verbosewarn{Boolean '\@backslashchar if#1##1' - redefined}% - }% - }% - \csnnewif{#1##1}% - \usename{#1##1\LTS@boolval}% - }% - \commacsvparse{#2}% -} -\robust@def*\ltssetbool#1#2{% - \ifcsndefFT{if#1}{% - \LTS@noboolerr{#1}% - }{% - \LTS@getboolstate\ltssetbool{#2}% - \csname#1\LTS@boolval\endcsname - }% -} -\robust@def*\ltssetbooltrue#1{% - \ifcsndefFT{if#1}{\LTS@noboolerr{#1}}{\usename{#1true}}% -} -\newletcs\ltsbooltrue\ltssetbooltrue -\robust@def*\ltssetboolfalse#1{% - \ifcsndefFT{if#1}{\LTS@noboolerr{#1}}{\usename{#1false}}% -} -\newletcs\ltsboolfalse\ltssetboolfalse -\robust@def*\LTS@noboolerr#1{% - \LTS@err{Boolean/switch '\string#1' is undefined}% - {You need to first define the boolean/switch '\string#1'.}% -} -\robust@def*\LTS@boolnameerr#1{% - \LTS@err{'\string\if#1' not valid as a boolean/switch}% - {Invalid boolean/switch name '\string#1'.}% -} -\new@def*\LTS@boolvalerr#1#2{% - \LTS@err{Invalid boolean/switch value '#2' in \string#1}% - {Valid boolean/switch values are \LTS@validboolvalues.}% -} -\new@def*\LTS@validboolvalues{true,false} -\robust@def*\AddValidBooleanValues#1{% - \ltsfiltermergecsv![,]\LTS@validboolvalues{#1}\nofilter -} -\robust@def*\RemoveValidBooleanValues#1{% - \filterremovecsv!\LTS@validboolvalues{#1}\nofilter -} -\robust@def*\LTS@getboolstate#1#2{% - \lowercase{% - \xifinsetTF{,#2,}{,\LTS@validboolvalues,}{% - \edef\LTS@boolval{#2}% - }% - }{% - \LTS@boolvalerr{#1}{#2}% - }% -} -\robust@def*\LTS@badboolname#1{% - \begingroup - \xifstrcmpTF{\expandafter\LTS@cartwo\string#1xx\car@nil}{if}{% - \LTS@boolnameerr{if}% - }{% - \edef\LTS@tempa{\s@expandarg\cpttrimspaces{\cptrm-`\q#1}}% - \oifstrcmpTF\LTS@tempa{x}{\LTS@boolnameerr{x}}{% - \oifstrcmpTF\LTS@tempa{on}{\LTS@boolnameerr{on}}{% - \oifstrcmpTF\LTS@tempa{off}{\LTS@boolnameerr{off}}{% - \oifstrcmpTF\LTS@tempa{tog}{\LTS@boolnameerr{tog}}{% - \oifstrcmpTF\LTS@tempa{bool}{\LTS@boolnameerr{bool}}{% - \oifstrcmpTF\LTS@tempa{switch}{\LTS@boolnameerr{switch}}{}% - }% - }% - }% - }% - }% - }% - \endgroup -} -\providecommand*\newswitch[1]{\cpt@swatrue\LTS@testopt{\LTS@newswitch#1}{false}} -\robust@def*\defswitch#1{\cpt@swafalse\LTS@testopt{\LTS@newswitch#1}{false}} -\robust@def*\LTS@newswitch#1[#2]{% - \ifinsetFT{,}{#1}{}{% - \begingroup - \edef\LTS@tempa{\ifcpt@swa'\string\newswitch' - \else'\string\defswitch'\fi}% - \edef\LTS@tempb{\ifcpt@swa'\string\NewSwitches' - \else'\string\DefSwitches'\fi}% - \LTS@err{Command \LTS@tempa\@space doesn't accept list}% - {Please submit only one switch to \LTS@tempa\MsgBrk - at a time. You may consider using\LTS@tempb\MsgBrk - if you really want to define a set of switches.}% - \endgroup - }% - \LTS@ensurenoscape{#1}% - \LTS@badboolname{#1}% - \ifboolTF{cpt@swa}{% - \ifcsndefinable{#1}\relax - \LTS@getboolstate\newswitch{#2}% - }{% - \ifcsndefFT{#1}{}{% - \LTS@verbosewarn{Switch '\@backslashchar#1' redefined}% - }% - \LTS@getboolstate\defswitch{#2}% - }% - \letcsntocsn{#1}{cpt\LTS@boolval}% -} -\robust@def*\NewSwitches{\cpt@swatrue\LTS@testopt\LTS@NewSwitches{}} -\robust@def*\DefSwitches{\cpt@swafalse\LTS@testopt\LTS@NewSwitches{}} -\robust@def*\LTS@NewSwitches[#1]#2{% - \LTS@testopt{\LTS@Sw@tches{#1}{#2}}{false}% -} -\new@def*\LTS@Sw@tches#1#2[#3]{% - \cptexpandsecond\LTS@getboolstate - {\ifboolTF{cpt@swa}\NewSwitches\DefSwitches}{#3}% - \docommalist{#2}{% - \LTS@ensurenoscape{##1}% - \LTS@badboolname{#1##1}% - \ifboolTF{cpt@swa}{% - \ifcsndefinable{if#1##1}\relax - }{% - \ifcsndefFT{if#1##1}{}{% - \LTS@verbosewarn{Switch '\@backslashchar if#1##1' - redefined}% - }% - }% - \letcsntocsn{#1##1}{cpt\LTS@boolval}% - }% -} -\robust@def*\NewTogs{\cpt@swatrue\LTS@testopt\LTS@NewTogs{}} -\robust@def*\DefTogs{\cpt@swafalse\LTS@testopt\LTS@NewTogs{}} -\new@def*\LTS@NewTogs[#1]#2{\LTS@testopt{\LTS@NewT@gs[#1]{#2}}{false}} -\new@def*\LTS@NewT@gs[#1]#2[#3]{% - \cptexpandsecond\LTS@getboolstate - {\ifcpt@swa\NewTogs\else\DefTogs\fi}{#3}% - \def\comma@do##1{% - \LTS@ensurenoscape{##1}% - \cptpassexpanded{\ifcpt@swa\newtog\else\deftog\fi}{#1##1}% - \usename{settog\LTS@boolval}{#1##1}% - }% - \commacsvparse{#2}% -} -\robust@def*\NewToks{\cpt@swatrue\LTS@testopt\LTS@NewToks{}} -\robust@def*\DefToks{\cpt@swafalse\LTS@testopt\LTS@NewToks{}} -\new@def*\LTS@NewToks[#1]#2{% - \def\comma@do##1{% - \LTS@ensurenoscape{##1}% - \ifboolTF{cpt@swa}{% - \ifcsndefinable{#1##1}\relax - }{% - \ifcsndefFT{#1##1}{}{% - \LTS@verbosewarn{Token register '\@backslashchar - #1##1' redefined}% - }% - }% - \csnnewtoks{#1##1}% - }% - \commacsvparse{#2}% -} -\robust@def*\NewCounts{\cpt@swatrue\LTS@testopt\LTS@NewCounts{}} -\robust@def*\DefCounts{\cpt@swafalse\LTS@testopt\LTS@NewCounts{}} -\new@def*\LTS@NewCounts[#1]#2{\LTS@testopt{\LTS@N@wCounts[#1]#2}{}} -\new@def*\LTS@N@wCounts[#1]#2[#3]{% - \def\comma@do##1{% - \LTS@ensurenoscape{##1}% - \ifboolTF{cpt@swa}{% - \ifcsndefinable{#1##1#3}\relax - }{% - \ifcsndefFT{#1##1#3}{}{% - \LTS@verbosewarn{Counter register '\@backslashchar - #1##1#3' redefined}% - }% - }% - \csnnewcount{#1##1#3}% - }% - \commacsvparse{#2}% -} -\robust@def*\NewCounters{\cpt@swatrue\LTS@testopt\LTS@NewCounters{}} -\robust@def*\DefCounters{\cpt@swafalse\LTS@testopt\LTS@NewCounters{}} -\new@def*\LTS@NewCounters[#1]#2{\LTS@testopt{\LTS@N@wCounters[#1]#2}{}} -\new@def*\LTS@N@wCounters[#1]#2[#3]{% - \def\comma@do##1{% - \LTS@ensurenoscape{##1}% - \ifboolTF{cpt@swa}{% - \ifcsndefinable{#1##1#3}\relax - }{% - \ifcsndefFT{#1##1#3}{}{% - \LTS@verbosewarn{Counter register '\@backslashchar - #1##1#3' redefined}% - }% - }% - \@definecounter{#1##1#3}% - }% - \commacsvparse{#2}% -} -\newletcs\NewNumbers\NewCounters -\robust@def*\NewDimens{\cpt@swatrue\LTS@testopt\LTS@NewDimens{}} -\robust@def*\DefDimens{\cpt@swafalse\LTS@testopt\LTS@NewDimens{}} -\new@def*\LTS@NewDimens[#1]#2{% - \def\comma@do##1{% - \LTS@ensurenoscape{##1}% - \ifboolTF{cpt@swa}{% - \ifcsndefinable{#1##1}\relax - }{% - \ifcsndefFT{#1##1}{}{% - \LTS@verbosewarn{Dimension register '\@backslashchar - #1##1' redefined}% - }% - }% - \csnnewdimen{#1##1}% - }% - \commacsvparse{#2}% -} -\robust@def*\NewBoxes{\cpt@swatrue\LTS@testopt\LTS@NewBoxes{}} -\robust@def*\DefBoxes{\cpt@swafalse\LTS@testopt\LTS@NewBoxes{}} -\new@def*\LTS@NewBoxes[#1]#2{% - \def\comma@do##1{% - \LTS@ensurenoscape{##1}% - \ifboolTF{cpt@swa}{% - \ifcsndefinable{#1##1}\relax - }{% - \ifcsndefFT{#1##1}{}{% - \LTS@verbosewarn{Box register '\@backslashchar - #1##1' redefined}% - }% - }% - \csnnewbox{#1##1}% - }% - \commacsvparse{#2}% -} -\robust@def*\NewSkips{\cpt@swatrue\LTS@testopt\LTS@NewSkips{}} -\robust@def*\DefSkips{\cpt@swafalse\LTS@testopt\LTS@NewSkips{}} -\new@def*\LTS@NewSkips[#1]#2{% - \def\comma@do##1{% - \LTS@ensurenoscape{##1}% - \ifboolTF{cpt@swa}{% - \ifcsndefinable{#1##1}\relax - }{% - \ifcsndefFT{#1##1}{}{% - \LTS@verbosewarn{Skip register '\@backslashchar - #1##1' redefined}% - }% - }% - \csnnewskip{#1##1}% - }% - \commacsvparse{#2}% -} -\newletcs\NewLengths\NewSkips -\newletcs\DefLengths\DefSkips -\robust@def*\NewMuSkips{\cpt@swatrue\LTS@testopt\LTS@NewMuSkips{}} -\robust@def*\DefMuSkips{\cpt@swafalse\LTS@testopt\LTS@NewMuSkips{}} -\new@def*\LTS@NewMuSkips[#1]#2{% - \def\comma@do##1{% - \LTS@ensurenoscape{##1}% - \ifboolTF{cpt@swa}{% - \ifcsndefinable{#1##1}\relax - }{% - \ifcsndefFT{#1##1}{}{% - \LTS@verbosewarn{\noexpand\muskip register '\@backslashchar - #1##1' redefined}% - }% - }% - \csnnewmuskip{#1##1}% - }% - \commacsvparse{#2}% -} -\robust@def*\NewWrites{\cpt@swatrue\LTS@testopt\LTS@NewWrites{}} -\robust@def*\DefWrites{\cpt@swafalse\LTS@testopt\LTS@NewWrites{}} -\new@def*\LTS@NewWrites[#1]#2{% - \def\comma@do##1{% - \LTS@ensurenoscape{##1}% - \ifboolTF{cpt@swa}{% - \ifcsndefinable{#1##1}\relax - }{% - \ifcsndefFT{#1##1}{}{% - \LTS@verbosewarn{Write stream '\@backslashchar - #1##1' redefined}% - }% - }% - \csnnewwrite{#1##1}% - }% - \commacsvparse{#2}% -} -\robust@def*\NewReads{\cpt@swatrue\LTS@testopt\LTS@NewReads{}} -\robust@def*\DefReads{\cpt@swafalse\LTS@testopt\LTS@NewReads{}} -\new@def*\LTS@NewReads[#1]#2{% - \def\comma@do##1{% - \LTS@ensurenoscape{##1}% - \ifboolTF{cpt@swa}{% - \ifcsndefinable{#1##1}\relax - }{% - \ifcsndefFT{#1##1}{}{% - \LTS@verbosewarn{Read stream '\@backslashchar - #1##1' redefined}% - }% - }% - \csnnewread{#1##1}% - }% - \commacsvparse{#2}% -} -\robust@def*\checknewcommands{% - \LTS@checkoptprefix{\LTS@teststpl\LTS@checknewcmds}% -} -\new@def*\LTS@checknewcmds#1{% - \begingroup - \edef\LTS@tempa{\ifLTS@st*\fi}% - \def\csv@do##1{% - \usename{ifcs\ifLTS@pl n\fi definable}{##1}\relax - }% - \expandafter\csv@@parse\LTS@tempa[,]{#1}% - \endgroup -} -\new@def*\LTS@post@prefixerr#1{% - \LTS@err{Bad prefixes for command '\string#1'}% - {You have wrongly prefixed command '\string#1'\MsgBrk - with both star sign and exclamation mark.\MsgBrk - You have to choose one of them. The star expands\MsgBrk - the arguments once, while the exclamation mark\MsgBrk - expands the arguments fully.}% -} -\robust@def*\postgroup{\LTS@teststcl\LTS@postgroup} -\new@def\LTS@postgroup#1{% - \ifLTS@st - \ifLTS@cl - \LTS@post@prefixerr\postgroup - \else - \edef\LTS@tempa{\unexpanded{#1}}% - \expandallonce\LTS@tempa - \fi - \else - \ifLTS@cl - \if\detokenize{#1*}% - \LTS@post@prefixerr\postgroup - \fi - \let\next\@firstofone - \else - \let\next\unexpanded - \fi - \fi - \advance\@tempcnta\@ne - \csn@xdef{LTS@aft@rgroup@\romannumeral\@tempcnta}{% - \gundefcsn{LTS@aft@rgroup@\romannumeral\@tempcnta}% - \ifboolTF{LTS@st}{\@firstofone\LTS@tempa\@gobble}\next{#1}% - }% - \aftercsname\aftergroup{LTS@aft@rgroup@\romannumeral\@tempcnta}% -} -\robust@def*\postassignment{\LTS@teststcl\LTS@postassignment} -\robust@def\LTS@postassignment#1{% - \begingroup - \ifboolTF{LTS@st}{% - \ifboolTF{LTS@cl}{% - \LTS@post@prefixerr\postassignment - }{% - \edef\LTS@tempa{\unexpanded{#1}}% - \expandallonce\LTS@tempa - }% - }{% - \ifboolTF{LTS@cl}{% - \if\detokenize{#1*}% - \LTS@post@prefixerr\postassignment - \fi - \let\next\@firstofone - }{% - \let\next\unexpanded - }% - }% - \advance\@tempcnta\@ne - \aftercsname\xdef{LTS@p@stassignment@\romannumeral\@tempcnta}{% - \gundefcsn{LTS@p@stassignment@\romannumeral\@tempcnta}% - \ifboolTF{LTS@st}{\@firstofone\LTS@tempa\@gobble}\next{#1}% - }% - \aftercsname{\endgroup\afterassignment} - {LTS@p@stassignment@\romannumeral\@tempcnta}% -} -\robust@def*\minorpostassignment{\LTS@testst\LTS@minorpostassignment} -\robust@def\LTS@minorpostassignment#1{% - \begingroup - \advance\@tempcnta\@ne - \csn@xdef{LTS@p@stassignment@\romannumeral\@tempcnta}{% - \gundefcsn{LTS@p@stassignment@\romannumeral\@tempcnta}% - \ifLTS@st\expandafter\@iden\else\expandafter\unexpanded\fi{#1}% - }% - \aftercsname{\endgroup\afterassignment} - {LTS@p@stassignment@\romannumeral\@tempcnta}% -} -\robust@def*\LTS@undef{\LTS@testcl\LTS@und@f} -\new@def*\LTS@und@f#1{% - \is@global@or@relax - \docommalist{#1}{% - \ifsingletoken@sp@TF{##1}{% - \LTS@ensurescape{##1}% - \glob@lrel@x\undefcs##1% - }{% - \cpt@notonetokenerr{##1}% - }% - }% -} -\robust@def*\ltsundefcslist{% - \LTS@checkoptprefix{\LTS@teststplcl{\cpt@testopt\LTS@undefcslist{,}}}% -} -\new@def*\LTS@undefcslist[#1]#2{% - \is@global@or@relax - \edef\reserved@a{\ifLTS@st*\fi}% - \def\csv@do##1{% - \ifLTS@pl - \glob@lrel@x\undefcsn{##1}% - \else - \glob@lrel@x\undefcs##1% - \fi - }% - \expandafter\csv@@parse\reserved@a[#1]{#2}% -} -\robust@def*\declarepackagecmd{\LTS@testopt\LTS@declarepkgcmd{}} -\new@def\LTS@declarepkgcmd[#1]#2{% - \LTS@ensurescape{#2}% - \ifdefTF#2{% - \letcsntocs{Saved\cptremovescape#2}#2% - \cptpassexpanded{% - \AtTagEndPackage{% - \let\noexpand#2\noexpandcsn{Saved\cptremovescape#2}% - \gundefcs\noexpandcsn{Saved\cptremovescape#2}% - }% - }% - }{% - \AtTagEndPackage{\gundefcs#2}% - }% - #1\def#2% -} -\robust@def*\declaredocumentcmd{\LTS@testopt\LTS@declaredoccmd{}} -\new@def\LTS@declaredoccmd[#1]#2{% - \LTS@ensurescape{#2}% - \ifcsdefinable#2\relax - \ifinstylefileTF{% - \cptpassexpanded{% - \LTS@AtBeginDocument{% - \let\noexpand#2\noexpandcsn{Saved\cptremovescape#2}% - \gundefcs\noexpandcsn{Saved\cptremovescape#2}% - }% - }% - \postassignment{% - \letcsntocs{Saved\cptremovescape#2}#2% - \gundefcs#2% - }% - }{}% - #1\def#2% -} -\robust@def*\LTS@providedef{\LTS@teststcl{\LTS@pr@videdef\relax}} -\robust@def*\LTS@providerobustdef{\LTS@teststcl{\LTS@pr@videdef\protected}} -\new@def\LTS@pr@videdef#1#2{% - \is@long@or@relax\is@global@or@relax - \LTS@ensurescape{#2}% - \ifdefTF#2{% - \LTS@verboseinfo{Command '\string#2' already defined: - \MsgBrk Not redefined}% - \minorpostassignment{\gundefcs\pr@v@de}% - }{% - \minorpostassignment{% - \gletcs#2\pr@v@de - \gletcsntocs{LTS@test@\cptremovescape#2}#2% - \gundefcs\pr@v@de - }% - }% - \glob@lrel@x\l@ngrel@x#1\def\pr@v@de -} -\new@def\testprovidedcommand#1{% - \LTS@ensurescape{#1}% - \begingroup - \ifmacroFT#1{% - \aftergroup\@secondoftwo - }{% - \aftercsname\aftergroup{LTS@\cptthreexp - \ifxTF\usename{LTS@test@\cptremovescape#1}#112of2}% - }% - \endgroup -} -\robust@def*\LTS@reviewcommandhandler#1{% - \LTS@verboseinfo{% - Previously 'provided' definition of '\string#1'\MsgBrk - is retained. Your new definition was ignored\MsgBrk - }% -} -\robust@def*\reviewcommand{\LTS@testopt\LTS@revcommand{}} -\new@def\LTS@revcommand[#1]#2#3{% - \testprovidedcommand#2{% - \LTS@reviewcommandhandler{#2}% - }{% - #1\def#2{#3}% - }% -} -% #1: list of comma-separated command pairs: -\robust@def*\newprovidedcommands#1{% - \def\reserved@e##1##2\LTS@nil{% - \ifdefTF{##2}{% - \LTS@providerobustdef*##1{##2}% - }{% - \cpt@notdeferr{##2}% - }% - }% - \def\csv@do##1{\reserved@e##1\LTS@nil}% - \csv@@parse[,]{#1}% -} -\new@def*\ifrelaxTF#1{% - \ifdefinedTF{#1}% - {\usename{LTS@\expandafter\ifxTF\cpt@car#1\car@nil - \relax12of2}}\@secondoftwo -} -\new@def*\ifcsnrelaxTF#1{% - \ifcsnameFT{#1}\@secondoftwo - {\usename{LTS@\aftercsname\expandafter\ifxTF\cpt@car#1\car@nil - \relax12of2}}% -} -\def\ifcsnrelaxFT#1{\usename{LTS@\ifcsnrelaxTF{#1}21of2}} -\new@def*\ifdefaxTFN#1{% - \ifdefinedTF{#1}% - {\usename{LTS@\expandafter\ifxTF\cpt@car#1\car@nil - \relax21of3}}\@thirdofthree -} -\new@def*\ifcsndefaxTFN#1{% - \ifcsnameTF{#1}% - {\usename{LTS@\expandafter\ifxTF\csname#1\endcsname - \relax21of3}}\@thirdofthree -} -\robust@def*\ifargifTF#1{% - \usename{LTS@\ifnum\pdfstrcmp - {\expandafter\LTS@carcube\string#1xxx\car@nil}% - {\string\if}=\z@pt1\else2\fi of2}% -} -\robust@def*\LTS@detokenize{\LTS@testst\LTS@det@kenize} -\robust@def*\LTS@det@kenize#1#2{% - \edef#2{\detokenize{#1}}% - \ifLTS@st - \simpleexpandarg\ifargifTF#2{% - \LTS@err{'\@backslashchar if' not valid}\@ehc - }{% - \LTS@scantoksa#2% - \edef#2{\cpttxdetok#2}% - }% - \fi -} -\new@def*\LTS@detokdespace{\LTS@testpl\LTS@det@kdespace} -\new@def\LTS@det@kdespace#1{% - \ifboolTF{LTS@pl}{% - \edef\LTS@resa{\detokenize{#1}}% - \despacecontent\LTS@resa - }{% - \ifdefTF{#1}{}{% - \LTS@err{Command '\string#1' is undefined}{Command - '\string\LTS@detokdespace' doesn't accept undefined - \MsgBrk commands when submitted without the '+' prefix.}% - }% - \ifargifTF{#1}{% - \LTS@err{Invalid argument '\string#1' for command\MsgBrk - '\string\LTS@detokdespace'}{Command '\string\LTS@detokdespace' - doesn't accept '\@backslashchar if'\MsgBrk when submitted - without the '+' prefix.}% - }{% - \edef#1{\cptoxdetok{#1}}% - \despacecontent#1% - }% - }% -} -\robust@def*\ifltxprotectTF#1{% - \begingroup - \ifmacroFT#1{% - \aftergroup\@secondoftwo - }{% - \edef\LTS@tempa##1{\def##1####1\string\protect####2&}% - \LTS@tempa\LTS@tempa{% - \aftercsname\aftergroup{LTS@\ifblankTF{##2}21of2}}% - \edef\LTS@tempb##1{##1\realmeaning#1\string\protect&}% - \LTS@tempb\LTS@tempa - }% - \endgroup -} -\robust@def*\ifltxprotectFT#1{% - \ifltxprotectTF{#1}\@secondoftwo\@firstoftwo -} -\robust@def*\ifcsnltxprotectTF{\aftercsname\ifltxprotectTF} -\robust@def*\ifetexprotectedTF#1{% - \begingroup - \edef\LTS@tempa##1{\def##1####1\string\protected####2&}% - \LTS@tempa\LTS@tempa{% - \aftercsname\aftergroup{LTS@\ifblankTF{##2}21of2}}% - \edef\LTS@tempb##1{##1\meaning#1\string\protected&}% - \LTS@tempb\LTS@tempa - \endgroup -} -\robust@def*\ifetexprotectedFT#1{% - \ifetexprotectedTF{#1}\@secondoftwo\@firstoftwo -} -\robust@def*\ifcsnprotectedTF{\aftercsname\ifetexprotectedTF} -\robust@def*\apptocs{% - \LTS@checkoptprefix{\LTS@teststplcl{\LTS@hooktomac{>}}}% -} -\robust@def*\preptocs{% - \LTS@checkoptprefix{\LTS@teststplcl{\LTS@hooktomac{<}}}% -} -\robust@def\LTS@hooktomac#1#2#3{% - \ifLTS@st\let\@expandb\expandcsonce\else\let\@expandb\unexpanded\fi - \cpt@getmacroprefix{#2}% - \ifLTS@pl - \let\@ifdef\ifcsndefFT\let\@expanda\expandcsnonce - \def\LTS@i##1{\def\@def####1{\aftercsname##1{####1}}}% - \else - \let\@ifdef\ifdefFT\let\@expanda\expandcsonce - \def\LTS@i##1{\def\@def####1{##1####1}}% - \fi - \ifLTS@cl\LTS@i\xdef\else\LTS@i\edef\fi - \@ifdef{#2}{% - \macroprefix\@def{#2}{\@expandb{#3}}% - }{% - \ifx#1>% - \macroprefix\@def{#2}{\@expanda{#2}\@expandb{#3}}% - \else - \macroprefix\@def{#2}{\@expandb{#3}\@expanda{#2}}% - \fi - }% - \LTS@undef!{\@ifdef,\@def,\@expanda,\@expandb,\LTS@i}% -} -\robust@def*\LTS@uaddtolist{\chardef\LTS@addnr\z@pt\LTS@addt@list} -\robust@def*\LTS@addtolist{\chardef\LTS@addnr\@ne\LTS@addt@list} -\robust@def*\LTS@xaddtolist{\chardef\LTS@addnr\tw@\LTS@addt@list} -\robust@def*\LTS@addt@list#1{% - \ifx#1*% - \LTS@err{Star (*) isn't valid as suffix to - \noexpand\LTS@addtolist or \string\LTS@listadd}% - \fi - \LTS@testplcl{\LTS@testlt{\LTS@testopt\LTS@addt@l@st{,}}}% - #1% -} -\new@def*\LTS@addt@l@st[#1]{% - \edef\parser{\detokenize{#1}}% - \ifLTS@cl\let\@def\xdef\else\let\@def\edef\fi - \ifLTS@pl\expandafter\aftercsname\fi\LTS@addt@l@@t -} -\robust@def\LTS@addt@l@@t#1#2{% - \ifcase\LTS@addnr - \let\@expand\unexpanded - \or - \let\@expand\expandcsonce - \else - \let\@expand\@iden - \fi - \begingroup - \toks@{\endgroup - \ifdefFT{#1}{% - \@def#1{\@expand{#2}}% - }{% - \ifcsnullTF#1{% - \@def#1{\@expand{#2}}% - }{% - \ifboolTF{LTS@lt}{% - \@def#1{\@expand{#2}\parser\expandcsonce{#1}}% - }{% - \@def#1{\expandcsonce{#1}\parser\@expand{#2}}% - }% - }% - }% - }% - \usename{% - \ifnum\LTS@addnr=\z@pt\else\ifnum\LTS@addnr=\@ne o\else x\fi\fi - ifblankTF% - }{#2}{\ifcpt@useempty\the\toks@\else\endgroup\fi}{\the\toks@}% - \undefcs\@expand\undefcs\@def - \chardef\LTS@addnr\@ne -} -\robust@def*\LTS@listadd#1{% - \LTS@plfalse\LTS@clfalse\LTS@ltfalse\chardef\LTS@addnr\z@pt - \LTS@addt@l@st[#1]% -} -\robust@def*\LTS@olistadd#1{% - \LTS@plfalse\LTS@clfalse\LTS@ltfalse\chardef\LTS@addnr\@ne - \LTS@addt@l@st[#1]% -} -\robust@def*\LTS@xlistadd#1{% - \LTS@plfalse\LTS@clfalse\LTS@ltfalse\chardef\LTS@addnr\tw@ - \LTS@addt@l@st[#1]% -} -\robust@def*\addtolistexpanded{% - \LTS@testcl{\LTS@testopt\LTS@addtolistexpanded{,}}% -} -\robust@def*\LTS@addtolistexpanded[#1]#2#3{% - \begingroup - \toks@{\endgroup - \ifdefTF#2{% - \usename{protected@\ifLTS@cl x\else e\fi def}% - #2{#2\ifcsnullTF{#2}{}{#1}#3}% - }{% - \usename{protected@\ifLTS@cl x\else e\fi def}#2{#3}% - }% - }% - \oifblankTF{#3}{\ifcpt@useempty\the\toks@\else\endgroup\fi} - {\the\toks@}% -} -\renew@def*\@check@eq#1#2{% - \expandafter\ifxTF\cpt@car#1\car@nil{#2}{}{% - \LTS@verbosewarn{% - Previous definition of '\string#1'\MsgBrk - doesn't match your new definition.\MsgBrk - I haven't redefined '\string#1'}% - }% -} -\ifpkgcurrTF{atveryend}{2010/03/24}{}{% - \RequirePackage{atveryend}[2010/03/24]} -\robust@def*\LTS@notprerr{% - \LTS@err{You have issued a preamble command here}% - {Move shown command to document preamble.}% -} -\robust@def*\LTS@notenderr{% - \LTS@err{You've called an \noexpand\enddocument - command\MsgBrk at the wrong place}{% - Move command to before \string\enddocument. - }% -} -\robust@def*\LTS@AtBeginDocument{\AtBeginDocument} -\robust@def*\LTS@BeforeBeginDocument{% - \grightaddtocs\LTS@beforedocstart -} -\new@def*\LTS@beforedocstart{} -\leftaddtocs\document{% - \endgroup - \let\LTS@BeforeBeginDocument\@firstofone - \LTS@beforedocstart - \let\LTS@BeforeBeginDocument\LTS@notprerr - \gundefcs\LTS@beforedocstart - \begingroup -} -\robust@def*\LTS@AfterBeginDocument{% - \grightaddtocs\LTS@afterdocstart -} -\new@def*\LTS@afterdocstart{} -\robust@def*\LTS@AfterAfterBeginDocument{% - \grightaddtocs\LTS@afterafterdocstart -} -\new@def*\LTS@afterafterdocstart{} -\rightaddtocs\document{% - \let\LTS@AfterBeginDocument\@firstofone - \LTS@afterdocstart - \let\LTS@AfterBeginDocument\LTS@notprerr - \gundefcs\LTS@afterdocstart - \let\LTS@AfterAfterBeginDocument\@firstofone - \LTS@afterafterdocstart - \let\LTS@AfterAfterBeginDocument\LTS@notprerr - \gundefcs\LTS@afterafterdocstart - \ignorespaces -} -\LTS@BeforeBeginDocument{\let\LTS@AtBeginDocument\@firstofone} -\robust@def*\LTS@AtEndDocument{\AtEndDocument} -\robust@def*\LTS@BeforeLastPage{\grightaddtocs\LTS@beforelastpage} -\new@def*\LTS@beforelastpage{} -\LTS@AtEndDocument{% - \let\LTS@bef@relastpage\AtVeryEnd@BeforeClearDocumentHook - \def\AtVeryEnd@BeforeClearDocumentHook{% - \let\LTS@BeforeLastPage\@firstofone - \LTS@beforelastpage\LTS@bef@relastpage - \let\LTS@BeforeLastPage\LTS@notenderr - \LTS@undef!{\LTS@beforelastpage,\LTS@bef@relastpage}% - }% -} -\robust@def*\LTS@AfterLastPage{\grightaddtocs\LTS@afterlastpage} -\new@def*\LTS@afterlastpage{} -\LTS@AtEndDocument{% - \let\LTS@afterl@stpage\AtVeryEnd@AfterLastShipoutHook - \def\AtVeryEnd@AfterLastShipoutHook{% - \let\LTS@AfterLastPage\@firstofone - \LTS@afterlastpage\LTS@afterl@stpage - \let\LTS@AfterLastPage\LTS@notenderr - \LTS@undef!{\LTS@afterlastpage,\LTS@afterl@stpage}% - }% -} -\robust@def*\LTS@AfterEndDocument{\grightaddtocs\LTS@afterenddoc} -\new@def*\LTS@afterenddoc{} -\AtEndOfPackage{\newletcs\AtTagEndOfDocument\LTS@AfterEndDocument} -\LTS@AtEndDocument{% - \let\LTS@aft@renddoc\AtVeryEnd@AtVeryEndDocumentHook - \def\AtVeryEnd@AtVeryEndDocumentHook{% - \let\LTS@AfterEndDocument\@firstofone - \LTS@afterenddoc\LTS@aft@renddoc - \let\LTS@AfterEndDocument\LTS@notenderr - \LTS@undef!{\LTS@afterenddoc,\LTS@aft@renddoc}% - }% -} -\robust@def*\LTS@AtEndPackage{\AtEndOfPackage} -\robust@def*\LTS@BeforeEndPackage{% - \gleftaddtocsn{\@currname.\@currext-h@@k}% -} -\robust@def*\LTS@AfterEndPackage{% - \grightaddtocsn{\@currname.\@currext-LTS@hook}% -} -\let\LTS@AtEndClass\LTS@AtEndPackage -\let\LTS@BeforeEndClass\LTS@BeforeEndPackage -\let\LTS@AfterEndClass\LTS@AfterEndPackage -\leftaddtocs\@popfilename{% - \usename{\@currname.\@currext-LTS@hook}% - \gundefcsn{\@currname.\@currext-LTS@hook}% -} -\robust@def\AtTagEndPackage#1{\AtEndOfPackage{\LTS@AfterEndPackage{#1}}} -\newletcs\LTS@AtTagEndPackage\AtTagEndPackage -\robust@def\afterpackageloaded#1{% - \LTS@after@cls@pkg@loaded{#1}\@pkgextension -} -\robust@def\afterclassloaded#1{% - \LTS@after@cls@pkg@loaded{#1}\@clsextension -} -\robust@def\LTS@after@cls@pkg@loaded#1#2#3{% - \edef\LTS@tempa{\expandafter\ifxTF\cpt@car#2\car@nil - \@pkgextension{sty}{cls}}% - \cptexpanded{% - \LTS@AfterAfterBeginDocument{% - \noexpand\ifcsndefTF{ver@#1.\LTS@tempa}{}{% - \LTS@warn{Package '#1' was never loaded}% - }% - }% - }% - \ifcsndefTF{ver@#1.\LTS@tempa}{% - #3\relax - }{% - \grightaddtocsn{#1.\LTS@tempa-LTS@hook}{#3}% - }% -} -\robust@def*\LTS@preamblecmdhook{} -\robust@def*\preamblecommands{\LTS@testpl\LTS@preamblecmds} -\new@def*\LTS@preamblecmds#1{% - \begingroup - \def\@cmd{\preamblecommands}% - \let\@ifnopattern\ifnopattern - \LTS@pkgpreamplecmd{#1}\LTS@preamblecmdhook{% - \cptpassexpanded{% - \grightaddtocs\LTS@preamblecmdhook - {\LTS@dopreamble\@expand\LTS@tempa}% - }% - }% - \endgroup -} -\robust@def*\AddPreambleCommands#1{% - \def\csv@do##1{% - \ltsfiltermergetsv!\LTS@preamblecmdhook - {\LTS@dopreamble{##1}}\nofilter - }% - \csv@@parse[,]{#1}% -} -\robust@def*\RemovePreambleCommands#1{% - \def\csv@do##1{% - \filterdeletetokens!\LTS@preamblecmdhook - {\LTS@dopreamble{##1}}\nofilter - }% - \csv@@parse[,]{#1}% -} -\robust@def*\packagecommands{\LTS@testpl\LTS@packagecmds} -\robust@def*\LTS@packagecmds#1{% - \begingroup - \toks@{}% - \def\@cmd{\packagecommands}% - \def\@ifnopattern##1\in##2{\ifnopattern##2\in{##1}}% - \LTS@pkgpreamplecmd{#1}\LTS@packagecmderr{% - \@after\ifparamacroTF\LTS@tempa{% - \def\@prepto{\preptoparamcs}% - }{% - \def\@prepto{\leftaddtocs}% - }% - \cptexpandarg{\toks@}{\the\toks@\@prepto\@expand\LTS@tempa - {\LTS@packagecmderr{\@expand\LTS@tempa}}\relax\relax}% - }% - \expandafter\endgroup\the\toks@ -} -\robust@def*\LTS@pkgpreamplecmd#1#2#3{% - \ifLTS@pl - \def\@scape{\simpleexpandarg\LTS@ensurenoscape}% - \let\@after\aftercsname - \let\@expand\noexpandcsn - \else - \def\@scape{\simpleexpandarg\LTS@ensurescape}% - \let\@after\expandafter - \let\@expand\expandcsonce - \fi - \def\csv@do##1{% - \def\LTS@tempa{##1}% - \@after\ifonetoken\LTS@tempa\do{% - \@scape\LTS@tempa - \@after\ifdefTF\LTS@tempa{% - \@after\@ifnopattern\LTS@tempa\in{#2}{#3}{}% - }{% - \LTS@warn{Command '\@after\string\LTS@tempa' undefined: - \MsgBrk ignored by \expandcsonce\@cmd}% - }% - }% - }% - \csv@@parse{#1}% -} -\robust@def*\LTS@dopreamble#1{% - \gdef#1{\LTS@err{'\string#1' is a preamble command}% - {Move command '\string#1' to document preamble.}}% -} -\LTS@AfterBeginDocument{% - \LTS@preamblecmdhook - \gletcs\LTS@dopreamble\@gobbleone -} -\robust@def*\LTS@packagecmderr#1{% - \ifinstylefileTF{}{% - \LTS@err{Command '\detokenize{#1}' issued outside style file}% - {The command '\detokenize{#1}' is available only - in style files.}% - }% -} -\robust@def*\parsemacro{\LTS@testst\LTS@parsemacro} -\robust@def*\LTS@parsemacro#1#2#3{% - \let\ifLTS@noxpst\ifLTS@st - \begingroup - \def\LTS@tempd##1{% - \emptify\LTS@resa - \edef\LTS@tempb{\cptoxdetok{#3}##1&}% - \edef\LTS@tempc####1{\def####1########1##1########2&}% - \LTS@tempc\LTS@tempc{% - \ifblankTF{####2}{% - \edef\LTS@resa{\expandcsonce\LTS@resa####1}% - }{% - \edef\LTS@resa{\expandcsonce\LTS@resa####1\detokenize{#2}##1}% - \LTS@tempc####2&% - }% - }% - \expandafter\LTS@tempc\LTS@tempb - \edef#3{\expandcsonce\LTS@resa}% - }% - \edef\LTS@tempa{\cptoxdetok{#1}}% - \def\tsv@do##1{\LTS@tempd{##1}}% - \tsv@@parse*\LTS@tempa - \postgroupdef#3\endgroup - % \LTS@scantoksa assumes that #3 has no parameters; - % use \LTS@scantoksd otherwise: - \ifLTS@noxpst\LTS@scantoksa#3\fi - \undefcs\ifLTS@noxpst -} -\robust@def*\noexpandparse#1{\parsemacro*\@backslashchar\noexpand#1} -\robust@def*\NoexpandParse#1{% - \let\ifLTS@noxpst\ifLTS@st - \begingroup - \emptify\LTS@resa - \def\LTS@tempd##1{\edef\LTS@resa{\expandcsonce\LTS@resa - \noexpand\noexpand\unexpanded{##1}}}% - \def\tsv@do##1{% - \ifmacroTF{##1}{% - \LTS@tempd{##1}% - }{% - \edef\LTS@tempb{\detokenize{##1}}% - \edef\LTS@tempc{\expandafter\LTS@car\LTS@tempb x\car@nil}% - \ifxTF\LTS@tempc\@backslashchar{% - \LTS@tempd{##1}% - }{% - \edef\LTS@resa{\expandcsonce\LTS@resa\unexpanded{##1}}% - }% - }% - }% - \tsv@@parse*{#1}% - \edef#1{\expandcsonce\LTS@resa}% - \postgroupdef#1\endgroup - \ifLTS@noxpst\LTS@scantoksa#1\fi - \undefcs\ifLTS@noxpst -} - -% #1: list; -% #2: a defined/undefined command: -\robust@def*\despacecommalist#1#2{% - \LTS@stfalse\LTS@despacecsvlist[,]{#1}% - \let#2=\despaced@list -} -\robust@def*\despacecsvlist{% - \LTS@testst{\LTS@testopt\LTS@despacecsvlist{,}}% -} -\robust@def*\LTS@despacecsvlist[#1]#2{% - \cpt@stchoose{LTS@st}{#2}\despaced@list\LTS@despacecsvlist - \ifcsnullTF\despaced@list{}{% - \xifinsetTF{\detokenize{#1}}{\cptoxdetok\despaced@list}{% - \cpt@sttrue\cpt@csvnormalize[#1]\despaced@list - }{% - \edef\despaced@list - {\simpleexpandarg\cpttrimspaces\despaced@list}% - }% - }% - \ifboolTF{LTS@st}{\let#2=\despaced@list}{}% -} -\robust@def*\despacexcsvlist{% - \LTS@teststpm{% - \ifnextisbrack\LTS@despacexcsvlist{\LTS@despacexcsvlist[,]}% - }% -} -\robust@def*\LTS@despacexcsvlist[#1]{% - \ifnextisbrack - {\LTS@d@spacexcsvlist#1}{\LTS@d@spacexcsvlist#1[#1]}% -} - -% #1: outer parser -% #2: inner parser -% #3: <list> or <listcmd> -% * -> #3 is a macro -% ' -> each element of #3 is again a macro of list -\robust@def*\LTS@d@spacexcsvlist#1[#2]#3{% - \let\ifxdespm\ifLTS@pm - \cpt@stchoose{LTS@st}{#3}\reserved@e\LTS@d@spacexcsvlist - \def\despaced@list{}% - \ifcsnullTF\reserved@e{}{% - \def\csv@do##1{% - \ifboolTF{xdespm}{% - \cpt@sttrue\cpt@csvnormalize[#2]{##1}% - \LTS@listadd#1\despaced@list{##1}% - }{% - \edef\reserved@e{\cpttrimspaces{##1}}% - \LTS@olistadd{#1}\despaced@list\reserved@e - }% - }% - \csv@@parse*[#1]\reserved@e - }% - \ifboolTF{LTS@st}{\let#3=\despaced@list}{}% - \undefcs\ifxdespm -} -\robust@def*\despacetsvlist#1#2{% - \LTS@ensuremacro{#2}% - \def#2{}% - \def\tsv@do##1{\rightaddtocs#2{##1}}% - \tsv@@parse{#1}% -} -\robust@def*\despacextsvlist#1#2{% - \LTS@ensuremacro{#2}% - \def#2{}% - \def\tsv@do##1{% - \despacetsvlist{##1}\reserved@e - \cptexpandargonce{\rightaddtocs#2}\reserved@e - }% - \tsv@@parse{#1}% -} -\robust@def*\newletmanytocs#1#2{% - \def\csv@do##1{% - \newletcs##1#2% - }% - \csv@@parse[,]{#1}% -} -\robust@def*\ltsnewletcs{\LTS@testst\LTS@newletcs} -\new@def*\LTS@newletcs#1{% - \cpt@ifeql{\LTS@n@wletcs{#1}}{\LTS@n@wletcs{#1}}% -} -\new@def*\LTS@n@wletcs#1#2{% - \ifdefTF#1{% - \ifLTS@st - \ifdefTF#2{% - \let#1=#2% - \LTS@verboseinfo{Command '\string#1' redefined}% - }{% - \LTS@err{Command '\string#2' undefined}% - {I can't let '\string#1' to undefined '\string#2'.}% - }% - \else - \LTS@err{Command '\string#1' already defined}% - {I can't assign defined '\string#1' to '\string#2'.}% - \fi - }{% - \ifdefTF#2{\let#1=#2}{% - \LTS@err{Command '\string#2' undefined}% - {I can't let '\string#1' to undefined '\string#2'.}% - }% - }% -} -\new@def*\LTS@newletcsnerr#1#2{% - \begingroup - \def\LTS@tempa{\ifcpt@swa\string#2\else\noexpandcsn{#2}\fi}% - \LTS@err{% - Command '\LTS@tempa' is already defined - }{% - Command '\LTS@tempa' is defined: You may use the starred - \MsgBrk version of \noexpand#1 for this type of assignment. - }% - \endgroup -} -\new@def*\newletcstocs{% - \LTS@err{% - Command '\string\newletcstocs' is undefined - }{% - Command '\string\newletcstocs' is undefined. You can use - \string\newletcs,\MsgBrk but this can't assign control - sequence names.\MsgBrk Perhaps you meant to use - \string\newletcsntocs, or\MsgBrk\noexpand\newletcstocsn - or \string\newletcsntocsn. - }% -} -\robust@def*\newletcsntocs{\LTS@teststcl\LTS@newletcsntocs} -\new@def*\LTS@newletcsntocs#1#2{% - \is@global@or@relax - \ifLTS@st - \glob@lrel@x\letcsntocs{#1}#2% - \else - \ifcsndefFT{#1}% - {\glob@lrel@x\letcsntocs{#1}#2}% - {\cpt@swafalse\LTS@newletcsnerr\newletcsntocs{#1}}% - \fi -} -\robust@def*\newletcstocsn{\LTS@teststcl\LTS@newletcstocsn} -\new@def*\LTS@newletcstocsn#1#2{% - \LTS@ensurescape{#1}% - \is@global@or@relax - \def\reserved@e{\begingroup\expandafter\endgroup\expandafter - \glob@lrel@x\expandafter\let\expandafter#1\csname#2\endcsname}% - \ifLTS@st - \reserved@e - \else - \ifdefFT{#1}\reserved@e{% - \cpt@swatrue\LTS@newletcsnerr\newletcstocsn{#1}% - }% - \fi -} -\robust@def*\newletcsntocsn{\LTS@teststcl\LTS@newletcsntocsn} -\new@def*\LTS@newletcsntocsn#1#2{% - \is@global@or@relax - \def\reserved@e{\begingroup\expandafter\endgroup\expandafter - \glob@lrel@x\expandafter\let\csname#1\aftercsname\endcsname{#2}}% - \ifLTS@st - \reserved@e - \else - \ifcsndefFT{#1}\reserved@e{% - \cpt@swafalse\LTS@newletcsnerr\newletcsntocsn{#1}% - }% - \fi -} -\robust@def*\provideletcsntocs{\LTS@testcl\LTS@provideletcsntocs} -\new@def*\LTS@provideletcsntocs#1#2{% - \is@global@or@relax - \ifcsndefTF{#1}{}{\glob@lrel@x\letcsntocs{#1}#2}% -} -\robust@def*\provideletcstocsn{\LTS@testcl\LTS@provideletcstocsn} -\new@def*\LTS@provideletcstocsn#1#2{% - \is@global@or@relax - \ifdefTF#1{}{% - \begingroup\expandafter\endgroup\expandafter\glob@lrel@x - \expandafter\let\expandafter#1\csname#2\endcsname - }% -} -\robust@def*\provideletcsntocsn{\LTS@testcl\LTS@provideletcsntocsn} -\def\LTS@provideletcsntocsn#1#2{% - \is@global@or@relax - \ifcsndefTF{#1}{}{% - \begingroup\expandafter\endgroup\expandafter\glob@lrel@x - \expandafter\let\csname#1\aftercsname\endcsname{#2}% - }% -} -\new@def*\provideletcstocs{% - \LTS@err{'\string\provideletcstocs' is undefined}% - {Command '\string\provideletcstocs' is undefined. - Perhaps you meant \MsgBrk to use \string\provideletcsntocs, - or \noexpand\provideletcstocsn or \string\provideletcsntocsn.}% -} -\robust@def*\numberexpr{% - \LTS@checkoptprefix{\LTS@testplcl{\LTS@numexpr{num}}}% -} -\robust@def*\dimensionexpr{% - \LTS@checkoptprefix{\LTS@testplcl{\LTS@numexpr{dim}}}% -} -\robust@def*\rubberexpr{% - \LTS@checkoptprefix{\LTS@testplcl{\LTS@numexpr{glue}}}% -} -\robust@def*\mrubberexpr{% - \LTS@checkoptprefix{\LTS@testplcl{\LTS@numexpr{mu}}}% -} -\new@def*\LTS@numexpr#1#2{% - \if\detokenize{#2*}% - \LTS@err{Invalid suffix to '\string\dimensionexpr' or - '\string\numberexpr'}{Star (*) not valid as suffix to - '\string\dimensionexpr' and '\string\numberexpr'.}% - \fi - \is@global@or@relax - \ifboolTF{LTS@pl}{% - \cptexpandsecond{\LTS@n@mexpr{#1}}{\noexpandcsn{#2}}% - }{% - \LTS@n@mexpr{#1}{#2}% - }% -} -\new@def*\LTS@n@mexpr#1#2#3{% - \LTS@ensurescape@notempty{#2}{#3}% - \ifdefTF{#2}{% - \glob@lrel@x#2=\usename{#1expr}#3\relax - }{% - \begingroup - \LTS@getorderincsvlist[,](\nr){#1}{num,dim,glue,mu}% - \edef\LTS@tempa{\ifcase\nr\relax - count\or dimen\or skip\or muskip\fi}% - \usename{new\LTS@tempa}#2\relax - \endgroup - \glob@lrel@x#2=\usename{#1expr}#3\relax - }% -} -\robust@def*\numberdef{% - \LTS@checkoptprefix{\LTS@testplcl{\LTS@numdef{num}}}% -} -\robust@def*\dimensiondef{% - \LTS@checkoptprefix{\LTS@testplcl{\LTS@numdef{dim}}}% -} -\robust@def*\rubberdef{% - \LTS@checkoptprefix{\LTS@testplcl{\LTS@numdef{glue}}}% -} -\robust@def*\mrubberdef{% - \LTS@checkoptprefix{\LTS@testplcl{\LTS@numdef{mu}}}% -} -\new@def*\LTS@numdef#1#2{% - \if\detokenize{*#2}% - \LTS@err{Invalid suffix to '\string\dimensiondef' or - '\string\numberdef'}{Star (*) not valid as suffix to - '\string\dimensiondef' and '\string\numberdef'.}% - \fi - \is@global@or@relax - \ifboolTF{LTS@pl}{% - \cptexpandsecond{\LTS@num@def{#1}}{\noexpandcsn{#2}}% - }{% - \LTS@num@def{#1}{#2}% - }% -} -\new@def*\LTS@num@def#1#2#3{% - \LTS@ensurescape@notempty{#2}{#3}% - \glob@lrel@x\edef#2{\the\usename{#1expr}#3\relax}% -} -\robust@def*\LTS@ensurescape@notempty#1#2{% - \LTS@ensurescape{#1}% - \ifblankFT{#2}{}{% - \LTS@err{Argument '\string#2' is empty}% - {Empty argument '\string#2' is invalid.\MsgBrk - I expected a nonempty argument here.}% - }% -} - -% #1: parser -% #2: string to find -% #3: list -% * -> both #2 and #3 are macros -% Call it with [] if there is no parser: -\robust@def*\ifexistinTF{\LTS@testst{\LTS@testopt\LTS@ifexistinTF,}} -\robust@def*\LTS@ifexistinTF[#1]#2\in#3{% - \begingroup - \edef\reserved@e{\ifboolTF{LTS@st}\cptoxdetok\detokenize{#2}}% - \despacecontent\reserved@e - \edef\reserved@f{\ifboolTF{LTS@st}\cptoxdetok\detokenize{#3}}% - \cpt@sttrue\cpt@csvnormalize[#1]\reserved@f - \edef\x{\detokenize{#1}}% - \cptexpandtwoargs{\endgroup\ifinsetTF} - {\x\reserved@e\x}{\x\reserved@f\x}% -} -\robust@def\ifpresentTF#1\in#2#{\ifinsetTF{#1}{#2}} -% This is more expensive but offers a variation on \ifexistinTF: -\robust@def*\ifpresentinTF{\LTS@testst{\LTS@testopt\LTS@ifpresentinTF,}} -\robust@def*\LTS@ifpresentinTF[#1]#2\in#3{% - \begingroup - \edef\reserved@e{\ifboolTF{LTS@st}\cptoxdetok\detokenize{#2}}% - \despacecontent\reserved@e - \edef\reserved@f{\ifboolTF{LTS@st}\cptoxdetok\detokenize{#3}}% - \cpt@choicefdfalse - \def\csv@do##1{% - \def\reserved@a{##1}% - \ifx\reserved@a\reserved@e\cpt@choicefdtrue\loopbreak\fi - }% - \csv@@parse*[;]\reserved@f - \ifboolTF{cpt@choicefd} - {\endgroup\@firstoftwo}{\endgroup\@secondoftwo}% -} - -% You can use \ifleadspaceTF or \iftrailspaceTF to test -% tokens beginning or ending with space. \ifendwithTF isn't -% suitable for this task: -\robust@def*\ifendwithTF#1#2{% - \ifblankTF{#2}\@secondoftwo{% - \begingroup - \edef\LTS@tempa{\s@expandarg\cpttrimspace{\detokenize{#1}}}% - \edef\LTS@tempb{\s@expandarg\cpttrimspace{\detokenize{#2}}}% - \let\endwith\relax - \cptexpandtwoargs\cpt@in{\LTS@tempb\endwith}{\LTS@tempa\endwith}% - \aftercsname\endgroup{@\ifcpt@in first\else second\fi oftwo}% - }% -} -\robust@def*\ifbeginwithTF#1#2{% - \ifblankTF{#2}\@secondoftwo{% - \begingroup - \edef\LTS@tempa{\s@expandarg\cpttrimspace{\detokenize{#1}}}% - \edef\LTS@tempb{\s@expandarg\cpttrimspace{\detokenize{#2}}}% - \let\begwith\relax - \cptexpandtwoargs\cpt@in{\begwith\LTS@tempb}{\begwith\LTS@tempa}% - \aftercsname\endgroup{@\ifcpt@in first\else second\fi oftwo}% - }% -} -\robust@def*\in@detok#1#2{% - \cptexpandtwoargs\cpt@in{\detokenize{#1}}{\detokenize{#2}}% -} -\newletcs\ifmemberTF\ifinsetTF -\newletcs\ifmemberFT\ifinsetFT -\robust@def*\ifbelongTF#1#2{% - \cptexpandtwoargs\ifinsetTF{\detokenize{#1}}{\detokenize{#2}}% -} -\robust@def*\ifbelongFT#1#2{\ifbelongTF{#1}{#2}\@secondoftwo\@firstoftwo} -\robust@def*\oifbelongTF#1#2{\cptexpandtwoargsonce\ifbelongTF{#1}{#2}} -\robust@def*\oifbelongFT#1#2{\cptexpandtwoargsonce\ifbelongFT{#1}{#2}} -\robust@def*\xifbelongTF#1#2{\cptexpandtwoargs\ifbelongTF{#1}{#2}} -\robust@def*\xifbelongFT#1#2{\cptexpandtwoargs\ifbelongFT{#1}{#2}} -\new@def*\ifdraftTF{\usename{LTS@\ifboolTF{LTS@draft}12of2}} -\new@def*\ifdraftFT{\usename{LTS@\ifdraftTF21of2}} -\new@def*\iffinalTF{\usename{LTS@\ifboolTF{LTS@final}12of2}} -\new@def*\iffinalFT{\usename{LTS@\iffinalTF21of2}} - -\new@def*\ValidCommandPrefixes{\relax\long\global\protected} -\robust@def*\newfunction{\begingroup\let\cmd0\LTS@newfunction@a} -\robust@def*\LTS@newfunction@a{% - \toks@{}% - \def\LTS@tempa##1{% - \def\cmd{##1}% - \LTS@ifnextchar.\LTS@newfunction@b{\LTS@newfunction@b..}% - }% - \ifcondTF\if\cmd0\fi{% - \LTS@starorlong\LTS@tempa - }{% - \LTS@tempa - }% -} -\robust@def*\LTS@newfunction@b.#1.{% - \def\checkprefix{% - \let\LTS@rsvda\prefix - \simpledeletetokens\LTS@rsvda\ValidCommandPrefixes - \ifcsemptyTF\LTS@rsvda{}{% - \LTS@err{Illegal prefixes '\expandcsonce\LTS@rsvda' - for command '\expandcsonce\cmd'}\@ehc - }% - }% - \ifsingletokenTF{#1}{% - \def\prefix{#1}\def\sentinel{}% - }{% - \def\prefix##1,##2##3\LTS@nil{% - \def\prefix{##1}\def\reserved{##2}% - \ifx\reserved\LTS@nnil - \def\sentinel{}% - \else - \if\detokenize{##2,}% - \def\sentinel{}% - \else - \def\sentinel{##2}% - \fi - \fi - }% - \prefix#1,{\LTS@nil}\LTS@nil - \checkprefix - }% - \expandafter\LTS@testopt\expandafter - {\expandafter\LTS@newfunction@c\cmd}0% -} -\robust@def*\LTS@newfunction@c#1[#2]{% - \ifnextisbrack{\LTS@newfunction@e#1[#2]}{\LTS@newfunction@d#1[#2]}% -} -\robust@def\LTS@newfunction@d#1[#2]#3{% - \ifcsdefinable#1{\LTS@newfunction@f#1\@ne{#2}{#3}}% -} -\robust@def\LTS@newfunction@e#1[#2][#3]#4{% - \ifcsdefinable#1{% - \cptexpandargonce{\cpt@in\protected}\prefix - \edef\LTS@tempa{% - \ifcpt@in\LTS@testopt\else\unexpanded{\@protected@testopt#1}\fi - \noexpandcsn{\string#1}\unexpanded{{#3}}% - }% - \cptexpandarg\toks@{% - \l@ngrel@x\prefix\def\noexpand#1{\expandcsonce\LTS@tempa}% - }% - \aftercsname\LTS@newfunction@f{\string#1}\tw@{#2}{#4}% - }% -} -\robust@def\LTS@newfunction@f#1#2#3{% - \ifx#2\tw@ - \gdef\@gtempa##11{[####1]}% - \else - \gletcs\@gtempa\@gobble - \fi - \expandafter\LTS@newfunction@g\expandafter{\number#3}#1% -} -\robust@def\LTS@newfunction@g#1#2{% - \defpass\reserved@a##1#1##2##{% - \edef\reserved@a{% - \endgroup\the\toks@\l@ngrel@x\prefix - \unexpanded{\expandafter\def\expandafter#2\@gtempa}% - }% - \s@expandarg\cptswap\sentinel{\reserved@a##1#1}% - }% - 0##1##2##3##4##5##6##7##8##9###1% -} -\robust@def*\renewfunction{% - \begingroup - \let\cmd1\LTS@starorlong\LTS@renewfunction -} -\def\LTS@renewfunction#1{% - \ifdefTF#1{% - \LTS@verboseinfo{Command '\string#1' redefined}% - }{% - \LTS@warn{Command '\string#1' was previously undefined, - \MsgBrk but now defined with \string\renewfunction}% - }% - \let\ifcsdefinable\rc@ifcsdefinable - \LTS@newfunction@a#1% -} -%% One-step expandable \l@ngrel@x: -\robust@def*\LTS@starorlong#1{% - \LTS@ifstar - {\def\l@ngrel@x{\relax}#1}{\def\l@ngrel@x{\long}#1}% -} -\robust@def*\LTS@starornone#1{% - \LTS@ifstar - {\let\l@ngrel@x\relax\def\st@rn@ne{*}#1}% - {\let\l@ngrel@x\long\def\st@rn@ne{}#1}% -} -\robust@def*\needcommand{\LTS@starornone\LTS@needcommand} -\new@def*\LTS@needcommand#1{% - \LTS@ensurescape{#1}% - \ifdefTF{#1}% - {\expandafter\CheckCommand\st@rn@ne}% - {\expandafter\newcommand\st@rn@ne}% - {#1}% -} -\robust@def*\ifinlistTF{% - \LTS@testst{\LTS@testopt\LTS@ifinlista{,}}% -} -\robust@def\LTS@ifinlista[#1]#2#3{% - \begingroup - \def\reserved@e##1#1#2#1##2\LTS@nil{\endgroup - \ifblankTF{##2}\@secondoftwo\@firstoftwo - }% - \ifboolTF{LTS@st}{% - \LTS@ensurescape{#3}% - \expandafter\reserved@e\expandafter - }{% - \reserved@e - }% - #1#3#1#2#1\LTS@nil -} -\new@def\oifinlistTF#1#2{% - \ifx#1,% - \LTS@err{Invalid first argument to \string\oifinlistTF}\@ehc - \fi - \cptexpandsecondargonce\ifinlistTF{#1}{#2}% -} -\new@def\xifinlistTF#1#2{% - \if\detokenize{#1,}% - \LTS@err{Invalid first argument '#1' to - \string\xifinlistTF}\@ehc - \fi - \cptexpandsecondarg\ifinlistTF{#1}{#2}% -} -\robust@def*\LTS@checkch{\LTS@teststpl\LTS@checkchoice} -\robust@def\ifinlistbTF#1#2#3#4{% - \if\LTS@lwc\LTS@sttrue\else\LTS@stfalse\fi - \LTS@pltrue - \LTS@checkchoice[\val\nr]{#1}{#2}{#3}{#4}% -} -\robust@def\ifinlistbFT#1#2#3#4{\ifinlistbTF{#1}{#2}{#4}{#3}} -\robust@def\oifinlistbTF#1#2#3#4{% - \if\LTS@lwc\LTS@sttrue\else\LTS@stfalse\fi - \LTS@pltrue - \cptexpandsecond{\LTS@checkchoice[\val\nr]}% - {{\expandcsonce{#1}}{\expandcsonce{#2}}}{#3}{#4}% -} -\robust@def\oifinlistbFT#1#2#3#4{\oifinlistbTF{#1}{#2}{#4}{#3}} -\robust@def\xifinlistbTF#1#2#3#4{% - \if\LTS@lwc\LTS@sttrue\else\LTS@stfalse\fi - \LTS@pltrue - \cptexpandsecond - {\LTS@checkchoice[\val\nr]}{{#1}{#2}}{#3}{#4}% -} -\robust@def\xifinlistbFT#1#2#3#4{% - \if\LTS@lwc\LTS@sttrue\else\LTS@stfalse\fi - \LTS@pltrue - \cptexpandsecond - {\LTS@checkchoice[\val\nr]}{{#1}{#2}}{#4}{#3}% -} -\new@def*\LTS@nochoice@handler#1#2{% - \LTS@err{% - Value '\expandcsonce{#1}' is not in list ^^J'\expandcsonce{#2}' - }{% - You have submitted an invalid value '\expandcsonce{#1}'\MsgBrk - for your key or test parameter. Value '\expandcsonce{#1}'\MsgBrk - is not in list:^^J'\expandcsonce{#2}'. - }% -} -\robust@def*\LTS@checkchoice{\LTS@testopt\LTS@ch@ckchoice{}} -\robust@def*\LTS@ch@ckchoice[#1]#2#3{% - \cpt@choicefdfalse - \begingroup - \ifLTS@st\lowercase{\fi - \ifblankTF{#1}{% - \def\LTS@tempa{\endgroup\LTS@ch@@@choice\LTS@nil{#2}{#3}}% - }{% - \def\LTS@tempa{\endgroup\LTS@ch@@kchoice#1\LTS@nil{#2}{#3}}% - }% - \ifLTS@st}\fi\LTS@tempa -} -\robust@def*\LTS@ch@@kchoice#1#2\LTS@nil#3#4{% - \ifblankTF{#2}% - {\LTS@ch@@@choice#1{#3}{#4}}{\LTS@ch@@@@hoice#1#2{#3}{#4}}% -} -\robust@def*\LTS@ch@@@choice#1#2#3{% - \begingroup - \def\LTS@tempc{#1}% - \ifx\LTS@tempc\LTS@nnil - % From \LTS@ch@ckchoice: - \emptify\LTS@tempc - \else - \def\LTS@tempc{\def#1{#2}}% - \fi - \cptexpandtwoargs\cpt@in{,\detokenize{#2},}{,\detokenize{#3},}% - \usename{cpt@choicefd\ifcpt@in true\else false\fi}% - \LTS@ch@@@@@oice\LTS@nochoice@handler{#2}{#3}% -} -\robust@def*\LTS@ch@@@@hoice#1#2#3#4{% - \def#1{#3}\def#2{-1}% - \begingroup - \LTS@scantoksa#1% - \cpt@cnta\z@pt - \def\LTS@tempc{}% - \def\csv@do##1{% - \def\LTS@tempb{##1}% - \LTS@scantoksa\LTS@tempb - \ifx#1\LTS@tempb - \edef\LTS@tempc{% - \def\noexpand#1{\unexpanded{##1}}% - \def\noexpand#2{\the\cpt@cnta}% - }% - \cpt@choicefdtrue\loopbreak - \fi - \advance\cpt@cnta\@ne - }% - \csv@@parse[,]{#4}% - \LTS@ch@@@@@oice\LTS@nochoice@handler{#3}{#4}% -} -\robust@def\LTS@ch@@@@@oice#1#2#3{% - \NoConvertInputToLowercase - \ifboolTF{cpt@choicefd}{% - \ifboolTF{LTS@pl}{% - \rightaddtocs\LTS@tempc\@firstoftwo - }{% - \rightaddtocs\LTS@tempc\@firstofone - }% - }{% - \ifboolTF{LTS@pl}{% - \rightaddtocs\LTS@tempc\@secondoftwo - }{% - \rightaddtocs\LTS@tempc{#1{#2}{#3}\@gobbleone}% - }% - }% - \expandafter\endgroup\LTS@tempc -} -\robust@def*\LTS@notpresent@handler#1#2{% - \LTS@verboseinfo{None of the tokens '\detokenize{#1}' - is found in '\detokenize{#2}'}% -} -\robust@def*\lwccontent#1{% - \ltsifmacroTF{#1}{% - \expandafter\if\expandafter\LTS@lwc\expandafter - \lowercase\expandafter{\expandafter\fi\expandafter\def - \expandafter#1\expandafter{#1}\if\LTS@lwc}\fi - }{% - \cpt@notcserr{#1}% - }% -} - -% #1: parser; -% #2: macro to hold order; -% #3: nomination/choice; -% #4: csv list; -% * -> both #3 and #4 are macros: -\robust@def*\getorderincsvlist{% - \LTS@testst{\LTS@testopt\LTS@getorderincsvlist{,}}% -} -\robust@def*\LTS@getorderincsvlist[#1]{% - \LTS@testpnopt{\LTS@g@torderincsvlist#1}\LTS@order -} -\robust@def*\LTS@g@torderincsvlist#1(#2)#3#4{% - \def#2{-1}% - \begingroup - \ifboolTF{LTS@st}{% - \edef\LTS@tempa{\simpleexpandarg\cpttrimspaces{#3}}% - \let\LTS@tempb=#4% - }{% - \edef\LTS@tempa{\cpttrimspaces{#3}} - \edef\LTS@tempb{\unexpanded{#4}}% - }% - \lwccontent\LTS@tempa\lwccontent\LTS@tempb - \edef\LTS@tempa{\cptoxdetok\LTS@tempa}% - \edef\LTS@tempb{\cptoxdetok\LTS@tempb}% - \cpt@cnta\z@pt\def\LTS@tempc{}% - \def\csv@do##1{% - \def\LTS@tempb{##1}% - \ifx\LTS@tempb\LTS@tempa - \edef\LTS@tempc{\def\noexpand#2{\the\cpt@cnta}}% - \loopbreak - \fi - \advance\cpt@cnta\@ne - }% - \csv@@parse*[,]\LTS@tempb - \NoConvertInputToLowercase - \expandafter\endgroup\LTS@tempc -} - -% #1: sublist (to check if one member of #1 is in #2); -% #2: main comma-separated list; -\robust@def*\ifoneincommalistTF#1#2{% - \if\LTS@lwc\LTS@sttrue\else\LTS@stfalse\fi - \LTS@pltrue - \LTS@ch@ckpresence[\val\nr]{#1}{#2}% -} - -% #1: bin (eg, \val\nr); -% #2: sublist (to check if one member of #2 is in #3); -% #3: main comma-separated list; -% For comma-separated list only: -\robust@def*\LTS@checkpr{\LTS@teststpl\LTS@checkpresence} -\robust@def*\LTS@checkpresence{\LTS@testopt\LTS@ch@ckpresence{}} -\new@def*\LTS@ch@ckpresence[#1]#2#3{% - \cpt@choicefdfalse - \begingroup - \ifLTS@st\lowercase{\fi - \ifblankTF{#1}{% - \def\LTS@tempa{\endgroup\LTS@ch@@@presence\LTS@nil{#2}{#3}}% - }{% - \def\LTS@tempa{\endgroup\LTS@ch@@kpresence#1\LTS@nil{#2}{#3}}% - }% - \ifLTS@st}\fi\LTS@tempa -} -\new@def*\LTS@ch@@kpresence#1#2\LTS@nil#3#4{% - \ifblankTF{#2}% - {\LTS@ch@@@presence#1{#3}{#4}}% - {\LTS@ch@@@@resence#1#2{#3}{#4}}% -} -\new@def*\LTS@ch@@@presence#1#2#3{% - \begingroup - \def\LTS@tempc{#1}% - \ifxTF\LTS@nnil\LTS@tempc{% - \def\LTS@tempc{}% - }{% - \def\LTS@tempc{\def#1{#3}}% - }% - \edef\LTS@tempa{\detokenize{#3}}% - \cpt@sttrue\cpt@csvnormalize[,]\LTS@tempa - % Leave \csv@@parse here! - \def\csv@do##1{% - \xifinsetFT{,\detokenize{##1},}{,\LTS@tempa,}{}{% - \edef\LTS@tempc{\def\noexpand#1{\unexpanded{##1}}}% - \cpt@choicefdtrue\loopbreak - }% - }% - \csv@@parse[,]{#2}% - \LTS@ch@@@@@oice\LTS@notpresent@handler{#2}{#3}% -} -\new@def*\LTS@ch@@@@resence#1#2#3#4{% - \def#1{}\def#2{-1}% - \begingroup - \cpt@cnta\z@pt\def\LTS@tempc{}% - \def\csv@do##1{% - \xifinsetFT{,\detokenize{##1},}{,\detokenize{#4},}{}{% - \edef\LTS@tempc{% - \def\noexpand#1{\unexpanded{##1}}% - \def\noexpand#2{\the\cpt@cnta}% - }% - \cpt@choicefdtrue\loopbreak - }% - \advance\cpt@cnta\@ne - }% - \csv@@parse[,]{#3}% - \LTS@ch@@@@@oice\LTS@notpresent@handler{#3}{#4}% -} - -% \ifmanyincsvlistTF[parser](no.){sublist}{mainlist} -% Check if the no. of elements of parser-separated list -% '#3' found in #4 is equal or greater than '#2'. #4 -% is the main list. If the test is true, \itemspresent returns -% all the elements found and \noofitems returns the number -% of elements found: -\ifcsdefinable\itemspresent\relax -\ifcsdefinable\noofitems\relax -\robust@def*\ifmanyincsvlistTF{% - \LTS@testopt\LTS@ifmanyincsvlistTF{,}% -} -\robust@def*\LTS@ifmanyincsvlistTF[#1]{% - \LTS@testpnopt{\LTS@ifm@nyincsvlistTF#1}{1}% -} -\robust@def*\LTS@ifm@nyincsvlistTF#1(#2)#3#4{% - \begingroup - \if\LTS@lwc\lowercase{\fi - \edef\LTS@tempa{\unexpanded{#3}}% - \edef\LTS@tempb{\unexpanded{#4}}% - \if\LTS@lwc}\fi - \cpt@sttrue\cpt@csvnormalize[#1]\LTS@tempb - \def\LTS@tempc{}\cpt@cnta\z@pt - \def\csv@do##1{% - \edef\x{\detokenize{#1}}% - \xifinsetFT{\detokenize{#1##1#1}}{\x\cptoxdetok\LTS@tempb\x}{% - \edef\LTS@tempc{\csliststack,\LTS@tempc\unexpanded{##1}}% - \advance\cpt@cnta\@ne - \ifnum\cpt@cnta>\numexpr#2-1\relax\loopbreak\fi - }% - }% - \csv@@parse*[#1]\LTS@tempa - \ifnum\cpt@cnta>\numexpr#2-1\relax - \gletcs\itemspresent\LTS@tempc - \xdef\noofitems{\the\cpt@cnta}% - \else - \gdef\itemspresent{}\gdef\noofitems{-1}% - \fi - \NoConvertInputToLowercase - \aftercsname\endgroup - {LTS@\ifnumcmpTF\cpt@cnta>\numexpr#2-1{1}2of2}% -} - -% \ifmanyintsvlistTF(no){sublist}{mainlist} -% Check if the no. of elements of tsv list #2 -% found in #3 is equal or greater than '#1'. #3 -% is the main list. If the test is true, \itemspresent returns -% all the elements found and \noofitems returns the number -% of elements found: -\robust@def*\ifmanyintsvlistTF{% - \LTS@testpnopt\LTS@ifmanyintsvlistTF{1}% -} -\robust@def*\LTS@ifmanyintsvlistTF(#1)#2#3{% - \begingroup - \if\LTS@lwc\lowercase{\fi - \edef\LTS@tempa{\unexpanded{#2}}% - \edef\LTS@tempb{\unexpanded{#3}}% - \if\LTS@lwc}\fi - \def\LTS@tempc{}\cpt@cnta\z@pt - \def\tsv@do##1{% - \xifinsetFT{\detokenize{##1}}{\cptoxdetok\LTS@tempb}{}{% - \edef\LTS@tempc{\csliststack,\LTS@tempc\unexpanded{##1}}% - \advance\cpt@cnta\@ne - \ifnum\cpt@cnta>\numexpr#1-1\relax\loopbreak\fi - }% - }% - \tsv@@parse*\LTS@tempa - \ifnum\cpt@cnta>\numexpr#1-1\relax - \gletcs\itemspresent\LTS@tempc - \xdef\noofitems{\the\cpt@cnta}% - \else - \gdef\itemspresent{}\gdef\noofitems{-1}% - \fi - \NoConvertInputToLowercase - \aftercsname\endgroup - {LTS@\ifnumcmpTF\cpt@cnta>\numexpr#1-1{1}2of2}% -} -\robust@def*\LTS@undeftogerr#1{% - \LTS@err{Toggle '#1' undefined}% - {You need to first define toggle '#1' before use.}% -} -\providecommand*\newtog[1]{\cpt@swatrue\LTS@testopt{\LTS@newtog{#1}}{false}} -\robust@def*\deftog#1{\cpt@swafalse\LTS@testopt{\LTS@newtog{#1}}{false}} -\new@def*\LTS@newtog#1[#2]{% - \begingroup - \ifinsetFT{,}{#1}{}{% - \edef\x{\ifcpt@swa'\string\newtog'\else'\string\deftog'\fi}% - \edef\y{\ifcpt@swa'\string\NewTogs'\else'\string\DefTogs'\fi}% - \LTS@err{Command \x doesn't accept list}{% - Please submit only one toggle to \x at a time. - \MsgBrk You can use \y to define a set of togs. - }% - }% - \endgroup - \LTS@ensurenoscape{#1}% - \ifboolTF{cpt@swa}{% - \ifcsndefFT{cpt@tog@#1}{}{% - \LTS@err{Toggle '#1' already defined}% - {Please provide a new toggle or use '\string\deftog'.}% - }% - \LTS@getboolstate\newtog{#2}% - }{% - \ifcsndefFT{cpt@tog@#1}{}{% - \LTS@verbosewarn{Toggle '#1' redefined}% - }% - \LTS@getboolstate\deftog{#2}% - }% - \letcsntocsn{cpt@tog@#1}{@\cptstrcmp - {\LTS@boolval}{true}{first}{second}oftwo}% -} -\providecommand*\providetog[1]{% - \ifcsndefTF{cpt@tog@#1}{% - \LTS@verboseinfo{Toggle '#1' already defined.\MsgBrk - Not redefined}% - }{% - \letcsntocs{cpt@tog@#1}\@secondoftwo - }% -} -\providecommand*\requiretog[1]{% - \aftercsname\needcommand{cpt@tog@#1}[2]{##2}% -} -\newtog{pdf}[false] -\newletcs\ifpdfTF\@secondoftwo -\newletcs\ifpdfFT\@firstoftwo -\ifdefTF\pdfoutput{% - \ifnumcmpTF\pdfoutput<\@ne{}{% - \settogtrue{pdf}% - \let\ifpdfTF\@firstoftwo - \let\ifpdfFT\@secondoftwo - }% -}{} -\new@def*\savecs#1{% - \LTS@ensurescape{#1}% - \ifcsndefTF{saved\cptgobblescape#1}{% - \LTS@err{\noexpand#1 already saved. You've to restore - \MsgBrk it or undefine '\noexpandcsn{saved\cptgobblescape#1}' - before\MsgBrk you can save \noexpand#1 again}\@ehc - }{% - \ifdefTF#1{% - \letcsntocs{saved\cptgobblescape#1}#1% - \ifcsndefFT{\string#1}{}{% - \letcsntocsn{@saved\cptgobblescape#1}{\string#1}% - }% - \ifcsndefFT{\cptgobblescape#1\@space}{}{% - \letcsntocsn{@@saved\cptgobblescape#1}% - {\cptgobblescape#1\@space}% - }% - \ifcsndefFT{\string#1\@space}{}{% - \letcsntocsn{@@@saved\cptgobblescape#1}{\string#1\@space}% - }% - }{% - \LTS@err{Undefined '\string#1' couldn't be saved\on@line}% - {You can't restore undefined commands. So why save\MsgBrk - undefined '\string#1' here?}% - }% - }% -} -\new@def*\restorecs#1{% - \LTS@ensurescape{#1}% - \ifcsndefTF{saved\cptgobblescape#1}{% - \letcstocsn#1{saved\cptgobblescape#1}% - \gundefcsn{saved\cptgobblescape#1}% - \ifcsndefFT{@saved\cptgobblescape#1}{}{% - \letcsntocsn{\string#1}{@saved\cptgobblescape#1}% - \gundefcsn{@saved\cptgobblescape#1}% - }% - \ifcsndefFT{@@saved\cptgobblescape#1}{}{% - \letcsntocsn{\cptgobblescape#1\@space}% - {@@saved\cptgobblescape#1}% - \gundefcsn{@@saved\cptgobblescape#1}% - }% - \ifcsndefFT{@@@saved\cptgobblescape#1}{}{% - \letcsntocsn{\string#1\@space}{@@@saved\cptgobblescape#1}% - \gundefcsn{@@@saved\cptgobblescape#1}% - }% - }{% - \LTS@err{No saved version of '\string#1' is available:\MsgBrk - '\string#1' couldn't be restored\on@line - }{% - Unsaved '\string#1' can't be restored.\MsgBrk - Note that each call to \noexpand\restorecs - undefines the saved command. - }% - }% -} -\providecommand*\input@path{} -\robust@def*\InputFileOnce{% - \savecs\input@path - \LTS@testst{\LTS@testpl{\LTS@testopt\LTS@inputfileonce{.}}}% -} -\new@def*\LTS@inputfileonce[#1]#2{% - \ifblankTF{#1}{}{\grightaddtocs\input@path{{#1/}}}% - \ifboolTF{LTS@st}{% - % Don't check whether the file has already been read: - \LTS@inp@tfileonce{#2}% - }{% - \ifcsndefTF{#2@LTS@read}{% - \ifLTS@verbose - \LTS@info{File '#2' already read:\MsgBrk - File '#2' wasn't read again}% - \fi - }{% - \LTS@inp@tfileonce{#2}% - }% - }% -} -\def\LTS@inp@tfileonce#1{% - \def\reserved@a##1##2{% - \IfFileExists{#1}{##1\@filef@und##2}% - }% - \ifboolTF{LTS@pl}{% - \reserved@a\include - }{% - \reserved@a\@@input - }{% - \letcsntocs{#1@LTS@read}\relax - \restorecs\input@path - }{% - \typein[\@gtempa]{^^J! File '\string#1' does not exist. - ^^JEnter filename or 'x' and <return> to continue.}% - \def\reserved@a{x}% - \ifxTF\@gtempa\reserved@a{% - \restorecs\input@path - }{% - \cptexpandarg{\LTS@inputfileonce[]}\@gtempa - }% - }% -} -\new@def*\xp@counttokens#1{% - \long\def\xp@counttokens##1{% - \the\numexpr\expandafter - \LTS@xpcounttokens##1#1\cpt@nnil\cpt@nnil\relax - }% -} -\xp@counttokens{ } -\new@def\LTS@xpcounttokens#1{% - \expandafter\ifxTF\cpt@car#1\car@nil - \cpt@nnil{0\cpt@removetonnil}{1+\LTS@xpcounttokens}% -} -\robust@def*\countalltokens#1{% - \def\countalltokens##1{% - \let\nr\m@one - \def\@counttokens{\futurelet\@let@token\LTS@countalltokens}% - \expandafter\@counttokens##1#1\cpt@nnil - }% -} -\countalltokens{ } -\robust@def*\LTS@countalltokens{% - \ifxTF\@let@token\cpt@nnil\cpt@removetonnil{% - \edef\nr{\the\numexpr\nr+1}% - \afterassignment\@counttokens - \let\@let@token= % - }% -} -\robust@def*\counttokens{\LTS@testst\LTS@counttokens} -\robust@def\LTS@counttokens#1{% - \begingroup - \def\nr{0}\def\emp{0}\def\spo{0}% - \def\siso@do##1{% - \ifx\@empty##1\@empty - \edef\emp{\the\numexpr\emp+1}% - \edef\nr{\the\numexpr\nr+1}% - \else - \ifx##1\@sptoken - \edef\spo{\the\numexpr\spo+1}% - \edef\nr{\the\numexpr\nr+1}% - \else - \edef\nr{\the\numexpr\nr+1}% - \fi - \fi - }% - \ifboolTF{LTS@st}{% - \expandafter\siso@@loop\expandafter{#1}% - }{% - \siso@@loop{#1}% - }% - \cptpassexpanded{% - \endgroup - \def\noexpand\nonempty{\nr}% - \def\noexpand\nr{{\nr}{\emp}{\spo}}% - }% -} -\newcommand*\ltscountargs[1]{% - \protected\def\ltscountargs##1{% - \begingroup - \@tempcnta\z@pt\@tempcntb\z@pt\cpt@cnta\z@pt - \def\end@countargs{\end@countargs}% - \def\LTS@countargs@a{\futurelet\next\LTS@countargs@c}% - \def\LTS@countargs@b####1{\LTS@countargs@a}% - \expandafter\LTS@countargs@a##1#1\end@countargs - }% -} -\ltscountargs{ } -\def\LTS@countargs@c{% - \ifxTF\next\end@countargs{% - \edef\next{% - \endgroup - \edef\noexpand\argcount{\the\numexpr\the\@tempcnta-1}% - \edef\noexpand\spacecount{\the\numexpr\the\@tempcntb-1}% - \edef\noexpand\nonspacecount{\the\cpt@cnta}% - }% - \expandafter\next\@gobble - }{% - \advance\@tempcnta\@ne - \ifxTF\next\@sptoken{% - \advance\@tempcntb\@ne - \afterassignment\LTS@countargs@a\let\next= % - }{% - \advance\cpt@cnta\@ne - \LTS@countargs@b - }% - }% -} -\robust@def*\macronizetokens{% - \begingroup - \@makeother{\#}% - \endlinechar\m@one - \LTS@testopt\LTS@macronize{}% -} -\robust@def*\LTS@macronize[#1]#2#3{% - % Check for catcode-10 tokens while keeping '#' as other: - \toks0{#3}% - \scantokens{\toks1{#3}}% - \xifstrcmpTF{\the\toks0}{\the\toks1}{}{% - \LTS@err{I can't macronize unscannable tokens: - ^^J^^J||\detokenize{#3}||}\@ehc - }% - \endgroup - \begingroup - \LTS@twohashcheck{#3}{}{% - \LTS@err{Illegal nested parameters in: - ^^J^^J\detokenize{#3}}\@ehc - }% - \edef\reserved@e{\detokenize{#3}}% - \chardef\nr@b\z@pt - \xifinsetFT\LTS@hashchar\reserved@e{}{% - \def\nr@a{1}% - \cptwhilenum\nr@a<10\do{% - \cptexpandtwoargs\cpt@in{\LTS@hashchar\nr@a}{\reserved@e}% - \ifcpt@in\let\nr@b\nr@a\fi - \pushnumber\nr@a - }% - \ifnum\nr@b>\z@pt - \emptify#2\def\nr@a{1}% - \cptwhilenum\nr@a<\numexpr\nr@b+1\do{% - \edef#2{\expandcsonce#2\LTS@hashchar\nr@a}% - \pushnumber\nr@a - }% - \fi - }% - \edef#2{#1\def\string#2#2{\reserved@e}}% - \LTS@scantoksd\endgroup#2% -} -\robust@def*\ifmeaningTF#1#2{% - \begingroup - \ifdefFT{#1}{% - \endgroup\@secondoftwo - }{% - \edef\LTS@tempa{\realmeaning{#1}}% - \edef\LTS@tempb{\detokenize{#2}}% - \aftercsname\endgroup{LTS@\ifxTF\LTS@tempa\LTS@tempb12of2}% - }% -} -\robust@def*\ifactivecharTF#1{% - \begingroup - \ltsifmacroTF{#1}{% - \edef\LTS@tempa{\string#1}% - \def\LTS@tempb{#1}% - \edef\LTS@tempb{\realmeaning\LTS@tempb}% - \aftercsname\aftergroup{LTS@\ifxTF\LTS@tempa\LTS@tempb12of2}% - }{% - \aftergroup\@secondoftwo - }% - \endgroup -} -\robust@def*\ltsifmacroTF#1{% - \begingroup - \edef\LTS@tempa##1{\def##1####1\detokenize{macro}:####2&}% - \LTS@tempa\LTS@tempa{% - \aftercsname\aftergroup{LTS@\ifblankTF{##2}21of2}% - }% - \edef\LTS@tempb##1{##1\detokenize{macro}:&}% - \LTS@tempb{\expandafter\LTS@tempa\meaning#1}% - \endgroup -} -\robust@def*\ltsifmacroFT#1{\ltsifmacroTF{#1}\@secondoftwo\@firstoftwo} -\robust@def*\ifparamacroTF#1{% - \begingroup - \edef\LTS@tempa##1{\def##1####1\detokenize{macro}:####2->####3&}% - \LTS@tempa\LTS@tempa{% - \aftercsname\aftergroup{LTS@\ifblankTF{##2}21of2}% - }% - \edef\LTS@tempb##1{##1\detokenize{macro}:->&}% - \LTS@tempb{\expandafter\LTS@tempa\meaning#1}% - \endgroup -} -\robust@def*\ifparamacroFT#1{\ifparamacroTF{#1}\@secondoftwo\@firstoftwo} -\robust@def*\ifcsnparamacroTF{\aftercsname\ifparamacroTF} -\robust@def*\ifprefmacroTF#1{% - \begingroup - \ifmacroFT{#1}{% - \aftergroup\@secondoftwo - }{% - \edef\LTS@tempa##1{\def##1####1\detokenize{macro}:####2&}% - \LTS@tempa\LTS@tempa{% - \aftercsname\aftergroup{LTS@\ifblankTF{##1}21of2}% - }% - \edef\LTS@tempb##1{##1\detokenize{macro}:&}% - \LTS@tempb{\expandafter\LTS@tempa\meaning#1}% - }% - \endgroup -} -\robust@def*\ifprefmacroFT#1{\ifprefmacroTF{#1}\@secondoftwo\@firstoftwo} -\robust@def*\ifprimitiveTF#1{% - \begingroup - \ltsifmacroTF{#1}{% - \endgroup\@secondoftwo - }{% - \def\LTS@tempa##1##2&{% - \aftercsname\endgroup{LTS@\if##1\@backslashchar1\else2\fi of2}% - }% - \expandafter\LTS@tempa\meaning#1&% - }% -} -\robust@def*\ifprimitiveFT#1{\ifprimitiveTF{#1}\@secondoftwo\@firstoftwo} -\robust@def\ifpatternTF#1#2{% - \begingroup - \edef\LTS@tempa##1{\def##1####1\detokenize{#2}####2&}% - \LTS@tempa\LTS@tempa{% - \aftercsname\aftergroup{LTS@\ifblankTF{##2}21of2}% - }% - \edef\LTS@tempb##1{##1\detokenize{#2}&}% - \LTS@tempb{\expandafter\LTS@tempa\meaning#1}% - \endgroup -} -\robust@def*\ifpatternFT#1#2{\ifpatternTF{#1}{#2}\@secondoftwo\@firstoftwo} -\robust@def*\ifnopattern#1\in#2{\ifpatternFT{#2}{#1}} -\robust@def*\ifscannableTF#1{% - % Fails if the content of #1 is already detokenized. - \begingroup - \edef\LTS@rsvda##1{% - \def##1####1\detokenize{macro}:####2->####3&{% - ####1\def\string\LTS@rsvda####2{####3}% - }% - \edef##1{##1\meaning#1&}% - }% - \LTS@rsvda\LTS@rsvda - \makeatletter\everyeof{\noexpand}\endlinechar\m@one - \scantokens\expandafter{\LTS@rsvda}\relax - \aftercsname\endgroup{LTS@\expandafter\ifxTF\cpt@car#1\car@nil - \LTS@rsvda12of2}% -} -\robust@def*\ifscannableFT#1{\ifscannableTF{#1}\@secondoftwo\@firstoftwo} -\robust@def*\delimitmacro#1#2{% - \ifsingletokenTF{#2}{}{% - \LTS@err{Delimiter '\detokenize{#2}' is more than - one token}\@ehc - }% - \ifscannableTF#1{% - \begingroup - \edef\LTS@tempa##1{% - \def##1####1\detokenize{macro:}####2->####3&{% - ####1\def\string#1####2\string#2{####3}% - }% - \edef##1{##1\meaning#1&}% - }% - \LTS@tempa\LTS@tempa - \LTS@scantoksd\endgroup\LTS@tempa - }{% - \LTS@err{Your \noexpand#1 isn't scannable}{% - Sorry, I can't delimit the last parameter of your\MsgBrk - command \noexpand#1: it isn't scannable. - }% - }% -} -\robust@def*\LTS@stepdownhash{% - \begingroup - \@makeother{\#}% - \endlinechar\m@one - \LTS@st@pdownhash -} -\robust@def*\LTS@st@pdownhash#1#2{% - \xifinsetTF{\detokenize{##}}{\detokenize{#1}}{% - \edef\LTS@rsvda##1{##1\detokenize{#1##}&}% - \edef\LTS@rsvdb##1{\def##1####1\detokenize{##}####2&}% - \LTS@rsvdb\LTS@rsvdb{% - \ifblankTF{##2}{% - \toks@\expandafter{\the\toks@##1}% - }{% - \cptpassexpanded{\toks@{\the\toks@##1\LTS@hashchar}}% - \LTS@rsvdb##2&% - }% - }% - \LTS@rsvda{\toks@{}\LTS@rsvdb}% - \edef#2{\the\toks@}% - }{% - \edef#2{\detokenize{#1}}% - }% - \postgroupdef#2\endgroup -} -\robust@def*\LTS@stepuphash{% - \begingroup - \@makeother{\#}% - \endlinechar\m@one - \LTS@st@puphash -} -\robust@def*\LTS@st@puphash#1#2{% - \xifinsetTF{\LTS@hashchar}{\detokenize{#1}}{% - \edef\LTS@rsvda##1{##1\detokenize{#1}\LTS@hashchar&}% - \edef\LTS@rsvdb##1{\def##1####1\LTS@hashchar####2&}% - \LTS@rsvdb\LTS@rsvdb{% - \ifblankTF{##2}{% - \toks@\expandafter{\the\toks@##1}% - }{% - \cptpassexpanded{\toks@{\the\toks@##1\LTS@hashchar\LTS@hashchar}}% - \LTS@rsvdb##2&% - }% - }% - \LTS@rsvda{\toks@{}\LTS@rsvdb}% - \edef#2{\the\toks@}% - }{% - \edef#2{\detokenize{#1}}% - }% - \postgroupdef#2\endgroup -} - -\robust@def*\LTS@onehashcheck#1{% - \begingroup - \edef\LTS@rsvda##1{\def##1####1\LTS@hashchar####2&}% - \LTS@rsvda\LTS@rsvda{% - \aftercsname\aftergroup{LTS@\ifblankTF{##2}12of2}}% - \edef\LTS@rsvdb##1{##1\detokenize{#1}\LTS@hashchar&}% - \LTS@rsvdb\LTS@rsvda - \endgroup -} -\robust@def*\LTS@twohashcheck#1{% - \begingroup - \edef\LTS@rsvda##1{\def##1####1\detokenize{##}####2&}% - \LTS@rsvda\LTS@rsvda{% - \aftercsname\endgroup{LTS@\ifblankTF{##2}12of2}% - }% - \edef\LTS@rsvdb##1{##1\detokenize{#1}\detokenize{##}&}% - \LTS@rsvdb\LTS@rsvda -} -\robust@def*\robustifycs{\LTS@testopt\LTS@robustifycs{}} -\robust@def*\LTS@robustifycs[#1]#2{% - \ifdefFT{#2}{% - \cpt@notdeferr{#2}% - }{% - \ltsifmacroTF{#2}{% - \ifetexprotectedTF{#2}{% - \LTS@verboseinfo - {Protected command '\string#2' not re-protected}% - }{% - \ifltxprotectTF{#2}{% - \letcstocsn\LTS@rsvda{\cptgobblescape#2\@space}% - \cpt@swatrue - }{% - \let\LTS@rsvda#2\cpt@swafalse - }% - \ifparamacroTF\LTS@rsvda{% - \ifscannableTF\LTS@rsvda{% - \begingroup - \edef\LTS@rsvdb##1{% - \def##1####1\detokenize{macro}:####2->####3&{% - #1\protected####1\def\string\LTS@rsvda####2{####3}% - }% - \edef##1{##1\meaning\LTS@rsvda&}% - }% - \LTS@rsvdb\LTS@rsvdb - \LTS@scantoksd\endgroup\LTS@rsvdb - \let#2\LTS@rsvda - }{% - \LTS@err{Command '\string#2' can't be made robust}% - {Command '\string#2' isn't retokenizable.}% - \cpt@swafalse - }% - }{% - \protected#1\edef#2{\expandcsonce\LTS@rsvda}% - }% - \ifcpt@swa - \ifcsndefTF{\string#2\@space}{}% - {\undefcsn{\cptgobblescape#2\@space}}% - \fi - }% - }{% - \LTS@err{Command '\string#2' isn't a macro}% - {Command '\string#2' can't be made robust.}% - }% - }% -} -\robust@def*\robustifycsn{\LTS@testopt\LTS@robustifycsn{}} -\robust@def*\LTS@robustifycsn[#1]#2{% - \cptexpandarg{\robustifycs[#1]}{\noexpandcsn{#2}}% -} -\robust@def*\robustifycsset{\LTS@testopt\LTS@robustifycsset{}} -\robust@def*\LTS@robustifycsset[#1]#2{% - \def\csv@do##1{% - \LTS@ensuremacro{##1}% - \robustifycs[#1]{##1}% - }% - \csv@@parse[,]{#2}% -} -\new@def*\LTS@hookfail#1#2{% - \LTS@warn{Hooking to command '\string#1' failed:\MsgBrk#2}% -} -% [<prefix>]{<cmd1>}{<cmd2>}{<success>}{<failure>} -\robust@def*\apptoparamcs{% - \long\def\setarg##1##2{##1##2}% - \begingroup\@makeother{\#}\LTS@hooktoparamcs -} -\robust@def*\preptoparamcs{% - \let\setarg\cptswap - \begingroup\@makeother{\#}\LTS@hooktoparamcs -} -\newcommand\LTS@hooktoparamcs[3][]{% - \endgroup - \ifdefFT{#2}{% - \LTS@hookfail{#2}{Command isn't defined or is relaxed}% - \@secondoftwo - }{% - \ltsifmacroTF{#2}{% - \ifparamacroTF{#2}{% - \ifscannableTF{#2}{% - \LTS@twohashcheck{#3}{% - \ifblankTF{#1}{% - \LTS@h@oktoparamcs{#2}{#3}% - }{% - \LTS@h@oktoparamcs[#1]{#2}{#3}% - }% - \@firstoftwo - }{% - \LTS@hookfail{#2}{Nested commands or parameters}% - \@secondoftwo - }% - }{% - \LTS@hookfail{#2}{Macro can't be retokenized\MsgBrk - safely after patching}% - \@secondoftwo - }% - }{% - \LTS@onehashcheck{#3}{% - \LTS@verboseinfo{Macro '\string#2' patched successfully}% - \ifetexprotectedTF{#2}\protected\relax - #1\edef#2{\setarg{\expandcsonce#2}{\unexpanded{#3}}}% - \LTS@verboseinfo{Macro '\string#2' patched successfully}% - \@firstoftwo - }{% - \LTS@hookfail{#2}{Command is a parameterless macro - \MsgBrk but you're hooking with a parametered macro}% - \@secondoftwo - }% - }% - }{% - \LTS@hookfail{#2}{Command isn't a macro}% - \@secondoftwo - }% - }% -} -\newcommand\LTS@h@oktoparamcs[3][]{% - \begingroup - \edef\LTS@tempa##1{% - \def##1####1\detokenize{macro}:####2->####3&{% - #1####1\def\string#2####2{\setarg{####3}{\detokenize{#3}}}% - }% - \edef##1{##1\meaning#2&}% - }% - \LTS@tempa\LTS@tempa - \LTS@scantoksd\endgroup\LTS@tempa -} -\robust@def*\TracingPatchesOn{\let\LTS@tracepatches\cptswtrue} -\robust@def*\TracingPatchesOff{\let\LTS@tracepatches\cptswfalse} -% If 'patchability' has been established: -\robust@def*\simplecmdpatch{% - \begingroup - \@makeother{\#}% - \endlinechar\m@one - \LTS@testopt\LTS@simplecmdpatch{####1}% -} -\new@def*\LTS@simplecmdpatch[#1]#2#3#4{% - \if\LTS@tracepatches - \typeout{^^J** Debugging patches: command '\string#2'}% - \fi - \endgroup - \begingroup - \edef\LTS@tempa##1##2{% - \def##1####1\detokenize{macro:}####2->####3&{% - #1\def\string#2####2{##2####3&}% - }% - \def##2####1\detokenize{#3}####2&{####1\detokenize{#4}####2}% - \edef##1{##1\meaning#2&}% - }% - \LTS@tempa\LTS@tempa\LTS@tempb - \catcode`\#=6\relax\makeatletter - \LTS@scantoksd\endgroup\LTS@tempa -} - -\robust@def*\patchcs{% - \LTS@ifstar\LTS@patchcs@b\LTS@patchcs@a -} -\robust@def*\LTS@patchcs@a{% - \let\LTS@hashcheckorno\LTS@twohashcheck - \begingroup - \@makeother{\#}\endlinechar\m@one - % If \LTS@testopt uses a different definition of - % \@ifnextchar, the number of hash characters here - % would have to change; it will most likely become 8: - \LTS@testopt\LTS@patchcs{####1}% -} -\robust@def*\LTS@patchcs@b{% - \if\stricthashcheck - \LTS@err{Patching failed: you can't use the star (*) - \MsgBrk variant while strict hash check is in force. - \MsgBrk Relax strict hash check with - '\string\NoStrictHashCheck'}\@ehc - \fi - \let\LTS@hashcheckorno\ifblankFT - \begingroup - \@makeother{\#}\endlinechar\m@one - \LTS@testopt\LTS@patchcs{####1}% -} -\new@def*\LTS@patchcs[#1]#2#3#4{% - \if\LTS@tracepatches - \typeout{^^J** Debugging patches: command '\string#2'}% - \fi - \LTS@hashcheckorno{#4}{% - \LTS@p@tchcs{#1}{#2}{#3}{#4}% - }{% - \endgroup - \LTS@patchdebug{--}{Nested parameters}% - \@secondoftwo - }% -} -\new@def*\LTS@p@tchcs#1#2#3#4{% - \LTS@ifpatchable{#2}{#3}{#4}{% - \LTS@patchdebug{++}{Command is patchable}% - \LTS@patchdebug{==}{Patching has begun}% - \begingroup - \edef\LTS@tempa##1##2{% - \def##1####1\detokenize{macro:}####2->####3&{% - #1\def\string#2####2{##2####3&}% - }% - \def##2####1\detokenize{#3}####2&{####1\detokenize{#4}####2}% - \edef##1{##1\meaning#2&}% - }% - \LTS@tempa\LTS@tempa\LTS@tempb - \LTS@scantoksd\endgroup\LTS@tempa - \LTS@patchdebug{==}{Patching completed successfully}% - \@firstoftwo - }{% - \LTS@patchdebug{--}{Patching couldn't be completed}% - \@secondoftwo - }% -} -\new@def*\LTS@patchdebug#1#2{% - \if\LTS@tracepatches - \typeout{[debug] #1 #2}% - \fi -} -\robust@def*\LTS@ifpatchable#1#2#3{% - \endgroup - \ifdefswitchTF{stricthashcheck}{% - \LTS@patchdebug{==}{'stricthashcheck' set true}% - % If #3 is macronizable, then it is scannable. - % Macronizing doesn't accept nested hash, but - % we're already in strict mode here. - \macronizetokens\LTS@rsvda{#3}% - \LTS@patchdebug{++}{No illegal nested parameters in command}% - }{}% - \ifdefFT{#1}{% - \LTS@patchdebug{--}{Command not defined}% - \@secondoftwo - }{% - \LTS@patchdebug{++}{Command is defined}% - \ltsifmacroTF{#1}{% - \LTS@patchdebug{++}{Command is a macro}% - \ifscannableTF{#1}{% - \LTS@patchdebug{++}{Macro can be retokenized safely - after patching}% - \LTS@hashcheckorno{#2}{% - \LTS@patchdebug{++}{No nested parameters in command - or 'stricthashcheck' is false}% - \ifpatternTF{#1}{#2}{% - \LTS@patchdebug{++}{Requested search pattern found}% - \@firstoftwo - }{% - \LTS@patchdebug{--}{Requested search pattern not found}% - \@secondoftwo - }% - }{% - \LTS@patchdebug{--}{Nested commands or parameters}% - \@secondoftwo - }% - }{% - \LTS@patchdebug{--}{Macro can't be retokenized - safely after patching}% - \@secondoftwo - }% - }{% - \LTS@patchdebug{--}{Command isn't a macro}% - \@secondoftwo - }% - }% -} -\robust@def*\ifpatchableTF{\begingroup\LTS@ifpatchable} -\robust@def*\reverseexpansion#1#2{% - \ifnumcmpFT#2=\@ne{}{% - \LTS@err{Invalid expansion order '\string#2' for - '\string\reverseexpansion'}{Why not just use - '\string\expandafter' here instead\MsgBrk of - '\string\reverseexpansion'?}% - \@gobbleone - }% - \ifcase\numexpr#2-2\relax - \def\LTS@rsvda{2,2}% - \or - \def\LTS@rsvda{3,4,4}% - \or - \def\LTS@rsvda{4,6,8,8}% - \else - \LTS@err{Invalid expansion order \string#2} - {Number '\string#2' of '\string\reverseexpansion' - is too large.}% - \expandafter\@gobble - \fi - \def\csv@do##1{% - \LTS@sttrue - \LTS@expandoneahead#1{##1}% - }% - \csv@@loop*[,]\LTS@rsvda -} -\robust@def*\expandoneahead{\LTS@testst\LTS@expandoneahead} -\robust@def\LTS@expandoneahead#1#2{% - \begingroup - \makecsn{\{}\lb\makecsn{\}}\rb - \toks@{}% - \@tempcnta\m@one - \def\LTS@i{\futurelet\next\LTS@iv}% - \def\LTS@ii{\afterassignment\LTS@i\let\next= }% - \def\LTS@iii##1{% - \ifnum\@tempcnta<#2\relax - \ifx##1\bgroup\relax - \toks@\expandafter{\the\expandafter\toks@\expandafter\expandafter\lb}% - \else - \ifx##1\egroup\relax - \toks@\expandafter{\the\expandafter\toks@\expandafter\expandafter\rb}% - \else - \toks@\expandafter{\the\toks@\expandafter##1}% - \fi - \fi - \else - \ifx##1\bgroup - \toks@\expandafter{\the\expandafter\toks@\lb}% - \else - \ifx##1\egroup - \toks@\expandafter{\the\expandafter\toks@\rb}% - \else - \toks@\expandafter{\the\toks@##1}% - \fi - \fi - \fi - }% - \def\LTS@iv{% - \advance\@tempcnta\@ne - \ifx\next\end - \let\cmd\@gobbleone - \else - \ifx\next\@sptoken - \toks@\expandafter{\the\toks@ \expandafter\@space}% - \let\cmd\LTS@ii - \else - \ifx\next\bgroup - \LTS@iii\bgroup\let\cmd\LTS@ii - \else - \ifx\next\egroup - \LTS@iii\egroup\let\cmd\LTS@ii - \else - \let\cmd\LTS@v - \fi - \fi - \fi - \fi - \cmd - }% - \def\LTS@v##1{\LTS@iii##1\LTS@i}% - \ifdefboolFT{LTS@st}{}\expandafter\LTS@i#1\end - \edef\LTS@resa{\the\toks@}% - \postgroupdef\LTS@resa\endgroup - \LTS@scantoksa\LTS@resa - \ifLTS@st\let#1\LTS@resa\fi -} -\robust@def*\expandallonce{\LTS@testopt\LTS@expandallonce\@M} -\robust@def*\LTS@expandallonce[#1]#2{% - \begingroup - \let\temp@bgroup\bgroup - \let\bgroup\LTS@undefined - \cpt@cnta#1\relax\advance\cpt@cnta\@ne - \LTS@exp@ndallonce#2% - \postgroupdef#2\endgroup - \NoExpandPrimitives -} -\new@def*\LTS@exp@ndallonce#1{% - \def\LTS@i{\futurelet\next\LTS@ii}% - \def\LTS@ii{% - \expandafter\LTS@iii\meaning\next\LTS@nil - \ifx\next\end - \let\cmd\@gobbleone - \else - \ifx\next\@sptoken - \edef#1{\expandcsonce#1\@space}% - \csn@def{cmd} {\LTS@i}% - \else - \let\cmd\LTS@iv - \fi - \fi - \cmd - }% - \def\LTS@iii##1##2\LTS@nil{\if##1\@backslashchar\let\next\relax\fi}% - \def\LTS@iv##1{% - \toks@\expandafter{#1}\toks1{##1}% - \ifx\next\temp@bgroup - \advance\cpt@cnta\m@one - \ifnum\cpt@cnta>\z@pt - \begingroup - \aftercsname\edef{\string#1}{\the\toks1}% - \aftercsname\LTS@exp@ndallonce{\string#1}% - \toks1\cptsevenxp{\usename{\string#1}}% - \edefpass#1{\endgroup\toks1{\the\toks1}}% - \fi - \edef#1{\the\toks@{\the\toks1}}% - \advance\cpt@cnta\@ne - \else - \edef#1{\the\toks1}% - \LTS@exp@nd@llonce#1% - \edef#1{\the\toks@\expandcsonce#1}% - \fi - \LTS@i - }% - \expandafter\emptify\expandafter#1\expandafter\LTS@i#1\end -} -\robust@def*\LTS@exp@nd@llonce#1{% - \begingroup - \oifmacroTF#1{% - \edef#1{\noexpand\expandcsonce\expandcsonce#1} - }{% - \edef\LTS@rsvda{\cptsevenxp\LTS@car\cptoxdetok{#1}x\car@nil}% - \ifxTF\LTS@rsvda\@backslashchar{% - \simpleexpandarg\ifprimitiveTF{#1}{% - \if\LTS@expprim - \edef#1{\expandcsonce#1}% - \else - \edef#1{\noexpand\noexpand\expandcsonce#1}% - \fi - }{% - \edef#1{\noexpand\noexpand\expandcsonce#1}% - }% - }{% - \edef#1{\expandcsonce#1}% - }% - }% - \postgroupdef#1\endgroup -} -\new@def*\CurrentPackageOrClass{\@cls@pkg\@space'\@currname'} -\new@def*\LTS@parsedate#1/#2/#3 v#4\LTS@nil{#1/#2/#3} -\robust@def*\LTS@notloadederr#1{% - \ifcsndefTF{ver@#1.\@pkgextension}{}{% - \LTS@err{Package '#1' wasn't loaded}% - {Document has begun and package '#1' wasn't loaded.\MsgBrk - You wanted package '#1' loaded.}% - }% -} -\new@def*\LTS@notloaded{} -\robust@def*\ensurepackageloaded#1{% - \def\csv@do##1{% - \grightaddtocs\LTS@notloaded{\LTS@doloaded{##1}}% - }% - \csv@@parse[,]{#1}% -} -\LTS@AtBeginDocument{% - \let\LTS@doloaded\LTS@notloadederr - \LTS@notloaded - \gletcs\LTS@doloaded\@gobbleone -} -\robust@def*\QuotationMarks#1{% - \begingroup - \ifinsetTF,{#1}{% - \def\LTS@tempa##1,##2\LTS@nil{% - \ifblankTF{##2}{% - \LTS@err{Unbalanced quotation marks '#1'}\@ehc - }{% - \protected@xdef\LTS@lquote{% - {\ltsprotectedtokens{\normalcolor\normalfont}##1}}% - \protected@xdef\LTS@rquote{% - {\ltsprotectedtokens{\normalcolor\normalfont}##2}}% - }% - }% - \LTS@tempa#1\LTS@nil - }{% - \LTS@err{I can't find comma in quotation marks '#1'}\@ehc - }% - \endgroup -} -\QuotationMarks{`,'} -\new@def*\ApplyToQuotes#1{% - \ifnumcmpTF\LTS@quotednr@b>\z@pt{% - \LTS@err{You haven't called '\string\ApplyNilToQuotes'\MsgBrk - since you last called '\string\ApplyToQuotes'}\@ehc - \@gobbleone - }{% - \gdef\LTS@quotefmt{#1}% - }% - \let\LTS@quotednr@b\@ne -} -\new@def*\ApplyNilToQuotes{% - \gletcs\LTS@quotefmt\@firstofone - \chardef\LTS@quotednr@b\z@pt -} -\ApplyNilToQuotes -\def\quote@while{\cpt@choicefdfalse\quote@loop} -\def\quote@loop#1{% - \ifboolTF{cpt@choicefd}{% - \quote@end - }{% - \ifx#1\quote@repeat\quote@repeat\fi - \ifx#1\quote@next\cpt@choicefdtrue\fi - }% - \quote@loop -} -\def\quote@repeat#1\quote@loop{\fi} -\def\quote@end#1\quote@repeat{} -\chardef\LTS@quotednr@a\z@pt -\chardef\LTS@quotednr@b\z@pt -\robust@def*\quoted{% - \pushnumber\LTS@quotednr@a - \ifnumcmpTF\LTS@quotednr@a>\tw@{% - \cpt@toodeep\quoted\tw@ - }{% - \begingroup - \@makeother{\#}% - \LTS@testst\LTS@quoted - }% -} -\new@def*\LTS@quoted#1{% - \def\LTS@quotearg{{\LTS@quotefmt{#1}}}% - \gletcsntocs{ifLTS@st@\romannumeral\LTS@quotednr@a}\ifLTS@st - \def\LTS@tempa{% - \ifLTS@st@i - \protected@edef\lquote{\LTS@lquote}% - \protected@edef\rquote{\LTS@rquote}% - \else - \protected@edef\lquote{\LTS@lquote\LTS@lquote}% - \protected@edef\rquote{\LTS@rquote\LTS@rquote}% - \fi - }% - \def\LTS@tempb##1##2{% - \ifnum\LTS@quotednr@a>\@ne - \LTS@tempa - \else - \protected@edef\lquote{##1\LTS@lquote}% - \protected@edef\rquote{##2\LTS@rquote}% - \fi - }% - \ifLTS@st - \LTS@tempb\LTS@lquote\LTS@rquote - \else - \LTS@tempb{}{}% - \fi - \def\popnumber{\noexpand\popnumber\noexpand}% - \protected@edef\rquote{\rquote\popnumber\LTS@quotednr@a}% - \futurelet\quote@next\LTS@qu@ted -} -\new@def*\LTS@qu@ted{% - \def\LTS@quotefnt{\footnote\footnotetext\footnotemark\mpfootnotemark}% - \def\LTS@quote@a{% - \if\LTS@wq - \expandafter\quote@while\LTS@quotefnt\quote@repeat - \ifcpt@choicefd - \protected@xdef\LTS@qu@t@d####1####2{% - \lquote\expandcsonce\LTS@quotearg\unskip####1{####2}\rquote - }% - \else - \protected@xdef\LTS@qu@t@d####1{% - \lquote\expandcsonce\LTS@quotearg\unskip####1\rquote}% - \fi - \else - \protected@xdef\LTS@qu@t@d{% - \lquote\expandcsonce\LTS@quotearg\rquote\unskip}% - \fi - }% - \protected@edef\LTS@tempa{,;:.!?\expandcsonce\LTS@quotefnt}% - \expandafter\quote@while\LTS@tempa\quote@repeat - \ifcpt@choicefd - \expandafter\LTS@quote@a - \else - \protected@xdef\LTS@qu@t@d{\lquote\expandcsonce\LTS@quotearg\rquote}% - \fi - \expandafter\endgroup\LTS@qu@t@d -} -\robust@def*\MakeQuoteCommand{\LTS@testst\LTS@MakeQuoteCommand} -\robust@def*\LTS@MakeQuoteCommand#1{% - \begingroup - \lccode`\~=`#1% - \lowercase{\endgroup - \newcsnedef*{\string~@quote}{\the\catcode`~}% - \ifLTS@st - \ifdefFT~{}{\letcsntocs{\string~@@quote}~}% - \let~\quoted - \else - \newletcs~\quoted - \fi - \catcode`#1=\active - }% -} -\robust@def*\DeleteQuoteCommand#1{% - \begingroup - \lccode`\~=`#1% - \lowercase{\endgroup - \ifcsndefTF{\string~@@quote}{% - \letcstocsn~{\string~@@quote}% - }{% - \gletcs~\LTS@undefined - }% - \catcode`#1=\usename{\string~@quote}% - }% -} -\robust@def*\nameabbrev#1#2{% - \begingroup - \LTS@ensurescape{#1}% - \makecsn#1\LTS@tempa - \expandafter\LTS@testopt\expandafter - {\expandafter\LTS@nameabbrev\expandafter{\LTS@tempa}{#2}}{}% -} -\new@def*\LTS@nameabbrev#1#2[#3]{% - \ifblankTF{#3}{% - \LTS@err{Empty abbreviation for name '\noexpandcsn{#1}'}\@ehc - }{% - \newcsnpgdef*{#1long}{#2\sspace}% - \newcsnpgdef*{#1short}{#3\sspace}% - \newcsnpgdef*{#1first}{#2~(#3)\sspace}% - }% - \newcsnpgdef*{#1}{% - \ifnamedefTF{nameabbrev@#1}{% - #3\sspace - }{% - \csn@gdef{nameabbrev@#1}{}% - \usename{#1first}\sspace - }% - }% - \endgroup -} -\newletcs\killifdocstarted\@iden -\LTS@AfterAfterBeginDocument{% - \LTS@scantoksa\sspace@exceptions - \let\killifdocstarted\@gobble -} -\robust@def*\sspace@while{\cpt@choicefdfalse\sspace@loop} -\robust@def*\sspace@loop#1{% - \ifboolTF{cpt@choicefd}{% - \sspace@end - }{% - \ifx#1\sspace@repeat\sspace@repeat\fi - \ifx#1\sspace@next\cpt@choicefdtrue\fi - }% - \sspace@loop -} -\robust@def\sspace@repeat#1\sspace@loop{\fi} -\robust@def\sspace@end#1\sspace@repeat{} -\robust@def*\sspace@exceptions{% - \},.'/?;:!~-)\ \/\bgroup\egroup\sspace\nobreak\penalty - \@sptoken\@space\@xobeysp\footnote\footnotemark -} -\robust@def*\sspace{\begingroup\futurelet\sspace@next\LTS@sspace} -\robust@def*\LTS@sspace{% - \killifdocstarted{\LTS@scantoksa\sspace@exceptions}% - \expandafter\sspace@while\sspace@exceptions\sspace@repeat - \expandafter\endgroup - \ifcpt@choicefd\else\expandafter\@space\fi -} -\robust@def*\AddSspaceExceptions#1{% - \ltsfiltermergetsv!\sspace@exceptions{#1}\nofilter -} -\robust@def*\RemoveSspaceExceptions#1{% - \filterdeletetokens!\sspace@exceptions{#1}\nofilter -} -\long\def\LTS@exprerr#1{% - \ltx@err{Invalid test expression}{#1.}% -} -\robust@def*\ltsifexprTF#1{% - \begingroup - \let\LTS@expr@neg\cptswfalse - \@tempcnta\z@pt - \LTS@expr@beg - \LTS@expr@bgroup#1(\expr@nil - \LTS@expr@end - \LTS@expr@eval@end -} -\def\LTS@expr@beg{% - \begingroup - \let\LTS@expr@neg\cptswfalse - \@tempcnta\z@pt -} -\def\LTS@expr@end{% - \LTS@expr@eval@end\LTS@expr@true\LTS@expr@false -} -\def\LTS@expr@eval@end{% - \aftercsname\endgroup - {@\ifnum\@tempcnta<\z@pt second\else first\fi oftwo}% -} -\def\LTS@expr@true{% - \advance\@tempcnta\if\LTS@expr@neg\m@one\else\z@pt\fi - \let\LTS@expr@neg\cptswfalse -} -\def\LTS@expr@false{% - \advance\@tempcnta\if\LTS@expr@neg\z@pt\else\m@one\fi - \let\LTS@expr@neg\cptswfalse -} -\long\def\LTS@expr@bgroup#1(#2\expr@nil{% - \LTS@expr@egroup#1)\expr@nil - \ifblankTF{#2}{}{% - \LTS@expr@beg - \LTS@expr@bgroup#2\expr@nil - }% -} -\long\def\LTS@expr@egroup#1)#2\expr@nil{% - \LTS@expr@and#1and\expr@nil - \ifblankTF{#2}{}{% - \LTS@expr@end - \LTS@expr@egroup#2\expr@nil - }% -} -\long\def\LTS@expr@and#1and#2\expr@nil{% - \LTS@expr@or#1or\expr@nil - \ifblankTF{#2}{}{% - \ifnum\@tempcnta<\z@pt - \@tempcnta\m@one - \else - \@tempcnta\z@pt - \fi - \LTS@expr@and#2\expr@nil - }% -} -\long\def\LTS@expr@or#1or#2\expr@nil{% - \LTS@expr@not#1not\expr@nil - \ifblankTF{#2}{}{% - \ifnum\@tempcnta<\z@pt - \@tempcnta\z@pt - \else - \@tempcnta\@ne - \fi - \LTS@expr@or#2\expr@nil - }% -} -\long\def\LTS@expr@not#1not#2\expr@nil{% - \LTS@expr@tog#1togg\expr@nil - \ifblankTF{#2}{}{% - \let\LTS@expr@neg\cptswtrue - \LTS@expr@not#2\expr@nil - }% -} -\long\def\LTS@expr@tog#1togg#2\expr@nil{% - \LTS@expr@bool#1bool\expr@nil - \ifblankTF{#2}{}{\LTS@expr@tog@a#2\expr@nil}% -} -\long\def\LTS@expr@tog@a#1#2\expr@nil{% - \ifcsndefTF{cpt@tog@\cpttrimspaces{#1}}{% - \usename{cpt@tog@#1}\LTS@expr@true\LTS@expr@false - }{% - \LTS@exprerr{Toggle '#1' undefined}% - \LTS@expr@false - }% - \LTS@expr@tog#2\expr@nil -} -\long\def\LTS@expr@bool#1bool#2\expr@nil{% - \LTS@expr@test#1test\expr@nil - \ifblankTF{#2}{}{\LTS@expr@bool@a#2\expr@nil}% -} -\long\def\LTS@expr@bool@a#1#2\expr@nil{% - \ifcsndefTF{if\cpttrimspaces{#1}}{% - \csname if#1\endcsname - \LTS@expr@true - \else - \LTS@expr@false - \fi - }{% - \LTS@exprerr{Boolean '#1' undefined}% - \LTS@expr@false - }% - \LTS@expr@bool#2\expr@nil -} -\long\def\LTS@expr@test#1test#2\expr@nil{% - \ifblankTF{#1}{}{% - \LTS@exprerr{The invalid part is: '\detokenize{#1}'}% - }% - \ifblankTF{#2}{}{% - \LTS@expr@test@a#2\expr@nil - }% -} -\long\def\LTS@expr@test@a#1#2\expr@nil{% - \cpttrimspaces{#1}% - \LTS@expr@true\LTS@expr@false - \LTS@expr@test#2\expr@nil -} - -% \newenviron, \renewenviron {<start>}<body>{<end>}. -% Collect environment body in \envbody: -\ltsnewbool{LTS@alwaystrim} -\new@def*\AlwaysTrimEnvironmentEntries{% - \global\LTS@alwaystrimtrue -} -\new@def*\trimenvspaces{% - \ifboolTF{LTS@alwaystrim}\cpttrimspaces\unexpanded -} -\new@def*\everyeoenv#1{\gdef\LTS@everyeoenv{#1}} -\everyeoenv{\@ignoretrue} -\robust@def*\newenviron{\cpt@starorlong\LTS@newenviron} -\robust@def*\LTS@newenviron#1{% - \edef\LTS@tempa{\trimenvspaces{#1}}% - \cptexpandarg\cpt@testopt - {\LTS@n@wenviron{\expandcsonce\LTS@tempa}}0% -} -\robust@def*\LTS@n@wenviron#1[#2]{% - \cpt@ifbrack - {\LTS@n@wenv@ron#1[#2]} - {\LTS@n@wenv@r@n{#1}{[#2]}}% -} -\robust@def*\LTS@n@wenv@ron#1[#2][#3]{\LTS@n@wenv@r@n{#1}{[#2][{#3}]}} -\robust@def*\renewenviron{\cpt@starorlong\LTS@renewenviron} -\robust@def*\LTS@renewenviron#1{% - \edef\LTS@tempa{\trimenvspaces{#1}}% - \ifcsndefTF\LTS@tempa{} - {\@latex@error{Environment #1 is undefined}\@ehc}% - \letcsntocs\LTS@tempa\relax - \letcsntocs{end\LTS@tempa}\relax - \expandafter\LTS@newenviron\expandafter{\LTS@tempa}% -} -\robust@def\LTS@n@wenv@r@n#1#2#3#4{% - \ifcsndefTF{#1}{}{\letcsntocsn{#1}{end#1}}% - \aftercsname\new@command{#1}#2{% - \edef\LTS@beforebody{\trimenvspaces{#3}}% - \LTS@collectbody - }% - \l@ngrel@x\csn@edef{end#1}{% - \begingroup - \defpass\noexpand\x{\endgroup\trimenvspaces{#4}}% - }% -} -\robust@def*\LTS@collectbody{% - \begingroup - \toks@{}% - \everyeof{\end{EOF}\relax}% - \LTS@coll@ctbody -} -\robust@def\LTS@coll@ctbody#1\end#2{% - \toks1{% - \cptexpanded{% - \toks@{\the\toks@\trimenvspaces{#1}% - \noexpand\end{\expandcsonce\LTS@tempa}}% - }% - \LTS@coll@ctbody - }% - \edef\LTS@tempa{\trimenvspaces{#2}}% - \ifxTF\LTS@tempa\@currenvir{% - \edef\LTS@tempb{\LTS@pushbegin#1\begin\end\cpt@relax}% - \ifcsemptyTF\LTS@tempb{% - \cptexpandsecond\endgroup{% - \edef\noexpand\envbody{\noexpand\unexpanded{% - \the\toks@\ifblankTF{#1}{}{\trimenvspaces{#1}}% - }}% - \unexpanded{% - \LTS@beforebody\relax\LTS@everyeoenv - \ifboolTF{LTS@alwaystrim}\@ignoretrue\relax - }% - \noexpand\end{\LTS@tempa}% - }% - }{% - \the\toks1 - }% - }{% - \oifstrcmpTF{\LTS@tempa}{document}{% - \expandafter\endgroup\expandafter - \@checkend\expandafter{\LTS@tempa}% - }{% - \oifstrcmpTF{\LTS@tempa}{EOF}{% - \expandafter\endgroup\expandafter - \@checkend\expandafter{\LTS@tempa}% - }{% - \the\toks1 - }% - }% - }% -} -\new@def\LTS@pushbegin#1\begin#2{% - \expandafter\ifxTF\cpt@car#2x\car@nil\end{% - \@gobble - }{% - \xifstrcmpTF{\detokenize\expandafter{\romannumeral-`\q - \trimenvspaces{#2}}}{\cptoxdetok\LTS@tempa}{% - x\cpt@gobbletorelax - }{% - \LTS@pushbegin - }% - }% -} - -\packagecommands{% - \packagecommands,\AtEndOfPackage, - \LTS@AtEndPackage,\AtEndOfClass,\LTS@AtEndClass, - \LTS@BeforeEndPackage,\LTS@BeforeEndClass,\LTS@AfterEndPackage, - \LTS@AfterEndClass,\ifclasscurrentTF,\ifclasscurrentFT -} -\preamblecommands{% - \preamblecommands,\LTS@BeforeBeginDocument,\ensurepackageloaded, - \needpackage } +\ltsdeclaremodules{base,environ,doc,index,incluput,review,trace} \XDeclareBiBooleanOptions{draft,final}[true](LTS@){}{} \XDeclareBooleanOption{verbose}[true](LTS@){% \ifLTS@verbose\cpt@verbosetrue\else\cpt@verbosefalse\fi @@ -5132,10 +59,13 @@ $Id: ltxtools.sty,v 0.0.1 2011/09/20 09:00:00 Ahmed Musa Exp $ \LTS@info{'tracepatches' set true\on@line}% }{}% } +\XDeclareBooleanOption{fp}[true](LTS@){% + \ifboolTF{LTS@fp}{% + \AfterProcessOptions{\RequirePackage[nomessages]{fp}}% + }{}% +} \XDeclareOption*{\LTS@warn{Unknown option '\CurrentOption' ignored}} \XExecuteOptions{verbose=false,final=true,tracepatches=false} \XProcessOptions*\relax \endinput - -%%% End of file ltxtools.sty %%% |