From e0c6872cf40896c7be36b11dcc744620f10adf1d Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Mon, 2 Sep 2019 13:46:59 +0900 Subject: Initial commit --- macros/latex/contrib/gmutils/README | 69 + macros/latex/contrib/gmutils/gmRCS.sty | 68 + macros/latex/contrib/gmutils/gmampulex.sty | 215 ++ macros/latex/contrib/gmutils/gmbase.sty | 3050 +++++++++++++++++++++++ macros/latex/contrib/gmutils/gmcommand.sty | 2432 ++++++++++++++++++ macros/latex/contrib/gmutils/gmenvir.sty | 143 ++ macros/latex/contrib/gmutils/gmlogos.sty | 232 ++ macros/latex/contrib/gmutils/gmmeta.sty | 292 +++ macros/latex/contrib/gmutils/gmmw.sty | 363 +++ macros/latex/contrib/gmutils/gmnotonlypream.sty | 88 + macros/latex/contrib/gmutils/gmparts.sty | 165 ++ macros/latex/contrib/gmutils/gmrelsize.sty | 80 + macros/latex/contrib/gmutils/gmtypos.sty | 2099 ++++++++++++++++ macros/latex/contrib/gmutils/gmurl.sty | 301 +++ macros/latex/contrib/gmutils/gmutils.pdf | Bin 0 -> 1759395 bytes macros/latex/contrib/gmutils/gmutils.sty | 136 + 16 files changed, 9733 insertions(+) create mode 100644 macros/latex/contrib/gmutils/README create mode 100644 macros/latex/contrib/gmutils/gmRCS.sty create mode 100644 macros/latex/contrib/gmutils/gmampulex.sty create mode 100644 macros/latex/contrib/gmutils/gmbase.sty create mode 100644 macros/latex/contrib/gmutils/gmcommand.sty create mode 100644 macros/latex/contrib/gmutils/gmenvir.sty create mode 100644 macros/latex/contrib/gmutils/gmlogos.sty create mode 100644 macros/latex/contrib/gmutils/gmmeta.sty create mode 100644 macros/latex/contrib/gmutils/gmmw.sty create mode 100644 macros/latex/contrib/gmutils/gmnotonlypream.sty create mode 100644 macros/latex/contrib/gmutils/gmparts.sty create mode 100644 macros/latex/contrib/gmutils/gmrelsize.sty create mode 100644 macros/latex/contrib/gmutils/gmtypos.sty create mode 100644 macros/latex/contrib/gmutils/gmurl.sty create mode 100644 macros/latex/contrib/gmutils/gmutils.pdf create mode 100644 macros/latex/contrib/gmutils/gmutils.sty (limited to 'macros/latex/contrib/gmutils') diff --git a/macros/latex/contrib/gmutils/README b/macros/latex/contrib/gmutils/README new file mode 100644 index 0000000000..cacdb870ac --- /dev/null +++ b/macros/latex/contrib/gmutils/README @@ -0,0 +1,69 @@ +The gmutils package +is a work of Grzegorz `Natror' Murzynowski, + + + +1. Copyright 2006, 2007, 2008, 2009, 2010 by Grzegorz `Natror' Murzynowski + +This program is subject to the LaTeX Project Public License. +See http://www.ctan.org/tex-archive/help/Catalogue/licenses.lppl.html +for the details of that license. + + +2. Introduction + +The gmutils.sty package provides some macros that are analogous to +the standard LaTeX ones but extend their functionality, such as +\@ifnextcat, \addtomacro or \begin(*). The others are just +conveniences I like to use in all my TeX works, such as \afterfi, \pk +or \cs. + +I wouldn't say they are only for the package writers but I assume +some nonzero (La)TeX-awareness of the user. + + +3. Installation + +Unpack the gmutils-tds.zip archive in some texmf directory or put the +gmutils.sty somewhere in the texmf/tex/latex branch on your +own. (Creating a /texmf/tex/latex/gm directory may be advisable if you +consider using other packages written by me.) + +Then you should refresh your TeX distribution's files' +database most probably. + + +4. Contents + +The distribution of this package consists of the following three files and a TDS-compliant archive. + +gmutils.sty +README +gmutils.pdf +gmutils-tds.zip + +5. Documentation + +The last of the above files (the .pdf) is a documentation compiled +from the .sty file by running LaTeX on the gmutils.sty file twice: +xelatex gmutils.sty + in the directory you wish the documentation to be in, +you don't have copy the .sty file there---TeX will find it, +then MakeIndex on the gmutils.idx file, and then LaTeX +on gmutilsDoc.tex once more. + +MakeIndex shell command: + makeindex -r gmutilsDoc +The -r switch is to forbid MakeIndex make implicit ranges since the +(code line) numbers will be hyperlinks + +Compiling of the documentation requires the packages: gmdoc +(gmdoc.sty and gmdocc.cls), gmverb.sty, gmutils.sty and also some +standard packages: hyperref.sty, xcolor.sty, geometry.sty, +multicol.sty, lmodern.sty, fontenc.sty that should be installed +on your computer by default. + +If you have not installed the mwart.cls class (available on CTAN in +mwcls package), the result of your compilation may differ a bit from +the .pdf provided in this .zip archive in formattings: If you have not +installed mwart.cls, the standard article.cls will be used. diff --git a/macros/latex/contrib/gmutils/gmRCS.sty b/macros/latex/contrib/gmutils/gmRCS.sty new file mode 100644 index 0000000000..1ecabf4d00 --- /dev/null +++ b/macros/latex/contrib/gmutils/gmRCS.sty @@ -0,0 +1,68 @@ +%% +%% \iffalse ^^A we skip the debug setting +\IfFileExists{\string~/bin/gen_and_xela}{\errorcontextlines=1000 }{} +%% \fi +%% ^^A $Id: TheUltimateMaster.gmd,v 0.352 2011/10/12 15:19:42 natror Exp natror $ +%% This is file “gmRCS.sty” generated with the DocStrip utility. +%% +%% +%% The original source files were: +%% +%% gmutils/gmutils.gmd (with options: `RCS') +%% +%% +%% Copyright © +%% by Grzegorz ‘Natror’ Murzynowski +%% natror (at) gmail (dot) com +%% +%% This program is subject to the LaTeX Project Public License. +%% See http://www.ctan.org/tex-archive/help/Catalogue/licenses.lppl.html +%% for the details of that license. +%% +%% LPPL status: "author-maintained". +%% +%% +%% +%% For documentation please refer to the file(s) +%% gmutils.{gmd,pdf}. +%% +%% +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{gmRCS} + [2011/10/12 v0.996 (GM)] + + +%% +%% +%% ^^A\typeout{\unexpanded{#4}}%% + + +\def\ParseRCSVersion$Id% +: #1.#2,v #3 #4 #5 #6 #7${% + \def\RCSFileName{#1}% + \def\RCSFileExt{#2}% + \def\RCSFile{#1.#2}% + \def\RCSVersion{#3}% + \def\RCSDate{#4}% + \def\RCSTime{#5}% + \def\RCSAuthor{#6}% +} + + +\def\defRCSeDatum +#1% datum name +#2% datum definition (basically |#|number) +{% + \@namedef{eRCS#1}$Id% + : ##1.##2,v ##3 ##4 ##5 ##6 ##7${#2}% +} + +\defRCSeDatum{File}{#1.#2} % |\eRCSFile| +\defRCSeDatum{Version}{#3}% |\eRCSVersion| +\defRCSeDatum{Date}{#4}% |\eRCSVDate| +\defRCSeDatum{Time}{#5}% |\eRCSVTime| +\defRCSeDatum{Author}{#6}% |\eRCSVAuthor| + +\endinput +%% +%% End of file `gmRCS.sty'. diff --git a/macros/latex/contrib/gmutils/gmampulex.sty b/macros/latex/contrib/gmutils/gmampulex.sty new file mode 100644 index 0000000000..9ae544868e --- /dev/null +++ b/macros/latex/contrib/gmutils/gmampulex.sty @@ -0,0 +1,215 @@ +%% +%% \iffalse ^^A we skip the debug setting +\IfFileExists{\string~/bin/gen_and_xela}{\errorcontextlines=1000 }{} +%% \fi +%% ^^A $Id: TheUltimateMaster.gmd,v 0.352 2011/10/12 15:19:42 natror Exp natror $ +%% This is file “gmampulex.sty” generated with the DocStrip utility. +%% +%% +%% The original source files were: +%% +%% gmutils/gmutils.gmd (with options: `ampulex') +%% +%% +%% Copyright © +%% by Grzegorz ‘Natror’ Murzynowski +%% natror (at) gmail (dot) com +%% +%% This program is subject to the LaTeX Project Public License. +%% See http://www.ctan.org/tex-archive/help/Catalogue/licenses.lppl.html +%% for the details of that license. +%% +%% LPPL status: "author-maintained". +%% +%% +%% +%% For documentation please refer to the file(s) +%% gmutils.{gmd,pdf}. +%% +%% +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{gmampulex} + [2011/10/12 v0.996 Ampulex Compressa-like modifier of macros (GM)] + + +%% +%% +%% ^^A\typeout{\unexpanded{#4}}%% + +\RequirePackage{gmcommand} + +\DeclareCommand\ampulexlet\long +{Q{\outer\long\global\protected}{} % (1) (optional) prefix\:(es); + % allowed is any sequence of them in any order, just like for the + % original \TeX's \incmd\def. + T{\def\edef\gdef\xdef\pdef}{\def} % (2) (optional) kind of definition; if + % not specified, \incmd\def\ will be used. + m % (3) macro to be let to, + m % (4) macro to provide the definition, + O{} % (5) \cs{def}'s parameters string; empty by default, + O{} % (6) definition body's parameters to be taken in a~one-step + % expansion of the redefined macro; empty by default; the + % undelimited parameters should be double-braced here. + m % (7) start token(s), + m % (8) end token(s) + m % (9) the replacement of |#7|, |#8| and whatever between them. +}{%^^B + % \changes{v0.93}{2008/08/29}{added} + % \changes{v0.94}{2008/09/07}{made \pk{xparse}-ish and + % \cs{ampulexset} removed} + % \chgs{2008/12/7 v0.98 first argument (the prefix) made of the + % \env{Q} type} + % For the example of usage see \ref{ampulexset}. \HideDef + % + \long\def\gmu@ampulexlet@resa + ##1#7% we put |#7| as a delimiter + ##2#8% we put |#8| as a delimiter + ##3\gmu@AmpulexDelimiter{% + % We use a special (undefined) \CS |\gmu@AmpulexDelimiter| as + % the final delimiter because standard \LaTeX's |\@nil| isn't + % probably a good idea since we + % want to ampulex deep \LaTeX's macros and other |\gmu@›…| + % macros too. + \gmu@ifempty{##3}% + }% + % Now |\gmu@ampulexlet@resa| is redefined to produce an open |\gmu@ifempty| + % depending on whether the start and end token(s) are found in the + % meaning of \inverb|#4|. + % + % Before we proceed, we deal with a difficulty with a special case + % when |#6| is “|#1|”, which occurs because of stripping braces of a + % single-brace argument. + \gmu@ifutokens{#6}{##1}% + {\def\ampulex@Args{{% + ####1}}% + }% + {\edef\ampulex@Args{\@nx\unexpanded{% + \unexpanded{#6}}}}% + \long \def\gmu@ampulexlet@resc##1{% + \@xa\@xa\@xa\@xa \@xa\@xa\@xa\gmu@ampulexlet@resa + \@xa\@xa\@xa#4% + \ampulex@Args + ##1% this parameter will be substituted with |#7#8| in + % line~\ref{resc1} and with emptiness in line~\ref{resc2}. + \gmu@AmpulexDelimiter + }% + % + \gmu@ampulexlet@resc{#7#8}%\label{resc1} % ^^V \gmu@ampulexlet@resb + % We've just applied the checker and it produces an open + % |\gmu@ifempty{⁄}| + % if the delimiters are found in the meaning of |#4| + % so, if \ are none, we issue a warning + {% + \PackageWarning{gmampulex}{% + \@nx#4 doesn't contain tokens + \detokenize{#7} nor \detokenize{#8}. You better check if this is + what you want to redefine.^^J% + \@nx#4 is^^J% + \meaning#4^^J% + }}% + % and we proceed if they are really some + {% + % We define a~temporary + % macro with the parameters delimited with the `start' and `end' parameters + % of \incs{ampulexdef}. It has to stand a double |\edef|. + \edef\gmu@ampulexlet@resa{% + \long\def\@nx\gmu@ampulexlet@resa + ####1\unexpanded{#7}% + ####2\unexpanded{#8}% + ####3\@nx\gmu@AmpulexDelimiter{% + \@nx\unexpanded{####1}% + % we drop the part between the |#7| and |#8| delimiters + % (including delimiters) + \unexpanded{\unexpanded{#9}}% we replace the part of the + % redefined macro's meaning with the replacement text. + \@nx\unexpanded{####3}% + }% of inner |\gmu@ampulexlet@resa| + }% of outer |\gmu@ampulexlet@resa| + \gmu@ampulexlet@resa + % Now |\gmu@ampulexlet@resa| carries the modifier of |#4|'s + % definition. + % + % +\unless\ifx\czat#4% + \edef\gmu@ampulexlet@resb{% double definition for double hashes of expanded + % |\unexpanded{#1›…}| + #1#2% + \@nx#3\unexpanded{#5}{% + \gmu@ampulexlet@resc{}%\label{resc2} + % Here we are sure the tokens sequences + % |#7| and |#8| are in the one-level expansion of |#4| so we don't pass them + % as sentinels (which \ac{BTW} would totally spoil the redefinition, what it + % did indeed 2010/6/23). + }% of |#3|'s definition body + }% of inner |\gmu@ampulexlet@resb| + \gmu@ampulexlet@resb +\else + \gmu@ifxany#2{\gdef\xdef}{\global}{}% + #1\edef#3#5{\gmu@ampulexlet@resc{}}%\label{resc2} +\fi + }% of if the delimiters were found in the meaning. +}% of |\ampulexlet| + +\DeclareCommand\ampulexdef\long{% + % \chgs{2010/04/22 v0.994 rewritten not to use the arguments 7–9 + % explicitly not to wrap them in a temporary macros, and to accept + % single hashes (instead of quadruple) in arguments 5 and 6. The + % temporary macros renamed + % to \cmd\gmu@reserveda and \cmd\gmu@reservedb. The body moved to + % \cmd\ampulexlet with adding another \CS argument to let let a + % macro not necessarily redefine it itself and this command made a + % particular case of that new one} +#1 Q{\outer\long\global\protected}{} % (1) as |\ampulexlet| +#2 T{\def\edef\gdef\xdef\pdef}{\def} % (2) ad |\ampulexlet| +#3 m % (3) macro to be redefined, +#4 O{} % (4) as |\ampulexlet|'s |#5|, i.e., \cs{def}'s parameters string; empty by default, +#5 O{} % (5) as |\ampulexlet|'s |#6|, i.e., definition body's + % parameters to be taken in a~one-step expansion of the redefined + % macro; empty by default; the undelimited parameters should be + % double-braced here (but not doubled). +#6 m % (6) start token(s), +#7 m % (7) end token(s), +#8 m % (8) the replacement +}{% + \DCUse\ampulexlet{#1}{#2}{#3}{#3}{#4}{#5}{#6}{#7}{#8}% +} + + + +\def\gmu@ENumLoop#1#2{% this is a~fully expandable loop generating |#2|${}-{}$|#1| + % space tokens (cf. The % \eTeX\ Manual p.~9). + \ifnum#1<#2 % + \gmu@tempa + \@xa\gmu@ENumLoop + \@xa{\number\numexpr#1+1\@xa}% + \@xa{\number#2\@xa}% + \fi}% of |\gmu@hashes|. + +\long\def\defENumLoop +#1% the loop macro's name +#2% the replacement of |\gmu@tempa| +{% + \ampulexlet#1\gmu@ENumLoop + [##1##2][{##1}{##2}]% + \gmu@tempa\@xa{#2\@xa}% + % + \ampulexdef#1% + [##1##2][{##1}{##2}]% + \gmu@ENumLoop\@xa{#1\@xa}% +} + +\edef\GenericInfoToTerminal{% + \unexpanded{% + \@XA{\ampulexlet\protected\long\GenericInfo}\csname + GenericInfo \endcsname[#1#2][{#1}{#2}]% + \write\m@ne % we replace the token between these with: + {\write\ifnum\tracingonline>\z@ \@unused\else\m@ne\fi}% + }% +} + +\ampulexdef\@starttoc[#1][#1]\makeatletter\@input{\makeatletter\NamedInput} + + +\endinput +%% +%% End of file `gmampulex.sty'. diff --git a/macros/latex/contrib/gmutils/gmbase.sty b/macros/latex/contrib/gmutils/gmbase.sty new file mode 100644 index 0000000000..23bd9ebb16 --- /dev/null +++ b/macros/latex/contrib/gmutils/gmbase.sty @@ -0,0 +1,3050 @@ +%% +%% \iffalse ^^A we skip the debug setting +\IfFileExists{\string~/bin/gen_and_xela}{\errorcontextlines=1000 }{} +%% \fi +%% ^^A $Id: TheUltimateMaster.gmd,v 0.352 2011/10/12 15:19:42 natror Exp natror $ +%% This is file “gmbase.sty” generated with the DocStrip utility. +%% +%% +%% The original source files were: +%% +%% gmutils/gmutils.gmd (with options: `base') +%% +%% +%% Copyright © +%% by Grzegorz ‘Natror’ Murzynowski +%% natror (at) gmail (dot) com +%% +%% This program is subject to the LaTeX Project Public License. +%% See http://www.ctan.org/tex-archive/help/Catalogue/licenses.lppl.html +%% for the details of that license. +%% +%% LPPL status: "author-maintained". +%% +%% +%% +%% For documentation please refer to the file(s) +%% gmutils.{gmd,pdf}. +%% +%% +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{gmbase} + [2011/10/12 v0.996 some low-level macros (GM)] + + +%% +%% +%% ^^A\typeout{\unexpanded{#4}}%% + +\RequirePackage {expl3, xparse} % because it's used anyway: by + +\ifx\XeTeXversion\relax + \let\XeTeXversion\@undefined% If someone earlier used +\fi + +\ifdefined\XeTeXversion +\XeTeXinputencoding utf-8 % we use Unicode dashes later in this file. +\fi% and if we are not in \XeTeX, we skip them thanks to \XeTeX-test. + +\unless\ifdefined\strcmp + \let\strcmp\pdfstrcmp +\fi + +\let\@xa\expandafter +\let\@nx\noexpand + +\def\@xanx{\@xa\@nx} + +\long\def\@xadef#1{\@xa\def\@xa#1\@xa} + +\long\def\@csn#1{\csname #1\endcsname} + +\long\def\Name#1#2{\@xa#1\csname #2\endcsname} + +\long\def\@xau#1{\unexpanded\@xa{#1}} + +\def\gmu@firstandspace#1{#1 } + +\long\def\strip@bslash#1{% + \gmu@ifempty{#1}{}{% + \gmu@if {cat}{\@nx~\@nx#1}% this is specially for an active + % backslash (have you ever met it?). Thanks to this special case + % the inner macro declared for an active |\| by |\DeclareCommand| + % is |\\\| not |\\csname\endcsname\|. + {\string#1}% if |#1| is active + {% + \@xa\@xa\@xa\ifnum\@xa\@xa\@xa\escapechar + \@xa\@xa\@xa=\@xa\@xa\@xa`\@xa\gmu@firstandspace + \string#1\@xa\@gobble + \else\@xa\@firstofone \fi + {\string#1}% + }% if |#1| is not active + }% of if |#1| not empty +} + +\long\def\bslash@or@ac#1{% + \ifcat\@nx~\@nx#1% + \else + \bslash + \fi + \strip@bslash{#1}% +} + +\long\def\@xanxcs #1{% + \ifcat\@nx~\@nx#1% + \@nx#1% + \else + \@xa\@nx\csname #1\endcsname + \fi +} + +\long\def\@xanxcssimple #1{% + \@xa\@nx\csname #1\endcsname +} + +\long\def\@xaucs#1{% + \unexpanded\@xa\@xa\@xa{\csname #1\endcsname}% +} + +\long\def\@xanxtri#1{% + \ifcat\@nx~\@nx#1% + \@nx#1% + \else + \@xa\@nx\csname \strip@bslash{#1}\endcsname + \fi +} + +\def\pdef{\protected\def} + +\def\lpdef{\long\protected\def} +\let\pldef\lpdef + +\long\def\gmu@ifdefinable +#1% a \CS +{% + \ifx #1\@undefined + \@xa \@firstoftwo + \else + \@xa\@secondoftwo + \fi + {\@firstoftwo}% + {\ifx #1\relax + \@xa\@firstoftwo + \else + \@xa \@secondoftwo + \fi + }% +} + +\def\pedef{\protected\edef} + +\def\pxdef{\protected\xdef} + +\long\def\gobble#1{} +\let\@gobble\gobble +\let\gobbletwo\@gobbletwo % it's a \LaTeX's |\long| macro (in File d: + +\long\def\@gobbleeight#1#2#3#4#5#6#7#8{} + +\long\pdef\provide#1{%\changes{v0.93}{2008/08/30}{added} + \ifdefined#1% \UnDef + \ifx\relax#1\afterfifi{\def#1}% + \else\afterfifi{\gmu@gobdef}% \UnDef + \fi + \else\afterfi{\def#1}% + \fi} + +\long\def\gmu@gobdef#1#{% \UnDef + \def\gmu@tempa{}% it's a~junk |\def|-assignment + % to absorb possible prefixes. + \@gobble +} + +\def\pprovide{\protected\provide} + +\long\def\@nameedef#1#2{% \changes{v0.93}{2008/08/30}{added} + \@xa\edef\csname#1\endcsname{#2}} + + +\pdef\gmu@DefSymbol#1{% + \unless\ifdefined#1% + \def#1{#1}% + \fi +} + +\newcommand\newdef % sort of newcommand that accepts prefixes. +[1]% +{% + \gmu@ifdefinable #1% + {\pdef #1} + {% + \PackageError {gmbase} {\@nx#1 already defined.}{}% + \gmu@gobdef + }% +} + +\protected\newdef \pnew {% + \protected\newdef +} + + +\long\def\gmu@if #1#2{% + \csname if#1\endcsname #2% + \@xa\@firstoftwo + \else\@xa\@secondoftwo + \fi +} + +\long\def\gmu@notif#1#2{% + \gmu@if {#1}{#2}% + \@secondoftwo\@firstoftwo +} + +\def\gmu@ifsw #1{\gmu@if {#1}{}} +\def\gmu@notsw #1{\gmu@notif {#1}{}} + +\def \gmu@ifincsname +{% + \ifincsname + \@xa\@firstoftwo + \else + \@xa\@secondoftwo + \fi +} + +\long\def\gmu@unless #1#2{% + \@xa\unless \csname if#1\endcsname #2% + \@xa\@firstoftwo + \else + \@xa\@secondoftwo + \fi +} + + +\lpdef\@iwru@EC#1#2#3{% + \@iwrum{#1»{#2}« »#3«}% + \gmu@passbraced{#1{#2}}{#3}% +} + +\long\def\gmu@generalCASE +#1% Testing macro (|\gmu@if| etc. +#2% |#1| of the testing macro +#3% |#2| of the testing macro +#4% |#3| of the testing macro (what if test satisfied)\\ +{% + #1{#2}{#3}% + {% + \gmu@EatCases{#4}}{}% +} + +\long\def\gmu@EatCases +#1% +#2\gmu@ESAC +{#1} + +\let\gmu@lastCASE\gmu@EatCases + +\def\gmu@CASE {\gmu@generalCASE \gmu@if } +\def\gmu@CASEnot {\gmu@generalCASE \gmu@notif } +\def\gmu@CASExany {\gmu@generalCASE \gmu@ifxany } +\def\gmu@CASExnone {\gmu@generalCASE \gmu@ifxnone } + +\long\def\gmu@reserved@firstofmany#1#2\gmu&nil{#1} + +\long\def\ifsingletoken#1{% ^^V \gmu &nil % such a strange delimiter to + % make it work both in letter and + % other |@| scopes etc.\ (|&| seems to + % me recatcoded rather seldom) + \ifnum \strcmp{\unexpanded{#1}}% + {\@xau{\gmu@reserved@firstofmany #1\blekotnizza@ \di \broccoli + \gmu&nil}% + }% of right text of |\strcmp| + =\z@ +} + +\long\def\gmu@predetokstring #1{% + \gmu@if {num} + {% + % After a couple of hours of debug I reached the proper test which + % is given below. The goal is to (expandably!) check whether |#1| + % is braced and/or begins with a blank space. In any of those + % cases we don't hit it('s first token) with |\string|. + % + % |\@firstofone| strips outermost pair of braces if any and + % gobbles the lading blank(s) if any so the detokenised strings + % will differ. + \strcmp + {\detokenize{#1x}}% + {\detokenize\@xa{\@firstofone #1x}}=\z@ + }% of test + {\@xa{\string#1}} + {{#1}}% +} + + +\long\def\ifstrings#1#2{% + \ifnum\strcmp + {\detokenize\gmu@predetokstring{#1x}}% + {\detokenize\gmu@predetokstring{#2x}}=\z@ +} + + +\long\def\ifstribs#1#2{% + \ifnum\strcmp{\strip@bslash{#1}}{\strip@bslash{#2}}=\z@ +} + + +\long\def\ifStrX#1#2{% + \gmu@CASEnot {x}{#1#2}% + {\iffalse}% if tokens are x-unequal, all is clear. + % + \gmu@CASEnot x {\@undefined#1} + {\iftrue}% + % + % some (i.e.\ \emph{both}) tokens are-x |\@undefined| or |\relax|, + % then + \gmu@CASE {strings}{#1#2}% + {\iftrue}% + % + \gmu@lastCASE + {\iffalse}% + \gmu@ESAC +} + +\long\def\firstofone#1{#1} + +\long\def\bracefirstofone#1{{#1}} + +\long\pdef\scantwo#1#2{ + \begingroup\endlinechar\m@ne + \@xa\endgroup\scantokens{#1#2}% +} + +\long\def\@firstofthree#1#2#3{#1} +\long\def\@secondofthree#1#2#3{#2} +\long\def\@thirdofthree#1#2#3{#3} +\long\def\@twoofthree#1#2#3{#1#2} +\long\def\@secondoffive#1#2#3#4#5{#2} + +\long\def\@firstofmany#1#2\@nil{#1} + +\long\def\@secondofmany#1#2#3\@nil{#2} + +\long\def\@allbutfirstof#1#2\@nil{#2} + + +\long\def\@firstthensecond #1#2{#1#2} % Note this macro strips braces + % if present. +\long\def\@secondthenfirst #1#2{#2#1} % Note as above. + + + +\def\longafterfi{% + \long\def\afterfi##1##2\fi{\fi##1}} +\longafterfi +\long\def\afterfifi#1#2\fi#3\fi{\fi\fi#1} +\long\def\afteriffifi#1#2\fi#3\fi{\fi#1} + +\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} + + +\long\def\foone#1{\begingroup#1\relax\egfirstofone} +\long\def\egfirstofone#1{\endgroup#1} + +\def\fooatletter{\foone\makeatletter} + +\newcommand*\@emptify[1]{\let#1=\@empty} +\gmu@ifdefinable\emptify{\let\emptify\@emptify} + +\newcommand*\g@emptify{\global\@emptify} +\gmu@ifdefinable\gemptify{\let\gemptify\g@emptify} + +\newcommand\@relaxen[1]{\let#1=\relax} +\gmu@ifdefinable\relaxen{\let\relaxen\@relaxen} + +\newcommand*\g@relaxen{\global\@relaxen} +\gmu@ifdefinable\grelaxen{\let\grelaxen\g@relaxen} + +\long\def\gmu@ifempty#1{%\ + \ifnum\strcmp{\detokenize{#1}}{}=\z@ + \@xa\@firstoftwo + \else\@xa\@secondoftwo + \fi +} + +\long\pdef\@ifnonempty#1#2#3{\gmu@ifempty{#1}{#3}{#2}} + + + +\long\def\gmu@ifexempty #1{% + \ifnum \strcmp{#1}{}=\z@ + \@xa\@firstoftwo + \else\@xa\@secondoftwo + \fi +} + +\long\pdef\IfAmong +#1% the token(s) whose presence we check, +\among % delimiter of |#1| +#2% the list of tokens in which we search |#1|, +{%\label{IfAmong} + % \chgs{2008/12/05 v0.98 split from \cs{IfAmong}} + % + \long\def\gmu@among@##1#1##2\gmu@among@{% + \gmu@ifempty{##2}\@secondoftwo\@firstoftwo}% + \gmu@among@#2#1\gmu@among@ +} + +\newif\ifgmu@ifquant + +\long\pdef\gmu@ifxany +#1% a single token to be |\ifx| ed with each of |#2| +#2% counterpart to the above—a sequence of tokens to check |#1| +{% + \gmu@ifempty{#2}{\@secondoftwo}{% + % we wrap the iteration over |#2|'s tokens in |\gmu@ifempty| because + % we expect many empty |#2|'s in |\DeclareCommand|'s |\loop| + % arguments (such as |Q| and |U|) + \gmu@ifquantfalse + \let\gmu@ifxa@aasiter\@@gmu@ifxa@aasiter + % + \edef\gmu@ifxa@aas{% edef and unexpanded to protect agains + % |#|\cat6 token(s) in |#1|. + \unexpanded{% + \ifx #1\gmu@ifxa@token + \gmu@ifquanttrue + \let\gmu@ifxa@aas\gmu@ifxa@drainer + \else + \ifx \gmu@ifxa@Limit\gmu@ifxa@token + \emptify \gmu@ifxa@aasiter + \fi + \fi + \gmu@ifxa@aasiter + }%of |\unexpanded| + }% of |\gmu@ifxa@aas| + % + \gmu@ifxa@aasiter #2\gmu@ifa@PreLimit\gmu@ifxa@Limit + \gmu@if {gmu@ifquant}{}% + }% of if |#2| nonempty +} + +\def\gmu@ifxa@drainer{% + \ifx\gmu@ifxa@Limit\gmu@ifxa@token + \emptify\gmu@ifxa@aasiter + \fi + \gmu@ifxa@aasiter +} + +\gmu@DefSymbol \gmu@ifa@PreLimit +\gmu@DefSymbol \gmu@ifxa@Limit + +\def\@@gmu@ifxa@aasiter{% + \afterassignment\gmu@ifxa@aas + \let\gmu@ifxa@token= }% thanks to this space it'll look also at + +\long\pdef\gmu@ifxnone +#1% token to be checked against +#2% list of tokens to \emph{not} find |#1| at +{% + \gmu@ifxany{#1}{#2}\@secondoftwo\@firstoftwo +} + + +\long\def\gmu@foreach#1\gmu@foreach@delim#2{% + % + \long\def\gmu@forer##1{% + \gmu@if {strings} {\gmu@foreach@delim {##1}}% + {}% if we've met the delimiter, we stop. + {% otherwise we wrap |#1| in a macro to make it available to |#2| + \edefU\gmu@forarg{##1}% + #2% we execute |#2| and probably continue iteration (unless the + % loop isn't broken with the next macro). + \gmu@forer + }% + }% of forer. + \gmu@forer#1\gmu@foreach@delim +} + +\long\def\gmu@foreach@break +#1\gmu@foreach@delim{} + +\long\def\gmu@ifsXXany +#1% kind of test (|strings| or |stribs| so far) +#2% token to be checked against |#3| +#3% the list of tokens to be iterated over\\ +{% + \gmu@ifsXXany@{#1}{#2}#3\gmu@ifsXXany@end + \@firstoftwo\@secondoftwo +} + +\long\def\gmu@ifsXXany@ +#1% kind of test +#2% left side of comparison +#3% right side of comparison +{% + \gmu@if {#1}{#2#3}% + \gmu@ifsXXany@found + {% else + \gmu@if {#1}{#3\gmu@ifsXXany@end}% + \@secondoftwo + {\gmu@ifsXXany@{#1}{#2}}% if we didn't meet the sentinel, we iterate + }% +} + +\long\def\gmu@ifsXXany@found +#1\gmu@ifsXXany@end +{\@firstoftwo} + +\def\gmu@ifstrany{\gmu@ifsXXany {strings}} + +\def\gmu@ifsbany{\gmu@ifsXXany {stribs}} + +\def\gmu@ifStrXany{\gmu@ifsXXany {StrX}} + +\long\def\gmu@ifstrnone#1#2#3#4{% + \gmu@ifstrany{#1}{#2}{#4}{#3}% +} + +\long\def\gmu@ifsbnone#1#2#3#4{% + \gmu@ifsbany{#1}{#2}{#4}{#3}% +} + +\long\def\gmu@ifStrXnone#1#2#3#4{% + \gmu@ifStrXany{#1}{#2}{#4}{#3}% +} + +\lpdef\gmu@CASEstrany {\gmu@generalCASE \gmu@ifstrany } + +\lpdef\gmu@CASEstrnone {\gmu@generalCASE \gmu@ifstrnone } + +\lpdef\gmu@CASEsbany {\gmu@generalCASE \gmu@ifsbany } + +\lpdef\gmu@CASEsbnone {\gmu@generalCASE \gmu@ifsbnone } + + +\newtoks\degroup@toks + +\long\pdef\gmu@degroup +#1% text to be degrouped +{\degroup@toks={}% + \gmu@degroup@iter#1\gmu@degroup@end +} + +\long\def\gmu@degroup@afterlet{% + \gmu@if x{\degroup@lettoken\bgroup}% + {\degroup@drainanditer}% + {\gmu@if x{\degroup@lettoken\egroup}% + {\degroup@drainanditer}% + {\degroup@addanditer}% + }% +} + +\def\gmu@degroup@iter{% + \futurelet\degroup@lettoken\gmu@degroup@afterlet} + +\def\degroup@drainanditer{% + \afterassignment\gmu@degroup@iter + \let\gmu@drain= +} + +\def\degroup@addanditer{% + \gmu@if x{\degroup@lettoken\gmu@letspace}% + {\addtotoks\degroup@toks{ }% + \degroup@drainanditer + }{% + \degroup@addanditer@i + }% +} + +\long\def\degroup@addanditer@i +#1{% + \gmu@if {strings}{#1\gmu@degroup@end}% + {}% we've reached the end of iteration + {% it's sth.\ to add + \addtotoks\degroup@toks{#1}% + \gmu@degroup@iter + }% +} + +\pdef\IfIntersect +{\gmu@ifintersect \gmu@ifxany} + +\lpdef\gmu@ifintersect +#1% an iterating test (|\gmu@ifxany|, |\gmu@ifstrany| or +#2% one list to match +#3% another list to match +{% + \let\IfIntersect@next\@secondoftwo + \gmu@foreach #2\gmu@foreach@delim{% + \@xa #1\gmu@forarg{#3}% + {\let\IfIntersect@next\@firstoftwo + \gmu@foreach@break + }{}% + }% of |\gmu@foreach|'s |#2|. + \IfIntersect@next +} + +\pdef\gmu@ifstrintersect +{\gmu@ifintersect\gmu@ifstrany} + +\pdef\gmu@ifsbintersect +{\gmu@ifintersect\gmu@ifsbany} + + +\newtoks\@XAtoks + +\long\pdef\@XA#1{% + \@XAtoks={#1}% + \@xa\the\@xa\@XAtoks} + +\long\pdef\@ifinmeaning#1\of#2{% \ + % \begin{enumargs} + % \item the token(s) whose presence we check, + % \item the macro in whose meaning we search |#1| (the first token of + % this argument is expanded one level with |\expandafter|), + % \item the `if found' stuff, + % \item the `if not found' stuff. + % \end{enumargs} + % + % \chgs{2007/11/06 v0.98 (in \pk{gmdoc}) made more elegant: + % \cs{if} changed to \cs{ifx} made four parameters and not expanding + % to an open \cs{if›(true⁄|false›)}. % ^^A | + % Also renamed from \cs{@ifismember}} + % \chgs{2008/12/05 v0.98 moved here from \pk{gmdoc} and rewritten, + % including split to \cs{IfAmong} because the latter is needed in + % \cs{DeclareCommand}} + % + \@XA{\IfAmong#1\among}\@xa{#2}} + +\gmu@DefSymbol\defNoHash +\gmu@DefSymbol\defHashy +\gmu@DefSymbol\boolean + +\def\gmu@geteschar{% + % A macro that edefines detokenised char of the charcode |\escapechar| + \edef\gmu@xiieschar{% + \gmu@CASE {num} {\escapechar <\z@} + {}% + % + \gmu@CASE {num}{\escapechar <32 } + {\@xa \@firstofmany \string \blekotnizza\@nil}% not firstthreeofmany!!!! + % + \gmu@CASE {num} {\escapechar=32 } + { }% space cannot be “first of…”. + \gmu@lastCASE + {\@xa \@firstofmany \string \blekotnizza \@nil}% + \gmu@ESAC + }% +} + +\long\def\gmu@IfBooleanMacro#1{% + \gmu@ifedetokens{\meaning#1}{macro:->true}% + {\@firstoftwo}% + {\gmu@ifedetokens{\meaning#1}{macro:->false}% + {\@firstoftwo}% + {\@secondoftwo}% + }% +} + +\pdef\IfIs +#1% a \CS +#2% |\dimen|, |\long|, |\toks|, |\skip|, |\count|, |\dimexpr|, + % |\numexpr|, |\glueexpr|, |\newif| for |\iffalse| and |\iftrue|, + % |\if| or |\conditional| for any Boolean test/switch, |\def| for a + % macro. + % + % This test tells us in particular what kind of assignment may be + % applied to |#1|. Therefore it turns true for |#1| being e.g.\ primitive + % \TeX's skip registers and |#2|==|\skip|. +{% + \@tempswafalse + % + \gmu@CASE x{\defNoHash#2}% + {% case “def no hash” (hashless macro) + \@tempswatrue + \edef\gmu@IfIs@resa{% + \pdef\@nx\gmu@IfIs@resa + ####1\detokenize{macro:->}% + ####2\@nx\@nil{\@ifnonempty{####2}}% + % And we prepare applying thus defined macro to |#1|: + \unexpanded{\@xa\gmu@IfIs@resa\meaning#1}% + \detokenize{macro:->}\@nx\@nil + }% of |\edef| + }% of case hasless macro (“def no hash”) + % + % if not hashless + \gmu@CASE x {\defHashy#2}% + {% + % case hashy macro + \@tempswatrue + \edef\gmu@IfIs@resa{% + \pdef\@nx\gmu@IfIs@resa + ####1\detokenize{macro:}####2\xiihash1####3->% + ####4\@nx\@nil{\@ifnonempty{####4}}% + % And we prepare applying thus defined macro to |#1|: + \unexpanded{\@xa\gmu@IfIs@resa\meaning#1}% + \detokenize{macro:}\xiihash1->\@nx\@nil + }% of |\edef| + }% of case hashy macro + % + \gmu@CASE x {#2\boolean} + {% case Boolean + \@tempswatrue + \def\gmu@IfIs@resa{\gmu@IfBooleanMacro#1}% + % + }% of case Boolean + % + \gmu@CASEstrany #2{\dimexpr \numexpr \glueexpr }% + {% case \eTeX\ expression + \@tempswatrue + \def\gmu@IfIs@resa{% if should be a macro expanding to + % expression contents + \IfIsExpression #1#2}% + }% of case expression + % + % The subsequent part of this huge test refers to |\meaning|s. We + % want to make it robust to possible (although rather seldom) + % changes of |\escapechar|. Therefore define an aux macro that + % expands to detokenised escape char. + % + % Assume that letters, icluding »e«, will not be used as the escape + % char: + \gmu@geteschar + % + % Now |\gmu@xiieschar| carries the detokenised escape char (is empty + % if |\escapechar|${}<0$). + % + % + \gmu@CASE x {\dimen#2}% + {% Case dimen. Let's check if it's special (inner \TeX's) + % or normal. + \gmu@ifxany#1{\prevdepth \pagegoal \pagetotal \pagestretch + \pagefilstretch \pagefillstretch \pagefilllstretch + \pageshrink \pagedepth + \hfuzz \vfuzz \overfullrule \emergencystretch \hsize \vsize + \maxdepth \splitmaxdepth \boxmaxdepth \lineskiplimit + \delimitershortfall \nulldelimiterspace \scriptspace + \mathsurround \predisplaysize \displaywidth + \displayindent \parindent \hangindent \hoffset \voffset + }% + {\@tempswatrue\let\gmu@IfIs@resa\@firstoftwo}% + {% subcase normal dimen + \def\gmu@IfIs@resa{% + \gmu@ifexempty {\gmu@xiieschar}% + {% + \pdef\gmu@IfIs@resa####1####2####3####4####5####6\@nil{% + \gmu@if {} + {1% + \if d####1\else0\fi + \if i####2\else0\fi + \if m####3\else0\fi + \if e####4\else0\fi + \if n####5\else0\fi + 1}% + }% of inner |\gmu@IfIs@resa|… + }% …if eschar negative + {% + \pdef\gmu@IfIs@resa####1####2####3####4####5####6####7\@nil{% + \gmu@if {} {1% + \if \gmu@xiieschar ####1\else0\fi + \if d####2\else0\fi + \if i####3\else0\fi + \if m####4\else0\fi + \if e####5\else0\fi + \if n####6\else0\fi + 1% + }% + }% of inner |\gmu@IfIs@resa|… + }% …when eschar nonnegative + }% of outer |\gmu@IfIs@resa| + }% of if special dimen or not + }% of case dimen + % + \gmu@CASE x {\count#2}% + {% case count + \gmu@ifxany#1{\spacefactor \prevgraf \deadcycles + \insertpenalties + \pretolerance \tolerance \hbadness \vbadness \linepenalty + \hyphenpenalty \exhyphenpenalty \binoppenalty \relpenalty + \clubpenalty \widowpenalty \displaywidowpenalty + \brokenpenalty \predisplaypenalty \postdisplaypenalty + \interlinepenalty \floatingpenalty \outputpenalty + \doublehyphendemerits \finalhyphendemerits \adjdemerits + \looseness \pausing \holdinginserts \tracingonline + \tracingmacros \tracingstats \tracingparagraphs + \tracingpages \tracingoutput \tracinglostchars + \tracingcommands \tracingrestores \language \uchyph + \lefthyphenmin \righthyphenmin \globaldefs + \defaulthyphenchar \defaultskewchar \escapechar \endlinechar + \newlinechar \maxdeadcycles \hangafter \fam \mag + \delimiterfactor \time \day \month \year \showboxbreadth + \showboxdepth \errorcontextlines + \lastlinefit + }% + {% if special count register then: + \@tempswatrue\let\gmu@IfIs@resa\@firstoftwo}% + {% + % if normal count register then + \def\gmu@IfIs@resa{% + \gmu@ifexempty \gmu@xiieschar + {\pdef\gmu@IfIs@resa####1####2####3####4####5####6\@nil{% + \gmu@if {} {1% + \if c####1\else0\fi + \if o####2\else0\fi + \if u####3\else0\fi + \if n####4\else0\fi + \if t####5\else0\fi + 1% + }% of test + }% of inner |\gmu@IfIs@resa|… + }% … when eschar is negative + % + {% eschar not empty (nonnegative) + \pdef\gmu@IfIs@resa####1####2####3####4####5####6####7\@nil{% + \gmu@if {} {1% + \if \gmu@xiieschar####1\else0\fi + \if c####2\else0\fi + \if o####3\else0\fi + \if u####4\else0\fi + \if n####5\else0\fi + \if t####6\else0\fi + 1% + }% of test + }% of inner |\gmu@IfIs@resa|… + }% … when eschar nonnegative + }% of outer |\gmu@IfIs@resa| + }% of if normal count register + }% of case count + % + \gmu@CASE x {\skip#2}% + {% case skip + \gmu@ifxany#1{% + \baselineskip \lineskip \parskip \abovedisplayskip + \abovedisplayshortskip \belowdisplayskip + \belowdisplayshortskip \leftskip \rightskip \topskip + \splittopskip \tabskip \spaceskip \xspaceskip \parfillskip + }% + {% if special skip + \@tempswatrue\let\gmu@IfIs@resa\@firstoftwo}% + {% not special skip + \def\gmu@IfIs@resa{% + \gmu@ifexempty \gmu@xiieschar + {\pdef\gmu@IfIs@resa####1####2####3####4####5\@nil{% + \gmu@if {} {1% + \if s####1\else0\fi + \if k####2\else0\fi + \if i####3\else0\fi + \if p####4\else0\fi + 1% + }% + }% of inner |\gmu@IfIs@resa|… + }% …when eschar nonnegative + % + {\pdef\gmu@IfIs@resa####1####2####3####4####5####6\@nil{% + \gmu@if {} {1% + \if \gmu@xiieschar ####1\else0\fi + \if s####2\else0\fi + \if k####3\else0\fi + \if i####4\else0\fi + \if p####5\else0\fi + 1% + }% + }% of inner |\gmu@IfIs@resa|… + }% …when eschar nonnegative + }% of outer |\gmu@IfIs@resa| + }% of if skip but not special + }% of case skip + % + \gmu@CASE x {\toks#2} + {% case toks + \gmu@ifxany#1{% + \output \everypar \everymath \everydisplay \everyhbox + \everyvbox \everyjob \everycr \errhelp \everyeof}% + {% subcase special toks + \@tempswatrue\let\gmu@IfIs@resa\@firstoftwo}% + {% subcase normal toks + \def\gmu@IfIs@resa{% + \gmu@ifexempty \gmu@xiieschar + {\pdef\gmu@IfIs@resa####1####2####3####4####5\@nil{% + \gmu@if {} {1% + \if t####1\else0\fi + \if o####2\else0\fi + \if k####3\else0\fi + \if s####4\else0\fi + 1% + }% + }% of inner |\gmu@IfIs@resa|… + }% …when eschar negative + {\pdef\gmu@IfIs@resa####1####2####3####4####5####6\@nil{% + \gmu@if {} {1% + \if \gmu@xiieschar ####1\else0\fi + \if t####2\else0\fi + \if o####3\else0\fi + \if k####4\else0\fi + \if s####5\else0\fi + 1% + }% + }% of inner |\gmu@IfIs@resa|… + }% …when eschar nonnegative + }% of outer |\gmu@IfIs@resa| + }% of if toks but not special + }% of case toks + % + \gmu@CASE x {\long#2}% + % if a macro is |\long|, then these detokens open its meaning + % despite of possible |\outer|. + {% case long macro + \def\gmu@IfIs@resa{% + \gmu@ifexempty \gmu@xiieschar + {\pdef\gmu@IfIs@resa####1####2####3####4####5\@nil{% + \gmu@if {} {1% + \if l####1\else0\fi + \if o####2\else0\fi + \if n####3\else0\fi + \if g####4\else0\fi + 1% + }% + }% of inner |\gmu@IfIs@resa|… + }% …when eschar negative + {\pdef\gmu@IfIs@resa####1####2####3####4####5####6\@nil{% + \gmu@if {} {1% + \ifnum \gmu@xiieschar ####1\else0\fi + \if l####2\else0\fi + \if o####3\else0\fi + \if n####4\else0\fi + \if g####5\else0\fi + 1% + }% + }% of inner |\gmu@IfIs@resa|… + }% …when eschar nonnegative + }% of outer |\gmu@IfIs@resa| + }% of case |\long| + % Note that we also can put here a test whether the meaning + % begins with |macro| which would mean that a macro is + % short. + \gmu@CASE x {\newif#2}% + {% case |\newif| (Boolean switch) + \def\gmu@IfIs@resa{% + \gmu@ifexempty \gmu@xiieschar + {\pdef\gmu@IfIs@resa####1####2####3% + ####4####5####6####7####8\@nil{% + \gmu@unless {} {0% lazy disjunction + \gmu@if {} {1% lazy conjunction + \if i####1\else0\fi + \if f####2\else0\fi + \if f####3\else0\fi + \if a####4\else0\fi + \if l####5\else0\fi + \if s####6\else0\fi + \if e####7\else0\fi + 1% + }% + {}{0}% + \gmu@if {} {1% lazy conjunction + \if i####1\else0\fi + \if f####2\else0\fi + \if t####3\else0\fi + \if r####4\else0\fi + \if u####5\else0\fi + \if e####6\else0\fi + \if \relax####7\else0\fi + 1% + }% + {}{0}% + 0% + }% + }% of inner |\gmu@IfIs@resa|… + }% …when eschar nonnegative + % + {\pdef\gmu@IfIs@resa####1####2####3% + ####4####5####6####7####8####9\@nil{% + \gmu@unless {} {0% + \gmu@if {} {1% + \if \gmu@xiieschar ####1\else0\fi + \if i####2\else0\fi + \if f####3\else0\fi + \if f####4\else0\fi + \if a####5\else0\fi + \if l####6\else0\fi + \if s####7\else0\fi + \if e####8\else0\fi + 1% + }% + {}{0}% + \gmu@if {} {1% + \if \gmu@xiieschar ####1\else0\fi + \if i####2\else0\fi + \if f####3\else0\fi + \if t####4\else0\fi + \if r####5\else0\fi + \if u####6\else0\fi + \if e####7\else0\fi + \if \relax####8\else0\fi + 1% + }% + {}{0}% + 0% + }% + }% of inner |\gmu@IfIs@resa|… + }% …when eschar nonnegative + }% of outer |\gmu@IfIs@resa| + }% of case |\newif| (Boolean switch) + % + \gmu@CASE {x\@xa\@xa} {\csname if\endcsname#2}% + {% case |\if| test + \def\gmu@IfIs@resa{% + \gmu@ifexempty \gmu@xiieschar + {\pdef\gmu@IfIs@resa####1####2####3\@nil{% + \gmu@if {} {1% + \if i####1\else0\fi + \if f####2\else0\fi + 1% + }% + }% of inner |\gmu@IfIs@resa|… + }% …when eschar negative + % + {\pdef\gmu@IfIs@resa####1####2####3####4\@nil{% + \gmu@if {} {1% + \if \gmu@xiieschar ####1\else0\fi + \if i####2\else0\fi + \if f####3\else0\fi + 1% + }% + }% of inner |\gmu@IfIs@resa|… + }% …when eschar nonnegative + }% of outer |\gmu@IfIs@resa| + }% of case |\if| + % + \gmu@lastCASE %^^A >>>>> ?????? + {false}{}{}% + \gmu@ESAC + % For the cases 1–$n$ we just launch their auxiliary macro: + \if@tempswa + \@xa\gmu@IfIs@resa + \else + % + % For the other cases their auxiliary macro defines “inner |@resa|” + % (protected) which perform the test on the meaning of |#1|. + \gmu@IfIs@resa + % + % now (new) |\gmu@IfIs@resa| it's defined as delimited + % with |#2| and |\@nil| (if |#1| may be one of kinds checked letter + % by letter). + % + \edef\gmu@IfIs@resb{% + \gmu@IfIs@resa\meaning#1% + \relax\relax\relax\relax\relax\relax\relax\relax %to provide + % something for gobbling tests. + \@xa\detokenize\@xa{\string#2}\@nx\@nil}% + \@xa\gmu@IfIs@resb + \fi +}% of |\IfIs| + +\unless\ifdefined\@tempskipa\newskip\@tempskipa\fi +\unless\ifdefined\@tempmuskipa\newmuskip\@tempmuskipa\fi + +\long\def\IfIsExpression +#1% the stuff to be examined +#2% |\dimexpr|, |\glueexpr|, |\numexpr| or |\muexpr| +{% + \ifx#2\numexpr\let\next\@tempcnta\fi + \ifx#2\glueexpr\let\next\@tempskipa\fi + \ifx#2\dimexpr\let\next\@tempdima\fi + \ifx#2\muexpr\let\next\@tempmuskipa\fi + \afterassignment\gmu@testtopenalty + \next=#2#1\penalty +} + +\def\gmu@testtopenalty#1\penalty{% + \gmu@ifempty{#1}} + +\pdef\newgif#1{% + {\escapechar\m@ne + \global\let#1\iffalse + \@gif#1\iftrue + \@gif#1\iffalse + }} +\def\@gif#1#2{% + \protected\@xa\gdef\csname\@xa\@gobbletwo\string#1% + g% the letter $g$ for `|\global|'. + \@xa\@gobbletwo\string#2\endcsname + {\global\let#1#2}} + +\pdef\newif#1{% We not only make \incs{newif} + % \incs{protected} but also make it to define \cs{protected} + % assignments so that premature expansion doesn't affect + % \inverb|\if…\fi| nesting. + % \changes{v0.92}{2008/08/09}{added redefinition so that now + % switches defined with it are \cs{protected} so they won't expand to + % a~further expanding or unbalanced \cs{iftrue/false} in an \cs{edef}} + \count@\escapechar \escapechar\m@ne + \let#1\iffalse + \@if#1\iftrue + \@if#1\iffalse + \escapechar\count@} + +\def\@if#1#2{% + \protected \@xa\def\csname\@xa\@gobbletwo\string#1% + \@xa\@gobbletwo\string#2\endcsname + {\let#1#2}} + +\pdef\hidden@iffalse{\iffalse} +\pdef\hidden@iftrue{\iftrue} + + +\pdef\grefstepcounter#1{% + {\let\protected@edef=\protected@xdef\refstepcounter{#1}}} + +\pdef\hgrefstepcounter#1{% + \ifhmode\leavevmode\fi\grefstepcounter{#1}} + + +\pdef\hunskip{\ifhmode\unskip\fi} + + +\def\glet{\global\let} + + +\lpdef\addtomacro +#1% macro (has to be parameterless) +#2% stuff to be added +{\edef #1{\@xau #1\unexpanded{#2}}} + +\pdef\gaddtomacro{\global\addtomacro} + +\long\def\prependtomacro#1#2{% \changes{v0.94}{2008/09/15}{order of + % arguments reversed} + \edef#1{\unexpanded{#2}\@xa\unexpanded\@xa{#1}}} + +\lpdef\addtotoks#1#2{% + #1=\@xa{\the#1#2}} + +\newtoks\gmu@prependtoks@aux + +\lpdef\gmu@prependtotoks@ambig +#1% scope +#2% toks register +#3% text of prependement +{% + \iffalse {\fi % hack to balance braces in definition + \@XA{% + #1#2=\bgroup#3% + }% during execution, this brace closes the |\@XA|'s argument… + \the#2}% and this one closes the text opened by |\bgroup|, i.e., +} + +\lpdef\prependtotoks +#1% toks register +#2% text to be prepended +{\gmu@prependtotoks@ambig {}{#1}{#2}}% + +\lpdef\gprependtotoks +#1% toks register +#2% text to be prepended +{\gmu@prependtotoks@ambig \global{#1}{#2}}% + +\long\def\addto@forlist +#1% a comma-separated list +#2% the element(s) added +{\ifx#1\@empty + \@xa\@gobble + \else\@xa\@firstofone + \fi + {\addtomacro#1{,}}% + \addtomacro#1{#2}% +} + +\lpdef\eaddtomacro +#1% a macro +#2% stuff to be added (will be fully expanded) +{\edef#1{\@xau#1#2}} + +\long\def\gmu@ifundefined #1{% not |\protected| because expandable. + % \changes{v0.94}{2008/9/12}{added. All \cs{@ifundefined}s used by + % me changed to this} + % \changes{v0.94}{2008/10/03}{made robust to unbalanced \cs{if}s and + % \cs{fi}s the same way as \LaTeX's \cs{@ifundefined} (after a~heavy + % debug :-)} + % + \gmu@CASEnot {csname} {#1\endcsname}% defined… + {\@firstoftwo}% + % + \gmu@CASE {x\@xa\@xa} {\csname #1\endcsname\relax}% but only as |\relax|---then + % 2nd argument. + {\@firstoftwo}% + \gmu@lastCASE + {\@secondoftwo}% + \gmu@ESAC +} + +\long\def\gmu@ifdefined #1#2#3{% + \gmu@ifundefined {#1}{#3}{#2}} + + +\long\def \gmu@ifCSdefined#1{% + \gmu@CASEnot {defined} {#1} + {\@secondoftwo}% + % + \gmu@CASE x {\relax #1} + {\@secondoftwo}% + % + \gmu@EatCases + {\@firstoftwo}% + \gmu@ESAC +} + +\long\def\CSNameIf +#1% the name to check and probably execute +{% + \ifcsname #1\endcsname + \@xa\@twoofthree + \else\@xa\@thirdofthree + \fi + {\csname #1\endcsname}% +} + +\foone{\catcode`\_=8 } +{\let\subs=_} + +\foone{\catcode`\^=7 } +{\let\sups=^} + +\foone{\@makeother\_} +{\def\xiiunder{_}} + +\let\all@unders\xiiunder +\foone{\catcode`\_=8 } +{\addtomacro\all@unders{_}} +\foone{\catcode`\_=11 } +{\addtomacro\all@unders{_}} +\foone{\catcode`\_=13 } +{\addtomacro\all@unders{_}} + +\foone{\@makeother\^^M}{\def\xiiM{ + }}% \chgs{2010/03/16 v0.992 added} + +\def\all@stars{*} +\foone{\catcode`\*=11 } +{\addtomacro\all@stars{*}} +\foone{\catcode`\*=13 } +{\addtomacro\all@stars{*}} + +\def\all@spaces{ } +\foone{\@makeother\ }{% +\addtomacro\all@spaces{ }% +} +\foone{\obeyspaces}{% +\addtomacro\all@spaces{ }% +} + +\foone\obeylines{% + \def\two@Ms{ + }} +\foone{\@makeother\^^M}{% + \addtomacro\two@Ms{ + }} + +\edef\spaces@and@Ms{\@xau{\all@spaces}\@xau{\two@Ms}} + +\ifdefined\XeTeXversion + \chardef\_="005F +\fi + +\foone{\@makeother\`}% +{\def\backquote{`}} + +\foone{\catcode`\[=1 \@makeother\{ + \catcode`\]=2 \@makeother\}}% +[% + \def\xiilbrace[{]% + \def\xiirbrace[}]% +]% of |\firstofone| + + +\foone{\catcode`\_=\active} +{% + \pdef\smartunder{% + \catcode`\_=\active + \def_{% + \ifincsname\xiiunder + \else + \ifmmode\subs + \else\xiiunder % + \fi + \fi}}}% We define it as \inverb|\_| not just as +\foone{\catcode`\!=0 + \@makeother\\} +{!newcommand*!xiibackslash{\}} + +\let\bslash=\xiibackslash + +\foone{\@makeother\%} +{\def\xiipercent{%}} + +\foone{\@makeother\&}% +{\def\xiiand{&}} + +\foone{\@makeother\ }% +{\def\xiispace{ }} + +\foone{\@makeother\#}% +{\def\xiihash{#}} + + +\AtBeginDocument{% + \ifdefined\xxt@visiblespace + \let\visiblespace\xxt@visiblespace + \def\xxt@visiblespace@fallback{{% + \fontspec{Latin Modern Mono}\textvisiblespace}}% + \else + \let\visiblespace\xiispace + \fi} + +\foone\obeyspaces{\def\gmu@activespace{ }} + +\foone\obeylines{\def\activeM{^^M}} + +\pdef\makeblanksignored{% + \catcode`\^^M=9\relax + \catcode`\^^I=9\relax + \catcode`\ =9\relax} + +\pdef\fooblanksignored{% + \foone{\makeblanksignored}% +} + + +\long\pdef\edefU#1#2{% + \edef#1{\unexpanded{#2}}% +} + +\long\pdef\xdefU#1#2{% + \xdef#1{\unexpanded{#2}}% +} + +\long\pdef\@ifnextcat#1#2#3{% + \edefU\reserved@d{#1}% + \edefU\reserved@a{#2}% + \edefU\reserved@b{#3}% + \futurelet\@let@token\@ifncat} + +\def\@ifncat{% + \ifx\@let@token\@sptoken + \let\reserved@c\@xifncat + \else + \ifcat\reserved@d\@nx\@let@token + \let\reserved@c\reserved@a + \else + \let\reserved@c\reserved@b + \fi + \fi + \reserved@c} + +{\def\:{\let\@sptoken= } \global\: % this makes |\@sptoken| a space token. + + % \DefIndex\@xifncat +\def\:{\@xifncat} \@xa\gdef\: {\futurelet\@let@token\@ifncat}} +\pdef\spifletter{\@ifnextcat a{\space}{}} + +\long\pdef\@ifnextif#1#2#3{% + \def\reserved@d{#1}% + \def\reserved@a{#2}% + \def\reserved@b{#3}% + \futurelet\@let@token\@ifnif} + +\def\@ifnif{% + \ifx\@let@token\@sptoken + \let\reserved@c\@xifnif + \else + \if\reserved@d\@nx\@let@token + \let\reserved@c\reserved@a + \else % |#1| of |\@ifnextif| is not |\if|-equivalent the future + % token. But this may be because the future token is active + % so it \emph{would} be |\if|-equivalent if not passed + % through |\futurelet|. Let's manage this case. + \begingroup + \edef\gmu@tempa{% + \lccode`\@nx~=`\reserved@d + }\gmu@tempa + \lowercase{\endgroup + \ifx~}\@let@token + \let\reserved@c\reserved@a + \else + \let\reserved@c\reserved@b + \fi + \fi + \fi + \reserved@c} + +{\def\:{\let\@sptoken= } \: % this makes |\@sptoken| a space token. +\def\:{\@xifnif} \@xa\gdef\: {\futurelet\@let@token\@ifnif}} + +\long\pdef\@ifnextac#1#2{% + \@ifnextnotgroup + {\gmu@ifnac{#1}{#2}}% + {#2}} + +\long\def\gmu@ifnac#1#2#3{% + \ifcat\@nx~\@nx#3% + \@xa\@firstoftwo + \else\@xa\@secondoftwo + \fi{#1#3}{#2#3}} + + + +\pdef\gmu@lowstar{% + \iffontchar\font"22C6 \char"22C6 \else\gmu@lowstarfake\fi +}% we could define it to + + +\def\gmu@tempa{*} +\foone{\catcode`\*=\active} +{\def\gmu@tempb{*}% it's defined in line \ref{active star} + % to make |*| defined (when it was undefined, + % \incmd\newcommand's \incs{gm@ifstar} test turned + % true, the next undefined token was gobbled and raised an error). + \let*=\gmu@lowstar} + +\edef\gmu@tempa{% + \long\pdef\@nx\gmu@ifstar##1##2{% \chgs{2008/12/16 v0.98 renamed from + % \cs{@ifstar} since something + % redefines \cs{@ifstar}} + \@nx\@ifnextif\gmu@tempa% + {\@nx\@firstoftwo{##1}}% it's a bit hacky but O.K.: if the + % condition is not satisfied, the following brace is taken + {% + \@nx\@ifnextchar\@xa\@nx\gmu@tempb + {\@nx\@firstoftwo{##1}}% and again, if the condition is not + % satisfied, the second brace is taken. + {##2}% + }% of if not |*|\cat 12 + }% of |\gmu@ifstar|. +}\gmu@tempa + + +\long\pdef\@ifnextnotgroup#1#2{% \chgs{2008/12/11 v0.98 extracted from + % \cs{@ifnextac}} This macro checks whether the next token is able + % to be picked or is it a~braced list of tokens or is it a~group + % closer so there's no token to be picked. + \@ifnextcat\bgroup{#2}{% + \@ifnextcat\egroup{#2}% \chgs{2008/12/11 v0.98 added test for + % \cmd\egroup} + {#1}}} + +\long\pdef\@ifnextgroup#1#2{% Note this macro turns true both before + % a~group opener and before a~group closer. + \@ifnextnotgroup{#2}{#1}} + +\pdef\ignoreactiveM{% + \@ifnextgroup{}{\gmu@checkM}% +} + +\foone\obeylines{% we know it's a~single token since we use this macro + % only in \incmd\@ifnextgroup's ‘else’. + \long\pdef\gmu@checkM#1{% + \ifx + #1\@xa\ignoreactiveM% + \else\@xa#1\fi % + }% +} + +\let\gmu@reserveda\*% +\def\*{% + \let\*\gmu@reserveda + \let\gmu@letspace= }% +\* % + + +\lpdef\gmu@peep@next #1{% + \let\@def@token\@undefined + \edefU\gmu@peepnext@inner {% + \gmu@CASE x {\@let@token\gmu@letspace}% + {\@ifnextchar\par + {#1} + {\let\@let@token= \gmu@letspace % note |=| and blank space + \@XA{#1}\space + }% + }% of if |\futurelet| detected a blank space + % + \gmu@CASE {AnyClause} % if any of the conditions below: + {{ x {\@let@token\@undefined} + x {\@let@token\relax}}} % it's arg of disjunction + {\gmu@peep@hash{#1}}% + % + \gmu@lastCASE + {#1}% + \gmu@ESAC + }% + \futurelet\@let@token\gmu@peepnext@inner +} + +\lpdef\gmu@peep@hash +#1% stuff that probably tests |#2| somehow +#2% a single token, which we are sure is undefined or |\relax| (and +{% + \def\@def@token{#2}% + #1% + #2% +} + +\lpdef\gmu@ifpeeped +#1% kind of comparison +#2% stuff to compare +{% + \gmu@if {defined} {\@def@token} + {\@XA{\gmu@if {#1}}\@xa{\@def@token #2}} + {\gmu@if {#1} {\@let@token #2}}% +} + +\long\pdef\@ifnextspace +#1% if yes +#2% if not +{% + \gmu@peep@next + {\gmu@if x {\@let@token\gmu@letspace}{#1}{#2}}% +} + +\long\pdef\@ifnextcharRS +#1% a single token (will be |\ifx|ed) +#2% what if yes +#3% what if not +{% + \gmu@peep@next + {\gmu@if {defined} {\@def@token} + {\@XA{\gmu@if {StrX}}\@xa {\@def@token #1}}% of the special “null” + % case + % + {\gmu@if x {\@let@token #1}}% + {#2}{#3}% + }% of |\gmu@peep@next| +} + +\long\pdef\@ifnextanyRS +#1% list of tokens (any balanced text, will be |\let| token after token +#2% what if next is one of listed |#1| +#3% what if not +{\gmu@peep@next + {\gmu@if {defined} {\@def@token} + {\@xa \gmu@ifStrXany \@def@token } + % otherwise we are next to a defined and not |\relax| token so + {\gmu@ifxany {\@let@token}}% + {#1}{#2}{#3}% + }% of peep +} + + +\long\def\gmu@ifnextStrXany +#1% outer macro's tested list of tokens +#2% “if found” branch +#3% “if not found” branch +{\gmu@notif {AnyClause} + {{ x {\@let@token\@undefined} x {\@let@token\relax}}}% + {#2}% + % + % Some (i.e.\ \emph{both}) |\@undefined| or |\relax|, then we + % compare strings + {\gmu@futureifany {#2}{#3}{#1}}% +} + +\long\def\gmu@futureifany +#1% what if \OK +#2% what if not \OK +#3% list of tokens +#4% token ot be checked against |#3| (and put back on the input) Note +{\gmu@ifstrany #4 {#3}{#1}{#2}#4} + +\long\pdef\@ifnextanyIS +#1% list of tokens (any balanced text, will be |\let| token after token +#2% what if next is one of listed in |#1| +#3% what if not +{% + \edefU\gmu@ifna@afterlet{% + \gmu@if x{\@let@token\gmu@letspace}% + {% if next is blank space, we drop it and retry: + \edefU\gmu@ifna@resa{\@ifnextanyIS{#1}{#2}{#3}}% + \afterassignment\gmu@ifna@resa + \let\gmu@drain= + }% + {% else we perform |\gmu@ifnextanyIS| + \gmu@ifxany{\@let@token}{#1}{% + \gmu@ifnextStrXany {#1}{#2}{#3}% + }% + {#3}% + }% + }% of the after-let macro + \futurelet\@let@token\gmu@ifna@afterlet +}% of |\@ifnextanyIS| + +\long\pdef\@ifnextnoneRS +#1% list of tokens (any balanced text, will be |\let| token after token +#2% what if next is one of listed |#1| +#3% what if not +{% + \@ifnextanyRS{#1}{#3}{#2}% +} + +\long\pdef\@ifnextgroupRS #1#2{% + \gmu@peep@next + {\gmu@if x{\@let@token\bgroup}{#1}% + {\gmu@if x{\@let@token\egroup}{#1}{#2}}% + }% +} + +\long\pdef\@ifnextnotgroupRS#1#2{% + \@ifnextgroupRS{#2}{#1}} + + + +\foone\obeylines{% + \long\pdef\@ifnextMac#1#2{% + \@ifnextchar^^M{#1}{#2}}} + +\long\def\xiistring#1{% + \if\@nx#1\xiispace + \xiispace + \else + \afterfi{\string#1}% to make the same error as bare |\string| + % would cause in case of empty \inhash1. + \fi} + +\def\@xiispaces#1 #2\@nil{% + #1% + \ifx\@xiispaces#2\@xiispaces + \else + \xiispace + \afterfi{\@xiispaces#2\@nil}% + \fi} + +\long\pdef\xiiEdetoke +#1% a scratch \CS +#2% stuff to be fully expanded and turned to catcode 12 including + % spaces. +{% + \edef#1{#2}% + \edef#1{% + \@xa\@xa\@xa\@xiispaces + \@xa\detokenize\@xa{#1} \@nil}% +} + +\long\def\@ifEUnextchar#1#2#3{% + % ‘if Edefed Unexpanded next char’ + \let\reserved@d=#1% + \edefU\reserved@a{#2}% + \edefU\reserved@b{#3}% + \futurelet\@let@token\@ifnch} + +\newcommand\gmu@storespecials[1][]{% we provide a~possibility of + % adding stuff. For usage see line \ref{@storespecials}. + \def\do##1{\catcode`\@nx##1=\the\catcode`##1\relax}% + \edef\gmu@restorespecials{% + \dospecials\do\^^M}#1} + +\pdef\gmu@septify{% restoring the standard catcodes of specials. The + % name is the opposite of `sanitize' ^^A( + % :-)\,. It restores also the original catcode of \inverb|^^M|. + \def\do{\relax\catcode`}% + \do\ 10\do\\0\do\{1\do\}2\do\$3\do\&4% + \do\#6\do\^7\do\_8\do\%14\do\~13\do\^^M5\relax + %\nostanza |%% \let\do\@makeother|\\ + % |%% \do0\do1\do2\do3\do4\do5\do6\do7\do8\do9\relax|\nostanza +} + +\newif\ifgmu@SMglobal + +\pdef\SMglobal{\gmu@SMglobaltrue} + +\def\MakePrivateLetters{\makeatletter} + +\pdef\StoreMacro{% + \begingroup\MakePrivateLetters + \gmu@ifstar\egStore@MacroSt\egStore@Macro} + +\lpdef\egStore@Macro#1{\endgroup\Store@Macro{#1}} +\lpdef\egStore@MacroSt#1{\endgroup\Store@MacroSt{#1}} + +\pdef\StoreMacro@nocat +{% + \gmu@ifstar \Store@MacroSt \Store@Macro +} + +\def\gmu@storeprefix{/gmu/store} + +\lpdef\Store@Macro#1{% + \escapechar92 + \ifgmu@SMglobal\afterfi\global\fi + \@xa\let\csname \gmu@storeprefix/\bslash@or@ac{#1}\endcsname#1% + \global\gmu@SMglobalfalse +} + +\lpdef\Store@MacroSt#1{% + \edef\gmu@smtempa{% + \ifgmu@SMglobal\@xa\global\fi + \let\@xa\@nx\csname\gmu@storeprefix/\bslash@or@ac{#1}\@xa\endcsname%\label{SMbslash} + % we add backslash because to ensure compatibility between + % \incs{(Re)StoreMacro} and \incs{(Re)StoreMacro*}, that is. to allow + % writing e.g. \inverb|\StoreMacro\kitten| and then + % \inverb|\RestoreMacro*{kitten}| to restore the meaning of + % \incs{kitten}.\ilrr + \ifcsname #1\endcsname % \chgs[\StoreMacro]{2010/04/16 v0.993 + % fixed asymmetry with the unstarred version: till today the + % unstarred version for an undefined \CS undefine the storage \CS + % and the starred version made it \cmd\relax. Now both undefine} + % If the argument \CS is undefined, we undefine the storage macro too. + \@xa\@nx\csname#1\endcsname + \else\@nx\@undefined + \fi + \global\gmu@SMglobalfalse}%% we wish the globality to be just + % once.\par + \gmu@smtempa +} + + +\lpdef\StoreMacros{\begingroup\MakePrivateLetters\egStore@Macros} + +\lpdef\egStore@Macros#1{\endgroup + \Store@Macros{#1}% +} + +\lpdef\Store@Macros #1{% + \gmu@setsetSMglobal + \let\gml@StoreCS\Store@Macro + \gml@storemacros#1.} + +\def\gmu@setsetSMglobal{% + \ifgmu@SMglobal + \let\gmu@setSMglobal\gmu@SMglobaltrue + \else + \let\gmu@setSMglobal\gmu@SMglobalfalse + \fi} + +\lpdef\gml@storemacros#1{% + \def\gmu@storemacros@resa{\@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\gmu@storemacros@resa.% a~dot finishes storing. + \global\gmu@SMglobalfalse + \else + \if\gmu@storemacros@resa,% The list this macro is put before may + % contain commas and that's O.K., we just continue the work. + \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 + % \gmiflink[letRestore]{below}. + \afterfifi{\gmu@setSMglobal\gml@storemacros}% + \fi + \fi +} + +\lpdef\RestoreMacro{% + \begingroup\MakePrivateLetters\gmu@ifstar\egRestore@MacroSt\egRestore@Macro} + +\lpdef\egRestore@Macro#1{\endgroup\Restore@Macro{#1}} +\lpdef\egRestore@MacroSt#1{\endgroup\Restore@MacroSt{#1}} + +\lpdef\Restore@Macro#1{% + \escapechar92 + \gmu@ifstored#1{% + \ifgmu@SMglobal\afterfi\global\fi + \@xa\let\@xa#1\csname \gmu@storeprefix/\bslash@or@ac{#1}\endcsname + \global\gmu@SMglobalfalse}% + {\unless\ifgmu@quiet + \PackageWarning{gmutils}{\@nx#1 is not stored, I do nothing with + it}% + \fi + }% +} + +\long\def\gmu@ifstored#1#2#3{% + \gmu@ifundefined{\gmu@storeprefix/% + \bslash@or@ac{#1}}{#3}{#2}% +} + +\lpdef\gmu@storeifnotyet#1{% + \gmu@if {} {\relax\@nx#1}% we check if it's a~\CS + {\gmu@ifstored{#1}{}{\StoreMacro@nocat#1}}% + {}% +} + +\lpdef\Restore@MacroSt#1{% + \gmu@ifundefined{\gmu@storeprefix/\bslash@or@ac{#1}}% + {\unless\ifgmu@quiet + \PackageWarning{gmutils}{\bslash#1 is not stored. I~do nothing}% + \fi}% + {\edef\gmu@smtempa{% + \ifgmu@SMglobal\global\fi + \@nx\let\@xa\@nx\csname#1\endcsname + \@xa\@nx\csname\gmu@storeprefix/\bslash@or@ac{#1}\endcsname}% cf. the commentary + % in line \ref{SMbslash}. + \gmu@smtempa}% + \global\gmu@SMglobalfalse +} + +\lpdef\RestoreMacros{% + \begingroup\MakePrivateLetters + \egRestore@Macros} + +\lpdef\egRestore@Macros#1{\endgroup + \Restore@Macros{#1}% +} + +\lpdef\Restore@Macros #1{% + \gmu@setsetSMglobal + \let\gml@StoreCS\Restore@Macro% \gmhypertarget[letRestore]{we} + % direct the core \CS towards restoring and call the same iterating + % macro as in line \ref{InnerStore}. + \gml@storemacros#1.} + +\pdef\ResetMacro{% restore possibly to |\@undefined| + % \chgs{2010/04/16 v0.993 added} + \begingroup\MakePrivateLetters\gmu@ifstar\egReset@MacroSt\egReset@Macro} + +\lpdef\egReset@Macro#1{\endgroup\Reset@Macro{#1}} +\lpdef\egReset@MacroSt#1{\endgroup\Reset@MacroSt{#1}} + +\lpdef\Reset@Macro#1{% + \escapechar92 + \ifgmu@SMglobal\@xa\global\fi + \ifcsname \gmu@storeprefix/\bslash@or@ac{#1}\endcsname + \@xa\let\@xa#1\csname \gmu@storeprefix/\bslash@or@ac{#1}\endcsname + \else + \let#1\@undefined + \fi + \global\gmu@SMglobalfalse +}% + +\lpdef\Reset@MacroSt#1{% + \ifcsname \gmu@storeprefix/\bslash@or@ac{#1}\endcsname + \ifgmu@SMglobal\@xa\global\fi + \@xa\let\csname#1\@xa\endcsname + \csname\gmu@storeprefix/\bslash@or@ac{#1}\endcsname % cf. the commentary + % in line \ref{SMbslash}. + \else + \@xa\let\csname#1\endcsname\@undefined + \fi + \global\gmu@SMglobalfalse +} + +\lpdef\ResetMacros{\begingroup\MakePrivateLetters\Reset@Macros} + +\lpdef\Reset@Macros#1{\endgroup + \gmu@setsetSMglobal + \let\gml@StoreCS\Reset@Macro% \gmhypertarget[letReset]{we} + % direct the core \CS towards restoring and call the same iterating + % macro as in line \ref{InnerStore}. + \gml@storemacros#1.} + +\pdef\StoredMacro{\begingroup\MakePrivateLetters\Stored@Macro} +\lpdef\Stored@Macro#1{\endgroup\Restore@Macro#1#1} + +\long\def\storedcsname#1{%% \changes{v0.88}{2008/08/03}{added} + \ifcsname \gmu@storeprefix/\bslash@or@ac{#1}\endcsname + \afterfi{% + \csname \gmu@storeprefix/\bslash@or@ac{#1}\endcsname}% + \else \@xa \@undefined + \fi +} + +\pdef\StoreEnvironment#1{% \label{StoreEnvironment} + \Store@MacroSt{#1}\Store@MacroSt{end#1}} + +\pdef\RestoreEnvironment#1{% + \Restore@MacroSt{#1}\Restore@MacroSt{end#1}} + +\pdef\StoringAndRelaxingDo{% + \gmu@SMdo@setscope + \long\def\do##1{% + \gmu@SMdo@scope + \@xa\let\csname \gmu@storeprefix/\bslash@or@ac{##1}\endcsname##1% + \gmu@SMdo@scope\let##1\relax}} + +\pdef\gmu@SMdo@setscope{% + \ifgmu@SMglobal\let\gmu@SMdo@scope\global + \else\let\gmu@SMdo@scope\relax + \fi + \global\gmu@SMglobalfalse +} + +\lpdef\RestoringDo{% + \gmu@SMdo@setscope + \long\def\do##1{% + \gmu@SMdo@scope + \@xa\let\@xa##1\csname + \gmu@storeprefix/\bslash@or@ac{##1}\endcsname}% +} + +\pdef\gmu@MakeScopePrefix +#1% \CS to be let |\global| or |\relax| +#2% a sequence of tokens +{% + \let#1\relax + \gmu@ifxany{\global}{#2}% + {\let#1\global}{}% +} + +\lpdef\gmu@namelet +#1% scope prefix (to be honest, \emph{any} sequence of tokens that may + % be passed as an argument: |\gmu@ifxany| will parse it) +#2% left side of the assignment +#3% right side of the assignment +{% + \gmu@MakeScopePrefix\gmu@namelet@scpref{#1}% + \gmu@if {csname} {#3\endcsname}% + {% + \@xa\gmu@namelet@scpref\@xa\let\csname#2\@xa\endcsname + \csname#3\endcsname}% + {% + \@xa\gmu@namelet@scpref + \@xa\let\csname#2\endcsname\@undefined}% +} + +\pdef\n@melet{\gmu@namelet\relax} + +\pdef\gn@melet{\gmu@namelet\global} + +\long\pdef\tri@let +#1% scope prefix(es) +#2% left side +#3% right side of the assignment +{% + \gmu@MakeScopePrefix\gmu@tri@let@scpref{#1}% + \ifcat\@nx~\@nx#2% + \def\next{\gmu@tri@let@scpref\let#2}% + \else \edef\next{\gmu@tri@let@scpref\let\@xanxtri{#2}}% + \fi + \ifcat\@nx~\@nx#3% + \next#3% + \else + \edef\next{% + \@xau\next + \ifcsname \strip@bslash{#3}\endcsname + \@xanxtri{#3}% + \else\@nx\@undefined + \fi + }% of next's edef + \next + \fi +}% + +\long\pdef\envirlet#1#2{% for |\let|ting environments. + \n@melet{#1}{#2}% + \n@melet{end#1}{end#2}% +} + +\long\pdef\glenvirlet#1#2{% for |\let|ting environments. + \gn@melet{#1}{#2}% + \gn@melet{end#1}{end#2}% +} + + + +\def\@ifXeTeX{% two-argument command + \ifdefined\XeTeXversion + \unless\ifx\XeTeXversion\relax\afterfifi\@firstoftwo\else\afterfifi\@secondoftwo\fi + \else\afterfi\@secondoftwo\fi +} + + +\newif\ifgmuXeTeX +\@ifXeTeX{\gmuXeTeXtrue}{}% + + +\@ifXeTeX{% + \pdef\textbullet{% \changes{v0.94}{2008/10/3}{the \XeTeX\ + % version enriched with \cs{iffontchar} due to lack of bullets + % with the default settings reported by Morten H\o{}gholm and Edd Barrett} + \iffontchar\font"2022 \char"2022 \else\ensuremath{\bullet}\fi}% + % + \pprovide\glyphname#1{% \changes{v0.96}{2008/11/12}{moved here from + % my private document class} + \XeTeXglyph \numexpr\XeTeXglyphindex "#1"\relax\relax}% since + % \XeTeX\ … \incs{numexpr} is redundant. +} +{\def\textbullet{\ensuremath{\bullet}}} + +\def\if@XeTeX {\@ifXeTeX {\iftrue}{\iffalse}} + + +\long\def\detoken@xa#1{\detokenize\@xa{#1}} + + \long\def\all@other#1{\@xa\gmu@gobmacro\meaning#1} + + % The |\gmu@gobmacro| macro above is applied to gobble the |\meaning|'s + % beginning, |long macro:->| all `other' that is. + % \Define\gmu@gobmacro + \edef\gmu@tempa{% + \def\@nx\gmu@gobmacro##1\@xa\@gobble\string\macro:##2->{}} + \gmu@tempa + + +\def\gmshowlists{% + \tracingonline=1 + \showboxdepth=1 \showboxbreadth=1000000 \showlists} + +\def\gmshowbox{% + \tracingonline=1 + \showboxdepth=10000 \showboxbreadth=10000 \showbox} + +\def\gmtracingoutput{% + \tracingoutput\@ne + \tracingonline=\@ne + \showboxdepth=1 + \showboxbreadth=1000000 +} + +\newif\ifgmu@debug@msgs + +\def\gmtron{% + \tracingonline=\@M + \tracingmacros=\@M + \tracingassigns=\@M + \tracingcommands=\@m + \gmu@debug@msgstrue + \let\let\let +} + +\def\gmtroff{% + \tracingonline=\m@ne + \tracingmacros\m@ne + \tracingassigns=\m@ne + \tracingcommands=\m@ne + \tracingoutput=\m@ne + \gmu@debug@msgsfalse + \let\let\let +} + +\newcommand\nameshow[1]{% + \ifcsname #1\endcsname + \@xa\show\csname#1\endcsname + \else \show\@undefined + \fi} + +\newcommand\nameshowthe[1]{% + \ifcsname #1\endcsname + \@xa\showthe\csname#1\endcsname + \else \showthe\@undefined + \fi} + +\newcommand\namemeaning[1]{% + \ifcsname #1\endcsname + \@xa\typeout{\@xa\meaning\csname#1\endcsname}% + \show\relax + \else \typeout{\meaning\@undefined}\show\relax + \fi} + +\def\secondclass{% + \newif\ifSecondClass + \SecondClasstrue + \@fileswithoptions\@clsextension}%|[outeroff,gmeometric]{gmdocc}|% + +\AtBeginDocument{% + \unless\ifdefined\@parindent + \newskip\@parindent + \@parindent=\parindent + \fi +} + +\def\balsmiley#1 {}% to balance parentheses and brackets in + % smileys. \balsmiley( ;-) \inverb|\balsmiley( ;-)| + +\long\def\scantnoline#1{% ‘rescan tokens without adding line at the end’ + {\endlinechar\m@ne\scantokens{#1}}} + +\pdef\getprevdepth{% to pass last depth through a group (e.g. |\end{envir.}|) + \endgraf + \xdef\setprevdepth{\prevdepth=\the\prevdepth\relax}% +} + +\pdef\getprevdepthlocal{% + \endgraf + \edef\setprevdepth{\prevdepth=\the\prevdepth\relax}% +} + +\def\StoreCatM{% + \protected\edef\RestoreCatM{% + \catcode`\@nx\^^M=\the\catcode`\^^M\relax}% +} + +\pdef\RestoreCatM{\PackageE{gmutils}{first store the catcode of + ^\empty^\empty M with \string\StoreCatM.}% +} + + +\RequirePackage{graphicx} + +\pdef\resizegraphics#1#2#3{% % \changes{v0.94}{2008/10/4}{\cs{includegraphics} + % works well in \XeTeX\ so I~remove the complicated version + % with \cs{XeTeXpicfile}} + % 2009/11/17 works bad with a file whose name contains spaces so I + % return \cmd\XeTeXpicfile + \resizebox{#1}{#2}{% + \edef\gmu@tempa{\@nx\csname XeTeX\@nx\@ifendswithpdf{% + \@xa\string\csname#3\endcsname}{pdf}{pic}file\@nx\endcsname}% + \gmu@tempa "#3"\relax}} + +\edef\gmu@tempa{% + \def\@nx\@ifendswithpdf##1{% + \unexpanded{% + \ifnum + \if\relax\gmu@pdfdetector}##1% + \detokenize{pdf}\unexpanded{\relax0\else1\fi}% we expand to 1 if + % \inhash1 ends with lowercase ‘pdf’ of cat. 12 + \unexpanded{\if\relax\gmu@PDFdetector}##1% + \detokenize{PDF}\unexpanded{\relax0\else1\fi}% we expand to 1 if + % \inhash1 ends with uppercase ‘PDF’ of cat. 12 + >0 + \unexpanded{\@xa\@firstoftwo\else\@xa\@secondoftwo\fi}% + }% of |\@ifendswithpdf| + % + % \stanza + % + \def\@nx\gmu@pdfdetector##1\detokenize{pdf}{}% + \def\@nx\gmu@PDFdetector##1\detokenize{PDF}{}% +}\gmu@tempa + + +\def\lastcentered{% + \lastlinefit\z@ + \parindent0sp\relax + \leftskip\dimexpr1\leftskip\relax plus 1fil\relax + \rightskip\dimexpr1\rightskip\relax plus -1fil\relax + \parfillskip0sp plus 2fil\relax +} + +\def\endlastcentered{\par\@endpetrue} + +\def\firstcentered{% + \lastlinefit\z@ + \parfillskip 0sp\relax + \rightskip0sp plus 1fil\relax + \leftskip0sp plus -1fil\relax + \parindent 0sp + \addtotoks\everypar{\hskip0sp plus 2fil\relax}% +} + +\let\endfirstcentered\endlastcentered + +\def\gmu@measurewd#1{% \label{@measurewd} + \edef\gmu@tempa{\the\fontcharwd\font`#1}% + \settowidth{\@tempdimb}{% to preserve kerning + \char`#1\char`#1\char`#1\char`#1\char`#1\char`#1% + \char`#1\char`#1\char`#1\char`#1\char`#1\char`#1% + \char`#1\char`#1\char`#1\char`#1\char`#1\char`#1% + \char`#1\char`#1\char`#1}% + \edef\gmu@tempb{\the\dimexpr(\@tempdimb-\gmu@tempa)/20}% +} + +\def\@xa@three#1#2{% reverses expansion of three tokens, two given as + % arguments. (third may be |{|^^A } + % ) + \@xa\@xa\@xa \@xa\@xa\@xa \@xa #1% + \@xa\@xa\@xa #2% + \@xa } + +\def\@xa@four#1#2#3{% reverses expansion of four tokens, three given as + % arguments. (fourth may be |{|^^A } + % ) + \@xa\@xa\@xa\@xa \@xa\@xa \@xa + \@xa\@xa\@xa\@xa \@xa\@xa\@xa\@xa #1% + \@xa\@xa\@xa\@xa \@xa\@xa \@xa #2 + \@xa\@xa\@xa #3% + \@xa } + + +\long\pdef\@ifenvir#1{%\label{@ifenvir}\ + % \begin{enumargs} + % \mand enquired environment name which will be confronted with + % \incs{@currenvir} + % \mand what if true (if the names are + % equivalent\qfootnote{The names are checked whether they produce + % the same \cmd\csname. They don't have to have the same + % catcodes.}) + % \mand what if false + % \end{enumargs} + % + % \changes{v0.92}{2008/08/07}{added} + % \chgs{2010/06/02 v0.993 made \cmd\protected after an error at work} + \gmu@ifedetokens{\@currenvir}{#1}% +} + +\pdef\@ifjobname#1{\gmu@ifedetokens{\jobname}{#1}} + +\long\def\gmu@ifstrcmp +#1% wrapper for left side of comparison +#2% wrapper for right side of comparison +#3% left side of comparison (list of tokens) +#4% right —”— +{% + \ifnum\strcmp{#1{#3}}{#2{#4}}=\z@ + \@xa\@firstoftwo + \else + \@xa\@secondoftwo + \fi +} + +\def\gmu@ifdetokens +{% + \gmu@ifstrcmp\detokenize\detokenize +}% of |\gmu@ifdetokens| + +\def\gmu@ifutokens +{% + \gmu@ifstrcmp\unexpanded\unexpanded +} + +\def\gmu@ifedetokens{% + \gmu@ifstrcmp \@firstofone \@firstofone +} + +\@XA{\pdef\gmu@pifdetokens}\@xa{\gmu@ifdetokens} + +\@XA{\pdef\gmu@pifutokens}\@xa{\gmu@ifutokens} + +\@XA{\pdef\gmu@pifedetokens}\@xa{\gmu@ifedetokens} + + % \chgs{2009/04/21 v0.99 moved to a~separate macro from + % \cmd\@ifenvir\ and made symmetric to both arguments} + % \chgs{2008/12/01 v0.98 rewritten not to make entries in the hash + % table, thanks to \cmd\detokenize\ and made robust to open \cs{if}s + % in the arguments thanks to substitution of explicit parameters + % with \cmd\@firstoftwo\ and \cmd\@secondoftwo} + + + +\def\gmu@HHashes#1#2{% this is a~fully expandable loop analogous to + % that of The % \eTeX\ Manual p.~9. + \ifnum#1<#2 % + ################\number#1 + \expandafter\gmu@HHashes + \expandafter{\number\numexpr#1+1\expandafter}% + \expandafter{\number#2\expandafter}% + \fi}% of |\gmu@HHashes|. + +\def\gmu@Hashes#1#2{% this is a~fully expandable loop analogous to + % that of The % \eTeX\ Manual p.~9. + % expanding in an |\edef| to |####›1›…####⁄| (quadruple hashes' sequence) + \ifnum#1<#2 % + ########\number#1 + \expandafter\gmu@HHashes + \expandafter{\number\numexpr#1+1\expandafter}% + \expandafter{\number#2\expandafter}% + \fi}% of |\gmu@hashes|. + +\def\gmu@hashes#1#2{% this is a loop analogous to + \ifnum#1<#2% + ####\number#1 + \expandafter\gmu@hashes + \expandafter{\number\numexpr#1+1\expandafter}% + \expandafter{\number#2\expandafter}% + \fi +}% of |\gmu@hashes|. + +\def\gmu@HHashesbraced#1#2{% + \ifnum#1<#2% + {################\number#1}% + \expandafter\gmu@HHashesbraced + \expandafter{\number\numexpr#1+1\expandafter}% + \expandafter{\number#2\expandafter}% + \fi}% of |\gmu@hashesbraced|. + +\def\gmu@Hashesbraced#1#2{% + \ifnum#1<#2% + {########\number#1}% + \expandafter\gmu@HHashesbraced + \expandafter{\number\numexpr#1+1\expandafter}% + \expandafter{\number#2\expandafter}% + \fi}% of |\gmu@hashesbraced|. + +\def\gmu@hashesbraced#1#2{% + \ifnum#1<#2% + {####\number#1}% + \expandafter\gmu@hashesbraced + \expandafter{\number\numexpr#1+1\expandafter}% + \expandafter{\number#2\expandafter}% + \fi +}% of |\gmu@hashesbraced|. + +\def\gmu@hashesOut#1#2{% + \ifnum#1<#2% + \space\space\space\space + »\@nx\unexpanded{####\number#1}«% + \expandafter\gmu@hashesOut + \expandafter{\number\numexpr#1+1\expandafter}% + \expandafter{\number#2\expandafter}% + \fi +}% of |\gmu@hashesbraced|. + +\def\gmu@hashesOutU#1#2{% + \ifnum#1<#2% + \space\space\space\space + »\@nx\unexpanded{####\number#1}«% + \expandafter\gmu@hashesOut + \expandafter{\number\numexpr#1+1\expandafter}% + \expandafter{\number#2\expandafter}% + \fi +}% of |\gmu@hashesbraced|. + +\@tempcnta=1 +\@whilenum\@tempcnta<11\do{% 2010/4/15 + \@nameedef{gmu@hashes@\the\numexpr\@tempcnta-1\relax}% + {\gmu@hashes1\@tempcnta}% + % + \@nameedef{gmu@Hashes@\the\numexpr\@tempcnta-1\relax}% + {\gmu@Hashes1\@tempcnta}% + % + \@nameedef{gmu@HHashes@\the\numexpr\@tempcnta-1\relax}% + {\gmu@HHashes1\@tempcnta}% + % + \@nameedef{gmu@hashesbraced@\the\numexpr\@tempcnta-1\relax}% + {\gmu@hashesbraced1\@tempcnta}% + % + \@nameedef{gmu@Hashesbraced@\the\numexpr\@tempcnta-1\relax}% + {\gmu@Hashesbraced1\@tempcnta}% + % % + \@nameedef{gmu@HHashesbraced@\the\numexpr\@tempcnta-1\relax}% + {\gmu@HHashesbraced1\@tempcnta}% + % + \edef\gmu@eloops@resa{% + \long\def\@xanxcs{% ^^A >>>>>> printhashes + gmu@TOhashes@\romannumeral\numexpr\@tempcnta-1\relax}% + \gmu@hashes1\@tempcnta{% + \@nx\TypeOut{% + \gmu@hashesOut % ^^A2 + 1 \@tempcnta}% + }% of |\gmu@TOhashes@viii| etc. + % + }% of temporary macro + % + \gmu@eloops@resa + % Generates nine pairs of macros |\gmu@TOhashes@i|, + % |\gmu@TOUhashes@i|, |\gmu@TOhashes@ii|, |\gmu@TOUhashes@ii| + % etc. that print (type out) their arguments on the terminal, + % ^^A expanded or \textbf Unexpanded. + % unexpanded + % + \advance\@tempcnta\@ne +}% of |\@whilenum| + +\foone{\catcode`\ \active}% +{\newcommand*\gmobeyspaces{\let \ \catcode`\ \active}} + +\newcommand*\nohy{\leavevmode\kern0sp\relax} +\newcommand*\yeshy{\leavevmode\penalty\@M\hskip\z@skip} + +\long\pdef\gmu@EdefCurrnames#1{% + \xiiEdetoke\gmu@EdefCurrnames@resa{#1}% + \@xa \gmu@EdefCurrnames@ \gmu@EdefCurrnames@resa.tex.\@nil + % if no extension is present, |tex| is assumed. This couple of + % macros won't work well for files with dots in their names. +} + +\pdef\gmu@EdefCurrnames@ #1.#2.#3\@nil{% + \def\@currname{#1}% + \def\@currext{#2}% +} + +\def\NamedInput@prepare#1{% we wrap in a macro to use also in |\DocInput| + \@pushfilename + \gmu@EdefCurrnames {#1}% +} + +\let\NamedInput@finish=\@popfilename + +\pdef\NamedInput#1{% useful e.g.~in error handling + \NamedInput@prepare {#1}% + \@@input #1\relax + \NamedInput@finish +} + +\def\gmu@ifdim +#1% dimen specification +#2% comparison +#3% dimen specification +{% + \ifnum0\ifx#2≤1\fi\ifx#2≥1\fi\ifx#2≠1\fi=\@ne + \afterfi\unless + \fi + \ifdim#1\ifx#2≤>\fi\ifx#2≥<\fi\ifx#2≠=\fi + \ifx#2>>\fi\ifx#2<<\fi\ifx#2==\fi + \dimexpr(#3)*1\relax% parentheses are for closing all possible + % \eTeX pressions not to gobble that |\relax| + % by them but only by the outermost |\dimexpr| + % to avoid premature expansion of the + % following |\expandafter|. (2010/6/14) + \@xa\@firstoftwo + \else\@xa\@secondoftwo + \fi +} + +\def\gmu@ifskip +#1% glue specification +#2% comparison for natural part +#3% comparison for stretch part +#4% comparison for shrink part +#5% glue specification +{\ifnum + 0\gmu@ifdim{1\glueexpr#1}#2{1\glueexpr#5}10% + \gmu@ifdim{\gluestretch\glueexpr#1}#3{\gluestretch\glueexpr#5}10% + \gmu@ifdim{\glueshrink\glueexpr#1}#4{\glueshrink\glueexpr#5}10=111 + \@xa\@firstoftwo + \else\@xa\@secondoftwo + \fi +}% of |\gmu@ifskip|. + +\def\gmu@ifbox +#1% a box register number (e.g.~|\copy\z@|) +#2% comparison for heights +#3% comparison for depths +#4% comparison for widths +#5% a box register number +{% + \gmu@ifskip + {\glueexpr (\ht#1 plus \dp#1 minus\wd#1 )*1\relax}% + #2#3#4% + {\glueexpr (\ht#5 plus \dp#5 minus\wd#5 )*1\relax}% +} + +\def\greater@dim#1#2{% + \ifdim\dimexpr#1>\dimexpr(#2)*1\relax + #1% + \else #2% + \fi +} + +\long\pdef\gmu@removeelement +#1% element to be removed +#2% macro carrying a comma-separated list +#3% \CS to carry removed element. +{% + \let#3\@undefined% + \def\gmu@removeelement@resa##1,#1,##2\@nil{% + \gmu@ifempty{##2}% + {\edefU#2{##1}}% + {\edefU#2{##1,##2}% + \def#3{#1}% + \@xa\gmu@removeelement@resa#2\@nil + }% + % If |##2| is not empty, then we know |#1| was in the list so we + % have to remove its copy from the end of the list. + }% of |\gmu@removeelement@resa| + \@xa\gmu@removeelement@resa\@xa,#2,#1,\@nil + % We gobble the beginning comma + \@xa\@xa\@xa\ifx\@xa\@firstofmany#2\relax\@nil,% + \edef#2{\unexpanded + \@xa\@xa\@xa{\@xa\@gobble#2}}% + \fi +} + +\long\def\@nxcsn#1{% + \@xa\@nx\csname #1\endcsname} + + +\def\@listbegvskipping{% + \@topsepadd=\topsep + \ifvmode + \advance\@topsepadd by\partopsep + \fi + \par + \addvspace\@topsepadd +} + + +\def\foolc#1#2{% + \begingroup\lccode`#1=`#2\relax + \lcfirstofone +} + +\long\def\lcfirstofone#1{% + \lowercase{\endgroup#1}% +} + +\long\def\PackageWarning#1#2{% + \GenericWarning{% + (#1)\@spaces\@spaces\@spaces\@spaces + }{% + Package #1 Warning: #2% + }% +} + +\long\def\TypeOut#1{% + \edef\TO@resa{#1}% + \edef\TO@resa{\@xa\detokenize\@xa{\TO@resa}}% + \typeout{\TO@resa}} + +\long\def\ShowOut#1{% + \TypeOut{#1}% + \show\TO@resa +} + +\long\pdef\incsdef +#1% a CS or active char +#2% parameters string +#3% definition's body +{% + \def#1#2{\gmu@ifincsname {\string#1}{#3}}% +} + + +\gmu@DefSymbol\gmu@CountTokens@end +\newcount\c@gmu@TokensCount + +\lpdef\gmu@CountTokens +#1% the tokens to be counted. +{% + \c@gmu@TokensCount=\m@ne + \let\gmu@CountToken@token\@undefined + \gmu@CountToken@iter + #1\gmu@CountTokens@end +} + +\def\gmu@CountToken@iter{% + \gmu@if x{\gmu@CountToken@token\gmu@CountTokens@end}% + {}% we've reached the end of iteration + {% + % We increase the counter and throw the iterator after next assignment + \advance\c@gmu@TokensCount\@ne + \afterassignment\gmu@CountToken@iter + \let\gmu@CountToken@token= + }% +}% + + +\long\def\gmu@passbraced +#1% the stuff to be put before |#2| +#2% the stuff we check and pass unbraced if single or braced otherwise +{% + \gmu@CountTokens{#2}% + \gmu@if {num}{\c@gmu@TokensCount=\@ne}% + {\gmu@if x{#2 }% if |#2| is single token of blank space then we + % don't consider it single since it can't be an + % argument to a macro if without braces. + \@secondoftwo\@firstoftwo + }% + \@secondoftwo + {#1#2}{#1{{#2}}}% +}% of |\gmu@passbraced| + +\long\def\gmu@passbracedNotSp +#1% the stuff to be put before |#2| +#2% the stuff we check and pass unbraced if single or braced otherwise +{% + \gmu@CountTokens{#2}% + \gmu@if {num}{\c@gmu@TokensCount=\@ne}% + {#1{#2}}% + {#1{{#2}}}% +}% of |\gmu@passbracedNotSp| + +\long\def\MeaningOrUnex#1{% + \gmu@if {singletoken}{{#1}}% + {\meaning#1}{\unexpanded{#1}}% +} + +\pldef\@iwru#1{% + % + % as simple as possible not to put much output on the terminal if + % tracing is on. + % + \immediate \write \@unused {l.\the\inputlineno:\space #1}% +} + +\pldef\@iwruJ{\@iwru{^^J}} + +\pldef\@iwrum#1{% + \@iwru{»\unexpanded{#1}« is »\MeaningOrUnex{#1}«}% +} + +\pldef\@iwruU #1{\@iwru{\unexpanded{#1}}} + +\pldef\@iwruif#1{% + \gmu@if {gmu@debug@msgs}{} + {\@iwru{#1}}{}% +} + +\long\pdef\IgnInfo +#1% package name +#2% description +#3% stuff we announce as ignored +{% + \PackageInfo{#1}{Item »\unexpanded{#3}« (\MeaningOrUnex{#3}) ignored^^J% + #2}% +} + +\pldef\@iwma{% + % (Added 2010/10/19) + % + % Note it takes a \emph{text} not an argument. + \immediate \write \@mainaux +} + +\def\stepnummacro +#1% a macro that expands to some numerical stuff +#2% +{\edef#1{\the\numexpr #1+#2}} + +\def\boolstobin +#1% a sequence of Boolean switches' names without »if« +{% + \numexpr \boolstobin@iter 0 #1 {}\gmu@delim % +} + +\def\boolstobin@iter +#1% expression so far +#2% the name of current switch (without »if«) +#3% tail of switches +\gmu@delim +{% + \gmu@ifempty{#3}% + {#1\relax}% |\relax| to close the num expression + {\boolstobin@iter + {(#1)*2+\csname if#2\endcsname 1\else 0\fi}% + #3\gmu@delim + }% +} + +\long\def\condstobin +#1% a sequence of conditionals' names without »if« followed by the condition +{% + \numexpr \condstobin@iter 0 #1 {}{}\gmu@delim % +} + +\long\def\condstobin@iter +#1% expression so far +#2% the name of current conditional (without »if«) +#3% the condition for |#2| +#4% tail of switches +\gmu@delim +{% + \gmu@ifempty{#3}% + {#1\relax}% |\relax| to close the num expression + {\condstobin@iter + {(#1)*2+\csname if#2\endcsname #31\else 0\fi}% + #4\gmu@delim + }% +} + + +\long\def\gmu@ifQUANT@iter +#1% the (binary) value that terminates calculation: 0 for AND and 1 + % for OR (it has to be a single token due to |\expandafter| in line + % \ref{@xa-in-QUANT}) +#2% the (binary) value so far; +#3% the name of current conditional (without »if«) +#4% the condition for |#2| +#5% tail of condition(al)s +\gmu@delim +{% + \gmu@ifempty{#5}% + {#2}% + {% or else we check whether |#2| is terminating + \gmu@if {num}{#2=#1 }% with a space + {#1}% + {\@xa\gmu@ifQUANT@iter \@xa #1% \label{@xa-in-QUANT} + \the\numexpr %^^V 1 * % |\numexpr| is used here to get the full + % expansion in one step. No need of superposing with identity. + (\gmu@if {#3}{#4 } {1} {0}) +\z@\relax + #5\gmu@delim + }% + }% +}% of |\gmu@ifQUANT@iter|. + +\long\def \ifAnyClause +#1{% + \ifnum + \gmu@ifQUANT@iter + 1% for the Existential Quantifier 1 terminates calculation (\emph{an(y)} + % example has just been found) + 0% To make any calculation sense we assume 0 at the beginning + % (i.e., “we haven't found an example yet”) + #1 + {false}{} {false} {}% the sentinel(s) + \gmu@delim % the delimiter + =\@ne % right side of |\Ѻifnum| +} + +\long\def\gmu@OR +#1% as above\\ +{% + \ifAnyClause {#1}% + \@xa\@firstoftwo + \else + \@xa\@secondoftwo + \fi +} + +\long\def\ifAllClauses +#1% a sequence of pairs \arg{conditionals' name without »if«}{the +{% + \ifnum + \gmu@ifQUANT@iter + 0% for the General Quantifier 0 terminates calculation (when a + % counter-example has just been found) + 1% To make any calculation sense we assume 1 at the beginning + #1 + {true}{} {true} {}% the sentinel(s) + \gmu@delim % the delimiter + =\@ne % right side of |\Ѻifnum| +} + +\long\def\gmu@AND +#1% +{% + \ifAllClauses {#1}% + \@xa\@firstoftwo + \else + \@xa\@secondoftwo + \fi +} + +\long\def\sName #1#2 {\@xa#1\csname #2\endcsname} + +\long\def\sdName #1#2 {\@xa#1\csname \detokenize{#2}\endcsname} + +\long\def\dName #1#2{\@xa #1\csname \detokenize{#2}\endcsname} + +\long\def\@sN #1 {\csname #1\endcsname} +\long\def\@sdN #1 {\csname \detokenize{#1}\endcsname} + + +\pdef\clap #1{\hbox to \z@{\hss #1\hss}} + +\pdef\hsizecline #1{\hbox to\hsize{\hss #1\hss}} + +\long\def\gmu@extreme +#1% kind of test (|num| or |dim|) +#2% inequality sign: |<| for minimum, |>| for maximum. +#3% left side of comparison +#4% right side of comparison +{% + \gmu@if {x\@xa\@xa}{\@firstofmany#4\@nil\relax} % this complicated test is to + % allow arguments beginning with some \incs{if⁄<…>} as in + % \incs{possvfil} e.g. + {#3}% + {% + \gmu@if {#1} {\csname #1expr\endcsname#3\relax + #2\csname #1expr\endcsname #4\relax } + {\gmu@extreme {#1}#2{#3}}% + {\gmu@extreme {#1}#2{#4}}% + }% +}% of |\gmu@extreme| + +\def\gmu@maxnum{\gmu@extreme {num}>} +\def\gmu@minnum{\gmu@extreme {num}<} + +\def\gmu@maxdim{\gmu@extreme {dim}>} +\def\gmu@mindim{\gmu@extreme {dim}<} + +\pdef\gmu@fitto +#1% scope (nothing, |\relax| or |\global|. +#2% left side of the assignment (must be a dimen able to be ”passive”) +#3% the comparison (if |#2#3#4| then reassign |#2|) +#4% right side of the assignment---any correct text for |\dimexpr|. +{% + \gmu@if {dim}{#2#3\dimexpr (#4)+\z@\relax\relax}% + {#1#2=\dimexpr (#4)+\z@\relax}% + {}% +} + +\pdef\gmu@g@enlargeto +#1% |#2| of the above +#2% |#4| of the above +{\gmu@fitto\global{#1}<{#2}} + +\pdef\discre#1#2#3{\leavevmode\kern\z@ + \discretionary{#1}{#2}{#3}\penalty\@M\hskip\z@skip} + +\pdef\discret#1{\discre{#1}{#1}{#1}} + +\pdef\gmu@flexhyphen{% + \discre{% before break + \ifnum\hyphenchar\font>\z@ + \char\hyphenchar\font + \fi + }% end of before break + {}%after break + {}% without break +} + +\def\:{% + \ifmmode\afterfi{\mskip\medmuskip}% + \else\afterfi{\discre{\null}{}{}}% \incs{null} to get + % \incs{hyphenpenalty} not \incs{exhyphenpenalty}. + \fi +} + +\lpdef\hboxreflected#1{% + \hbox{% + \reflectbox{#1}% + }% +} + +\pdef\gmu@ifSystemX{% the ‘If file exists” test is \emph{NOT} + % expandable since it involves opening some + % streams. Therefore we define this macro as protected. + \IfFileExists{/etc/passwd}% +} + +\def\hrule@zero{\hrule height\z@ width\z@ depth\z@} +\def\vrule@zero{\vrule height\z@ width\z@ depth\z@} + +\def\do#1#2{% (2010/10/11) + \Name \def{gmu@iflast#1}{% + \ifnum #2=\lastnodetype + \@xa\@firstoftwo + \else + \@xa\@secondoftwo + \fi + }% +} + +\do {glue}{11} \do{skip}{11} +\do{kern}{12} +\do {penalty}{13} + +\def\gmu@dimratio +#1% numerator dim(en/expr) +#2% denominator dim(en/expr) +{\strip@pt + \dimexpr 1pt * + \numexpr\dimexpr (#1)*1\relax\relax / + \numexpr \dimexpr (#2)*1\relax \relax + \relax +} + +\def\MakeFalseIfDefined #1{% + \ifcsname if#1\endcsname + \csn{#1false}% + \fi +} + +\def\MakeTrueIfDefined #1{% + \ifcsname if#1\endcsname + \csn{#1true}% + \fi +} + +\def\gmu@pageremain{\dimexpr + \ifdim\pagegoal=\maxdimen \textheight \else \pagegoal \fi + -\pagetotal + \relax +} + +\def\gmu@GobbleMinus #1{\if-#1\else#1\fi} + +\def\gmu@absExpr +#1% \eTeX's expression primitive, num or dim so far (2010/12/17, 11.46) +#2% expression of respective kind +{% + \@xa\gmu@GobbleMinus\the #1#2\endexpr +} + +\def\gmu@absdim {\gmu@absExpr \dimexpr } +\def\gmu@absnum {\gmu@absExpr \numexpr } + +\pdef\gmu@SetPagegoal #1{% + \gmu@if {dim} {\pagegoal=\maxdimen}% + {}% in this case we do nothing, as explained above + {\pagegoal = \dimexpr (#1)\relax}% +} + +\pdef\gmu@SetPagegoalGlobal #1{% + \gmu@if {dim} {\pagegoal=\maxdimen}% + {}% in this case we do nothing, as explained above + {\global\pagegoal = \dimexpr (#1)\relax}% +} + +\pdef\gmu@AdvancePagegoal #1{% the arg.\ should be a proper stuff for + % a sub-dimexpr (i.a., no spurious |\relax|es are allowed). + \gmu@SetPagegoal {\pagegoal +#1}% +} + +\def\pagegoalortextheight{% as in the name: + \dimexpr + \ifdim \pagegoal=\maxdimen + \textheight + \else \pagegoal + \fi + \relax +} + +\def\gmu@totalht #1{% the arg.\ should be a~box register. + \dimexpr \ht #1+\dp#1\relax +} + +\def\vbadness@M {% + \unless\ifnum\vbadness=\@M + \edef\gmu@VeryBadBadness {\the\vbadness }% + \vbadness\@M + \fi +} + +\def\vbadness@Restore {% + \ifdefined \gmu@VeryBadBadness + \vbadness \gmu@VeryBadBadness \relax + \else + \PackageError{gmbase}{You try to gm-restore \vbadness\space where + it is not gm-stored}{}% + \fi +} + +\relaxen\endexpr + +\relaxen\endrule + +\def\gmu@ifpageodd {% + \ifodd \c@page + \@xa\@firstoftwo + \else + \@xa\@secondoftwo + \fi +} + + +\gmu@DefSymbol\gmu@Fake + +\def\gmu@FakeLoaded +#1% extension +#2% name +{\ifcsname ver@#2.#1\endcsname + \@xa\ifx\csname ver@#2.#1\endcsname \relax + \@xa\@xa\@xa \@firstofone + \else + \@xa\@xa\@xa \@gobble + \fi + \else + \@xa\@firstofone + \fi + {\Name\def {ver@#2.#1}{\gmu@Fake }}% +} + +\def\gmu@FakeUnloaded +#1% extension +#2% name +{\ifcsname ver@#2.#1\endcsname + \@xa\ifx\csname ver@#2.#1\endcsname\gmu@Fake + \Name\let {ver@#2.#1}\@undefined + \fi + \fi +} + +\pdef\LoadPackagePolski {% + \gmu@FakeLoaded \@pkgextension {inputenc}% + \RequirePackage {polski}% + \gmu@FakeUnloaded \@pkgextension {inputenc}% +} + +\def\hrule@zero{\hrule height\z@ width\z@ depth\z@} + + +\pdef \protected@nil {} +\let\protected@empty\protected@nil + +\ifgmuXeTeX + + % 2011/02/03, 12.53 definitions of the macros for combinig + + \def\gmu@nobound + #1% a~char + #2% bound number + {% + \gmu@unless {} + {0% + \gmu@if {num}{#2=\@ne }{0}{}% + \gmu@if {num}{#2=13 } {0}{}% + 1} + {} + {% + \leavevmode + \kern -\glyphbound #1 1% + }% + #1% + \gmu@unless {} + {0% + \gmu@if {num}{#2=\thr@@ }{0}{}% + \gmu@if {num}{#2=13 }{0}{}% + 1} + {} + {% + \kern -\glyphbound #1 3% + }% + } + + \def\glyphbound + #1% char (name) + #2% number of the bound + {% + \XeTeXglyphbounds #2 \XeTeXglyphindex "#1" + } + + \def\gmu@halfcomb + #1% the “basic” char + #2% the accent char + #3% emergency [\pk{fontspec}] font spec + {% + #1\kern-\gmu@halfwd #1% + \clap{% + \gmu@unless {fontchar}{\font `#2 } + {#3}{}% + #2}% + \kern\gmu@halfwd #1% + } + + \def\gmu@halfwd#1{0,45\fontcharwd\font`#1 } + + \def\gmu@llapcomb + #1% the “basic” char + #2% the accent char + #3% emergency [\pk{fontspec}] font spec + {% + \gmu@nobound #13% + \llap{% + \gmu@unless {fontchar}{\font `#2 } + {#3}{}% + #2}% + \kern \XeTeXglyphbounds 3 \XeTeXglyphindex "#1" + } + +\fi % of if \XeTeX + +\pdef\@rmfromreset +#1% counter to be freed, e.g., |figure|, +#2% counter from whose power we free |#1|, e.g., |chapter|. +{% + {% + \def\@elt ##1{% + \gmu@ifdetokens{#1}{##1}% + {}% then we remove the element, otherwise + {\@nx\@elt {##1}}% + }% + % + \Name\xdef{cl@#2}{\csname cl@#2\endcsname}% + }% +} + + +\long\def \gmu@iflist {% + % |#1| (implicit) what if in a list environment + % |#2| (implicit) what if not in a list env. + \ifnum \@listdepth>\z@ + \@xa\@firstoftwo + \else + \@xa\@secondoftwo + \fi +} + +\foone {\@makeother \^^I }{% + \def\xiitab{^^I}% +} + +\foone {\catcode 9=\active } {% + % Totally perverse, but seems to be useful with DocStrip. + \def\gmu@maketabtab {% + \def ^^I{\xiitab}% + }% +} + + +\endinput +%% +%% End of file `gmbase.sty'. diff --git a/macros/latex/contrib/gmutils/gmcommand.sty b/macros/latex/contrib/gmutils/gmcommand.sty new file mode 100644 index 0000000000..f83fc8a2c1 --- /dev/null +++ b/macros/latex/contrib/gmutils/gmcommand.sty @@ -0,0 +1,2432 @@ +%% +%% \iffalse ^^A we skip the debug setting +\IfFileExists{\string~/bin/gen_and_xela}{\errorcontextlines=1000 }{} +%% \fi +%% ^^A $Id: TheUltimateMaster.gmd,v 0.352 2011/10/12 15:19:42 natror Exp natror $ +%% This is file “gmcommand.sty” generated with the DocStrip utility. +%% +%% +%% The original source files were: +%% +%% gmutils/gmutils.gmd (with options: `command') +%% +%% +%% Copyright © +%% by Grzegorz ‘Natror’ Murzynowski +%% natror (at) gmail (dot) com +%% +%% This program is subject to the LaTeX Project Public License. +%% See http://www.ctan.org/tex-archive/help/Catalogue/licenses.lppl.html +%% for the details of that license. +%% +%% LPPL status: "author-maintained". +%% +%% +%% +%% For documentation please refer to the file(s) +%% gmutils.{gmd,pdf}. +%% +%% +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{gmcommand} + [2011/10/12 v0.996 definition of \string \DeclareCommand \string &al. based on the ancient xparse (pre-expl3) (GM)] + + +%% +%% +%% ^^A\typeout{\unexpanded{#4}}%% + +\RequirePackage{gmbase} % we require the low-level macros. + +\unless\ifcsname ifgmu@quiet\endcsname +\Name\newif {ifgmu@quiet}% % it has to be at least (at highest) in + % \CH{2010/09/06 v0.993 moved here from + % % \pk{gmutils.sty} (a bug fix)} +\fi + + +\unless\ifdefined\@temptokenb +\newtoks\@temptokenb +\fi + +\newif\if@dc@alllong@ % for an option of all arguments long (it's + % stronger than |GroteLang| defined later (the + % latter is |\let| it). +\newif\if@dc@quiet@ % for suppressing the message of using of + +\newif\ifDCMessages % a~global switch to suppress the message about + +\newtoks\@dc@arguments % the register for storing parsed + % |\\command {#1}›…{⁄}|. + +\newcount\c@dc@catchernum +\newcount\c@dc@argnum + +\newif\if@dc@ignore@ +\newif\if@dc@GroteNegere@ % for “gross” ignoring +\newif\if@dc@GroteLang@ % for “gross” longness + +\newif\if@dc@long@ + +\newif\if@dc@BareSpace@ + + +\def\@dc@long@letter{% +\if@dc@long@ P\fi +} + +\newif\if@dc@xadefault + +\def\@nx@xa{\@nx\@xa} +\def\@xa@nx{\@xa\@nx} +\def\@xa@xa{\@xa\@xa} + +\newif\if@dc@xadefault@i@ +\newif\if@dc@xadefault@ii@ +\newif\if@dc@xaeacher@ + +\def\@dc@falsify@xadefaults{% + \@dc@xadefaultfalse + \@dc@xadefault@i@false + \@dc@xadefault@ii@false +} + +\lpdef\DeclareCommand#1#2#3{% ^^B It's the draft version just + % ^^B~to declare the true one, which is defined in line + % \ref{DC:final}. + % + % \begin{enumargs} + % \item command to be defined, + % \item arguments specification, + % \item definition body. + % \end{enumargs} + % \chgs[\DeclareCommand]{2008/12/05 v0.98 added the \env{S}/\env{T} + % spec parsing, the + % \env{s} spec parsing rewritten to be a~shorthand for + % \env{S\{*\}}, unused code removed} + % \chgs{2010/04/15 v0.993 implemented the \cmd\SameAs feature} + % + % + % +\@dc@alllong@true + \@dc@ResetParseAuxilia + % + \@dc@ParseNextSpecifier #2% + \@dc@buckstopshere% it's the sentinel of parsing. Doesn't have to be + % defined since the test performs a strings comparison. + \protected\edef#1{% + \@nx\@dc@ {\the\toks@}% + \@xanxcs{\@dc@InnerName{#1}}% + \@nx #1% + }% + \edef\gmu@DeclareCommand@resa{% + \long\def\@xanxcs{\@dc@InnerName{#1}}% + \@xau\@dc@innerhashes{% + \unexpanded{#3}}% + }% of resa + \gmu@DeclareCommand@resa +}% of the ‘draft’ |\DeclareCommand|. + +\long\def\@dc@ + #1% the argument catchers in a~pair of braces (their arguments + % may contain \incmd\par\ so the macro is long). + #2% |\\thecommand\| + #3% |\thecommand| + {% + \ifx\protect\@typeset@protect + \@xa\@firstofone + \else + \protect#3\@xa\@gobble + \fi + {\@dc@arguments{#2}#1\the\@dc@arguments}% +} + +\newtoks \@dc@ParsedSpecs + +\def\@dc@ResetParseAuxilia{% + % + \@dc@ParsedSpecs={}% + % + \c@dc@catchernum\z@ % the count of catchers + \c@dc@argnum\z@ % the count of arguments (inner arity) (it may be + % smaller than the above if we ignore some arguments) + % + \toks@{}% in this register we will store the created sequence of + % argument catchers. + % + % And for the |M⁄m| specifiers: + \@dc@Mmode@false + % + \emptify\@dc@innerhashes % in this macro we will store the sequence of + % \inverb|#1#2…|. + % + \@dc@GroteNegere@false + \let\if@dc@GroteLang@\if@dc@alllong@ +} + +\newif \if@dc@Mmode@ +\def\@dc@Ms@num {\z@}% + +\def\@dc@Ms@init{% + \@dc@Mmode@true + \def\@dc@Ms@num {\z@}% + \edef\@dc@Ms@initial@listate{% + \@dc@Ms@listate + }% of edef +} + +\def\@dc@Ms@listate{% + \boolstobin{{@dc@long@}{@dc@ignore@}}% +} + +\def\@dc@Ms@shipout {% + \gmu@if {num} {\@dc@Ms@num>\z@}% + {\@xa\dc@addtoParsed@\@xa{\@dc@Ms@num}% + \def\@dc@Ms@num{\z@}% + \@dc@Mmode@false + }% + {}% +} + +\def\@dc@ResetStepAuxilia {% + % We set the local ignorance switch to its “gross” value + \let\if@dc@ignore@ =\if@dc@GroteNegere@ + \let\if@dc@long@ = \if@dc@GroteLang@ + % and reset the expandaftering switches + \@dc@falsify@xadefaults + \@dc@BareSpace@false +} + +\def\@dc@argtypes{% + =\gobblespace \loop \lostwax \SameAs \Scope + AaBbCcDdGgKkMmOo% + QqSs*TtUuWw% + \drs +} + +\def\@dc@drses{\drs} % decimal respecting space + +\@ifXeTeX +{\addtomacro\@dc@argtypes{ďĎŤťǓǔÔô}% + \addtomacro\@dc@drses{ďĎ}% +} +{} + +\def\@dc@ParseSpecifier #1{% The main inner macro parsing argument + \gmu@CASE {stribs}{{#1}\@dc@buckstopshere}% + {% + \@dc@Ms@shipout + \edef\@dc@innerhashes {% + \gmu@hashes 1{\numexpr\c@dc@argnum +\@ne}% + }% + }% + \gmu@CASE {stribs}{{#1}>}% + {% + \grab@prefix }% + \@XA{% + \gmu@CASEsbnone{#1}}\@xa{% + \@dc@argtypes + }% + {\IgnInfo{gmcommand}{while parsing arg specifiers}{#1}% + \@dc@ParseNextSpecifier }% + \gmu@CASE {stribs}{{#1}\SameAs}% + {\@dc@SameAs}% + \gmu@ifsbnone {#1}{Mm}% + {\@dc@Ms@shipout }% + {}% + \gmu@if {@dc@Mmode@}{}% + {}% + {% + \gmu@ifsbany{#1}{=\gobblespace}{\@dc@ignore@true}{}% + \gmu@ifsw {@dc@BareSpace@}% + {\@dc@addtoparsed@BareSpace } + {}% + % + % + \gmu@ifsw {@dc@long@}% + {\@dc@addtospecs@bare{>P}} + {}% + % + \gmu@ifsw {@dc@ignore@}% + {\@dc@addtoparsed@Ignore }% + {}% + % + \@dc@addtospecs@bare {#1}% + % + \@xa\addtotoks\@xa\toks@\@xa{% + \csname ArgumentCatcher@\@dc@long@letter + \strip@bslash{#1}% + \endcsname + }% of toks' text. + \advance\c@dc@catchernum\@ne + }% of if not |M|-mode + \gmu@notif {@dc@ignore@}{}% + {\@dc@addinnerhash }% \label{@dc@addinnerhash} + {}% (empty “not-else” branch of ignoring) + \gmu@CASEsbany {#1}{Mm}% + {\@dc@process@ms}% + \gmu@CASEsbany {#1}{Kk}% + {\@dc@define@K}% + \gmu@CASEsbany {#1}{\gobblespace}% + {\@dc@ParseNextSpecifier}% + \gmu@CASEsbany{#1}{=\Scope AaBbCcDdOoSs*}% + {\grab@optparam{#1}}% + \@XA{\gmu@CASEsbany{#1}}\@xa{\@dc@drses}% + {\grab@optparam{#1}}% + \gmu@CASEsbany{#1}{UuǓǔWw\lostwax}% + {\@dc@grab@Loop #1}% putting the specifier's letter as |#1| for the + % grabber suppresses adding it to the parsed specifiers' list. + \gmu@lastCASE + {% + \grab@twoparams{#1}}% + \gmu@ESAC + % +}% of |\@dc@ParseSpecifier| + +\def\@dc@addtoparsed@Ignore{% + \addtotoks\toks@{\@dc@ignorearg}% + \@dc@addtospecs@bare{>i}% +} + +\def\@dc@addinnerhash{% + \advance\c@dc@argnum\@ne +} + +\def\@dc@addtoparsed@BareSpace{% + \addtotoks\toks@{\@dc@BareSpaceArg }% + \@dc@addtospecs@bare{>\BareSpace }% +} + +\def\@dc@process@ms{% + \gmu@if {@dc@Mmode@}{}% + {\gmu@if {num}{\@dc@Ms@initial@listate=\@dc@Ms@listate}% + {\@dc@process@ms@grabnum }% of if the state has'nt been changed + {\@dc@Ms@shipout + % Remember however that we've increased number of arguments so now we + % set it back: + \advance\c@dc@argnum\m@ne + \@dc@ParseSpecifier m% + }% of if the state has been changed + }% of if |M|-mode + {\@dc@Ms@init + \@dc@process@ms@grabnum + }% of not if |M|-mode. +}% of \@dc@process@ms + +\def \@dc@process@ms@grabnum {% + \@ifnextanyIS {\bgroup \@ne \tw@ \thr@@ 123456789}% + {% + \@dc@process@ms@fin}% + {% + \@dc@process@ms@fin \@ne}% +} + +\def \@dc@process@ms@fin #1{% + \edef\@dc@processms@hash {\the\numexpr#1}% + \edef\@dc@processms@left {\the\numexpr 9-\c@dc@argnum+\@ne}% + % + \gmu@AND {% + {num} {\@dc@processms@hash >\z@} + {num} {\@dc@processms@hash <\numexpr + \@dc@processms@left+1 \relax }% + }% + {\stepnummacro \@dc@Ms@num \@dc@processms@hash + \edef\@dc@hashgoal {% + \the\numexpr\c@dc@argnum +% + \@dc@processms@hash-1}% minus 1 because one + \@whilenum \c@dc@argnum<\@dc@hashgoal \do{% + \@dc@addinnerhash + }% + % + \@dc@ParseNextSpecifier + }% of if all conds.\ satisfied + {% some of the conds.\ not satisfied + \PackageError{gmcommand}{% + The argument to the M or m specifier, if any, has to be ^^J% + a number between 1 and \@dc@processms@left ^^J% + (there is/are \the\c@dc@argnum\space arg(s) declared + already).^^J% + I ignore this m/M.}% + {}% + \gmu@passbraced \@dc@ParseNextSpecifier {#1}% + }% +}% of |\@dc@process@ms| + +\def\@dc@ParseNextSpecifier{% + \@dc@ResetStepAuxilia + \@dc@ParseSpecifier +} + +\lpdef\@dc@AddAndParse#1{% + \dc@addtoParsed@{#1}% + \@dc@falsify@xadefaults + \@dc@ParseNextSpecifier +} + + +\def\grab@optparam #1{% arg specifier + \@ifnextchar\bgroup{\@dc@AddAndParse}% + {% + \edef\@dc@tempa{% + \gmu@if {csname}% + {@dc@optparam@deft@\strip@bslash{#1}\endcsname}% + {\@xaucs {@dc@optparam@deft@\strip@bslash{#1}}}% + {\@nx \NoValue}% + }% + \@xa\@dc@AddAndParse\@xa{\@dc@tempa}% + }% +} + + +\long\def\@dc@DeclareDefault #1#2{% + \uppercase{% + \Name\edefU{\strip@bslash{\@dc@optparam@deft@}\strip@bslash{#1}}{#2}}% + % + \lowercase{% + \Name\edefU{@dc@optparam@deft@\strip@bslash{#1}}{#2}}% +} + +\@dc@DeclareDefault D{0} +\@dc@DeclareDefault d{0} + +\@ifXeTeX {% + \@dc@DeclareDefault Ď{0}% +} +{} + +\@xa\@dc@DeclareDefault \@xa\Scope\@xa{\all@stars} + +\@dc@DeclareDefault = {\@tempcnta} + + +\@dc@DeclareDefault Q {\NoValue} + +\@ifXeTeX {% + \@dc@DeclareDefault Ô{\NoValue}% +} +{} + +\@dc@DeclareDefault U {\NoValue} + +\long\def\@dc@maybe@expandafter #1{% + \gmu@if {@dc@xadefault}{}% + {\gmu@ifutokens{#1}{\NoValue}% + {\@secondoftwo}{\@firstoftwo}% + }% if we are to expandafter |#1|. + {\@secondoftwo}% if we don't expandafter |#1| +} + +\long\def\dc@addtotoks@ #1{% + \@dc@maybe@expandafter {#1}% + % + {\toks@\@xa\@xa\@xa{\@xa\the\@xa\toks@\@xa{#1}}}% + {\toks@\@xa{\the\toks@{#1}}}% +} + +\long\def\@dc@addtospecs #1{% + \@dc@maybe@expandafter {#1}% + {\@xa \addtotoks \@xa\@dc@ParsedSpecs\@xa{\@xa{#1}}% + }% + {\addtotoks\@dc@ParsedSpecs{{#1}}}% +} + +\long\def\dc@addtoParsed@ #1{% + \dc@addtotoks@{#1}% + \@dc@addtospecs{#1}% +} + +\long\def\@dc@addtospecs@bare #1{% + \addtotoks\@dc@ParsedSpecs{#1}% +} + +\long\def\@dc@addtotoks@bare #1{% + \addtotoks\toks@ {#1}% +} + +\long\def\@dc@addtoParsed@bare #1{% + \@dc@addtotoks@bare {#1}% + \@dc@addtospecs@bare {#1}% +} + +\long\def\grab@twoparams +#1% the specifier +#2% first parameter, which is mandatory +{% default default (when default is absent) + \if@dc@xadefault@i@\@dc@xadefaulttrue\fi + \dc@addtoParsed@{#2}% + \if@dc@xadefault@ii@ + \@dc@falsify@xadefaults\@dc@xadefaulttrue + \fi + \grab@optparam{#1}% +} + +\long\def\@dc@addargum#1{% + \addtotoks\@dc@arguments{#1}% +\@iwruif {@@@@@@ @dc@arguments: »\the\@dc@arguments«}% +} + +\Store@Macro\@dc@addargum + +\pdef\@dc@ignorearg{% + \long\def\@dc@addargum##1{% + \Restore@Macro\@dc@addargum}% +} + +\StoreMacro@nocat\gmu@passbraced + +\pdef\@dc@BareSpaceArg{% + \let \gmu@passbraced \gmu@passbracedNotSp + \def\@dc@addargum {% + \Restore@Macro\@dc@addargum + \Restore@Macro\gmu@passbraced + \@dc@addargum + }% +} + + +\def\grab@prefix@CASE{% just a shorthand + \@xa\gmu@CASEsbany\gmu@forarg +} + +\long\def\grab@prefix #1{% + %% \CH{2010/07/26 v0.993 made for-eaching to make it behave as + %% expected, i.e.\ that latter settings prævalent over the former} + % + \gmu@foreach#1\gmu@foreach@delim {% + % + \grab@prefix@CASE + {\long!lL\par Pp}% + {\@dc@long@true}% + % + \grab@prefix@CASE + {Ii}% + {\@dc@ignore@true}% + % + \grab@prefix@CASE + {\@xa\expandafter}% + {\@dc@xadefaulttrue}% + % + \grab@prefix@CASE + {\@xa \@xa@nx \@xa@xa \expandafter \@xanx \xanx \xaxa}% + {\@dc@xadefault@i@true}% + % + \grab@prefix@CASE + {\@xa \@nx@xa \@xa@xa \expandafter \@nxxa \nxxa}% + {\@dc@xadefault@ii@true}% + % + \grab@prefix@CASE + {\@xaeacher \xaeacher \xaEacher \xaE }% + {\@dc@xadefault@ii@true}% + % + \grab@prefix@CASE + {\GroteNegere \GrossIgnore \GroteN \GrossI} + {\@dc@GroteNegere@true + \@dc@ignore@true}% + % + \grab@prefix@CASE + {\GroteNegereStop\GrossIgnoreStop + \GroteNStop\GrossIStop} + {\@dc@GroteNegere@false + \@dc@ignore@false}% + % + \grab@prefix@CASE + {\GroteLang\GrossLong\GroteL\GrossL} + {\@dc@GroteLang@true + \@dc@long@true}% + % + \grab@prefix@CASE + {\GroteLangStop\GrossLangStop + \GroteLStop\GrossLStop}% + {% + \let\if@dc@GroteLang@=\if@dc@alllong@ + \let\if@dc@long@=\if@dc@alllong@ + }% + % + \grab@prefix@CASE + {\BareSpace} + {\@dc@BareSpace@true} + % + % + \gmu@EatCases + {\IgnInfo{gmcommand}{while parsing arg specifiers}{#1}}% + \gmu@ESAC + % + }% of for each + \@dc@ParseSpecifier % +}% of |\grab@prefix| + +\long\def\dc@DefParseNext#1{% + % This is to allow hashes in the defaults. + \edefU\@dc@parse@next{#1}% +} + +\def\@dc@Alias +#1% |\lowercase| or |\firstofone| +#2% left side of the assignment +#3% right side of the assignment +#4% |Lower| or empty +{% + \gmu@if {csname}% + {ArgumentCatcher@\strip@bslash #3\endcsname}% + {#1{% + \@xa\let\csname\strip@bslash\ArgumentCatcher@ + \strip@bslash #2\@xa\endcsname}% + \csname ArgumentCatcher@\strip@bslash #3\endcsname + }{\PackageError{gmutils/gmcommand}{% + You're trying to #4Alias the »\unexpanded{#3}« catcher^^J% + but it is not defined!}{}% + }% +} + +\def\@dc@LowerAliases #1{% + % To provide lowercase aliases of the catchers: + \@dc@Alias \lowercase {#1}{#1}{Lower}% + \@dc@Alias \lowercase {\P#1}{\P#1}{Lower}% we provide »P« as a \CS + % to avoid lowercase'ing it. +} + +\def\@dc@AliasCatcher +#1% left side of the assignment +#2% right side of the assignment +{% + \@dc@Alias \firstofone {#1}{#2}{}% +} + +\def\@dc@AliasPLower +#1% specifier to alias +{\@dc@AliasCatcher {P#1}{#1}% + \@dc@LowerAliases{#1}% +} + +\long\def\ArgumentCatcher@B +#1% default value +#2% tail of args catchers. +\@dc@arguments % delimiter +{% + \@ifnextcat\bgroup + {\dc@DefParseNext{#2}\ArgumentCatcher@m@i }% + {\@dc@addargum {{#1}}#2\@dc@arguments }% +} + +\long\def\ArgumentCatcher@PB +#1% default value +#2% tail of args catchers. +\@dc@arguments % delimiter +{\@ifnextcat\bgroup + {\dc@DefParseNext{#2}\ArgumentCatcher@Pm@i }% + {\@dc@addargum {{#1}}#2\@dc@arguments }% +} + +\@dc@LowerAliases B + +\long\def\ArgumentCatcher@T@ % parsing of a~single \textbf Token + % continued: +#1% kind of test (|strings| or |StrX| so far (2010/12/28, 7.24)) +#2% the list to search |#4| on, +#3% the default value, +#4% the tail of args parsers, +#5% the token we search in |#1| (it's an unbraced +{% + #1 #5{#2}% + {\@dc@addargum {{#5}}#4\@dc@arguments}% + {\@dc@addargum {{#3}}#4\@dc@arguments#5}% +} + +\long\def\ArgumentCatcher@T % parsing of a~ single \textbf Token. It's +#1% the list we search optional token on, +#2% the default value, +#3% the tail of args parser. +\@dc@arguments{% + \@ifnextnotgroup + % \label{dc@S:bgroup} + {\ArgumentCatcher@T@ \gmu@ifStrXany {#1}{#2}{#3}}% + {\@dc@addargum {{#2}}#3\@dc@arguments}% if we parse an + % opening or closing brace, then we are sure it's not any expected + % Single. +} + +\@dc@AliasPLower T + +\long\def\ArgumentCatcher@Ť #1#2#3% as in |›…@T| +{% one-token catcher that respects space. + \ArgumentCatcher@Loop + {StrX}{\any}{#1}{\any}{}{1}{#2}{% empty eacher + }{#3}% +} + +\@dc@AliasPLower Ť + + +\edef\ArgumentCatcher@S +#1% default value +{% + \@nx\ArgumentCatcher@T {\@xa\@nx\all@stars}{#1}}% the |s| arg spec is + +\@dc@AliasPLower S +\@dc@AliasCatcher * S + +\newif\if@debugacro@ + +\long\def\ArgumentCatcher@Loop %^^A >>>>>>>loop +#1% kind of test (|StrX| or |str| or anything else for what +#2% “sign” of match for iteration: |\any| or |\none| +#3% list of tokens |\@let@token| will be matched against with |#1| +#4% test for “drainers” (allowed values as for |#1|) +#5% list of “drainers”: if |\@let@token| satisfies the |#3| test, +#6% upper bound of number of items (may be empty or negative to turn +#7% default value (if empty sequence is parsed), |\NoValue| by default. +#8% an “eacher”—stuff to be put before each token/text added to the +#9% the tail of args parser +\@dc@arguments % delimiter +{% + \dc@DefParseNext{#9}% + \emptify\@dc@seQuence + \c@dc@Loop@bound=\numexpr(\gmu@ifempty{#6}{-1}{#6})*1\relax + \gmu@if {num}{\c@dc@Loop@bound<\z@}% + {\c@dc@Loop@bound=-\c@dc@Loop@bound + \let\@dc@Loop@countby\z@ + }% + {\let\@dc@Loop@countby\m@ne}% + % + \gmu@ifempty{#3}% + {\gmu@if {strings}{\none #2}% + {\@dc@Loop@iteralltrue}% it's an additional switch for better + % performance in a special case: when we wish + % only count the items and iterate over anything + {% + \Store@Macro\ArgumentCatcher@Loop@defcheck + \def\ArgumentCatcher@Loop@defcheck{% + \Restore@Macro\ArgumentCatcher@Loop@defcheck + \ArgumentCatcher@Loop@shipout}% + }% of if |#2| str-is |\any| + }% of if |#3| empty + {\@dc@Loop@iterallfalse}% when |#2| nonempty, we \emph{have} to + % perform matching. \rrthis + % + \gmu@ifempty{#5}% + {\gmu@if {strings} {\none #4}% + {\@dc@Loop@addallfalse\@dc@Loop@drainalltrue}% + {\@dc@Loop@addalltrue\@dc@Loop@drainallfalse}% + }% of if |#5| empty + {\@dc@Loop@addallfalse\@dc@Loop@drainallfalse}% when |#4| nonempty, + % we \emph{have} to perform matching. \rrthis + % + \edef\ArgumentCatcher@Loop@afterpeep{% + \gmu@if {@dc@Loop@iterall}{}% + {\firstoftwo}% + {\unexpanded{% + \@dc@Loop@test + {#1}#2{#3}% if the next token StrX-is/is not on |#2|, + % then… \label{h1.@let@token.h2} + }% of |\unexpanded| + }% of if we don't iterate over all (of preparation of iteration test) + {\gmu@if {@dc@Loop@addall}{}% + {\@nx \ArgumentCatcher@Loop@add}% + {\gmu@if {@dc@Loop@drainall}{}% + {\@nx \ArgumentCatcher@Loop@drain}% + {\unexpanded{% + \@dc@Loop@test + {#1}#4{#5}% if the next token satisfies |#4|-direction StrX/str + % match against |#5|, then we discard it, + % otherwise we add it. + \ArgumentCatcher@Loop@drain + \ArgumentCatcher@Loop@add + }% of |\unexpanded| + }% of not drain all + }% of if not add all + }% + {\gmu@if {@dc@Loop@iterall}{}% + {}% + {\@nx \ArgumentCatcher@Loop@shipout}% + }% + \unexpanded{{#7}{#8}}% + }% of |\ArgumentCatcher@Loop@afterpeep| + % + \ArgumentCatcher@Loop@defcheck {#7}{#8}% + \ArgumentCatcher@Loop@check +}% of |\ArgumentCatcher@Loop| + +\newcount\c@dc@Loop@bound + +\newif\if@dc@Loop@iterall +\newif\if@dc@Loop@addall +\newif\if@dc@Loop@drainall + +\long\def\@dc@Loop@test +#1% kind of test (|StrX| or |str| so far (2010/12/28, 7.51)) +#2% |\any| or |\none| +#3% list of tokens to match against +#4% what if \OK +#5% what if not \OK. +{% remember we are in the argument of |\gmu@peep@next| so we are after + % peep. + \gmu@if {defined}{\@def@token} + {\csname gmu@if#1\strip@bslash #2\@xa\endcsname + \@def@token }% + {\csname + gmu@if% + \gmu@ifdetokens {#1}{str}% + {NX}% + {x}% + \strip@bslash #2% + \endcsname + \@let@token }% + {#3}{#4}{#5}% +} + +\@dc@AliasCatcher {PLoop} {Loop} + +\long\def\ArgumentCatcher@Loop@defcheck +#1% default, +#2% “eacher” +{% + \edefU\ArgumentCatcher@Loop@check{% + \gmu@if {num}{\c@dc@Loop@bound>\z@} + {\advance \c@dc@Loop@bound \@dc@Loop@countby + \gmu@peep@next + \ArgumentCatcher@Loop@afterpeep } + {\ArgumentCatcher@Loop@shipout {#1}{#2}}% of if num bound reached + }% of |\ArgumentCatcher@Loop@check| +}% of |\ArgumentCatcher@Loop@defcheck| + +\lpdef\@dc@Loop@CareOfSpace +#1% a macro with all the arguments except last +{\gmu@ifpeeped x \gmu@letspace + {\edef\@dc@Loop@careofspace@aas{% + \unexpanded{#1{ }}% + }% edef unexpanded to allow |#| tokens in |#1| + \afterassignment\@dc@Loop@careofspace@aas + \let\gmu@drain= }% after |=| is a space. + {#1}% next not space, so just |#1| and let it process the next token + % its way. +} + +\StoreMacro@nocat\@dc@Loop@CareOfSpace + +\lpdef\@dc@Loop@CareOfSpace@NoBraces +#1% a macro with all the arguments except last +{% +\gmu@ifpeeped x \gmu@letspace + {\edef\@dc@Loop@careofspace@aas{% + \unexpanded{#1 }% note the space + }% edef unexpanded to allow |#| tokens in |#1| + \afterassignment\@dc@Loop@careofspace@aas + \let\gmu@drain= }% after |=| is a space. + {#1}% next not space, so just |#1| and let it process the next token + % its way. +} + + +\lpdef\@dc@Loop@CareOfSpaceAndGroup +#1% as in the previous macro +{\@iwruif {Care of both: @let@token: »\meaning\@let@token«}% + \@dc@Loop@CareOfSpace{% + \gmu@passbraced{#1}% + }% +}% of “take care of both” + +\long\def\ArgumentCatcher@Loop@add +#1% default +#2% eacher +{\@dc@Loop@CareOfSpaceAndGroup + {\ArgumentCatcher@Loop@add@{#2}}% +} + +\long\def\ArgumentCatcher@Loop@add@ +#1% eacher +#2% token/text to be added +{\addtomacro\@dc@seQuence{#1#2}% + \@iwruif {@@@@@@ Q-add: »\the\@dc@arguments«}% + \ArgumentCatcher@Loop@check +}% of |\ArgumentCatcher@Loop@add@| + +\long\def\ArgumentCatcher@Loop@drain +#1% default +#2% eacher +{% + \@iwruif{@@@@@@ Q-drain: »\the\@dc@arguments«}% + \@dc@Loop@CareOfSpaceAndGroup + {\@xa\ArgumentCatcher@Loop@check\@gobble}% +} + +\long\def\ArgumentCatcher@Loop@shipout +#1% default +#2% eacher +{% + \gmu@if x{\@dc@seQuence\@empty}% + {\def\@dc@seQuence{#1}% + \gmu@if x{\@dc@seQuence\@empty}% + {}{\prependtomacro\@dc@seQuence{#2}}% + }% + {}% if |\@dc@seQuence| is nonempty, we don't modify it. + \@xa\@dc@addargum\@xa{\@xa{\@dc@seQuence}}% + \@iwruif {@@@@@@ Q-finish: »\the\@dc@arguments«}% + \@dc@parse@next\@dc@arguments +}% of |\ArgumentCatcher@Loop@shipout| + +\long\def\ArgumentCatcher@Q +#1% list +#2% default (|\NoValue| by default, as in previous versions). +{% + \ArgumentCatcher@Loop + {StrX}% + \any + { #1}% note the space before |#1|—settheory sum of |#1| and drainers. + \any + { }% we ignore spaces—it's a legacy setting, maybe we'll optionise + % it in the future + \m@ne % we allow any number of tokens + {#2}% default, by default |\NoValue|, as defined in line \ref{Q-arg deft.} + {}% empty eacher +}% + +\@dc@AliasPLower Q + +\@ifXeTeX {% + \long\def\ArgumentCatcher@Ô + #1% list + #2% default (|\NoValue| by default, as in previous versions). + {% + \@dc@BareSpaceArg + \ArgumentCatcher@Loop + {str}% + \any + { #1}% note the space before |#1|—settheory sum of |#1| and drainers. + \any + { }% we ignore spaces—it's a legacy setting, maybe we'll optionise + % it in the future + \m@ne % we allow any number of tokens + {#2}% default, by default |\NoValue|, as defined in line \ref{Q-arg deft.} + {}% empty eacher + }% + + \@dc@AliasPLower Ô + +}{}% of if \XeTeX + +\def\ArgumentCatcher@D{% decimal argument (useful for dates e.g.) + \ArgumentCatcher@Q + {-+0123456789}% + % the default value will be delivered by the defaults' catcher +} + +\@dc@AliasPLower D + +\@ifXeTeX +{% + \def\ArgumentCatcher@Ď + #1% default value, 0 by default + {% decimal argument + \ArgumentCatcher@Loop + {StrX}% + \any + {-+0123456789}% + \any + {}% + \m@ne + {#1}% + {}% + }% + +\@dc@AliasPLower Ď + +}{}% of if \XeTeX + +\def\ArgumentCatcher@U {% + \ArgumentCatcher@Loop {StrX}% +} + +\@dc@AliasPLower U + +\@dc@AliasCatcher W {U} + +\@dc@AliasPLower W + +\@dc@AliasCatcher {lostwax} U % ^^A Catcher@lostwax + +\long\def\ArgumentCatcher@item +#1% “sign” of matching +#2% list to match against +#3% default value +#4% eacher (which in this case will be applied to \emph{the} (one) +{% + \ArgumentCatcher@Loop + {StrX}% + #1% + {#2}% + \none {}% we add all that matches + 1 % at most one item + {#3}% + {#4}% +} + +\if@XeTeX + + \def\ArgumentCatcher@Ǔ{% + \@dc@BareSpaceArg + \ArgumentCatcher@Loop {StrX}% + } + + \@dc@AliasPLower Ǔ + +\fi + + +\long\def\ArgumentCatcher@genM +#1% the letter »P« (for long catcher) or nothing (for the short version) +#2% number of undelimited parametrs to catch (arabic) +#3% tail of parsers +\@dc@arguments{% + \dc@DefParseNext{#3}% + \csname ArgumentCatcher@#1m@% + \romannumeral#2% + \endcsname +} + + +\def\ArgumentCatcher@M{\ArgumentCatcher@genM {}} +\def\ArgumentCatcher@PM{\ArgumentCatcher@genM P} + +\@dc@AliasCatcher {m} {M} +\@dc@AliasCatcher {Pm} {PM} + +\@dc@AliasCatcher {ms} {M} +\@dc@AliasCatcher {Pms} {PM} + +\@tempcnta=\@ne +\@whilenum\@tempcnta<9\do{% + % + \edef\gmu@tempa{% + % + % The short catchers of mandatories: + \def\@xanxcs{% + ArgumentCatcher@m@\romannumeral\@tempcnta}% + \gmu@hashes1{\numexpr\@tempcnta+1}% + {\@nx\@dc@addargum{% + \gmu@hashesbraced 1{\numexpr\@tempcnta+1}}% + \@nx\@dc@parse@next\@nx\@dc@arguments + }% of \incs{ArgumentCatcher@m@\}. + % + % And the long ones: + \long \def\@xanxcs{% + ArgumentCatcher@Pm@\romannumeral\@tempcnta}% + \gmu@hashes1{\numexpr\@tempcnta+1}% + {\@nx\@dc@addargum{% + \gmu@hashesbraced 1{\numexpr\@tempcnta+1}}% + \@nx\@dc@parse@next\@nx\@dc@arguments + }% of \incs{ArgumentCatcher@Pm@\}. + % + }% of |\edef|. + \gmu@tempa + \advance\@tempcnta1\relax +}% of the loop. + +\if 1 1 +\@tempcnta\@ne +\@whilenum\@tempcnta<9\do{% + \typeout{\bslash ArgumentCatcher@m@\romannumeral\@tempcnta: ^^J% + \Name\meaning{ArgumentCatcher@m@\romannumeral\@tempcnta}^^J}% + \typeout{\bslash ArgumentCatcher@Pm@\romannumeral\@tempcnta : ^^J% + \Name\meaning + {ArgumentCatcher@Pm@\romannumeral\@tempcnta}^^J^^J^^J% + }% + \advance\@tempcnta\@ne +} + +\fi + +\def\ArgumentCatcher@m@ix +#1#2#3#4#5#6#7#8#9{% + \@dc@addargum{% + {#1}{#2}{#3}{#4}{#5}{#6}{#7}{#8}{#9}}% + \the \@dc@arguments +} + +\long\def\ArgumentCatcher@Pm@ix +#1#2#3#4#5#6#7#8#9{% + \@dc@addargum{% + {#1}{#2}{#3}{#4}{#5}{#6}{#7}{#8}{#9}}% + \the \@dc@arguments +} + +\long\def\ArgumentCatcher@K % a~Knuthian delimited or undelimited +#1% the particular Knuthian macro +#2% the tail of args parser. +\@dc@arguments % tail delimiter +{\dc@DefParseNext{#2}#1} + +\@dc@AliasPLower K + +\long\def\gmu@twostring#1#2{\string#1\string#2} + +\long\def\ArgumentCatcher@G@longorshort +#1% longness prefix (|\long| or nothing) +#2% left and right delimiters +#3% default value +#4% the tail of args parser. +\@dc@arguments % tail delimiter +{% + \edef\@dc@Gname{ArgumentCatcher@G\gmu@twostring#2}% + \gmu@if {csname}{\@dc@Gname \endcsname}% + {}% + {#1\Name\def{\@dc@Gname \@xa}% + \@dc@Gparams#2{\@dc@addargum{{##2}}##1\@dc@arguments}% + }% + \@xa\@ifEUnextchar\@firstoftwo#2% + {\def\dc@parse@next{#4}% we hide possible |\par|s. + \csname \@dc@Gname \endcsname\dc@parse@next}% + {\@dc@addargum{{#3}}#4\@dc@arguments}% +} + +\long\def\@dc@Gparams#1#2{##1#1##2#2} + +\lpdef\ArgumentCatcher@G % short general catcher +#1% left and right delimiters +#2% default value +{\ArgumentCatcher@G@longorshort{}{#1}{#2}} + +\lpdef\ArgumentCatcher@PG % long general catcher +#1% left and right delimiter +#2% default value +{\ArgumentCatcher@G@longorshort{\long}{#1}{#2}} + +\def\@dc@DefAsGeneral +#1% specifier +#2% delimiters +{\Name\lpdef{ArgumentCatcher@\strip@bslash{#1}}% + ##1% default value + {\ArgumentCatcher@G{#2}{##1}}% + \Name\lpdef{ArgumentCatcher@P\strip@bslash{#1}}% + ##1% default value + {\ArgumentCatcher@PG{#2}{##1}}% »P« was missing. Fixed 2011/03/22, 16.14. + % + \gmu@if {cat}{a\@nx#1}% + {\@dc@LowerAliases #1}{}% +} + +\@dc@DefAsGeneral A{<>} + +\@dc@DefAsGeneral O{[]} + + +\def\DCnocoordinate{\@dc@DefAsGeneral C{()}} +\DCnocoordinate + +\edefU\DCcoordinate{% + % + \long\def\ArgumentCatcher@C + #1% default value + #2% tail of parsers + \@dc@arguments % tail's delimiter + {% + \@ifEUnextchar(%^^A) + {\dc@DefParseNext{#2}\ArgumentCatcher@c@}% + {\@dc@addargum{{#1}}#2\@dc@arguments}% + }% + % + \let\ArgumentCatcher@c\ArgumentCatcher@C + \let\ArgumentCatcher@Pc\ArgumentCatcher@PC + % + \long\def\ArgumentCatcher@PC#1#2\@dc@arguments{% + \@ifEUnextchar(%^^A) + {\dc@DefParseNext{#2}\ArgumentCatcher@Pc@}% + {\@dc@addargum{{#1}}#2\@dc@arguments}% + }% + % + \def\ArgumentCatcher@c@(#1){% + \gmu@ifxany,{#1}% + {\@xa\@dc@addargum\@dc@commasep#1\@dc@commasep}% + {\@dc@addargum{{#1}}}\@dc@parse@next\@dc@arguments + }% + % \stanza + \def\@dc@commasep#1,#2\@dc@commasep{{{{#1}{#2}}}}% + % \stanza + \long\def\ArgumentCatcher@Pc@(#1){% + \gmu@ifxany,{#1}% + {\@xa\@dc@addargum\@dc@commasep#1\@dc@commasep}% + {\@dc@addargum{{#1}}}\@dc@parse@next\@dc@arguments + }% +} + + +\def\@dc@Scope@shipout#1{% + \ifx\@dc@seQuence\@empty\def\@dc@seQuence{#1}\fi + \@xa \gmu@ifxany\@xa \global\@xa{\@dc@seQuence}% + {\@dc@addargum{{\global}}}% + {\@dc@addargum{{\relax}}}% + \@dc@parse@next\@dc@arguments +} + +\def\ArgumentCatcher@Scope +#1% the separator(s) +{\let\@dc@seQuence@shipout@@\@dc@seQuence@shipout + \let\@dc@seQuence@shipout\@dc@Scope@shipout + \ArgumentCatcher@Q{\global\relax}{\relax}% + \let\@dc@seQuence@shipout\@dc@seQuence@shipout@@ + \@dc@ignorearg + \ArgumentCatcher@T{#1}{\NoValue}% +} + +\@dc@AliasCatcher {PScope} \Scope + + +\long\def\gmuIfNoValueTF#1{% % \chgs{2008/12/1 v0.98 the \pk{xparse} tests for + % the presence of value redefined and much simplified (43 \CS'es + % less). Moreover, they are now fully expandable: \cmd\gmuIfNoValueTF, + % \cmd\gmuIfNoValueT, \cmd\gmuIfNoValueF, \cmd\gmuIfValueTF, \cmd\gmuIfValueT, + % \cmd\gmuIfValueF} + % + % \chgs{2010/05/27 v0.993 bug fix: order of \cmd\NoValue and + % \cs{@firstofmany} reversed after a catastrophal |{11}{11}| argument} + \@xa\ifx\@xa\NoValue\@firstofmany#1\@empty\@nil \afterfi\@firstoftwo + \else\afterfi\@secondoftwo + \fi} + +\long\def\gmuIfNoValueT#1#2{\gmuIfNoValueTF{#1}{#2}\@empty} + +\long\def\gmuIfNoValueF#1#2{\gmuIfNoValueTF{#1}\@empty{#2}} + +\long\def\gmuIfValueTF#1#2#3{\gmuIfNoValueTF{#1}{#3}{#2}} + +\long\def\gmuPutIfValue#1{\gmuIfValueT{#1}{#1}} + +\let\gmuIfValueT\gmuIfNoValueF + +\let\gmuIfValueF\gmuIfNoValueT + +\long\pdef\IfLong#1{%\ + % \begin{enumargs} + % \item the argument to check for |\par|, + % \item what if |\par| found, + % \item what if |\par| not found. + % \end{enumargs} + % + \edef\gmu@IfLong@resa{\detokenize{#1}}% + \edef\gmu@IfLong@resa{% + \IfAmong\string\par\@nx\among{\gmu@IfLong@resa}}% + \gmu@IfLong@resa} + + +\long\@namedef{ArgumentCatcher@=}% +#1% register used in the assignment +#2% the tail of args parser. +\@dc@arguments{% + \dc@DefParseNext{% + \@dc@addargum\NoValue % to make ignoring mechanism work + #2\@dc@arguments}% + \afterassignment\@dc@parse@next + #1}% optional space and |=| is left at user's discretion. In fact, + +\n@melet{ArgumentCatcher@P=}{ArgumentCatcher@=} + + +\long\def\ArgumentCatcher@gobblespace +{\ArgumentCatcher@T {\dc@gobblespace@dummy}{\NoValue}} + +\let\ArgumentCatcher@Pgobblespace\ArgumentCatcher@gobblespace + +\def\dc@gobblespace@dummy{\dc@gobblespace@dummy} + +\let\gobblespace\dc@gobblespace@dummy + + +\errorcontextlines=100 + +\long\def\@dc@InnerName#1{% + \bslash@or@ac{#1}% + \bslash +}% + +\long\def\@dc@InnerEndName #1{% version for the end-macros of environments + \bslash end\strip@bslash{#1}% +}% + +%% \CH{2010/07/26 v0.993 This strikingly simple idea of storing the +%% specifiers' sequence in a macro came to my head only after some +%% three years of developing \cmd\DeclareCommand} +\long\edef\@dc@SpecsArName#1{% + Specs \string& arity of + \@nx\bslash@or@ac{#1}% +}% + +\pdef\@dc@messages {% + \gmu@notif {@dc@quiet@}{}% + {% + \gmu@if {DCMessages}{}% + {\PackageInfo{gmcommand}{^^J% + Parsing arguments for \dc@innername^^J% + [specified as: + \unexpanded + \@xa\@xa\@xa \@xa\@xa\@xa \@xa{% + \@xa\@xa\@xa\@secondofmany + % + % not |\@secondofthree| because first use of this definition is for + % |\DeclareCommand| not having its specifiers' carrier. + % + \csname \@dc@specsname\endcsname {}{}\@nil }% + \space ]^^J% + [in file: \@currname.\@currext\space ]}% of info message + }% of if \ac DC messages + {}% of if not |DCMessages| + }% of if not |@dc@quiet@| + {}% of if not not |@dc@quiet@| +}% of |\@dc@messages| + + +\edefU\@dc@DCbody {% +{% \label{DC:final} % + % \chgs{2008/12/05 v0.98 added the \cs{@bsphack}---\cs{@esphack} option} + % \chgs{2008/12/07 v0.98 added the \env{Q\arg{tokens}} argument type + % (a~word over the alphabet \)} + \edef\dc@innername {\@dc@InnerName #1}% we'll use it in |K|-type arg.\ catcher and + \edef\@dc@specsname {\@dc@SpecsArName{#1}}% + \gmu@ifCSdefined {#1}% + {\gmu@if{DCMessages}{}% + {\PackageWarning{gmcommand}{% + ^^J% + Redefining command \dc@innername\space + with \string\DeclareCommand}% + }% + {}% + }% + {\gmu@if {DCMessages}{}% + {\PackageInfo{gmcommand}{^^J% + \string\DeclareCommand-ing \dc@innername\space (new)^^J}% + }% + {}% + }% + \@dc@alllong@false + \@dc@quiet@false + % + \emptify\@dc@Specs@tempa + % + \gmu@ifsbintersect{#2}{\long!lL}{% + \addtomacro\@dc@Specs@tempa{\long}% + \@dc@alllong@true}% + {}% + % + \gmu@ifsbintersect{#2}{.qQ\quiet}{% + \addtomacro\@dc@Specs@tempa{\quiet}% + \@dc@quiet@true}% + {}% + % + \gmu@ifsbintersect{#2}{iIwW\sphack}% + {% if `invisibility' is specified: \UnDef + \addtomacro\@dc@Specs@tempa{\sphack}% + \def\@dc@bsphack@{\@nx\@bsphack}% \UnDef + \def\@dc@esphack@{\@nx\@esphack}% + }% + {\emptify\@dc@bsphack@ + \emptify\@dc@esphack@}% if `invisibility' is not specified. + % + \gmu@ifsbany\envhack{#2}% + {% but if we define an environment: + \addtomacro\@dc@Specs@tempa{\envhack}% + \emptify\@dc@bsphack@ + \emptify\@dc@esphack@ + \edef\@dc@setThrowArgs{% + \dc@ThrowArgs{\string#1}}% if our command is used + }% + {% and if we don't define an environment: + \emptify\@dc@setThrowArgs + }% + % + \relaxen\@dc@global@ + \relaxen\@dc@outer@ + % + \gmu@ifsbany\outer{#2}% + {\addtomacro\@dc@Specs@tempa{\outer}% + \let\@dc@outer@\outer}% + {}% + % + \gmu@ifsbany\global{#2}{% + \addtomacro\@dc@Specs@tempa {\IAmDeclaredGlobally}% + \let\@dc@global@\global}% + {}% + % + \@xa\Name \@xa\edefU + \@xa\@dc@specsname + \@xa{\@xa{\@dc@Specs@tempa}}% + \@dc@ResetParseAuxilia + % + \@dc@ParseNextSpecifier #3% + \@dc@buckstopshere % it's the sentinel of parsing. Since the test + % + \@xa \Name \@xa \addtomacro \@xa \@dc@specsname + \@xa {\@xa{\the\@dc@ParsedSpecs}}% + % + \@xa\Name\@xa\addtomacro\@xa\@dc@specsname + \@xa{\@xa{\the \c@dc@argnum}}% + % + \@dc@outer@\@dc@global@ % possibly the prefixes, +%%%%% +%%%%%% Here comes the definition of the coating macro, named the +%%%%%% same as the command: + \protected\edef#1{% always |\protected| \balsmiley( ;-) + \@dc@bsphack@ % perhaps |\@bsphack| + % + \@dc@messages + % + \@nx\@dc@{\the\toks@}% in the braces appear the argument catchers. + \@xanxcs{\dc@innername}% + \ifx\@dc@outer@\outer + \@xanxcs{\@xa\gobble\string#1 }% note the blank + \else \@nx #1% + \fi + }% of main coating macro's |\edef|. \UnDef + % + \edef\gmu@DeclareCommand@resa{% + \@dc@global@ % perhaps |\global| + \long\def\@xanxcs{\@dc@InnerName{#1}}% for a~command + \@xau\@dc@innerhashes % it's |#1#2#3…| + {% the body of the inner ‘|\\⁄\|’ macro: + \@dc@setThrowArgs + \unexpanded{#4}% + \@dc@esphack@}% + }% of |\edef|. + \gmu@DeclareCommand@resa +}% of |\DeclareCommand|'s body. +} + +\def\@dc@DCprefixQlist{\global\protected\outer\long + \relax % for the somewhat perverse case when |\@dc@global| may be + !lL.qQiIwW\sphack\envhack} + +\long\def\ShowCommand #1{% + \@iwruJ + \@iwru{»\string#1« is »\meaning#1«}% + \@iwruJ + \@iwru{»\Name\string{\@dc@InnerName{#1}}« is + »\Name\meaning{\@dc@InnerName{#1}}«}% + \@iwruJ + \@iwru{»\Name\string{\@dc@SpecsArName{#1}}« is + »\Name\meaning{\@dc@SpecsArName{#1}}«}% + \@iwruJ + \show\show +} + +\@XA{\DeclareCommand\DeclareCommand % This is the final version by now.\ +{ + #1 >Pm % command to be defined (may be even \incs{par} if you + #2 >\@xa Q{\@dc@DCprefixQlist}{} %\ + #3 >Pm % arguments specification (may contain \incmd\par), + #4 >Pm % the definition body; may contain nearly anything including +}}\@dc@DCbody + + +\@XA{\DeclareCommand \DeclareCommand \long + {m >\@xa Q{\@dc@DCprefixQlist}{} mm}}% +\@dc@DCbody + + +\long\def\dc@EAName#1{% Env.\ arguments' toks' name + \if\bslash#1\else#1\fi's_args} + +\pdef\dc@ThrowArgs#1{% + \gmu@if{csname}{\dc@EAName{#1}\endcsname} + {}% if it's defined, we do nothing (we assume it's defined by us and + % is toks register.) + {% else we define it as a new toks + % \label{'s args} + \@xa\newtoks\csname\dc@EAName{#1}\endcsname + }% + \csname\dc@EAName{#1}\endcsname=% + \@xa\@xa\@xa{\@xa\@gobble\the\@dc@arguments}% +}% + + +\def\@dc@K@defaultrepl{##1} + +\DeclareCommand\@dc@define@K \long {mb}{% \label{K@parse} + % First we add the particular \CS to the toks register:\nostanza + \edef\gmu@tempa{% + \unexpanded{\toks@\@xa}% + {\@nx\the\toks@{% + \@xanxcs{\dc@innername @K\the\c@dc@catchernum}% + }% + }% + % here we add to the parsers toks list a \CS\ named + % |\⁄@K⁄| (the particular Knuthian catcher) + }\gmu@tempa + % and define this macro: \nostanza + \edef\gmu@tempa{% + % And now we define that particular Knuthian catcher. + \def\@xanxcs{\dc@innername @K\the\c@dc@catchernum}% + \gmu@if {@dc@xadefault@i@}{}% + {\@xau{#1}}% + {\unexpanded{#1}}% + {% + \@nx\@dc@addargum{{% + \gmuIfValueTF{#2}{% + \gmu@if{@dc@xadefault@ii@}{}% + {\@xau{#2}}% + {\unexpanded{#2}}% + }{\@xau{\@dc@K@defaultrepl}}% + }}% we add the Knuthian + % replacement to the toks register as \inhash n. + \@nx \@dc@parse@next \@dc@arguments + }% and continue parsing. + }% of |\edef|. Now we execute this temporary macro, which means we \incmd\def|\⁄@K⁄| + \@dc@global@ % set properly before |\@dc@ParseNextSpecifier #3⁄|. + \if P\@dc@long@letter\relax\long\fi + \gmu@tempa + % + \@dc@addtospecs {#1}% + % + \gmuIfValueTF{#2}{% + \gmu@if{@dc@xadefault@ii@}{}% + {\@xa\@dc@addtospecs\@xa{#2}}% + {\@dc@addtospecs{#2}}% + } + {\@xa\@dc@addtospecs\@xa{\@dc@K@defaultrepl}}% + % + % Now we clean up and continue construction of arguments parser. \nostanza + \@dc@ParseNextSpecifier +}% of |\@dc@define@K| + +\DeclareCommand\@dc@grab@Loop \long {% + #1 T{\any \none Uu\U \u Ǔǔ\Ǔ \ǔ Ww\W \w \lostwax} % the “sign” of matching for adding; use of + % the letters suppresses adding them to the + % parsed specifiers' list, which is crucial for + % |\SameAs| copying of specifiers: the “until” and “while” loops + % don't shift their arguments. + % + #2 >Pm % list of tokens to match for/against iteration + % + >i T{\drain \drop \Drain \Drop \lost \Lost} + #3 T{\any \none }{\any} % the “sign” of matching for draining + % + #4 b{} % list of drainers, empty by default + % + >i T{\count \ubound} + #5 D{\m@ne} % upper bound of iterations + % + >i T{\default \Default} + #6 b % default value (|\NoValue| by default) + % + #7 T{\eacher \Eacher \defEacher} % default is |\NoValue| and that's no + % harm since we test if |#7| == |\defEacher|. + #8 B{} % eacher, empty by default +}{% + % + \@dc@process@matchsign {#1} {##1}% + % + \dc@addtoParsed@{#2}% + % + \gmu@if {strings}{\lostwax#1}% + {\gmu@if {@dc@xadefault}{}% + {\@xa\edefU\@xa\@dc@LostWaxList\@xa{#2}}% + {\edefU\@dc@LostWaxList{#2}}% + }% + {}% + % + \@dc@process@matchsign {#3} {##3}% + % + \dc@addtoParsed@{#4}% + % + \@xa \@dc@addtospecs@bare \@xa{\the\numexpr #5}% + \@dc@addtotoks@bare{{#5}}% to ignore possible expandafter. + % + \dc@addtoParsed@ {#6}% + % + \gmu@if {strings}{\defEacher#7} + {% + \Name\def{\dc@innername/defdEacher/\the\c@dc@argnum}% + ##1{#8}% + % + \Name \dc@addtoParsed@ + {\dc@innername/defdEacher/\the\c@dc@argnum}% + } + {\gmu@if {@dc@xaeacher@}{} + {\@dc@xadefaulttrue}{\@dc@xadefaultfalse}% + \dc@addtoParsed@ {#8}% + }% + % + \gmu@if {strings}{\lostwax#1} + {\grab@LostWax} + {\@dc@ParseNextSpecifier}% +} + +\DeclareCommand\grab@LostWax { + >iT{\lost \Lost} + #1 b{\lostwax@NoVal} + >iT {\count \ubound} + #2 D{1} + >iT{\endlost \EndLost} +}{% + % We build an ignored “while” catcher. + % + \def\@dc@LostWaxA{>iw}% + % + \gmu@ifdetokens {\lostwax@NoVal}{#1} + {% + % if no particular value of the “lost wax” is provided, we assume + % the same as the “until” delimiter(s). + % + \prependtomacro\@dc@LostWaxA{>\@xa}% + \addtomacro\@dc@LostWaxA{\@dc@LostWaxList}% + }% + % + % Otherwise first we check whether “lost wax” provided has nonempty + % intersection with the “until” delimiters. + {% + \@xa\gmu@ifstrintersect + \@xa{\@dc@LostWaxList}{#1} + {\addtomacro\@dc@LostWaxA{{#1}}}% + {\PackageError{gmutils/gmcommand}{^^J% + You try to declare a "Lost Wax" catcher^^J% + with the "Lost" list disjoint with the "Until" list.^^J% + I assume sum of them}% + {}% + % + \@xa \addtomacro\@xa\@dc@LostWaxA + \@xa{\@xa{\@dc@LostWaxList #1}}% + }% + }% + % + \addtomacro\@dc@LostWaxA{ \count #2 \relax}% + % + \@xa\@dc@ParseNextSpecifier \@dc@LostWaxA +}% of |\grab@LostWax|. + +\def\@dc@process@matchsign +#1% the argument +#2% its numeral in human language (for the error message) +{% + \gmu@CASE {strings} {{#1}\any } + {\@dc@addtoParsed@bare {\any }}% + % + \gmu@CASEsbany {#1} {Ww} + {\@dc@addtotoks@bare {\any}}% + % + \gmu@CASE {strings} {{#1}\none} + {\@dc@addtoParsed@bare {\none }}% + % + \gmu@CASEsbany {#1} {UuǓǔ\lostwax } + {\@dc@addtotoks@bare {\none }}% + % + \gmu@lastCASE + {\PackageError{gmcommand}{% + You *have* to declare »\string\any« or »\string\none« ^^J% + as the #2 argument for the »\string\loop« catcher}{}% + }% + \gmu@ESAC +} + +\long\pdef\UnDeclareCommand#1{% + \let#1\@undefined + \ifcsname\@dc@InnerName{#1}\endcsname + \n@melet{\@dc@InnerName{#1}}{@undefined}% + \fi + \ifcsname\@dc@SpecsArName{#1}\endcsname + \n@melet{\@dc@SpecsArName{#1}}{@undefined}% + \fi +} + + +\edef\gmu@tempa{% + \def\@nx\gmu@ifHashless@##1% + \detokenize{macro:}##2->##3\@nx\@nil}% +\gmu@tempa +{\gmu@if {}{\gmu@ifempty{#2}{1}{0}\gmu@ifempty{#3}{2}{1}}} + +\long\edef\gmu@ifHashlessMacro +#1% a \CS, name or active char +{% + \edef\@nx\gmu@WHL@arg{\@nx\@xanxtri{#1}}% + \unexpanded{\@xa\@xa\@xa\gmu@ifHashless@ + \@xa\meaning\gmu@WHL@arg}% + \relax % to ensure that |#3| of |\gmu@ifHashless@| is nonempty + % if match for the delimiters is found earlier + \detokenize{macro:***->}\@nx\@nil % the sentinels +} + +\long\def\gmu@ifDeclared#1{% + % \begin{enumargs} + % \item a \CS or csname or an active char, + % \item true branch, + % \item false branch % + % \end{enumargs} + \let\gmu@ifDe@next\@secondoftwo + % + % + \gmu@CASEnot {csname} {\@dc@SpecsArName{#1}\endcsname}% + {}% + % + \gmu@CASEnot {csname}{\@dc@InnerName{#1}\endcsname}% + {}% + % + \gmu@EatCases + {\gmu@ifHashlessMacro{#1}% + {\edef\gmu@ifDe@resa{% + \@nx\gmu@ifxany\@xanxcs{\@dc@InnerName{#1}}% + {\unexpanded\@xa\@xa\@xa{\gmu@WHL@arg}}% + % Above: to get the contents of the outer macro we use the macro + % carrying conversion of possible name into a \CS and expand + % it twice. Then we freeze it with |\unexpanded|. + {\let\@nx\gmu@ifDe@next\@nx\@firstoftwo}% if the inner macro + % is present in the + % contents of |#1|, we take the first implicit argument + {}% otherwise we do nothing (taking the second implicit is + % already set) + }% of edef + \gmu@ifDe@resa + }% of if a hashless macro + {}% of if not a hasless macro + }% + % + \gmu@ESAC + \gmu@ifDe@next +}% of |\gmu@ifDeclared| + +\long\def\@dc@SameAs#1{% + \gmu@ifDeclared {#1}% + {% + \@xa\@xa\@xa \@xa\@xa\@xa \@xa + \@dc@ParseNextSpecifier + \@xa\@xa\@xa \@secondofthree + \csname \@dc@SpecsArName{#1}\endcsname + }% + {% + \PackageError{gmcommand}{% + Command \@nx#1 ^^J% + is not declared with \DeclareCommand. ^^J% + I can't repeat its parameters in current command declaration}% + {}% + }% +}% of |\@dc@SameAs| + +\DeclareCommand\DCUse{ + #1 >Pm % the command +}{% ^^A with star we automatically pass the + \gmu@ifDeclared{#1}% + {% + \@dc@arguments\@xa{\@xa + \csname \@dc@InnerName{#1}\endcsname + }% + % + \csname ArgumentCatcher@Pm@\romannumeral + \@xa \@xa \@xa \@thirdofthree + \csname \@dc@SpecsArName{#1}\endcsname % of arity carrier + \endcsname % of the catcher + }% + {\DC@EndNotDeclaredErr{#1}}% +}% + +\pdef \DC@EndNotDeclaredErr #1{% + \PackageError{gmcommand}{% + Command \bslash end\strip@bslash{#1} ^^J% + is not declared with \DeclareCommand. ^^J% + Therefore I can't use its DC-inner macro (because of its nonexistence).^^J}% + {}% +} + +\DeclareCommand\DCUseEnd{ + #1 >Pm % the command (without “end”) +}{% + \gmu@ifDeclared{end\strip@bslash{#1}}% + {% + \@dc@arguments\@xa{\@xa + \csname \@dc@InnerEndName{#1}\endcsname + }% + % + \csname ArgumentCatcher@Pm@\romannumeral + \@xa \@xa \@xa \@thirdofthree + \csname \@dc@SpecsArName{#1}\endcsname % of arity carrier + \endcsname % of the catcher + }% + {\DC@EndNotDeclaredErr{#1}}% +}% + + +\DeclareCommand\DeclareEnvironment \long +{ + #1--#4 \SameAs \DeclareCommand + % We repeat the specifiers, but the role of |#4| is slightly + % different here: here it's the |\begin| part definition. + % + #5 m % the end definition; it \emph{can} contain any + % \inverb|#|\---the arguments of the environment are passed + % to it, too. +}{% + \def\gmu@DeclareEnvironment@resa{\envhack}% we add the information we define an + % environment. + \gmuIfValueT{#2}% + {\addtomacro\gmu@DeclareEnvironment@resa{#2}}% we pass all the ‘prefixes’ to + % \incs{Decl\+are\+Comm\+and} + % \stanza + \@xa\DeclareCommand\csname#1\@xa\endcsname + \gmu@DeclareEnvironment@resa{#3}{#4}% + % + %\nostanza Now the begin definition is done. Let's get down to the + %end definition. \nostanza + % + \let\@dc@env@endglobal=\@dc@global@ % note this \CS was for sure redefined by the last + % \incs{Decl\+are\+Com\+m\+and} (and by nothing else) and that's + % exactly what we want. + \edef\gmu@DeclareEnvironment@resb{% + \@nx\@xa + \@xanxcs{\bslash end#1}% + \@nx\the + \@xanxcs{\dc@EAName{#1}}% + }% of |\edef|. It reuslts in + % \[|\@xa \\end⁄ \the\\⁄'s_args|\] + % which does not collide with the inner macro of the |\end›…| + % command, since the latter is |\\end›…\|. +\gmu@if{csname}{\dc@EAName{#1}\endcsname}{\gmu@namelet\global{\dc@EAName{#1}}{@undefined}}{}% + \edef\gmu@DeclareEnvironment@resa{% \UnDef + \@dc@global@\long\def % the inner end macro is always \incmd\long\ + % and perhaps defined \incmd\global ly. + \@xanxcs{\bslash end#1}% + \@xau\@dc@innerhashes % it's |#1#2#3›…|---the inner end macro takes the + % same number of parameters as the begin macro. + {% the definition body + \unexpanded{#5}}% + }% of |\edef›…@resa|. + \gmu@DeclareEnvironment@resa + \edef\gmu@DeclareEnvironment@resc{% + \DeclareCommand\@xanxcs{end#1}% + \@dc@env@endglobal + {}% no parameters + {\@xau {\gmu@DeclareEnvironment@resb + \@ignoretrue}% + }% + }% + \gmu@DeclareEnvironment@resc + % + % +}% of |\DeclareEnvironment| + +\DeclareCommand\NewCommand +{\SameAs\DeclareCommand} +{% + \gmu@ifCSdefined {#1} + {\DCUse\DeclareCommand#1{#2}{#3}{#4}}% + {\PackageError{gmcommand}% + {Command \@nx#1 already defined \on@line!}% + {}% + }% +} + +\DeclareCommand\RenewCommand +{\SameAs\DeclareCommand} +{% + \gmu@ifCSdefined {#1} + {\DCUse\DeclareCommand#1{#2}{#3}{#4}}% + {\PackageError{gmcommand}% + {Command \@nx#1 not yet defined \on@line!}% + {}% + }% +} + +\DeclareCommand\ProvideCommand +{\SameAs\DeclareCommand} +{% + \gmu@ifCSdefined {#1} + {} + {\DCUse\DeclareCommand#1{#2}{#3}{#4}}% +} + +\DeclareCommand\NewEnvironment +{\SameAs\DeclareEnvironment} +{% + \gmu@ifdefined{#1} + {\DCUse\DeclareEnvironment{#1}{#2}{#3}{#4}{#5}}% + {\PackageError{gmcommand} + {Environment #1 already defined \on@line!}{}% + }% +} + +\DeclareCommand\RenewEnvironment +{\SameAs\DeclareEnvironment} +{% + \gmu@ifdefined {#1} + {\DCUse\DeclareEnvironment{#1}{#2}{#3}{#4}{#5}}% + {\PackageError{gmcommand} + {Environment #1 not yet defined \on@line!}{}% + }% +} + + +\DeclareCommand\XeTeXthree{o}{% \ + % \changes{v0.90}{2008/8/4}{adjusted + % to the redefinition of + % \cs{verb} in \pk{xlxtra} 2008/07/29} + \@ifXeTeX{% + \gmuIfValueT{#1}{\PassOptionsToPackage{#1}{fontspec}}% + \@ifpackageloaded{gmverb}% + {% + \Store@Macro\verb + \StoreEnvironment{verbatim}% + \StoreEnvironment{verbatim*}% + }{}% + \RequirePackage{xltxtra}% since v 0.4 (2008/07/29) this package + % redefines |\verb| and \env{verbatim*}, + % and quite elegantly provides an option + % to suppress the redefinitions, but + % unfortunately that option excludes also + % a~nice definition of |\xxt@visiblespace| + % which I~fancy. + \@ifpackageloaded{gmverb}% + {% + \Restore@Macro\verb + \RestoreEnvironment{verbatim}% + \RestoreEnvironment{verbatim*}% + }{}% + % + \AtBeginDocument{% + \@ifpackageloaded{gmlogos}{% + \Restore@Macro\LaTeX\Restore@MacroSt{LaTeX }% my version of the + % \LaTeX\ logo has been stored just + % after defining, in line \ref{SMLaTeX}. \ilrr + \Restore@Macro\eTeX}% + {}% + }% + % \stanza + \pdef\adddefaultfontfeatures##1{% + \addtomacro\zf@default@options{#1,}} + }% of |\@ifXeTeX|'s first argument, + {}% |\@ifXeTeX|'s second argument, +}% of |\XeTeXthree|'s body. + +\DeclareCommand\setspaceskip{% + A{1}% optional factor for all three components + O{\fontdimen2\font}% + >is + O{\fontdimen3\font}% + >is + O{\fontdimen4\font}} +{\spaceskip=\glueexpr\dimexpr#2*#1\relax plus\dimexpr #3*#1\relax + minus\dimexpr#4*#1\relax\relax} + +\pdef\unsetspaceskip{% + \spaceskip=\z@skip +} + +\def\makestarlow{% + \begingroup\lccode`\~=`\*\lowercase{%% \Define** + \endgroup\def~{\gmu@lowstar}}% 2009/10/19 |\let| changed to + % \inverb|\def| to allow redefinitions of \incmd\gmu@lowstar. + \catcode`\*=\active + \defLowStarFake +} + +\DeclareCommand\defLowStarFake{% + Q{+-0123456789,.}{0,5}% fraction of fontchar depth of the star glyph +}% +{% + \def\gmu@lowstarfake{% + \leavevmode\vbox{\hbox{*}\kern#1\fontchardp\font`*}% + }% +} + +\def\gmu@lowstarfake{*} % useful for next command where normal star is + +\DeclareCommand\enoughpage{% + #1 D{\NoValue} % (optional short version (number of + % |\baselineskip|s)) Before 2010/9/10 the default + % value was the |D|-default, i.e., 0, which lead to + % improper working of this command. + #2 B{2\baselineskip}% (2) optional (formerly mandatory) long version of + % required room on a page + >is + #3 >PB{} % (3) what if the room is enough + >is + #4 >PB{\newpage} % (4) what if there's to little room on a page +}{% + % \chgs{2009/03/18 v0.98 made \eTeX-ish} + % \chgs{2009/05/25 v0.98 made ifthenelse-like with ‘then’ and ‘else’ + % optional default \ and \cmd\newpage resp.} + % \chgs{2009/10/21 v0.98 \cmd\par\ removed since to let it be used + % for \cmd\pagebreak\ inside a paragraph} + \gmu@if {num} + {\numexpr + \ifdim + % if the space left is less than we wish then 1, otherwise 0. + \gmu@pageremain + <% + \dimexpr + (\gmuIfValueTF{#1}{#1\baselineskip}{#2})*1% + \endexpr + % + % \CH{2010/06/28 v0.993 I added |(›…)*1| to assure that |\relax| + % really delimits the dimexpr} + % + 1\else 0% + \fi + *% + \ifdim \gmu@pageremain >-1sp + 1% if the room left on current page is nonnegative, + % then we indeed are on current page so “enough” and + % “not enough” does make sense: Enough is enough. + \else 0% otherwise we are on next page (or further) and assume + % there is enough room for our purpose. + \fi + *% + \ifdim \pagegoal <\maxdimen + 1 % if there are some boxes on current page, so checking room + % does make sense. + \else 0% otherwise (no boxes on current page) assume there's + % enough room + \fi + >\z@ + }% of condition + {\typeout{@@@@@ not enough page \on@line}% + #4% + }% + {#3}% +} + +\long\def\gmu@LC@LetInners +#1% scope prefix (|\global| or |\relax| +#2% left side +#3% right side of the assignment +{% + \edef\gmu@LC@InnerLeft{\@dc@InnerName{#2}}% + \edef\gmu@LC@InnerRight{\@dc@InnerName{#3}}% + % + \gmu@namelet{#1}{\gmu@LC@InnerLeft}{\gmu@LC@InnerRight}% + \edef\gmu@LC@InnerLeft{\@dc@SpecsArName{#2}}% + \edef\gmu@LC@InnerRight{\@dc@SpecsArName{#3}}% + % + \gmu@namelet{#1}{\gmu@LC@InnerLeft}{\gmu@LC@InnerRight}% +} + +\long\def\gmu@CL@PrepareArg +#1% left/right +#2% |\@xa| or |\edef|, maybe sth.\ more in the future +#3% a \CS, text of a name or an active char +{% + \Name\let{gmu@CL@#1}\@undefined + \ifx\@xa#2\Name\edef{gmu@CL@#1}{\@xau{#3}}\fi + \ifx\edef#2\Name\edef{gmu@CL@#1}{#3}\fi + \unless\ifcsname gmu@CL@#1\endcsname + \Name\edef{gmu@CL@#1}{% + \gmu@if{cat}{\@nx~\@nx#3}% + {\@nx#3}{\strip@bslash{#3}}% + }% + \fi +} + +\DeclareCommand\CommandLet \long {% + \Scope % (1) + T{\@xa\edef} % (2) whether left side should be |\expandaftered| + m % (3) left side of assignment + >iT{=} % pro forma + T{\@xa\edef} % (4) whether right side should be |\expandaftered| + m % (5) right side of the asssignment +}{% + % + \gmu@CL@PrepareArg{left}#2{#3}% + \gmu@CL@PrepareArg{right}#4{#5}% + % + \@xa\gmu@ifDeclared\@xa{\gmu@CL@right}{% + \edef\gmu@LC@resa{% + \DeclareCommand % + \@xa\@xanxtri\@xa{\gmu@CL@left}% + #1% scope prefix + {\@nx\SameAs\@xa\@xanxtri\@xa{\gmu@CL@right}}% args. spec + {}% the body of the command will be |\let| via letting inners. + }% + % + \gmu@LC@resa + \@XA{\@xa\gmu@LC@LetInners\@xa#1% + \@xa{\gmu@CL@left}}\@xa{\gmu@CL@right}% + }% of if Declared + {% if not Declared, we just |\let|: +\if\@nx#3ѥ\typeout{@@@@@ »\@xa\@dc@InnerName\@xa{\gmu@CL@right}« is not + Declared?: \Name\meaning{\@xa\@dc@InnerName\@xa{\gmu@CL@right}}% +}% +\show\NotDeclared +\fi + \@XA{\@xa\tri@let\@xa#1% + \@xa{\gmu@CL@left}}\@xa{\gmu@CL@right}% + }% +} + +\DeclareCommand\envirlet \long{\Scope mm}{% for |\let|ting environments. + \CommandLet #1{#2}{#3}% + \CommandLet #1{end#2}{end#3}% +} + +\DeclareCommand\@fornum{% + m% (1) initial (least) num. value + m% (2) limit (last iterated over) num. value + O{1}% (3) step of iteration + m% (4) body of the loop +}% +{\edef\gmu@fornum@min{\the\numexpr #1}% + \edef\gmu@fornum@lim{\the\numexpr #2}% + \let\gmu@fornum@curr\gmu@fornum@min + \@whilenum\gmu@fornum@curr<\gmu@fornum@lim + \do{#4% + \edef\gmu@fornum@curr{% + \the\numexpr\gmu@fornum@curr+#3}% + }% of |\@whilenum|'s body. +}% of |\@fornum|. + +\pdef\StoreCommand{% + \begingroup + %\label{SC begr} + \MakePrivateLetters + \@StoreCommand +} + +\long\def\gmu@SC@StorageName +#1% a \CS, name or active char +#2% group level +{% + \gmu@storeprefix/% + \ifnum\numexpr#2>-1 \the\numexpr(#2)*1\relax\fi + \bslash@or@ac {#1}% +}% + +\def\gmu@SC@setgrouplevel +#1% |+›⁄|-⁄|\NoValue| +#2% a decimal number +{\edef\gmu@SC@grouplevel{% + \the\numexpr + \gmuIfValueTF{#1}% + {\currentgrouplevel#1#2+1}{#2}% + }% of the grouplevel-carrying macro +} + +\DeclareCommand\@StoreCommand +{% + #1 T{+-}% grouplevel shift indicator + #2 d % group level or shift (the latter relative to the current g.l.) + #3 >Pm% name or \CS +}{% + \endgroup %we close the group opened in line \ref{SC begr}. + \gmu@SC@setgrouplevel{#1}{#2}% + % + \edef\gmu@SC@resa{% + \gmu@SC@StorageName{#3}{\gmu@SC@grouplevel}}% + % + \let\gmu@SC@scope\relax + \ifnum\gmu@SC@grouplevel>\currentgrouplevel + \let\gmu@SC@scope\global + \fi + \@xa\CommandLet\@xa\gmu@SC@scope\@xa{\gmu@SC@resa}{#3}% +} + +\pdef\StoreEnvironment{% + \begingroup + \MakePrivateLetters + \@StoreEnvironment +} + +\def\@StoreEnvironment#1{% + \@StoreCommand{#1}% + \begingroup + \@StoreCommand{end#1}% +} + +\pdef\RestoreEnvironment{% + \begingroup + \MakePrivateLetters + \@RestoreEnvironment +} + +\def\@RestoreEnvironment#1{% + \endgroup + \RestoreCommand{#1}% + \RestoreCommand{end#1}% +} + +\pdef\UseStored{% + \begingroup + \MakePrivateLetters + \@UseStored} + + +\DeclareCommand\@UseStored \long{% + #1 T{+-}% (1) indicator of grouplevel shift (in distiction from an absolute + % group level) + #2 d % (2) optional grouplevel or shift (0 by default) + #3 O{\@gobble}% (3) stuff to be put before the |#4| \CS, e.g., an + #4 m % (4) a \CS or csname to be taken from the storage liquid +}{% \chgs{2010/06/23 v0.993 added} + \endgroup + \gmu@SC@setgrouplevel{#1}{#2}% + \edef\gmu@SC@grouplevel{% + \the\numexpr\gmu@SC@grouplevel+1}% for the first turn of loop + % + \loop + \edef\gmu@SC@grouplevel{% + % we decrease the group level number + \the\numexpr\gmu@SC@grouplevel-1}% + % + \edef\gmu@SC@currname{% + % define the cs' storage name for that level + \gmu@SC@StorageName{#4}{\gmu@SC@grouplevel}}% + \ifnum + % and check the conjunction of conditions: the group level is >=-1… + \unless\ifnum\gmu@SC@grouplevel<-1 1\else 0\fi + % and the csname remains not defined. + \unless\ifcsname \gmu@SC@currname \endcsname 1\else 0\fi + =11 + \repeat + \gmu@if{csname}{\gmu@SC@currname\endcsname}% + {% + % ^^A \s how\ExecutingTrueBranch + \@XA{#3{#4}}\csname \gmu@SC@currname\endcsname}% first + {% + % ^^A \s how\ExecutingFalseBranch + #3{#4}\@undefined}% second +}% of |\@UseStored| + +\DeclareCommand\RestoreCommand{\Scope d}{% + \UseStored #2[\CommandLet #1*]% +} + + +\newbox\gmu@smashbox + +\DeclareCommand\set@smashbox{% + \Scope + T{hv}{h} +}{#1\setbox\gmu@smashbox =\csname #2box\endcsname }% + +\def\smash@box{\smash{\box\gmu@smashbox}} + + +\newbox\gmu@boxA +\newbox\gmu@boxB +\newdimen\gmu@dima +\newdimen\gmu@dimb + +\DeclareCommand\gmu@extremebox { + #1 m % a dimen register (will be assigned the extr.\ value) or a + % \CS (will be defined as |\the| extreme value) + #2 T {\min\max}{\max} % kind of extreme + #3 T {\wd\ht\dp\totalheight}{\wd} % dimension to compare, the last two for total |\ht|+|\dp|. + #4 \lostwax {\global\relax} \eacher{\gmu@dimextreme@step} \lost{\relax} + #5 T{\global}{} % scope of assignment +}{% + \gmu@if x {\max#2} + {\gmu@dimb=-\maxdimen + \def\gmu@dimextreme@comp{<}% + } + {\gmu@dimb=\maxdimen + \def\gmu@dimextreme@comp{>}% + }% + % + \long \def\gmu@dimextreme@step ##1{% + \setbox\gmu@boxA=\hbox{##1}% + % + \gmu@dima= \gmu@if x {\totalheight#3} + {\dimexpr \ht\gmu@boxA +\dp\gmu@boxA\relax} + {#3\gmu@boxA}% + \relax + % + \gmu@if {dim} + {\gmu@dimb\gmu@dimextreme@comp \gmu@dima } + {\gmu@if {dim} {\gmu@dima>\z@} + {\gmu@dimb=\gmu@dima } + {}% + } + {}% + % + }% + % + #4% + \IfIs #1\dimen + {#5#1=\gmu@dimb} + {#5\edef #1{\the\gmu@dimb }}% +}% + +\pdef\gmu@getht +#1% box register +#2% dimen (or glue) register to assign the (substitute) height to +{% + \setbox\gmu@boxA=\copy#1\relax + \ifvbox\gmu@boxA + \vbadness@M + \setbox\gmu@boxB=\vsplit\gmu@boxA to \maxdimen + \vbadness@Restore + % + % chcemy rzeczywiście pomierzyć, a nie być może odrzucić odstępy, + % kerny i grzywny. + \setbox\gmu@boxB=\vbox{\splitdiscards }% + \ifdim \ht\gmu@boxB >\z@ + \setbox \gmu@boxA=\vbox{ + \unvbox\gmu@boxB + \unvbox\gmu@boxA + }% + \fi + \else + \setbox\gmu@boxA=\box\voidb@x + \fi + % + \ifvoid\gmu@boxA + #2=\ht#1\relax + \else + #2=\maxdimen + \fi +}% of |\gmu@getht| + + + +\DeclareCommand\enlargefsize{ + #1 m % enlargement (dim(expr)) for font size + #2 b % enlargement (dim(expr)) for baselineskip (if absent, |#1| is used) +}{\edef\gmu@tempa{% + \@nx\fontsize{\the\dimexpr\f@size pt+#1}% + {\the\dimexpr 1\baselineskip+ \gmuIfValueTF{#2}{#2}{#1}}% + }\gmu@tempa\selectfont +} + +\DeclareCommand\scalefsize { + #1 m % scale for font size + #2 b % scale for baselineskip (if absent, |#1| is used) + \gobblespace +}{\edef\gmu@tempa{% + \@nx\fontsize{\the\dimexpr #1\dimexpr\f@size pt\relax}% + {\the\dimexpr \gmuIfValueTF{#2}{#2}{#1}\baselineskip}% + }\gmu@tempa\selectfont +} + +\let\gmu@discretionaryhyphen\- % for the cases when we don't redefine + % \incs\- but use \incs\UrlFix + +\DeclareCommand\bihyphen{ + O{*} % token that'll make the discretionary hyphen |\-| allow other break-points +}{% + \DeclareCommand\gmu@discretionaryhyphen{% + T{#1}% + G{&&}% + a + }{% + \gmuIfValueT{##2}{% + \gmu@ifempty{##2}{}{% + \def\gmu@bihyphen@char{##2}}% + }% + \gmuIfValueT{##3}{% + \gmu@ifempty{##3}{}{% + \def\gmu@bihyphen@corr{##3}}% + }% + % + % Depending on |#1| we allow (if present, then we take |\discre|) + % hyphenation of the word's before- and + % after-parts or forbid it (if absent, then we take + % |\discretionary|). + \gmuIfValueTF{##1}\discre\discretionary + {% before break + \gmuIfValueTF{##2} + {% + \gmu@ifempty{##2}{\gmu@bihyphen@char}{##2}% + }% + {% + \ifnum\hyphenchar\font>\z@ + \char\hyphenchar\font + \fi}% + }% end of before break + {%after break + \gmuIfValueT{##3}{% + \gmu@ifempty{##3}{\gmu@bihyphen@corr}{##3}% + }% + }% + {% without break + }% almost as in \TB: unlike \TB, we allow hyphenchars + % $\ge255$ as we are \XeTeX. + }% of |\DeclareCommand\-| + \gmu@storeifnotyet\-% original |\-| is a~\TeX's + % primitive, therefore we should store it. + \CommandLet\-\gmu@discretionaryhyphen + \CommandLet\@dischyph\gmu@discretionaryhyphen % to override + % \pk{framed.sty} + \pdef\gmu@flexhyphen{\gmu@discretionaryhyphen#1\relax}% +}% of |\bihyphen| + +\relaxen\gmu@bihyphen@corr + +\@ifXeTeX{% + \DeclareCommand\gmshowlists { + >iT{\depth} + Ď{1}% + >iT{\breadth} + Ď{10000000} + }% +}{% not in \XeTeX\ we use legacy |D| arg.\ specifiers: + \DeclareCommand\gmshowlists { + >iT{\depth} + D{1}% + >iT{\breadth} + D{10000000} + }% +} +{\tracingonline=\@ne + \showboxdepth=#1\relax % how many levels of + % box nesting should be shown + \showboxbreadth=#2\relax % after how many elements »etc.« will be put + \showlists +} + +\DeclareCommand\gmtracingoutput { + \SameAs\gmshowlists +} +{\tracingonline=\@ne + \tracingoutput=\@ne + \showboxdepth=#1\relax % how many levels of + % box nesting should be shown + \showboxbreadth=#2\relax % after how many elements »etc.« will be put +} + + +\newcount\c@FiBreakPenalty + +\DeclareCommand \AllowFiBreak {% + % The defaults are as in DEK's |\filbreak|. + Q{l}{l} + = {\c@FiBreakPenalty } +} +{% + \penalty\@M + \csname vfi#1\endcsname + \penalty \c@FiBreakPenalty + \csname vfi#1neg\endcsname +} + + +\DeclareCommand \IgnorePars {m Q{\par}} {#1} + +\DeclareCommand\putpenalty {=} +{% + \gmu@iflastglue + {\@tempskipa=\lastskip + \mode@skip -\@tempskipa + \penalty \@tempcnta + \mode@skip \@tempskipa + }% + {\gmu@iflastkern + {\@temdima=\lastkern + \kern-\@temdima + \penalty \@tempcnta + \kern \@temdima + } + {% + \penalty\@tempcnta + }% + }% +} + +\newskip \gmu@TrashSkip + +\pdef \mode@skip {% + \ifvmode \vskip + \else + \ifhmode \hskip + \else + \ifmmode \mskip + \else + \gmu@TrashSkip + \fi + \fi + \fi +} + + +\endinput +%% +%% End of file `gmcommand.sty'. diff --git a/macros/latex/contrib/gmutils/gmenvir.sty b/macros/latex/contrib/gmutils/gmenvir.sty new file mode 100644 index 0000000000..347198ceac --- /dev/null +++ b/macros/latex/contrib/gmutils/gmenvir.sty @@ -0,0 +1,143 @@ +%% +%% \iffalse ^^A we skip the debug setting +\IfFileExists{\string~/bin/gen_and_xela}{\errorcontextlines=1000 }{} +%% \fi +%% ^^A $Id: TheUltimateMaster.gmd,v 0.352 2011/10/12 15:19:42 natror Exp natror $ +%% This is file “gmenvir.sty” generated with the DocStrip utility. +%% +%% +%% The original source files were: +%% +%% gmutils/gmutils.gmd (with options: `envir') +%% +%% +%% Copyright © +%% by Grzegorz ‘Natror’ Murzynowski +%% natror (at) gmail (dot) com +%% +%% This program is subject to the LaTeX Project Public License. +%% See http://www.ctan.org/tex-archive/help/Catalogue/licenses.lppl.html +%% for the details of that license. +%% +%% LPPL status: "author-maintained". +%% +%% +%% +%% For documentation please refer to the file(s) +%% gmutils.{gmd,pdf}. +%% +%% +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{gmenvir} + [2011/10/12 v0.996 redefinition of \string \begin \space and \string \end (GM)] + + +%% +%% +%% ^^A\typeout{\unexpanded{#4}}%% + +\RequirePackage{gmbase, gmampulex} % the low-level macros + + + +\emptify\@envirstack + +\def\@pushenvir{% + %^^V\edef\@currenvir{\@currenvir}% is already expanded. + \xdef\@envirstack{% + {\@xa\detokenize\@xa{\@currenvir}}% + {\the\currentgrouplevel}% + {\@currenvline}% + \@envirstack + }% +} + +\def\@popenvir #1#2#3{% + \@XA{\@popenvir@ #1#2#3}\@envirstack\@nil +} + +\def\@popenvir@ #1#2#3#4#5#6#7\@nil{% + \gdef #1{#4}% |#1| carries last envir name + \gdef #2{#5}% |#2| carries last envir level + \gdef #3{#6}% |#3| carries last envir beginnig line + \gdef\@envirstack{#7}% and we update the stack +} + +\long\def\@begnamedgroup#1{% + \edef\@prevgrouplevel{\the\currentgrouplevel}% added 2009/03/24 to + % handle special pseudo-environments that don't increase + % \incmd\currentgrouplevel (such as \inenv{document}). Note it's + % |\edef|ed \emph{outside} the environment's group. + \@ignorefalse% not to ignore blanks after group + \begingroup\@endpefalse + \edef\@prevenvir{\@currenvir}% Note we |\edef| it inside the group + % (for obvious reason), unlike the ‘previous’ grouplevel. + \edef\@currenvir{#1}% We could do recatcoding + % through\inverb|\string| or \nlperc\cmd\detokenize\ but all the name + % `other' and 10 could affect + % a~thousand packages so we don't do that and we'll recatcode in + % a~testing macro, see line \ref{@ifenvir}. + \edef\@currenvline{\on@line}% + \@pushenvir % we put current envir to |\@envirstack|. + \csname #1\endcsname}% if the argument is a~command's name (an + +\def\begin{\gmu@ifstar{\@begnamedgroup}{% + \@begnamedgroup@ifcs}} + +\def\@begnamedgroup@ifcs#1{% + \ifcsname#1\endcsname\afterfi{\@begnamedgroup{#1}}% + \else\afterfi{\@latex@error{Environment #1 undefined}\@eha}% + \fi}% + + +\long\def\@fourthofmany#1#2#3#4#5\@nil{#4}% + +\lpdef\@ifprevenvir#1{%\label{@ifenvir}\ + \gmu@ifedetokens + {\@xa\@fourthofmany\@envirstack\relax\relax\relax\relax\@nil}% + {#1}% +} + + +\def\@checkend#1{% + \@ifenvir{#1}% + {}% + {\@badend{#1}}% +} + +\ampulexdef\end[#1][#1]\endcsname\@checkend{% +\endcsname +\@xa\gmu@ifempty\@xa{\@envirstack}% +{% + \PackageError {gmutils/base}% + {There's no environment to pop!}{Oy vey, gefeelte fish!}% +}% +{\@popenvir\gmu@drain\gmu@drain\gmu@drain }% +\@checkend +} + +\pdef\@endif#1{\@ifenvir{#1}{\end{#1}}{}} + +\pdef\@endifprev#1{\@ifprevenvir{#1}{\end{#1}}{}} + +\newcount\c@EnvirInterruption + +\lpdef\gmu@InterruptEnvir +#1% the contents of interruption. +{% + \global \advance\c@EnvirInterruption\@ne + \Name \@popenvir + {gmu@InterruptCurrenv \the\c@EnvirInterruption}\gmu@drain\gmu@drain + \endgroup + #1% + \begingroup + \@XA {\let\@currenvir}% + \csname gmu@InterruptCurrenv \the\c@EnvirInterruption \endcsname + \@pushenvir + \global \advance\c@EnvirInterruption\m@ne +} + + +\endinput +%% +%% End of file `gmenvir.sty'. diff --git a/macros/latex/contrib/gmutils/gmlogos.sty b/macros/latex/contrib/gmutils/gmlogos.sty new file mode 100644 index 0000000000..107ccfd785 --- /dev/null +++ b/macros/latex/contrib/gmutils/gmlogos.sty @@ -0,0 +1,232 @@ +%% +%% \iffalse ^^A we skip the debug setting +\IfFileExists{\string~/bin/gen_and_xela}{\errorcontextlines=1000 }{} +%% \fi +%% ^^A $Id: TheUltimateMaster.gmd,v 0.352 2011/10/12 15:19:42 natror Exp natror $ +%% This is file “gmlogos.sty” generated with the DocStrip utility. +%% +%% +%% The original source files were: +%% +%% gmutils/gmutils.gmd (with options: `logos') +%% +%% +%% Copyright © +%% by Grzegorz ‘Natror’ Murzynowski +%% natror (at) gmail (dot) com +%% +%% This program is subject to the LaTeX Project Public License. +%% See http://www.ctan.org/tex-archive/help/Catalogue/licenses.lppl.html +%% for the details of that license. +%% +%% LPPL status: "author-maintained". +%% +%% +%% +%% For documentation please refer to the file(s) +%% gmutils.{gmd,pdf}. +%% +%% +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{gmlogos} + [2011/05/05 v0.996 TeX-related logos (GM)] + + +%% +%% +%% ^^A\typeout{\unexpanded{#4}}%% + +\RequirePackage{gmbase} + + +\let\oldLaTeX\LaTeX +\let\oldLaTeXe\LaTeXe + +\pdef\TeX{T\kern-.1667em\lower.5ex\hbox{E}\kern-.125emX\@} +\Store@Macro\TeX +\AtBeginDocument{\Restore@Macro\TeX} + +\lpdef\EofTeX +#1#2% whether put kerns before and after »E« respectively. +#3% we do nothing with it (maybe unbrace) but we want to gobble + % possible space. +{\if1#1\relax \kern-.1667em \fi + \lower.5ex\hbox{E}% + \if1#2\relax \kern-.125em \fi + #3 +} + +\newcommand*\DeclareLogo[3][\relax]{% \begin{enumargs*} + % \opt is for non-\LaTeX\ spelling and will be used in the + % \acro{PD1} encoding (to make pdf bookmarks); + % \item is the command, its name will be the PD1 spelling by + % default, + % \item is the definition for all the font encodings except PD1. + % \end{enumargs*} + % + \ifx\relax#1\def\gmu@DeclareLogo@resa{\@xa\@gobble\string#2}% + \else + \def\gmu@DeclareLogo@resa{#1}% + \fi + \edef\gmu@DeclareLogo@resa{% + \@nx\DeclareTextCommand\@nx#2{PD1}{\gmu@DeclareLogo@resa}} + \gmu@DeclareLogo@resa + \DeclareTextCommandDefault#2{#3}% + \pdef#2{#3}% added for \XeTeX. +} + +\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}% + \gmlogos@hyphen + \TeX +} + +\DeclareLogo\LaTeXe{\mbox{\m@th \if + b\expandafter\@car\f@series\@nil\boldmath\fi + \LaTeX\kern.15em2$_{\textstyle\varepsilon}$}} + +\Store@Macro\LaTeX +\Store@MacroSt{LaTeX } + +\DeclareLogo[(La)TeX]{\LaTeXpar}{% + {% + \setbox\z@\hbox{(}%) + \leavevmode % \chgs{2010/04/09 v0.993 added \cmd\leavevmode\ (a + % bug fix)} + \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@}\gmlogos@hyphen\TeX +} + +\gmu@ifundefined{AmSTeX} + {\def\AmSTeX{\leavevmode\hbox{$\mathcal A\kern-.2em\lower.376ex% + \hbox{$\mathcal M$}\kern-.2em\mathcal S$-\TeX}}}{} + +\DeclareLogo\BibTeX{{\rmfamily B\kern-.05em% + \textsc{i{\kern-.025em}b}\kern-.08em% the kern is wrapped in + % braces for my |\fakescaps|' sake. + \TeX}} + +\DeclareLogo\SliTeX{{\rmfamily S\kern-.06emL\kern-.18em\raise.32ex\hbox + {\scshape i}\kern -.03em\TeX}} + +\DeclareLogo\PlainTeX{\textsc{Plain}\kern2pt\TeX} + +\DeclareLogo\Web{\textsc{Web}} +\DeclareLogo[The TeX book]\TeXbook{\textsl{The \TeX\space book}} +\let\TB\TeXbook% \textit{TUG Boat} uses this. + +\DeclareLogo[e-TeX]\eTeX{% + \iffontchar\font"03B5{\itshape ε}\else + \ensuremath{\varepsilon}\fi-\kern-.125em\TeX}% definition sent by Karl + +\Store@Macro\eTeX + +\DeclareLogo[pdfe-TeX]\pdfeTeX{pdf\gmlogos@hyphen\eTeX} + +\DeclareLogo\pdfTeX{pdf\gmlogos@hyphen\TeX} +\DeclareLogo\pdfLaTeX{pdf\gmlogos@hyphen\LaTeX} + + +\gmu@ifundefined{XeTeX}{% + \DeclareLogo\XeTeX{X\kern-.125em\relax + \gmu@ifundefined{reflectbox}{% + \lower.5ex\hbox{E}\kern-.1667em\relax}{% + \lower.5ex\hbox{\reflectbox{E}}\kern-.1667em\relax}% + \TeX + }% +}{} + +\gmu@ifundefined{XeLaTeX}{% + \DeclareLogo\XeLaTeX{X\kern-.125em\relax + \gmu@ifundefined{reflectbox}{% + \lower.5ex\hbox{E}\kern-.1667em\relax}{% + \lower.5ex\hbox{\reflectbox{E}}\kern-.1667em\relax}% + \LaTeX}}{} + +\DeclareLogo\XeTeXpar{% \chgs{2010/04/09 v0.993 added} + \setbox\z@\hbox{(}%) + \leavevmode + \copy\z@ + \kern-.2\wd\z@ + \smash{% the “Xe” part is copied from \pk{xltxtra} + X\lower0.5ex + \hbox{\kern-0.15em + \gmu@ifundefined{XeTeXversion}% + {\setbox0=\hbox{E}\dimen0=\ht0\advance\dimen0by\dp0% + \raise\dimen0\hbox{\rotatebox{180}{\box0}}% + }% of if not in \XeTeX, then in \XeTeX: + {\ifnum\XeTeXfonttype\font>0 + \ifnum\XeTeXcharglyph"018E>0 + \char"018E\relax + \else + \ifdim\fontdimen1\font=0pt + \reflectbox{E}% + \else + \XeTeXuseglyphmetrics=1% + \setbox0=\hbox{E}\dimen0=\ht0\advance\dimen0by\dp0% + \raise\dimen0\hbox{\rotatebox{180}{\box0}}% + \fi + \fi + \else + \setbox0=\hbox{E}\dimen0=\ht0\advance\dimen0by\dp0% + \raise\dimen0\hbox{\rotatebox{180}{\box0}}% + \fi}% of reversed E when in \XeTeX + }% of hbox + }% of smash ^^A( + \setbox\z@\hbox{)}% + \kern-.2\wd\z@ + \copy\z@ + \kern-0.15em + \TeX}% + +\DeclareLogo[LuaTeX]\LuaTeX{\textsc{Lua}\gmlogos@hyphen\TeX} + +\DeclareLogo [ConTeXt]\ConTeXt{Con\gmlogos@hyphen\TeX t} + +\emptify\gmlogos@hyphen + +\def\HyphenateLogo#1{% + {\let\gmlogos@hyphen\-% + #1}% +} + + +\endinput +%% +%% End of file `gmlogos.sty'. diff --git a/macros/latex/contrib/gmutils/gmmeta.sty b/macros/latex/contrib/gmutils/gmmeta.sty new file mode 100644 index 0000000000..fa8b106d61 --- /dev/null +++ b/macros/latex/contrib/gmutils/gmmeta.sty @@ -0,0 +1,292 @@ +%% +%% \iffalse ^^A we skip the debug setting +\IfFileExists{\string~/bin/gen_and_xela}{\errorcontextlines=1000 }{} +%% \fi +%% ^^A $Id: TheUltimateMaster.gmd,v 0.352 2011/10/12 15:19:42 natror Exp natror $ +%% This is file “gmmeta.sty” generated with the DocStrip utility. +%% +%% +%% The original source files were: +%% +%% gmutils/gmutils.gmd (with options: `meta') +%% +%% +%% Copyright © +%% by Grzegorz ‘Natror’ Murzynowski +%% natror (at) gmail (dot) com +%% +%% This program is subject to the LaTeX Project Public License. +%% See http://www.ctan.org/tex-archive/help/Catalogue/licenses.lppl.html +%% for the details of that license. +%% +%% LPPL status: "author-maintained". +%% +%% +%% +%% For documentation please refer to the file(s) +%% gmutils.{gmd,pdf}. +%% +%% +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{gmmeta} + [2011/10/12 v0.996 meta-symbols for typesetting macros and arguments (GM)] + + +%% +%% +%% ^^A\typeout{\unexpanded{#4}}%% +\RequirePackage{gmcommand} +\pdef\meta#1{% + % \begin{quotation} + % Since the old implementation of |\meta| could be used in math we better ensure + % that this is possible with the new one as well. So we use |\ensuremath| around + % |\langle| and |\rangle|. However this is not enough: if |\meta@font@select| below + % expands to |\itshape| it will fail if used in math mode. For this reason we hide + % the whole thing inside an |\nfss@text| box in that case. + % \end{quotation} + {\meta@fontsetting\ensuremath\langle}% + \ifmmode\@xa\nfss@text\fi + {% this has to be a~begin-group because \incmd{\nfss@text} becomes + % \incmd\hbox\ in math mode. + \gmu@activespaceblank + \meta@font@select + % Need to keep track of what we changed just in case the user changes font inside + % the argument so we store the font explicitly. + #1\/% + }% + {\meta@fontsetting\ensuremath\rangle}% +}% of |\meta|. + +\pdef\gmu@activespaceblank{% + \@xa\def\gmu@activespace{\space\ignorespaces}% note the + % subtle perversity of this definition: if we meet more than one + % subsequent active spaces, then the first of them will + % typeset \incmd\space and its \incmd\ignorespaces\ will + % gobble \incmd\space\ of the second and will stop at + % \incs{ignorespaces} and this \incs{ignorespaces} will gobble + % the next \incs{space} and so on. +} + +\def\meta@fontsetting{\color{red!85!black}} + +\def\meta@font@select{\meta@fontsetting\it} + +\def\<#1>{\meta{#1}} + +\pdef\metachar#1{\begingroup\metacharfont #1\endgroup} +\def\metacharfont{\meta@fontsetting\rm} + +\pdef\vs{\discre{\visiblespace}{}{\visiblespace}} + +\def\printspaces#1{{\let~=\vs \let\ =\vs \gmu@pswords#1 \@nil}} +\def\gmu@pswords#1 #2\@nil{% + \ifx\relax#1\relax\else#1\fi + \ifx\relax#2\relax\else\vs\penalty\hyphenpenalty\gmu@pswords#2\@nil\fi}% note + +\pdef\sfname#1{\textsf{\printspaces{#1}}} + +\def\gmu@discretionaryslash{\discre{/}{\hbox{}}{/}}% the second + +\pdef\file#1{\gmu@printslashes#1/\gmu@printslashes} + +\def\gmu@printslashes#1/#2\gmu@printslashes{% + \sfname{#1}% + \ifx\gmu@printslashes#2\gmu@printslashes + \else + \textsf{\gmu@discretionaryslash}% + \afterfi{\gmu@printslashes#2\gmu@printslashes}\fi} + + +\pdef\pk#1{\textsf{#1}} + +\DeclareCommand\cs{O{\type@bslash\penalty\@M\hskip\z@skip}}{%\ + % \begin{enumargs} + % \dc O{\bslash} the control sequence's prefix, by default it's + % \inverb|\| allowing hyphenation of subsequent word, + % \dc m the control sequence or anything to be typeset in + % typewriter font. + % \end{enumargs} + % \chgs{2008/12/12 v0.98 added \cs{verbatim@specials}} + % \chgs{2008/12/12 v0.98 made \cmd\- switch to \cmd\normalfont\ + % because \IMHO\ this underlines the fact that a~\CS\ belongs to the + % narrative. \cmd\hyphenchar\ set to 45 as in usual texts} + \begingroup + \ifdefined\verbatim@specials\verbatim@specials\fi + \edef\-{\discretionary{% + \ifdefined\gmv@hyphen\gmv@hyphen + \else\unexpanded{{\normalfont-}}% + \fi}{}{}}% + \def\{{\type@lbrace\yeshy}\def\}{\char`\}}% + \narrativett + \edef\narrativett@storedhyphenchar{\the\hyphenchar\font}% + \hyphenchar\font=% + \ifdefined\gmv@hyphenchar\gmv@hyphenchar + \else "A6 + \fi + \cs@inner{#1}% +}% of |\cs| + +\let\type@bslash\bslash + +\pdef\cs@inner#1#2{% + #1#2% + \endgroup} + +\def\narrativett{\ttfamily}% such name because I~introduce it to + +\long\pdef\env{\cs[]} + +\foone{\@makeother\^} + {\pdef\hathat{\cs[^^]}} + +\AtBeginDocument{% + \@ifpackageloaded{gmdoc}{\def\hash{\cs[\#]}}{}} + +\def\possfil{\hfil\penalty1000\hfilneg} + +\def\possvfil{\vfil + \penalty\numexpr + \gmu@minnum{\clubpenalty+\widowpenalty}{9999}% + \relax % eaten by |\gmu@maxnum| + \relax % eaten by |\numexpr| + \vfilneg} + + +\long\def\cmd#1{\@xa\cs\@xa{\@xa\cmd@to@cs\string#1}\spifletter}% it has to be + +\def\cmd@to@cs#1#2{\char\number`#2\relax} + +\pdef\marg#1{{\narrativett\type@lbrace}\arg@wrap{#1}{\narrativett\char`\}}} + +\pdef\oarg{\@ifnextchar[\@oargsq\@oarg} +\pdef\@oarg#1{{\narrativett[}\arg@wrap{#1}{\narrativett]}} +\pdef\@oargsq[#1]{\@oarg{#1}} + +\pdef\parg{\@ifnextchar(\@pargp\@parg} +\def\@parg#1{{\narrativett(}\arg@wrap{#1}{\narrativett)}} +\def\@pargp(#1){\@parg{#1}} + +\pdef\aarg{\@ifnextchar<\@aarga\@aarg} +\def\@aarg#1{{\narrativett<}\arg@wrap{#1}{\narrativett>}} +\def\@aarga<#1>{\@aarg{#1}} + +\def\@verbaarga#1#2>{\@aarg{#2}\arg@dc} + +\foone{\catcode`>\active}{% + \def\@verbaargact#1#2>{\@aarg{#2}\arg@dc}% +} + +\foone{\@makeother\{\@makeother\}% + \catcode`[=\@ne\catcode`]=\tw@} +[% ^^A{ + \def\@verbmargm#1#2}[% for an argument in curly braces in a verbatim, where + % the braces are not groupers and not necessary ‘other’. We'll know + % by \incmd{\@ifnextif} that the future token is an opening + % brace. Note this macro has 2nd parameter delimited with ‘other’ + % closing brace (so may not act correctly when braces are nested + % (then hide them with special verbatim groupers)). + \marg[#2]% + \arg@dc + ]% +]% of |\foone| + +\def\arg@wrap{\meta} + +\DeclareCommand\arg@dc!{% + % \chgs{200/03/04 v0.991 added rcognising of verbatim braces and + % angles} + s % (1) + o % (2) + c % (3) + b % (4) + a % (5) + T{\arg} % (6) just gobbled (for backwards compatibility) +}{% This command iterates while it + % has arguments and typesets them in brackets, parentheses or curly + % braces. Note it gobbles subsequent |\arg|s and just iterates. + \def\next{0}% + \gmuIfValueT{#1}% + {\metachar[\scanverb{*}\metachar]\def\next{1}}% + \gmuIfValueT{#2}{\@oarg{#2}\def\next{1}}% + \gmuIfValueT{#3}{\@parg{#3}\def\next{1}}% + \gmuIfValueT{#4}{\marg{#4}\def\next{1}}% + \gmuIfValueT{#5}{\aarg{#5}\def\next{1}}% + \@ifnextchar\egroup{\endgroup}{% + \if1\next\@xa\arg@dc + \else % it's crucial that we look for verbatim braces \emph{after} + % we checked there were no \inhash4, otherwise there would + % be an error. + \def\next{% + \@ifnextif\xiilbrace{\@verbmargm}% + {% not active or other lbrace + \@ifnextif<{% then we look for angles + \ifnum\catcode`>=\active + \@xa\@verbaargact + \else\@xa\@verbaarga + \fi}% + {% and if not angles neither verbatim braces, then + \endgroup % if we have no more arguments to typeset, we + % close the group opened in lines \ref{queer.group} and \ref{queer.group2}. + \spifletter + }% + }% + }% + \@xa \next + \fi + }% of not egroup +}% of |\arg@dc| + +\foone{\obeylines\@makeother\^^C}{% + \AtBeginDocument{% + \let\math@arg\arg % + \pdef\arg{% This is |\arg| for meta-arguments. + \ifmmode\math@arg % + % \chgs{200/03/04 v0.991 added rcognising of verbatim braces and angles} + \else\afterfi{% + \begingroup % + % \label{queer.group} + \ifdefined\@ifQueerEOL\@ifQueerEOL{% + \def^^M{\unskip\space}% in the ‘queer’ \ac{EOL}s scope we + % keep line end active in case we have + % \incmd\arg\nlpercent\arg{arg.} ending a~line: the next + % char peeper touches line end or, if the line end was $_5$, + % gobbles the space it turns into so the comment layer would + % ‘leak’ to the code layer. + }{}\fi % + \arg@dc}% + \fi}% of |\arg|, + }% of |\AtBeginDocument|, + % + % \stanza + % And this is arg-typesetting command for verbatim arguments. + \pdef\argv{% + \begingroup % + % \label{queer.group2} + \@makeother\^^C% + \pdef\arg@wrap##1{% + \narrativett{##1}% + }% + \ifdefined\@ifQueerEOL\@ifQueerEOL{% + \def^^M{\unskip\space}% in the ‘queer’ \ac{EOL}s scope we + % keep line end active… as above + }{}% + \fi % of |\ifdefined| + \arg@dc}% +}% of |\foone|. + + +\DeclareCommand\cat{Q{'"0123456789ABCDEF}{0}}{% + ${}_{\the\numexpr#1}\m@th$\spifletter +} + +\pdef\CS{% \changes{v0.99n}{2008/08/30}{added} + \acro{CS}% + \@ifnextcat a{ }{}}% we put a~space if the next token is + +\pdef\CSs{\CS{}es\@ifnextcat a{ }{}}% for pluralis. +\pdef\CSes{\CS{}es\@ifnextcat a{ }{}}% for pluralis. + + +\endinput +%% +%% End of file `gmmeta.sty'. diff --git a/macros/latex/contrib/gmutils/gmmw.sty b/macros/latex/contrib/gmutils/gmmw.sty new file mode 100644 index 0000000000..46b8e41fa7 --- /dev/null +++ b/macros/latex/contrib/gmutils/gmmw.sty @@ -0,0 +1,363 @@ +%% +%% \iffalse ^^A we skip the debug setting +\IfFileExists{\string~/bin/gen_and_xela}{\errorcontextlines=1000 }{} +%% \fi +%% ^^A $Id: TheUltimateMaster.gmd,v 0.352 2011/10/12 15:19:42 natror Exp natror $ +%% This is file “gmmw.sty” generated with the DocStrip utility. +%% +%% +%% The original source files were: +%% +%% gmutils/gmutils.gmd (with options: `mw') +%% +%% +%% Copyright © +%% by Grzegorz ‘Natror’ Murzynowski +%% natror (at) gmail (dot) com +%% +%% This program is subject to the LaTeX Project Public License. +%% See http://www.ctan.org/tex-archive/help/Catalogue/licenses.lppl.html +%% for the details of that license. +%% +%% LPPL status: "author-maintained". +%% +%% +%% +%% For documentation please refer to the file(s) +%% gmutils.{gmd,pdf}. +%% +%% +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{gmmw} + [2011/10/12 v0.996 improvements and workarounds to the MWCLS classes (GM)] + + +%% +%% +%% ^^A\typeout{\unexpanded{#4}}%% +\RequirePackage{gmcommand} + + +\AtBeginDocument{% because we don't know when exactly \pk{hyperref} is + % loaded and maybe after this package. + \@ifpackageloaded{hyperref}{\newcounter{NoNumSecs}% + \setcounter{NoNumSecs}{617}% to make |\ref|ing to an unnumbered section + % visible (and funny?). + \def\gmu@hyperrefstepcounter{\refstepcounter{NoNumSecs}}% + \pdef\gmu@targetheading#1{% + \hypertarget{#1}{#1}}}% end of then + {\def\gmu@hyperrefstepcounter{}% + \def\gmu@targetheading#1{#1}}% end of else +}% of |\AtBeginDocument| + +\def\gmu@dontnumbersectionsoutofmainmatter{% + \if@mainmatter\else \HeadingNumberedfalse \fi} +\def\gmu@clearpagesduetoopenright{% + \if@openright\cleardoublepage\else \clearpage\fi} + +\long\def\@ifnotmw#1#2{\gmu@ifundefined{mw@sectionxx}{#1}{#2}} + +\@ifnotmw{}{% +\def\mw@sectionxx#1#2[#3]#4{% + \edef\mw@HeadingLevel{\csname #1@level\endcsname + \space}% space delimits level number! + \ifHeadingNumbered + \ifnum \mw@HeadingLevel>\c@secnumdepth \HeadingNumberedfalse \fi + % \nostanza line below is in |\gmu@ifundefined| to make it work in classes + % other than \pk{mwbk}\nostanza + \gmu@ifundefined{if@mainmatter}{}{\gmu@dontnumbersectionsoutofmainmatter} + \fi +%% \ifHeadingNumbered +%% \refstepcounter{#1}% +%% \protected@edef\HeadingNumber{\csname the#1\endcsname\relax}% +%% \else +%% \let\HeadingNumber\@empty +%% \fi + \def\HeadingRHeadText{#2}% + \def\HeadingTOCText{#3}% + \def\HeadingText{#4}% + \def\mw@HeadingType{#1}% + \if\mw@HeadingBreakBefore + \if@specialpage\else\thispagestyle{closing}\fi + \gmu@ifundefined{if@openright}{}{\gmu@clearpagesduetoopenright}% + \if\mw@HeadingBreakAfter + \thispagestyle{blank}\else + \thispagestyle{opening}\fi + \global\@topnum\z@ + \fi% of |\if\mw@HeadingBreakBefore| +%% + \ifHeadingNumbered + \refstepcounter{#1}% + \protected@edef\HeadingNumber{\csname the#1\endcsname\relax}% + \else + \let\HeadingNumber\@empty + \gmu@hyperrefstepcounter % we step an auxiliary counter to make a + % hyperref's label/target. + \fi% of |\ifHeadingNumbered| +%% + \if\mw@HeadingRunIn + \mw@runinheading + \else + \if\mw@HeadingWholeWidth + \if@twocolumn + \if\mw@HeadingBreakAfter + \onecolumn + \mw@normalheading + \pagebreak\relax + \if@twoside + \null + \thispagestyle{blank}% + \newpage + \fi% of |\if@twoside| + \twocolumn + \else + \@topnewpage[\mw@normalheading]% + \fi% of |\if\mw@HeadingBreakAfter| + \else + \mw@normalheading + \if\mw@HeadingBreakAfter\pagebreak\relax\fi + \fi% of |\if@twocolumn| + \else + \mw@normalheading + \if\mw@HeadingBreakAfter\pagebreak\relax\fi + \fi% of |\if\mw@HeadingWholeWidth| + \fi% of |\if\mw@HeadingRunIn| + } + + +\relaxen\SetSectionFormatting +\newcommand*\SetSectionFormatting[5][\empty]{% + \ifx\empty#1\relax\else% empty (not |\empty|!) |#1| also launches |\else|.\HideDef + \def\mw@HeadingRunIn{10}\def\mw@HeadingBreakBefore{10}% + \def\mw@HeadingBreakAfter{10}\def\mw@HeadingWholeWidth{10}% + \gmu@ifempty{#1}{}{\mw@processflags#1,\relax}% If |#1| is omitted, + % the flags are left unchanged. If |#1| is given, even as [], the + % flags are first cleared and then processed again. + \fi + \gmu@ifundefined{#2}{\@namedef{#2}{\mw@section{#2}}}{}% + \mw@secdef{#2}{@preskip} {#3}{2 oblig.}% + \mw@secdef{#2}{@head} {#4}{3 oblig.}% + \mw@secdef{#2}{@postskip}{#5}{4 oblig.}% + \ifx\empty#1\relax + \mw@secundef{#2@flags}{1 (optional)}% + \else\mw@setflags{#2}% \ResumeDef + \fi} + +\def\mw@secdef#1#2#3#4{% ^^B + \gmu@ifempty{#3} + {\mw@secundef{#1#2}{#4}} + {\@namedef{#1#2}{#3}}} + +\def\mw@secundef#1#2{% + \gmu@ifundefined{#1}{% + \ClassError{mwcls/gm}{% + command \bslash#1 undefined \MessageBreak + after \bslash SetSectionFormatting!!!\MessageBreak}{% + Provide the #2 argument of \bslash SetSectionFormatting.}}{}} + +\def\addtoheading#1#2{% + \n@melet{gmu@addtoheading@resa}{#1@head}% + \edef\gmu@addtoheading@resa{\unexpanded{#2}\@xa\unexpanded{\gmu@addtoheading@resa}}% + \n@melet{#1@head}{gmu@addtoheading@resa}% +} + +}% of |\@ifnotmw|'s else. + + +\@ifnotmw{}{% We proceed only in \acro{MWCLS}. + +\def\@afterheading{% + \@nobreaktrue + \xdef\gmu@prevsec{\mw@HeadingType}% added now + \everypar{% + \grelaxen\gmu@prevsec% added now. All the rest is original \LaTeX. + \if@nobreak + \@nobreakfalse + \clubpenalty \@M + \if@afterindent \else + {\setbox\z@\lastbox}% + \fi + \else + \clubpenalty \@clubpenalty + \everypar{}% + \fi}} + +\def\gmu@checkaftersec{% + \gmu@ifundefined{gmu@prevsec}{}{% + \ifgmu@postsec% an additional switch that is true by default but + % may be turned into an \cs{ifdim} in special + % cases, see line \ref{gmu@postsec}. + {\@xa\mw@getflags\@xa{\gmu@prevsec}% + \glet\gmu@checkaftersec@resa\mw@HeadingBreakAfter}% \UnDef + \if\mw@HeadingBreakBefore\def\gmu@checkaftersec@resa{11}\fi% if the + % current heading inserts page break before itself, all the play + % with vskips is irrelevant. + \if\gmu@checkaftersec@resa\else + \penalty10000\relax + \skip\z@=\csname\gmu@prevsec @postskip\endcsname\relax + \skip\tw@=\csname\mw@HeadingType @preskip\endcsname\relax + \gmu@ifundefined{\mw@HeadingType @twoheadskip}{% + \ifdim\skip\z@>\skip\tw@ + \vskip-\skip\z@% we strip off the post-skip of previous + % header if it's bigger than current pre-skip + \else + \vskip-\skip\tw@% we strip off the current pre-skip otherwise + \fi}{% But if the two-header-skip is defined, we put + % \emph{it} + \penalty10000 + \vskip-\skip\z@ + \penalty10000 + \vskip-\skip\tw@ + \penalty10000 + \vskip\csname\mw@HeadingType @twoheadskip\endcsname + \relax}% + \penalty10000 + \hrule height\z@\relax% to hide the last (un)skip before subsequent + % \incs{addvspace}s. \ilrr + \penalty10000 + \fi + \fi + }% of |\gmu@ifundefined{gmu@prevsec}| `else'. +}% of |\def\gmu@checkaftersec|. + +\def\ParanoidPostsec{% \label{gmu@postsec} this version of + % \inverb|\ifgmu@postsec| is intended for the special case of + % sections may contain no normal text, as while \pk{gmdoc}ing. + \def\ifgmu@postsec{% note this macro expands to an open \cs{if}. + \skip\z@=\csname\gmu@prevsec @postskip\endcsname\relax + \ifdim\lastskip=\skip\z@\relax% we play + % with the vskips only if the last skip is the previous + % heading's postskip (a~counter-example I~met while + % \pk{gmdoc}ing). + }} + +\let\ifgmu@postsec\iftrue + +\def\gmu@getaddvs#1\addvspace#2\gmu@getaddvs{% + \toks\z@={#1}% + \toks\tw@={#2}} + +\def\gmu@setheading#1{% + \@xa\gmu@getaddvs#1\gmu@getaddvs + \edef#1{% + \the\toks\z@\@nx\gmu@checkaftersec + \@nx\addvspace\the\toks\tw@}} + +\gmu@setheading\mw@normalheading +\gmu@setheading\mw@runinheading + +\def\SetTwoheadSkip#1#2{\@namedef{#1@twoheadskip}{#2}} + +}% of |\@ifnotmw|'s else. + + +\@ifnotmw{}{% We define this declaration only when in \pk{mwcls}. +\DeclareCommand\WPheadings{T{\chapter}}{% + \SetSectionFormatting[breakbefore,wholewidth] + {part}{\z@\@plus1fill}{}{\z@\@plus3fill}% + % + \gmuIfValueF{#1}{% + \gmu@ifundefined{chapter}{}{% + \SetSectionFormatting[breakbefore,wholewidth] + {chapter} + {66\p@}% |{67\p@}|% for Adventor/Schola 0,95. + {\FormatHangHeading{\LARGE}} + {27\p@\@plus0,2\p@\@minus1\p@}% + }% + }% of unless |#1| + % + \SetTwoheadSkip{section}{27\p@\@plus0,5\p@}% + \SetSectionFormatting{section} + {24\p@\@plus0,5\p@\@minus5\p@}% ^^A {24\p@\@plus5\p@\@minus2\p@} + {\FormatHangHeading {\Large}} + {10\p@\@plus0,5\p@}% ed.\ Krajewska of ``Wiedza Powszechna'', as + % we understand her, wants the skip between a~heading and text + % to be rigid. + % + \SetTwoheadSkip{subsection}{11\p@\@plus0,5\p@\@minus1\p@}% + \SetSectionFormatting{subsection} + {19\p@\@plus0,4\p@\@minus6\p@} + {\FormatHangHeading {\large}}% 12/14 pt + {6\p@\@plus0,3\p@}% after-skip 6\,pt due to p.12, not to squeeze + % the before-skip too much. + % + \SetTwoheadSkip{subsubsection}{10\p@\@plus1,75\p@\@minus1\p@}% + \SetSectionFormatting{subsubsection} + {10\p@\@plus0,2\p@\@minus1\p@} + {\FormatHangHeading {\normalsize}} + {3\p@\@plus0,1\p@}% those little skips should be smaller than + % you calculate out of a~geometric progression, because the + % interline skip enlarges them. + % + \SetSectionFormatting[runin]{paragraph} + {7\p@\@plus0,15\p@\@minus1\p@} + {\FormatRunInHeading{\normalsize}} + {2\p@}% + % + \SetSectionFormatting[runin]{subparagraph} + {4\p@\@plus1\p@\@minus0,5\p@} + {\FormatRunInHeading{\normalsize}} + {\z@}% +}% of |\WPheadings| +}% of |\@ifnotmw| + +\@ifnotmw{% we are not in \pk{mwcls} and want to + % handle \pk{mwcls}-like sectionings i.e., those written with two + % optionals. + \def\gmu@secini{gm@la}% + \Store@Macros{% + \partmark \chaptermark \sectionmark \subsectionmark + \subsubsectionmark \paragraphmark}% + % \Define\gmu@secxx + \def\gmu@secxx#1#2[#3]#4{% + \ifx\gmu@secstar\@empty + % \nostanza a~tiny little trick to allow + % a~special version of the heading just to the running head. + \@namedef{#1mark}##1{% we redefine \cs{\mark} to gobble its + % argument and to launch the stored true marking command on the + % appropriate argument. + \storedcsname{#1mark}{#2}% + \Restore@MacroSt{#1mark}% after we've done what we + % wanted we restore original |\#1mark|.\ilrr + }% + \def\gmu@secstar{[#3]}% if |\gmu@secstar| + % is empty, which means the sectioning command was written + % starless, we pass the `true' sectioning command |#3| as the + % optional argument. Otherwise the sectioning command was written + % with star so the `true' s.c.\ takes no optional. + \fi + \@xa\@xa\csname\gmu@secini#1\endcsname + \gmu@secstar{#4}}% +}{% we are in \pk{mwcls} and want to reverse MW's optionals order + % i.e., if there's just one optional, it should go both to toc and to + % running head. + \def\gmu@secini{gm@mw}% + % + \let\gmu@secmarkh\@gobble% in \pk{mwcls} there's no need to make + % tricks for special version to running headings. + % \Define\gmu@secxx + \def\gmu@secxx#1#2[#3]#4{% + \@xa\@xa\csname\gmu@secini#1\endcsname + \gmu@secstar[#2][#3]{#4}}% +} + +\def\gmu@sec#1{\@dblarg{\gmu@secx{#1}}} +\def\gmu@secx#1[#2]{% + \@ifnextchar[{\gmu@secxx{#1}{#2}}{\gmu@secxx{#1}{#2}[#2]}}% if + +\def\gmu@straightensec#1{% the parameter is for the command's name. + \gmu@ifundefined{#1}{}{% we don't change the ontological status of the + % command because someone may test it. + \n@melet{\gmu@secini#1}{#1}% + \@namedef{#1}{% + \gmu@ifstar{\def\gmu@secstar{*}\gmu@sec{#1}}{% + \def\gmu@secstar{}\gmu@sec{#1}}}}% +}% + +\let\do\gmu@straightensec +\do{part}\do{chapter}\do{section}\do{subsection}\do{subsubsection} +\@ifnotmw{}{\do{paragraph}}% this `straightening' of + +\endinput +%% +%% End of file `gmmw.sty'. diff --git a/macros/latex/contrib/gmutils/gmnotonlypream.sty b/macros/latex/contrib/gmutils/gmnotonlypream.sty new file mode 100644 index 0000000000..1578aba3d9 --- /dev/null +++ b/macros/latex/contrib/gmutils/gmnotonlypream.sty @@ -0,0 +1,88 @@ +%% +%% \iffalse ^^A we skip the debug setting +\IfFileExists{\string~/bin/gen_and_xela}{\errorcontextlines=1000 }{} +%% \fi +%% ^^A $Id: TheUltimateMaster.gmd,v 0.352 2011/10/12 15:19:42 natror Exp natror $ +%% This is file “gmnotonlypream.sty” generated with the DocStrip utility. +%% +%% +%% The original source files were: +%% +%% gmutils/gmutils.gmd (with options: `notonlypream') +%% +%% +%% Copyright © +%% by Grzegorz ‘Natror’ Murzynowski +%% natror (at) gmail (dot) com +%% +%% This program is subject to the LaTeX Project Public License. +%% See http://www.ctan.org/tex-archive/help/Catalogue/licenses.lppl.html +%% for the details of that license. +%% +%% LPPL status: "author-maintained". +%% +%% +%% +%% For documentation please refer to the file(s) +%% gmutils.{gmd,pdf}. +%% +%% +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{gmnotonlypream} + [2011/10/12 v0.996 modification of the 'only preamble' clause (GM)] + + +%% +%% +%% ^^A\typeout{\unexpanded{#4}}%% + +\RequirePackage{gmampulex} + + +\newcommand\not@onlypreamble[1]{{% + \def\do##1{\ifx#1##1\else\@nx\do\@nx##1\fi}% + \xdef\@preamblecmds{\@preamblecmds}}} + +\not@onlypreamble\@preamblecmds +\not@onlypreamble\@ifpackageloaded +\not@onlypreamble\@ifclassloaded +\not@onlypreamble\@ifl@aded +\not@onlypreamble\@pkgextension + +\not@onlypreamble\@pushfilename +\not@onlypreamble\@popfilename + +\not@onlypreamble\@currnamestack + + +\def\gmu@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\gmno@NotprerrMessage##1}\@nx\@eha}}% + \@preamblecmds} + +\def\gmno@NotprerrMessage#1{% + \PackageError{gmutils/LaTeX}% + {\@nx\string#1 \@nx\gmu@notprerr}{}% +} + + +\def\gmu@nocite@ampulex{% we wrap the stuff in a~macro to hide an open + % \incs{if}. And not to make the begin-input hook too large. + % \label{ampulexset} the first optional argument is the + % parameters string and the second the argument for one-level + % expansion of \incs{nocite}. Both hash strings are doubled to pass + % the % first \incs{def}. + \ampulexdef\nocite[##1][##1] + \ifx + {\@onlypreamble\document}% + \iftrue} + +\AtBeginDocument{\gmu@nocite@ampulex}% + +\endinput +%% +%% End of file `gmnotonlypream.sty'. diff --git a/macros/latex/contrib/gmutils/gmparts.sty b/macros/latex/contrib/gmutils/gmparts.sty new file mode 100644 index 0000000000..2551f47445 --- /dev/null +++ b/macros/latex/contrib/gmutils/gmparts.sty @@ -0,0 +1,165 @@ +%% +%% \iffalse ^^A we skip the debug setting +\IfFileExists{\string~/bin/gen_and_xela}{\errorcontextlines=1000 }{} +%% \fi +%% ^^A $Id: TheUltimateMaster.gmd,v 0.352 2011/10/12 15:19:42 natror Exp natror $ +%% This is file “gmparts.sty” generated with the DocStrip utility. +%% +%% +%% The original source files were: +%% +%% gmutils/gmutils.gmd (with options: `parts') +%% +%% +%% Copyright © +%% by Grzegorz ‘Natror’ Murzynowski +%% natror (at) gmail (dot) com +%% +%% This program is subject to the LaTeX Project Public License. +%% See http://www.ctan.org/tex-archive/help/Catalogue/licenses.lppl.html +%% for the details of that license. +%% +%% LPPL status: "author-maintained". +%% +%% +%% +%% For documentation please refer to the file(s) +%% gmutils.{gmd,pdf}. +%% +%% +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{gmparts} + [2011/10/12 v0.996 modification of \string \include \space \string & in/excluding parts of main file (GM)] + + +%% +%% +%% ^^A\typeout{\unexpanded{#4}}%% + + +\RequirePackage{gmcommand} + +\def\gmu@getext#1.#2\@nil{%\UnDef + \def\gmu@filename{#1}%\UnDef + \def\gmu@fileext{#2}} + +\def\include#1{\relax + \ifnum\@auxout=\@partaux + \@latex@error{\string\include\space cannot be nested}\@eha + \else \@include#1 \fi} + +\def\@include#1 {% + \gmu@getext#1.\@nil + % \UnDef + \ifx\gmu@fileext\empty\def\gmu@fileext{tex}\fi + \clearpage + \if@filesw + \immediate\write\@mainaux{\string\@input{\gmu@filename.aux}}% + \fi + \@tempswatrue + \if@partsw + \@tempswafalse + \edef\reserved@b{#1}% + \@for\reserved@a:=\@partlist\do{% + \ifx\reserved@a\reserved@b\@tempswatrue\fi}% + \fi + \if@tempswa + \let\@auxout\@partaux + \if@filesw + \immediate\openout\@partaux \gmu@filename.aux + \immediate\write\@partaux{\relax}% + \fi + \@input@{\gmu@filename.\gmu@fileext}% + \inclasthook + \clearpage + \@writeckpt{\gmu@filename}% + \if@filesw + \immediate\closeout\@partaux + \fi + \else + \deadcycles\z@ + \@nameuse{cp@\gmu@filename}% + \fi + \let\@auxout\@mainaux +} + +\newcommand\whenonly[3]{% + \def\gmu@whonly{#1,}% + \ifx\gmu@whonly\@partlist\afterfi{#2}\else\afterfi{#3}\fi} + +\def\inclasthook{\thispagestyle{closing}} + +\def\filepart#1{\relax + \ifnum\@auxout=\@partaux + \@latex@error{\string\filepart\space cannot be nested}\@eha + \else\afterfi{\@filepart#1 }\fi} + +\def\@filepart#1 {% + \clearpage + \edef\gmu@filepartname{#1}% we'll use it later + \if@filesw + \immediate\write\@mainaux{\string\@input{#1.aux}}% + \fi + \@tempswatrue + \if@partsw + \@tempswafalse + \@for\gmu@filepart@resa:=\@partlist\do{% + \ifx\gmu@filepart@resa\gmu@filepartname\@tempswatrue\fi}% + \fi + \if@tempswa + \let\@auxout\@partaux + \if@filesw + \immediate\openout\@partaux #1.aux + \immediate\write\@partaux{\relax}% + \fi + \@xa\@firstoftwo + % \label{spart:iftrue} + \else + \deadcycles\z@ + \@nameuse{cp@\gmu@filepartname}% + \let\@auxout\@mainaux + \@xa\@secondoftwo + \fi + {\iftrue}% + {\let\endfilepart\fi + \csname gm@skipped@#1\endcsname + \def\next{\Restore@MacroSt {endfilepart}% + \@ifnextchar\bgroup{\show\NextBgroup\@gobble}{}}% + \@xa\next\iffalse}% +} + +\DeclareCommand\endfilepart{b}{% Note the argument is not used really. Maybe later we'll + % use it for checking of proper matching. Or maybe not. + \inclasthook + \clearpage + \@writeckpt{\gmu@filepartname}% + \if@filesw + \immediate\closeout\@partaux + \fi + \fi% this |\fi| closes |\Iftrue| put by line \ref{spart:iftrue}. + \let\@auxout\@mainaux +} + +\Store@Macro\endfilepart + +\def\nofileparts{% + \let\filepart\@gobble + \DeclareCommand\endfilepart{b}{}% +} + + +\def\includecountfix{% + \def\@wckptelt##1{% + \immediate\write\@partaux{% + \providecounter{##1}% to + % provide the font counters defined + % in parts of the document. + \string\setcounter{##1}{\the\@nameuse{c@##1}}}}% +} + +\pdef\providecounter#1{% + \unless\ifcsname c@#1\endcsname\newcounter{#1}\fi} + +\endinput +%% +%% End of file `gmparts.sty'. diff --git a/macros/latex/contrib/gmutils/gmrelsize.sty b/macros/latex/contrib/gmutils/gmrelsize.sty new file mode 100644 index 0000000000..9ee550c475 --- /dev/null +++ b/macros/latex/contrib/gmutils/gmrelsize.sty @@ -0,0 +1,80 @@ +%% +%% \iffalse ^^A we skip the debug setting +\IfFileExists{\string~/bin/gen_and_xela}{\errorcontextlines=1000 }{} +%% \fi +%% ^^A $Id: TheUltimateMaster.gmd,v 0.352 2011/10/12 15:19:42 natror Exp natror $ +%% This is file “gmrelsize.sty” generated with the DocStrip utility. +%% +%% +%% The original source files were: +%% +%% gmutils/gmutils.gmd (with options: `relsize') +%% +%% +%% Copyright © +%% by Grzegorz ‘Natror’ Murzynowski +%% natror (at) gmail (dot) com +%% +%% This program is subject to the LaTeX Project Public License. +%% See http://www.ctan.org/tex-archive/help/Catalogue/licenses.lppl.html +%% for the details of that license. +%% +%% LPPL status: "author-maintained". +%% +%% +%% +%% For documentation please refer to the file(s) +%% gmutils.{gmd,pdf}. +%% +%% +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{gmrelsize} + [2010/04/09 v0.996 chosen macros from the relsize package and mine (GM)] + + +%% +%% +%% ^^A\typeout{\unexpanded{#4}}%% +\protected\def\relsize#1{% + \ifmmode \@nomath\relsize\else + \begingroup + \@tempcnta % assign number representing current font size + \ifx\@currsize\normalsize 4\else % funny order is to have most … + \ifx\@currsize\small 3\else % …likely sizes checked first + \ifx\@currsize\footnotesize 2\else + \ifx\@currsize\large 5\else + \ifx\@currsize\Large 6\else + \ifx\@currsize\LARGE 7\else + \ifx\@currsize\scriptsize 1\else + \ifx\@currsize\tiny 0\else + \ifx\@currsize\huge 8\else + \ifx\@currsize\Huge 9\else + 4\rs@unknown@warning % unknown state: |\normalsize| as starting point + \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi + \advance\@tempcnta#1\relax + \ifnum\@tempcnta<\z@ \rs@size@warning{small}{\string\tiny}\@tempcnta\z@ \fi + \@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 + \rs@size@warning{large}{\string\Huge}\Huge +\fi\fi}% end of |\relsize|. + +\providecommand*\rs@size@warning[2]{\PackageWarning{gmutils (relsize)}{% + Size requested is too #1.\MessageBreak Using #2 instead}% +}% + +\providecommand*\rs@unknown@warning{\PackageWarning{gmutils (relsize)}{Current font size + is unknown! (Why?!?)\MessageBreak Assuming \string\normalsize}} + +\DeclareRobustCommand*\larger[1][\@ne]{\relsize{+#1}} +\DeclareRobustCommand*\smaller[1][\@ne]{\relsize{-#1}} +\DeclareRobustCommand*\textlarger[2][\@ne]{{\relsize{+#1}#2}} +\DeclareRobustCommand*\textsmaller[2][\@ne]{{\relsize{-#1}#2}} +\protected\def\largerr{\relsize{+2}} +\protected\def\smallerr{\relsize{-2}} + + +\endinput +%% +%% End of file `gmrelsize.sty'. diff --git a/macros/latex/contrib/gmutils/gmtypos.sty b/macros/latex/contrib/gmutils/gmtypos.sty new file mode 100644 index 0000000000..65f6516e9c --- /dev/null +++ b/macros/latex/contrib/gmutils/gmtypos.sty @@ -0,0 +1,2099 @@ +%% +%% \iffalse ^^A we skip the debug setting +\IfFileExists{\string~/bin/gen_and_xela}{\errorcontextlines=1000 }{} +%% \fi +%% ^^A $Id: TheUltimateMaster.gmd,v 0.352 2011/10/12 15:19:42 natror Exp natror $ +%% This is file “gmtypos.sty” generated with the DocStrip utility. +%% +%% +%% The original source files were: +%% +%% gmutils/gmutils.gmd (with options: `typos') +%% +%% +%% Copyright © +%% by Grzegorz ‘Natror’ Murzynowski +%% natror (at) gmail (dot) com +%% +%% This program is subject to the LaTeX Project Public License. +%% See http://www.ctan.org/tex-archive/help/Catalogue/licenses.lppl.html +%% for the details of that license. +%% +%% LPPL status: "author-maintained". +%% +%% +%% +%% For documentation please refer to the file(s) +%% gmutils.{gmd,pdf}. +%% +%% +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{gmtypos} + [2011/10/12 v0.996 a collection of macros, mostly typographical (GM)] + + +%% +%% +%% ^^A\typeout{\unexpanded{#4}}%% + +\RequirePackage{gmcommand, gmnotonlypream} + +\unless\ifcsname ifgmu@quiet\endcsname + \@xa\newif\csname ifgmu@quiet\endcsname +\fi + +\DeclareOption{quiet}{\gmu@quiettrue} + +\ProcessOptions + +\AtBeginDocument{% + \@ifpackageloaded{fontspec}{% + \pdef\udigits{% + \addfontfeature{Numbers=Uppercase}}% + }{% + \emptify\udigits}% +} + + +\def\Xedekfracc{\gmu@ifstar\gmu@xedekfraccstar\gmu@xedekfraccplain} + % (plain) The starless version turns the font feature |frac| on. + % + % (\*) But nor my modification of Minion Pro neither \TeX\ Gyre + % Pagella doesn't feature the + % |frac| font feature properly so, with the starred version of the + % declaration we use the characters from the font where available + % (see the |\@namedef|s below) and the |numr| and |dnom| features + % with the fractional slash otherwise (via |\gmu@dekfracc|). + % + % (\*\*) But Latin Modern Sans Serif Quotation doesn't support the + % numerator and denominator positions so we provide the double + % star version for it, which takes the char from font if it exist + % and typesets with lowers and kerns otherwise. + +\def\gmu@xedekfraccstar{% + \def\gmu@xefraccdef##1##2{% + \iffontchar\font ##2 + \@namedef{gmu@xefracc##1}{\char##2 }% + \else + \n@melet{gmu@xefracc##1}{relax}% + \fi}% + % + \def\gmu@dekfracc##1/##2{% + {\addfontfeature{VerticalPosition=Numerator}##1}\gmu@numeratorkern + \char"2044 \gmu@denominatorkern + {\addfontfeature{VerticalPosition=Denominator}##2}}% + % + % We define the fractional macros. Since Adobe Minion Pro doesn't + % contain $\frac n5$ nor $\frac n6$, we don't provide them here. + \gmu@xefraccdef{1/4}{"BC}% + \gmu@xefraccdef{1/2}{"BD}% + \gmu@xefraccdef{3/4}{"BE}% + \gmu@xefraccdef{1/3}{"2153}% + \gmu@xefraccdef{2/3}{"2154}% + \gmu@xefraccdef{1/5}{"2155}% + \gmu@xefraccdef{2/5}{"2156}% + \gmu@xefraccdef{3/5}{"2157}% + \gmu@xefraccdef{4/5}{"2158}% + \gmu@xefraccdef{1/6}{"2159}% + \gmu@xefraccdef{5/6}{"215A}% + \gmu@xefraccdef{1/8}{"215B}% + \gmu@xefraccdef{3/8}{"215C}% + \gmu@xefraccdef{5/8}{"215D}% + \gmu@xefraccdef{7/8}{"215E}% + \pdef\dekfracc@args##1/##2{% + \gmu@ifundefined{gmu@xefracc\detokenize{##1/##2}}{% + \gmu@dekfracc{##1}/{##2}}{% + \csname gmu@xefracc\detokenize{##1/##2}\endcsname}% + \if@gmu@mmhbox\egroup\fi + }% of |\dekfracc@args|. + \gmu@ifstar{\let\gmu@dekfracc\gmu@dekfraccsimple}{}% + } + +\def\gmu@xedekfraccplain{% `else' of the main |\gmu@ifstar| + \pdef\dekfracc@args##1/##2{% + \ifmmode\hbox\fi{% + \addfontfeature{Fractions=On}% + ##1/##2}% + \if@gmu@mmhbox\egroup\fi + }% of |\dekfracc@args| + } + +\newif\if@gmu@mmhbox% we'll use this switch for |\dekfracc| and also + +\pdef\dekfracc{% \changes{v0.94}{2008/09/14}{made to work also in math + % mode, even with math-active digits} + \ifmmode\hbox\bgroup\@gmu@mmhboxtrue\fi + \dekfracc@args} + +\def\gmu@numeratorkern{\kern-.055em\relax} +\def\gmu@denominatorkern{\kern-.05em\relax} + + + +\pdef\textsuperscript@@#1{% + \@textsuperscript{\selectfont#1}}% +\def\@textsuperscript#1{% + {\m@th\ensuremath{^{\mbox{\fontsize\sf@size\z@#1}}}}} + +\let\textsuperscript@@\textsuperscript + +\def\GMtextsuperscript{% + \@ifXeTeX{% + \DeclareCommand\textsuperscript{sm}{% + \gmuIfValueTF{##1}{\textsuperscript@@{##2}}% + {% + \begingroup + \addfontfeature{VerticalPosition=Numerator}##2% + \endgroup}}% + }{\truetextsuperscript}} + +\def\truetextsuperscript{% + \let\textsuperscript\textsuperscript@@ +} + + + +\def\gmu@getfontstring{% + \xdef\gmu@fontstring{% + \gmu@fontstring@}} + +\def\gmu@fontstring@{% + \@xa\@xa\@xa\gmu@fontstring@@\@xa\meaning\the\font\@nil} + +\def\gmu@fontstring@@#1"#2"#3\@nil{"#2"} + +\def\gmu@getfontscale#1Scale#2=#3,{% + \ifx\gmu@getfontscale#3\else + \def\gmu@tempa{MatchLowercase}% + \def\gmu@tempb{#3}% + \ifx\gmu@tempa\gmu@tempb + \gmu@calc@scale{5}% + \@xa\@firstoftwo + \else + \def\gmu@tempa{MatchUppercase}% + \ifx\gmu@tempa\gmu@tempb + \gmu@calc@scale{8}% + \afterfifi\@firstoftwo + \else\afterfifi\@secondoftwo + \fi + \fi + {\xdef\gmu@fontscalebr{[\gmu@fontscale] }}% + {\xdef\gmu@fontscalebr{[#3] }}% + \afterfi\gmu@getfontscale + \fi +} + +\def\gmu@getfontdata#1{% + \global\emptify\gmu@fontscalebr + \begingroup + #1% + \@xa\@xa\@xa\gmu@getfontscale + \csname zf@family@options\f@family\endcsname + ,Scale=\gmu@getfontscale,% + \gmu@getfontstring + \xdef\gmu@theskewchar{\the\skewchar\font}% + \endgroup} + +\def\gmu@stripchar#1"{"} + +\DeclareCommand\gmath@getfamnum{C{\gmath@fam}}{% + \edef\gmath@famnum{\@xa\gmu@stripchar\meaning#1}% +} + + +\DeclareCommand\gmathFams{o % the name of math version + C{\NoValue} % ‘rescue’ font. Will be accessible via + % \inverb|\symgmathRoman⁄| (math family) and + % \inverb|\gmath@fontt⁄| (font). +}{% + \gmuIfValueT{#1}{% + \DeclareMathVersion{#1}% this sets the defaults so no need to + % define them explicitly + }% of if |#1| given + % + \gmu@getfontdata{\rmfamily\itshape}% + % + \edef\gmu@tempa{% + \gmuIfValueTF{#1}{\@nx\SetSymbolFont{letters}{#1}}% + {\@nx\DeclareSymbolFont{letters}}% + {\encodingdefault}{gmathit\gmuPutIfValue{#1}}{m}{it}% + \gmuIfValueT{#1}{% + \@nx\DeclareSymbolFont{letters#1}% + {\encodingdefault}{gmathit\gmuPutIfValue{#1}}{m}{it}% + }% + \@nx\DeclareFontFamily{\encodingdefault}{gmathit\gmuPutIfValue{#1}}{% + \skewchar\font\gmu@theskewchar\space}% + \@nx\DeclareFontShape{\encodingdefault}{gmathit\gmuPutIfValue{#1}}{m}{it}{% + <-> \gmu@fontscalebr \gmu@fontstring}{}% + \gmuIfValueT{#1}{% + \@nx\SetMathAlphabet\@nx\mathit{#1}{\encodingdefault}{gmathit#1}{m}{it}}% + }\gmu@tempa + % + \gmuIfValueT{#2}{% + \gmu@getfontdata{#2\gmu@ifstored{\upshape}{\storedcsname{upshape}}{\upshape}}% + \edef\gmu@tempa{% + \@nx\DeclareSymbolFont{gmathRoman\gmuPutIfValue{#1}}% + {\encodingdefault}{gmathRm\gmuPutIfValue{#1}}{m}{n}% + \@nx\DeclareFontFamily{\encodingdefault}{gmathRm\gmuPutIfValue{#1}}{% + \skewchar\font\gmu@theskewchar\space}% + \@nx\DeclareFontShape{\encodingdefault}{gmathRm\gmuPutIfValue{#1}}{m}{n}{% + <-> \gmu@fontscalebr \gmu@fontstring}{}% + }\gmu@tempa + \@xa\font\csname gmath@fontt\gmuPutIfValue{#1}\endcsname + =\gmu@fontstring\relax + % \stanza + \gmu@getfontdata{#2\gmu@ifstored{\itshape}{\storedcsname{itshape}}{\itshape}}% + \edef\gmu@tempa{% + \@nx\DeclareSymbolFont{gmathItalic\gmuPutIfValue{#1}}% + {\encodingdefault}{gmathIt\gmuPutIfValue{#1}}{m}{n}% + \@nx\DeclareFontFamily{\encodingdefault}{gmathIt\gmuPutIfValue{#1}}{% + \skewchar\font\gmu@theskewchar\space}% + \@nx\DeclareFontShape{\encodingdefault}{gmathIt\gmuPutIfValue{#1}}{m}{n}{% + <-> \gmu@fontscalebr \gmu@fontstring}{}% + }\gmu@tempa + }% of if |#2| given + % \stanza + \gmu@getfontdata{\rmfamily\upshape}% + \edef\gmu@tempa{% + \gmuIfValueTF{#1}{\@nx\SetSymbolFont{gmathroman}{#1}}% + {\@nx\DeclareSymbolFont{gmathroman}}% + {\encodingdefault}{gmathrm\gmuPutIfValue{#1}}{m}{n}% + \@nx\DeclareFontFamily{\encodingdefault}{gmathrm\gmuPutIfValue{#1}}{% + \skewchar\font\gmu@theskewchar\space}% + \@nx\DeclareFontShape{\encodingdefault}{gmathrm\gmuPutIfValue{#1}}{m}{n}{% + <-> \gmu@fontscalebr \gmu@fontstring}{}% + \gmuIfValueT{#1}{% + \@nx\SetMathAlphabet\@nx\mathrm{#1}{\encodingdefault}{gmathrm#1}{m}{n}}% + }\gmu@tempa + \@xa\font\csname gmath@font\gmuPutIfValue{#1}\endcsname + =\gmu@fontstring\relax + \gmathfamshook +} + +\emptify\gmathfamshook + +\DeclareCommand\gmathbase{oC{\NoValue}}{% + \gmathFams[#1](#2)% + \DeclareCommand\gmath@do{% + m % (1) the character or \CS\ to be declared, + o % (2) the Unicode to be assigned, + m % (3) math type (\CS like \cs{mathord} etc.) + C{\gmath@fam} % font family + }{%\ + % + \gmath@getfamnum(##4)% + \gmuIfValueTF{##2}{% + \edef\gmu@tempa{% + = \mathchar@type##3\space + \gmath@famnum\space + "##2\relax}% + \if\relax\@nx##1% + \gmu@ifstored{##1}{}{\Store@Macro##1}% + \edef\gmu@tempa{% + \XeTeXmathchardef \@nx##1\gmu@tempa}% + \else + \edef\gmu@tempa{% + \XeTeXmathcode `##1 \gmu@tempa} + \fi% + }% + {% no value of |##2| + \edef\gmu@tempa{% + \XeTeXmathcode `##1 = + \mathchar@type##3\space + \gmath@famnum\space + `##1\relax}% + }% + \gmu@tempa + }% of \incs{gmath@do} + % + \DeclareCommand\gmath@doif{% + m % (1) the Unicode hex of char enquired, + m % (2) the char or \CS\ to be declared, + m % (3) math type \CS (\cs{mathord} etc.), + o % (4) second-choice Unicode (taken if first-choice is absent), + o % (5) third-choice Unicode (as above if second-choice is absent from font). + B{\gmath@fam} % (6) never used in this package. Why? + C{\NoValue} + }{% + \gmu@storeifnotyet{##2}% + \@xa\let\@xa\gmath@ft\csname + gmath@font% + \ifx\gmath@fam##6\else t\fi + \gmath@version + \endcsname + \iffontchar\gmath@ft"##1 \gmath@do##2[##1]##3(##6)% + \else + \gmuIfValueTF{##4}{% + \iffontchar\gmath@ft"##4 \gmath@do##2[##4]##3(##6)% + \else + \gmuIfValueTF{##5}{% + \iffontchar\gmath@ft"##5 \gmath@do##2[##5]##3(##6)% + \else + \gmath@restore{##1}{##2}{##3}{##4}{##5}{##7}% + \fi}% + {\gmath@restore{##1}{##2}{##3}{##4}{##5}{##7}}% + \fi}% + {\gmath@restore{##1}{##2}{##3}{##4}{##5}{##7}}% + \fi + }% of |\gmath@doif| + % In the command above we try to define math char or a~\CS in the + % family given as |##6|. If there're no respective chars, we try + % the same with the family given (as a~word) in |##7|. + \def\gmath@restore##1##2##3##4##5##6{% + \gmuIfValueT{##6}% + {\ifcsname ##6\endcsname + \edef\gmu@tempa{% + \unexpanded{\gmath@doif{##1}{##2}{##3}[##4][##5]}% + {\@xanxcs{##6}}\relax + }\gmu@tempa + \@xa\@gobbletwo % if family |##6| is defined, we gobble the + % other branch + \fi + }% + \firstofone + {\if\relax\@nx##2% + \Restore@Macro##2% + \fi + }% + }% + % +\iffalse % doesn't work in a~non-math font. + \DeclareCommand\gmath@delc{mo}{%\ + % \begin{enumargs*} + % \mand the char or \CS\ to be declared, + % \opt the Unicode (if not the same as the char). + % \end{enumargs*} + % + \gmath@getfamnum + \gmuIfValueTF{##2}{% + \edef\gmu@tempa{% + = \gmath@famnum\space "##2\relax}% + \edef\gmu@tempa{% + \XeTeXdelcode `##1 \gmu@tempa} + }% + {% + \edef\gmu@tempa{% + \XeTeXdelcode `##1 = + \gmath@famnum\space + `##1\relax}% + }% + \gmu@tempa + }% of \incs{gmath@delc} + % + \def\gmath@delcif##1##2{%\ + % \begin{enumargs*} + % \mand the Unicode enquired, + % \item the char to be delcode-declared + % \end{enumargs*} + % + \iffontchar\gmath@font"##1 \gmath@delc##2[##1]\fi} +\fi% of iffalse + % + \def\gmath@delimif##1##2##3{%\ + % \begin{enumargs*} + % \item the Unicode enquired, + % \item the \CS\ defined as \cs{XeTeXdelimiter}, + % \item the math type \CS\ (probably \incs{mathopen} or + % \incs{mathclose}). + % \end{enumargs*} + \iffontchar\gmath@font"##1 + \gmath@getfamnum + \protected\edef##2{\@nx\ensuremath{% + \XeTeXdelimiter \mathchar@type##3\space + \gmath@famnum\space "##1\relax}}% + \fi}% of \cs{gmath@delimif}. + % + \pdef\rmopname##1##2##3{% + \mathop {##1\kern \z@ \mathrm{##3}}\csname n##2limits@\endcsname + }% + % + \DeclareCommand\gmu@dogmathbase{oC{\NoValue}}{% + \Restore@Macro\mathchar@type% + % + \gmuIfValueT{##1}{\mathversion{##1}}% + % + \edef\gmath@version{\gmuPutIfValue{##1}}% + % + \@xa\let\@xa\gmath@fam\csname symgmathroman% + \endcsname + \edef\gmath@famm{symgmathRoman\gmath@version}% as you see, this is + % not a~font family (number) but a~macro containing the name: of + % the secondary (‘rescue’) family. + % + \typeout{@@@ gmutils.sty: taking some math chars from the font^^J \gmu@fontstring@}% + \gmath@do+\mathbin + \gmath@doif{2212}-\mathbin[2013](\gmath@famm)% minus sign if present or else en dash + \gmath@do=\mathrel + \gmath@do0\mathord + \gmath@do1\mathord + \gmath@do2\mathord + \gmath@do3\mathord + \gmath@do4\mathord + \gmath@do5\mathord + \gmath@do6\mathord + \gmath@do7\mathord + \gmath@do8\mathord + \gmath@do9\mathord + %% + \gmath@doif{2264}\le\mathrel(\gmath@famm)% + \let\leq\le + \let\leeng\le + \gmath@doif{2265}\ge\mathrel(\gmath@famm)% + \let\geq\ge + \let\geeng\ge + \gmath@doif{2A7D}\xleq\mathrel(\gmath@famm)% + \gmath@doif{2A7E}\xgeq\mathrel(\gmath@famm)% + \@ifpackageloaded{polski}{% + \ifdefined\xleq + \gmu@storeifnotyet\leq + \let\leq=\xleq + \let\le=\leq + \fi + \ifdefined\xgeq + \gmu@storeifnotyet\geq + \let\geq=\xgeq + \let\ge=\geq + \fi}{}% + % + \gmath@do.\mathpunct + \gmath@do,\mathpunct + \gmath@do;\mathpunct + \gmath@do…\mathpunct + \gmath@do(\mathopen + \gmath@do)\mathclose + \gmath@do[\mathopen + \gmath@do]\mathclose + % + \gmath@doif{00D7}×\mathbin (\gmath@famm)% + \gmath@do:\mathrel + \gmath@doif{00B7}·\mathbin(\gmath@famm)% + \gmath@doif{22C6}*\mathbin(\gmath@famm)% % low star + \gmath@doif{2300}\varnothing\mathord(\gmath@famm)% + \gmath@doif{221E}\infty\mathord(\gmath@famm)% + \gmath@doif{2248}\approx\mathrel(\gmath@famm)% + \gmath@doif{2260}\neq\mathrel(\gmath@famm)% + \let\ne\neq + \gmath@doif{00AC}\neg\mathbin(\gmath@famm)% + \gmath@doif{00AC}\nego\mathord(\gmath@famm)% + \gmath@do/\mathop + \gmath@do<\mathrel + \gmath@do>\mathrel + \gmath@doif{2329}\langle\mathopen(\gmath@famm)% + \gmath@doif{232A}\rangle\mathclose(\gmath@famm)% + \gmath@doif{2202}\partial\mathord(\gmath@famm)% + \gmath@doif{00B1}\pm\mathbin(\gmath@famm)% + \gmath@doif{007E}\sim\mathrel(\gmath@famm)% + \gmath@doif{2190}\leftarrow\mathrel(\gmath@famm)% + \gmath@doif{2192}\rightarrow\mathrel(\gmath@famm)% + \gmath@doif{2194}\leftrightarrow\mathrel(\gmath@famm)%% if not present, + % \incs{gmathfurther} will take care + % of it if left and right arrows are present. + \gmath@doif{2191}\uparrow\mathrel(\gmath@famm)%% it should be a~delimiter + % (declared with \incs{gmath@delimif}) % but in a~non-math + % font the delimiters don't work (2008/11/19) and I~don't think + % I'll ever need up- and down- arrows as delimiters. + \gmath@doif{2193}\downarrow\mathrel(\gmath@famm)% + % + \gmath@doif{2208}\in\mathrel[03F5][0454](\gmath@famm)%% + % As a~fan of modal logics I~allow redefinition of \incs{lozenge} + % and \incs{square} iff both are in the font. I~don't accept + % the ‘ballot box’ U+2610. + \if\iffontchar\gmath@font"25CA 0\else 1\fi + \iffontchar\gmath@font"25FB 0\else\iffontchar\gmath@font"25A1 0\else 2\fi\fi + \gmath@do\lozenge[25CA]\mathord + \gmath@doif{25FB}\square\mathord[25A1](\gmath@famm)%% ‘medium white square (modal + % operator)’ of just ‘white square’. + \fi + \gmath@doif{EB08}\bigcircle\mathbin(\gmath@famm)% + \gmath@doif{2227}\wedge\mathbin(\gmath@famm)% + \gmath@doif{2228}\vee\mathbin(\gmath@famm)% + % + \gmath@doif{0393}\Gamma\mathalpha(\gmath@famm)% + \gmath@doif{0394}\Delta\mathalpha(\gmath@famm)% + \gmath@doif{0398}\Theta\mathalpha(\gmath@famm)% + \gmath@doif{039B}\Lambda\mathalpha(\gmath@famm)% + \gmath@doif{039E}\Xi\mathalpha(\gmath@famm)% + \gmath@doif{03A3}\Sigma\mathalpha(\gmath@famm)% + \gmath@doif{03A5}\Upsilon\mathalpha(\gmath@famm)% + \gmath@doif{03А6}\Phi\mathalpha(\gmath@famm)% + \gmath@doif{03A8}\Psi\mathalpha(\gmath@famm)% + \gmath@doif{03A9}\Omega\mathalpha(\gmath@famm)% + % + \@xa\let\@xa\gmath@fam\csname symletters\gmath@version% + \endcsname + \edef\gmath@famm{symgmathItalic\gmath@version}% + % + \gmath@doif{03B1}\alpha\mathalpha(\gmath@famm)% + \gmath@doif{03B2}\beta\mathalpha(\gmath@famm)% + \gmath@doif{03B3}\gamma\mathalpha(\gmath@famm)% + \gmath@doif{03B4}\delta\mathalpha(\gmath@famm)% + \gmath@doif{03F5}\epsilon\mathalpha(\gmath@famm)% + \gmath@doif{03B5}\varepsilon\mathalpha(\gmath@famm)% + \gmath@doif{03B6}\zeta\mathalpha(\gmath@famm)% + \gmath@doif{03B7}\eta\mathalpha(\gmath@famm)% + \gmath@doif{03B8}\theta\mathalpha(\gmath@famm)% + \gmath@doif{03D1}\vartheta\mathalpha(\gmath@famm)% + \gmath@doif{03B9}\iota\mathalpha(\gmath@famm)% + \gmath@doif{03BA}\kappa\mathalpha(\gmath@famm)% + \gmath@doif{03BB}\lambda\mathalpha(\gmath@famm)% + \gmath@doif{03BC}\mu\mathalpha(\gmath@famm)% + \gmath@doif{03BD}\nu\mathalpha(\gmath@famm)% + \gmath@doif{03BE}\xi\mathalpha(\gmath@famm)% + \gmath@doif{03C0}\pi\mathalpha(\gmath@famm)% + \gmath@doif{03A0}\Pi\mathalpha(\gmath@famm)% + \gmath@doif{03C1}\rho\mathalpha(\gmath@famm)% + \gmath@doif{03C3}\sigma\mathalpha(\gmath@famm)% + \gmath@doif{03DA}\varsigma\mathalpha(\gmath@famm)%% 03C2? + \gmath@doif{03C4}\tau\mathalpha(\gmath@famm)% + \gmath@doif{03C5}\upsilon\mathalpha(\gmath@famm)% + \gmath@doif{03D5}\phi\mathalpha(\gmath@famm)% + \gmath@doif{03C7}\chi\mathalpha(\gmath@famm)% + \gmath@doif{03C8}\psi\mathalpha(\gmath@famm)% + \gmath@doif{03C9}\omega\mathalpha(\gmath@famm)% + % + \if 1 1% + \iffontchar\gmath@font"221A + \fontdimen61\gmath@font=1pt + \edef\sqrtsign{% + \XeTeXradical \@xa\gmu@stripchar\meaning\symgmathroman\space "221A\relax}% + \fi + \fi% of if 1 1. + \def\max{\rmopname \relax m{max}}% + \def\min{\rmopname \relax m{min}}% + \def\lim{\rmopname \relax m{lim}}% + \def\sin{\rmopname \relax o{sin}}% + \def\cos{\rmopname \relax o{cos}}% + \def\tg{\rmopname \relax o{tg}}% + \def\ctg{\rmopname \relax o{ctg}}% + \def\tan{\rmopname \relax o{tan}}% + \def\ctan{\rmopname \relax o{ctan}}% + }% of |\gmu@dogmathbase| + \AtBeginDocument{\gmu@dogmathbase[#1](#2)% + \let\gmathbase\gmu@dogmathbase + }% of atbd + \not@onlypreamble\gmathbase +}% of \cs{gmathbase} + + +\@onlypreamble\gmathbase + +\pdef\gmathfurther{% \HideDef + % \changes{v0.94}{2008/10/4}{removed definition of + % \cs{}\s and \cs{}\s} + % \changes{v0.96}{2008/11/7}{Greek letters completed. Wrapped with + % \cs{addtotoks} to allow using in any order with \cs{garamath} + % and others} + % + \def\do##1##2##3{\gmu@storeifnotyet##1% + \def##1{% + \mathop{\mathchoice{\hbox{% + \rm + \edef\gma@tempa{\the\fontdimen8\font}% + \larger[3]% + \lower\dimexpr(\fontdimen8\font-\gma@tempa)/2 % + \hbox{##2}}}{\hbox{% + \rm + \edef\gma@tempa{\the\fontdimen8\font}% + \larger[2]% + \lower\dimexpr(\fontdimen8\font-\gma@tempa)/2 % + \hbox{##2}}}% + {\mathrm{##2}}{\mathrm{##2}}}##3}}% + \iffontchar\gmath@font"2211 \do\sum{\char"2211}{}\fi% + \do\forall{\gma@quantifierhook \rotatebox[origin=c]{180}{A}% + \gmu@forallkerning + }{\nolimits}% + \def\gmu@forallkerning{\setbox0=\hbox{A}\setbox2=\hbox{\scriptsize x}% + \kern\dimexpr\ht2/3*2 -\wd0/2\relax}% to be able to redefine it + % when the big quantifier is Bauhaus-like. + \do\exists{\rotatebox[origin=c]{180}{\gma@quantifierhook E}}\nolimits% + % + \def\do##1##2##3{\gmu@storeifnotyet##1% + \def##1{##3{% + \mathchoice{\hbox{\rm##2}}{\hbox{\rm##2}}% + {\hbox{\rm\scriptsize##2}}{\hbox{\rm\tiny##2}}}}}% + % + \unless\iffontchar\gmath@font"2227 + \do\vee{\rotatebox[origin=c]{90}{<}}\mathbin% + \fi + \unless\iffontchar\gmath@font"2228 + \do\wedge{\rotatebox[origin=c]{-90}{<}}\mathbin + \fi + % + \unless\iffontchar\gmath@font"2194 + \if\iffontchar\gmath@font"2190 0\else1\fi + \iffontchar\gmath@font"2192 0\else2\fi + \do\leftrightarrow{\char"2190\kern-0,1em \char"2192}\mathrel + \fi\fi + % + \def\do##1##2##3{\gmu@storeifnotyet##1% + \def##1####1{##2{\hbox{% + \rm + \setbox0=\hbox{####1}% + \edef\gma@tempa{\the\ht0}% + \edef\gma@tempb{\the\dp0}% + ##3% + \setbox0=\hbox{####1}% + \lower\dimexpr(\ht0 + \dp0)/2-\dp0 -((\gma@tempa+\gma@tempb)/2-\gma@tempb) % + \box0}}}}% + \do\bigl\mathopen\larger + \do\bigr\mathclose\larger + \do\Bigl\mathopen\largerr + \do\Bigr\mathclose\largerr + \do\biggl\mathopen{\larger[3]}% + \do\biggr\mathclose{\larger[3]}% + \do\Biggl\mathopen{\larger[4]}% + \do\Biggr\mathclose{\larger[4]}% + % + % + \addtotoks\everymath{% \changes{v0.96}{2008/11/20}{the + % \cs{everymath}'s left brace moved here: + % earlier all the stuff was put into \cs{everymath}} + \def\do##1##2{\gmu@storeifnotyet##1% + \def##1{\ifmmode##2{\mathchoice + {\hbox{\rm\char`##1}}{\hbox{\rm\char`##1}}% + {\hbox{\rm\scriptsize\char`##1}}{\hbox{\rm\tiny\char`##1}}}% + \else\char`##1\fi}}% + \do\{\mathopen + \do\}\mathclose + % + \def\={\mathbin{=}}% + \def\neqb{\mathbin{\neq}}% + \let\neb\neqb + \def\do##1{\gmu@storeifnotyet##1% + \edef\gma@tempa{% + \def\@xanxcs{\@xa\gobble\string##1r}{% + \@nx\mathrel{\@nx##1}}}% + \gma@tempa}% + \do\vee \do\wedge \do\neg + \def\fakern{\mkern-3mu}% + \thickmuskip=8mu plus 4mu\relax + % + \gma@gmathhook + }% of |\everymath|. + \everydisplay\everymath + \ifdefined\Url + \ampulexdef\Url{\let\do}\@makeother + {\everymath{}\let\do\@makeother}% I~don't know why but the + % \pk{url} package's \incs{url} typesets the argument inside + % a~math which caused digits not to be typewriter but Roman and + % lowercase. + \fi% of |\ifdefined\Url|. +}% of |\def\gmathfurther|. \ResumeDef + +\Store@Macro\mathchar@type + +\DeclareCommand\gmath{oC{\NoValue}}{% + \gmathbase[#1](#2)% + \gmathfurther + \gmuIfValueT{#1}{\csname gmathhook#1\endcsname}% this allows adding + % version-specific stuff (I~first used this for Fell fonts rescued + % with Garamond Premier) +} + +\pdef\gmathscripts{% \changes{v0.96}{2008/11/11}{added} + \addtotoks\everymath{\catcode`\^=7\relax \catcode`\_=8\relax }% + \everydisplay\everymath} + +\pdef\gmathcats{% + \addtotoks\everymath{\gmu@septify}% + \everydisplay\everymath} + +\emptify\gma@quantifierhook +\def\quantifierhook#1{% + \def\gma@quantifierhook{#1}} + +\emptify\gma@gmathhook +\def\gmathhook#1{\addtomacro\gma@gmathhook{#1}} + +\def\gma@dollar$#1${{\gmath$#1$}}% +\def\gma@bare#1{\gma@dollar$#1$}% +\def\gma@checkbracket{\@ifnextchar\[%^^A\] + \gma@bracket\gma@bare} +\def\gma@bracket\[#1\]{{\gmath\[#1\]}\@ifnextchar\par{}{\noindent}} +\def\gma{\@ifnextchar$%^^A $ + \gma@dollar\gma@checkbracket} + + %^^B trial composition +\def\bgcolor{\color{white}} + +\DeclareCommand\garamath{% + O{\rm}% the font command +}{% + % Before 2009/10/19 all the stuff was added to |\everymath| which + % didn't work. + \quantifierhook{\addfontfeature{OpticalSize=800}}% + % + \def\gma@arrowdash{{% + \setbox0=\hbox{\char"2192}\copy0\kern-0,6\wd0 + \bgcolor\rule[-\dp0]{0,6\wd0}{\dimexpr1,07\ht0+\dp0}\kern-0,6\wd0}}% + % + \def\gma@gmathhook{% + \def\do####1####2####3{\gmu@storeifnotyet####1% + \def####1{####3{% + \mathchoice{\hbox{#1####2}}{\hbox{#1####2}}% + {\hbox{#1\scriptsize####2}}{\hbox{#1\tiny####2}}}}}% + \do\mapsto{\rule[0,4ex]{0,1ex}{0,4ex}\kern-0,05em% + \gma@arrowdash\kern-0,05em\char"2192}\mathrel + \do\cup{\scshape u}\mathbin + \do\varnothing{\setbox0=\hbox{\gma@quantifierhook\addfontfeature{Scale=1.272727}0}% + \setbox2=\hbox{\char"2044}% + \copy0 \kern-0,5\wd0 \kern-0,5\wd2 \lower0,125\wd0 \copy2 + \kern0,5\wd0\kern-0,5\wd2}{}% of |\varnothing| + \do\leftarrow{\char"2190\kern-0,05em\gma@arrowdash}\mathrel + \do\shortleftarrow{\char"2190}\mathrel + \do\rightarrow{\gma@arrowdash\kern-0,05em\char"2192}\mathrel + \do\shortrightarrow{\char"2192\relax}\mathrel + \do\in{\gma@quantifierhook\char"0454}\mathbin + \do\prec{\gma@quantifierhook + \rotatebox[origin=c]{-90}{% + \glyphname{u03A5.a}}}\mathrel % added 2009/9/11 + }% of |\gma@gmathhook| +}% of |\garamath|. + + + +\def\gmu@tempa{\kern-0,08em\penalty10000\hskip0sp\relax + s\penalty10000\hskip0sp\relax} + +\protected\edef\Vs{V\gmu@tempa} + +\protected\edef\Ws{W\gmu@tempa} + +\pdef\Wz{W\kern-0,05em\penalty10000\hskip0sp\relax z} + + +\pdef\leftslanting@{% + \def\litdimen{\strip@pt\fontdimen1\font ex}% + \def\litcorrection{% + \ifhmode\null\nobreak\hskip\litdimen\relax\fi}% + \def\litkern{% note it's to be used inside the left slanted font, + % unlike \incmd\litcorrection, intended to be used \emph{before} + % switching to left slant/italic. + \leavevmode\null + \kern-\litdimen\relax}% + \def\dilitkern{\kern\litdimen\litkern}% + % \stanza + \pdef\litshape{% \changes{v0.93}{2008/08/22}{copied here from + % E.~Szarzyński's \ty{The Letters}} + \litcorrection + \itshape + \@tempdima=-2\fontdimen1\font + \advance\leftskip by\strip@pt\fontdimen1\font ex % to assure at + % least the lowercase letters not to overshoot to the (left) + % margin. Note this has any effect only if there is a~\incs{par} in + % the scope. + \litcorrection + \edef\gmu@tempa{% + \@nx\addfontfeature{FakeSlant=\strip@pt\@tempdima}}%^^B + % \ilrr when not \incs{edef}ed, it caused an error, which is + % perfectly understandable. + \gmu@tempa}% + % + % + \pdef\textlit##1{% \changes{v0.93}{2008/08/22}{added} + {\litshape##1}}% + % + \pdef\lit{\rm\litshape}% + % + % + \pdef\lsl{{% + \litcorrection + \it + % \changes{v0.93}{2008/08/22}{copied here from E.~Szarzyński's \ty{The + % Letters}} + \@tempdima=-\fontdimen1\font + \litcorrection + \xdef\gmu@tempa{% + \@nx\addfontfeature{RawFeature={slant=\strip@pt\@tempdima}}}}% + \rm % Note in this declaration we left-slant the basic Roman font + % not the itshape of the current family. + \gmu@tempa}% + % + % Now we can redefine \cs{em} and \cs{emph} to use left Italic for + % nested emphasis. In Polish typesetting there is bold in nested + % emphasis as I~have heard but we don't like bold since it perturbs + % homogeneous greyness of a~page. So we introduce a~three-cycle + % instead of two-: Italic, left Italic, upright. + % + \pdef\em{%\changes{v0.93}{2008/08/22}{added} + \ifdim\fontdimen1\font=\z@ \itshape + \else + \ifdim\fontdimen1\font>\z@ \litshape + \else \upshape + \fi + \fi}% + % + % + \pdef\emph##1{% \changes{v0.93}{2008/08/22}{added} + {\em##1}}% +}% of \cs{leftslanting@}. + +\pdef\leftslanting{\AtBeginDocument\leftslanting@} + +\AtBeginDocument{\let\leftslanting\leftslanting@} + + +\def\romorzero#1{% + \ifnum#1=0 zero\else\romannumeral#1 \fi} + +\DeclareCommand\fakeonum{% + o % fake bold for the digit »2« (for which emboldening improves + % look), + >Pm % the text to fake old-style numbers in. +}{%\ + % I~tried to use this command as a~declaration but active digits are + % very uncomfortable, e.g.\ you can't define macros with arguments. + % \chgs{2008/12/04 v0.98 added} + \gmu@if@onum{#2}{% + \begingroup + \edef\gmu@tempa{#2}% + \makeatletter% + \gmuIfValueT{#1}{% + \prependtomacro\fake@onum@ii{% + \begingroup\addfontfeature{FakeBold=#1}}% + \addtomacro\fake@onum@ii\endgroup + }% + \endlinechar\m@ne % to suppress the line end added by + % |\scantokens|, especially in active |^^M|'s scopes. + \gmu@dofakeonum + \@xa\scantokens\@xa{\gmu@tempa}% + \endgroup + }% of |\gmu@ifonum| ‘else’. +}% of |\fakeonum|. + +\def\gmu@dofakeonum{% + \def\do##1{% + \catcode`##1\active + \scantokens{% + \@xa\let\@xa##1% + \csname fake@onum@\@xa\romorzero\string##1\endcsname\empty}}% + \do0\do1\do2\do3\do4\do5\do6\do7\do8\do9% +} + +\def\do#1#2{% + \@namedef{fake@onum@\romorzero#1}{#2}} + +\def\gmu@tempa#1{% + \do#1{\leavevmode + \gmu@calculateslant{#1}% uses \incs{gmu@tempa} and + % \incs{gmu@tempb}, therefore goes first. And defines \incs{gmu@tempd}. + \gmu@measurewd{#1}% the width of char |#1| is in \incs{gmu@tempa} + % without kerning and in \incs{gmu@tempb} with kerning. + % + \edef\gmu@tempc{\the\fontcharht\font`#1}% + \hbox to \gmu@tempb {% + \hss\resizebox{\gmu@tempa}% + {\dimexpr\fontdimen5\font+\gmu@tempc-\fontdimen8\font}% + {\gmu@tempd#1}\hss}}} + +\gmu@tempa0 % |\fake@onum@zero| +\gmu@tempa1 % |\fake@onum@i| +\gmu@tempa2 % |\fake@onum@ii| + +\def\gmu@tempa#1{% + \do#1{\leavevmode + \gmu@measurewd{#1}% + \lower + \dimexpr\fontdimen8\font-\fontdimen5\font\relax + \hbox to \gmu@tempb {\hss#1\hss}}% +} + +\gmu@tempa3 % |\fake@onum@iii| +\gmu@tempa4 % |\fake@onum@iv| +\gmu@tempa5 % |\fake@onum@v| +\gmu@tempa7 % |\fake@onum@vii| +\gmu@tempa9 % |\fake@onum@ix| + +\def\gmu@tempa#1{% to preserve pseudo-kerning in digits sequences. + \do#1{\leavevmode + \gmu@measurewd#1% + \hbox to \gmu@tempb {\hss#1\hss}}} + +\gmu@tempa6 % |\fake@onum@vi| +\gmu@tempa8 % |\fake@onum@viii| + +\protected\def\gmu@if@onum{% + \edef\gmu@tempa{\@xa\meaning\the\font}% + \@xa\@ifinmeaning\detokenize{+onum}\of\gmu@tempa +} + +\pdef\gmu@getslant{% we define |\gmu@tempa| to the (fake) slant of current font. + \edef\gmu@tempa{\@xa\meaning\the\font\detokenize{slant=0,}}% + \edef\gmu@tempb{% + \def\@nx\gmu@tempb####1% + \detokenize{slant=}% + ####2,####3}% + \gmu@tempb\@nil{##2}% + \edef\gmu@tempa{\@xa\gmu@tempb\gmu@tempa\@nil pt}% +} + +\def\gmu@calculateslant#1{% + \gmu@getslant + \edef\gmu@tempa{\the\numexpr\dimexpr\fontdimen1\font + \gmu@tempa}%\ + % \incs{gmu@tempa} bears the number of scaled points of total slant + % (\inverb|\fontdimen1\font|${}+$\inverb|slant=…| if present) per 1pt + % of \inhash1.\ilrr + \edef\gmu@tempa{\the\numexpr \gmu@tempa * + \numexpr\fontdimen5\font\relax/\numexpr\fontcharht\font`#1 + \relax}%\ + % we scale the total slant of \inverb|#1| by the ratio of original + % and scaled height of \inverb|#1|. + \edef\gmu@tempd{% + \the\dimexpr \gmu@tempa sp - \fontdimen1\font}%\ + % and we subtract slant-fontdimen from the scaled total slant. + \ifdim\gmu@tempd=\z@ \emptify\gmu@tempd + \else\edef\gmu@tempd{% + \@nx\addfontfeature{FakeSlant=\strip@pt\dimexpr\gmu@tempd}}% + \fi} + +\DeclareCommand\gmu@cepstnof{O{\gmu@tempa}% a~cs to be |\xdef|ed the + % font specification, + s% not used really, + m% |\fontspec| token or name of feature font (\inverb|Italic|, \inverb|Bold|, + % \inverb|SmallCaps|, \inverb|BoldItalic| ), + O{, Scale=MatchLowercase}% \pk{fontspec} font features (key=val) +} +{% |\gmu@cepstnof|'s body + \def\gmu@cepstnof@resc##1:##2:\@nil{% + \ifx:##2:\else RawFeature={\gmu@maybestripcomma##2,,\@nil} \fi}% + % \stanza + \def\gmu@cepstnof@resd##1/##2/\@nil{% to check whether font name + % contains |/| (which may not be true!) + \ifx&##2&\@xa\@firstoftwo\else\@xa\@secondoftwo\fi}% + % \stanza + \def\gmu@cepstnof@rese##1:##2:\@nil{% to check whether the font name + % contains |:| when it doesn't contain |/|. + \ifx&##2&\@xa\@firstoftwo\else\@xa\@secondoftwo\fi}% + % \stanza + \edef\gmu@cepstnof@resa{% + % now, reserved B parses the font name and features. It uses an + % auxiliary reserved C because after |/| may be or may not be + % features specification. + \@xa\@xa\@xa\gmu@cepstnof@resd\@xa\meaning\the\font//\@nil + {% font name doesn't contain a~slash + \@xa\@xa\@xa\gmu@cepstnof@rese\@xa\meaning\the\font::\@nil + {% nor does it contain a~colon + \def\@nx\gmu@cepstnof@resb\detokenize{select font + "}####1\detokenize{"}####2\@nx\@nil{% + \ifx\fontspec#3% + \@nx\@nx\@nx\fontspec[\@gobble#4\@empty]{####1}% gobble a~comma + \else + #3Font={####1}, #3Features={\@gobble #4\@empty}% + \fi + }% + }% + {% no slash but there is a~colon + \def\@nx\gmu@cepstnof@resb\detokenize{select font + "}####1:####2\detokenize{"}####3\@nx\@nil{% + \ifx\fontspec#3% + \@nx\@nx\@nx\fontspec[\@nx\gmu@cepstnof@resc####2::\@nx\@nil#4]{####1}% + \else + #3Font={####1}, #3Features={\@nx\gmu@cepstnof@resc####2::\@nx\@nil#4}% + \fi + }% + }% + }% of ‘no slash’ case + {% font name contains a~slash + \def\@nx\gmu@cepstnof@resb\detokenize{select font + "}####1/####2\detokenize{"}####3\@nx\@nil{% + \ifx\fontspec#3% + \@nx\@nx\@nx\fontspec[\@nx\gmu@cepstnof@resc####2::\@nx\@nil#4]{####1}% + \else + #3Font={####1}, #3Features={\@nx\gmu@cepstnof@resc####2::\@nx\@nil#4}% + \fi + }% of |\gmu@cepstnof@resb| + }% of ‘slash present’ case + }\gmu@cepstnof@resa + \xdef#1{\@xa\@xa\@xa\gmu@cepstnof@resb\@xa\meaning\the\font\@nil}% +}% + +\def\gmu@stripcomma#1,{#1} + +\def\gmu@maybestripcomma#1,,#2\@nil{#1} + +\pdef\gmu@setbasefont{\@xa\let\@xa\gmu@basefont\the\font} + +\let\setbasefont\gmu@setbasefont + +\DeclareCommand\gmu@calc@scale{% + O{1}% a~factor, + m% number of the fontdimen + } +{\begingroup + % We ‘descale’ the current font:\nostanza + \gmu@cepstnof\fontspec[, Scale=1]\gmu@tempa + \@xa\let\@xa\gmu@currfont@descaled\the\font + \gmu@basefont + \gmu@cepstnof\fontspec[, Scale=1]\gmu@tempa + % \nostanza now also the base font is descaled. + \xdef\gmu@fontscale{% + \strip@pt + \dimexpr 1pt * + \numexpr\dimexpr#1\fontdimen#2\font\relax\relax / + \numexpr\fontdimen#2\gmu@currfont@descaled\relax + \relax}% + \endgroup} + + +\def\gmu@tilde{% + \leavevmode\lower.8ex\hbox{$\,\widetilde{\mbox{ }}\,$}} +\AtBeginDocument{% to bypass redefinition of |\~| as a~text command + % with various encodings + \pdef\texttilde{% + % \changes{v0.83}{2007/08/22}{postponed to + % \cs{begin\{document\}} to avoid overwriting by a~text command + % and + % made sensible to a~subsequent + % /} % \changes{v0.86}{2007/12/11}{renamed from \cmd\~ + % since the latter is one of \LaTeX's\ accents} + \@ifnextchar/{\gmu@tilde\kern-0,1667em\relax}\gmu@tilde}} + +\foone{\catcode`\^^M\active}% the comment signs here are crucial. +{\def\defobeylines{\catcode`\^^M=13 \def^^M{\par}}} + + +\def\deksmallskip{\vskip\smallskipamount} +\def\undeksmallskip{\vskip-\smallskipamount} +\def\dekmedbigskip{\vskip\glueexpr \medskipamount+\smallskipamount} +\def\dekmedskip{\vskip\medskipamount} +\def\dekbigskip{\vskip\bigskipamount} + +\def\hfillneg{\hskip 0pt plus -1fill\relax} + +\newcommand*{\TODO}[1][]{{% + \sffamily\bfseries\huge TO-DO!\if\relax#1\relax\else\space\fi#1}} +\newcommand*\twocoltoc{% + \RequirePackage{multicol}% + \def\@starttoc##1{% + \begin{multicols}{2}\makeatletter + \NamedInput % changed from |\@input| 2010/8/13. + {\jobname .##1}% + \if@filesw \@xa \newwrite \csname tf@##1\endcsname + \immediate \openout \csname tf@##1\endcsname \jobname .##1\relax + \fi + \@nobreakfalse\end{multicols}% + }% of |\starttoc| +} + +\@onlypreamble\twocoltoc + + +\pdef\equals{\hunskip${}={}$\ignorespaces} +\pdef\eequals{\hunskip${}=={}$\ignorespaces} + +\pdef\·{\hunskip${}·{}$\ignorespaces} + + +\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}} + + +\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}} + +\newcommand*\liturgiques[1][red]{% Requires the \pk{color} package. + \gmu@RPfor{xcolor}\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. + \Store@Macro\*% + \def\*{\czer{\storedcsname{*}}}% + \def\+{\czer{†}}% + \newcommand*\nieczer[1]{\textcolor{black}{##1}}% +} + +\newcommand*\gmu@RPfor[3][]{% \changes{v0.93}{2008/08/30}{renamed from + % \cs{gmu@RPif} and \#3 changed from a~csname to \CS} + \ifx\relax#1\relax\emptify\gmu@resa + \else \def\gmu@resa{[#1]}% + \fi + \@xa\RequirePackage\gmu@resa{#2}} + +\AtBeginDocument{% + \renewcommand*\gmu@RPfor[3][]{% + \unless\ifdefined#3% + \@ifpackageloaded{#2}{}{% + \typeout{^^J! Package `#2' not loaded!!! (\on@line)^^J}}% + \fi}} + +\pprovide\continuum{% + \gmu@RPfor{eufrak}\mathfrak\ensuremath{\mathfrak{c}}} + +\def\iteracro{% + \pdef\acro##1{% + \begingroup + \acropresetting + \gmu@acrospaces##1 \gmu@acrospaces + \endgroup + }% +} + +\emptify\acropresetting + +\iteracro + +\def\gmu@acrospaces#1 #2\gmu@acrospaces{% + \gmu@acroiter#1\gmu@acroiter + \ifx\relax#2\relax\else + \space + \afterfi{\gmu@acrospaces#2\gmu@acrospaces}% when |#2| is nonempty, + % it is ended with a~space. Adding one + % more space in this line resulted in + % an infinite loop, of course. + \fi +} + +\def\gmu@acroiter#1{% + \gmu@notif {x\@xa\@xa} {\@firstofmany#1\@undefined\@nil \gmu@acroiter} + {\gmu@acrokernel{#1}% + % and iterate + \gmu@acroiter + }% of if sentinel or not + {}% +} + +\def\gmu@acrokernel #1{% + \gmu@if {cat} {a\@xanx\@firstofmany#1\@undefined\@nil}% + {\gmu@if {num} {`#1=\uccode`#1\space }% a space to delimit numer + % (without it further macros were + % expanded which in this case are + % |\expandafter\@firstoftwo\else\@secondoftwo| and this made the test didn't work.) + {{\acrocore{#1}}}% + {{#1}}% tu było |\smallerr| + }% + {#1}% +} + +\pdef\acrocore{\smaller % was: |\scshape\lowercase| +} + + +\def\IMHO{\acro{IMHO}\spifletter} +\def\AKA{\acro{AKA}\spifletter} + +\pdef\usc#1{{\addfontfeature{Letters=UppercaseSmallCaps}#1}} + +\def\uscacro{\let\acrocore\usc} + + + +\def\gmu@dekfraccsimple#1/#2{\leavevmode\kern.1em + \raise.7ex\hbox{%^^A \udigits + \gmu@fracfontsetup#1}\gmu@numeratorkern + \dekfraccslash\gmu@denominatorkern + {%^^A\udigits + \gmu@fracfontsetup#2}% + \if@gmu@mmhbox\egroup\fi} + +\def\gmu@fracfontsetup{% + \smaller[3]\addfontfeature{FakeBold=1}} + +\def\dekfraccsimple{% \label{2292} + \let\dekfracc@args\gmu@dekfraccsimple +} +\@ifXeTeX{\def\dekfraccslash{\char"2044 }} +{\def\dekfraccslash{/}} % You can define it as the fraction slash, +\dekfraccsimple + + + +\newcommand*\ikern{\,\penalty\@M\hskip\z@skip\relax} + + +\def\gmu@scapLetters#1{% + \ifx#1\relax\relax\else% two |\relax|es to cover the case of empty |#1|. + \ifcat a\@nx#1\relax + \ifnum\the\lccode`#1=`#1\relax + {\fakescapscore\MakeUppercase{#1}}% not Plain |\uppercase| + % because that works bad with \pk{inputenc}. + \else#1% + \fi + \else#1% + \fi% + \@xa\gmu@scapLetters + \fi}% +\def\gmu@scapSpaces#1 #2\@nil{% + \ifx#1\relax\relax + \else\gmu@scapLetters#1\relax + \fi + \ifx#2\relax\relax + \else\afterfi{\ \gmu@scapSpaces#2\@nil}% + \fi} +\def\gmu@scapss#1\@nil{{\def~{{\nobreakspace}}% + \gmu@scapSpaces#1 \@nil}}%|% \def\\{{\newline}}\relax| + +\pdef\fakescaps#1{{\gmu@scapss#1\@nil}} + +\let\fakescapscore\gmu@scalematchX + +\def\tinycae{{\tiny\AE}}% to use in |\fakescaps[\tiny]{…}| + +\RequirePackage{calc} + + +\@ifpackageloaded{fontspec}{% + \def\gmu@scalar{1.0}% + \def\zf@scale{}% + \def\gmu@scalematchX{% + \begingroup + \ifx\zf@scale\empty\def\gmu@scalar{1.0}% + \else\let\gmu@scalar\zf@scale\fi + \setlength\@tempdima{\fontdimen5\font}% 5---ex height + \setlength\@tempdimb{\fontdimen8\font}% 8---\XeTeX\ synthesised + % uppercase height. + \divide\@tempdimb by1000\relax + \divide\@tempdima by\@tempdimb + \setlength{\@tempdima}{\@tempdima*\real{\gmu@scalar}}% + \gmu@ifundefined{fakesc@extrascale}{}{% + \setlength{\@tempdima}{\@tempdima*\real{\fakesc@extrascale}}}% + \@tempcnta=\@tempdima + \divide\@tempcnta by 1000\relax + \@tempcntb=-1000\relax + \multiply\@tempcntb by\@tempcnta + \advance\@tempcntb by\@tempdima + \xdef\gmu@scscale{\the\@tempcnta.% + \ifnum\@tempcntb<100 0\fi + \ifnum\@tempcntb<10 0\fi + \the\@tempcntb}%^^A{\strip@pt\@tempdimc}% + \endgroup + \addfontfeature{Scale=\gmu@scscale}% + }}{\let\gmu@scalematchX\smallerr} + +\def\fakescextrascale#1{\def\fakesc@extrascale{#1}} + +\newcommand*\wyzejnizej[1]{% + \edef\gmu@tempa{\gmu@ifundefined{r@#1}{\arabic{page}}{% + \@xa\@xa\@xa\@secondoftwo\csname r@#1\endcsname}}% + \ifnum\gmu@tempa<\arabic{page}\relax wy\.zej\fi + \ifnum\gmu@tempa>\arabic{page}\relax ni\.zej\fi + \ifnum\gmu@tempa=\arabic{page}\relax \@xa\ignorespaces\fi +} + + + +\def\napapierkistretch{0,3pt}% It's quite much for 11/13pt leading. + +\def\napapierkicore{\advance\baselineskip% + by 0ptplus\napapierkistretch\relax} + +\DeclareEnvironment{napapierki}{s}{% + % \chgs{2009/01/05 v0.98 added optional star controlling globalness} + \par\gmuIfValueT{#1}{\global}% + % + \napapierkicore} +{% + \par + \gmuIfValueT{#1}{\global\baselineskip=1\baselineskip\relax + }% +}% so that you can use \inverb|\napapierki*›…\endnapapierki*| + + +\newcount\gmu@luzniej + +\newcommand*\luzniejcore[1][1]{% + \advance\gmu@luzniej\@ne% We use this count to check whether we open + % the environment or just set |\looseness| inside it again. + \ifnum\gmu@luzniej=\@ne \multiply\tolerance by 2 \fi + \looseness=#1\relax} + +\newenvironment*{luzniej}{\par\luzniejcore}{\par} + +\newenvironment*{luzniej*}[1][1]{% + \multiply\tolerance by 2\relax + \everypar{\looseness=#1\relax}}{\par} + +\newcommand*\nawj{\kern0,1em\relax}% a~kern to be put between + +\def\pauza@skipcore{\hskip0.2em plus0.1em\relax + \pauzacore + \@ifnextanyIS {,;:}% + {% 2009/11/22 added a special case of a comma following pauza, + % 2011/02/22, 13.33 extended to colon and semicolon (well, the + % latter should not happen in such a position but a colon did (in + % Polish)). + }{\hskip.2em plus0.1em\relax\ignorespaces}}% +\def\ppauza@skipcore{\unskip\penalty10000\hskip0.2em plus0.1em\relax + \ppauza@dash\hskip.2em plus0.1em\ignorespaces} + +\AtBeginDocument{% + \pdef\pauza{% + \ifhmode + \unskip\penalty10000 + \hskip0.2em plus0.1em\relax + \pauzacore\hskip.2em plus0.1em\relax\ignorespaces% + \else + \pauzadial + \fi + }% + % + % According to \tytul{Instrukcja technologiczna.\ Skład ręczny ^^B + % i~maszynowy} the dialogue dash (in Polish) should be followed by + % a~rigid hskip of \dekfracc1/2\,em. + \pdef\pauzadial{% + \ifhmode\unskip\quad\else\leavevmode\fi + \pauzacore\penalty10000\hskip0,5em\ignorespaces + } + % + % And a~version with no space at the left, to begin a~|\noindent|ed + % paragraph explaining e.g.\ a~quotation: + \pdef\lpauza{% + \leavevmode + \pauzacore\hskip.2em plus0.1em\ignorespaces}% + % + % We define |\ppauza| as an en dash surrounded with thin stretchable + % spaces and sticking to the upper line or bare but discretionary + % depending on the next token being space${}_10$. Of course you'll + % never get such a~space after a~literal \CS so an explicit |\ppauza| + % will always result with a~bare discretionary en dash, but if we + % |\let–\ppauza|… + % \stanza + \pdef\ppauza{% + \ifvmode \PackageError{gmutils}{% + command \bslash ppauza (en dash) not intended for vmode.}{% + Use \bslash ppauza (en dash) only in number and numeral ranges.}% + \else + \unskip\discretionary + {\ppauza@dash}{\ppauza@dash}{\ppauza@dash}% + \fi}% +}% of at begin document + +\ifdefined\XeTeXversion +\AtBeginDocument{% to be independent of moment of loading of \pk{polski}. + \pdef\—{% + \ifhmode + \unskip\penalty10000 + \afterfi{% + \@ifnextanyRS { ,;:}% was comma as a special case; 2011/02/22, + % 13.32 added colon and semicolon. + % + % The above needs some explanation, I suppose. We check if next token + % is blank space or some punctuations, for which purpose we + % use \inverb|\@ifnextanyRS|, where |RS| stands for + % “respecting space”. So if next is a space it turns true. Then + % \inverb|\pauza@skipcore|'s test does not respect space + % (gobbles it) and typesets punctuators with no skip while a + % blank replaces with a skip. + % + {\pauza@skipcore}% + {\@ifnextMac{\pauza@skipcore}% + {\pauzacore\penalty\hyphenpenalty\hskip\z@skip}% + }% + }% of |\afterfi|'s argument + \else + % \nostanza According to \tytul{Instrukcja technologiczna.\ Skład ręczny ^^B + % i~maszynowy} the dialogue dash should be followed by a~rigid + % hskip of \dekfracc1/2\,em.\nostanza + \leavevmode\pauzacore\penalty10000\hskip0,5em\ignorespaces + \fi + }% + % The next command's name consists of letters and therefore it eats + % any spaces following it, so |\@ifnextspace| would always be + % false, therefore we don't use it.\nostanza + \pdef\–{% + \ifvmode \PackageError{gmutils}{% + command \bslash ppauza (en dash) not intended for vmode.}{% + Use \bslash ppauza (en dash) only in number and numeral ranges.}% + \else + \afterfi{% + \@ifnextspace{\ppauza@skipcore}{% + \@ifnextMac\ppauza@skipcore + {\unskip\discretionary + {\ppauza@dash}{\ppauza@dash}{\ppauza@dash}}}% + }% + \fi + }% + % + \def\emdash{\char`\—} +}% of at begin document + +\def\longpauza{% + \def\pauzacore@long{—}% + \let\pauzacore\pauzacore@long +} +\longpauza + +\def\shortpauza{% + \def\pauzacore@short{\hbox{–\kern,23em\relax\llap{–}}}% + \let\pauzacore\pauzacore@short +}% +\def\ppauza@dash{–}% + +\else % not \XeTeX +\def\longpauza{\def\pauzacore{---}} +\longpauza +\def\shortpauza{% + \def\pauzacore{--\kern,23em\relax\llap{--}}}% +\def\ppauza@dash{--}% + +\fi% of if \XeTeX\ or not. + +\ifdefined\XeTeXversion + +\foone{\catcode`—\active \catcode`–\active \catcode`-\active}{%\label{not@ifundef} + \def\adashes{\AtBeginDocument\adashes}% because |\pauza| + % is defined at begin document. + \AtBeginDocument{\def\adashes{% + \catcode`—\active \def—{\—}% + \catcode`–\active \def–{\–}% + \addtomacro\dospecials{\do\–\do\—}% + \addtomacro\@sanitize{\@makeother\–\@makeother\—}% + \addtomacro\gmu@septify{\do\–13\do\—13\relax}% +}}} +\else +\relaxen\adashes +\fi + + +\def\gmu@dywiz{\ifmmode-\else + \ifvmode-\else\afterfifi\dywiz\fi\fi}% + +\foone{\catcode`-\active}{% aktivnyj diefis aktywny dywiz active hyphen + \def\ahyphen{\let-\gmu@dywiz\catcode`\-\active}} + +\newcommand*\czas[1][.]{% + \the\numexpr(\time-30)/60\relax#1% + \@tempcnta=\numexpr\time-(\time-30)/60*60\relax + \ifnum\@tempcnta<10 0\fi\the\@tempcnta} + +\newenvironment*{tytulowa}{\newpage}{\par\thispagestyle{empty}\newpage} + +\def\nazwired{\quad\textsc} + + +\pdef\polskadata{% + \DeclareCommand\gmu@datefsl{% + ##1 Q{0123456789\bgroup}>iT{/-} % year + ##2 Q{0123456789\bgroup}>iT{/-} % month + ##3 Q{0123456789\bgroup} % day + >is % terminator of date scanning that will be gobbled + ##4 T{,}% another terminator of date, but this will be printed + ##5 K{##1\gmu@datefsl} % additional stuff after comma (or instead date) + }{% + \gmuIfValueF{##2}{\gmuPutIfValue{##3}}% + \gmuIfValueT{##2}{% + \@tempcnta=0##3\relax\the\@tempcnta + \ifcase##2\relax\or\ stycznia\or\ lutego% + \or\ marca\or\ kwietnia\or\ maja\or\ czerwca\or\ lipca\or\ sierpnia% + \or\ września\or\ października\or\ listopada\or\ grudnia\else + {}% + \fi}% + \gmuIfValueT{##1}{\space ##1}% + \gmuPutIfValue{##4}% + \gmu@ifempty{##5}{}{ ##5}% + }% of \incs{gmu@datefsl}. + }% of |\polskadata| + +\polskadata + +\pdef\englishdate{% + \DeclareCommand\gmu@datefsl{% + Q{0123456789\bgroup}>iT{/-} % (1) year + Q{0123456789\bgroup}>iT{/-} % (2) month + Q{0123456789\bgroup} % (3) day + >is + T{,} K{##1\gmu@datefsl} % (4, 5) additional stuff after comma + }{% + \gmuIfValueF{##2}{\gmuPutIfValue{##3}}% + \gmuIfValueT{##2}{% + \ifcase##2\relax\or January\or February% + \or March\or April\or May\or June\or July\or August% + \or September\or October\or November\or December\else + {}% + \fi}% + \space + \@tempcnta=##3\relax\the\@tempcnta, + \gmuIfValueT{##1}{ ##1}% + \gmuPutIfValue{##4}% + \gmu@ifempty{##5}{}{ ##5}% + }% of \incs{gmu@datefsl}. +}% + +\newif\ifdate +\pdef\bidate #1{% + \gmu@datefsl#1\gmu@datefsl +} + +\DeclareCommand\linedate{s{}m} +{% + \par + \linedate@hook #1#2\@nil% + \addvspace{\dateskipamount}% + \possvfil% if we put it before |\addvspace|, the v-space is always + % added. + % + \ifdate + % ^^U \addvspace{\dateskipamount}% + \if@CofaćPrzedDatą@ + \penalty\@M + \vskip-0,5\baselineskip + \else + \@CofaćPrzedDatą@true + \fi + % + \date@line{\DateFont \bidate{#1#2}}% + \nopagebreak + % ^^U \else%|%\ifnum\arabic{dateinsection}>0\dekbigskip\fi| + % ^^U \addvspace{\bigskipamount}\possvfil + \fi +}% end of |\linedate|. + +\newif\if@CofaćPrzedDatą@ +\@CofaćPrzedDatą@true + +\pdef\NoPredate {\@CofaćPrzedDatą@false} + +\newcommand*\DateFont{\footnotesize\itshape} + +\def\linedate@hook #1\@nil{} + +\newskip\dateskipamount +\dateskipamount\medskipamount + +\pdef\rdate{\let\date@line\rightline \linedate} + +\def\date@left#1{\par{% + \raggedright#1% + \leftskip\z@skip + \@@par}}% + +\pdef\ldate{%\changes{v0.94}{2008/09/06}{\cs{leftline} + % replaced with \cs{par}…\cs{par} to work well with \pk{floatflt}} + \let\date@line\date@left + \linedate} + +\newcommand*\runindate[1]{% + \paragraph{\footnotesize\itshape \gmu@datef#1\gmu@datef}% + \stepcounter{dateinsection}} +\let\thedate\ldate + +\pdef\zwrobcy#1{\emph{#1}} %ostinato, allegro con moto, + %garden party etc., także kompliment + +\pdef\tytul#1{\emph{#1}} + +\newenvironment{maszynopis}[1][]{#1\ttfamily + \hyphenchar\font=45\relax% this assignment is global for the font. + \@tempskipa=\glueexpr\rightskip+\leftskip\relax + \ifdim\gluestretch\@tempskipa=\z@ + \tolerance900 + % \nostanza it worked well with tolerance \equals 900.\nostanza + \advance\rightskip by\z@ plus0,5em\relax\fi + \fontdimen3\font=\z@% we forbid stretching spaces…\par\nostanza\gmdnoindent + %|% \fontdimen4\font=\z@| but allow shrinking them.\nostanza + \hyphenpenalty0 % not to make \TeX\ nervous: in a~typewriting this + % marvellous algorithm of hyphenation should be turned off and every + % line broken at the last allowable point. + \Store@Macro\pauzacore + \def\pauzacore{-\rlap{\kern-0,3em-}-}% +}{\par} + +\pdef\justified{% + \leftskip=1\leftskip% to preserve the natural length and discard + % stretch and shrink. + \rightskip=1\rightskip + \parfillskip=1\parfillskip + \advance\parfillskip by 0sp plus 1fil\relax + \let\\\@normalcr} + +\DeclareCommand\fullpar{% + T{+-}% + Q{+-0123456789} % optional looseness (most probably negative) +}{% + \begingroup + \gmuIfValueT{#1}{\looseness=#1\gmuIfValueTF{#2}{#2}{1}\relax + \multiply\tolerance by \tw@ + }% + \fullparcore + \par + \endgroup} + +\pdef\fullparcore{% + \hunskip + \parfillskip\z@skip} + +\newcommand*\twoparinit{% the name stands for `\emph{last} paragraph + % line's length \emph{min}imum \emph{two} \incs{parindent}. + \def\twopar@defts{% + \hsize-\leftskip-\rightskip-\fontcharwd\font`…}% + \def\twopar@atleast{2\@parindent}% + \DeclareCommand\twopar{% + T{+-}% (1) you can specify loosening the paragraph by one only by + % typing single |+| and tightening by one by typing single |-|. + Q{+-0123456789}% (2) + A{\twopar@atleast}% (3) + >iT{\cipolagwa}}{% + \begingroup + \gmuIfValueT{##1}{% + \looseness=##1\gmuIfValueTF{##2}{##2}{1}\relax + \multiply\tolerance by2 + }% + \twoparcore<##3>% + \endgraf + \endgroup + }% of \incmd\twopar. + % \stanza + \ifdefined\XeTeXversion + \DeclareCommand\twoparcore{% + A{\twopar@atleast} + \gobblespace + }{% + \hunskip % it's \ac{O.K.} it's in a~group, it'll work anyway. + \edef\gmu@tempa{\the\dimexpr\twopar@defts-##1\relax}% + \parfillskip=\glueexpr\gmu@tempa minus \gmu@tempa + \relax% to delimit |\glueexpr|. + \relax% to delimit the assignment. + }% + \else % not \XeTeX---doesn't use |\fontcharwd|. + \DeclareCommand\twoparcore{% + A{\twopar@default} + \gobblespace + }{% + \hunskip % it's \ac{O.K.} it's in a~group, it'll work anyway. + {\setbox0=\hbox{\dots}% + \xdef\gmu@tempa{\the\wd0}}% + \edef\gmu@tempa{% + \the\dimexpr\hsize-\leftskip-\rightskip + -\gmu@tempa-2\@parindent\relax}% + \parfillskip=\glueexpr\gmu@tempa minus \gmu@tempa + \relax% to delimit |\glueexpr|. + \relax% to delimit the assignment. + }% + \fi + % \stanza + \AtBeginDocument{% + \def\restoreparindent{\parindent\@parindent}% + }% of \cmd\AtBeginDocument. +}% of \cs{twoparinit}. + + +\def\gmu@leftskipcorr{% + \kern1\leftskip + \ifcsname \@currenvir leftskip\endcsname + \kern-1\csname \@currenvir leftskip\endcsname + \fi +} + +\DeclareCommand\wherncore{om}{%\ + % \begin{enumargs} + % \dc optional value of \incs{hskip} of (left) indent of the parbox. If + % absent, parbox is aligned right; + % \dc text for the datum parbox. + % \end{enumargs} + \gmuIfValueTF{#1}{\leftline{% + \kern1\leftskip + \whernfont + \hskip#1\relax\parbox + {\dimexpr\hsize-\leftskip-\rightskip-#1}% + {#2}% of |\parbox|, + }% of |\leftline|, + }% of |ValueT{#1}|. + {% |ValueF{#1}|: + \rightline + {\whernfont + \whern@parbox{#2}% + \kern1\rightskip + }% of |\rightline|, + \setprevdepth + }% of |ValueF{#1}|, +}% of |\wherncore|. + +\DeclareCommand\whern@parbox{% + T {\leftskip\rightskip}% horizontal alignment of resulting box (the + % side to be ragged) + O{t} % vertical alignment of parbox + >is % separator + O{0,7666\hsize} % (3) width of parbox + m % (4) parbox contents +}{% + % \begin{enumargs} + % \dc S the skip of the ragged side, + % \dc the |\parbox|'s contents. + % \end{enumargs} + \parbox[#2]{#3}{% + \gmuIfValueTF{#1}{#1}{\leftskip}=0sp plus \textwidth + \parfillskip0sp\relax + \let\\\linebreak + \disobeylines + \whernfont #4\unskip\strut\endgraf + \getprevdepth + }% of |\parbox|, +}% of |\whern@parbox|. + +\def\whern{% + \endgraf\nopagebreak + \gmu@ifstar{\wherncore}% + {\vskip\whernskip\wherncore}% +} + +\let\whernfont\footnotesize + +\newskip\whernskip +\whernskip2\baselineskip minus 2\baselineskip\relax + +\foone{\obeylines}{% + \DeclareCommand\whernup{% +#1 o % a~vskip before + >is % separating star (ignored) +#2 o % custom width of parbox +#3 >Pm% +#4 o % a vskip between this box and subsqt. text + >iQ{ \par + }% + }% of args' spec +}% of obey lines +{\par + \gmuIfValueT{#1}{\vskip#1\relax}% + % + % The \env{prosato} env. of \pk{gmverse} \& derivs. set some + % positive parskip and counterkrank its first occurrence by a vskip + % of its negative. Therefore here we put ourselves in a |\rlap| and + % put at the very beginning of a paragraph. + \ifinner \noindent\nobreak\kern-1\leftskip \nobreak + \rlap{% + \vbox{% + \fi % of if inner + \leftline{% + % ^^A \gmu@leftskipcorr + \gmuIfValueTF{#2}{\whern@parbox\rightskip[b][#2]}% + {\whern@parbox\rightskip[b]}% + {#3}% + }% + % + \ifinner + \gmuIfValueT {#4}{\vskip\glueexpr #4\endexpr }% + \phantom{Ala ma Filifjonkgyr}% + }% of vbox + }% of rlap + % + \penalty\@M + \kern 1\leftskip + \@ifenvir{quote}{\hskip\z@skip}{\hskip\parindent\relax}% + \else + \gmuIfValueT {#4}{\vskip \glueexpr #4\endexpr }% + \fi +}% of |\whernup|'s body. + + +\pdef\thousep#1{% a~macro that'll put the thousand separator between + % every two three-digit groups.\par\nostanza + % First we check whether we have at least five digits. + %\changes{v0.93}{2008/08/23}{added} + \gmu@thou@fiver#1\relax\relax\relax\relax\relax% we put five + % \incs{relax}es after the parameter to ensure the string will meet + % \incs{gmu\+@\+thou\+@\+fi\+ver}'s definition.\ilrr + \gmu@thou@fiver{#1}{% if more than five digits: + \emptify\gmu@thou@put + \relaxen\gmu@thou@o\relaxen\gmu@thou@i\relaxen\gmu@thou@ii + \@tempcnta\z@ + \gmu@thou@putter#1\gmu@thou@putter + \gmu@thou@put + }} + +\def\gmu@thou@fiver#1#2#3#4#5\gmu@thou@fiver#6#7{% this macro only + % checks if the text delimited with itself consists of at least five tokens/braces + \ifx\relax#5\relax\@xa\@firstoftwo + \else\@xa\@secondoftwo + \fi{#6}{#7}} + +\def\gmu@thou@putter #1#2{% we are sure to have at least five tokens + % before the sentinel \incs{gmu@thou@putter}. + \advance\@tempcnta\@ne + \@tempcntb\@tempcnta + \divide\@tempcntb3\relax + \@tempcnta=\numexpr\@tempcnta-\@tempcntb*3 + \edef\gmu@thou@put{\@xau{\gmu@thou@put}\unexpanded{#1}% + \ifx\gmu@thou@putter#2\else + \ifcase\@tempcnta + \gmu@thou@o\or\gmu@thou@i\or\gmu@thou@ii% all three + % \CSes are yet \incs{relax} so we may put them in + % an \incs{edef} safely.\ilrr + \fi + \fi}% of \cs{edef} + \ifx\gmu@thou@putter #2% if we are at end of the digits… + \edef\gmu@tempa{% + \ifcase\@tempcnta + \gmu@thou@o\or\gmu@thou@i\or\gmu@thou@ii + \fi}% + \@xa\let\gmu@tempa\gmu@thousep% … we set the proper \CS… + \else% or … + \afterfi{% iterate. + \gmu@thou@putter#2}% of \cs{afterfi} + \fi% of if end of digits. +}% of \cs{gmu@thou@putter}. + +\def\gmu@thousep{\,}% in Polish the recommended thousand separator is + +\pdef\xathousep#1{\@xa\thousep\@xa{\the#1}} + +\def\shortthousep{% + \DeclareCommand\thous{ + D {\NoValue} % decimal argument + }{% + % we declare it as a command with Q-type argument to allow spaces + % between digits. + \ifmmode\hbox\bgroup\@gmu@mmhboxtrue\fi + \gmuIfValueTF{##1}{% we are given a sequence of digits + \@tempcnta=##1\relax + \ifnum\@tempcnta<0 $-$% + \@tempcnta=-\@tempcnta + \fi + \xathousep\@tempcnta + \if@gmu@mmhbox\egroup + \else\@xa\spifletter + \fi + }% + {% no bare digits given, then we assume the argument is braced. + \thousep + }% + }% of |\thous|. +}% of |\shortthousep|. + + +\DeclareCommand\ATfootnotes{s}{% \chgs{2008/11/29 v0.98 moved here + % from my own private macro package to allow the beauty of these + % footnotes for the general audience} + % \stanza + % We make the footnote mark in the footnote |\scriptsize| not + % |\scriptscriptsize|.\nostanza + \gmuIfValueT{#1}% the following setting is suitable for old style + % numbers in footnote marks, therefore I~place it in the starred + % version of the command. + {\prependtomacro\gmu@ATfootnotes{% + \pdef\@makefnmark{% + \mbox {\normalfont \textsuperscript {\smaller[3]\@thefnmark }}}% + }% of prepend, + }% of |\gmuIfValueT|. + % + \gmu@ATfootnotes + \gmu@AT@ampulex\maketitle% without \pk{hyperref} + \unless\if@HyOrg@maketitle@ampulexed@ + \ifdefined\HyOrg@maketitle + \afterfi{\gmu@AT@ampulex\HyOrg@maketitle}% with \pk{hyperref} + \fi + \@HyOrg@maketitle@ampulexed@true + \fi +} + +\newif\if@HyOrg@maketitle@ampulexed@ + +\pdef\gmu@AT@ampulex #1{% + \ampulexdef#1{\def\@makefnmark}% + \if@twocolumn + {\gmu@ATfootnotes\if@twocolumn}% Ampulex redefinition of + % \incs{maketitle} for the standard classes. + \ampulexdef#1{\long\def\@makefntext}% + \if@twocolumn{\gmu@ATfootnotes\if@twocolumn}% Ampulex redefinition + % of \incs{maketitle} for \pk{mwcls}. +} + +\pdef\gmu@ATfootnotes{% + % And we make the footnote number not be in superscript but on the + % base line, according to Andrzej Tomaszewski's suggestion on + % Bacho\TeX\ 2008, and the same size as in the footnote mark.\nostanza + \long\pdef\@makefntext##1{% + \ifdefined\@parindent \parindent\@parindent + \else \parindent 1em\relax + \fi + \indent{\ATf@font\scriptsize% ^^A \hphantom{19}\llap + {\@thefnmark}}% + \gmu@fnhook + \enspace\ignorespaces##1}% +} + +\let\ATf@font\normalfont + +\emptify\gmu@fnhook + + +\pdef\rrthis{% ‘rag right this’: make only the current paragraph + % ragged right (e.g.\ if the paragraph consists of a~long \ac{URL}). + % \chgs{2008/12/01 v0.98 added} + \begingroup\rightskip=0sp plus \hsize \endgraf\endgroup} + +\pdef\centerthis{% 2009/12/15 + \begingroup + \rightskip=1\rightskip plus \hsize + \leftskip=1\leftskip plus\hsize + \parfillskip=\z@skip + \endgraf\endgroup} + + +\def\TrzaskaTilde{% + \@xa\DeclareCommand\@xa\gmu@smarttilde + \@xa{\@xa T\@xa{\all@stars~}}{% + \gmuIfValueTF{##1}{\nobreakspace{}}% + {\ifdim\dimexpr\hsize-\leftskip-\rightskip + -\ifdim\hangindent<\z@-\fi\hangindent % the last + % parameter is used with respect to the \pk{floatflt} package. + >% + \ifdim\f@size pt>\dimexpr10pt-1sp\relax + 168dd + \else + 144dd + \fi + \nobreakspace {}% + \else + \ % + \fi + }% of |\gmu@ifstar|'s else, + }% of |\gmu@smarttilde|, + \let~\gmu@smarttilde +}% of |\TrzaskaTilde|. + + +\newcommand{\clearemptydoublepage}{% + \newpage{\pagestyle{empty}\cleardoublepage}} + +\foone\obeylines{% + \def\disobeylines{% for arguments in which line end is active to + % simulate normal behaviour + \ifnum\catcode`\^^M=\active% + \pdef^^M{\@ifnextgroup{\ifhmode\unskip\space\fi}{\gmu@disMinner}}% + \def\gmu@disMinner##1{% + \ifx^^M##1\endgraf% + \else\afterfi{\ifhmode\unskip\space\fi}\fi##1}% + \fi}% +} + + +\DeclareCommand\*{Q{0123456789}{1}} +{\gmu@flexhyphen + \gmu@star@loop0{#1}\relax +}% + +\def\gmu@star@loop#1#2{% this is an expandable loop as in The + % \eTeX\ Manual p.~9. + \ifnum#1<\numexpr#2\relax% + \gmu@lowstar + \gmu@flexhyphen + \@xa\gmu@star@loop + \@xa{\number\numexpr#1+1\@xa}% + \@xa{\number#2\@xa}% + \fi} + +\ifdefined\XeTeXversion + +\foone{% + \catcode`„\active + \catcode`”\active + \catcode`’\active + \catcode`—\active + \catcode`–\active +}{% + \def\activequotes{% + \incsdef„{}{\@ifnextchar—% + {\lv\llap{\string„}\pauzadial}{\string„}}% + \incsdef”{}{\string”\@ifnextanyRS{.,}{\quotkern}{}}% + \incsdef’{}{\string’\@ifnextanyRS{.,}{\quotkern}{}}% + \catcode`„\active + \catcode`”\active + }% + \def\activepunctsQ {„”’—–}% +} + +\catcode`ѥ\active + +\DeclareCommand\ac {b} {% + \gmuIfValueTF{#1}% + {% + \acro{#1}% + }% + {\ac@u}% +} + +\def\ac@kernel#1{{\gmu@acrokernel {#1}}}% |#1| in braces because |\acrocore| + % valid in \ty{Dzienniczek} uses + % |\lowercase| (that requires braced text). + + +\@xa\def\@xa\@dc@basicdelims\@xa{% + \two@Ms \par \relax + \bgroup + \egroup \begingroup \endgroup + \begin \end + $% ^^A$ + \(\)\[\]% other math delims + &\\% tabular delims +} + +\let\@dc@basicdelimsp\@dc@basicdelims + +\@xa\addtomacro\@xa\@dc@basicdelimsp +\@xa{\all@spaces} + +\@xa\def\@xa\@dc@punctanddelims +\@xa{\@dc@basicdelims :,.;?!„”«»‹›"'`‘’}% + +\let \@dc@acpunctanddelims \@dc@punctanddelims + +\@xa\addtomacro\@xa\@dc@acpunctanddelims +\@xa{\activepunctsQ} + +\let \@dc@acpunctanddelimsp \@dc@punctanddelims + +\@xa\addtomacro\@xa\@dc@acpunctanddelimsp +\@xa{\all@spaces} + +\addtomacro\@dc@acpunctanddelimsp{~} + +\DeclareCommand\ac@u{ + >\@xa U {\@dc@acpunctanddelimsp ()[]<>ѥ} \default{} + \eacher {\ac@kernel} + >iW{ѥ} +} +{% + \ifmmode\@xa\text\else\@xa\firstofone\fi{#1}% +} + +\fi % of if \XeTeX\ of l.~\ref{12322}. + +\@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} + +\@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} + +\endinput +%% +%% End of file `gmtypos.sty'. diff --git a/macros/latex/contrib/gmutils/gmurl.sty b/macros/latex/contrib/gmutils/gmurl.sty new file mode 100644 index 0000000000..646585eea1 --- /dev/null +++ b/macros/latex/contrib/gmutils/gmurl.sty @@ -0,0 +1,301 @@ +%% +%% \iffalse ^^A we skip the debug setting +\IfFileExists{\string~/bin/gen_and_xela}{\errorcontextlines=1000 }{} +%% \fi +%% ^^A $Id: TheUltimateMaster.gmd,v 0.352 2011/10/12 15:19:42 natror Exp natror $ +%% This is file “gmurl.sty” generated with the DocStrip utility. +%% +%% +%% The original source files were: +%% +%% gmutils/gmutils.gmd (with options: `url') +%% +%% +%% Copyright © +%% by Grzegorz ‘Natror’ Murzynowski +%% natror (at) gmail (dot) com +%% +%% This program is subject to the LaTeX Project Public License. +%% See http://www.ctan.org/tex-archive/help/Catalogue/licenses.lppl.html +%% for the details of that license. +%% +%% LPPL status: "author-maintained". +%% +%% +%% +%% For documentation please refer to the file(s) +%% gmutils.{gmd,pdf}. +%% +%% +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{gmurl} + [2011/10/12 v0.996 modifications to the url package (GM)] + + +%% +%% +%% ^^A\typeout{\unexpanded{#4}}%% + + +\RequirePackage{gmcommand} + + +\def\urladdstar{% + \AtBeginDocument{% + \@ifpackageloaded{hyperref}{% + \Store@Macro\url + \pdef\url{\gmu@ifstar{\nolinkurl}{\storedcsname{url}}}% + }{}}} + +\@onlypreamble\urladdstar + +\@ifXeTeX{% + \pdef\UrlFix{\AtBeginDocument{% + \@ifpackageloaded{url}{\gmu@UrlFix}{}}% + \relaxen\UrlFix}% + % + \AtBeginDocument{% + \pdef\UrlFix{% + \@ifpackageloaded{url}{\gmu@UrlFix}{}% + \relaxen\UrlFix}}% +} +{% + \pdef\UrlFix{\PackageWarning{gmutils}{!!! The \string\UrlFix\space + declaration works only with XeTeX}}% +} + +\@ifXeTeX{}{% + \edef\gmu@restoreUpUpUp{\catcode`\@nx\^^^=\the\catcode`\^^^}% + \AtEndOfPackage\gmu@restoreUpUpUp + \catcode`\^^^=9 } + +\def\gmu@UrlFix{% + % \stanza + % default style assignments + \def\UrlBreaks{\do\.\do\@\do\\\do\/\do\!\do\_\do\|\do\;\do\]% + \do\)\do\,\do\?\do\'\do\"\do\+\do\=\do\#\do\%\do\~\do\_\do\|% + \do\{\do\}\do\$}% + \def\UrlBigBreaks{\do\:}% + \def\UrlNoBreaks{\do\(\do\[\do\{}% + \def\UrlSpecials{% + \do\ {\hbox{\visiblespace}}\do\^^M{\hbox{\visiblespace}}}% + % \stanza + % + % \stanza + \def\Url@Format##1{% + \UrlFont + \ifdefined\verbatim@specials + \catcode`\>\active + \verbatim@specials + \verbatim@mathhack + \fi % setting of + % the escape char, begin and end group and optionally math shift, + % defined in \pk{gmverb}. + \gmu@UrlSetup + \UrlLeft + \edef\gmu@theendlinechar{\the\endlinechar}% + \endlinechar\m@ne + \kern\z@% to forbid hyphenating the first word if the \ac{URL} + % begins with a~word + \hyphenchar\font=\UrlHyphenchar\relax + \let\-\gmu@discretionaryhyphen + \scantokens{##1}% + \endlinechar\gmu@theendlinechar\relax + \UrlRight + }% of |\Url@Format|. + % \stanza + \edef\UrlHyphenchar{% + \ifdefined\gmv@hyphenchar\gmv@hyphenchar + \else"A6 \fi}% \label{UrlHyphenchar} broken bar, |¦| or the same as + % provided in \pk{gmverb} for verbatims. You + % can redefine it as you please. This char is used as the + % hyphenation char in \ac{URL}s and therefore should be different + % from |-| (hyphen), which is often a part of an \ac{URL}. The + % broken bar seems to be quite unlikely in \ac{URL}s and/or file + % names. + % \stanza + \def\verbatim@mathhack{% + \ifdefined\verbatim@specials@list + \@xa\verbatim@mathhack@\verbatim@specials@list + \fi + }% + % \stanza + \def\verbatim@mathhack@##1##2##3##4##5##6{% + \gmuIfValueT{##4}{% + \edef\gmu@thinmuskip{\the\thinmuskip}% + \edef\gmu@medmuskip{\the\medmuskip}% + \edef\gmu@thickmuskip{\the\thickmuskip}% + \begingroup + \lccode`\~=`##4\lowercase{% + \endgroup\def~####1~}% + {$\thinmuskip\gmu@thinmuskip\relax + \medmuskip\gmu@medmuskip\relax + \thickmuskip\gmu@thickmuskip\relax + ####1% + $}% + \catcode`##4\active + }% + }% + %\stanza + \def\gmu@UrlSetup{% + \medmuskip\Urlmuskip \thickmuskip\medmuskip \thinmuskip0mu% + \relpenalty\UrlBigBreakPenalty \binoppenalty\UrlBreakPenalty + \def\do{\gmu@doUrlMath\UrlBreakPenalty}\UrlBreaks % bin + % (\incs{hyphenpenalty} anyway) + \def\do{\gmu@doUrlMath\UrlBigBreakPenalty}\UrlBigBreaks % rel + % (\incs{hyphenpenalty} anyway) + \def\do{\gmu@doUrlMath\@M}\UrlNoBreaks % open (no break) + \def\do{\gmu@doUrlMathAc\UrlBreakPenalty}% (\incs{hyphenpenalty}) + \UrlSpecials + \if \iffontchar\font"2329 1\else0\fi\iffontchar\font"232A 1\else2\fi + % \nostanza we check whether the font provides both left and right + % angle brackets. \nostanza + \gmu@measurewd{^^^^2329}% + \edef\gmu@tempa{% + \@nx\gmu@doUrlMathAc\@M\@nx\<{% + \hbox to\gmu@tempb{\unexpanded{\hss\char"2329 \hss}}}% + }\gmu@tempa + \gmu@measurewd{^^^^232a}% + \edef\gmu@tempa{% + \@nx\do\@nx\>{% + \hbox to\gmu@tempb{\unexpanded{\hss\char"232A \hss}}}% + }\gmu@tempa + \else + \gmu@doUrlMathAc\@M\<{\langle}\do\>{\rangle}% + \fi + \iffontchar\font"22C6 % low star + \do\*{\hbox{\char"22C6 }}% + \else \do\**% + \fi + \ifx\do@url@hyp\@empty + \gmu@measurewd{-}% this macro is defined in line \ref{@measurewd}. + \edef\gmu@tempa{% + \unexpanded{\gmu@doUrlMathAc\@M\-}% + {\hbox to \gmu@tempb{\unexpanded{\hss-\hss}}% + \@nx\-}% hyphen is a + % good point for hyphenation, but the hyphenation char should + % be sth. else, and it is indeed: |¦| (broken bar, + % |\char"A6|). See also line \ref{UrlHyphenchar} + }\gmu@tempa + \fi + \addfontfeature{Ligatures=NoCommon, Mapping=none}% instead of + % ‘doing’ \incs{ver\+bat\+im\+@\+no\+lig\+@\+list}. + }% of |\gmu@UrlSetup|. + % \stanza + % + % \stanza + \def\gmu@doUrlMath##1##2{%\ + % \begin{enumargs} + % \item value of the penalty (used as a~Boolean: if $<$ + % \thous 10000, \nlperc\cs{hyphenpenalty} will be used anyway, if $\ge$ + % \thous10000, there will be no \incs{discretionary}), + % \item the char, given as |\⁄|. + % \end{enumargs} + \begingroup + \lccode`\~=`##2\lowercase{% + \endgroup\def~{\@ifnextchar~}% + \@xa\addtomacro\@xa~}% of |\lowercase|. + \ifnum##1<\@M + {% + {\char`##2\csname gmu@dbl\string##2kern\endcsname}% if next is the same char + {\ifmmode\char`##2% else + \else\gmu@urlbreakable{##1}{##2}% + \fi}% + }% of |\addtomacro|'s argument |\ifnum| true. + \else + {% + {\char`##2\csname gmu@dbl\string##2kern\endcsname}{\char`##2}% + }% of |\addtomacro|'s argument |\ifnum| false. + \fi + \catcode`##2=\active + }% of |\gmu@doUrlMath|. + % \stanza + \def\gmu@doUrlMathAc##1##2##3{%\ + % \begin{enumargs} + % \item (value of) a~penalty (see the remark to \inverb|##1| of + % the previous macro), + % \item the char (as |\⁄|), + % \item the definition. + % \end{enumargs} + \begingroup + \lccode`\~=`##2\lowercase{% + \endgroup\def~{\@ifnextchar~}% + \@xa\addtomacro\@xa~}% of |\lowercase|. + \ifnum ##1<\@M + {% + {\ifmmode\char`##2\else$##3\m@th$\fi}% + {\ifmmode\char`##2% + \else\discretionary{\hbox{$##3\m@th$}}{}{\hbox{$##3\m@th$}}% + \fi}% + }% of |\addtomacro|'s argument if num true. + \else + {% + {\ifmmode\char`##2\else$##3\m@th$\fi}{\ifmmode\char`##2\else$##3\m@th$\fi}% + }% of |\addtomacro|'s argument if num false. + \fi + \catcode`##2=\active + }% of |\gmu@doUrlMathAc|. + % \stanza + \pdef\gmu@url@rigidbreak##1##2{\discretionary{\char`##2}{}{\char`##2}}% + % \stanza + \pdef\gmu@url@flexbreak##1##2{\penalty\@M \hskip\z@ plus0,03em + \char`##2\penalty##1\hskip\z@ plus0,03em\relax}% + % \stanza + \let\gmu@urlbreakable\gmu@url@flexbreak + % \stanza + \def\Url@z##1{% + % Do any hyper referencing due to hyperref (or perform a url-def) + \Url@HyperHook + % Now do the formatting in a group (can also have \incs{Url@HyperHook} take + % this as an argument). \nostanza + {\Url@Format{##1}}% + \endgroup}% + % \stanza + \DeclareUrlCommand\file{\urlstyle{sf}}% + % \stanza + \emptify\Url@moving% with our settings |\url| is pretty allowed in + % moving arguments, I~hope. +}% of |\gmu@UrlFix|. + +\DeclareCommand\UrlSlashKern{O{tt}m}% +{\AtBeginDocument{% + \@nameedef{url@#1style}{\def\@nx\UrlFont{% + \@xanxcs{#1family}% + \def\@xanxcs{gmu@dbl\string\/kern}% + {\kern#2\relax}% + }% of |\UrlFont| + }% of |\url#1style| + \urlstyle{#1}% + }% of |\AtBeginDocument| +}% of |\UrlSlashKern| + +\def\DeclareUrlCommand#1#2{\pdef#1{\leavevmode\begingroup #2\Url}} + +\foolc ~ : {% + \@ifXeTeX{% + \def\metaat~{% + \penalty\@M \hskip\z@skip + \meta{аt}% it's a Cyrillic »a«! + \penalty\exhyphenpenalty + \hskip\z@skip + }% + % + \def\metadot~{% + \penalty\@M \hskip\z@skip + \meta{dоt}% it's a Cyrillic »o«! + \penalty\exhyphenpenalty + \hskip\z@skip + }% + }% of if \XeTeX + {% + \def\metaat~{\PackageError{gmurl}{Command \bslash metaat + works only in XeTeX}@}% + % + \def\metadot~{\PackageError{gmurl}{Command \bslash metaat + works only in XeTeX}.}% + }% of if not XeTeX +}% of |\foolc| + +\endinput +%% +%% End of file `gmurl.sty'. diff --git a/macros/latex/contrib/gmutils/gmutils.pdf b/macros/latex/contrib/gmutils/gmutils.pdf new file mode 100644 index 0000000000..ea896ed4e9 Binary files /dev/null and b/macros/latex/contrib/gmutils/gmutils.pdf differ diff --git a/macros/latex/contrib/gmutils/gmutils.sty b/macros/latex/contrib/gmutils/gmutils.sty new file mode 100644 index 0000000000..b2af20cc33 --- /dev/null +++ b/macros/latex/contrib/gmutils/gmutils.sty @@ -0,0 +1,136 @@ +%% +%% \iffalse ^^A we skip the debug setting +\IfFileExists{\string~/bin/gen_and_xela}{\errorcontextlines=1000 }{} +%% \fi +%% ^^A $Id: TheUltimateMaster.gmd,v 0.352 2011/10/12 15:19:42 natror Exp natror $ +%% This is file “gmutils.sty” generated with the DocStrip utility. +%% +%% +%% The original source files were: +%% +%% gmutils/gmutils.gmd (with options: `utils') +%% +%% +%% Copyright © 2005, 2006, 2007, 2008, 2009, 2010, 2011 +%% by Grzegorz ‘Natror’ Murzynowski +%% natror (at) gmail (dot) com +%% +%% This program is subject to the LaTeX Project Public License. +%% See http://www.ctan.org/tex-archive/help/Catalogue/licenses.lppl.html +%% for the details of that license. +%% +%% LPPL status: "author-maintained". +%% +%% +%% +%% For documentation please refer to the file(s) +%% gmutils.{gmd,pdf}. +%% +%% +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{gmutils} + [2011/10/12 v0.996 some low-TeXnical macros, most of them copied from the Gurus (GM)] + + +%% +%% +%% ^^A\typeout{\unexpanded{#4}}%% + + +\unless\ifdefined\Name + \def\Name#1#2{\expandafter#1\csname#2\endcsname} +\fi + +\unless\ifcsname ifgmu@quiet\endcsname +\Name\newif {ifgmu@quiet}% % it has to be at least (at highest) in +\fi + +\RequirePackage{xkeyval} + +\RequirePackage{gmbase} + + +\DeclareOptionX{quiet}{\gmu@quiettrue + \PassOptionsToPackage{quiet}{gmtypos}% +} + +\def\gmu@PackOptionX +#1% name of a package with or without leading “gm”. +{% + % So we declare an OptionX that by default loads this package thanks + % to a special \CS having been defined to load it or do nothing. + \DeclareOptionX{#1}[on]{% + % ^^V \ifcsname gmu@Require@#1\endcsname + % ^^V \PackageError{gmutils}{Value clash for the ***#1*** package option}{}% + % ^^V \fi + \lowercase{\@xa\if\@gobble ##1\relax}% “off” given as the value + \@namedef{gmu@Require@#1}{}% + \else % “on” + \afterfi{% + \@namedef{gmu@Require@#1}{% + \IfFileExists{gm#1.sty}% + {\RequirePackage{gm#1}}% if there's a \pk{gm} package, we load + % it, else we load + {\RequirePackage{#1}}% + }% of namedef + }% of afterfi + \fi + }% of |\DeclareOptionX| + \IfFileExists{gm#1.sty}% + {\DeclareOptionX{gm#1}[on]{% + \ExecuteOptionsX{#1=####1}% + }% + }% of if yes. Else: + {}% + % +} + + \gmu@PackOptionX{command} + \gmu@PackOptionX{ampulex} + \gmu@PackOptionX{envir} + \gmu@PackOptionX{relsize} + \gmu@PackOptionX{meta} % provides |\bihyphen|, |\discre|, |\discret| + \gmu@PackOptionX{logos} + \gmu@PackOptionX{notonlypream} + \gmu@PackOptionX{mw} + + \gmu@PackOptionX{typos} + \gmu@PackOptionX{parts} + \gmu@PackOptionX{url} + \gmu@PackOptionX{RCS} + +\ExecuteOptionsX{command, envir, ampulex, relsize, meta, logos, + notonlypream, % ^^V mw=off, + typos, parts, url} + +\ProcessOptionsX + +\def\doifdefined#1{\ifdefined#1\@xa#1\fi} + +\doifdefined\gmu@Require@command +\doifdefined\gmu@Require@envir +\doifdefined\gmu@Require@ampulex +\doifdefined\gmu@Require@relsize +\doifdefined\gmu@Require@meta +\doifdefined\gmu@Require@logos +\doifdefined\gmu@Require@notonlypream +\doifdefined\gmu@Require@mw +\doifdefined\gmu@Require@typos +\doifdefined\gmu@Require@parts +\doifdefined\gmu@Require@url +\doifdefined\gmu@Require@RCS + + +\def\heshe{they} +\def\hisher{their} +\def\himher{them} +\def\hishers{theirs} + +\def\HeShe{They} +\def\HisHer{Their} +\def\HimHer{Them} +\def\HisHers{Theirs} + +\endinput +%% +%% End of file `gmutils.sty'. -- cgit v1.2.3