diff options
author | Karl Berry <karl@freefriends.org> | 2011-02-09 00:14:24 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2011-02-09 00:14:24 +0000 |
commit | 411888f6b880268f3f4e445bb276455b72e742a1 (patch) | |
tree | f9ed21962ad5c0336b19d9f672e19865c3217269 /Master | |
parent | 8585b7dec2ed96446fd3f1fa2fcda92db8292a78 (diff) |
new latex package catoptions (7feb11)
git-svn-id: svn://tug.org/texlive/trunk@21347 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rw-r--r-- | Master/texmf-dist/doc/latex/catoptions/README | 15 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/catoptions/catoptions-guide.pdf | bin | 0 -> 337140 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/catoptions/catoptions-guide.tex | 478 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/catoptions/catoptions-guide.cfg | 80 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/catoptions/catoptions.sty | 2266 | ||||
-rwxr-xr-x | Master/tlpkg/bin/tlpkg-ctan-check | 2 | ||||
-rw-r--r-- | Master/tlpkg/tlpsrc/catoptions.tlpsrc | 0 | ||||
-rw-r--r-- | Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc | 1 |
8 files changed, 2841 insertions, 1 deletions
diff --git a/Master/texmf-dist/doc/latex/catoptions/README b/Master/texmf-dist/doc/latex/catoptions/README new file mode 100644 index 00000000000..e75d6b7a377 --- /dev/null +++ b/Master/texmf-dist/doc/latex/catoptions/README @@ -0,0 +1,15 @@ +This is the README file for the 'catoptions' package. + +SUMMARY +The 'catoptions' package changes package loading internals so that all subsequently loaded packages can rely on normal/standard catcodes of all ASCII characters. The package defines canonical control sequences to represent all the visible ASCII characters. It also provides robust options parsing mechanisms, in addition to many TeX programming tools. + +AUTHOR +Ahmed Musa + +EARLIER WORKS +The 'catoptions' package is based on the 'pcatcode' package by Michael J. Downes and David M. Jones. + +VERSION +Version 0.1, February 2011 + + diff --git a/Master/texmf-dist/doc/latex/catoptions/catoptions-guide.pdf b/Master/texmf-dist/doc/latex/catoptions/catoptions-guide.pdf Binary files differnew file mode 100644 index 00000000000..9018dc051d0 --- /dev/null +++ b/Master/texmf-dist/doc/latex/catoptions/catoptions-guide.pdf diff --git a/Master/texmf-dist/doc/latex/catoptions/catoptions-guide.tex b/Master/texmf-dist/doc/latex/catoptions/catoptions-guide.tex new file mode 100644 index 00000000000..7a7538d17b2 --- /dev/null +++ b/Master/texmf-dist/doc/latex/catoptions/catoptions-guide.tex @@ -0,0 +1,478 @@ +\documentclass[a4paper,10pt,final,language=UKenglish,fancysec,framesecno, + parabst,inputcfg]{amltxdoc} +\makeatletter +\WrapQuotes +\NoPrintNotes +\makeindex + +\begin{document} + +\begin{frontmatter} +\title{The \texttt{\color{blue}catoptions} Package\titleref{t1}} +\titlenote[t1]{The package is available at + \iftogTF{pdf}{\url{\@titleurl}}{\url{\@shorttitleurl}}.} +\version{0.1} +\titleurl{http://www.ctan.org/tex-archive/macros/latex/contrib/catoptions/} +\shorttitleurl{http://www.ctan.org/} +\author{Ahmed Musa \Email{a.musa@rocketmail.com}\\Preston, Lancashire, UK} + +\def\abstractname{\textsf{Summary}} +\begin{abstract} + \small + The \pkg'{catoptions} provides several extensions to the \pkgm'{pcatcode}. Apart from the tools related to setting up, preserving and restoring category codes, it includes many programming macros and even new list and options processing interfaces. It modifies the \latex kernel's options parsing mechanism to forestall premature expansion of options and values (in the manner of the \pkgs'{xkvltxp,kvoptions-patch}), so that the \pkg'{catoptions} may be loaded even before \hx{\documentclass}. In fact, the package is meant to be loaded on top of other packages, so as to exploit its catcode preserving scheme. Among other reasons, this necessitated the development of the options parsing scheme of this package. Only the catcode and options parsing facilities are treated in this manual; the macro programming interfaces will be covered in the documentation of the \pkg'{ltxtools}. The machinery of the \pkg'{catoptions} adds no cost to the simple syntax of \LaTeX's native options parser. Users who are already familiar with \LaTeX's legacy options processing don't necessarily have to invest the time that is essential in learning the extensive machinery of existing key-value and option parsers, although those other packages (\eg, \pkgs{xkeyval, kvsetkeys, kvoptions, skeyval, rkeyval, pgfkeys, pgfopts}) contain richer featuresets. Existing packages don't have to be modified to use the features of the \pkg'{catoptions}. The \pkg'{catoptions}, while maintaining simplicity, does not strip off even one level of outer braces in parsing package options and in list processing. It robustly normalizes key-values and options prior to parsing. +\end{abstract} + +\let\licensename\relax +\begin{license} +\xwmcolorbox[textalign=justified,outerframecolor=blue,innerframecolor=orange,width=.985\hsize]{% + This work (\ie, all the files in the \pkg'{catoptions} bundle) may be distributed and/or modified under the conditions of the \lppl, either version~1.3 of this license or any later version. + \endgraff + 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. + \endgraf + \centerline{\makered{\CopyrightYear}}\vspace{-.8\baselineskip}\relax +} +\end{license} +\end{frontmatter} + +\begin{xwmshade}[fillcolor=white,framecolor=orange,framerule=1pt,framesep=2pt, + width=1.0\hsize]\tableofcontents +\end{xwmshade} + + +\docsection(sec:motivation){Motivation} + +My motivation for turning to the \pkgnoidx'{pcatcode} was to save myself the trouble of declaring category codes at the beginning of my packages. After spending some time on the \pkgnoidx'{pcatcode}, I discovered I had learnt enough to make changes and additions to some of its macros and functionality. After completing the catcode stuff in the \pkg'{catoptions}, I wanted to pass options to the package. If the package is to be loaded on top of other packages, as intended, then its options parsing scheme should be independent of other packages. But realizing the trouble with passing expandable option values to packages and classes via the \latex kernel's scheme, I decided to implement modifications to the kernel's options parser. Apart from the problem of premature expansion of options and values by the \latex kernel, outer curly braces in option values are lost during parsing. Indeed, the kernel's option parsing scheme doesn't recognize option values indicated with the equality sign. And the syntaxes (if not also the semantics) of \cptuse{latex3}, whose options parser is presumably more robust than that of \cptuse{latex2e}, calls for additional investment in time that may not be readily affordable to some users. + + +\docsection(sec:pkg-options)<Package options>{Package options} + +The \pkg'{catoptions} has only two options, namely, \ffx'{verbose, usepox}. The option \fxim{verbose} instructs the package to put information onto the log file when existing commands are being redefined by means of the command \fx{\robust@redef} (which has the same syntax with \tex's legacy \hx{\def}). This option may be used in the future to provide debugging features for the package. + +If the \pkg'{catoptions} is loaded before \hx{documentclass}, it will invariably use the options processing mechanism of the package (namely, the more robust commands \ffx'{\XDeclareOption, \XExecuteOptions, \XProcessOptions} in place of \latex's native commands \hhx'{\DeclareOption, \ExecuteOptions, \ProcessOptions})\footnote{The user interfaces of \ffx'{\XDeclareOption, \XExecuteOptions, \XProcessOptions} are similar to those of \hhx'{\DeclareOption, \ExecuteOptions, \ProcessOptions} but they aren't the same. See \cref{sec:options-parse}.}. In that case, the legacy commands \hhx'{\DeclareOption, \ExecuteOptions, \ProcessOptions} are aliased to \ffx'{\XDeclareOption, \XExecuteOptions, \XProcessOptions}, respectively. The latter set of commands do immediately recognize that they have to deal with option functions that are based on the kernel's semantics. This allows expandable options and option values to be passed via \hx{\documentclass}---if \pkg{catoptions} is loaded before \hx{\documentclass}. This also implies that existing packages can use the options parsing scheme of \pkg'{catoptions} without modifying the packages. + +The option \fxim{usepox} directs the package to use the \pkg{catoptions}'s options processing scheme for all the packages loaded after \hx{\documentclass}, instead of \latex's native options parsing procedures. This allows \pkg{catoptions}'s options parsing scheme to be used for existing packages loaded after \hx{\documentclass}. + +Assuming that the options \qoutedtt{textstyle} and \qoutedtt{name} belong to an existing package (say, \qoutedtt{mypackage}) to be loaded later, then the following example demonstrates one feature of the \pkg'{catoptions}: + +\start{example}[] +\RequirePackage[verbose, usepox]{catoptions} +\documentclass[textstyle=\ttfamily,name={Mr X\"avier Sanchez},a4paper, + draft,10pt]{article} +\usepackage{mypackage} +\finish{example} +\fxim*{\RequirePackage,\usepackage,\documentclass} + + +\docsection(sec:saving-catcodes){Saving and restituting category codes} + +There are the following user commands for saving and returning category codes of \quoted{other} characters to their previous states: + +\start{newmacro}[] +\cptnormalcatcodes +\cptpushcatcodes +\cptpopcatcodes +\UseNormalCatcodes +\GetCurrentCatcodeSubset +\cptfutureletsetup +\finish{newmacro} +\fxim*{\UseNormalCatcodes,\cptpushcatcodes,\cptpopcatcodes, +\cptnormalcatcodes,\cptfutureletsetup,\GetCurrentCatcodeSubset} +\fxim*{\cptfutureletsetup} + +The command \fx{\cptnormalcatcodes} simply resets the category codes of all \otherchars together with those of the space character and \fx{\^^I} and \fx{\^^J} to their standard values. The command \fx{\cptpushcatcodes} pushes the current category codes for restitution later with \fx{\cptpopcatcodes}. The command \fx{\UseNormalCatcodes} works only in packages and does more than one thing: it calls \ffx'{\cptpushcatcodes, \cptnormalcatcodes,\cptfutureletsetup} in that order. At the end of the package, it automatically issues \fx{\cptpopcatcodes} to recover all the category codes earlier pushed. The command \fx{\UseNormalCatcodes} can conveniently be issued at the start of the package and the developer can be assured of access to the standard category codes of all \otherchars together with those of the space character and \fx{\^^I} and \fx{\^^J}. It should be called only once in a package: subsequent calls will have no effect. + +After issuing the command \fx{\GetCurrentCatcodeSubset}, you can do + +\start{example}[] +\show\currentcatcodesubset +\finish{example} +\fxim*{\currentcatcodesubset} + +to see the current catcode setup. The command \fx{\cptfutureletsetup} is described in \cref{sec:future-letting}. + +\start{example}[\UseNormalCatcodes] +\ProvidesPackage{mypackage}[2011/01/16 v0.01] +\NeedsTeXFormat{LaTeX2e}[1995/12/01] +\RequirePackage[verbose, usepox]{catoptions} +\UseNormalCatcodes +\finish{example} +%\fxi*{\UseNormalCatcodes} + + +\docsection(sec:future-letting){Future-letting of \headq{other} characters} + +The command \fx{\cptfutureletsetup} defines canonical control sequences to represent all the visible ASCII characters (ranging from space to \fx{~} and 32--126 characters): + +\start'{example}[Futurelet characters] +space|R(|textvisiblespace) exclam|R(!) dblquote|R(") hash|R(#) dollar|R($) ampersand|R(|ampersand) +lrquote|R(') lparen|R(|() rparen|R(|)) star|R(*) plus|R(+) comma|R(,) hyphen|R(-) period|R(.) +slash|R(/) colon|R(:) semicolon|R(;) less|R(<) equal|R(=) greater|R(>) question|R(?) lbracket|R([) +rbracket|R(]) hat|R(^) underscore|R(_) lquote|R(`) lbrace|R({) vert|R(|rv) rbrace|R(}) tilde|R(~) +bslash|R(\) +\finish{example} +%\fxim*{\cptfutureletsetup} + +The defined commands have the syntaxes + +\start'{newmacro}[Futurelet characters] +\|nang(stub)|nang(char) +\if|nang(stub)|nang(char) +\finish{newmacro} + +They are prefixed with \ang{stub} which can be set with the command + +\start{newmacro}[\declarefutureletprefix] +\declarefutureletprefix{|nang(stub)} +\finish{newmacro} +\fxim*{\declarefutureletprefix} + +For instance, with the choice \fx{\declarefutureletprefix{fl@}}, we have the following commands on hand for testing after \fx{\futurelet}. If any of the commands emanating from \ang{stub}, concatenated with the name of the character, is already defined, an error message is flagged. It should be noted that these commands are available only after issuing the command \fx{\cptfutureletsetup}, which is called automatically at \hx{\AtBeginDocument}. At \hx{\AtBeginDocument} the \pkg'{catoptions} calls \fx{\cptrestorecatcodes}, followed by \fx{\cptfutureletsetup}. + +\start+{newmacro}[Futurelet commands] +\fl@space \fl@exclam \fl@dblquote \fl@hash +\fl@dollar \fl@ampersand \fl@lrquote \fl@lparen +\fl@rparen \fl@star \fl@plus \fl@comma +\fl@hyphen \fl@period \fl@slash \fl@colon +\fl@semicolon \fl@less \fl@equal \fl@greater +\fl@question \fl@lbracket \fl@rbracket \fl@hat +\fl@underscore \fl@lquote \fl@lbrace \fl@vert +\fl@rbrace \fl@tilde \fl@bslash +\finish{newmacro} + +The \pkg'{catoptions} has already defined these test macros. To further aid testing, the following commands are defined by the \pkg'{catoptions}: + +\start+{newmacro}[Futurelet commands] +\iffl@space \iffl@exclam \iffl@dblquote \iffl@hash +\iffl@dollar \iffl@ampersand \iffl@lrquote \iffl@lparen +\iffl@rparen \iffl@star \iffl@plus \iffl@comma +\iffl@hyphen \iffl@period \iffl@slash \iffl@colon +\iffl@semicolon \iffl@less \iffl@equal \iffl@greater +\iffl@question \iffl@lbracket \iffl@rbracket \iffl@hat +\iffl@underscore \iffl@lquote \iffl@lbrace \iffl@vert +\iffl@rbrace \iffl@tilde \iffl@bslash +\finish{newmacro} +\fxim*{Futurelet commands} + +The use syntaxes for these commands are as follows: + +\start{example}[Futurelet characters] +\futurelet\next\cmd |textbf(|R(*)) +\def\cmd{\ifx\fl@star\next `I saw star'\else `I didn't see star'\fi} +\def\cmd{\iffl@star\next{`I saw star'}{`I didn't see star'}} +\finish{example} + +Notice that \fx{\ifx\fl@comma\next} is a conventional \tex test, while \fx{\iffl@...} expects two \latex branches (\ffx'{\@firstoftwo,\@secondoftwo}). It may be argued that these commands are needlessly too many and may be defined by means of only two macros. That would appear a valid point, but the commands are meant to be easy to recall and use. If, for example, you are testing for the presence of \fx{\tilde}, you simply do \fx{\iffl@tilde\next{...}{...}}, assuming a \ang{stub} of \fx{fl@}. + +After setting up \fx{\futurelet} characters with \fx{\cptfutureletsetup}, you can reset active characters to catcode~13 by \fx{\futureletresetactives}. + + +\docsection(sec:package-prelim){Setting up package preliminaries} + +Every package normally requires some preliminary declarations, such as seen below. The commands \ffx'{\StyleFilePurpose, \StyleFileRCSInfo, \StyleFileInfo, \SetStyleFileMessages} are defined by the \pkg'{catoptions}. All of them have intuitive syntaxes, except the command \fx{\SetStyleFileMessages}, whose syntax is explained below. + +\start{example}[Package preliminaries] +\StyleFilePurpose{A collection of useful commands} +\StyleFileRCSInfo +$Id: mypackage.sty,v 0.1 2011/01/01 09:00:00 My Name Exp $ +\ProvidesPackage{mypackage}[\StyleFileInfo] +\NeedsTeXFormat{LaTeX2e}[1996/12/01] +\SetStyleFileMessages[mypack@]{err}{warn}{info} +\finish{example} + +\start{newmacro}[\SetStyleFileMessages] +\SetStyleFileMessages[|nang(stub)]{|nang(err)}{|nang(warn)}{|nang(info)} +\finish{newmacro} +\fxim*{\SetStyleFileMessages} + +Here, \ang{stub} is an optional prefix for the three package messages described below. The default value of \ang{stub} is the first three characters of the package or class name (\hx{\@currname}) concatenated with the \quoted{at} sign \quoted{\fx{@}}. The mandatory arguments \ang{err}, \ang{warn}, and \ang{info} are the suffices for the package error, warning and information messages, respectively. + +For instance, with the declaration + +\start{example}[\SetStyleFileMessages] +\SetStyleFileMessages[mypack@]{error}{warning}{info} +\finish{example} + +the following commands are automatically defined by the \pkg'{catoptions}: + +\start{example}[\SetStyleFileMessages] +\mypack@error |tto Error message of two parameters +\mypack@warning |tto Warning message of one parameter +\mypack@info |tto Information message of one parameter +\finish{example} + +The commands \ffx'{\mypack@error,\mypack@info} can be used as follows: + +\start{example}[\SetStyleFileMessages] +\ifcptonetokenTF{#1}{% + \mypack@info{Correct single argument `\detokenize{#1}': accepted}% +}{% + \mypack@error{Multiple arguments `\detokenize{#1}'}% + {Invalid multiple arguments `\detokenize{#1}' rejected}% +} +\finish{example} + + +\docsection(sec:options-parse){Options parsing} + +The interfaces of the options processing commands are as follows, which, apart from the optional family \ang{fam} and default value \ang{default}, are syntactically similar to the corresponding native \latex commands. The optional family name is useful for defining unique options that stand only a remote chance of being mixed up with options of other families. And the optional default value is handy when the user doesn't supply a value for an option: no errors are produced in this case. Existing packages can be processed with these commands without any modifications to those packages. In fact, we have run many existing packages on the bases of these commands (by letting \latex's \hhx'{\DeclareOption,\ExecuteOptions,\ProcessOptions} to these commands), without encountering difficulties. + +\start{newmacro}[\XDeclareOption] +\XDeclareOption<|nang(fam)>{|nang(option)}[|nang(default)]{|nang(fn)} +\XDeclareOption|*<|nang(fam)>{|nang(fn)} +\finish{newmacro} +\fxim*{\XDeclareOption} + +The \unstform of the macro \fx{\XDeclareOption} declares an option that can be used as a package or class option and executed by \fx{\XExecuteOptions} or \fx{\XProcessOptions}. This macro is similar to the standard \latex macro \hx{\DeclareOption}, but with this command the user can pass a value to the option as well. That value can be accessed by using \fx{#1} or \fx{\currval} in \ang{fn}. This will contain \ang{default} when no value has been specified for the option. The default value of the optional argument \ang{default} is empty. This implies that when the user does not assign a value to \ang{option} and when no default value has been defined, no error message will ensue. The optional argument \ang{fam} can be used to specify a unique family for the option. When the argument is not used, the macro will insert the default family name (namely, \fx{\@currname.\@currext}). The current option name is available in \fx{\curropt}. + +\start{example}[\XDeclareOption] +\ProvidesPackage{mypackage}[\StyleFileInfo] +\newif\ifmybool +\XDeclareOption{mybool}[true]{\@nameuse{mybool#1}} +\XDeclareOption{leftmargin}[.5\hsize]{\setlength\leftmargin{#1}} +\finish{example} + +The options \ffx'{mybool,leftmargin} could then be called via any of the following statements: + +\start{example}[\XDeclareOption] +|com(Inside class or package files:) +\RequirePackage[mybool=true,leftmargin=20\p@]{mypackage} +|com(Inside document file:) +\usepackage[mybool=false,leftmargin=20\p@]{mypackage} +|com(Via document class:) +\documentclass[mybool,leftmargin=20\p@]{myclass} +\finish{example} + +The \stform of the macro \fx{\XDeclareOption} can be used to process unknown options. It is similar to \latex's \hx{\DeclareOption}\RedStar. You can deploy \hx{\CurrentOption} within the \ang{fn} of this macro to access the option name and value for which the option is unknown. These values (possibly including an option) could, for example, be passed on to another class or package or could be used as an extra class or package option that, for instance, specifies a style that should be loaded. + +The following example produces a warning when the user supplies an option that was not previously declared. + +\start{example}[\XDeclareOption*] +\XDeclareOption|*{\PackageWarningNoLine{mypackage}{Unknown option + `\CurrentOption' ignored}} +\finish{example} + +\start{newmacro}[\XDeclareCommandOption] +\XDeclareCommandOption<|nang(fam)>{|nang(option)}[|nang(default)]|(pref|){|nang(fn)} +\finish{newmacro} +\fxim*{\XDeclareCommandOption} + +The command \fx{\XDeclareCommandOption} will, apart from declaring the option \ang{option}, also create a macro \fnn{{pref}{option}} to hold the user-supplied value of the option. The macro so created can be used in \ang{fn} or in any other place. The default value of the optional \ang{pref} is \quoted{\fx{\@currname @}} prefixed with the letters \fx{cmd}. + + +\start{newmacro}[\XDeclareBooleanOption] +\XDeclareBooleanOption<|nang(fam)>{|nang(option)}[|nang(default)]|(pref|){|nang(fn)} +\finish{newmacro} +\fxim*{\XDeclareBooleanOption} + +The command \fx{\XDeclareBooleanOption} will, apart from declaring the option \ang{option}, also create a boolean \fnn{{if}{pref}{option}}. It will automatically toggle this boolean (to \hx{true} or \hx{false}) when the option is set and the input is valid, depending on the user-supplied value of the option. The macros so created can be used in \ang{fn} or in any other place. The default value of the optional \ang{pref} is \quoted{\fx{\@currname @}} with no additional prefix. Only \hx{true} or \hx{false} may be submitted as the value of a boolean option. + + +\start{newmacro}[\XExecuteOptions] +\XExecuteOptions<|nang(fam)>{|nang(options)} +\finish{newmacro} +\fxim*{\XExecuteOptions} + +The re-entrant \fx{\XExecuteOptions} macro sets options created by \fx{\XDeclareOption} and is basically a means of setting up the default values of the options. The optional argument \ang{fam} can be used to specify a list of families that define the options. When the argument is not used, the macro will insert the default family name (\fx{\@currname.\@currext}). This macro will not use the declaration done by \fx{\XDeclareOption}\RedStar when undeclared options appear in its argument. Instead, in this case the macro will issue a warning and ignore the option. This differs from the behavior of \latex's \hx{\ExecuteOptions}. + +\start{example}[\XExecuteOptions] +\XExecuteOptions{leftmargin=0pt} +\finish{example} +%\fxi*{\XExecuteOptions} + +This initializes \hx{\leftmargin} to 0pt. + +\start{newmacro}[\XProcessOptions] +\XProcessOptions<|nang(fam)>[|nang(na)] +\XProcessOptions|*<|nang(fam)>[|nang(na)] +\finish{newmacro} +\fxim*{\XProcessOptions} + +The re-entrant \fx{\XProcessOptions} macro processes the options and values passed by the user to the class or package. The optional argument \ang{fam} can be used to specify the families that have been used to define the options. The optional argument \ang{na} can be used to specify options that should be ignored. When used in a class file, this macro will ignore unknown options. This allows the user to use global options in the \hx{\documentclass} command which could be claimed by packages loaded later. + +The \stform of \fx{\XProcessOptions} works like the \unstform except that the former also copies user input from the \hx{\documentclass} command and processes the options in the order specified by the \hx{\documentclass}. When the user specifies an option in the \hx{\documentclass} which also exists in the local family (or families) of the package calling \fx{\XProcessOptions}\RedStar, the local option will be set as well. In this case, \fx{#1} in \fx{\XDeclareOption} macro will contain the user-value entered in the \hx{\documentclass} (or \fx{\usepackage} or \fx{\RequirePackage}) command for this option. First the global options from \hx{\documentclass} will set local options and afterwards the local options (specified via \hhx'{\usepackage, \RequirePackage, \LoadClass} or similar commands) will set local options, which could overwrite the global options set earlier, depending on how the options sections are organized. The macro \fx{\XProcessOptions}\RedStar reduces to \fx{\XProcessOptions} only when issued from the class which forms the document class for the file at hand (to avoid setting the same options twice), but not for classes loaded later using, for instance, \hx{\LoadClass}. Global options that do not exist in the local families of the package or class calling \fx{\XProcessOptions}\RedStar will be simply ignored or highlighted. + +The implementation here differs significantly from the \latex kernel's scheme of carrying out \hx{\ProcessOptions} and \hx{\ProcessOptions}\RedStar. It also deviates from the implementations by other options processing packages. The differences lie mainly in how the local and global options are distinguished and in the order of processing those options. Among other issues, the family structure introduced by the \pkg'{catoptions} (though lightweight) makes the independence between local and global options possible, even if the options from the two categories share the same namespace and are mixed in, say, \hx{\documentclass} command. Also, document classes loaded by \hx{\LoadClass} don't have the same primacy as the first document class. When using \latex kernel's \hx{\ProcessOptions} or \hx{\ProcessOptions}\RedStar, a class file can't copy document class options, even if the class file is loaded by \hx{\LoadClass}. This is not the case with the \pkg'{catoptions}. + +\start+{example}[\XDeclareOption,\XExecuteOptions,\XProcessOptions] +|com(This is a sample class file. We specify a family for the options,) +|com(instead of using the default family |(testclass.sty|).) +\ProvidesClass{testclass}[2011/01/15 v1.0 A test class] +\NeedsTeXFormat{LaTeX2e} +|com(The following loading of `catoptions' may need to be commented out) +|com(to avoid option clash with another loading of the package in the document.) +|makepurple(% \RequirePackage{catoptions}) +\UseNormalCatcodes +\newvariables{if}{bool}{a,b} +\XDeclareOption<testclass>{boola}[true]{\cptuse{boola#1}} +\XDeclareBooleanOption<testclass>{boolb}[true]|(test@|){% + \iftest@boolb + \AtEndOfPackage{\gdef\tex{\TeX\xspace}}% + \fi +} +\XDeclareCommandOption<testclass>{color}[blue]|(test@|){% + \def\text{\textcolor{\test@color}{Result of test}}% +} +\XDeclareOption<testclass>{align}[left]{% + \ifstrcmpTF{#1}{left}{% + \let\align\raggedright + }{% + \ifstrcmpTF{#1}{right}{% + \let\align\raggedleft + }{% + \ifstrcmpTF{#1}{center}{% + \let\align\centering + }{% + \@latex@error{Invalid value `#1' for align}{% + You have issued an illegal value `#1' for the variable `align'. + }% + }% + }% + }% +} +\XDeclareOption*<testclass>{\PassOptionsToClass{\CurrentOption}{article}} +\XExecuteOptions<testclass>{boola,boolb} +\XProcessOptions*<testclass>\relax +\LoadClass{article} +\RequirePackage{xcolor} +\endinput + +|com(This is a sample document:) +\RequirePackage[usepox,align=right,boola=false,boolb]{catoptions} +\documentclass[name={Mr J\"avier Claudioos},a4paper,draft,10pt]{testclass} +|com(You can use \usepackage{catoptions} as below, but then the) +|com(\documentclass option `name={Mr J\"avier Claudioos}' can't be processed:) +|makepurple(% \usepackage[usepox,align=right,boola=false,boolb]{catoptions}) +\usepackage{cleveref} + +\begin{document} + Blackberry bush ... blackberry-lily. +\end{document} +\finish{example} + +\docsection(sec:normalize)<Normalizing lists>{Normalizing csv and kv lists} + +Any arbitrary comma-separated-values (csv) list can be normalized by using \fx{\csv@@normalize} before processing the list. + +\start{newmacro}[\csv@@normalize] +\csv@@normalize[|nang(parser)]{|nang(list)} +\csv@@normalize|*[|nang(parser)]|nang(listcmd) +\finish{newmacro} +\fxim*{\csv@@normalize} + +Here, \ang{list}, which is populated by parser-separated elements, is not expanded before normalization; \ang{listcmd}, on the other hand, is expanded once before normalization. The default value of the optional \ang{parser} is~\qcomma (comma). \quoted{Normalization} implies changing the category codes of all the active parsers to their standard values, as well as trimming leading and trailing spaces around the elements of the list and removing consecutive multiple parsers. Thus empty entries that are not enforced by curly braces are removed. The result (\ie, normalized list) is available in the macro \fx{\normalized@csvlist} (in the \unstform case) or \ang{listcmd} (in the \stform case). + +\start{example}[\csv@@normalize] +\begingroup +\catcode`\;=\active +\gdef\x{x ; ; {y}; ; z} +\endgroup + +\csv@@normalize*[;]\x +|com(\show\x) +\finish{example} + +\start{newmacro}[\kv@@normalize] +\kv@@normalize[|nang(parser)]{|nang(list)} +\kv@@normalize|*[|nang(parser)]|nang(listcmd) +\finish{newmacro} +\fxim*{\kv@@normalize} + +The command \fx{\kv@@normalize} normalizes a list of key-values, returning the result in the macro \fx{\normalized@kvlist} (in the \unstform case) or \ang{listcmd} (in the \stform case). Besides dealing with multiple commas and the spaces between entries, in this case the spaces between keys and the equality sign are removed and multiple equality signs are made only one. Moreover, the category codes of the arbitrary parser and the equality sign is made normal/other throughout the list. The command \fx{\kv@@normalize} is meant for options or key-value parsing; it is used in the options processing scheme of \pkg'{catoptions}. + +\start{example}[\csv@@normalize] +\begingroup +\catcode`\;\string=\active +\catcode`\=\string=\active +\gdef\x{x=A ; ; y=={B} ; ; z=C} +\endgroup + +\kv@@normalize*[;]\x +|com(\show\x) +\finish{example} + + +\docsection(csv-kv-parse)<Parsing lists>{Parsing csv and kv lists} + +\start{newmacro}[\csv@@parse,\kv@@parse] +\csv@@parse[|nang(parser)][|nang(list)] +\csv@@parse|*[|nang(parser)][|nang(listcmd)] +\kv@@parse[|nang(parser)][|nang(list)] +\kv@@parse|*[|nang(parser)][|nang(listcmd)] +\finish{newmacro} +\fxim*{\csv@@parse,\kv@@parse} + +The macros \ffx'{\csv@@parse,\kv@@parse} call \ffx'{\csv@@normalize, \kv@@normalize}, respectively. The macro \fx{\csv@@parse} is meant for general csv-list processing with an arbitrary parser, while the command \fx{\kv@@parse} is designed for processing key-value lists. The macros \ffx'{\csv@@parse,\kv@@parse} loop over a given \ang{parser}-separated \ang{list} and execute the user-defined, parametered commands \ffx'{\csv@do,\kv@do}, respectively, for every item in the list, passing the item as an argument and preserving outer braces. + +The commands \ffx'{\csv@@parse,\kv@@parse} aren't expandable. White spaces before and after the list separator are always ignored. If an item contains \ang{parser} or starts with a space, it must be wrapped in curly braces. The braces will persist thereafter, but will of course be removed during printing (if the items are printed). The default value of \ang{parser} is comma (\qcomma). + +The starred variants of \ffx'{\csv@@parse,\kv@@parse} expand \ang{listcmd} once before commencing the loop. + +Empty entries in \ang{list} or \ang{listcmd} will be processed if the boolean \fx{@useempty} is true. You may thus issue the command \fx{\UseEmptyEntry} or \fx{\DiscardEmptyEntry} before commencing the iteration. Issuing any of these commands prior to the commencement of the loop is recommended, because a previous call to either \fx{\csv@@parse} or \fx{\kv@@parse} (perhaps by another package) could have set \fx{@useempty} to a state that is no longer valid or desired. Both \ffx'{\csv@@parse,\kv@@parse} will execute at least once for empty \ang{list} or \ang{listcmd}. Both commands \ffx'{\csv@@parse,\kv@@parse} can be nested to any level and can be mixed. + +\start{example}[\csv@@parse] +\begingroup +\catcode`\;=\active +\gdef\x{a ; ; {b}; ; c} +\endgroup + +\@tempcnta\z@ +\def\csv@do#1{% + \advance\@tempcnta\@ne + \@namedef{x@\romannumeral\@tempcnta}{#1}% +} +\csv@@parse*[;]\x +|com(\show\x@ii) + +\def\xa{a,b,c} +\def\xb{x,y,z} +\def\csv@do#1{% + \pushnumber\nra + \csn@edef{arg@\romannumeral\nra}{#1}% + \let\nrb\z@ + \def\csv@do##1{% + \pushnumber\nrb + \csn@edef{arg@\romannumeral\nra @\romannumeral\nrb}{#1,##1}% + }% + \csv@@parse*\xb +} +\csv@@parse*\xa +\finish{example} + +The following is a pseudocode that depicts the use of \fx{\kv@@parse}: + +\start{example}[\kv@@parse] +\def\kv@do#1{% + \def\CurrentOption{#1}% + if \CurrentOption is not empty then + split \CurrentOption into option and value + search if option exists in \@declaredoptions + if option is found then + Execute the option's function + else + Report option as unknown + fi + fi +} +|com(\kv@@parse will normalize \@classoptions before parsing it:) +if there are declared options then + \kv@@parse*\@classoptions +fi +\finish{example} + + +\docsection(sec:version-hist){Version history} + +\begin{versionhist} + \begin{version}{0.1}{2011/01/25} + \item First public release. + \end{version} + +\end{versionhist} + +\newpage +\indexpreamble{Index numbers refer to page numbers.} +\indexpreambleformat{\centering} +\indexcolumns\tw@ +\printindex + +\end{document}
\ No newline at end of file diff --git a/Master/texmf-dist/tex/latex/catoptions/catoptions-guide.cfg b/Master/texmf-dist/tex/latex/catoptions/catoptions-guide.cfg new file mode 100644 index 00000000000..dddd4003035 --- /dev/null +++ b/Master/texmf-dist/tex/latex/catoptions/catoptions-guide.cfg @@ -0,0 +1,80 @@ +\ProvidesFile{catoptions-guide.cfg}% + [2011/02/06 v0.1 Definitions file for catoptions-guide.tex (AM)] + +\usepackage{xwatermark} +\fancypagenos[% + nopageone = true, + showpageno = true, + showfootrule = false, + ycoord = -.45\paperheight, + xcoord = .4\paperwidth, + scale = 1, + angle = 45, + lhead = {The \textcolor{maccolor}{catoptions} package}, + style = {Page~\thepage~of~\pageref{xwmlastpage}}, + rhead = \tcl{black}{\today}, +] + +\amltxoptions{% + geometry = {left=3cm,right=3cm,top=2.5cm,bottom=2.5cm,includeheadfoot}, + review = false, + parindent = false, + toc = false, + frontpagestyle = empty, + pretitleskip = 0ex, + afttitleskip = 1ex, + presuptitleskip = 15ex, + aftsuptitleskip = 0ex, + presubtitleskip = 0ex, + aftsubtitleskip = 0ex, + natbib = {numbers,sort&compress}, + cmdcolor = xmagenta1, + stycolor = xgreen1, + specolor = teal, + secheadcolor = blue +} + +\AfterStartOfDocument{\MakeQuoteCommand*_} +\def\otherchars{\quoted{other} characters\sspace} +\newletcs*\sectionbreak\medbreak +\newletcs\mccolor\makemaccolor +\newletcs\pucolor\makepurple +\AtBeginDocument{\redef*\thefootnote{\fnsymbol{footnote}}} + +%\dummywatermark +\newwatermark +[page=1,fontfamily=phv,fontsize=11pt,fontseries=m,align=center, + coordunit=pc,width=\hsize,angle=0,scale=1.8,xcoord=0,ycoord=32.5] +{\fadingtext[textcolor=blue,boxcolor=red, + scale=1.8,letterwidth=7.8mm,height=1.5ex]{catoptions}\\[1ex] + \tcl{blue}{\resizebox{.5\width}{!}{Setting up + {\tt\string\futurelet} characters, restoring catcodes, + and parsing options}}% +} + +%\dummywatermark +\newwatermark +[page=1,fontfamily=phv,fontsize=10pt,fontseries=m,color=black,align=center, +coordunit=pc,width=\hsize,angle=0,scale=1,xcoord=0,ycoord=24] +{% + \Citation[author={Michael J. Downes, 1958--2003},textcolor=black,leftmargin=0em, + fonttype=\small]{% + The \pkgnoidx'{pcatcode} functionality would work best if it were built into the + \usecsn{latex2e} kernel, but it cannot be usefully added to the kernel now without + adversely affecting document compatibility across different systems. This package + therefore modifies one or two of the low-level package-loading functions defined + by the kernel. Theoretically speaking, the \pkgnoidx'{pcatcode} itself has to guard against the + kind of catcode problems that it is intended to circumvent. If you would like a + nice little \tex\unskip nician's exercise, try your hand, before looking at the code of the + \pkgnoidx'{pcatcode}, at the task that I set for myself: find the minimal set of catcode + assumptions that one has to make before attempting to establish normalcy, where normalcy is + defined as the state at the end of the \latex kernel, just before the last + \hx{\makeatother}. This is the state that may normally be expected at the + beginning of a \hx{\documentclass} file, if the \latex format file does not + have any extensions (\eg, \pkgm{babel}) compiled in. + }% +} + +\endinput + +%%% End of file catoptions-guide.cfg %%% diff --git a/Master/texmf-dist/tex/latex/catoptions/catoptions.sty b/Master/texmf-dist/tex/latex/catoptions/catoptions.sty new file mode 100644 index 00000000000..0ccb627de06 --- /dev/null +++ b/Master/texmf-dist/tex/latex/catoptions/catoptions.sty @@ -0,0 +1,2266 @@ +%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++% +% This is 'catoptions' package (Version 0.1, August 2010) % +% % +% The catoptions package changes LaTeX package loading internals % +% so that all subsequently loaded packages can rely on having % +% normal catcodes in effect. The package also contains some useful % +% macros unconnected with catcodes. In particular, it contains % +% options processing facilities that have the familiar and simple % +% syntax of LaTeX's legacy options parsing mechanism, but with % +% improved robustness in terms of option value default, preservation % +% of braces in option values, and parsing of expandable package % +% and class option values. % +% % +% The catcode facilities of the package are an extension of the % +% 'pcatcode' package by Michael J. Downes and David M. Jones. % +% % +% 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 LPPL maintenance status of this software is 'author-maintained'. % +% % +% Copyright (c) 2011 Ahmed Musa (a.musa@rocketmail.com). % +% % +%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++% + +\begingroup +\chardef\%\catcode37\catcode37 14\relax\expandafter\iffalse\string\ +\fi\let\e\endlinechar\chardef\E\e\e13\chardef\n\catcode\e\catcode\e5 % +\chardef\s\catcode32 \catcode32 10 +\chardef\==\catcode61 \catcode61 12 +\chardef\l=\catcode123 \catcode123=1 +\chardef\r=\catcode125 \catcode125=2 +\chardef\[=\catcode91 \catcode91=12 +\chardef\]=\catcode93 \catcode93=12 +\chardef\^=\catcode94 \catcode94=7 +\chardef\.=\catcode46 \catcode46=12 +\chardef\/=\catcode47 \catcode47=12 +\chardef\~=\catcode126 \catcode126=13 +\chardef\&=\catcode38 \catcode38=4 +\chardef\$=\catcode36 \catcode36=3 +\chardef\_=\catcode95 \catcode95=8 +\chardef\+=\catcode43 \catcode43=12 +\chardef\!=\catcode33 \catcode33=12 +\chardef\'=\catcode39 \catcode39=12 +\chardef\(=\catcode40 \catcode40=12 +\chardef\)=\catcode41 \catcode41=12 +\chardef\*=\catcode42 \catcode42=12 +\chardef\,=\catcode44 \catcode44=12 +\chardef\-=\catcode45 \catcode45=12 +\chardef\:=\catcode58 \catcode58=12 +\chardef\<=\catcode60 \catcode60=12 +\chardef\>=\catcode62 \catcode62=12 +\chardef\`=\catcode96 \catcode96=12 +\edef\x{% + \endgroup + \def\noexpand\cptrestorecatcodes{% + \endlinechar=\number\E \catcode\number\e=\number\n + \catcode32=\number\s \catcode123=\number\l + \catcode125=\number\r \catcode37=\number\% + \catcode61=\number\= \catcode91=\number\[ + \catcode93=\number\] \catcode94=\number\^ + \catcode46=\number\. \catcode47=\number\/ + \catcode126=\number\~ \catcode38=\number\& + \catcode36=\number\$ \catcode95=\number\_ + \catcode43=\number\+ \catcode33=\number\! + \catcode39=\number\' \catcode40=\number\( + \catcode41=\number\) \catcode42=\number\* + \catcode44=\number\, \catcode45=\number\- + \catcode58=\number\: \catcode60=\number\< + \catcode62=\number\> \catcode96=\number\` + }% +} +\x +\catcode37 14\relax\expandafter\iffalse\string\ +\fi\endlinechar13\catcode13 5 % +\catcode61\string=12 +\catcode32=10 +\catcode123=1 +\catcode125=2 +\catcode91=12 +\catcode93=12 +\catcode46=12 +\catcode47=12 +\catcode94=7 +\catcode126=13 +\chardef\cpt@xiipt=12 +\chardef\active=13 +\chardef\cpt@xciipt=92 +\ifx\@xp\expandafter\else\@ifdefinable\@xp{\let\@xp\expandafter}\fi +\NeedsTeXFormat{LaTeX2e}[1995/12/01] +\ProvidesPackage{catoptions} + [2011/01/01 v0.1 Preserving catcodes & parsing options (AM)] +\ifcase% + \ifx\eTeXversion\cpt@undefined\z@\else + \ifnum\eTeXversion<\tw@\z@\else\@ne\fi\fi + \PackageError{catoptions}{eTeX not loaded or old version}% + {This package requires eTeX version 2 or later.}% + \expandafter\endinput +\fi +\def\cptnormalcatcodes{% + \endlinechar13 + \catcode33=12\catcode34=12\catcode35=6\catcode36=3\catcode37=14 + \catcode38=4\catcode39=12\catcode40=12\catcode41=12\catcode42=12 + \catcode43=12\catcode44=12\catcode45=12\catcode46=12\catcode47=12 + \catcode58=12\catcode59=12\catcode60=12\catcode61=12\catcode62=12 + \catcode63=12\catcode91=12\catcode92=0\catcode93=12\catcode94=7 + \catcode95=8\catcode96=12\catcode123=1\catcode124=12\catcode125=2 + \catcode126=13\catcode32=10\catcode13=5\catcode9=10\catcode10=12 +} +\begingroup +\let\s\string +\escapechar\m@ne +\xdef\cpt@otherchars{% + \s\!\s\"\s\#\s\$\s\%\s\&\s\'\s\(\s\)\s\*\s+\s\,\s\-\s\.\s\/\s\:% + \s\;\s\<\s\=\s\>\s\?\s\[\s\\\s\]\s\^\s\_\s\`\s\{\s\|\s\}\s\~% +} +\endgroup +\newcommand*\BeginOverlookWhiteSpace{% + \edef\cpt@spacecatcode{\the\catcode`\ }% + \edef\cpt@tabcatcode{\the\catcode`\^^I}% + \chardef\cpt@endlinechar=\number\endlinechar + \catcode`\ =9\relax + \catcode`\^^I=9\relax + \endlinechar\m@ne +} +\newcommand*\EndOverlookWhiteSpace{% + \catcode`\ =\cpt@spacecatcode + \catcode`\^^I=\cpt@tabcatcode + \endlinechar\cpt@endlinechar +} +\def\cpt@catcodestack{} +\def\cptpushcatcodes{% + \begingroup + \def\x##1{% + \ifx##1\@nnil\else + \catcode\number`##1=\the\catcode`##1\relax + \expandafter\x + \fi + }% + \xdef\cpt@catcodestack{% + \expandafter\x\cpt@otherchars\ \ + \^^I\^^J\@nnil{\cpt@catcodestack}% + }% + \endgroup +} +\cptpushcatcodes +\cptnormalcatcodes +\def\cptpopcatcodes{% + \begingroup + \def\x##1##{\endgroup##1\xdef\cpt@catcodestack}% + \expandafter\x\cpt@catcodestack +} +\@ifdefinable\currentcatcodesubset\relax +\newcommand*\GetCurrentCatcodeSubset{% + \begingroup + \def\x##1{% + \ifx##1\cpt@nnil\else + \@space(\string##1\@firstofone{:\number\catcode`##1})% + \expandafter\x + \fi + }% + \edef\x{% + \def\noexpand\currentcatcodesubset{% + \x\^^I\^^J\^^L\^^M\ \!\"\#\$\%\&% + \'\(\)\*\+\,\-\.\/\:\;\<\=\>\?\@\[\\\]\^\_\`\{\}\|\~\cpt@nnil + }% + }% + \expandafter\endgroup\x +} +\def\cpt@fletmacros{} +\newcommand*\declarefutureletprefix[1]{% + \gdef\cpt@fletprefix{#1}% + \gdef\cpt@fletmacros{}% +} +\declarefutureletprefix{fl@} +\begingroup +\cptrestorecatcodes +\begingroup +\catcode`\3="3 \catcode`\4="4 \catcode`\7="7 \catcode`\8="8 +\catcode`\A="A \catcode`\B="B \catcode`\C="C \catcode`\D="D +\gdef\cpt@flet@a#1#2{% + \begingroup + \edef\cpt@tempa{\noexpandcsn{\cpt@fletprefix#1}}% + \edef\cpt@tempb{\noexpandcsn{if\cpt@fletprefix#1}}% + \oifinsetTF\cpt@tempa\cpt@fletmacros{}{% + \edef\x{\g@right@addto@macro\noexpand\cpt@fletmacros + {\expandcsonce\cpt@tempa\expandcsonce\cpt@tempb}}% + \x + }% + \lccode`\0=`#2\lccode`\3=`#2\lccode`\4=`#2\lccode`\6=`#2% + \lccode`\7=`#2\lccode`\8=`#2\lccode`\B=`#2\lccode`\C=`#2% + \lccode`\D=`#2% + \ifnum\catcode`#2=\active + \def\do##1{\noexpand\do\noexpand##1\noexpand}% + \lowercase{% + \xdef\cpt@activecharacters{% + \cpt@activecharacters + \do#2D% + }% + }% + \fi + \xdef\cpt@tempa{% + \let\noexpand\cpt@tempa\noexpand\cpt@undefined + \cptglet\expandcsonce\cpt@tempa= % + }% + \aftergroup\cpt@tempa + \lowercase{% + \expandafter\endgroup + \ifcase\numexpr\catcode`#2\relax + 0\or \bgroup\or \egroup\or 3\or 4\or 5\or 6\or 7\or + 8\or 9\or \@sptoken\or B\or C\else D\fi + }% +} +\endgroup +\gdef\cpt@futureletchars{% + space\@\ \@ exclam\@\!\@ dblquote\@\"\@ hash\@\#\@ dollar\@\$\@ + ampersand\@\&\@ rquote\@\'\@ lparen\@\(\@ rparen\@\)\@ star\@\*\@ + plus\@\+\@ comma\@\,\@ hyphen\@\-\@ period\@\.\@ slash\@\/\@ + colon\@\:\@ semicolon\@\;\@ less\@\<\@ equal\@\=\@ greater\@\>\@ + question\@\?\@ lbracket\@\[\@ rbracket\@\]\@ hat\@\^\@ + underscore\@\_\@ lquote\@\`\@ lbrace\@\{\@ vert\@\|\@ rbrace\@\}\@ + tilde\@\~\@ bslash\@\\\@ +} +\gdef\cptfutureletsetup{% + \gdef\cpt@activecharacters{}% + \def\cpt@flet@b##1\@##2\@{% + \ifx##1\end\else + \cpt@flet@a{##1}{##2}% + \expandafter\cpt@flet@b + \fi + }% + \def\cpt@fletundef##1\@##2\@{% + \ifx##1\end\else + \begingroup + \edef\x{\noexpandcsn{\cpt@fletprefix##1}}% + \expandafter\ifdefTF\x{% + \oifinsetTF\x\cpt@fletmacros{}{% + \cpt@err{Invalid futurelet prefix '\expandcsonce + \cpt@fletprefix'.\MsgBrk You can use + \string\declarefutureletprefix\space to select + \MsgBrk another prefix}\@ehc + }% + }{}% + \endgroup + \undef@csn{\cpt@fletprefix##1}% + \undef@csn{if\cpt@fletprefix##1}% + \expandafter\cpt@fletundef + \fi + }% + \def\cpt@fletdef##1\@##2\@{% + \ifx##1\end\else + \csn@xdef{if\cpt@fletprefix##1}####1{% + \noexpand\@nameuse{@\noexpand\ifx + \noexpandcsn{\cpt@fletprefix##1}% + ####1\unexpanded{\@empty first\else second\fi oftwo}}% + }% + \expandafter\cpt@fletdef + \fi + }% + \expandafter\cpt@fletundef\cpt@futureletchars\end\@\@ + \expandafter\cpt@fletdef\cpt@futureletchars\end\@\@ + \expandafter\cpt@flet@b\cpt@futureletchars\end\@\@ +} +\AtBeginDocument{\cptrestorecatcodes\cptfutureletsetup} +\gdef\futureletresetactives{% + \def\do##1##2{\let##1= ##2}% + \cpt@activecharacters + \let\do\relax +} +\endgroup + +\@ifdefinable\UseNormalCatcodes\relax +\protected\def\UseNormalCatcodes{% + \ifcsemptyF\@currname{% + \let\UseNormalCatcodes\relax + \cptpushcatcodes + \cptnormalcatcodes + \cptfutureletsetup + \AfterEndOfStyleFile{% + \cptpopcatcodes + \let\UseNormalCatcodes\rc@UseNormalCatcodes + }% + }% +} +\@ifdefinable\rc@UseNormalCatcodes\relax +\global\let\rc@UseNormalCatcodes\UseNormalCatcodes +\newcommand\cptswap[2]{#2#1} +\newcommand\cptswapfirstbraced[2]{#2{#1}} +\cptswap{ }{\let\@sptoken= } +\def\@space{ } +\long\def\@nameuse#1{\csname#1\endcsname} +\long\def\@gobblethree#1#2#3{} +\long\def\@firstofthree#1#2#3{#1} +\long\def\@secondofthree#1#2#3{#2} +\long\def\@thirdofthree#1#2#3{#3} +\let\@iden\@firstofone +\newcommand\@alloftwo[2]{#1#2} +\protected\def\cpt@nil{} +\def\cpt@nnil{\cpt@nil} +\long\def\cpt@car#1#2\car@nil{#1} +\long\def\cpt@cdr#1#2\cdr@nil{#2} +\long\def\remove@to@nnil#1\@nnil{} +\long\def\catch@to@nnil#1\@nnil{#1} +\long\def\remove@to@dot#1.{} +\long\def\catch@to@dot#1.{#1} +\@ifdefinable\cpt@rnm{\let\cpt@rnm\romannumeral} +\def\cpt@rmnstop{0 } +\def\cptthreexp{\expandafter\expandafter\expandafter} +\def\cptsevenxp{\expandafter\expandafter\expandafter + \expandafter\expandafter\expandafter\expandafter} +\protected\def\cptlocalxp#1{\begingroup\cptthreexp\endgroup#1} +\protected\def\cptlocalxpxp{\cptlocalxp\expandafter} +\newcommand*\cptzapspaces[1]{% + \def\cptzapspaces##1{% + \cpt@rnm0\cpt@zapspaces.\@space##1#1\cpt@nil + }% +} +\cptzapspaces{ } +\def\cpt@zapspaces#1 #2\cpt@nil{% + \@nameuse{@\ifx\\#2\\first\else second\fi oftwo}% + {\remove@to@dot#1}{% + \expandafter\cpt@zapspaces\expandafter + .\remove@to@dot#1#2\cpt@nil + }% +} +\@ifdefinable\kernel@for{\let\kernel@for\@for} +\@ifdefinable\newvariables\relax +\protected\def\newvariables#1#2#3{% + \@testopt{\cpt@newvariables{#1}{#2}{#3}}{}% +} +\protected\def\cpt@newvariables#1#2#3[#4]{% + \edef\cpt@tempb{\ifnum\pdfstrcmp{#1}{if}=\z@ if\fi}% + \kernel@for\cpt@tempa:=\cpt@rnm0\cptzapspaces{\@space#3}\do{% + \@nameuse{@\ifcsname\cpt@tempb#2\cpt@tempa\endcsname + first\else second\fi oftwo}% + {% + \edef\reserved@a{\cpt@tempb#2\cpt@tempa}\@notdefinable + }{% + \csname new#1\expandafter\endcsname\csname + \cpt@tempb#2\cpt@tempa\endcsname + \ifnum\pdfstrcmp{#1}{if}=\z@ + \ifx\\#4\\\def\cpt@tempc{false}\else\def\cpt@tempc{#4}\fi + \csname#2\cpt@tempa\cpt@tempc\endcsname + \else + \ifx\\#4\\\let\cpt@tempc\z@\else\def\cpt@tempc{#4}\fi + \csname#2\cpt@tempa\endcsname\cpt@tempc\relax + \fi + }% + }% +} +\newvariables{if}{cpt@}{st,pl,pm,verbose,usepox,optf,igopt, + inpox,olddx}\relax +\newvariables{if}{@}{iscounter,breakloop,choicefd,useempty, + checklistparser,userobustdespace}\relax +\newvariables{count}{cpt@}{depth,grouplevel,grouptype}\relax +\@ifdefinable\cptbreakloop{\let\cptbreakloop\@breaklooptrue} +\@ifdefinable\UseEmptyEntry{% + \protected\def\UseEmptyEntry{\global\@useemptytrue}} +\@ifdefinable\DiscardEmptyEntry{% + \protected\def\DiscardEmptyEntry{\global\@useemptyfalse}} +\@ifdefinable\UseRobustDespace{% + \protected\def\UseRobustDespace{\global\@userobustdespacetrue}} +\@ifdefinable\UseNormalDespace{% + \protected\def\UseNormalDespace{\global\@userobustdespacefalse}} +\newcommand*\MsgBrk{\MessageBreak} +\newcommand*\cptgetcatcode[1]{% + \number + \ifcat\noexpand#1\bgroup1\else + \ifcat\noexpand#1\egroup2\else + \ifcat\noexpand#1$3\else %$ + \ifcat\noexpand#1&4\else + \ifcat\noexpand#1##6\else + \ifcat\noexpand#1^7\else + \ifcat\noexpand#1_8\else + \ifcat\noexpand#1\@sptoken10\else + \ifcat\noexpand#1a11\else + \ifcat\noexpand#1!12\else + \ifcat\noexpand#1\noexpand~13\else + -1\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi +} +\newcommand\cptremovescape[1]{\expandafter\@gobble\string#1} +\newcommand\cptgobblescape[1]{% + \ifnum\escapechar>\@cclv\else + \ifnum\escapechar<\z@\else + \expandafter\expandafter + \csname @gobble\ifnum\escapechar=\@xxxii @space\fi + \cptthreexp\endcsname + \fi\fi + \string#1% +} +\newcommand\ifnullTF[1]{% + \@nameuse{@\ifnum\pdfstrcmp{}{\detokenize{#1}}% + =\z@ first\else second\fi oftwo}% +} +\newcommand\ifnullFT[1]{\ifnullTF{#1}\@secondoftwo\@firstoftwo} +\newcommand\ifnullT[1]{\ifnullTF{#1}\@firstofone\@gobble} +\newcommand\ifnullF[1]{\ifnullTF{#1}\@gobble\@firstofone} +\@ifdefinable\ifstremptyTF{\let\ifstremptyTF\ifnullTF} +\@ifdefinable\ifstremptyFT{\let\ifstremptyFT\ifnullFT} +\@ifdefinable\ifstremptyT{\let\ifstremptyT\ifnullT} +\@ifdefinable\ifstremptyF{\let\ifstremptyF\ifnullF} +\@ifdefinable\iftoksnullTF\relax +\def\iftoksnullTF#1#{% + \expandafter\ifnullTF\expandafter{\the#1}% +} +\newcommand\ifblankTF[1]{% + \@nameuse{@\ifnum\pdfstrcmp{}{\detokenize\expandafter + {\@gobble#1.}}=\z@ first\else second\fi oftwo}% +} +\newcommand\ifblankFT[1]{\ifblankTF{#1}\@secondoftwo\@firstoftwo} +\newcommand\ifblankT[1]{\ifblankTF{#1}\@firstofone\@gobble} +\newcommand\ifblankF[1]{\ifblankTF{#1}\@gobble\@firstofone} +\newcommand\oifblankTF[1]{\expandafter\ifblankTF\expandafter{#1}} +\newcommand\xifblankTF[1]{\cptfullexpandarg\ifblankTF{#1}} +\newcommand*\ifdefTF[1]{% + \@nameuse{@\ifdefined#1\ifx#1\relax second\else first\fi + \else second\fi oftwo}% +} +\newcommand*\ifdefFT[1]{\ifdefTF{#1}\@secondoftwo\@firstoftwo} +\newcommand*\ifdefT[1]{\ifdefTF{#1}\@firstofone\@gobble} +\newcommand*\ifdefF[1]{\ifdefTF{#1}\@gobble\@firstofone} +\newcommand*\ifcsndefTF[1]{% + \ifcsname#1\endcsname + \expandafter\@firstofone + \else + \cptthreexp\@secondoftwo\expandafter\@gobble + \fi + {\cptaftercs\ifdefTF{#1}}% +} +\newcommand*\ifcsndefFT[1]{\ifcsndefTF{#1}\@secondoftwo\@firstoftwo} +\newcommand*\ifcsndefT[1]{\ifcsndefTF{#1}\@firstofone\@gobble} +\newcommand*\ifcsndefF[1]{\ifcsndefTF{#1}\@gobble\@firstofone} +\newcommand*\letnewcmd[2]{\ifcptdefinable{#1}{\let#1=#2}} +\newcommand*\ifcptdefinable[2]{% + \edef\reserved@a{\cptgobblescape#1}% + \ifdefTF{#1}{% + \@notdefinable + }{% + \ifcsndefTF{end\reserved@a}{% + \@notdefinable + }{% + #2% + }% + }% +} +\newcommand\cpt@def@[3]{% + \ifcptdefinable#3{% + \ifstremptyTF{#2}{}\protected + \cptthreexp\l@ngrel@x\@nameuse{#1def}#3% + }% +} +\ifcptdefinable\robust@def\relax +\protected\def\robust@def{\@star@or@long{\cpt@def@{}{p}}} +\robust@def*\new@def{\@star@or@long{\cpt@def@{}{}}} +\robust@def*\new@gdef{\@star@or@long{\cpt@def@{g}{}}} +\robust@def*\robust@gdef{\@star@or@long{\cpt@def@{g}{p}}} +\robust@def*\new@edef{\@star@or@long{\cpt@def@{e}{}}} +\robust@def*\robust@edef{\@star@or@long{\cpt@def@{e}{p}}} +\robust@def*\new@xdef{\@star@or@long{\cpt@def@{x}{}}} +\robust@def*\robust@xdef{\@star@or@long{\cpt@def@{x}{p}}} +\robust@def*\renew@def{\@star@or@long{\cpt@redef@{}}} +\robust@def*\robust@redef{\@star@or@long{\cpt@redef@{p}}} +\new@def*\cpt@redef@#1#2{% + \ifdefT#2{% + \ifcpt@verbose + \@latex@info{Command '\string#2' redefined}% + \fi + }% + \ifstrcmpTF{#1}{p}\protected\relax\l@ngrel@x\def#2% +} +\new@def*\ifcounterTF#1{% + \ifstrcmpTF{\count}{#1}\@secondoftwo{% + \expandafter\cpt@ifcounter@a\meaning#1:&% + }% +} +\edef\cpt@ifcounter@a#1#2{% + \def#1##1:##2&{#2##1\string\count&}% + \def#2##1\string\count##2&{\noexpand\ifblankTF{##1}}% +} +\cpt@ifcounter@a\cpt@ifcounter@a\cpt@ifcounter@b +\robust@def*\pushnumber#1{% + \ifdefTF#1{% + \edef#1{\the\numexpr#1+1}% + }{% + \let#1\@ne + }% +} +\robust@def*\popnumber#1{% + \ifdefTF#1{% + \ifnumTF#1=\z@{% + \let\relax\relax + \cpt@err{Number '\string#1' is already 0}\@ehc + }{% + \edef#1{\the\numexpr#1-1}% + }% + }{% + \let\relax\relax + \cpt@err{Number '\string#1' is undefined}\@ehc + }% +} +\robust@def*\pushcounter#1{% + \ifdefTF#1{% + \if@iscounter + \global\advance#1\@ne + \else + \ifcounterTF#1{% + \global\advance#1\@ne + }{% + \cpt@err{Number '\string#1' isn't a counter}\@ehc + }% + \fi + }{% + \@nameuse{newcount}#1% + }% + \@iscounterfalse +} +\robust@def*\popcounter#1{% + \ifdefTF#1{% + \ifnumTF#1=\z@{% + \cpt@err{Counter or number '\string#1' is already 0}\@ehc + }{% + \if@iscounter + \global\advance#1\m@ne + \else + \ifcounterTF#1{% + \global\advance#1\m@ne + }{% + \cpt@err{Number '\string#1' isn't a counter}\@ehc + }% + \fi + }% + }{% + \cpt@err{Counter '\string#1' is undefined}\@ehc + }% + \@iscounterfalse +} +\new@def*\push@rnarg#1{\@xp\cptremovescape\push@arg @\cpt@rnm#1} +\robust@def*\pushfunctions#1#2{% + \ifcounterTF#2{% + \@iscountertrue\pushcounter#2% + }{% + \global\pushnumber#2% + }% + \def\push@@do{\csn@let@cs{\push@rnarg{#2}}}% + \def\push@do{\expandafter\push@@do\push@arg}% + \let\rc@escapechar\escapechar\escapechar\cpt@xciipt + \pushingloop{#1}% + \escapechar\rc@escapechar +} +\robust@def*\popfunctions#1#2{% + \ifnum#2=\z@ + \cpt@err{Number '\string#2' is currently '0'}\@ehc + \fi + \def\push@do{% + \expandafter\cs@let@csn\push@arg{\push@rnarg{#2}}% + \undef@csn{\push@rnarg{#2}}% + }% + \let\rc@escapechar\escapechar\escapechar\cpt@xciipt + \pushingloop{#1}% + \escapechar\rc@escapechar + \ifcounterTF#2{% + \@iscountertrue\popcounter#2% + }{% + \global\popnumber#2% + }% +} +\robust@def*\pushingloop#1{\cpt@pushingloop#1,\cpt@nil,&} +\robust@def*\cpt@pushingloop#1,#2&{% + \edef\push@arg{\unexpanded{#1}}% + \ifxF\push@arg\cpt@nnil{% + \normal@despacecontent\push@arg + \push@do\relax\cpt@pushingloop#2&% + }% +} +\robust@def*\cpt@toodeep#1#2{% + \cpt@err{Command '\string#1' nested too deeply}% + {Sorry, but command '\string#1' can't be nested + \MsgBrk to depth(s) higher than #2.}% + \@gobble +} +\robust@def*\oneDloop{% + \let\Dlooptype\@ne\cpt@ifstar\oneDloop@b\oneDloop@a +} +\robust@def*\normaloneDloop{% + \let\Dlooptype\z@\cpt@ifstar\oneDloop@b\oneDloop@a +} +\robust@def*\getDlooptype{% + \ifx\Dlooptype\cpt@undefined\let\Dlooptype\@ne\fi +} +\robust@def*\oneDloop@b#1{% + \getDlooptype + \expandafter\oneDloop@a\expandafter{#1}% +} +\robust@def*\oneDloop@a#1#2#3{% + \getDlooptype + \pushnumber\oneDloopdepth + \ifnum\oneDloopdepth>\@ne\cpt@toodeep\oneDloop1\fi + \@breakloopfalse + \cpt@Dloop@a#1,\cpt@nil,{#3}% + \popnumber\oneDloopdepth +} +\robust@def*\xDloop{% + \let\Dlooptype\@ne\cpt@ifstar\xDloop@b\xDloop@a +} +\robust@def*\normalxDloop{% + \let\Dlooptype\z@\cpt@ifstar\xDloop@b\xDloop@a +} +\robust@def*\xDloop@b#1{% + \getDlooptype + \expandafter\xDloop@a\expandafter{#1}% +} +\robust@def\xDloop@a#1#2#3{% + \getDlooptype + \pushfunctions{#2,\if@useempty,\if@breakloop,\Dlooptype}\cpt@depth + \@breakloopfalse + \cpt@Dloop@a#1,\cpt@nil,{#3}% + \popfunctions{#2,\if@useempty,\if@breakloop,\Dlooptype}\cpt@depth +} +\robust@def\cpt@Dloop@a{% + \if@boolTF{@breakloop}{% + \defpass\gobble@remainder##1&##2##3{}% + }{% + \cpt@Dloop@b.% + }% +} +\robust@def\cpt@Dloop@b#1,#2#4{% + \edef#3{\expandcsonce{\remove@to@dot#1}}% + \ifxF#3\cpt@nnil{% + \ifcsemptyTF#3{% + \if@useempty#4\relax\fi + }{% + \@nameuse{\ifnum\Dlooptype=\z@ normal\else robust\fi + @despacecontent}#3% + #4\relax + }% + \cpt@Dloop@a#2{#4}% + }% +} +\robust@def*\foreachitem{\cpt@testst\cpt@foreach} +\newcommand\cpt@foreach[4][,]{% + \pushfunctions{#3,\if@useempty,\if@breakloop, + \if@userobustdespace}\cpt@depth + \@breakloopfalse + \ifcpt@st\let#3#2\else\edef#3{\unexpanded{#2}}\fi + \long\def\cpt@foreach@a{% + \if@boolTF{@breakloop}{% + \defpass\gobble@remainder####1&####2####3{}% + }{% + \cpt@foreach@b.% + }% + }% + \long\def\cpt@foreach@b##1#1##2&##3##4{% + \edef##3{\expandcsonce{\remove@to@dot##1}}% + \ifxF##3\cpt@nnil{% + \ifcsemptyTF##3{% + \if@useempty##4\relax\fi + }{% + \@nameuse{\if@userobustdespace robust\else normal\fi + @despacecontent}##3% + ##4\relax + }% + \cpt@foreach@a##2&##3{##4}% + }% + }% + \expandafter\cpt@foreach@a#3#1\cpt@nil#1{#4}% + \popfunctions{#3,\if@useempty,\if@breakloop, + \if@userobustdespace}\cpt@depth + \UseNormalDespace +} +\robust@def*\oneDfifo{\cpt@teststoptb\cpt@oneDfifo} +\robust@def*\cpt@oneDfifo[#1]#2{% + \declarefifoparser{#1}% + \pushnumber\oneDfifodepth + \ifnum\oneDfifodepth>\@ne\cpt@toodeep\oneDfifo1\fi + \@breakloopfalse + \begingroup + \if@boolTF{cpt@st}% + {\let\cpt@tempa#2}{\edef\cpt@tempa{\unexpanded{#2}}}% + \expandafter\endgroup\expandafter\cpt@fifoloop@a + \cpt@tempa#1\cpt@nil#1% + \popnumber\oneDfifodepth +} +\robust@def*\xDfifo{\cpt@teststoptb\cpt@xDfifo} +\robust@def*\cpt@xDfifo[#1]#2{% + \declarefifoparser{#1}% + \pushfunctions{\fifo@do,\if@breakloop,\if@useempty}\cpt@depth + \@breakloopfalse + \begingroup + \if@boolTF{cpt@st}% + {\let\cpt@tempa#2}{\edef\cpt@tempa{\unexpanded{#2}}}% + \expandafter\endgroup\expandafter\cpt@fifoloop@a + \cpt@tempa#1\cpt@nil#1% + \popfunctions{\fifo@do,\if@breakloop,\if@useempty}\cpt@depth +} +\robust@def*\declarefifoparser#1{% + \protected\def\cpt@fifoloop@a{% + \if@boolTF{@breakloop}{% + \defpass\gobble@remainder####1\cpt@nil#1{}% + }{% + \cpt@fifoloop@b.% + }% + }% + \protected\def\cpt@fifoloop@b##1#1{% + \edef\fifo@arg{\expandcsonce{\@gobble##1}}% + \ifxF\fifo@arg\cpt@nnil{% + \ifcsemptyTF\fifo@arg{% + \if@boolT{@useempty}{\fifo@do{}\relax}% + }{% + \expandafter\fifo@do\expandafter{\fifo@arg}\relax + }% + \cpt@fifoloop@a + }% + }% +} +\robust@def*\oneDsiso{\cpt@testst\cpt@oneDsiso} +\robust@def\cpt@oneDsiso#1{% + \pushnumber\oneDsisodepth + \ifnum\oneDsisodepth>\@ne\cpt@toodeep\oneDsiso1\fi + \@breakloopfalse + \begingroup + \if@boolTF{cpt@st}% + {\let\cpt@tempa#1}{\edef\cpt@tempa{\unexpanded{#1}}}% + \expandafter\endgroup\expandafter\cpt@sisoloop\cpt@tempa\sisorepeat + \popnumber\oneDsisodepth +} +\robust@def*\xDsiso{\cpt@testst\cpt@xDsiso} +\robust@def\cpt@xDsiso#1{% + \pushfunctions{\siso@do,\if@useempty,\if@breakloop}\cpt@depth + \@breakloopfalse + \begingroup + \ifcpt@st\let\cpt@tempa#1\else\edef\cpt@tempa{\unexpanded{#1}}\fi + \expandafter\endgroup\expandafter\cpt@sisoloop\cpt@tempa\sisorepeat + \popfunctions{\siso@do,\if@useempty,\if@breakloop}\cpt@depth +} +\robust@def*\cpt@sisoloop{% + \if@boolTF{@breakloop}{% + \defpass\gobble@remainder##1\sisorepeat{}% + }{% + \begingroup + \let\@bgroup\bgroup + \let\bgroup\cpt@undefined + \futurelet\next\cpt@sisol@op + }% +} +\robust@def\cpt@sisol@op#1{% + \expandafter\endgroup + \ifx\next\@bgroup\def\siso@arg{{#1}}\else\def\siso@arg{#1}\fi + \ifblankTF{#1}{% + \if@useempty\siso@do{}\relax\fi + }{% + \ifx#1\sisorepeat\sisorepeat\fi + \expandafter\siso@do\expandafter{\siso@arg}\relax + }% + \cpt@sisoloop +} +\robust@def\sisorepeat#1\cpt@sisoloop{\fi}% +\robust@def*\csv@@parse{% + \let\csv@kv@nr\z@ + \cpt@teststoptb\csv@kv@parse +} +\robust@def*\kv@@parse{% + \let\csv@kv@nr\@ne + \cpt@teststoptb\csv@kv@parse +} +\newcommand\csv@kv@parse[2][,]{% + \cs@let@csn\csv@kv@do{\ifnum\csv@kv@nr=\z@ csv\else kv\fi @do}% + \ifdefF\csv@kv@do{% + \cpt@err{'\string\csv@do' or '\string\kv@do' undefined}\@ehc + }% + \long\def\csv@tempa{% + \if@boolTF{@breakloop}{% + \defpass\gobble@remainder####1\cpt@nil#1{}% + }{% + \csv@tempb.% + }% + }% + \long\def\csv@tempb##1#1{% + \edef\csv@tempc{\expandcsonce{\remove@to@dot##1}}% + \ifxF\csv@tempc\cpt@nnil{% + \ifcsemptyTF\csv@tempc{% + \if@boolT{@useempty}{\csv@kv@do{}}\relax + }{% + \expandafter\csv@kv@do\expandafter{\csv@tempc}\relax + }% + \csv@tempa + }% + }% + \if@boolTF{cpt@st}% + {\let\csv@tempc#2}{\edef\csv@tempc{\unexpanded{#2}}}% + \ifcsemptyF\csv@tempc{% + \@nameuse{\ifnum\csv@kv@nr=\@ne kv\else csv\fi @@normalize}% + *[#1]\csv@tempc + }% + \pushfunctions{\csv@kv@do,\if@useempty,\if@breakloop}\cpt@depth + \@breakloopfalse + \expandafter\csv@tempa\csv@tempc#1\cpt@nil#1% + \popfunctions{\csv@kv@do,\if@useempty,\if@breakloop}\cpt@depth +} +\robust@def*\on@currlevel#1#2{% + \ifdefTF\curr@level{% + \ifnum\curr@level=\z@ + \cpt@err{'\string\curr@level' is zero}{% + I can't do anything on zero current level.}% + \fi + }{% + \cpt@err{'\string\curr@level' undefined}\@ehc + }% + \@fullxpsec + {#1}{\noexpandcsn{\cptgobblescape#2@\cpt@rnm\curr@level}}% +} +\new@def\cptafterfi#1\fi{\fi#1} +\new@def\cptafterelsefi#1\else#2\fi{\fi#1} +\new@def\cptafterfifi#1\fi#2\fi{\fi\fi#1} +\robust@def*\cptemptify#1{\let#1\@empty} +\new@def*\ifcsemptyTF#1{% + \@nameuse{@\ifx#1\@empty first\else second\fi oftwo}% +} +\robust@def*\cptemptifycsset#1{% + \normaloneDloop{#1}\cpt@tempa{% + \expandafter\def\cpt@tempa{}% + }% +} +\new@def*\ifcsemptyFT#1{\ifcsemptyTF{#1}\@secondoftwo\@firstoftwo} +\new@def*\ifcsemptyT#1{\ifcsemptyTF{#1}\@firstofone\@gobble} +\new@def*\ifcsemptyF#1{\ifcsemptyTF{#1}\@gobble\@firstofone} +\new@def*\oifcsemptyTF#1{\expandafter\ifcsemptyTF#1} +\new@def*\oifcsemptyFT#1{\expandafter\ifcsemptyFT#1} +\new@def*\oifcsemptyT#1{\expandafter\ifcsemptyT#1} +\new@def*\oifcsemptyF#1{\expandafter\ifcsemptyF#1} +\new@def*\ifcsnemptyTF#1{% + \ifcsndefTF{#1}{% + \expandafter\ifx\csname#1\endcsname\@empty + \expandafter\@firstoftwo + \else + \expandafter\@secondoftwo + \fi + }{% + \@secondoftwo + }% +} +\new@def*\ifcsnemptyFT#1{\ifcsnemptyTF{#1}\@secondoftwo\@firstoftwo} +\new@def*\ifcsnemptyT#1{\ifcsnemptyTF{#1}\@firstofone\@gobble} +\new@def*\ifcsnemptyF#1{\ifcsnemptyTF{#1}\@gobble\@firstofone} +\new@def*\ifdefnotnullTF#1{% + \ifdefTF{#1}{\ifcsemptyTF{#1}{\@secondoftwo}% + {\@firstoftwo}}{\@secondoftwo}% +} +\new@def*\ifdefnotnullFT#1{\ifdefnotnullTF{#1}\@secondoftwo\@firstoftwo} +\new@def*\ifdefnotnullT#1{\ifdefnotnullTF{#1}\@firstofone\@gobble} +\new@def*\ifdefnotnullF#1{\ifdefnotnullTF{#1}\@gobble\@firstofone} +\new@def*\expandcsonce#1{\unexpanded\expandafter{#1}} +\new@def*\expandcsnonce#1{\cptthreexp\expandcsonce\@nameuse{#1}} +\new@def*\noexpandcsn#1{\expandcsonce{\csname#1\endcsname}} +\new@def*\cptxpdetok#1{\detokenize\expandafter{#1}} +\robust@def\cptpassexpanded#1{% + \begingroup\protected@edef\x{\endgroup#1}\x +} +\robust@def\cptpassunexpanded#1{\begingroup\long\def\x{\endgroup#1}\x} +\robust@def\defpass#1#2#{\afterassignment#1\long\def#1#2} +\robust@def\edefpass#1#2#{\afterassignment#1\long\edef#1#2} +\robust@def*\cptfullexpandsecond#1#2{\cptpassexpanded{\unexpanded{#1}#2}} +\robust@def*\cptexpandsecondonce#1#2{% + \cptpassexpanded{\unexpanded{#1}\expandcsonce{#2}}} +\robust@def*\cptfullexpandarg#1#2{\cptpassexpanded{\unexpanded{#1}{#2}}} +\robust@def*\cptexpandargonce#1#2{% + \cptpassexpanded{\unexpanded{#1}{\expandcsonce{#2}}}% +} +\robust@def*\protected@xptwoargs#1#2#3{% + \begingroup + \protected@edef\x{\endgroup\unexpanded{#1}{#2}{#3}}\x +} +\robust@def*\cptexpandtwoargsonce#1#2#3{% + \cptpassexpanded{% + \unexpanded{#1}{\expandcsonce{#2}}{\expandcsonce{#3}}}% +} +\letnewcmd\@xpargox\cptexpandargonce +\letnewcmd\@fullxparg\cptfullexpandarg +\letnewcmd\@xpsecox\cptexpandsecondonce +\letnewcmd\@fullxpsec\cptfullexpandsecond +\letnewcmd\@xptwoargox\cptexpandtwoargsonce +\robust@def*\StyleFileRCSInfo$#1 #2 #3 #4 #5 #6 #7 #8 ${% + \def\cpt@filedate{#4}% + \def\cpt@fileversion{v#3}% + \def\cpt@filetime{#5}% + \def\cpt@fileauthor{#6\@space#7}% +} +\new@def*\cpt@filedesc{} +\defpass\cpt@tempa#1{% + \robust@def*\StyleFilePurpose##1{% + \gdef\cpt@filedesc{##1#1(\cpt@fileauthor)}% + }% +}{ } +\new@def*\StyleFileInfo{% + \cpt@filedate\@space\cpt@fileversion\@space\cpt@filedesc +} +\robust@def*\SetStyleFileMessages{% + \begingroup + \catcode`\ =9\catcode`\^^I=9% + \edef\cpt@tempa{\@xp\@carcube\@currname\@nil @}% + \def\cpt@tempb{\@testopt{\@xp\endgroup\cpt@SetStyleFileMessages}}% + \@xp\cpt@tempb\@xp{\cpt@tempa}% +} +\robust@def*\cpt@SetStyleFileMessages[#1]#2#3#4{% + \begingroup + \def\cpt@tempa##1{\noexpandcsn{##1}}% + \protected\def\cpt@tempb{\global\protected\@namedef}% + \edef\cpt@tempc{\ifx\@currext\@pkgextension Package\else Class\fi}% + \@tempswafalse + \kernel@for\cpt@rsvda:={#2,#3,#4}\do{% + \ifcsname#1\cpt@rsvda\endcsname + \@tempswatrue\let\cpt@rsvdb\cpt@rsvda + \fi + }% + \if@tempswa + \def\reserved@a{#1\cpt@rsvdb}\@notdefinable + \else + \cptpassexpanded{% + \cpt@tempb{#1#2}####1{\cpt@tempa{\cpt@tempc Info}% + {\@currname}{####1\noexpand\@gobble}}% + \cpt@tempb{#1#3}####1{\cpt@tempa{\cpt@tempc WarningNoLine}% + {\@currname}{####1}}% + \cpt@tempb{#1#4}####1####2{\cpt@tempa{\cpt@tempc Error}% + {\@currname}{####1}{####2}}% + }% + \fi + \endgroup + \interactionmode\thr@@ +} +\SetStyleFileMessages[cpt@]{info}{warn}{err} +\robust@def*\cpt@begingroup{% + \begingroup + \cpt@grouplevel\currentgrouplevel + \cpt@grouptype\currentgrouptype +} +\robust@def*\cpt@endgroup{% + \ifnum\cpt@grouptype=\currentgrouptype + \ifnum\cpt@grouplevel=\currentgrouplevel\else + \cpt@err{There is a group level mismatch}\@ehc + \aftergroup\showgroups + \fi + \else + \cpt@err{There is a group type mismatch}\@ehc + \aftergroup\showgroups + \fi + \endgroup +} +\new@def*\ifboolTF#1{% + \ifcsndefTF{if#1}{% + \if@boolTF{#1}% + }{% + \cpt@err{Boolean '\usecsn{#1}' undefined}\@ehc + }% +} +\new@def*\ifboolFT#1{\ifboolTF{#1}\@secondoftwo\@firstoftwo} +\new@def*\ifboolT#1{\ifboolTF{#1}\@firstofone\@gobble} +\new@def*\ifboolF#1{\ifboolTF{#1}\@gobble\@firstofone} +\new@def*\ifbooleanTF#1#{\ifboolTF{#1}} +\new@def*\if@boolTF#1{% + \@nameuse{if#1}\expandafter\@firstoftwo\else + \expandafter\@secondoftwo\fi +} +\new@def*\if@boolFT#1{\if@boolTF{#1}\@secondoftwo\@firstoftwo} +\new@def*\if@boolT#1{\if@boolTF{#1}\@firstofone\@gobble} +\new@def*\if@boolF#1{\if@boolTF{#1}\@gobble\@firstofone} +\new@def*\ifnumTF#1#{% + \@nameuse{@\ifnum#1first\else second\fi oftwo}% +} +\new@def*\ifnumT#1#{\ifnumTF#1{\@firstofone}\@gobble} +\new@def*\ifnumF#1#{\ifnumTF#1{\@gobble}\@firstofone} +\new@def*\ifnumFT#1#{\@nameuse{@\ifnumTF#1{second}{first}oftwo}} +\robust@def*\cptnumdef#1#2{\edef#1{\the\numexpr#2}} +\robust@def*\cptdimdef#1#2{\edef#1{\the\dimexpr#2}} +\robust@def*\cptnumadd#1#2{\edef#1{\the\numexpr#1+#2}} +\robust@def*\cptdimadd#1#2{\edef#1{\the\dimexpr#1+#2}} +\new@edef*\@leftbracechar{\@xp\@car\string{\@nil\iffalse}\fi} +\long\def\cptstrcmp#1#2{% + \ifnum\pdfstrcmp{#1}{#2}=\z@\@xp\@firstoftwo\else + \@xp\@secondoftwo\fi +} +\new@def\ifstrcmpTF#1#2{% + \cptstrcmp{\detokenize{#1}}{\detokenize{#2}}% +} +\new@def\ifstrcmpFT#1#2{\ifstrcmpTF{#1}{#2}\@secondoftwo\@firstoftwo} +\new@def\ifstrcmpT#1#2{\ifstrcmpTF{#1}{#2}\@firstofone\@gobble} +\new@def\ifstrcmpF#1#2{\ifstrcmpTF{#1}{#2}\@gobble\@firstofone} +\long\def\ifbracedTF#1{% + \cptstrcmp{\detokenize\@xp{\@gobble#1.}}{}\@secondoftwo{% + \cptstrcmp{\detokenize\@xp{\@gobble#1}}{}{% + \cptstrcmp{\@xp\cpt@car\detokenize{#1}\car@nil}{\@leftbracechar}% + \@firstoftwo\@secondoftwo + }{% + \@secondoftwo + }% + }% +} +\newcommand\ifbracedFT[1]{\ifbracedTF{#1}\@secondoftwo\@firstoftwo} +\newcommand\ifbracedT[1]{\ifbracedTF{#1}\@firstofone\@gobble} +\newcommand\ifbracedF[1]{\ifbracedTF{#1}\@gobble\@firstofone} +\long\def\ifleftbracedTF#1{% + \cptstrcmp{\detokenize\@xp{\@gobble#1.}}{}\@secondoftwo{% + \cptstrcmp{\@xp\@car\detokenize{#1}\@nil}{\@leftbracechar}% + \@firstoftwo\@secondoftwo + }% +} +\new@def\ifxTF#1#2{% + \@nameuse{@\ifx#1#2\@empty first\else second\fi oftwo}% +} +\new@def\ifxFT#1#2{\ifxTF{#1}{#2}\@secondoftwo\@firstoftwo} +\new@def\ifxT#1#2{\ifxTF{#1}{#2}\@firstofone\@gobble} +\new@def\ifxF#1#2{\ifxTF{#1}{#2}\@gobble\@firstofone} +\new@def*\ifcptdefeqTF#1#2{% + \ifdefTF{#1}{% + \ifdefTF{#2}{% + \@nameuse{@\ifx#1#2first\else second\fi of oftwo}% + }\@secondoftwo + }\@secondoftwo +} +\new@def\ifcatTF#1#{% + \@nameuse{@\ifcat#1first\else second\fi oftwo}% +} +\new@def\ifcharcmpTF#1#2{% + \ifcptonetokenTF{#1}{% + \ifcptonetokenTF{#2}{% + \@nameuse{@\if\detokenize\@xp{\cpt@rnm\@xp + \cptswap\@xp{\cpt@rnm-`\q#2}{-`\q#1}}% + first\else second\fi oftwo}% + }{% + \cpt@err{More than one token in '\detokenize{#2}'}\@ehc + \@secondoftwo + }% + }{% + \cpt@err{More than one token in '\detokenize{#1}'}\@ehc + \@secondoftwo + }% +} +\new@def\ifcharcmpFT#1#2{\ifcharcmpTF{#1}{#2}\@secondoftwo\@firstoftwo} +\new@def\ifcharcmpT#1#2{\ifcharcmpTF{#1}{#2}\@firstofone\@gobble} +\new@def\ifcharcmpF#1#2{\ifcharcmpTF{#1}{#2}\@gobble\@firstofone} +\new@def\ifcptonetokenTF#1{% + \ifblankTF{#1}\@secondoftwo{% + \ifbracedTF{#1}\@secondoftwo{% + \expandafter\ifstremptyTF\expandafter{\@gobble#1}% + }% + }% +} +\robust@def*\cpt@checklistparser#1#2{% + \ifcptonetokenTF{#1}% + {#2}{\cpt@err{Invalid list parser '#1'}\@ehc}% +} +\robust@def\exitgroupdef#1{% + \cptpassexpanded{\endgroup\edef + \noexpand#1{\noexpand\unexpanded{\expandcsonce#1}}}% +} +\robust@def*\cptaftergroup#1{% + \advance\@tempcnta\@ne + \csn@xdef{cpt@exitgroup@\cpt@rnm\@tempcnta}{% + \global\undef@csn{cpt@exitgroup@\cpt@rnm\@tempcnta}% + \unexpanded\ifnullF{#1}\expandafter{#1}% + }% + \cptaftercs\aftergroup{cpt@exitgroup@\cpt@rnm\@tempcnta}% +} +\robust@def\cptafterassignment#1{% + \begingroup + \advance\@tempcnta\@ne + \csn@xdef{cpt@afterassignment@\cpt@rnm\@tempcnta}{% + \global\undef@csn{cpt@afterassignment@\cpt@rnm\@tempcnta}% + \unexpanded\ifnullF{#1}\expandafter{#1}% + }% + \expandafter\endgroup\expandafter\afterassignment + \csname cpt@afterassignment@\cpt@rnm\@tempcnta\endcsname +} +\robust@def\cptdefxppass#1#2#{% + \cptafterassignment{\expandafter#1}\def#1#2% +} +\robust@def\defsec@fir#1#2{\edef#2{\unexpanded{#1}}} +\robust@def\cpt@ifnextchar#1#2#3{% + \kernel@ifnextchar\bgroup + {\kernel@ifnextchar{#1}{#2}{#3}}% + {\cpt@ifn@xtchar{#1}{#2}{#3}}% +} +\robust@def\cpt@ifn@xtchar#1#2#3#4{% + \csname @\if\detokenize{#1#4}first\else + second\fi oftwo\endcsname{#2}{#3}#4% +} +\robust@def\cpt@testopt#1#2{\cpt@ifnextchar[{#1}{#1[{#2}]}} +\robust@def*\cpt@ifbrack#1#2{\cpt@ifnextchar[{#1}{#2}} +\new@def*\cpt@xtestopt#1#2#3{\cpt@xifbrack#1&[&{#2#1}{#2[{#3}]{#1}}} +\new@def*\cpt@xifbrack#1[#2#{% + \@nameuse{@\ifnullTF{#1#2}{first}{second}oftwo}% +} +\robust@def\cpt@testparenopt#1#2{\cpt@ifnextchar({#1}{#1({#2})}} +\robust@def\cpt@ifstar#1{\cpt@ifnextchar*{\@firstoftwo{#1}}} +\robust@def\cpt@ifplus#1{\cpt@ifnextchar+{\@firstoftwo{#1}}} +\robust@def\cpt@ifprime#1{\cpt@ifnextchar'{\@firstoftwo{#1}}} +\robust@def\cpt@testst#1{\cpt@ifstar{\cpt@sttrue#1}{\cpt@stfalse#1}} +\robust@def\cpt@testpl#1{\cpt@ifplus{\cpt@pltrue#1}{\cpt@plfalse#1}} +\robust@def\cpt@teststpl#1{\cpt@testst{\cpt@testpl{#1}}} +\robust@def\cpt@testpm#1{\cpt@ifprime{\cpt@pmtrue#1}{\cpt@pmfalse#1}} +\robust@def\cpt@teststpm#1{\cpt@testst{\cpt@testpm{#1}}} +\robust@def\cpt@teststopta#1{\cpt@testst{\cpt@testopt{#1}{}}} +\robust@def\cpt@teststoptb#1{\cpt@testst{\cpt@testopt{#1}{,}}} +\new@def*\cptifstrcase#1{\cpt@xtestopt{#1}\cpt@ifstrcase{}} +\new@def\cpt@ifstrcase[#1]#2#3{% + \expandafter\cptswapfirstbraced\expandafter{#2}% + {\cpt@ifstrc@se#3\cpt@mil\cpt@mil\cpt@nil}{#1}% +} +\new@def\cpt@ifstrc@se#1#2#3\cpt@nil#4#5{% + \ifstremptyTF{#3}{#5}{% + \ifstrcmpTF{#1}{#4}{#2}{% + \cpt@ifstrc@se#3\cpt@nil{#4}{#5}% + }% + }% +} +\robust@def\ifinsetTF#1#2{% + \begingroup + \def\in@@##1#1##2##3\in@@{\endgroup + \ifx##2\in@\in@false\else\in@true\fi + }% + \in@@#2{\in@@}#1\in@\in@@ + \ifin@\@xp\@firstoftwo\else\@xp\@secondoftwo\fi +} +\robust@def\ifinsetFT#1#2{\ifinsetTF{#1}{#2}\@secondoftwo\@firstoftwo} +\robust@def\ifinsetT#1#2{\ifinsetTF{#1}{#2}\@firstofone\@gobble} +\robust@def\ifinsetF#1#2{\ifinsetTF{#1}{#2}\@gobble\@firstofone} +\robust@def\oifinsetTF#1#2{% + \begingroup + \edef\cpt@tempa{{\expandcsonce{#1}}{\expandcsonce{#2}}}% + \expandafter\endgroup\expandafter\ifinsetTF\cpt@tempa +} +\robust@def\oifinsetFT#1#2{\oifinsetTF{#1}{#2}\@secondoftwo\@firstoftwo} +\robust@def\oifinsetT#1#2{\oifinsetTF{#1}{#2}\@firstofone\@gobble} +\robust@def\oifinsetF#1#2{\oifinsetTF{#1}{#2}\@gobble\@firstofone} +\robust@def\xifinsetTF#1#2{% + \begingroup + \protected@edef\cpt@tempa{{#1}{#2}}% + \expandafter\endgroup\expandafter\ifinsetTF\cpt@tempa +} +\robust@def\xifinsetFT#1#2{\xifinsetTF{#1}{#2}\@secondoftwo\@firstoftwo} +\robust@def\xifinsetT#1#2{\xifinsetTF{#1}{#2}\@firstofone\@gobble} +\robust@def\xifinsetF#1#2{\xifinsetTF{#1}{#2}\@gobble\@firstofone} +\robust@def*\kill@one@element{\cpt@testopt\cpt@killoneelement{,}} +\robust@def\cpt@killoneelement[#1]#2#3{% + \if@checklistparser\cpt@checklistparser{#1}\relax\fi + \begingroup + \@onelevel@sanitize#3% + \edef\cpt@rsvda{\detokenize{#2}}% + \cpttrimparser[#1]\cpt@rsvda + \cptpassexpanded{\unexpanded{\def\cpt@rsvdb##1#1}\cpt@rsvda}% + #1##2\cpt@nil{##1#1##2\cpt@mil}% + \def\cpt@rsvdc##1#1\cpt@mil##2\cpt@mil{\ifx#1##1\@empty\else##1\fi}% + \cptpassexpanded{\edef\noexpand#3{\unexpanded{\expandafter\cpt@rsvdc + \cpt@rsvdb}#1#3#1\noexpand\cpt@mil#1\cpt@rsvda#1\cpt@nil}}% + \exitgroupdef#3% + \cptscantokens#3% +} +\def\cptkillelements{\cpt@testopt\cpt@killelements{,}} +\def\cpt@killelements[#1]#2#3{% + \def\kill@tempa{#2}% + \csv@@normalize*\kill@tempa + \csv@@normalize*#3% + \@checklistparserfalse + \def\fifo@do##1{\cpt@killoneelement[#1]{##1}#3}% + \oneDfifo*\kill@tempa + \undef@cs\kill@tempa + \@checklistparsertrue +} + +\def\remove@one@element{\cpt@testopt\cpt@removeoneelement{,}} +\def\cpt@removeoneelement[#1]#2#3{% + \if@checklistparser\cpt@checklistparser{#1}\relax\fi + \begingroup + \def\cpt@removeone##1#1#2#1##2\remove@nil{% + \gdef#3{##1#1##2}% + \xifinsetT{\remove@nil#1}{\remove@nil\expandcsonce{#3}}{% + \def\cpt@removeone#1####1\remove@nil{\gdef#3{####1}}% + \expandafter\cpt@removeone#3\remove@nil + }% + \xifinsetT{#1\remove@nil}{\expandcsonce{#3}\remove@nil}{% + \def\cpt@removeone####1#1\remove@nil{\gdef#3{####1}}% + \expandafter\cpt@removeone#3\remove@nil + }% + }% + \xifinsetT{#1\unexpanded{#2}#1}{#1\expandcsonce{#3}#1}{% + \protected\def\remove@nil{}% + \expandafter\cpt@removeone\expandafter#1#3#1\remove@nil + }% + \endgroup +} +\def\cptremoveelements{\cpt@testopt\cpt@removeelements{,}} +\def\cpt@removeelements[#1]#2#3{% + \def\remove@tempa{#2}% + \csv@@normalize*\remove@tempa + \csv@@normalize*#3% + \@checklistparserfalse + \def\fifo@do##1{\cpt@removeoneelement[#1]{##1}#3}% + \oneDfifo*\remove@tempa + \undef@cs\remove@tempa + \@checklistparsertrue +} +\robust@def*\preservebracedefQ#1#2{% + \def\preserve@prefix{#1}% + \def\preserve@delimiter{#2}% +} +\preservebracedefQ{\long}{\@nil} +\robust@def*\preservebracedef#1{% + \cpt@preservebracedef + \cpt@pr@servebracedef#1.% +} +\robust@def*\PreserveBraceDef#1#2{% + \cpt@preservebracedef + \long\edef\preserve@after{\unexpanded{#1}}% + \afterassignment\preserve@after + \cpt@pr@servebracedef#2.% +} +\robust@def*\cpt@preservebracedef{% + \begingroup + \def\x{\endgroup\preserve@prefix + \def\cpt@pr@servebracedef####1####2}% + \expandafter\x\preserve@delimiter{% + \preserve@prefix\edef##1{% + \unexpanded\expandafter{\remove@to@dot##2}% + }% + }% +} +\robust@def*\cptglet{\global\let} +\robust@def*\csn@def#1{\cptthreexp\def\@nameuse{#1}} +\robust@def*\csn@gdef#1{\cptthreexp\gdef\@nameuse{#1}} +\robust@def*\csn@edef#1{\cptthreexp\edef\@nameuse{#1}} +\robust@def*\csn@xdef#1{\cptthreexp\xdef\@nameuse{#1}} +\robust@def*\csn@let@cs#1{\cptthreexp\let\@nameuse{#1}} +\robust@def*\cs@let@csn#1#2{% + \begingroup\expandafter\endgroup\expandafter + \let\expandafter#1\csname#2\endcsname +} +\robust@def*\csn@let@csn#1#2{% + \begingroup\expandafter\endgroup + \expandafter\let\csname#1\expandafter + \endcsname\csname#2\endcsname +} +\new@def\cptaftercs#1#2{% + \expandafter\cptswap\expandafter{\csname#2\endcsname}{#1}% +} +\new@def\cptuse#1{\ifcsndefTF{#1}{\@nameuse{#1}}{}} +\robust@def*\cptglobalize#1{\cptglet#1#1} +\robust@def*\undef@cs#1{\let#1\@undefined} +\robust@def*\undef@csn#1{\cptthreexp\undef@cs\@nameuse{#1}} +\robust@def*\undef@csset{\cpt@testst\cpt@undefcsset} +\robust@def*\cpt@undefcsset#1{% + \ifcpt@st\let\cpt@tempa#1\else\def\cpt@tempa{#1}\fi + \normaloneDloop*\cpt@tempa\cpt@tempa{% + \expandafter\ifcptescapedTF\cpt@tempa{% + \expandafter\undef@cs\cpt@tempa + }{% + \cpt@err{I can't find escape in token + '\cptxpdetok\cpt@tempa'}\@ehc + }% + }% +} +\robust@def*\cpttrimparser{\cpt@testopt\cpt@trimparser{,}} +\robust@def\cpt@trimparser[#1]#2{% + \begingroup + \def\cpt@trimb{% + \xifinsetT{#1\cpt@nil}{\cptxpdetok{#2}\cpt@nil}{% + \def\cpt@trimc####1#1\cpt@nil{% + \edef#2{\expandcsonce{\@gobble####1}}% + \cpt@trimb + }% + \expandafter\cpt@trimc\expandafter.#2\cpt@nil + }% + }% + \defpass\cpt@trima{% + \xifinsetTF{\cpt@nil#1}{\cpt@nil\cptxpdetok{#2}}{% + \def\cpt@trimc#1####1\cpt@nil{% + \edef#2{\unexpanded{####1}}% + \cpt@trima + }% + \expandafter\cpt@trimc#2\cpt@nil + }{% + \cpt@trimb + }% + }% + \exitgroupdef#2% +} +\robust@def*\stripouterbraces{\cpt@testopt\cpt@stripouterbraces\@ne} +\robust@def\cpt@stripouterbraces[#1]{% + \begingroup + \def\after@def##1##2##3{\exitgroupdef{##3}}% + \let\nr\z@ + \catcode`\{=1 + \catcode`\}=2 + \catcode`\#=6 + \cpt@str@pouterbraces{#1}% +} +\robust@def\cpt@str@pouterbraces#1#2#3{% + \edef\nr{\the\numexpr\nr+1}% + \edef#3{\unexpanded{#2}}% + \cpt@str@pouterbr@ces#2\strip@nil#3#1% +} +\robust@def\cpt@str@pouterbr@ces#1\strip@nil#2#3{% + \defcmp@ifx{#1}#2% + \expandafter\after@def + \else + \ifnum\nr>#3\relax + \cptthreexp\after@def + \else + \cptthreexp\cpt@str@pouterbraces + \fi + \fi + {#3}{#1}{#2}% +} +\robust@def\stripallouterbraces#1#2{% + \edef#2{% + \unexpanded\cptthreexp{\cpt@stripallouterbraces{#1}}% + }% +} +\robust@def\cpt@stripallouterbraces#1{% + \cpt@rnm\ifbracedTF{#1}{% + \expandafter\ifstremptyTF\expandafter{\@secondoftwo#1{}}{% + \expandafter\@gobble\cpt@stripallouterbraces#1% + }{0 #1}% + }{0 #1}% +} +\robust@def\defcmp@ifx#1#2{% + \begingroup + \edef\cpt@tempa{\unexpanded{#1}}% + \expandafter\endgroup\ifx#2\cpt@tempa +} +\robust@def\defcmp@ifxTF#1#2{% + \begingroup + \edef\cpt@tempa{\unexpanded{#1}}% + \ifxTF#2\cpt@tempa + {\endgroup\@firstoftwo}{\endgroup\@secondoftwo}% +} +\robust@def*\cpt@bracearg{\cpt@testopt\cpt@br@cearg\@ne} +\robust@def\cpt@br@cearg[#1]#2#3{% + \ifbracedTF{#2}{% + \begingroup + \let\nr\z@ + \loop + \edef#3{\unexpanded{{#2}}}% + \pushnumber\nr + \ifnum\nr<#1\relax + \repeat + \exitgroupdef#3% + }{% + \edef#3{\unexpanded{#2}}% + }% +} +\begingroup +\catcode`\&=3 +\new@gdef\xp@despace#1{\cpt@rnm-`\q\cpt@normaldespace.#1& &} +\robust@gdef\normal@despace#1#2{% + \edef#2{\expandcsonce{\cpt@rnm-`\q\cpt@normaldespace.#1& &}}% +} +\robust@gdef\cpt@normaldespace#1 &{\cpt@norm@ldespace#1&} +\robust@gdef\cpt@norm@ldespace#1{\@xp\noexpand\@gobble#1} +\endgroup +\robust@def\robust@despace#1#2{% + \edef#2{\unexpanded{#1}}% + \let\despace@tempa#2% + \normal@despace{#1}#2% + \ifxF#2\despace@tempa{% + \expandafter\robust@despace\expandafter{#2}#2% + }% +} +\robust@def*\normal@despacecontent#1{% + \expandafter\normal@despace\expandafter{#1}#1% +} +\robust@def*\robust@despacecontent#1{% + \expandafter\robust@despace\expandafter{#1}#1% +} +\robust@def*\normal@despacecsvlist{% + \let\despace@type\z@ + \cpt@testopt\cpt@despacecsvlist{,}% +} +\robust@def*\robust@despacecsvlist{% + \let\despace@type\@ne + \cpt@testopt\cpt@despacecsvlist{,}% +} +\robust@def*\cpt@despacecsvlist[#1]#2{% + \begingroup + \let\cpt@rsvdb\@empty + \UseEmptyEntry + \ifnum\despace@type=\z@\let\do\normal@despace\else + \let\do\robust@despace\fi + \def\fifo@do##1{% + \do{##1}\cpt@rsvda + \cpt@sttrue\cpt@addtolist[#1]\cpt@rsvdb\cpt@rsvda + }% + \oneDfifo*[#1]{#2}% + \let#2\cpt@rsvdb + \exitgroupdef#2% +} +\new@edef*\ifcptmacroTF#1{% + \unexpanded{\expandafter\cpt@ifmacro\meaning}% + #1\detokenize{macro}:\cpt@nil +} +\edef\cpt@ifmacro{% + \def\noexpand\cpt@ifmacro##1\detokenize{macro}:##2\cpt@nil +} +\cpt@ifmacro{\@nameuse{@\ifblankTF{#2}{second}{first}oftwo}} +\robust@def*\ifcptescapedTF#1{% + \begingroup\escapechar\cpt@xciipt + \edef\cpt@tempa{\expandafter\cpt@car\string#1x\car@nil}% + \cptthreexp\endgroup\@nameuse{@\ifx\cpt@tempa + \@backslashchar first\else second\fi oftwo}% +} +\robust@def*\@left@addto@macro{% + \let\cpt@def\edef\let\swap\cptswap + \cpt@addtomacro +} +\robust@def*\@right@addto@macro{% + \let\cpt@def\edef\let\swap\@alloftwo + \cpt@addtomacro +} +\robust@def*\g@left@addto@macro{% + \let\cpt@def\xdef\let\swap\cptswap + \cpt@addtomacro +} +\robust@def*\g@right@addto@macro{% + \let\cpt@def\xdef\let\swap\@alloftwo + \cpt@addtomacro +} +\robust@def\cpt@addtomacro#1#2{% + \ifdefTF#1{% + \cpt@def#1{\swap{\expandcsonce{#1}}{\unexpanded{#2}}}% + }{% + \cpt@def#1{\unexpanded{#2}}% + }% + \undef@cs\cpt@def\undef@cs\swap +} +\robust@def*\BeforeStartOfDocument{% + \g@right@addto@macro\cpt@beforestartdoc@hook +} +\@onlypreamble\BeforeStartOfDocument +\new@def*\cpt@beforestartdoc@hook{} +\g@left@addto@macro\document{% + \endgroup + \let\BeforeStartOfDocument\@firstofone + \cpt@beforestartdoc@hook + \let\BeforeStartOfDocument\@notprerr + \global\undef@cs\cpt@beforestartdoc@hook + \begingroup +} +\robust@def*\AfterStartOfDocument{% + \g@right@addto@macro\cpt@afterstartdoc@hook +} +\new@def*\cpt@afterstartdoc@hook{} +\g@right@addto@macro\document{% + \let\AfterStartOfDocument\@firstofone + \cpt@afterstartdoc@hook + \let\AfterStartOfDocument\@notprerr + \global\undef@cs\cpt@afterstartdoc@hook + \ignorespaces +} +\g@left@addto@macro\@popfilename{% + \@nameuse{% + @\ifcsname\@currname.\@currext-cpt@h@@k\endcsname + iden\else gobble\fi + }% + {\@nameuse{\@currname.\@currext-cpt@h@@k}}% + \global\undef@csn{\@currname.\@currext-cpt@h@@k}% +} +\robust@def*\cptaddtolist{\cpt@teststoptb\cpt@addtolist} +\robust@def\cpt@addtolist[#1]#2#3{% + \cpt@checklistparser{#1}\relax + \begingroup + \def\cpt@tempa{\endgroup + \ifdefTF#2{% + \ifcpt@st + \protected@edef#2{\expandcsonce#2\ifcsemptyF#2#1#3}% + \else + \edef#2{\expandcsonce#2\ifcsemptyF#2#1\unexpanded{#3}}% + \fi + }{% + \ifcpt@st + \protected@edef#2{#3}% + \else + \edef#2{\unexpanded{#3}}% + \fi + }% + }% + \ifblankTF{#3}{\if@useempty\cpt@tempa\else\endgroup\fi}% + \cpt@tempa +} +\robust@def*\cptaddtocommalist#1#2{% + \ifdefTF{#1}{% + \xdef#1{% + \ifx#1\@empty\else\expandcsonce{#1},\fi + \expandcsonce{#2}% + }% + }{% + \xdef#1{\expandcsonce{#2}}% + }% +} +\def\cptloadpackages#1{% + \def\cpt@loadpackages##1##2##3\cpt@nil{% + \@ifpackageloaded{##1}{}{\RequirePackage[##2]{##1}[##3]}% + }% + \@useemptyfalse + \normalxDloop{#1}\cpt@tempa{% + \expandafter\cpt@loadpackages\cpt@tempa\cpt@nil + }% +} +\robust@def*\AfterEndOfStyleFile{% + \begingroup + \def\cpt@tempa{\endgroup + \expandafter\g@right@addto@macro + \csname\@currname.\@currext-cpt@h@@k\endcsname + }% + \ifcsemptyTF\@currname\endgroup\cpt@tempa +} +\edef\cpt@hashchar{\string#} +\robust@def*\cpt@pushhash{% + \begingroup + \@makeother{\#}% + \endlinechar\m@ne + \cpt@pop@hash +} +\robust@def\cpt@push@hash#1#2{% + \xifinsetTF\cpt@hashchar{\detokenize{#1}}{% + \edef\x##1{##1\detokenize{#1}\cpt@hashchar\cpt@nil}% + \edef\y##1{\def##1####1\cpt@hashchar####2\cpt@nil}% + \y\y{% + \ifblankTF{##2}{% + \toks@\expandafter{\the\toks@##1}% + }{% + \cptpassexpanded{\toks@{\the\toks@##1\cpt@hashchar\cpt@hashchar}}% + \y##2\cpt@nil + }% + }% + \x{\toks@{}\y}% + }{% + \toks@\expandafter{\detokenize{#1}}% + }% + \edef#2{\the\toks@}\exitgroupdef#2% +} +\robust@def*\cpt@pophash{% + \begingroup + \@makeother{\#}% + \endlinechar\m@ne + \cpt@push@hash +} +\robust@def\cpt@pop@hash#1#2{% + \xifinsetTF{\detokenize{##}}{\detokenize{#1}}{% + \edef\x##1{##1\detokenize{#1##}\cpt@nil}% + \edef\y##1{\def##1####1\detokenize{##}####2\cpt@nil}% + \y\y{% + \ifblankTF{##2}{% + \toks@\expandafter{\the\toks@##1}% + }{% + \cptpassexpanded{\toks@{\the\toks@##1\cpt@hashchar}}% + \y##2\cpt@nil + }% + }% + \x{\toks@{}\y}% + }{% + \toks@\expandafter{\detokenize{#1}}% + }% + \edef#2{\the\toks@}\exitgroupdef#2% +} +\robust@def*\cpt@everyscantoks{% + \everyeof{\noexpand}% + \endlinechar\m@ne + \makeatletter + \catcode`\ =10\relax + \catcode`\\\z@ + \catcode`\{\@ne + \catcode`\}\tw@ +} +\def\cptscantokens#1{% + \begingroup + \edef#1{\def\string#1{\cptxpdetok{#1}}}% + \cpt@everyscantoks + \scantokens\expandafter{#1}\relax + \exitgroupdef#1% +} +\robust@def*\cpt@preamblecmds{% + \cptpushcatcodes,\cptpopcatcodes, + \UseNormalCatcodes,\rc@UseNormalCatcodes, + \StyleFilePurpose,\StyleFileInfo,\AfterEndOfStyleFile, + \StyleFileRCSInfo,\SetStyleFileMessages, + \XDeclareOption,\XDeclareCommandOption,\XDeclareBooleanOption, + \XProcessOptions,\XExecuteOptions, + \cpt@processedoptions,\cpt@optionlist,\cpt@splitoption, + \cpt@processoptions,\cpt@xprocessoptions,\cpt@pr@cessoptions, + \cpt@pr@c@ssoptions +} +\AtEndOfPackage{\undef@cs\cpt@preamblecmds} +\normaloneDloop*\cpt@preamblecmds\cpt@tempa{% + \expandafter\ifcptonetokenTF\expandafter{\cpt@tempa}{% + \expandafter\@onlypreamble\expandafter{\cpt@tempa}% + }{% + \cpt@err{Illegal multiple elements}\@ehc + }% +} +\robust@def*\csv@@normalize{\cpt@teststoptb\cpt@csvnormalize} +\robust@def\cpt@csvnormalize[#1]#2{% + \let\normalize@listtype\z@ + \csv@kv@normalize{#1}{#2}\normalized@csvlist +} +\robust@def*\kv@@normalize{\cpt@teststoptb\cpt@kvnormalize} +\robust@def\cpt@kvnormalize[#1]#2{% + \let\normalize@listtype\@ne + \csv@kv@normalize{#1}{#2}\normalized@kvlist +} +\robust@def\csv@kv@normalize#1#2#3{% + \ifcptonetokenTF{#1}{}{\cpt@err{Multiple list parser}\@ehc}% + \let\if@normst\ifcpt@st + \begingroup + \expandafter\setup@parser@normalize\string#1% + \if@boolTF{@normst}{% + \toks@\expandafter{\expandafter#1#2#1}% + }{% + \toks@{#1#2#1}% + }% + \normalize@activeparser + \expandafter\normalize@spaceletter\string#1% + \expandafter\normalize@letterspace\string#1% + \expandafter\normalize@doubleletter\string#1% + \ifnumT\normalize@listtype=\@ne{% + \normalize@activeequal + \expandafter\normalize@spaceletter\string=% + \expandafter\normalize@letterspace\string=% + \expandafter\normalize@doubleletter\string=% + \commaequal@err + }% + \edef#3{\the\toks@}% + \expandafter\cpttrimparser\expandafter[\string#1]#3% + \exitgroupdef#3% + \if@normst\let#2#3\undef@cs#3\fi + \undef@cs\if@normst +} +\def\setup@parser@normalize#1{% + \begingroup + \uccode`\~=`#1% + \uppercase{\endgroup + \def\normalize@activeparser{% + \def\cpt@tempa####1~####2\cpt@nil{% + \toks@\expandafter{\the\toks@####1}% + \ifblankF{####2}{\cpt@tempa#1####2\cpt@nil}% + }% + \toks@\expandafter{\expandafter}% + \expandafter\cpt@tempa\the\toks@~\cpt@nil + }% + }% +} +\begingroup +\catcode`\= 12 +\uccode`\~=`\=% +\uppercase{\endgroup + \def\normalize@activeequal{% + \def\cpt@tempa##1~##2\cpt@nil{% + \expandafter\ifblankTF\expandafter{\the\toks@}{% + \toks@{##1}% + }{% + \toks@\expandafter{\the\toks@=##1}% + }% + \ifblankF{##2}{\cpt@tempa##2\cpt@nil}% + }% + \toks@\expandafter{\expandafter}\expandafter + \cpt@tempa\the\toks@~\cpt@nil + }% +} +\def\normalize@doubleletter#1{% + \def\cpt@tempa##1#1#1##2\cpt@nil{% + \ifblankTF{##2}{% + \toks@{##1}% + }{% + \toks@{##1#1##2}% + \expandafter\cpt@tempa\the\toks@\cpt@nil + }% + }% + \expandafter\cpt@tempa\the\toks@#1#1\cpt@nil +} +\defpass\cpt@tempa#1{% + \def\normalize@spaceletter##1{% + \def\cpt@tempa####1#1##1####2\cpt@nil{% + \ifblankTF{####2}{% + \toks@{####1}% + }{% + \toks@{####1##1####2}% + \expandafter\cpt@tempa\the\toks@\cpt@nil + }% + }% + \expandafter\cpt@tempa\the\toks@#1##1\cpt@nil + }% + \def\normalize@letterspace##1{% + \def\cpt@tempa####1##1#1####2\cpt@nil{% + \ifblankTF{####2}{% + \toks@{####1}% + }{% + \toks@{####1##1####2}% + \expandafter\cpt@tempa\the\toks@\cpt@nil + }% + }% + \expandafter\cpt@tempa\the\toks@##1#1\cpt@nil + }% +}{ } +\robust@def*\commaequal@err{% + \def\cpt@tempa##1,=##2\cpt@nil{% + \ifblankTF{##2}{}{% + \cpt@err{There is 'comma' next to 'equal' (,=) in + \MsgBrk your key-val list}\@ehc + }% + }% + \expandafter\cpt@tempa\the\toks@,=\cpt@nil +} +\let\cpt@documentclass\cpt@undefined +\robust@def*\cpt@getdocumentclass{% + \normaloneDloop*\@filelist\cpt@tempa{% + \filename@parse\cpt@tempa + \ifx\filename@ext\@clsextension + \ifcsndefT{opt@\filename@area\filename@base.\filename@ext}{% + \xdef\cpt@documentclass{% + \filename@area\filename@base.\filename@ext + }% + }% + \fi + \ifx\cpt@documentclass\cpt@undefined\else\@breaklooptrue\fi + }% + \ifdefF\cpt@documentclass{% + \@latex@info@no@line{'catoptions' package loaded before + \string\documentclass}% + }% +} +\ifx\@filelist\relax\else\ifx\@filelist\@gobble\else + \ifx\@filelist\@empty\else + \cptsevenxp\cpt@getdocumentclass +\fi\fi\fi +\ifx\cpt@documentclass\cpt@undefined + \let\cpt@documentclass\@empty + \let\cpt@classoptionslist\@empty +\else + \ifx\@classoptionslist\relax\else + \ifx\@classoptionslist\@empty\else + \kv@@normalize*\@classoptionslist + \fi\fi + \let\cpt@classoptionslist\@classoptionslist + \expandafter\cptemptify\expandafter\@classoptionslist\expandafter + \normaloneDloop\expandafter{\@classoptionslist}\cpt@tempa{% + \oifinsetF{=}\cpt@tempa{% + \cptaddtocommalist\@classoptionslist\cpt@tempa + }% + }% +\fi +\robust@def*\cpt@testfam#1{% + \cpt@ifnextchar<{#1}{#1<{\@currname.\@currext}>}% +} +\robust@redef\@pass@ptions#1#2#3{% + \begingroup + \ifcptonetokenTF{#2}{% + \ifcptmacroTF{#2}{% + \let\@expand\expandcsonce + }{% + \let\@expand\unexpanded + }% + }{% + \let\@expand\unexpanded + }% + \csn@xdef{opt@#3.#1}{% + \ifcsndefT{opt@#3.#1}{\expandcsnonce{opt@#3.#1},}% + \@expand{#2}% + }% + \endgroup +} +\robust@redef*\OptionNotUsed{% + \ifx\@currext\@clsextension + \cptaddtocommalist\@unusedoptionlist\CurrentOption + \fi +} +\robust@redef*\@use@ption{% + \xifinsetT{,\cptxpdetok\CurrentOption,}% + {,\cptxpdetok\@unusedoptionlist,}{% + \@xpargox{\cpt@killoneelement[,]}\CurrentOption + \@unusedoptionlist + }% + \csname ds@\CurrentOption\endcsname +} +\robust@redef*\@fileswith@pti@ns#1[#2]#3[#4]{% + \begingroup + \edef\fileopts{\unexpanded{#2}}% + \ifcsemptyF\fileopts{\kv@@normalize*\fileopts}% + \def\fileswithopts##1##2{% + \noexpand\@onefilewithoptions{##1}% + [\expandcsonce\fileopts]\unexpanded{[#4]##2}% + }% + \def\file@withopts##1{\cptpassexpanded{\toks@{##1}}}% + \toks@{}% + \ifxTF#1\@clsextension{% + \ifx\@classoptionslist\relax + \xdef\@classoptionslist{\expandcsonce\fileopts}% + \file@withopts{\fileswithopts{#3}{#1\@documentclasshook}}% + \else + \file@withopts{\fileswithopts{#3}{#1}}% + \fi + }{% + \edef\cpt@tempa{\cptzapspaces{#3}}% + \DiscardEmptyEntry + \normaloneDloop*\cpt@tempa\cpt@tempa{% + \file@withopts{\the\toks@\fileswithopts{\cpt@tempa}\@pkgextension}% + }% + }% + \expandafter\endgroup\the\toks@ +} +\let\@@fileswith@pti@ns\@fileswith@pti@ns +\robust@def*\RecoverAtEndOfPackage#1{% + \csn@let@cs{rc@\expandafter\@gobble\string#1}#1% + \begingroup + \edef\cpt@tempa{% + \let\unexpanded{#1}% + \noexpandcsn{rc@\expandafter\@gobble\string#1}% + }% + \edef\cpt@tempb{\expandcsnonce{\@currname.\@currext-h@@k}}% + \xifinsetF{\cptxpdetok\cpt@tempa}{\cptxpdetok\cpt@tempb}{% + \expandafter\AtEndOfPackage\expandafter{\cpt@tempa}% + }% + \xifinsetF{\cptxpdetok\cpt@tempa}{\cptxpdetok\RequirePackage}{% + \xdef\RequirePackage{% + \expandcsonce\cpt@tempa\expandcsonce\RequirePackage + }% + }% + \endgroup +} +\RecoverAtEndOfPackage\cpt@defdefault@ds +\robust@def*\cpt@badoptionerr{% + \expandafter\ifcptescapedTF\expandafter{\curropt}{% + \cpt@err{Bad option name '\expandcsonce\curropt'}\@ehc + }{% + \expandafter\ifcptmacroTF\expandafter{\curropt}{% + \cpt@err{Bad option name '\expandcsonce\curropt'}\@ehc + }{}% + }% +} +\robust@def*\XDeclareOption{% + \let\@fileswith@pti@ns\@badrequireerror + \cpt@ifstar + {\cpt@testfam\cpt@defdefault@ds}% + {\cpt@testfam\cpt@declareoption}% +} +\robust@def*\cpt@declareoption<#1>#2{% + \def\curropt{#2}% + \cpt@badoptionerr + \cpt@testopt{\cpt@d@clareoption{#1}{#2}}{}% +} +\robust@def\cpt@d@clareoption#1#2[#3]#4{% + \cpt@d@cl@reoption{#1}{#2}{#3}% + \if@boolTF{cpt@olddx}{% + \global\long\csn@edef{#1@ds@#2}{\unexpanded{#4}}% + }{% + \begingroup + \long\def\cpt@tempa##1{\endgroup + \global\long\csn@def{#1@ds@#2}####1{##1}% + }% + \cpt@tempa{#4}% + }% + \cpt@olddxfalse +} + +\robust@def*\XDeclareCommandOption{% + \let\@fileswith@pti@ns\@badrequireerror + \let\cmdoption\@ne + \cpt@testfam\cpt@declarecmdoption +} +\robust@def*\XDeclareBooleanOption{% + \let\@fileswith@pti@ns\@badrequireerror + \let\cmdoption\z@ + \cpt@testfam\cpt@declarecmdoption +} +\robust@def*\cpt@declarecmdoption<#1>#2{% + \def\curropt{#2}% + \cpt@badoptionerr + \cpt@testopt{\cpt@d@clarecmdoption{#1}{#2}}{}% +} +\robust@def\cpt@d@clarecmdoption#1#2[#3]{% + \cptfullexpandarg{\cpt@testparenopt{\cpt@d@cl@recmdoption + {#1}{#2}{#3}}}{\ifnum\cmdoption=\@ne cmd\fi\@currname @}% +} +\robust@def\cpt@d@cl@recmdoption#1#2#3(#4)#5{% + \cpt@d@cl@reoption{#1}{#2}{#3}% + \ifnum\cmdoption=\@ne + \def\cpt@rsvda{\csn@def{#4#2}{####1}}% + \else + \@fullxpsec{\@nameuse{newif}}{\noexpandcsn{if#4#2}}% + \def\cpt@rsvda{% + \ifinsetF{,####1,}{,true,false,}{% + \@latex@error{Invalid value for option '#2'}\@ehc + }% + \cptuse{#4#2####1}% + }% + \fi + \long\def\cpt@rsvdb##1{% + \long\csn@gdef{#1@ds@#2}####1{% + ##1\relax + }% + }% + \expandafter\cpt@rsvdb\expandafter{\cpt@rsvda#5}% +} +\robust@def\cpt@d@cl@reoption#1#2#3{% + \ifcsndefTF{#1@declaredoptions}{% + \xifinsetTF{,\detokenize{#2},}{,\cpt@getdeclaredoptions{#1},}{% + \cpt@warn{Option '#2' multiply defined\MsgBrk in + family '#1'\MsgBrk (in \@cls@pkg\@space'\@currname')% + }% + }{% + \cpt@stfalse + \cptfullexpandarg{\cpt@addtolist[,]}% + {\noexpandcsn{#1@declaredoptions}}{#2}% + }% + }{% + \csn@def{#1@declaredoptions}{#2}% + }% + \global\csn@edef{#1@ds@#2@default}{% + \noexpandcsn{#1@ds@#2}{\unexpanded{#3}}% + }% +} +\new@def*\cpt@getdeclaredoptions#1{% + \ifcsnemptyTF{#1@declaredoptions}{}{% + \detokenize\cptsevenxp{\@nameuse{#1@declaredoptions}}% + }% +} +\robust@def*\cpt@defdefault@ds<#1>#2{% + \csn@edef{#1@default@ds}{\unexpanded{#2}}% + \protected\def\cpt@defdefault@ds<##1>##2{% + \cpt@err{'\string\XDeclareOption*' multiply defined in + \MsgBrk\@cls@pkg\space'\@currname'}{Multiple star + variant of \string\XDeclareOption\@space in + \@cls@pkg\@space'\@currname'.}% + }% +} +\letnewcmd\rc@cpt@defdefault@ds\cpt@defdefault@ds +\new@def*\cpt@optionlist#1{% + \ifcsndefT{opt@#1}{\unexpanded\cptsevenxp{\@nameuse{opt@#1}}}% +} +\letnewcmd\cpt@processedoptions\@empty +\robust@def*\XProcessOptions{% + \let\@fileswith@pti@ns\@badrequireerror + \edef\cpt@testname{\@currname.\@currext}% + \ifx\cpt@testname\cpt@documentclass + \let\@unusedoptionlist\cpt@classoptionslist + \fi + \edef\cpt@classoptions{% + \ifx\cpt@testname\cpt@documentclass\else + \expandcsonce\cpt@classoptionslist\fi + }% + \edef\@curroptions{\cpt@optionlist{\@currname.\@currext}}% + \ifcsemptyF\@curroptions{\kv@@normalize*\@curroptions}% + \cpt@ifstar + {\cpt@sttrue\cpt@testfam\cpt@processoptions}% + {\cpt@stfalse\cpt@testfam\cpt@processoptions}% +} +\robust@def*\cpt@processoptions<#1>{% + \if@boolTF{cpt@st}{% + \cpt@testopt{\cpt@xprocessoptions#1}{}% + }{% + \cpt@testopt{\cpt@pr@cessoptions#1}{}% + }% +} +\robust@def*\cpt@pr@cessoptions#1[#2]{% + \def\currfam{#1}% + \def\kv@do##1{% + \edef\CurrentOption{\unexpanded{##1}}% + \ifcsemptyF\CurrentOption{% + \cpt@splitoption\z@ + \if@boolT{cpt@optf}{% + \cpt@inpoxtrue + \ifcsndefT{#1@ds@\curropt}{% + \ifblankTF{#2}{% + \cpt@igoptfalse + }{% + \oifinsetTF{\curropt}{#2}{% + \cpt@igopttrue + }{% + \cpt@igoptfalse + }% + }% + \cpt@useoption + }% + }% + }% + }% + \ifcsemptyF\cpt@classoptions{% + \cptfullexpandarg + {\kv@@parse*}{\noexpandcsn{#1@declaredoptions}}% + }% + \cpt@pr@c@ssoptions{#1}{#2}% +} +\robust@def*\cpt@xprocessoptions#1[#2]{% + \def\currfam{#1}% + \def\kv@do##1{% + \edef\CurrentOption{\unexpanded{##1}}% + \ifcsemptyF\CurrentOption{% + \cpt@splitoption\@ne + \xifinsetT{,\cptxpdetok\curropt,}% + {,\cpt@getdeclaredoptions{#1},}{% + \cpt@inpoxtrue + \ifcsndefT{#1@ds@\curropt}{% + \ifblankTF{#2}{% + \cpt@igoptfalse + }{% + \oifinsetTF{\curropt}{#2}{% + \cpt@igopttrue + }{% + \cpt@igoptfalse + }% + }% + \cpt@useoption + }% + }% + }% + }% + \ifcsemptyF\cpt@classoptions{\kv@@parse*\cpt@classoptions}% + \cpt@pr@c@ssoptions{#1}{#2}% +} +\robust@def*\cpt@pr@c@ssoptions#1#2{% + \def\currfam{#1}% + \def\kv@do##1{% + \edef\CurrentOption{\unexpanded{##1}}% + \ifcsemptyF\CurrentOption{% + \cpt@splitoption\@ne + \cpt@inpoxtrue + \ifcsndefTF{#1@ds@\curropt}{% + \ifblankTF{#2}{% + \cpt@igoptfalse + }{% + \oifinsetTF{\curropt}{#2}{% + \cpt@igopttrue + }{% + \cpt@igoptfalse + }% + }% + \cpt@useoption + }{% + \ifcsndefTF{#1@default@ds}{% + \@nameuse{#1@default@ds}% + }{% + \default@ds + }% + }% + }% + }% + \ifcsemptyF\@curroptions{\kv@@parse*\@curroptions}% + \let\CurrentOption\@empty + \ifx\cpt@documentclass\cpt@undefined + \cptglet\cpt@pr@cessedoptions\cpt@processedoptions + \else + \let\cpt@pr@cessedoptions\@empty + \fi + \undef@cs\cpt@classoptions + \let\cpt@processedoptions\@empty + \let\@fileswith@pti@ns\@@fileswith@pti@ns + \cpt@olddxfalse + \AtEndOfPackage{\let\@unprocessedoptions\relax}% +} +\robust@def*\XExecuteOptions{\cpt@testfam\cpt@executeoptions} +\robust@def*\cpt@executeoptions<#1>#2{% + \def\currfam{#1}% + \let\cpt@executedoptions\@empty + \let\rc@CurrentOption\CurrentOption + \def\kv@do##1{% + \edef\CurrentOption{\unexpanded{##1}}% + \ifcsemptyF\CurrentOption{% + \cpt@splitoption\@ne + \xifinsetTF{,\cptxpdetok\curropt,}% + {,\cpt@getdeclaredoptions{#1},}{% + \xifinsetTF{,\cptxpdetok\curropt,}% + {,\cptxpdetok\cpt@executedoptions,}{% + \cpt@warn{Option '\curropt' multiply submitted to + \MsgBrk\string\XExecuteOptions: re-executed}% + }{% + \cptaddtocommalist\cpt@executedoptions\curropt + }% + \cpt@inpoxfalse\cpt@igoptfalse\cpt@useoption + }{% + \cpt@warn{Option '\expandcsonce\curropt' not + declared: ignored}% + }% + }% + }% + \kv@@parse{#2}% + \let\CurrentOption\rc@CurrentOption + \let\cpt@executedoptions\@empty + \cpt@olddxfalse +} +\robust@def\cpt@splitoption#1{% + \ifcase#1\relax + \cpt@optffalse + \oneDloop@b\cpt@classoptions\@currentoption{% + \ifcsemptyF\@currentoption{% + \xifinsetTF{=}{\cptxpdetok\@currentoption}{% + \@xp\cpt@split@ption\@currentoption=\cpt@nil + }{% + \let\@curropt\@currentoption + \let\@currval\@empty + }% + \let\currval\@currval + \ifx\@curropt\CurrentOption + \cpt@optftrue\@breaklooptrue + \let\curropt\@curropt + \let\currentoption\@currentoption + \fi + }% + }% + \or + \let\currentoption\CurrentOption + \xifinsetTF{=}{\cptxpdetok\CurrentOption}{% + \expandafter\cpt@split@ption\CurrentOption=\cpt@nil + \let\curropt\@curropt + \let\currval\@currval + }{% + \let\curropt\CurrentOption + \let\currval\@empty + }% + \else + \cpt@err{Invalid case '\expandcsonce{#1}' for + command '\string\cpt@splitoption'}\@ehc + \fi +} +\def\cpt@split@ption#1=#2\cpt@nil{% + \edef\@curropt{\unexpanded{#1}}% + \ifinsetTF{=\cpt@nil}{#2\cpt@nil}{% + \begingroup + \def\cpt@tempa##1=##2\cpt@nil{\endgroup + \edef\@currval{\expandcsonce{\remove@to@dot##1}}% + }% + \cpt@tempa.#2\cpt@nil + }{% + \edef\@currval{\unexpanded{#2}}% + }% +} +\robust@def*\cpt@useoption{% + \ifcpt@inpox + \xifinsetF{,\cptxpdetok\CurrentOption,}% + {,\cptxpdetok\cpt@processedoptions,}{% + \cptaddtocommalist\cpt@processedoptions\CurrentOption + }% + \remove@curr@option\currentoption + \ifx\currentoption\CurrentOption\else + \remove@curr@option\CurrentOption + \fi + \fi + \ifcpt@igopt\else + \ifcpt@olddx + \cptuse{\currfam @ds@\curropt}% + \else + \ifcsndefT{\currfam @ds@\curropt}{% + \ifcsemptyTF\currval{% + \cptthreexp\cpt@usedefault + \csname\currfam @ds@\curropt @default\endcsname\cpt@nil + }{% + \cpt@use@ption + }% + }% + \fi + \fi +} +\robust@def*\cpt@use@ption{% + \cpt@pushoptionstate + \@xpargox{\cptuse{\currfam @ds@\curropt}}\currval\relax + \cpt@popoptionstate +} +\robust@def*\cpt@usedefault#1#2\cpt@nil{% + \ifcptmacroTF{#1}{% + \edef\cpt@tempa{\expandafter\@gobble\string#1}% + }{% + \cpt@err{Invalid option macro passed to command + '\string\cpt@usedefault'}\@ehc + }% + \edef\cpt@tempb{\currfam @ds@\curropt}% + \@onelevel@sanitize\cpt@tempb + \ifxTF\cpt@tempa\cpt@tempb{% + \begingroup + \csn@def{\currfam @ds@\curropt}##1{% + \toks@{\def\currval{##1}}% + }% + \cptuse{\currfam @ds@\curropt @default}% + \expandafter\endgroup\the\toks@ + \cpt@use@ption + }{% + \cpt@warn{Non-standard default function for option + '\expandcsonce\curropt':\MsgBrk Executed anyway}% + \cpt@pushoptionstate + \cptuse{\currfam @ds@\curropt @default}\relax + \cpt@popoptionstate + }% +} +\robust@def*\cpt@optionstate{% + \currfam,\curropt,\currval,\CurrentOption,\currentoption,% + \ifcpt@inpox,\ifcpt@optf,\ifcpt@igopt +} +\robust@def*\cpt@pushoptionstate{% + \@xp\pushfunctions\@xp{\cpt@optionstate}\cpt@optdepth +} +\robust@def*\cpt@popoptionstate{% + \@xp\popfunctions\@xp{\cpt@optionstate}\cpt@optdepth +} +\robust@def*\remove@curr@option#1{% + \@xpargox{\cpt@killoneelement[,]}{#1}\@unusedoptionlist +} +\BeforeStartOfDocument{% + \ifdefT\cpt@pr@cessedoptions{% + \ifcsemptyF\cpt@pr@cessedoptions{% + \ifcsemptyF\@unusedoptionlist{% + \oneDloop@b\cpt@pr@cessedoptions\cpt@tempa{% + \xifinsetT{,\cptxpdetok\cpt@tempa,}% + {,\cptxpdetok\@unusedoptionlist,}{% + \remove@curr@option\cpt@tempa + }% + }% + }% + }% + }% + \cptglobalize\@unusedoptionlist + \undef@cs\cpt@pr@cessedoptions +} +\cptpassunexpanded{% + \begingroup + \def\cpt@tempa{\endgroup + \cptglet\cpt@kernel@DeclareOption\DeclareOption + \cptglet\cpt@kernel@ProcessOptions\ProcessOptions + \cptglet\cpt@kernel@ExecuteOptions\ExecuteOptions + \gdef\DeclareOption{\cpt@olddxtrue\XDeclareOption}% + \gdef\ProcessOptions{\cpt@olddxtrue\XProcessOptions}% + \gdef\ExecuteOptions{\cpt@olddxtrue\XExecuteOptions}% + \AtEndOfPackage{% + \ifcpt@usepox\else + \def\documentclass{% + \let\documentclass\@twoclasseserror + \if@compatibility\else + \def\usepackage{% + \cptglet\DeclareOption\cpt@kernel@DeclareOption + \cptglet\ProcessOptions\cpt@kernel@ProcessOptions + \cptglet\ExecuteOptions\cpt@kernel@ExecuteOptions + \cpt@olddxfalse + \RequirePackage + }% + \fi + \@fileswithoptions\@clsextension + }% + \fi + }% + }% + \ifx\cpt@documentclass\cpt@undefined + \expandafter\cpt@tempa\else\expandafter\endgroup\fi +} +\XDeclareBooleanOption{verbose}[true](cpt@){} +\XDeclareBooleanOption{usepox}[true](cpt@){% + \ifcpt@usepox + \AtEndOfPackage{% + \gdef\DeclareOption{\cpt@olddxtrue\XDeclareOption}% + \gdef\ProcessOptions{\cpt@olddxtrue\XProcessOptions}% + \gdef\ExecuteOptions{\cpt@olddxtrue\XExecuteOptions}% + }% + \fi +} +\XDeclareOption*{\cpt@warn{Unknown option '\CurrentOption' ignored}} +\XExecuteOptions{verbose=false,usepox=true} +\XProcessOptions* + +\cptpopcatcodes +\cptrestorecatcodes + +\endinput + +%% End of file catoptions.sty %% diff --git a/Master/tlpkg/bin/tlpkg-ctan-check b/Master/tlpkg/bin/tlpkg-ctan-check index cdf4e50bb59..f3cded332d8 100755 --- a/Master/tlpkg/bin/tlpkg-ctan-check +++ b/Master/tlpkg/bin/tlpkg-ctan-check @@ -68,7 +68,7 @@ my @TLP_working = qw( c-pascal cachepic calctab calligra calrsfs cals calxxxx-yyyy cancel canoniclayout capt-of captcont captdef caption carlisle carolmin-ps cases casyl - catchfilebetweentags catechis + catchfilebetweentags catechis catoptions cbcoptic cbfonts cc-pl ccaption ccfonts ccicons cclicenses cd cd-cover cdpbundl diff --git a/Master/tlpkg/tlpsrc/catoptions.tlpsrc b/Master/tlpkg/tlpsrc/catoptions.tlpsrc new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/Master/tlpkg/tlpsrc/catoptions.tlpsrc diff --git a/Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc b/Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc index 7280a2c1410..f7df651d5ca 100644 --- a/Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc +++ b/Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc @@ -76,6 +76,7 @@ depend cases depend casyl depend catchfilebetweentags depend catechis +depend catoptions depend cbcoptic depend ccaption depend cclicenses |