% \iffalse %% %% (C) Copyright 1999 Frank Mittelbach, Chris Rowley, David Carlisle %% All rights reserved. %% %% Not for general distribution. In its present form it is not allowed %% to put this package onto CD or an archive without consulting the %% the authors. %% %<*dtx> \ProvidesFile{ldcsetup.dtx} % %\NeedsTeXFormat{LaTeX2e} %\ProvidesPackage{ldcsetup} %\ProvidesFile{ldcsetup.drv} % \fi % \ProvidesFile{ldcsetup.dtx} [1999/09/10 v0.04 coding conventions and stuff] % % \iffalse %<*driver> \documentclass{ltxdoc} \begin{document} \DocInput{ldcsetup.dtx} \end{document} % % \fi % % \CheckSum{249} % % \GetFileInfo{ldcsetup.dtx} % % \title{The \textsf{ldcsetup} package\thanks{This file % has version number \fileversion, last % revised \filedate.}} % \author{DPC, FMi} % \date{\filedate} % \maketitle % % \begin{abstract} % Basic code shared by several other packages currently under development. % \end{abstract} % % \StopEventually{} % % \begin{macrocode} %<*package> % \end{macrocode} % % \begin{macrocode} \RequirePackage{keyval,calc} % \end{macrocode} % % \section{Ignoring White Space} % Within a package, or in a document preamble, you can use % |\IgnoreWhiteSpace| this makes white space ignored, and |@| % a letter, and |~| a space character. It lasts until the end of the % current package or preamble. % %% Puts an ignored space at the end of the line, so `|\ |' does the right % thing. (Perhaps should instead just change catcode of |^^M|) % \begin{macrocode} \def\IgnoreWhiteSpace{% \edef\@tempa{% \catcode`\noexpand\~=\the\catcode`\~\relax \catcode`\noexpand\ =\the\catcode`\ \relax \catcode`\noexpand\^^I=\the\catcode`\^^I\relax \catcode`\noexpand\@=\the\catcode`\@\relax \endlinechar=\the\endlinechar\relax }% \ifx\@currname\@empty \expandafter\AtBeginDocument\expandafter{\@tempa}% \else \expandafter\AtEndOfPackage\expandafter{\@tempa}% \fi \catcode`\~=10\relax \catcode`\ =9\relax \catcode`\^^I=9\relax \makeatletter % \endlinechar=\m@ne \endlinechar=` % } % \end{macrocode} % % Do it for this package. % \begin{macrocode} \IgnoreWhiteSpace % \end{macrocode} % % \section{KV fixes} % Allow\footnote{Not needed now?} key names to start with |\|. % \begin{macrocode} \def\define@key#1#2{% \@ifnextchar[ {\KV@def{#1}{\string#2}} {\@namedef{KV@#1@\string#2}####1}} \def\setkeys#1#2{% \def\KV@prefix{KV@#1@\expandafter\string}% \KV@do#2,\relax,} % \end{macrocode} % % Make KV |#| safe. % \begin{macrocode} % \end{macrocode} % % \begin{macrocode} \newtoks\KV@toks % \end{macrocode} % % \begin{macrocode} \def\KV@@sp@c#1\@nil#2\relax#3{\KV@toks{#1}\edef#3{\the\KV@toks}} % \end{macrocode} % % Generate error messages on missing `,'. % % More exactly if two `=' appear after a key generate an error. % The current KV just silently ignores everything after the second `='. % \begin{macrocode} \def\KV@equal{=} % \end{macrocode} % % \begin{macrocode} \def\KV@split#1=#2=#3\relax{% \KV@@sp@def\@tempa{#1}% \def\@tempd{#3}% \ifx\@tempa\@empty\else \expandafter\let\expandafter\@tempc \csname\KV@prefix\@tempa\endcsname \ifx\@tempc\relax \KV@error{\@tempa\space \expandafter\@gobbletwo\string\@undefined}\@eha \else \ifx\@tempd\@empty \KV@default \else \KV@@sp@def\@tempb{#2}% \ifx\@tempd\KV@equal \expandafter\@tempc\expandafter{\@tempb}\relax \else \KV@error{Extra~=~ sign~ after~ `#1'}\KV@erry \fi \fi \fi \fi} % \end{macrocode} % % \begin{macrocode} \def\KV@erry{\expandafter\KV@errx\meaning\@tempd\relax ignored\MessageBreak missing~comma~in~`\expandafter\strip@prefix\meaning\@tempb'~?} % \end{macrocode} % % \begin{macrocode} \def\KV@errx#1>#2==\relax{% `#2' } % \end{macrocode} % % \begin{macrocode} \def\KV@default{% \expandafter\let\expandafter\@tempb \csname\KV@prefix\@tempa @default\endcsname \ifx\@tempb\relax \KV@error{No value specified for \@tempa}\@eha \else \@tempb\relax \fi} % \end{macrocode} % % \LaTeX\ style error message. % \begin{macrocode} \def\KV@error#1#2{\PackageError{keyval}{#1}{#2}} % \end{macrocode} % % Instead of doing a full KV parse, and evaluating all the keys, % you might want to parse a parameter list, even for undefined keys, % removing spaces, splitting up the `,` and `=' and resolving cases % where no value is supplied. This is used in |\DeclareGenericFunction| % which \emph{defines} a set of keys via such a KV parse. % % A setting of |, key = value ,| will result in |\KV@elt{key}{value}| % being added to the list, a seting of |, key ,| will result in % |\KV@default@elt{key}| being added. At the end of the parse the list % is executed. No keys are checked at this stage (so no csnames are used % up) the two |\KV|\ldots|@elt| commands must be defined as appropriate. % % \begin{macrocode} \def\KV@parse#1{ \begingroup % \end{macrocode} % % Locally fudge |\KV@@def| to just add to a token register % rather than make a definition. % \begin{macrocode} \def\KV@@sp@c##1\@nil##2\relax##3{\addto@hook##3{{##1}}} % \end{macrocode} % % Locally fudge |\KV@split| to just add to a token register % rather than execute the code for the found keys. % \begin{macrocode} \def\KV@split##1=##2=##3\relax{% \def\@tempd{##3}% \expandafter\ifx\expandafter=\@firstofone##1=\else \ifx\@tempd\@empty \addto@hook\KV@toks\KV@default@elt \KV@@sp@def\KV@toks{##1}% \else \ifx\@tempd\KV@equal \addto@hook\KV@toks\KV@elt \KV@@sp@def\KV@toks{##1}% \KV@@sp@def\KV@toks{##2}% \else \KV@err{Extra `=' after `##1'}\@ehd \fi \fi \fi} % \end{macrocode} % % Initialise % \begin{macrocode} \KV@toks{} % \end{macrocode} % Do the parse % \begin{macrocode} \KV@do#1,\relax, % \end{macrocode} % Evaluate the token register outside the group. % \begin{macrocode} \expandafter \endgroup \the\KV@toks} % \end{macrocode} % % \section{Calc fixes} % % Count Register assignments via calc. % \begin{macrocode} \let\SetInternalCounter\calc@assign@count % \end{macrocode} % % % \section{Misc code that is best collected in one place} % % This section will receive odd code that would be of potential use to % other packages and should eventually made it to the kernel % (perhaps). % % \begin{macro}{\UndeclareRobustCommand} % Remove a robust command from memory if it isn't used any % longer. Of course this doesn't free the hash table but at least % the space gets reclaimed. % \begin{macrocode} \def\UndeclareRobustCommand#1{% \global\let#1\undefined \global\expandafter \let\csname\expandafter\@gobble\string#1~\endcsname\undefined } % \end{macrocode} % \end{macro} % % % \begin{macrocode} % % \end{macrocode} % % \Finale %