summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/gmutils
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2008-08-13 23:51:49 +0000
committerKarl Berry <karl@freefriends.org>2008-08-13 23:51:49 +0000
commit7d82064f4764b45c6b2fe5fcf7e2a92be6f13bcf (patch)
treee9e76b9f2d6b902354447e0d2f3657cf6e501a9a /Master/texmf-dist/tex/latex/gmutils
parent107bb27229d89531b8954ea2b10504f33c44b097 (diff)
gmutils update (13aug08)
git-svn-id: svn://tug.org/texlive/trunk@10317 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/gmutils')
-rw-r--r--Master/texmf-dist/tex/latex/gmutils/gmutils.sty158
1 files changed, 114 insertions, 44 deletions
diff --git a/Master/texmf-dist/tex/latex/gmutils/gmutils.sty b/Master/texmf-dist/tex/latex/gmutils/gmutils.sty
index 63efb272a15..2c9058651dd 100644
--- a/Master/texmf-dist/tex/latex/gmutils/gmutils.sty
+++ b/Master/texmf-dist/tex/latex/gmutils/gmutils.sty
@@ -48,17 +48,17 @@
% \chschange{v0.88}{2008/8/3}{4040}
% \chschange{v0.90}{2008/8/4}{4035}
% \chschange{v0.91}{2008/8/6}{4055}
+% \chschange{v0.92}{2008/8/11}{4133}
%
-
-% \iffalse we skip the driver
+% \skiplines we skip the driver
\ifnum\catcode`\@=12
-\documentclass[codespacesgrey,outeroff,pagella]{gmdocc}
+\documentclass[debug,countalllines,codespacesgrey,outeroff,pagella]{gmdocc}
\usepackage{eufrak}% for |\continuum| in the commentary.
\twocoltoc
\begin{document}
-\DocInput{\jobname.sty}%e:/texmf/tex/latex/gm/
+\DocInput{\jobname.sty}
\PrintChanges
\thispagestyle{empty}
\typeout{%
@@ -71,11 +71,11 @@
\afterfi{\end{document}}
\fi% of driver pass
-%\fi
+%\endskiplines
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{gmutils}
- [2008/08/06 v0.91 some rather TeXnical macros, some of them tricky (GM)]
+ [2008/08/07 v0.92 some rather TeXnical macros, some of them tricky (GM)]
%
% \tableofcontents
@@ -178,7 +178,7 @@
% \LaTeX's |\newif| modulo the letter $g$ and the |\global| prefix.
% (File d: \file{ltdefns.dtx} Date: 2004/02/20 Version v1.3g, lines
% 139--150) \Define\newgif
-\def\newgif#1{%
+\protected\def\newgif#1{%
{\escapechar\m@ne
\global\let#1\iffalse
\@gif#1\iftrue
@@ -190,11 +190,30 @@
% a~group.
% \DefIndex\@gif
\def\@gif#1#2{%
- \@xa\gdef\csname\@xa\@gobbletwo\string#1%
+ \protected\@xa\gdef\csname\@xa\@gobbletwo\string#1%
g% the letter $g$ for `|\global|'.
\@xa\@gobbletwo\string#2\endcsname
{\global\let#1#2}}
+\protected\def\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
+ % an further expanding or unbalanced \cs{iftrue/false} in an 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}}
+
+
% After |\newgif\iffoo| you may type |{\foogtrue}| and the |\iffoo|
% switch becomes globally equal |\iftrue|. Simili modo |\foogfalse|.
% Note the letter $g$ added to underline globalness of the assignment.
@@ -214,7 +233,7 @@
% Warning. I~use it because of very special reasons in \pk{gmdoc} and
% in general it is probably not a~good idea to make |\refstepcounter|
% global since it is contrary to the original \LaTeX\ approach.
-\newcommand*\grefstepcounter[1]{%
+\protected\def\grefstepcounter#1{%
{\let\protected@edef=\protected@xdef\refstepcounter{#1}}}
% Na\"\i{}ve first try |\globaldefs=\tw@| raised an error
% |unknown command \reserved@e|. The matter was to globalize
@@ -224,6 +243,27 @@
% change made to |\refstepcounter| by \pk{hyperref}.
% \dekmedskip
%
+% 2008/08/10 I~spent all the night debugging \cs{penalty 10000} that
+% was added after a~hypertarget in vertical mode. I~didn't dare to
+% touch \pk{hyperref}'s guts, so I~worked it around with ensuring
+% every \cs{grefstepcounter} to be in hmode:
+
+\protected\def\hgrefstepcounter#1{%
+ \ifhmode\leavevmode\fi\grefstepcounter{#1}}
+
+% By the way I~read some lines from \TB\ and was reminded that
+% \cs{unskip} strips any last skip, whether horizontal or
+% vertical. And I~use \cs{unskip} mostly to replace a~blank space with
+% some fixed skip. Therefore define
+
+\protected\def\hunskip{\ifhmode\unskip\fi}
+
+% Note the two macros defined above are \cs{protected}. I~think it's
+% a~good idea to make \cs{protected} all the macros that contain
+% assignments. There is one more thing with \cs{ifhmode}: it can be different
+% at the point of \cs{edef} and at the point of execution.
+
+
% Another shorthand. It may decrease a~number of |\expandafter|s e.g.
% \Define\glet
\def\glet{\global\let}
@@ -248,6 +288,11 @@
% \Define\addtomacro
\let\addtomacro=\addto@macro
+% 2008/08/09 I~need to prepend something not add at the end---so
+\long\def\prependtomacro#1#2{%
+ \edef#2{\unexpanded{#1}\@xa\unexpanded\@xa{#2}}}
+% Note that \cs{prependtomacro} can be prefixed.
+
% \Define\addtotoks
\long\def\addtotoks#1#2{%
#1=\@xa{\the#1#2}}
@@ -280,8 +325,11 @@
% \changes{v0.59}{06/09/04}{moved here from \pk{gmdoc}}
\def\gmshowlists{\showboxdepth=1000 \showboxbreadth=1000 \showlists}
-% \Define\nameshow
-\newcommand*\nameshow[1]{\@xa\show\csname#1\endcsname}
+
+\newcommand\nameshow[1]{\@xa\show\csname#1\endcsname}
+\newcommand\nameshowthe[1]{\@xa\showthe\csname#1\endcsname}
+% Note that to get proper |\showthe\my@dimen14| in the `other' |@|'s
+% scope you write |\nameshowthe{my@dimen}14|\,.
% Standard |\string| command returns a~string of `other' chars except
@@ -457,7 +505,8 @@
\long\def\afteriffififi#1#2\fi#3\fi#4\fi{\fi\fi#1}
\long\def\afterfififi#1#2\fi#3\fi#4\fi{\fi\fi\fi#1}
-% \division{Almost an Environment or Redefinition of \cs{begin}}
+% \division{Environments redefined}
+% \subdivision{Almost an Environment or Redefinition of \cs{begin}}
%
% We'll extend the functionality of |\begin|: the non-starred
% instances shall act as usual and we'll add the starred version. The
@@ -485,11 +534,13 @@
%\end{verbatim}
%
% \Define\@begnamedgroup
-\@ifdefinable\@begnamedgroup{\relax}
-\def\@begnamedgroup#1{%
+\long\def\@begnamedgroup#1{%
\@ignorefalse% not to ignore blanks after group
\begingroup\@endpefalse
- \def\@currenvir{#1}%
+ \edef\@currenvir{#1}% We could do recatcoding
+ % through\inverb|\string| but all the name `other' 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}%
\csname #1\endcsname}% if the argument is a~command's name (an
% environment's e.g.), this command will now be executed. (If the
@@ -505,13 +556,19 @@
% And we make it the starred version of |\begin|.
% \begin{DoIndex}{\begin}
-% \Define\old@begin \Define\begin
-\let\old@begin\begin
+% \Define\begin
% \Define*\begin*
-\def\begin{\@ifstar{\@begnamedgroup}{\old@begin}}
+\def\begin{\@ifstar{\@begnamedgroup}{%
+ \@begnamedgroup@ifcs}}
% \end{DoIndex}
-% \division{Improvement of \cs{end}}
+\def\@begnamedgroup@ifcs#1{%
+ \ifcsname#1\endcsname\afterfi{\@begnamedgroup{#1}}%
+ \else\afterfi{\@latex@error{Environment #1 undefined}\@eha}%
+ \fi}%
+
+
+%\subdivision{\cs{@ifenvir} and Improvement of \cs{end}}
%
% \changes{v0.74}{2006/11/27}{The catcodes of \cs{begin} and \cs{end}
% argument(s) don't have to agree strictly anymore: an environment is properly
@@ -519,18 +576,27 @@
% same \cs{csname}}
%
% It's very clever and useful that |\end| checks whether its argument
-% is |ifx|-equivalent |@currenvir|. However, it works not quite as
-% I~would expect: Since the idea of environment is to open a~group and
-% launch the cs named in the |\begin|'s argument. That last thing is
-% done with |\csname...\endcsname| so the char catcodes are
-% equivalent. Thus should be also in the |\end|'s test and therefore
-% we ensure the compared texts are both expanded and made all `other'.
-
-\def\@checkend#1{%
- \edef\reserved@a{\@xa\string\csname#1\endcsname}%
- \edef\exii@currenvir{\@xa\string\csname\@currenvir\endcsname}%
- \ifx\reserved@a\exii@currenvir\else\@badend{#1}\fi}
+% is |ifx|-equivalent |@currenvir|. However, in standard \LaTeX\ it
+% works not quite as I~would expect: Since the idea of environment is
+% to open a~group and launch the \acro{CS} named in the |\begin|'s
+% argument. That last thing is done with |\csname...\endcsname| so
+% the char catcodes are equivalent. Thus should be also in the
+% |\end|'s test and therefore we ensure the compared texts are both
+% expanded and made all `other'.
+
+% First a~(not expandable) macro that checks whether current
+% environment is as given in |#1|.
+%
+\long\def\@ifenvir#1#2#3{%\label{@ifenvir}
+ % \changes{v0.92}{2008/08/07}{added}
+ \edef\gmu@reserveda{\@xa\string\csname\@currenvir\endcsname}%
+ \edef\gmu@reservedb{\@xa\string\csname#1\endcsname}%
+ \ifx\gmu@reserveda\gmu@reservedb\afterfi{#2}%
+ \else\afterfi{#3}%
+ \fi}
+\def\@checkend#1{\@ifenvir{#1}{}{\@badend{#1}}}
+% \changes{v0.92}{2008/08/07}{shortened thanks to \cs{@ifenvir}}
% Thanks to it you may write |\begin{macrocode*}| with |*|\catother
% and end it with |\end{macrocode*}| with |*|\catletter\ (that was the
% problem that led me to this solution). The error messages looked
@@ -541,6 +607,7 @@
% or letter star.
+
%\division{From \pk{relsize}}
%
%\changes{v0.58}{06/09/02}{Relative fontsize change macros added}
@@ -636,6 +703,7 @@
% standard definition.
% \Define\gobbletwo
\long\def\gobble#1{}
+\let\@gobble\gobble
\let\gobbletwo\@gobbletwo
@@ -783,8 +851,10 @@
% |\discretionary| \TeX\ primitive has three arguments: |#1| `before
% break', |#2| `after break', |#3| `without break', remember?
% \Define\discre \Define\discret
-\def\discre#1#2#3{\kern0sp\discretionary{#1}{#2}{#3}\penalty10000\hskip0sp\relax}
-\def\discret#1{\kern0sp\discretionary{#1}{#1}{#1}\penalty10000\hskip0sp\relax}
+\def\discre#1#2#3{\leavevmode\kern0sp%
+ \discretionary{#1}{#2}{#3}\penalty10000\hskip0sp\relax}
+\def\discret#1{\leavevmode\kern0sp%
+ \discretionary{#1}{#1}{#1}\penalty10000\hskip0sp\relax}
% A~tiny little macro that acts like |\-| outside the math mode and
% has its original meaning inside math.
@@ -1963,8 +2033,8 @@
\@ifpackageloaded{gmverb}{\RestoreMacro\verb}{}%
\AtBeginDocument{%
\RestoreMacro\LaTeX\RestoreMacro*{LaTeX }}% my version of the
- % \LaTeX\ logo has been stored just
- % after defining, in line \ref{SMLaTeX}.
+ % \LaTeX\ logo has been stored just
+ % after defining, in line \ref{SMLaTeX}.
% ^^A \def\dekfracc##1/##2{\vfrac{##1}{##2}}
}{}}
@@ -2138,12 +2208,12 @@
% because no one `normal' redefines the active space. But we are
% \emph{not} normal and we do \emph{not} do usual things and therefore
% we want a~declaration that not only will |\active|ate the space but
-% also will (re)define it as the |\ | primitive. So define
+% also will (re)define it as the \verb*|\ | primitive. So define
% |\gmobeyspaces| that obeys this requirement.
%
% (This definition is repeated in \pk{gmverb}.)
\foone{\catcode`\ \active}%
-{\def\gmobeyspaces{\catcode`\ \active\let \ }}
+{\def\gmobeyspaces{\let \ \catcode`\ \active}}
% While typesetting poetry, I~was surprised that sth.\ didn't work. The
% reason was that original |\obeylines| does |\let| not |\def|, so I~give
@@ -2182,8 +2252,8 @@
\sffamily\bfseries\huge TODO!\if\relax#1\relax\else\space\fi#1}}
% \changes{v0.64}{06/9/17}{moved here from \pk{pmlectionis}}
-% \iffalse
-% The code contained in this iffalse I~wrote to make the table of
+% \skiplines
+% The code contained in this skiplines I~wrote to make the table of
% contents twocolumn. The first difficulties led me to making the
% writes immediate at begin and end document but this also worked bad
% in a~special situation, namely, when a~contents line was added on
@@ -2208,7 +2278,7 @@
% \MakeWriteImmediate
% \addtocontents{#1}{#2}%
% }}
-% \fi
+% \endskiplines
% I~like twocolumn tables of contents. First I~tried to provide them by
% writing |\begin{multicols}{2}| and |\end{multicols}| outto the
@@ -2436,8 +2506,8 @@
%\changes{v0.82}{2007/07/17}{added}
% And a~macro to forbid hyphenation of the next word:
-\newcommand*\nohy{\kern0sp\relax}
-\newcommand*\yeshy{\penalty10000\hskip0sp\relax}
+\newcommand*\nohy{\leavevmode\kern0sp\relax}
+\newcommand*\yeshy{\leavevmode\penalty10000\hskip0sp\relax}
% In both of the above definitionc `0sp' not |\z@| to allow their
% writing to and reading from files where @ is `other'.
@@ -2598,10 +2668,10 @@
\ifnum\gmu@tempa=\arabic{page}\relax \@xa\ignorespaces\fi
}
-
-%\subdivision{\env{luzniej} and \env{napapierki}---environments ^^B
-% used in page breaking for money}
+%\subdivision{\env{luzniej} and \env{napapierki}---environments used\
+% in page breaking for money}
%
+% \QueerEOL
% The name of first of them comes from Polish typesetters' phrase
% ``rozbija\cacute\ [sk\l ad] na papierki''---`to broaden [leading] with
% paper scratches'.