diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex/gmutils/gmutils.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/gmutils/gmutils.sty | 661 |
1 files changed, 516 insertions, 145 deletions
diff --git a/Master/texmf-dist/tex/latex/gmutils/gmutils.sty b/Master/texmf-dist/tex/latex/gmutils/gmutils.sty index 761a1d7880d..2d2c7a78f3f 100644 --- a/Master/texmf-dist/tex/latex/gmutils/gmutils.sty +++ b/Master/texmf-dist/tex/latex/gmutils/gmutils.sty @@ -1,15 +1,15 @@ % % \GetFileInfo{gmutils.sty} % \title{The \pk{gmutils} Package\thfileinfo} -% \author{Grzegorz `Natror' Murzynowski} +% \author{Grzegorz Murzynowski} % \maketitle % % \begin{copyrnote} % -%%Written by Grzegorz `Natror' Murzynowski, +%%Written by Grzegorz Murzynowski, %% natror at o2 dot pl %% -%% \copyright\,2005, 2006 by Grzegorz `Natror' Murzynowski. +%% \copyright\,2005, 2006, 2007 by Grzegorz Murzynowski. %% %% This program is subject to the \LaTeX\ Project Public License. %% See ^^A @@ -38,11 +38,14 @@ % \chschange{v0.71}{06/10/27}{876} % \chschange{v0.72}{06/11/14}{906} % \chschange{v0.74}{06/12/1}{1185} +% \chschange{v0.76}{07/4/9}{1538} +% \chschange{v0.77}{07/4/14}{1547} +% \chschange{v0.78}{2007/4/26}{1685} % \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{gmutils} - [2006/11/29 v0.74 some rather TeXnical macros, some of them tricky (GM)] + [2007/04/24 v0.78 some rather TeXnical macros, some of them tricky (GM)] % % \tableofcontents @@ -110,7 +113,12 @@ % \pk{mwcls}, the standard \pk{article.cls} class would be used. % \end{gmlonely} % -% \division{\cs{newgif} and Other Globals} +% +% \division{A~couple of abbreviations} +% \CodeDefine\@xa \CodeDefine\@nx +\let\@xa\expandafter +\let\@nx\noexpand + % % The |\newgif| declaration's effect is used even in the \LaTeXe\ % source by redefining some particular user defined ifs (UD-ifs @@ -132,9 +140,9 @@ % a~group. % \CodeDefIndex\@gif \def\@gif#1#2{% - \expandafter\gdef\csname\expandafter\@gobbletwo\string#1% + \@xa\gdef\csname\@xa\@gobbletwo\string#1% g% the letter $g$ for `|\global|'. - \expandafter\@gobbletwo\string#2\endcsname + \@xa\@gobbletwo\string#2\endcsname {\global\let#1#2}} % After |\newgif\iffoo| you may type |{\foogtrue}| and the |\iffoo| @@ -171,7 +179,72 @@ \def\glet{\global\let} -% \division{\cs{@ifnextcat}} +% \LaTeX\ provides a~very useful |\g@addto@macro| macro that adds its +% second argument to the current definition of its first argument +% (works iff the first argument is a~no argument macro). But I~needed +% it some times in a~document, where |@| is not a~letter. So: +% \CodeDefine\gaddtomacro +\let\gaddtomacro=\g@addto@macro + +% The redefining of the first argument of the above macro(s) is +% |\global|. What if we want it local? Here we are: +% \CodeDefine\addto@macro +\long\def\addto@macro#1#2{% + \toks@\@xa{#1#2}% + \edef#1{\the\toks@}% +}%(|\toks@| is a~scratch register, namely |\toks0|.) + +% And for use in the very document, +% \CodeDefine\addtomacro +\let\addtomacro=\addto@macro + +%\CodeDefine\@emptify \CodeDefine\emptify +\newcommand*\@emptify[1]{\let#1=\@empty} +\@ifdefinable\emptify{\let\emptify\@emptify} + +% Note the two following commands are in fact one-argument. +%\CodeDefine\g@emptify \CodeDefine\gemptify +\newcommand*\g@emptify{\global\@emptify} +\@ifdefinable\gemptify{\let\gemptify\g@emptify} + +% \CodeDefine\@relaxen \CodeDefine\relaxen +\newcommand*\@relaxen[1]{\let#1=\relax} +\@ifdefinable\relaxen{\let\relaxen\@relaxen} + +% Note the two following commands are in fact one-argument. +% \CodeDefine\g@relaxen \CodeDefine\grelaxen +\newcommand*\g@relaxen{\global\@relaxen} +\@ifdefinable\grelaxen{\let\grelaxen\g@relaxen} + + +% For the heavy debugs I~was doing while preparing \pk{gmdoc}, as +% a~last resort I~used |\showlists|. But this command alone was +% usually too little: usually it needed setting |\showboxdepth| and +% |\showboxbreadth| to some positive values. So, +% +% \CodeDefine\gmshowlists +% \changes{v0.59}{06/09/04}{moved here from \pk{gmdoc}} +\def\gmshowlists{\showboxdepth=1000 \showboxbreadth=1000 \showlists} + +% \CodeDefine\nameshow +\newcommand*\nameshow[1]{\@xa\show\csname#1\endcsname} + + +% Standard |\string| command returns a~string of `other' chars except +% for the space, for which it returns | |$_{10}$. In \pk{gmdoc} +% I~needed the spaces in macros' and environments' names to be always +% \catother, so I~define +% \CodeDefine\xiistring +% \changes{v0.59}{06/09/04}{moved here from \pk{gmdoc}} +\def\xiistring#1{% + \if\@nx#1\twelvespace + \twelvespace + \else + \string#1% + \fi} + + +% \division{\cs{@ifnextcat}, \cs{@ifnextac}} % % As you guess, we |\def| |\@ifnextcat| \`a~la |\@ifnextchar|, see % \LaTeXe\ source dated 2003/12/01, file d, lines 253--271. The @@ -181,10 +254,14 @@ % remember from \TeXbook, the former test doesn't expand macros while % the latter does. But in |\@ifnextcat| the peeked token is protected % against expanding by |\noexpand|. Note that the first parameter is -% not protected and therefore it shall be expanded if it's a~macro. +% not protected and therefore it shall be expanded if it's +% a~macro. Because an assignment is involved, you can't test whether +% the next token is an active char. %\CodeDefine\@ifnextcat +% \changes{v0.75}{2007/01/01}{\cs{let} for \cs[\#]1 changed to +% \cs{def} to allow things like \cs{noexpand\*}} \long\def\@ifnextcat#1#2#3{% - \let\reserved@d=#1% + \def\reserved@d{#1}% \def\reserved@a{#2}% \def\reserved@b{#3}% \futurelet\@let@token\@ifncat} @@ -194,7 +271,7 @@ \ifx\@let@token\@sptoken \let\reserved@c\@xifncat \else - \ifcat\reserved@d\noexpand\@let@token + \ifcat\reserved@d\@nx\@let@token \let\reserved@c\reserved@a \else \let\reserved@c\reserved@b @@ -205,10 +282,53 @@ {\def\:{\let\@sptoken= } \: % this makes |\@sptoken| a space token. % \CodeDefIndex\@xifncat -\def\:{\@xifncat} \expandafter\gdef\: {\futurelet\@let@token\@ifncat}} -% Note the trick to achieve a~macro with no parameter and requiring +\def\:{\@xifncat} \@xa\gdef\: {\futurelet\@let@token\@ifncat}} +% Note the trick to get a~macro with no parameter and requiring % a~space after it. We do it inside a~group not to spoil the general % meaning of |\:| (which we extend later). +% \dekmedskip +% +% But how to peek at the next token to check whether it's an active +% char? First, we look with |\@ifnextcat| whether there stands a~group +% opener. We do that to avoid taking a~whole |{...}| as the argument +% of the next macro, that doesn't use |\futurelet| but takes the next +% token as an argument, tests it and puts back intact. +% \CodeDefine\@ifnextac +% \changes{v0.75}{2007/01/11}{added} +% +\long\def\@ifnextac#1#2{% + \@ifnextcat\bgroup{#2}{\gm@ifnac{#1}{#2}}} + +\long\def\gm@ifnac#1#2#3{% + \ifcat\@nx~\@nx#3\afterfi{#1#3}\else\afterfi{#2#3}\fi} + +% Yes, it won't work for an active char |\let| to |{|${}_1$, but it +% \emph{will} work for an active char |\let| to a~char of +% catcode${}\neq1$. (Is there anybody on Earth who'd make an active +% char working as |\bgroup|?) +% +% \stanza Now, define a~test that checks whether the next token is +% a~genuine space, | |${}_{10}$ that is. First define a~CS let such +% a~space. The assignment needs a~little trick (\TeXbook\ appendix D) +% since |\let|'s syntax includes one optional space after |=|. +% +\let\@tempa\*% +\def\*{% + \let\*\@tempa + \let\gm@letspace= }% +\* % + +% \CodeDefine\@ifnextspace +\def\@ifnextspace#1#2{% + \let\@reserveda\*% + \def\*{% + \let\*\@reserveda + \ifx\@let@token\gm@letspace\afterfi{#1}% + \else\afterfi{#2}% + \fi}% + \futurelet\@let@token\*} +% First use of this macro is for an active |-| that expands to |---| +% if followed by a~space. % \division{\cs{afterfi} and Pals} @@ -223,25 +343,29 @@ % % I~think the situations when the Knuthian (the former) trick is not % available are rather seldom, but they are imaginable at least: the -% |\next| trick involves an assignment so it won't work e.g. in +% |\next| trick involves an assignment so it won't work e.g.\ in % |\edef|. But in general it's only a~matter of taste which one to % use. % -% \CodeDefine\afterfi \CodeDefine\afterfifi \CodeDefine\afterelsefi -% \CodeDefine\afterelsefifi \CodeDefine\afterelseiffifi +% One warning: those macros peel the braces off, i.e., +% \[|\if..\afterfi{\@makeother\^^M}\fi|\] +% causes a~leakage of +% |^^M|\catother. To avoid pollution write +% \[|\if..\afterfi{\bgroup\@makeother\^^M\egroup}\fi|\,.\] +% +% \CodeDefine\afterfi \CodeDefine\afterfifi +% \CodeDefine\afteriffifi -\long\def\afterfi#1\fi{\fi#1} -% One more of that family: -\long\def\afterelsefifi#1\else#2\fi#3\fi{\fi\fi#1} -% \dots\ and some other: -\long\def\afterelsefi#1\else#2\fi{\fi#1} -\long\def\afterfifi#1\fi#2\fi{\fi\fi#1} -\long\def\afterelseiffifi#1\else#2\if#3\fi#4\fi{\fi#1} -% Note, if you fancy this smart trick, that some `|else|' cases are -% covered by proper non-|else| |\after...|\ macros, e.g., -% |\afterfielsefi|'s task would be fulfilled by |\afterfifi| and -% |\afterelsefifi| covers also the `|\afterelsefielsefi|' case. +\long\def\afterfi#1#2\fi{\fi#1} +% And two more of that family: +\long\def\afterfifi#1#2\fi#3\fi{\fi\fi#1} +\long\def\afteriffifi#1#2\if#3\fi#4\fi{\fi#1} +% Notice the refined elegance of those macros, that cover both `then' +% and `else' cases thanks to |#2| that is discarded. +\long\def\afterififfififi#1#2\fi#3\fi#4\fi{\fi#1} +\long\def\afteriffififi#1#2\fi#3\fi#4\fi{\fi\fi#1} +\long\def\afterfififi#1#2\fi#3\fi#4\fi{\fi\fi\fi#1} % \division{Almost an Environment or Redefinition of \cs{begin}} % @@ -313,8 +437,8 @@ % we ensure the compared texts are both expanded and made all `other'. \def\@checkend#1{% - \edef\reserved@a{\expandafter\string\csname#1\endcsname}% - \edef\exii@currenvir{\expandafter\string\csname\@currenvir\endcsname}% + \edef\reserved@a{\@xa\string\csname#1\endcsname}% + \edef\exii@currenvir{\@xa\string\csname\@currenvir\endcsname}% \ifx\reserved@a\exii@currenvir\else\@badend{#1}\fi} % Thanks to it you may write |\begin{macrocode*}| with |*|\catother @@ -372,7 +496,7 @@ \advance\@tempcnta#1\relax % watch out for size underflow: \ifnum\@tempcnta<\z@ \rs@size@warning{small}{\string\tiny}\@tempcnta\z@ \fi - \expandafter\endgroup + \@xa\endgroup \ifcase\@tempcnta % set new size based on altered number \tiny \or \scriptsize \or \footnotesize \or \small \or \normalsize \or \large \or \Large \or \LARGE \or \huge \or \Huge \else @@ -495,7 +619,7 @@ % the whole thing inside an |\nfss@text| box in that case. % \end{quotation} \ensuremath\langle - \ifmmode \expandafter \nfss@text \fi + \ifmmode \@xa \nfss@text \fi {% \meta@font@select % Need to keep track of what we changed just in case the user changes font inside @@ -538,7 +662,7 @@ % A~tiny little macro that acts like |\-| outside the math mode and % has its original meaning inside math. -\def\:{\ifmmode\afterelsefi\mskip\medmuskip\else\afterfi\discret{}\fi} +\def\:{\ifmmode\afterfi{\mskip\medmuskip}\else\afterfi{\discret{}}\fi} % \CodeDefine\vs \newcommand*{\vs}{\discre{\textvisiblespace}{}{\textvisiblespace}} @@ -570,8 +694,7 @@ % The below macro I~use to format the packages' names. % \CodeDefine\pk \CodeDefine\file -\@ifundefined{pk}{% - \DeclareRobustCommand*{\pk}[1]{\textsf{\textup{#1}}}}{} +\DeclareRobustCommand*{\pk}[1]{\textsf{\textup{#1}}} % Some (if not all) of the below macros are copied from \pk{doc} % and/or \pk{ltxdoc}. @@ -582,13 +705,13 @@ % boldface sometimes. % % \CodeDefine\cs -\@ifundefined{cs}{\DeclareRobustCommand*{\cs}[2][\bslash]{{% +\DeclareRobustCommand*{\cs}[2][\bslash]{{% \def\-{\discretionary{{\rmfamily-}}{}{}}% - \def\{{\char`\{}\def\}{\char`\}}\ttfamily #1#2}}}{} + \def\{{\char`\{}\def\}{\char`\}}\ttfamily #1#2}} % \CodeDefine\env % \changes{v0.66}{06/09/29}{the braces removed} -\@ifundefined{env}{\DeclareRobustCommand*{\env}[1]{\cs[]{#1}}}{} +\DeclareRobustCommand*{\env}[1]{\cs[]{#1}} % And one for encouraging linebreaks e.g., before long verbatim words. % \CodeDefine\possfil \newcommand*\possfil{\hfil\penalty1000\hfilneg} @@ -601,7 +724,7 @@ % |\outer|).\end{quotation} % % \CodeDefine\cmd -\def\cmd#1{\cs{\expandafter\cmd@to@cs\string#1}} +\def\cmd#1{\cs{\@xa\cmd@to@cs\string#1}} % \CodeDefIndex\cmd@to@cs \def\cmd@to@cs#1#2{\char\number`#2\relax} @@ -628,8 +751,10 @@ % \CodeDefine\arg \AtBeginDocument{% \let\math@arg\arg - \def\arg{\ifmmode\math@arg\else\afterfi - \@ifnextchar[\@oargsq{\@ifnextchar(\@pargp\marg}\fi}%^^A)] + \def\arg{\ifmmode\math@arg\else\afterfi{% + \@ifnextchar[%^^A] + \@oargsq{\@ifnextchar(%^^A) + \@pargp\marg}}\fi}% } % \division{Storing and Restoring the Meanings of CSs} @@ -641,13 +766,28 @@ %\CodeDefine\StoreMacro %\changes{v0.61}{06/09/05}{added.} %\changes{v0.67}{06/10/11}{enriched with \cs{makeatletter}} -\def\StoreMacro{\bgroup\makeatletter\egStore@Macro} +\def\StoreMacro{% + \bgroup\makeatletter\@ifstar\egStore@MacroSt\egStore@Macro} + \long\def\egStore@Macro#1{\egroup\Store@Macro{#1}} +\long\def\egStore@MacroSt#1{\egroup\Store@MacroSt{#1}} + \long\def\Store@Macro#1{% - \expandafter\let\csname /gml/store\string#1\endcsname#1} + \@xa\let\csname /gml/store\string#1\endcsname#1} + +\long\def\Store@MacroSt#1{% + \edef\gmu@smtempa{% + \@nx\let\@xa\@nx\csname/gml/store#1\endcsname\@xa\@nx\csname#1\endcsname} + \gmu@smtempa} % We make the |\StoreMacro| command a~three-step to allow usage of the % most inner macro also in the next command. % +% The starred version, |\StoreMacro*| works with csnames (without the +% backslash). It's first used to store the meanings of robust +% commands, when you may need to store not only |\foo|, but also +% |\csname foo \endcsname|. +% +% % The next command iterates over a~list of CSs and stores each of % them. The CS may be separated with commas but they don't have to. % \CodeDefine\StoreMacros @@ -659,14 +799,14 @@ % And the inner iterating macro: \long\def\gml@storemacros#1{% - \def\@tempa{\noexpand#1}% My \TeX\ Guru's trick to deal with |\fi| + \def\@tempa{\@nx#1}% My \TeX\ Guru's trick to deal with |\fi| % and such, i.e., to hide |#1| from \TeX\ when it is processing a~test's % branch without expanding. \if\@tempa.% a~dot finishes storing. \else \if\@tempa,% The list this macro is put before may % contain commas and that's O.K., we just continue the work. - \afterelsefifi\gml@storemacros + \afterfifi\gml@storemacros \else% what is else this shall be stored. \gml@StoreCS{#1}% we use a~particular CS to may |\let| it both to % the storing macro as above and to the restoring one as @@ -679,10 +819,19 @@ %\CodeDefine\RestoreMacro %\changes{v0.61}{06/09/05}{added.} %\changes{v0.67}{06/10/11}{enriched with \cs{makeatletter}} -\def\RestoreMacro{\bgroup\makeatletter\egRestore@Macro} +\def\RestoreMacro{% + \bgroup\makeatletter\@ifstar\egRestore@MacroSt\egRestore@Macro} + \long\def\egRestore@Macro#1{\egroup\Restore@Macro{#1}} +\long\def\egRestore@MacroSt#1{\egroup\Restore@MacroSt{#1}} + \long\def\Restore@Macro#1{% - \expandafter\let\expandafter#1\csname /gml/store\string#1\endcsname} + \@xa\let\@xa#1\csname /gml/store\string#1\endcsname} + +\long\def\Restore@MacroSt#1{% + \edef\gmu@smtempa{% + \@nx\let\@xa\@nx\csname#1\endcsname\@xa\@nx\csname/gml/store#1\endcsname} + \gmu@smtempa} % \CodeDefine\RestoreMacros \long\def\RestoreMacros{\bgroup\makeatletter\Restore@Macros} @@ -712,9 +861,10 @@ % \changes{v0.61}{06/09/05}{renamed from \cs{MacroStoringDo} and the % storing cs's prefix changed from \cs[]{@gml@srs}.} \long\def\StoringAndRelaxingDo{% - \def\do##1{\expandafter\let\csname /gml/store\string##1\endcsname##1% + \def\do##1{\@xa\let\csname /gml/store\string##1\endcsname##1% \let##1\relax}} + % And here is the counter-definition for restore. % % \CodeDefine\RestoringDo @@ -724,16 +874,51 @@ % relaxing of the storing cs removed.} \long\def\RestoringDo{% \def\do##1{% - \expandafter\let\expandafter##1\csname /gml/store\string##1\endcsname}} + \@xa\let\@xa##1\csname /gml/store\string##1\endcsname}} % And to store a~cs as explicitly named cs, i.e. to |\let| one csname -% another: -\def\@namelet#1#2{% +% another (|\n@melet| not |\@namelet| becasuse the latter is defined +% in Till Tantau's \pk{beamer} class another way): +\def\n@melet#1#2{% \edef\@tempa{% - \let\expandafter\noexpand\csname#1\endcsname - \expandafter\noexpand\csname#2\endcsname}% + \let\@xa\@nx\csname#1\endcsname + \@xa\@nx\csname#2\endcsname}% \@tempa} + +% \division{Not only preamble!} +% Let's remove some commands from the list to erase at begin document! +% Primarily that list was intended to save memory not to forbid +% anything. Nowadays, when memory is cheap, the list of only-preamble +% commands should be rethought \IMO. + +\newcommand\not@onlypreamble[1]{% + \def\do##1{\ifx#1##1\else\@nx\do\@nx##1\fi}% + \edef\@preamblecmds{\@preamblecmds}} + +\not@onlypreamble\@preamblecmds +\not@onlypreamble\@ifpackageloaded +\not@onlypreamble\@ifclassloaded +\not@onlypreamble\@ifl@aded +\not@onlypreamble\@pkgextension + +% And let's make the message of only preamble command's forbidden use +% informative a~bit: + +\def\gm@notprerr{ can be used only in preamble (\on@line)} + +\AtBeginDocument{% + \def\do#1{\@nx\do\@nx#1}% + \edef\@preamblecmds{% + \def\@nx\do##1{% + \def##1{! \@nx\string##1 \@nx\gm@notprerr}}% + \@preamblecmds}} + + + + + + % \division{Third Person Pronouns} % % Is a~reader of my documentations `she' or 'he' and does it make @@ -813,6 +998,7 @@ % e.g. % + % \division{Improvements to \pk{mwcls} Sectioning Commands} % % That is, `Expe-ri-mente'\footnote{A.\ Berg, \textit{Wozzeck}.} mit MW @@ -860,8 +1046,9 @@ % \CodeDefine\@ifnotmw \long\def\@ifnotmw#1#2{\@ifundefined{mw@sectionxx}{#1}{#2}} +\let\gmu@def\def \@ifnotmw{% - \StoreMacro\def \def\def#14#2{\RestoreMacro\def}}{} + \StoreMacro\gmu@def \def\gmu@def#14#2{\RestoreMacro\gmu@def}}{} % I~know it may be of bad taste (to write such a~way \emph{here}) but % I~feel so lonely and am in an alien state of mind after 3 hour sleep % last night and, worst of all, listening to sir Edward Elgar's flamboyant @@ -880,7 +1067,7 @@ % |\let| not |\def|. % The kernel of MW's sectioning commands: -\def\mw@sectionxx#1#2[#3]#4{% +\gmu@def\mw@sectionxx#1#2[#3]#4{% \edef\mw@HeadingLevel{\csname #1@level\endcsname \space}% space delimits level number! \ifHeadingNumbered @@ -949,6 +1136,8 @@ } %%%% (End of Experimente with MW sectioning.) + + % % \division{Compatibilising Standard and \pk{mwcls} Sectionings} % @@ -995,13 +1184,13 @@ % \CodeDefine\gm@secxx \def\gm@secxx#1#2[#3]#4{% \ifx\gm@secstar\@empty - \@namelet{gm@true@#1mark}{#1mark}% a~little trick to allow + \n@melet{gm@true@#1mark}{#1mark}% a~little trick to allow % a~special version of the heading just to the running head. \@namedef{#1mark}##1{% we redefine \cs{\<sec>mark} to gobble its % argument and to launch the stored true marking command on the % appropriate argument. \csname gm@true@#1mark\endcsname{#2}% - \@namelet{#1mark}{gm@true@#1mark}% after we've done what we + \n@melet{#1mark}{gm@true@#1mark}% after we've done what we % wanted we restore original |\#1mark|. }% \def\gm@secstar{[#3]}% if |\gm@secstar| @@ -1010,7 +1199,7 @@ % optional argument. Otherwise the sectioning command was written % with star so the `true' s.c.\ takes no optional. \fi - \expandafter\expandafter\csname\gm@secini#1\endcsname + \@xa\@xa\csname\gm@secini#1\endcsname \gm@secstar{#4}}% % \stanza }{% we are in \pk{mwcls} and want to reverse MW's optionals order @@ -1022,7 +1211,7 @@ % tricks for special version to running headings. % \CodeDefine\gm@secxx \def\gm@secxx#1#2[#3]#4{% - \expandafter\expandafter\csname\gm@secini#1\endcsname + \@xa\@xa\csname\gm@secini#1\endcsname \gm@secstar[#2][#3]{#4}}% } @@ -1035,7 +1224,7 @@ \def\gm@straightensec#1{% the parameter is for the command's name. \@ifundefined{#1}{}{% we don't change the ontological status of the % command because someone may test it. - \@namelet{\gm@secini#1}{#1}% + \n@melet{\gm@secini#1}{#1}% \@namedef{#1}{% \@ifstar{\def\gm@secstar{*}\gm@sec{#1}}{% \def\gm@secstar{}\gm@sec{#1}}}}% @@ -1048,90 +1237,187 @@ % capacity exceeded' error. Anyway, who on Earth wants paragraph % titles in toc or running head? % + +% \division{\env{enumerate*} and \env{itemize*}} +% We wish the starred version of \env{enumerate} to be just numbered +% paragraphs. But \pk{hyperref} redefines |\item| so we should do it +% a~smart way, to set the \LaTeX's \env{list} parameters that is. % +% (Marcin Woli\'nski in \pk{mwcls} defines those environments slightly +% different: his item labels are indented, mine are not; his +% subsequent paragraphs of an item are not indented, mine are.) % -%\division{Varia} +% \CodeDefine*{enumerate*} +\@namedef{enumerate*}{% + \ifnum\@enumdepth>\thr@@ + \@toodeep + \else + \advance\@enumdepth\@ne + \edef\@enumctr{enum\romannumeral\the\@enumdepth}% + \@xa\list\csname label\@enumctr\endcsname{% + \partopsep\topsep \topsep\z@ \leftmargin\z@ + \itemindent\@parindent %\advance\itemindent\labelsep + \labelwidth\@parindent + \advance\labelwidth-\labelsep + \listparindent\@parindent + \usecounter \@enumctr + \def\makelabel##1{##1\hfil}}% + \fi} +\@namedef{endenumerate*}{\endlist} + +% \CodeDefine*{itemize*} +\@namedef{itemize*}{% + \ifnum\@itemdepth>\thr@@ + \@toodeep + \else + \advance\@itemdepth\@ne + \edef\@itemitem{labelitem\romannumeral\the\@itemdepth}% + \@xa\list\csname\@itemitem\endcsname{% + \partopsep\topsep \topsep\z@ \leftmargin\z@ + \itemindent\@parindent + \labelwidth\@parindent + \advance\labelwidth-\labelsep + \listparindent\@parindent + \def\makelabel##1{##1\hfil }}% + \fi} +\@namedef{enditemize*}{\endlist} + + +% \division{The Logos} % -% \LaTeX\ provides a~very useful |\g@addto@macro| macro that adds its -% second argument to the current definition of its first argument -% (works iff the first argument is a~no argument macro). But I~needed -% it some times in a~document, where |@| is not a~letter. So: -% \CodeDefine\gaddtomacro -\let\gaddtomacro=\g@addto@macro +% We'll modify The \LaTeX\ logo now to make it fit better to various +% fonts. -% The redefining of the first argument of the above macro(s) is -% |\global|. What if we want it local? Here we are: -% \CodeDefine\addto@macro -\long\def\addto@macro#1#2{% - \toks@\expandafter{#1#2}% - \edef#1{\the\toks@}% -}%(|\toks@| is a~scratch register, namely |\toks0|.) +\let\oldLaTeX\LaTeX +\let\oldLaTeXe\LaTeXe + +\def\TeX{T\kern-.1667em\lower.5ex\hbox{E}\kern-.125emX\@} + +\newcommand*\DeclareLogo[3][\relax]{% + % |#1| is for non-\LaTeX\ spelling and will be used in the PD1 + % encoding (to make pdf bookmarks);\\ + % |#2| is the command, its name will be the PD1 spelling by + % default,\\ + % |#3| is the definition for all the font encodings except PD1. + \ifx\relax#1\def\@tempa{\@xa\@gobble\string#2}% + \else + \def\@tempa{#1}% + \fi + \edef\@tempa{% + \@nx\DeclareTextCommand\@nx#2{PD1}{\@tempa}} + \@tempa + \DeclareTextCommandDefault#2{#3}} + + +\DeclareLogo\LaTeX{% + {% + L% + \setbox\z@\hbox{\check@mathfonts + \fontsize\sf@size\z@ + \math@fontsfalse\selectfont + A}% + \kern-.57\wd\z@ + \sbox\tw@ T% + \vbox to\ht\tw@{\copy\z@ \vss}% + \kern-.2\wd\z@}% originally $-,15$\,em for T. + {% + \ifdim\fontdimen1\font=\z@ + \else + \count\z@=\fontdimen5\font + \multiply\count\z@ by 64\relax + \divide\count\z@ by\p@ + \count\tw@=\fontdimen1\font + \multiply\count\tw@ by\count\z@ + \divide\count\tw@ by 64\relax + \divide\count\tw@ by\tw@ + \kern-\the\count\tw@ sp\relax + \fi}% + \TeX} + + +\DeclareLogo\LaTeXe{\mbox{\m@th \if + b\expandafter\@car\f@series\@nil\boldmath\fi + \LaTeX\kern.15em2$_{\textstyle\varepsilon}$}} -% And for use in the very document, -% \CodeDefine\addtomacro -\let\addtomacro=\addto@macro % `\LaTeXpar' in my opinion better describes what I~work with/in than % just `\LaTeX'. % \CodeDefine\LaTeXpar -\DeclareRobustCommand*{\LaTeXpar}{(L\kern-.36em% - {\sbox\z@ T% - \vbox to\ht\z@{\hbox{\check@mathfonts - \fontsize\sf@size\z@ - \math@fontsfalse\selectfont - A}% - \vss}% - }% - \kern-.07em% originally $-,15$\,em - )\TeX} +\DeclareLogo[(La)TeX]{\LaTeXpar}{% + {% + \setbox\z@\hbox{(}%) + \copy\z@ + \kern-.2\wd\z@ L% + \setbox\z@\hbox{\check@mathfonts + \fontsize\sf@size\z@ + \math@fontsfalse\selectfont + A}% + \kern-.57\wd\z@ + \sbox\tw@ T% + \vbox to\ht\tw@{\box\z@% + \vss}% + }% + \kern-.07em% originally $-,15$\,em for T. + {%( + \sbox\z@)% + \kern-.2\wd\z@\copy\z@ + \kern-.2\wd\z@}\TeX +} -%\CodeDefine\@emptify \CodeDefine\emptify -\newcommand*\@emptify[1]{\let#1=\@empty} -\@ifdefinable\emptify{\let\emptify\@emptify} -% Note the two following commands are in fact one-argument. -%\CodeDefine\g@emptify \CodeDefine\gemptify -\newcommand*\g@emptify{\global\@emptify} -\@ifdefinable\gemptify{\let\gemptify\g@emptify} +% \division{Expanding turning stuff all into `other'} -% \CodeDefine\@relaxen \CodeDefine\relaxen -\newcommand*\@relaxen[1]{\let#1=\relax} -\@ifdefinable\relaxen{\let\relaxen\@relaxen} +% While typesetting a~unicode file contents with \pk{inputenc} package +% I~got a~trouble with some Unicode sequences that expanded to +% unexpandable CSs: they could'nt be used within +% |\csname...\endcsname|. My \TeX Guru advised to use |\meanig| to +% make all the name `other'. So---here we are. +% +% Don't use them in |\edef|s, they would expand not quite. +% \CodeDefine\unex@namedef \CodeDefine\unex@nameuse -% Note the two following commands are in fact one-argument. -% \CodeDefine\g@relaxen \CodeDefine\grelaxen -\newcommand*\g@relaxen{\global\@relaxen} -\@ifdefinable\grelaxen{\let\grelaxen\g@relaxen} +% The next macro turns its |#2| all into `other' chars and assigns +% them to |#1| which has to be a~CS or an active char. +% +% \CodeDefine\def@other -% For the heavy debugs I~was doing while preparing \pk{gmdoc}, as -% a~last resort I~used |\showlists|. But this command alone was -% usually too little: usually it needed setting |\showboxdepth| and -% |\showboxbreadth| to some positive values. So, +\long\def\def@other#1#2{% + \long\def\gm@def@other@tempa{#2}% + \all@other#1{#2}} + +% The next macro is intended to be put in |\edef|s with a~macro +% argument. The meaning of the macro will be made all `other' and the +% words '(long) macro:->' gobbled. +%\CodeDefine\all@other +\def\all@other#1{\@xa\gm@gobmacro\meaning#1} + +% The |\gm@gobmacro| macro above is applied to gobble the |\meaning|'s +% beginnig, |long macro:->| all `other' that is. % -% \CodeDefine\gmshowlists -% \changes{v0.59}{06/09/04}{moved here from \pk{gmdoc}} -\def\gmshowlists{\showboxdepth=1000 \showboxbreadth=1000 \showlists} +% \CodeDefine\gm@gobmacro +\edef\@tempa{% + \def\@nx\gm@gobmacro##1\@xa\@gobble\string\macro:->{}} +\@tempa -% \CodeDefine\nameshow -\newcommand*\nameshow[1]{\expandafter\show\csname#1\endcsname} +% In the next two macros' names, `unex' stands both for not expanding +% the argument(s) and for disastrously partial unexpandability of the +% macros themselves. +\long\def\unex@namedef#1#2{% + \edef@other\gmu@tempa{#1}% + \@xa\long\@xa\def\csname\gmu@tempa\endcsname{#2}} -% Standard |\string| command returns a~string of `other' chars except -% for the space, for which it returns | |$_{10}$. In \pk{gmdoc} -% I~needed the spaces in macros' and environments' names to be always -% \catother, so I~define -% \CodeDefine\xiistring -% \changes{v0.59}{06/09/04}{moved here from \pk{gmdoc}} -\def\xiistring#1{% - \if\noexpand#1\twelvespace - \twelvespace - \else - \string#1% - \fi} + +\long\def\unex@nameuse#1{% + \edef@other\gmu@tempa{#1}% + \csname\gmu@tempa\endcsname} +%\division{Varia} +% + % A~very neat macro provided by \pk{doc}. I~copy it % \*|verbatim|. % \CodeDefine\* @@ -1158,7 +1444,7 @@ % \changes{v0.62}{06/09/07}{moved from \pk{pmlectionis.cls}} \bgroup\catcode`\^^M\active% the comment signs here are crucial. \firstofone{\egroup% -\newcommand*\defobeylines{\catcode`\^^M=13 \def^^M{\par}}}% +\def\defobeylines{\catcode`\^^M=13 \def^^M{\par}}}% % Another thing I~dislike in \LaTeX\ yet is doing special things for % |\...skip|'s, 'cause I~like the Knuthian simplicity. So I~sort of @@ -1224,7 +1510,7 @@ \RequirePackage{multicol}% \def\@starttoc##1{% \begin{multicols}{2}\makeatletter\@input {\jobname .##1}% - \if@filesw \expandafter \newwrite \csname tf@##1\endcsname + \if@filesw \@xa \newwrite \csname tf@##1\endcsname \immediate \openout \csname tf@##1\endcsname \jobname .##1\relax \fi \@nobreakfalse\end{multicols}}} @@ -1241,25 +1527,6 @@ \advance\dimen0 by-\pagetotal \ifdim\dimen0<#1\relax\newpage\fi} -% The |\dots| didn't come out well. My small investigation revealed -% a~mysterious replacement of the original \LaTeX\ definition of -% |\textellipsis| with -% \begin{verbatim} -%> \textellipsis=macro: -%->\PD1-cmd \textellipsis \PD1\textellipsis . -% \end{verbatim} -% \par So, let's ensure |\dots| are given the proper kerning: -% \CodeDefine\ltxtextellipsis\CodeDefine\dots -\DeclareTextCommandDefault\ltxtextellipsis{% - .\kern\fontdimen3\font - .\kern\fontdimen3\font - .\kern\fontdimen3\font} - -\DeclareRobustCommand*\dots{% - \ifmmode\mathellipsis\else\ltxtextellipsis\fi} - -\let\ldots\dots - % Two shorthands for debugging: %\CodeDefine\tOnLine\CodeDefine\OnAtLine \newcommand*\tOnLine{\typeout{\on@line}} @@ -1276,11 +1543,105 @@ % \CodeDefine\jobnamewoe \def\gm@jobn#1.#2\@@nil{#1} -\def\jobnamewoe{\expandafter\gm@jobn\jobname.\@@nil}% We add the dot +\def\jobnamewoe{\@xa\gm@jobn\jobname.\@@nil}% We add the dot % to be sure there is one although I'm not sure whether you can \TeX\ % a~file that has no extrension. + +% While typesetting a~UTF-8 ls-R result I~found a~difficulty that +% follows: UTF-8 encoding is handled by the \pk{inputenc} +% package. It's O.K. so far. The UTF-8 sequences are managed using +% active chars. That's O.K. so far. While writing such sequences to +% a~file, the active chars expand. You feel the blues? When the result of +% expansion is read again, it sometimes is again an active char, but +% now it doesn't star a~correct UTF-8 sequence. +% +% Because of that I~wanted to `freeze' the active chars so that they +% would be |\write|n to a~file unexpanded. A~very brutal operation is +% done: we look at all 256 chars' catcodes and if we find an active +% one, we |\let| it |\relax|. As the macro does lots and lots of +% assignments, it shouldn't be used in |\edef|s. +% +% \CodeDefine\freeze@actives +% \changes{v0.76}{2007/02/07}{added} + +\def\freeze@actives{% + \count\z@\z@ + % + \@whilenum\count\z@<\@cclvi\do{% + \ifnum\catcode\count\z@=\active + \uccode`\~=\count\z@ + \uppercase{\let~\relax}% + \fi + \advance\count\z@\@ne}} + + +% A~macro that typesets all 256 chars of given font. It makes use of +% |\@whilenum|. \CodeDefine\ShowFont + +\newcommand*\ShowFont[1][6]{% + \begin{multicols}{#1}[The current font (the \f@encoding\ encoding):] + \parindent\z@ + \count\z@\m@ne + \@whilenum\count\z@<\@cclv\do{ + \advance\count\z@\@ne + \ \the\count\z@:~\char\count\z@\par} + \end{multicols}} + + +% A~couple of macros for typesetting liturgic texts such as psalmody +% of Liturgia Horarum. I~wrap them into a~declaration since they'll be +% needed not every time. +% \CodeDefine\liturgiques +% \changes{v0.76}{07/3/30}{added, or rather moved from \file{Akatyst.tex}} +\newcommand*\liturgiques[1][red]{% Requires the \pk{color} package. + \gmu@RP{color}% + \newcommand*\czerwo{\small\color{#1}}% environment + \newcommand{\czer}[1]{\leavevmode{\czerwo##1}}% we leave + % vmode because if we don't, then \env{verse}'s |\everypar| would be + % executed in a~group and thus its effect lost. + \def\*{\czer{$*$}} + \def\+{\czer{$\dag$}} + \newcommand*\nieczer[1]{\textcolor{black}{##1}}} + +% A~command that issues a~message urging to load a~package if it has +% not been loaded. +\let\gmu@RP\RequirePackage + +% \CodeDefine\gmu@RP +\AtBeginDocument{% + \renewcommand*\gmu@RP[2][]{% + \@ifpackageloaded{#2}{}{% + \typeout{^^J! Package `#2' not loaded!!! (\on@line)^^J}}}} + + +% It's very strange to me but it seems that $\continuum$ is not +% defined in the basic math packages. It is missing at least in the +% \textit{Symbols} book.\CodeDefine\continuum +\providecommand*\continuum{\gmu@RP{eufrak}\mathfrak{c}} + +% And this macro I~saw in the \pk{ltugproc} document class nad I~liked +% it. +\providecommand*\acro[1]{{\scshape\lowercase{#1}}} + +\newcommand*\IMO{\acro{IMO}} +\newcommand*\AKA{\acro{AKA}} + + + +% Probably the only use of it is loading \pk{gmdocc.cls} `as second +% class'. This command takes first argument optional, options of the +% class, and second mandatory, the class name. I~use it in an article +% about \pk{gmdoc}. +\def\secondclass{% + \newif\ifSecondClass + \SecondClasstrue + \@fileswithoptions\@clsextension}%|[outeroff,gmeometric]{gmdocc}|% +% it's loading \pk{gmdocc.cls} with all the bells and whistles except +% the error message. + + \endinput % % \changes{v0.70}{06/10/20}{Package renamed to \pk{gmutils} from @@ -1294,13 +1655,23 @@ % only one optional, it's the title to toc and running head not just % to the latter} % +% \changes{v0.76}{2007/03/10}{A~`fixing' of \cs{dots} was rolled back +% since it came out they were O.K. and that was the QX encoding that +% prints them very tight} % +% \changes{v0.77}{2007/04/13}{\cs{afterfi} \& pals made two-argument +% as the Marcin Woli\'nski's analogoi are. At this occasion some +% redundant macros of that family are deleted} +% +% \changes{v0.78}{2007/04/26}{\cs{@namelet} renamed to \cs{n@melet} +% to solve a~conflict with the \pk{beamer} class. The package contents +% regrouped} % % \PrintChanges\PrintIndex %\NoEOF % (For my GNU Emacs:) %%% Local Variables: -%%% mode: latex -%%% TeX-master: "e:/LaTeX/TeXGuru/gmutils/gmutilsDoc" +%%% mode: doctex +%%% TeX-master: "../../../../LaTeX/TeXGuru/gmutils/gmutilsDoc.tex" %%% End: |