diff options
author | Norbert Preining <norbert@preining.info> | 2019-09-15 03:00:57 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2019-09-15 03:00:57 +0000 |
commit | fed27f633aadbacbd3d1221da7993fed8d4efffe (patch) | |
tree | 3cae3cde89de26b178894a2e88d9ef5ba89dafcc /macros/latex-dev/required | |
parent | 0eea86bf18826522b3686f54fc3afb8ddc31e62a (diff) |
CTAN sync 201909150300
Diffstat (limited to 'macros/latex-dev/required')
124 files changed, 48987 insertions, 12 deletions
diff --git a/macros/latex-dev/required/amsmath/README.md b/macros/latex-dev/required/amsmath/README.md new file mode 100644 index 0000000000..66a27edf03 --- /dev/null +++ b/macros/latex-dev/required/amsmath/README.md @@ -0,0 +1,81 @@ +The amsmath bundle for LaTeX +============================ + +Release 2019-10-01 pre-release 3 + +Overview +-------- + +The `amsmath` package is an extension package for LaTeX that provides +additional features to facilitate mathematical typesetting. It has been +developed by the American Mathematical Society (AMS) and released for general +use as a service to the mathematical community. A number of smaller +auxiliary packages are also distributed with the `amsmath` package. + +Effective in 2016, maintenance of `amsmath was transferred from AMS to +the LaTeX Project; as `amsmath` is considered a "required" package, this +centralizes control over the core LaTeX components. + +Installation +------------ + +We no longer distribute installation instructions for the various TeX +implementations. All modern TeX systems include `amsmath` as-standard, and end +users should in general use the release versions supplied in this way. + +Release distribution is carried out only through the CTAN archives. + +Documentation +------------- + +The primary documentation for `amsmath` is in provided as `amsldoc.pdf`. + +Additional documentation files include: + + - `diffs-m.txt` + - `subeqn.pdf` + - `technote.pdf` + - `testmath.pdf` + +which are included in the collection. All of these can be accessed +easily with most distributions by entering `texdoc` *filename* at the +command line, or via [TeXdoc Online](http://texdoc.net). + +Change logs +----------- + +The file `changes.txt` lists recent changes in reverse chronological order. + +The file `diffs-m.txt` contains information on development and changes +prior to 2000. + +Reporting Bugs +-------------- + +If you wish to report a problem or bug in the `amsmath` bundle +please use the [Issue Tracker for LaTeX2e on +GitHub](https://github.com/latex3/latex2e/issues) +and follow the guidelines that pop up if you press the "New issue" button. + +In particular, to check that you are really seeing a bug, please write +a short, self-contained document that shows the problem. This should +include the `latexbug` package, which will warn if your test file is +not suitable for one or the other reason. See the [CONTRIBUTING +guide](https://github.com/latex3/latex2e/blob/master/CONTRIBUTING.md) +for further details, or if you need to obtain the `latexbug` package. + +If the bug turns out to be with third-party software then please +contact the developer, and not us! + +License +------- + +The contents of this bundle are distributed under the [LaTeX Project +Public License](https://www.latex-project.org/lppl/lppl-1-3c/), +version 1.3c or later. + +----- + +<p>Copyright (C) 2001-2004, 2007, 2008, 2010, 2011, 2013 American Mathematical Society. <br /> +<p>Copyright (C) 2016-2019 The LaTeX Project and American Mathematical Society. <br /> + diff --git a/macros/latex-dev/required/amsmath/ams-external.txt b/macros/latex-dev/required/amsmath/ams-external.txt new file mode 100644 index 0000000000..fa2dbea556 --- /dev/null +++ b/macros/latex-dev/required/amsmath/ams-external.txt @@ -0,0 +1,547 @@ +%%% list of external commands used by amsmath (not totally correct) + +\! +\" +\( +\* +\, +\- +\. +\/ +\: +\; +\= +\Acute +\AmS +\AmSfont +\And +\AtBeginDocument +\Bar +\Big +\Bigg +\Biggr +\Bigr +\Breve +\Check +\DOTS +\DOTSB +\DOTSI +\DOTSX +\Ddot +\DeclareFontEncoding +\DeclareFontShape +\DeclareMathAccent +\DeclareMathDelimiter +\DeclareMathOperator +\DeclareMathSymbol +\DeclareOption +\DeclareRobustCommand +\Dot +\ExecuteOptions +\GenericError +\GenericInfo +\GenericWarning +\Grave +\Hat +\Leftarrow +\Longleftarrow +\Longleftrightarrow +\Longrightarrow +\MessageBreak +\MultiIntegral +\PackageError +\PackageWarning +\PackageWarningNoLine +\PassOptionsToPackage +\Pr +\ProcessOptions +\Relbar +\RequirePackage +\Rightarrow +\Tilde +\Umathaccent +\Umathcar +\Umathchar +\Umathcharnumdef +\Umathcode +\Umathcodenum +\Umathfractiondelsize +\Vec +\Vert +\XeTeXcharclass +\[ +\] +\above +\abovedisplayskip +\abovewithdelims +\accentedsymbol +\acute +\addtocounter +\advance +\aftergroup +\allowbreak +\allowdisplaybreaks +\alph +\arabic +\arccos +\arcsin +\arctan +\arg +\array +\arraycolsep +\arraystretch +\atop +\atopwithdelims +\badness< +\bar +\baselineskip +\baselineskip6 +\begin +\begingroup +\belowdisplayskip +\bgroup +\big +\bigcap +\bigcup +\bigg +\biggr +\bigodot +\bigoplus +\bigotimes +\bigr +\bigsqcup +\biguplus +\bigvee +\bigwedge +\binom +\bmod +\boldsymbol +\box +\boxed +\breve +\cases +\cdotp +\cdots +\cfrac +\char +\chardef +\check +\cleaders +\colon +\columnwidth +\coprod +\copy +\cos +\cosh +\cot +\coth +\cr +\crcr +\csc +\csname +\csnamen +\csnamethe +\dbinom +\ddddot +\dddot +\ddot +\def +\deg +\delimiter +\delimiterfactor +\delimitershortfall +\det +\dfrac +\dim +\displaybreak +\displayindent +\displaylimits +\displaystyle +\displaywidth +\divide +\do +\dot +\doteq +\dots +\dotsb +\dotsc +\dotsi +\dotsm +\dotso +\dp +\edef +\egroup +\else +\end +\endalign +\endaligned +\endarray +\endcsname +\endgather +\endgroup +\endmathdisplay +\endmatrix +\endmultline +\endsplit +\endsubarray +\eqno +\eqref +\everycr +\everydisplay +\everymath +\exp +\expandafter +\fbox +\fi +\fontchardp +\fontcharht +\fontdimen +\fontencoding +\fontfamily +\frac +\fracwithdelims +\futurelet +\gcd +\gdef +\genfrac +\global +\grave +\halign +\halignto +\hat +\hbox +\hdots +\hdotsfor +\hfil +\hfill +\hfilneg +\hfuzz +\hom +\hookleftarrow +\hookrightarrow +\hrule +\hskip +\ht +\ialign +\idotsint +\if +\ifDOTS +\ifcase +\ifdim +\iff +\iffalse +\iffalse%initialvalue +\ifhbox +\ifinner +\ifm +\ifmacrostarts +\ifmmode +\ifnum +\ifnum` +\ifodd +\iftrue +\ifvmode +\ifx +\ignorespaces +\ignorespacesafterend +\iiiint +\iiint +\iint +\impliedby +\implies +\inf +\injlim +\int +\interdisplaylinepenalty +\intertext +\intop +\joinrel +\jot +\ker +\kern +\l% +\lVert +\label +\lastbox +\lastkern +\lastskip +\lbrace +\ldots +\leavevmode +\left +\leftarrow +\leftmargini +\leftmarginiminus +\leftroot +\leqno +\let +\lg +\lhook +\lim +\liminf +\limits +\lineskip +\lineskiplimit +\linewidth +\llap +\ln +\log +\long +\longleftarrow +\longleftrightarrow +\longmapsto +\longrightarrow +\loop +\lq +\lvert +\mapsto +\mapstochar +\mathaccent +\mathaccentV +\mathalpha +\mathbin +\mathchar +\mathchardef +\mathchoice +\mathclose +\mathcode +\mathdisplay +\mathellipsis +\mathgroup +\mathhexbox +\mathinner +\mathop +\mathopen +\mathord +\mathpalette +\mathpunct +\mathrel +\mathring +\mathsurround +\mathxxx +\mathxxxtest +\mathxxxx +\matrix +\max +\maxdimen +\mbox +\meaning +\medmuskip +\medspace +\min +\minalignsep +\mintagsep +\mkern +\mod +\moveleft +\mskip +\mspace +\multicolumn +\multiply +\multlinegap +\multlinegap10pt +\multlinetaggap +\multlinetaggap10pt +\negmedspace +\negthickspace +\negthinspace +\newbox +\newcommand +\newcount +\newcounter +\newdimen +\newenvironment +\newhelp +\newif +\newmuskip +\newskip +\newtoks +\noalign +\nobreak +\nobreakdash +\nobreakspace +\noexpand +\noindent +\nointerlineskip +\nolimits +\nonscript +\nonumber +\normalbaselines +\normalcolor +\normalfont +\normallineskiplimit +\not +\notag +\nottest +\null +\nulldelimiterspace +\number +\numberwithin +\of +\oint +\ointop +\omit +\openup +\operatorfont +\operatorname +\operatornamewithlimits +\or +\over +\overleftarrow +\overleftrightarrow +\overline +\overrightarrow +\overset +\overwithdelims +\par +\parshape +\penalty +\pmatrix +\pmod +\pod +\postdisplaypenalty +\predisplaypenalty +\prevdepth +\primfrac +\prod +\projlim +\protect +\providecommand +\qopname +\quad +\rVert +\raise +\raisetag +\rangle +\rbrace +\rbrack +\rceil +\ref +\refstepcounter +\relax +\relaxo +\relbar +\renewcommand +\renewenvironment +\repeat +\rfloor +\rgroup +\rhook +\right +\rightarrow +\rlap +\rmoustache +\romannumeral +\root +\rootbox +\rq +\rvert +\scriptfont +\scriptscriptfont +\scriptscriptstyle +\scriptstyle +\sec +\selectfont +\setbox +\setcounter +\shoveleft +\shoveright +\sideset +\sim +\sin +\sinh +\skewchar +\smash +\space +\spaceor +\span +\spbreve +\spcheck +\spdddot +\spddot +\spdot +\sphat +\split +\sptilde +\sqrtsign +\stepcounter +\string +\strut +\strutbox +\subarray +\substack +\sum +\sup +\symoperators +\tabskip +\tag +\taghere +\tan +\tanh +\tbinom +\text +\textellipsis +\textfont +\textstyle +\textup +\tfrac +\the +\theequation +\theparentequation +\thetag +\thickmuskip +\thickmuskip0mu +\thickspace +\thinmuskip +\thinspace +\tilde +\tmspace +\toks +\typeout +\u +\underleftarrow +\underleftrightarrow +\underrightarrow +\underset +\unhbox +\unhcopy +\unpenalty +\unskip +\unvbox +\unvcopy +\uppercase +\uproot +\usefont +\value +\varDelta +\varGamma +\varLambda +\varOmega +\varPhi +\varPi +\varPsi +\varSigma +\varTheta +\varUpsilon +\varXi +\varinjlim +\varliminf +\varlimsup +\varprojlim +\vbox +\vcenter +\vec +\vee +\veqno +\vert +\vrule +\vskip +\vss +\vtop +\wd +\widehat +\widetilde +\xdef +\xleaders +\xleftarrow +\xrightarrow diff --git a/macros/latex-dev/required/amsmath/ams-internal.txt b/macros/latex-dev/required/amsmath/ams-internal.txt new file mode 100644 index 0000000000..06a0c97f09 --- /dev/null +++ b/macros/latex-dev/required/amsmath/ams-internal.txt @@ -0,0 +1,482 @@ +%%%% list of internal commands used by amsmath (not totally correct) + +\@@above +\@@abovewithdelims +\@@atop +\@@atopwithdelims +\@@eqno +\@@italiccorr +\@@leqno +\@@over +\@@overline +\@@overwithdelims +\@@sqrt +\@@undefined +\@@underline +\@M +\@addtoreset +\@amsmath@err +\@arrayboxrestore +\@arrayparboxrestore +\@backslashchar +\@badmath +\@car +\@cdots +\@centering +\@checkend +\@currentlabel +\@currenvir +\@declmathop +\@depth +\@display@init +\@displaytrue +\@eha +\@ehc +\@ehd +\@elt +\@empty +\@emptytoks +\@envbody +\@eqnnum +\@eqnswfalse +\@eqnswtrue +\@eqpen +\@fleqntrue +\@for +\@genfrac +\@getpen +\@gobble +\@gobblefour +\@gobblethree +\@gobbletwo +\@gtempa +\@height +\@iden +\@ifdefinable +\@ifnextchar +\@ifnotempty +\@ifpackageloaded +\@ifpackagewith +\@ifstar +\@ifundefined +\@ignoretrue +\@ldots +\@let@token +\@lign +\@m +\@mathmargin +\@mathmeasure +\@mathstyle +\@namedef +\@ne +\@nil +\@nocnterr +\@nocounterr +\@nx +\@onlypreamble +\@saveprimitive +\@sptoken +\@stpelt +\@tempa +\@tempb +\@tempc +\@tempcnta +\@tempcntb +\@tempd +\@tempdima +\@tempdimb +\@tempdimc +\@temptokena +\@testopt +\@totalleftmargin +\@undefined +\@width +\@xp +\@xp#1 +\DN@ +\DOTS@ +\DOTSCASE@ +\FN@ +\Invalid@@ +\Leftarrowfill@ +\Leftrightarrowfill@ +\Let@ +\Mathstrut@ +\Mathstrutbox@ +\RIfM@ +\Rightarrowfill@ +\SK@@label +\SK@equationtrue +\SK@tagform@ +\Umathch@ +\acc@check +\acc@error +\accentclass@ +\add@amp +\add@amps +\addto@envbody +\addto@hook +\align@ +\align@preamble +\align@recover +\aligned@a +\alignedat@a +\alignedspace@left +\alignsafe@testopt +\alignsep@ +\alignsep@- +\alignsep@< +\alt@tag +\ams@DeclareRobustCommand +\ams@def +\ams@newcommand +\ams@renewcommand +\andhelp@ +\arrowfill@ +\bBigg@ +\begin@stack +\big@size +\bigcap@ +\bigcup@ +\bigodot@ +\bigoplus@ +\bigotimes@ +\bigsqcup@ +\biguplus@ +\bigvee@ +\bigwedge@ +\binrel@ +\binrel@@ +\black@ +\bold@false +\bold@true +\boldsymboldots@ +\boxz@ +\c@MaxMatrixCols +\c@MaxMatrixColsc +\calc@shift@align +\calc@shift@gather +\check@mathfonts +\checkat@false +\checkat@true +\cl@@ckpt +\classnum@ +\cmex@opt +\collect@@body +\collect@body +\column@ +\column@plus +\coprod@ +\count@ +\csname@@ +\csnamec@ +\csnamecl@ +\csnameemdf@ +\csnamem@gobble +\csnamemb@ +\ctagsplit@false +\ctagsplit@true +\default@tag +\delayed@ +\df@label +\df@tag +\dft@tag +\dimen@ +\displ@y +\displ@y@ +\displaywidth@ +\dotsb@ +\dotso@ +\dotsspace@ +\dspbrk@ +\dspbrk@context +\dspbrk@lvl +\dt@pfalse +\dt@ptrue +\emdf@L +\emdf@La +\emdf@R +\emdf@Ra +\emdf@U +\emdf@Ua +\endmathdisplay@a +\endmathdisplay@fleqn +\endmultline@math +\env@cases +\env@matrix +\eqnshift@ +\every@math@size +\ex@ +\ext@arrow +\extra@ +\extrap@ +\f@series +\f@size +\field@lengths +\fieldlengths@ +\finsm@sh +\firstchoice@false +\firstchoice@true +\fracwithdelims@ +\frozen@everymath +\gather@ +\gather@split +\gdisplaywidth@ +\genfrac@choice +\genfrac@rule +\getdsp@pen +\getmathch@ +\getmathcode@ +\gmeasure@ +\gobble@tag +\gtest@false +\gtest@true +\hdots@for +\hexnumber@ +\if@display +\if@eqnsw +\if@fleqn +\ifbold@ +\ifcheckat@ +\ifctagsplit@ +\ifdt@p +\iffirstchoice@ +\ifgtest@ +\ifinalign@ +\ifingather@ +\ifmeasuring@ +\ifshifttag@ +\ifst@rred +\iftag@ +\iftagsleft@ +\iftagsleft@L +\ifxxat@ +\ilimits@ +\inalign@false +\inalign@true +\incr@eqnum +\inf@bad +\ingather@false +\ingather@true +\insplit@ +\intdots@ +\intertext@ +\intkern@ +\ints@a +\ints@b +\ints@c +\invalid@tag +\keybin@ +\keybin@test +\label@in@display +\leavevmode@ifvmode +\leftarrowfill@ +\leftrightarrowfill@ +\leftroot@ +\leftroot@mu +\lendmultline@ +\lendsplit@ +\lineht@ +\ltx@label +\m@gobble +\m@ne +\m@th +\m@th$ +\macc@a +\macc@adjust +\macc@code +\macc@depth +\macc@group +\macc@kerna +\macc@kernb +\macc@nested +\macc@nested@a +\macc@nucleus +\macc@palette +\macc@set@skewchar +\macc@skewchar +\macc@style +\macc@test +\macc@tmp +\macro@ +\macro@@ +\make@df@tag +\make@df@tag@@ +\make@df@tag@@@ +\make@display@tag +\makesm@sh +\maketag@@ +\maketag@@@ +\math@ +\math@bgroup +\math@cr +\math@cr@ +\math@cr@@ +\math@cr@@@ +\math@cr@@@align +\math@cr@@@align@measure +\math@cr@@@aligned +\math@cr@@@alignedat +\math@cr@@@gather +\math@cr@@[ +\math@egroup +\mathbin@ +\mathch@ +\mathdisplay@@pop +\mathdisplay@@push +\mathdisplay@pop +\mathdisplay@push +\mathdisplay@stack +\mathrel@ +\mathsm@sh +\matrix@check +\matrix@error +\maxcol@width +\maxcolumn@widths +\maxfields@ +\mb@b +\mb@t +\mb@tb +\mdots@ +\mdots@@ +\meaning@ +\meaning@@ +\measure@ +\measuring@false +\measuring@true +\mmeasure@ +\multline@ +\multline@indent +\new@ifnextchar +\newmcodes@ +\newmcodes@m +\newmcodes@o +\next@ +\nextii@ +\nextiii@ +\nextiv@ +\nextix@ +\nextv@ +\nextvi@ +\nextvii@ +\nextviii@ +\nfss@text +\nmlimits@ +\noaccents@ +\nogood@displaybreak +\nolimits@ +\nomath@env +\nonmatherr@ +\not@ +\operator@font +\operator@fontlim$ +\operator@fontmod +\overarrow@ +\p@ +\p@equation +\place@tag +\place@tag@gather +\plainroot@ +\print@eqnum +\process@envbody +\prod@ +\protected@edef +\push@begins +\r@@t +\raise@tag +\relaxnext@ +\rendmultline@ +\rendsplit@ +\reset@equation +\reset@strutbox@ +\resetMathstrut@ +\restore@hfuzz +\restore@math@cr +\restorealignstate@ +\restorecolumn@ +\restorecounters@ +\rightarrowfill@ +\rightdelim@ +\row@ +\savealignstate@ +\savecolumn@ +\savecounters@ +\savefieldlength@ +\saveshift@ +\savetaglength@ +\select@group +\set@field +\set@gather@field +\set@mathaccent +\setboxz@h +\sf@size +\shdots@for +\shift@tag +\shifttag@false +\shifttag@true +\sixt@@n +\skip@ +\slimits@ +\split@ +\split@al@a +\split@al@tagcheck +\split@aligned +\split@err +\split@tag +\split@warning +\spread@equation +\ssf@size +\st@rredfalse +\st@rredtrue +\start@align +\start@aligned +\start@gather +\start@multline +\std@equal +\std@minus +\striplong@ +\strut@ +\strut@$ +\strutbox@ +\sum@ +\tag@false +\tag@help +\tag@in@align +\tag@in@display +\tag@in@display@a +\tag@lengths +\tag@shifts +\tag@true +\tag@width +\tagform@ +\tagshift@ +\tagsleft@false +\tagsleft@true +\tagwidth@ +\tdots@ +\text@ +\textdef@ +\thecharacter@ +\thedots@ +\thr@@ +\toks@ +\too@wide +\totwidth@ +\try@load@fontshape +\tw@ +\underarrow@ +\uproot@ +\use@mathgroup +\varlim@ +\varliminf@ +\varlimsup@ +\wdz@ +\x@calc@shift@lc +\x@calc@shift@lf +\x@calc@shift@rc +\x@calc@shift@rf +\x@lcalc@width +\x@rcalc@width +\xatlevel@ +\xxat@true +\z@ diff --git a/macros/latex-dev/required/amsmath/amsbsy.dtx b/macros/latex-dev/required/amsmath/amsbsy.dtx new file mode 100644 index 0000000000..890fbd0d82 --- /dev/null +++ b/macros/latex-dev/required/amsmath/amsbsy.dtx @@ -0,0 +1,238 @@ +% +% \iffalse meta-comment +% +% Copyright (C) 1995, 1999 American Mathematical Society. +% Copyright (C) 2016-2019 LaTeX3 Project and American Mathematical Society. +% +% This work may be distributed and/or modified under the +% conditions of the LaTeX Project Public License, either version 1.3c +% of this license or (at your option) any later version. +% The latest version of this license is in +% https://www.latex-project.org/lppl.txt +% and version 1.3c or later is part of all distributions of LaTeX +% version 2005/12/01 or later. +% +% This work has the LPPL maintenance status `maintained'. +% +% The Current Maintainer of this work is the LaTeX3 Project. +% +% \fi +% +%\iffalse +%<*driver> +\documentclass{amsdtx} +\def\MaintainedByLaTeXTeam#1{% +\begin{center}% +\fbox{\fbox{\begin{tabular}{@{}l@{}}% +This file is maintained by the \LaTeX{} Project team.\\% +Bug reports can be opened (category \texttt{#1}) at\\% +\url{https://latex-project.org/bugs/}.\end{tabular}}}\end{center}} +\usepackage{amsbsy} +\GetFileInfo{amsbsy.sty} +\begin{document} +\title{The \pkg{amsbsy} package} +\author{Frank Mittelbach\and Rainer Sch\"opf\and Michael Downes} +\date{Version \fileversion, \filedate} +\DocInput{amsbsy.dtx} +\end{document} +%</driver> +%\fi +% +% \maketitle +% \MaintainedByLaTeXTeam{amslatex} +% +% \MakeShortVerb\| +% +% \section{Introduction} +% +% The package \texttt{amsbsy}, first written in 1989, implements a +% few commands for producing \textbf{bold} characters in the `normal' +% \emph{math version}. +% \begin{quote}\em +% Note: It is recommended nowadays to use the \pkg{bm} package, which +% became available in 1997. +% \end{quote} +% +% If we have bold fonts which contain the character in question then +% we will use these fonts to produce the wanted character. But +% sometimes math fonts are only available in a certain weight +% (e.g.\ the AMS symbol fonts). +% \DescribeMacro\pmb +% For these cases we provide a command which is called \verb+\pmb+ (an +% acronym for \textbf{p}oor \textbf{m}an's \textbf{b}old) with one argument. +% The bolder weight is achieved by copying the argument three times in +% slightly different positions which is better than nothing but no +% match for a real bold font. +% +% \DescribeMacro\boldsymbol +% There also exists the \verb+\boldsymbol+ command which is better in +% all cases where bold fonts exists. This command will internally +% switch to the corresponding `bold' \emph{math version} typeset its +% argument in this version. +% +% Both commands will preserve the nature of their arguments, i.e.\ if +% they get a relational atom their result will again be a relation as +% far as \tex/'s mathspacing is concerned. +% +% Since it is good policy to make at least a small test we try to +% typeset the infinity sign ($\infty$) first with \verb+\pmb+ and then +% with \verb+\boldsymbol+. +% \[ +% \pmb{\infty} = \boldsymbol{\infty} \quad ? +% \] +% \StopEventually{} +% +% Standard package info. +% \begin{macrocode} +\NeedsTeXFormat{LaTeX2e}% LaTeX 2.09 can't be used (nor non-LaTeX) +[1994/12/01]% LaTeX date must December 1994 or later +\ProvidesPackage{amsbsy}[1999/11/29 v1.2d Bold Symbols] +% \end{macrocode} +% +% \section{The implementation} +% +% We need some functions from the \pkg{amsgen} package. +% \begin{macrocode} +\RequirePackage{amsgen} +% \end{macrocode} +% +%\begin{macro}{\boldsymbol} +% In implementing boldsymbol, we must take into account \tex/'s +% limitation of only 16 mathgroups (math families, in Knuth's +% terminology). If we wanted to maintain mathgroups for both the bold +% and non-bold version of each math font, it would not take long to +% run out of mathgroups. Therefore what we do instead for a bold +% symbol is embed it in an \verb|\hbox|; inside that \verb|\hbox|, +% when we start another math formula, we can change all the +% mathgroups to their bold equivalents. +% +% However, to get the correct math style inside the hbox (display, +% text, script or scriptscript) we have to use \verb|\mathchoice|. +% Since \verb|\mathversion{bold}| has a lot of overhead, and +% \verb|\mathchoice| typesets the argument text four times, we would +% rather not put the \verb|\mathversion| command inside each +% \verb|\hbox| in the \verb|\mathchoice|; on the other hand, +% \verb|\mathversion| gives an error message if it's used in math +% mode. Therefore if we want to execute \verb|\mathversion{bold}| +% before starting the \verb|\mathchoice| we have to temporarily +% disable the \verb|\@nomath| error. (The error message is intended +% to keep people from accidentally emboldening a preceding part of a +% math formula, since only the mathgroups defined at the end of a +% math formula will determine the fonts used in that formula; but we +% are going to typeset our bold symbol not in the current formula but +% in an embedded formula, so that this danger doesn't apply here.) +% \begin{macrocode} +\DeclareRobustCommand{\boldsymbol}[1]{% +% \end{macrocode} +% Start a group to localize the change of \verb|\@nomath|: +% \begin{macrocode} + \begingroup +% \end{macrocode} +% Disable \verb|\@nomath| so that we don't have to leave math +% mode before executing \verb|\mathversion|: +% \begin{macrocode} + \let\@nomath\@gobble \mathversion{bold}% +% \end{macrocode} +% \cs{math@atom} is a test macro which looks at its argument and +% produces a math atom of the proper class. +% \begin{macrocode} + \math@atom{#1}{% +% \end{macrocode} +% Although it is tempting to use \verb|\text| here, to save some +% main memory, that caused a bug in the past due to some internal +% interactions with \verb|\mathversion|. +% \begin{macrocode} + \mathchoice% + {\hbox{$\m@th\displaystyle#1$}}% + {\hbox{$\m@th\textstyle#1$}}% + {\hbox{$\m@th\scriptstyle#1$}}% + {\hbox{$\m@th\scriptscriptstyle#1$}}}% +% \end{macrocode} +% End the group we started earlier. +% \begin{macrocode} + \endgroup} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\math@atom} +% The macro \verb+\math@atom+ looks at its argument and produce a +% correct math atom, i.e.\ a primitive like \verb+\mathopen+. +% Until the day we have a real implementation for all cases we use +% the \verb+\binrel@+ command from \amstex/ which can distinguish +% between binary, relation and ord atoms. +% \begin{macrocode} +\def\math@atom#1#2{% + \binrel@{#1}\binrel@@{#2}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\pmb} +% Poor man's bold command, works by typesetting multiple copies of +% the given argument with small offsets. +% \begin{macrocode} +\DeclareRobustCommand{\pmb}{% + \ifmmode\else \expandafter\pmb@@\fi\mathpalette\pmb@} +% \end{macrocode} +% +% \cs{pmb@@} is called by \cn{pmb} in the non-math-mode case. +% Discard the first two arguments which are for the math-mode case. +% \begin{macrocode} +\def\pmb@@#1#2#3{\leavevmode\setboxz@h{#3}% + \dimen@-\wdz@ + \kern-.5\ex@\copy\z@ + \kern\dimen@\kern.25\ex@\raise.4\ex@\copy\z@ + \kern\dimen@\kern.25\ex@\box\z@ +} +% \end{macrocode} +% +% \begin{macrocode} +\newdimen\pmbraise@ +% \end{macrocode} +% Note: because of the use of \cs{mathpalette}, if \cs{pmb@} is applied to a +% single math italic character (or a single character from some other +% slanted math font), the italic correction will be added. This will +% cause subscripts to fall too far away from the character in some +% cases, e.g., $\pmb{T}_1$ or $\pmb{\mathcal{T}}_1$. +% \begin{macrocode} +\def\pmb@#1#2{\setbox8\hbox{$\m@th#1{#2}$}% + \setboxz@h{$\m@th#1\mkern.5mu$}\pmbraise@\wdz@ + \binrel@{#2}% + \dimen@-\wd8 % + \binrel@@{% + \mkern-.8mu\copy8 % + \kern\dimen@\mkern.4mu\raise\pmbraise@\copy8 % + \kern\dimen@\mkern.4mu\box8 }% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macrocode} +\def\binrel@#1{\begingroup + \setboxz@h{\thinmuskip0mu + \medmuskip\m@ne mu\thickmuskip\@ne mu + \setbox\tw@\hbox{$#1\m@th$}\kern-\wd\tw@ + ${}#1{}\m@th$}% +% \end{macrocode} +% The \cn{noexpand} here should be unnecessary, but just in case +% \ldots +% \begin{macrocode} + \edef\@tempa{\endgroup\let\noexpand\binrel@@ + \ifdim\wdz@<\z@ \mathbin + \else\ifdim\wdz@>\z@ \mathrel + \else \relax\fi\fi}% + \@tempa +} +% \end{macrocode} +% For completeness, assign a default value for \cs{binrel@@}. +% \begin{macrocode} +\let\binrel@@\relax +% \end{macrocode} +% +% The usual \cs{endinput} to ensure that random garbage at the end of +% the file doesn't get copied by \fn{docstrip}. +% \begin{macrocode} +\endinput +% \end{macrocode} +% +% \CheckSum{131} +% \Finale diff --git a/macros/latex-dev/required/amsmath/amsbsy.ins b/macros/latex-dev/required/amsmath/amsbsy.ins new file mode 100644 index 0000000000..fe1cd5413d --- /dev/null +++ b/macros/latex-dev/required/amsmath/amsbsy.ins @@ -0,0 +1,50 @@ +%% +%% Copyright 2010 American Mathematical Society. +%% Copyright 2016 LaTeX3 Project and American Mathematical Society. +%% +%% This work may be distributed and/or modified under the +%% conditions of the LaTeX Project Public License, either version 1.3c +%% of this license or (at your option) any later version. +%% The latest version of this license is in +%% https://www.latex-project.org/lppl.txt +%% and version 1.3c or later is part of all distributions of LaTeX +%% version 2005/12/01 or later. +%% +%% This work has the LPPL maintenance status `maintained'. +%% +%% The Current Maintainer of this work is the LaTeX3 Project. +%% +%% ==================================================================== + +\input docstrip + +\askforoverwritefalse + +\keepsilent + +\preamble + +Copyright 1995, 1999 American Mathematical Society. +Copyright 2016 LaTeX3 Project and American Mathematical Society. + +This work may be distributed and/or modified under the +conditions of the LaTeX Project Public License, either version 1.3c +of this license or (at your option) any later version. +The latest version of this license is in + https://www.latex-project.org/lppl.txt +and version 1.3c or later is part of all distributions of LaTeX +version 2005/12/01 or later. + +This work has the LPPL maintenance status `maintained'. + +The Current Maintainer of this work is the LaTeX3 project. + +\endpreamble + +\usedir{tex/latex/amsmath} + +\generate{ + \file{amsbsy.sty}{\from{amsbsy.dtx}{}} +} + +\endbatchfile diff --git a/macros/latex-dev/required/amsmath/amsbsy.pdf b/macros/latex-dev/required/amsmath/amsbsy.pdf Binary files differnew file mode 100644 index 0000000000..9a2dabfc88 --- /dev/null +++ b/macros/latex-dev/required/amsmath/amsbsy.pdf diff --git a/macros/latex-dev/required/amsmath/amscd.dtx b/macros/latex-dev/required/amsmath/amscd.dtx new file mode 100644 index 0000000000..2d0a35d685 --- /dev/null +++ b/macros/latex-dev/required/amsmath/amscd.dtx @@ -0,0 +1,322 @@ +% +% \iffalse meta-comment +% +% Copyright (C) 1995, 1999 American Mathematical Society. +% Copyright (C) 2016-2019 LaTeX3 Project and American Mathematical Society. +% +% This work may be distributed and/or modified under the +% conditions of the LaTeX Project Public License, either version 1.3c +% of this license or (at your option) any later version. +% The latest version of this license is in +% https://www.latex-project.org/lppl.txt +% and version 1.3c or later is part of all distributions of LaTeX +% version 2005/12/01 or later. +% +% This work has the LPPL maintenance status `maintained'. +% +% The Current Maintainer of this work is the LaTeX3 Project. +% +% \fi +% +%\iffalse +%<*driver> +\documentclass{amsdtx} +\def\MaintainedByLaTeXTeam#1{% +\begin{center}% +\fbox{\fbox{\begin{tabular}{@{}l@{}}% +This file is maintained by the \LaTeX{} Project team.\\% +Bug reports can be opened (category \texttt{#1}) at\\% +\url{https://latex-project.org/bugs/}.\end{tabular}}}\end{center}} +\usepackage{amscd} +\GetFileInfo{amscd.sty} +% Dummy citation to avoid error in an example. +\bibcite{fre:cichon}{C} +\begin{document} +\title{The \pkg{amscd} package} +\author{Frank Mittelbach\and Rainer Sch\"opf\and Michael Downes} +\date{Version \fileversion, \filedate} +\DocInput{amscd.dtx} +\end{document} +%</driver> +%\fi +% +% \maketitle +% \MaintainedByLaTeXTeam{amslatex} +% +% \MakeShortVerb\| +% \newcommand{\operatorname}[1]{\mathop{\mathrm{#1}}} +% \newcommand{\per}{\operatorname{per}} +% \newcommand{\cov}{\operatorname{cov}} +% \newcommand{\non}{\operatorname{non}} +% \newcommand{\cf}{\operatorname{cf}} +% \newcommand{\add}{\operatorname{add}} +% \newcommand{\End}{\operatorname{End}} +% +% \section{Introduction} +% +% The \pkg{amscd} package provides a \env{CD} environment that +% emulates the commutative diagram capabilities of \amstex/ version +% 2.x. This means that only simple rectangular diagrams are +% supported, with no diagonal arrows or more exotic features. Many +% users will be better served by one of the more powerful diagram +% packages such as \pkg{diagram}, \pkg{xypic}, or \pkg{kuvio}. +% +% Example: +% \begin{equation}\begin{CD} +% S^{{\mathcal{W}}_\Lambda}\otimes T @>j>> T\\ +% @VVV @VV{\End P}V\\ +% (S\otimes T)/I @= (Z\otimes T)/J +% \end{CD}\end{equation} +% \begin{verbatim} +% \begin{equation}\begin{CD} +% S^{{\mathcal{W}}_\Lambda}\otimes T @>j>> T\\ +% @VVV @VV{\End P}V\\ +% (S\otimes T)/I @= (Z\otimes T)/J +% \end{CD}\end{equation} +% \end{verbatim} +% (assuming \cn{End} is defined as an `operator name'. +% +% Another example: +% +% We will make liberal use of Cichon's Diagram \cite{fre:cichon}: +% \begin{equation} +% \begin{CD} +% \cov(\mathcal{L}) @>>> \non(\mathcal{K}) @>>> \cf(\mathcal{K}) @>>> +% \cf(\mathcal{L})\\ +% @VVV @AAA @AAA @VVV\\ +% \add(\mathcal{L}) @>>> \add(\mathcal{K}) @>>> \cov(\mathcal{K}) @>>> +% \non(\mathcal{L}) +% \end{CD}\end{equation} +% \begin{verbatim} +% \begin{equation}\begin{CD} +% \cov(\mathcal{L}) @>>> \non(\mathcal{K}) @>>> \cf(\mathcal{K}) @>>> +% \cf(\mathcal{L})\\ +% @VVV @AAA @AAA @VVV\\ +% \add(\mathcal{L}) @>>> \add(\mathcal{K}) @>>> \cov(\mathcal{K}) @>>> +% \non(\mathcal{L}) +% \end{CD}\end{equation} +% \end{verbatim} +% +% \StopEventually{} +% +% Standard package info. +% \begin{macrocode} +\NeedsTeXFormat{LaTeX2e}% LaTeX 2.09 can't be used (nor non-LaTeX) +[1994/12/01]% LaTeX date must December 1994 or later +\ProvidesPackage{amscd}[2017/04/14 v2.1 AMS Commutative Diagrams] +% \end{macrocode} +% \begin{macrocode} +\RequirePackage{amsgen} +% \end{macrocode} +% Better not to redefine \verb|\math@cr| if it is already defined, +% because for CD use only we want to omit the part of the code +% related to \verb|\dspbrk@lvl| (see \fn{amsmath.sty}). +% +% [mjd,1999/11/04] These definitions have gone somewhat obsolete; but +% we had probably better leave them as they are for backward +% compatibility. +% \begin{macrocode} +\@ifundefined{math@cr}{% + \def\math@cr{{\ifnum0=`}\fi + \@ifstar{\global\@eqpen\@M\math@cr@}% + {\global\@eqpen\interdisplaylinepenalty \math@cr@}} +% \end{macrocode} +% The following section merely duplicates some code from the +% \pkg{amsmath} package, in case the \pkg{amscd} package is used by +% itself. For documentation of the code refer to \fn{amsmath.dtx}. +% \begin{macrocode} + \def\math@cr@{\new@ifnextchar[\math@cr@@{\math@cr@@[\z@]}} + \def\math@cr@@[#1]{\ifnum0=`{\fi}\math@cr@@@ + \noalign{\vskip#1\relax}} + \def\restore@math@cr{\def\math@cr@@@{\cr}} +}{} +\restore@math@cr +% \end{macrocode} +% [mjd,1999/11/04] These definitions too are somewhat obsolete; +% but we had probably better leave them as they are for backward +% compatibility. +% \begin{macrocode} +\@ifundefined{rightarrowfill@}{ + \def\rightarrowfill@#1{\m@th\setboxz@h{$#1-$}\ht\z@\z@ + $#1\copy\z@\mkern-6mu\cleaders + \hbox{$#1\mkern-2mu\box\z@\mkern-2mu$}\hfill + \mkern-6mu\mathord\rightarrow$} + \def\leftarrowfill@#1{\m@th\setboxz@h{$#1-$}\ht\z@\z@ + $#1\mathord\leftarrow\mkern-6mu\cleaders + \hbox{$#1\mkern-2mu\copy\z@\mkern-2mu$}\hfill + \mkern-6mu\box\z@$} + \def\leftrightarrowfill@#1{\m@th\setboxz@h{$#1-$}\ht\z@\z@ + $#1\mathord\leftarrow\mkern-6mu\cleaders + \hbox{$#1\mkern-2mu\box\z@\mkern-2mu$}\hfill + \mkern-6mu\mathord\rightarrow$} +}{} +% \end{macrocode} +% +% \begin{macrocode} +\def\atdef@#1{\expandafter\def\csname\space @\string#1\endcsname} +\@ifundefined{Iat}{% + \DeclareRobustCommand{\Iat}{\FN@\at@} +}{} +\begingroup \catcode`\@=\active +% \end{macrocode} +% Define math \qc{\@} to replicate its mathcode-dictated behavior. +% This is in case \qc{\@} occurs outside of \env{CD}. +% \begin{macrocode} +\csname if\string @compatibility\endcsname +\else \fam=\mathcode`\@ + \xdef @{\mathchar\number\fam\space } +\fi +\gdef\CDat{\let @=\Iat} +\endgroup +\mathcode`\@="8000 % make @ pseudo-active in math +\def\at@{\let\next@\at@@ + \ifcat\noexpand\next a\else + \ifcat\noexpand\next0\else + \ifcat\noexpand\next\relax\else + \let\next@\at@@@\fi\fi\fi\next@} +\def\at@@#1{\expandafter + \ifx\csname\space @\string#1\endcsname\relax + \DN@{\at@@@#1}% + \else + \DN@{\csname\space @\string#1\endcsname}% + \fi\next@}% +% \end{macrocode} +% The following items should be defined only if they are not +% already defined, either to leave the package name untouched (in +% the case of \cs{PackageError}) or to avoid redundant allocation +% of token or dimen registers. +% \begin{macrocode} +\@ifundefined{default@tag}{% + \def\default@tag{% + \def\tag{\PackageError{amscd}{\protect\tag\space not allowed + here}\@eha}}% +}{}% +\@ifundefined{at@@@}{% + \def\at@@@{\PackageError{amscd}{\Invalid@@ @}{\the\athelp@}\char64\relax} +}{} +\@ifundefined{athelp@}{\csname newhelp\endcsname\athelp@ +{Only certain combinations beginning with @ make sense to me.^^J% +I'll assume you wanted @@ for a printed @.}}{} +\@ifundefined{minaw@}{\newdimen\minaw@}{} +\@ifundefined{bigaw@}{\newdimen\bigaw@}{} +% \end{macrocode} +% +% Assignment of a couple of dimensions, and initialization of +% \verb=\ampersand@=. We check to see if we need to define +% \verb=\minaw@= and \verb=\bigaw@=. +% \begin{macrocode} +\minaw@11.111pt +\newdimen\minCDarrowwidth +\minCDarrowwidth2.5pc +\newif\ifCD@ +\let\ampersand@\relax +% \end{macrocode} +% +% Added \verb|\restore@math@cr\default@tag| to fix line numbering +% problems, 7-JUN-1991. Suggested by I.~Zakharevich. +% \begin{macrocode} +\newenvironment{CD}{% + \CDat + \bgroup\relax\iffalse{\fi\let\ampersand@&\iffalse}\fi + \CD@true\vcenter\bgroup\let\\\math@cr\restore@math@cr\default@tag + \tabskip\z@skip\baselineskip20\ex@ + \lineskip3\ex@\lineskiplimit3\ex@\halign\bgroup + &\hfill$\m@th##$\hfill\crcr +}{% + \crcr\egroup\egroup\egroup +} +% \end{macrocode} +% +% \begin{macro}{\CD@check} +% This check is used by all macros that must not appear outside the +% \env{CD} environment. The first argument is the symbol to be used +% after \verb+@+, the second one the action to be performed. +% +% Once again we use the trick of defining a temporary control +% sequence \verb+\next@+ and calling it after the final \verb+\fi+. +% This is not absolutely necessary, but it ensures that the +% conditional text is processed in one and the same column +% of the enclosing alignment. +% \begin{macrocode} +\def\CD@check#1#2{\ifCD@\DN@{#2}\else + \DN@{\PackageError{amscd}{@\protect#1 not + allowed outside of the CD environment}\@eha}% + \fi\next@} +% \end{macrocode} +% \end{macro} +% +% \begin{macrocode} +\atdef@>#1>#2>{\ampersand@ + \ifCD@ \global\bigaw@\minCDarrowwidth \else \global\bigaw@\minaw@ \fi + \setboxz@h{$\m@th\scriptstyle\;{#1}\;\;$}% + \ifdim\wdz@>\bigaw@\global\bigaw@\wdz@\fi +% \end{macrocode} +% If \verb|#2| is empty we can save some work. +% \begin{macrocode} + \@ifnotempty{#2}{\setbox\@ne\hbox{$\m@th\scriptstyle\;{#2}\;\;$}% + \ifdim\wd\@ne>\bigaw@\global\bigaw@\wd\@ne\fi}% + \ifCD@\enskip\fi + \mathrel{\mathop{\hbox to\bigaw@{\rightarrowfill@\displaystyle}}% + \limits^{#1}\@ifnotempty{#2}{_{#2}}}% + \ifCD@\enskip\fi \ampersand@} +% +\atdef@<#1<#2<{\ampersand@ + \ifCD@ \global\bigaw@\minCDarrowwidth \else \global\bigaw@\minaw@ \fi + \setboxz@h{$\m@th\scriptstyle\;\;{#1}\;$}% + \ifdim\wdz@>\bigaw@ \global\bigaw@\wdz@ \fi + \@ifnotempty{#2}{\setbox\@ne\hbox{$\m@th\scriptstyle\;\;{#2}\;$}% + \ifdim\wd\@ne>\bigaw@ \global\bigaw@\wd\@ne \fi}% + \ifCD@\enskip\fi + \mathrel{\mathop{\hbox to\bigaw@{\leftarrowfill@\displaystyle}}% + \limits^{#1}\@ifnotempty{#2}{_{#2}}}% + \ifCD@\enskip\fi \ampersand@} +% \end{macrocode} +% +% Variants of the above two arrows, using \verb|(| and \verb|)| +% characters instead of \verb|<| and \verb|>| characters, are +% provided for those whose keyboards don't have the latter. +% \begin{macrocode} +\begingroup \catcode`\~=\active \lccode`\~=`\@ +\lowercase{% + \global\atdef@)#1)#2){~>#1>#2>} + \global\atdef@(#1(#2({~<#1<#2<} +}% end lowercase +\endgroup +% \end{macrocode} +% +% \begin{macrocode} +\atdef@ A#1A#2A{\CD@check{A..A..A}{\llap{$\m@th\vcenter{\hbox + {$\scriptstyle#1$}}$}\Big\uparrow + \rlap{$\m@th\vcenter{\hbox{$\scriptstyle#2$}}$}&&}} +% +\atdef@ V#1V#2V{\CD@check{V..V..V}{\llap{$\m@th\vcenter{\hbox + {$\scriptstyle#1$}}$}\Big\downarrow + \rlap{$\m@th\vcenter{\hbox{$\scriptstyle#2$}}$}&&}} +% +\atdef@={\CD@check={&\enskip\mathrel + {\vbox{\hrule\@width\minCDarrowwidth\vskip2\ex@\hrule\@width + \minCDarrowwidth}}\enskip&}} +% +\atdef@|{\CD@check|{\Big\Vert&&}} +% +\atdef@\vert{\CD@check\vert{\Big\Vert&&}} +% +\atdef@.{\CD@check.{&&}} +% \end{macrocode} +% +% The \cn{pretend} command has weird syntax that doesn't fit well +% with standard \latex/ syntax so we leave it undone, at least for +% now. [mjd,1994/10/27] +% \begin{macrocode} +%\def\pretend#1\haswidth#2{\setboxz@h{$\m@th\scriptstyle{#2}$}\hbox +% to\wdz@{\hfill$\m@th\scriptstyle{#1}$\hfill}} +% \end{macrocode} +% +% The usual \cs{endinput} to ensure that random garbage at the end of +% the file doesn't get copied by \fn{docstrip}. +% \begin{macrocode} +\endinput +% \end{macrocode} +% +% \CheckSum{459} +% \Finale diff --git a/macros/latex-dev/required/amsmath/amscd.ins b/macros/latex-dev/required/amsmath/amscd.ins new file mode 100644 index 0000000000..148c4cb32e --- /dev/null +++ b/macros/latex-dev/required/amsmath/amscd.ins @@ -0,0 +1,50 @@ +%% +%% Copyright 2010 American Mathematical Society. +%% Copyright 2016 LaTeX3 Project and American Mathematical Society. +%% +%% This work may be distributed and/or modified under the +%% conditions of the LaTeX Project Public License, either version 1.3c +%% of this license or (at your option) any later version. +%% The latest version of this license is in +%% https://www.latex-project.org/lppl.txt +%% and version 1.3c or later is part of all distributions of LaTeX +%% version 2005/12/01 or later. +%% +%% This work has the LPPL maintenance status `maintained'. +%% +%% The Current Maintainer of this work is the LaTeX3 Project. +%% +%% ==================================================================== + +\input docstrip + +\askforoverwritefalse + +\keepsilent + +\preamble + +Copyright 1995, 1999 American Mathematical Society. +Copyright 2016 LaTeX3 Project and American Mathematical Society. + +This work may be distributed and/or modified under the +conditions of the LaTeX Project Public License, either version 1.3c +of this license or (at your option) any later version. +The latest version of this license is in + https://www.latex-project.org/lppl.txt +and version 1.3c or later is part of all distributions of LaTeX +version 2005/12/01 or later. + +This work has the LPPL maintenance status `maintained'. + +The Current Maintainer of this work is the LaTeX3 project. + +\endpreamble + +\usedir{tex/latex/amsmath} + +\generate{ + \file{amscd.sty}{\from{amscd.dtx}{}} +} + +\endbatchfile diff --git a/macros/latex-dev/required/amsmath/amscd.pdf b/macros/latex-dev/required/amsmath/amscd.pdf Binary files differnew file mode 100644 index 0000000000..860352c44a --- /dev/null +++ b/macros/latex-dev/required/amsmath/amscd.pdf diff --git a/macros/latex-dev/required/amsmath/amsgen.dtx b/macros/latex-dev/required/amsmath/amsgen.dtx new file mode 100644 index 0000000000..5edc26b9cc --- /dev/null +++ b/macros/latex-dev/required/amsmath/amsgen.dtx @@ -0,0 +1,386 @@ +% +% \iffalse meta-comment +% +% Copyright (C) 1995, 1999 American Mathematical Society. +% Copyright (C) 2016-2019 LaTeX3 Project and American Mathematical Society. +% +% This work may be distributed and/or modified under the +% conditions of the LaTeX Project Public License, either version 1.3c +% of this license or (at your option) any later version. +% The latest version of this license is in +% https://www.latex-project.org/lppl.txt +% and version 1.3c or later is part of all distributions of LaTeX +% version 2005/12/01 or later. +% +% This work has the LPPL maintenance status `maintained'. +% +% The Current Maintainer of this work is the LaTeX3 Project. +% +% \fi +% +% \iffalse +%<*driver> +\documentclass{amsdtx} +\def\MaintainedByLaTeXTeam#1{% +\begin{center}% +\fbox{\fbox{\begin{tabular}{@{}l@{}}% +This file is maintained by the \LaTeX{} Project team.\\% +Bug reports can be opened (category \texttt{#1}) at\\% +\url{https://latex-project.org/bugs/}.\end{tabular}}}\end{center}} +\usepackage{amsgen} +\GetFileInfo{amsgen.sty} +\begin{document} +\title{The \pkg{amsgen} package} +\author{American Mathematical Society\\Michael Downes} +\date{Version \fileversion, \filedate} +\DocInput{amsgen.dtx} +\end{document} +%</driver> +% \fi +% +% \maketitle +% \MaintainedByLaTeXTeam{amslatex} +% +% \MakeShortVerb\| +% +% \section{Introduction} +% This is an internal package for storing common functions +% that are shared by more than one package in the \amslatex/ +% distribution. Some of these might eventually make it into the \latex/ +% kernel. +% +% \StopEventually{} +% +% Standard package info. +% Using \cs{ProvidesFile} rather than \cs{ProvidesPackage} because +% the latter, when input by, e.g, \cls{amsbook}, results in +% \texttt{LaTeX warning: You have requested document class `amsbook', +% but the document class provides `amsgen'.} +% \begin{macrocode} +\NeedsTeXFormat{LaTeX2e}% LaTeX 2.09 can't be used (nor non-LaTeX) +[1994/12/01]% LaTeX date must December 1994 or later +\ProvidesFile{amsgen.sty}[1999/11/30 v2.0 generic functions] +% \end{macrocode} +% +% \section{Implementation} +% Some general macros shared by \fn{amsart.dtx}, \fn{amsmath.dtx}, +% \fn{amsfonts.dtx}, \dots +% +% \begin{macro}{\@saveprimitive} +% The \pkg{amsmath} package redefines a number of \tex/ primitives. +% In case some preceding package also decided to redefine one of +% those same primitives, we had better do some checking to make +% sure that we are able to save the primitive meaning for internal +% use. This is handled by the \cs{@saveprimitive} function. We +% follow the example of \cs{@@input} where the primitive meaning is +% stored in an internal control sequence with a |@@| prefix. +% Primitive control sequences can be distinguished by the fact that +% \cs{string} and \cs{meaning} return the same information. +% \begin{macrocode} +\providecommand{\@saveprimitive}[2]{\begingroup\escapechar`\\\relax + \edef\@tempa{\string#1}\edef\@tempb{\meaning#1}% + \ifx\@tempa\@tempb \global\let#2#1% + \else +% \end{macrocode} +% Check to see if \arg{2} was already given the desired primitive +% meaning somewhere else. +% \begin{macrocode} + \edef\@tempb{\meaning#2}% + \ifx\@tempa\@tempb + \else + \@latex@error{Unable to properly define \string#2; primitive + \noexpand#1no longer primitive}\@eha + \fi + \fi + \endgroup} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@xp} +% \begin{macro}{\@nx} +% Shorthands for long command names. +% \begin{macrocode} +\let\@xp=\expandafter +\let\@nx=\noexpand +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\@emptytoks} +% A token register companion for \cs{@empty}. Saves a little main mem and +% probably makes initializations such as |\toks@{}| run faster too. +% \begin{macrocode} +\newtoks\@emptytoks +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@oparg} +% Use of \cs{@oparg} simplifies some constructions where a macro +% takes an optional argument in square brackets. We can't use +% \cn{newcommand} here because this function might be previously +% defined by the \pkg{amsmath} package in a loading sequence such as +% \begin{verbatim} +% \usepackage{amsmath,amsthm} +% \end{verbatim} +% \begin{macrocode} +\def\@oparg#1[#2]{\@ifnextchar[{#1}{#1[#2]}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@ifempty} +% \begin{macro}{\@ifnotempty} +% |\@ifnotempty| and |\@ifempty| use category 11 |@| characters to +% test whether the argument is empty or not, since these are highly +% unlikely to occur in the argument. As with \cn{@oparg}, there is a +% possibility that these commands were defined previously in +% \fn{amsmath.sty}. +% \begin{macrocode} +\long\def\@ifempty#1{\@xifempty#1@@..\@nil} +\long\def\@xifempty#1#2@#3#4#5\@nil{% + \ifx#3#4\@xp\@firstoftwo\else\@xp\@secondoftwo\fi} +% \end{macrocode} +% \cs{@ifnotempty} is a shorthand that makes code read better when +% no action is needed in the empty case. At a cost of double +% argument-reading---so for often-executed code, avoiding +% \cs{@ifnotempty} might be wise. +% \begin{macrocode} +\long\def\@ifnotempty#1{\@ifempty{#1}{}} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% Some abbreviations to conserve token mem. +% \begin{macrocode} +\def\FN@{\futurelet\@let@token} +\def\DN@{\def\next@} +\def\RIfM@{\relax\ifmmode} +\def\setboxz@h{\setbox\z@\hbox} +\def\wdz@{\wd\z@} +\def\boxz@{\box\z@} +\def\relaxnext@{\let\@let@token\relax} +% \end{macrocode} +% +% \begin{macro}{\new@ifnextchar} +% This macro is a new version of \latex/'s \verb+\@ifnextchar+, +% macro that does not skip over spaces. +% \begin{macrocode} +\long\def\new@ifnextchar#1#2#3{% +% \end{macrocode} +% By including the space after the equals sign, we make it possible +% for \cs{new@ifnextchar} to do look-ahead for any token, including a +% space! +% \begin{macrocode} + \let\reserved@d= #1% + \def\reserved@a{#2}\def\reserved@b{#3}% + \futurelet\@let@token\new@ifnch +} +% +\def\new@ifnch{% + \ifx\@let@token\reserved@d \let\reserved@b\reserved@a \fi + \reserved@b +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@ifstar} +% There will essentially never be a space before the \qc{\*}, so +% using \cs{@ifnextchar} is unnecessarily slow. +% \begin{macrocode} +\def\@ifstar#1#2{\new@ifnextchar *{\def\reserved@a*{#1}\reserved@a}{#2}} +% \end{macrocode} +% \end{macro} +% +% The hook \cs{every@size} was changed to \cs{every@math@size} in the +% December 1994 release of \latex/ and its calling procedures changed. +% If \cs{every@math@size} is undefined it means the user has an older +% version of \latex/ so we had better define it and patch a couple of +% functions (\cs{glb@settings} and \cs{set@fontsize}). +% \begin{macrocode} +\@ifundefined{every@math@size}{% +% \end{macrocode} +% Reuse the same token register; since it was never used except for +% the purposes that are affected below, this is OK. +% \begin{macrocode} +\let\every@math@size=\every@size +\def\glb@settings{% + \expandafter\ifx\csname S@\f@size\endcsname\relax + \calculate@math@sizes + \fi + \csname S@\f@size\endcsname + \ifmath@fonts +% \ifnum \tracingfonts>\tw@ +% \@font@info{Setting up math fonts for +% \f@size/\f@baselineskip}\fi + \begingroup + \escapechar\m@ne + \csname mv@\math@version \endcsname + \globaldefs\@ne + \let \glb@currsize \f@size + \math@fonts + \endgroup + \the\every@math@size + \else +% \ifnum \tracingfonts>\tw@ +% \@font@info{No math setup for \f@size/\f@baselineskip}% +% \fi + \fi +} +% \end{macrocode} +% Remove |\the\every@size| from \cs{size@update}. +% \begin{macrocode} +\def\set@fontsize#1#2#3{% + \@defaultunits\@tempdimb#2pt\relax\@nnil + \edef\f@size{\strip@pt\@tempdimb}% + \@defaultunits\@tempskipa#3pt\relax\@nnil + \edef\f@baselineskip{\the\@tempskipa}% + \edef\f@linespread{#1}% + \let\baselinestretch\f@linespread + \def\size@update{% + \baselineskip\f@baselineskip\relax + \baselineskip\f@linespread\baselineskip + \normalbaselineskip\baselineskip + \setbox\strutbox\hbox{% + \vrule\@height.7\baselineskip + \@depth.3\baselineskip + \@width\z@}% +%%% \the\every@size + \let\size@update\relax}% + } +}{}% end \@ifundefined test +% \end{macrocode} +% +% \begin{macro}{\ex@} +% The \cs{ex@} variable provides a small unit of space for use in +% math-mode constructions, that varies according to the current type +% size. For example, the \cn{pmb} command uses \cs{ex@} units. +% Since a macro or mu unit solution for the \meta{dimen} \cs{ex@} won't +% work without changing a lot of current code in the \pkg{amsmath} +% package, we set \cs{ex@} through the \cs{every@math@size} hook. +% The value of \cs{ex@} is scaled nonlinearly in a range of roughly +% 0.5pt to 1.5pt, by the function \cs{compute@ex@}. +% \begin{macrocode} +\newdimen\ex@ +\addto@hook\every@math@size{\compute@ex@} +% \end{macrocode} +% \end{macro} +% +% \cs{compute@ex@} computes \cs{ex@} as a nonlinear scaling from 10pt +% to current font size (\cs{f@size}). Using .97 as the multiplier makes 1 +% |ex@| $\approx$ .9pt when the current type size is 8pt and 1 |ex@| +% $\approx$ 1.1pt when the current type size is 12pt. +% +% The formula is essentially +% \begin{displaymath} +% \newcommand{\points}{\mbox{pt}} +% \newcommand{\floor}[1]{\lfloor#1\rfloor} +% 1\points \pm (1\points - (.97)^{\floor{\vert 10 - n\vert}}) +% \end{displaymath} +% where $n$ = current type size, but adjusted to differentiate +% half-point sizes as well as whole point sizes, and there is a +% cutoff for extraordinarily large values of \cs{f@size} ($>$ 20pt) +% so that the value of \cs{ex@} never exceeds 1.5pt. +% +% \begin{macrocode} +\def\compute@ex@{% + \begingroup + \dimen@-\f@size\p@ + \ifdim\dimen@<-20\p@ +% \end{macrocode} +% Never make \cs{ex@} larger than 1.5pt. +% \begin{macrocode} + \global\ex@ 1.5\p@ + \else +% \end{macrocode} +% Adjust by the reference size and multiply by 2 to allow for +% half-point sizes. +% \begin{macrocode} + \advance\dimen@10\p@ \multiply\dimen@\tw@ +% \end{macrocode} +% Save information about the current sign of \cs{dimen@}. +% \begin{macrocode} + \edef\@tempa{\ifdim\dimen@>\z@ -\fi}% +% \end{macrocode} +% Get the absolute value of \cs{dimen@}. +% \begin{macrocode} + \dimen@ \ifdim\dimen@<\z@ -\fi \dimen@ + \advance\dimen@-\@m sp % fudge factor +% \end{macrocode} +% Here we use \cs{vfuzz} merely as a convenient scratch register +% \begin{macrocode} + \vfuzz\p@ +% \end{macrocode} +% Multiply in a loop. +% \begin{macrocode} + \def\do{\ifdim\dimen@>\z@ + \vfuzz=.97\vfuzz + \advance\dimen@ -\p@ +%\message{\vfuzz: \the\vfuzz, \dimen@: \the\dimen@}% + \@xp\do \fi}% + \do + \dimen@\p@ \advance\dimen@-\vfuzz + \global\ex@\p@ + \global\advance\ex@ \@tempa\dimen@ + \fi + \endgroup +%\typeout{\string\f@size: \f@size}\showthe\ex@ +} +% \end{macrocode} +% Tests of the \cs{compute@ex@} function yield the following results: +% +% \begin{center}\begin{tabular}{rlrl} +% \cs{f@size}& \cs{ex@}& \cs{f@size}& \cs{ex@}\\ +% 10& 1.0pt& 9& 0.94089pt\\ +% 11& 1.05911pt& 8.7& 0.91266pt\\ +% 12& 1.11473pt& 8.5& 0.91266pt\\ +% 14.4& 1.23982pt& 8.4& 0.88527pt\\ +% 17.28& 1.36684pt& 8& 0.88527pt\\ +% 20.74& 1.5pt& 7& 0.83293pt\\ +% 19.5& 1.4395pt& 6& 0.78369pt\\ +% && 5& 0.73737pt\\ +% && 1& 0.57785pt +% \end{tabular}\end{center} +% +% \begin{macro}{\@addpunct} +% Use of the \cs{@addpunct} function allows ending punctuation in +% section headings and elsewhere to be intelligently omitted +% when punctuation is already present. +% \begin{macrocode} +\def\@addpunct#1{\ifnum\spacefactor>\@m \else#1\fi} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\frenchspacing} +% Change \cn{frenchspacing} to ensure that \cs{@addpunct} will +% continue to work properly even when `french' spacing is in effect. +% \begin{macrocode} +\def\frenchspacing{\sfcode`\.1006\sfcode`\?1005\sfcode`\!1004% + \sfcode`\:1003\sfcode`\;1002\sfcode`\,1001 } +% \end{macrocode} +% \end{macro} +% +% \subsection{Miscellaneous} +% \begin{macrocode} +\def\nomath@env{\@amsmath@err{% + \string\begin{\@currenvir} allowed only in paragraph mode% +}\@ehb% "You've lost some text" +} +% \end{macrocode} +% A trade-off between main memory space and hash size; using +% \verb+\Invalid@@+ saves 14 bytes of main memory for each use of +% \verb+\Invalid@+, at the cost of one control sequence name. +% \verb+\Invalid@+ is currently used about five times and +% \verb+\Invalid@@+ is used by itself in some other instances, +% which means that it saves us more memory than \verb+\FN@+, +% \verb+\RIfM@+, and some of the other abbreviations above. +% \begin{macrocode} +\def\Invalid@@{Invalid use of \string} +% \end{macrocode} +% +% The usual \cs{endinput} to ensure that random garbage at the end of +% the file doesn't get copied by \fn{docstrip}. +% \begin{macrocode} +\endinput +% \end{macrocode} +% +% \CheckSum{337} +% \Finale diff --git a/macros/latex-dev/required/amsmath/amsgen.ins b/macros/latex-dev/required/amsmath/amsgen.ins new file mode 100644 index 0000000000..8c5683cb5a --- /dev/null +++ b/macros/latex-dev/required/amsmath/amsgen.ins @@ -0,0 +1,50 @@ +%% +%% Copyright 2010 American Mathematical Society. +%% Copyright 2016 LaTeX3 Project and American Mathematical Society. +%% +%% This work may be distributed and/or modified under the +%% conditions of the LaTeX Project Public License, either version 1.3c +%% of this license or (at your option) any later version. +%% The latest version of this license is in +%% https://www.latex-project.org/lppl.txt +%% and version 1.3c or later is part of all distributions of LaTeX +%% version 2005/12/01 or later. +%% +%% This work has the LPPL maintenance status `maintained'. +%% +%% The Current Maintainer of this work is the LaTeX3 Project. +%% +%% ==================================================================== + +\input docstrip + +\askforoverwritefalse + +\keepsilent + +\preamble + +Copyright 1995, 1999 American Mathematical Society. +Copyright 2016 LaTeX3 Project and American Mathematical Society. + +This work may be distributed and/or modified under the +conditions of the LaTeX Project Public License, either version 1.3c +of this license or (at your option) any later version. +The latest version of this license is in + https://www.latex-project.org/lppl.txt +and version 1.3c or later is part of all distributions of LaTeX +version 2005/12/01 or later. + +This work has the LPPL maintenance status `maintained'. + +The Current Maintainer of this work is the LaTeX3 project. + +\endpreamble + +\usedir{tex/latex/amsmath} + +\generate{ + \file{amsgen.sty}{\from{amsgen.dtx}{}} +} + +\endbatchfile diff --git a/macros/latex-dev/required/amsmath/amsgen.pdf b/macros/latex-dev/required/amsmath/amsgen.pdf Binary files differnew file mode 100644 index 0000000000..9078999dc0 --- /dev/null +++ b/macros/latex-dev/required/amsmath/amsgen.pdf diff --git a/macros/latex-dev/required/amsmath/amsldoc.pdf b/macros/latex-dev/required/amsmath/amsldoc.pdf Binary files differnew file mode 100644 index 0000000000..decc68fe74 --- /dev/null +++ b/macros/latex-dev/required/amsmath/amsldoc.pdf diff --git a/macros/latex-dev/required/amsmath/amsldoc.tex b/macros/latex-dev/required/amsmath/amsldoc.tex new file mode 100644 index 0000000000..9e08f029f5 --- /dev/null +++ b/macros/latex-dev/required/amsmath/amsldoc.tex @@ -0,0 +1,2770 @@ +% +% Copyright (C) 1995, 2000, 2013 American Mathematical Society. +% Copyright (C) 2016-2019 LaTeX3 Project and American Mathematical Society. +% +% This work may be distributed and/or modified under the +% conditions of the LaTeX Project Public License, either version 1.3c +% of this license or (at your option) any later version. +% The latest version of this license is in +% https://www.latex-project.org/lppl.txt +% and version 1.3c or later is part of all distributions of LaTeX +% version 2005/12/01 or later. +% +% This work has the LPPL maintenance status `maintained'. +% +% The Current Maintainer of this work is the LaTeX3 Project. +% +\documentclass[leqno,titlepage,openany]{amsldoc}[1999/12/13] + +\def\MaintainedByLaTeXTeam#1{% +\begin{center}% +\fbox{\fbox{\begin{tabular}{@{}l@{}}% +This file is maintained by the \LaTeX{} Project team.\\% +Bug reports can be opened (category \texttt{#1}) at\\% +\url{https://latex-project.org/bugs/}.\end{tabular}}}\end{center}} + +\ifx\UndEfiNed\url + \ClassError{amsldoc}{% + This version of amsldoc.tex must be processed\MessageBreak + with a newer version of amsldoc.cls (2.02 or later).}{} +\fi + +\renewcommand\bibname{References} + +% Definitions that should be moved to amsldoc.cls +% when it is next updated +\makeatletter +\let\cleardouble@page\cleardoublepage +\AtBeginDocument{% + \ifx\cleardouble@page\cleardoublepage + \def\cleardoublepage{\clearpage{\pagestyle{empty}\cleardouble@page}} + \fi +} + +% #1 is empty or one of class, environment, option, package +% could use different font in each case +\makeatletter +\def\@category@index#1#2{% + \autoindex{% + #2\actualchar\string\index#1font{#2}% + \ifx\@nil#1\@nil\else\space#1\fi + }% +} + +\let\indexpackagefont\textsf +\let\indexclassfont\textsf +\let\indexoptionfont\texttt +\let\indexenvironmentfont\texttt +\let\indexfont\texttt +\makeatother +% For a package that won't be indexed, i.e. amsmath +\newcommand{\nipkg}{\textsf} +\def\tikz/{Ti\textit{k}Z} +% End definitions for amsldoc.cls + +\title{User's Guide for the \nipkg{amsmath} Package (Version~2.1)} +\author{American Mathematical Society, \LaTeX3 Project} +\date{1999-12-13 (revised 2002-02-25, 2016-11-14, 2018-04-05)} +\makeatletter +\def\@thanks{\bigskip\MaintainedByLaTeXTeam{amslatex}} +\makeatother + +% Use the amsmath package and amscd package in order to print +% examples. +\usepackage{amsmath} +\usepackage{amscd} + +\usepackage{imakeidx} +% Need alternate coding for vertical bar to get it into index. +% Based on \qcbang and \cnbang in amsldoc.cls, refined by David Carlisle. +% Give it a sort field that will be at the end of the symbols; +% must avoid " and | which have special meanings. +\DeclareRobustCommand{\qcvert}{\qc\|\index{{z1}@{\ntt\char'174}}} +\DeclareRobustCommand{\cnvert}{% + \ncn{\|}\index{{z0}@{\ntt\bslchar\char'174}}} +% Need alternate index sort field for bang to allow & to sort first +\DeclareRobustCommand{\altcnbang}{% + \ncn{\!}\index{"!b@{\ntt\bslchar\qcbang}}} +\DeclareRobustCommand{\cnamp}{% + \index{"!a@\texttt{\&}}} + +\makeindex[intoc] % generate index data +\providecommand{\see}[2]{\textit{see} #1} + +% The amsldoc class includes a number of features useful for +% documentation about TeX, including: +% +% ---Commands \tex/, \amstex/, \latex/, ... for uniform treatment +% of the various logos and easy handling of following spaces. +% +% ---Commands for printing various common elements: \cn for command +% names, \fn for file names (including font-file names), \env for +% environments, \pkg and \cls for packages and classes, etc. + +% Many of the command names used here are rather long and will +% contribute to poor linebreaking if we follow the \latex/ practice +% of not hyphenating anything set in tt font; instead we selectively +% allow some hyphenation. +\allowtthyphens % defined in amsldoc.cls + +\hyphenation{ac-cent-ed-sym-bol add-to-counter add-to-length align-at + aligned-at allow-dis-play-breaks ams-art ams-cd ams-la-tex amsl-doc + ams-symb ams-tex ams-text ams-xtra bmatrix bold-sym-bol cen-ter-tags + eqn-ar-ray idots-int int-lim-its latex med-space neg-med-space + neg-thick-space neg-thin-space no-int-lim-its no-name-lim-its + over-left-arrow over-left-right-arrow over-right-arrow pmatrix + qed-sym-bol set-length side-set small-er tbinom the-equa-tion + thick-space thin-space un-der-left-arrow un-der-left-right-arrow + un-der-right-arrow use-pack-age var-inj-lim var-proj-lim vmatrix + xalign-at xx-align-at} + +% Prepare for illustrating the \vec example +\newcommand{\vect}[1]{\mathbf{#1}} + +\newcommand{\booktitle}[1]{\textit{#1}} +\newcommand{\journalname}[1]{\textit{#1}} +\newcommand{\seriesname}[1]{\textit{#1}} + +% Command to insert and index a particular phrase. Doesn't work for +% certain kinds of special characters in the argument. +\newcommand{\ii}[1]{#1\index{#1}} + +\newcommand{\vstrut}[1]{\vrule width0pt height#1\relax} + +% An environment for presenting comprehensive address information: +\newenvironment{infoaddress}{% + \par\topsep\medskipamount + \trivlist\centering + \item[]% + \begin{minipage}{.7\columnwidth}% + \raggedright +}{% + \end{minipage}% + \endtrivlist +} + +\newenvironment{eqxample}{% + \par\addvspace\medskipamount + \noindent\begin{minipage}{.5\columnwidth}% + \def\producing{\end{minipage}\begin{minipage}{.5\columnwidth}% + \hbox\bgroup\kern-.2pt\vrule width.2pt% + \vbox\bgroup\parindent0pt\relax +% The 3pt is to cancel the -\lineskip from \displ@y + \abovedisplayskip3pt \abovedisplayshortskip\abovedisplayskip + \belowdisplayskip0pt \belowdisplayshortskip\belowdisplayskip + \noindent} +}{% + \par +% Ensure that a lonely \[\] structure doesn't take up width less than +% \hsize. + \hrule height0pt width\hsize + \egroup\vrule width.2pt\kern-.2pt\egroup + \end{minipage}% + \par\addvspace\medskipamount +} + +% Errors in output shouldn't be \texttt, and they may also be longer +% than one line, but they should be identified by the "errorbullet". +% (They were formerly labeled as aubsections.) +\newenvironment{erroro}[1]{% + \par\addvspace\medskipamount + \noindent\hangindent\parindent + \hbox to\parindent{\errorbullet\hfil}\ignorespaces + #1\par\vspace{\smallskipamount} +}{% + \par\addvspace\medskipamount +} + +% The chapters are so short, perhaps we shouldn't call them by the +% name `Chapter'. We make \chaptername read an argument in order to +% remove a following \space or "{} " (both possibilities are present +% in book.cls). + +\renewcommand{\chaptername}[1]{} +\newcommand{\chapnum}[1]{\mdash #1\mdash } +\makeatletter +\def\@makechapterhead#1{% + \vspace{1.5\baselineskip}% + {\parindent \z@ \raggedright \reset@font + \ifnum \c@secnumdepth >\m@ne + \large\bfseries \chapnum{\thechapter}% + \par\nobreak + \vskip.5\baselineskip\relax + \fi + #1\par\nobreak + \vskip\baselineskip + }} +\makeatother + +% A command for ragged-right parbox in a tabular. +\newcommand{\rp}{\let\PBS\\\raggedright\let\\\PBS} + +% Non-indexed file name +\newcommand{\nfn}[1]{\texttt{#1}} + +% For the examples in the math spacing table. +%%\newcommand{\lspx}{\mbox{\rule{5pt}{.6pt}\rule{.6pt}{6pt}}} +%%\newcommand{\rspx}{\mbox{\rule[-1pt]{.6pt}{7pt}% +%% \rule[-1pt]{5pt}{.6pt}}} +\newcommand{\lspx}{\mathord{\Rightarrow\mkern-1mu}} +\newcommand{\rspx}{\mathord{\mkern-1mu\Leftarrow}} +\newcommand{\spx}[1]{$\lspx #1\rspx$} + +% For a list of characters representing document input. +\newcommand{\clist}[1]{% + \mbox{\ntt\spaceskip.2em plus.1em \xspaceskip\spaceskip#1}} + +% Fix weird \latex/ definition of rightmark. +\makeatletter +\def\rightmark{\expandafter\@rightmark\botmark{}{}} +% Also turn off section marks. +\let\sectionmark\@gobble +\renewcommand{\chaptermark}[1]{% + \uppercase{\markboth{\rhcn#1}{\rhcn#1}}} +\newcommand{\rhcn}{\thechapter. } +\makeatother + +% Include down to \section but not \subsection, in toc: +\setcounter{tocdepth}{1} + +% Subheadings for the bibliography +\newif\iffirstbibsubhead \firstbibsubheadtrue +\newcommand{\bibsubhead}[1]{% + \iffirstbibsubhead \firstbibsubheadfalse + \else \addvspace{\medskipamount} + \fi + \item[]\hspace*{-\leftmargin}\textbf{#1}\par + \vspace{\smallskipamount} +} + +\DeclareMathOperator{\ix}{ix} +\DeclareMathOperator{\nul}{nul} +\DeclareMathOperator{\End}{End} +\DeclareMathOperator{\xxx}{xxx} + +\usepackage{hyperref} +\hypersetup{pdfborder=0 0 0} +\makeatletter +\let\oldcs\cs +\def\cs#1{\texorpdfstring{\oldcs{#1}}{\@backslashchar\@backslashchar#1}} +\let\cn\cs +\makeatother +\begin{document} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\frontmatter + +\maketitle + +\pagestyle{headings} +\tableofcontents +\cleardoublepage % for better page number placement + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\mainmatter +\chapter{Introduction} + +\index{amsmath@\texttt{amsmath} package|(} + +The \nipkg{amsmath} package is a \LaTeX{} package that provides +miscellaneous enhancements for improving the information structure and +printed output of documents that contain mathematical formulas. Readers +unfamiliar with \LaTeX{} should refer to \cite{lamport}. If you have an +up-to-date version of \LaTeX{}, the \nipkg{amsmath} package is normally +provided along with it. Upgrading when a newer version of the +\nipkg{amsmath} package is released can be done via +\url{http://mirror.ctan.org/macros/latex/required/amsmath.zip}. + +This documentation describes the features of the \nipkg{amsmath} package +and discusses how they are intended to be used. It also covers some +ancillary packages: +\begin{ctab}{lll} +\pkg{amsbsy}& \pkg{amsopn}& \pkg{amsxtra}\\ +\pkg{amscd}& \pkg{amstext}\\ +\end{ctab} +These all have something to do with the contents of math formulas. For +information on extra math symbols and math fonts, see \cite{amsfonts} +and \url{https://www.ams.org/tex/amsfonts.html}. For documentation of the +\pkg{amsthm} package or AMS document classes (\cls{amsart}, +\cls{amsbook}, etc.\@) see \cite{amsthdoc} or \cite{amshandbk} and +\url{https://www.ams.org/tex/author-info.html}. + +If you are a long-time \latex/ user and have lots of mathematics in what +you write, then you may recognize solutions for some familiar problems +in this list of \nipkg{amsmath} features: +\begin{itemize} + +\item A convenient way to define new `operator name' commands analogous +to \cn{sin} and \cn{lim}, including proper side spacing and automatic +selection of the correct font style and size (even when used in +sub- or superscripts). + +\item Multiple substitutes for the \env{eqnarray} environment to make +various kinds of equation arrangements easier to write. + +\item Equation numbers automatically adjust up or down to avoid +overprinting on the equation contents (unlike \env{eqnarray}). + +\item Spacing around equals signs matches the normal spacing in the +\env{equation} environment (unlike \env{eqnarray}). + +\item A way to produce multiline subscripts as are often used with +summation or product symbols. + +\item An easy way to substitute a variant equation number for a given +equation instead of the automatically supplied number. + +\item An easy way to produce subordinate equation numbers of the form +(1.3a) (1.3b) (1.3c) for selected groups of equations. + +\end{itemize} + +The \nipkg{amsmath} package is distributed together with some small +auxiliary packages: +\begin{description} +\item[\nipkg{amsmath}] Primary package, provides various features for + displayed equations and other mathematical constructs. + +\item[\pkg{amstext}] Provides a \cn{text} command for + typesetting a fragment of text inside a display. + +\item[\pkg{amsopn}] Provides \cn{DeclareMathOperator} for defining new + `operator names' like \cn{sin} and \cn{lim}. + +\item[\pkg{amsbsy}] For backward compatibility this package continues +to exist but use of the newer \pkg{bm} package that comes with \LaTeX{} +is recommended instead. + +\item[\pkg{amscd}] Provides a \env{CD} environment for simple + commutative diagrams (no support for diagonal arrows). + +\item[\pkg{amsxtra}] Provides certain odds and ends such as + \cn{fracwithdelims} and \cn{accentedsymbol}, for compatibility with + documents created using version 1.1. + +\end{description} + +The \nipkg{amsmath} package incorporates \pkg{amstext}, \pkg{amsopn}, and +\pkg{amsbsy}. The features of \pkg{amscd} and \pkg{amsxtra}, however, +are available only by invoking those packages separately. + +The independent \pkg{mathtools} package \cite{mt} provides some +enhancements to \nipkg{amsmath}; \pkg{mathtools} loads \nipkg{amsmath} +automatically, so there is no need to separately load \nipkg{amsmath} +if \pkg{mathtools} is used. Some \pkg{mathtools} facilities +will be noted below as appropriate. + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\chapter{Options for the \nipkg{amsmath} package}\label{options} + +The \nipkg{amsmath} package has the following options: +\index{options!amsmath@\texttt{amsmath} package options|(} +\begin{description} + +\item[\opt{centertags}] (default) For an equation containing a +\env{split} environment, place equation +numbers\index{equationn@equation numbers!vertical placement} +vertically centered on the total height of the equation. + +\item[\opt{tbtags}] `Top-or-bottom tags': For an equation containing +a \env{split} environment, place equation +numbers\index{equationn@equation numbers!vertical placement} level with the last +(resp.\ first) line, if numbers are on the right (resp.\ left). + +\item[\opt{sumlimits}] (default) Place the subscripts and +superscripts\index{subscripts and superscripts!placement}\relax +\index{limits|see{subscripts and superscripts}} of summation symbols +above and below, in displayed equations. This option also affects other +symbols of the same type\mdash $\prod$, $\coprod$, $\bigotimes$, +$\bigoplus$, and so forth\mdash but excluding integrals (see below). + +\item[\opt{nosumlimits}] Always place the subscripts and superscripts of +summation-type symbols to the side, even in displayed equations. + +\item[\opt{intlimits}] Like \opt{sumlimits}, but for +integral\index{integrals!placement of limits} symbols. + +\item[\opt{nointlimits}] (default) Opposite of \opt{intlimits}. + +\item[\opt{namelimits}] (default) Like \opt{sumlimits}, but for certain +`operator names' such as $\det$, $\inf$, $\lim$, $\max$, $\min$, that +traditionally have subscripts% +\index{subscripts and superscripts!placement} placed underneath when +they occur in a displayed equation. + +\item[\opt{nonamelimits}] Opposite of \opt{namelimits}. + +\end{description} + +\goodbreak + +\begin{description} +\item[\opt{alignedleftspaceyes}] +\item[\opt{alignedleftspaceno}] +\item[\opt{alignedleftspaceyesifneg}] +\end{description} + +To use one of these package options, put the option name in the optional +argument of the \cn{usepackage} command\mdash e.g., +\verb"\usepackage[intlimits]{amsmath}". +For AMS document classes and any other classes that preload \nipkg{amsmath} +desired options must be specified with the \cn{documentclass}\mdash +e.g.,\\ +\verb+\documentclass[intlimits,tbtags,reqno]{amsart}+. + +The \nipkg{amsmath} package also recognizes the following options which +are normally selected (implicitly or explicitly) through the +\cn{documentclass} command, and thus need not be repeated in the option +list of the \cn{usepackage}|{amsmath}| statement. +\begin{description} + +\item[\opt{leqno}] Place equation numbers on the left.% +\index{equationn@equation numbers!left or right placement} + +\item[\opt{reqno}] Place equation numbers on the right. + +\item[\opt{fleqn}] Position equations at a fixed indent from the left +margin rather than centered in the text column.% +\index{displayed equations!centering} + +\end{description} + +Three options have been added to control the space to the left of +\env{aligned} and \env{gathered} environments. Prior to the 2017 release +a thin space was added to the left but not the right of these constructs. +This appears to have been an accidental feature of the implementation and +was typically corrected by prefixing the environments with \altcnbang. + +The new default behavior is aimed to ensure that the environments do +not have a thin space added in most cases, and that existing documents +using |\!\begin{aligned}| continue to work as before. + +\begin{description} +\item[\opt{alignedleftspaceyes}] Always add \cn{\,} to the left of \env{aligned} and \env{gathered}. +\item[\opt{alignedleftspaceno}] Never add \cn{\,} to the left of \env{aligned} and \env{gathered}. +\item[\opt{alignedleftspaceyesifneg}] Only add \cn{\,} if the environment is prefixed by negative space. (New default behavior.) +\end{description} + +\index{options!amsmath@\texttt{amsmath} package options|)} + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\chapter{Displayed equations} + +\section{Introduction} +The \nipkg{amsmath} package provides a number of additional displayed +equation structures\index{displayed equations}% +\index{equations|see{displayed equations}} beyond the ones +provided in basic \latex/. The augmented set includes: +\begin{verbatim} + equation equation* align align* + gather gather* alignat alignat* + multline multline* flalign flalign* + split +\end{verbatim} +(Although the standard \env{eqnarray} environment remains available, +it is better to use \env{align} or \env{equation}+\env{split} instead. +Within \env{eqnarray}, spacing\index{horizontal spacing} around signs +of relation is not the preferred mathematical spacing, and is +inconsistent with that spacing as it appears in other environments. +Long lines in this environment may result in misplaced or overprinted +equation numbers. This environment also does not support the use of +\cn{qed} or \cn{qedhere} as provided by theorem packages.) + +Except for \env{split}, each environment has both starred and unstarred +forms, where the unstarred forms have automatic numbering using +\latex/'s \env{equation} counter. You can suppress the number on any +particular line by putting \cn{notag} before the end of that line; +\cn{notag} should not be used outside a display environment as it will +mess up the numbering. You can also +override\index{equationn@equation numbers!overriding} a number with a tag +of your own using \cn{tag}|{|\<label>|}|, where \<label> means arbitrary +text such as |$*$| or |ii| used to \qq{number} the equation. +A tag can reference a different tagged display by use of +|\tag{\ref{|\<label>|}|\<modifier>|}| where \<modifier> is optional. +If you are using \pkg{hyperref}, use \cn{ref*}; +use of the starred form of \cn{ref} prevents a reference to a modified +tag containing a nested link from linking to the original display. + +There is also a +\cn{tag*} command that causes the text you supply to be typeset +literally, without adding parentheses around it. \cn{tag} and \cn{tag*} +can also be used within the unnumbered versions of all the \nipkg{amsmath} +alignment structures. Some examples of the use of \cn{tag} may be found +in the sample files \fn{testmath.tex} and \fn{subeqn.tex} provided with +the \nipkg{amsmath} package. + +The \env{split} environment is a special subordinate form that is used +only \emph{inside} one of the others. It cannot be used inside +\env{multline}, however. \env{split} supports only one alignment (|&|) +column; if more are needed, \env{aligned} or \env{alignedat} should be +used. The width of a \env{split} structure is the full line width. + +In the structures that do alignment (\env{split}, \env{align} and +variants), relation symbols have an |&| before them but not +after\mdash unlike \env{eqnarray}. Putting the |&| after the +relation symbol will interfere with the normal spacing; it has to go +before. + +In all multiline environments, lines are divided by \cn{\\}. The \cn{\\} +should \emph{not} be used to end the last line. Using it there will +result in unwanted extra vertical space following the display. + +In \emph{all} math environments (inline or display), blank lines +(equivalent to \cn{par}) are not permitted, and will result in an error. + +\begin{table}[p] +\caption[]{Comparison of displayed equation environments (vertical lines +indicating nominal margins)}\label{displays} +\renewcommand{\theequation}{\arabic{equation}} +\begin{eqxample} +\begin{verbatim} +\begin{equation*} +a=b +\end{equation*} +\end{verbatim} +\producing +\begin{equation*} +a=b +\end{equation*} +\end{eqxample} + +\begin{eqxample} +\begin{verbatim} +\begin{equation} +a=b +\end{equation} +\end{verbatim} +\producing +\begin{equation} +a=b +\end{equation} +\end{eqxample} + +\begin{eqxample} +\begin{verbatim} +\begin{equation}\label{xx} +\begin{split} +a& =b+c-d\\ + & \quad +e-f\\ + & =g+h\\ + & =i +\end{split} +\end{equation} +\end{verbatim} +\producing +\begin{equation}\label{xx} +\begin{split} +a& =b+c-d\\ + & \quad +e-f\\ + & =g+h\\ + & =i +\end{split} +\end{equation} +\end{eqxample} + +\begin{eqxample} +\begin{verbatim} +\begin{multline} +a+b+c+d+e+f\\ ++i+j+k+l+m+n +\end{multline} +\end{verbatim} +\producing +\begin{multline} +a+b+c+d+e+f\\ ++i+j+k+l+m+n +\end{multline} +\end{eqxample} + +\begin{eqxample} +\begin{verbatim} +\begin{gather} +a_1=b_1+c_1\\ +a_2=b_2+c_2-d_2+e_2 +\end{gather} +\end{verbatim} +\producing +\begin{gather} +a_1=b_1+c_1\\ +a_2=b_2+c_2-d_2+e_2 +\end{gather} +\end{eqxample} + +\begin{eqxample} +\begin{verbatim} +\begin{align} +a_1& =b_1+c_1\\ +a_2& =b_2+c_2-d_2+e_2 +\end{align} +\end{verbatim} +\producing +\begin{align} +a_1& =b_1+c_1\\ +a_2& =b_2+c_2-d_2+e_2 +\end{align} +\end{eqxample} + +\begin{eqxample} +\begin{verbatim} +\begin{align} +a_{11}& =b_{11}& + a_{12}& =b_{12}\\ +a_{21}& =b_{21}& + a_{22}& =b_{22}+c_{22} +\end{align} +\end{verbatim} +\producing +\begin{align} +a_{11}& =b_{11}& + a_{12}& =b_{12}\\ +a_{21}& =b_{21}& + a_{22}& =b_{22}+c_{22} +\end{align} +\end{eqxample} + +\begin{eqxample} +\begin{verbatim} +\begin{flalign*} +a_{11} + b_{11}& = c_{11}& + a_{12}& =b_{12}\\ +b_{21}& = c_{21}& + a_{22}& =b_{22}+c_{22} +\end{flalign*} +\end{verbatim} +\producing +\begin{flalign*} +a_{11} + b_{11}& = c_{11}& + a_{12}& =b_{12}\\ +b_{21}& = c_{21}& + a_{22}& =b_{22}+c_{22} +\end{flalign*} +\end{eqxample} +\end{table} + +%% ------------------------------------------------------------------ %% +\enlargethispage{1\baselineskip} + +\section{Single equations} + +The \env{equation} environment is for a single equation with an +automatically generated number. The \env{equation*} environment is the +same except for omitting the number.% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\footnote{Basic \latex/ doesn't provide an \env{equation*} environment, +but rather a functionally equivalent environment named +\env{displaymath}.} +The wrapper \verb+\[ ... \]+ is equivalent to \env{equation*}.% +\index{[@\verb+\[ ... \]+} + +%% ------------------------------------------------------------------ %% + +\section{Split equations without alignment} + +The \env{multline} environment is a variation of the \env{equation} +environment used for equations that don't fit on a single line. The +first line of a \env{multline} will be at the left margin and the last +line at the right margin, except for an indention on both sides in the +amount of \cn{multlinegap}. Any additional lines in between will be +centered independently within the display width (unless the \opt{fleqn} +option is in effect).% +\index{options!behavior of particular options} + +Like \env{equation}, \env{multline} has only a single equation number +(thus, none of the individual lines should be marked with \cn{notag}). +The equation number is placed on the last line (\opt{reqno} option) or +first line (\opt{leqno} option); vertical centering as for \env{split} +is not supported by \env{multline}.% +\index{options!behavior of particular options} + +It's possible to force one of the middle lines to the left or right with +commands \cn{shoveleft}, \cn{shoveright}. These commands take the entire +line as an argument, up to but not including the final \cn{\\}; for +example +\begin{multline} +\framebox[.65\columnwidth]{A}\\ +\framebox[.5\columnwidth]{B}\\ +\shoveright{\framebox[.55\columnwidth]{C}}\\ +\framebox[.65\columnwidth]{D} +\end{multline} +\begin{verbatim} +\begin{multline} +\framebox[.65\columnwidth]{A}\\ +\framebox[.5\columnwidth]{B}\\ +\shoveright{\framebox[.55\columnwidth]{C}}\\ +\framebox[.65\columnwidth]{D} +\end{multline} +\end{verbatim} + +The value of \cn{multlinegap} can be changed with the usual \latex/ +commands \cn{setlength} or \cn{addtolength}. + +%% ------------------------------------------------------------------ %% + +\section{Split equations with alignment} + +Like \env{multline}, the \env{split} environment is for \emph{single} +equations that are too long to fit on one line and hence must be split +into multiple lines. Unlike \env{multline}, however, the \env{split} +environment provides for alignment among the split lines, using |&| to +mark alignment points. Unlike the other \nipkg{amsmath} equation +structures, the \env{split} environment provides no numbering, because +it is intended to be used \emph{only inside some other displayed + equation structure}, usually an \env{equation}, \env{align}, or +\env{gather} environment, which provides the numbering. For example: +\begin{equation}\label{e:barwq}\begin{split} +H_c&=\frac{1}{2n} \sum^n_{l=0}(-1)^{l}(n-{l})^{p-2} + \sum_{l _1+\dots+ l _p=l}\prod^p_{i=1} \binom{n_i}{l _i}\\ +&\quad\cdot[(n-l )-(n_i-l _i)]^{n_i-l _i}\cdot + \Bigl[(n-l )^2-\sum^p_{j=1}(n_i-l _i)^2\Bigr]. + \kern-2em % adjust equation body to the right [mjd,13-Nov-1994] +\end{split}\end{equation} + +\begin{verbatim} +\begin{equation}\label{e:barwq}\begin{split} +H_c&=\frac{1}{2n} \sum^n_{l=0}(-1)^{l}(n-{l})^{p-2} + \sum_{l _1+\dots+ l _p=l}\prod^p_{i=1} \binom{n_i}{l _i}\\ +&\quad\cdot[(n-l )-(n_i-l _i)]^{n_i-l _i}\cdot + \Bigl[(n-l )^2-\sum^p_{j=1}(n_i-l _i)^2\Bigr]. +\end{split}\end{equation} +\end{verbatim} + +The \env{split} structure should constitute the entire body of the +enclosing structure, apart from commands like \cn{label} that produce no +visible material. + +%% ------------------------------------------------------------------ %% + +\section{Equation groups without alignment} + +The \env{gather} environment is used for a group of consecutive +equations when there is no alignment desired among them; each one is +centered separately within the text width (see Table~\ref{displays}). +Equations inside \env{gather} are separated by a \cn{\\} command. +Any equation in a \env{gather} may consist of a \verb'\begin{split}' + \dots\ \verb'\end{split}' structure\mdash for example: +\begin{verbatim} +\begin{gather} + first equation\\ + \begin{split} + second & equation\\ + & on two lines + \end{split} + \\ + third equation +\end{gather} +\end{verbatim} + +%% ------------------------------------------------------------------ %% + +\section{Equation groups with mutual alignment} + +The \env{align} environment is used for two or more equations when +vertical alignment is desired; usually binary relations such as equal +signs are aligned (see Table~\ref{displays}). + +To have several equation columns side-by-side, use extra ampersands +to separate the columns: +\begin{align} +x&=y & X&=Y & a&=b+c\\ +x'&=y' & X'&=Y' & a'&=b\\ +x+x'&=y+y' & X+X'&=Y+Y' & a'b&=c'b +\end{align} +% +\begin{verbatim} +\begin{align} +x&=y & X&=Y & a&=b+c\\ +x'&=y' & X'&=Y' & a'&=b\\ +x+x'&=y+y' & X+X'&=Y+Y' & a'b&=c'b +\end{align} +\end{verbatim} +Line-by-line annotations on an equation can be done by judicious +application of \cn{text} inside an \env{align} environment: +\begin{align} +x& = y_1-y_2+y_3-y_5+y_8-\dots + && \text{by \eqref{eq:C}}\\ + & = y'\circ y^* && \text{by \eqref{eq:D}}\\ + & = y(0) y' && \text {by Axiom 1.} +\end{align} +% +\begin{verbatim} +\begin{align} +x& = y_1-y_2+y_3-y_5+y_8-\dots + && \text{by \eqref{eq:C}}\\ + & = y'\circ y^* && \text{by \eqref{eq:D}}\\ + & = y(0) y' && \text {by Axiom 1.} +\end{align} +\end{verbatim} +A variant environment \env{alignat} allows the horizontal space between +equations to be explicitly specified. This environment takes one argument, +the number of \qq{equation columns} (the number of pairs of right-left +aligned columns; the argument is the number of pairs): count the maximum +number of \verb'&'s in any row, add~1 and divide by~2. +\begin{alignat}{2} +x& = y_1-y_2+y_3-y_5+y_8-\dots + &\quad& \text{by \eqref{eq:C}}\\ + & = y'\circ y^* && \text{by \eqref{eq:D}}\\ + & = y(0) y' && \text {by Axiom 1.} +\end{alignat} +% +\begin{verbatim} +\begin{alignat}{2} +x& = y_1-y_2+y_3-y_5+y_8-\dots + &\quad& \text{by \eqref{eq:C}}\\ + & = y'\circ y^* && \text{by \eqref{eq:D}}\\ + & = y(0) y' && \text {by Axiom 1.} +\end{alignat} +\end{verbatim} +The environment \env{flalign} (``full length alignment'') stretches the +space between the equation columns to the maximum possible width, leaving +only enough space at the margin for the equation number, if present. +\begin{flalign} +x&=y & X&=Y\\ +x'&=y' & X'&=Y'\\ +x+x'&=y+y' & X+X'&=Y+Y' +\end{flalign} +% +\begin{verbatim} +\begin{flalign} +x&=y & X&=Y\\ +x'&=y' & X'&=Y'\\ +x+x'&=y+y' & X+X'&=Y+Y' +\end{flalign} +\end{verbatim} +% +\begin{flalign*} +x&=y & X&=Y\\ +x'&=y' & X'&=Y'\\ +x+x'&=y+y' & X+X'&=Y+Y' +\end{flalign*} +% +\begin{verbatim} +\begin{flalign*} +x&=y & X&=Y\\ +x'&=y' & X'&=Y'\\ +x+x'&=y+y' & X+X'&=Y+Y' +\end{flalign*} +\end{verbatim} + +%% ------------------------------------------------------------------ %% + +\section{Alignment building blocks} + +Like \env{equation}, the multi-equation environments \env{gather}, +\env{align}, and \env{alignat} are designed to produce a structure +whose width is the full line width. This means, for example, that one +cannot readily add parentheses around the entire structure. But +variants\index{ed env@\texttt{-ed} environments|(} +\env{gathered}, \env{aligned}, and \env{alignedat} are provided whose +total width is the actual width of the contents; thus they can be used +as a component in a containing expression. E.g., +\begin{equation*} +\left.\begin{aligned} + B'&=-\partial\times E,\\ + E'&=\partial\times B - 4\pi j, +\end{aligned} +\right\} +\qquad \text{Maxwell's equations} +\end{equation*} +\begin{verbatim} +\begin{equation*} +\left.\begin{aligned} + B'&=-\partial\times E,\\ + E'&=\partial\times B - 4\pi j, +\end{aligned} +\right\} +\qquad \text{Maxwell's equations} +\end{equation*} +\end{verbatim} +Like the \env{array} environment, these \texttt{-ed} variants also take +an optional\index{options!positioning of \texttt{-ed} environments} +|[t]|\index{t option@\texttt{t} (top) option}, +|[b]|\index{b option@\texttt{b} (bottom) option} or the default +|[c]|\index{c option@\texttt{c} (center) option} +argument to specify vertical +positioning. For maximum interoperability, do not insert a +space\index{options!space before \texttt{[}} +or line break\index{line break} before the option. See +also the note on page~\pageref{breaknote} regarding page breaking +within the \texttt{-ed} environments. + +\qq{Cases} constructions like the following are common in +mathematics: +\begin{equation}\label{eq:C} +P_{r-j}= + \begin{cases} + 0& \text{if $r-j$ is odd},\\ + r!\,(-1)^{(r-j)/2}& \text{if $r-j$ is even}. + \end{cases} +\end{equation} +and in the \nipkg{amsmath} package there is a \env{cases} environment to +make them easy to write: +\begin{verbatim} +P_{r-j}=\begin{cases} + 0& \text{if $r-j$ is odd},\\ + r!\,(-1)^{(r-j)/2}& \text{if $r-j$ is even}. + \end{cases} +\end{verbatim} +Notice the use of \cn{text} (cf.~\secref{text}) and the nested math +formulas. \env{cases} is set in \cn{textstyle}. If \cn{displaystyle} +is wanted, it must be requested explicitly; \pkg{mathtools} provides +a \env{dcases} environment for this purpose. + +The |-ed|\index{ed env@\texttt{-ed} environments|)} and \env{cases} +environments must appear within an enclosing math environment, which can +be either in text, between |$...$|, or in any of the display environments. + +%% ------------------------------------------------------------------ %% + +\section{Adjusting tag placement} + +Placing equation numbers can be a rather complex problem in multiline +displays. The environments of the \nipkg{amsmath} package try hard to +avoid overprinting an equation number on the equation contents, if +necessary moving the number down or up to a separate line. Difficulties +in accurately calculating the profile of an equation can occasionally +result in number movement that doesn't look right. +A \cn{raisetag} command is provided to adjust the vertical position of the +current equation number, if it has been shifted away from its normal +position. To move a particular number up by six points, write +|\raisetag{6pt}|. (At the end of a display, this also shifts up the +text following the display.) +This kind of adjustment is fine tuning like line +breaks and page breaks, and should therefore be left undone until your +document is nearly finalized, or you may end up redoing the fine tuning +several times to keep up with changing document contents. + +%% ------------------------------------------------------------------ %% + +\section{Vertical spacing and page breaks in multiline displays} + +You can use the \cn{\\}|[|\<dimension>|]|% +\index{options!extra vertical space after \cn{\\}} +command to get extra vertical +space between lines in all the \nipkg{amsmath} displayed equation +environments, as is usual in \latex/. Do not type a space between the% +\index{options!space before \texttt{[}} +\cn{\\} and the following |[|; \emph{only} for display environments +defined by \nipkg{amsmath} the space is interpreted to mean that the +bracketed material is part of the document content. + +When the \nipkg{amsmath} package is +in use \ii{page breaks} between equation lines are normally disallowed; +the philosophy is that page breaks in such material should receive +individual attention from the author. To get an individual page break +inside a particular displayed equation, a \cn{displaybreak} command is +provided. \cn{displaybreak} is best placed immediately before the +\cn{\\} where it is to take effect. Like \latex/'s \cn{pagebreak}, +\cn{displaybreak} takes an optional argument% +\index{options!behavior of particular options} between 0 and 4 denoting +the desirability of the pagebreak. |\displaybreak[0]| means \qq{it is + permissible to break here} without encouraging a break; +\cn{displaybreak} with no optional argument is the same as +|\displaybreak[4]| and forces a break. + +If you prefer a strategy of letting page breaks fall where they may, +even in the middle of a multiline equation, then you might put +\cn{allowdisplaybreaks}\texttt{[1]} in the preamble of your document. An +optional argument\index{options!behavior of particular options} +1\ndash 4 can be used for finer control: |[1]| means +allow page breaks, but avoid them as much as possible; values of 2,3,4 +mean increasing permissiveness. When display breaks are enabled with +\cn{allowdisplaybreaks}, the \cn{\\*} command can be used to prohibit a +pagebreak after a given line, as usual. + +\begin{bfseries} +Note:\label{breaknote} Certain equation environments wrap their contents +in an unbreakable box, with the consequence that neither \cn{displaybreak} +nor \cn{allowdisplaybreaks} will have any effect on them. These include +\env{split}, \env{aligned}, \env{gathered}, and \env{alignedat}. +\end{bfseries} + +%% ------------------------------------------------------------------ %% + +\section{Interrupting a display} + +The command \cn{intertext} is used for a short interjection of one or +two lines of text\index{text fragments inside math} in the middle of a +multiple-line display structure (see also the \cn{text} command in +\secref{text}). Its salient feature is preservation of the alignment, +which would not happen if you simply ended the display and then started +it up again afterwards. \cn{intertext} may only appear right after a +\cn{\\} or \cn{\\*} command. Notice the position of the word \qq{and} in +this example. +\begin{align} + A_1&=N_0(\lambda;\Omega')-\phi(\lambda;\Omega'),\\ + A_2&=\phi(\lambda;\Omega')-\phi(\lambda;\Omega),\\ +\intertext{and} + A_3&=\mathcal{N}(\lambda;\omega). +\end{align} +\begin{verbatim} +\begin{align} + A_1&=N_0(\lambda;\Omega')-\phi(\lambda;\Omega'),\\ + A_2&=\phi(\lambda;\Omega')-\phi(\lambda;\Omega),\\ +\intertext{and} + A_3&=\mathcal{N}(\lambda;\omega). +\end{align} +\end{verbatim} + +The \pkg{mathtools} package provides a command \cn{shortintertext} that +is intended for use when the interjected text is only a few words; it uses +less vertical space than \cn{intertext}. This +is most effective when equation numbers are on the right.% +\index{equationn@equation numbers!left or right placement} + +%% ------------------------------------------------------------------ %% + +\section{Equation numbering} + +\subsection{Numbering hierarchy} +In \latex/ if you wanted to have equations numbered within +sections\mdash that is, have +equation numbers (1.1), (1.2), \dots, (2.1), (2.2), +\dots, in sections 1, 2, and so forth\mdash you could redefine +\cn{theequation} as suggested in the \latex/ manual \cite[\S6.3, \S +C.8.4]{lamport}: +\begin{verbatim} +\renewcommand{\theequation}{\thesection.\arabic{equation}} +\end{verbatim} + +This works pretty well, except that the equation counter won't be reset +to zero at the beginning of a new section or chapter, unless you do it +yourself using \cn{setcounter}. To make this a little more convenient, +the \nipkg{amsmath} package provides a +command\index{equationn@equation numbers!hierarchy} \cn{numberwithin}. +To have equation numbering tied to section numbering, with automatic +reset of the equation counter, write +\begin{verbatim} +\numberwithin{equation}{section} +\end{verbatim} +As its name implies, the \cn{numberwithin} command can be applied to +any counter, not just the \texttt{equation} counter. + +\subsection{Cross references to equation numbers} + +To make cross-references to equations easier, an \cn{eqref} +command\index{equationn@equation numbers!cross-references} is provided. This +automatically supplies the parentheses around the equation number. I.e., +if \verb'\ref{abc}' produces 3.2 then \verb'\eqref{abc}' produces +(3.2). The parentheses around an \cn{eqref} equation number will be +set in upright type regardless of type style of the context. + +\subsection{Subordinate numbering sequences} + +The \nipkg{amsmath} package provides also a wrapper environment, +\env{subequations}\index{equationn@equation numbers!subordinate numbering}, to make it +easy to number equations in a particular \cn{align} or similar group with +a subordinate numbering scheme. For example +\begin{verbatim} +\begin{subequations} +... +\end{subequations} +\end{verbatim} +causes all numbered equations within that part of the document to be +numbered (4.9a) (4.9b) (4.9c) \dots, if the preceding numbered +equation was (4.8). A \cn{label} command immediately after +\verb/\begin{subequations}/ will produce a \cn{ref} of the parent +number 4.9, not 4.9a. The counters used by the subequations +environment are \verb/parentequation/ and \verb/equation/ and +\cn{addtocounter}, \cn{setcounter}, \cn{value}, etc., can be applied +as usual to those counter names. To get anything other than lowercase +letters for the subordinate numbers, use standard \latex/ methods for +changing numbering style \cite[\S6.3, \S C.8.4]{lamport}. For example, +redefining \cn{theequation} as follows will produce roman numerals. +\begin{verbatim} +\begin{subequations} +\renewcommand{\theequation}{\theparentequation \roman{equation}} +... +\end{verbatim} + +\subsection{Numbering style} + +The default equation number is set in \cn{normalfont}. This means that +in bold section headings, bold is suppressed; a workaround for this is +to use \verb+(\ref{+\ldots\verb+})+ rather than \verb+\eqref{+\ldots\verb+}+. + +If smaller type is specified for a numbered display, the size of the +equation number will also be small. The default size can be ensured +throughout a document by applying this patch in the preamble: +\begin{verbatim} +\makeatletter +\renewcommand{\maketag@@@}[1]{\hbox{\m@th\normalsize\normalfont#1}}% +\makeatother +\end{verbatim} +(This modification may be included in a future version of +\nipkg{amsmath}.) + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\chapter{Miscellaneous mathematical features} + +\section{Matrices}\label{ss:matrix} + +The \nipkg{amsmath} package provides some environments for +matrices\index{matrices} beyond the basic \env{array} environment of +\latex/. The \env{pmatrix}, \env{bmatrix}, \env{Bmatrix}, \env{vmatrix} +and \env{Vmatrix} have (respectively) $(\,)$, $[\,]$, $\lbrace\,\rbrace$, +$\lvert\,\rvert$, and $\lVert\,\rVert$ delimiters\index{delimiters} +built in. For naming consistency there is a +\env{matrix} environment sans delimiters. This is not entirely redundant +with the \env{array} environment; the matrix environments all use more +economical horizontal spacing than the rather prodigal spacing of the +\env{array} environment. Also, unlike the \env{array} environment, you +don't have to give column specifications for any of the matrix +environments; by default you can have up to 10 centered columns.% +\footnote{%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +More precisely: The maximum number of columns in a matrix is determined +by the counter |MaxMatrixCols| (normal value = 10), which you can change +if necessary using \latex/'s \cn{setcounter} or \cn{addtocounter} +commands.% +}\space%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +(If you need left or right alignment in a column or other special +formats you may use \env{array}, or the \pkg{mathtools} +package which provides \verb+*+ variants% +\index{matrix@\indexenvironmentfont{matrix} environment!\verb+*+ variants} +of these environments with +an optional argument to specify left or right alignment.) + +To produce a small matrix suitable for use in text, there is a +\env{smallmatrix} environment (e.g., +\begin{math} +\bigl( \begin{smallmatrix} + a&b\\ c&d +\end{smallmatrix} \bigr) +\end{math}) +that comes closer to fitting within a single text line than a normal +matrix. Delimiters\index{delimiters} must be provided. (The +\pkg{mathtools} package provides |p|,|b|,|B|,|v|,|V| versions of +\env{smallmatrix},% +\index{smallmatrix@\indexenvironmentfont{smallmatrix} environment!variant delimiters} +as well as |*| variants% +\index{smallmatrix@\indexenvironmentfont{smallmatrix} environment!\verb+*+ variants} +as described above.) +The above example was produced by +\begin{verbatim} +\bigl( \begin{smallmatrix} + a&b\\ c&d +\end{smallmatrix} \bigr) +\end{verbatim} + +\cn{hdotsfor}|{|\<number>|}| produces a row of dots in a +matrix\index{matrices!ellipsis dots}\index{ellipsis dots!in +matrices}\index{dots|see{ellipsis dots}} spanning the given number of +columns. For example, +\begin{center} +\begin{minipage}{.3\columnwidth} +\noindent$\begin{matrix} a&b&c&d\\ +e&\hdotsfor{3} \end{matrix}$ +\end{minipage}% +\qquad +\begin{minipage}{.45\columnwidth} +\begin{verbatim} +\begin{matrix} a&b&c&d\\ +e&\hdotsfor{3} \end{matrix} +\end{verbatim} +\end{minipage}% +\end{center} + +The spacing of the dots can be varied through use of a square-bracket +option,\index{options!behavior of particular options} +for example, |\hdotsfor[1.5]{3}|. The number in square brackets +will be used as a multiplier (i.e., the normal value is 1.0). +\begin{equation}\label{eq:D} +\begin{pmatrix} D_1t&-a_{12}t_2&\dots&-a_{1n}t_n\\ +-a_{21}t_1&D_2t&\dots&-a_{2n}t_n\\ +\hdotsfor[2]{4}\\ +-a_{n1}t_1&-a_{n2}t_2&\dots&D_nt\end{pmatrix}, +\end{equation} +\begin{verbatim} +\begin{pmatrix} D_1t&-a_{12}t_2&\dots&-a_{1n}t_n\\ +-a_{21}t_1&D_2t&\dots&-a_{2n}t_n\\ +\hdotsfor[2]{4}\\ +-a_{n1}t_1&-a_{n2}t_2&\dots&D_nt\end{pmatrix} +\end{verbatim} + +%% ------------------------------------------------------------------ %% + +\section{Math spacing commands} + +The \nipkg{amsmath} package slightly extends the set of math +spacing\index{horizontal spacing} commands, as shown below. +Both the spelled-out and abbreviated forms of these commands are robust, +and they can also be used outside of math. +\begin{ctab}{lll|lll} +Abbrev.& Spelled out& Example & Abbrev.& Spelled out& Example\\ +\hline +\vstrut{2.5ex} +& no space& \spx{}& & no space & \spx{}\\ +\cn{\,}& \cn{thinspace}& \spx{\,}& + \altcnbang& \cn{negthinspace}& \spx{\!}\\ +\cn{\:}& \cn{medspace}& \spx{\:}& + & \cn{negmedspace}& \spx{\negmedspace}\\ +\cn{\;}& \cn{thickspace}& \spx{\;}& + & \cn{negthickspace}& \spx{\negthickspace}\\ +& \cn{quad}& \spx{\quad}\\ +& \cn{qquad}& \spx{\qquad} +\end{ctab} +For the greatest possible control over math spacing, use \cn{mspace} +and `math units'. One math unit, or |mu|, is equal to 1/18 em. Thus to +get a negative \cn{quad} you could write |\mspace{-18.0mu}|. + +%% ------------------------------------------------------------------ %% + +\section{Dots} + +For preferred placement of ellipsis dots (raised or on-line) in various +contexts there is no general consensus. It may therefore be considered a +matter of taste. By using the semantically oriented commands +\begin{itemize} +\item \cn{dotsc} for \qq{dots with commas} +\item \cn{dotsb} for \qq{dots with binary operators/relations} +\item \cn{dotsm} for \qq{multiplication dots} +\item \cn{dotsi} for \qq{dots with integrals} +\item \cn{dotso} for \qq{other dots} (none of the above) +\end{itemize} +instead of \cn{ldots} and \cn{cdots}, you make it possible for your +document to be adapted to different conventions on the fly, in case (for +example) you have to submit it to a publisher who insists on following +house tradition in this respect. The default treatment for the various +kinds follows American Mathematical Society conventions: +\begin{center} +\begin{tabular}{@{}l@{}l@{}} +\begin{minipage}[t]{.54\textwidth} +\begin{verbatim} +Then we have the series $A_1, A_2, +\dotsc$, the regional sum $A_1 ++A_2 +\dotsb $, the orthogonal +product $A_1 A_2 \dotsm $, and +the infinite integral +\[\int_{A_1}\int_{A_2}\dotsi\]. +\end{verbatim} +\end{minipage} +& +\begin{minipage}[t]{.45\textwidth} +\noindent +Then we have the series $A_1,A_2,\dotsc$, +the regional sum $A_1+A_2+\dotsb$, +the orthogonal product $A_1A_2\dotsm$, +and the infinite integral +\[\int_{A_1}\int_{A_2}\dotsi.\] +\end{minipage} +\end{tabular} +\end{center} +For most situations, the undifferentiated \cn{dots} can be used, and +\nipkg{amsmath} will output the most suitable form based on the +immediate context; if an inappropriate form results, it can be corrected +after examining the output. + +%% ------------------------------------------------------------------ %% + +\section{Nonbreaking dashes} + +A command \cn{nobreakdash} is provided to suppress the possibility of a +line break\index{line break|(} after the following hyphen or dash. For +example, if you write `pages 1\ndash 9' as |pages 1\nobreakdash--9| +then a line break will never occur between the dash and the 9. You can +also use \cn{nobreakdash} to prevent undesirable hyphenations in +combinations like |$p$-adic|. For frequent use, it's advisable to make +abbreviations, e.g., +\begin{verbatim} +\newcommand{\p}{$p$\nobreakdash}% for "\p-adic" +\newcommand{\Ndash}{\nobreakdash--}% for "pages 1\Ndash 9" +% For "\n dimensional" ("n-dimensional"): +\newcommand{\n}[1]{$n$\nobreakdash-\hspace{0pt}} +\end{verbatim} +The last example shows how to prohibit a line break\index{line break|)} +after the hyphen but allow normal hyphenation in the following +word. (It suffices to add a zero-width space after the hyphen.) + +%% ------------------------------------------------------------------ %% + +\section{Accents in math} + +In ordinary \LaTeX{} the placement of the second accent in doubled math +accents is often poor. With the \nipkg{amsmath} package you +will get improved placement of the second accent: +$\hat{\hat{A}}$ (\cn{hat}|{\hat{A}}|). + +The commands \cn{dddot} and \cn{ddddot} are available to produce triple +and quadruple dot accents in addition to the \cn{dot} and \cn{ddot} +accents already available in \latex/. + +To get a superscripted hat or tilde character, load the \pkg{amsxtra} +package and use \cn{sphat} or \cn{sptilde}. Usage is \verb'A\sphat' +(note the absence of the \verb'^' character). + + +To place an arbitrary symbol in math accent position, or to get under +accents, see the \pkg{accents} package by Javier Bezos. (\nipkg{amsmath} +must be loaded before \pkg{accents}.) + +%% ------------------------------------------------------------------ %% + +\section{Roots} + +In ordinary \latex/ the placement of root indices is sometimes not so +good: $\sqrt[\beta]{k}$ (|\sqrt||[\beta]{k}|). In the +\nipkg{amsmath} package \cn{leftroot} and \cn{uproot} allow you to adjust +the position of the root:% +\index{options!adjust positioning} +\begin{verbatim} + \sqrt[\leftroot{-2}\uproot{2}\beta]{k} +\end{verbatim} +will move the beta up and to the right: +$\sqrt[\leftroot{-2}\uproot{2}\beta]{k}$. The negative argument used +with \cn{leftroot} moves the $\beta$ to the right. The units are a small +amount that is a useful size for such adjustments. + +%% ------------------------------------------------------------------ %% + +\section{Boxed formulas} + +The command \cn{boxed} puts a box around its +argument, like \cn{fbox} except that the contents are in math mode: +\begin{equation} +\boxed{\eta \leq C(\delta(\eta) +\Lambda_M(0,\delta))} +\end{equation} +\begin{verbatim} + \boxed{\eta \leq C(\delta(\eta) +\Lambda_M(0,\delta))} +\end{verbatim} + +%% ------------------------------------------------------------------ %% + +\section{Over and under arrows} + +Basic \latex/ provides \cn{overrightarrow} and \cn{overleftarrow} +commands. Some additional over and under arrow commands are provided +by the \nipkg{amsmath} package to extend the set: + +\begin{tabbing} +\qquad\=\ncn{overleftrightarrow}\qquad\=\kill +\> \cn{overleftarrow} \> \cn{underleftarrow} \+\\ + \cn{overrightarrow} \> \cn{underrightarrow} \\ + \cn{overleftrightarrow}\> \cn{underleftrightarrow} +\end{tabbing} + +%% ------------------------------------------------------------------ %% + +\section{Extensible arrows} + +\cn{xleftarrow} and \cn{xrightarrow} produce +arrows\index{arrows!extensible} that extend automatically to accommodate +unusually wide subscripts or superscripts. These commands take one +optional argument\index{options!behavior of particular options} +(the subscript) and one mandatory argument (the +superscript, possibly empty): +\begin{equation} +A\xleftarrow{n+\mu-1}B \xrightarrow[T]{n\pm i-1}C +\end{equation} +\begin{verbatim} + \xleftarrow{n+\mu-1}\quad \xrightarrow[T]{n\pm i-1} +\end{verbatim} + +%% ------------------------------------------------------------------ %% + +\section{Affixing symbols to other symbols} + +\latex/ provides \cn{stackrel} for placing a +superscript\index{subscripts and superscripts} above a binary relation. +In the \nipkg{amsmath} package there are somewhat more general commands, +\cn{overset} and \cn{underset}, that can be used to place one symbol +above or below another symbol, whether it's a relation or something +else. The input |\overset{*}{X}| will place a superscript-size $*$ above +the $X$: $\overset{*}{X}$; \cn{underset} is the analog for adding a +symbol underneath. + +See also the description of \cn{sideset} in \secref{sideset}. + +%% ------------------------------------------------------------------ %% + +\section{Fractions and related constructions} + +\subsection{The \cn{frac}, \cn{dfrac}, and \cn{tfrac} commands} + +The \cn{frac} command, which is in the basic command set of +\latex/,\index{fractions|(} takes two arguments\mdash numerator and +denominator\mdash and typesets them in normal fraction form. The +\nipkg{amsmath} package provides also \cn{dfrac} and \cn{tfrac} as +convenient abbreviations for |{\displaystyle\frac| |...| |}| +and\indexcs{textstyle}\relax +\indexcs{displaystyle} |{\textstyle\frac| |...| |}|. +\begin{equation} +\frac{1}{k}\log_2 c(f)\quad\tfrac{1}{k}\log_2 c(f)\quad +\sqrt{\frac{1}{k}\log_2 c(f)}\quad\sqrt{\dfrac{1}{k}\log_2 c(f)} +\end{equation} +\begin{verbatim} +\begin{equation} +\frac{1}{k}\log_2 c(f)\;\tfrac{1}{k}\log_2 c(f)\; +\sqrt{\frac{1}{k}\log_2 c(f)}\;\sqrt{\dfrac{1}{k}\log_2 c(f)} +\end{equation} +\end{verbatim} + +\subsection{The \cn{binom}, \cn{dbinom}, and \cn{tbinom} commands} + +For binomial expressions\index{binomials} such as $\binom{n}{k}$ +\nipkg{amsmath} has \cn{binom}, \cn{dbinom} and \cn{tbinom}: +\begin{equation} +2^k-\binom{k}{1}2^{k-1}+\binom{k}{2}2^{k-2} +\end{equation} +\begin{verbatim} +2^k-\binom{k}{1}2^{k-1}+\binom{k}{2}2^{k-2} +\end{verbatim} + +\subsection{The \cn{genfrac} command} + +The capabilities of \cn{frac}, \cn{binom}, and their variants are +subsumed by a generalized fraction command \cn{genfrac} with six +arguments. The last two correspond to \cn{frac}'s numerator and +denominator; the first two are optional delimiters\index{delimiters} (as +seen in \cn{binom}); the third is a line thickness override (\cn{binom} +uses this to set the fraction line thickness to 0\mdash i.e., invisible); +and the fourth argument is a mathstyle override: integer values 0\ndash 3 +select respectively \cn{displaystyle}, \cn{textstyle}, \cn{scriptstyle}, +and \cn{scriptscriptstyle}. If the third argument is left empty, the line +thickness defaults to `normal'. + +\begin{center}\begin{minipage}{.85\columnwidth} +\raggedright \normalfont\ttfamily \exhyphenpenalty10000 +\newcommand{\ma}[1]{% + \string{{\normalfont\itshape#1}\string}\penalty9999 \ignorespaces} +\string\genfrac \ma{left-delim} \ma{right-delim} \ma{thickness} +\ma{mathstyle} \ma{numerator} \ma{denominator} +\end{minipage}\end{center} +To illustrate, here is how \cn{frac}, \cn{tfrac}, and +\cn{binom} might be defined. +\begin{verbatim} +\newcommand{\frac}[2]{\genfrac{}{}{}{}{#1}{#2}} +\newcommand{\tfrac}[2]{\genfrac{}{}{}{1}{#1}{#2}} +\newcommand{\binom}[2]{\genfrac{(}{)}{0pt}{}{#1}{#2}} +\end{verbatim} +If you find yourself repeatedly using \cn{genfrac} throughout a document +for a particular notation, you will do yourself a favor (and your +publisher) if you define a meaningfully-named abbreviation for that +notation, along the lines of \cn{frac} and \cn{binom}. + +The primitive generalized fraction commands \cs{over}, \cs{overwithdelims}, +\cs{atop}, \cs{atopwithdelims}, \cs{above}, \cs{abovewithdelims} produce +warning messages if used with the \nipkg{amsmath} package, for reasons +discussed in \fn{technote.tex}. + +%% ------------------------------------------------------------------ %% + +\section{Continued fractions} + +The continued fraction\index{continued fractions} +\begin{equation} +\cfrac{1}{\sqrt{2}+ + \cfrac{1}{\sqrt{2}+ + \cfrac{1}{\sqrt{2}+\cdots +}}} +\end{equation} +can be obtained by typing +{\samepage +\begin{verbatim} +\cfrac{1}{\sqrt{2}+ + \cfrac{1}{\sqrt{2}+ + \cfrac{1}{\sqrt{2}+\dotsb +}}} +\end{verbatim} +}% End of \samepage +This produces better-looking results than straightforward use of +\cn{frac}. Left or right placement of any of the numerators is +accomplished by using \cn{cfrac}|[l]| or \cn{cfrac}|[r]| instead of +\cn{cfrac}.\index{options!adjust positioning}% +\index{fractions|)} + +%% ------------------------------------------------------------------ %% + +\section{Smash options} + +The command \cn{smash} is used to typeset a subformula with an +effective height and depth of zero, which is sometimes +useful in adjusting the subformula's position with respect to adjacent +symbols. With the \nipkg{amsmath} package \cn{smash} has optional +arguments\index{options!behavior of particular options} +|[t]|\index{t option@\texttt{t} (top) option} and +|[b]|\index{b option@\texttt{b} (bottom) option} because occasionally it is +advantageous to be able to \qq{smash} only the top or only the bottom +of something while retaining the natural depth or height. For example, +when adjacent radical symbols are unevenly sized or positioned because +of differences in the height and depth of their contents, \cn{smash} +can be employed to make them more consistent. Compare +$\sqrt{x}+\sqrt{y}+\sqrt{z}$ and $\sqrt{x}+\sqrt{\smash[b]{y}}+\sqrt{z}$, +where the latter was produced by +\verb"$\sqrt{x}" \verb"+" +\verb"\sqrt{"\5\verb"\smash[b]{y}}" \verb"+" \verb"\sqrt{z}$". + +%% ------------------------------------------------------------------ %% + +\section{Delimiters} + +\index{delimiters|(} + +\subsection{Delimiter sizes}\label{bigdel} + +The automatic delimiter sizing done by \cn{left} and \cn{right} has two +limitations: First, it is applied mechanically to produce delimiters +large enough to encompass the largest contained item, and second, the +range of sizes is not even approximately continuous but has fairly large +quantum jumps. This means that a math fragment that is infinitesimally +too large for a given delimiter size will get the next larger size, a +jump of 3pt or so in normal-sized text. There are two or three +situations where the delimiter size is commonly adjusted, using a set of +commands that have `big' in their names.% +\index{delimiters!fixed size|(} +\begin{ctab}{l|llllll} +Delimiter& + text& \ncn{left}& \ncn{bigl}& \ncn{Bigl}& \ncn{biggl}& \ncn{Biggl}\\ +size& + size& \ncn{right}& \ncn{bigr}& \ncn{Bigr}& \ncn{biggr}& \ncn{Biggr}\\ +\hline +Result\vstrut{5ex}& + $\displaystyle(b)(\frac{c}{d})$& + $\displaystyle\left(b\right)\left(\frac{c}{d}\right)$& + $\displaystyle\bigl(b\bigr)\bigl(\frac{c}{d}\bigr)$& + $\displaystyle\Bigl(b\Bigr)\Bigl(\frac{c}{d}\Bigr)$& + $\displaystyle\biggl(b\biggr)\biggl(\frac{c}{d}\biggr)$& + $\displaystyle\Biggl(b\Biggr)\Biggl(\frac{c}{d}\Biggr)$ +\end{ctab} +The first kind of situation is a cumulative operator with limits above +and below. With \cn{left} and \cn{right} the delimiters usually turn out +larger than necessary, and using the |Big| or |bigg| +sizes\index{big@\cn{big}, \cn{Big}, \cn{bigg}, \dots\ delimiters} +instead gives better results: +\begin{equation*} +\left[\sum_i a_i\left\lvert\sum_j x_{ij}\right\rvert^p\right]^{1/p} +\quad\text{versus}\quad +\biggl[\sum_i a_i\Bigl\lvert\sum_j x_{ij}\Bigr\rvert^p\biggr]^{1/p} +\end{equation*} +\begin{verbatim} +\biggl[\sum_i a_i\Bigl\lvert\sum_j x_{ij}\Bigr\rvert^p\biggr]^{1/p} +\end{verbatim} +The second kind of situation is clustered pairs of delimiters where +\cn{left} and \cn{right} make them all the same size (because that is +adequate to cover the encompassed material) but what you really want +is to make some of the delimiters slightly larger to make the nesting +easier to see. +\begin{equation*} +\left((a_1 b_1) - (a_2 b_2)\right) +\left((a_2 b_1) + (a_1 b_2)\right) +\quad\text{versus}\quad +\bigl((a_1 b_1) - (a_2 b_2)\bigr) +\bigl((a_2 b_1) + (a_1 b_2)\bigr) +\end{equation*} +\begin{verbatim} +\left((a_1 b_1) - (a_2 b_2)\right) +\left((a_2 b_1) + (a_1 b_2)\right) +\quad\text{versus}\quad +\bigl((a_1 b_1) - (a_2 b_2)\bigr) +\bigl((a_2 b_1) + (a_1 b_2)\bigr) +\end{verbatim} +The third kind of situation is a slightly oversize object in running +text, such as $\left\lvert\frac{b'}{d'}\right\rvert$ where the +delimiters produced by \cn{left} and \cn{right} cause too much line +spreading. In that case \ncn{bigl} and \ncn{bigr}\index{big@\cn{big}, +\cn{Big}, \cn{bigg}, \dots\ delimiters} can be used to produce +delimiters that are slightly larger than the base size but still able to +fit within the normal line spacing: +$\bigl\lvert\frac{b'}{d'}\bigr\rvert$. + +In ordinary \latex/ \ncn{big}, \ncn{bigg}, \ncn{Big}, and \ncn{Bigg} +delimiters aren't scaled properly over the full range of \latex/ font +sizes. With the \nipkg{amsmath} package they are.% +\index{delimiters!fixed size|)} + +\subsection{Vertical bar notations} + +The \nipkg{amsmath} package provides commands \cn{lvert}, \cn{rvert}, +\cn{lVert}, \cn{rVert} (compare \cn{langle}, \cn{rangle}) to address the +%problem of overloading for the vert bar character \qc{\|}. This +problem of overloading for the vert bar character \qcvert. This +character is currently used in \latex/ documents to represent a wide +variety of mathematical objects: the `divides' relation in a +number-theory expression like $p\vert q$, or the absolute-value +operation $\lvert z\rvert$, or the `such that' condition in set +notation, or the `evaluated at' notation $f_\zeta(t)\bigr\rvert_{t=0}$. +The multiplicity of uses in itself is not so bad; what is bad, however, +is that fact that not all of the uses take the same typographical +treatment, and that the complex discriminatory powers of a knowledgeable +reader cannot be replicated in computer processing of mathematical +documents. It is recommended therefore that there should be a one-to-one +correspondence in any given document between the vert bar character +%\qc{\|} and a selected mathematical notation, and similarly for the +\qcvert\ and a selected mathematical notation, and similarly for the +%double-bar command \ncn{\|}\index{"|@\verb"*+"\"|+}. This immediately +double-bar command \cnvert. This immediately +rules out the use of \qc{|} +%and \ncn{\|}\index{"|@\verb"*+"\"|+} for delimiters, because left and right +and \cnvert\ for delimiters, because left and right +delimiters are distinct usages that do not relate in the same way to +adjacent symbols; recommended practice is therefore to define suitable +commands in the document preamble for any paired-delimiter use of vert +bar symbols: +\begin{verbatim} +\providecommand{\abs}[1]{\lvert#1\rvert} +\providecommand{\norm}[1]{\lVert#1\rVert} +\end{verbatim} +whereupon the document would contain |\abs{z}| to produce $\lvert +z\rvert$ and |\norm{v}| to produce $\lVert v\rVert$. +The \pkg{mathools} provides the command \cn{DeclarePairedDelimiter} +for defining |\abs|-like macros with scaling delimiters. +\index{delimiters|)} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\chapter{Operator names} + +\section{Defining new operator names}\label{s:opname} + +Math functions\index{operator names}\relax \index{function +names|see{operator names}} such as $\log$, $\sin$, and $\lim$ are +traditionally typeset in roman type to make them visually more distinct +from one-letter math variables, which are set in math italic. The more +common ones have predefined names, \cn{log}, \cn{sin}, \cn{lim}, and so +forth, but new ones come up all the time in mathematical papers, so the +\nipkg{amsmath} package provides a general mechanism for defining new +`operator names'. To define a math function \ncn{xxx} to work like +\cn{sin}, you write +\begin{verbatim} +\DeclareMathOperator{\xxx}{xxx} +\end{verbatim} +whereupon ensuing uses of \ncn{xxx} will produce {\upshape xxx} in the +proper font and automatically add proper spacing\index{horizontal +spacing!around operator names} on either side when necessary, so that you +get $A\xxx B$ instead of $A\mathrm{xxx}B$. In the second argument of +\cn{DeclareMathOperator} (the name text), a pseudo-text mode prevails: +the hyphen character \qc{\-} will print as a text hyphen rather than a +minus sign and an asterisk \qc{\*} will print as a raised text asterisk +instead of a centered math star. (Compare +\textit{a}-\textit{b}*\textit{c} and $a-b*c$.) But otherwise the name +text is printed in math mode, so that you can use, e.g., subscripts and +superscripts there. + +%%%%xxx%%%\enlargethispage{1\baselineskip} +If the new operator should have subscripts and superscripts placed in +`limits' position above and below as with $\lim$, $\sup$, or $\max$, use +the \qc{\*} form of the \cn{DeclareMathOperator} command: +\begin{verbatim} +\DeclareMathOperator*{\Lim}{Lim} +\end{verbatim} +See also the discussion of subscript placement in +Section~\ref{subplace}. + +\goodbreak + +The following operator names are predefined: + +\vspace{-1\baselineskip} +\begin{ctab}{@{}rlrlrlrl} +\cn{arccos}& $\arccos$ &\cn{deg}& $\deg$ & \cn{lg}& $\lg$ & \cn{projlim}& $\projlim$\\ +\cn{arcsin}& $\arcsin$ &\cn{det}& $\det$ & \cn{lim}& $\lim$ & \cn{sec}& $\sec$\\ +\cn{arctan}& $\arctan$ &\cn{dim}& $\dim$ & \cn{liminf}& $\liminf$ &\cn{sin}& $\sin$\\ +\cn{arg}& $\arg$ & \cn{exp}& $\exp$ & \cn{limsup}& $\limsup$ &\cn{sinh}& $\sinh$\\ +\cn{cos}& $\cos$ & \cn{gcd}& $\gcd$ & \cn{ln}& $\ln$ & \cn{sup}& $\sup$\\ +\cn{cosh}& $\cosh$ & \cn{hom}& $\hom$ & \cn{log}& $\log$ & \cn{tan}& $\tan$\\ +\cn{cot}& $\cot$ & \cn{inf}& $\inf$ & \cn{max}& $\max$ & \cn{tanh}& $\tanh$\\ +\cn{coth}& $\coth$ & \cn{injlim}& $\injlim$ &\cn{min}& $\min$\\ +\cn{csc}& $\csc$ & \cn{ker}& $\ker$ & \cn{Pr}& $\Pr$ +\end{ctab} +\par\nobreak +\vspace{-1.2\baselineskip} +\begin{ctab}{rlrl} +\cn{varinjlim}& $\displaystyle\varinjlim$& +\cn{varliminf}& $\displaystyle\varliminf$\\ +\cn{varprojlim}& $\displaystyle\varprojlim$& +\cn{varlimsup}& $\displaystyle\varlimsup$ +\end{ctab} + +There is also a command \cn{operatorname} such that using +\begin{verbatim} +\operatorname{abc} +\end{verbatim} +in a math formula is equivalent to a use of \ncn{abc} defined by +\cn{DeclareMathOperator}. This may be occasionally useful for +constructing more complex notation or other purposes. (Use the variant +\cn{operatorname*} to get limits.) + +%% ------------------------------------------------------------------ %% + +\section{\cn{mod} and its relatives} + +Commands \cn{mod}, \cn{bmod}, \cn{pmod}, \cn{pod} are provided to deal +with the special spacing conventions of \qq{mod} notation. \cn{bmod} and +\cn{pmod} are available in \latex/, but with the \nipkg{amsmath} package +the spacing of \cn{pmod} will adjust to a smaller value if it's used in +a non-display-mode formula. \cn{mod} and \cn{pod} are variants of +\cn{pmod} preferred by some authors; \cn{mod} omits the parentheses, +whereas \cn{pod} omits the \qq{mod} and retains the parentheses. +\begin{equation} +\gcd(n,m\bmod n);\quad x\equiv y\pmod b; +\quad x\equiv y\mod c;\quad x\equiv y\pod d +\end{equation} +\begin{verbatim} +\gcd(n,m\bmod n);\quad x\equiv y\pmod b; +\quad x\equiv y\mod c;\quad x\equiv y\pod d +\end{verbatim} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\enlargethispage{1\baselineskip} + +\chapter{The \cn{text} command}\label{text} + +The main use of the command \cn{text} is for words or +phrases\index{text fragments inside math} in a display. It is very +similar to the \latex/ command \cn{mbox} in its effects, but has a +couple of advantages. If you want a word or phrase of text in a +subscript, you can type |..._{\textrm{word or phrase}}|, which is slightly +easier than the \cn{mbox} equivalent: |..._{\mbox{\rmfamily\scriptsize| |word| +|or| |phrase}}|. Note that the standard \cn{textrm} command will use the +\nipkg{amsmath} \cn{text} definition, but ensure the \verb+\rmfamily+ +font is used. +\begin{equation} +f_{[x_{i-1},x_i]} \text{ is monotonic,} +\quad i = 1,\dots,c+1 +\end{equation} +\begin{verbatim} +f_{[x_{i-1},x_i]} \text{ is monotonic,} +\quad i = 1,\dots,c+1 +\end{verbatim} + +The font used for \cn{text} is the same as that of the surrounding +environment; i.e., within a theorem, the contents of \cn{text} will +be set in italic. + +If a math expression is included in a \cn{text} string, it must be +explicitly marked as math (|$...$|). +\[ +\partial_s f(x) = \frac{\partial}{\partial x_0} f(x)\quad + \text{for $x= x_0 + I x_1$.} +\] +\begin{verbatim} +\partial_s f(x) = \frac{\partial}{\partial x_0} f(x)\quad + \text{for $x= x_0 + I x_1$.} +\end{verbatim} + +Function names should \emph{not} be entered as \cn{text}. Instead, +use \cn{mathrm} or \cn{DeclareMathOperator} as appropriate. These are +fixed entities that should not change depending on outside content +(such as appearing within a theorem that is set in italic), and in the +case of declared operators, proper spacing\index{horizontal +spacing!around operator names} is applied automatically. + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\chapter{Integrals and sums} + +\section{Multiline subscripts and superscripts} + +The \cn{substack} command can be used to produce a multiline subscript +or superscript:\index{subscripts and superscripts!multiline}\relax +\index{superscripts|see{subscripts and superscripts}} for example +\begin{ctab}{ll} +\begin{minipage}[t]{.6\columnwidth} +\begin{verbatim} +\sum_{\substack{ + 0\le i\le m\\ + 0<j<n}} + P(i,j) +\end{verbatim} +\end{minipage} +& +$\displaystyle +\sum_{\substack{0\le i\le m\\ 0<j<n}} P(i,j)$ +\end{ctab} +A slightly more generalized form is the \env{subarray} environment which +allows you to specify that each line should be left-aligned instead of +centered, as here: +\begin{ctab}{ll} +\begin{minipage}[t]{.6\columnwidth} +\begin{verbatim} +\sum_{\begin{subarray}{l} + i\in\Lambda\\ 0<j<n + \end{subarray}} + P(i,j) +\end{verbatim} +\end{minipage} +& +$\displaystyle + \sum_{\begin{subarray}{l} + i\in \Lambda\\ 0<j<n + \end{subarray}} + P(i,j)$ +\end{ctab} + +%% ------------------------------------------------------------------ %% + +\section{The \cn{sideset} command}\label{sideset} + +There's also a command called \cn{sideset}, for a rather special +purpose: putting symbols at the subscript and +superscript\index{subscripts and superscripts!on sums} corners of a +large operator symbol such as $\sum$ or $\prod$. \emph{Note: this +command is not designed to be applied to anything other than sum-class +symbols.} The prime +example is the case when you want to put a prime on a sum symbol. If +there are no limits above or below the sum, you could just use +\cn{nolimits}: here's +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +|\sum\nolimits' E_n| in display mode: +\begin{equation} +\sum\nolimits' E_n +\end{equation} +If, however, you want not only the prime but also something below or +above the sum symbol, it's not so easy\mdash indeed, without +\cn{sideset}, it would be downright difficult. With \cn{sideset}, you +can write +\begin{ctab}{ll} +\begin{minipage}[t]{.6\columnwidth} +\begin{verbatim} +\sideset{}{'} + \sum_{n<k,\;\text{$n$ odd}} nE_n +\end{verbatim} +\end{minipage} +&$\displaystyle +\sideset{}{'}\sum_{n<k,\;\text{$n$ odd}} nE_n +$ +\end{ctab} +The extra pair of empty braces is explained by the fact that +\cn{sideset} has the capability of putting an extra symbol or symbols at +each corner of a large operator; to put an asterisk at each corner of a +product symbol, you would type +\begin{ctab}{ll} +\begin{minipage}[t]{.6\columnwidth} +\begin{verbatim} +\sideset{_*^*}{_*^*}\prod +\end{verbatim} +\end{minipage} +&$\displaystyle +\sideset{_*^*}{_*^*}\prod +$ +\end{ctab} + +%% ------------------------------------------------------------------ %% + +\section{Placement of subscripts and limits}\label{subplace} + +The default positioning for subscripts depends on the +base symbol involved. The default for sum-class symbols is +`displaylimits' positioning: When a sum-class symbol appears +in a displayed formula, subscript and superscript are placed in `limits' +position above and below, but in an inline formula, they are placed to +the side, to avoid unsightly and wasteful spreading of the +surrounding text lines. +The default for integral-class symbols is to have sub- and +superscripts always to the side, even in displayed formulas. +(See the discussion of the \opt{intlimits} and related +options\index{options!behavior of particular options} in +Section~\ref{options}.) + +Operator names such as $\sin$ or $\lim$ may have either `displaylimits' +or `limits' positioning depending on how they were defined. The standard +operator names are defined according to normal mathematical usage. + +The commands \cn{limits} and \cn{nolimits} can be used to override the +normal behavior of a base symbol: +\begin{equation*} +\sum\nolimits_X,\qquad \iint\limits_{A}, +\qquad\varliminf\nolimits_{n\to \infty} +\end{equation*} +To define a command whose subscripts follow the +same `displaylimits' behavior as \cn{sum}, put +\cn{displaylimits} at the tail end of the definition. When multiple +instances of \cn{limits}, \cn{nolimits}, or \cn{displaylimits} occur +consecutively, the last one takes precedence. + +%% ------------------------------------------------------------------ %% + +\section{Multiple integral signs} + +\cn{iint}, \cn{iiint}, and \cn{iiiint} give multiple integral +signs\index{integrals!multiple} with the spacing between them nicely +adjusted, in both text and display style. \cn{idotsint} is an extension +of the same idea that gives two integral signs with dots between them. +\begin{gather} +\iint\limits_A f(x,y)\,dx\,dy\qquad\iiint\limits_A +f(x,y,z)\,dx\,dy\,dz\\ +\iiiint\limits_A +f(w,x,y,z)\,dw\,dx\,dy\,dz\qquad\idotsint\limits_A f(x_1,\dots,x_k) +\end{gather} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\chapter{Commutative diagrams}\label{s:commdiag} +\index{commutative diagrams} + +Some commutative diagram commands like the ones in \amstex/ are +available as a separate package, \pkg{amscd}. For complex commutative +diagrams authors will need to turn to more comprehensive packages like +\tikz/\index{TikZ@\tikz/ package} (in particular, \pkg{tikz-cd}) +or \xypic/\index{XY-pic@\xypic/ package}, +but for simple diagrams without diagonal +arrows\index{arrows!in commutative diagrams} the \pkg{amscd} commands +may be more convenient. Here is one example. +\begin{equation*} +\begin{CD} +S^{\mathcal{W}_\Lambda}\otimes T @>j>> T\\ +@VVV @VV{\End P}V\\ +(S\otimes T)/I @= (Z\otimes T)/J +\end{CD} +\end{equation*} +\begin{verbatim} +\begin{CD} +S^{\mathcal{W}_\Lambda}\otimes T @>j>> T\\ +@VVV @VV{\End P}V\\ +(S\otimes T)/I @= (Z\otimes T)/J +\end{CD} +\end{verbatim} +In the \env{CD} environment the commands |@>>>|, +|@<<<|, |@VVV|, and |@AAA| give respectively right, left, down, and up +arrows. For the horizontal arrows, material between the first and second +|>| or |<| symbols will be typeset as a superscript, and material +between the second and third will be typeset as a subscript. Similarly, +material between the first and second or second and third |A|s or |V|s +of vertical arrows will be typeset as left or right \qq{sidescripts}. +The commands |@=| and \verb'@|' give horizontal and vertical double lines. +A \qq{null arrow} command |@.| can be used instead of a visible arrow +to fill out an array where needed. + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\chapter{Using math fonts} + +\section{Introduction} + +For more comprehensive information on font use in \latex/, see the +\latex/ font guide (\fn{fntguide.tex}) or \booktitle{The \latex/ +Companion} \cite{tlc2}. The basic set of math font commands\index{math +fonts}\relax \index{math symbols|see{math fonts}} in \latex/ includes +\cn{mathbf}, \cn{mathrm}, \cn{mathcal}, \cn{mathsf}, \cn{mathtt}, +\cn{mathit}. Additional math alphabet commands such as +\cn{mathbb} for blackboard bold, \cn{mathfrak} for Fraktur, and +\cn{mathscr} for Euler script are available through the packages +\pkg{amsfonts} and \pkg{euscript} (distributed separately). + +%% ------------------------------------------------------------------ %% +\enlargethispage{1\baselineskip} + +\section{Recommended use of math font commands} + +If you find yourself employing math font commands frequently in your +document, you might wish that they had shorter names, such as \ncn{mb} +instead of \cn{mathbf}. Of course, there is nothing to keep you from +providing such abbreviations for yourself by suitable \cn{newcommand} +statements. But for \latex/ to provide shorter names would actually be a +disservice to authors, as that would obscure a much better alternative: +defining custom command names derived from the names of the underlying +mathematical objects, rather than from the names of the fonts used to +distinguish the objects. For example, if you are using bold to indicate +vectors, then you will be better served in the long run if you define a +`vector' command instead of a `math-bold' command: +\begin{verbatim} + \newcommand{\vect}[1]{\mathbf{#1}} +\end{verbatim} +you can write |\vect{a} + \vect{b}| to produce $\vect{a} + +\vect{b}$. +If you decide several months down the road that you want to use the bold +font for some other purpose, and mark vectors by a small over-arrow +instead, then you can put the change into effect merely by changing the +definition of \ncn{vect}; otherwise you would have to replace all +occurrences of \cn{mathbf} throughout your document, perhaps even +needing to inspect each one to see whether it is indeed +an instance of a vector. + +It can also be useful to assign distinct +command names for different letters of a particular font: +\begin{verbatim} +\DeclareSymbolFont{AMSb}{U}{msb}{m}{n}% or use amsfonts package +\DeclareMathSymbol{\C}{\mathalpha}{AMSb}{"43} +\DeclareMathSymbol{\R}{\mathalpha}{AMSb}{"52} +\end{verbatim} +These statements would define the commands \cn{C} and \cn{R} to produce +blackboard-bold letters from the `AMSb' math symbols font. If you refer +often to the\break complex numbers or real numbers in your document, you +might find this method more convenient than (let's say) defining a +\ncn{field} command and writing\break |\field{C}|, |\field{R}|. But for +maximum flexibility and control, define such a \ncn{field} command and +then define \ncn{C} and \ncn{R} in terms of that +command:\indexcs{mathbb} +\begin{verbatim} +\usepackage{amsfonts}% to get the \mathbb alphabet +\newcommand{\field}[1]{\mathbb{#1}} +\newcommand{\C}{\field{C}} +\newcommand{\R}{\field{R}} +\end{verbatim} + +%% ------------------------------------------------------------------ %% +\enlargethispage{3\baselineskip} + +\section{Bold math symbols} + +The \cn{mathbf} command is commonly used to obtain bold Latin letters in +math, but for most other kinds of math symbols it has no effect, or its +effects depend unreliably on the set of math fonts that are in use. For +example, writing +\begin{verbatim} +\Delta \mathbf{\Delta}\mathbf{+}\delta \mathbf{\delta} +\end{verbatim} +produces $\Delta \mathbf{\Delta}\mathbf{+}\delta +\mathbf{\delta}$; the \cn{mathbf} has no effect on the plus +sign or the small delta. +% should be paragraph break; avoid overfull box on next line +The \nipkg{amsmath} package therefore provides two additional commands, +\cn{boldsymbol} and \cn{pmb}, that can be applied to other kinds of math +symbols. \cn{boldsymbol} can be used for a math symbol that remains +unaffected by \cn{mathbf} if (and only if) your current math font set +includes a bold version of that symbol. \cn{pmb} can be used as a last +resort for any math symbols that do not have a true bold version +provided by your set of math fonts; \qq{pmb} stands for \qq{poor man's +bold} and the command works by typesetting multiple copies of the symbol +with slight offsets. The quality of the output is inferior, especially +for symbols that contain any hairline strokes. When the standard default set of +\latex/ math fonts are in use (Computer Modern), the only symbols that +are likely to require \cn{pmb} are large operator symbols like \cn{sum}, +extended delimiter\index{delimiters} symbols, or the extra math symbols +provided by the \pkg{amssymb} package \cite{amsfonts}. + +The following formula shows some of the results that are possible: +\begin{verbatim} +A_\infty + \pi A_0 +\sim \mathbf{A}_{\boldsymbol{\infty}} \boldsymbol{+} + \boldsymbol{\pi} \mathbf{A}_{\boldsymbol{0}} +\sim\pmb{A}_{\pmb{\infty}} \pmb{+}\pmb{\pi} \pmb{A}_{\pmb{0}} +\end{verbatim} +\begin{equation*} +A_\infty + \pi A_0 +\sim \mathbf{A}_{\boldsymbol{\infty}} \boldsymbol{+} + \boldsymbol{\pi} \mathbf{A}_{\boldsymbol{0}} +\sim\pmb{A}_{\pmb{\infty}} \pmb{+}\pmb{\pi} \pmb{A}_{\pmb{0}} +\end{equation*} +If you want to use only the \cn{boldsymbol} command without loading the +whole \nipkg{amsmath} package, the \pkg{bm} package is recommended (this +is a standard \latex/ package, not an AMS package; you probably have it +already if you have a 1997 or newer version of \latex/). + +%% ------------------------------------------------------------------ %% + +\section{Italic Greek letters} + +For italic versions of the capital Greek letters, the following commands +are provided: +\begin{ctab}{rlrl} +\cn{varGamma}& $\varGamma$& \cn{varSigma}& $\varSigma$\\ +\cn{varDelta}& $\varDelta$& \cn{varUpsilon}& $\varUpsilon$\\ +\cn{varTheta}& $\varTheta$& \cn{varPhi}& $\varPhi$\\ +\cn{varLambda}& $\varLambda$& \cn{varPsi}& $\varPsi$\\ +\cn{varXi}& $\varXi$& \cn{varOmega}& $\varOmega$\\ +\cn{varPi}& $\varPi$ +\end{ctab} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\chapter{Error messages and output problems} + +\section{General remarks} + +This is a supplement to Chapter~8 of the \latex/ manual \cite{lamport} +(first edition: Chapter~6). Appendix~B of the +\textit{Companion}~\cite{tlc2} lists all \latex/ errors including those +for \nipkg{amsmath} with likely causes for each. For the reader's +convenience, the set of error messages discussed here overlaps +somewhat with the set in those references, +but please be aware that we don't provide exhaustive coverage here. +The error messages are arranged in alphabetical order, disregarding +unimportant text such as |! LaTeX Error:| at the beginning, and +nonalphabetical characters such as \qc{\\}. Where examples are given, we +show also the help messages that appear on screen when you respond to an +error message prompt by entering |h|. + +Remember that the important error message is the first for a given line. +When running in nonstop mode, errors accumulate, and the first error +may create a further error condition from which it is impossible to +recover. In such a situation processing will stop after 100~errors, +so the reporting of genuine errors may not be complete, and it may be +impossible to determine which reported errors are genuine and which +are not. + +A final section discusses some output errors, i.e., instances where +the printed document has something wrong but there was no \latex/ +error during typesetting. + +%% ------------------------------------------------------------------ %% +%% ********** +\enlargethispage{-2\baselineskip} + +\section{Error messages} + +\begin{error}{\begin{split} won't work here.} +\errexa +\begin{verbatim} +! Package amsmath Error: \begin{split} won't work here. + ... + +l.8 \begin{split} + +? h +\Did you forget a preceding \begin{equation}? +If not, perhaps the `aligned' environment is what you want. +? +\end{verbatim} +\errexpl +The \env{split} environment does not construct a stand-alone displayed +equation; it needs to be used within some other environment such as +\env{equation} or \env{gather}. + +\end{error} + +\begin{error}{Erroneous nesting of equation structures} +\errexa +\begin{verbatim} +! Package amsmath Error: Erroneous nesting of equation structures; +(amsmath) trying to recover with `aligned'. + +See the amsmath package documentation for explanation. +Type H <return> for immediate help. + ... + +l.260 \end{alignat*} + \end{equation*} +\end{verbatim} +\errexpl +The structures \env{align}, \env{alignat}, etc., are designed +for top-level use and for the most part cannot be nested inside some +other displayed equation structure. The chief exception is that +\env{align} and most of its variants can be used inside the +\env{gather} environment. +\end{error} + +\begin{error}{Extra & on this line} +\errexa +\begin{verbatim} +! Package amsmath Error: Extra & on this line. + +See the amsmath package documentation for explanation. +Type H <return> for immediate help. + ... + +l.9 \end{alignat} + +? h +\An extra & here is so disastrous that you should probably exit + and fix things up. +? +\end{verbatim} +\errexpl +In an \env{alignat} structure the number of alignment points per line +is dictated by the numeric argument given after |\begin{alignat}|. +If you use more alignment points in a line it is assumed that you +accidentally left out a newline command \cn{\\} and the above error is +issued. +\end{error} + +%% ********** +\enlargethispage{1.5\baselineskip} + +\begin{error}{Font OMX/cmex/m/n/7=cmex7 not loadable ...} +\errexa +\begin{verbatim} +! Font OMX/cmex/m/n/7=cmex7 not loadable: Metric (TFM) file not found. +<to be read again> + relax +l.8 $a + b+b^2$ +? h +I wasn't able to read the size data for this font, +so I will ignore the font specification. +[Wizards can fix TFM files using TFtoPL/PLtoTF.] +You might try inserting a different font spec; +e.g., type `I\font<same font id>=<substitute font name>'. +? +\end{verbatim} +\errexpl +Certain extra sizes of some Computer Modern fonts that were formerly +available mainly through the AMSFonts\index{amsfont@AMSFonts collection} +distribution are considered part of standard \latex/ (as of June 1994): +\fn{cmex7}\ndash \texttt{9}, \fn{cmmib5}\ndash \texttt{9}, and +\fn{cmbsy5}\ndash \texttt{9}. If these extra sizes are missing on your +system, you should try first to get them from the source where you +obtained \latex/. If that fails, you could try getting the fonts from +CTAN (e.g., in the form of Metafont\index{Metafont source files} source +files, directory \nfn{/tex-archive/fonts/latex/mf}, or in PostScript +Type 1 format, directory +\nfn{/tex-archive/fonts/cm/ps-type1/bakoma}\index{BaKoMa fonts}\relax +\index{PostScript fonts}). + +If the font name begins with \fn{cmex}, there is a special option% +\index{options!behavior of particular options} +\opt{cmex10} for the \nipkg{amsmath} package that provides a temporary +workaround. I.e., change the \cn{usepackage} to +\begin{verbatim} +\usepackage[cmex10]{amsmath} +\end{verbatim} +This will force the use of the 10-point size of the \fn{cmex} font in +all cases. Depending on the contents of your document this may be +adequate. +\end{error} + +\enlargethispage{1\baselineskip} +\begin{error}{Improper argument for math accent} +\errexa +\begin{verbatim} +! Package amsmath Error: Improper argument for math accent: +(amsmath) Extra braces must be added to +(amsmath) prevent wrong output. + +See the amsmath package documentation for explanation. +Type H <return> for immediate help. + ... + +l.415 \tilde k_{\lambda_j} = P_{\tilde \mathcal + {M}} +? +\end{verbatim} +\errexpl +Non-simple arguments for any \LaTeX{} command should be enclosed in +braces. In this example extra braces are needed as follows: +\begin{verbatim} +... P_{\tilde{\mathcal{M}}} +\end{verbatim} +\end{error} + +\begin{error}{Math formula deleted: Insufficient extension fonts} +\errexa +\begin{verbatim} +! Math formula deleted: Insufficient extension fonts. +l.8 $ab+b^2$ + +? +\end{verbatim} +\errexpl +This usually follows a previous error |Font ... not loadable|; see the +discussion of that error (above) for solutions. +\end{error} + +\enlargethispage{1\baselineskip} +\begin{error}{Missing number, treated as zero} +\errexa +\begin{verbatim} +! Missing number, treated as zero. +<to be read again> + a +l.100 \end{alignat} + +? h +A number should have been here; I inserted `0'. +(If you can't figure out why I needed to see a number, +look up `weird error' in the index to The TeXbook.) + +? +\end{verbatim} +\errexpl +There are many possibilities that can lead to this error. However, one +possibility that is relevant for the \nipkg{amsmath} package is that you +forgot to give the number argument of an \env{alignat} environment, as +in: +\begin{verbatim} +\begin{alignat} + a& =b& c& =d\\ +a'& =b'& c'& =d' +\end{alignat} +\end{verbatim} +where the first line should read instead +\begin{verbatim} +\begin{alignat}{2} +\end{verbatim} + +Another possibility is that you have a left bracket character |[| +following a line break\index{line break} command \cn{\\} in a multiline +construction such as \env{array}, \env{tabular}, or \env{eqnarray}. +This will be interpreted by \latex/ as the beginning of an `additional +vertical space request \cite[\S C.1.6]{lamport}, even if it occurs on the +following line and is intended to be part of the contents. For example, +\begin{verbatim} +\begin{array}{c} +a+b\\ +[f,g]\\ +m+n +\end{array} +\end{verbatim} +To prevent the error message in such a case, you can +add braces as discussed in the \latex/ manual \cite[\S C.1.1]{lamport}: +\begin{verbatim} +\begin{array}{c} +a+b\\ +{[f,g]}\\ +m+n +\end{array} +\end{verbatim} +or precede the bracketed expression by \cn{relax}. +\end{error} + +\goodbreak + +\begin{error}{Missing \right. inserted} +\errexa +\begin{verbatim} +! Missing \right. inserted. +<inserted text> + \right . +l.10 \end{multline} + +? h +I've inserted something that you may have forgotten. +(See the <inserted text> above.) +With luck, this will get me unwedged. But if you +really didn't forget anything, try typing `2' now; then +my insertion and my current dilemma will both disappear. +\end{verbatim} +\errexpl +This error typically arises when you try to insert a +line break\index{line break} or |&|\cnamp\ between a +\cn{left}-\cn{right} pair of delimiters\index{delimiters} in any +multiline environment, including \env{split}. +\begin{verbatim} +\begin{multline} +AAA\left(BBB\\ + CCC\right) +\end{multline} +\end{verbatim} +There are two possible solutions: (1)~instead of using \cn{left} and +\cn{right}, use `big' delimiters\index{delimiters!fixed size} of fixed +size (\cn{bigl} \cn{bigr} \cn{biggl} \cn{biggr} \dots; see +\secref{bigdel}); or (2)~use null delimiters\index{delimiters!null} to +break up the \cn{left}-\cn{right} pair into parts for each line (or cell): +\begin{verbatim} +AAA\left(BBB\right.\\ + \left.CCC\right) +\end{verbatim} +The latter solution may result in mismatched +delimiter\index{delimiters!mismatched sizes} sizes; +ensuring that they match requires using \cn{vphantom} in the segment +that has the smaller delimiter (or possibly \cn{smash} in the segment +that has the larger delimiter). In the argument of \cn{vphantom} put a +copy of the tallest element that occurs in the other segment, e.g., +\begin{verbatim} +xxx \left(\int_t yyy\right.\\ + \left.\vphantom{\int_t} zzz ... \right) +\end{verbatim} +\end{error} + +\goodbreak + +\begingroup +\lccode`M=`M +\lccode`@=`\} +\lowercase{\endgroup +\begin{error}{Missing @ inserted}} + +\errexa +\begin{verbatim} +! Missing } inserted. +<inserted text> + \right . +l.10 \end{multline} + +? h +I've inserted something that you may have forgotten. +(See the <inserted text> above.) +With luck, this will get me unwedged. But if you +really didn't forget anything, try typing `2' now; then +my insertion and my current dilemma will both disappear. +\end{verbatim} +\errexpl +This error is often the result of using \verb+$+ within a multiline +display environment. Remove such \verb+$+ signs (except when they +appear within \verb+\text{...}+). +\end{error} + +\begin{error}{Old form `\pmatrix' should be \begin{pmatrix}.} +\errexa +\begin{verbatim} +! Package amsmath Error: Old form `\pmatrix' should be + \begin{pmatrix}. + +See the amsmath package documentation for explanation. +Type H <return> for immediate help. + ... + +\pmatrix ->\left (\matrix@check \pmatrix + \env@matrix +l.16 \pmatrix + {a&b\cr c&d\cr} +? h +`\pmatrix{...}' is old Plain-TeX syntax whose use is +ill-advised in LaTeX. +? +\end{verbatim} +\errexpl +When the \nipkg{amsmath} package is used, the old forms of \cn{pmatrix}, +\cn{matrix}, and \cn{cases} cannot be used any longer because of naming +conflicts. Their syntax did not conform with standard \LaTeX{} syntax +in any case. +\end{error} + +\enlargethispage{2\baselineskip} +\begin{error}{Paragraph ended before \xxx was complete} +\errexa +\begin{verbatim} +Runaway argument? + +! Paragraph ended before \multline was complete. +<to be read again> + \par +l.100 + +? h +I suspect you've forgotten a `}', causing me to apply this +control sequence to too much text. How can we recover? +My plan is to forget the whole thing and hope for the best. +? +\end{verbatim} +\errexpl +This might be produced by a blank line between the |\begin| and |\end|. +Another possibility is a misspelling in the |\end{multline}| command, +e.g., +\begin{verbatim} +\begin{multline} +... +\end{multiline} +\end{verbatim} +or by using abbreviations for certain environments, such as |\bal| and +|\eal| for |\begin{align}| and |\end{align}|: +\begin{verbatim} +\bal +... +\eal +\end{verbatim} +For technical reasons that kind of abbreviation does not work with +the more complex displayed equation environments of the \nipkg{amsmath} package +(\env{gather}, \env{align}, \env{split}, etc.; cf.\ \fn{technote.tex}). +\end{error} + +\begin{error}{Runaway argument?} +See the discussion for the error message +\texttt{Paragraph ended before \ncn{xxx} was complete}. +\end{error} + +\begin{error}{Unknown option `xxx' for package `yyy'} +\errexa +\begin{verbatim} +! LaTeX Error: Unknown option `intlim' for package `amsmath'. +... +? h +The option `intlim' was not declared in package `amsmath', perhaps you +misspelled its name. Try typing <return> to proceed. +? +\end{verbatim} +\errexpl +This means that you misspelled the option\index{options!unknown} +name, or the package simply does not have an option that you expected +it to have. Consult the documentation for the given package. +\end{error} + +%% ------------------------------------------------------------------ %% + +\section{Warning messages} + +\begin{error}{Cannot use `split' here} +\errexa +\begin{verbatim} +Package amsmath Warning: Cannot use `split' here; +(amsmath) trying to recover with `aligned' +\end{verbatim} +\errexpl The \env{split} environment is designed to serve as the entire +body of an equation, or an entire line of an \env{align} or \env{gather} +environment. There cannot be any printed material before or +after it within the same enclosing structure: +\begin{verbatim} +\begin{equation} +\left\{ % <-- Not allowed +\begin{split} +... +\end{split} +\right. % <-- Not allowed +\end{equation} +\end{verbatim} +\end{error} + +\begin{error}{Foreign command \over [or \atop or \above]} +\errexa +\begin{verbatim} +Package amsmath Warning: Foreign command \over; \frac or \genfrac +(amsmath) should be used instead. +\end{verbatim} +\errexpl The primitive generalized fraction commands of \tex/\mdash +\cs{over}, \cs{atop}, \cs{above}\mdash are deprecated when the +\nipkg{amsmath} package is used because their syntax is foreign to \latex/ +and \nipkg{amsmath} provides native \latex/ equivalents. See +\fn{technote.tex} for further information. +\end{error} + +%% ------------------------------------------------------------------ %% + +\section{Wrong output} + +\begin{erroro}{Section numbers 0.1, 5.1, 8.1 instead of 1, 2, 3} +% +This most likely means that you have the arguments for \cn{numberwithin} +in reverse order: +\begin{verbatim} +\numberwithin{section}{equation} +\end{verbatim} +That means `print the section number as \textit{equation +number}.\textit{section number} and reset to 1 every time an equation +occurs' when what you probably wanted was the inverse +\begin{verbatim} +\numberwithin{equation}{section} +\end{verbatim} +\end{erroro} + +\begin{erroro}{The \cn{numberwithin} command had no effect on equation + numbers} +% +Are you looking at the first section in your document? Check the section +numbers elsewhere to see if the problem is the one described in the +previous item. +\end{erroro} + +\begin{erroro}{Bracketed material disappears at the beginning of + \env{aligned} or \env{gathered}} +% +For most multiline equation environments, \nipkg{amsmath} disables the +\latex/ convention to recognize a [bracketed] expression as an option% +\index{ed env@\texttt{-ed} environments}% +\index{options!positioning of \texttt{-ed} environments}% +\index{options!space before \texttt{[}} +when it occurs at the beginning of an environment or immediately +following \cn{\\}, provided a space intervenes. This fails at the +beginning of \env{aligned} and \env{gathered}, and is a bug. Insert +\cn{relax} before the opening brace to restore the desired result. +\end{erroro} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\chapter{Additional information} + +\section{Compatibility with other packages} + +Several packages have already been mentioned as providing facilities +lacking in \nipkg{amsmath}. + +\begin{itemize} +\item \pkg{bm} is recommended for specifying bold math symbols. +\item \pkg{mathtools} provides enhancements to some \nipkg{amsmath} + environments as well as additional compatible features, such as + \env{rcases} (similar to \env{cases} but with the brace on the + right-hand side), \env{multlined} (a subsidiary environment + comparable to \env{multline}), and \cn{shortintertext} (more + compact spacing than \cn{intertext}). If \pkg{mathtools} is used, + \nipkg{amsmath} is loaded automatically, so it is not necessary + to load it separately. +\item \pkg{unicode-math} provides commands for (most?)\ math symbols + in Unicode. +%\item \pkg{empheq} +\end{itemize} + +These packages have known problems when used with \nipkg{amsmath}. +\begin{itemize} +\item \pkg{lineno} may omit numbers before display environments. +\item \pkg{breqn} redefines a number of commands from other packages, + so is best loaded after \nipkg{amsmath} and other packages with math + facilities.\\ \pkg{breqn} is not yet totally stable, and a number of + bugs have been reported via \texttt{tex.stackexchange} \cite{tex-sx}. +\item \pkg{wasysym}, \pkg{mathabx} and perhaps other font packages also + define multiple integrals\index{integrals!multiple} using the same + names as \nipkg{amsmath}. +\end{itemize} + +%% ------------------------------------------------------------------ %% + +\section{Converting existing documents} + +\subsection{Converting from plain \LaTeX{}} + +A \LaTeX{} document will typically continue to work the same in most +respects if \verb'\usepackage{amsmath}' is added in the document +preamble. By default, however, the \nipkg{amsmath} package suppresses page +breaks inside multiple-line displayed equation structures such as +\env{eqnarray}, \env{align}, and \env{gather}. To continue allowing page +breaks inside \env{eqnarray} after switching to \nipkg{amsmath}, you will +need to add the following line in your document preamble: +\begin{verbatim} +\allowdisplaybreaks[1] +\end{verbatim} +To ensure normal spacing around relation symbols, you might also want to +change \env{eqnarray} to \env{align}, \env{multline}, or +\env{equation}\slash\env{split} as appropriate. + +Most of the other differences in \nipkg{amsmath} usage can be considered +optional refinements, e.g., using +\begin{verbatim} +\DeclareMathOperator{\Hom}{Hom} +\end{verbatim} +instead of \verb'\newcommand{\Hom}{\mbox{Hom}}'. + +\subsection{Converting from \texorpdfstring{\amslatex/}{amslatex} 1.1} +See \fn{diffs-m.txt}. + +%% ------------------------------------------------------------------ %% + +\section{Technical notes} +The file \fn{technote.tex} contains some remarks on miscellaneous +technical questions that are less likely to be of general interest. + +%% ------------------------------------------------------------------ %% + +\section{Getting help} + +The \nipkg{amsmath} collection of packages is maintained by the \latex/ +team \cite{ltx-team}. Bugs should be reported using the instructions +at \url{https://www.latex-project.org/bugs/}. +Please be careful not to confuse \nipkg{amsmath} with the AMS document +classes (\cls{amsart}, \cls{amsbook}, and \cls{amsproc}), which +automatically incorporate \nipkg{amsmath}; bugs in the classes should +be reported directly to AMS, by email to \mail{tech-support@ams.org}. + +%Questions or comments regarding \nipkg{amsmath} and related packages +%should be sent to: +%\begin{infoaddress} +%American Mathematical Society\\ +%Technical Support\\ +%Electronic Products and Services\\ +%P. O. Box 6248\\ +%Providence, RI 02940\\[3pt] +%Phone: 800-321-4AMS (321-4267) \quad or \quad 401-455-4080\\ +%Internet: \mail{tech-support@ams.org} +%\end{infoaddress} +%If you are reporting a problem you should include +%the following information to make proper investigation possible: +%\begin{enumerate} +%\item The source file where the problem occurred, preferably reduced +% to minimum size by removing any material that can be removed without +% affecting the observed problem. +%\item A \latex/ log file showing the error message (if applicable) and +% the version numbers of the document class and option files being used. +%\end{enumerate} + +The online forum\index{online Q\,\&\,A forum} \texttt{tex.stackexchange} +\cite{tex-sx} is a good source of answers to common questions on usage. +Look first in the archive to see if your question has already been asked +and answered; if it has not, post your own question. + +There is an online discussion group called \fn{comp.text.tex} \cite{ctt} +that is a fairly good source of information about \latex/ and \tex/ in +general. This group, formerly a Unix newsgroup, predates +\texttt{tex.stackexchange} by decades, and the archives can be a useful +resource for historical investigation. + +%% ------------------------------------------------------------------ %% + +\section{Of possible interest}\label{a:possible-interest} +Information about obtaining AMSFonts or other \tex/-related +software from the AMS web server at \fn{www.ams.org} +can be obtained by sending an email request to +\mail{tech-support@ams.org}. This software is also posted on +CTAN\index{CTAN (Comprehensive \TeX\ Archive Network)} and included +in distributions based on \TeX\,Live\index{TEX Live@\TeX\,Live}. + +The \tex/ Users Group\index{TeX Users@\tex/ Users Group} is a nonprofit +organization that publishes a journal +(\journalname{TUGboat}\index{TUGboat@\journalname{TUGboat}}), holds +meetings, and serves as a clearinghouse for general information about +\tex/ and \tex/-related software. +\begin{infoaddress} +\tex/ Users Group\\ +PO Box 2311\\ +Portland, OR 97208-2311\\ +USA\\[3pt] +Phone: +1-503-223-9994\\ +Email: \mail{office@tug.org} +\end{infoaddress} +Membership in the \tex/ Users Group is a good way to support continued +development of free \tex/-related software. There are also many local +\tex/ user groups in other countries; information about contacting a +local user group can be gotten from the \tex/ Users Group. + +\index{amsmath@\texttt{amsmath} package|)} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\newpage + +\begin{thebibliography}{10} +\addcontentsline{toc}{chapter}{\bibname} + +\raggedright + +\bibsubhead{References in print} + +\bibitem{mil} George Gr\"atzer, \booktitle{More Math into \latex/}, fifth ed., +Springer, New York, 2016. +% Deal with a line breaking problem +%\begin{raggedright} +%\bibitem{mil} G. Gr\"{a}tzer, +%\emph{Math into \LaTeX{}: An Introduction to \LaTeX{} and AMS-\LaTeX{}} +% \url{https://www.ams.org/cgi-bin/bookstore/bookpromo?fn=91&arg1=bookvideo&itmc=MLTEX}, +%Birkh\"{a}user, Boston, 1995.\par +%\end{raggedright} + +\bibitem{kn} Donald E. Knuth, \booktitle{The \tex/book}, +Addison-Wesley, Reading, MA, 1984. + +\bibitem{lamport} Leslie Lamport, \booktitle{\latex/: A document preparation +system}, 2nd revised ed., Addison-Wesley, Reading, MA, 1994. + +\bibitem{tlc2} Frank Mittelbach, Michel Goossens, et al., +\booktitle{The \latex/ companion}, second ed., Addison-Wesley, Reading, +MA, 2004. This is now also available as an ebook, in both English and +German; see \url{https://www.latex-project.org/help/books/}. +The front matter, including the full Table of Contents, can be viewed +online, from a link on the same page. +%Michel Goossens, Frank Mittelbach, and Alexander Samarin, +%\booktitle{The \latex/ companion}, Addison-Wesley, Reading, MA, 1994. +% [\emph{Note: The 1994 edition is not a reliable guide for the +% \nipkg{amsmath} package unless you refer to the errata for Chapter +% 8\mdash file \fn{compan.err}, distributed with \LaTeX{}.}] + +\bibitem{msf} Frank Mittelbach and Rainer Sch\"opf, +\textit{The new font family selection\mdash user +interface to standard \latex/}, \journalname{TUGboat} \textbf{11}, +no.~2 (June 1990), pp.~297\ndash 305. + +\bibitem{jt} Michael Spivak, \booktitle{The joy of \tex/}, 2nd revised ed., +Amer. Math. Soc., Providence, RI, 1990. + +\bibsubhead{Package documentation} + +\bibitem{amshandbk}\booktitle{AMS author handbook}, separate versions +for journal articles, monographs and proceedings articles, Amer. Math. +Soc., Providence, RI, 2017; +\url{https://www.ams.org/publications/authors/tex/author-handbook}. + +\bibitem{amsfonts}\booktitle{AMSFonts version \textup{2.2d}\mdash user's guide}, +Amer. Math. Soc., Providence, RI, 2002; distributed +with the AMSFonts package +\url{http://mirror.ctan.org/tex-archive/fonts/amsfonts/doc/amsfndoc.pdf}. + +\bibitem{amsthdoc}\booktitle{Using the \pkg{amsthm} Package}, version 2.20.3, +Amer. Math. Soc., Providence, RI, 2017; +\url{http://mirror.ctan.org/tex-archive/macros/latex/required/amscls/doc/amsthdoc.pdf}. + +\bibitem{mt} Morten H{\o}gholm, Lars Madsen, \booktitle{The \pkg{mathtools} +package}, 2018; +\url{http://mirror.ctan.org/tex-archive/macros/latex/contrib/mathtools/mathtools.pdf}. + +\bibsubhead{Online resources} + +\bibitem{ltx-team} The \latex/ Project, \url{https://www.latex-project.org}. + +\bibitem{ctt} Online discussion group \texttt{comp.text.tex}, +\url{https://groups.google.com/forum/\#!forum/comp.text.tex}. + +\bibitem{tex-sx} Online question and answer forum \texttt{tex.stackexchange}, +\url{https://tex.stackexchange.com}. + +\end{thebibliography} + +\printindex + +\end{document} diff --git a/macros/latex-dev/required/amsmath/amsmath.dtx b/macros/latex-dev/required/amsmath/amsmath.dtx new file mode 100644 index 0000000000..8671694b70 --- /dev/null +++ b/macros/latex-dev/required/amsmath/amsmath.dtx @@ -0,0 +1,6383 @@ +% +% \iffalse meta-comment +% +% Copyright (C) 1995, 2000, 2013 American Mathematical Society. +% Copyright (C) 2016-2019 LaTeX3 Project and American Mathematical Society. +% +% This work may be distributed and/or modified under the +% conditions of the LaTeX Project Public License, either version 1.3c +% of this license or (at your option) any later version. +% The latest version of this license is in +% https://www.latex-project.org/lppl.txt +% and version 1.3c or later is part of all distributions of LaTeX +% version 2005/12/01 or later. +% +% This work has the LPPL maintenance status `maintained'. +% +% The Current Maintainer of this work is the LaTeX3 Project. +% +% \fi +% +%\iffalse +%<*driver> +\documentclass{amsdtx} +\def\MaintainedByLaTeXTeam#1{% +\begin{center}% +\fbox{\fbox{\begin{tabular}{@{}l@{}}% +This file is maintained by the \LaTeX{} Project team.\\% +Bug reports can be opened (category \texttt{#1}) at\\% +\url{https://latex-project.org/bugs/}.\end{tabular}}}\end{center}} +\raggedbottom +\let\savedarg\arg +\usepackage{amsmath} +\let\arg\savedarg +\GetFileInfo{amsmath.sty} +\begin{document} +\title{The \pkg{amsmath} package} +\author{Frank Mittelbach\and Rainer Sch\"opf\and Michael Downes\and + David M. Jones\and David Carlisle} +\date{Version \fileversion, \filedate} +\providecommand{\histnote}{} +\renewenvironment{histnote}{% + \trivlist\item[\hspace{\labelsep}\bfseries Historical Note:]% +}{% + \endtrivlist +} +\DocInput{amsmath.dtx} +\end{document} +%</driver> +%\fi +% +% \maketitle +% \MaintainedByLaTeXTeam{amslatex} +% +% \MakeShortVerb\| +% +% \section{Introduction} +% +% A \latex/ package named \pkg{amstex} was created in 1988--1989 by +% adapting \fn{amstex.tex} for use within \latex/. The \pkg{amsmath} +% package is the successor of the \pkg{amstex} package. It was +% substantially overhauled to integrate it with \latex/2e, which +% arrived on the scene in 1994. It provides more or less the same +% features, but there are quite a few organizational differences as +% well as some new features and bug fixes. For example, the +% \pkg{amstex} package automatically loaded the \pkg{amsfonts} +% package, but the \pkg{amsmath} package does not. At the present +% time (November 1999) user-level documentation of the commands +% provided here is found in the AMSmath Users' Guide, +% \fn{amsldoc.tex}. +% +% \StopEventually{} +% +% Standard file identification. +% \begin{macrocode} +\NeedsTeXFormat{LaTeX2e}% LaTeX 2.09 can't be used (nor non-LaTeX) +[1994/12/01]% LaTeX date must be December 1994 or later +% \end{macrocode} +% +% Providing a rollback to earlier version(s) +% \begin{macrocode} +\providecommand\DeclareRelease[3]{} +\providecommand\DeclareCurrentRelease[2]{} +% +\DeclareRelease{}{2018-12-01}{amsmath-2018-12-01.sty} +\DeclareCurrentRelease{}{2019-04-01} +% \end{macrocode} +% +% \begin{macrocode} +\ProvidesPackage{amsmath}[2019/04/01 v2.17c AMS math features] +% \end{macrocode} +% +% \section{Catcode defenses} +% +% Some packages change the catcode of characters that are essential +% in low-level \tex/ syntax. Any package that does so does not +% qualify as a PWWO package (\qq{Plays Well With Others}) because it +% can cause other packages to fail if they are loaded later. \LaTeX{} +% is partly to blame for this because it fails to provide adequate +% built-in safeguards in the package loading mechanisms. In the +% absence of such safeguards, we will provide them here. +% \begin{macrocode} +\edef\@temp{\catcode 96=\number\catcode 96 } +\catcode\string `\`=12 +\def\do#1{\catcode\number`#1=\number\catcode`#1} +\edef\@temp{% + \noexpand\AtEndOfPackage{% + \@temp + \do\"\do\'\do\(\do\)\do\*\do\+\do\,\do\-\do\.% + \do\/\do\<\do\=\do\>\do\[\do\]\do\^\do\_\relax + }% +} +\@temp +\def\do#1{\catcode\number`#1=12 } +\do\"\do\'\do\(\do\)\do\*\do\+\do\,\do\-\do\. +\do\/\do\<\do\=\do\>\do\[\do\] +\catcode`\^=7 \catcode`\_=8 +% \end{macrocode} +% +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% \section{Declare some options} +% +% Handling of limits on integrals, sums, operatornames. +% \begin{macrocode} +\DeclareOption{intlimits}{\let\ilimits@\displaylimits} +\DeclareOption{nointlimits}{\let\ilimits@\nolimits} +\DeclareOption{sumlimits}{\let\slimits@\displaylimits} +\DeclareOption{nosumlimits}{\let\slimits@\nolimits} +\DeclareOption{namelimits}{\PassOptionsToPackage{namelimits}{amsopn}} +\DeclareOption{nonamelimits}{% + \PassOptionsToPackage{nonamelimits}{amsopn}} +% \end{macrocode} +% +% The following two switches might have been defined already by the +% documentclass, but it doesn't hurt to re-execute the \cs{newif}'s. +% \begin{macrocode} +\newif\ifctagsplit@ +\newif\iftagsleft@ +% \end{macrocode} +% Right or left placement of equation numbers. +% \begin{macrocode} +\DeclareOption{leqno}{\tagsleft@true} +\DeclareOption{reqno}{\tagsleft@false} +\DeclareOption{centertags}{\ctagsplit@true} +\DeclareOption{tbtags}{\ctagsplit@false} +% \end{macrocode} +% +% The \opt{cmex10} option is an escape hatch for people who don't +% happen to have sizes 7--9 of the \fn{cmex} fonts available to them +% yet. (Strictly speaking they are considered part of a minimum +% \latex/ distribution now, i.e., all \LaTeXe{} users should have +% them, without needing to get the AMSFonts distrib.) +% \begin{macrocode} +\DeclareOption{cmex10}{% + \ifnum\cmex@opt=\@ne \def\cmex@opt{0}% + \else \def\cmex@opt{10}\fi +} +% \end{macrocode} +% To help things work out better with various package loading orders +% of \pkg{amsmath} and \pkg{amsfonts}, we establish a variable to +% communicate the status of the cmex font definition. If the +% \pkg{amsfonts} package was loaded first this variable might be +% already defined, in which case we want to preserve its value. +% \begin{macrocode} +\@ifundefined{cmex@opt}{\def\cmex@opt{7}}{} +% \end{macrocode} +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% \section{Flush-left equations [DMJ]} +% +% The left margin of math enviroments is controlled by +% \cs{@mathmargin}. This can be set to \cs{@centering} to +% implement the default behaviour, i.e., centered equations, and to +% something else to implement the flushleft style. +% +% In theory, all that's needed to activate the flushleft mode +% in the AMS document classes is something like this: +% \begin{verbatim} +% \DeclareOption{fleqn}{% +% \AtBeginDocument{\@mathmargin30pt\relax}% +% } +% \end{verbatim} +% (In fact, unless the document class wants to specify the +% \cs{@mathmargin}, it doesn't need to do anything with the +% \opt{fleqn} option.) +% \begin{macrocode} +\newif\if@fleqn +% +\newskip\@mathmargin +\@mathmargin\@centering +% +\DeclareOption{fleqn}{% + \@fleqntrue + \@mathmargin = -1sp + \let\mathindent=\@mathmargin + \AtBeginDocument{% + \ifdim\@mathmargin= -1sp + \@mathmargin\leftmargini minus\leftmargini + \fi + }% +} +% \end{macrocode} +% +% DMJ: This ensures that \cs{@mathmargin} is given some sort of +% sensible default if the class doesn't specify one, while still +% allowing a user to override the default value in their document +% preamble. (Incidentally, I'm initializing \cs{@mathmargin} to +% \cs{leftmargini} for compatibility with \fn{fleqn.clo}, but I'm +% not at all convinced that's the right thing to do.) +% +% The next question is what happens when amsmath is used with +% one of the standard classes. Unfortunately, \latex/ implements +% \opt{fleqn} somewhat clumsily; instead of paramaterizing the +% definitions of the math structures (as I've attempted to do +% here), \fn{fleqn.clo} declares a dimen \cn{mathindent} that is +% much like my \cs{@mathmargin} and then redefines \cn\[, \cn\], +% \cn{equation}, and \cn{eqnarray}. This means that things could +% get rather messy in 2.09 compatibility mode, since \fn{fleqn.clo} +% might be loaded after \fn{amsmath.sty}, which could cause a real +% mess. +% +% [mjd,1999/07/07]: Let \cs{mathindent} = \cs{@mathmargin} as +% envisioned by DMJ. Compatibility-mode documents will all use the +% \pkg{amstex} package, not \pkg{amsmath}. There is a remote chance +% of a problem if someone makes an assignment to \cs{mathindent} in a +% way that implicitly assumes it is a dimen register (inasmuch as it +% has now become a skip register), and the string ``plus'' follows in +% the input stream, but if someone's document croaks in that way, I +% think they will just have to bite the bullet and fix it. The +% alternative is to penalize a lot of other users with a known +% handicap. +% +% \section{Spacing around \cn{aligned} and \cn{gathered}} +% +% [dpc, 2016] Option to control the space to the left of aligned and gathered. +% +% Previously \cn{aligned} and \cn{gathered} inserted a thin space on +% their left but not their right, there is no good reason for this +% that anyone can remember, it has just always been that way +% inherited from amstex. The usual advice to authors has been to use +% |\!\begin{aligned}| to get better spacing. +% +% Here introduce: +% +% \opt{alignedleftspaceyes} to keep the behaviour of adding this space. +% +% \opt{alignedleftspaceno} to disable adding this space. +% +% \opt{alignedleftspaceyesifneg} the new default behaviour, do not add +% the space unless the environment is preceded by a negative skip or +% kern, so that |\!\begin{aligned}| works as before. +% +% \changes{v2.16a}{2016/11/05}{New options to control aligned spacing} +% \begin{macrocode} +\DeclareOption{alignedleftspaceyes}{\def\alignedspace@left{\null\,}} +\DeclareOption{alignedleftspaceno}{\def\alignedspace@left{\null}} +\DeclareOption{alignedleftspaceyesifneg}{% +\def\alignedspace@left{% + \edef\@tempa{\expandafter\@car\the\lastskip\@nil}% + \if-\@tempa\null\,% + \else + \edef\@tempa{\expandafter\@car\the\lastkern\@nil}% + \if-\@tempa\null\,% + \else\null + \fi + \fi}% +} +% \end{macrocode} +% +% +% \begin{macrocode} +\DeclareOption{?}{} +% \end{macrocode} +% +% \begin{macrocode} +\ExecuteOptions{% + nointlimits,sumlimits,namelimits,centertags,alignedleftspaceyesifneg} +% \end{macrocode} +% The \cs{par} after \cs{ProcessOptions} is to ensure the correct +% line number on screen if an error occurs during option processing; +% otherwise the lookahead for a \qc{\*} option would result in \tex/ +% showing the following line instead. +% \begin{macrocode} +\ProcessOptions\par +% \end{macrocode} +% +% \begin{macrocode} +\@ifpackagewith{amsmath}{?}{% + \typeout{^^J% +Documentation for the amsmath package is found in amsldoc.dvi^^J% +(or .pdf or .tex).^^J% +^^J% +See also https://www.ams.org/tex/amslatex.html.^^J% +^^J% +Note: Using the first edition of The LaTeX Companion (1994) without^^J% +errata as a guide for amsmath use is not recommended.^^J% + }% +}{% + \typeout{% +For additional information on amsmath, use the \lq ?\rq\space option.% + }% +} +% \end{macrocode} +% +% Processing to handle the \opt{cmex10} option is a little tricky +% because of different possible loading orders for \pkg{amsmath} and +% \pkg{amsfonts}. The package \pkg{amsmath} sets the \cs{cmex@opt} +% flag to 7 or 10, and the package \pkg{amsfonts} sets the flag to 1 +% or 0. +% \begin{macrocode} +\ifnum\cmex@opt=7 \relax + \DeclareFontShape{OMX}{cmex}{m}{n}{% + <-8>cmex7<8>cmex8<9>cmex9% + <10><10.95><12><14.4><17.28><20.74><24.88>cmex10% + }{}% + \expandafter\let\csname OMX/cmex/m/n/10\endcsname\relax +\else + \ifnum\cmex@opt=\z@ % need to override cmex7 fontdef from amsfonts +% \end{macrocode} +% Force reloading of the OMX/cmex font definition file. +% \begin{macrocode} + \begingroup + \fontencoding{OMX}\fontfamily{cmex}% + \expandafter\let\csname OMX+cmex\endcsname\relax + \try@load@fontshape + \endgroup +% \end{macrocode} +% The \fn{cmex10} font gets special preload handling in the building +% of the \latex/ format file, need an extra bit here to work around +% that. +% \begin{macrocode} + \expandafter\let\csname OMX/cmex/m/n/10\endcsname\relax + \def\cmex@opt{10}% + \fi +\fi +% \end{macrocode} +% +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% \section{Call some other packages} +% +% The \pkg{amstext} package provides the \cn{text} command. The +% \pkg{amsbsy} package provides \cn{boldsymbol} and \cn{pmb}. (Since +% 1997 it is usually better to use the \pkg{bm} package instead; but +% I think we have to keep \pkg{amsbsy} here for backward +% compatibility [mjd,1999/11/19].) The \pkg{amsopn} package provides +% \cn{DeclareMathOperator}. +% \begin{macrocode} +\RequirePackage{amstext}[1995/01/25] +\RequirePackage{amsbsy}[1995/01/20] +\RequirePackage{amsopn}[1995/01/20] +% \end{macrocode} +% +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% \section{Miscellaneous} +% +% \begin{macro}{\ams@newcommand} +% Where \pkg{stix} and \pkg{amsmath} define the same control +% sequences, we want to avoid inadvertently overriding \pkg{stix}'s +% definitions. If \pkg{stix} is loaded before \pkg{amsmath}, the +% following conditional takes care of the problem. There is +% similar code in the \pkg{stix} package in case \pkg{amsmath} is +% loaded first. +% \begin{macrocode} +\@ifpackageloaded{stix}{% + \let\ams@newcommand\providecommand + \let\ams@renewcommand\providecommand + \let\ams@def\providecommand + \let\ams@DeclareRobustCommand\providecommand +}{% + \let\ams@newcommand\newcommand + \let\ams@renewcommand\renewcommand + \let\ams@def\def + \let\ams@DeclareRobustCommand\DeclareRobustCommand +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@amsmath@err} +% Defining this error function saves main mem. +% \begin{macrocode} +\def\@amsmath@err{\PackageError{amsmath}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\AmS} +% The \cs{AmS} prefix can be used to construct the combination +% |\AmS-\LaTeX|. +% \begin{macrocode} +\providecommand{\AmS}{{\protect\AmSfont + A\kern-.1667em\lower.5ex\hbox{M}\kern-.125emS}} +% \end{macrocode} +% In \cn{AmSfont} we call cmsy directly in lieu of trying to access +% it through the math fonts setup (e.g. |\the\textfont2|) because +% math fonts can't be relied on to be properly set up if we are not +% inside a math formula. This means that if this command is used in a +% document where CM fonts are not wanted, then a font substitution +% will need to be declared, e.g.: +% \begin{verbatim} +% \DeclareFontShape{OMS}{cmsy}{m}{n}{ <-> sub * xxx/m/n }{} +% \end{verbatim} +% where |xxx| is some alternate font family. +% Taking the first letter of \cs{f@series} will produce |b| or |m| +% for the most common values (|b,bx,m|). It may produce nonsense for +% more unusual values of \cs{f@series}, so for safety's sake we have +% an additional \cs{if} test. We want to avoid setting the series to +% |bx| because in a standard \latex/ installation the combination +% |cmsy/bx/n| does not have a font definition, and the user +% would get a font substitution warning on screen. +% \begin{macrocode} +\newcommand{\AmSfont}{% + \usefont{OMS}{cmsy}{\if\@xp\@car\f@series\@nil bb\else m\fi}{n}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@mathmeasure} +% The function |\@mathmeasure| takes three arguments; the third arg +% is typeset as a math formula in an hbox, using arg |#2| as the +% mathstyle, and the result is left in the box named by the first +% arg. It is assumed that we are already in math mode, so we can turn +% off |\everymath| (in particular, |\check@mathfonts|). +% +% As of 2018/12 release we don't turn off |\evermath| as this +% optimization can be harmful. +% \changes{v2.17b}{2018/12/01}{Don't drop \cs{frozen@everymath}} +% \begin{macrocode} +\ifx\leavevmode@ifvmode\@undefined % kernel is < 2018/12 +\def\@mathmeasure#1#2#3{\setbox#1\hbox{\frozen@everymath\@emptytoks + \m@th$#2#3$}} +\else +\def\@mathmeasure#1#2#3{\setbox#1\hbox{% + \m@th$#2#3$}} +\fi +% \end{macrocode} +% \end{macro} +% +% The \cs{inf@bad} constant is for testing overfull boxes. +% \begin{macrocode} +\@ifundefined{inf@bad}{% + \newcount\inf@bad \inf@bad=1000000 \relax +}{} +% \end{macrocode} +% +%\subsection{Math spacing commands} +% +% \begin{macro}{\tmspace} +% \begin{macro}{\,} +% \begin{macro}{\thinspace} +% \begin{macro}{\!} +% \begin{macro}{\negthinspace} +% \begin{macro}{\:} +% \begin{macro}{\medspace} +% \begin{macro}{\negmedspace} +% \begin{macro}{\;} +% \begin{macro}{\thickspace} +% \begin{macro}{\negthickspace} +% Here we fill in some gaps in the set of spacing commands, and make them +% all work equally well in or out of math. +% We want all these commands to be robust but declaring them all with +% \cs{DeclareRobustCommand} uses up an control sequence name per +% command; to avoid this, we define a common command \cs{tmspace} +% (text-or-math space) which carries the robustness burden for all of +% them. The standard \cs{relax} before the \cs{ifmmode} is not +% necessary because of the \cs{protect} added by +% \cs{DeclareRobustCommand}. +% \changes{v2.17b}{2018/12/01}{Start LR-mode for \cs{thinspace} and +% friends if necessary (github/49)} +% \begin{macrocode} +\ifx\leavevmode@ifvmode\@undefined +\DeclareRobustCommand{\tmspace}[3]{% + \ifmmode\mskip#1#2\else\kern#1#3\fi\relax} +\else +\DeclareRobustCommand{\tmspace}[3]{% + \ifmmode\mskip#1#2\else\leavevmode@ifvmode\kern#1#3\fi\relax} +\fi +\renewcommand{\,}{\tmspace+\thinmuskip{.1667em}} +\let\thinspace\, +\renewcommand{\!}{\tmspace-\thinmuskip{.1667em}} +\let\negthinspace\! +\renewcommand{\:}{\tmspace+\medmuskip{.2222em}} +\let\medspace\: +\newcommand{\negmedspace}{\tmspace-\medmuskip{.2222em}} +\renewcommand{\;}{\tmspace+\thickmuskip{.2777em}} +\let\thickspace\; +\newcommand{\negthickspace}{\tmspace-\thickmuskip{.2777em}} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\mspace} +% And while we're at it, why don't we provide an equivalent of +% \cn{hspace} for math mode use. This allows use of |mu| units in +% (for example) constructing compound math symbols. +% \begin{macrocode} +\newcommand{\mspace}[1]{\mskip#1\relax} +% \end{macrocode} +% \end{macro} +% +% \subsection{Vertical bar symbols} +% \begin{macro}{\lvert} +% \begin{macro}{\rvert} +% \begin{macro}{\lVert} +% \begin{macro}{\rVert} +% Add left/right specific versions of \cn{vert}, \cn{Vert}. Don't +% assume the delimiter codes are the CM defaults. +% \begin{macrocode} +\def\@tempa#1#2\@nil{% + \ifx\delimiter#1\@tempcnta#2\relax\else\@tempcnta\z@\fi +} +\@xp\@tempa\vert\@empty\@nil +\ifnum\@tempcnta>\z@ + \advance\@tempcnta "4000000 + \xdef\lvert{\delimiter\number\@tempcnta\space } + \advance\@tempcnta "1000000 + \xdef\rvert{\delimiter\number\@tempcnta\space } +\else + \ifx\@@undefined\lvert + % Fall back to cmex encoding since we don't know what else to do. + \DeclareMathDelimiter{\lvert} + {\mathopen}{symbols}{"6A}{largesymbols}{"0C} + \DeclareMathDelimiter{\rvert} + {\mathclose}{symbols}{"6A}{largesymbols}{"0C} + \fi +\fi +\@xp\@tempa\Vert\@empty\@nil +\ifnum\@tempcnta>\z@ + \advance\@tempcnta "4000000 + \xdef\lVert{\delimiter\number\@tempcnta\space } + \advance\@tempcnta "1000000 + \xdef\rVert{\delimiter\number\@tempcnta\space } +\else + \ifx\@@undefined\lVert + \DeclareMathDelimiter{\lVert} + {\mathopen}{symbols}{"6B}{largesymbols}{"0D} + \DeclareMathDelimiter{\rVert} + {\mathclose}{symbols}{"6B}{largesymbols}{"0D} + \fi +\fi +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \subsection{Fractions} +% Bury the generalized fraction primitives \cs{over}, \cs{atop}, +% etc., because of their bizarre syntax, which is decidedly out of +% place in a \latex/ document. +% \begin{macrocode} +\@saveprimitive\over\@@over +\@saveprimitive\atop\@@atop +\@saveprimitive\above\@@above +\@saveprimitive\overwithdelims\@@overwithdelims +\@saveprimitive\atopwithdelims\@@atopwithdelims +\@saveprimitive\abovewithdelims\@@abovewithdelims +% \end{macrocode} +% +% \begin{macro}{\primfrac} +% If someone insists on using \cs{over}, give a warning the first +% time and then resurrect the old definition. Laissez-faire policy. +% \begin{macrocode} +\DeclareRobustCommand{\primfrac}[1]{% + \PackageWarning{amsmath}{% +Foreign command \@backslashchar#1;\MessageBreak +\protect\frac\space or \protect\genfrac\space should be used instead% +\MessageBreak + } + \global\@xp\let\csname#1\@xp\endcsname\csname @@#1\endcsname + \csname#1\endcsname +} +% \end{macrocode} +% \end{macro} +% \begin{macrocode} +\renewcommand{\over}{\primfrac{over}} +\renewcommand{\atop}{\primfrac{atop}} +\renewcommand{\above}{\primfrac{above}} +\renewcommand{\overwithdelims}{\primfrac{overwithdelims}} +\renewcommand{\atopwithdelims}{\primfrac{atopwithdelims}} +\renewcommand{\abovewithdelims}{\primfrac{abovewithdelims}} +% \end{macrocode} +% +% \cn{frac} calls \cn{@@over} directly instead of via \cn{genfrac}, for +% better speed because it is so common. \cn{tfrac} and \cn{dfrac} are +% abbreviations for some commonly needed mathstyle overrides. To +% conserve csnames we avoid making \cn{dfrac} and \cn{tfrac} robust +% (\cn{genfrac} is itself robust). +% \begin{macrocode} +\DeclareRobustCommand{\frac}[2]{{\begingroup#1\endgroup\@@over#2}} +\newcommand{\dfrac}{\genfrac{}{}{}0} +\newcommand{\tfrac}{\genfrac{}{}{}1} +% \end{macrocode} +% The \cn{binom} command for binomial notation works like \cn{frac} +% and has similar variants. Note that we do not use \cs{z@} in +% \cn{dbinom} and \cn{tbinom} because they are not top-level robust +% like \cn{binom}, and so the \cs{z@} with the potentially +% problematic \qc{\@} character would become visible when writing one +% of those commands to a \fn{.toc} file. +% \begin{macrocode} +\DeclareRobustCommand{\binom}{\genfrac()\z@{}} +\newcommand{\dbinom}{\genfrac(){0pt}0} +\newcommand{\tbinom}{\genfrac(){0pt}1} +% \end{macrocode} +% +% \begin{macro}{\genfrac} +% \changes{v2.16a}{2016/11/05}{New genfrac implementation for extended +% TeXs} +% This command provides access to \tex/'s generalized fraction +% primitives. Args: \arg{1} left delim, \arg{2} right delim, \arg{3} +% line thickness, \arg{4} mathstyle override, \arg{5} numerator, +% \arg{6} denominator. But we only read the first four args at first, +% in order to give us a moment to select the proper generalized +% fraction primitive. Any of those four args could be empty, and when +% empty the obvious defaults are selected (no delimiters, default +% line thickness (normally .4pt), and no mathstyle override). +% +% the |withdelims| primitives do not work in xetex with OpenType +% fonts, and the relevant font dimen parameters are often not set +% in luatex as theer are no matching values in the OpenType Math +% table, so here we use variants that use the font parameters if +% they are set, but scale using |\left\right| rather than the +% |withdelims| primitives. +% +% \begin{macrocode} +\ifx\directlua\@undefined +% \end{macrocode} +% +% \begin{macrocode} +\ifx\XeTeXcharclass\@undefined +% \end{macrocode} +% Classic version +% \begin{macrocode} +\DeclareRobustCommand{\genfrac}[4]{% + \def\@tempa{#1#2}% + \edef\@tempb{\@nx\@genfrac\@mathstyle{#4}% + \csname @@\ifx @#3@over\else above\fi + \ifx\@tempa\@empty \else withdelims\fi\endcsname} + \@tempb{#1#2#3}} +% \end{macrocode} +% +% \begin{macrocode} +\else +% \end{macrocode} +% XeTeX version +% \begin{macrocode} +\def\genfrac@rule#1#2#3#4{% +\hbox{$\left#1\vcenter{\hrule \@width\z@ + \@height + \ifdim\fontdimen#2#3\tw@=\z@ + #4\fontdimen6#3\tw@ + \else + \fontdimen#2#3\tw@ + \fi + }\right.$}} +% \end{macrocode} +% +% \begin{macrocode} +\def\genfrac@choice#1#2{% +\ifx @#2@\else +% \end{macrocode} +% \changes{v2.17a}{2017/09/02}{move \cs{nulldelimiterspace} correction} +% \begin{macrocode} +\ifx c#1\kern-\nulldelimiterspace\fi +{\delimitershortfall\z@\delimiterfactor\@m + \mathsurround\z@\nulldelimiterspace\z@ +\mathchoice +{\genfrac@rule{#2}{20}\textfont{2.39}}% +{\genfrac@rule{#2}{21}\textfont{1}}% +{\genfrac@rule{#2}{21}\scriptfont{1.45}}% +{\genfrac@rule{#2}{21}\scriptscriptfont{1.35}}% +}% +\ifx o#1\kern-\nulldelimiterspace\fi +\fi +} +% \end{macrocode} +% +% \begin{macrocode} +\DeclareRobustCommand{\genfrac}[6]{{% +\@mathstyle{#4}% +\genfrac@choice o{#1}% +{\begingroup#5\endgroup\ifx @#3@\@@over\else\@@above\fi#3\relax#6}% +\genfrac@choice c{#2}% +}} +% \end{macrocode} +% +% \begin{macrocode} +\fi +\else +% \end{macrocode} +% LuaTeX version +% \begin{macrocode} +\def\genfrac@rule#1#2#3{% +\hbox{$\left#1\vcenter{\hrule \@width\z@ + \@height + \ifdim\Umathfractiondelsize#2=\z@ + #3\fontdimen6#3\tw@ + \else + \Umathfractiondelsize#2% + \fi + }\right.$}} +% \end{macrocode} +% +% \begin{macrocode} +\def\genfrac@choice#1#2{% +\ifx @#2@\else +% \end{macrocode} +% \changes{v2.17a}{2017/09/02}{move \cs{nulldelimiterspace} correction} +% \begin{macrocode} +\ifx c#1\kern-\nulldelimiterspace\fi +{\delimitershortfall\z@\delimiterfactor\@m + \mathsurround\z@\nulldelimiterspace\z@ +\mathchoice +{\genfrac@rule{#2}\displaystyle{2.39}}% +{\genfrac@rule{#2}\textstyle{1}}% +{\genfrac@rule{#2}\scriptstyle{1.45}}% +{\genfrac@rule{#2}\scriptscriptstyle{1.35}}% +}% +\ifx o#1\kern-\nulldelimiterspace\fi +\fi +} +% \end{macrocode} +% +% \begin{macrocode} +\DeclareRobustCommand{\genfrac}[6]{{% +\@mathstyle{#4}% +\genfrac@choice o{#1}% +{\begingroup#5\endgroup\ifx @#3@\@@over\else\@@above\fi#3\relax#6}% +\genfrac@choice c{#2}% +}} +% \end{macrocode} +% +% \begin{macrocode} +\fi +% \end{macrocode} +% +% End of test for Lua\TeX/Xe\TeX. +% +% \cs{@genfrac} takes the preceding arguments and reads the +% numerator and denominator. Note that there's no convenient way to +% make the numerator and denominator \emph{contents} +% displaystyle, through this interface. +% +% Args: \arg{1} mathstyle, \arg{2} fraction primitive, +% \arg{3} delimiters and rule thickness, +% \arg{4} numerator, \arg{5} denominator. +% \begin{macrocode} +\def\@genfrac#1#2#3#4#5{{#1{\begingroup#4\endgroup#2#3\relax#5}}} +% \end{macrocode} +% \end{macro} +% +% Empty mathstyle arg: no change; 0 = displaystyle, 1 = textstyle, 2 +% = scriptstyle, 3 = scriptscriptstyle. +% \begin{macrocode} +\def\@mathstyle#1{% + \ifx\@empty#1\@empty\relax + \else\ifcase#1\displaystyle % case 0 + \or\textstyle\or\scriptstyle\else\scriptscriptstyle\fi\fi} +% \end{macrocode} +% +% \subsection{Sums and Integrals} +% Default value for sum limits is \cs{displaylimits}, see option +% `nosumlimits'. +% +% We redefine all the cumulative operator symbols to use +% \cs{slimits@} so that switching between \cs{displaylimits} and +% \cs{nolimits} can be controlled by package options. Also add +% \cs{DOTSB} for the benefit of the dots lookahead. But we'd better +% make sure \cn{coprod} and the others are simple mathchars; if not, +% the attempted changes will probably fail miserably. +% +% \changes{v2.15}{2016/02/20}{Accept \cs{Umathchar}} +% \begin{macrocode} +\begingroup +% \end{macrocode} +% \begin{macrocode} +\edef\@tempa{\string\mathchar"} +\edef\@tempd{\string\Umathchar"} +\def\@tempb#1"#2\@nil{#1"} +\edef\@tempc{\expandafter\@tempb\meaning\coprod "\@nil} +\ifx\@tempc\@tempd\let\@tempc\@tempa\fi +% \end{macrocode} +% \begin{macrocode} +\ifx\@tempa\@tempc + \global\let\coprod@\coprod + \gdef\coprod{\DOTSB\coprod@\slimits@} + \global\let\bigvee@\bigvee + \gdef\bigvee{\DOTSB\bigvee@\slimits@} + \global\let\bigwedge@\bigwedge + \gdef\bigwedge{\DOTSB\bigwedge@\slimits@} + \global\let\biguplus@\biguplus + \gdef\biguplus{\DOTSB\biguplus@\slimits@} + \global\let\bigcap@\bigcap + \gdef\bigcap{\DOTSB\bigcap@\slimits@} + \global\let\bigcup@\bigcup + \gdef\bigcup{\DOTSB\bigcup@\slimits@} + \global\let\prod@\prod + \gdef\prod{\DOTSB\prod@\slimits@} + \global\let\sum@\sum + \gdef\sum{\DOTSB\sum@\slimits@} + \global\let\bigotimes@\bigotimes + \gdef\bigotimes{\DOTSB\bigotimes@\slimits@} + \global\let\bigoplus@\bigoplus + \gdef\bigoplus{\DOTSB\bigoplus@\slimits@} + \global\let\bigodot@\bigodot + \gdef\bigodot{\DOTSB\bigodot@\slimits@} + \global\let\bigsqcup@\bigsqcup + \gdef\bigsqcup{\DOTSB\bigsqcup@\slimits@} +\fi +\endgroup +% \end{macrocode} +% +% \subsection{Roots and radicals} +% +% \begin{macro}{\root} +% This root stuff needs syntax work and implementation work. Surely +% something more compact can be done?? [mjd, 1994/09/05] +% \begin{macrocode} +\newcommand{\leftroot}{\@amsmath@err{\Invalid@@\leftroot}\@eha} +\newcommand{\uproot}{\@amsmath@err{\Invalid@@\uproot}\@eha} +\newcount\uproot@ +\newcount\leftroot@ +\renewcommand{\root}{\relaxnext@ + \DN@{\ifx\@let@token\uproot\let\next@\nextii@\else + \ifx\@let@token\leftroot\let\next@\nextiii@\else + \let\next@\plainroot@\fi\fi\next@}% + \def\nextii@\uproot##1{\uproot@##1\relax\FN@\nextiv@}% + \def\nextiv@{\ifx\@let@token\@sptoken\DN@. {\FN@\nextv@}\else + \DN@.{\FN@\nextv@}\fi\next@.}% + \def\nextv@{\ifx\@let@token\leftroot\let\next@\nextvi@\else + \let\next@\plainroot@\fi\next@}% + \def\nextvi@\leftroot##1{\leftroot@##1\relax\plainroot@}% + \def\nextiii@\leftroot##1{\leftroot@##1\relax\FN@\nextvii@}% + \def\nextvii@{\ifx\@let@token\@sptoken + \DN@. {\FN@\nextviii@}\else + \DN@.{\FN@\nextviii@}\fi\next@.}% + \def\nextviii@{\ifx\@let@token\uproot\let\next@\nextix@\else + \let\next@\plainroot@\fi\next@}% + \def\nextix@\uproot##1{\uproot@##1\relax\plainroot@}% + \bgroup\uproot@\z@\leftroot@\z@\FN@\next@} +\def\plainroot@#1\of#2{\setbox\rootbox\hbox{% + $\m@th\scriptscriptstyle{#1}$}% + \mathchoice{\r@@t\displaystyle{#2}}{\r@@t\textstyle{#2}} + {\r@@t\scriptstyle{#2}}{\r@@t\scriptscriptstyle{#2}}\egroup} +% \end{macrocode} +% \end{macro} +% +% \changes{v2.0}{1999/06/17}{Normalize @@sqrt to sqrtsign} + +% Name change from \cs{@@sqrt} to \cs{sqrtsign} happened in the +% 1995/12/01 release of \latex/. If we were to assume that +% \cs{sqrtsign} is defined then someone with the 1995/06/01 release +% of \latex/ would have trouble using this package. +% \begin{macrocode} +\@ifundefined{sqrtsign}{\let\sqrtsign\@@sqrt}{} +\def\r@@t#1#2{\setboxz@h{$\m@th#1\sqrtsign{#2}$}% + \dimen@\ht\z@\advance\dimen@-\dp\z@ + \setbox\@ne\hbox{$\m@th#1\mskip\uproot@ mu$}% + \advance\dimen@ by1.667\wd\@ne + \mkern-\leftroot@ mu\mkern5mu\raise.6\dimen@\copy\rootbox + \mkern-10mu\mkern\leftroot@ mu\boxz@} +% \end{macrocode} +% +% \subsection{Et cetera} +% +% \changes{v2.0}{1999/06/18}{Leave Greek cap letters unaltered} +% +% Specific names for the variant italic cap Greek letters are not +% defined by \latex/. If no preceding package defined these, we will +% define them now. +% \begin{macrocode} +\@ifundefined{varGamma}{% + \DeclareMathSymbol{\varGamma}{\mathord}{letters}{"00} + \DeclareMathSymbol{\varDelta}{\mathord}{letters}{"01} + \DeclareMathSymbol{\varTheta}{\mathord}{letters}{"02} + \DeclareMathSymbol{\varLambda}{\mathord}{letters}{"03} + \DeclareMathSymbol{\varXi}{\mathord}{letters}{"04} + \DeclareMathSymbol{\varPi}{\mathord}{letters}{"05} + \DeclareMathSymbol{\varSigma}{\mathord}{letters}{"06} + \DeclareMathSymbol{\varUpsilon}{\mathord}{letters}{"07} + \DeclareMathSymbol{\varPhi}{\mathord}{letters}{"08} + \DeclareMathSymbol{\varPsi}{\mathord}{letters}{"09} + \DeclareMathSymbol{\varOmega}{\mathord}{letters}{"0A} +}{} +% \end{macrocode} +% +% \begin{macro}{\overline} +% \amstex/ redefines \cn{overline} as shown here, for reasons that +% are probably less important in \latex/: Make it read its argument +% as a macro argument rather than a ``math field'' (\emph{The +% \tex/book}, Chapter 26), to avoid problems when something that is +% apparently a single symbol is actually a non-simple macro (e.g., +% \cn{dag}) \emph{and} is given as a single-token argument without +% enclosing braces. +% \begin{macrocode} +\@saveprimitive\overline\@@overline +\DeclareRobustCommand{\overline}[1]{\@@overline{#1}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\boxed} +% The \cs{boxed} command is specifically intended to put a box around +% an equation or piece of an equation. (Not including the equation +% number.) This isn't trivial for end-users to do it properly +% with \cs{fbox} so we provide a command for them. +% \begin{macrocode} +\newcommand{\boxed}[1]{\fbox{\m@th$\displaystyle#1$}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\implies} +% \begin{macro}{\impliedby} +% \begin{macrocode} +\newcommand{\implies}{\DOTSB\;\Longrightarrow\;} +\newcommand{\impliedby}{\DOTSB\;\Longleftarrow\;} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\And} +% \begin{macrocode} +\def\And{\DOTSB\;\mathchar"3026 \;} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\nobreakdash} +% The command \cn{nobreakdash} is designed only for use before a +% hyphen or dash (|-|, |--|, or |---|). +% Setting the hyphen in a box and then unboxing it means that the +% normal penalty will not be added after it---and if the penalty is +% not there a break will not be taken (unless an explicit penalty +% or glue follows, thus the final \verb=\nobreak=). +% \begin{macrocode} +\newcommand{\nobreakdash}{\leavevmode + \toks@\@emptytoks \def\@tempa##1{\toks@\@xp{\the\toks@-}\FN@\next@}% + \DN@{\ifx\@let@token-\@xp\@tempa + \else\setboxz@h{\the\toks@\nobreak}\unhbox\z@\fi}% + \FN@\next@ +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\colon} +% \cs{colon} is for a colon in math that resembles a text colon: +% small space on the left, larger space on the right. The \qc{\:} +% character by itself is treated as a \cs{mathrel} i.e. large, equal +% spacing on both sides. +% \begin{macrocode} +\renewcommand{\colon}{\nobreak\mskip2mu\mathpunct{}\nonscript + \mkern-\thinmuskip{:}\mskip6muplus1mu\relax} +% \end{macrocode} +% \end{macro} +% +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% \section{Ellipsis dots} +% +% We can't use \cs{newif} for \cs{ifgtest@} because we want +% to include \cs{global} in the definitions of +% \cs{gtest@true} and \cs{gtest@false}. +% \begin{macrocode} +\let\ifgtest@\iffalse % initial value +\def\gtest@true{\global\let\ifgtest@\iftrue} +\def\gtest@false{\global\let\ifgtest@\iffalse} +\let\DOTSI\relax +\let\DOTSB\relax +\let\DOTSX\relax +{\uccode`7=`\\ \uccode`8=`m \uccode`9=`a \uccode`0=`t \uccode`!=`h + \uppercase{% + \gdef\math@#1#2#3#4#5#6\math@{\gtest@false\ifx 7#1\ifx 8#2% + \ifx 9#3\ifx 0#4\ifx !#5\xdef\meaning@{#6}\gtest@true + \fi\fi\fi\fi\fi}}} +{\uccode`7=`c \uccode`8=`h \uccode`9=`\" + \uppercase{\gdef\mathch@#1#2#3#4#5#6\mathch@{\gtest@false + \ifx 7#1\ifx 8#2\ifx 9#5\gtest@true\xdef\meaning@{9#6}\fi\fi\fi}}} +% \end{macrocode} +% \changes{v2.15}{2016/02/20}{Accept \cs{Umathchar}} +% \begin{macrocode} +{\uccode`(=`U \uccode`)=`m + \uppercase{\gdef\Umathch@#1#2#3#4"#5"#6\Umathch@{\gtest@false + \ifx(#2\ifx)#3\gtest@true + \ifcase"#5 \or\or\gdef\thedots@{\dotsb@}\or\gdef\thedots@{\dotsb@}\fi + \fi\fi + }}} +% \end{macrocode} +% \changes{v2.15}{2016/02/20}{Decode the mathcode of character tokens for Unicode TeX} +% For Unicode TeXs, if the next token is a character token look up the (U)mathcode. Do not do this for classic TeX for compatibility reasons. +% \begin{macrocode} +\ifx\Umathcharnumdef\@undefined +\gdef\thecharacter@#1\thecharacter@{} +\else +{\uccode`(=`t \uccode`)=`c + \uppercase{\gdef\thecharacter@#1#2#3#4#5\thecharacter@{% + \ifx(#1\ifx)#4% + \@xp\getmathcode@\meaning@\getmathcode@ + \fi\fi +}}} +\def\getmathcode@#1 #2 #3#4\getmathcode@{% + \Umathcharnumdef\@tempa\Umathcodenum`#3\relax + \edef\meaning@{\meaning\@tempa}% + \@xp\Umathch@\meaning@\Umathch@ +} +\fi +% \end{macrocode} +% \begin{macrocode} +\newcount\classnum@ +\def\getmathch@#1.#2\getmathch@{\classnum@#1 \divide\classnum@4096 + \ifcase\number\classnum@\or\or\gdef\thedots@{\dotsb@}\or + \gdef\thedots@{\dotsb@}\fi} +{\uccode`4=`b \uccode`5=`i \uccode`6=`n + \uppercase{\gdef\mathbin@#1#2#3{\relaxnext@ + \def\nextii@##1\mathbin@{\ifx\@sptoken\@let@token\gtest@true\fi}% + \gtest@false\DN@##1\mathbin@{}% + \ifx 4#1\ifx 5#2\ifx 6#3\DN@{\FN@\nextii@}\fi\fi\fi\next@}}} +{\uccode`4=`r \uccode`5=`e \uccode`6=`l + \uppercase{\gdef\mathrel@#1#2#3{\relaxnext@ + \def\nextii@##1\mathrel@{\ifx\@sptoken\@let@token\gtest@true\fi}% + \gtest@false\DN@##1\mathrel@{}% + \ifx 4#1\ifx 5#2\ifx 6#3\DN@{\FN@\nextii@}\fi\fi\fi\next@}}} +{\uccode`5=`m \uccode`6=`a \uccode`7=`c + \uppercase{\gdef\macro@#1#2#3#4\macro@{\gtest@false + \ifx 5#1\ifx 6#2\ifx 7#3\gtest@true + \xdef\meaning@{\macro@@#4\macro@@}\fi\fi\fi}}} +\def\macro@@#1->#2\macro@@{#2} +\newcount\DOTSCASE@ +{\uccode`6=`\\ \uccode`7=`D \uccode`8=`O \uccode`9=`T \uccode`0=`S + \uppercase{\gdef\DOTS@#1#2#3#4#5{\gtest@false\DN@##1\DOTS@{}% + \ifx 6#1\ifx 7#2\ifx 8#3\ifx 9#4\ifx 0#5\let\next@\DOTS@@ + \fi\fi\fi\fi\fi + \next@}}} +{\uccode`3=`B \uccode`4=`I \uccode`5=`X + \uppercase{\gdef\DOTS@@#1{\relaxnext@ + \def\nextii@##1\DOTS@{\ifx\@sptoken\@let@token\gtest@true\fi}% + \DN@{\FN@\nextii@}% + \ifx 3#1\global\DOTSCASE@\z@\else + \ifx 4#1\global\DOTSCASE@\@ne\else + \ifx 5#1\global\DOTSCASE@\tw@\else\DN@##1\DOTS@{}% + \fi\fi\fi\next@}}} +{\uccode`5=`\\ \uccode`6=`n \uccode`7=`o \uccode`8=`t + \uppercase{\gdef\not@#1#2#3#4{\relaxnext@ + \def\nextii@##1\not@{\ifx\@sptoken\@let@token\gtest@true\fi}% + \gtest@false\DN@##1\not@{}% + \ifx 5#1\ifx 6#2\ifx 7#3\ifx 8#4\DN@{\FN@\nextii@}\fi\fi\fi + \fi\next@}}} +% \end{macrocode} +% \changes{v2.15}{2016/02/20}{macro added to strip \cs{long} during tests} +% \begin{macrocode} +{\uccode`9=`\l % + \uppercase{\gdef\striplong@#1#2#3\relax{% + \ifx9#2 \@xp\@xp\@xp\zap@to@space\fi}}} +\def\zap@to@space#1 {} +% \end{macrocode} +% \begin{macrocode} +\def\keybin@{\gtest@true + \ifx\@let@token+\else\ifx\@let@token=\else + \ifx\@let@token<\else\ifx\@let@token>\else + \ifx\@let@token-\else\ifx\@let@token*\else\ifx\@let@token:\else + \gtest@false\fi\fi\fi\fi\fi\fi\fi} +% \end{macrocode} +% Patch to ensure \cs{@ldots} is defined. (Name changed to +% \cn{mathellipsis} in Dec 94 release of \latex/.) +% \begin{macrocode} +\@ifundefined{@ldots}{\def\@ldots{\mathellipsis}}{} +% \end{macrocode} +% \begin{macro}{\ldots} +% \begin{macro}{\dots} +% Reiterate the standard definition of \cs{ldots} to keep it from +% being clobbered by the redefinition of \cs{dots}. +% \begin{macrocode} +\DeclareRobustCommand{\ldots}{% + \ifmmode \mathellipsis \else \textellipsis \fi +} +\DeclareRobustCommand{\dots}{% + \ifmmode \@xp\mdots@\else \@xp\textellipsis \fi +} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \begin{macrocode} +\def\tdots@{\leavevmode\unskip\relaxnext@ + \DN@{$\m@th\@ldots\, + \ifx\@let@token,\,$\else\ifx\@let@token.\,$\else + \ifx\@let@token;\,$\else\ifx\@let@token:\,$\else + \ifx\@let@token?\,$\else\ifx\@let@token!\,$\else + $ \fi\fi\fi\fi\fi\fi}% + \ \FN@\next@} +\def\mdots@{\FN@\mdots@@} +% \end{macrocode} +% \changes{v2.15}{2016/02/20}{Indent \cs{mdots@@} for readability and add additional tests} +% \begin{macrocode} +\def\mdots@@{\gdef\thedots@{\dotso@}% + \ifx\@let@token\boldsymbol + \gdef\thedots@\boldsymbol{\boldsymboldots@}% + \else + \ifx,\@let@token \gdef\thedots@{\dotsc}% + \else + \ifx\not\@let@token + \gdef\thedots@{\dotsb@}% + \else + \keybin@ + \ifgtest@ % if \keybin@ test + \gdef\thedots@{\dotsb@}% + \else +% \end{macrocode} +% \changes{v2.15d}{2016/06/28}{Add space token to prevent runaway argument error} +% \begin{macrocode} + \xdef\meaning@{\meaning\@let@token. .........}% +% \end{macrocode} +% In previous versions \verb|\long| macros were not seen by the lokkahead. +% That was bad as this file uses \verb|\(re)newcommand| for \verb|\implies| etc. +% \begin{macrocode} + \xdef\meaning@@{\@xp\striplong@\meaning@\relax\meaning@}% +% \end{macrocode} +% \begin{macrocode} + \@xp\math@\meaning@\math@ + \ifgtest@ % if \mathxxx test + \@xp\mathch@\meaning@\mathch@ + \ifgtest@ % if \mathchar + \@xp\getmathch@\meaning@\getmathch@ + \fi % end if \mathchar + \else % \not \mathxxx +% \end{macrocode} +% Test for \verb|\Umathchar| added. +% \begin{macrocode} + \@xp\Umathch@\meaning@"0"\Umathch@ + \ifgtest@ % if \Umathchar + \else % else not \Umathcar +% \end{macrocode} +% \begin{macrocode} + \@xp\macro@\meaning@@\macro@ + \ifgtest@ % if macro test + \@xp\not@\meaning@\not@ + \ifgtest@ % if macro starts \not test + \gdef\thedots@{\dotsb@}% + \else% else not \not + \@xp\DOTS@\meaning@\DOTS@ + \ifgtest@ % \if DOTS + \ifcase\number\DOTSCASE@ %ifcase dots + \gdef\thedots@{\dotsb@}% + \or\gdef\thedots@{\dotsi}\else + \fi % endifcase dots + \else % not macro starts \DOTS + \@xp\math@\meaning@\math@ + \ifgtest@ % \if macro starts \mathxxxx + \@xp\mathbin@\meaning@\mathbin@ + \ifgtest@ % if macro starts \mathbin + \gdef\thedots@{\dotsb@}% + \else % not macro starting \mathbin + \@xp\mathrel@\meaning@\mathrel@ + \ifgtest@ % if macro starts \mathrel + \gdef\thedots@{\dotsb@}% + \fi % endif macro starts \mathrel (no else) + \fi % endif macro starts \mathbin + \fi % endif macro starts with \mathxxx (no else) + \fi % endif macro starts \DOTS else + \fi % end macro starting \not \ifgtest@ test (no else) +% \end{macrocode} +% Additional test for a catcode 12 character. +% \begin{macrocode} + \else + \@xp\thecharacter@\meaning@\thecharacter@ +% \end{macrocode} +% \begin{macrocode} + \fi % end macro \ifgtest@ test (no else) + \fi % end if \Umathchar test + \fi % end \math@ \ifgtest@ + \fi % end \keybin@ \ifgtest@ test (no else) + \fi % end if \not (no else) + \fi % end if comma (no else) + \fi % end if boldsymbol (no else) + \thedots@} +% \end{macrocode} +% +% The \qc{\=} character is necessary in the two \cs{let} assignments +% in \cs{boldsymboldots@}, because the symbol we are making +% bold might be an \qc{\=} sign. +% \begin{macrocode} +\def\boldsymboldots@#1{% + \bold@true\let\@let@token=#1\let\delayed@=#1\mdots@@ + \boldsymbol#1\bold@false} +% \end{macrocode} +% +% The definition of \cs{@cdots} is merely the \fn{plain.tex} +% definition of \cs{cdots}. +% \begin{macrocode} +\ams@def\@cdots{\mathinner{\cdotp\cdotp\cdotp}} +\newcommand{\dotsi}{\!\@cdots} +\let\dotsb@\@cdots +% \end{macrocode} +% +% If any new right delimiters are defined, they would need to be +% added to the definition of \cs{rightdelim@} in order for \cn{dots} +% to work properly in all cases. +% \begin{macrocode} +\def\rightdelim@{\gtest@true + \ifx\@let@token)\else + \ifx\@let@token]\else + \ifx\@let@token\rbrack\else + \ifx\@let@token\}\else + \ifx\@let@token\rbrace\else + \ifx\@let@token\rangle\else + \ifx\@let@token\rceil\else + \ifx\@let@token\rfloor\else + \ifx\@let@token\rgroup\else + \ifx\@let@token\rmoustache\else + \ifx\@let@token\right\else + \ifx\@let@token\bigr\else + \ifx\@let@token\biggr\else + \ifx\@let@token\Bigr\else + \ifx\@let@token\Biggr\else\gtest@false + \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi} +\def\extra@{% + \rightdelim@\ifgtest@ + \else\ifx\@let@token$\gtest@true + \else\xdef\meaning@{\meaning\@let@token..........}% + \@xp\macro@\meaning@\macro@\ifgtest@ + \@xp\DOTS@\meaning@\DOTS@ + \ifgtest@ + \ifnum\DOTSCASE@=\tw@\gtest@true\else\gtest@false + \fi\fi\fi\fi\fi} +\newif\ifbold@ +\def\dotso@{\relaxnext@ + \ifbold@ + \let\@let@token\delayed@ + \def\nextii@{\extra@\@ldots\ifgtest@\,\fi}% + \else + \def\nextii@{\DN@{\extra@\@ldots\ifgtest@\,\fi}\FN@\next@}% + \fi + \nextii@} +% \end{macrocode} +% Why not save some tokens? (space vs. time). +% \begin{macrocode} +\def\extrap@#1{% + \DN@{#1\,}% + \ifx\@let@token,\else + \ifx\@let@token;\else + \ifx\@let@token.\else\extra@ + \ifgtest@\else + \let\next@#1\fi\fi\fi\fi\next@} +% \end{macrocode} +% +% \begin{macro}{\cdots} +% \begin{macro}{\dotsb} +% \begin{macro}{\dotsm} +% \begin{macro}{\dotso} +% \begin{macro}{\dotsc} +% The \cn{cdots} command. +% \begin{macrocode} +\ams@DeclareRobustCommand{\cdots}{\DN@{\extrap@\@cdots}\FN@\next@} +\let\dotsb\cdots +\let\dotsm\cdots +\DeclareRobustCommand{\dotso}{\relax + \ifmmode \DN@{\extrap@\@ldots}% + \else \let\next@\tdots@\fi + \FN@\next@} +\DeclareRobustCommand{\dotsc}{% + \DN@{\ifx\@let@token;\@ldots\,% + \else \ifx\@let@token.\@ldots\,% + \else \extra@\@ldots \ifgtest@\,\fi + \fi\fi}% + \FN@\next@} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \begin{macro}{\longrightarrow} +% \begin{macro}{\Longrightarrow} +% \begin{macro}{\longleftarrow} +% \begin{macro}{\Longleftarrow} +% \begin{macro}{\longleftrightarrow} +% \begin{macro}{\Longleftrightarrow} +% \begin{macro}{\mapsto} +% \begin{macro}{\longmapsto} +% \begin{macro}{\hookrightarrow} +% \begin{macro}{\hookleftarrow} +% \begin{macro}{\iff} +% Various arrows. +% \begin{macrocode} +\renewcommand{\longrightarrow}{% + \DOTSB\protect\relbar\protect\joinrel\rightarrow} +\renewcommand{\Longrightarrow}{% + \DOTSB\protect\Relbar\protect\joinrel\Rightarrow} +\renewcommand{\longleftarrow}{% + \DOTSB\leftarrow\protect\joinrel\protect\relbar} +\renewcommand{\Longleftarrow}{% + \DOTSB\Leftarrow\protect\joinrel\protect\Relbar} +\renewcommand{\longleftrightarrow}{\DOTSB\leftarrow\joinrel\rightarrow} +\renewcommand{\Longleftrightarrow}{\DOTSB\Leftarrow\joinrel\Rightarrow} +\renewcommand{\mapsto}{\DOTSB\mapstochar\rightarrow} +\renewcommand{\longmapsto}{\DOTSB\mapstochar\longrightarrow} +\renewcommand{\hookrightarrow}{\DOTSB\lhook\joinrel\rightarrow} +\renewcommand{\hookleftarrow}{\DOTSB\leftarrow\joinrel\rhook} +\renewcommand{\iff}{\DOTSB\;\Longleftrightarrow\;} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \begin{macro}{\doteq} +% The \cn{doteq} command formerly used \cs{buildrel}; we avoid that +% because it requires `\cn{over}' as part of its syntax. Use 0pt +% instead of \cs{z@} for robustitude. +% \begin{macrocode} +\renewcommand{\doteq}{% + \DOTSB\mathrel{\mathop{\kern0pt =}\limits^{\textstyle.}}} +% \end{macrocode} +% \end{macro} +% +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% \section{Integral signs} +% +% \begin{macro}{\if@display} +% The straightforward \cs{ifinner} test to see if the current math +% context is non-display, fails if, for instance, we are typesetting +% a multiline display within an \cs{halign}, with the pieces going +% into constructions like +% \begin{verbatim} +% $\displaystyle...$ +% \end{verbatim} +% So we need a better test to find out if we are `in a display'. We +% therefore create \cs{if@display}. +% +% \begin{macrocode} +\newif\if@display +\everydisplay\@xp{\the\everydisplay \@displaytrue} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\int} +% \begin{macro}{\oint} +% \begin{macro}{\iint} +% \begin{macro}{\iiint} +% \begin{macro}{\iiiint} +% \begin{macro}{\idotsint} +% Default value for integral limits is \cs{nolimits}, see the +% definition of the `nointlimits' option. +% \begin{macrocode} +\renewcommand{\int}{\DOTSI\intop\ilimits@} +\renewcommand{\oint}{\DOTSI\ointop\ilimits@} +\def\intkern@{\mkern-6mu\mathchoice{\mkern-3mu}{}{}{}} +\def\intdots@{\mathchoice{\@cdots}% + {{\cdotp}\mkern1.5mu{\cdotp}\mkern1.5mu{\cdotp}}% + {{\cdotp}\mkern1mu{\cdotp}\mkern1mu{\cdotp}}% + {{\cdotp}\mkern1mu{\cdotp}\mkern1mu{\cdotp}}} +% +\ams@newcommand{\iint}{\DOTSI\protect\MultiIntegral{2}} +\ams@newcommand{\iiint}{\DOTSI\protect\MultiIntegral{3}} +\ams@newcommand{\iiiint}{\DOTSI\protect\MultiIntegral{4}} +\newcommand{\idotsint}{\DOTSI\protect\MultiIntegral{0}} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\MultiIntegral} +% If the \cs{limits} option is applied, use \cs{mathop} and fudge +% the left-hand space a bit to make the subscript visually centered. +% +% \verb'#1' is the multiplicity. +% \begin{macrocode} +\newcommand{\MultiIntegral}[1]{% + \edef\ints@c{\noexpand\intop + \ifnum#1=\z@\noexpand\intdots@\else\noexpand\intkern@\fi + \ifnum#1>\tw@\noexpand\intop\noexpand\intkern@\fi + \ifnum#1>\thr@@\noexpand\intop\noexpand\intkern@\fi + \noexpand\intop + \noexpand\ilimits@ + }% + \futurelet\@let@token\ints@a +} +% \end{macrocode} +% \end{macro} +% +% \begin{macrocode} +\def\ints@a{% + \ifx\limits\@let@token \ints@b + \else \ifx\displaylimits\@let@token \ints@b + \else\ifx\ilimits@\displaylimits \ints@b + \fi\fi\fi + \ints@c +} +% \end{macrocode} +% +% \begin{macrocode} +\def\ints@b{% + \mkern-7mu\mathchoice{\mkern-2mu}{}{}{}% + \mathop\bgroup + \mkern7mu\mathchoice{\mkern2mu}{}{}{}% + \let\ilimits@\egroup +}% +% \end{macrocode} +% +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% \section{Size dependent definitions} +% +% We now define all stuff which has to change whenever a new math +% size is to be activated. \latex/ provides a hook called +% |\every@math@size| to support such a need. All assignments in the +% |\every@math@size| hook that need to take outside effect should be +% global. +% +% \subsection{Struts for math} +% +% The various kinds of struts could use some analysis and perhaps +% consolidation. +% +% For example perhaps the \cn{bBigg} delimiters could use +% \begin{verbatim} +% 1.2\ht\strutbox (1.8, 2.4, 3.0) +% \end{verbatim} +% instead of +% \begin{verbatim} +% 1.0\big@size (1.5, 2.0, 2.5) +% \end{verbatim} +% since \cs{strut} is reset with every size change [mjd, 1994/10/07]. +% But this change would introduce the possibility of changed line +% and page breaks in existing documents, so would need to be +% handled with care. +% +% \begin{macro}{\Mathstrut@} +% \begin{macro}{\Mathstrutbox@} +% \begin{macro}{\resetMathstrut@} +% Here comes the code for Spivak's |\Mathstrut@|. +% \begin{macrocode} +\newbox\Mathstrutbox@ +\setbox\Mathstrutbox@=\hbox{} +\def\Mathstrut@{\copy\Mathstrutbox@} +% \end{macrocode} +% The setting of the height and depth of the |\Mathstrutbox@| is done +% in the |\every@math@size| hook since it depends on the height of a +% paren. As \cs{every@math@size} is triggered by |$| after a font +% size change, we want to avoid using another math formula |$...$| to +% measure the math paren height; instead we go through the mathcode +% of the \qc{\(} character. We assume that the mathcode has a leading +% hex digit 4 indicating `open delimiter'; this allows us to make a +% relatively simple function to get the correct font and character +% position. +% +% \changes{v2.15}{2016/02/20}{Modify \cs{resetMathstrut@} for Unicode \TeX} +% \changes{v2.15b}{2016/03/10}{Modify \cs{resetMathstrut@} for classic \TeX\ to preserve box 0} +% Original code assuming |\mathcode| is kept for 8bit \TeX. Unicode \TeX{} +% uses |\Umathcharnumdef| which works for xetex and luatex, which use +% different forms for |\mathchardef|. (New luatex always reports +% definitions using |\Umathchardef| syntax even if |\mathchardef| used.) +% +% The unicode version uses e-tex |\fontcharht| to avoid boxing which +% could also be done for pdftex, but not done here. +% \begin{macrocode} +\ifx\Umathcharnumdef\@undefined +% \end{macrocode} +% Original code +% \begin{macrocode} +\def\resetMathstrut@{% + \begingroup + \setbox\z@\hbox{% + \mathchardef\@tempa\mathcode`\(\relax + \def\@tempb##1"##2##3{\the\textfont"##3\char"}% + \expandafter\@tempb\meaning\@tempa \relax + }% + \edef\@tempa{% + \ht\Mathstrutbox@\the\ht\z@\relax + \dp\Mathstrutbox@\the\dp\z@\relax}% + \expandafter\endgroup\@tempa +} +\else +% \end{macrocode} +% xetex/luatex version +% \changes{v2.15a}{2016/03/03}{missing percent added} +% \begin{macrocode} +\def\resetMathstrut@{% + \begingroup + \Umathcharnumdef\@tempa\Umathcodenum`\(\relax + \def\@tempb##1"##2"##3"##4\relax{% + \endgroup + \ht\Mathstrutbox@=\fontcharht\textfont"##3 "##4\relax + \dp\Mathstrutbox@=\fontchardp\textfont"##3 "##4\relax}% + \expandafter\@tempb\meaning\@tempa \relax +} +% \end{macrocode} +% \begin{macrocode} +\fi +% \end{macrocode} +% These height and depth assignments are implicitly global. +% \begin{macrocode} +\addto@hook\every@math@size{\resetMathstrut@} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\strut@} +% \begin{macro}{\strutbox@} +% Next follows a special internal strut which is supposed to match +% the height and the depth of a normal |\strut| minus +% |\normallineskiplimit| according to M. Spivak. +% +% This should really go into the definition of \cs{size@update}, and +% then the box reset could be local; but \cs{size@update} doesn't +% have any hook and is handled in such a way that it cannot even be +% changed except by changing \cs{set@fontsize}. So instead we put +% \cs{reset@strutbox@} into \cs{every@math@size} and make it global. +% Then because of some complications in the way \cs{glb@settings} and +% \cs{check@mathfonts} work, we have to re-invoke it at the beginning +% of every environment that might use \cs{strut@}. Fortunately this +% can be achieved (more or less) through the \cs{spread@equation} +% hook. [mjd,2000/03/10] +% \begin{macrocode} +\newbox\strutbox@ +\def\strut@{\copy\strutbox@} +\def\reset@strutbox@{% + \global\setbox\strutbox@\hbox{% + \lower.5\normallineskiplimit + \vbox{\kern-\normallineskiplimit\copy\strutbox}}} +\addto@hook\every@math@size{\reset@strutbox@} +\AtBeginDocument{\reset@strutbox@} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \subsection{Big delimiters} +% +% We are now going to redefine the plain \tex/ commands \cn{big}, +% \cn{bigl}, etc., to produce different results in different sizes. +% Actually we only have to define \cn{big}, \cn{Big}, etc., since +% they are used to construct the directional versions \cn{bigl}, +% \cn{bigr}, and the rest. +% +% \begin{macro}{\big} +% \begin{macro}{\Big} +% \begin{macro}{\bigg} +% \begin{macro}{\Bigg} +% To save token space we put everything into the common macro +% |\bBigg@|. The macros are now simply a call to |\bBigg@| with a +% factor to determine the correct height of the delimiter as an +% argument. This code should better go into a future version of +% the \latex/ kernel; the macro |\n@space| is then superfluous (since +% it is only used once) and should be removed to avoid wasting hash +% table space unnecessarily. +% \begin{macrocode} +\renewcommand{\big}{\bBigg@\@ne} +\renewcommand{\Big}{\bBigg@{1.5}} +\renewcommand{\bigg}{\bBigg@\tw@} +\renewcommand{\Bigg}{\bBigg@{2.5}} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\bBigg@} +% Now we tackle the macro which has to do the real work. It +% actually has two arguments, the factor and the wanted delimiter. +% \changes{v2.17b}{2018/12/01}{Start LR-mode for \cs{bigl} and +% friends if necessary (github/49)} +% \begin{macrocode} +\ifx\leavevmode@ifvmode\@undefined +\def\bBigg@#1#2{% +% \end{macrocode} +% We start with an extra set of braces because we want +% constructions like |\def\bigl{\mathopen\big}| to work without the +% overhead of extra arguments. +% \begin{macrocode} + {\@mathmeasure\z@{\nulldelimiterspace\z@}% + {\left#2\vcenter to#1\big@size{}\right.}% + \box\z@}} +\else +\def\bBigg@#1#2{\leavevmode@ifvmode + {\@mathmeasure\z@{\nulldelimiterspace\z@}% + {\left#2\vcenter to#1\big@size{}\right.}% + \box\z@}} +\fi +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\big@size} +% |\big@size| needs to be set to 1.2 times the height of a math +% paren. This height is already recorded in |\Mathstrutbox@|. +% \begin{macrocode} +\addto@hook\every@math@size{% + \global\big@size 1.2\ht\Mathstrutbox@ + \global\advance\big@size 1.2\dp\Mathstrutbox@ } +\newdimen\big@size +% \end{macrocode} +% \end{macro} +% +% +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% \section{Math accents} +% +% We want to change the leading digit of math accents to be +% \cs{accentclass@} so that it can vary according to certain internal +% purposes. +% \begin{macrocode} +\def\accentclass@{7} +\def\noaccents@{\def\accentclass@{0}} +% \end{macrocode} +% +% There are a few \meta{math alphabet}s in the standard fonts where +% we have to change the extra macros because the standard definitions +% don't account for these accent problems. The first is for the +% \cs{mathit} command. +% \begin{macrocode} +\DeclareFontEncoding{OML}{}{\noaccents@} +% \end{macrocode} +% The next one corrects the \cs{cal} alphabet. +% \begin{macrocode} +\DeclareFontEncoding{OMS}{}{\noaccents@} +% \end{macrocode} +% +% \begin{macro}{\dddot} +% \begin{macro}{\ddddot} +% Triple and quadruple dot accents. +% \begin{macrocode} +\ams@newcommand{\dddot}[1]{% + {\mathop{#1}\limits^{\vbox to-1.4\ex@{\kern-\tw@\ex@ + \hbox{\normalfont ...}\vss}}}} +\ams@newcommand{\ddddot}[1]{% + {\mathop{#1}\limits^{\vbox to-1.4\ex@{\kern-\tw@\ex@ + \hbox{\normalfont....}\vss}}}} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% The following code deals with support for compound accents. +% By redefining \cs{set@mathaccent} we ensure that +% \cn{DeclareMathAccent} will define accent commands to run our +% \cs{mathaccentV} function instead of the primitive \cs{mathaccent}. +% \begin{macrocode} +\def\set@mathaccent#1#2#3#4{% + \xdef#2{\@nx\protect\@nx\mathaccentV + {\@xp\@gobble\string#2}\hexnumber@#1#4}% +} +% \end{macrocode} +% +% \begin{macro}{\hat} +% \begin{macro}{\check} +% \begin{macro}{\tilde} +% \begin{macro}{\acute} +% \begin{macro}{\grave} +% \begin{macro}{\dot} +% \begin{macro}{\ddot} +% \begin{macro}{\breve} +% \begin{macro}{\bar} +% \begin{macro}{\vec} +% \begin{macro}{\mathring} +% We redefine the standard math accent commands to +% call \cs{mathaccentV}, using the mathgroup/encoding-number +% information embedded in their previous definitions. If the +% definition of an accent command does not have the expected form, we +% leave the accent command alone, but give a warning. For widehat and +% widetilde, we need to avoid clobbering the definitions done by the +% \pkg{amsfonts} package. Arbitrating the contention between +% \pkg{amsmath} and \pkg{amsfonts} to allow doubling a widetilde +% accent looks tricky, so for the time being [mjd,1999/07/19] we just +% leave \cn{widehat} and \cn{widetilde} alone. As a result, if the +% \pkg{amsmath} package is loaded on top of a vanilla \latex/ +% documentclass, everything runs through with no warnings. If a +% Lucida Math or other math fonts package is loaded in addition to +% \pkg{amsmath}, there are greater difficulties, but those are +% addressed elsewhere. +% +% +% \changes{v2.15}{2016/02/20}{Detect \cs{Umathaccent} on package load} +% Adjust the test made at package load to recognise +% |\Umathaccent|. Although currently it is just used to give a +% modified warning that the accents will not be redefined. +% +% Note that the engines behave quite differently here, luatex +% even without these definitions using the OpenType accent set up by +% unicode-math stacks |\hat{hat{f}}| correctly but xetex acts like +% classic tex and needs this adjustment. This difference is not +% addressed here at all. +% +% This test is just at package loading and has no affect on the +% definitions used in 8bit TeX. +% \begin{macrocode} +%\def\@tempa#1{\@xp\@tempb\meaning#1\@nil#1} +% \end{macrocode} +% The extended definition below tests if the accent is already +% robust (as newer \LaTeX{} kernels do this by default) and if so +% picks up the robust definition. However, as of +% now it still redefines it to be non-robust. +% \begin{macrocode} +\def\@tempa#1{% + \@ifundefined{\@xp\@gobble\string#1\space}% + {\@xp\@tempb\meaning#1\@nil#1}% + {\@xp\@xp\@xp\@tempb\@xp\meaning + \csname\@xp\@gobble\string#1\space\endcsname\@nil#1}% +} +\def\@tempb#1>#2#3 #4\@nil#5{% + \@xp\ifx\csname#3\endcsname\mathaccent + \@tempc#4?"7777\@nil#5% + \else + \@xp\ifx\csname#3\endcsname\Umathaccent + \@tempd#4\@nil#5% + \else + \PackageWarningNoLine{amsmath}{% + Unable to redefine math accent \string#5}% + \fi\fi} +\def\@tempc#1"#2#3#4#5#6\@nil#7{% + \chardef\@tempd="#3\relax\set@mathaccent\@tempd{#7}{#2}{#4#5}} +\def\@tempd#1\@nil#2{% + \PackageWarningNoLine{amsmath}{% + Unable to redefine \string\Umathaccent\space\string#2}% +} +% \end{macrocode} +% \begin{macrocode} +\@tempa{\hat} +\@tempa{\check} +\@tempa{\tilde} +\@tempa{\acute} +\@tempa{\grave} +\@tempa{\dot} +\@tempa{\ddot} +\@tempa{\breve} +\@tempa{\bar} +\@tempa{\vec} +\@ifundefined{mathring}{% + \DeclareMathAccent{\mathring}{\mathalpha}{operators}{"17} +}{% + \@tempa{\mathring} +} +%%\@tempa\widetilde +%%\@tempa\widehat +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% +% Regression testing of amsmath 2.0 showed that in some documents +% there occurred fragments of the form +% \begin{verbatim} +% \hat\mathcal{G} +% \end{verbatim} +% This is not at all correct syntax for the argument of a \latex/ +% command but it produced the intended result anyway because of the +% internal syntax of the \cs{mathaccent} primitive. With +% \cs{mathaccentV}, it will yield an error message. We therefore do a +% special check for such syntax problems in order to make the error +% message more informative. (dmj: ??????) +% \begin{macrocode} +\newcommand{\acc@check}{} +\newcommand{\acc@error}{} +\def\acc@check{\@ifnextchar\@empty\relax\acc@error} +% \end{macrocode} +% We put most of the tokens in a separate macro so they do not get +% scanned unless they are actually needed. +% \begin{macrocode} +\def\acc@error{% + \@amsmath@err{% + Improper argument for math accent:\MessageBreak + Extra braces must be added to prevent wrong output% + }\@ehc +} +% \end{macrocode} +% +% For \cs{mathaccentV} part of the processing is dependent on the +% depth of nesting of math accent commands. We introduce a dedicated +% counter for this instead of using chardef because we want to +% increment/decrement it during processing, and incrementing a +% chardef integer is more work. +% \begin{macrocode} +\newcount\macc@depth +% \end{macrocode} +% +% Provide this function in case it is not already available. +% \begin{macrocode} +\long\def\@gobblethree#1#2#3{} +% \end{macrocode} +% +% The \cs{mathaccentV} function first counts the number of nested +% math accents by setting the argument in a throw-away box. (This is +% not as risky as such an operation would normally be because the +% argument is generally either a simple math symbol or a nested math +% accent call with a simple math symbol at the bottom of the +% nesting.) +% +% There are two benefits from counting the nesting levels first +% before doing anything else: (1) we can fall back to a simple +% \cs{mathaccent} call if the nesting depth is 1, and (2) if the +% nesting depth is greater than 1, we would like to be able to tell +% when we have reached the lowest level, because at that point we +% want to save the argument for later use and place an accent on top +% of a phantom copy. +% +% When we have multiple accents, they will be placed on top of the +% invisible box, followed by some suitable kerns, then a visible copy +% of the nucleus. To see why, let us look at what goes wrong with a +% double application of the \cs{mathaccent} primitive. The standard +% definition of \cs{hat} is \verb'\mathaccent"705E', so +% \verb'\hat{\hat{F}}' expands to +%\begin{verbatim} +%\mathaccent"705E{\mathaccent"705E{F}} +%\end{verbatim} +% The result of this operation is +%\begin{verbatim} +%\vbox(12.11111+0.0)x7.81946 +%.\hbox(6.94444+0.0)x0.0, shifted 1.40973 +%..\OT1/cmr/m/n/10 ^ +%.\kern-4.30554 +%.\vbox(9.47221+0.0)x7.81946 +%..\hbox(6.94444+0.0)x0.0, shifted 2.24309 +%...\OT1/cmr/m/n/10 ^ +%..\kern-4.30554 +%..\hbox(6.83331+0.0)x7.81946 +%...\OML/cmm/m/it/10 F +%\end{verbatim} +% \tex/ starts by constructing a vbox with the hat character on top +% of the F. Then it puts another hat character on top of the vbox; +% but without skew information, because that is only applied by +% \cs{mathaccent} when the base object is a simple symbol. So the +% first accent is skewed to the correct position but all later +% accents are not. By the way, the actual width of the F in the above +% example is less than 7.81946; the box in which it is packed was +% automatically lengthened by the width of the F's italic correction +% (without actually putting in a kern for it). +% +% To get the second accent shifted farther to the right we +% artificially increase the width of the innermost box and add +% a compensating kern afterward. Furthermore, to get proper placement +% of a following subscript or superscript, we take the base symbol +% out, leaving a phantom in its place, and print it by itself +% following the kern. We then need to increase the kern amount to +% move the base character backward under the accents again. +% Here is what the results look like: +%\begin{verbatim} +%\vbox(12.11111+0.0)x9.48618 +%.\hbox(6.94444+0.0)x0.0, shifted 2.24309 +%..\OT1/cmr/m/n/10 ^ +%.\kern-4.30554 +%.\vbox(9.47221+0.0)x9.48618 +%..\hbox(6.94444+0.0)x0.0, shifted 2.24309 +%...\OT1/cmr/m/n/10 ^ +%..\kern-4.30554 +%..\hbox(6.83331+0.0)x9.48618 +%...\hbox(6.83331+0.0)x7.81946 +%...\kern 1.66672 +%\kern -9.48618 +%\OML/cmm/m/it/10 F +%\end{verbatim} +% +% Much of this implementation is based on code from the \pkg{accents} +% package of Javier Bezos. I added the test to revert to a simple +% \cs{mathaccent} when accents are not nested, and some other +% refinements to reduce the number of kerns used (to conserve box +% memory) and the number of cycles through \cs{mathchoice} (to make +% things run a little faster). It was all rather difficult and my +% first two attempts had serious bugs but I hope and believe that +% this version will do better. [mjd,2000/03/15] +% +% The \qq{V} in \cs{mathaccentV} is just an indication that it takes +% five arguments. It is important that the name includes +% \texttt{mathaccent}, otherwise \cs{DeclareMathAccent} will balk at +% redefining one of our accent commands, for example when an +% alternative math font package is loaded. +% \begin{macrocode} +\def\mathaccentV#1#2#3#4#5{% + \ifmmode + \gdef\macc@tmp{\macc@depth\@ne}% + \setbox\z@\hbox{% + \let\mathaccentV\macc@test + \let\use@mathgroup\@gobbletwo \let\select@group\@gobblethree + \frozen@everymath{}$#5$% + }% + \macc@tmp + \ifnum\macc@depth=\@ne + \global\let\macc@nucleus\@empty + \mathaccent"\accentclass@ + \else + \@xp\macc@nested + \fi + #2#3#4{#5}% + \macc@nucleus + \else + \@xp\nonmatherr@\csname#1\endcsname + \fi +} +% \end{macrocode} +% +% \begin{macrocode} +\def\macc@test#1#2#3#4{\xdef\macc@tmp{\macc@tmp\advance\macc@depth\@ne}} +% \end{macrocode} +% +% \begin{macrocode} +\def\macc@group{-1} +% \end{macrocode} +% +% \begin{macrocode} +\def\macc@nested#1#2#3#4{% + \begingroup + \let\math@bgroup\@empty \let\math@egroup\macc@set@skewchar + \mathsurround\z@ \frozen@everymath{\mathgroup\macc@group\relax}% + \macc@set@skewchar\relax + \let\mathaccentV\macc@nested@a + \macc@nested@a\relax#1#2#3{#4}% + \endgroup +} +% \end{macrocode} +% +% \begin{macrocode} +\let\macc@palette\mathpalette +% \end{macrocode} +% +% \begin{macrocode} +\def\macc@nested@a#1#2#3#4#5{% +% \end{macrocode} +% This test saves some work that would otherwise be always repeated +% fourfold thanks to \cs{mathchoice}. +% \begin{macrocode} + \ifnum\macc@group=\mathgroup + \else \macc@set@skewchar\relax \edef\macc@group{\the\mathgroup}% + \fi + \mathchardef\macc@code "\accentclass@ #2#3#4\relax + \macc@palette\macc@a{#5}% +} +% \end{macrocode} +% +% The reason that \cs{macc@set@skewchar} takes an argument is so that +% it can serve as a direct substitute for \cs{math@egroup}, in +% addition to being used separately. +% +% Setting a skewchar with this method works for symbols of variable +% mathgroup (class 7, letters and numbers) but not necessarily for +% special symbols like \cn{partial} or \cs{xi} whose mathgroup +% doesn't change; fortunately the most commonly used ones come from +% mathgroup one, which is the fall-back mathgroup for skewchar. +% \begin{macrocode} +\def\macc@set@skewchar#1{% + \begingroup + \ifnum\mathgroup=\m@ne \let\@tempa\@ne + \else + \ifnum\skewchar\textfont\mathgroup=\m@ne \let\@tempa\@ne + \else \let\@tempa\mathgroup + \fi + \fi + \count@=\skewchar\textfont\@tempa + \advance\count@"7100 + \edef\@tempa{\endgroup + \mathchardef\noexpand\macc@skewchar=\number\count@\relax}% + \@tempa + #1% +} +% \end{macrocode} +% +% Arg1 is math-style, arg2 is accent base object. We assume that math +% style doesn't change within the nested group of accents; this means +% we can set \cs{macc@style} only once and redefine \cs{macc@palette} +% to use it, in order to run \cs{mathchoice} only once instead of +% multiplying the calls exponentially as the nesting level increases. +% \begin{macrocode} +\def\macc@a#1#2{% + \begingroup + \let\macc@style#1\relax + \def\macc@palette##1{##1\macc@style}% + \advance\macc@depth\m@ne + \ifnum\macc@depth=\z@ + \gdef\macc@nucleus{#2}% +% \end{macrocode} +% Extra \cs{@empty} tokens are to prevent low-level \tex/ errors from +% the potential syntactic error that \cs{acc@check} checks for. +% \begin{macrocode} + \setbox\z@\hbox{$#1#2\@empty{}\macc@skewchar$}% + \setbox\tw@\hbox{$#1#2\@empty\macc@skewchar$}% + \dimen@\tw@\wd\tw@ \advance\dimen@-\tw@\wd\z@ + \xdef\macc@kerna{\the\dimen@\relax}% + \setbox4\hbox{$#1#2\acc@check\@empty$}% + \global\setbox\@ne\hbox to\wd4{}% + \ht\@ne\ht4 \dp\@ne\dp4 + \xdef\macc@kernb{\the\wd4\relax}% + \mathaccent\macc@code{\box\@ne\kern\macc@kerna}% + \else + \mathaccent\macc@code{\let\macc@adjust\@empty #1#2\@empty}% + \macc@adjust + \fi + \endgroup +} +% \end{macrocode} +% +% \begin{macrocode} +\def\macc@adjust{% + \dimen@\macc@kerna\advance\dimen@\macc@kernb + \kern-\dimen@ +} +% \end{macrocode} +% +% The commands \cs{Hat}, \cs{Tilde}, \ldots, are supported as +% synonyms of \cs{hat}, \cs{tilde}, \ldots, for backward +% compatibility. +% \begin{macrocode} +\def\Hat{\hat} +\def\Check{\check} +\def\Tilde{\tilde} +\def\Acute{\acute} +\def\Grave{\grave} +\def\Dot{\dot} +\def\Ddot{\ddot} +\def\Breve{\breve} +\def\Bar{\bar} +\def\Vec{\vec} +% \end{macrocode} +% +% This error message about math mode is used several times so we make +% an abbreviation for it. +% \begin{macrocode} +\def\nonmatherr@#1{\@amsmath@err{\protect + #1 allowed only in math mode}\@ehd} +% \end{macrocode} +% +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% \section{Mods, continued fractions, etc.} +% +% \begin{macro}{\bmod} +% \begin{macro}{\pmod} +% \begin{macro}{\pod} +% \begin{macro}{\mod} +% The commands \cn{bmod}, \cn{pmod}, \cn{pod}, \cn{mod} aren't +% currently robust. [mjd, 1994/09/05] +% \begin{macrocode} +\renewcommand{\bmod}{\nonscript\mskip-\medmuskip\mkern5mu\mathbin + {\operator@font mod}\penalty900 + \mkern5mu\nonscript\mskip-\medmuskip} +\newcommand{\pod}[1]{\allowbreak + \if@display\mkern18mu\else\mkern8mu\fi(#1)} +\renewcommand{\pmod}[1]{\pod{{\operator@font mod}\mkern6mu#1}} +\newcommand{\mod}[1]{\allowbreak\if@display\mkern18mu + \else\mkern12mu\fi{\operator@font mod}\,\,#1} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\cfrac} +% Continued fractions. The optional arg l or r controls horizontal +% placement of the numerators. The |\kern-\nulldelimiterspace| +% is needed in the definition if we want the right-hand sides of the +% fraction rules to line up. The \cs{strut} keeps the numerator of +% a subsidiary cfrac from coming too close to the fraction rule above +% it. +% \begin{macrocode} +\newcommand{\cfrac}[3][c]{{\displaystyle\frac{% + \strut\ifx r#1\hfill\fi#2\ifx l#1\hfill\fi}{#3}}% + \kern-\nulldelimiterspace} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\overset} +% \begin{macro}{\underset} +% \cn{overset} and \cn{underset} put symbols above, respectively +% below, a symbol that is not a \cs{mathop} and therefore does not +% naturally accept limits. \cs{binrel@@} uses information collected +% by \cs{binrel@} to make the resulting construction be of type +% mathrel or mathbin if the base symbol is either of those types. +% \begin{macrocode} +\newcommand{\overset}[2]{\binrel@{#2}% + \binrel@@{\mathop{\kern\z@#2}\limits^{#1}}} +% \end{macrocode} +% +% \begin{macrocode} +\newcommand{\underset}[2]{\binrel@{#2}% + \binrel@@{\mathop{\kern\z@#2}\limits_{#1}}} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% +% \begin{macro}{\overunderset} +% This is the combination of the previous two commands which is +% something that is sometimes needed. +% \changes{v2.17c}{FMi}{New command \cs{overunderset}} +% \begin{macrocode} +\newcommand{\overunderset}[3]{\binrel@{#3}% + \binrel@@{\mathop{\kern\z@#3}\limits^{#1}_{#2}}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\sideset} +% \cn{sideset} allows placing `adscript' symbols at the four +% corners of a \cs{mathop}, \emph{in addition to} limits. Left-side +% adscripts go into arg \arg{1}, in the form |_{...}^{...}|, and +% right-side adscripts go into arg \arg{2}. +% +% As currently written [mjd, 1995/01/21] this is pretty haphazard. +% In order to really make it work properly in full generality we'd +% have to read and measure the top and bottom limits and use +% mathchoice to always get the right mathstyle for each piece, +% etc., etc. +% \begin{macrocode} +\newcommand{\sideset}[3]{% + \@mathmeasure\z@\displaystyle{#3}% +% \end{macrocode} +% Use a global box assignment here since the depth override is +% implicitly global. Then move the constructed box to a local box +% register (2) to ensure it won't get destroyed during the next two +% mathmeasure statements. This precaution may be more extreme than +% necessary in practice. +% \begin{macrocode} + \global\setbox\@ne\vbox to\ht\z@{}\dp\@ne\dp\z@ + \setbox\tw@\box\@ne + \@mathmeasure4\displaystyle{\copy\tw@#1}% + \@mathmeasure6\displaystyle{#3\nolimits#2}% + \dimen@-\wd6 \advance\dimen@\wd4 \advance\dimen@\wd\z@ + \hbox to\dimen@{}\mathop{\kern-\dimen@\box4\box6}% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\smash} +% We add to the \cn{smash} command an optional argument +% denoting the part of the formula to be smashed. +% \changes{v2.17b}{2018/12/01}{Start LR-mode for \cs{smash} +% if necessary (github/49)} +% \begin{macrocode} +\ifx\leavevmode@ifvmode\@undefined +\renewcommand{\smash}[1][tb]{% + \def\mb@t{\ht}\def\mb@b{\dp}\def\mb@tb{\ht\z@\z@\dp}% + \edef\finsm@sh{\csname mb@#1\endcsname\z@\z@\box\z@}% + \ifmmode \@xp\mathpalette\@xp\mathsm@sh + \else \@xp\makesm@sh + \fi +} +\else +\renewcommand{\smash}[1][tb]{% + \def\mb@t{\ht}\def\mb@b{\dp}\def\mb@tb{\ht\z@\z@\dp}% + \edef\finsm@sh{\csname mb@#1\endcsname\z@\z@ \leavevmode@ifvmode\box\z@}% + \ifmmode \@xp\mathpalette\@xp\mathsm@sh + \else \@xp\makesm@sh + \fi +} +\fi +% \end{macrocode} +% \end{macro} +% +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% \section{Extensible arrows} +% +% The minus sign used in constructing these arrow fills is smashed so +% that superscripts above the arrows won't be too high. This +% primarily affects the \cn{xleftarrow} and \cn{xrightarrow} arrows. +% +% \begin{macrocode} +\mathchardef\std@minus\mathcode`\-\relax +\mathchardef\std@equal\mathcode`\=\relax +% \end{macrocode} +% In case some alternative math fonts are loaded later: +% \begin{macrocode} +\AtBeginDocument{% + \mathchardef\std@minus\mathcode`\-\relax + \mathchardef\std@equal\mathcode`\=\relax +} +% \end{macrocode} +% +% \begin{macro}{\relbar} +% \begin{macro}{\Relbar} +% \begin{macrocode} +\ams@def\relbar{\mathrel{\mathpalette\mathsm@sh\std@minus}} +\ams@def\Relbar{\mathrel\std@equal} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macrocode} +\def\arrowfill@#1#2#3#4{% + $\m@th\thickmuskip0mu\medmuskip\thickmuskip\thinmuskip\thickmuskip + \relax#4#1\mkern-7mu% + \cleaders\hbox{$#4\mkern-2mu#2\mkern-2mu$}\hfill + \mkern-7mu#3$% +} +\def\leftarrowfill@{\arrowfill@\leftarrow\relbar\relbar} +\def\rightarrowfill@{\arrowfill@\relbar\relbar\rightarrow} +\def\leftrightarrowfill@{\arrowfill@\leftarrow\relbar\rightarrow} +\def\Leftarrowfill@{\arrowfill@\Leftarrow\Relbar\Relbar} +\def\Rightarrowfill@{\arrowfill@\Relbar\Relbar\Rightarrow} +\def\Leftrightarrowfill@{\arrowfill@\Leftarrow\Relbar\Rightarrow} +% \end{macrocode} +% +% \begin{macrocode} +\def\overarrow@#1#2#3{\vbox{\ialign{##\crcr#1#2\crcr + \noalign{\nointerlineskip}$\m@th\hfil#2#3\hfil$\crcr}}} +\ams@renewcommand{\overrightarrow}{% + \mathpalette{\overarrow@\rightarrowfill@}} +\ams@renewcommand{\overleftarrow}{% + \mathpalette{\overarrow@\leftarrowfill@}} +\ams@newcommand{\overleftrightarrow}{% + \mathpalette{\overarrow@\leftrightarrowfill@}} +% \end{macrocode} +% +% \begin{macrocode} +\def\underarrow@#1#2#3{% + \vtop{\ialign{##\crcr$\m@th\hfil#2#3\hfil$\crcr + \noalign{\nointerlineskip\kern1.3\ex@}#1#2\crcr}}} +\ams@newcommand{\underrightarrow}{% + \mathpalette{\underarrow@\rightarrowfill@}} +\ams@newcommand{\underleftarrow}{% + \mathpalette{\underarrow@\leftarrowfill@}} +\ams@newcommand{\underleftrightarrow}{% + \mathpalette{\underarrow@\leftrightarrowfill@}} +% \end{macrocode} +% +% \begin{macrocode} +%\newcommand{\xrightarrow}[2][]{\ext@arrow 0359\rightarrowfill@{#1}{#2}} +\def\ext@arrow#1#2#3#4#5#6#7{% + \mathrel{\mathop{% +% \end{macrocode} +% Measure the superscript and subscript. +% \begin{macrocode} + \setbox\z@\hbox{#5\displaystyle}% + \setbox\tw@\vbox{\m@th + \hbox{$\scriptstyle\mkern#3mu{#6}\mkern#4mu$}% + \hbox{$\scriptstyle\mkern#3mu{#7}\mkern#4mu$}% + \copy\z@ + }% + \hbox to\wd\tw@{\unhbox\z@}}% +% \end{macrocode} +% We don't want to place an empty subscript since that will produce +% too much blank space below the arrow. +% \begin{macrocode} + \limits + \@ifnotempty{#7}{^{\if0#1\else\mkern#1mu\fi + #7\if0#2\else\mkern#2mu\fi}}% + \@ifnotempty{#6}{_{\if0#1\else\mkern#1mu\fi + #6\if0#2\else\mkern#2mu\fi}}}% +} +% \end{macrocode} +% +% Some extensible arrows to serve as mathrels and taking +% sub/superscripts. These commands are robust because they take an +% optional argument. +% \begin{macrocode} +\newcommand{\xrightarrow}[2][]{\ext@arrow 0359\rightarrowfill@{#1}{#2}} +\newcommand{\xleftarrow}[2][]{\ext@arrow 3095\leftarrowfill@{#1}{#2}} +% \end{macrocode} +% +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% \section{Array-related environments} +% \subsection{Remarks} +% +% Because these environments can be nested within the equation +% structures that allow \cn{tag}, there is some cross-influence in +% the internal workings of the \cn{\\} command. +% +% \subsection{The \env{subarray} environment and \cn{substack} command} +% +% The \cn{substack} command can be used to set subscripts +% and superscripts that consist of several lines. Usage: +% \begin{verbatim} +% X_{\substack{a=1\\b=2}} +% \end{verbatim} +% +% \changes{v2.0}{1999/06/17}{Removed environment definitions: Sb, Sp} +% +% \begin{environment}{subarray} +% The \env{subarray} environment makes a small-size array suitable +% for use in a subscript or superscript. At the moment the supported +% arguments are not the full possibilities of \env{array} but only +% |c| or |l| for centered or left-aligned. And only one column. +% \begin{macrocode} +\newenvironment{subarray}[1]{% +% \end{macrocode} +% Note: The predecessors of \env{subarray} (\env{Sb} and \env{Sp}, +% inherited from \amstex/) used \cs{vbox} instead of \cs{vcenter}. +% But when a multiline subscript is placed in \cs{limits} position +% \cs{vcenter} is no worse than \cs{vbox}, and when it is placed +% in the \cs{nolimits} position (e.g., for an integral), \cs{vcenter} +% provides clearly better positioning than \cs{vbox}. +% \begin{macrocode} + \vcenter\bgroup +% \end{macrocode} +% Use \cs{Let@} to set the proper meaning of the \cn{\\} and \cn{\\*} +% commands. And restore the meaning of \cs{math@cr@@@} to \cs{cr} +% (see above) in case \env{subarray} is used inside one of the more +% complicated alignment macros where the meaning of \cs{math@cr@@@} +% is different. Similarly, call \cs{default@tag} to ensure that a +% line break here doesn't get an equation number! +% \begin{macrocode} + \Let@ \restore@math@cr \default@tag +% \end{macrocode} +% Set the line spacing to be the same as \cs{atop} (when \cs{atop} +% occurs in \cs{textstyle} or smaller), cf \textit{The \tex/book}, +% Appendix G. +% \begin{macrocode} + \baselineskip\fontdimen10 \scriptfont\tw@ + \advance\baselineskip\fontdimen12 \scriptfont\tw@ + \lineskip\thr@@\fontdimen8 \scriptfont\thr@@ + \lineskiplimit\lineskip +% \end{macrocode} +% Start the \cs{vbox} \cs{halign} structure that encloses the +% contents. Notice that we never get \cs{scriptscriptstyle}. That +% would require a \cs{mathchoice} (ugh). +% \begin{macrocode} + \ialign\bgroup\ifx c#1\hfil\fi + $\m@th\scriptstyle##$\hfil\crcr +}{% + \crcr\egroup\egroup +} +% \end{macrocode} +% \end{environment} +% +% \begin{macro}{\substack} +% The \cn{substack} command is just an abbreviation for the +% most common use of \env{subarray}. +% \begin{macrocode} +\newcommand{\substack}[1]{\subarray{c}#1\endsubarray} +% \end{macrocode} +% \end{macro} +% +% \subsection{Matrices} +% +% \begin{environment}{smallmatrix} +% \env{smallmatrix} is again an alignment, this time in a centered +% box. The opening incantations are basically the same as those in +% \cs{multilimits@}, followed by the alignment itself. A remark: +% the baselineskip (|9\ex@|) used in \amstex/ is too large for +% use in text with the usual baselineskip of $12$ or $13$ points; we +% change it here to |6\ex@| and also adjust the \cs{lineskip} +% and \cs{lineskiplimit} slightly to compensate. (MJD) +% \begin{macrocode} +\newenvironment{smallmatrix}{\null\,\vcenter\bgroup + \Let@\restore@math@cr\default@tag + \baselineskip6\ex@ \lineskip1.5\ex@ \lineskiplimit\lineskip + \ialign\bgroup\hfil$\m@th\scriptstyle##$\hfil&&\thickspace\hfil + $\m@th\scriptstyle##$\hfil\crcr +}{% + \crcr\egroup\egroup\,% +} +% \end{macrocode} +% \end{environment} +% +% \begin{environment}{matrix} +% The \env{matrix} environment is just an \env{array} that provides +% up to ten centered columns, so that users don't have to give the +% col-spec argument explicitly---unless they want some of the columns +% noncentered, that is. The maximum number of columns is actually not +% fixed at ten but given by the counter |MatrixCols|, and can +% therefore be increased by changing that counter. +% +% The extra space of \cn{arraycolsep} that \env{array} adds on each +% side is a waste so we remove it here (perhaps we should instead +% remove it from \env{array} in general, but that's a harder task). +% +% TODO: Think about re-implementing \cn{matrix} to get rid of the +% \cs{c@MatrixCols} limit and have hard-wired preamble that doesn't +% have to be rebuilt each time. +% +% We must use \cn{renewenvironment} for \env{matrix} and +% \env{pmatrix} because \latex/ doesn't kill the definitions found in +% \fn{plain.tex}, even though it probably should because of their +% foreign syntax. +% \begin{macrocode} +\renewenvironment{matrix}{% + \matrix@check\matrix\env@matrix +}{% + \endarray \hskip -\arraycolsep +} +% \end{macrocode} +% \end{environment} +% +% \begin{macro}{\env@matrix} +% +% \begin{macrocode} +\def\env@matrix{\hskip -\arraycolsep + \let\@ifnextchar\new@ifnextchar + \array{*\c@MaxMatrixCols c}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\c@MaxMatrixCols} +% \begin{macrocode} +\newcount\c@MaxMatrixCols \c@MaxMatrixCols=10 +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\matrix@check} +% For various reasons, authors sometimes use the Plain \TeX{} form of +% \cn{matrix} or \cn{pmatrix} in \LaTeX{} documents. If they later +% add an invocation of the \pkg{amsmath} package to their document, +% the Plain \TeX{} syntax would lead to rather unintelligible error +% messages. The \cs{matrix@check} function does some checking to +% forestall that problem. +% \begin{macrocode} +\def\matrix@check#1{% + \@xp\ifx\csname\@currenvir\endcsname#1% + \else\matrix@error#1% +% \end{macrocode} +% This error recovery is not that good but is better than the +% infinite loop that can result from calling \cs{array} without a +% matching \cs{endarray}. (The array setup leaves \cs{par} empty.) +% \begin{macrocode} + \@xp\@gobble + \fi +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\matrix@error} +% +% \begin{macrocode} +\def\matrix@error#1{% + \@amsmath@err{% +Old form `\string#1' should be \string\begin{\@xp\@gobble\string#1}% + }{% +`\string#1{...}' is old Plain-TeX syntax whose use is +ill-advised in LaTeX.% + }% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macrocode} +\renewenvironment{pmatrix}{% + \left(% + \matrix@check\pmatrix\env@matrix +}{ + \endmatrix\right)% +} +\newenvironment{bmatrix}{\left[\env@matrix}{\endmatrix\right]} +\newenvironment{Bmatrix}{% + \left\lbrace\env@matrix +}{% + \endmatrix\right\rbrace +} +\newenvironment{vmatrix}{\left\lvert\env@matrix}{\endmatrix\right\rvert} +\newenvironment{Vmatrix}{\left\lVert\env@matrix}{\endmatrix\right\rVert} +% \end{macrocode} +% +% \begin{macrocode} +\let\hdots\@ldots +% \end{macrocode} +% +% \begin{macrocode} +\newcommand{\hdotsfor}[1]{% + \ifx[#1\@xp\shdots@for\else\hdots@for\@ne{#1}\fi} +\newmuskip\dotsspace@ +\def\shdots@for#1]{\hdots@for{#1}} +\def\hdots@for#1#2{\multicolumn{#2}c% + {\m@th\dotsspace@1.5mu\mkern-#1\dotsspace@ + \xleaders\hbox{$\m@th\mkern#1\dotsspace@.\mkern#1\dotsspace@$}% + \hfill + \mkern-#1\dotsspace@}% + } +% \end{macrocode} +% +% \begin{environment}{cases} +% The easiest way to produce the \env{cases} environment is to base +% it on the \env{array} environment. We must use +% \cn{renewenvironment} to override the definition of \cn{cases} that +% \latex/ (unwisely) leaves in place from \fn{plain.tex}. +% \begin{macrocode} +\renewenvironment{cases}{% + \matrix@check\cases\env@cases +}{% + \endarray\right.% +} +\def\env@cases{% + \let\@ifnextchar\new@ifnextchar + \left\lbrace + \def\arraystretch{1.2}% + \array{@{}l@{\quad}l@{}}% +} +% \end{macrocode} +% \end{environment} +% +% +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% \section{Equation sub-numbering} +% +% \begin{macrocode} +\newcounter{parentequation}% Counter for ``parent equation''. +% \end{macrocode} +% +% We can't assume \cs{ignorespacesafterend} is defined since it was +% not there in the earliest releases of \latex/ 2e. And we need to +% include the \cs{global} for the same reason. +% \begin{macrocode} +\@ifundefined{ignorespacesafterend}{% + \def\ignorespacesafterend{\global\@ignoretrue}% +}{} +% \end{macrocode} +% +% \begin{environment}{subequations} +% \begin{macrocode} +\newenvironment{subequations}{% +% \end{macrocode} +% Before sending down the `equation' counter to the subordinate +% level, add 1 using standard \cn{refstepcounter}. +% \begin{macrocode} + \refstepcounter{equation}% +% \end{macrocode} +% Define \cn{theparentequation} equivalent to current +% \cn{theequation}. \cn{edef} is necessary to expand the current +% value of the equation counter. This might in rare cases cause +% something to blow up, in which case the user needs to add +% \cn{protect}. +% \begin{macrocode} + \protected@edef\theparentequation{\theequation}% + \setcounter{parentequation}{\value{equation}}% +% \end{macrocode} +% And set the equation counter to 0, so that the normal incrementing +% processes in the various equation environments will produce the +% desired results. +% \begin{macrocode} + \setcounter{equation}{0}% + \def\theequation{\theparentequation\alph{equation}}% + \ignorespaces +}{% + \setcounter{equation}{\value{parentequation}}% + \ignorespacesafterend +} +% \end{macrocode} +% \end{environment} +% +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% \section{Equation numbering} +% +% In the multiline equation environments provided here, the task +% of equation numbering is linked to the task of line breaking +% in the sense that it is the \cn{\\} command that marks where an +% equation number for the current line will be processed and added to +% the page. +% +% \begin{macro}{\numberwithin} +% Provide a convenient way to specify that equations should be +% numbered within sections. +% \begin{macrocode} +\newcommand{\numberwithin}[3][\arabic]{% + \@ifundefined{c@#2}{\@nocounterr{#2}}{% + \@ifundefined{c@#3}{\@nocnterr{#3}}{% + \@addtoreset{#2}{#3}% + \@xp\xdef\csname the#2\endcsname{% + \@xp\@nx\csname the#3\endcsname .\@nx#1{#2}}}}% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\eqref} +% To make references to equation numbers easier, we provide +% \cn{eqref}. We almost don't need \cn{textup}, except that +% \cs{tagform@} doesn't supply the italic correction. +% \begin{macrocode} +\newcommand{\eqref}[1]{\textup{\tagform@{\ref{#1}}}} +% \end{macrocode} +% \end{macro} +% +% \subsection{Preliminary macros} +% +% The following macros implement the \latex/ syntax for the +% \cn{\\} command, i.e. the possibility to add an asterisk to +% inhibit a page break, or an optional argument to denote additional +% vertical space. They are modelled more or less after the +% corresponding macros for \latex/'s \env{eqnarray} and \env{array} +% environments. +% +% [We can perhaps use the eqnarray mechanism if we change it so that +% it also uses \cs{openup}.] +% +% \begin{macro}{\dspbrk@lvl} +% We begin by defining the \cs{dspbrk@lvl} counter. This counter +% records the desirability of a break after the current row, as a +% number between $0$ and $4$. Its default value is $-1$ meaning that +% no explicit \cn{displaybreak} command was given, and the default +% \cs{interdisplaylinepenalty} is to be used. +% \begin{macrocode} +\newcount\dspbrk@lvl +\dspbrk@lvl=-1 +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\interdisplaylinepenalty} +% We set the \cs{interdisplaylinepenalty} to $10000$. +% \begin{macrocode} +\interdisplaylinepenalty\@M +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\allowdisplaybreaks} +% The \cn{allowdisplaybreaks} command. Since this is intended for use +% outside displayed formulas (typically in the preamble), it does not +% need to use \cs{new@ifnextchar}. +% \begin{macrocode} +\newcommand{\allowdisplaybreaks}[1][4]{% + \interdisplaylinepenalty\getdsp@pen{#1}\relax +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\getdsp@pen} +% Modelled after \latex/'s \cs{@getpen}. We use higher numbers +% than would normally be provided by \cs{@lowpenalty}, +% \cs{@medpenalty}, and \cs{@highpenalty}, since display +% breaks are almost always less desirable. +% \begin{macrocode} +\def\getdsp@pen#1{% + \ifcase #1\@M \or 9999 \or 6999 \or 2999 \or \z@\fi +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\displaybreak} +% \begin{macro}{\dspbrk@} +% \begin{macro}{\dspbrk@context} +% \begin{macro}{\nogood@displaybreak} +% For breaks in a certain row of a alignment. +% \begin{macrocode} +\newcommand{\displaybreak}{\new@ifnextchar[\dspbrk@{\dspbrk@[4]}} +\chardef\dspbrk@context=\sixt@@n +% \end{macrocode} +% +% \begin{macrocode} +\def\dspbrk@[#1]{% + \ifmeasuring@ + \else + \ifcase\dspbrk@context % case 0 --- OK + \global\dspbrk@lvl #1\relax + \or % case 1 --- inside a box + \nogood@displaybreak + \else % other cases --- outside of a display + \@amsmath@err{\Invalid@@\displaybreak}\@eha + \fi + \fi +} +% \end{macrocode} +% +% This is the value of \cn{displaybreak} when it occurs inside some +% structure where it will not work. +% \begin{macrocode} +\def\nogood@displaybreak{% + \@amsmath@err{\protect +\displaybreak\space cannot be applied here}% +{One of the enclosing environments creates an + unbreakable box\MessageBreak +(e.g., split, aligned, gathered, ...).}% +} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\math@cr} +% The macro \cs{math@cr} ends a row inside one of the equation +% environments, i.e., this is the internal name of the \cn{\\} +% commands in these environments. As usual for this kind of macro +% inside of alignments we insert a special brace into \tex/'s input +% stream. The initial \cs{relax} is needed to trigger entry into the +% \textit{u} template of the current column if the author ended the +% current row with an empty column (i.e., the mathcr was immediately +% preceded by an ampersand). +% \begin{macrocode} +\def\math@cr{\relax\iffalse{\fi\ifnum0=`}\fi +% \end{macrocode} +% The first step is now to check whether an asterisk follows. +% \cs{@eqpen} is used to hold the penalty value to be put on +% the vertical list. +% Then we call up \cs{math@cr@} which performs the next step. +% If an asterisk is read page breaking is inhibited. +% \begin{macrocode} + \@ifstar{\global\@eqpen\@M\math@cr@}% +% \end{macrocode} +% Otherwise we have to check the \cs{dspbrk@lvl} value. +% \begin{macrocode} + {\global\@eqpen + \ifnum\dspbrk@lvl <\z@ \interdisplaylinepenalty + \else -\@getpen\dspbrk@lvl \fi + \math@cr@}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\math@cr@} +% The purpose of \cs{math@cr@} is to check whether an optional +% argument follows. If not it provides \cs{z@} as default +% value. +% \begin{macrocode} +\def\math@cr@{\new@ifnextchar[\math@cr@@{\math@cr@@[\z@]}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\math@cr@@} +% \cs{math@cr@@} closes the special brace opened in +% \cs{math@cr}, and calls \cs{math@cr@@@} which is supposed +% the `real' row ending command. The meaning of this macro depends +% on the environment in which it is used. +% \begin{macrocode} +\def\math@cr@@[#1]{\ifnum0=`{\fi \iffalse}\fi\math@cr@@@ +% \end{macrocode} +% Finally we put the additional space onto the vertical list. +% \begin{macrocode} + \noalign{\vskip#1\relax}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\Let@} +% \cs{Let@} is called by all environments where \cn{\\} +% ends a row of an alignment. +% \begin{macrocode} +\def\Let@{\let\\\math@cr} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\restore@math@cr} +% We mentioned already that the exact meaning of \cs{math@cr@@@} +% depends on the current environment. Since it is often a simple +% \cs{cr} we provide \cs{restore@math@cr} to reset it. +% \begin{macrocode} +\def\restore@math@cr{\def\math@cr@@@{\cr}} +% \end{macrocode} +% This is also the default case. +% \begin{macrocode} +\restore@math@cr +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\intertext} +% \begin{macro}{\intertext@} +% The \cn{intertext} command is used for inserting text between the +% rows of an alignment. It might better be done as an environment, +% but the \cs{begingroup} from \cn{begin} would cause the +% \cs{noalign} to fail. +% \begin{macrocode} +\newcommand{\intertext}{\@amsmath@err{\Invalid@@\intertext}\@eha} +% \end{macrocode} +% \cs{intertext@} is called by all environments that allow the use of +% the \cn{intertext} command. +% \begin{macrocode} +\def\intertext@{% + \def\intertext##1{% +% \end{macrocode} +% If current mode is not vmode, the most likely reason is that the +% writer forgot the \cn{\\} that is supposed to precede +% \cn{intertext}. All right, then, let's try adding it our ownself. +% But, to be slightly careful: \cn{\\} does a futurelet, and it's +% slightly dangerous to allow a letted token to barge around loose in +% our internal code when it has been let to a conditional token +% like \cs{fi}. So let's interpose something in front of the \cs{fi} +% for the futurelet to take instead. (And careful again: it has to be +% something evanescent, not (e.g.) \cs{relax} which would cause the +% next halign cell to fire up and keep \cs{noalign} from working.) +% \begin{macrocode} + \ifvmode\else\\\@empty\fi + \noalign{% + \penalty\postdisplaypenalty\vskip\belowdisplayskip + \vbox{\normalbaselines +% \end{macrocode} +% We need to do something extra if the outside environment is a list +% environment. I don't see offhand an elegant way to test ``are we +% inside any list environment'' that is both easy and reliable (for +% example, checking for zero \cs{@totalleftmargin} wouldn't catch the +% case where \cs{@totalleftmargin} is zero but \cs{linewidth} is less +% than \cs{columnwidth}), so it seems to me checking \cs{linewidth} +% is the best practical solution. +% \changes{v2.15c}{2016/05/23}{\cs{ignorespaces} at the start of the argument} +% \begin{macrocode} + \ifdim\linewidth=\columnwidth + \else \parshape\@ne \@totalleftmargin \linewidth + \fi + \noindent\ignorespaces##1\par}% + \penalty\predisplaypenalty\vskip\abovedisplayskip% + }% +}} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% +% \subsection{Implementing tags and labels} +% +% In this section we describe some of the macros needed to make the +% \cn{tag} command work in various places. We start by defining a +% help text to be used when a \cn{tag} command is used somewhere +% it should not appear. +% +% \begin{macro}{\tag@help} +% This is the default error help text provided when \cn{tag} +% generates an error message. +% Note that \cs{newhelp} generates a control sequence name +% from the string given as its argument so that a leading +% backslash is provided automatically. +% \begin{macrocode} +\newhelp\tag@help + {tag cannot be used at this point.\space + If you don't understand why^^Jyou should consult + the documentation.^^JBut don't worry: just continue, and I'll + forget what happened.} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\gobble@tag} +% This macro is to be used when \cn{tag} should silently +% skip its argument. +% It is made to handle the \qc{\*}-form of \cn{tag} as well. +% \begin{macrocode} +\def\gobble@tag{\@ifstar\@gobble\@gobble} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\invalid@tag} +% \cs{invalid@tag} is a macro that should be used whenever +% \cn{tag} appears in an illegal place. +% It sets up \cs{tag@help} (as defined above) as help message, +% prints its argument as error message, and skips \cn{tag}'s +% argument. +% \begin{macrocode} +\def\invalid@tag#1{\@amsmath@err{#1}{\the\tag@help}\gobble@tag} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\dft@tag} +% \begin{macro}{\default@tag} +% \cs{dft@tag} provides a convenient way to disallow the +% use of \cn{tag} at certain points. +% One simply has to write +% \begin{verbatim} +%\let\tag\dft@tag +% \end{verbatim} +% and the \cn{tag} command will produce an error message, +% with a suitable error help text, and discard its argument. +% \begin{macrocode} +\def\dft@tag{\invalid@tag{\string\tag\space not allowed here}} +% \end{macrocode} +% Since this is used several times we provide an abbreviation for +% it. +% \begin{macrocode} +\def\default@tag{\let\tag\dft@tag} +% \end{macrocode} +% Since this is also the default, i.e.\ the \cn{tag} command +% should not be used except in special places, we issue a +% \cs{default@tag} command. +% \begin{macrocode} +\default@tag +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% Now that we have taken care of the case that \cn{tag} is not +% allowed we will provide some macros to process tags appropriately. +% As the user documentation states, a \cn{tag} command (without +% the asterisk typesets its argument according to the document +% styles' conventions, whereas a \cn{tag*} command typesets its +% argument exactly as given. We define therefore the following +% interface: +% +% \begin{macro}{\maketag@@} +% \begin{macro}{\maketag@@@} +% \begin{macro}{\tagform@} +% \cn{tag} is supposed to call \cs{maketag@@} which checks +% whether an asterisk follows. If this is the case it calls up +% \cs{maketag@@@} which sets its argument `as is'. Otherwise +% \cs{tagform@} is called to do the job. (This macro is to be +% defined appropriately by the document style.) +% \begin{macrocode} +\def\maketag@@{\@ifstar\maketag@@@\tagform@} +% \end{macrocode} +% We define \cs{maketag@@@} to use the normal font of the document +% text (since this is the usual practice for numbering of document +% elements) and to put a box around the tag. Furthermore we use +% \cs{m@th} for exceptional cases where the tag involves a +% superscript or some such math. (Probably from an explicit use of +% \cs{tag*} rather than from the automatic numbering.) +% \begin{macrocode} +\def\maketag@@@#1{\hbox{\m@th\normalfont#1}} +% \end{macrocode} +% We use the following default definition for \cs{tagform@} +% that puts only parentheses around the tag. +% \begin{macrocode} +\def\tagform@#1{\maketag@@@{(\ignorespaces#1\unskip\@@italiccorr)}} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% +% We need to insinuate \cs{tagform@} into \cs{@eqnnum} in case +% \env{eqnarray} is used (probably in a document that was originally +% written without use of the \pkg{amsmath} package). +% \begin{macrocode} +\iftagsleft@ + \def\@eqnnum{\hbox to1sp{}\rlap{\normalfont\normalcolor + \hskip -\displaywidth\tagform@\theequation}} +\else + \def\@eqnnum{{\normalfont\normalcolor \tagform@\theequation}} +\fi +% \end{macrocode} +% +% \begin{macro}{\thetag} +% Sometimes one needs to set a literal tag according to the rules of +% the document style. To achieve this we provide the \cn{thetag} +% command. It typesets its argument by calling \cs{tagform@} on +% it. +% \begin{macrocode} +\newcommand{\thetag}{\leavevmode\tagform@} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\df@tag} +% \begin{macro}{\make@df@tag} +% \begin{macro}{\make@df@tag@@} +% \begin{macro}{\make@df@tag@@@} +% Sometimes it is necessary for a \cn{tag} command to store a tag +% in a safe place and to process it later, e.g., for a tag in a row +% of an alignment where the tag can only be typeset when the +% \cn{\\} at the end of the row was seen. Such a tag is stored in +% the macro \cs{df@tag} (for `deferred tag'). For this purpose we +% provide the \cs{make@df@tag} macro. It is built very similar to +% the \cs{maketag@@} macro above. +% \begin{macrocode} +\let\df@tag\@empty +\def\make@df@tag{\@ifstar\make@df@tag@@\make@df@tag@@@} +% \end{macrocode} +% \cs{make@df@tag} sets \cs{@currentlabel} and defines +% \cs{df@tag} appropriately. +% +% To simplify the task of tracking \cs{tag} and \cs{label} +% commands inside math display environments, we defer \cs{label} +% commands until the tag is typeset, similar to the way that +% \cs{tag}s themselves are deferred. This allows arbitrary +% placement of \cs{label} and \cs{tag} commands and also means we +% only increment the \cs{equation} counter when we really need to, +% thus avoiding the \cs{setb@ck} nonsense that used to be required. +% +% \begin{macrocode} +\def\make@df@tag@@#1{% + \gdef\df@tag{\maketag@@@{#1}\def\@currentlabel{#1}}} +% \end{macrocode} +% Autogenerated number: +% \begin{macrocode} +\def\make@df@tag@@@#1{\gdef\df@tag{\tagform@{#1}% + \toks@\@xp{\p@equation{#1}}\edef\@currentlabel{\the\toks@}}} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\ltx@label} +% \begin{macro}{\label@in@display} +% \begin{macro}{\df@label} +% Next, we store the default definition of \cs{label} in +% \cs{ltx@label} and then define a new version of \cs{label} for use +% in math display environments. \cs{label@in@display} merely issues a +% warning message if there is already a pending label (which will be +% discarded) and then stores the label in \cs{df@label}. +% \begin{macrocode} +\let\ltx@label\label +% +\def\label@in@display{% + \ifx\df@label\@empty\else + \@amsmath@err{Multiple \string\label's: + label '\df@label' will be lost}\@eha + \fi + \gdef\df@label +} +% \end{macrocode} +% In case there is an enumerate inside a minipage inside an equation, +% we need to reset \cn{label} to its normal value: +% \begin{macrocode} +\toks@\@xp{\@arrayparboxrestore \let\label\ltx@label}% +\edef\@arrayboxrestore{\the\toks@} +% \end{macrocode} +% +% \begin{macrocode} +\let\df@label\@empty +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\make@display@tag} +% Now we define a macro to process \cs{tag} and \cs{label} commands +% in various display environments. If the |@eqnsw| switch is set, +% then we should supply an equation number; otherwise, if the +% |@tag| switch is set, we should use the tag stored in +% \cs{df@tag}. Finally, we process any pending \cs{label}s. +% +% TODO: Arguably, \cs{make@display@tag} should issue a warning +% message if there is a \cs{label} but neither a tag nor an +% equation number. Also, it would probably be worthwhile to +% explore whether \cs{iftag@} could be done away with and replaced +% by checks to see if \cs{df@tag} is empty or not. +% \begin{macrocode} +\def\make@display@tag{% + \if@eqnsw \incr@eqnum \print@eqnum + \else \iftag@ \df@tag \global\let\df@tag\@empty \fi + \fi +% \end{macrocode} +% Need to check the \cs{ifmeasuring@} flag otherwise the \cs{write} +% node from \cn{label} might be discarded in a temp box and clearing +% \cs{df@label} will keep it from being reiterated on the real +% typesetting pass. +% \begin{macrocode} + \ifmeasuring@ + \else + \ifx\df@label\@empty + \else + \@xp\ltx@label\@xp{\df@label}% + \global\let\df@label\@empty + \fi + \fi +} +% \end{macrocode} +% \end{macro} +% +% Now we define the special versions of \cn{tag} used within the +% \env{align} environments. +% +% \begin{macro}{\tag@in@align} +% The \cn{tag} command may only appear once in a row of +% an alignment. Therefore we first check the switch |tag@| +% that is set to false at the begin of every row. +% If this switch is true a \cn{tag} was already given in this +% row and we define \cs{next@} to expand to a call to +% \cs{invalid@tag}. +% \begin{macrocode} +\def\tag@in@align{% + \relax + \iftag@ + \DN@{\invalid@tag{Multiple \string\tag}}% + \else +% \end{macrocode} +% Otherwise we set the |tag@| switch. But there is more to +% be done: we must also prevent the automatic generation of a +% tag. Therefore we also reset the |@eqnsw|. +% \begin{macrocode} + \global\tag@true +% \end{macrocode} +% Changed to \cs{nonumber}, since that seems to be all that's +% required.---dmj, 1994/12/21 +% \begin{macrocode} + \nonumber +% \end{macrocode} +% Within a row of an \env{align} environment the \cn{tag} +% command must not typeset the tag immediately since its +% position can be determined only later. +% Therefore we use the \cs{make@df@tag} macro defined +% earlier. +% Finally we call \cs{next@} to process the argument +% that follows. +% \begin{macrocode} + \let\next@\make@df@tag + \fi + \next@ +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\raisetag} +% Usage: \cn{raisetag} \meta{dimen} +% +% This will modify the vertical placement of the tag of the current +% equation by \meta{dimen}. Note that according to the current uses +% of \cs{raise@tag} in e.g., \cs{place@tag@gather}, no adjustment +% occurs if the tag falls in its normal position; i.e., \cn{raisetag} +% has no effect unless the tag has already been shifted off-line. +% +% \begin{macrocode} +\newcommand{\raisetag}[1]{\skip@#1\relax + \xdef\raise@tag{\vskip\iftagsleft@\else-\fi\the\skip@\relax}% +} +% \end{macrocode} +% \cn{raise@tag} will be reemptied at the beginning of each equation, +% which might occur at a |\begin{xxx}| or \cn{\\}. +% \begin{macrocode} +\let\raise@tag\@empty +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\notag} +% For consistency we provide \cn{notag}, equivalent to +% \cn{nonumber}. The alternative would have been to rename +% \cn{tag} as \cn{number} to go along with \cn{nonumber}, +% but of course \cs{number} is a \tex/ primitive that should not +% be redefined. +% \begin{macrocode} +\newcommand{\notag}{\nonumber} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\nonumber} +% Need to add some additional code to \cn{nonumber} to deal with some +% complications related to nested environments. +% \begin{macrocode} +\renewcommand{\nonumber}{% + \if@eqnsw + \ifx\incr@eqnum\@empty \addtocounter{equation}\m@ne \fi + \fi + \let\print@eqnum\@empty \let\incr@eqnum\@empty + \global\@eqnswfalse +} +% \end{macrocode} +% +% \begin{macrocode} +\def\print@eqnum{\tagform@\theequation} +\def\incr@eqnum{\refstepcounter{equation}\let\incr@eqnum\@empty} +% \end{macrocode} +% \end{macro} +% +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% \section{Multiline equation environments} +% +% \subsection{Remarks} +% +% In late 1994 David M. Jones did a thorough overhaul of these +% environments so that the number placement and a few other aspects +% are substantially improved over the original versions that were +% ported essentially unchanged from \fn{amstex.tex} in 1989. Most of +% the commentary in this section is DMJ's, and comments of any +% significance that I added are marked by my initials and date +% [mjd, 1995/01/11]. +% +% \subsection{Preliminaries} +% +% \begin{macro}{\ifinalign@} +% \begin{macro}{\ifingather@} +% We define two switches that are set to true in certain +% alignments: |inalign@| and |ingather@| inside of +% the \env{align} and \env{gather} environments. +% These switches are needed to control certain actions that +% depend on the surrounding conditions, more specifically: +% on the setting already done by the surrounding environments. +% \begin{macrocode} +\newif\ifinalign@ +\newif\ifingather@ +% \end{macrocode} +% \begin{histnote} +% Removed the \cs{ifinany@} test [mjd,1999/06/28] since it was mainly +% used for the purpose now handled by \cs{spread@equation}. +% \changes{v1.2g}{1999/06/28}{Removed ifinany@} +% \end{histnote} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\@arrayparboxrestore} +% Here we must reset a few additional parameters. +% \begin{macrocode} +\@xp\def\@xp\@arrayparboxrestore\@xp{\@arrayparboxrestore + \ingather@false\inalign@false \default@tag + \let\spread@equation\@spread@equation + \let\reset@equation\@empty + \def\print@eqnum{\tagform@\theequation}% + \def\incr@eqnum{\refstepcounter{equation}\let\incr@eqnum\@empty}% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\iftag@} +% The switch |tag@| is set to false at the beginning of every +% row and set to true by a \cn{tag} command. +% This allows us to check whether there is more than one tag on +% a row. +% \begin{macrocode} +\newif\iftag@ +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\ifst@rred} +% The switch |st@rred| is set to true by all starred +% environments +% and set to false by the unstarred versions. +% \begin{macrocode} +\newif\ifst@rred +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\ifmeasuring@} +% All display environments get typeset twice---once during a +% ``measuring'' phase and then again during a ``production'' phase; +% \cs{ifmeasuring@} will be used to determine which case we're in, +% so we can take appropriate action. +% +% \begin{macrocode} +\newif\ifmeasuring@ +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\ifshifttag@} +% \cs{ifshifttag@} is used by \env{gather} to communicate between +% \cs{calc@shift@gather} and \cs{place@tag@gather} whether an +% equation tag should be shifted to a separate line. It's also +% used by \env{multline}. +% \begin{macrocode} +\newif\ifshifttag@ +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\row@} +% \begin{macrocode} +\newcount\row@ +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\column@} +% The counter \cs{column@} is used by the alignment macros to +% keep track of the current column. +% +% \begin{macrocode} +\newcount\column@ +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\column@plus} +% \cs{\column@plus} is a useful abbreviation. +% \begin{macrocode} +\def\column@plus{% + \global\advance\column@\@ne +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\maxfields@} +% \begin{macrocode} +\newcount\maxfields@ +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\add@amp} +% \begin{macro}{\add@amps} +% \begin{macrocode} +\def\add@amp#1{\if m#1&\@xp\add@amp\fi} +\def\add@amps#1{% + \begingroup + \count@#1\advance\count@-\column@ + \edef\@tempa{\endgroup + \@xp\add@amp\romannumeral\number\count@ 000q}% + \@tempa +} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\andhelp@} +% The help text stored in \cs{andhelp@} is used for errors +% generated by too many \qc{\&} characters in a row. +% \begin{macrocode} +\newhelp\andhelp@ +{An extra & here is so disastrous that you should probably exit^^J +and fix things up.} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\eqnshift@} +% \cs{eqnshift@} is used by \env{align} and \env{gather} as the +% indentation of the lines of the environment from the left margin. +% \begin{macrocode} +\newdimen\eqnshift@ +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\alignsep@} +% \begin{macrocode} +\newdimen\alignsep@ +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\tagshift@} +% \begin{macrocode} +\newdimen\tagshift@ +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\mintagsep} +% \cs{mintagsep} is the minimum allowable separation between an +% equation and its tag. We set it to half a quad in +% \cs{textfont}2, which is \tex/'s built-in value. +% \begin{macrocode} +\newcommand{\mintagsep}{.5\fontdimen6\textfont\tw@} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\minalignsep} +% This should probably be a skip register [mjd,1999/06/18] +% \begin{macrocode} +\newcommand{\minalignsep}{10pt} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\tagwidth@} +% \begin{macrocode} +\newdimen\tagwidth@ +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\totwidth@} +% \begin{macrocode} +\newdimen\totwidth@ +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\lineht@} +% The dimen register \cs{lineht@} is used to keep track of the +% height (or depth, if tags are on the right) of a row in an +% alignment. +% \begin{macrocode} +\newdimen\lineht@ +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\tag@width} +% \begin{macro}{\savetaglength@} +% \begin{macro}{\shift@tag} +% \begin{macro}{\tag@shifts} +% \begin{macrocode} +\def\tag@width#1{% + \ifcase\@xp#1\tag@lengths\fi +} + +\def\savetaglength@{% + \begingroup + \let\or\relax + \xdef\tag@lengths{\tag@lengths\or \the\wdz@}% + \endgroup +} + +\def\shift@tag#1{% + \ifcase\@xp#1\tag@shifts\fi\relax +} + +\let\tag@shifts\@empty +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\saveshift@} +% \begin{macrocode} +\def\saveshift@#1{% + \begingroup + \let\or\relax + \xdef\tag@shifts{\or#1\tag@shifts}% + \endgroup +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\spread@equation} +% This does the line-spacing adjustment that is normally wanted for +% displayed equations. We also call \cs{reset@strutbox@} here because +% otherwise a preceding font size change might leave \cs{strutbox@} +% with wrong contents. This is a less-than-ideal solution but +% probably good enough for now, until the situation can be +% overhauled. +% \begin{macrocode} +\def\spread@equation{\reset@strutbox@ + \openup\jot \let\spread@equation\@empty} +\let\@spread@equation\spread@equation +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\displ@y} +% \begin{macro}{\displ@y@} +% \begin{macro}{\@display@init} +% \cs{displ@y} is from \fn{plain.tex}, with +% \cs{interdisplaylinepenalty} changed to \cs{@eqpen}. Also we +% transplanted most of its internal organs to \cs{@display@init} to +% support \cs{displ@y@} and other possibilities. Don't try to make +% sense of these naming conventions! They are a narrowly calculated +% mishmash of Knuth/Spivak/Lamport/Mittelbach precedents. The reason +% for not cleaning them up and forcing all names to a consistent +% scheme is that then in principle we'd have to do it everywhere else +% too. And we programmers are paranoid about the side effects of name +% changes. +% \begin{macrocode} +\def\displ@y{\@display@init{}} +\def\@display@init#1{% + \global\dt@ptrue \spread@equation + \everycr{% + \noalign{% + #1% + \ifdt@p + \global\dt@pfalse + \vskip-\lineskiplimit + \vskip\normallineskiplimit + \else + \penalty\@eqpen \global\dspbrk@lvl\m@ne + \fi + }% + }% +} +% \end{macrocode} +% \cs{displ@y@} is nearly the same; it additionally sets the |tag@| +% switch and the \cs{column@} and \cs{dspbrk@lvl} counters to their +% default values. The argument is normally a bit of code to empty out +% \cs{raise@tag}, but in \env{multline} we don't want that to happen +% in \cs{everycr}. +% \begin{macrocode} +\def\displ@y@{\@display@init{% + \global\column@\z@ \global\dspbrk@lvl\m@ne + \global\tag@false \global\let\raise@tag\@empty +}} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\black@} +% \changes{v2.17a}{2017/09/02}{add fixed width box so overfull warning generated in centred environments in lists} +% This macro is made to produce an overfull box message and +% possibly (depending on the value of \cs{overfullrule}) +% a rule in the margin if the total width of an alignment +% is larger than the value of \cs{displaywidth}. +% \begin{macrocode} +\def\black@#1{% + \noalign{% + \ifdim#1>\displaywidth + \dimen@\prevdepth + \nointerlineskip + \vskip-\ht\strutbox@ + \vskip-\dp\strutbox@ + \vbox{\noindent\hbox to\displaywidth{\hbox to#1{\strut@\hfill}}}% + \prevdepth\dimen@ + \fi + }% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\savecounters@} +% \begin{macro}{\restorecounters@} +% These are used during the measuring phase of the various display +% math environments to save and restore the values of all \latex/ +% counters. We make these local to a group, so nested environments +% works. +% +% Changed \cn{stepcounter} to |\csname c@...\endcsname| to avoid +% overhead of ifundefined test [mjd, 1995/01/20]. +% \begin{macrocode} +\def\savecounters@{% + \begingroup + \def\@elt##1{% + \global\csname c@##1\endcsname\the\csname c@##1\endcsname}% + \xdef\@gtempa{% + \cl@@ckpt + \let\@nx\restorecounters@\@nx\@empty + }% + \endgroup + \let\restorecounters@\@gtempa +} +% +\let\restorecounters@\@empty +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\savealignstate@} +% \begin{macro}{\restorealignstate@} +% These are used to save the values of various parameters that are +% shared by \env{align} and \env{gather} when the former is used +% inside the latter. +% \begin{macrocode} +\def\savealignstate@{% + \begingroup + \let\or\relax + \xdef\@gtempa{% + \global\totwidth@\the\totwidth@ + \global\row@\the\row@ + \gdef\@nx\tag@lengths{\tag@lengths}% + \let\@nx\restorealignstate@\@nx\@empty + }% + \endgroup + \let\restorealignstate@\@gtempa +} + +\let\restorealignstate@\@empty +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\savecolumn@} +% \begin{macro}{\restorecolumn@} +% +% \begin{macrocode} +\def\savecolumn@{% + \edef\restorecolumn@{% + \global\column@\number\column@ + \let\@nx\restorecolumn@\@nx\@empty + }% +} +\let\restorecolumn@\@empty +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \subsection{Scanning the environment's body} +% +% Several of the math alignment macros must scan their body twice: +% once to determine how wide the columns are and then to actually +% typeset them. This means that we must collect all text in this body +% before calling the environment macros. +% +% \begin{macro}{\@envbody} +% We start by defining a token register to contain the body. +% \begin{macrocode} +\newtoks\@envbody +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\addto@envbody} +% Then we define a macro to add something (i.e.\ its argument) to the +% token register \cs{@envbody}. +% \begin{macrocode} +\def\addto@envbody#1{\global\@envbody\@xp{\the\@envbody#1}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\collect@body} +% The macro \cs{collect@body} starts the scan for the |\end{...}| +% command of the current environment. It takes a macro name as +% argument. This macro is supposed to take the whole body of the +% environment as its argument. For example, |\begin{align}| would +% call |\collect@body\@align| if |@align#1{...}| is the macro that +% sets the alignment with body \arg{1}. +% +% \begin{macrocode} +\def\collect@body#1{% + \@envbody{\@xp#1\@xp{\the\@envbody}}% + \edef\process@envbody{\the\@envbody\@nx\end{\@currenvir}}% + \@envbody\@emptytoks \def\begin@stack{b}% +% \end{macrocode} +% +% If we simply called \cs{collect@@body} directly, +% the error message for a \cn{par} token (usually from a blank line) +% would be +% \begin{verbatim} +% ! Paragraph ended before \collect@@body was complete. +% \end{verbatim} +% But we use a little finesse to get a more intelligible error +% message: +% \begin{verbatim} +% ! Paragraph ended before \multline* was complete. +% \end{verbatim} +% In order to avoid using up csnames unnecessarily we use the actual +% environment name as the name of the temporary function that is +% \cs{let} to \cs{collect@@body}; but then in order to preserve the +% theoretical possibility of nesting for environments that use +% \cs{collect@body} (not currently required by any \pkg{amsmath} +% environment [mjd,1999/06/23]), we do the \cs{let} inside a group. +% \begin{macrocode} + \begingroup + \@xp\let\csname\@currenvir\endcsname\collect@@body +% \end{macrocode} +% This small twist eliminates the need for \cs{expandafter}'s in +% \cs{collect@@body}. +% \begin{macrocode} + \edef\process@envbody{\@xp\@nx\csname\@currenvir\endcsname}% + \process@envbody +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\push@begins} +% When adding a piece of the current environment's contents to +% \cs{@envbody}, we scan it to check for additional \cn{begin} +% tokens, and add a `b' to the stack for any that we find. +% \begin{macrocode} +\def\push@begins#1\begin#2{% + \ifx\end#2\else b\@xp\push@begins\fi +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\collect@@body} +% \cs{collect@@body} takes two arguments: the first will consist of +% all text up to the next \cn{end} command, the second will be the +% \cn{end} command's argument. If there are any extra \cn{begin} +% commands in the body text, a marker is pushed onto a stack by the +% \cs{push@begins} function. Empty state for this stack means that we +% have reached the \cn{end} that matches our original \cn{begin}. +% Otherwise we need to include the \cn{end} and its argument in the +% material that we are adding to our environment body accumulator. +% +% \begin{histnote} +% In a former implementation, the error messages resulting from a +% typo in the environment name were unsatisfactory, because it was +% matching of the environment name that was used to determine the end +% of our environment body, instead of counting begin-end pairs. +% Thanks to Lars Hellstr\"{o}m for a suggestion that led to this +% improvement. [mjd,1999/06/23] +% \end{histnote} +% \begin{macrocode} +\def\collect@@body#1\end#2{% + \edef\begin@stack{\push@begins#1\begin\end \@xp\@gobble\begin@stack}% + \ifx\@empty\begin@stack + \endgroup + \@checkend{#2}% + \addto@envbody{#1}% + \else + \addto@envbody{#1\end{#2}}% + \fi + \process@envbody % A little tricky! Note the grouping +} +% \end{macrocode} +% \end{macro} +% +% +% \subsection{Simple aligning environments} +% +% \begin{macro}{\math@cr@@@aligned} +% From tabskip we get an extra space of minalignsep after every +% second column; but when this falls at the right edge of the whole +% aligned structure, we need to cancel that space. +% \begin{macrocode} +\def\math@cr@@@aligned{% + \ifodd\column@ \let\next@\@empty + \else \def\next@{&\kern-\alignsep@}% + \fi + \next@ \cr +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\start@aligned} +% The \env{aligned} and \env{alignedat} environments are identical +% except that the latter takes a mandatory argument to specify the +% number of align structures, while the former allows any number of +% align structures automatically (the use of \env{alignedat} is +% deprecated). So, they will be defined in terms of +% \cs{start@aligned}, which will take two arguments. The first +% argument specifies the placement of the environments; it is +% either |c|, |t|, or |b|. The second is the number of align +% structures; a value of~$-1$ means that an arbitrary number are +% allowed. +% \begin{macrocode} +\newcommand{\start@aligned}[2]{% + \RIfM@\else + \nonmatherr@{\begin{\@currenvir}}% + \fi + \savecolumn@ % Assumption: called inside a group +% \end{macrocode} +% The \cs{null} here is to keep the \cs{,} glue from causing the +% invocation of the clause in \tex/'s built-in tag placement +% algorithm that can cause an equation to be shifted all the way over +% to the margin. +% \begin{macrocode} + \alignedspace@left + \if #1t\vtop \else \if#1b \vbox \else \vcenter \fi \fi \bgroup + \maxfields@#2\relax + \ifnum\maxfields@>\m@ne + \multiply\maxfields@\tw@ +% \end{macrocode} +% Introduced new \cs{math@cr@@@} so we can provide standard error +% message for too many \qc{\&}'s in \env{alignedat}. +% \begin{macrocode} + \let\math@cr@@@\math@cr@@@alignedat + \alignsep@\z@skip + \else + \let\math@cr@@@\math@cr@@@aligned + \alignsep@\minalignsep + \fi +% \end{macrocode} +% Reset the meaning of \cn{\\}. +% \begin{macrocode} + \Let@ \chardef\dspbrk@context\@ne +% \end{macrocode} +% Restore the default definition of \cn{tag} (error message), in +% case \env{aligned} is used inside, e.g., a \env{gather} +% environment that accepts \cn{tag}. +% \begin{macrocode} + \default@tag + \spread@equation % no-op if already called +% \end{macrocode} +% Finally we start the alignment itself. For \env{aligned} we add +% \cs{minalignsep} after every second column to mimic the +% behavior of \env{align}. For \env{alignedat} the user has to +% specify interalign space explicitly. +% \begin{macrocode} + \global\column@\z@ + \ialign\bgroup + &\column@plus + \hfil + \strut@ + $\m@th\displaystyle{##}$% + \tabskip\z@skip + &\column@plus + $\m@th\displaystyle{{}##}$% + \hfil + \tabskip\alignsep@ + \crcr +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\math@cr@@@alignedat} +% \cs{math@cr@@@alignedat} checks to make sure the user hasn't put in +% too many \qc{\&}s in \env{alignedat}. Since \env{alignedat} +% doesn't use \cs{displ@y@}, we also reset \cs{column@} here. Note +% than in \env{aligned}, \cs{column@} will increase without bound, +% since it never gets reset, but this is harmless. +% \begin{macrocode} +\def\math@cr@@@alignedat{% + \ifnum\column@>\maxfields@ + \begingroup + \measuring@false + \@amsmath@err{Extra & on this line}% + {\the\andhelp@}% "An extra & here is disastrous" + \endgroup + \fi + \global\column@\z@ + \cr +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\alignsafe@testopt} +% Testing for an optional argument can be really, really tricky in +% certain complicated contexts. This we discovered by getting some +% bug reports for uses of \env{aligned}. So here is a safer +% form of \latex/'s \cs{@testopt} function. +% \begin{macrocode} +\def\alignsafe@testopt#1#2{% + \relax\iffalse{\fi\ifnum`}=0\fi + \@ifnextchar[% + {\let\@let@token\relax \ifnum`{=\z@\fi\iffalse}\fi#1}% + {\let\@let@token\relax \ifnum`{=\z@\fi\iffalse}\fi#1[#2]}% +} +% \end{macrocode} +% \end{macro} +% +% \begin{environment}{aligned} +% The \env{aligned} environment takes an optional argument that +% indicates its vertical position in relation to surrounding +% material: |t|, |c|, or |b| for top, center, or bottom. +% \begin{macrocode} +\newenvironment{aligned}{% + \let\@testopt\alignsafe@testopt + \aligned@a +}{% + \crcr\egroup + \restorecolumn@ + \egroup +} +\newcommand{\aligned@a}[1][c]{\start@aligned{#1}\m@ne} +% \end{macrocode} +% \end{environment} +% +% \begin{environment}{alignedat} +% To get a top or bottom positioned \env{alignedat} structure, you +% would write something like +% \begin{verbatim} +% \begin{alignedat}[t]{3} +% \end{verbatim} +% +% \begin{macrocode} +\newenvironment{alignedat}{% + \let\@testopt\alignsafe@testopt + \alignedat@a +}{% + \endaligned +} +\newcommand{\alignedat@a}[1][c]{\start@aligned{#1}} +% \end{macrocode} +% \end{environment} +% +% \begin{environment}{gathered} +% The \env{gathered} environment is for several lines that are +% centered independently. +% \begin{macrocode} +\newenvironment{gathered}[1][c]{% + \RIfM@\else + \nonmatherr@{\begin{gathered}}% + \fi + \alignedspace@left + \if #1t\vtop \else \if#1b\vbox \else \vcenter \fi\fi \bgroup + \Let@ \chardef\dspbrk@context\@ne \restore@math@cr + \spread@equation + \ialign\bgroup + \hfil\strut@$\m@th\displaystyle##$\hfil + \crcr +}{% + \endaligned +} +% \end{macrocode} +% \end{environment} +% +% +% \subsection{The \env{gather} environment} +% +% \begin{macro}{\start@gather} +% \begin{macrocode} +\def\start@gather#1{% + \RIfM@ + \nomath@env + \DN@{\@namedef{end\@currenvir}{}\@gobble}% + \else + $$% + #1% + \ifst@rred \else \global\@eqnswtrue \fi + \let\next@\gather@ + \fi + \collect@body\next@ +} +% \end{macrocode} +% \end{macro} +% +% \begin{environment}{gather} +% \begin{environment}{gather*} +% \begin{macrocode} +\newenvironment{gather}{% + \start@gather\st@rredfalse +}{% + \math@cr \black@\totwidth@ \egroup + $$\ignorespacesafterend +} + +\newenvironment{gather*}{% + \start@gather\st@rredtrue +}{% + \endgather +} +% \end{macrocode} +% \end{environment} +% \end{environment} +% +% \begin{macro}{\gather@} +% \begin{macrocode} +\def\gather@#1{% + \ingather@true \let\split\insplit@ + \let\tag\tag@in@align \let\label\label@in@display + \chardef\dspbrk@context\z@ + \intertext@ \displ@y@ \Let@ + \let\math@cr@@@\math@cr@@@gather + \gmeasure@{#1}% + \global\shifttag@false + \tabskip\z@skip + \global\row@\@ne + \halign to\displaywidth\bgroup + \strut@ + \setboxz@h{$\m@th\displaystyle{##}$}% + \calc@shift@gather + \set@gather@field + \tabskip\@centering + &\setboxz@h{\strut@{##}}% + \place@tag@gather + \tabskip \iftagsleft@ \gdisplaywidth@ \else \z@skip \span\fi + \crcr + #1% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\gmeasure@} +% \begin{macrocode} +\def\gmeasure@#1{% + \begingroup + \measuring@true + \totwidth@\z@ + \global\let\tag@lengths\@empty + \savecounters@ + \setbox\@ne\vbox{% + \everycr{\noalign{\global\tag@false + \global\let\raise@tag\@empty \global\column@\z@}}% + \let\label\@gobble + \halign{% + \setboxz@h{$\m@th\displaystyle{##}$}% + \ifdim\wdz@>\totwidth@ + \global\totwidth@\wdz@ + \fi + &\setboxz@h{\strut@{##}}% + \savetaglength@ + \crcr + #1% + \math@cr@@@ + }% + }% + \restorecounters@ + \if@fleqn + \global\advance\totwidth@\@mathmargin + \fi + \iftagsleft@ + \ifdim\totwidth@>\displaywidth + \global\let\gdisplaywidth@\totwidth@ + \else + \global\let\gdisplaywidth@\displaywidth + \fi + \fi + \endgroup +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\math@cr@@@gather} +% Modified \cs{math@cr@@@gather} so that it always puts in the +% final field, which needs to be done under the new method for +% determining tag placement. This is probably more efficient +% anyway. +% +% \begin{macrocode} +\def\math@cr@@@gather{% + \ifst@rred\nonumber\fi + &\relax + \make@display@tag + \ifst@rred\else\global\@eqnswtrue\fi +% \end{macrocode} +% We advance \cs{row@} here, rather than at the beginning of the +% preamble, because otherwise the \env{split} environment will +% cause \cs{row@} to be advanced twice instead of once. +% \begin{macrocode} + \global\advance\row@\@ne + \cr +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\calc@shift@gather} +% \cs{calc@shift@gather} has must make two decisions: (1) whether the +% equation tag for the current line should be put on a separate +% line and (2) what the distance between the equation and the +% equation tag should be. We implement \tex/'s built-in +% tag-placement as well as possible, with one improvement: the +% minimum separation between tag and equation is now a +% user-settable parameter. +% +% [1995/01/17] Added a check to make sure that the width of the tag +% on the current line is $>0$ before testing to see if tagwidth + +% linewidth + mintagsep $>$ displaywidth. Since an imbedded align +% shows up as line with width \cn{displaywidth}, and even lines +% without a tag get processed as if an empty tag were present, the +% result was that the empty tag assigned to the line containing the +% align was being shifted downwards, creating extra space after the +% align. +% \begin{macrocode} +\def\calc@shift@gather{% + \dimen@\mintagsep\relax + \tagwidth@\tag@width\row@\relax +% \end{macrocode} +% If we're in \opt{fleqn} mode, there is no flexibility about +% placement of the equation, so all we can do is see if there's +% room for the tag in the given margin. +% \begin{macrocode} + \if@fleqn + \global\eqnshift@\@mathmargin + \ifdim\tagwidth@>\z@ + \advance\dimen@\tagwidth@ + \iftagsleft@ + \ifdim\dimen@>\@mathmargin + \global\shifttag@true + \fi + \else + \advance\dimen@\@mathmargin + \advance\dimen@\wdz@ + \ifdim\dimen@>\displaywidth + \global\shifttag@true + \fi + \fi + \fi + \else + \global\eqnshift@\displaywidth + \global\advance\eqnshift@-\wdz@ + \ifdim\tagwidth@>\z@ + \multiply\dimen@\tw@ + \advance\dimen@\wdz@ + \advance\dimen@\tagwidth@ + \ifdim\dimen@>\displaywidth + \global\shifttag@true + \else + \ifdim\eqnshift@<4\tagwidth@ + \global\advance\eqnshift@-\tagwidth@ + \fi + \fi + \fi + \global\divide\eqnshift@\tw@ + \iftagsleft@ + \global\eqnshift@-\eqnshift@ + \global\advance\eqnshift@\displaywidth + \global\advance\eqnshift@-\wdz@ + \fi + \ifdim\eqnshift@<\z@ + \global\eqnshift@\z@ + \fi + \fi +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\place@tag@gather} +% \begin{macro}{\set@gather@field} +% \begin{macrocode} +\def\place@tag@gather{% + \iftagsleft@ + \kern-\gdisplaywidth@ + \ifshifttag@ + \rlap{\vbox{% + \normalbaselines + \boxz@ + \vbox to\lineht@{}% + \raise@tag + }}% + \global\shifttag@false + \else + \rlap{\boxz@}% + \fi + \else + \ifdim\totwidth@>\displaywidth + \dimen@\totwidth@ + \advance\dimen@-\displaywidth + \kern-\dimen@ + \fi + \ifshifttag@ + \llap{\vtop{% + \raise@tag + \normalbaselines + \setbox\@ne\null + \dp\@ne\lineht@ + \box\@ne + \boxz@ + }}% + \global\shifttag@false + \else + \llap{\boxz@}% + \fi + \fi +} +% +\def\set@gather@field{% + \iftagsleft@ + \global\lineht@\ht\z@ + \else + \global\lineht@\dp\z@ + \fi + \kern\eqnshift@ + \boxz@ + \hfil +} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% +% \subsection{The \env{align} family of environments} +% +% The \env{align}, \env{flalign}, \env{alignat}, \env{xalignat}, +% and \env{xxalignat} environments are virtually +% identical, and thus will share much code. We'll refer to the +% environments generically as ``\env{align}'' and will +% distinguish between them explicitly +% only when necessary. +% +% \begin{macro}{\ifxxat@} +% \begin{macro}{\ifcheckat@} +% \begin{macro}{\xatlevel@} +% The \cs{xatlevel@} macro will be used, informally speaking, to +% distinguish between the \env{alignat} and \env{xalignat}, and +% \env{xxalignat} environments. +% +% \begin{macrocode} +\newif\ifxxat@ + +\newif\ifcheckat@ + +\let\xatlevel@\@empty +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\start@align} +% \cs{start@align} will be called by all of the \env{align}-like +% environments. The first argument will be the \cs{xatlevel@}, +% i.e., 0, 1, or~2; the second argument will be either +% \cs{st@rredtrue} or \cs{st@rredfalse}. The third argument will +% be the number of aligned +% structures in the environment (either as supplied by the user, or +% $-1$ to indicate that checking shouldn't be done). After +% performing the appropriate error detection and initialization, +% \cs{start@align} calls \cs{align@}. +% +% Note that the \cs{equation} counter is no longer stepped at the +% beginning of these environments. +% +% TODO: Implement \cs{shoveleft} and \cs{shoveright} for +% \env{align}. +% \begin{macrocode} +\def\start@align#1#2#3{% + \let\xatlevel@#1% always \z@, \@ne, or \tw@ + \maxfields@#3\relax + \ifnum\maxfields@>\m@ne + \checkat@true + \ifnum\xatlevel@=\tw@ + \xxat@true + \fi + \multiply\maxfields@\tw@ + \else + \checkat@false + \fi + \ifingather@ + \iffalse{\fi\ifnum0=`}\fi + \DN@{\vcenter\bgroup\savealignstate@\align@#2}% + \else + \ifmmode + \if@display + \DN@{\align@recover}% + \else + \nomath@env + \DN@{\@namedef{end\@currenvir}{}\@gobble}% + \fi + \else + $$% + \let\split\insplit@ + \DN@{\align@#2}% + \fi + \fi + \collect@body\next@ +} +% \end{macrocode} +% +% With version 1.2 of \pkg{amsmath}, it was possible to use +% \env{align*} and relatives in certain wrong contexts without +% getting an error, e.g. +% \begin{verbatim} +% \begin{equation*} +% \begin{align*} +% ... +% \end{align*} +% \end{equation*} +% \end{verbatim} +% +% For backward compatibility we therefore give only a warning for +% this condition instead of a full error, and try to recover using +% the \env{aligned} environment. The alignment of the material may be +% adversely affected but it will at least remain readable. +% \begin{macrocode} +\def\align@recover#1#2#3{% + \endgroup + \@amsmath@err{% +Erroneous nesting of equation structures;\MessageBreak +trying to recover with `aligned'% + }\@ehc + \begin{aligned}\relax#1\end{aligned}% +} +% \end{macrocode} +% \end{macro} +% +% \begin{environment}{align} +% \begin{environment}{align*} +% \begin{environment}{flalign} +% \begin{environment}{flalign*} +% \begin{environment}{alignat} +% \begin{environment}{alignat*} +% \begin{environment}{xalignat} +% \begin{environment}{xalignat*} +% \begin{environment}{xxalignat} +% The definitions of the various \env{align} environments are quite +% straight-forward. +% +% \begin{macrocode} +\newenvironment{alignat}{% + \start@align\z@\st@rredfalse +}{% + \endalign +} +\newenvironment{alignat*}{% + \start@align\z@\st@rredtrue +}{% + \endalign +} +\newenvironment{xalignat}{% + \start@align\@ne\st@rredfalse +}{% + \endalign +} +\newenvironment{xalignat*}{% + \start@align\@ne\st@rredtrue +}{% + \endalign +} +\newenvironment{xxalignat}{% + \start@align\tw@\st@rredtrue +}{% + \endalign +} +\newenvironment{align}{% + \start@align\@ne\st@rredfalse\m@ne +}{% + \math@cr \black@\totwidth@ + \egroup + \ifingather@ + \restorealignstate@ + \egroup + \nonumber + \ifnum0=`{\fi\iffalse}\fi + \else + $$% + \fi + \ignorespacesafterend +} +\newenvironment{align*}{% + \start@align\@ne\st@rredtrue\m@ne +}{% + \endalign +} +\newenvironment{flalign}{% + \start@align\tw@\st@rredfalse\m@ne +}{% + \endalign +} +\newenvironment{flalign*}{% + \start@align\tw@\st@rredtrue\m@ne +}{% + \endalign +} +% \end{macrocode} +% \end{environment} +% \end{environment} +% \end{environment} +% \end{environment} +% \end{environment} +% \end{environment} +% \end{environment} +% \end{environment} +% \end{environment} +% +% +% \begin{macro}{\align@} +% TODO: Some of these sets of initializations show up in multiple +% places. It might be worth making an abbreviation for them. +% +% \begin{macrocode} +\def\align@#1#2{% + \inalign@true \intertext@ \Let@ \chardef\dspbrk@context\z@ + \ifingather@\else\displ@y@\fi + \let\math@cr@@@\math@cr@@@align + \ifxxat@\else \let\tag\tag@in@align \fi + \let\label\label@in@display + #1% set st@r + \ifst@rred\else \global\@eqnswtrue \fi + \measure@{#2}% + \global\row@\z@ + \tabskip\eqnshift@ + \halign\bgroup + \span\align@preamble\crcr + #2% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\math@cr@@@align} +% \begin{macrocode} +\def\math@cr@@@align{% + \ifst@rred\nonumber\fi + \if@eqnsw \global\tag@true \fi + \global\advance\row@\@ne + \add@amps\maxfields@ + \omit + \kern-\alignsep@ + \iftag@ + \setboxz@h{\@lign\strut@{\make@display@tag}}% + \place@tag + \fi + \ifst@rred\else\global\@eqnswtrue\fi + \global\lineht@\z@ + \cr +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\math@cr@@@align@measure} +% \begin{macrocode} +\def\math@cr@@@align@measure{% + &\omit + \global\advance\row@\@ne + \ifst@rred\nonumber\fi + \if@eqnsw \global\tag@true \fi + \ifnum\column@>\maxfields@ + \ifcheckat@ + \begingroup + \measuring@false + \@amsmath@err{Extra & on this line}% + {\the\andhelp@}% "An extra & here is disastrous" + \endgroup + \else + \global\maxfields@\column@ + \fi + \fi + \setboxz@h{\@lign\strut@{% + \if@eqnsw + \stepcounter{equation}% + \tagform@\theequation + \else + \iftag@\df@tag\fi + \fi + }}% + \savetaglength@ + \ifst@rred\else\global\@eqnswtrue\fi + \cr +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\field@lengths} +% \begin{macro}{\savefieldlength@} +% \begin{macro}{\fieldlengths@} +% \begin{macrocode} +\let\field@lengths\@empty + +\def\savefieldlength@{% + \begingroup + \let\or\relax + \xdef\field@lengths{% + \field@lengths + \ifnum\column@=0 + \or + \else + ,% + \fi + \the\wdz@ + }% + \endgroup +} + +\def\fieldlengths@#1{% + \ifcase\@xp#1\field@lengths\fi +} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\maxcolumn@widths} +% \cs{maxcolumn@widths} will be used to hold the widths of the +% fields of the \env{alignat} environment. The widths will be +% separated by the token \cn{or}, making it easy to extract a given +% width using \cn{ifcase}. +% \begin{macrocode} +\let\maxcolumn@widths\@empty +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\maxcol@width} +% \cs{maxcol@width} $n$ = maximum width of $n$th column of the current +% \env{alignat} (i.e., the $n$th field of \cs{maxcolumn@widths}.) +% It expands to a \<dimen>, so it can be used as the right-hand +% side of a \<variable assignment> or \<arithmetic> statement. +% It's argument can be any \<number>, \<integer variable> or macro +% that expands to one of these. [Check to make sure this is true.] +% +% This is subtler than it looks. +% \begin{macrocode} +\def\maxcol@width#1{% + \ifcase\@xp#1\maxcolumn@widths\fi\relax +} +% \end{macrocode} +% \end{macro} +% +% Now comes the real fun. A typical \env{align} environments looks +% something like this, where the vertical bars mark the edges of +% the fields of the underlying \cs{halign}: +% \[ +% \makeatletter\tabskip\@centering\offinterlineskip +% \halign to\displaywidth{%^^A +% &$\strut$\vrule\hfil$\m@th\displaystyle{\@lign#}$\vrule +% \tabskip1pt&\vrule$\m@th\displaystyle{\@lign#}$\hfil\vrule +% \tabskip\@centering\cr +% \omit\small\hfil 1\hfil &\omit\small\hfil 2 &\omit\small\hfil +% 3\hfil &\omit\small\hfil 4\hfil & \omit\small\hfil 5\hfil +% &\omit\small\hfil 6\hfil\cr +% \noalign{\vskip8pt\relax} +% V_i + q_i v_j & =v_i , & X_i & = x_i - q_i x_j, +% & U_i & = u_i,\qquad +% \hbox{for $i\ne j$;} %&\omit\hfill \llap{(3)} +% \cr +% V_j & = v_j, & X_j & = x_j, +% & U_j & = u_j + \sum_{i\ne j} q_i u_i. %&\omit\hfill \llap{(4)} +% \cr} +% \] +% Note that each align structure consists of two fields, with no +% space between them (a small space has been added here to +% highlight the boundaries). Furthermore, the text inside the +% odd-numbered fields is flushright, while the text inside the +% even-numbered fields is flushleft. The equation tags (shown on +% the right here) can be on either the right or the left. If there +% is not room (in a sense to be defined shortly) for the tag on the +% same line as the equation, the tag will be shifted to a separate +% line. +% +% Each environment also has a certain number of ``flexible +% spaces,'' meaning spaces whose width we are allowed to adjust to +% take up the amount of ``free space'' in the line, meaning the +% space not taken up by the equation tag and the fields of the +% underlying \cs{halign}. +% +% The flexible spaces come in two flavors: interalign spaces and +% margin spaces. If there are $n$ align structures ($n=3$ in the +% illustration above), there are $n-1$ interalign spaces, unless we +% are in an \env{alignat} environment, in which case there are no +% flexible interalign spaces. +% +% The number of margin spaces is a little more complicated: +% Normally, there are two, but if we're in \opt{fleqn} mode, there +% is only one. Furthermore, if we're in an \env{xxalignat} or +% \env{flalign} environment (corresponding to $\cs{xatlevel@} = 2$, +% then there are no flexible margin spaces. +% +% Calculating the interalign and margin spaces is done in two +% stages. +% +% First, the total amount of free space is divided uniformly among +% all the flexible spaces, without regard for the lengths of the tags +% on the various lines. For the non-\opt{fleqn} case, this +% corresponds to centering the align structures between the margins. +% Note that in \opt{fleqn} mode, the right margin is still allowed to +% be larger than \cs{@mathmargin}. This introduces an element of +% asymmetry into the appearance of the environment, but it has the +% advantage of leaving more space for equation tags in the right +% margin. If the right margin were constrained to be equal to the +% left margin in this case, tags would need to be shifted to a +% separate line more often than would be desirable. +% +% Ordinarily, all flexible spaces will be given the same width. +% However, this is not invariably true, since the interalign spaces +% are constrained to be at least \cs{minalignsep} wide, while---in +% the absence of equation tags, at least---the margin spaces are +% allowed to shrink to zero. As we shall see in a minute, if there +% are tags in the environment, then the margins are also bounded +% below by \cs{mintagsep}. +% +% Next, we examine each line of the environment that has a tag to +% see if there is a gap of at least \cs{mintagsep} between the +% equation and its tag. If there isn't, we attempt to center the +% equation between the tag and the opposite margin, leaving a gap +% of at least \cs{mintagsep} on either side, in order to preserve +% some symmetry, i.e., we want the equation to \emph{look} like +% it's centered between the margin and the tag, so we don't want +% the margin space to be less than the gap between the tag and the +% equation. (Arguably, it would be better to allow the margin +% space to shrink to zero in this case in order to avoid shifting +% the tag to a separate line at any cost, but that would require +% all of our calculations to be a little more complicated and hence +% a little slower.) Finally, if no values of the interalign spaces +% and the margins (with the constraints outlined above) will +% produce an acceptable distance between the equation and its tag, +% then the tag will be shifted to a separate line. +% +% \begin{macro}{\measure@} +% \cs{measure@} collects the various bits of information that we'll +% need to perform the calculations outlined above, namely, the +% number of align structures in the environment, the natural +% lengths of the fields on each row, the maximum widths of each +% column, and the widths of the equation tags on each line. It +% also calculates the number of flexible interalign and margin +% spaces and computes the initial values of the parameters +% \cs{eqnshift@} and \cs{alignsep@}, which correspond to the widths +% of the margins and the interalign spaces, respectively. +% \begin{macrocode} +\def\measure@#1{% + \begingroup + \measuring@true + \global\eqnshift@\z@ + \global\alignsep@\z@ + \global\let\tag@lengths\@empty + \global\let\field@lengths\@empty + \savecounters@ + \global\setbox0\vbox{% + \let\math@cr@@@\math@cr@@@align@measure + \everycr{\noalign{\global\tag@false + \global\let\raise@tag\@empty \global\column@\z@}}% + \let\label\@gobble + \global\row@\z@ + \tabskip\z@ + \halign{\span\align@preamble\crcr + #1% + \math@cr@@@ + \global\column@\z@ + \add@amps\maxfields@\cr + }% + }% + \restorecounters@ +% \end{macrocode} +% It's convenient to have \cs{maxfields@} rounded up to the nearest +% even number, so that \cs{maxfields@} is precisely twice the +% number of align structures. +% \begin{macrocode} + \ifodd\maxfields@ + \global\advance\maxfields@\@ne + \fi +% \end{macrocode} +% It doesn't make sense to have a single align structure in either +% \env{flalign} or \env{xxalignat}. So, we check for that case now +% and, if necessary, switch to an \env{align} or \env{alignat}. +% Arguably, we should issue a warning message, but why bother? +% \begin{macrocode} + \ifnum\xatlevel@=\tw@ + \ifnum\maxfields@<\thr@@ + \let\xatlevel@\z@ + \fi + \fi +% \end{macrocode} +% |\box0| now contains the lines of the \cs{halign}. After the +% following maneuver, |\box1| will contain the last line of the +% \cs{halign}, which is what we're interested in. (Incidentally, +% the penalty we're removing is the \cs{@eqpen} inserted by +% \cs{math@cr}. Normally, this is \cs{interdisplaylinepenalty}, +% unless the user has overridden that with a \cs{displaybreak} +% command.) +% \begin{macrocode} + \setbox\z@\vbox{% + \unvbox\z@ \unpenalty \global\setbox\@ne\lastbox + }% +% \end{macrocode} +% |\box1| begins with \cs{tabskip} glue and contains alternating +% \cs{hbox}es (the fields whose widths we're trying to get) and +% \cs{tabskip} glue [need better diagram]: +% \begin{verbatim} +% \hbox{\tabskip\hbox\tabskip...\hbox\tabskip}\end{verbatim} +% In fact, all the \cs{tabskip} glue will be 0pt, because all the +% \cs{tabskip}s in an \env{alignat} environment have a natural +% width of 0pt, and the \cs{halign} has been set in its natural +% width. +% +% One nice result of this is that we can read \cs{totwidth@} off +% immediately, since it is just the width of |\box1|, plus +% \cs{@mathmargin} if we're in \opt{fleqn} mode. (Actually, we +% also have to take \cs{minalignsep} into account, but we'll do +% that later): +% \begin{macrocode} + \global\totwidth@\wd\@ne + \if@fleqn \global\advance\totwidth@\@mathmargin \fi +% \end{macrocode} +% Now we initialize \cs{align@lengths} and start peeling the boxes +% off, one by one, and adding their widths to \cs{align@lengths}. +% We stop when we run out of boxes, i.e., when \cs{lastbox} returns +% a void box. We're going to build a list using \cs{or} as a +% delimiter, so we want to disable it temporarily. +% \begin{macrocode} + \global\let\maxcolumn@widths\@empty + \begingroup + \let\or\relax + \loop + \global\setbox\@ne\hbox{% + \unhbox\@ne \unskip \global\setbox\thr@@\lastbox + }% + \ifhbox\thr@@ + \xdef\maxcolumn@widths{ \or \the\wd\thr@@ \maxcolumn@widths}% + \repeat + \endgroup +% \end{macrocode} +% Now we calculate the number of flexible spaces and the initial +% values of \cs{eqnshift@} and \cs{alignsep@}. +% We start by calculating $\cs{displaywidth}-\cs{totwidth@}$, +% which gives us the total amount of ``free space'' in a row. +% \begin{macrocode} + \dimen@\displaywidth + \advance\dimen@-\totwidth@ +% \end{macrocode} +% Next we calculate the number of columns of flexible spaces in the +% display, which depends on whether we're in \opt{fleqn} mode and +% in which particular environment we are in. +% +% We use \cs{@tempcnta} to store the total number of flexible spaces +% in the align and \cs{@tempcntb} for the number of interalign +% spaces. +% \begin{macrocode} + \ifcase\xatlevel@ +% \end{macrocode} +% In \env{alignat}, the interalign spaces are under user control, +% not ours. So, we set \cs{alignsep@} and \cs{minalignsep} both +% equal to 0pt. Later, when calculating a new value for +% \cs{alignsep@}, we will only save the new value if it is less +% than the current value of \cs{alignsep@} (i.e., \cs{alignsep@} +% will never increase). Since the values we calculate will never +% be negative, this will ensure that \cs{alignsep@} remains zero in +% \env{alignat}. +% \begin{macrocode} + \global\alignsep@\z@ + \let\minalignsep\z@ + \@tempcntb\z@ +% \end{macrocode} +% In \opt{fleqn} mode, the left margin---and hence the right margin +% in this case---is fixed. Otherwise, we divide the free space +% equally between the two margins. +% \begin{macrocode} + \if@fleqn + \@tempcnta\@ne + \global\eqnshift@\@mathmargin + \else + \@tempcnta\tw@ + \global\eqnshift@\dimen@ + \global\divide\eqnshift@\@tempcnta + \fi + \or +% \end{macrocode} +% In an \env{align} or \env{xalignat} environment with $n$ aligned +% structures, there are $n-1$ interalign spaces and either 1 or~2 +% flexible margins, depending on whether we're in \opt{fleqn} mode +% or not. +% \begin{macrocode} + \@tempcntb\maxfields@ + \divide\@tempcntb\tw@ + \@tempcnta\@tempcntb + \advance\@tempcntb\m@ne +% \end{macrocode} +% If we are in \opt{fleqn} mode, we fix the left margin and divide +% the free space equally among the interalign spaces and the right +% margin. +% \begin{macrocode} + \if@fleqn + \global\eqnshift@\@mathmargin + \global\alignsep@\dimen@ + \global\divide\alignsep@\@tempcnta + \else +% \end{macrocode} +% Otherwise, we divide the free space equally among the interalign +% spaces and both margins. +% \begin{macrocode} + \global\advance\@tempcnta\@ne + \global\eqnshift@\dimen@ + \global\divide\eqnshift@\@tempcnta + \global\alignsep@\eqnshift@ + \fi + \or +% \end{macrocode} +% Finally, if we're in an \env{flalign} or \env{xxalignat} +% environment, there are no flexible margins and $n-1$ flexible +% interalign spaces. +% \begin{macrocode} + \@tempcntb\maxfields@ + \divide\@tempcntb\tw@ + \global\advance\@tempcntb\m@ne + \global\@tempcnta\@tempcntb + \global\eqnshift@\z@ + \global\alignsep@\dimen@ +% \end{macrocode} +% If we're in \opt{fleqn} mode, we need to add back the +% \cs{@mathmargin} that was removed when \cs{dimen@} was originally +% calculated above. +% \begin{macrocode} + \if@fleqn + \global\advance\alignsep@\@mathmargin\relax + \fi + \global\divide\alignsep@\@tempcntb + \fi +% \end{macrocode} +% Now we make sure \cs{alignsep@} isn't too small. +% \begin{macrocode} + \ifdim\alignsep@<\minalignsep\relax + \global\alignsep@\minalignsep\relax + \ifdim\eqnshift@>\z@ + \if@fleqn\else + \global\eqnshift@\displaywidth + \global\advance\eqnshift@-\totwidth@ + \global\advance\eqnshift@-\@tempcntb\alignsep@ + \global\divide\eqnshift@\tw@ + \fi + \fi + \fi + \ifdim\eqnshift@<\z@ + \global\eqnshift@\z@ + \fi + \calc@shift@align +% \end{macrocode} +% Next, we calculate the value of \cs{tagshift@}. This is the glue +% that will be inserted in front of the equation tag to make sure +% it lines up flush against the appropriate margin. +% \begin{macrocode} + \global\tagshift@\totwidth@ + \global\advance\tagshift@\@tempcntb\alignsep@ + \if@fleqn + \ifnum\xatlevel@=\tw@ + \global\advance\tagshift@-\@mathmargin\relax + \fi + \else + \global\advance\tagshift@\eqnshift@ + \fi + \iftagsleft@ \else + \global\advance\tagshift@-\displaywidth + \fi +% \end{macrocode} +% Finally, we increase \cs{totwidth@} by an appropriate multiple of +% \cs{minalignsep}. If the result is greater than +% \cs{displaywidth}, it means that at least one line in the +% \env{align} is overfull and we will issue an appropriate warning +% message (via \cs{bl@ck}) at the end of the environment. +% \begin{macrocode} + \dimen@\minalignsep\relax + \global\advance\totwidth@\@tempcntb\dimen@ + \ifdim\totwidth@>\displaywidth + \global\let\displaywidth@\totwidth@ + \else + \global\let\displaywidth@\displaywidth + \fi + \endgroup +} +% \end{macrocode} +% \end{macro} +% +% The code for calculating the appropriate placement of equation +% tags in the \env{align} environments is quite complicated and +% varies wildly depending on the settings of the |tagsleft@| and +% |@fleqn| switches. To minimize memory and hash space usage, we +% only define the variant appropriate for the current setting of +% those switches. +% +% It would be worthwhile to examine this code more closely someday +% and see if it could be optimized any. +% +% \paragraph{Tag placement when \cs{tagsleft@true}, +% \cs{@fleqntrue}.} +% +% We begin with the version of \cs{calc@shift@align} appropriate +% for flush-left equations with tags on the left. +% +% \begin{macro}{\calc@shift@align} +% This is the simplest case. Since the left margin is fixed, in +% general the only thing to do is check whether there is room for +% the tag in the left margin. The only exception is that if +% $\cs{eqnshift@} = 0\,\mathrm{pt}$---meaning that we're in a +% \env{flalign} environment and this is the first line with a tag +% that we've encountered---then we set $\cs{eqnshift@} = +% \cs{@mathmargin}$ and recalculate \cs{alignsep@}. This is done +% by \cs{x@calc@shift@lf}. +% \begin{macrocode} +\iftagsleft@\if@fleqn + \def\calc@shift@align{% + \global\let\tag@shifts\@empty + \begingroup +% \end{macrocode} +% \cs{@tempdima} is initialized to $\cs{@mathmargin} - +% \cs{mintagsep}$, which yields the maximum size of a tag that will +% not be shifted to another line. +% \begin{macrocode} + \@tempdima\@mathmargin\relax + \advance\@tempdima-\mintagsep\relax +% \end{macrocode} +% Now we examine each row in turn. If the width of the tag on the +% line is non-positive---meaning either that there is no tag or +% else that the user has forced it to have zero width---we mark the +% tag to remain unshifted. Otherwise, we call \cs{x@calc@shift@lf} +% to determine whether any adjustments need to be made to +% \cs{eqnshift@} and \cs{alignsep@}. Note the difference in +% treatment of zero-width tags between this code and \tex/'s +% built-in algorithm: here, a width of zero prohibits the tag from +% being shifted, while in \tex/'s built-in algorithm, a width of +% zero forces the tag to be shifted. +% \begin{macrocode} + \loop + \ifnum\row@>0 + \ifdim\tag@width\row@>\z@ + \x@calc@shift@lf + \else + \saveshift@0% + \fi + \advance\row@\m@ne + \repeat + \endgroup + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\x@calc@shift@lf} +% As mentioned above, \cs{x@calc@shift@lf} first checks to see if +% the current left margin is set to 0 and, if so, resets it to +% \cs{@mathmargin} and recalculates \cs{alignsep@}. Next, it +% checks whether the length of the current tag exceeds the +% previously calculated limit and, if so, marks the tag to be +% shifted to a separate line. +% \begin{macrocode} + \def\x@calc@shift@lf{% + \ifdim\eqnshift@=\z@ + \global\eqnshift@\@mathmargin\relax + \alignsep@\displaywidth + \advance\alignsep@-\totwidth@ + \global\divide\alignsep@\@tempcntb + \ifdim\alignsep@<\minalignsep\relax + \global\alignsep@\minalignsep\relax + \fi + \fi + \ifdim\tag@width\row@>\@tempdima + \saveshift@1% + \else + \saveshift@0% + \fi + } +\fi\fi +% \end{macrocode} +% \end{macro} +% +% \paragraph{Tag placement when \cs{tagsleft@false}, +% \cs{@fleqntrue}.} +% +% Next we consider the case when equations are flush-left, but tags +% are on the right. This case is somewhat more complicated than +% the previous one, since we can adjust the right margin by varying +% the inter-align separatin. Thus, when a tag is found to be too +% close to its equation, we first attempt to decrease +% \cs{alignsep@} enough to move the equation off to an acceptable +% distance. Only if that would require a value of \cs{alignsep@} +% less than \cs{minalignsep} do we move the tag to a separate line. +% +% \begin{macro}{\calc@shift@align} +% This version of \cs{calc@shift@align} differs from the previous +% version only in calling \cs{x@calc@shift@rf} rather than +% \cs{x@calc@shift@lf}. +% \begin{macrocode} +\iftagsleft@\else\if@fleqn + \def\calc@shift@align{% + \global\let\tag@shifts\@empty + \begingroup + \loop + \ifnum\row@>0 + \ifdim\tag@width\row@>\z@ + \x@calc@shift@rf + \else + \saveshift@0% + \fi + \advance\row@\m@ne + \repeat + \endgroup + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\x@calc@shift@rf} +% To start, we need to know two quantities: the number of align +% structures in the current row and the ``effective length'' of the +% row, defined as the distance from the left margin to the +% right edge of the text assuming that \cs{eqnshift@} and +% \cs{alignsep@} are both~0. To get the number of align +% structures, we first count the number of columns by counting the +% number of entries in the \cs{fieldlengths@} for the current row. +% The effective length is calcuated by \cs{x@rcalc@width} and put +% in the temporary register \cs{@tempdimc}, using \cs{@tempdimb} as +% an auxiliary variable. +% \begin{macrocode} + \def\x@calc@shift@rf{% + \column@\z@ + \@tempdimb\z@ + \@tempdimc\z@ + \edef\@tempb{\fieldlengths@\row@}% + \@for\@tempa:=\@tempb\do{% + \advance\column@\@ne + \x@rcalc@width + }% + \begingroup +% \end{macrocode} +% If there are $n$ columns in the current row, then there are +% $\lfloor (n+1)/2 \rfloor$ align structures and $\lfloor (n-1)/2 +% \rfloor$ interalign spaces. +% \begin{macrocode} + \advance\column@\m@ne + \divide\column@\tw@ +% \end{macrocode} +% If this is smaller than the maximum number of interalign spaces +% in the environment, then we need to reduce \cs{@tempcnta} (the +% total number of flexible spaces in the current line) by +% $\cs{@tempcntb} - \cs{column@}$ and reset \cs{@tempcntb} to +% \cs{column@}. +% \begin{macrocode} + \ifnum\@tempcntb>\column@ + \advance\@tempcnta-\@tempcntb + \advance\@tempcnta\column@ + \@tempcntb\column@ + \fi +% \end{macrocode} +% Next, we add the width of the tag and the (fixed) left margin to +% the effective length calculated above. This can be used to +% calculate how much ``free space'' there is in the current line +% and thus how much leeway we have to increase the amount of space +% between the tag and the equation. +% \begin{macrocode} + \tagwidth@\tag@width\row@\relax + \@tempdima\eqnshift@ + \advance\@tempdima\@tempdimc\relax + \advance\@tempdima\tagwidth@ +% \end{macrocode} +% The first thing to check is whether the tag should be shifted to +% a separate line. To do this, we add the minimum interalign +% separation and the \cs{mintagsep} to the value of \cs{@tempdima} +% just calculated. This yields the minimum acceptable length of +% the current line. If that is greater than \cs{displaywidth}, we +% mark the tag to be calculated. Otherwise, we mark the tag to be +% kept on the same line and then check to see if the \cs{alignsep@} +% needs to be reduced to make room for the tag. +% \begin{macrocode} + \dimen@\minalignsep\relax + \multiply\dimen@\@tempcntb + \advance\dimen@\mintagsep\relax + \advance\dimen@\@tempdima + \ifdim\dimen@>\displaywidth + \saveshift@1% + \else + \saveshift@0% +% \end{macrocode} +% Now we perform essentially the same calculation, but using the +% current value of \cs{alignsep@} instead of \cs{minalignsep}. +% This gives the current length of the line. If this is greater +% than \cs{displaywidth}, we recalculate \cs{alignsep@} to make +% room for the tag. +% \begin{macrocode} + \dimen@\alignsep@\relax + \multiply\dimen@\@tempcntb + \advance\dimen@\@tempdima + \advance\dimen@\tagwidth@ + \ifdim\dimen@>\displaywidth + \dimen@\displaywidth + \advance\dimen@-\@tempdima + \ifnum\xatlevel@=\tw@ + \advance\dimen@-\mintagsep\relax + \fi + \divide\dimen@\@tempcnta + \ifdim\dimen@<\minalignsep\relax + \global\alignsep@\minalignsep\relax + \else + \global\alignsep@\dimen@ + \fi + \fi + \fi + \endgroup + } +\fi\fi +% \end{macrocode} +% \end{macro} +% +% \paragraph{Tag placement when \cs{tagsleft@false}, +% \cs{@fleqnfalse}.} +% +% This is similar to the previous case, except for the added +% complication that both \cs{alignsep@} and \cs{eqnshift@} can +% vary, which makes the computations correspondingly more +% complicated. +% +% \begin{macro}{\calc@shift@align} +% \begin{macrocode} +\iftagsleft@\else\if@fleqn\else + \def\calc@shift@align{% + \global\let\tag@shifts\@empty + \begingroup + \loop + \ifnum\row@>0 + \ifdim\tag@width\row@>\z@ + \x@calc@shift@rc + \else + \saveshift@0% + \fi + \advance\row@\m@ne + \repeat + \endgroup + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\x@calc@shift@rc} +% \begin{macrocode} + \def\x@calc@shift@rc{% + \column@\z@ + \@tempdimb\z@ + \@tempdimc\z@ + \edef\@tempb{\fieldlengths@\row@}% + \@for\@tempa:=\@tempb\do{% + \advance\column@\@ne + \x@rcalc@width + }% + \begingroup + \advance\column@\m@ne + \divide\column@\tw@ + \ifnum\@tempcntb>\column@ + \advance\@tempcnta-\@tempcntb + \advance\@tempcnta\column@ + \@tempcntb\column@ + \fi + \tagwidth@\tag@width\row@\relax + \@tempdima\@tempdimc + \advance\@tempdima\tagwidth@ + \dimen@\minalignsep\relax + \multiply\dimen@\@tempcntb + \advance\dimen@\mintagsep\relax + \ifnum\xatlevel@=\tw@ \else + \advance\dimen@\mintagsep\relax + \fi + \advance\dimen@\@tempdima + \ifdim\dimen@>\displaywidth + \saveshift@1% + \else + \saveshift@0% + \dimen@\eqnshift@ + \advance\dimen@\@tempdima + \advance\dimen@\@tempcntb\alignsep@ + \advance\dimen@\tagwidth@ + \ifdim\dimen@>\displaywidth + \dimen@\displaywidth + \advance\dimen@-\@tempdima + \ifnum\xatlevel@=\tw@ + \advance\dimen@-\mintagsep\relax + \fi + \divide\dimen@\@tempcnta + \ifdim\dimen@<\minalignsep\relax + \global\alignsep@\minalignsep\relax + \eqnshift@\displaywidth + \advance\eqnshift@-\@tempdima + \advance\eqnshift@-\@tempcntb\alignsep@ + \global\divide\eqnshift@\tw@ + \else + \ifdim\dimen@<\eqnshift@ + \ifdim\dimen@<\z@ + \global\eqnshift@\z@ + \else + \global\eqnshift@\dimen@ + \fi + \fi + \ifdim\dimen@<\alignsep@ + \global\alignsep@\dimen@ + \fi + \fi + \fi + \fi + \endgroup + } +\fi\fi +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\x@rcalc@width} +% \begin{macrocode} +\iftagsleft@\else + \def\x@rcalc@width{% + \ifdim\@tempa > \z@ + \advance\@tempdimc\@tempdimb + \ifodd\column@ + \advance\@tempdimc\maxcol@width\column@ + \@tempdimb\z@ + \else + \advance\@tempdimc\@tempa\relax + \@tempdimb\maxcol@width\column@ + \advance\@tempdimb-\@tempa\relax + \fi + \else + \advance\@tempdimb\maxcol@width\column@\relax + \fi + } +\fi +% \end{macrocode} +% \end{macro} +% +% \paragraph{Tag placement when \cs{tagsleft@true}, +% \cs{@fleqnfalse}.} +% +% \begin{macro}{\calc@shift@align} +% \begin{macrocode} +\iftagsleft@\if@fleqn\else + \def\calc@shift@align{% + \global\let\tag@shifts\@empty + \begingroup + \loop + \ifnum\row@>\z@ + \ifdim\tag@width\row@>\z@ + \x@calc@shift@lc + \else + \saveshift@0% + \fi + \advance\row@\m@ne + \repeat + \endgroup + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\x@calc@shift@lc} +% \begin{macrocode} + \def\x@calc@shift@lc{% + \column@\z@ +% \end{macrocode} +% \cs{@tempdima} will (eventually) be set to the effective width of +% the current row, defined as the distance from the leftmost point +% of the current line to the end of the last field of the +% \cs{halign}, ignoring any intervening \cs{tabskip}s, plus the +% width of the current tag. That is, it will be the width of the +% first non-empty field plus the sum of the maximum widths of all +% following fields, plus the tag width. +% +% \cs{@tempdimb} will be the ``indentation'' of leftmost end of +% text, ignoring the \cs{tabskip} glue, i.e., it will be the sum of +% the maximum widths of any fields to the left of the first +% non-empty field, plus whatever empty space there is at the +% beginning of the first non-empty field. +% \begin{macrocode} + \@tempdima\z@ % ``width of equation'' + \@tempdimb\z@ % ``indent of equation'' + \edef\@tempb{\fieldlengths@\row@}% + \@for\@tempa:=\@tempb\do{% + \advance\column@\@ne + \x@lcalc@width + }% + \begingroup + \tagwidth@\tag@width\row@\relax +% \end{macrocode} +% \cs{@tempdima} is now easy to calculate, since it is just +% $\cs{totwidth@} - \cs{@tempdimb} + \cs{tagwidth@}$. +% \begin{macrocode} + \@tempdima\totwidth@ + \advance\@tempdima-\@tempdimb + \advance\@tempdima\tagwidth@ +% \end{macrocode} +% Next, we check to see whether there is room for both the equation +% and the tag on the same line, by calculating the minimum +% acceptable length of the current row and comparing that to +% \cs{displaywidth}. Note that here we use \cs{@tempcntb}, i.e., +% the number of interalign spaces after the first non-empty align +% structure. +% \begin{macrocode} + \dimen@\minalignsep\relax + \multiply\dimen@\@tempcntb + \advance\dimen@\mintagsep\relax + \ifnum\xatlevel@=\tw@ \else + \advance\dimen@\mintagsep\relax + \fi + \advance\dimen@\@tempdima +% \end{macrocode} +% If the minimum acceptable width of the current line is greater +% than \cs{displaywidth}, we mark the current tag to be shifted to +% a separate line. +% \begin{macrocode} + \ifdim\dimen@>\displaywidth + \saveshift@1% + \else +% \end{macrocode} +% Otherwise, the tag can stay on the same line as the equation, but +% we need to check whether it is too close to the equation. So, we +% calculate the distance between the left margin and the left side +% of the equation, using the current values of \cs{eqnshift@} and +% \cs{alignsep@}. Note that we use \cs{count@} here, not +% \cs{@tempcntb}, as above. +% \begin{macrocode} + \saveshift@0% + \dimen@\alignsep@ + \multiply\dimen@\count@ + \advance\dimen@\eqnshift@ + \advance\dimen@\@tempdimb +% \end{macrocode} +% If the left margin is less than twice the tag width, we calculate +% new values of \cs{eqnshift@} and \cs{alignsep@} to move the +% equation further away from the tag. In particular, we center the +% current line between its tag and the right margin. Note that +% although we later will need to transform \cs{dimen@} into a value +% suitable for use as \cs{eqnshift@}, for the time being it is more +% useful to think of it as the space separating the tag from the +% equation. +% \begin{macrocode} + \ifdim\dimen@<2\tagwidth@ + \dimen@\displaywidth + \advance\dimen@-\@tempdima + \ifnum\xatlevel@=\tw@ + \advance\dimen@-\mintagsep\relax + \fi +% \end{macrocode} +% In certain circumstances we will get a divide-by-zero error here +% unless we guard against it. Use of \cs{@tempcnta} is complicated, +% sometimes it is assigned globally, sometimes locally. Need to sort +% it out one of these days [mjd,2000/06/02]. +% \begin{macrocode} + \ifnum\@tempcnta>\z@ + \divide\dimen@\@tempcnta + \else \dimen@\z@ + \fi +% \end{macrocode} +% As usual, we check to make sure we don't set \cs{alignsep@} +% smaller than \cs{minalignsep} and, in any case, that we don't +% replace \cs{alignsep@} by a larger value. +% \begin{macrocode} + \ifdim\dimen@<\minalignsep\relax + \global\alignsep@\minalignsep\relax + \dimen@\displaywidth + \advance\dimen@-\@tempdima + \advance\dimen@-\@tempcntb\alignsep@ + \global\divide\dimen@\tw@ + \else + \ifdim\dimen@<\alignsep@ + \global\alignsep@\dimen@ + \fi + \fi +% \end{macrocode} +% Next, we calculate an appropriate value of \cs{eqnshift@}, +% assuming that \cs{dimen@} is the desired separation between the +% tag and equation of the current line. This means that we first +% need to adjust \cs{dimen@} if we're in an \env{flalign} +% environment. +% \begin{macrocode} + \ifnum\xatlevel@=\tw@ + \dimen@\mintagsep\relax + \fi +% \end{macrocode} +% Now we calculate the value of \cs{eqnshift@} needed to produce a +% separation of \cs{dimen@} between the equation tag and the +% beginning of the equation. To do this, we need the following +% equation to hold: +% \[ +% \cs{eqnshift@} + n\cs{alignsep@} + \cs{@tempdimb} +% = \cs{tagwidth@} + \cs{dimen@} +% \] +% where $n = \cs{count@}$ is the number of interalign spaces before +% the first non-empty field of the current line. +% \begin{macrocode} + \advance\dimen@\tagwidth@ + \advance\dimen@-\@tempdimb + \advance\dimen@-\count@\alignsep@ +% \end{macrocode} +% The value of \cs{eqnshift@} just calculated is the minimum +% acceptable value; thus, we save it only if it is larger than the +% current value. +% \begin{macrocode} + \ifdim\dimen@>\eqnshift@ + \global\eqnshift@\dimen@ + \fi + \fi + \fi + \endgroup + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\x@lcalc@width} +% This macro calculates the ``indentation'' of the current row, as +% defined above under the description of \cs{x@calc@shift@lc}. +% This macro is called for each field of the current line, with +% \cs{@tempa} set to the width of the current field. Ideally, the +% loop enclosing \cs{x@lcalc@width} would terminate as soon as +% \cs{@tempa} is non-zero, but that would be a bit tricky to +% arrange. Instead, we use \cs{@tempdima} as a flag to signal when +% we've encountered the first non-empty field. +% +% \begin{macrocode} + \def\x@lcalc@width{% + \ifdim\@tempdima = \z@ +% \end{macrocode} +% If the current field is empty (i.e., $\cs{@tempa} = +% \mathrm{0\,pt}$, then we increment \cs{@tempdimb} by the width of +% the current field). Otherwise, we set $\cs{@tempdima} = +% \mathrm{1\,pt}$ as a signal value and increment \cs{@tempdimb} by +% the width of whatever empty space there might be at the left of +% the current field. +% \begin{macrocode} + \ifdim\@tempa > \z@ + \@tempdima\p@ + \ifodd\column@ + \advance\@tempdimb \maxcol@width\column@ + \advance\@tempdimb-\@tempa + \fi +% \end{macrocode} +% In addition, we need to adjust the values of \cs{@tempcnta} and +% \cs{@tempcntb} to account for any empty align structures that +% might occur at the beginning of the current line. More +% specifically, we first set \cs{count@} equal to the number of +% interalign spaces preceding the current field (namely, $\lfloor +% (\cs{\column@}-1)/2 \rfloor$), and then subtract \cs{count@} from +% both \cs{@tempcnta} and \cs{@tempcntb}. The rationale is that +% for the purposes of adjusting the spacing between the tag and the +% equation, the only flexible interalign spaces are those after +% the first non-empty align structure, so we need to treat those +% different from the ones before the first non-empty align +% structure. +% \begin{macrocode} + \count@\column@ + \advance\count@\m@ne + \divide\count@\tw@ + \advance\@tempcnta-\count@ + \advance\@tempcntb-\count@ + \else + \advance\@tempdimb \maxcol@width\column@\relax + \fi + \fi + } +\fi\fi +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\place@tag} +% \cs{place@tag} takes care of the placment of tags in the +% \env{align} environments. +% \begin{macrocode} +\def\place@tag{% + \iftagsleft@ + \kern-\tagshift@ + \if1\shift@tag\row@\relax + \rlap{\vbox{% + \normalbaselines + \boxz@ + \vbox to\lineht@{}% + \raise@tag + }}% + \else + \rlap{\boxz@}% + \fi + \kern\displaywidth@ + \else + \kern-\tagshift@ + \if1\shift@tag\row@\relax +% \end{macrocode} +% Added depth to correct vertical spacing of shifted +% equation tags.---dmj, 1994/12/29 +% \begin{macrocode} + \llap{\vtop{% + \raise@tag + \normalbaselines + \setbox\@ne\null + \dp\@ne\lineht@ + \box\@ne + \boxz@ + }}% + \else + \llap{\boxz@}% + \fi + \fi +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\align@preamble} +% \begin{macrocode} +\def\align@preamble{% + &\hfil + \strut@ + \setboxz@h{\@lign$\m@th\displaystyle{##}$}% + \ifmeasuring@\savefieldlength@\fi + \set@field + \tabskip\z@skip + &\setboxz@h{\@lign$\m@th\displaystyle{{}##}$}% + \ifmeasuring@\savefieldlength@\fi + \set@field + \hfil + \tabskip\alignsep@ +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\set@field} +% \cs{set@field} increments the column counter, tracks the value of +% \cs{lineht@} and finally inserts the box containing the contents +% of the current field. +% \begin{macrocode} +\def\set@field{% + \column@plus + \iftagsleft@ + \ifdim\ht\z@>\lineht@ + \global\lineht@\ht\z@ + \fi + \else + \ifdim\dp\z@>\lineht@ + \global\lineht@\dp\z@ + \fi + \fi + \boxz@ +} +% \end{macrocode} +% \end{macro} +% +% +% \subsection {The \env{split} environment} +% +% \begin{macro}{\split@err} +% A special error function for \env{split} to conserve main mem (at a +% cost of string pool/hash size. +% \begin{macrocode} +\edef\split@err#1{% + \@nx\@amsmath@err{% + \string\begin{split} won't work here% + }{% + \@xp\@nx\csname + Did you forget a preceding \string\begin{equation}?^^J% + If not, perhaps the `aligned' environment is what + you want.\endcsname}% +} +% \end{macrocode} +% \end{macro} +% +% \begin{environment}{split} +% If the \env{split} environment occurs inside \env{align} or +% \env{gather}, it can make use of the enclosing halign; if it is +% called inside a simple equation, we add an implicit `gather' +% container. +% +% \begin{macrocode} +\newenvironment{split}{% + \if@display + \ifinner + \@xp\@xp\@xp\split@aligned + \else + \ifst@rred \else \global\@eqnswtrue \fi + \fi + \else \let\endsplit\@empty \@xp\collect@body\@xp\split@err + \fi + \collect@body\gather@split +}{% + \crcr + \egroup + \egroup + \iftagsleft@ \@xp\lendsplit@ \else \@xp\rendsplit@ \fi +} +% \end{macrocode} +% +% \begin{macrocode} +\let\split@tag\relax % init +% \end{macrocode} +% +% \begin{macrocode} +\def\gather@split#1#2#3{% + \@xp\endgroup \reset@equation % math@cr will handle equation numbering + \iftag@ + \toks@\@xp{\df@tag}% + \edef\split@tag{% + \gdef\@nx\df@tag{\the\toks@}% + \global\@nx\tag@true \@nx\nonumber + }% + \else \let\split@tag\@empty + \fi + \spread@equation +% \end{macrocode} +% The extra vcenter wrapper here is not really a good thing but +% without it there are compatibility problems with old documents that +% throw in some extra material between \verb'\begin{equation}' and +% \verb'\begin{split}' (for example, \verb'\hspace{-1pc}' or +% \verb'\left\{'). [mjd,1999/09/20] +% \begin{macrocode} + \vcenter\bgroup + \gather@{\split@tag \begin{split}#1\end{split}}% + \def\endmathdisplay@a{% + \math@cr \black@ \totwidth@ \egroup + \egroup + }% +} +% \end{macrocode} +% +% \end{environment} +% +% \begin{macro}{\insplit@} +% \begin{macrocode} +\def\insplit@{% + \global\setbox\z@\vbox\bgroup + \Let@ \chardef\dspbrk@context\@ne \restore@math@cr + \default@tag % disallow use of \tag here + \ialign\bgroup + \hfil + \strut@ + $\m@th\displaystyle{##}$% + &$\m@th\displaystyle{{}##}$% + \hfill % Why not \hfil?---dmj, 1994/12/28 + \crcr +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\rendsplit@} +% Moved the box maneuvers inside the \cs{ifinalign@}, since that is +% the only place they are needed.---dmj, 1994/12/28 +% +% TODO: Explore interaction of tag-placement algorithm with +% \env{split}. Is there any way for \env{split} to pass the +% relevant information out to the enclosing \env{gather} or +% \env{align}? +% \begin{macrocode} +\def\rendsplit@{% + \ifinalign@ +% \end{macrocode} +% Changed |\box9| into a \cs{vtop} here for better spacing. +% \begin{macrocode} + \global\setbox9 \vtop{% + \unvcopy\z@ + \global\setbox8 \lastbox + \unskip + }% + \setbox\@ne\hbox{% + \unhcopy8 + \unskip + \global\setbox\tw@\lastbox + \unskip + \global\setbox\thr@@\lastbox + }% + \ifctagsplit@ + \gdef\split@{% + \hbox to\wd\thr@@{}% + &\vcenter{\vbox{\moveleft\wd\thr@@\boxz@}}% + }% + \else + \global\setbox7 \hbox{\unhbox\tw@\unskip}% +% \end{macrocode} +% Added \cs{add@amps} to make sure we put the last line of the +% \env{split} into the proper column of an \env{align} environment +% with multiple align structures.---dmj, 1994/12/28 +% +% Special care has to be taken in this case because the \env{split} +% turns into two lines of the \env{align} instead of just one. So, +% we have to make sure that the first line produced by the +% \env{split} doesn't upset our bookkeeping, hence we call +% \cs{savetaglength@} to insert 0\,pt as the tag for this +% pseudo-line, and we advance the \cs{row@} counter and reset +% \cs{lineht@} afterwards. It would be nice if we could just +% replace the \cs{crcr} by \cs{math@cr@@@}, but that would cause +% problems with the tag processing. +% \begin{macrocode} + \gdef\split@{% + \global\@tempcnta\column@ + &\setboxz@h{}% + \savetaglength@ + \global\advance\row@\@ne + \vbox{\moveleft\wd\thr@@\box9}% + \crcr + \noalign{\global\lineht@\z@}% + \add@amps\@tempcnta + \box\thr@@ + &\box7 + }% + \fi + \else + \ifctagsplit@ + \gdef\split@{\vcenter{\boxz@}}% + \else +% \end{macrocode} +% Changed to just \cs{boxz@}, otherwise last line gets centered +% rather than aligned properly with respect to the rest of the +% lines. But this means that we can't see inside of the last line +% to decide whether the tag needs to be moved. Will have to think +% about this.---dmj, 1994/12/28 +% \begin{macrocode} + \gdef\split@{% + \boxz@ +% \box9 +% \crcr +% \hbox{\box\thr@@\box7}% + }% + \fi + \fi + \aftergroup\split@ +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\lendsplit@} +% \begin{macrocode} +\def\lendsplit@{% + \global\setbox9\vtop{\unvcopy\z@}% + \ifinalign@ +% \end{macrocode} +% Moved following two boxes inside the \cs{ifinalign@}, since they +% are only used in that case. In fact, if we just kept track of +% the width of the first column, we could dispense with this +% entirely. Surely that would be more efficient than all these box +% copies.---dmj, 1994/12/28 +% \begin{macrocode} + \setbox\@ne\vbox{% + \unvcopy\z@ + \global\setbox8\lastbox + }% + \setbox\@ne\hbox{% + \unhcopy8% + \unskip + \setbox\tw@\lastbox + \unskip + \global\setbox\thr@@\lastbox + }% + \ifctagsplit@ + \gdef\split@{% + \hbox to\wd\thr@@{}% + &\vcenter{\vbox{\moveleft\wd\thr@@\box9}}% + }% + \else + \gdef\split@{% + \hbox to\wd\thr@@{}% + &\vbox{\moveleft\wd\thr@@\box9}% + }% + \fi + \else + \ifctagsplit@ + \gdef\split@{\vcenter{\box9}}% + \else + \gdef\split@{\box9}% + \fi + \fi + \aftergroup\split@ +} +% \end{macrocode} +% \end{macro} +% +% With \pkg{amsmath} 1.2 it was possible to put things like +% \verb'\left\{' between \verb'\begin{equation}' and +% \verb'\begin{split}' without getting any error message. For +% backward compatibility we try to avoid a fatal error in this case +% and instead attempt recovery with \env{aligned}. +% \begin{macrocode} +\def\split@aligned#1#2{% + \iffalse{\fi\ifnum0=`}\fi + \collect@body\split@al@a} +% \end{macrocode} +% +% \begin{macrocode} +\def\split@al@a#1#2#3{% + \split@warning + \endgroup +% \end{macrocode} +% If the \opt{fleqn} and \opt{tbtags} options are both in effect then +% we will need to add an optional argument on the \env{aligned} +% environment. +% \begin{macrocode} + \toks@{\begin{aligned}}% + \if@fleqn \split@al@tagcheck \fi +% \end{macrocode} +% The \cs{relax} here is to prevent \cs{@let@token} from being left +% equal to an ampersand if that happens to be the first thing in the body. +% \begin{macrocode} + \the\toks@\relax#1\end{aligned}% + \ifnum0=`{\fi\iffalse}\fi +} +% \end{macrocode} +% +% \begin{macrocode} +\def\split@al@tagcheck{% + \ifctagsplit@ + \else + \iftagsleft@ \toks@\@xp{\the\toks@ [t]}% + \else \toks@\@xp{\the\toks@ [b]}% + \fi + \fi +} +% \end{macrocode} +% +% \begin{macrocode} +\def\split@warning{% + \PackageWarning{amsmath}{% +Cannot use `split' here;\MessageBreak trying to recover with `aligned'}% +} +% \end{macrocode} +% +% \subsection{The \env{multline} environment} +% +% In the original \amstex/, \cn{multlinegap} is a macro with an +% argument that resets an internal dimension (one with an \qc{\@} +% character in its name). Here, to save control sequence names, we +% define \cn{multlinegap} to be the dimension itself and the +% documentation instructs users to use \cn{setlength} if they +% need to change it. +% \begin{macro}{\multlinegap} +% \begin{macro}{\multlinetaggap} +% Changed \cs{multlinegap} and \cs{multlinetaggap} to skip +% registers. Also changed name to \cs{multlinetaggap} from +% \cs{multlinetaggap@}. +% \begin{macrocode} +\newskip\multlinegap +\multlinegap10pt +\newskip\multlinetaggap +\multlinetaggap10pt +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\start@multline} +% \begin{macrocode} +\def\start@multline#1{% + \RIfM@ + \nomath@env + \DN@{\@namedef{end\@currenvir}{}\@gobble}% + \else + $$% + #1% + \ifst@rred + \nonumber + \else + \global\@eqnswtrue + \fi + \let\next@\multline@ + \fi + \collect@body\next@ +} +% \end{macrocode} +% \end{macro} +% +% \begin{environment}{multline} +% \begin{environment}{multline*} +% \begin{macrocode} +\newenvironment{multline}{% + \start@multline\st@rredfalse +}{% + \iftagsleft@ \@xp\lendmultline@ \else \@xp\rendmultline@ \fi + \ignorespacesafterend +} +% \end{macrocode} +% +% \begin{macrocode} +\newenvironment{multline*}{\start@multline\st@rredtrue}{\endmultline} +% \end{macrocode} +% \end{environment} +% \end{environment} +% +% \begin{macro}{\multline@} +% \begin{macrocode} +\def\multline@#1{% + \Let@ +% \end{macrocode} +% +% For multline neither \cs{displ@y} no \cs{displ@y@} is quite right; +% we want to advance the row number and (I suppose?) the +% display-pagebreak level, but we only want to do tag-related stuff +% once before the first line, not repeat it for every line. (Recall +% that the arg of \cs{@display@init} goes into \cs{everycr}.) +% \begin{macrocode} + \@display@init{\global\advance\row@\@ne \global\dspbrk@lvl\m@ne}% + \chardef\dspbrk@context\z@ + \restore@math@cr +% \end{macrocode} +% The \env{multline} environment is somewhat unusual, in that +% \cs{tag} and \cs{label} are enabled only during the measuring +% phase and disabled during the production phase. +% Here we disable \cs{tag} and \cs{label}; \cs{mmeasure@} will +% re-enable them temporarily. +% \begin{macrocode} + \let\tag\tag@in@align + \global\tag@false \global\let\raise@tag\@empty + \mmeasure@{#1}% + \let\tag\gobble@tag \let\label\@gobble + \tabskip \if@fleqn \@mathmargin \else \z@skip \fi + \totwidth@\displaywidth + \if@fleqn + \advance\totwidth@-\@mathmargin + \fi + \halign\bgroup + \hbox to\totwidth@{% +% \end{macrocode} +% In order to get the spacing of the last line right in fleqn +% mode, we need to play a little game here. Normally the +% stretchability of the \cs{hskip} here will be suppressed by the +% \cs{hfil} at the end of the template, except inside the last line, +% when that \cs{hfil} will be removed by the \cs{hfilneg} in +% \cs{lendmultline@}. +% \begin{macrocode} + \if@fleqn + \hskip \@centering \relax + \else + \hfil + \fi + \strut@ + $\m@th\displaystyle{}##\endmultline@math + \hfil + }% + \crcr +% \end{macrocode} +% In \opt{fleqn} mode, it's the \cs{tabskip} of \cs{@mathmargin} +% that needs to be removed in the first line, not the \cs{hfil} at +% the beginning of the template. +% \begin{macrocode} + \if@fleqn + \hskip-\@mathmargin + \def\multline@indent{\hskip\@mathmargin}% put it back + \else + \hfilneg + \def\multline@indent{\hskip\multlinegap}% + \fi + \iftagsleft@ + \iftag@ + \begingroup + \ifshifttag@ + \rlap{\vbox{% + \normalbaselines + \hbox{% + \strut@ + \make@display@tag + }% + \vbox to\lineht@{}% + \raise@tag + }}% +% \end{macrocode} +% If the equation tag doesn't fit on the same line with the first +% line of the display, we'll indent the first line by +% \cn{multlinegap}. This is a change from \pkg{amstex}, where the +% first line would have been flush against the left margin in this +% case. A corresponding change will be made in \cs{rendmultline@}. +% \begin{macrocode} + \multline@indent + \else + \setbox\z@\hbox{\make@display@tag}% + \dimen@\@mathmargin \advance\dimen@-\wd\z@ + \ifdim\dimen@<\multlinetaggap + \dimen@\multlinetaggap + \fi + \box\z@ \hskip\dimen@\relax + \fi + \endgroup + \else + \multline@indent + \fi + \else + \multline@indent + \fi + #1% +} +% \end{macrocode} +% +% An extra level of indirection for the closing \verb'$' in multline +% allows us to avoid getting an extra thinmuskip from a final +% mathpunct in the equation contents, when equation numbers are on +% the right. If we did not use this workaround, the sequence of +% elements for a final comma would be, e.g., +% \begin{verbatim} +% ... ,<hskip><box containing equation number> +% \end{verbatim} +% which is equivalent to a sequence \verb'<mathpunct><mathord>' as +% far as the automatic math spacing is concerned. +% \begin{macrocode} +\def\endmultline@math{$} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\lendmultline@} +% Bug fix: changed \cs{crcr} to \cs{math@cr} so that \cs{@eqpen} +% gets reset properly if \cs{displaybreak} is used on the +% penultimate line of an \env{align}. +% \begin{macrocode} +\def\lendmultline@{% + \hfilneg + \hskip\multlinegap + \math@cr + \egroup + $$% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\rendmultline@} +% \begin{macrocode} +\def\rendmultline@{% + \iftag@ + $\let\endmultline@math\relax + \ifshifttag@ + \hskip\multlinegap +% \end{macrocode} +% Added depth to correct vertical spacing of shifted equation +% tags.---dmj, 1994/12/29 +% \begin{macrocode} + \llap{\vtop{% + \raise@tag + \normalbaselines + \setbox\@ne\null + \dp\@ne\lineht@ + \box\@ne + \hbox{\strut@\make@display@tag}% + }}% + \else + \hskip\multlinetaggap + \make@display@tag + \fi + \else + \hskip\multlinegap + \fi + \hfilneg +% \end{macrocode} +% Use \cs{math@cr} rather than just \cs{crcr} so that \cs{@eqpen} +% gets reset properly if \cs{displaybreak} is used. +% \begin{macrocode} + \math@cr + \egroup$$% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\mmeasure@} +% \begin{macrocode} +\def\mmeasure@#1{% + \begingroup + \measuring@true +% \end{macrocode} +% We use \cs{begin/endgroup} rather than |{}| in this definition of +% \cn{label} because the latter would create an extra (wasteful of +% main mem) null box in the current math list. [mjd, 1995/01/17] +% \begin{macrocode} + \def\label##1{% + \begingroup\measuring@false\label@in@display{##1}\endgroup}% + \def\math@cr@@@{\cr}% + \let\shoveleft\@iden \let\shoveright\@iden + \savecounters@ + \global\row@\z@ + \setbox\@ne\vbox{% + \global\let\df@tag\@empty + \halign{% + \setboxz@h{\@lign$\m@th\displaystyle{}##$}% + \iftagsleft@ + \ifnum\row@=\@ne + \global\totwidth@\wdz@ + \global\lineht@\ht\z@ + \fi + \else + \global\totwidth@\wdz@ + \global\lineht@\dp\z@ + \fi + \crcr + #1% + \crcr + }% + }% + \ifx\df@tag\@empty\else\global\tag@true\fi + \if@eqnsw\global\tag@true\fi + \iftag@ + \setboxz@h{% + \if@eqnsw + \stepcounter{equation}% + \tagform@\theequation + \else + \df@tag + \fi + }% + \global\tagwidth@\wdz@ + \dimen@\totwidth@ + \advance\dimen@\tagwidth@ + \advance\dimen@\multlinetaggap + \iftagsleft@\else + \if@fleqn + \advance\dimen@\@mathmargin + \fi + \fi + \ifdim\dimen@>\displaywidth + \global\shifttag@true + \else + \global\shifttag@false + \fi + \fi + \restorecounters@ + \endgroup +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\shoveleft} +% \begin{macro}{\shoveright} +% \cs{shoveleft} and \cs{shoveright} need to do slightly different +% things depending on whether tags are on the left or the right and +% whether we're in \opt{fleqn} mode. For compactness of code, we +% make the appropriate decisions at ``compile'' time rather than at +% load time. +% +% TODO: Investigate making \cs{shoveright} behave ``properly''(?) if +% used on the first line of a \env{multline} and make \cs{shoveleft} +% behave properly if used on the last line of a \env{multline}. But +% in his \fn{amstex.doc} Spivak indicates those commands should never +% be used on a first or last line. Perhaps better to leave the +% question open unless/until real-life examples turn up. +% \begin{macrocode} +\iftagsleft@ + \def\shoveright#1{% + #1% + \hfilneg + \hskip\multlinegap + } +\else + \def\shoveright#1{% + #1% + \hfilneg + \iftag@ + \ifshifttag@ + \hskip\multlinegap + \else + \hskip\tagwidth@ + \hskip\multlinetaggap + \fi + \else + \hskip\multlinegap + \fi + } +\fi + +\if@fleqn + \def\shoveleft#1{#1}% +\else + \iftagsleft@ + \def\shoveleft#1{% + \setboxz@h{$\m@th\displaystyle{}#1$}% + \setbox\@ne\hbox{$\m@th\displaystyle#1$}% + \hfilneg + \iftag@ + \ifshifttag@ + \hskip\multlinegap + \else + \hskip\tagwidth@ + \hskip\multlinetaggap + \fi + \else + \hskip\multlinegap + \fi + \hskip.5\wd\@ne + \hskip-.5\wdz@ + #1% + } + \else + \def\shoveleft#1{% + \setboxz@h{$\m@th\displaystyle{}#1$}% + \setbox\@ne\hbox{$\m@th\displaystyle#1$}% + \hfilneg + \hskip\multlinegap + \hskip.5\wd\@ne + \hskip-.5\wdz@ + #1% + } + \fi +\fi +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \subsection{The \env{equation} environment} +% +% Rewritten from the ground up for version 2.0 to fix no-shrink and +% no-shortskips bugs [mjd,2000/01/06]. +% +% Standard \latex/ provides three environments for one-line equations: +% \cn{[}\cn{]}, \env{equation}, and \env{displaymath}. We add +% \env{equation*} as a synonym for \env{displaymath}. +% \begin{macrocode} +\@saveprimitive\leqno\@@leqno +\@saveprimitive\eqno\@@eqno +\def\eqno{\@@eqno\let\eqno\relax\let\leqno\relax} +\def\leqno{\@@leqno\let\leqno\relax\let\eqno\relax} +% +\let\veqno=\@@eqno +\iftagsleft@ \let\veqno=\@@leqno \fi +% \end{macrocode} +% +% Support for the \pkg{showkeys} package: provide no-op definitions +% for a couple of SK functions, if they are not already defined. Then +% we can just call them directly in our code without any extra fuss. +% If the \pkg{showkeys} package is loaded later, our trivial +% definitions will get overridden and everything works fine. +% \begin{macrocode} +\@ifundefined{SK@@label}{% + \let\SK@@label\relax \let\SK@equationtrue\relax +}{} +% \end{macrocode} +% +% \begin{macrocode} +\let\reset@equation\@empty +% \end{macrocode} +% +% Cf \cs{tag@in@align}. This is a bit of a mess though. Could use +% some work. [mjd,1999/12/21] +% \begin{macrocode} +\let\alt@tag\@empty +\def\tag@in@display#1#{\relax\tag@in@display@a{#1}} +\def\tag@in@display@a#1#2{% + \iftag@ + \invalid@tag{Multiple \string\tag}\relax + \else + \global\tag@true \nonumber \reset@equation \st@rredtrue + \if *\string#1% + \gdef\alt@tag{\def\SK@tagform@{#2\@gobble}% + \ifx\SK@@label\relax \let\tagform@\SK@tagform@ \fi + }% + \make@df@tag@@{#2}% + \else + \make@df@tag@@@{#2}% + \fi + \fi +} +% \end{macrocode} +% +% \begin{macrocode} +\let\restore@hfuzz\@empty +% \end{macrocode} +% +% \begin{macrocode} +\def\mathdisplay#1{% + \ifmmode \@badmath + \else + $$\def\@currenvir{#1}% +% \end{macrocode} +% Allow use of \cn{displaybreak}. +% \begin{macrocode} + \let\dspbrk@context\z@ +% \end{macrocode} +% Although in some cases simpler label handling would seem to be +% sufficient, always using \cs{label@in@display} makes it easier to +% support the \pkg{showkeys} package. +% \begin{macrocode} + \let\tag\tag@in@display \let\label\label@in@display \SK@equationtrue + \global\let\df@label\@empty \global\let\df@tag\@empty + \global\tag@false + \let\mathdisplay@push\mathdisplay@@push + \let\mathdisplay@pop\mathdisplay@@pop + \if@fleqn +% \end{macrocode} +% Turn off overfull box messages temporarily\mdash otherwise there +% would be unwanted extra ones emitted during our measuring +% operations. +% \begin{macrocode} + \edef\restore@hfuzz{\hfuzz\the\hfuzz\relax}% + \hfuzz\maxdimen +% \end{macrocode} +% Initially set the equation body in a box of displaywidth. Then if +% the box is not overfull, as we find by checking \cs{badness}, we +% have acquired useful information for the subsequent processing. +% \begin{macrocode} + \setbox\z@\hbox to\displaywidth\bgroup + \let\split@warning\relax \restore@hfuzz + \everymath\@emptytoks \m@th $\displaystyle + \fi + \fi +} +% \end{macrocode} +% +% Arg 1 is not currently used. I thought it might come in handy for +% error messages. +% \begin{macrocode} +\def\endmathdisplay#1{% + \ifmmode \else \@badmath \fi + \endmathdisplay@a + $$% +% \end{macrocode} +% I guess the following code means this structure is non-reentrant. +% But there is plenty of scope for tricky bugs here; suppressing them +% by brute force at least makes it possible to get things working +% correctly for normal use. [mjd,2000/01/06] +% \begin{macrocode} + \global\let\df@label\@empty \global\let\df@tag\@empty + \global\tag@false \global\let\alt@tag\@empty + \global\@eqnswfalse +} +% \end{macrocode} +% +% \begin{macrocode} +\def\endmathdisplay@a{% + \if@eqnsw \gdef\df@tag{\tagform@\theequation}\fi + \if@fleqn \@xp\endmathdisplay@fleqn + \else \ifx\df@tag\@empty \else \veqno \alt@tag \df@tag \fi + \ifx\df@label\@empty \else \@xp\ltx@label\@xp{\df@label}\fi + \fi + \ifnum\dspbrk@lvl>\m@ne + \postdisplaypenalty -\@getpen\dspbrk@lvl + \global\dspbrk@lvl\m@ne + \fi +} +% \end{macrocode} +% +% A boolean variable: Was that last box overfull or not? A value of 0 +% means yes, it was overfull. +% \begin{macrocode} +\let\too@wide\@ne +% \end{macrocode} +% +% Special handling is needed for flush-left equations. We need to +% measure the equation body (found in box 0 after we close it with +% the \cs{egroup}). Then after a fairly normal test to see if it fits +% within the available space, we need to consider overlapping into +% the displayindent area if displayindent is nonzero (as in an +% indented list). If there is an equation number we may have to shift +% it by hand to a separate line when there is not enough room; +% we can no longer take advantage of the automatic shifting provided +% by the \cn{leqno}, \cn{eqno} primitives. +% +% We initially add \cs{@mathmargin} glue at the end of box 0 to get +% an accurate overfull test. If \cs{@mathmargin} contains any shrink +% then we cannot reliably tell whether the box will be overfull or +% not simply by doing hand calculations from the actual width of the +% equation body. We have to actually set the box and find out what +% happens. +% +% On the other hand if we put the \cs{@mathmargin} glue at the +% beginning of the box it's awkward to remove it afterwards. So we +% first put it in at the end and later we will move it to the +% beginning as needed. +% +% \begin{macrocode} +\def\endmathdisplay@fleqn{% + $\hfil\hskip\@mathmargin\egroup +% \end{macrocode} +% We need to save the information about whether box 0 was overfull in +% a variable, otherwise it will disappear in the next setbox +% operation. And we couldn't set the equation number box earlier than +% now, because the body of the equation might have contained a +% \cs{tag} command (well, it could have been done, but this way +% we can reuse the tag-handling code from elsewhere). +% \begin{macrocode} + \ifnum\badness<\inf@bad \let\too@wide\@ne \else \let\too@wide\z@ \fi + \ifx\@empty\df@tag + \else + \setbox4\hbox{\df@tag + \ifx\df@label\@empty \else \@xp\ltx@label\@xp{\df@label}\fi + }% + \fi + \csname emdf@% + \ifx\df@tag\@empty U\else \iftagsleft@ L\else R\fi\fi + \endcsname +} +% \end{macrocode} +% +% For an unnumbered flush-left equation we hope first that the +% the contents fit within displaywidth. If not we need to fall back +% on a more complicated reboxing operation. +% \begin{macrocode} +\def\emdf@U{% + \restore@hfuzz + \ifodd\too@wide % not too wide: just need to swap the glue around + \hbox to\displaywidth{\hskip\@mathmargin\unhbox\z@\unskip}% + \else % M+B > displaywidth + \emdf@Ua + \fi +} +% \end{macrocode} +% +% Some notation: $M$ \cs{@mathmargin}, $B$ the width of the equation +% body, $I$ \cs{displayindent}, $D$ \cs{displaywidth}, $N$ the width +% of the equation number (aka the tag), $S$ \cs{mintagsep}, $C$ +% \cs{columnwidth}. If $M+B > \mbox{displaywidth}$, and if we assume +% $M$ contains shrink, then the only solution left is to encroach +% into the displayindent space. +% \begin{macrocode} +\def\emdf@Ua{% + \hbox to\columnwidth{% + \ifdim\displayindent>\z@ + \hskip\displayindent minus\displayindent + \fi + \hskip\@mathmargin \unhbox\z@ \unskip + }% + \displayindent\z@ \displaywidth\columnwidth +} +% \end{macrocode} +% +% Find out first if the tag fits in ideal position. If so we can just +% plunk down box 2. Otherwise we need to do something more complicated. +% \begin{macrocode} +\def\emdf@R{% + \setbox\tw@\hbox to\displaywidth{% + \hskip\@mathmargin \unhcopy\z@\unskip\hfil\hskip\mintagsep\copy4 + }% + \restore@hfuzz + \ifnum\badness<\inf@bad \box\tw@ \else \emdf@Ra \fi +} +% \end{macrocode} +% +% We shift the equation number to line 2 if it does not fit within +% \cs{displaywidth}. Note that we do not first attempt to let the +% equation body shift leftward into the \cs{displayindent} space. If +% that is desired it will have to be done by hand by adding negative +% space at the beginning of the equation body. I don't expect this to +% arise very often in practice since most of the time +% \cs{displayindent} is zero anyway. +% \begin{macrocode} +\def\emdf@Ra{% + \skip@\displayindent minus\displayindent + \displayindent\z@ \displaywidth\columnwidth + \spread@equation \everycr{}\tabskip\z@skip + \halign{\hbox to\displaywidth{##}\cr + \relax + \ifdim\skip@>\z@ \hskip\skip@ \fi + \hskip\@mathmargin\unhbox\z@\unskip\hfil\cr + \noalign{\raise@tag}% + \hfil\box4 \cr}% +} +% \end{macrocode} +% +% Find out first if the tag fits in ideal position. If so we can just +% plunk down box 2. Otherwise we need to do something more +% complicated. +% \begin{macrocode} +\def\emdf@L{% +% \end{macrocode} +% Calculate the difference between $M$ and $N+S$. If the latter is +% greater, we don't want to add any extra glue between the number and +% the equation body. Otherwise the amount that we want to add is +% \verb'x minus x' where $x=M-(N+S)$. I.e., the distribution of +% spaces across the line is $N,S,x minus x,B,hfil$. +% \begin{macrocode} + \@tempdima\@mathmargin + \advance\@tempdima-\wd4 \advance\@tempdima-\mintagsep + \skip@\@tempdima minus\@tempdima + \setbox\tw@\hbox to\displaywidth{% + \copy4\hskip\mintagsep + \ifdim\skip@>\z@ \hskip\skip@\fi + \unhcopy\z@\unskip + }% + \restore@hfuzz + \ifnum\badness<\inf@bad \box\tw@ \else \emdf@La \fi +} +% \end{macrocode} +% +% If the equation body and equation number will not fit on the same +% line, we put the number on line 1 and the body on line 2, with the +% body positioned as for an unnumbered equation. +% \begin{macrocode} +\def\emdf@La{% + \spread@equation \everycr{}\tabskip\z@skip + \halign{\hbox to\displaywidth{##}\cr + \box4 \hfil \cr + \noalign{\raise@tag}% + \hskip\@mathmargin\unhbox\z@\unskip\hfil\cr}% +} +% \end{macrocode} +% +% If someone has \verb'\[ \]' nested inside a minipage environment +% nested inside a numbered equation, the mathdisplay variables that +% are global will get out of whack unless we take extra care. So we +% make a stack and push all the variables before entering mathdisplay +% and pop them afterwards. But we can save a little work by not doing +% this at the top level, only at inner levels. +% \begin{macrocode} +\newtoks\mathdisplay@stack +\let\mathdisplay@push\@empty +\def\mathdisplay@@push{% + \begingroup + \toks@\@xp{\df@label}\@temptokena\@xp{\df@tag}% + \toks8\@xp{\alt@tag}% + \edef\@tempa{% + \global\if@eqnsw\@nx\@eqnswtrue\else\@nx\@eqnswfalse\fi + \global\iftag@\@nx\tag@false\else\@nx\tag@true\fi + \gdef\@nx\df@label{\the\toks@}\gdef\@nx\df@tag{\the\@temptokena}% + \gdef\@nx\alt@tag{\the\toks8}% + \global\mathdisplay@stack{\the\mathdisplay@stack}% + }% + \global\mathdisplay@stack\@xp{\@tempa} + \endgroup +} +% \end{macrocode} +% +% \begin{macrocode} +\let\mathdisplay@pop\@empty +\def\mathdisplay@@pop{\the\mathdisplay@stack} +% \end{macrocode} +% +% \begin{macrocode} +\renewenvironment{equation}{% + \incr@eqnum + \mathdisplay@push + \st@rredfalse \global\@eqnswtrue + \mathdisplay{equation}% +}{% + \endmathdisplay{equation}% + \mathdisplay@pop + \ignorespacesafterend +} +% \end{macrocode} +% +% \begin{macrocode} +\newenvironment{equation*}{% + \mathdisplay@push + \st@rredtrue \global\@eqnswfalse + \mathdisplay{equation*}% +}{% + \endmathdisplay{equation*}% + \mathdisplay@pop + \ignorespacesafterend +} +% \end{macrocode} +% +% Note: \latex/ defines the \env{displaymath} environment in +% terms of \cn{[} and \cn{]}. +% \begin{macrocode} +\DeclareRobustCommand{\[}{\begin{equation*}} +\DeclareRobustCommand{\]}{\end{equation*}} +% \end{macrocode} +% +% The usual \cs{endinput} to ensure that random garbage at the end of +% the file doesn't get copied by \fn{docstrip}. +% \begin{macrocode} +\endinput +% \end{macrocode} +% +% \section{Credits} +% +% Much of the code for the \pkg{amsmath} package had its orgin in +% \fn{amstex.tex}, written by Michael Spivak. The initial work of +% porting \fn{amstex.tex} to \fn{amstex.sty} was done in 1988--1989 +% by Frank Mittelbach and Rainer Sch\"opf. In 1994 David M. Jones +% added the support for the \opt{fleqn} option and did extensive +% improvements to the \env{align[at]} family of environments and to +% the equation number handling in general. Michael Downes at the AMS +% served as coordinator for the efforts of Mittelbach, Sch\"opf, and +% Jones, and has contributed various bug fixes and additional +% refinements over time. +% +% Versions 1.0 and 1.1 of the package carried the name \pkg{amstex} +% instead of \pkg{amsmath}, to indicate its origins; the name was +% changed in 1994 to make it user-oriented rather than +% history-oriented. +% +\endinput diff --git a/macros/latex-dev/required/amsmath/amsmath.ins b/macros/latex-dev/required/amsmath/amsmath.ins new file mode 100644 index 0000000000..7a6a087359 --- /dev/null +++ b/macros/latex-dev/required/amsmath/amsmath.ins @@ -0,0 +1,50 @@ +%% +%% Copyright 2010 American Mathematical Society. +%% Copyright 2016 LaTeX3 Project and American Mathematical Society. +%% +%% This work may be distributed and/or modified under the +%% conditions of the LaTeX Project Public License, either version 1.3c +%% of this license or (at your option) any later version. +%% The latest version of this license is in +%% https://www.latex-project.org/lppl.txt +%% and version 1.3c or later is part of all distributions of LaTeX +%% version 2005/12/01 or later. +%% +%% This work has the LPPL maintenance status `maintained'. +%% +%% The Current Maintainer of this work is the LaTeX3 Project. +%% +%% ==================================================================== + +\input docstrip + +\askforoverwritefalse + +\keepsilent + +\preamble + +Copyright 1995, 1999, 2000, 2013 American Mathematical Society. +Copyright 2016 LaTeX3 Project and American Mathematical Society. + +This work may be distributed and/or modified under the +conditions of the LaTeX Project Public License, either version 1.3c +of this license or (at your option) any later version. +The latest version of this license is in + https://www.latex-project.org/lppl.txt +and version 1.3c or later is part of all distributions of LaTeX +version 2005/12/01 or later. + +This work has the LPPL maintenance status `maintained'. + +The Current Maintainer of this work is the LaTeX3 project. + +\endpreamble + +\usedir{tex/latex/amsmath} + +\generate{ + \file{amsmath.sty}{\from{amsmath.dtx}{}} +} + +\endbatchfile diff --git a/macros/latex-dev/required/amsmath/amsmath.pdf b/macros/latex-dev/required/amsmath/amsmath.pdf Binary files differnew file mode 100644 index 0000000000..94a460afa4 --- /dev/null +++ b/macros/latex-dev/required/amsmath/amsmath.pdf diff --git a/macros/latex-dev/required/amsmath/amsopn.dtx b/macros/latex-dev/required/amsmath/amsopn.dtx new file mode 100644 index 0000000000..b7047377f3 --- /dev/null +++ b/macros/latex-dev/required/amsmath/amsopn.dtx @@ -0,0 +1,263 @@ +% +% \iffalse meta-comment +% +% Copyright (C) 1995, 1999 American Mathematical Society. +% Copyright (C) 2016-2019 LaTeX3 Project and American Mathematical Society. +% +% This work may be distributed and/or modified under the +% conditions of the LaTeX Project Public License, either version 1.3c +% of this license or (at your option) any later version. +% The latest version of this license is in +% https://www.latex-project.org/lppl.txt +% and version 1.3c or later is part of all distributions of LaTeX +% version 2005/12/01 or later. +% +% This work has the LPPL maintenance status `maintained'. +% +% The Current Maintainer of this work is the LaTeX3 Project. +% +% \fi +% +%\iffalse +%<*driver> +\documentclass{amsdtx} +\def\MaintainedByLaTeXTeam#1{% +\begin{center}% +\fbox{\fbox{\begin{tabular}{@{}l@{}}% +This file is maintained by the \LaTeX{} Project team.\\% +Bug reports can be opened (category \texttt{#1}) at\\% +\url{https://latex-project.org/bugs/}.\end{tabular}}}\end{center}} +\let\savedarg\arg +\usepackage{amsopn} +\let\arg\savedarg +\GetFileInfo{amsopn.sty} +\begin{document} +\title{The \pkg{amsopn} package} +\author{Michael Downes} +\date{Version \fileversion, \filedate} +\DocInput{amsopn.dtx} +\end{document} +%</driver> +%\fi +% +% \maketitle +% \MaintainedByLaTeXTeam{amslatex} +% +% \MakeShortVerb\| +% +% \section{Introduction} +% +% The \pkg{amsopn} package provides a command +% \cn{DeclareMathOperator} for defining new `math operator names' +% similar to the standard function names \cn{sin}, \cn{lim}, +% \cn{max}, etc. +% +% \StopEventually{} +% +% Standard file identification. +% \begin{macrocode} +\NeedsTeXFormat{LaTeX2e}% LaTeX 2.09 can't be used (nor non-LaTeX) +[1994/12/01]% LaTeX date must December 1994 or later +\ProvidesPackage{amsopn}[2016/03/08 v2.02 operator names] +% \end{macrocode} +% +% What \cs{nolimits@} does is keep a \cn{limits} typed by the user +% from having any effect. This is used for operatornames whose +% standard usage is never to have limits. +% \begin{macrocode} +\def\nolimits@{\@ifnextchar\limits{\nolimits\@gobble}{\nolimits}} +% \end{macrocode} +% +% In operator names, it is sometimes desired to have text-mode +% punctuation characters such as |*-/:'|. +% Because the body of an +% operator name is set in math mode, these few punctuation +% characters will not come out right (wrong symbol/and or wrong +% spacing). The purpose of \cs{newmcodes@} is to make them act like +% their normal text versions. +% +% Where practical, we use decimal numbers to cut down main mem +% usage (\qc{\"} not needed). +% use |\Umathcodedefnum| with xetex and LuaTeX to avoid problems +% using |\mathcode| if |-| has already been defined using |\Umathcode|. +% \changes{v2.02}{2016/03/08}{Unicode TeX version of \cs{newmcodes@}} +% \begin{macrocode} +\begingroup \catcode`\"=12 +\ifx\Umathcode\@undefined +\gdef\newmcodes@{\mathcode`\'39\mathcode`\*42\mathcode`\."613A% +% \end{macrocode} +% Define \cs{std@minus} for \cs{relbar} use; otherwise there are +% problems with arrows constructed with relbar. +% \begin{macrocode} + \ifnum\mathcode`\-=45 \else + \mathchardef\std@minus\mathcode`\-\relax + \fi + \mathcode`\-45\mathcode`\/47\mathcode`\:"603A\relax} +% \end{macrocode} +% \begin{macrocode} +\else +% \end{macrocode} +% \begin{macrocode} +\gdef\newmcodes@{\mathcode`\'39\mathcode`\*42\mathcode`\."613A% + \ifnum\Umathcodenum`\-=45 \else + \Umathcharnumdef\std@minus\Umathcodenum`\-\relax + \fi + \mathcode`\-45\mathcode`\/47\mathcode`\:"603A\relax} +% \end{macrocode} +% \begin{macrocode} +\fi +\endgroup +% \end{macrocode} +% +% The command \cs{operatorname} prints its argument as a `math +% operator' like \cs{sin} or \cs{det}, with proper font and spacing. +% \begin{macrocode} +\DeclareRobustCommand{\operatorname}{% + \@ifstar{\qopname\newmcodes@ m}% + {\qopname\newmcodes@ o}}% +% \end{macrocode} +% In the interior of the \cs{mathop} we need a null object (we choose +% a zero kern for minimum waste of main mem) in order to guard +% against the case where \arg{3} is a single letter; \tex/ will seize +% it and center it on the math axis if there is nothing else inside +% the \cs{mathop} atom. +% \begin{macrocode} +\DeclareRobustCommand{\qopname}[3]{% + \mathop{#1\kern\z@\operator@font#3}% + \csname n#2limits@\endcsname} +% \end{macrocode} +% +% \begin{macro}{\DeclareMathOperator} +% The command \cn{DeclareMathOperator} defines the first argument to +% be an operator name whose text is the second argument. The star +% form means that the operator name should take limits (like \cn{max} +% or \cn{lim}). +% \begin{macrocode} +\newcommand{\DeclareMathOperator}{% + \@ifstar{\@declmathop m}{\@declmathop o}} +% \end{macrocode} +% \end{macro} +% +% In the basic set of operator names (below) we did not use +% \cn{DeclareRobustCommand} because of the hash table cost. But we +% use it here to minimize the chances of trouble, since we are +% producing a user-defined command. +% \begin{macrocode} +\long\def\@declmathop#1#2#3{% + \@ifdefinable{#2}{% + \DeclareRobustCommand{#2}{\qopname\newmcodes@#1{#3}}}} +% +\@onlypreamble\DeclareMathOperator +\@onlypreamble\@declmathop +% \end{macrocode} +% +% \begin{macrocode} +\def\arccos{\qopname\relax o{arccos}} +\def\arcsin{\qopname\relax o{arcsin}} +\def\arctan{\qopname\relax o{arctan}} +\def\arg{\qopname\relax o{arg}} +\def\cos{\qopname\relax o{cos}} +\def\cosh{\qopname\relax o{cosh}} +\def\cot{\qopname\relax o{cot}} +\def\coth{\qopname\relax o{coth}} +\def\csc{\qopname\relax o{csc}} +\def\deg{\qopname\relax o{deg}} +\def\det{\qopname\relax m{det}} +\def\dim{\qopname\relax o{dim}} +\def\exp{\qopname\relax o{exp}} +\def\gcd{\qopname\relax m{gcd}} +\def\hom{\qopname\relax o{hom}} +\def\inf{\qopname\relax m{inf}} +\def\injlim{\qopname\relax m{inj\,lim}} +\def\ker{\qopname\relax o{ker}} +\def\lg{\qopname\relax o{lg}} +\def\lim{\qopname\relax m{lim}} +\def\liminf{\qopname\relax m{lim\,inf}} +\def\limsup{\qopname\relax m{lim\,sup}} +\def\ln{\qopname\relax o{ln}} +\def\log{\qopname\relax o{log}} +\def\max{\qopname\relax m{max}} +\def\min{\qopname\relax m{min}} +\def\Pr{\qopname\relax m{Pr}} +\def\projlim{\qopname\relax m{proj\,lim}} +\def\sec{\qopname\relax o{sec}} +\def\sin{\qopname\relax o{sin}} +\def\sinh{\qopname\relax o{sinh}} +\def\sup{\qopname\relax m{sup}} +\def\tan{\qopname\relax o{tan}} +\def\tanh{\qopname\relax o{tanh}} +% \end{macrocode} +% +% \begin{macro}{\operator@font} +% \begin{macro}{\operatorfont} +% This command is provided to allow the document styles to decide in +% which way math operators like `max' or `log' are typeset. The +% default is to set them in \meta{math group} zero of the current +% math version. The original name was \cs{operator@font}, retained +% for compatibility; the second name was added to make it +% more accessible so that users can call this font for use in special +% constructs that are not ordinary operator names but conceptually +% related. +% \begin{macrocode} +\def\operator@font{\mathgroup\symoperators} +\def\operatorfont{\operator@font} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% For backwards compatibility we keep this old command name for the +% time being: +% \begin{macrocode} +\def\operatornamewithlimits{\operatorname*} +% \end{macrocode} +% +% These macros use \cs{mathpalette}s so that they will change size +% in script and scriptscript styles, though it's hard to imagine they +% will ever be used there (the arrows, particularly, look bad in +% subscript sizes). Notice that the use of \cs{ex@} means that the +% vertical spacing may not be optimal in script and scriptscript +% sizes. Unfortunately \tex/ provides no easy way to do math mode +% vertical spacing that varies with current math style like mu units. +% \begin{macrocode} +\def\varlim@#1#2{% + \vtop{\m@th\ialign{##\cr + \hfil$#1\operator@font lim$\hfil\cr + \noalign{\nointerlineskip\kern1.5\ex@}#2\cr + \noalign{\nointerlineskip\kern-\ex@}\cr}}% +} +\def\varinjlim{% + \mathop{\mathpalette\varlim@{\rightarrowfill@\textstyle}}\nmlimits@ +} +\def\varprojlim{% + \mathop{\mathpalette\varlim@{\leftarrowfill@\textstyle}}\nmlimits@ +} +\def\varliminf{\mathop{\mathpalette\varliminf@{}}\nmlimits@} +\def\varliminf@#1{\@@underline{\vrule\@depth.2\ex@\@width\z@ + \hbox{$#1\m@th\operator@font lim$}}} +\def\varlimsup{\mathop{\mathpalette\varlimsup@{}}\nmlimits@} +\def\varlimsup@#1{\@@overline{\hbox{$#1\m@th\operator@font lim$}}} +% \end{macrocode} +% +% \begin{macrocode} +\let\nmlimits@\displaylimits +\DeclareOption{namelimits}{\let\nmlimits@\displaylimits} +\DeclareOption{nonamelimits}{\let\nmlimits@\nolimits} +\ProcessOptions\relax +% \end{macrocode} +% +% If we don't load the \pkg{amsgen} package then the use of \cs{ex@} +% in \cs{varlim@} will lead to trouble. +% \begin{macrocode} +\RequirePackage{amsgen}\relax +% \end{macrocode} +% +% The usual \cs{endinput} to ensure that random garbage at the end of +% the file doesn't get copied by \fn{docstrip}. +% \begin{macrocode} +\endinput +% \end{macrocode} +% +% \changes{v1.2a}{1995/02/20}{Fixed operatorname +% (shouldn't have same limits behavior as operatorname*)} +% +% \Finale diff --git a/macros/latex-dev/required/amsmath/amsopn.ins b/macros/latex-dev/required/amsmath/amsopn.ins new file mode 100644 index 0000000000..8c977446cc --- /dev/null +++ b/macros/latex-dev/required/amsmath/amsopn.ins @@ -0,0 +1,50 @@ +%% +%% Copyright 2010 American Mathematical Society. +%% Copyright 2016 LaTeX3 Project and American Mathematical Society. +%% +%% This work may be distributed and/or modified under the +%% conditions of the LaTeX Project Public License, either version 1.3c +%% of this license or (at your option) any later version. +%% The latest version of this license is in +%% https://www.latex-project.org/lppl.txt +%% and version 1.3c or later is part of all distributions of LaTeX +%% version 2005/12/01 or later. +%% +%% This work has the LPPL maintenance status `maintained'. +%% +%% The Current Maintainer of this work is the LaTeX3 Project. +%% +%% ==================================================================== + +\input docstrip + +\askforoverwritefalse + +\keepsilent + +\preamble + +Copyright 1995, 1999 American Mathematical Society. +Copyright 2016 LaTeX3 Project and American Mathematical Society. + +This work may be distributed and/or modified under the +conditions of the LaTeX Project Public License, either version 1.3c +of this license or (at your option) any later version. +The latest version of this license is in + https://www.latex-project.org/lppl.txt +and version 1.3c or later is part of all distributions of LaTeX +version 2005/12/01 or later. + +This work has the LPPL maintenance status `maintained'. + +The Current Maintainer of this work is the LaTeX3 project. + +\endpreamble + +\usedir{tex/latex/amsmath} + +\generate{ + \file{amsopn.sty}{\from{amsopn.dtx}{}} +} + +\endbatchfile diff --git a/macros/latex-dev/required/amsmath/amsopn.pdf b/macros/latex-dev/required/amsmath/amsopn.pdf Binary files differnew file mode 100644 index 0000000000..f854a4246b --- /dev/null +++ b/macros/latex-dev/required/amsmath/amsopn.pdf diff --git a/macros/latex-dev/required/amsmath/amstex.sty b/macros/latex-dev/required/amsmath/amstex.sty new file mode 100644 index 0000000000..edb57c1214 --- /dev/null +++ b/macros/latex-dev/required/amsmath/amstex.sty @@ -0,0 +1,2025 @@ +% +% \iffalse meta-comment +% +% Copyright 1995, 1999 American Mathematical Society. +% Copyright 2016 LaTeX3 Project and American Mathematical Society. +% +% This work may be distributed and/or modified under the +% conditions of the LaTeX Project Public License, either version 1.3c +% of this license or (at your option) any later version. +% The latest version of this license is in +% https://www.latex-project.org/lppl.txt +% and version 1.3c or later is part of all distributions of LaTeX +% version 2005/12/01 or later. +% +% This work has the LPPL maintenance status `maintained'. +% +% The Current Maintainer of this work is the LaTeX3 Project. +% +% \fi +% +% This file was generated from version 1.2beta of amstex.dtx and then +% underwent additional hand-editing. +\if@compatibility \else \catcode`\%=9 \fi +%\PackageError{amstex}{% +%Package `amstex' is obsolete, substituting `amsmath'}{You +%should use \string\usepackage{amsmath} instead. If +%that does not give satisfactory results, rename your previous copy +%of amstex.sty to amstex12beta.sty and call it with +%\string\usepackage{amstex12beta}.} +%\catcode`\%=14 \relax \input{amsmath.sty}\endinput +% +\ProvidesPackage{amstex}[1999/11/15 v1.2f AMS extra math features] +\let\@amsfonts=T +\DeclareOption{noamsfonts}{\let\@amsfonts=F} +\DeclareOption{psamsfonts}{\let\@amsfonts=P} +\DeclareOption{intlimits}{\let\ilimits@\displaylimits} +\DeclareOption{nointlimits}{\let\ilimits@\nolimits} +\DeclareOption{sumlimits}{\let\slimits@\displaylimits} +\DeclareOption{nosumlimits}{\let\slimits@\nolimits} +\DeclareOption{namelimits}{\let\nlimits@\displaylimits} +\DeclareOption{nonamelimits}{\let\nlimits@\nolimits} +\newif\ifctagsplit@ +\newif\iftagsleft@ +\DeclareOption{leqno}{\tagsleft@true} +\DeclareOption{reqno}{\tagsleft@false} +\DeclareOption{centertags}{\ctagsplit@true} +\DeclareOption{tbtags}{\ctagsplit@false} +\newif\if@fleqn +\newskip\@mathmargin +\@mathmargin\@centering +\DeclareOption{fleqn}{% + \@fleqntrue + \@mathmargin\m@ne sp + \AtBeginDocument{% + \ifdim\@mathmargin=\m@ne sp + \@mathmargin\leftmargini + \fi + }% +} +\DeclareOption{righttag}{\tagsleft@false} +\DeclareOption{ctagsplt}{\ctagsplit@true} +\DeclareOption{intlim}{\let\ilimits@\displaylimits} +\DeclareOption{nosumlim}{\let\slimits@\nolimits} +\DeclareOption{nonamelm}{\let\nlimits@\nolimits} +\ExecuteOptions{nointlimits,sumlimits,namelimits,centertags} +\ProcessOptions +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% In this section \RequirePackage statements were replaced with the +%% contents of the referenced files. +%%% filename = "amsgen.dtx", +%%% version = "1.2beta", +%%% date = "1994/12/13", +\providecommand{\@saveprimitive}[2]{\begingroup\escapechar`\\\relax + \edef\@tempa{\string#1}\edef\@tempb{\meaning#1}% + \ifx\@tempa\@tempb \global\let#2#1% + \else + \edef\@tempb{\meaning#2}% + \ifx\@tempa\@tempb + \else + \@latex@error{Unable to properly define \string#2; primitive + \noexpand#1no longer primitive}\@eha + \fi + \fi + \endgroup} +\let\@xp=\expandafter +\let\@nx=\noexpand +\newtoks\@emptytoks +\def\@oparg#1[#2]{\@ifnextchar[{#1}{#1[#2]}} +\def\@ifempty#1{\@xifempty#1@@..\@nil} +\long\def\@xifempty#1#2@#3#4#5\@nil{% + \ifx#3#4\@xp\@firstoftwo\else\@xp\@secondoftwo\fi} +\long\def\@ifnotempty#1{\@ifempty{#1}{}} +\def\FN@{\futurelet\@let@token} +\def\DN@{\def\next@} +\def\RIfM@{\relax\ifmmode} +\def\setboxz@h{\setbox\z@\hbox} +\def\wdz@{\wd\z@} +\def\boxz@{\box\z@} +\def\relaxnext@{\let\@let@token\relax} +\def\new@ifnextchar#1#2#3{% + \let\@tempe #1\def\@tempa{#2}\def\@tempb{#3}\futurelet + \@tempc\new@ifnch} +\def\new@ifnch{\ifx\@tempc \@tempe \let\@tempd\@tempa + \else\let\@tempd\@tempb\fi\@tempd} +\def\new@ifstar#1#2{\new@ifnextchar *{\def\@tempa*{#1}\@tempa}{#2}} +\@ifundefined{every@math@size}{% +\let\every@math@size=\every@size +\def\glb@settings{% + \expandafter\ifx\csname S@\f@size\endcsname\relax + \calculate@math@sizes + \fi + \csname S@\f@size\endcsname + \ifmath@fonts + \begingroup + \escapechar\m@ne + \csname mv@\math@version \endcsname + \globaldefs\@ne + \let \glb@currsize \f@size + \math@fonts + \endgroup + \the\every@math@size + \else + \fi +} +\def\set@fontsize#1#2#3{% + \@defaultunits\@tempdimb#2pt\relax\@nnil + \edef\f@size{\strip@pt\@tempdimb}% + \@defaultunits\@tempskipa#3pt\relax\@nnil + \edef\f@baselineskip{\the\@tempskipa}% + \edef\f@linespread{#1}% + \let\baselinestretch\f@linespread + \def\size@update{% + \baselineskip\f@baselineskip\relax + \baselineskip\f@linespread\baselineskip + \normalbaselineskip\baselineskip + \setbox\strutbox\hbox{% + \vrule\@height.7\baselineskip + \@depth.3\baselineskip + \@width\z@}% +%%% \the\every@size + \let\size@update\relax}% + } +}{}% end \@ifundefined test +\newdimen\ex@ +\addto@hook\every@math@size{\compute@ex@} +\def\compute@ex@{% + \begingroup + \dimen@-\f@size\p@ + \ifdim\dimen@<-20\p@ + \global\ex@ 1.5\p@ + \else + \advance\dimen@10\p@ \multiply\dimen@\tw@ + \edef\@tempa{\ifdim\dimen@>\z@ -\fi}% + \dimen@ \ifdim\dimen@<\z@ -\fi \dimen@ + \advance\dimen@-\@m sp % fudge factor + \vfuzz\p@ + \def\do{\ifdim\dimen@>\z@ + \vfuzz=.97\vfuzz + \advance\dimen@ -\p@ + \@xp\do \fi}% + \do + \dimen@\p@ \advance\dimen@-\vfuzz + \global\ex@\p@ + \global\advance\ex@ \@tempa\dimen@ + \fi + \endgroup +} +\def\@addpunct#1{\ifnum\spacefactor>\@m \else#1\fi} +\def\frenchspacing{\sfcode`\.1006\sfcode`\?1005\sfcode`\!1004% + \sfcode`\:1003\sfcode`\;1002\sfcode`\,1001 } +\def\@mathmeasure#1#2#3{\setbox#1\hbox{\frozen@everymath\@emptytoks + \m@th$#2#3$}} +\def\nomath@env{\PackageError{amstex}{% + \string\begin{\@currenvir} allowed only in paragraph mode% +}\@ehb% "You've lost some text" +} +\def\Invalid@@{Invalid use of \string} +\def\nonmatherr@#1{\PackageError{amsfonts}% + {\noexpand#1allowed only in math mode}\@ehd} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%% filename = "amstext.dtx", +%%% version = "1.2beta", +%%% date = "1994/12/13", +\DeclareRobustCommand{\text}{% + \ifmmode\expandafter\text@\else\expandafter\mbox\fi} +\let\nfss@text\text +\def\text@#1{\mathchoice + {\textdef@\displaystyle\f@size{#1}}% + {\textdef@\textstyle\tf@size{\firstchoice@false #1}}% + {\textdef@\textstyle\sf@size{\firstchoice@false #1}}% + {\textdef@\textstyle \ssf@size{\firstchoice@false #1}}% + \check@mathfonts +} +\def\textdef@#1#2#3{\hbox{{% + \everymath{#1}% + \let\f@size#2\selectfont + #3}}} +\newif\iffirstchoice@ +\firstchoice@true +\def\stepcounter#1{% + \iffirstchoice@ + \global\expandafter\advance\csname c@#1\endcsname \@ne + \begingroup + \let\@elt\@stpelt + \csname cl@#1\endcsname + \endgroup + \fi} +\toks@{\iffirstchoice@\else\@xp\@gobblefour\fi\protect} +\edef\GenericInfo{\the\toks@ + \@xp\@nx\csname GenericInfo \endcsname} +\edef\GenericWarning{\the\toks@ + \@xp\@nx\csname GenericWarning \endcsname} +\toks@{\iffirstchoice@\else + \@xp\@xp\@xp\@gobblefour + \@xp\@gobbletwo\fi\protect} +\edef\GenericError{\the\toks@ + \@xp\@nx\csname GenericError \endcsname} +\def\label#1{\@bsphack\iffirstchoice@\if@filesw {\let\thepage\relax + \def\protect{\noexpand\noexpand\noexpand}% +\xdef\@gtempa{\write\@auxout{\string + \newlabel{#1}{{\@currentlabel}{\thepage}}}}}\@gtempa + \if@nobreak \ifvmode\nobreak\fi\fi\fi\fi\@esphack} +\begingroup \catcode`\"=12 +\gdef\mathhexbox#1#2#3{\text{$\m@th\mathchar"#1#2#3$}} +\endgroup +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%% filename = "amsfonts.dtx", +%%% version = "1.2beta", +%%% date = "1994/12/13", +\newbox\Mathstrutbox@ +\setbox\Mathstrutbox@=\hbox{} +\def\Mathstrut@{\copy\Mathstrutbox@} +\addto@hook\every@math@size{\setbox\z@\hbox{\normalfont(}% + \ht\Mathstrutbox@\ht\z@ \dp\Mathstrutbox@\dp\z@} +\newbox\strutbox@ +\def\strut@{\copy\strutbox@} +\addto@hook\every@math@size{% + \global\setbox\strutbox@\hbox{\lower.5\normallineskiplimit + \vbox{\kern-\normallineskiplimit\copy\strutbox}}} +\def\big{\bBigg@\@ne} +\def\Big{\bBigg@{1.5}} +\def\bigg{\bBigg@\tw@} +\def\Bigg{\bBigg@{2.5}} +\def\bBigg@#1#2{% + {% + \hbox{$\left#2\vcenter to#1\big@size{}\right.% + \n@space + $}}} +\addto@hook\every@math@size{% + \global\big@size 1.2\ht\Mathstrutbox@ + \global\advance\big@size 1.2\dp\Mathstrutbox@ } +\newdimen\big@size +%% msam, msbm, eufm fonts dealt with at end of file +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%% filename = "amsbsy.dtx", +%%% version = "1.2beta", +%%% date = "1994/10/27", +\DeclareRobustCommand{\boldsymbol}[1]{% + \begingroup + \let\@nomath\@gobble \mathversion{bold}% + \math@atom{#1}{% + \mathchoice% + {\hbox{$\m@th\displaystyle#1$}}% + {\hbox{$\m@th\textstyle#1$}}% + {\hbox{$\m@th\scriptstyle#1$}}% + {\hbox{$\m@th\scriptscriptstyle#1$}}}% + \endgroup} +\def\math@atom#1#2{% + \binrel@{#1}\binrel@@{#2}} +\DeclareRobustCommand{\pmb}{% + \ifmmode\else \expandafter\pmb@@\fi\mathpalette\pmb@} +\def\pmb@@#1#2#3{\leavevmode\setboxz@h{#3}% + \dimen@-\wdz@ + \kern-.5\ex@\copy\z@ + \kern\dimen@\kern.25\ex@\raise.4\ex@\copy\z@ + \kern\dimen@\kern.25\ex@\box\z@ +} +\newdimen\pmbraise@ +\def\pmb@#1#2{\setbox8\hbox{$\m@th#1{#2}$}% + \setboxz@h{$\m@th#1\mkern.5mu$}\pmbraise@\wdz@ + \binrel@{#2}% + \dimen@-\wd8 % + \binrel@@{% + \mkern-.8mu\copy8 % + \kern\dimen@\mkern.4mu\raise\pmbraise@\copy8 % + \kern\dimen@\mkern.4mu\box8 }% +} +\def\binrel@#1{\begingroup + \setboxz@h{\thinmuskip0mu + \medmuskip\m@ne mu\thickmuskip\@ne mu + \setbox\tw@\hbox{$#1\m@th$}\kern-\wd\tw@ + ${}#1{}\m@th$}% + \edef\@tempa{\endgroup\let\noexpand\binrel@@ + \ifdim\wdz@<\z@ \mathbin + \else\ifdim\wdz@>\z@ \mathrel + \else \relax\fi\fi}% + \@tempa +} +\let\binrel@@\relax +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\def\AmSTeX{\protect\AmS-\protect\TeX{}} +\def\AmS{{\protect\AmSfont + A\kern-.1667em\lower.5ex\hbox{M}\kern-.125emS}} +\def\AmSfont{% + \usefont{OMS}{cmsy}{\if\@xp\@car\f@series\@nil bb\else m\fi}{n}} +\def\prim@s{\prime\futurelet\@let@token\pr@m@s} +\def\pr@m@s{% + \ifx\@let@token'\DN@##1{\prim@s}\else\let\next@\egroup\fi\next@} +\let\@prime=\prime +\renewcommand{\prime}{{\kern\z@\@prime}} +\DeclareRobustCommand{\mspace}[3]{% + \ifmmode\mskip#1#2\else\kern#1#3\fi\relax} +\renewcommand{\,}{\mspace+\thinmuskip{.1667em}} +\let\thinspace\, +\renewcommand{\!}{\mspace-\thinmuskip{.1667em}} +\let\negthinspace\! +\renewcommand{\:}{\mspace+\medmuskip{.2222em}} +\let\medspace\: +\newcommand{\negmedspace}{\mspace-\medmuskip{.2222em}} +\renewcommand{\;}{\mspace+\thickmuskip{.2777em}} +\let\thickspace\; +\newcommand{\negthickspace}{\mspace-\thickmuskip{.2777em}} +\def\implies{\DOTSB\;\Longrightarrow\;} +\def\impliedby{\DOTSB\;\Longleftarrow\;} +\begingroup \catcode`\"=12 % in case activated by a preceding package +\gdef\And{\DOTSB\;\mathchar"3026 \;} +\gdef\lvert{\delimiter"426A30C } +\gdef\rvert{\delimiter"526A30C } +\gdef\lVert{\delimiter"426B30D } +\gdef\rVert{\delimiter"526B30D } +\endgroup % restore " +\DeclareRobustCommand{\frac}{\new@ifnextchar[{\frfrac{}}{\frfrac{}[]}} +\def\frfrac#1[#2]#3#4{\def\next@{#2}% + \ifx\next@\@empty \def\next@{#1{#3\over#4}}% + \else \def\next@{{#1{#3\above#2\relax#4}}}% + \fi + \next@} +\def\dfrac{\protect\frfrac\displaystyle[]} +\def\tfrac{\protect\frfrac\textstyle[]} +\DeclareRobustCommand{\binom}{\frbinom{}} +\def\frbinom#1#2#3{{#1{#2\atopwithdelims()#3}}} +\def\dbinom{\protect\frbinom\displaystyle} +\def\tbinom{\protect\frbinom\textstyle} +\def\colon{\nobreak\mskip2mu\mathpunct{}\nonscript + \mkern-\thinmuskip{:}\mskip6muplus1mu\relax} +\begingroup \catcode`\"=12 +\DeclareMathSymbol{\coprod@}{\mathop}{largesymbols}{"60} +\gdef\coprod{\DOTSB\coprod@\slimits@} +\DeclareMathSymbol{\bigvee@}{\mathop}{largesymbols}{"57} +\gdef\bigvee{\DOTSB\bigvee@\slimits@} +\DeclareMathSymbol{\bigwedge@}{\mathop}{largesymbols}{"56} +\gdef\bigwedge{\DOTSB\bigwedge@\slimits@} +\DeclareMathSymbol{\biguplus@}{\mathop}{largesymbols}{"55} +\gdef\biguplus{\DOTSB\biguplus@\slimits@} +\DeclareMathSymbol{\bigcap@}{\mathop}{largesymbols}{"54} +\gdef\bigcap{\DOTSB\bigcap@\slimits@} +\DeclareMathSymbol{\bigcup@}{\mathop}{largesymbols}{"53} +\gdef\bigcup{\DOTSB\bigcup@\slimits@} +\DeclareMathSymbol{\prod@}{\mathop}{largesymbols}{"51} +\gdef\prod{\DOTSB\prod@\slimits@} +\DeclareMathSymbol{\sum@}{\mathop}{largesymbols}{"50} +\gdef\sum{\DOTSB\sum@\slimits@} +\DeclareMathSymbol{\bigotimes@}{\mathop}{largesymbols}{"4E} +\gdef\bigotimes{\DOTSB\bigotimes@\slimits@} +\DeclareMathSymbol{\bigoplus@}{\mathop}{largesymbols}{"4C} +\gdef\bigoplus{\DOTSB\bigoplus@\slimits@} +\DeclareMathSymbol{\bigodot@}{\mathop}{largesymbols}{"4A} +\gdef\bigodot{\DOTSB\bigodot@\slimits@} +\DeclareMathSymbol{\bigsqcup@}{\mathop}{largesymbols}{"46} +\gdef\bigsqcup{\DOTSB\bigsqcup@\slimits@} +\endgroup +\def\dddot#1{{\mathop{#1}\limits^{\vbox to-1.4\ex@{\kern-\tw@\ex@ + \hbox{\normalfont ...}\vss}}}} +\def\ddddot#1{{\mathop{#1}\limits^{\vbox to-1.4\ex@{\kern-\tw@\ex@ + \hbox{\normalfont....}\vss}}}} +\def~{\nobreakspace} +\DeclareRobustCommand{\nobreakspace}{\unskip\nobreak\ \ignorespaces} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\newif\if@display +\everydisplay\expandafter{\the\everydisplay \@displaytrue} +\def\int{\DOTSI\intop\ilimits@} +\def\oint{\DOTSI\ointop\ilimits@} +\def\intkern@{\mkern-6mu\mathchoice{\mkern-3mu}{}{}{}} +\def\intdots@{\mathchoice{\@cdots}% + {{\cdotp}\mkern1.5mu{\cdotp}\mkern1.5mu{\cdotp}}% + {{\cdotp}\mkern1mu{\cdotp}\mkern1mu{\cdotp}}% + {{\cdotp}\mkern1mu{\cdotp}\mkern1mu{\cdotp}}} + +\def\iint{\DOTSI\protect\ints@\tw@} +\def\iiint{\DOTSI\protect\ints@\thr@@} +\def\iiiint{\DOTSI\protect\ints@{4}} +\def\idotsint{\DOTSI\protect\ints@\z@} + +\def\ints@#1{% + \mkern-7mu\mathchoice{\mkern-2mu}{}{}{}% + \mathop{\mkern7mu\mathchoice{\mkern2mu}{}{}{}% + \intop\ifnum#1=\z@\intdots@ + \else\intkern@\fi + \ifnum#1>\tw@\intop\intkern@\fi + \ifnum#1>\thr@@\intop\intkern@\fi + \intop + }\ilimits@ +} +\def\nolimits@{% + \DN@{\nolimits\ifx\@let@token\limits\expandafter\@gobble\fi}% + \FN@\next@} +\begingroup \catcode`\"=12 +\gdef\newmcodes@{\mathcode`\'39\mathcode`\*42\mathcode`\."613A% + \mathcode`\-45\mathcode`\/47\mathcode`\:"603A\relax} +\endgroup +\DeclareRobustCommand{\operatorname}{% + \@ifstar{\qopname\newmcodes@ n}% + {\qopname\newmcodes@{no}}}% +\DeclareRobustCommand{\qopname}[3]{\mathop{#1\kern\z@\operator@font#3}% + \csname #2limits@\endcsname} +\def\arccos{\qopname\relax{no}{arccos}} +\def\arcsin{\qopname\relax{no}{arcsin}} +\def\arctan{\qopname\relax{no}{arctan}} +\def\arg{\qopname\relax{no}{arg}} +\def\cos{\qopname\relax{no}{cos}} +\def\cosh{\qopname\relax{no}{cosh}} +\def\cot{\qopname\relax{no}{cot}} +\def\coth{\qopname\relax{no}{coth}} +\def\csc{\qopname\relax{no}{csc}} +\def\deg{\qopname\relax{no}{deg}} +\def\det{\qopname\relax n{det}} +\def\dim{\qopname\relax{no}{dim}} +\def\exp{\qopname\relax{no}{exp}} +\def\gcd{\qopname\relax n{gcd}} +\def\hom{\qopname\relax{no}{hom}} +\def\inf{\qopname\relax n{inf}} +\def\injlim{\qopname\relax n{inj\,lim}} +\def\ker{\qopname\relax{no}{ker}} +\def\lg{\qopname\relax{no}{lg}} +\def\lim{\qopname\relax n{lim}} +\def\liminf{\qopname\relax n{lim\,inf}} +\def\limsup{\qopname\relax n{lim\,sup}} +\def\ln{\qopname\relax{no}{ln}} +\def\log{\qopname\relax{no}{log}} +\def\max{\qopname\relax n{max}} +\def\min{\qopname\relax n{min}} +\def\Pr{\qopname\relax n{Pr}} +\def\projlim{\qopname\relax n{proj\,lim}} +\def\sec{\qopname\relax{no}{sec}} +\def\sin{\qopname\relax{no}{sin}} +\def\sinh{\qopname\relax{no}{sinh}} +\def\sup{\qopname\relax n{sup}} +\def\tan{\qopname\relax{no}{tan}} +\def\tanh{\qopname\relax{no}{tanh}} +\def\operator@font{\mathgroup\symoperators} +\def\operatornamewithlimits{\operatorname*} +\def\varlim@#1#2{\mathop{\vtop{\ialign{##\crcr + \hfil$#1\m@th\operator@font lim$\hfil\crcr + \noalign{\nointerlineskip\kern\ex@}#2#1\crcr + \noalign{\nointerlineskip\kern-\ex@}\crcr}}}} +\def\varinjlim{\mathpalette\varlim@\rightarrowfill@} +\def\varprojlim{\mathpalette\varlim@\leftarrowfill@} +\def\varliminf{\mathpalette\varliminf@{}} +\def\varliminf@#1{\mathop{\@@underline{\vrule\@depth.2\ex@\@width\z@ + \hbox{$#1\m@th\operator@font lim$}}}} +\def\varlimsup{\mathpalette\varlimsup@{}} +\def\varlimsup@#1{\mathop{\@@overline + {\hbox{$#1\m@th\operator@font lim$}}}} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\def\numberwithin#1#2{\@ifundefined{c@#1}{\@nocounterr{#1}}{% + \@ifundefined{c@#2}{\@nocnterr{#2}}{% + \@addtoreset{#1}{#2}% + \toks@\expandafter\expandafter\expandafter{\csname the#1\endcsname}% + \expandafter\xdef\csname the#1\endcsname + {\expandafter\noexpand\csname the#2\endcsname + .\the\toks@}}}} +\def\eqref#1{\textup{\tagform@{\ref{#1}}}} +\def\bmod{\mskip-\medmuskip\mkern5mu\mathbin + {\operator@font mod}\penalty900 + \mkern5mu\mskip-\medmuskip} +\def\pod#1{\allowbreak\if@display\mkern18mu\else\mkern8mu\fi(#1)} +\def\pmod#1{\pod{{\operator@font mod}\mkern6mu#1}} +\def\mod#1{\allowbreak\if@display\mkern18mu + \else\mkern12mu\fi{\operator@font mod}\,\,#1} +\newcommand{\cfrac}[3][c]{{\displaystyle\frac{% + \strut\ifx r#1\hfill\fi#2\ifx l#1\hfill\fi}{#3}}% + \kern-\nulldelimiterspace} +\def\lcfrac{\cfrac[l]} +\def\rcfrac{\cfrac[r]} +\def\overset#1#2{\binrel@{#2}% + \binrel@@{\mathop{\kern\z@#2}\limits^{#1}}} +\def\underset#1#2{\binrel@{#2}% + \binrel@@{\mathop{\kern\z@#2}\limits_{#1}}} +\def\sideset#1#2#3{% + \setbox\z@\hbox{$\displaystyle{\vphantom{#3}}#1{#3}\m@th$}% + \setbox\tw@\hbox{$\displaystyle{#3}#2\m@th$}% + \hskip\wd\z@\hskip-\wd\tw@\mathop{\hskip\wd\tw@\hskip-\wd\z@ + {\vphantom{#3}}#1{#3}#2}} +\renewcommand{\smash}[2][tb]{% + \def\smash@{#1}% + \ifmmode\expandafter\mathpalette\expandafter\mathsm@sh\else + \expandafter\makesm@sh\fi{#2}} +\def\finsm@sh{\def\mb@t{\ht\z@\z@}\def\mb@b{\dp\z@\z@}% + \def\mb@tb{\mb@t\mb@b}% + {\csname mb@\smash@\endcsname}% + \leavevmode\boxz@} +\def\rightarrowfill@#1{\m@th\setboxz@h{$#1\relbar$}\ht\z@\z@ + $#1\copy\z@\mkern-6mu\cleaders + \hbox{$#1\mkern-2mu\box\z@\mkern-2mu$}\hfill + \mkern-6mu\mathord\rightarrow$} +\def\leftarrowfill@#1{\m@th\setboxz@h{$#1\relbar$}\ht\z@\z@ + $#1\mathord\leftarrow\mkern-6mu\cleaders + \hbox{$#1\mkern-2mu\copy\z@\mkern-2mu$}\hfill + \mkern-6mu\box\z@$} +\def\leftrightarrowfill@#1{\m@th\setboxz@h{$#1\relbar$}\ht\z@\z@ + $#1\mathord\leftarrow\mkern-6mu\cleaders + \hbox{$#1\mkern-2mu\box\z@\mkern-2mu$}\hfill + \mkern-6mu\mathord\rightarrow$} +\def\overarrow@#1#2#3{\vbox{\ialign{##\crcr#1#2\crcr + \noalign{\kern-\ex@\nointerlineskip}$\m@th\hfil#2#3\hfil$\crcr}}} +\def\overrightarrow{\mathpalette{\overarrow@\rightarrowfill@}} +\def\overleftarrow{\mathpalette{\overarrow@\leftarrowfill@}} +\def\overleftrightarrow{\mathpalette{\overarrow@\leftrightarrowfill@}} +\def\underarrow@#1#2#3{% + \vtop{\ialign{##\crcr$\m@th\hfil#2#3\hfil$\crcr + \noalign{\nointerlineskip\kern-.5\ex@}#1#2\crcr}}} +\def\underrightarrow{\mathpalette{\underarrow@\rightarrowfill@}} +\def\underleftarrow{\mathpalette{\underarrow@\leftarrowfill@}} +\def\underleftrightarrow{\mathpalette{\underarrow@\leftrightarrowfill@}} +\let\ifgtest@\iffalse % initial value +\def\gtest@true{\global\let\ifgtest@\iftrue} +\def\gtest@false{\global\let\ifgtest@\iffalse} +\let\DOTSI\relax +\let\DOTSB\relax +\let\DOTSX\relax +{\uccode`7=`\\ \uccode`8=`m \uccode`9=`a \uccode`0=`t \uccode`!=`h + \uppercase{% + \gdef\math@#1#2#3#4#5#6\math@{\gtest@false\ifx 7#1\ifx 8#2% + \ifx 9#3\ifx 0#4\ifx !#5\xdef\meaning@{#6}\gtest@true + \fi\fi\fi\fi\fi}}} +{\uccode`7=`c \uccode`8=`h \uccode`9=`\" + \uppercase{\gdef\mathch@#1#2#3#4#5#6\mathch@{\gtest@false + \ifx 7#1\ifx 8#2\ifx 9#5\gtest@true\xdef\meaning@{9#6}\fi\fi\fi}}} +\newcount\classnum@ +\def\getmathch@#1.#2\getmathch@{\classnum@#1 \divide\classnum@4096 + \ifcase\number\classnum@\or\or\gdef\thedots@{\dotsb@}\or + \gdef\thedots@{\dotsb@}\fi} +{\uccode`4=`b \uccode`5=`i \uccode`6=`n + \uppercase{\gdef\mathbin@#1#2#3{\relaxnext@ + \def\nextii@##1\mathbin@{\ifx\@sptoken\@let@token\gtest@true\fi}% + \gtest@false\DN@##1\mathbin@{}% + \ifx 4#1\ifx 5#2\ifx 6#3\DN@{\FN@\nextii@}\fi\fi\fi\next@}}} +{\uccode`4=`r \uccode`5=`e \uccode`6=`l + \uppercase{\gdef\mathrel@#1#2#3{\relaxnext@ + \def\nextii@##1\mathrel@{\ifx\@sptoken\@let@token\gtest@true\fi}% + \gtest@false\DN@##1\mathrel@{}% + \ifx 4#1\ifx 5#2\ifx 6#3\DN@{\FN@\nextii@}\fi\fi\fi\next@}}} +{\uccode`5=`m \uccode`6=`a \uccode`7=`c + \uppercase{\gdef\macro@#1#2#3#4\macro@{\gtest@false + \ifx 5#1\ifx 6#2\ifx 7#3\gtest@true + \xdef\meaning@{\macro@@#4\macro@@}\fi\fi\fi}}} +\def\macro@@#1->#2\macro@@{#2} +\newcount\DOTSCASE@ +{\uccode`6=`\\ \uccode`7=`D \uccode`8=`O \uccode`9=`T \uccode`0=`S + \uppercase{\gdef\DOTS@#1#2#3#4#5{\gtest@false\DN@##1\DOTS@{}% + \ifx 6#1\ifx 7#2\ifx 8#3\ifx 9#4\ifx 0#5\let\next@\DOTS@@ + \fi\fi\fi\fi\fi + \next@}}} +{\uccode`3=`B \uccode`4=`I \uccode`5=`X + \uppercase{\gdef\DOTS@@#1{\relaxnext@ + \def\nextii@##1\DOTS@{\ifx\@sptoken\@let@token\gtest@true\fi}% + \DN@{\FN@\nextii@}% + \ifx 3#1\global\DOTSCASE@\z@\else + \ifx 4#1\global\DOTSCASE@\@ne\else + \ifx 5#1\global\DOTSCASE@\tw@\else\DN@##1\DOTS@{}% + \fi\fi\fi\next@}}} +{\uccode`5=`\\ \uccode`6=`n \uccode`7=`o \uccode`8=`t + \uppercase{\gdef\not@#1#2#3#4{\relaxnext@ + \def\nextii@##1\not@{\ifx\@sptoken\@let@token\gtest@true\fi}% + \gtest@false\DN@##1\not@{}% + \ifx 5#1\ifx 6#2\ifx 7#3\ifx 8#4\DN@{\FN@\nextii@}\fi\fi\fi + \fi\next@}}} +\def\keybin@{\gtest@true + \ifx\@let@token+\else\ifx\@let@token=\else\ifx\@let@token<% + \else\ifx\@let@token>\else\ifx\@let@token-\else\ifx\@let@token*% + \else\ifx\@let@token:\else\gtest@false\fi\fi\fi\fi\fi\fi\fi} +\@ifundefined{@ldots}{\def\@ldots{\mathellipsis}}{} +\DeclareRobustCommand{\dots}{\relax + \csname\ifmmode m\else t\fi dots@\endcsname} +\def\tdots@{\leavevmode\unskip\relaxnext@ + \DN@{$\m@th\@ldots\, + \ifx\@let@token,\,$\else\ifx\@let@token.\,$\else\ifx\@let@token;\,$% + \else\ifx\@let@token:\,$\else\ifx\@let@token?\,$% + \else\ifx\@let@token!\,$\else$ \fi\fi\fi\fi\fi\fi}% + \ \FN@\next@} +\def\mdots@{\FN@\mdots@@} +\def\mdots@@{\gdef\thedots@{\dotso@}% + \ifx\@let@token\boldsymbol\gdef\thedots@\boldsymbol{\boldsymboldots@}% + \else\ifx,\@let@token\gdef\thedots@{\dotsc}% + \else\ifx\not\@let@token\gdef\thedots@{\dotsb@}% + \else\keybin@ + \ifgtest@\gdef\thedots@{\dotsb@}% + \else\xdef\meaning@{\meaning\@let@token..........}% + \xdef\meaning@@{\meaning@}% + \expandafter\math@\meaning@\math@ + \ifgtest@ + \expandafter\mathch@\meaning@\mathch@ + \ifgtest@\expandafter\getmathch@\meaning@\getmathch@\fi + \else\expandafter\macro@\meaning@@\macro@ + \ifgtest@ + \expandafter\not@\meaning@\not@\ifgtest@\gdef\thedots@{\dotsb@}% + \else\expandafter\DOTS@\meaning@\DOTS@ + \ifgtest@ + \ifcase\number\DOTSCASE@\gdef\thedots@{\dotsb@}% + \or\gdef\thedots@{\dotsi}\else\fi + \else\expandafter\math@\meaning@\math@ + \ifgtest@\expandafter\mathbin@\meaning@\mathbin@ + \ifgtest@\gdef\thedots@{\dotsb@}% + \else\expandafter\mathrel@\meaning@\mathrel@ + \ifgtest@\gdef\thedots@{\dotsb@}% + \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi + \thedots@} +\def\boldsymboldots@#1{% + \bold@true\let\@let@token=#1\let\delayed@=#1\mdots@@ + \boldsymbol#1\bold@false} +\def\@cdots{\mathinner{\cdotp\cdotp\cdotp}} +\def\dotsi{\!\@cdots} +\let\dotsb@\@cdots +\def\rightdelim@{\gtest@true + \ifx\@let@token)\else + \ifx\@let@token]\else + \ifx\@let@token\rbrack\else + \ifx\@let@token\}\else + \ifx\@let@token\rbrace\else + \ifx\@let@token\rangle\else + \ifx\@let@token\rceil\else + \ifx\@let@token\rfloor\else + \ifx\@let@token\rgroup\else + \ifx\@let@token\rmoustache\else + \ifx\@let@token\right\else + \ifx\@let@token\bigr\else + \ifx\@let@token\biggr\else + \ifx\@let@token\Bigr\else + \ifx\@let@token\Biggr\else\gtest@false + \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi} +\def\extra@{% + \rightdelim@\ifgtest@ + \else\ifx\@let@token$\gtest@true + \else\xdef\meaning@{\meaning\@let@token..........}% + \expandafter\macro@\meaning@\macro@\ifgtest@ + \expandafter\DOTS@\meaning@\DOTS@ + \ifgtest@ + \ifnum\DOTSCASE@=\tw@\gtest@true\else\gtest@false + \fi\fi\fi\fi\fi} +\newif\ifbold@ +\def\dotso@{\relaxnext@ + \ifbold@ + \let\@let@token\delayed@ + \def\nextii@{\extra@\@ldots\ifgtest@\,\fi}% + \else + \def\nextii@{\DN@{\extra@\@ldots\ifgtest@\,\fi}\FN@\next@}% + \fi + \nextii@} +\def\extrap@#1{% + \DN@{#1\,}% + \ifx\@let@token,\else + \ifx\@let@token;\else + \ifx\@let@token.\else\extra@ + \ifgtest@\else + \let\next@#1\fi\fi\fi\fi\next@} +\DeclareRobustCommand{\ldots}{\relax + \ifmmode \DN@{\extrap@\@ldots}% + \else \let\next@\tdots@\fi + \FN@\next@} +\DeclareRobustCommand{\cdots}{\DN@{\extrap@\@cdots}\FN@\next@} +\let\dotso\ldots +\let\dotsb\cdots +\let\dotsm\dotsb +\DeclareRobustCommand{\dotsc}{% + \DN@{\ifx\@let@token;\@ldots\,% + \else \ifx\@let@token.\@ldots\,% + \else \extra@\@ldots \ifgtest@\,\fi + \fi\fi}% + \FN@\next@} +\def\longrightarrow{\DOTSB\relbar\joinrel\rightarrow} +\def\Longrightarrow{\DOTSB\Relbar\joinrel\Rightarrow} +\def\longleftarrow{\DOTSB\leftarrow\joinrel\relbar} +\def\Longleftarrow{\DOTSB\Leftarrow\joinrel\Relbar} +\def\longleftrightarrow{\DOTSB\leftarrow\joinrel\rightarrow} +\def\Longleftrightarrow{\DOTSB\Leftarrow\joinrel\Rightarrow} +\def\mapsto{\DOTSB\mapstochar\rightarrow} +\def\longmapsto{\DOTSB\mapstochar\longrightarrow} +\def\hookrightarrow{\DOTSB\lhook\joinrel\rightarrow} +\def\hookleftarrow{\DOTSB\leftarrow\joinrel\rhook} +\def\doteq{\DOTSB\buildrel\textstyle.\over=} +\def\iff{\DOTSB\;\Longleftrightarrow\;} +\begingroup \catcode`\"=12 +\mathchardef\@tempa="7000 +\ifx\@tempa\Gamma + \DeclareMathSymbol{\Gamma}{\mathord}{operators}{"00} + \DeclareMathSymbol{\Delta}{\mathord}{operators}{"01} + \DeclareMathSymbol{\Theta}{\mathord}{operators}{"02} + \DeclareMathSymbol{\Lambda}{\mathord}{operators}{"03} + \DeclareMathSymbol{\Xi}{\mathord}{operators}{"04} + \DeclareMathSymbol{\Pi}{\mathord}{operators}{"05} + \DeclareMathSymbol{\Sigma}{\mathord}{operators}{"06} + \DeclareMathSymbol{\Upsilon}{\mathord}{operators}{"07} + \DeclareMathSymbol{\Phi}{\mathord}{operators}{"08} + \DeclareMathSymbol{\Psi}{\mathord}{operators}{"09} + \DeclareMathSymbol{\Omega}{\mathord}{operators}{"0A} + \DeclareMathSymbol{\varGamma}{\mathord}{letters}{"00} + \DeclareMathSymbol{\varDelta}{\mathord}{letters}{"01} + \DeclareMathSymbol{\varTheta}{\mathord}{letters}{"02} + \DeclareMathSymbol{\varLambda}{\mathord}{letters}{"03} + \DeclareMathSymbol{\varXi}{\mathord}{letters}{"04} + \DeclareMathSymbol{\varPi}{\mathord}{letters}{"05} + \DeclareMathSymbol{\varSigma}{\mathord}{letters}{"06} + \DeclareMathSymbol{\varUpsilon}{\mathord}{letters}{"07} + \DeclareMathSymbol{\varPhi}{\mathord}{letters}{"08} + \DeclareMathSymbol{\varPsi}{\mathord}{letters}{"09} + \DeclareMathSymbol{\varOmega}{\mathord}{letters}{"0A} +\fi +\endgroup +\def\accentclass@{7} +\def\noaccents@{\def\accentclass@{0}} +\DeclareFontEncoding{OML}{}{\noaccents@} +\DeclareFontEncoding{OMS}{}{\noaccents@} +\edef\@tempa#1#2{\def#1{\mathaccent\string"\noexpand\accentclass@#2 }} +\@tempa\hat{05E}\@tempa\check{014}\@tempa\tilde{07E}\@tempa\acute{013} +\@tempa\grave{012}\@tempa\dot{05F}\@tempa\ddot{07F}\@tempa\breve{015} +\@tempa\bar{016} +\newcount\skewcharcount@ +\newcount\familycount@ +\def\theskewchar@{\familycount@\@ne + \global\skewcharcount@\the\skewchar\textfont\@ne + \ifnum\mathgroup>\m@ne\ifnum\mathgroup<16 + \global\familycount@\the\mathgroup\relax + \global\skewcharcount@\the\skewchar\textfont\the\mathgroup\relax\fi\fi + \ifnum\skewcharcount@>\m@ne + \ifnum\skewcharcount@<128 + \multiply\familycount@256 + \global\advance\skewcharcount@\familycount@ + \global\advance\skewcharcount@28672 + \mathchar\skewcharcount@\else + \global\skewcharcount@\m@ne\fi\else + \global\skewcharcount@\m@ne\fi} +\newcount\pointcount@ +\def\getpoints@#1.#2\getpoints@{\pointcount@#1 } +\newdimen\accentdimen@ +\newcount\accentmu@ +\def\dimentomu@{\multiply\accentdimen@ 100 + \expandafter\getpoints@\the\accentdimen@\getpoints@ + \multiply\pointcount@18 + \divide\pointcount@\@m + \global\accentmu@\pointcount@} +\def\mathaccent@#1#2{\ifnum\mathgroup=\m@ne\xdef\thefam@{1}\else + \xdef\thefam@{\the\mathgroup}\fi + \accentdimen@\z@ + \setboxz@h{\unbracefonts@$\m@th\mathgroup\thefam@\relax#2$}% + \ifdim\accentdimen@=\z@\DN@{\mathaccent#1{#2}}% + \setbox\@ne\hbox{\unbracefonts@ + $\m@th\mathgroup\thefam@\relax#2\theskewchar@$} + \setbox\tw@\hbox{$\m@th\ifnum\skewcharcount@=\m@ne\else + \mathchar\skewcharcount@\fi$}% + \global\accentdimen@\wd\@ne\global\advance\accentdimen@-\wdz@ + \global\advance\accentdimen@-\wd\tw@ + \global\multiply\accentdimen@\tw@ + \dimentomu@\global\advance\accentmu@\@ne + \else\DN@{{\mathaccent#1{#2\mkern\accentmu@ mu}% + \mkern-\accentmu@ mu}{}}\fi + \next@} +\def\unbracefonts@{\let\math@bgroup\@empty\let\math@egroup\@empty} +\begingroup \catcode`\"=12 +\def\@tempa#1#2{\gdef#1{\RIfM@\DN@{\mathaccent@{"\accentclass@#2 }}% + \else\DN@{\nonmatherr@{#1}}\fi\next@}} +\@tempa\Hat{05E}\@tempa\Check{014}\@tempa\Tilde{07E}\@tempa\Acute{013} +\@tempa\Grave{012}\@tempa\Dot{05F}\@tempa\Ddot{07F}\@tempa\Breve{015} +\@tempa\Bar{016} +\gdef\Vec{\RIfM@\DN@{\mathaccent@{"017E }}\else + \DN@{\nonmatherr@\Vec}\fi\next@} +\endgroup +\begingroup \catcode`\"=12 +\gdef\@@sqrt#1{\radical"270370 {#1}} +\endgroup +\@saveprimitive\overline\@@overline +\def\overline#1{\@@overline{#1}} +\def\boxed#1{\fbox{\m@th$\displaystyle#1$}} +\def\setb@ck{\iffirstchoice@\global\advance\c@equation\m@ne\fi} +\newcount\dspbrk@lvl +\dspbrk@lvl=-1 +\interdisplaylinepenalty\@M +\def\allowdisplaybreaks{% + \new@ifnextchar[\allowdspbrks@{\allowdspbrks@[4]}} +\def\allowdspbrks@[#1]{% + \interdisplaylinepenalty\getdsp@pen{#1}} +\def\getdsp@pen#1{% + \ifcase #1\relax \@M + \or 9999 + \or 6999 + \or 2999 + \or \z@\fi} +\def\displaybreak{\PackageError{amstex}{\Invalid@@\displaybreak}\@eha} +\def\displaybreak@{% + \def\displaybreak{\new@ifnextchar[\dspbrk@{\dspbrk@[4]}}} +\def\dspbrk@[#1]{\global\dspbrk@lvl #1\relax} +\def\math@cr{{\ifnum0=`}\fi + \new@ifstar{\global\@eqpen\@M\math@cr@}% + {\global\@eqpen + \ifnum\dspbrk@lvl <\z@ \interdisplaylinepenalty + \else -\@getpen\dspbrk@lvl \fi + \math@cr@}} +\def\math@cr@{\new@ifnextchar[\math@cr@@{\math@cr@@[\z@]}} +\def\math@cr@@[#1]{\ifnum0=`{\fi}\math@cr@@@ + \noalign{\vskip#1\relax}} +\def\Let@{\let\\\math@cr} +\def\restore@math@cr{\def\math@cr@@@{\cr}} +\restore@math@cr +\def\intertext{\PackageError{amstex}{\Invalid@@\intertext}\@eha} +\def\intertext@{\def\intertext##1{\noalign{% + \penalty\postdisplaypenalty\vskip\belowdisplayskip + \vbox{\normalbaselines\noindent##1}% + \penalty\predisplaypenalty\vskip\abovedisplayskip}}} +\newhelp\tag@help + {tag cannot be used at this point.\space + If you don't understand why^^Jyou should consult + the documentation.^^JBut don't worry: just continue, and I'll + forget what happened.} +\def\gobble@tag{\new@ifstar\@gobble\@gobble} +\def\invalid@tag#1{\PackageError{amstex}{#1}{\the\tag@help}\gobble@tag} +\def\dft@tag{\invalid@tag{\string\tag\space not allowed here}} +\def\default@tag{\let\tag\dft@tag} +\default@tag +\def\maketag@@{\new@ifstar\maketag@@@\tagform@} +\def\maketag@@@#1{\hbox{\m@th\normalfont#1}} +\def\tagform@#1{\maketag@@@{(\ignorespaces#1\unskip)}} +\def\thetag{\leavevmode\tagform@} +\def\make@df@tag{\new@ifstar\make@df@tag@@\make@df@tag@@@} +\def\make@df@tag@@#1{% + \def\@currentlabel{#1}% + \gdef\df@tag{\maketag@@@{#1}}} +\def\make@df@tag@@@#1{\@seteqlabel{#1}\gdef\df@tag{\tagform@{#1}}} +\def\@seteqlabel#1{\toks@\@xp{\p@equation{#1}}% + \edef\@currentlabel{\the\toks@}} +\def\notag{\nonumber} +\iftagsleft@ +\def\@eqnnum{\hbox to1sp{}\rlap{\normalfont + \hskip -\displaywidth\tagform@\theequation}} +\fi + +\let\@adjusttag\@empty + +\def\adjusttag#1{\skip@#1\relax\gdef\@adjusttag{#1}} + +\def\@movetag{% + \ifx\@adjusttag\@empty \else + \vskip\@adjusttag\relax + \global\let\@adjusttag\@empty + \fi +} +\def\multilimits@{\bgroup + \Let@ + \restore@math@cr + \default@tag + \baselineskip\fontdimen10 \scriptfont\tw@ + \advance\baselineskip\fontdimen12 \scriptfont\tw@ + \lineskip\thr@@\fontdimen8 \scriptfont\thr@@ + \lineskiplimit\lineskip + \vbox\bgroup\ialign\bgroup\hfil$\m@th\scriptstyle{##}$\hfil\crcr} +\def\Sb{_\multilimits@} +\def\Sp{^\multilimits@} +\def\endSb{\crcr\egroup\egroup\egroup} +\let\endSp=\endSb +\def\smallmatrix{\null\,\vcenter\bgroup + \Let@\restore@math@cr\default@tag + \baselineskip6\ex@ \lineskip1.5\ex@ \lineskiplimit\lineskip + \ialign\bgroup\hfil$\m@th\scriptstyle{##}$\hfil&&\thickspace\hfil + $\m@th\scriptstyle{##}$\hfil\crcr} +\def\endsmallmatrix{\crcr\egroup\egroup\,} +\newcount\c@MaxMatrixCols +\c@MaxMatrixCols=10 + +\def\matrix{\hskip -\arraycolsep\array{*\c@MaxMatrixCols c}} +\def\endmatrix{\endarray \hskip -\arraycolsep} +\@ifundefined{prepnext@tok}{% + \def\@array[#1]#2{% + \setbox\@arstrutbox\hbox{\vrule\@height\arraystretch\ht\strutbox + \@depth\arraystretch\dp\strutbox \@width\z@}% + \@mkpream{#2}\edef\@preamble{\ialign \noexpand\@halignto + \bgroup \tabskip\z@ \@arstrut \@preamble \tabskip\z@ \cr}% + \let\@startpbox\@@startpbox \let\@endpbox\@@endpbox + \if #1t\vtop \else \if#1b\vbox \else \vcenter \fi\fi + \bgroup \let\par\@empty + \let\@sharp##\let\protect\relax + \lineskip\z@\baselineskip\z@\@preamble}% +\begingroup \lccode`\~=`\@ \catcode`\~=\active % just to be sure! +\lowercase{% +\gdef\@xexpast#1*#2#3#4\@@{\begingroup + \def~{@}\edef\reserved@a{#1}\@tempcnta#2\relax + \ifnum\@tempcnta >\z@ + \@whilenum\@tempcnta >\z@\do + {\edef\reserved@a{\reserved@a#3}\advance\@tempcnta \m@ne}% + \let\reserved@b\@xexpast + \else \let\reserved@b\@xexnoop\fi + \expandafter\reserved@b \reserved@a #4\@@ + \expandafter\endgroup + \expandafter\def\expandafter\reserved@a\expandafter{\reserved@a}% + \let\@tempa\reserved@a +}% End of \@xexpast +}% End of \lowercase +\endgroup +}{}% End of \@ifundefined test. +\def\pmatrix{\left(\matrix} +\def\endpmatrix{\endmatrix\right)} +\def\bmatrix{\left[\matrix} +\def\endbmatrix{\endmatrix\right]} +\def\vmatrix{\left|\matrix} +\def\endvmatrix{\endmatrix\right|} +\def\Vmatrix{\left\|\matrix} +\def\endVmatrix{\endmatrix\right\|} +\let\hdots\@ldots +\def\hdotsfor#1{\if\noexpand#1[\expandafter\shdots@for\else + \hdots@for\@ne{#1}\fi} +\newmuskip\dotsspace@ +\def\shdots@for#1]{\hdots@for{#1}} +\def\hdots@for#1#2{\multicolumn{#2}c% + {\m@th\dotsspace@1.5mu\mkern-#1\dotsspace@ + \xleaders\hbox{$\m@th\mkern#1\dotsspace@.\mkern#1\dotsspace@$}% + \hfill + \mkern-#1\dotsspace@}% + } +\def\cases{\left\{\def\arraystretch{1.2}\hskip-\arraycolsep + \array{l@{\quad}l}} +\def\endcases{\endarray\hskip-\arraycolsep\right.} +\newif\ifinany@ +\newif\ifinalign@ +\newif\ifingather@ +\newcount\and@ +\newif\iftag@ +\newhelp\andhelp@ +{An extra & here is so disastrous that you should probably exit^^J +and fix things up.} +\newif\ifst@rred +\newtoks\@envbody +\def\addto@envbody#1{\@envbody\expandafter{\the\@envbody#1}} +\def\collect@body#1{% + \@envbody{}% + \def\process@envbody{% + \expandafter#1\expandafter{\the\@envbody}}% + \expandafter\let\csname\@currenvir\endcsname\collect@@body + \csname\@currenvir\endcsname} +\def\collect@@body#1\end#2{% + \def\@tempa{#2}% + \ifx\@tempa\@currenvir + \addto@envbody{#1}% + \expandafter\edef\csname\@currenvir\endcsname + {\noexpand\process@envbody\noexpand\end{\@tempa}}% + \else + \addto@envbody{#1\end{#2}}% + \fi + \csname\@currenvir\endcsname} +\newenvironment{aligned}{% + \relax\ifmmode\else\nonmatherr@{\begin{aligned}}\fi + \null\,\new@ifnextchar[{\aligned@}{\aligned@[c]}% +}{% + \crcr\egroup\egroup +} +\def\aligned@[#1]{% + \if #1t\vtop \else \if#1b\vbox \else \vcenter \fi\fi + \bgroup + \Let@\restore@math@cr + \default@tag + \ifinany@\else\openup\jot\fi + \ialign\bgroup\hfil\strut@$\m@th\displaystyle{##}$&% + $\m@th\displaystyle{{}##}$\hfil\crcr} +\newtoks\hashtoks@ +\hashtoks@{#} +\newcount\atcount@ +\def\doat@#1{\toks@{\hfil\strut@$\m@th + \displaystyle{\the\hashtoks@}$&$\m@th\displaystyle + {{}\the\hashtoks@}$\hfil}% + \atcount@#1\relax\advance\atcount@\m@ne + \loop\ifnum\atcount@>\z@\toks@\expandafter{\the\toks@&\hfil$\m@th + \displaystyle{\the\hashtoks@}$&$\m@th + \displaystyle{{}\the\hashtoks@}$\hfil}\advance + \atcount@\m@ne\repeat + \xdef\preamble@{\the\toks@}\xdef\preamble@@{\preamble@}} +\newenvironment{alignedat}[2][c]{% + \null\,% + \if #1t\vtop \else \if#1b\vbox \else \vcenter \fi\fi + \bgroup\doat@{#2}\Let@ \restore@math@cr\default@tag + \ifinany@\else\openup\jot\fi\ialign\bgroup\span\preamble@@\crcr +}{% + \endaligned +} +\newenvironment{gathered}[1][c]{% + \relax\ifmmode\else\nonmatherr@{\begin{gathered}}\fi + \null\,% + \if #1t\vtop \else \if#1b\vbox \else \vcenter \fi\fi + \bgroup\Let@\restore@math@cr + \ifinany@\else\openup\jot\fi\ialign + \bgroup\hfil\strut@$\m@th\displaystyle##$\hfil\crcr +}{% + \endaligned +} +\def\tag@in@align{\relax + \iftag@\DN@{\invalid@tag{Multiple \string\tag}}\else + \global\tag@true + \if@eqnsw\global\@eqnswfalse\fi + \let\next@\make@df@tag\fi + \next@} +\def\math@cr@@@align{% + \if@eqnsw\global\tag@true\fi + \iftag@ + \ifcase\and@ + \DN@{&&}\else + \DN@{&}\fi\else + \let\next@\relax\fi + \next@ + \relax + \if@eqnsw\tagform@\theequation\stepcounter{equation}\else + \iftag@\df@tag\fi\fi + \global\@eqnswtrue\cr} +\def\Tag@{\relax\iftag@\else\firstchoice@true + \PackageError{amstex}{% + Extra & on this line% + }{\the\andhelp@% "An extra & here is disastrous" +}\fi} +\newdimen\lwidth@ +\newdimen\rwidth@ +\newdimen\maxlwidth@ +\newdimen\maxrwidth@ +\newdimen\totwidth@ +\def\measure@#1{\lwidth@\z@\rwidth@\z@\maxlwidth@\z@\maxrwidth@\z@ + \global\and@\z@ + \setbox\@ne\vbox{% + \everycr{\noalign{\global\tag@false\global\and@\z@}}\Let@ + \let\tag\gobble@tag + \let\notag\@empty \let\nonumber\@empty + \firstchoice@false + \halign{\setboxz@h{$\m@th\displaystyle{\@lign##}$}% + \global\lwidth@\wdz@ + \ifdim\lwidth@>\maxlwidth@\global\maxlwidth@\lwidth@\fi + \global\advance\and@\@ne + &\setboxz@h{$\m@th\displaystyle{{}\@lign##}$}% + \global\rwidth@\wdz@ + \ifdim\rwidth@>\maxrwidth@\global\maxrwidth@\rwidth@\fi + \global\advance\and@\@ne + &\Tag@\@gobble{##}\crcr#1\crcr}}% + \totwidth@\maxlwidth@\advance\totwidth@\maxrwidth@} +\def\displ@y{\global\dt@ptrue\openup\jot\m@th + \everycr{\noalign{\ifdt@p \global\dt@pfalse + \vskip-\lineskiplimit \vskip\normallineskiplimit + \else \penalty\@eqpen \fi}}} +\def\displ@y@{\global\dt@ptrue\openup\jot + \everycr{\noalign{\global\tag@false + \global\and@\z@ + \global\dspbrk@lvl\m@ne + \ifdt@p\global\dt@pfalse + \vskip-\lineskiplimit\vskip\normallineskiplimit\else + \penalty\@eqpen\fi}}} +\def\black@#1{\noalign{\ifdim#1>\displaywidth + \dimen@\prevdepth\nointerlineskip + \vskip-\ht\strutbox@\vskip-\dp\strutbox@ + \vbox{\noindent\hbox to#1{\strut@\hfill}}% + \prevdepth\dimen@ + \fi}} +\def\align{\ifingather@ + {\ifnum0=`}\fi + \DN@{\@nameuse{align (in \string\gather)}}% + \else \ifmmode\nomath@env + \DN@{\let\endalign\relax\@gobble}\else + $$\stepcounter{equation}% + \st@rredfalse\let\next@\align@\fi\fi + \collect@body\next@} +\@namedef{align*}{\ifingather@ + {\ifnum0=`}\fi + \DN@{\@nameuse{align* (in \string\gather)}}\else + \ifmmode\nomath@env + \DN@{\@namedef{endalign*}{}\@gobble}\else + $$\st@rredtrue + \let\next@\align@\fi\fi + \collect@body\next@} +\newdimen\lineht@ +\def\align@{\inalign@true\inany@true + \displaybreak@\intertext@ + \let\math@cr@@@\math@cr@@@align + \let\tag\tag@in@align + \global\and@\z@\global\dspbrk@lvl\m@ne + \iftagsleft@\DN@{\@nameuse{align }}\else + \DN@{\@nameuse{align \space}}\fi\next@} +\@namedef{align }#1{% + \measure@{#1}% + \global\and@\z@ + \global\dspbrk@lvl\m@ne + \if@fleqn %%*F + \advance\totwidth@\@mathmargin %%*F + \fi %%*F + \ifdim\totwidth@>\displaywidth + \let\displaywidth@\totwidth@ + \else + \let\displaywidth@\displaywidth + \fi + \ifingather@ + \everycr{% + \noalign{% + \global\and@\z@ + \global\dspbrk@lvl\m@ne + }% + }% + \else + \displ@y@ + \fi + \Let@ + \ifst@rred\else\@seteqlabel\theequation\fi + \tabskip\@mathmargin %%*F + \dimen@\displaywidth %%*F + \if@fleqn %%*F + \ifingather@ %%*F + \tabskip\z@skip %%*F + \advance\dimen@-\@mathmargin %%*F + \fi %%*F + \fi %%*F + \halign to\dimen@\bgroup %%*F + \ifst@rred\nonumber\fi + \hfil + \strut@ + \setboxz@h{\global\tag@false$\m@th\displaystyle{\@lign##}$}% + \global\lwidth@\wdz@ + \global\lineht@\ht\z@ + \boxz@ + \global\advance\and@\@ne + \tabskip\z@skip + &\setboxz@h{$\m@th\displaystyle{{}\@lign##}$}% + \global\rwidth@\wdz@ + \ifdim\ht\z@>\lineht@ + \global\lineht@\ht\z@ + \fi + \boxz@ + \hfil + \global\advance\and@\@ne + \tabskip\@centering + &\kern-\displaywidth@ + \setboxz@h{\@lign\strut@{##}}% + \if@fleqn %%*F + \dimen@\@mathmargin %%*F + \advance\dimen@\maxlwidth@ %%*F + \advance\dimen@-\lwidth@ %%*F + \else %%*F + \dimen@\displaywidth + \advance\dimen@-\totwidth@ + \divide\dimen@\tw@ + \advance\dimen@\maxlwidth@ + \advance\dimen@-\lwidth@ + \fi %%*F + \ifdim\dimen@<\tw@\wdz@ + \rlap{\vbox{\normalbaselines\boxz@\vbox to\lineht@{}}}% + \else + \rlap{\boxz@}% + \fi + \tabskip\displaywidth@ + \crcr + #1% +} +\@namedef{align \space}#1{% + \measure@{#1}% + \if@fleqn %%*F + \advance\totwidth@\@mathmargin %%*F + \fi %%*F + \global\and@\z@ + \global\dspbrk@lvl\m@ne + \ifingather@ + \everycr{\noalign{\global\and@\z@\global\dspbrk@lvl\m@ne}}% + \else + \displ@y@ + \fi + \Let@ + \ifst@rred\else\@seteqlabel\theequation\fi + \tabskip\@mathmargin %%*F + \dimen@\displaywidth %%*F + \if@fleqn %%* + \ifingather@ %%*F + \tabskip\z@skip %%*F + \advance\dimen@-\@mathmargin %%*F + \fi %%*F + \fi %%*F + \halign to\dimen@\bgroup %%*F + \ifst@rred\nonumber\fi + \hfil + \strut@ + \setboxz@h{\global\tag@false$\m@th\displaystyle{\@lign##}$}% + \global\lwidth@\wdz@\boxz@ + \global\advance\and@\@ne + \tabskip\z@skip + &\setboxz@h{$\m@th\displaystyle{{}\@lign##}$}% + \global\rwidth@\wdz@ + \boxz@ + \hfill + \global\advance\and@\@ne + \tabskip\@centering + &\setboxz@h{\@lign\strut@{##}}% + \dimen@\displaywidth + \advance\dimen@-\totwidth@ + \divide\dimen@\tw@ + \advance\dimen@\maxrwidth@ + \advance\dimen@-\rwidth@ + \ifdim\dimen@<\tw@\wdz@ + \llap{\vtop{\@movetag\normalbaselines\null\boxz@}}%%*T + \else + \llap{\boxz@}% + \fi + \tabskip\z@skip + \crcr#1% +} +\def\endalign{\math@cr@@@align + \black@\totwidth@ + \egroup$$\global\@ignoretrue\setb@ck} + +\@namedef{endalign*}{\math@cr@@@align\black@\totwidth@ + \egroup$$\global\@ignoretrue} +\@namedef{align (in \string\gather)}{% + \ifst@rred\stepcounter{equation}\fi + \def\endalign{\@nameuse{endalign (in \string\gather)}\ifnum0=`{\fi}}% + \vcenter\bgroup\st@rredfalse + \collect@body\align@} +\@namedef{endalign (in \string\gather)}{% + \math@cr@@@align\black@\totwidth@ + \egroup\egroup + \ifst@rred\setb@ck\fi% this ifst@rred is set by the enclosing gather + \global\tag@false\global\@eqnswfalse} +\@namedef{align* (in \string\gather)}{% + \@namedef{endalign*}{\@nameuse{endalign* (in \string\gather)}% + \ifnum0=`{\fi}}% + \vcenter\bgroup\st@rredtrue + \collect@body\align@} +\@namedef{endalign* (in \string\gather)}{% + \math@cr@@@align\black@\totwidth@\egroup\egroup + \global\tag@false\global\@eqnswfalse} +\newif\ifxat@ +\def\alignat#1{% + \ifmmode\nomath@env\DN@{\let\endalignat\relax\@gobble}\else$$% + \st@rredfalse\stepcounter{equation}\@seteqlabel\theequation + \DN@{\@nameuse{alignat }#1}\fi + \collect@body\next@} +\@namedef{alignat*}#1{% + \ifmmode\nomath@env\DN@{\@namedef{endalignat*}{}\@gobble}\else$$% + \st@rredtrue + \DN@{\@nameuse{alignat }#1}\fi + \collect@body\next@} +\newif\ifmeasuring@ +\newbox\savealignat@ +\def\math@cr@@@alignat{% + \if@eqnsw\global\tag@true\fi + \iftag@ + \multiply\count@\tw@ + \xdef\next@{}\loop\ifnum\count@>\and@\xdef\next@{&\next@}% + \advance\count@\m@ne\repeat\else + \let\next@\relax\fi + \next@ + \relax + \if@eqnsw\tagform@\theequation\stepcounter{equation}\else + \iftag@\df@tag\fi\fi + \global\@eqnswtrue\cr}% +\@namedef{alignat }#1#2{% + \inany@true + \xat@false + \let\tag\tag@in@align + \def\math@cr@@@{\count@#1\relax \math@cr@@@alignat}% + \displaybreak@ + \intertext@ + \displ@y@ + \ifst@rred + \global\@eqnswfalse + \else + \global\@eqnswtrue + \fi + \measuring@true + \setbox\savealignat@\hbox{% + $\m@th\displaystyle\Let@ + \attag@{#1}% + \vbox{\firstchoice@false\halign{\span\preamble@@\crcr#2\crcr}}$% + }% + \measuring@false + \Let@ + \attag@{#1}% + \tabskip\@mathmargin %%*F + \halign to\displaywidth\bgroup + \span\preamble@@\crcr + #2% +} +\def\endalignat{\math@cr@@@\black@{\wd\savealignat@}% + \egroup\setb@ck$$\global\@ignoretrue} +\@namedef{endalignat*}{\math@cr@@@\black@{\wd\savealignat@}\egroup + $$\global\@ignoretrue} +\def\xalignat#1{% + \ifmmode\nomath@env\DN@{\let\endxalignat\relax\@gobble}\else$$% + \st@rredfalse\stepcounter{equation}\@seteqlabel\theequation + \DN@{\@nameuse{xalignat }#1}\fi + \collect@body\next@} +\@namedef{xalignat*}#1{% + \ifmmode\nomath@env\DN@{\@namedef{endxalignat*}{}\@gobble}\else$$% + \st@rredtrue + \DN@{\@nameuse{xalignat }#1}\fi + \collect@body\next@} +\let\endxalignat=\endalignat + +\expandafter\let\csname endxalignat*\expandafter + \endcsname\csname endalignat*\endcsname +\@namedef{xalignat }#1#2{% + \inany@true + \xat@true + \let\tag\tag@in@align + \def\math@cr@@@{\count@#1\relax\math@cr@@@alignat}% + \displaybreak@ + \intertext@ + \displ@y@ + \measuring@true + \setbox\savealignat@\hbox{% + $\m@th\displaystyle\Let@ + \attag@{#1}% + \vbox{% + \firstchoice@false + \halign{\span\preamble@@\crcr#2\crcr}% + }% + $% + }% + \measuring@false + \Let@ + \attag@{#1}% + \tabskip\@mathmargin %%*F + \halign to\displaywidth\bgroup + \span\preamble@@\crcr#2% +} +\def\attag@#1{% + \let\TAG@\Tag@\let\Tag@0% + \ifmeasuring@\def\llap@##1{\setboxz@h{##1}\hbox to\tw@\wdz@{}}% + \def\rlap@##1{\setboxz@h{##1}\hbox to\tw@\wdz@{}}\else + \let\llap@\llap\let\rlap@\rlap\fi + \toks@{\hfil\strut@$\m@th\displaystyle{\@lign\the\hashtoks@}$% + \tabskip\z@skip + \global\advance\and@\@ne + &$\m@th\displaystyle{{}\@lign\the\hashtoks@}$\hfil + \ifxat@\tabskip\@centering\fi\global\advance\and@\@ne}% + \iftagsleft@ + \@temptokena{\tabskip\@centering&\Tag@\kern-\displaywidth + \rlap@{\@lign + \the\hashtoks@ + }% + \global\advance\and@\@ne\tabskip\displaywidth}\else + \@temptokena{\tabskip\@centering&\Tag@\llap@{\@lign + \the\hashtoks@ + }\global\advance\and@\@ne\tabskip\z@skip}\fi + \atcount@#1\relax\advance\atcount@\m@ne + \loop\ifnum\atcount@>\z@ + \toks@\expandafter{\the\toks@&\hfil$\m@th\displaystyle{\@lign + \the\hashtoks@}$\global\advance\and@\@ne + \tabskip\z@skip + &$\m@th\displaystyle{{}\@lign\the\hashtoks@}$\hfil\ifxat@ + \tabskip\@centering\fi\global\advance\and@\@ne}\advance\atcount@\m@ne + \repeat + \xdef\preamble@{\the\toks@\the\@temptokena}% + \xdef\preamble@@{\ifst@rred\noexpand\nonumber\fi\preamble@}% + \let\Tag@\TAG@} +\def\xxalignat#1{% + \ifmmode\nomath@env\DN@{\let\endxxalignat\relax\@gobble}\else$$% + \DN@{\@nameuse{xxalignat }#1}\fi + \collect@body\next@} +\@namedef{xxalignat }#1#2{\inany@true + \displaybreak@\intertext@ + \displ@y\setbox\savealignat@\hbox{$\m@th\displaystyle\Let@ + \xxattag@{#1}% + \vbox{\firstchoice@false\halign{\span\preamble@@\crcr#2\crcr}}$}% + \Let@\xxattag@{#1}\tabskip\z@skip\halign to\displaywidth\bgroup + \span\preamble@@\crcr#2} +\expandafter\let\expandafter\endxxalignat\csname endxalignat*\endcsname +\def\xxattag@#1{\toks@{\tabskip\z@skip\hfil\strut@ + $\m@th\displaystyle{\the\hashtoks@}$&% + $\m@th\displaystyle{{}\the\hashtoks@}$\hfil\tabskip\@centering&}% + \atcount@#1\relax\advance\atcount@\m@ne\loop\ifnum\atcount@>\z@ + \toks@ + \expandafter + {\the\toks@&\hfil$\m@th\displaystyle{\the\hashtoks@}$% + \tabskip\z@skip&$\m@th\displaystyle{{}\the\hashtoks@}$\hfil + \tabskip\@centering}\advance\atcount@\m@ne\repeat + \xdef\preamble@{\the\toks@\tabskip\z@skip}\xdef\preamble@@{\preamble@}} +\newdimen\gwidth@ +\newdimen\gmaxwidth@ +\def\gmeasure@#1{\gwidth@\z@\gmaxwidth@\z@\setbox\@ne\vbox{\Let@ + \firstchoice@false\let\tag\gobble@tag + \halign{\setboxz@h{$\m@th\displaystyle{##}$}\global\gwidth@\wdz@ + \ifdim\gwidth@>\gmaxwidth@\global\gmaxwidth@\gwidth@\fi + &\@gobble{##}\crcr#1\crcr}}} +\def\math@cr@@@gather{% + \if@eqnsw\global\tag@true\fi + \iftag@ + \DN@{&\relax \if@eqnsw + \tagform@\theequation \stepcounter{equation}% + \else\iftag@\df@tag\fi\fi}% + \else + \expandafter\@gobble\fi + \next@ + \global\@eqnswtrue\cr} +\def\gather{% + \ifmmode\nomath@env\DN@{\let\endgather\relax\@gobble}\else $$% + \ingather@true\inany@true + \stepcounter{equation}% + \let\tag\tag@in@align\st@rredfalse + \displaybreak@\intertext@ + \displ@y + \Let@\@seteqlabel\theequation + \let\math@cr@@@\math@cr@@@gather + \iftagsleft@\DN@{\@nameuse{gather }}\else + \DN@{\@nameuse{gather \space}}\fi\fi + \collect@body\next@} +\@namedef{gather*}{% + \ifmmode\nomath@env\DN@{\@namedef{endgather*}{}\@gobble}\else $$% + \ingather@true\inany@true + \let\tag\tag@in@align\st@rredtrue + \displaybreak@\intertext@ + \displ@y\Let@ + \let\math@cr@@@\math@cr@@@gather + \iftagsleft@\DN@{\@nameuse{gather }}\else + \DN@{\@nameuse{gather \space}}\fi\fi + \collect@body\next@} +\newdimen\glineht@ +\@namedef{gather \space}#1{% + \gmeasure@{#1}% + \if@fleqn %%*F + \advance\gmaxwidth@\@mathmargin %%*F + \fi %%*F + \global\dt@ptrue + \tabskip\@mathmargin %%*F + \halign to\displaywidth\bgroup + \ifst@rred\nonumber\else\global\@eqnswtrue\fi + \if@fleqn\else\hfil\fi %%*F + \strut@ + \setboxz@h{\global\tag@false$\m@th\displaystyle{##}$}% + \global\gwidth@\wdz@\boxz@ + \hfil + \tabskip\@centering %%*F + &\setboxz@h{\strut@{##}}% + \dimen@\displaywidth + \advance\dimen@-\gwidth@ + \if@fleqn %%*F + \advance\dimen@-\@mathmargin %%*F + \else %%*F + \divide\dimen@\tw@ %%*B + \fi %%*F + \ifdim\dimen@<\tw@\wdz@ %%* + \llap{\vtop{\@movetag\normalbaselines\null\boxz@}}%%*T %%* + \else + \llap{\boxz@}% %%* + \fi + \tabskip\z@skip + \crcr + #1% +} +\def\endgather{\math@cr + \black@\gmaxwidth@\egroup $$\setb@ck\global\@ignoretrue} + +\@namedef{endgather*}{\math@cr + \black@\gmaxwidth@\egroup $$\global\@ignoretrue} +\@namedef{gather }#1{% + \gmeasure@{#1}% + \global\dt@ptrue + \if@fleqn %%*F + \advance\gmaxwidth@\@mathmargin %%*F + \fi %%*F + \ifdim\gmaxwidth@>\displaywidth + \let\gdisplaywidth@\gmaxwidth@ + \else + \let\gdisplaywidth@\displaywidth + \fi + \tabskip\@mathmargin %%*F + \halign to\displaywidth\bgroup + \ifst@rred\nonumber\else\global\@eqnswtrue\fi + \if@fleqn\else\hfil\fi %%*F + \strut@ + \setboxz@h{\global\tag@false$\m@th\displaystyle{##}$}% + \global\gwidth@\wdz@ + \global\glineht@\ht\z@ + \boxz@ + \hfil + \tabskip\@centering %%*F + &\kern-\gdisplaywidth@ + \setboxz@h{\strut@{##}}% + \if@fleqn %%*F + \dimen@\@mathmargin %%*F + \else %%*F + \dimen@\displaywidth + \advance\dimen@-\gwidth@ + \divide\dimen@\tw@ %%*B + \fi %%*F + \ifdim\dimen@<\tw@\wdz@ %%* + \rlap{\vbox{\normalbaselines\boxz@\vbox to\glineht@{}}}% %%* + \else + \rlap{\boxz@}% %%* + \fi + \tabskip\gdisplaywidth@ + \crcr + #1% +} +\def\split{% + \ifinany@\let\next@\insplit@\else + \DN@{\PackageError{amstex}{\string\begin{split} is not allowed + here. Try the `aligned' environment.}\@ehb}\fi + \next@} +\def\insplit@{\global\setbox\z@\vbox\bgroup + \Let@ \restore@math@cr \default@tag % disallow use of \tag here + \ialign\bgroup \hfil\strut@ + $\m@th\displaystyle{##}$&$\m@th\displaystyle{{}##}$\hfill\crcr} +\def\endsplit{\crcr\egroup\egroup + \iftagsleft@\expandafter\lendsplit@\else + \expandafter\rendsplit@\fi} +\def\rendsplit@{\global\setbox9 \vbox + {\unvcopy\z@\global\setbox8 \lastbox\unskip}% + \setbox\@ne\hbox{\unhcopy8 \unskip\global\setbox\tw@\lastbox + \unskip\global\setbox\thr@@\lastbox}% + \global\setbox7 \hbox{\unhbox\tw@\unskip}% + \ifinalign@\ifctagsplit@ + \gdef\split@{\hbox to\wd\thr@@{}& + \vcenter{\vbox{\moveleft\wd\thr@@\boxz@}}}% + \else\gdef\split@{&\vbox{\moveleft\wd\thr@@\box9}\crcr + \box\thr@@&\box7}\fi + \else + \ifctagsplit@\gdef\split@{\vcenter{\boxz@}}\else + \gdef\split@{\box9\crcr\hbox{\box\thr@@\box7}}\fi + \fi + \aftergroup\split@} +\def\lendsplit@{\global\setbox9\vtop{\unvcopy\z@}% + \setbox\@ne\vbox{\unvcopy\z@\global\setbox8\lastbox}% + \setbox\@ne\hbox{\unhcopy8\unskip\setbox\tw@\lastbox + \unskip\global\setbox\thr@@\lastbox}% + \ifinalign@\ifctagsplit@ + \gdef\split@{\hbox to\wd\thr@@{}& + \vcenter{\vbox{\moveleft\wd\thr@@\box9}}}% + \else + \gdef\split@{\hbox to\wd\thr@@{}&\vbox{\moveleft\wd\thr@@\box9}}\fi + \else + \ifctagsplit@\gdef\split@{\vcenter{\box9}}\else + \gdef\split@{\box9}\fi + \fi\aftergroup\split@} +\newdimen\multlinegap +\multlinegap10pt +\newdimen\multlinetaggap@ +\multlinetaggap@10pt +\def\multline{% + \ifmmode\nomath@env\DN@{\let\endmultline\relax\@gobble}% + \else $$\DN@{\collect@body\multline@}\fi + \st@rredfalse\@eqnswtrue \@seteqlabel\theequation + \stepcounter{equation}\next@} +\@namedef{multline*}{% + \ifmmode\nomath@env\DN@{\@namedef{endmultline*}{}\@gobble}% + \else $$\DN@{\collect@body\multline@}\fi + \st@rredtrue\@eqnswfalse \let\@currentlabel\@empty + \next@} +\def\multline@{\inany@true\displaybreak@ + \global\tag@false + \def\tag{\ifst@rred\else + \global\advance\c@equation\m@ne\fi\tag@in@align}% + \iftagsleft@ + \expandafter\lmultline@@\else + \expandafter\rmultline@@\fi} +\newdimen\mwidth@ +\def\rmmeasure@#1{% + \def\shoveleft##1{##1}\def\shoveright##1{##1}% + \setbox\@ne\vbox{\firstchoice@false\Let@\halign{\setboxz@h + {$\m@th\@lign\displaystyle{}##$}\global\mwidth@\wdz@ + \crcr#1\crcr}}} +\newdimen\mlineht@ +\newif\ifzerocr@ +\newif\ifonecr@ +\def\lmmeasure@#1{\global\zerocr@true\global\onecr@false + \everycr{\noalign{\ifonecr@\global\onecr@false\fi + \ifzerocr@\global\zerocr@false\global\onecr@true\fi}}% + \def\shoveleft##1{##1}\def\shoveright##1{##1}% + \setbox\@ne\vbox{\Let@\firstchoice@false\halign{\setboxz@h + {$\m@th\@lign\displaystyle{}##$}\ifonecr@\global\mwidth@\wdz@ + \global\mlineht@\ht\z@\fi\crcr#1\crcr}}} +\newbox\mtagbox@ +\newdimen\ltwidth@ +\newdimen\rtwidth@ +\def\lmultline@@#1{% + \lmmeasure@{#1}% + \setbox\mtagbox@\hbox{% + \iftag@ + \df@tag + \else + \if@eqnsw + \global\tag@true + \tagform@\theequation + \fi + \fi + }% + \dimen@\mwidth@ + \advance\dimen@\wd\mtagbox@ + \advance\dimen@\multlinetaggap@ + \if@fleqn %%*F + \advance\dimen@\@mathmargin %%*F + \fi %%*F + \ifdim\dimen@>\displaywidth + \ltwidth@\z@ + \else + \ltwidth@\wd\mtagbox@ + \fi + \lmultline@@@#1 +} +\def\lmultline@@@{% + \displ@y + \def\shoveright##1{##1\hfilneg\hskip\multlinegap}% + \if@fleqn %%*F + \def\shoveleft##1{##1}% %%*F + \else %%*F + \def\shoveleft##1{% + \setboxz@h{$\m@th\displaystyle{}##1$}% + \setbox\@ne\hbox{$\m@th\displaystyle##1$}% + \hfilneg + \iftag@ + \ifdim\ltwidth@>\z@ + \hskip\ltwidth@ + \hskip\multlinetaggap@ + \fi + \else + \hskip\multlinegap + \fi + \hskip.5\wd\@ne + \hskip-.5\wdz@##1% + }% + \fi %%*F + \if@fleqn %%*F + \tabskip\@mathmargin %%*F + \else %%*F + \tabskip\z@skip %%* + \fi %%*F + \totwidth@\displaywidth %%*F + \if@fleqn %%*F + \advance\totwidth@-\@mathmargin %%*F + \fi %%*F + \halign\bgroup + \Let@ + \let\tag\gobble@tag + \hbox to\totwidth@{% %%*F + \strut@$\m@th\displaystyle + \if@fleqn %%*F + \hskip 0pt plus 1000pt %%*F + \else %%*F + \hfil + \fi %%*F + {}##\hfil$% + }% + \crcr + \if@fleqn %%*F + \hskip-\@mathmargin %%*F + \else %%*F + \hfilneg + \fi %%*F + \iftag@ + \ifdim\ltwidth@>\z@ + \box\mtagbox@ + \hskip\multlinetaggap@ + \else + \rlap{% + \vbox{% + \normalbaselines + \hbox{\strut@\box\mtagbox@}% + \vbox to\mlineht@{}% + }% + }% + \hskip\multlinegap %%* + \fi + \else + \hskip\multlinegap + \fi +} +\def\rmultline@@#1{% + \rmmeasure@{#1}% + \setbox\mtagbox@\hbox{% + \iftag@ + \df@tag + \else + \if@eqnsw + \global\tag@true + \tagform@\theequation + \fi + \fi + }% + \dimen@\mwidth@ + \advance\dimen@\wd\mtagbox@ + \advance\dimen@\multlinetaggap@ + \if@fleqn %%*F + \advance\dimen@\@mathmargin %%*F + \fi %%*F + \ifdim\dimen@>\displaywidth + \rtwidth@\z@ + \else + \rtwidth@\wd\mtagbox@ + \fi + \rmultline@@@#1 +} +\def\rmultline@@@{% + \displ@y + \def\shoveright##1{% + ##1% + \hfilneg + \iftag@ + \ifdim\rtwidth@>\z@ + \hskip\rtwidth@ + \hskip\multlinetaggap@ + \fi + \else + \hskip\multlinegap + \fi + }% + \if@fleqn %%*F + \def\shoveleft##1{##1}% %%*F + \else %%*F + \def\shoveleft##1{% + \setboxz@h{$\m@th\displaystyle{}##1$}% + \setbox\@ne\hbox{$\m@th\displaystyle##1$}% + \hfilneg + \hskip\multlinegap + \hskip.5\wd\@ne + \hskip-.5\wdz@ + ##1% + }% + \fi %%*F + \if@fleqn %%*F + \tabskip\@mathmargin %%*F + \else %%*F + \tabskip\z@skip %%* + \fi %%*F + \totwidth@\displaywidth %%*F + \if@fleqn %%*F + \advance\totwidth@-\@mathmargin %%*F + \fi %%*F + \halign\bgroup + \Let@ + \let\tag\gobble@tag + \hbox to\totwidth@{% + \strut@$\m@th\displaystyle + \if@fleqn %%*F + \hskip 0pt plus 1000pt %%*F + \else %%*F + \hfil + \fi %%*F + {}##\hfil$% + }% + \crcr + \if@fleqn %%*F + \hskip-\@mathmargin %%*F + \else %%*F + \hfilneg + \fi %%*F + \hskip\multlinegap +} +\def\endmultline{\iftagsleft@\expandafter\lendmultline@\else + \expandafter\rendmultline@\fi\global\@ignoretrue} +\expandafter\let\csname endmultline*\endcsname=\endmultline +\def\lendmultline@{\hfilneg\hskip\multlinegap\crcr\egroup$$} +\def\rendmultline@{% + \iftag@ + \ifdim\rtwidth@>\z@ + \hskip\multlinetaggap@ + \box\mtagbox@ + \else + \hskip\multlinegap %%* + \llap{% + \vtop{% + \@movetag %%*T + \normalbaselines\null\hbox{\strut@\box\mtagbox@}% + }% + }% + \fi + \else + \hskip\multlinegap + \fi + \hfilneg + \crcr + \egroup$$% +} +\expandafter\def + \expandafter\@arrayparboxrestore + \expandafter{\@arrayparboxrestore + \inany@false\ingather@false\inalign@false + \default@tag} +\def\equation{\gather\def\\{\PackageError{amstex}{\Invalid@@\\}\@eha}} +\def\endequation{\endgather} +\newenvironment{equation*}{% + \equation +}{% + \nonumber\endequation +} +\newcounter{parentequation}% Counter for ``parent equation''. +\newenvironment{subequations}{% + \refstepcounter{equation}% + \begingroup % conservative approach + \let\protect\@nx + \edef\@tempa{\def\@nx\theparentequation{\theequation}}% + \@xp\endgroup\@tempa + \setcounter{parentequation}{\value{equation}}% + \setcounter{equation}{0}% + \def\theequation{\theparentequation\alph{equation}}% + \ignorespaces +}{% + \setcounter{equation}{\value{parentequation}}% + \global\@ignoretrue +} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\def\atdef@#1{\expandafter\def\csname\space @\string#1\endcsname} +\begingroup \catcode`\@=\active +\gdef @{\Iat} +\endgroup +\DeclareRobustCommand{\Iat}{\FN@\at@} +\def\at@{\let\next@\at@@ + \ifcat\noexpand\@let@token a\else + \ifcat\noexpand\@let@token0\else + \ifcat\noexpand\@let@token\relax\else + \let\@let@token@\at@@@\fi\fi\fi\next@} +\def\at@@#1{\expandafter + \@ifundefined{ @\string#1}% + {\DN@{\at@@@#1}}% + {\DN@{\csname\space @\string#1\endcsname}}% + \next@}% +\def\at@@@{\PackageError{amstex}{\Invalid@@ @}% + {\the\athelp@}% "I'll assume you wanted @@" + \char64\relax} +\newhelp\athelp@ +{Only certain combinations beginning with @ make sense to me.^^J% +I'll assume you wanted @@ for a printed @.} +\atdef@ @{{\atchar}}% to define @@ +\chardef\atchar=64 +\def\makeatother{\catcode64=\active} +\def\@tempa#1#2#3#4#5#6{% + {#1}{#2}\ifnum0#6=0{13}\@xp\@gobblefour + \else{#3}\fi\@tempa{#4}{#5}{#6}}% +\xdef\@currnamestack{\@xp\@tempa\@currnamestack{}{}{0}} +{\def\@makeother{\noexpand\@makeother\noexpand} +\xdef\@sanitize{\@sanitize\@makeother\@}} +{\def\do{\noexpand\do\noexpand} +\xdef\dospecials{\dospecials\do\@}} +\atdef@,{\ifmmode\mskip.1\thinmuskip\else \nonmatherr@{@,}\fi} +\atdef@!{\RIfM@\mskip-.1\thinmuskip\else \nonmatherr@{@!}\fi} + +\@ifpackageloaded{amscd}{% +}{% +\atdef@>#1>#2>{% + \global\bigaw@\minaw@ + \setboxz@h{$\m@th\scriptstyle\;{#1}\;\;$}% + \ifdim\wdz@>\bigaw@ \global\bigaw@\wdz@ \fi + \@ifnotempty{#2}{\setbox\@ne\hbox{$\m@th\scriptstyle\;{#2}\;\;$}% + \ifdim\wd\@ne>\bigaw@ \global\bigaw@\wd\@ne \fi}% + \mathrel{\mathop{\hbox to\bigaw@{\rightarrowfill@\displaystyle}}% + \limits^{#1}\@ifnotempty{#2}{_{#2}}}% +}% end of @>>> +\atdef@<#1<#2<{% + \global\bigaw@\minaw@ + \setboxz@h{$\m@th\scriptstyle\;\;{#1}\;$}% + \ifdim\wdz@>\bigaw@ \global\bigaw@\wdz@ \fi + \@ifnotempty{#2}{\setbox\@ne\hbox{$\m@th\scriptstyle\;\;{#2}\;$}% + \ifdim\wd\@ne>\bigaw@ \global\bigaw@\wd\@ne \fi}% + \mathrel{\mathop{\hbox to\bigaw@{\leftarrowfill@\displaystyle}}% + \limits^{#1}\@ifnotempty{#2}{_{#2}}}% +}% end of @<<< +}% end of @ifpackageloaded +\@ifundefined{minaw@}{\newdimen\minaw@}{} +\minaw@11.111pt +\@ifundefined{bigaw@}{\newdimen\bigaw@}{} +\atdef@-{\let\next-%% + \DN@{\ifx\next-%% + \def\next-{\setbox\z@\hbox{-}\unhbox\z@\FN@\next@}%% + \expandafter\next \else\nobreak\fi}%% + \next@-}%% +\def\leftroot{\PackageError{amstex}{\Invalid@@\leftroot}\@eha} +\def\uproot{\PackageError{amstex}{\Invalid@@\uproot}\@eha} +\newcount\uproot@ +\newcount\leftroot@ +\def\root{\relaxnext@ + \DN@{\ifx\@let@token\uproot\let\next@\nextii@\else + \ifx\@let@token\leftroot\let\next@\nextiii@\else + \let\next@\plainroot@\fi\fi\next@}% + \def\nextii@\uproot##1{\uproot@##1\relax\FN@\nextiv@}% + \def\nextiv@{\ifx\@let@token\@sptoken\DN@. {\FN@\nextv@}\else + \DN@.{\FN@\nextv@}\fi\next@.}% + \def\nextv@{\ifx\@let@token\leftroot\let\next@\nextvi@\else + \let\next@\plainroot@\fi\next@}% + \def\nextvi@\leftroot##1{\leftroot@##1\relax\plainroot@}% + \def\nextiii@\leftroot##1{\leftroot@##1\relax\FN@\nextvii@}% + \def\nextvii@{\ifx\@let@token\@sptoken + \DN@. {\FN@\nextviii@}\else + \DN@.{\FN@\nextviii@}\fi\next@.}% + \def\nextviii@{\ifx\@let@token\uproot\let\next@\nextix@\else + \let\next@\plainroot@\fi\next@}% + \def\nextix@\uproot##1{\uproot@##1\relax\plainroot@}% + \bgroup\uproot@\z@\leftroot@\z@\FN@\next@} +\def\plainroot@#1\of#2{\setbox\rootbox\hbox{% + $\m@th\scriptscriptstyle{#1}$}% + \mathchoice{\r@@t\displaystyle{#2}}{\r@@t\textstyle{#2}} + {\r@@t\scriptstyle{#2}}{\r@@t\scriptscriptstyle{#2}}\egroup} +\def\r@@t#1#2{\setboxz@h{$\m@th#1\@@sqrt{#2}$}% + \dimen@\ht\z@\advance\dimen@-\dp\z@ + \setbox\@ne\hbox{$\m@th#1\mskip\uproot@ mu$}% + \advance\dimen@ by1.667\wd\@ne + \mkern-\leftroot@ mu\mkern5mu\raise.6\dimen@\copy\rootbox + \mkern-10mu\mkern\leftroot@ mu\boxz@} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% Fragment from old amsfonts.sty to deal with msam, msbm, eufm fonts; +%% omit if `noamsfonts' option was specified. +\ifx F\@amsfonts \endinput \fi +\DeclareSymbolFont{AMSa}{U}{msa}{m}{n} +\DeclareSymbolFont{AMSb}{U}{msb}{m}{n} +\ifx P\@amsfonts + \DeclareFontFamily{U}{msa}{}% + \DeclareFontShape{U}{msa}{m}{n}{<-6>msam5<6-8>msam7<8->msam10}{}% + \DeclareFontFamily{U}{msb}{}% + \DeclareFontShape{U}{msb}{m}{n}{<-6>msbm5<6-8>msbm7<8->msbm10}{}% + \DeclareFontFamily{U}{euf}{}% + \DeclareFontShape{U}{euf}{m}{n}{<-6>eufm5<6-8>eufm7<8->eufm10}{}% + \DeclareFontShape{U}{euf}{b}{n}{<-6>eufb5<6-8>eufb7<8->eufb10}{}% +\fi +\@ifundefined{yen}{% + \edef\yen{\noexpand\mathhexbox{\hexnumber@\symAMSa}55} +}{} +\@ifundefined{checkmark}{% + \edef\checkmark{\noexpand\mathhexbox{\hexnumber@\symAMSa}58} +}{} +\@ifundefined{circledR}{% + \edef\circledR{\noexpand\mathhexbox{\hexnumber@\symAMSa}72} +}{} +\@ifundefined{maltese}{% + \edef\maltese{\noexpand\mathhexbox{\hexnumber@\symAMSa}7A} +}{} +\begingroup \catcode`\"=12 +\DeclareMathDelimiter\ulcorner{\mathopen} {AMSa}{"70}{AMSa}{"70} +\DeclareMathDelimiter\urcorner{\mathclose}{AMSa}{"71}{AMSa}{"71} +\DeclareMathDelimiter\llcorner{\mathopen} {AMSa}{"78}{AMSa}{"78} +\DeclareMathDelimiter\lrcorner{\mathclose}{AMSa}{"79}{AMSa}{"79} +\xdef\widehat#1{\noexpand\@mathmeasure\z@\textstyle{#1}% + \noexpand\ifdim\noexpand\wdz@>\tw@ em% + \mathaccent"0\hexnumber@\symAMSb 5B{#1}% + \noexpand\else\mathaccent"0362{#1}\noexpand\fi} +\xdef\widetilde#1{\noexpand\@mathmeasure\z@\textstyle{#1}% + \noexpand\ifdim\noexpand\wdz@>\tw@ em% + \mathaccent"0\hexnumber@\symAMSb 5D{#1}% + \noexpand\else\mathaccent"0365{#1}\noexpand\fi} +\DeclareMathSymbol\dabar@{\mathord}{AMSa}{"39} +\xdef\dashrightarrow{\mathrel{\dabar@\dabar@ + \mathchar"0\hexnumber@\symAMSa 4B}}% +\xdef\dashleftarrow{\mathrel{\mathchar"0\hexnumber@\symAMSa 4C\dabar@ + \dabar@}}% +\global\let\dasharrow\dashrightarrow +\global\let\rightleftharpoons\undefined +\DeclareMathSymbol\rightleftharpoons{\mathrel}{AMSa}{"0A} +\global\let\angle\undefined +\DeclareMathSymbol\angle {\mathord}{AMSa}{"5C} +\global\let\hbar\undefined +\DeclareMathSymbol\hbar {\mathord}{AMSb}{"7E} +\global\let\sqsubset\undefined +\DeclareMathSymbol\sqsubset {\mathrel}{AMSa}{"40} +\global\let\sqsupset\undefined +\DeclareMathSymbol\sqsupset {\mathrel}{AMSa}{"41} +\global\let\mho\undefined +\DeclareMathSymbol\mho {\mathord}{AMSb}{"66} +\DeclareMathSymbol\square {\mathord}{AMSa}{"03} +\DeclareMathSymbol\lozenge {\mathord}{AMSa}{"06} +\DeclareMathSymbol\vartriangleright {\mathrel}{AMSa}{"42} +\DeclareMathSymbol\vartriangleleft {\mathrel}{AMSa}{"43} +\DeclareMathSymbol\trianglerighteq {\mathrel}{AMSa}{"44} +\DeclareMathSymbol\trianglelefteq {\mathrel}{AMSa}{"45} +\DeclareMathSymbol\rightsquigarrow {\mathrel}{AMSa}{"20} +\def\@tempa{\not@base\lhd} +\ifx\lhd\@tempa + \global\let\lhd\vartriangleleft + \global\let\unlhd\trianglelefteq + \global\let\rhd\vartriangleright + \global\let\unrhd\trianglerighteq + \global\let\Box\square + \global\let\Diamond\lozenge + \global\let\leadsto\rightsquigarrow +\xdef\Join{\mathrel{\mathchar"0\hexnumber@\symAMSb 6F\mkern-13.8mu% + \mathchar"0\hexnumber@\symAMSb 6E}} +\fi +\endgroup +\DeclareMathAlphabet\mathfrak{U}{euf}{m}{n} +\SetMathAlphabet\mathfrak{bold}{U}{euf}{b}{n} +\DeclareSymbolFontAlphabet{\mathbb}{AMSb} +\DeclareFontEncodingDefaults{\relax}{\def\accentclass@{7}} +\def\frak{\mathfrak} +\def\Bbb{\mathbb} +\def\bold{\mathbf} +\begingroup \catcode`\"=12 \relax +\gdef\newsymbol#1#2#3#4#5{% + \@ifdefinable#1{% + \edef\next@ + {\ifcase #2 \or + \hexnumber@\symAMSa\or + \hexnumber@\symAMSb\fi}% + \ifx\next@\@empty + \PackageError{amsfonts}{\Invalid@@\newsymbol}\@ehd% + \else + \global\mathchardef#1"#3\next@#4#5 + \fi}} +\endgroup +%% Some odds and ends +\def\sphat{^{\mathchoice{}{}% + {\,\,\smash[b]{\hbox{\lower4\ex@\hbox{$\m@th\widehat{\null}$}}}}% + {\,\smash[b]{\hbox{\lower3\ex@\hbox{$\m@th\hat{\null}$}}}}}} +\def\spcheck{^\vee} +\def\sptilde{^\sim} +\def\spdot{^{\hbox{\raise\ex@\hbox{\normalfont .}}}} +\def\spddot{^{\hbox{\raise\ex@\hbox{\normalfont ..}}}} +\def\spdddot{^{\hbox{\raise\ex@\hbox{\normalfont...}}}} +\def\spbreve{^{\!\smash[b]{\hbox{\lower4\ex@\hbox{\u{}}}}}} +\def\fracwithdelims#1#2{\new@ifnextchar[{\fracwithdelims@#1#2}% + {\fracwithdelims@#1#2[\@empty]}} +\def\fracwithdelims@#1#2[#3]#4#5{\relax + \ifx\@empty#3{#4\overwithdelims#1#2#5}\else + {#4\abovewithdelims#1#2#3\relax#5}\fi} +\def\accentedsymbol#1#2{% + \expandafter\newbox + \csname\expandafter\@gobble\string#1@box\endcsname + \expandafter\setbox + \csname\expandafter\@gobble\string#1@box\endcsname + \hbox{$\m@th#2$}% + \newcommand{#1}{% + \expandafter\copy + \csname\expandafter\@gobble\string#1@box\endcsname{}}% +} +\def~{\nobreakspace} +\DeclareRobustCommand{\nobreakspace}{\unskip\nobreak\ \ignorespaces} +%% +%% End of file `amstex.sty'. diff --git a/macros/latex-dev/required/amsmath/amstext.dtx b/macros/latex-dev/required/amsmath/amstext.dtx new file mode 100644 index 0000000000..a4c9aeb5d9 --- /dev/null +++ b/macros/latex-dev/required/amsmath/amstext.dtx @@ -0,0 +1,302 @@ +% +% \iffalse meta-comment +% +% Copyright (C) 1995, 1999 American Mathematical Society. +% Copyright (C) 2016-2019 LaTeX3 Project and American Mathematical Society. +% +% This work may be distributed and/or modified under the +% conditions of the LaTeX Project Public License, either version 1.3c +% of this license or (at your option) any later version. +% The latest version of this license is in +% https://www.latex-project.org/lppl.txt +% and version 1.3c or later is part of all distributions of LaTeX +% version 2005/12/01 or later. +% +% This work has the LPPL maintenance status `maintained'. +% +% The Current Maintainer of this work is the LaTeX3 Project. +% +% \fi +% +% \iffalse +%<*driver> +\documentclass{amsdtx} +\def\MaintainedByLaTeXTeam#1{% +\begin{center}% +\fbox{\fbox{\begin{tabular}{@{}l@{}}% +This file is maintained by the \LaTeX{} Project team.\\% +Bug reports can be opened (category \texttt{#1}) at\\% +\url{https://latex-project.org/bugs/}.\end{tabular}}}\end{center}} +\usepackage{amstext} +\GetFileInfo{amstext.sty} +\begin{document} +\title{The \pkg{amstext} package} +\author{Frank Mittelbach \and Rainer Sch\"opf} +\date{Version \fileversion, \filedate} +\DocInput{amstext.dtx} +\end{document} +%</driver> +% \fi +% +% \maketitle +% \MaintainedByLaTeXTeam{amslatex} +% +% \MakeShortVerb\| +% +% \section{Introduction} +% +% This style file implements the \AmSTeX{} macro \cn{text} for use +% with the new font selection scheme. The \cn{text} macro is a +% sophisticated command which allows the user to insert ``normal text'' +% into math formulas without worrying about correct sizes in sub- or +% superscripts. It can also be used in ordinary text; there it +% produces an unbreakable unit similar to \cn{mbox}. +% +% Here is an example demonstrating some of its features: +% \[ +%^^A mathbin spacing is nonscript glue, disappears in superscript +% x^{2\,\times\,\text{size of $y$}} +% \leq +% z_{i_{\text{upper bound of the array}}} +% \] +% This was produced by +% \begin{verbatim} +% \[ +% x^{2\,\times\,\text{size of $y$}} +% \leq +% z_{i_{\text{upper bound of the array}}} +% \] +% \end{verbatim} +% +% Additionally this style file redefines an internal \fn{plain.tex} +% macro called \cs{mathhexbox} so that commands like \cn{dag} +% or \cn{P} will change sizes if used in math subscripts. +% +% \StopEventually{} +% Package information. +% \begin{macrocode} +\NeedsTeXFormat{LaTeX2e}% LaTeX 2.09 can't be used (nor non-LaTeX) +[1994/12/01]% LaTeX date must be December 1994 or later +\ProvidesPackage{amstext}[2000/06/29 v2.01 AMS text] +% \end{macrocode} +% +% \section{The implementation} +% We need a few tools from \fn{amsgen.sty}. +% \begin{macrocode} +\RequirePackage{amsgen} +% \end{macrocode} +% +% \begin{macro}{\text} +% Now we come to the \cn{text} macro which is used to place +% ordinary text inside of math formulas. If it is used outside +% math it will produce an unbreakable unit of text. +% \begin{macrocode} +\DeclareRobustCommand{\text}{% + \ifmmode\expandafter\text@\else\expandafter\mbox\fi} +% \end{macrocode} +% At the present time (late 1994) the \latex/ internal function +% |\nfss@text| is used in |\ref|, in font commands like |\textbf|, +% and in a few text symbol definitions like |\$| and |\pounds|. By +% equating |\nfss@text| to |\text| we give it the ability of +% |\text| to change sizes properly if used in a subscript. +% \begin{macrocode} +\let\nfss@text\text +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\text@} +% If \cn{text} is encountered inside math mode the macro +% \cs{text@} is called. It has one mandatory argument, the text +% which should be produced. Since we do not know in which math +% style we are currently in we call \cs{mathchoice} to tyeset +% our text in all four possible styles. +% \begin{macrocode} +\def\text@#1{{\mathchoice +% \end{macrocode} +% To save token space we call a macro \cs{textdef@} which takes +% three arguments: the current math style, the corresponding size +% macro and the text to typeset possibly with some additional +% information for typesetting. +% \begin{macrocode} + {\textdef@\displaystyle\f@size{#1}}% +% \end{macrocode} +% The other three cases are similar except for the +% \cs{iffirstchoice} switch which we set to false. This is +% done to prevent \LaTeX{} macros like \cn{ref} or \cn{index} +% from writing their arguments more than once. +% \begin{macrocode} + {\textdef@\textstyle\f@size{\firstchoice@false #1}}% + {\textdef@\textstyle\sf@size{\firstchoice@false #1}}% + {\textdef@\textstyle \ssf@size{\firstchoice@false #1}}% +% \end{macrocode} +% Here we need to check whether a math size-change occurred inside +% the argument of \cn{text}. If so, restore +% \begin{macrocode} + \check@mathfonts + }% +} +% \end{macrocode} +% The macros \cs{f@size}, \cs{sf@size} and \cs{ssf@size} hold the +% sizes which should be used when we are loading a new font for use +% in \cs{textfont}, \cs{scriptfont} and \cs{scriptscriptfont}. There +% is some question whether we should use use \cs{tf@size} or +% \cs{f@size} for the main size, but since the primary purpose of the +% \cn{text} macro is to switch back to text within a display, it +% seems that \cs{f@size} is the better choice. (Indeed it could be +% said that the \cn{text} actually provides two different functions: +% one for escaping out of math mode in a display to print some words, +% and the other for handling math objects that are named by a +% fragment of text, when \cn{operatorname} isn't the right choice. +% For the latter \cs{tf@size} might be more correct but for the +% former \cs{f@size} is clearly better.) +% \end{macro} +% +% \begin{macro}{\textdef@} +% To typeset the argument of \cn{text} correctly we have to make +% several actions. We start by placing everything inside an +% \cs{hbox}. But this is not enough: we need one extra level of +% grouping. These extra braces are necessary because of the new +% font selection scheme which might produce an \cs{aftergroup} +% to globally restore some font values after the current group. To +% prevent any damage by this mechanism we add the braces thereby +% bringing the token inserted by \cs{aftergroup} inside the +% \cs{hbox}.\footnote{The mechanism will not produce a second +% \cs{aftergroup}. For more details see the technical documentation +% for NFSS2.} +% \begin{macrocode} +\def\textdef@#1#2#3{\hbox{{% +% \end{macrocode} +% Since text typeset inside an \cs{hbox} always stays in the size +% of the text surrounding the formula we have to adjust this for +% script and scriptscript sizes. For any math formula inside this +% argument this will be achieved by setting \cs{everymath} to +% the first argument of \cs{textdef@} since this argument +% contains the math size in the current typeset case of +% \cs{mathchoice}. +% Since \latex/ also knows about \cn{parbox}es and the +% \env{minipage} environment it might be neccessary to adjust +% \cs{everydisplay} too but this has to be tested further. +% \begin{macrocode} + \everymath{#1}% +% \end{macrocode} +% The next line of code changes locally (i.e.\ inside the current +% \cs{hbox}) the value of \cs{f@size}. This macro holds the +% size for typesetting ordinary text (e.g.\ loading or selecting a +% new font via \cs{selectfont}). By changing it to a smaller +% value a following \cs{selectfont} will switch to the wanted +% size. +% \begin{macrocode} + \let\f@size#2\selectfont +% \end{macrocode} +% Now we simply call the third argument and close all open groups. +% \begin{macrocode} + #3}}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\iffirstchoice@} +% Here is the switch that we use to decide if \cn{ref} etc.\ +% should print its warnings. The default is true since +% normally these warnings shouldn't be suppressed. +% \begin{macrocode} +\newif\iffirstchoice@ +\firstchoice@true +% \end{macrocode} +% \end{macro} +% +% \subsection{Re-definition of \latex/ macros to work with \cn{text}} +% +% If a counter-changing command occurs inside the argument of +% \cn{text}, we don't want the counter to be changed four times +% because \cn{stepcounter} and \cn{addtocounter} have global effect. +% So we add the \cs{iffirstchoice@} test to make the counter +% operations execute only once. +% +% \begin{macro}{\stepcounter} +% Use \cs{def} rather than \cn{renewcommand*} because the star-form +% (for non-\cs{long} definitions) doesn't work with the June 1994 +% release of \latex/. +% \begin{macrocode} +\def\stepcounter#1{% + \iffirstchoice@ + \addtocounter{#1}\@ne + \begingroup \let\@elt\@stpelt \csname cl@#1\endcsname \endgroup + \fi +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\addtocounter} +% \begin{macrocode} +\def\addtocounter#1#2{% + \iffirstchoice@ + \@ifundefined {c@#1}{\@nocounterr {#1}}% + {\global \advance \csname c@#1\endcsname #2\relax}% + \fi} +% \end{macrocode} +% \end{macro} +% +% For \cn{ref}, \cn{pageref}, and indeed anything else that issues a +% warning or error, \cn{text} will produce four copies of the +% warning/error message. To suppress the last three copies, we change +% \cs{GenericInfo}, \cs{GenericWarning}, \cs{GenericError}. +% \begin{macrocode} +\let\m@gobble\@empty +\@xp\let\csname m@gobble4\endcsname\@gobblefour +\long\@xp\def\csname m@gobble6\endcsname#1#2#3#4#5#6{} +% \end{macrocode} +% +% \begin{macrocode} +\toks@{% + \csname m@gobble\iffirstchoice@\else 4\fi\endcsname + \protect} +\edef\GenericInfo{\the\toks@ + \@xp\@nx\csname GenericInfo \endcsname} +% +\edef\GenericWarning{\the\toks@ + \@xp\@nx\csname GenericWarning \endcsname} +% +\toks@{% + \csname m@gobble\iffirstchoice@\else 6\fi\endcsname + \protect} +\edef\GenericError{\the\toks@ + \@xp\@nx\csname GenericError \endcsname} +% \end{macrocode} +% +% At one time \cn{label}, \cs{@wrindex} and \cs{@wrglossary} were +% changed here too to use the \cs{iffirstchoice@} test but it seems +% that was a mistake because those are non-immediate writes. +% Something like +% \begin{verbatim} +% \text{something \index{foo}} +% \end{verbatim} +% within a math formula would therefore \emph{lose the index term} if +% the surrounding context was not displaystyle. (Unlikely in +% practice, but not impossible.) [mjd,1994/12/09] +% +%\subsection{Applications of \cn{text}} +% +% \begin{macro}{\mathhexbox} +% We start with an re-definition of the \fn{plain.tex} macro +% \cs{mathhexbox}. (Although M. Spivak in \amstex/ uses the name +% \cs{mathhexbox@} for this purpose, I [FMi] don't see any reason +% to use a new name since the new definition is superior, has the +% same syntax and is used for the same purpose.) +% \begin{macrocode} +\begingroup \catcode`\"=12 +\gdef\mathhexbox#1#2#3{\text{$\m@th\mathchar"#1#2#3$}} +\endgroup +% \end{macrocode} +% This redefinition means that now symbols like \S, \P, \dag, \ldots, +% which are defined via \cs{mathhexbox} in \fn{plain.tex} or +% elsewhere now correctly change sizes if they are used in math mode. +% \end{macro} +% +% The usual \cs{endinput} to ensure that random garbage at the end of +% the file doesn't get copied by \fn{docstrip}. +% \begin{macrocode} +\endinput +% \end{macrocode} +% +% \CheckSum{129} +% \Finale diff --git a/macros/latex-dev/required/amsmath/amstext.ins b/macros/latex-dev/required/amsmath/amstext.ins new file mode 100644 index 0000000000..84fcb0cb95 --- /dev/null +++ b/macros/latex-dev/required/amsmath/amstext.ins @@ -0,0 +1,51 @@ +%% +%% Copyright 2010 American Mathematical Society. +%% Copyright 2016 LaTeX3 Project and American Mathematical Society. +%% +%% This work may be distributed and/or modified under the +%% conditions of the LaTeX Project Public License, either version 1.3c +%% of this license or (at your option) any later version. +%% The latest version of this license is in +%% https://www.latex-project.org/lppl.txt +%% and version 1.3c or later is part of all distributions of LaTeX +%% version 2005/12/01 or later. +%% +%% This work has the LPPL maintenance status `maintained'. +%% +%% The Current Maintainer of this work is the LaTeX3 Project. +%% +%% ==================================================================== + +\input docstrip + +\askforoverwritefalse + +\keepsilent + +\preamble + +Copyright 1995, 1999 American Mathematical Society. +Copyright 2016 LaTeX3 Project and American Mathematical Society. + +This work may be distributed and/or modified under the +conditions of the LaTeX Project Public License, either version 1.3c +of this license or (at your option) any later version. +The latest version of this license is in + https://www.latex-project.org/lppl.txt +and version 1.3c or later is part of all distributions of LaTeX +version 2005/12/01 or later. + +This work has the LPPL maintenance status `maintained'. + +The Current Maintainer of this work is the LaTeX3 project. + +\endpreamble + +\usedir{tex/latex/amsmath} + +\generate{ + \file{amstext.sty}{\from{amstext.dtx}{}} +} + +\endbatchfile + diff --git a/macros/latex-dev/required/amsmath/amstext.pdf b/macros/latex-dev/required/amsmath/amstext.pdf Binary files differnew file mode 100644 index 0000000000..a5c78d6737 --- /dev/null +++ b/macros/latex-dev/required/amsmath/amstext.pdf diff --git a/macros/latex-dev/required/amsmath/amsxtra.dtx b/macros/latex-dev/required/amsmath/amsxtra.dtx new file mode 100644 index 0000000000..2165dde41a --- /dev/null +++ b/macros/latex-dev/required/amsmath/amsxtra.dtx @@ -0,0 +1,127 @@ +% +% \iffalse meta-comment +% +% Copyright (C) 1995, 1999 American Mathematical Society. +% Copyright (C) 2016-2019 LaTeX3 Project and American Mathematical Society. +% +% This work may be distributed and/or modified under the +% conditions of the LaTeX Project Public License, either version 1.3c +% of this license or (at your option) any later version. +% The latest version of this license is in +% https://www.latex-project.org/lppl.txt +% and version 1.3c or later is part of all distributions of LaTeX +% version 2005/12/01 or later. +% +% This work has the LPPL maintenance status `maintained'. +% +% The Current Maintainer of this work is the LaTeX3 Project. +% +% \fi +% +%\iffalse +%<*driver> +\documentclass{amsdtx} +\def\MaintainedByLaTeXTeam#1{% +\begin{center}% +\fbox{\fbox{\begin{tabular}{@{}l@{}}% +This file is maintained by the \LaTeX{} Project team.\\% +Bug reports can be opened (category \texttt{#1}) at\\% +\url{https://latex-project.org/bugs/}.\end{tabular}}}\end{center}} +\usepackage{amsxtra} +\GetFileInfo{amsxtra.sty} +\begin{document} +\title{The \pkg{amsxtra} package} +\author{American Mathematical Society\\Michael Downes} +\date{Version \fileversion, \filedate} +\DocInput{amsxtra.dtx} +\end{document} +%</driver> +%\fi +% +% \maketitle +% \MaintainedByLaTeXTeam{amslatex} +% +% \MakeShortVerb\| +% +% \section{Introduction} +% The \pkg{amsxtra} package contains a few rarely used commands that +% were present in version 1.1 of the \pkg{amstex} package: +% \cn{fracwithdelims}, {accentedsymbol}, \cn{sphat}, \cn{spcheck}, +% \cn{sptilde}, \cn{spdot}, \cn{spddot}, \cn{spdddot}, \cn{spbreve}. +% If any of these commands were used in existing documents, the +% \pkg{amsxtra} package provides a way to get them. But for 99\% of +% documents using the \pkg{amstex} package these commands are just +% wasted overhead. +% +% \StopEventually{} +% +% \begin{macrocode} +\ProvidesPackage{amsxtra}[1999/11/15 v1.2c AMS extra commands] +% \end{macrocode} +% We need to ensure that either the \pkg{amstex} package or the +% \pkg{amsmath} package is loaded. This means we need something a +% little more complicated than \cn{RequirePackage}. +% \begin{macrocode} +\@ifpackageloaded{amstex}{}{% + \RequirePackage{amsmath}[1996/10/01 v1.2]} +% \end{macrocode} +% +% Superscripted accent characters. +% \begin{macrocode} +\def\sphat{^{\mathchoice{}{}% + {\,\,\smash[b]{\hbox{\lower4\ex@\hbox{$\m@th\widehat{\null}$}}}}% + {\,\smash[b]{\hbox{\lower3\ex@\hbox{$\m@th\hat{\null}$}}}}}} +\def\spcheck{^\vee} +\def\sptilde{^\sim} +\def\spdot{^{\hbox{\raise\ex@\hbox{\normalfont .}}}} +\def\spddot{^{\hbox{\raise\ex@\hbox{\normalfont ..}}}} +\def\spdddot{^{\hbox{\raise\ex@\hbox{\normalfont...}}}} +\def\spbreve{^{\!\smash[b]{\hbox{\lower4\ex@\hbox{\u{}}}}}} +% \end{macrocode} +% +% The \cn{fracwithdelims} command is skipped if the base package is +% \pkg{amsmath}; it is only needed if the base package is +% \pkg{amstex}. +% \begin{macrocode} +\@ifpackageloaded{amstex}{% +\def\fracwithdelims#1#2{\new@ifnextchar[{\fracwithdelims@#1#2}% + {\fracwithdelims@#1#2[\@empty]}} +\def\fracwithdelims@#1#2[#3]#4#5{\relax + \ifx\@empty#3{#4\overwithdelims#1#2#5}\else + {#4\abovewithdelims#1#2#3\relax#5}\fi} +}{} +% \end{macrocode} +% +% Perhaps |\accentedsymbol| should use |\newsavebox|, but I don't +% know of any compelling reason at the moment.[mjd,5-Sep-1994] +% |\accentedsymbol| can only produce a single size of +% the given symbol, so you'd need two different versions for main +% size and subscript size. +% \begin{macrocode} +\def\accentedsymbol#1#2{% + \expandafter\newbox + \csname\expandafter\@gobble\string#1@box\endcsname + \expandafter\setbox + \csname\expandafter\@gobble\string#1@box\endcsname + \hbox{$\m@th#2$}% + \newcommand{#1}{% + \expandafter\copy + \csname\expandafter\@gobble\string#1@box\endcsname{}}% +} +% \end{macrocode} +% +% Change the definition of \qc{\~} to automatically remove a +% preceding space as well as a following space, if present. +% \begin{macrocode} +\def~{\nobreakspace} +\DeclareRobustCommand{\nobreakspace}{\unskip\nobreak\ \ignorespaces} +% \end{macrocode} +% +% The usual \cs{endinput} to ensure that random garbage at the end of +% the file doesn't get copied by \fn{docstrip}. +% \begin{macrocode} +\endinput +% \end{macrocode} +% +% \CheckSum{113} +% \Finale diff --git a/macros/latex-dev/required/amsmath/amsxtra.ins b/macros/latex-dev/required/amsmath/amsxtra.ins new file mode 100644 index 0000000000..9e739c3d4b --- /dev/null +++ b/macros/latex-dev/required/amsmath/amsxtra.ins @@ -0,0 +1,51 @@ +%% +%% Copyright 2010 American Mathematical Society. +%% Copyright 2016 LaTeX3 Project and American Mathematical Society. +%% +%% This work may be distributed and/or modified under the +%% conditions of the LaTeX Project Public License, either version 1.3c +%% of this license or (at your option) any later version. +%% The latest version of this license is in +%% https://www.latex-project.org/lppl.txt +%% and version 1.3c or later is part of all distributions of LaTeX +%% version 2005/12/01 or later. +%% +%% This work has the LPPL maintenance status `maintained'. +%% +%% The Current Maintainer of this work is the LaTeX3 Project. +%% +%% ==================================================================== + +\input docstrip + +\askforoverwritefalse + +\keepsilent + +\preamble + +Copyright 1995, 1999 American Mathematical Society. +Copyright 2016 LaTeX3 Project and American Mathematical Society. + +This work may be distributed and/or modified under the +conditions of the LaTeX Project Public License, either version 1.3c +of this license or (at your option) any later version. +The latest version of this license is in + https://www.latex-project.org/lppl.txt +and version 1.3c or later is part of all distributions of LaTeX +version 2005/12/01 or later. + +This work has the LPPL maintenance status `maintained'. + +The Current Maintainer of this work is the LaTeX3 project. + +\endpreamble + +\usedir{tex/latex/amsmath} + +\generate{ + \file{amsxtra.sty}{\from{amsxtra.dtx}{}} +} + +\endbatchfile + diff --git a/macros/latex-dev/required/amsmath/amsxtra.pdf b/macros/latex-dev/required/amsmath/amsxtra.pdf Binary files differnew file mode 100644 index 0000000000..11cea1ef60 --- /dev/null +++ b/macros/latex-dev/required/amsmath/amsxtra.pdf diff --git a/macros/latex-dev/required/amsmath/changes.txt b/macros/latex-dev/required/amsmath/changes.txt new file mode 100644 index 0000000000..1b2d097dd5 --- /dev/null +++ b/macros/latex-dev/required/amsmath/changes.txt @@ -0,0 +1,123 @@ +2019-02-06 Frank Mittelbach <Frank.Mittelbach@latex-project.org> + + * amsmath.dtx (section{Mods, continued fractions, etc.}): + Command \overunderset added + +######################### +# 2018-12-01 Release +######################### + +2018-10-09 Frank Mittelbach <Frank.Mittelbach@latex-project.org> + + * amsmath.dtx + Don't drop \frozen@everymath + Start LR-mode for \thinspace and friends if necessary (github/49) + Start LR-mode for \bigl and friends if necessary (github/49) + Start LR-mode for \smash if necessary (github/49) + +######################### +# 2018-04-01 Release +######################### + +2017-09-02 David Carlisle <latex-bugs@latex-project.org> + + * amsmath.dtx: ensure that overfull alignments give warnings in more cases + https://tex.stackexchange.com/questions/141287/addmargin-enumerate-and-align-miss-an-overfull-hbox + + * amsmath.dtx: move the nulldelimiterspace correction for closing + delimiters in \genfrac for extended TeXs to the line before + \nulldelimiterspace is locally set to 0pt. + +2017-04-14 David Carlisle <latex-bugs@latex-project.org> + + * amscd.dtx: typo fix in ProvidesPackage line. + +2016-11-05 David Carlisle <latex-bugs@latex-project.org> + + * alignedleftspace[yes|no|yesifneg] package options + * New genfrac implementation for XeTeX and LuaTeX + * Delete obsolete install.txt file. + +2016-06-28 David Carlisle <latex-bugs@latex-project.org> + + * amsmath.dtx: Add space to prevent runaway argument error with \dots \left... + +2016-05-26 David Carlisle <latex-bugs@latex-project.org> + + * amsmath.dtx: ignore spaces at start of \intertext + +2016-03-10 David Carlisle <latex-bugs@latex-project.org> + + * amsmath.dtx: Preserve box0 in \resetMathstrut@ + +2016-03-08 David Carlisle <latex-bugs@latex-project.org> + + * amsopn.dtx: In xetex, and luatex, add version of \newmcodes@ + that works even if - has a \Umathcode definition. + +2016-03-03 David Carlisle <latex-bugs@latex-project.org> + + * amsmath.dtx: missing % + +2016-02-20 David Carlisle <latex-bugs@latex-project.org> + + * amsmath.dtx: update to support \Umathchardef and \long macros in \dots. + +2013-01-14 amsmath.dtx 2.14 + + * amsmath.sty 2.14 + -- Minimal changes to make amsmath compatible with stix.sty. + +2000-07-18 amsmath.dtx 2.13 + -- After the numbering patches in 2.11, \notag failed in certain + circumstances: introduce some more auxiliary functions to sort + things out, and redefine \nonumber. + +2000-06-29 amstext.dtx 2.01 + -- Use \f@size instead of \tf@size because they are not + necessarily the same and the former is better for putting a few + words into a display. + +2000-06-06 amsmath.dtx 2.12 + -- Fix transposed lines in 2.11 patch. + +2000-06-02 amsmath.dtx 2.11 + + * amsmath.sty 2.11 + -- Prevent "Arithmetic overflow" error by guarding against + divide-by-zero in \x@calc@shift@lc (align environment). + + * amsdtx.dtx + -- Moved to the amscls distribution. + +2000-05-25 amsmath.dtx 2.10 + -- Clear up error message for \allowdisplaybreaks[0]. + -- Make mathdisplay re-entrant by introducing mathdisplay@stack, + to clear up numbering problems in unusual circumstances such as + \[ \] nested inside minipage inside equation. + +2000-04-21 amsmath.dtx 2.09 + -- Ensure good catcodes for " etc. + +2000-03-16 amsmath.dtx 2.08 + -- Fixed erroneous tag placement on split with fleqn/tbtags options. + +2000-03-15 amsmath.dtx 2.07 + -- Add \reset@strutbox@ to deal with the following bug: After + $...\mbox{\Huge $...$}...$, line spacing is wrong in a + following "gather" or other environment that uses \strut@. + -- Patch to fix bug with intlimits option: too much space in the + middle of \iint. + -- Overhaul math accents again to fix a couple of bugs reported by + Thimm. + +2000-03-10 amsmath.dtx 2.06 + -- Change \MathAccent to \mathaccentV so \DeclareMathAccent won't + give an error when redefining an accent. + +2000-01-06 amsmath.dtx 2.05 + -- Fixed incorrect placement of fleqn/reqno equation numbers + inside indented lists (displaywidth < columnwidth). Changed the + multline/fleqn/leqno indent to match mathmargin when possible + instead of always just using multlinetaggap. + diff --git a/macros/latex-dev/required/amsmath/diffs-m.txt b/macros/latex-dev/required/amsmath/diffs-m.txt new file mode 100644 index 0000000000..af3a273f52 --- /dev/null +++ b/macros/latex-dev/required/amsmath/diffs-m.txt @@ -0,0 +1,551 @@ +diffs-m.txt [1999/12/15] American Mathematical Society + +This is a synopsis of the principal differences between various versions +of the amsmath package and its companion packages. + +A synopsis of changes in the "AMS-LaTeX" distribution is included at the +end of this file. See also diffs-c.txt in the amslatex/classes area. + +Those upgrading from version 1.2 to version 2.0 will probably be +interested in the question: + + After I upgrade will anything fail in my pre-existing documents? + +Certain of the bug fixes have the potential to affect the output of +existing documents in the following ways: + +---Vertical spacing for some displayed equations will change because +"abovedisplayshortskip" is now applied when possible. + +---Incorrect horizontal spacing for certain math constructs will change, +e.g., for \iint\nolimits or a subscript on a double-accented letter. + +---The default subscript placement in displayed formulas for \varinjlim, +\varprojlim, \varliminf, \varlimsup is now below rather than to the +side. To get the old behavior, add \nolimits---e.g., +\varliminf\nolimits_{...}. + +---Ellipsis dots in text (\ldots or \dots) will now behave the same as +in standard LaTeX; the surrounding space may therefore change. + +During regression testing we found some errors cropping up in documents +from incorrect usage that had not been caught with version 1.2. Although +these errors are relatively rare, documents containing such usage will +need to be corrected before they will run properly with version 2.0: + +---Use of two mutually exclusive display structures for the same +display. In this example the outer \[ \] are redundant: + + \[ + \begin{align*} + ... + \end{align*} + \] + +---Inadequate argument markup for math accents: + + \hat \mathcal{C} + +This should have been written with braces surrounding the argument of +the \hat command: \hat{\mathcal{C}}. + +For documents where error messages crop up after the upgrade, there are +various possible approaches, including: + +(a) Change instances of incorrect usage (if applicable). + +(b) Put a copy of amsmath.sty version 1.2 into the home directory of the +document. Then it should continue to work the same as before. + +(c) Use the snapshot package in combination with a shell script to +arrange that version 1.2 of amsmath is found instead of 2.0 when +processing the document. See ftp://ftp.ams.org/pub/tex/snapshot.*. This +approach requires a certain amount of technical knowledge. + +(d) Downgrade to version 1.2 again. + +======================================================================== +Changes in amsmath 2.0 [November 1999] + +---The AMS-LaTeX User's Guide (amsldoc.tex) has been turned into the + AMSmath User's Guide by moving the amsthm documentation into a + separate file (amsthdoc.tex) in the amslatex/classes area. + +---Restored normal use of "shortskip" spacing in single equations. + +[!! NOTE: This means that page breaks may change in existing documents.] + +---Restored normal use of available shrink around binary operators in + single equations. + +---Fixed poor subscript placement for double-accented letters. Math +accent handling was reworked in the process in such a way that the +capitalized forms of the math accent commands are no longer necessary. +\hat{\hat{X}} will do proper alignment of the second accent. \Hat et +cetera are retained for compabitility reasons. (Thanks to Javier Bezos +for donating some code from his accents package.) + +[!! NOTE: Improper math accent use will now produce wrong output.] + +Suppose that we have \boldH defined in the preamble as +\newcommand{\boldH}{\mathbf{H}}. Then the following examples illustrate +recommended usage. + + \hat{\mathbf{H}} OK + \hat{\boldH} OK + \hat\boldH Works OK, but deprecated by the LaTeX book + \hat\mathbf{H} Not OK! Output will be incorrect. + +Since the output will be wrong, amsmath gives an error message when the +last variant is detected. + +---The following kinds of mixed structures worked by happenstance with + amsmath 1.2, although they should have produced an error message. + With amsmath 2.0 they will produce an error or warning message. + + [!! NOTE: Potential error messages] + + % Outer \[ \] is redundant + + \[ + \begin{align*} + ... + \end{align*} + \] + + % Outer \begin{equation*} ... \end{equation*} is redundant + + \begin{equation*}\begin{alignat*}{2} + ... + \end{alignat*} + \end{equation*} + + % No printed material is allowed between \begin{equation} and + % \begin{split}: + + \begin{equation*}\left \{ + \begin{split} + ... + \end{split}\right . + \end{equation*} + +---diff12.tex is replaced by diffs-m.txt and diffs-c.txt, with the + latter moving to the amslatex/classes area. + +---Added an "?" option which gives some information about the available + documentation. + +---The amsmath definitions for matrix, pmatrix, and cases are + incompatible with the plain-TeX syntax for \pmatrix, \matrix, and + \cases, which are used occasionally by some authors in LaTeX + documents. In version 2.0 the error messages resulting from the + plain-TeX syntax have been made more intelligible. + +---If you need the boldsymbol facilities of the amsbsy package, use of + the "bm" (boldmath) package is recommended instead for new documents. + The amsbsy package is retained for compatibility with existing + documents. If you have a recent version of LaTeX (1998 or newer) you + already have the bm package; otherwise you may need to get it from + CTAN. (It is not an AMS package.) + +---\iint\nolimits: Fixed poor placement of subscript (also \iiint, +\idotsint, etc). + +---\varinjlim, \varprojlim, \varliminf, \varlimsup: Default to +\displaylimits instead of nolimits. + +---Fixed alignedat so that it doesn't take the first token of its + contents and try to interpret it as a number. + +---Leave text version of \dots and \ldots unchanged. + +---Changed \numberwithin so it no longer assumes previous definition of + \thesomething contained no prefixes. + +---\mathbf{\Gamma}: Leave cap Greek letters alone instead of converting + them from variable (fam 7) to fixed (fam 0). \mathbf{\gamma} still + fails---but that's a math font problem. + +---\mathindent is aliased to \@mathmargin so that when the fleqn option + is used, users can reset it as the LaTeX book advertises. + +---With the showkeys package: Corrected loss of marginal notes when +labels occurred inside an align environment. + +---Carried over some tweaks (\bmod, \right/leftarrowfill) from the 1996 + version of plain.tex. + +---Adjusted spacing of overarrow@ and underarrow@ to allow more room for + larger cmsy arrowheads. + +---Corrected spurious "overfull \hbox" warnings for \xrightarrow. + +---Corrected poor spacing for \xleftarrow. + +---Removed the \leavevmode in \smash which caused trouble for some + applications (e.g., the crop package) that expected the original + LaTeX definition. + +---Changed \def to \newcommand/\newenvironment where appropriate. + +---Use \sqrtsign instead of \@@sqrt (but include a backward + compatibility hack for the latter). + +---Left brace in \env{cases} environment would fail to work in + certain circumstances: Fix by using \lbrace instead of \{. + +---Use \ignorespacesafterend where applicable instead of + \global\@ignoretrue. + +---Protected commands in the definition of \theequation were + incorrectly expanded by the subequations environment when copying + the definition to \theparentequation: Fix by using \protected@edef. + +---Spurious extra space following punctuation at that end of a display: + In \math@cr, \math@cr@@, etc, use \iffalse{\fi instead of simply { to + keep an unwanted mathord atom from being added at the end of the + current math list; added \endmultline@math to work around a similar + sort of problem specific to the `multline' environment. + +---Various wrong results or no effect for \displaybreak inside "align", + "alignat", etc. Resetting \dspbrk@level in the \everycr of + \@display@init cleared most of these up. + +---Changed \displaybreak to issue an error message if enclosed in boxing + environment that will keep it from having any effect. + +---Turned off \displaybreak during the measuring phase of multline. + +---Fixed some numbering problems with multline and multline* and error + for use of \tag. + +---Use \@gtempa instead of \@tempa where assigned globally (standard + save stack precaution). + +---Save and restore \column@ to keep aligned from screwing up the column + counting of a parent align environment. Made \column@ assignments + uniformly global, except in a couple of places where the risk of side + effects seemed too great. + +---Error recovery for misspelled '\end{multline}' was not very helpful. + Improve \collect@body along lines suggested by Hellström. + +---Fixed up certain number placement problems with align + +---Add \alignsafe@testopt to work around a LaTeX bug: when a nested + alignment environment that takes an optional argument has an empty + first cell (i.e., begins with an &) LaTeX's optional argument + scanning screws up the alignment state. + +---Add `mathdisplay' environment (internal use) to correct several + problems of \[ \] and the `equation' environment arising from the + previous implementation as a degenerate case of `gather'. + +---It is possible now to use \eeq as an abbreviation for \end{equation} +(one of the consequences of the preceding change). But still not \eal +for \end{align} or certain other display structures. + +---Reorganize `split' internal calling sequence to go along with the use + of `mathdisplay' in \[ \] and `equation'. + +---Suppression of LaTeX error messages during measuring phase made + primitive TeX errors harder to understand; stop suppressing. (As a + result, users will sometimes get redundant error messages now.) + Remove obsolete Sb, Sp environments again. + +---The file amsintx.dtx was removed from the distribution pending + further development. + +---Remove the \ifinany@ switch, use \spread@equation instead to achieve + the same ends. + +---Remove unbracefonts@ function, no longer needed after changes in + math accent handling. + +---Got rid of the special trap for '^x that had been carried over from +AMS-TeX. + +---Made \overline, \doteq, \longrightarrow, etc, robust. + +---Changed \relbar to use \std@minus---otherwise \underleftrightarrow +works poorly in a \DeclareMathOperator definition. + +---Use \new@ifnextchar in matrix, pmatrix, cases so that \\<newline>[x] +doesn't trigger an error. + +---Bug fix for nested use of \label inside minipage inside equation. + +---Add minalignsep after every second column in aligned, for consistency +with align. + +======================================================================== +Changes in amsmath 1.2 [January 1995] + +---Name change; relation to the "amsfonts" package + +In version 1.1 of AMS-LaTeX, the name of this package was "amstex". The +new name is "amsmath". The amstex package automatically invoked the +amsfonts package as well; the amsmath package does not. + +---Adapted for LaTeX2e + +Old method of invocation: + + \documentstyle[amstex]{article}% LaTeX 2.09 + +New method of invocation: + + \documentclass{article} + \usepackage{amsmath} + +---Handling of options intlim, nosumlim, nonamelm, righttag, ctagsplt + +Old usage: + + \documentstyle[amstex,righttag,intlim] + +New usage: + + \usepackage[reqno,intlimits]{amsmath} + +Several option names were changed (mainly, they are no longer restricted +to eight characters): + + intlim -> intlimits + nosumlim -> nosumlimits + nonamelm -> nonamelimits + righttag -> reqno [for consistency with "leqno"] + ctagsplt -> centertags + +---Character @ is no longer used as a special command prefix + +Certain commands in the amstex pkg started with "@" instead of "\". This +special usage has been discontinued, except for the amscd package, and +then only within the CD environment. Practically speaking, this means +primarily that it is no longer necessary to use doubled @@ to get a +single printed @ character (e.g., in e-mail addresses). + +---The @, and @! micro-spacing commands are no longer provided + +As a consequence of the @ character change, "@," and "@!" are no longer +recognized spacing commands. An \mspace command is provided that can be +used instead; see the AMSmath User's Guide. + +---Extensible arrow commands @>>> and @<<< + +The commands @>>> and @<<< are no longer available [except in the CD +environment of the amscd package]; alternative commands \xleftarrow and +\xrightarrow are provided by the amsmath package. The sub and +superscripts are given through an optional resp. mandatory argument, for +example + + X\xleftarrow{b}Y % superscript "b" only + X\xrightarrow[\alpha]{\beta}Y % sub alpha, sup beta + +---The command \bold has been superseded by the command \mathbf, as the +latter is now the standard name provided by LaTeX for this purpose. + +---The commands \newsymbol, \frak, \Bbb are no longer available because +the amsfonts package is not loaded by amsmath. In any case those +commands now have new names---\frak -> \mathfrak, \Bbb -> \mathbb, etc. +See the amsfonts documentation for further details. + +---The amsmath package provides \lvert and \rvert to use for vert-bar +symbols when they act as delimiters (compare \langle, \rangle for +angle-bracket delimiters). Commands \lVert and \rVert are likewise +provided instead of \| for paired-delimiter use of the double-vert +symbol. Use of | and \| for paired delimiters can lead to incorrect +spacing in rare cases. Further discussion is found in the AMS-LaTeX +user's guide (amsldoc.tex). + +---The ~ command is now left unchanged by amsmath; the change +that makes it remove a redundant preceding or following space character +is now done only by AMS documentclasses (in version 1.1 this was done by +the amstex package). + +---The following rarely used commands are removed to the amsxtra +package: \accentedsymbol, \sphat, \spcheck, \sptilde, \spdot, \spddot, +\spdddot, \spbreve, \@))), \@(((. + +---The six generalized fraction commands \over, \overwithdelims, \atop, +\atopwithdelims, \above, \abovewithdelims are deprecated and produce +warning messages. Their functionality can be obtained through \frac, +\binom, and \genfrac instead. See amsldoc.tex and technote.tex for +further details. + +---The \fracwithdelims command is gone, as \genfrac provides +equivalent functionality (and a little more). + +---The optional argument of \frac that allowed changing the thickness of +the fraction line is gone. That functionality is now provided only +through \genfrac: the need to change the line thickness is so rare in +practice that it seems better not to burden the ubiquitous \frac command +with the somewhat time-consuming look-ahead process required for an +optional argument. I.e., this change will contribute in a small way to +making your documents run faster. + +---The commands \lcfrac and \rcfrac for left or right alignment of +continued fraction numerators are gone; they are replaced by an optional +argument of the \cfrac command. + +---A new command \DeclareMathOperator is provided for defining new +operator names: + +\DeclareMathOperator{\Tr}{Tr} +\DeclareMathOperator*{\xlim}{x-lim} + +The * form makes the operator name produce limit-style sub and +superscripts, like \max or \lim. This is now the preferred method, +instead of using the old command \operatorname (which is, however, +retained for now). The command \operatornamewithlimits has been renamed +\operatorname*. These commands now can also be obtained through a +separate package amsopn, so it's not necessary to load the entire +amsmath package just to get that feature. + +---Environments "Sb", "Sp" retired. + +The environments Sb and Sp for multiline subscripts have been replaced +by a single command \substack, used as follows: + +\sum_{\substack{first line\\second line}} + +This command can be used equally well in a subscript or superscript, and +provides better vertical positioning (as compared to Sb, Sp) if a +multiline subscript is placed on the side, as perhaps for an integral. +There is also a slightly generalized alternative, an environment +subarray that allows you to specify either centering or left alignment +for the contents: + +\sum_{\begin{subarray}{l}first line\\second line\end{subarray}} + +---New command \nobreakdash + +A command \nobreakdash is provided to suppress the possibility of a +linebreak after the following hyphen or dash. For example, if you write +"$p$\nobreakdash-adic" then a linebreak will never be taken between the +hyphen and the "adic". + +---The placement of equation numbers has been substantially improved for +align, gather, and split. Numbers will now never overlap on top of the +equation body (as far as we can ascertain), and they are much less +likely to be shifted up or down unnecessarily when there is actually +adequate space to leave the number in the normal place. In a few +remaining cases, an equation number will be shifted unnecessarily +because technical complications make accurate measurement of the +available room too difficult; for those cases a \raisetag command is +provided that allows you to manually adjust the vertical position of the +equation number. + +---The [xx]align[at] family of environments has been thoroughly revised: +now the xalignat environment is gone, as its function has been merged +into the align environment (it's no longer necessary to specify how many +side-by-side structures, as was required for xalignat, because align +automatically handles any number of them). Similarly, the xxalignat +environment has been replaced by an environment flalign that doesn't +require you to specify how many side-by-side structures will be needed. +Certain numbering problems (presence of an equation number when it +should be absent, or vice versa) have also been cleared up. + +(Thanks to David M. Jones for his substantial [volunteer] work behind +this change and the preceding one.) + +---The alignedat environment was changed to take two arguments rather +than one: a mandatory argument (as formerly) specifying the number of +align structures, and a new optional one specifying the placement of the +environment (parallel to the optional argument of aligned). However, +aligned is simpler to use, allowing any number of aligned structures +automatically, and therefore the use of alignedat is deprecated. + +---The seldom-used command \oldnos is gone; if you need it, you should +consult the LaTeX documentation on using fonts (e.g., fntguide.tex) to +find out how to construct an equivalent command. + +---A new subequations environment causes all numbered equation +environments within its scope to be numbered (4.9a) (4.9b) (4.9c) etc., +if the preceding numbered equation was 4.8. A \label command immediately +after \begin{subequations} will produce a \ref of the parent number +`4.9', not `4.9a'. The counters used by the subequations environment are +parentequation and equation and standard uses of \addtocounter, +\setcounter, etc., are possible with those counter names. + +---The amsmath package (unlike amstex) respects the setting provided by +the documentclass for putting equation numbers on the right or the left. +[Technical note: a documentclass that has leqno as the default should +explicitly pass that option to the amsmath package with +\PassOptionsToPackage in order for it to be effective.] + +---The fleqn option for left-aligned instead of centered equations is +now supported (thanks to David M. Jones). + +************************************************************************ +The remainder of this file discusses some changes that do not directly +pertain to the amsmath package but to the parent distribution known as +"AMS-LaTeX". + +======================================================================== +Changes in AMS-LaTeX 2.0 + +---The AMS-LaTeX User's Guide (amsldoc.tex) is split up into amsldoc.tex +and amsthdoc.tex, with the latter moving into the "classes" area. + +---The file amslatex.faq was split into amsmath.faq and amsclass.faq. + +---The file amslatex.bug was done away with; most of the information was +merged into diffs-m.txt, diffs-c.txt, amsmath.faq, and amsclass.faq. + +======================================================================== +Changes in AMS-LaTeX 1.2 + +---Adapted for LaTeX2e + +AMS-LaTeX 1.0 and 1.1 were designed to work with LaTeX 2.09, which +became obsolete in 1994 with the appearance of "LaTeX2e". AMS-LaTeX 1.2 +has been extensively adapted to take advantage of various features of +LaTeX2e. It is no longer a separate TeX format---i.e., it does not need +to be invoked by a separate "amslatex" command. + +---LaTeX 2.09 font commands (\bf, \it, etc) + +Pre-existing documents will for the most part continue to work fine +without requiring any changes. However, depending on the installation +options used for your copy of AMS-LaTeX 1.1 you may need to update the +options list of the \documentstyle command by adding newlfont, for +example: + + \documentstyle[newlfont]{amsart} + +---The packages amsfonts, amssymb were moved to the AMSFonts +distribution. They used to be included in the AMS-LaTeX distribution for +pragmatic reasons but their natural home is with the AMSFonts +distribution. + +---Package amstex renamed to amsmath + +The amstex package has been renamed amsmath. The old name `amstex' came +from the fact that version 1.0 was a more or less straight port into +LaTeX of selected portions from the macro package AmS-TeX written by +Michael Spivak, but the historical origins of the package are likely of +less interest to the general usership---especially looking to the +future---than a straightforward declaration in the name `amsmath' of the +sort of features that are provided. + +Another important reason for the name change was to make possible some +progress that would be out of the question (because of the impact on +existing documents) if the name `amstex' were retained. For example, +unlike amstex, amsmath doesn't automatically load the amsfonts package, +as that package was moved out to the AMSFonts distribution as described +above. If this change were not accompanied by a name change, many +existing documents would have to be updated by hand (adding +\usepackage{amsfonts}) in order to run without error. A frozen version +of amstex.sty is provided for processing pre-existing documents; it +won't have active maintainence henceforth except for bug fixes. For new +documents, authors should use the amsmath package. + +Therefore, "\usepackage{amstex}" is incorrect usage---do not rely on the +1994 edition of `The LaTeX Companion' in this respect (unless you obtain +the errata for Chapter 8). + +---New documentclass amsproc + +A new documentclass amsproc was added for collections of articles, such as +the proceedings of a conference. diff --git a/macros/latex-dev/required/amsmath/manifest.txt b/macros/latex-dev/required/amsmath/manifest.txt new file mode 100644 index 0000000000..ee6b8e3238 --- /dev/null +++ b/macros/latex-dev/required/amsmath/manifest.txt @@ -0,0 +1,32 @@ +README.txt +amsbsy.dtx +amsbsy.ins +amsbsy.pdf +amscd.dtx +amscd.ins +amscd.pdf +amsgen.dtx +amsgen.ins +amsgen.pdf +amsldoc.pdf +amsldoc.tex +amsmath.dtx +amsmath.ins +amsmath.pdf +amsopn.dtx +amsopn.ins +amsopn.pdf +amstex.sty +amstext.dtx +amstext.ins +amstext.pdf +amsxtra.dtx +amsxtra.ins +amsxtra.pdf +diffs-m.txt +subeqn.pdf +subeqn.tex +technote.pdf +technote.tex +testmath.pdf +testmath.tex diff --git a/macros/latex-dev/required/amsmath/subeqn.pdf b/macros/latex-dev/required/amsmath/subeqn.pdf Binary files differnew file mode 100644 index 0000000000..2e84ebe942 --- /dev/null +++ b/macros/latex-dev/required/amsmath/subeqn.pdf diff --git a/macros/latex-dev/required/amsmath/subeqn.tex b/macros/latex-dev/required/amsmath/subeqn.tex new file mode 100644 index 0000000000..c34b3f6952 --- /dev/null +++ b/macros/latex-dev/required/amsmath/subeqn.tex @@ -0,0 +1,202 @@ +%%% ==================================================================== +%%% @LaTeX-file{ +%%% filename = "subeqn.tex", +%%% version = "1.2c", +%%% date = "1999/11/29", +%%% time = "14:49:29 EST", +%%% checksum = "29866 202 668 6426", +%%% author = "American Mathematical Society", +%%% copyright = "Copyright 1999 American Mathematical Society, +%%% all rights reserved. Copying of this file is +%%% authorized only if either: +%%% (1) you make absolutely no changes to your copy, +%%% including name; OR +%%% (2) if you do make changes, you first rename it +%%% to some other name.", +%%% address = "American Mathematical Society, +%%% Technical Support, +%%% Electronic Products and Services, +%%% P. O. Box 6248, +%%% Providence, RI 02940, +%%% USA", +%%% telephone = "401-455-4080 or (in the USA and Canada) +%%% 800-321-4AMS (321-4267)", +%%% FAX = "401-331-3842", +%%% email = "tech-support@ams.org (Internet)", +%%% supported = "yes", +%%% keywords = "latex, amslatex, ams-latex, amstex", +%%% abstract = "This is part of the AMS-\LaTeX{} distribution. +%%% It is a sample document illustrating the use of +%%% the subequations environment and the effect of +%%% the fleqn option.", +%%% docstring = "The checksum field above contains a CRC-16 +%%% checksum as the first value, followed by the +%%% equivalent of the standard UNIX wc (word +%%% count) utility output of lines, words, and +%%% characters. This is produced by Robert +%%% Solovay's checksum utility.", +%%% } +%%% ==================================================================== +\documentclass[fleqn]{article} + +\title{Test of subequations environment} +\author{mjd} + +\usepackage{amsmath} +\numberwithin{equation}{section} + +\newcommand{\env}[1]{{\normalfont\texttt{#1}}} + +\AtEndDocument{\multipasswarning} +\newcommand{\multipasswarning}{% + \clearpage + \typeout{% + **********************************************************************} + \typeout{% + Note: This document needs to run through LaTeX three times, instead of} + \typeout{% + the usual two, to resolve indirect cross-references.} + \typeout{% + **********************************************************************} +} + +\makeatletter +% Omit the warning message if three passes have been completed (on +% first pass \ref{check} is undefined and it is set to 0; on second +% pass \ref{check} is 0 and set to 1; on third pass it is 1). +\def\checkref{\begingroup + \@ifundefined{r@check}{\let\r@check\relax\def\@currentlabel{0}}{\def\@currentlabel{1}}% + \ifnum1=0\expandafter\@firstoftwo\r@check\relax + \global\let\multipasswarning\relax + \fi + \label{check}% + \endgroup} +\makeatother + +\begin{document} +\section{Prime equation numbers} + +First an equation. +\begin{equation}\label{e:previous} +A=B +\end{equation} +That was equation \eqref{e:previous}. + +Then the same, with a prime on the number.\checkref +\begin{equation} +\tag{\ref{e:previous}$'$}\label{e:prevprime} +C=D +\end{equation} +And that was equation \eqref{e:prevprime}. + +Notice, by the way, that when a \verb"\ref" occurs inside a \verb"\tag", +and that \verb"\tag" is then \verb"\label"'d, a \verb"\ref" for the the +second \verb"\label" requires \emph{three} runs of \LaTeX{} in order to +get the proper value. (If you run through the logic of \LaTeX{}'s +cross-referencing mechanisms as they apply in this case, you will see +that this is necessary.) + +\section{Subnumbered equations} + +Here is a,b,c sub-numbering. +\begin{subequations} +\begin{eqnarray} +A&=&B\\ +D&=&C \label{e:middle}\\ +E&=&F +\end{eqnarray} +\end{subequations} +That was produced with the \env{eqnarray} environment; the middle line +was labeled as \eqref{e:middle}. + +An equation following the end of the \verb"subequations" environment +should revert to normal numbering: +\begin{equation}\label{e:check} +H<K +\end{equation} +A check on the labeling: that was equation~\eqref{e:check}. + +The sub-numbered equations can be spread out through the text, like +this: +\begin{subequations} +\begin{equation} +A=B +\end{equation} +The \verb"subequations" environment can span arbitrary text between +subsidiary equations. The only restriction is that if there are any +numbered equations inside the \verb"subequations" environment that break +out of the subequation numbering sequence, they would have to be handled +specially. +\begin{equation} +D=C \label{e:newmiddle} +\end{equation} +More arbitrary text. +\begin{equation} +E=F +\end{equation} +\end{subequations} +Label check: the middle one was \eqref{e:newmiddle} + +A final equation for a numbering check. +\begin{equation}\label{e:final} +G=H +\end{equation} +That equation was labeled as \eqref{e:final}. + +\section{Tests of \env{align}, \env{gather}, and other +AMS-\protect\LaTeX{} environments} + +The \env{align} environment: +\begin{subequations} +\begin{align} +\label{align:a}A+B&=B+A\\ +\label{align:b}C&=D+E\\ +\label{align:c}E&=F +\end{align} +\end{subequations} +Label check: that was \eqref{align:a}, \eqref{align:b}, and +\eqref{align:c}. + +The \env{align} environment again: +\begin{subequations} +\begin{align} +\label{xalign:a}A+B&=B& B&=B+A\\ +\label{xalign:b}C&=D+E& C\oplus D&=E\\ +\label{xalign:c}E&=F& E'&=F' +\end{align} +\end{subequations} +Label check: that was \eqref{xalign:a}, \eqref{xalign:b}, and +\eqref{xalign:c}. + +The \env{gather} environment. For the third line we refer to one of the +numbers in the first \env{align} structure. +\begin{subequations} +\begin{gather} +\label{gather:a}A+B=B\\ +\label{gather:b}C=D+E\\ +\tag{\ref{align:c}$'$}\label{gather:c}E=F +\end{gather} +\end{subequations} +Label check: that was \eqref{gather:a}, +\eqref{gather:b}, and +\eqref{gather:c}. + +The next \env{subequations} environment encompasses two separate +equations. A \env{split} environment: +\begin{subequations} +\begin{equation} +\label{split:x} +\begin{split} +A&=B+C+F\\ +&=G +\end{split} +\end{equation} +and a \env{multline} environment: +\begin{multline}\label{multline:x} +A[B]C[D]E[F]G[[H[I]J[K]L[M]N]]=\\ +H[I]J[K]L[M]N[O]P[Q]R[S]T[U]V[W]X[Y]Z +\end{multline} +\end{subequations} +Label check: That was \eqref{split:x} and \eqref{multline:x}. + +\end{document} diff --git a/macros/latex-dev/required/amsmath/technote.pdf b/macros/latex-dev/required/amsmath/technote.pdf Binary files differnew file mode 100644 index 0000000000..7d7ab397c8 --- /dev/null +++ b/macros/latex-dev/required/amsmath/technote.pdf diff --git a/macros/latex-dev/required/amsmath/technote.tex b/macros/latex-dev/required/amsmath/technote.tex new file mode 100644 index 0000000000..aede450621 --- /dev/null +++ b/macros/latex-dev/required/amsmath/technote.tex @@ -0,0 +1,233 @@ +%%% ==================================================================== +%%% @LaTeX-file{ +%%% filename = "technote.tex", +%%% version = "2.0", +%%% date = "1999/11/15", +%%% time = "15:07:20 EST", +%%% checksum = "58506 233 1647 12005", +%%% author = "American Mathematical Society", +%%% copyright = "Copyright 1995, 1999 American Mathematical Society, +%%% all rights reserved. Copying of this file is +%%% authorized only if either: +%%% (1) you make absolutely no changes to your copy, +%%% including name; OR +%%% (2) if you do make changes, you first rename it +%%% to some other name.", +%%% address = "American Mathematical Society, +%%% Technical Support, +%%% Electronic Products and Services, +%%% P. O. Box 6248, +%%% Providence, RI 02940, +%%% USA", +%%% telephone = "401-455-4080 or (in the USA and Canada) +%%% 800-321-4AMS (321-4267)", +%%% FAX = "401-331-3842", +%%% email = "tech-support@ams.org (Internet)", +%%% supported = "yes", +%%% keywords = "amsmath, latex", +%%% abstract = "This is part of the AMS-\LaTeX{} distribution. It +%%% is a document discussing some technical issues in the +%%% contents and interface of AMS-\LaTeX{} packages." +%%% docstring = "The checksum field above contains a CRC-16 checksum +%%% as the first value, followed by the equivalent of +%%% the standard UNIX wc (word count) utility output of +%%% lines, words, and characters. This is produced by +%%% Robert Solovay's checksum utility.", +%%% } +%%% ==================================================================== +\NeedsTeXFormat{LaTeX2e}% LaTeX 2.09 can't be used (nor non-LaTeX) +[1994/12/01]% LaTeX date must December 1994 or later +\documentclass{amsdtx} + +\title{Technical notes on the \pkg{amsmath} package} +\author{American Mathematical Society\\Michael Downes} +\date{1999/10/29} + +\markboth + {Technical notes on the \pkg{amsmath} package} + {Technical notes on the \pkg{amsmath} package} +\renewcommand{\sectionmark}[1]{} + +\providecommand{\etc}[1]{etc.} + +\providecommand{\begend}[1]{% + {\ntt \symbol{92}begin\symbol{123}#1\symbol{125}} + \ldots\ {\ntt\symbol{92}end\symbol{123}#1\symbol{125}}% +} + +\MakeShortVerb{\|} + +\begin{document} +\maketitle + +\section{Introduction} + +These notes are miscellaneous remarks on some technical questions +applicable to version 2.0 of \amslatex/. + +\section{Deprecated and disallowed commands} + +Certain commands that were in the \pkg{amstex} package (the predecessor, +in \amslatex/ 1.0 and 1.1, of the \pkg{amsmath} package) were moved into +\pkg{amsxtra} because they seemed to be little-used relics: +\cn{accentedsymbol}, \qq{sup accents} (\cn{sptilde}, \cn{sphat}, etc.). + +Certain other commands\mdash e.g., \cn{over}, \cn{pmatrix}, and +\cn{cases}\mdash are changed by the \pkg{amsmath} package to produce +warning messages or error messages, depending on their history; these +are discussed in more detail in the following sections. + +\section{Why do \cn{matrix}, \cn{pmatrix}, and \cn{cases} stop working +when I add the \pkg{amsmath} package?} + +If you used the \fn{plain.tex} versions of \cn{matrix}, \cn{pmatrix}, or +\cn{cases} in a document and then later converted the document to use +the \pkg{amsmath} package (or one of the AMS documentclasses, which +automatically call the \pkg{amsmath} package internally), the instances +of those commands will produce error messages. The problem is that when +\latex/ was originally created, it adopted most of its mathematics +features straight from \fn{plain.tex}. But in the case of \cn{matrix}, +\cn{pmatrix}, \cn{cases} this was a mistake\mdash the \fn{plain.tex} +syntax for them is decidedly non-\latex/ in style, for example the fact +that they use \cs{cr} instead of \cn{\\} to mark line breaks, and they +don't use \cn{begin} and \cn{end}. In basic \latex/ this mistake will be +perpetuated at least until \latex/3 appears, in order to avoid breaking +existing documents. But no existing documents that were written with the +\pkg{amsmath} package have that syntactic problem, as \pkg{amsmath} +provides proper \latex/-syntax versions of \cn{matrix} and the others. +The possibility of optionally allowing the \fn{plain.tex} variants to +make document conversion easier seems ill-advised since those variants +are so blatantly wrong in a \latex/ context. The \env{array} environment +ought to have been used instead. + +\section{Why do \cn{over}, \cn{atop}, \cn{above} [\dots{\ntt withdelims}] + give a warning when I add the \pkg{amsmath} package?} + +Using the six generalized fraction commands \cn{over}, +\cn{overwithdelims}, \cn{atop}, \cn{atopwithdelims}, \cn{above}, +\cn{abovewithdelims} is not really a good idea in \latex/, for reasons +explained below. I construe \latex/'s provision of \cs{frac}, and the +lack of any mention in the \latex/ book of the primitive fraction +commands, as an implicit injunction against their use, although I don't +think Lamport actually spent a lot of time pondering the issue, and the +basic \latex/ version of \cn{frac} provides access only to \cn{over}, +not to \cn{atop}, \cn{above}, or the \verb'withdelims' variants. The +\pkg{amsmath} package, however, provides a \cn{genfrac} command that +gives user-level access to all six of the generalized fraction +primitives in a way that conforms to the syntactic conventions followed +by all other \latex/ commands. + +Not only is the unusual syntax of the \tex/ primitives rather out of +place in \latex/, but furthermore that syntax seems to be responsible +for one of the most significant flaws in \tex/'s mathematical +typesetting capabilities: the fact that the current mathstyle at any +given point in a math formula cannot be determined until the end of the +formula, because of the possibility that a following generalized +fraction command will change the mathstyle of the \emph{preceding} +material. To cite two of the worst side effects: \cn{mathchoice} must +actually typeset all four of its arguments, instead of being able to +immediately select only one; and, were it possible to always know the +current math style at a given point, math font selection would be +greatly simplified and the upper limit of 16 different math font +\cn{fam}s would never be a problem as \cn{text,script[script]font} +assignments for any \cn{fam} could take immediate effect and therefore +could be changed arbitrarily often within a single formula. More +concretely, math font selection difficulties are responsible for many of +the more convoluted passages in the source code of \latex/'s NFSS (that +does font loading on demand) and of the \pkg{amsmath} package, and by +extension it has historically been responsible for significant delays in +making new features available to end users and for making those features +more prone to bugs. + +There are additional bad consequences following from the syntax of those +generalized fraction commands that only become evident when you do some +writing of nontrivial macros for math use. For example, as things +currently stand you cannot measure the size of any object in math +without going through \cn{mathchoice} and \emph{leaving and reentering +math mode} via \verb'\hbox{$' (which then introduces complications +regarding \cn{everymath} and \cn{mathsurround}). And it seems that +uncertainty about the current mathstyle is the only barrier to allowing +the use of mu units with \cn{vrule}, to make vertical struts in +constructing compound symbols or notation. And so on and so forth. + +\section{The \opt{fleqn} option and \cn{mathindent}} + +Strictly speaking, the \pkg{amsmath} package doesn't use \cn{mathindent} +to control the left indent of displayed equations when the \opt{fleqn} +option is in effect: it uses an internal parameter \cs{@mathmargin} +instead. However, for compatibility with existing \latex/ documentation, +\pkg{amsmath} turns \cn{mathindent} into an alias for \cs{@mathmargin}. +There is a small risk here: In the plain \latex/ implementation, +\cn{mathindent} is a dimen register, but with \pkg{amsmath} +\cs{@mathmargin} is a skip register and, by association, so is +\cn{mathindent}. If any package or documentclass uses \cn{mathindent} in +a way that depends on it being a dimen register, when used in +conjunction with the \pkg{amsmath} package it may be vulnerable to a +well-known pitfall having to do with the primitive \tex/ lookahead for a +\texttt{plus} or \texttt{minus} key word. However if the standard +\latex/ commands \cn{setlength} and \cn{addtolength} are used to modify +\cn{mathindent} then this problem will not arise. + +\section{Why can't I use abbreviations for \protect\begend{align}?} + +Authors often like to use abbreviations such as |\beq| |\eeq| for +|\begin{equation}| |\end{equation}|. For some environments defined by +the \pkg{amsmath} package, such as \env{align}, \env{gather}, +\env{multline}, and others of the same general type, this does not work: +An attempt to define |\bal| |\eal| as shorthand for |\begin{align}| +|\end{align}| will fail with a puzzling error message. This has to do +with unfortunately nontrivial technical complications: the given +environments must read their contents as a delimited macro argument +because they do multipass processing of the contents using algorithms +inherited from Spivak's \fn{amstex.tex}. The obvious +solution\mdash substitution of different algorithms that do box shuffling +instead of token shuffling for the multipass calculations\mdash would +require rewriting these display environments from the ground up; while +that is a worthy goal, it was beyond the original scope of the +\amslatex/ project. Work is under way on an auxiliary package called +\pkg{breqn} that addresses not only this problem but a number of others; +at the time of this writing, however [September 1999] it has only +progressed as far as a beta release. + +Some workarounds: +\begin{itemize} +\item |\def\bal#1\eal{\begin{align}#1\end{align}}| +\item Define |\newcommand{\env}[2]{\begin{#1}#2\end{#1}}| and then use + |\env{align}{...}| +\end{itemize} + +\section{The \pkg{upref} package} + +The reason for splitting out the \pkg{upref} package instead of +automatically incorporating it in the \cls{amsart} and \cls{amsbook} +classes is this: It involves low-level surgery on an important \latex/ +command. This means that if ever this command changes in the future (as +it did between versions 2.09 and 2e of \latex/) we have a maintenance +problem. And the benefit that \pkg{upref} provides is something that +most end users don't care much about. + +\section{The \pkg{amsintx} package} + +After a very preliminary trial release the \pkg{amsintx} package was +withdrawn to await further development. It is still considered a worthy +project but has simply not yet made it to the head of the priority queue +in the AMS \latex/ development program, as it has had to contend with a +number of other equally worthy projects for development time. + +\section{Hyphenation in the documentation} + +Hyphenation was allowed for certain long command names in +\fn{amsldoc.tex}; this presented technical difficulties because \latex/ +normally deactivates hyphenation for tt fonts. The method chosen to +reinstate hyphenation was to turn off the encoding-specific function +\cs{OT1+cmtt} that disables the \cs{hyphenchar} for tt fonts; see the +definition of \cn{allowtthyphens} in \fn{amsdtx.dtx}. Then a list of all +tt words in the document was gathered (from the \fn{.idx} file, produced +by the \cn{cn}, \cn{fn}, \cn{pkg}, etc. commands) and \cn{showhyphens} +was applied to this list. The result was another list in the resulting +\tex/ log, containing those words in a form suitable for the argument of +\cn{hyphenation}. That list was then edited by hand to overrule +undesirable hyphenations; words with acceptable hyphenations were +dropped from the list, as they don't need to be repeated there. + +\end{document} diff --git a/macros/latex-dev/required/amsmath/testmath.pdf b/macros/latex-dev/required/amsmath/testmath.pdf Binary files differnew file mode 100644 index 0000000000..d97ff85f73 --- /dev/null +++ b/macros/latex-dev/required/amsmath/testmath.pdf diff --git a/macros/latex-dev/required/amsmath/testmath.tex b/macros/latex-dev/required/amsmath/testmath.tex new file mode 100644 index 0000000000..069944ee9d --- /dev/null +++ b/macros/latex-dev/required/amsmath/testmath.tex @@ -0,0 +1,2342 @@ +%%% ==================================================================== +%%% @LaTeX-file{ +%%% filename = "testmath.tex", +%%% version = "2.0", +%%% date = "1999/11/15", +%%% time = "15:09:17 EST", +%%% checksum = "07762 2342 7811 82371", +%%% author = "American Mathematical Society", +%%% copyright = "Copyright 1995, 1999 American Mathematical Society, +%%% all rights reserved. Copying of this file is +%%% authorized only if either: +%%% (1) you make absolutely no changes to your copy, +%%% including name; OR +%%% (2) if you do make changes, you first rename it +%%% to some other name.", +%%% address = "American Mathematical Society, +%%% Technical Support, +%%% Electronic Products and Services, +%%% P. O. Box 6248, +%%% Providence, RI 02940, +%%% USA", +%%% telephone = "401-455-4080 or (in the USA and Canada) +%%% 800-321-4AMS (321-4267)", +%%% FAX = "401-331-3842", +%%% email = "tech-support@ams.org (Internet)", +%%% codetable = "ISO/ASCII", +%%% keywords = "latex, amsmath, examples, documentation", +%%% supported = "yes", +%%% abstract = "This is a test file containing extensive examples of +%%% mathematical constructs supported by the amsmath +%%% package.", +%%% docstring = "The checksum field above contains a CRC-16 +%%% checksum as the first value, followed by the +%%% equivalent of the standard UNIX wc (word +%%% count) utility output of lines, words, and +%%% characters. This is produced by Robert +%%% Solovay's checksum utility.", +%%% } +%%% ==================================================================== +\NeedsTeXFormat{LaTeX2e}% LaTeX 2.09 can't be used (nor non-LaTeX) +[1994/12/01]% LaTeX date must December 1994 or later +\documentclass[draft]{article} +\pagestyle{headings} + +\title{Sample Paper for the \pkg{amsmath} Package\\ +File name: \fn{testmath.tex}} +\author{American Mathematical Society} +\date{Version 2.0, 1999/11/15} + +\usepackage{amsmath,amsthm} + +% Some definitions useful in producing this sort of documentation: +\chardef\bslash=`\\ % p. 424, TeXbook +% Normalized (nonbold, nonitalic) tt font, to avoid font +% substitution warning messages if tt is used inside section +% headings and other places where odd font combinations might +% result. +\newcommand{\ntt}{\normalfont\ttfamily} +% command name +\newcommand{\cn}[1]{{\protect\ntt\bslash#1}} +% LaTeX package name +\newcommand{\pkg}[1]{{\protect\ntt#1}} +% File name +\newcommand{\fn}[1]{{\protect\ntt#1}} +% environment name +\newcommand{\env}[1]{{\protect\ntt#1}} +\hfuzz1pc % Don't bother to report overfull boxes if overage is < 1pc + +% Theorem environments + +%% \theoremstyle{plain} %% This is the default +\newtheorem{thm}{Theorem}[section] +\newtheorem{cor}[thm]{Corollary} +\newtheorem{lem}[thm]{Lemma} +\newtheorem{prop}[thm]{Proposition} +\newtheorem{ax}{Axiom} + +\theoremstyle{definition} +\newtheorem{defn}{Definition}[section] + +\theoremstyle{remark} +\newtheorem{rem}{Remark}[section] +\newtheorem*{notation}{Notation} + +%\numberwithin{equation}{section} + +\newcommand{\thmref}[1]{Theorem~\ref{#1}} +\newcommand{\secref}[1]{\S\ref{#1}} +\newcommand{\lemref}[1]{Lemma~\ref{#1}} + +\newcommand{\bysame}{\mbox{\rule{3em}{.4pt}}\,} + +% Math definitions + +\newcommand{\A}{\mathcal{A}} +\newcommand{\B}{\mathcal{B}} +\newcommand{\st}{\sigma} +\newcommand{\XcY}{{(X,Y)}} +\newcommand{\SX}{{S_X}} +\newcommand{\SY}{{S_Y}} +\newcommand{\SXY}{{S_{X,Y}}} +\newcommand{\SXgYy}{{S_{X|Y}(y)}} +\newcommand{\Cw}[1]{{\hat C_#1(X|Y)}} +\newcommand{\G}{{G(X|Y)}} +\newcommand{\PY}{{P_{\mathcal{Y}}}} +\newcommand{\X}{\mathcal{X}} +\newcommand{\wt}{\widetilde} +\newcommand{\wh}{\widehat} + +\DeclareMathOperator{\per}{per} +\DeclareMathOperator{\cov}{cov} +\DeclareMathOperator{\non}{non} +\DeclareMathOperator{\cf}{cf} +\DeclareMathOperator{\add}{add} +\DeclareMathOperator{\Cham}{Cham} +\DeclareMathOperator{\IM}{Im} +\DeclareMathOperator{\esssup}{ess\,sup} +\DeclareMathOperator{\meas}{meas} +\DeclareMathOperator{\seg}{seg} + +% \interval is used to provide better spacing after a [ that +% is used as a closing delimiter. +\newcommand{\interval}[1]{\mathinner{#1}} + +% Notation for an expression evaluated at a particular condition. The +% optional argument can be used to override automatic sizing of the +% right vert bar, e.g. \eval[\biggr]{...}_{...} +\newcommand{\eval}[2][\right]{\relax + \ifx#1\right\relax \left.\fi#2#1\rvert} + +% Enclose the argument in vert-bar delimiters: +\newcommand{\envert}[1]{\left\lvert#1\right\rvert} +\let\abs=\envert + +% Enclose the argument in double-vert-bar delimiters: +\newcommand{\enVert}[1]{\left\lVert#1\right\rVert} +\let\norm=\enVert + +\begin{document} +\maketitle +\markboth{Sample paper for the {\protect\ntt\lowercase{amsmath}} package} +{Sample paper for the {\protect\ntt\lowercase{amsmath}} package} +\renewcommand{\sectionmark}[1]{} + +\section{Introduction} + +This paper contains examples of various features from \AmS-\LaTeX{}. + +\section{Enumeration of Hamiltonian paths in a graph} + +Let $\mathbf{A}=(a_{ij})$ be the adjacency matrix of graph $G$. The +corresponding Kirchhoff matrix $\mathbf{K}=(k_{ij})$ is obtained from +$\mathbf{A}$ by replacing in $-\mathbf{A}$ each diagonal entry by the +degree of its corresponding vertex; i.e., the $i$th diagonal entry is +identified with the degree of the $i$th vertex. It is well known that +\begin{equation} +\det\mathbf{K}(i|i)=\text{ the number of spanning trees of $G$}, +\quad i=1,\dots,n +\end{equation} +where $\mathbf{K}(i|i)$ is the $i$th principal submatrix of +$\mathbf{K}$. +\begin{verbatim} +\det\mathbf{K}(i|i)=\text{ the number of spanning trees of $G$}, +\end{verbatim} + +Let $C_{i(j)}$ be the set of graphs obtained from $G$ by attaching edge +$(v_iv_j)$ to each spanning tree of $G$. Denote by $C_i=\bigcup_j +C_{i(j)}$. It is obvious that the collection of Hamiltonian cycles is a +subset of $C_i$. Note that the cardinality of $C_i$ is $k_{ii}\det +\mathbf{K}(i|i)$. Let $\wh X=\{\hat x_1,\dots,\hat x_n\}$. +\begin{verbatim} +$\wh X=\{\hat x_1,\dots,\hat x_n\}$ +\end{verbatim} +Define multiplication for the elements of $\wh X$ by +\begin{equation}\label{multdef} +\hat x_i\hat x_j=\hat x_j\hat x_i,\quad \hat x^2_i=0,\quad +i,j=1,\dots,n. +\end{equation} +Let $\hat k_{ij}=k_{ij}\hat x_j$ and $\hat k_{ij}=-\sum_{j\not=i} \hat +k_{ij}$. Then the number of Hamiltonian cycles $H_c$ is given by the +relation \cite{liuchow:formalsum} +\begin{equation}\label{H-cycles} +\biggl(\prod^n_{\,j=1}\hat x_j\biggr)H_c=\frac{1}{2}\hat k_{ij}\det +\wh{\mathbf{K}}(i|i),\qquad i=1,\dots,n. +\end{equation} +The task here is to express \eqref{H-cycles} +in a form free of any $\hat x_i$, +$i=1,\dots,n$. The result also leads to the resolution of enumeration of +Hamiltonian paths in a graph. + +It is well known that the enumeration of Hamiltonian cycles and paths in +a complete graph $K_n$ and in a complete bipartite graph $K_{n_1n_2}$ +can only be found from \textit{first combinatorial principles} +\cite{hapa:graphenum}. One wonders if there exists a formula which can +be used very efficiently to produce $K_n$ and $K_{n_1n_2}$. Recently, +using Lagrangian methods, Goulden and Jackson have shown that $H_c$ can +be expressed in terms of the determinant and permanent of the adjacency +matrix \cite{gouja:lagrmeth}. However, the formula of Goulden and +Jackson determines neither $K_n$ nor $K_{n_1n_2}$ effectively. In this +paper, using an algebraic method, we parametrize the adjacency matrix. +The resulting formula also involves the determinant and permanent, but +it can easily be applied to $K_n$ and $K_{n_1n_2}$. In addition, we +eliminate the permanent from $H_c$ and show that $H_c$ can be +represented by a determinantal function of multivariables, each variable +with domain $\{0,1\}$. Furthermore, we show that $H_c$ can be written by +number of spanning trees of subgraphs. Finally, we apply the formulas to +a complete multigraph $K_{n_1\dots n_p}$. + +The conditions $a_{ij}=a_{ji}$, $i,j=1,\dots,n$, are not required in +this paper. All formulas can be extended to a digraph simply by +multiplying $H_c$ by 2. + +\section{Main Theorem} +\label{s:mt} + +\begin{notation} For $p,q\in P$ and $n\in\omega$ we write +$(q,n)\le(p,n)$ if $q\le p$ and $A_{q,n}=A_{p,n}$. +\begin{verbatim} +\begin{notation} For $p,q\in P$ and $n\in\omega$ +... +\end{notation} +\end{verbatim} +\end{notation} + +Let $\mathbf{B}=(b_{ij})$ be an $n\times n$ matrix. Let $\mathbf{n}=\{1, +\dots,n\}$. Using the properties of \eqref{multdef}, it is readily seen +that + +\begin{lem}\label{lem-per} +\begin{equation} +\prod_{i\in\mathbf{n}} +\biggl(\sum_{\,j\in\mathbf{n}}b_{ij}\hat x_i\biggr) +=\biggl(\prod_{\,i\in\mathbf{n}}\hat x_i\biggr)\per \mathbf{B} +\end{equation} +where $\per \mathbf{B}$ is the permanent of $\mathbf{B}$. +\end{lem} + +Let $\wh Y=\{\hat y_1,\dots,\hat y_n\}$. Define multiplication +for the elements of $\wh Y$ by +\begin{equation} +\hat y_i\hat y_j+\hat y_j\hat y_i=0,\quad i,j=1,\dots,n. +\end{equation} +Then, it follows that +\begin{lem}\label{lem-det} +\begin{equation}\label{detprod} +\prod_{i\in\mathbf{n}} +\biggl(\sum_{\,j\in\mathbf{n}}b_{ij}\hat y_j\biggr) +=\biggl(\prod_{\,i\in\mathbf{n}}\hat y_i\biggr)\det\mathbf{B}. +\end{equation} +\end{lem} + +Note that all basic properties of determinants are direct consequences +of Lemma ~\ref{lem-det}. Write +\begin{equation}\label{sum-bij} +\sum_{j\in\mathbf{n}}b_{ij}\hat y_j=\sum_{j\in\mathbf{n}}b^{(\lambda)} +_{ij}\hat y_j+(b_{ii}-\lambda_i)\hat y_i\hat y +\end{equation} +where +\begin{equation} +b^{(\lambda)}_{ii}=\lambda_i,\quad b^{(\lambda)}_{ij}=b_{ij}, +\quad i\not=j. +\end{equation} +Let $\mathbf{B}^{(\lambda)}=(b^{(\lambda)}_{ij})$. By \eqref{detprod} +and \eqref{sum-bij}, it is +straightforward to show the following +result: +\begin{thm}\label{thm-main} +\begin{equation}\label{detB} +\det\mathbf{B}= +\sum^n_{l =0}\sum_{I_l \subseteq n} +\prod_{i\in I_l}(b_{ii}-\lambda_i) +\det\mathbf{B}^{(\lambda)}(I_l |I_l ), +\end{equation} +where $I_l =\{i_1,\dots,i_l \}$ and $\mathbf{B}^{(\lambda)}(I_l |I_l )$ +is the principal submatrix obtained from $\mathbf{B}^{(\lambda)}$ +by deleting its $i_1,\dots,i_l $ rows and columns. +\end{thm} + +\begin{rem} +Let $\mathbf{M}$ be an $n\times n$ matrix. The convention +$\mathbf{M}(\mathbf{n}|\mathbf{n})=1$ has been used in \eqref{detB} and +hereafter. +\end{rem} + +Before proceeding with our discussion, we pause to note that +\thmref{thm-main} yields immediately a fundamental formula which can be +used to compute the coefficients of a characteristic polynomial +\cite{mami:matrixth}: +\begin{cor}\label{BI} +Write $\det(\mathbf{B}-x\mathbf{I})=\sum^n_{l =0}(-1) +^l b_l x^l $. Then +\begin{equation}\label{bl-sum} +b_l =\sum_{I_l \subseteq\mathbf{n}}\det\mathbf{B}(I_l |I_l ). +\end{equation} +\end{cor} +Let +\begin{equation} +\mathbf{K}(t,t_1,\dots,t_n) +=\begin{pmatrix} D_1t&-a_{12}t_2&\dots&-a_{1n}t_n\\ +-a_{21}t_1&D_2t&\dots&-a_{2n}t_n\\ +\hdotsfor[2]{4}\\ +-a_{n1}t_1&-a_{n2}t_2&\dots&D_nt\end{pmatrix}, +\end{equation} +\begin{verbatim} +\begin{pmatrix} D_1t&-a_{12}t_2&\dots&-a_{1n}t_n\\ +-a_{21}t_1&D_2t&\dots&-a_{2n}t_n\\ +\hdotsfor[2]{4}\\ +-a_{n1}t_1&-a_{n2}t_2&\dots&D_nt\end{pmatrix} +\end{verbatim} +where +\begin{equation} +D_i=\sum_{j\in\mathbf{n}}a_{ij}t_j,\quad i=1,\dots,n. +\end{equation} + +Set +\begin{equation*} +D(t_1,\dots,t_n)=\frac{\delta}{\delta t}\eval{\det\mathbf{K}(t,t_1,\dots,t_n) +}_{t=1}. +\end{equation*} +Then +\begin{equation}\label{sum-Di} +D(t_1,\dots,t_n) +=\sum_{i\in\mathbf{n}}D_i\det\mathbf{K}(t=1,t_1,\dots,t_n; i|i), +\end{equation} +where $\mathbf{K}(t=1,t_1,\dots,t_n; i|i)$ is the $i$th principal +submatrix of $\mathbf{K}(t=1,t_1,\dots,t_n)$. + +Theorem ~\ref{thm-main} leads to +\begin{equation}\label{detK1} +\det\mathbf{K}(t_1,t_1,\dots,t_n) +=\sum_{I\in\mathbf{n}}(-1)^{\envert{I}}t^{n-\envert{I}} +\prod_{i\in I}t_i\prod_{j\in I}(D_j+\lambda_jt_j)\det\mathbf{A} +^{(\lambda t)}(\overline{I}|\overline I). +\end{equation} +Note that +\begin{equation}\label{detK2} +\det\mathbf{K}(t=1,t_1,\dots,t_n)=\sum_{I\in\mathbf{n}}(-1)^{\envert{I}} +\prod_{i\in I}t_i\prod_{j\in I}(D_j+\lambda_jt_j)\det\mathbf{A} +^{(\lambda)}(\overline{I}|\overline{I})=0. +\end{equation} + +Let $t_i=\hat x_i,i=1,\dots,n$. Lemma ~\ref{lem-per} yields +\begin{multline} +\biggl(\sum_{\,i\in\mathbf{n}}a_{l _i}x_i\biggr) +\det\mathbf{K}(t=1,x_1,\dots,x_n;l |l )\\ +=\biggl(\prod_{\,i\in\mathbf{n}}\hat x_i\biggr) +\sum_{I\subseteq\mathbf{n}-\{l \}} +(-1)^{\envert{I}}\per\mathbf{A}^{(\lambda)}(I|I) +\det\mathbf{A}^{(\lambda)} +(\overline I\cup\{l \}|\overline I\cup\{l \}). +\label{sum-ali} +\end{multline} +\begin{verbatim} +\begin{multline} +\biggl(\sum_{\,i\in\mathbf{n}}a_{l _i}x_i\biggr) +\det\mathbf{K}(t=1,x_1,\dots,x_n;l |l )\\ +=\biggl(\prod_{\,i\in\mathbf{n}}\hat x_i\biggr) +\sum_{I\subseteq\mathbf{n}-\{l \}} +(-1)^{\envert{I}}\per\mathbf{A}^{(\lambda)}(I|I) +\det\mathbf{A}^{(\lambda)} +(\overline I\cup\{l \}|\overline I\cup\{l \}). +\label{sum-ali} +\end{multline} +\end{verbatim} + +By \eqref{H-cycles}, \eqref{detprod}, and \eqref{sum-bij}, we have +\begin{prop}\label{prop:eg} +\begin{equation} +H_c=\frac1{2n}\sum^n_{l =0}(-1)^{l} +D_{l}, +\end{equation} +where +\begin{equation}\label{delta-l} +D_{l}=\eval[2]{\sum_{I_{l}\subseteq \mathbf{n}} +D(t_1,\dots,t_n)}_{t_i=\left\{\begin{smallmatrix} +0,& \text{if }i\in I_{l}\quad\\% \quad added for centering +1,& \text{otherwise}\end{smallmatrix}\right.\;,\;\; i=1,\dots,n}. +\end{equation} +\end{prop} + +\section{Application} +\label{lincomp} + +We consider here the applications of Theorems~\ref{th-info-ow-ow} and +~\ref{th-weak-ske-owf} to a complete +multipartite graph $K_{n_1\dots n_p}$. It can be shown that the +number of spanning trees of $K_{n_1\dots n_p}$ +may be written +\begin{equation}\label{e:st} +T=n^{p-2}\prod^p_{i=1} +(n-n_i)^{n_i-1} +\end{equation} +where +\begin{equation} +n=n_1+\dots+n_p. +\end{equation} + +It follows from Theorems~\ref{th-info-ow-ow} and +~\ref{th-weak-ske-owf} that +\begin{equation}\label{e:barwq} +\begin{split} +H_c&=\frac1{2n} +\sum^n_{{l}=0}(-1)^{l}(n-{l})^{p-2} +\sum_{l _1+\dots+l _p=l}\prod^p_{i=1} +\binom{n_i}{l _i}\\ +&\quad\cdot[(n-l )-(n_i-l _i)]^{n_i-l _i}\cdot +\biggl[(n-l )^2-\sum^p_{j=1}(n_i-l _i)^2\biggr].\end{split} +\end{equation} +\begin{verbatim} +... \binom{n_i}{l _i}\\ +\end{verbatim} +and +\begin{equation}\label{joe} +\begin{split} +H_c&=\frac12\sum^{n-1}_{l =0} +(-1)^{l}(n-l )^{p-2} +\sum_{l _1+\dots+l _p=l} +\prod^p_{i=1}\binom{n_i}{l _i}\\ +&\quad\cdot[(n-l )-(n_i-l _i)]^{n_i-l _i} +\left(1-\frac{l _p}{n_p}\right) +[(n-l )-(n_p-l _p)]. +\end{split} +\end{equation} + +The enumeration of $H_c$ in a $K_{n_1\dotsm n_p}$ graph can also be +carried out by Theorem ~\ref{thm-H-param} or ~\ref{thm-asym} +together with the algebraic method of \eqref{multdef}. +Some elegant representations may be obtained. For example, $H_c$ in +a $K_{n_1n_2n_3}$ graph may be written +\begin{equation}\label{j:mark} +\begin{split} +H_c=& +\frac{n_1!\,n_2!\,n_3!} +{n_1+n_2+n_3}\sum_i\left[\binom{n_1}{i} +\binom{n_2}{n_3-n_1+i}\binom{n_3}{n_3-n_2+i}\right.\\ +&+\left.\binom{n_1-1}{i} +\binom{n_2-1}{n_3-n_1+i} +\binom{n_3-1}{n_3-n_2+i}\right].\end{split} +\end{equation} + +\section{Secret Key Exchanges} +\label{SKE} + +Modern cryptography is fundamentally concerned with the problem of +secure private communication. A Secret Key Exchange is a protocol +where Alice and Bob, having no secret information in common to start, +are able to agree on a common secret key, conversing over a public +channel. The notion of a Secret Key Exchange protocol was first +introduced in the seminal paper of Diffie and Hellman +\cite{dihe:newdir}. \cite{dihe:newdir} presented a concrete +implementation of a Secret Key Exchange protocol, dependent on a +specific assumption (a variant on the discrete log), specially +tailored to yield Secret Key Exchange. Secret Key Exchange is of +course trivial if trapdoor permutations exist. However, there is no +known implementation based on a weaker general assumption. + +The concept of an informationally one-way function was introduced +in \cite{imlelu:oneway}. We give only an informal definition here: + +\begin{defn} A polynomial time +computable function $f = \{f_k\}$ is informationally +one-way if there is no probabilistic polynomial time algorithm which +(with probability of the form $1 - k^{-e}$ for some $e > 0$) +returns on input $y \in \{0,1\}^{k}$ a random element of $f^{-1}(y)$. +\end{defn} +In the non-uniform setting \cite{imlelu:oneway} show that these are not +weaker than one-way functions: +\begin{thm}[\cite{imlelu:oneway} (non-uniform)] +\label{th-info-ow-ow} +The existence of informationally one-way functions +implies the existence of one-way functions. +\end{thm} +We will stick to the convention introduced above of saying +``non-uniform'' before the theorem statement when the theorem +makes use of non-uniformity. It should be understood that +if nothing is said then the result holds for both the uniform and +the non-uniform models. + +It now follows from \thmref{th-info-ow-ow} that + +\begin{thm}[non-uniform]\label{th-weak-ske-owf} Weak SKE +implies the existence of a one-way function. +\end{thm} + +More recently, the polynomial-time, interior point algorithms for linear +programming have been extended to the case of convex quadratic programs +\cite{moad:quadpro,ye:intalg}, certain linear complementarity problems +\cite{komiyo:lincomp,miyoki:lincomp}, and the nonlinear complementarity +problem \cite{komiyo:unipfunc}. The connection between these algorithms +and the classical Newton method for nonlinear equations is well +explained in \cite{komiyo:lincomp}. + +\section{Review} +\label{computation} + +We begin our discussion with the following definition: + +\begin{defn} + +A function $H\colon \Re^n \to \Re^n$ is said to be +\emph{B-differentiable} at the point $z$ if (i)~$H$ is Lipschitz +continuous in a neighborhood of $z$, and (ii)~ there exists a positive +homogeneous function $BH(z)\colon \Re^n \to \Re^n$, called the +\emph{B-derivative} of $H$ at $z$, such that +\[ \lim_{v \to 0} \frac{H(z+v) - H(z) - BH(z)v}{\enVert{v}} = 0. \] +The function $H$ is \textit{B-differentiable in set $S$} if it is +B-differentiable at every point in $S$. The B-derivative $BH(z)$ is said +to be \textit{strong} if +\[ \lim_{(v,v') \to (0,0)} \frac{H(z+v) - H(z+v') - BH(z)(v + -v')}{\enVert{v - v'}} = 0. \] +\end{defn} + + +\begin{lem}\label{limbog} There exists a smooth function $\psi_0(z)$ +defined for $\abs{z}>1-2a$ satisfying the following properties\textup{:} +\begin{enumerate} +\renewcommand{\labelenumi}{(\roman{enumi})} +\item $\psi_0(z)$ is bounded above and below by positive constants +$c_1\leq \psi_0(z)\leq c_2$. +\item If $\abs{z}>1$, then $\psi_0(z)=1$. +\item For all $z$ in the domain of $\psi_0$, $\Delta_0\ln \psi_0\geq 0$. +\item If $1-2a<\abs{z}<1-a$, then $\Delta_0\ln \psi_0\geq +c_3>0$. +\end{enumerate} +\end{lem} + +\begin{proof} +We choose $\psi_0(z)$ to be a radial function depending only on $r=\abs{z}$. +Let $h(r)\geq 0$ be a suitable smooth function satisfying $h(r)\geq c_3$ +for $1-2a<\abs{z}<1-a$, and $h(r)=0$ for $\abs{z}>1-\tfrac a2$. The radial +Laplacian +\[\Delta_0\ln\psi_0(r)=\left(\frac {d^2}{dr^2}+\frac +1r\frac d{dr}\right)\ln\psi_0(r)\] +has smooth coefficients for $r>1-2a$. Therefore, we may +apply the existence and uniqueness theory for ordinary differential +equations. Simply let $\ln \psi_0(r)$ be the solution of the differential +equation +\[\left(\frac{d^2}{dr^2}+\frac 1r\frac d{dr}\right)\ln \psi_0(r)=h(r)\] +with initial conditions given by $\ln \psi_0(1)=0$ and +$\ln\psi_0'(1)=0$. + +Next, let $D_\nu$ be a finite collection of pairwise disjoint disks, +all of which are contained in the unit disk centered at the origin in +$C$. We assume that $D_\nu=\{z\mid \abs{z-z_\nu}<\delta\}$. Suppose that +$D_\nu(a)$ denotes the smaller concentric disk $D_\nu(a)=\{z\mid +\abs{z-z_\nu}\leq (1-2a)\delta\}$. We define a smooth weight function +$\Phi_0(z)$ for $z\in C-\bigcup_\nu D_\nu(a)$ by setting $\Phi_ +0(z)=1$ when $z\notin \bigcup_\nu D_\nu$ and $\Phi_ +0(z)=\psi_0((z-z_\nu)/\delta)$ when $z$ is an element of $D_\nu$. It +follows from \lemref{limbog} that $\Phi_ 0$ satisfies the properties: +\begin{enumerate} +\renewcommand{\labelenumi}{(\roman{enumi})} +\item \label{boundab}$\Phi_ 0(z)$ is bounded above and below by +positive constants $c_1\leq \Phi_ 0(z)\leq c_2$. +\item \label{d:over}$\Delta_0\ln\Phi_ 0\geq 0$ for all +$z\in C-\bigcup_\nu D_\nu(a)$, +the domain where the function $\Phi_ 0$ is defined. +\item \label{d:ad}$\Delta_0\ln\Phi_ 0\geq c_3\delta^{-2}$ +when $(1-2a)\delta<\abs{z-z_\nu}<(1-a)\delta$. +\end{enumerate} +Let $A_\nu$ denote the annulus $A_\nu=\{(1-2a)\delta<\abs{z-z_\nu}<(1-a) +\delta \}$, and set $A=\bigcup_\nu A_\nu$. The +properties (\ref{d:over}) and (\ref{d:ad}) of $\Phi_ 0$ +may be summarized as $\Delta_0\ln \Phi_ 0\geq c_3\delta^{-2}\chi_A$, +where $\chi _A$ is the characteristic function of $A$. +\end{proof} + +Suppose that $\alpha$ is a nonnegative real constant. We apply +Proposition~\ref{prop:eg} with $\Phi(z)=\Phi_ 0(z) e^{\alpha\abs{z}^2}$. If +$u\in C^\infty_0(R^2-\bigcup_\nu D_\nu(a))$, assume that $\mathcal{D}$ +is a bounded domain containing the support of $u$ and $A\subset +\mathcal{D}\subset R^2-\bigcup_\nu D_\nu(a)$. A calculation gives +\[\int_{\mathcal{D}}\abs{\overline\partial u}^2\Phi_ 0(z) e^{\alpha\abs{z}^2} +\geq c_4\alpha\int_{\mathcal{D}}\abs{u}^2\Phi_ 0e^{\alpha\abs{z}^2} ++c_5\delta^{-2}\int_ A\abs{u}^2\Phi_ 0e^{\alpha\abs{z}^2}.\] + +The boundedness, property (\ref{boundab}) of $\Phi_ 0$, then yields +\[\int_{\mathcal{D}}\abs{\overline\partial u}^2e^{\alpha\abs{z}^2}\geq c_6\alpha +\int_{\mathcal{D}}\abs{u}^2e^{\alpha\abs{z}^2} ++c_7\delta^{-2}\int_ A\abs{u}^2e^{\alpha\abs{z}^2}.\] + +Let $B(X)$ be the set of blocks of $\Lambda_{X}$ +and let $b(X) = \abs{B(X)}$. If $\phi \in Q_{X}$ then +$\phi$ is constant on the blocks of $\Lambda_{X}$. +\begin{equation}\label{far-d} + P_{X} = \{ \phi \in M \mid \Lambda_{\phi} = \Lambda_{X} \}, +\qquad +Q_{X} = \{\phi \in M \mid \Lambda_{\phi} \geq \Lambda_{X} \}. +\end{equation} +If $\Lambda_{\phi} \geq \Lambda_{X}$ then +$\Lambda_{\phi} = \Lambda_{Y}$ for some $Y \geq X$ so that +\[ Q_{X} = \bigcup_{Y \geq X} P_{Y}. \] +Thus by M\"obius inversion +\[ \abs{P_{Y}}= \sum_{X\geq Y} \mu (Y,X)\abs{Q_{X}}.\] +Thus there is a bijection from $Q_{X}$ to $W^{B(X)}$. +In particular $\abs{Q_{X}} = w^{b(X)}$. + +Next note that $b(X)=\dim X$. We see this by choosing a +basis for $X$ consisting of vectors $v^{k}$ defined by +\[v^{k}_{i}= +\begin{cases} 1 & \text{if $i \in \Lambda_{k}$},\\ +0 &\text{otherwise.} \end{cases} +\] +\begin{verbatim} +\[v^{k}_{i}= +\begin{cases} 1 & \text{if $i \in \Lambda_{k}$},\\ +0 &\text{otherwise.} \end{cases} +\] +\end{verbatim} + +\begin{lem}\label{p0201} +Let $\A$ be an arrangement. Then +\[ \chi (\A,t) = \sum_{\B \subseteq \A} +(-1)^{\abs{\B}} t^{\dim T(\B)}. \] +\end{lem} + +In order to compute $R''$ recall the definition +of $S(X,Y)$ from \lemref{lem-per}. Since $H \in \B$, +$\A_{H} \subseteq \B$. Thus if $T(\B) = Y$ then +$\B \in S(H,Y)$. Let $L'' = L(\A'')$. Then +\begin{equation}\label{E_SXgYy} +\begin{split} +R''&= \sum_{H\in \B \subseteq \A} (-1)^{\abs{\B}} +t^{\dim T(\B)}\\ +&= \sum_{Y \in L''} \sum_{\B \in S(H,Y)} +(-1)^{\abs{\B}}t^{\dim Y} \\ +&= -\sum_{Y \in L''} \sum_{\B \in S(H,Y)} (-1)^ +{\abs{\B - \A_{H}}} t^{\dim Y} \\ +&= -\sum_{Y \in L''} \mu (H,Y)t^{\dim Y} \\ +&= -\chi (\A '',t). +\end{split} +\end{equation} + +\begin{cor}\label{tripleA} +Let $(\A,\A',\A'')$ be a triple of arrangements. Then +\[ \pi (\A,t) = \pi (\A',t) + t \pi (\A'',t). \] +\end{cor} + +\begin{defn} +Let $(\A,\A',\A'')$ be a triple with respect to +the hyperplane $H \in \A$. Call $H$ a \textit{separator} +if $T(\A) \not\in L(\A')$. +\end{defn} + +\begin{cor}\label{nsep} +Let $(\A,\A',\A'')$ be a triple with respect to $H \in \A$. +\begin{enumerate} +\renewcommand{\labelenumi}{(\roman{enumi})} +\item +If $H$ is a separator then +\[ \mu (\A) = - \mu (\A'') \] +and hence +\[ \abs{\mu (\A)} = \abs{ \mu (\A'')}. \] + +\item If $H$ is not a separator then +\[\mu (\A) = \mu (\A') - \mu (\A'') \] +and +\[ \abs{\mu (\A)} = \abs{\mu (\A')} + \abs{\mu (\A'')}. \] +\end{enumerate} +\end{cor} + +\begin{proof} +It follows from \thmref{th-info-ow-ow} that $\pi(\A,t)$ +has leading term +\[(-1)^{r(\A)}\mu (\A)t^{r(\A)}.\] +The conclusion +follows by comparing coefficients of the leading +terms on both sides of the equation in +Corollary~\ref{tripleA}. If $H$ is a separator then +$r(\A') < r(\A)$ and there is no contribution +from $\pi (\A',t)$. +\end{proof} + +The Poincar\'e polynomial of an arrangement +will appear repeatedly +in these notes. It will be shown to equal the +Poincar\'e polynomial +of the graded algebras which we are going to +associate with $\A$. It is also the Poincar\'e +polynomial of the complement $M(\A)$ for a +complex arrangement. Here we prove +that the Poincar\'e polynomial is the chamber +counting function for a real arrangement. The +complement $M(\A)$ is a disjoint union of chambers +\[M(\A) = \bigcup_{C \in \Cham(\A)} C.\] +The number +of chambers is determined by the Poincar\'e +polynomial as follows. + +\begin{thm}\label{th-realarr} +Let $\A_{\mathbf{R}}$ be a real arrangement. Then +\[ \abs{\Cham(\A_{\mathbf{R}})} = \pi (\A_{\mathbf{R}},1). \] +\end{thm} + +\begin{proof} +We check the properties required in Corollary~\ref{nsep}: +(i) follows from $\pi (\Phi_{ l},t) = 1$, and (ii) is a +consequence of Corollary~\ref{BI}. +\end{proof} + +\begin{figure} +\vspace{5cm} +\caption[]{$Q(\A_{1}) = xyz(x-z)(x+z)(y-z)(y+z)$} +\end{figure} + +\begin{figure} +\vspace{5cm} +\caption[]{$Q(\A_{2})= xyz(x+y+z)(x+y-z)(x-y+z)(x-y-z)$} +\end{figure} + + +\begin{thm} +\label{T_first_the_int} +Let $\phi$ be a protocol for a random pair $\XcY$. +If one of $\st_\phi(x',y)$ and $\st_\phi(x,y')$ is a prefix of the other +and $(x,y)\in\SXY$, then +\[ +\langle \st_j(x',y)\rangle_{j=1}^\infty +=\langle \st_j(x,y)\rangle_{j=1}^\infty +=\langle \st_j(x,y')\rangle_{j=1}^\infty . +\] +\end{thm} +\begin{proof} +We show by induction on $i$ that +\[ +\langle \st_j(x',y)\rangle_{j=1}^i +=\langle \st_j(x,y)\rangle_{j=1}^i +=\langle \st_j(x,y')\rangle_{j=1}^i. +\] +The induction hypothesis holds vacuously for $i=0$. Assume it holds for +$i-1$, in particular +$[\st_j(x',y)]_{j=1}^{i-1}=[\st_j(x,y')]_{j=1}^{i-1}$. Then one of +$[\st_j(x',y)]_{j=i}^{\infty}$ and $[\st_j(x,y')]_{j=i}^{\infty}$ is a +prefix of the other which implies that one of $\st_i(x',y)$ and +$\st_i(x,y')$ is a prefix of the other. If the $i$th message is +transmitted by $P_\X$ then, by the separate-transmissions property and +the induction hypothesis, $\st_i(x,y)=\st_i(x,y')$, hence one of +$\st_i(x,y)$ and $\st_i(x',y)$ is a prefix of the other. By the +implicit-termination property, neither $\st_i(x,y)$ nor $\st_i(x',y)$ +can be a proper prefix of the other, hence they must be the same and +$\st_i(x',y)=\st_i(x,y)=\st_i(x,y')$. If the $i$th message is +transmitted by $\PY$ then, symmetrically, $\st_i(x,y)=\st_i(x',y)$ by +the induction hypothesis and the separate-transmissions property, and, +then, $\st_i(x,y)=\st_i(x,y')$ by the implicit-termination property, +proving the induction step. +\end{proof} + +If $\phi$ is a protocol for $(X,Y)$, and $(x,y)$, $(x',y)$ are distinct +inputs in $\SXY$, then, by the correct-decision property, +$\langle\st_j(x,y)\rangle_{j=1}^\infty\ne\langle +\st_j(x',y)\rangle_{j=1}^\infty$. + +Equation~(\ref{E_SXgYy}) defined $\PY$'s ambiguity set $\SXgYy$ +to be the set of possible $X$ values when $Y=y$. +The last corollary implies that for all $y\in\SY$, +the multiset% +\footnote{A multiset allows multiplicity of elements. +Hence, $\{0,01,01\}$ is prefix free as a set, but not as a multiset.} +of codewords $\{\st_\phi(x,y):x\in\SXgYy\}$ is prefix free. + +\section{One-Way Complexity} +\label{S_Cp1} + +$\Cw1$, the one-way complexity of a random pair $\XcY$, +is the number of bits $P_\X$ must transmit in the worst case +when $\PY$ is not permitted to transmit any feedback messages. +Starting with $\SXY$, the support set of $\XcY$, we define $\G$, +the \textit{characteristic hypergraph} of $\XcY$, and show that +\[ +\Cw1=\lceil\,\log\chi(\G)\rceil\ . +\] + +Let $\XcY$ be a random pair. For each $y$ in $\SY$, the support set of +$Y$, Equation~(\ref{E_SXgYy}) defined $\SXgYy$ to be the set of possible +$x$ values when $Y=y$. The \textit{characteristic hypergraph} $\G$ of +$\XcY$ has $\SX$ as its vertex set and the hyperedge $\SXgYy$ for each +$y\in\SY$. + + +We can now prove a continuity theorem. +\begin{thm}\label{t:conl} +Let $\Omega \subset\mathbf{R}^n$ be an open set, let +$u\in BV(\Omega ;\mathbf{R}^m)$, and let +\begin{equation}\label{quts} +T^u_x=\left\{y\in\mathbf{R}^m: + y=\tilde u(x)+\left\langle \frac{Du}{\abs{Du}}(x),z +\right\rangle \text{ for some }z\in\mathbf{R}^n\right\} +\end{equation} +for every $x\in\Omega \backslash S_u$. Let $f\colon \mathbf{R}^m\to +\mathbf{R}^k$ be a Lipschitz continuous function such that $f(0)=0$, and +let $v=f(u)\colon \Omega \to \mathbf{R}^k$. Then $v\in BV(\Omega +;\mathbf{R}^k)$ and +\begin{equation} +Jv=\eval{(f(u^+)-f(u^-))\otimes \nu_u\cdot\, +\mathcal{H}_{n-1}}_{S_u}. +\end{equation} +In addition, for $\abs{\wt{D}u}$-almost every $x\in\Omega $ the +restriction of the function $f$ to $T^u_x$ is differentiable at $\tilde +u(x)$ and +\begin{equation} +\wt{D}v=\nabla (\eval{f}_{T^u_x})(\tilde u) +\frac{\wt{D}u}{\abs{\wt{D}u}}\cdot\abs{\wt{D}u}.\end{equation} +\end{thm} + +Before proving the theorem, we state without proof three elementary +remarks which will be useful in the sequel. +\begin{rem}\label{r:omb} +Let $\omega\colon \left]0,+\infty\right[\to \left]0,+\infty\right[$ +be a continuous function such that $\omega (t)\to 0$ as $t\to +0$. Then +\[\lim_{h\to 0^+}g(\omega(h))=L\Leftrightarrow\lim_{h\to +0^+}g(h)=L\] +for any function $g\colon \left]0,+\infty\right[\to \mathbf{R}$. +\end{rem} +\begin{rem}\label{r:dif} +Let $g \colon \mathbf{R}^n\to \mathbf{R}$ be a Lipschitz +continuous function and assume that +\[L(z)=\lim_{h\to 0^+}\frac{g(hz)-g(0)}h\] +exists for every $z\in\mathbf{Q}^n$ and that $L$ is a linear function of +$z$. Then $g$ is differentiable at 0. +\end{rem} +\begin{rem}\label{r:dif0} +Let $A \colon \mathbf{R}^n\to \mathbf{R}^m$ be a linear function, and +let $f \colon \mathbf{R}^m\to \mathbf{R}$ be a function. Then the +restriction of $f$ to the range of $A$ is differentiable at 0 if and +only if $f(A)\colon \mathbf{R}^n\to \mathbf{R}$ is differentiable at 0 +and +\[\nabla(\eval{f}_{\IM(A)})(0)A=\nabla (f(A))(0).\] +\end{rem} + +\begin{proof} + We begin by showing that $v\in BV(\Omega;\mathbf{R}^k)$ and +\begin{equation}\label{e:bomb} +\abs{Dv}(B)\le K\abs{Du}(B)\qquad\forall B\in\mathbf{B}(\Omega ), +\end{equation} +where $K>0$ is the Lipschitz constant of $f$. By \eqref{sum-Di} and by +the approximation result quoted in \secref{s:mt}, it is possible to find +a sequence $(u_h)\subset C^1(\Omega ;\mathbf{R}^m)$ converging to $u$ in +$L^1(\Omega ;\mathbf{R}^m)$ and such that +\[\lim_{h\to +\infty}\int_\Omega \abs{\nabla u_h}\,dx=\abs{Du}(\Omega ).\] +The functions $v_h=f(u_h)$ are locally Lipschitz continuous in $\Omega +$, and the definition of differential implies that $\abs{\nabla v_h}\le +K\abs{\nabla u_h}$ almost everywhere in $\Omega $. The lower semicontinuity +of the total variation and \eqref{sum-Di} yield +\begin{equation} +\begin{split} +\abs{Dv}(\Omega )\le\liminf_{h\to +\infty}\abs{Dv_h}(\Omega) & +=\liminf_{h\to +\infty}\int_\Omega \abs{\nabla v_h}\,dx\\ +&\le K\liminf_{h\to +\infty}\int_\Omega +\abs{\nabla u_h}\,dx=K\abs{Du}(\Omega). +\end{split}\end{equation} +Since $f(0)=0$, we have also +\[\int_\Omega \abs{v}\,dx\le K\int_\Omega \abs{u}\,dx;\] +therefore $u\in BV(\Omega ;\mathbf{R}^k)$. Repeating the same argument +for every open set $A\subset\Omega $, we get \eqref{e:bomb} for every +$B\in\mathbf{B}(\Omega)$, because $\abs{Dv}$, $\abs{Du}$ are Radon measures. To +prove \lemref{limbog}, first we observe that +\begin{equation}\label{e:SS} +S_v\subset S_u,\qquad\tilde v(x)=f(\tilde u(x))\qquad \forall x\in\Omega +\backslash S_u.\end{equation} +In fact, for every $\varepsilon >0$ we have +\[\{y\in B_\rho(x): \abs{v(y)-f(\tilde u(x))}>\varepsilon \}\subset \{y\in +B_\rho(x): \abs{u(y)-\tilde u(x)}>\varepsilon /K\},\] +hence +\[\lim_{\rho\to 0^+}\frac{\abs{\{y\in B_\rho(x): \abs{v(y)-f(\tilde u(x))}> +\varepsilon \}}}{\rho^n}=0\] +whenever $x\in\Omega \backslash S_u$. By a similar argument, if $x\in +S_u$ is a point such that there exists a triplet $(u^+,u^-,\nu_u)$ +satisfying \eqref{detK1}, \eqref{detK2}, then +\[ +(v^+(x)-v^-(x))\otimes \nu_v=(f(u^+(x))-f(u^-(x)))\otimes\nu_u\quad +\text{if }x\in S_v +\] +and $f(u^-(x))=f(u^+(x))$ if $x\in S_u\backslash S_v$. Hence, by (1.8) +we get +\begin{equation*}\begin{split} +Jv(B)=\int_{B\cap S_v}(v^+-v^-)\otimes \nu_v\,d\mathcal{H}_{n-1}&= +\int_{B\cap S_v}(f(u^+)-f(u^-))\otimes \nu_u\,d\mathcal{H}_{n-1}\\ +&=\int_{B\cap S_u}(f(u^+)-f(u^-))\otimes \nu_u\,d\mathcal{H}_{n-1} +\end{split}\end{equation*} +and \lemref{limbog} is proved. +\end{proof} + +To prove \eqref{e:SS}, it is not restrictive to assume that $k=1$. +Moreover, to simplify our notation, from now on we shall assume that +$\Omega = \mathbf{R}^n$. The proof of \eqref{e:SS} is divided into two +steps. In the first step we prove the statement in the one-dimensional +case $(n=1)$, using \thmref{th-weak-ske-owf}. In the second step we +achieve the general result using \thmref{t:conl}. + +\subsection*{Step 1} +Assume that $n=1$. Since $S_u$ is at most countable, \eqref{sum-bij} +yields that $\abs{\wt{D}v}(S_u\backslash S_v)=0$, so that +\eqref{e:st} and \eqref{e:barwq} imply that $Dv=\wt{D}v+Jv$ is +the Radon-Nikod\'ym decomposition of $Dv$ in absolutely continuous and +singular part with respect to $\abs{\wt{D} u}$. By +\thmref{th-weak-ske-owf}, we have +\begin{equation*} +\frac{\wt{D}v}{\abs{\wt{D}u}}(t)=\lim_{s\to t^+} +\frac{Dv(\interval{\left[t,s\right[})} +{\abs{\wt{D}u}(\interval{\left[t,s\right[})},\qquad +\frac{\wt{D}u}{\abs{\wt{D}u}}(t)=\lim_{s\to t^+} +\frac{Du(\interval{\left[t,s\right[})} +{\abs{\wt{D}u}(\interval{\left[t,s\right[})} +\end{equation*} +$\abs{\wt{D}u}$-almost everywhere in $\mathbf{R}$. It is well known +(see, for instance, \cite[2.5.16]{ste:sint}) that every one-dimensional +function of bounded variation $w$ has a unique left continuous +representative, i.e., a function $\hat w$ such that $\hat w=w$ almost +everywhere and $\lim_{s\to t^-}\hat w(s)=\hat w(t)$ for every $t\in +\mathbf{R}$. These conditions imply +\begin{equation} +\hat u(t)=Du(\interval{\left]-\infty,t\right[}), +\qquad \hat v(t)=Dv(\interval{\left]-\infty,t\right[})\qquad +\forall t\in\mathbf{R} +\end{equation} +and +\begin{equation}\label{alimo} +\hat v(t)=f(\hat u(t))\qquad\forall t\in\mathbf{R}.\end{equation} +Let $t\in\mathbf{R}$ be such that +$\abs{\wt{D}u}(\interval{\left[t,s\right[})>0$ for every $s>t$ and +assume that the limits in \eqref{joe} exist. By \eqref{j:mark} and +\eqref{far-d} we get +\begin{equation*}\begin{split} +\frac{\hat v(s)-\hat +v(t)}{\abs{\wt{D}u}(\interval{\left[t,s\right[})}&=\frac {f(\hat +u(s))-f(\hat u(t))}{\abs{\wt{D}u}(\interval{\left[t,s\right[})}\\ +&=\frac{f(\hat u(s))-f(\hat +u(t)+\dfrac{\wt{D}u}{\abs{\wt{D}u}}(t)\abs{\wt{D}u +}(\interval{\left[t,s\right[}))}% +{\abs{\wt{D}u}(\interval{\left[t,s\right[})}\\ +&+\frac +{f(\hat u(t)+\dfrac{\wt{D}u}{\abs{\wt{D}u}}(t)\abs{\wt{D} +u}(\interval{\left[t,s\right[}))-f(\hat +u(t))}{\abs{\wt{D}u}(\interval{\left[t,s\right[})} +\end{split}\end{equation*} +for every $s>t$. Using the Lipschitz condition on $f$ we find +{\setlength{\multlinegap}{0pt} +\begin{multline*} +\left\lvert\frac{\hat v(s)-\hat +v(t)}{\abs{\wt{D}u}(\interval{\left[t,s\right[})} -\frac{f(\hat +u(t)+\dfrac{\wt{D}u}{\abs{\wt{D}u}}(t) +\abs{\wt{D}u}(\interval{\left[t,s\right[}))-f(\hat +u(t))}{\abs{\wt{D}u}(\interval{\left[t,s\right[})}\right\rvert\\ +\le K\left\lvert +\frac{\hat u(s)-\hat u(t)} + {\abs{\wt{D}u}(\interval{\left[t,s\right[})} +-\frac{\wt{D}u}{\abs{ +\wt{D}u}}(t)\right\rvert.\end{multline*} +}% end of group with \multlinegap=0pt +By \eqref{e:bomb}, the function $s\to +\abs{\wt{D}u}(\interval{\left[t,s\right[})$ is continuous and +converges to 0 as $s\downarrow t$. Therefore Remark~\ref{r:omb} and the +previous inequality imply +\[\frac{\wt{D}v}{\abs{\wt{D}u}}(t)=\lim_{h\to 0^+} +\frac{f(\hat u(t)+h\dfrac{\wt{D}u}{\abs{\wt{D}u}} +(t))-f(\hat u(t))}h\quad\abs{\wt{D}u}\text{-a.e. in }\mathbf{R}.\] +By \eqref{joe}, $\hat u(x)=\tilde u(x)$ for every +$x\in\mathbf{R}\backslash S_u$; moreover, applying the same argument to +the functions $u'(t)=u(-t)$, $v'(t)=f(u'(t))=v(-t)$, we get +\[\frac{\wt{D}v}{\abs{\wt{D}u}}(t)=\lim_{h\to 0} +\frac{f(\tilde u(t) ++h\dfrac{\wt{D}u}{\abs{\wt{D}u}}(t))-f(\tilde u(t))}{h} +\qquad\abs{\wt{D}u}\text{-a.e. in }\mathbf{R}\] +and our statement is proved. + +\subsection*{Step 2} + +Let us consider now the general case $n>1$. Let $\nu\in \mathbf{R}^n$ be +such that $\abs{\nu}=1$, and let $\pi_\nu=\{y\in\mathbf{R}^n: \langle +y,\nu\rangle =0\}$. In the following, we shall identify $\mathbf{R}^n$ +with $\pi_\nu\times\mathbf{R}$, and we shall denote by $y$ the variable +ranging in $\pi_\nu$ and by $t$ the variable ranging in $\mathbf{R}$. By +the just proven one-dimensional result, and by \thmref{thm-main}, we get +\[\lim_{h\to 0}\frac{f(\tilde u(y+t\nu)+h\dfrac{\wt{D}u_y}{\abs{ +\wt{D}u_y}}(t))-f(\tilde u(y+t\nu))}h=\frac{\wt{D}v_y}{\abs{ +\wt{D}u_y}}(t)\qquad\abs{\wt{D}u_y}\text{-a.e. in }\mathbf{R}\] +for $\mathcal{H}_{n-1}$-almost every $y\in \pi_\nu$. We claim that +\begin{equation} +\frac{\langle \wt{D}u,\nu\rangle }{\abs{\langle \wt{D}u,\nu\rangle +}}(y+t\nu)=\frac{\wt{D}u_y} +{\abs{\wt{D}u_y}}(t)\qquad\abs{\wt{D}u_y}\text{-a.e. in }\mathbf{R} +\end{equation} +for $\mathcal{H}_{n-1}$-almost every $y\in\pi_\nu$. In fact, by +\eqref{sum-ali} and \eqref{delta-l} we get +\begin{multline*} +\int_{\pi_\nu}\frac{\wt{D}u_y}{\abs{\wt{D}u_y}}\cdot\abs{\wt{D}u_y +}\,d\mathcal{H}_{n-1}(y)=\int_{\pi_\nu}\wt{D}u_y\,d\mathcal{H}_{n-1}(y)\\ +=\langle \wt{D}u,\nu\rangle =\frac +{\langle \wt{D}u,\nu\rangle }{\abs{\langle \wt{D}u,\nu\rangle}}\cdot +\abs{\langle \wt{D}u,\nu\rangle }=\int_{\pi_\nu}\frac{ +\langle \wt{D}u,\nu\rangle }{\abs{\langle \wt{D}u,\nu\rangle }} +(y+\cdot \nu)\cdot\abs{\wt{D}u_y}\,d\mathcal{H}_{n-1}(y) +\end{multline*} +and \eqref{far-d} follows from \eqref{sum-Di}. By the same argument it +is possible to prove that +\begin{equation} +\frac{\langle \wt{D}v,\nu\rangle }{\abs{\langle \wt{D}u,\nu\rangle +}}(y+t\nu)=\frac{\wt{D}v_y}{\abs{\wt{D}u_y}}(t)\qquad\abs{ +\wt{D}u_y}\text{-a.e. in }\mathbf{R}\end{equation} +for $\mathcal{H}_{n-1}$-almost every $y\in \pi_\nu$. By \eqref{far-d} +and \eqref{E_SXgYy} we get +\[ +\lim_{h\to 0}\frac{f(\tilde u(y+t\nu)+h\dfrac{\langle \wt{D} +u,\nu\rangle }{\abs{\langle \wt{D}u,\nu\rangle }}(y+t\nu))-f(\tilde +u(y+t\nu))}{h} +=\frac{\langle \wt{D}v,\nu\rangle }{\abs{\langle +\wt{D}u,\nu\rangle }}(y+t\nu)\] +for $\mathcal{H}_{n-1}$-almost every $y\in\pi_\nu$, and using again +\eqref{detK1}, \eqref{detK2} we get +\[ +\lim_{h\to 0}\frac{f(\tilde u(x)+h\dfrac{\langle +\wt{D}u,\nu\rangle }{\abs{\langle \wt{D}u,\nu\rangle }}(x))-f(\tilde +u(x))}{h}=\frac{\langle \wt{D}v,\nu\rangle }{\abs{\langle \wt{D}u,\nu +\rangle }}(x) +\] +$\abs{\langle \wt{D}u,\nu\rangle}$-a.e. in $\mathbf{R}^n$. + +Since the function $\abs{\langle \wt{D}u,\nu\rangle }/\abs{\wt{D}u}$ +is strictly positive $\abs{\langle \wt{D}u,\nu\rangle }$-almost everywhere, +we obtain also +\begin{multline*} +\lim_{h\to 0}\frac{f(\tilde u(x)+h\dfrac{\abs{\langle +\wt{D}u,\nu\rangle }}{\abs{\wt{D}u}}(x)\dfrac{\langle \wt{D} +u,\nu\rangle }{\abs{\langle \wt{D}u,\nu\rangle }}(x))-f(\tilde u(x))}{h}\\ +=\frac{\abs{\langle \wt{D}u,\nu\rangle }}{\abs{\wt{D}u}}(x)\frac +{\langle \wt{D}v,\nu\rangle }{\abs{\langle +\wt{D}u,\nu\rangle }}(x) +\end{multline*} +$\abs{\langle \wt{D}u,\nu\rangle }$-almost everywhere in $\mathbf{R}^n$. + +Finally, since +\begin{align*} +&\frac{\abs{\langle \wt{D}u,\nu\rangle }}{\abs{\wt{D}u}} +\frac{\langle \wt{D}u,\nu\rangle }{\abs{\langle \wt{D}u,\nu\rangle}} +=\frac{\langle \wt{D}u,\nu\rangle }{\abs{\wt{D}u}} +=\left\langle \frac{\wt{D}u}{\abs{\wt{D}u}},\nu\right\rangle + \qquad\abs{\wt{D}u}\text{-a.e. in }\mathbf{R}^n\\ +&\frac{\abs{\langle \wt{D}u,\nu\rangle }}{\abs{\wt{D}u}} +\frac{\langle \wt{D}v,\nu\rangle }{\abs{\langle \wt{D}u,\nu\rangle}} +=\frac{\langle \wt{D}v,\nu\rangle }{\abs{\wt{D}u}} +=\left\langle \frac{\wt{D}v}{\abs{\wt{D}u}},\nu\right\rangle + \qquad\abs{\wt{D}u}\text{-a.e. in }\mathbf{R}^n +\end{align*} +and since both sides of \eqref{alimo} +are zero $\abs{\wt{D}u}$-almost everywhere +on $\abs{\langle \wt{D}u,\nu\rangle }$-negligible sets, we conclude that +\[ +\lim_{h\to 0}\frac{f\left( +\tilde u(x)+h\left\langle \dfrac{\wt{D} +u}{\abs{\wt{D}u}}(x),\nu\right\rangle \right)-f(\tilde u(x))}h +=\left\langle \frac{\wt{D}v}{\abs{\wt{D}u}}(x),\nu\right\rangle, +\] +$\abs{\wt{D}u}$-a.e. in $\mathbf{R}^n$. +Since $\nu$ is arbitrary, by Remarks \ref{r:dif} and~\ref{r:dif0} +the restriction of $f$ to +the affine space $T^u_x$ is differentiable at $\tilde u(x)$ for $\abs{\wt{D} +u}$-almost every $x\in \mathbf{R}^n$ and \eqref{quts} holds.\qed + +It follows from \eqref{sum-Di}, \eqref{detK1}, and \eqref{detK2} that +\begin{equation}\label{Dt} +D(t_1,\dots,t_n)=\sum_{I\in\mathbf{n}}(-1)^{\abs{I}-1}\abs{I} +\prod_{i\in I}t_i\prod_{j\in I}(D_j+\lambda_jt_j)\det\mathbf{A}^{(\lambda)} +(\overline I|\overline I). +\end{equation} +Let $t_i=\hat x_i$, $i=1,\dots,n$. Lemma 1 leads to +\begin{equation}\label{Dx} +D(\hat x_1,\dots,\hat x_n)=\prod_{i\in\mathbf{n}}\hat x_i +\sum_{I\in\mathbf{n}}(-1)^{\abs{I}-1}\abs{I}\per \mathbf{A} +^{(\lambda)}(I|I)\det\mathbf{A}^{(\lambda)}(\overline I|\overline I). +\end{equation} +By \eqref{H-cycles}, \eqref{sum-Di}, and \eqref{Dx}, +we have the following result: +\begin{thm}\label{thm-H-param} +\begin{equation}\label{H-param} +H_c=\frac{1}{2n}\sum^n_{l =1}l (-1)^{l -1}A_{l} +^{(\lambda)}, +\end{equation} +where +\begin{equation}\label{A-l-lambda} +A^{(\lambda)}_l =\sum_{I_l \subseteq\mathbf{n}}\per \mathbf{A} +^{(\lambda)}(I_l |I_l )\det\mathbf{A}^{(\lambda)} +(\overline I_{l}|\overline I_l ),\abs{I_{l}}=l . +\end{equation} +\end{thm} + +It is worth noting that $A_l ^{(\lambda)}$ of \eqref{A-l-lambda} is +similar to the coefficients $b_l $ of the characteristic polynomial of +\eqref{bl-sum}. It is well known in graph theory that the coefficients +$b_l $ can be expressed as a sum over certain subgraphs. It is +interesting to see whether $A_l $, $\lambda=0$, structural properties +of a graph. + +We may call \eqref{H-param} a parametric representation of $H_c$. In +computation, the parameter $\lambda_i$ plays very important roles. The +choice of the parameter usually depends on the properties of the given +graph. For a complete graph $K_n$, let $\lambda_i=1$, $i=1,\dots,n$. +It follows from \eqref{A-l-lambda} that +\begin{equation}\label{compl-gr} +A^{(1)}_l =\begin{cases} n!,&\text{if }l =1\\ +0,&\text{otherwise}.\end{cases} +\end{equation} +By \eqref{H-param} +\begin{equation} +H_c=\frac 12(n-1)!. +\end{equation} +For a complete bipartite graph $K_{n_1n_2}$, let $\lambda_i=0$, $i=1,\dots,n$. +By \eqref{A-l-lambda}, +\begin{equation} +A_l = +\begin{cases} -n_1!n_2!\delta_{n_1n_2},&\text{if }l =2\\ +0,&\text{otherwise }.\end{cases} +\label{compl-bip-gr} +\end{equation} +Theorem ~\ref{thm-H-param} +leads to +\begin{equation} +H_c=\frac1{n_1+n_2}n_1!n_2!\delta_{n_1n_2}. +\end{equation} + +Now, we consider an asymmetrical approach. Theorem \ref{thm-main} leads to +\begin{multline} +\det\mathbf{K}(t=1,t_1,\dots,t_n;l |l )\\ +=\sum_{I\subseteq\mathbf{n}-\{l \}} +(-1)^{\abs{I}}\prod_{i\in I}t_i\prod_{j\in I} +(D_j+\lambda_jt_j)\det\mathbf{A}^{(\lambda)} +(\overline I\cup\{l \}|\overline I\cup\{l \}). +\end{multline} + +By \eqref{H-cycles} and \eqref{sum-ali} we have the following asymmetrical +result: +\begin{thm}\label{thm-asym} +\begin{equation} +H_c=\frac12\sum_{I\subseteq\mathbf{n}-\{l \}} +(-1)^{\abs{I}}\per\mathbf{A}^{(\lambda)}(I|I)\det +\mathbf{A}^{(\lambda)} +(\overline I\cup\{l \}|\overline I\cup\{l \}) +\end{equation} +which reduces to Goulden--Jackson's formula when $\lambda_i=0,i=1,\dots,n$ +\cite{mami:matrixth}. +\end{thm} + +\section{Various font features of the \pkg{amsmath} package} +\label{s:font} +\subsection{Bold versions of special symbols} + +In the \pkg{amsmath} package \cn{boldsymbol} is used for getting +individual bold math symbols and bold Greek letters---everything in +math except for letters of the Latin alphabet, +where you'd use \cn{mathbf}. For example, +\begin{verbatim} +A_\infty + \pi A_0 \sim +\mathbf{A}_{\boldsymbol{\infty}} \boldsymbol{+} +\boldsymbol{\pi} \mathbf{A}_{\boldsymbol{0}} +\end{verbatim} +looks like this: +\[A_\infty + \pi A_0 \sim \mathbf{A}_{\boldsymbol{\infty}} +\boldsymbol{+} \boldsymbol{\pi} \mathbf{A}_{\boldsymbol{0}}\] + +\subsection{``Poor man's bold''} +If a bold version of a particular symbol doesn't exist in the +available fonts, +then \cn{boldsymbol} can't be used to make that symbol bold. +At the present time, this means that +\cn{boldsymbol} can't be used with symbols from +the \fn{msam} and \fn{msbm} fonts, among others. +In some cases, poor man's bold (\cn{pmb}) can be used instead +of \cn{boldsymbol}: +% Can't show example from msam or msbm because this document is +% supposed to be TeXable even if the user doesn't have +% AMSFonts. MJD 5-JUL-1990 +\[\frac{\partial x}{\partial y} +\pmb{\bigg\vert} +\frac{\partial y}{\partial z}\] +\begin{verbatim} +\[\frac{\partial x}{\partial y} +\pmb{\bigg\vert} +\frac{\partial y}{\partial z}\] +\end{verbatim} +So-called ``large operator'' symbols such as $\sum$ and $\prod$ +require an additional command, \cn{mathop}, +to produce proper spacing and limits when \cn{pmb} is used. +For further details see \textit{The \TeX book}. +\[\sum_{\substack{i<B\\\text{$i$ odd}}} +\prod_\kappa \kappa F(r_i)\qquad +\mathop{\pmb{\sum}}_{\substack{i<B\\\text{$i$ odd}}} +\mathop{\pmb{\prod}}_\kappa \kappa(r_i) +\] +\begin{verbatim} +\[\sum_{\substack{i<B\\\text{$i$ odd}}} +\prod_\kappa \kappa F(r_i)\qquad +\mathop{\pmb{\sum}}_{\substack{i<B\\\text{$i$ odd}}} +\mathop{\pmb{\prod}}_\kappa \kappa(r_i) +\] +\end{verbatim} + +\section{Compound symbols and other features} +\label{s:comp} +\subsection{Multiple integral signs} + +\cn{iint}, \cn{iiint}, and \cn{iiiint} give multiple integral signs +with the spacing between them nicely adjusted, in both text and +display style. \cn{idotsint} gives two integral signs with dots +between them. +\begin{gather} +\iint\limits_A f(x,y)\,dx\,dy\qquad\iiint\limits_A +f(x,y,z)\,dx\,dy\,dz\\ +\iiiint\limits_A +f(w,x,y,z)\,dw\,dx\,dy\,dz\qquad\idotsint\limits_A f(x_1,\dots,x_k) +\end{gather} + +\subsection{Over and under arrows} + +Some extra over and under arrow operations are provided in +the \pkg{amsmath} package. (Basic \LaTeX\ provides +\cn{overrightarrow} and \cn{overleftarrow}). +\begin{align*} +\overrightarrow{\psi_\delta(t) E_t h}& +=\underrightarrow{\psi_\delta(t) E_t h}\\ +\overleftarrow{\psi_\delta(t) E_t h}& +=\underleftarrow{\psi_\delta(t) E_t h}\\ +\overleftrightarrow{\psi_\delta(t) E_t h}& +=\underleftrightarrow{\psi_\delta(t) E_t h} +\end{align*} +\begin{verbatim} +\begin{align*} +\overrightarrow{\psi_\delta(t) E_t h}& +=\underrightarrow{\psi_\delta(t) E_t h}\\ +\overleftarrow{\psi_\delta(t) E_t h}& +=\underleftarrow{\psi_\delta(t) E_t h}\\ +\overleftrightarrow{\psi_\delta(t) E_t h}& +=\underleftrightarrow{\psi_\delta(t) E_t h} +\end{align*} +\end{verbatim} +These all scale properly in subscript sizes: +\[\int_{\overrightarrow{AB}} ax\,dx\] +\begin{verbatim} +\[\int_{\overrightarrow{AB}} ax\,dx\] +\end{verbatim} + +\subsection{Dots} + +Normally you need only type \cn{dots} for ellipsis dots in a +math formula. The main exception is when the dots +fall at the end of the formula; then you need to +specify one of \cn{dotsc} (series dots, after a comma), +\cn{dotsb} (binary dots, for binary relations or operators), +\cn{dotsm} (multiplication dots), or \cn{dotsi} (dots after +an integral). For example, the input +\begin{verbatim} +Then we have the series $A_1,A_2,\dotsc$, +the regional sum $A_1+A_2+\dotsb$, +the orthogonal product $A_1A_2\dotsm$, +and the infinite integral +\[\int_{A_1}\int_{A_2}\dotsi\]. +\end{verbatim} +produces +\begin{quotation} +Then we have the series $A_1,A_2,\dotsc$, +the regional sum $A_1+A_2+\dotsb$, +the orthogonal product $A_1A_2\dotsm$, +and the infinite integral +\[\int_{A_1}\int_{A_2}\dotsi\] +\end{quotation} + +\subsection{Accents in math} + +Double accents: +\[\Hat{\Hat{H}}\quad\Check{\Check{C}}\quad +\Tilde{\Tilde{T}}\quad\Acute{\Acute{A}}\quad +\Grave{\Grave{G}}\quad\Dot{\Dot{D}}\quad +\Ddot{\Ddot{D}}\quad\Breve{\Breve{B}}\quad +\Bar{\Bar{B}}\quad\Vec{\Vec{V}}\] +\begin{verbatim} +\[\Hat{\Hat{H}}\quad\Check{\Check{C}}\quad +\Tilde{\Tilde{T}}\quad\Acute{\Acute{A}}\quad +\Grave{\Grave{G}}\quad\Dot{\Dot{D}}\quad +\Ddot{\Ddot{D}}\quad\Breve{\Breve{B}}\quad +\Bar{\Bar{B}}\quad\Vec{\Vec{V}}\] +\end{verbatim} +This double accent operation is complicated +and tends to slow down the processing of a \LaTeX\ file. + + +\subsection{Dot accents} +\cn{dddot} and \cn{ddddot} are available to +produce triple and quadruple dot accents +in addition to the \cn{dot} and \cn{ddot} accents already available +in \LaTeX: +\[\dddot{Q}\qquad\ddddot{R}\] +\begin{verbatim} +\[\dddot{Q}\qquad\ddddot{R}\] +\end{verbatim} + +\subsection{Roots} + +In the \pkg{amsmath} package \cn{leftroot} and \cn{uproot} allow you to adjust +the position of the root index of a radical: +\begin{verbatim} +\sqrt[\leftroot{-2}\uproot{2}\beta]{k} +\end{verbatim} +gives good positioning of the $\beta$: +\[\sqrt[\leftroot{-2}\uproot{2}\beta]{k}\] + +\subsection{Boxed formulas} The command \cn{boxed} puts a box around its +argument, like \cn{fbox} except that the contents are in math mode: +\begin{verbatim} +\boxed{W_t-F\subseteq V(P_i)\subseteq W_t} +\end{verbatim} +\[\boxed{W_t-F\subseteq V(P_i)\subseteq W_t}.\] + +\subsection{Extensible arrows} +\cn{xleftarrow} and \cn{xrightarrow} produce +arrows that extend automatically to accommodate unusually wide +subscripts or superscripts. The text of the subscript or superscript +are given as an optional resp.\@ mandatory argument: +Example: +\[0 \xleftarrow[\zeta]{\alpha} F\times\triangle[n-1] + \xrightarrow{\partial_0\alpha(b)} E^{\partial_0b}\] +\begin{verbatim} +\[0 \xleftarrow[\zeta]{\alpha} F\times\triangle[n-1] + \xrightarrow{\partial_0\alpha(b)} E^{\partial_0b}\] +\end{verbatim} + +\subsection{\cn{overset}, \cn{underset}, and \cn{sideset}} +Examples: +\[\overset{*}{X}\qquad\underset{*}{X}\qquad +\overset{a}{\underset{b}{X}}\] +\begin{verbatim} +\[\overset{*}{X}\qquad\underset{*}{X}\qquad +\overset{a}{\underset{b}{X}}\] +\end{verbatim} + +The command \cn{sideset} is for a rather special +purpose: putting symbols at the subscript and superscript +corners of a large operator symbol such as $\sum$ or $\prod$, +without affecting the placement of limits. +Examples: +\[\sideset{_*^*}{_*^*}\prod_k\qquad +\sideset{}{'}\sum_{0\le i\le m} E_i\beta x +\] +\begin{verbatim} +\[\sideset{_*^*}{_*^*}\prod_k\qquad +\sideset{}{'}\sum_{0\le i\le m} E_i\beta x +\] +\end{verbatim} + +\subsection{The \cn{text} command} +The main use of the command \cn{text} is for words or phrases in a +display: +\[\mathbf{y}=\mathbf{y}'\quad\text{if and only if}\quad +y'_k=\delta_k y_{\tau(k)}\] +\begin{verbatim} +\[\mathbf{y}=\mathbf{y}'\quad\text{if and only if}\quad +y'_k=\delta_k y_{\tau(k)}\] +\end{verbatim} + +\subsection{Operator names} +The more common math functions such as $\log$, $\sin$, and $\lim$ +have predefined control sequences: \verb=\log=, \verb=\sin=, +\verb=\lim=. +The \pkg{amsmath} package provides \cn{DeclareMathOperator} and +\cn{DeclareMathOperator*} +for producing new function names that will have the +same typographical treatment. +Examples: +\[\norm{f}_\infty= +\esssup_{x\in R^n}\abs{f(x)}\] +\begin{verbatim} +\[\norm{f}_\infty= +\esssup_{x\in R^n}\abs{f(x)}\] +\end{verbatim} +\[\meas_1\{u\in R_+^1\colon f^*(u)>\alpha\} +=\meas_n\{x\in R^n\colon \abs{f(x)}\geq\alpha\} +\quad \forall\alpha>0.\] +\begin{verbatim} +\[\meas_1\{u\in R_+^1\colon f^*(u)>\alpha\} +=\meas_n\{x\in R^n\colon \abs{f(x)}\geq\alpha\} +\quad \forall\alpha>0.\] +\end{verbatim} +\cn{esssup} and \cn{meas} would be defined in the document preamble as +\begin{verbatim} +\DeclareMathOperator*{\esssup}{ess\,sup} +\DeclareMathOperator{\meas}{meas} +\end{verbatim} + +The following special operator names are predefined in the \pkg{amsmath} +package: \cn{varlimsup}, \cn{varliminf}, \cn{varinjlim}, and +\cn{varprojlim}. Here's what they look like in use: +\begin{align} +&\varlimsup_{n\rightarrow\infty} + \mathcal{Q}(u_n,u_n-u^{\#})\le0\\ +&\varliminf_{n\rightarrow\infty} + \left\lvert a_{n+1}\right\rvert/\left\lvert a_n\right\rvert=0\\ +&\varinjlim (m_i^\lambda\cdot)^*\le0\\ +&\varprojlim_{p\in S(A)}A_p\le0 +\end{align} +\begin{verbatim} +\begin{align} +&\varlimsup_{n\rightarrow\infty} + \mathcal{Q}(u_n,u_n-u^{\#})\le0\\ +&\varliminf_{n\rightarrow\infty} + \left\lvert a_{n+1}\right\rvert/\left\lvert a_n\right\rvert=0\\ +&\varinjlim (m_i^\lambda\cdot)^*\le0\\ +&\varprojlim_{p\in S(A)}A_p\le0 +\end{align} +\end{verbatim} + +\subsection{\cn{mod} and its relatives} +The commands \cn{mod} and \cn{pod} are variants of +\cn{pmod} preferred by some authors; \cn{mod} omits the parentheses, +whereas \cn{pod} omits the `mod' and retains the parentheses. +Examples: +\begin{align} +x&\equiv y+1\pmod{m^2}\\ +x&\equiv y+1\mod{m^2}\\ +x&\equiv y+1\pod{m^2} +\end{align} +\begin{verbatim} +\begin{align} +x&\equiv y+1\pmod{m^2}\\ +x&\equiv y+1\mod{m^2}\\ +x&\equiv y+1\pod{m^2} +\end{align} +\end{verbatim} + +\subsection{Fractions and related constructions} +\label{fracs} + +The usual notation for binomials is similar to the fraction concept, +so it has a similar command \cn{binom} with two arguments. Example: +\begin{equation} +\begin{split} +\sum_{\gamma\in\Gamma_C} I_\gamma& +=2^k-\binom{k}{1}2^{k-1}+\binom{k}{2}2^{k-2}\\ +&\quad+\dots+(-1)^l\binom{k}{l}2^{k-l} ++\dots+(-1)^k\\ +&=(2-1)^k=1 +\end{split} +\end{equation} +\begin{verbatim} +\begin{equation} +\begin{split} +[\sum_{\gamma\in\Gamma_C} I_\gamma& +=2^k-\binom{k}{1}2^{k-1}+\binom{k}{2}2^{k-2}\\ +&\quad+\dots+(-1)^l\binom{k}{l}2^{k-l} ++\dots+(-1)^k\\ +&=(2-1)^k=1 +\end{split} +\end{equation} +\end{verbatim} +There are also abbreviations +\begin{verbatim} +\dfrac \dbinom +\tfrac \tbinom +\end{verbatim} +for the commonly needed constructions +\begin{verbatim} +{\displaystyle\frac ... } {\displaystyle\binom ... } +{\textstyle\frac ... } {\textstyle\binom ... } +\end{verbatim} + +The generalized fraction command \cn{genfrac} provides full access to +the six \TeX{} fraction primitives: +\begin{align} +\text{\cn{over}: }&\genfrac{}{}{}{}{n+1}{2}& +\text{\cn{overwithdelims}: }& + \genfrac{\langle}{\rangle}{}{}{n+1}{2}\\ +\text{\cn{atop}: }&\genfrac{}{}{0pt}{}{n+1}{2}& +\text{\cn{atopwithdelims}: }& + \genfrac{(}{)}{0pt}{}{n+1}{2}\\ +\text{\cn{above}: }&\genfrac{}{}{1pt}{}{n+1}{2}& +\text{\cn{abovewithdelims}: }& + \genfrac{[}{]}{1pt}{}{n+1}{2} +\end{align} +\begin{verbatim} +\text{\cn{over}: }&\genfrac{}{}{}{}{n+1}{2}& +\text{\cn{overwithdelims}: }& + \genfrac{\langle}{\rangle}{}{}{n+1}{2}\\ +\text{\cn{atop}: }&\genfrac{}{}{0pt}{}{n+1}{2}& +\text{\cn{atopwithdelims}: }& + \genfrac{(}{)}{0pt}{}{n+1}{2}\\ +\text{\cn{above}: }&\genfrac{}{}{1pt}{}{n+1}{2}& +\text{\cn{abovewithdelims}: }& + \genfrac{[}{]}{1pt}{}{n+1}{2} +\end{verbatim} + +\subsection{Continued fractions} +The continued fraction +\begin{equation} +\cfrac{1}{\sqrt{2}+ + \cfrac{1}{\sqrt{2}+ + \cfrac{1}{\sqrt{2}+ + \cfrac{1}{\sqrt{2}+ + \cfrac{1}{\sqrt{2}+\dotsb +}}}}} +\end{equation} +can be obtained by typing +\begin{verbatim} +\cfrac{1}{\sqrt{2}+ + \cfrac{1}{\sqrt{2}+ + \cfrac{1}{\sqrt{2}+ + \cfrac{1}{\sqrt{2}+ + \cfrac{1}{\sqrt{2}+\dotsb +}}}}} +\end{verbatim} +Left or right placement of any of the numerators is accomplished by using +\cn{cfrac[l]} or \cn{cfrac[r]} instead of \cn{cfrac}. + +\subsection{Smash} + +In \pkg{amsmath} there are optional arguments \verb"t" and \verb"b" for +the plain \TeX\ command \cn{smash}, because sometimes it is advantageous +to be able to `smash' only the top or only the bottom of something while +retaining the natural depth or height. In the formula +$X_j=(1/\sqrt{\smash[b]{\lambda_j}})X_j'$ \cn{smash}\verb=[b]= has been +used to limit the size of the radical symbol. +\begin{verbatim} +$X_j=(1/\sqrt{\smash[b]{\lambda_j}})X_j'$ +\end{verbatim} +Without the use of \cn{smash}\verb=[b]= the formula would have appeared +thus: $X_j=(1/\sqrt{\lambda_j})X_j'$, with the radical extending to +encompass the depth of the subscript $j$. + +\subsection{The `cases' environment} +`Cases' constructions like the following can be produced using +the \env{cases} environment. +\begin{equation} +P_{r-j}= + \begin{cases} + 0& \text{if $r-j$ is odd},\\ + r!\,(-1)^{(r-j)/2}& \text{if $r-j$ is even}. + \end{cases} +\end{equation} +\begin{verbatim} +\begin{equation} P_{r-j}= + \begin{cases} + 0& \text{if $r-j$ is odd},\\ + r!\,(-1)^{(r-j)/2}& \text{if $r-j$ is even}. + \end{cases} +\end{equation} +\end{verbatim} +Notice the use of \cn{text} and the embedded math. + +\subsection{Matrix} + +Here are samples of the matrix environments, +\cn{matrix}, \cn{pmatrix}, \cn{bmatrix}, \cn{Bmatrix}, \cn{vmatrix} +and \cn{Vmatrix}: +\begin{equation} +\begin{matrix} +\vartheta& \varrho\\\varphi& \varpi +\end{matrix}\quad +\begin{pmatrix} +\vartheta& \varrho\\\varphi& \varpi +\end{pmatrix}\quad +\begin{bmatrix} +\vartheta& \varrho\\\varphi& \varpi +\end{bmatrix}\quad +\begin{Bmatrix} +\vartheta& \varrho\\\varphi& \varpi +\end{Bmatrix}\quad +\begin{vmatrix} +\vartheta& \varrho\\\varphi& \varpi +\end{vmatrix}\quad +\begin{Vmatrix} +\vartheta& \varrho\\\varphi& \varpi +\end{Vmatrix} +\end{equation} +% +\begin{verbatim} +\begin{matrix} +\vartheta& \varrho\\\varphi& \varpi +\end{matrix}\quad +\begin{pmatrix} +\vartheta& \varrho\\\varphi& \varpi +\end{pmatrix}\quad +\begin{bmatrix} +\vartheta& \varrho\\\varphi& \varpi +\end{bmatrix}\quad +\begin{Bmatrix} +\vartheta& \varrho\\\varphi& \varpi +\end{Bmatrix}\quad +\begin{vmatrix} +\vartheta& \varrho\\\varphi& \varpi +\end{vmatrix}\quad +\begin{Vmatrix} +\vartheta& \varrho\\\varphi& \varpi +\end{Vmatrix} +\end{verbatim} + +To produce a small matrix suitable for use in text, use the +\env{smallmatrix} environment. +\begin{verbatim} +\begin{math} + \bigl( \begin{smallmatrix} + a&b\\ c&d + \end{smallmatrix} \bigr) +\end{math} +\end{verbatim} +To show +the effect of the matrix on the surrounding lines of +a paragraph, we put it here: \begin{math} + \bigl( \begin{smallmatrix} + a&b\\ c&d + \end{smallmatrix} \bigr) +\end{math} +and follow it with enough text to ensure that there will +be at least one full line below the matrix. + +\cn{hdotsfor}\verb"{"\textit{number}\verb"}" produces a row of dots in a matrix +spanning the given number of columns: +\[W(\Phi)= \begin{Vmatrix} +\dfrac\varphi{(\varphi_1,\varepsilon_1)}&0&\dots&0\\ +\dfrac{\varphi k_{n2}}{(\varphi_2,\varepsilon_1)}& +\dfrac\varphi{(\varphi_2,\varepsilon_2)}&\dots&0\\ +\hdotsfor{5}\\ +\dfrac{\varphi k_{n1}}{(\varphi_n,\varepsilon_1)}& +\dfrac{\varphi k_{n2}}{(\varphi_n,\varepsilon_2)}&\dots& +\dfrac{\varphi k_{n\,n-1}}{(\varphi_n,\varepsilon_{n-1})}& +\dfrac{\varphi}{(\varphi_n,\varepsilon_n)} +\end{Vmatrix}\] +\begin{verbatim} +\[W(\Phi)= \begin{Vmatrix} +\dfrac\varphi{(\varphi_1,\varepsilon_1)}&0&\dots&0\\ +\dfrac{\varphi k_{n2}}{(\varphi_2,\varepsilon_1)}& +\dfrac\varphi{(\varphi_2,\varepsilon_2)}&\dots&0\\ +\hdotsfor{5}\\ +\dfrac{\varphi k_{n1}}{(\varphi_n,\varepsilon_1)}& +\dfrac{\varphi k_{n2}}{(\varphi_n,\varepsilon_2)}&\dots& +\dfrac{\varphi k_{n\,n-1}}{(\varphi_n,\varepsilon_{n-1})}& +\dfrac{\varphi}{(\varphi_n,\varepsilon_n)} +\end{Vmatrix}\] +\end{verbatim} +The spacing of the dots can be varied through use of a square-bracket +option, for example, \verb"\hdotsfor[1.5]{3}". The number in square brackets +will be used as a multiplier; the normal value is 1. + +\subsection{The \cn{substack} command} + +The \cn{substack} command can be used to produce a multiline +subscript or superscript: +for example +\begin{verbatim} +\sum_{\substack{0\le i\le m\\ 0<j<n}} P(i,j) +\end{verbatim} +produces a two-line subscript underneath the sum: +\begin{equation} +\sum_{\substack{0\le i\le m\\ 0<j<n}} P(i,j) +\end{equation} +A slightly more generalized form is the \env{subarray} environment which +allows you to specify that each line should be left-aligned instead of +centered, as here: +\begin{equation} +\sum_{\begin{subarray}{l} + 0\le i\le m\\ 0<j<n + \end{subarray}} + P(i,j) +\end{equation} +\begin{verbatim} +\sum_{\begin{subarray}{l} + 0\le i\le m\\ 0<j<n + \end{subarray}} + P(i,j) +\end{verbatim} + + +\subsection{Big-g-g delimiters} +Here are some big delimiters, first in \cn{normalsize}: +\[\biggl(\mathbf{E}_{y} + \int_0^{t_\varepsilon}L_{x,y^x(s)}\varphi(x)\,ds + \biggr) +\] +\begin{verbatim} +\[\biggl(\mathbf{E}_{y} + \int_0^{t_\varepsilon}L_{x,y^x(s)}\varphi(x)\,ds + \biggr) +\] +\end{verbatim} +and now in \cn{Large} size: +{\Large +\[\biggl(\mathbf{E}_{y} + \int_0^{t_\varepsilon}L_{x,y^x(s)}\varphi(x)\,ds + \biggr) +\]} +\begin{verbatim} +{\Large +\[\biggl(\mathbf{E}_{y} + \int_0^{t_\varepsilon}L_{x,y^x(s)}\varphi(x)\,ds + \biggr) +\]} +\end{verbatim} + +\newpage +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\makeatletter + +%% This turns on vertical rules at the right and left margins, to +%% better illustrate the spacing for certain multiple-line equation +%% structures. +\def\@makecol{\ifvoid\footins \setbox\@outputbox\box\@cclv + \else\setbox\@outputbox + \vbox{\boxmaxdepth \maxdepth + \unvbox\@cclv\vskip\skip\footins\footnoterule\unvbox\footins}\fi + \xdef\@freelist{\@freelist\@midlist}\gdef\@midlist{}\@combinefloats + \setbox\@outputbox\hbox{\vrule width\marginrulewidth + \vbox to\@colht{\boxmaxdepth\maxdepth + \@texttop\dimen128=\dp\@outputbox\unvbox\@outputbox + \vskip-\dimen128\@textbottom}% + \vrule width\marginrulewidth}% + \global\maxdepth\@maxdepth} +\newdimen\marginrulewidth +\setlength{\marginrulewidth}{.1pt} +\makeatother + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\appendix +\section{Examples of multiple-line equation structures} +\label{s:eq} + +\textbf{\large Note: Starting on this page, vertical rules are +added at the margins so that the positioning of various display elements +with respect to the margins can be seen more clearly.} + +\subsection{Split} +The \env{split} environment is not an independent environment +but should be used inside something else such as \env{equation} +or \env{align}. + +If there is not enough room for it, the equation number for a +\env{split} will be shifted to the previous line, when equation numbers are +on the left; the number shifts down to the next line when numbers are on +the right. +\begin{equation} +\begin{split} +f_{h,\varepsilon}(x,y) +&=\varepsilon\mathbf{E}_{x,y}\int_0^{t_\varepsilon} +L_{x,y_\varepsilon(\varepsilon u)}\varphi(x)\,du\\ +&= h\int L_{x,z}\varphi(x)\rho_x(dz)\\ +&\quad+h\biggl[\frac{1}{t_\varepsilon}\biggl(\mathbf{E}_{y} + \int_0^{t_\varepsilon}L_{x,y^x(s)}\varphi(x)\,ds + -t_\varepsilon\int L_{x,z}\varphi(x)\rho_x(dz)\biggr)\\ +&\phantom{{=}+h\biggl[}+\frac{1}{t_\varepsilon} + \biggl(\mathbf{E}_{y}\int_0^{t_\varepsilon}L_{x,y^x(s)} + \varphi(x)\,ds -\mathbf{E}_{x,y}\int_0^{t_\varepsilon} + L_{x,y_\varepsilon(\varepsilon s)} + \varphi(x)\,ds\biggr)\biggr]\\ +&=h\wh{L}_x\varphi(x)+h\theta_\varepsilon(x,y), +\end{split} +\end{equation} +Some text after to test the below-display spacing. + +\begin{verbatim} +\begin{equation} +\begin{split} +f_{h,\varepsilon}(x,y) +&=\varepsilon\mathbf{E}_{x,y}\int_0^{t_\varepsilon} +L_{x,y_\varepsilon(\varepsilon u)}\varphi(x)\,du\\ +&= h\int L_{x,z}\varphi(x)\rho_x(dz)\\ +&\quad+h\biggl[\frac{1}{t_\varepsilon}\biggl(\mathbf{E}_{y} + \int_0^{t_\varepsilon}L_{x,y^x(s)}\varphi(x)\,ds + -t_\varepsilon\int L_{x,z}\varphi(x)\rho_x(dz)\biggr)\\ +&\phantom{{=}+h\biggl[}+\frac{1}{t_\varepsilon} + \biggl(\mathbf{E}_{y}\int_0^{t_\varepsilon}L_{x,y^x(s)} + \varphi(x)\,ds -\mathbf{E}_{x,y}\int_0^{t_\varepsilon} + L_{x,y_\varepsilon(\varepsilon s)} + \varphi(x)\,ds\biggr)\biggr]\\ +&=h\wh{L}_x\varphi(x)+h\theta_\varepsilon(x,y), +\end{split} +\end{equation} +\end{verbatim} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\newpage +Unnumbered version: +\begin{equation*} +\begin{split} +f_{h,\varepsilon}(x,y) +&=\varepsilon\mathbf{E}_{x,y}\int_0^{t_\varepsilon} +L_{x,y_\varepsilon(\varepsilon u)}\varphi(x)\,du\\ +&= h\int L_{x,z}\varphi(x)\rho_x(dz)\\ +&\quad+h\biggl[\frac{1}{t_\varepsilon}\biggl(\mathbf{E}_{y} + \int_0^{t_\varepsilon}L_{x,y^x(s)}\varphi(x)\,ds + -t_\varepsilon\int L_{x,z}\varphi(x)\rho_x(dz)\biggr)\\ +&\phantom{{=}+h\biggl[}+\frac{1}{t_\varepsilon} + \biggl(\mathbf{E}_{y}\int_0^{t_\varepsilon}L_{x,y^x(s)} + \varphi(x)\,ds -\mathbf{E}_{x,y}\int_0^{t_\varepsilon} + L_{x,y_\varepsilon(\varepsilon s)} + \varphi(x)\,ds\biggr)\biggr]\\ +&=h\wh{L}_x\varphi(x)+h\theta_\varepsilon(x,y), +\end{split} +\end{equation*} +Some text after to test the below-display spacing. + +\begin{verbatim} +\begin{equation*} +\begin{split} +f_{h,\varepsilon}(x,y) +&=\varepsilon\mathbf{E}_{x,y}\int_0^{t_\varepsilon} +L_{x,y_\varepsilon(\varepsilon u)}\varphi(x)\,du\\ +&= h\int L_{x,z}\varphi(x)\rho_x(dz)\\ +&\quad+h\biggl[\frac{1}{t_\varepsilon}\biggl(\mathbf{E}_{y} + \int_0^{t_\varepsilon}L_{x,y^x(s)}\varphi(x)\,ds + -t_\varepsilon\int L_{x,z}\varphi(x)\rho_x(dz)\biggr)\\ +&\phantom{{=}+h\biggl[}+\frac{1}{t_\varepsilon} + \biggl(\mathbf{E}_{y}\int_0^{t_\varepsilon}L_{x,y^x(s)} + \varphi(x)\,ds -\mathbf{E}_{x,y}\int_0^{t_\varepsilon} + L_{x,y_\varepsilon(\varepsilon s)} + \varphi(x)\,ds\biggr)\biggr]\\ +&=h\wh{L}_x\varphi(x)+h\theta_\varepsilon(x,y), +\end{split} +\end{equation*} +\end{verbatim} +%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\newpage +If the option \env{centertags} is included in the options +list of the \pkg{amsmath} package, +the equation numbers for \env{split} environments will be +centered vertically on the height +of the \env{split}: +{\makeatletter\ctagsplit@true +\begin{equation} +\begin{split} + \abs{I_2}&=\left\lvert \int_{0}^T \psi(t)\left\{u(a,t)-\int_{\gamma(t)}^a + \frac{d\theta}{k(\theta,t)} + \int_{a}^\theta c(\xi)u_t(\xi,t)\,d\xi\right\}dt\right\rvert\\ +&\le C_6\left\lvert \left\lvert f\int_\Omega\left\lvert \wt{S}^{-1,0}_{a,-} + W_2(\Omega,\Gamma_l)\right\rvert\right\rvert + \left\lvert \abs{u}\overset{\circ}\to W_2^{\wt{A}} + (\Omega;\Gamma_r,T)\right\rvert\right\rvert. +\end{split} +\end{equation}}% +Some text after to test the below-display spacing. + +%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\newpage +Use of \env{split} within \env{align}: +{\delimiterfactor750 +\begin{align} +\begin{split}\abs{I_1} + &=\left\lvert \int_\Omega gRu\,d\Omega\right\rvert\\ +&\le C_3\left[\int_\Omega\left(\int_{a}^x + g(\xi,t)\,d\xi\right)^2d\Omega\right]^{1/2}\\ +&\quad\times \left[\int_\Omega\left\{u^2_x+\frac{1}{k} + \left(\int_{a}^x cu_t\,d\xi\right)^2\right\} + c\Omega\right]^{1/2}\\ +&\le C_4\left\lvert \left\lvert f\left\lvert \wt{S}^{-1,0}_{a,-} + W_2(\Omega,\Gamma_l)\right\rvert\right\rvert + \left\lvert \abs{u}\overset{\circ}\to W_2^{\wt{A}} + (\Omega;\Gamma_r,T)\right\rvert\right\rvert. +\end{split}\label{eq:A}\\ +\begin{split}\abs{I_2}&=\left\lvert \int_{0}^T \psi(t)\left\{u(a,t) + -\int_{\gamma(t)}^a\frac{d\theta}{k(\theta,t)} + \int_{a}^\theta c(\xi)u_t(\xi,t)\,d\xi\right\}dt\right\rvert\\ +&\le C_6\left\lvert \left\lvert f\int_\Omega + \left\lvert \wt{S}^{-1,0}_{a,-} + W_2(\Omega,\Gamma_l)\right\rvert\right\rvert + \left\lvert \abs{u}\overset{\circ}\to W_2^{\wt{A}} + (\Omega;\Gamma_r,T)\right\rvert\right\rvert. +\end{split} +\end{align}}% +Some text after to test the below-display spacing. + +\begin{verbatim} +\begin{align} +\begin{split}\abs{I_1} + &=\left\lvert \int_\Omega gRu\,d\Omega\right\rvert\\ +&\le C_3\left[\int_\Omega\left(\int_{a}^x + g(\xi,t)\,d\xi\right)^2d\Omega\right]^{1/2}\\ +&\quad\times \left[\int_\Omega\left\{u^2_x+\frac{1}{k} + \left(\int_{a}^x cu_t\,d\xi\right)^2\right\} + c\Omega\right]^{1/2}\\ +&\le C_4\left\lvert \left\lvert f\left\lvert \wt{S}^{-1,0}_{a,-} + W_2(\Omega,\Gamma_l)\right\rvert\right\rvert + \left\lvert \abs{u}\overset{\circ}\to W_2^{\wt{A}} + (\Omega;\Gamma_r,T)\right\rvert\right\rvert. +\end{split}\label{eq:A}\\ +\begin{split}\abs{I_2}&=\left\lvert \int_{0}^T \psi(t)\left\{u(a,t) + -\int_{\gamma(t)}^a\frac{d\theta}{k(\theta,t)} + \int_{a}^\theta c(\xi)u_t(\xi,t)\,d\xi\right\}dt\right\rvert\\ +&\le C_6\left\lvert \left\lvert f\int_\Omega + \left\lvert \wt{S}^{-1,0}_{a,-} + W_2(\Omega,\Gamma_l)\right\rvert\right\rvert + \left\lvert \abs{u}\overset{\circ}\to W_2^{\wt{A}} + (\Omega;\Gamma_r,T)\right\rvert\right\rvert. +\end{split} +\end{align} +\end{verbatim} + +%%%%%%%%%%%%%%%%%% + +\newpage +Unnumbered \env{align}, with a number on the second \env{split}: +\begin{align*} +\begin{split}\abs{I_1}&=\left\lvert \int_\Omega gRu\,d\Omega\right\rvert\\ + &\le C_3\left[\int_\Omega\left(\int_{a}^x + g(\xi,t)\,d\xi\right)^2d\Omega\right]^{1/2}\\ +&\phantom{=}\times \left[\int_\Omega\left\{u^2_x+\frac{1}{k} + \left(\int_{a}^x cu_t\,d\xi\right)^2\right\} + c\Omega\right]^{1/2}\\ +&\le C_4\left\lvert \left\lvert f\left\lvert \wt{S}^{-1,0}_{a,-} + W_2(\Omega,\Gamma_l)\right\rvert\right\rvert + \left\lvert \abs{u}\overset{\circ}\to W_2^{\wt{A}} + (\Omega;\Gamma_r,T)\right\rvert\right\rvert. +\end{split}\\ +\begin{split}\abs{I_2}&=\left\lvert \int_{0}^T \psi(t)\left\{u(a,t) + -\int_{\gamma(t)}^a\frac{d\theta}{k(\theta,t)} + \int_{a}^\theta c(\xi)u_t(\xi,t)\,d\xi\right\}dt\right\rvert\\ +&\le C_6\left\lvert \left\lvert f\int_\Omega + \left\lvert \wt{S}^{-1,0}_{a,-} + W_2(\Omega,\Gamma_l)\right\rvert\right\rvert + \left\lvert \abs{u}\overset{\circ}\to W_2^{\wt{A}} + (\Omega;\Gamma_r,T)\right\rvert\right\rvert. +\end{split}\tag{\theequation$'$} +\end{align*} +Some text after to test the below-display spacing. + +\begin{verbatim} +\begin{align*} +\begin{split}\abs{I_1}&=\left\lvert \int_\Omega gRu\,d\Omega\right\rvert\\ + &\le C_3\left[\int_\Omega\left(\int_{a}^x + g(\xi,t)\,d\xi\right)^2d\Omega\right]^{1/2}\\ +&\phantom{=}\times \left[\int_\Omega\left\{u^2_x+\frac{1}{k} + \left(\int_{a}^x cu_t\,d\xi\right)^2\right\} + c\Omega\right]^{1/2}\\ +&\le C_4\left\lvert \left\lvert f\left\lvert \wt{S}^{-1,0}_{a,-} + W_2(\Omega,\Gamma_l)\right\rvert\right\rvert + \left\lvert \abs{u}\overset{\circ}\to W_2^{\wt{A}} + (\Omega;\Gamma_r,T)\right\rvert\right\rvert. +\end{split}\\ +\begin{split}\abs{I_2}&=\left\lvert \int_{0}^T \psi(t)\left\{u(a,t) + -\int_{\gamma(t)}^a\frac{d\theta}{k(\theta,t)} + \int_{a}^\theta c(\xi)u_t(\xi,t)\,d\xi\right\}dt\right\rvert\\ +&\le C_6\left\lvert \left\lvert f\int_\Omega + \left\lvert \wt{S}^{-1,0}_{a,-} + W_2(\Omega,\Gamma_l)\right\rvert\right\rvert + \left\lvert \abs{u}\overset{\circ}\to W_2^{\wt{A}} + (\Omega;\Gamma_r,T)\right\rvert\right\rvert. +\end{split}\tag{\theequation$'$} +\end{align*} +\end{verbatim} +%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\newpage +\subsection{Multline} +Numbered version: +\begin{multline}\label{eq:E} +\int_a^b\biggl\{\int_a^b[f(x)^2g(y)^2+f(y)^2g(x)^2] + -2f(x)g(x)f(y)g(y)\,dx\biggr\}\,dy \\ + =\int_a^b\biggl\{g(y)^2\int_a^bf^2+f(y)^2 + \int_a^b g^2-2f(y)g(y)\int_a^b fg\biggr\}\,dy +\end{multline} +To test the use of \verb=\label= and +\verb=\ref=, we refer to the number of this +equation here: (\ref{eq:E}). + +\begin{verbatim} +\begin{multline}\label{eq:E} +\int_a^b\biggl\{\int_a^b[f(x)^2g(y)^2+f(y)^2g(x)^2] + -2f(x)g(x)f(y)g(y)\,dx\biggr\}\,dy \\ + =\int_a^b\biggl\{g(y)^2\int_a^bf^2+f(y)^2 + \int_a^b g^2-2f(y)g(y)\int_a^b fg\biggr\}\,dy +\end{multline} +\end{verbatim} +%%%%%%%%%%%%%%%%%%%%%%%%%%% + +Unnumbered version: +\begin{multline*} +\int_a^b\biggl\{\int_a^b[f(x)^2g(y)^2+f(y)^2g(x)^2] + -2f(x)g(x)f(y)g(y)\,dx\biggr\}\,dy \\ + =\int_a^b\biggl\{g(y)^2\int_a^bf^2+f(y)^2 + \int_a^b g^2-2f(y)g(y)\int_a^b fg\biggr\}\,dy +\end{multline*} +Some text after to test the below-display spacing. + +\begin{verbatim} +\begin{multline*} +\int_a^b\biggl\{\int_a^b[f(x)^2g(y)^2+f(y)^2g(x)^2] + -2f(x)g(x)f(y)g(y)\,dx\biggr\}\,dy \\ + =\int_a^b\biggl\{g(y)^2\int_a^bf^2+f(y)^2 + \int_a^b g^2-2f(y)g(y)\int_a^b fg\biggr\}\,dy +\end{multline*} +\end{verbatim} +%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\iffalse % bugfix needed, error message "Multiple \tag" + % [mjd,24-Jan-1995] +\newpage +And now an ``unnumbered'' version numbered with a literal tag: +\begin{multline*}\tag*{[a]} +\int_a^b\biggl\{\int_a^b[f(x)^2g(y)^2+f(y)^2g(x)^2] + -2f(x)g(x)f(y)g(y)\,dx\biggr\}\,dy \\ + =\int_a^b\biggl\{g(y)^2\int_a^bf^2+f(y)^2 + \int_a^b g^2-2f(y)g(y)\int_a^b fg\biggr\}\,dy +\end{multline*} +Some text after to test the below-display spacing. + +\begin{verbatim} +\begin{multline*}\tag*{[a]} +\int_a^b\biggl\{\int_a^b[f(x)^2g(y)^2+f(y)^2g(x)^2] + -2f(x)g(x)f(y)g(y)\,dx\biggr\}\,dy \\ + =\int_a^b\biggl\{g(y)^2\int_a^bf^2+f(y)^2 + \int_a^b g^2-2f(y)g(y)\int_a^b fg\biggr\}\,dy +\end{multline*} +\end{verbatim} + +%%%%%%%%%%%%%%%%%%%%%%%%%%% + +The same display with \verb=\multlinegap= set to zero. +Notice that the space on the left in +the first line does not change, because of the equation number, while +the second line is pushed over to the right margin. +{\setlength{\multlinegap}{0pt} +\begin{multline*}\tag*{[a]} +\int_a^b\biggl\{\int_a^b[f(x)^2g(y)^2+f(y)^2g(x)^2] + -2f(x)g(x)f(y)g(y)\,dx\biggr\}\,dy \\ + =\int_a^b\biggl\{g(y)^2\int_a^bf^2+f(y)^2 + \int_a^b g^2-2f(y)g(y)\int_a^b fg\biggr\}\,dy +\end{multline*}}% +Some text after to test the below-display spacing. + +\begin{verbatim} +{\setlength{\multlinegap}{0pt} +\begin{multline*}\tag*{[a]} +\int_a^b\biggl\{\int_a^b[f(x)^2g(y)^2+f(y)^2g(x)^2] + -2f(x)g(x)f(y)g(y)\,dx\biggr\}\,dy \\ + =\int_a^b\biggl\{g(y)^2\int_a^bf^2+f(y)^2 + \int_a^b g^2-2f(y)g(y)\int_a^b fg\biggr\}\,dy +\end{multline*}} +\end{verbatim} +%%%%%%%%%%%%%%%%%%%%%%%%%%% +\fi % matches \iffalse above [mjd,24-Jan-1995] + +%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\newpage +\subsection{Gather} +Numbered version with \verb;\notag; on the second line: +\begin{gather} +D(a,r)\equiv\{z\in\mathbf{C}\colon \abs{z-a}<r\},\\ +\seg(a,r)\equiv\{z\in\mathbf{C}\colon +\Im z= \Im a,\ \abs{z-a}<r\},\notag\\ +c(e,\theta,r)\equiv\{(x,y)\in\mathbf{C} +\colon \abs{x-e}<y\tan\theta,\ 0<y<r\},\\ +C(E,\theta,r)\equiv\bigcup_{e\in E}c(e,\theta,r). +\end{gather} +\begin{verbatim} +\begin{gather} +D(a,r)\equiv\{z\in\mathbf{C}\colon \abs{z-a}<r\},\\ +\seg(a,r)\equiv\{z\in\mathbf{C}\colon +\Im z= \Im a,\ \abs{z-a}<r\},\notag\\ +c(e,\theta,r)\equiv\{(x,y)\in\mathbf{C} +\colon \abs{x-e}<y\tan\theta,\ 0<y<r\},\\ +C(E,\theta,r)\equiv\bigcup_{e\in E}c(e,\theta,r). +\end{gather} +\end{verbatim} +%%%%%%%%%%%%%%%%%%%%%%%%%%% + +Unnumbered version. +\begin{gather*} +D(a,r)\equiv\{z\in\mathbf{C}\colon \abs{z-a}<r\},\\ +\seg (a,r)\equiv\{z\in\mathbf{C}\colon +\Im z= \Im a,\ \abs{z-a}<r\},\\ +c(e,\theta,r)\equiv\{(x,y)\in\mathbf{C} + \colon \abs{x-e}<y\tan\theta,\ 0<y<r\},\\ +C(E,\theta,r)\equiv\bigcup_{e\in E}c(e,\theta,r). +\end{gather*} +Some text after to test the below-display spacing. +\begin{verbatim} +\begin{gather*} +D(a,r)\equiv\{z\in\mathbf{C}\colon \abs{z-a}<r\},\\ +\seg (a,r)\equiv\{z\in\mathbf{C}\colon +\Im z= \Im a,\ \abs{z-a}<r\},\\ +c(e,\theta,r)\equiv\{(x,y)\in\mathbf{C} + \colon \abs{x-e}<y\tan\theta,\ 0<y<r\},\\ +C(E,\theta,r)\equiv\bigcup_{e\in E}c(e,\theta,r). +\end{gather*} +\end{verbatim} +%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\newpage +\subsection{Align} +Numbered version: +\begin{align} +\gamma_x(t)&=(\cos tu+\sin tx,v),\\ +\gamma_y(t)&=(u,\cos tv+\sin ty),\\ +\gamma_z(t)&=\left(\cos tu+\frac\alpha\beta\sin tv, + -\frac\beta\alpha\sin tu+\cos tv\right). +\end{align} +Some text after to test the below-display spacing. + +\begin{verbatim} +\begin{align} +\gamma_x(t)&=(\cos tu+\sin tx,v),\\ +\gamma_y(t)&=(u,\cos tv+\sin ty),\\ +\gamma_z(t)&=\left(\cos tu+\frac\alpha\beta\sin tv, + -\frac\beta\alpha\sin tu+\cos tv\right). +\end{align} +\end{verbatim} +%%%%%%%%%%%%%%%%%%%%%%%%%%% + +Unnumbered version: +\begin{align*} +\gamma_x(t)&=(\cos tu+\sin tx,v),\\ +\gamma_y(t)&=(u,\cos tv+\sin ty),\\ +\gamma_z(t)&=\left(\cos tu+\frac\alpha\beta\sin tv, + -\frac\beta\alpha\sin tu+\cos tv\right). +\end{align*} +Some text after to test the below-display spacing. + +\begin{verbatim} +\begin{align*} +\gamma_x(t)&=(\cos tu+\sin tx,v),\\ +\gamma_y(t)&=(u,\cos tv+\sin ty),\\ +\gamma_z(t)&=\left(\cos tu+\frac\alpha\beta\sin tv, + -\frac\beta\alpha\sin tu+\cos tv\right). +\end{align*} +\end{verbatim} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +A variation: +\begin{align} +x& =y && \text {by (\ref{eq:C})}\\ +x'& = y' && \text {by (\ref{eq:D})}\\ +x+x' & = y+y' && \text {by Axiom 1.} +\end{align} +Some text after to test the below-display spacing. + +\begin{verbatim} +\begin{align} +x& =y && \text {by (\ref{eq:C})}\\ +x'& = y' && \text {by (\ref{eq:D})}\\ +x+x' & = y+y' && \text {by Axiom 1.} +\end{align} +\end{verbatim} +%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\newpage +\subsection{Align and split within gather} +When using the \env{align} environment within the \env{gather} +environment, one or the other, or both, should be unnumbered (using the +\verb"*" form); numbering both the outer and inner environment would +cause a conflict. + +Automatically numbered \env{gather} with \env{split} and \env{align*}: +\begin{gather} +\begin{split} \varphi(x,z) +&=z-\gamma_{10}x-\gamma_{mn}x^mz^n\\ +&=z-Mr^{-1}x-Mr^{-(m+n)}x^mz^n +\end{split}\\[6pt] +\begin{align*} +\zeta^0 &=(\xi^0)^2,\\ +\zeta^1 &=\xi^0\xi^1,\\ +\zeta^2 &=(\xi^1)^2, +\end{align*} +\end{gather} +Here the \env{split} environment gets a number from the outer +\env{gather} environment; numbers for individual lines of the +\env{align*} are suppressed because of the star. + +\begin{verbatim} +\begin{gather} +\begin{split} \varphi(x,z) +&=z-\gamma_{10}x-\gamma_{mn}x^mz^n\\ +&=z-Mr^{-1}x-Mr^{-(m+n)}x^mz^n +\end{split}\\[6pt] +\begin{align*} +\zeta^0 &=(\xi^0)^2,\\ +\zeta^1 &=\xi^0\xi^1,\\ +\zeta^2 &=(\xi^1)^2, +\end{align*} +\end{gather} +\end{verbatim} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +The \verb"*"-ed form of \env{gather} with the non-\verb"*"-ed form of +\env{align}. +\begin{gather*} +\begin{split} \varphi(x,z) +&=z-\gamma_{10}x-\gamma_{mn}x^mz^n\\ +&=z-Mr^{-1}x-Mr^{-(m+n)}x^mz^n +\end{split}\\[6pt] +\begin{align} \zeta^0&=(\xi^0)^2,\\ +\zeta^1 &=\xi^0\xi^1,\\ +\zeta^2 &=(\xi^1)^2, +\end{align} +\end{gather*} +Some text after to test the below-display spacing. + +\begin{verbatim} +\begin{gather*} +\begin{split} \varphi(x,z) +&=z-\gamma_{10}x-\gamma_{mn}x^mz^n\\ +&=z-Mr^{-1}x-Mr^{-(m+n)}x^mz^n +\end{split}\\[6pt] +\begin{align} \zeta^0&=(\xi^0)^2,\\ +\zeta^1 &=\xi^0\xi^1,\\ +\zeta^2 &=(\xi^1)^2, +\end{align} +\end{gather*} +\end{verbatim} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\newpage +\subsection{Alignat} +Numbered version: +\begin{alignat}{3} +V_i & =v_i - q_i v_j, & \qquad X_i & = x_i - q_i x_j, + & \qquad U_i & = u_i, + \qquad \text{for $i\ne j$;}\label{eq:B}\\ +V_j & = v_j, & \qquad X_j & = x_j, + & \qquad U_j & u_j + \sum_{i\ne j} q_i u_i. +\end{alignat} +Some text after to test the below-display spacing. + +\begin{verbatim} +\begin{alignat}{3} +V_i & =v_i - q_i v_j, & \qquad X_i & = x_i - q_i x_j, + & \qquad U_i & = u_i, + \qquad \text{for $i\ne j$;}\label{eq:B}\\ +V_j & = v_j, & \qquad X_j & = x_j, + & \qquad U_j & u_j + \sum_{i\ne j} q_i u_i. +\end{alignat} +\end{verbatim} +%%%%%%%%%%%%%%%%%%%%%%%%%%% + +Unnumbered version: +\begin{alignat*}3 +V_i & =v_i - q_i v_j, & \qquad X_i & = x_i - q_i x_j, + & \qquad U_i & = u_i, + \qquad \text{for $i\ne j$;} \\ +V_j & = v_j, & \qquad X_j & = x_j, + & \qquad U_j & u_j + \sum_{i\ne j} q_i u_i. +\end{alignat*} +Some text after to test the below-display spacing. + +\begin{verbatim} +\begin{alignat*}3 +V_i & =v_i - q_i v_j, & \qquad X_i & = x_i - q_i x_j, + & \qquad U_i & = u_i, + \qquad \text{for $i\ne j$;} \\ +V_j & = v_j, & \qquad X_j & = x_j, + & \qquad U_j & u_j + \sum_{i\ne j} q_i u_i. +\end{alignat*} +\end{verbatim} +%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\newpage +The most common use for \env{alignat} is for things like +\begin{alignat}{2} +x& =y && \qquad \text {by (\ref{eq:A})}\label{eq:C}\\ +x'& = y' && \qquad \text {by (\ref{eq:B})}\label{eq:D}\\ +x+x' & = y+y' && \qquad \text {by Axiom 1.} +\end{alignat} +Some text after to test the below-display spacing. + +\begin{verbatim} +\begin{alignat}{2} +x& =y && \qquad \text {by (\ref{eq:A})}\label{eq:C}\\ +x'& = y' && \qquad \text {by (\ref{eq:B})}\label{eq:D}\\ +x+x' & = y+y' && \qquad \text {by Axiom 1.} +\end{alignat} +\end{verbatim} +%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\newpage +\setlength{\marginrulewidth}{0pt} + +\begin{thebibliography}{10} + +\bibitem{dihe:newdir} +W.~Diffie and E.~Hellman, \emph{New directions in cryptography}, IEEE +Transactions on Information Theory \textbf{22} (1976), no.~5, 644--654. + +\bibitem{fre:cichon} +D.~H. Fremlin, \emph{Cichon's diagram}, 1983/1984, presented at the +S{\'e}minaire Initiation {\`a} l'Analyse, G. Choquet, M. Rogalski, J. +Saint Raymond, at the Universit{\'e} Pierre et Marie Curie, Paris, 23e +ann{\'e}e. + +\bibitem{gouja:lagrmeth} +I.~P. Goulden and D.~M. Jackson, \emph{The enumeration of directed +closed {E}uler trails and directed {H}amiltonian circuits by +{L}angrangian methods}, European J. Combin. \textbf{2} (1981), 131--212. + +\bibitem{hapa:graphenum} +F.~Harary and E.~M. Palmer, \emph{Graphical enumeration}, Academic +Press, 1973. + +\bibitem{imlelu:oneway} +R.~Impagliazzo, L.~Levin, and M.~Luby, \emph{Pseudo-random generation +from one-way functions}, Proc. 21st STOC (1989), ACM, New York, +pp.~12--24. + +\bibitem{komiyo:unipfunc} +M.~Kojima, S.~Mizuno, and A.~Yoshise, \emph{A new continuation method +for complementarity problems with uniform p-functions}, Tech. Report +B-194, Tokyo Inst. of Technology, Tokyo, 1987, Dept. of Information +Sciences. + +\bibitem{komiyo:lincomp} +\bysame, \emph{A polynomial-time algorithm for a class of linear +complementarity problems}, Tech. Report B-193, Tokyo Inst. of +Technology, Tokyo, 1987, Dept. of Information Sciences. + +\bibitem{liuchow:formalsum} +C.~J. Liu and Yutze Chow, \emph{On operator and formal sum methods for +graph enumeration problems}, SIAM J. Algorithms Discrete Methods +\textbf{5} (1984), 384--438. + +\bibitem{mami:matrixth} +M.~Marcus and H.~Minc, \emph{A survey of matrix theory and matrix +inequalities}, Complementary Series in Math. \textbf{14} (1964), 21--48. + +\bibitem{miyoki:lincomp} +S.~Mizuno, A.~Yoshise, and T.~Kikuchi, \emph{Practical polynomial time +algorithms for linear complementarity problems}, Tech. Report~13, Tokyo +Inst. of Technology, Tokyo, April 1988, Dept. of Industrial Engineering +and Management. + +\bibitem{moad:quadpro} +R.~D. Monteiro and I.~Adler, \emph{Interior path following primal-dual +algorithms, part {II}: Quadratic programming}, August 1987, Working +paper, Dept. of Industrial Engineering and Operations Research. + +\bibitem{ste:sint} +E.~M. Stein, \emph{Singular integrals and differentiability properties +of functions}, Princeton Univ. Press, Princeton, N.J., 1970. + +\bibitem{ye:intalg} +Y.~Ye, \emph{Interior algorithms for linear, quadratic and linearly +constrained convex programming}, Ph.D. thesis, Stanford Univ., Palo +Alto, Calif., July 1987, Dept. of Engineering--Economic Systems, +unpublished. + +\end{thebibliography} + +\end{document} +\endinput diff --git a/macros/latex-dev/required/graphics/README.md b/macros/latex-dev/required/graphics/README.md index 81f39d1d7b..009e20da95 100644 --- a/macros/latex-dev/required/graphics/README.md +++ b/macros/latex-dev/required/graphics/README.md @@ -1,7 +1,7 @@ The LaTeX `graphics` bundle =========================== -Release 2019-10-01 pre-release 2 +Release 2019-10-01 pre-release 3 Overview -------- diff --git a/macros/latex-dev/required/graphics/color.dtx b/macros/latex-dev/required/graphics/color.dtx index d85b78349d..8de7d013a3 100644 --- a/macros/latex-dev/required/graphics/color.dtx +++ b/macros/latex-dev/required/graphics/color.dtx @@ -2,7 +2,7 @@ % \iffalse % %% color.dtx Copyright (C) 1994--1999 David Carlisle -%% Copyright (C) 2005--2016 David Carlisle, LaTeX3 Project +%% Copyright (C) 2005-2019 David Carlisle, LaTeX3 Project %% %% This file is part of the Standard LaTeX `Graphics Bundle'. %% It may be distributed under the terms of the LaTeX Project Public diff --git a/macros/latex-dev/required/graphics/color.pdf b/macros/latex-dev/required/graphics/color.pdf Binary files differindex efdebda318..77198b2e49 100644 --- a/macros/latex-dev/required/graphics/color.pdf +++ b/macros/latex-dev/required/graphics/color.pdf diff --git a/macros/latex-dev/required/graphics/drivers.dtx b/macros/latex-dev/required/graphics/drivers.dtx index 07c201cf87..d693ebd27b 100644 --- a/macros/latex-dev/required/graphics/drivers.dtx +++ b/macros/latex-dev/required/graphics/drivers.dtx @@ -3,7 +3,7 @@ % %% drivers.dtx Copyright (C) 1994 David Carlisle Sebastian Rahtz %% Copyright (C) 1995 1996 1997 1998 1999 David Carlisle -%% Copyright (C) 2000--2016 David Carlisle, LaTeX3 Project +%% Copyright (C) 2000-2019 David Carlisle, LaTeX3 Project %% %% This file is part of the Standard LaTeX `Graphics Bundle'. %% It may be distributed under the terms of the LaTeX Project Public diff --git a/macros/latex-dev/required/graphics/drivers.pdf b/macros/latex-dev/required/graphics/drivers.pdf Binary files differindex ef6a372bf5..4a25175e87 100644 --- a/macros/latex-dev/required/graphics/drivers.pdf +++ b/macros/latex-dev/required/graphics/drivers.pdf diff --git a/macros/latex-dev/required/graphics/epsfig.dtx b/macros/latex-dev/required/graphics/epsfig.dtx index ba37d771cc..f9197c7b1c 100644 --- a/macros/latex-dev/required/graphics/epsfig.dtx +++ b/macros/latex-dev/required/graphics/epsfig.dtx @@ -2,7 +2,7 @@ % \iffalse % %% epsfig.dtx Copyright (C) 1994-1996 1999 Sebastian Rahtz -%% Copyright (C) 2000--2015,2017 David Carlisle, LaTeX3 Project +%% Copyright (C) 2000-2019 David Carlisle, LaTeX3 Project %% %% This file is part of the Standard LaTeX `Graphics Bundle'. %% It may be distributed under the terms of the LaTeX Project Public diff --git a/macros/latex-dev/required/graphics/epsfig.pdf b/macros/latex-dev/required/graphics/epsfig.pdf Binary files differindex 3aa7fcff62..4347ed4a77 100644 --- a/macros/latex-dev/required/graphics/epsfig.pdf +++ b/macros/latex-dev/required/graphics/epsfig.pdf diff --git a/macros/latex-dev/required/graphics/graphics.pdf b/macros/latex-dev/required/graphics/graphics.pdf Binary files differindex 63a2ed999c..17afa48d1f 100644 --- a/macros/latex-dev/required/graphics/graphics.pdf +++ b/macros/latex-dev/required/graphics/graphics.pdf diff --git a/macros/latex-dev/required/graphics/graphicx.dtx b/macros/latex-dev/required/graphics/graphicx.dtx index aad8460ac5..4134c4eed1 100644 --- a/macros/latex-dev/required/graphics/graphicx.dtx +++ b/macros/latex-dev/required/graphics/graphicx.dtx @@ -2,7 +2,7 @@ % \iffalse % %% graphicx.dtx Copyright (C) 1994 David Carlisle Sebastian Rahtz -%% Copyright (C) 1995--2015,2017 David Carlisle, LaTeX3 Project +%% Copyright (C) 1995-2019 David Carlisle, LaTeX3 Project %% %% This file is part of the Standard LaTeX `Graphics Bundle'. %% It may be distributed under the terms of the LaTeX Project Public diff --git a/macros/latex-dev/required/graphics/graphicx.pdf b/macros/latex-dev/required/graphics/graphicx.pdf Binary files differindex 6137b786f8..73b8ad6c50 100644 --- a/macros/latex-dev/required/graphics/graphicx.pdf +++ b/macros/latex-dev/required/graphics/graphicx.pdf diff --git a/macros/latex-dev/required/graphics/grfguide.pdf b/macros/latex-dev/required/graphics/grfguide.pdf Binary files differindex cd6d72046e..42955a440c 100644 --- a/macros/latex-dev/required/graphics/grfguide.pdf +++ b/macros/latex-dev/required/graphics/grfguide.pdf diff --git a/macros/latex-dev/required/graphics/grfguide.tex b/macros/latex-dev/required/graphics/grfguide.tex index b00a86d307..19888db741 100644 --- a/macros/latex-dev/required/graphics/grfguide.tex +++ b/macros/latex-dev/required/graphics/grfguide.tex @@ -1,5 +1,5 @@ %% grfguide.tex Copyright (C) 1994 1995 1996 1998 1999 David Carlisle -%% Copyright (C) 2005 2014 2016 2017 David Carlisle, LaTeX3 Project +%% Copyright (C) 2005-2019 David Carlisle, LaTeX3 Project %% %% This file is part of the Standard LaTeX `Graphics Bundle'. %% It may be distributed under the terms of the LaTeX Project Public diff --git a/macros/latex-dev/required/graphics/keyval.dtx b/macros/latex-dev/required/graphics/keyval.dtx index f656961d0b..1e1581eee3 100644 --- a/macros/latex-dev/required/graphics/keyval.dtx +++ b/macros/latex-dev/required/graphics/keyval.dtx @@ -1,7 +1,7 @@ % % \iffalse %% keyval.dtx Copyright (C) 1993 1994 1995 1997 1998 1999 David Carlisle -%% Copyright (C) 2000--2015 David Carlisle, LaTeX3 Project +%% Copyright (C) 2000-2019 David Carlisle, LaTeX3 Project %% %% This file is part of the Standard LaTeX `Graphics Bundle'. %% It may be distributed under the terms of the LaTeX Project Public diff --git a/macros/latex-dev/required/graphics/keyval.pdf b/macros/latex-dev/required/graphics/keyval.pdf Binary files differindex 8790611726..fd6f74aba0 100644 --- a/macros/latex-dev/required/graphics/keyval.pdf +++ b/macros/latex-dev/required/graphics/keyval.pdf diff --git a/macros/latex-dev/required/graphics/lscape.dtx b/macros/latex-dev/required/graphics/lscape.dtx index 733e183ee6..a5a3dc3220 100644 --- a/macros/latex-dev/required/graphics/lscape.dtx +++ b/macros/latex-dev/required/graphics/lscape.dtx @@ -2,7 +2,7 @@ % \iffalse % %% lscape.dtx Copyright (C) 1994 1999-2000 David Carlisle -%% Copyright (C) 2000--2015 David Carlisle, LaTeX3 Project +%% Copyright (C) 2000-2019 David Carlisle, LaTeX3 Project %% %% This file is part of the Standard LaTeX `Graphics Bundle'. %% It may be distributed under the terms of the LaTeX Project Public diff --git a/macros/latex-dev/required/graphics/lscape.pdf b/macros/latex-dev/required/graphics/lscape.pdf Binary files differindex bf3d93a04c..edb151476c 100644 --- a/macros/latex-dev/required/graphics/lscape.pdf +++ b/macros/latex-dev/required/graphics/lscape.pdf diff --git a/macros/latex-dev/required/graphics/rotating.dtx b/macros/latex-dev/required/graphics/rotating.dtx index 41bd399d4e..149c19d049 100644 --- a/macros/latex-dev/required/graphics/rotating.dtx +++ b/macros/latex-dev/required/graphics/rotating.dtx @@ -3,9 +3,9 @@ % % % File: rotating.dtx -%% Copyright 1995--1999 Sebastian Rahtz and Leonor Barroca -%% Copyright 2001--2003,2007--2009 Robin Fairbairns -%% Copyright 2016 LaTeX3 Project +%% Copyright (C) 1995--1999 Sebastian Rahtz and Leonor Barroca +%% Copyright (C) 2001--2003,2007--2009 Robin Fairbairns +%% Copyright (C) 2016-2019 LaTeX3 Project % % This work may be distributed and/or modified under the % conditions of the LaTeX Project Public License, either version 1.3c diff --git a/macros/latex-dev/required/graphics/rotating.pdf b/macros/latex-dev/required/graphics/rotating.pdf Binary files differindex bfaa34d0ab..97b252ecd5 100644 --- a/macros/latex-dev/required/graphics/rotating.pdf +++ b/macros/latex-dev/required/graphics/rotating.pdf diff --git a/macros/latex-dev/required/graphics/rotex.pdf b/macros/latex-dev/required/graphics/rotex.pdf Binary files differindex 1564784475..d064b44420 100644 --- a/macros/latex-dev/required/graphics/rotex.pdf +++ b/macros/latex-dev/required/graphics/rotex.pdf diff --git a/macros/latex-dev/required/graphics/trig.dtx b/macros/latex-dev/required/graphics/trig.dtx index 712db13ba2..2b152578ad 100644 --- a/macros/latex-dev/required/graphics/trig.dtx +++ b/macros/latex-dev/required/graphics/trig.dtx @@ -1,6 +1,6 @@ % \iffalse %% File: trig.dtx Copyright (C) 1993 1994 1995 1996 1997 1999 David Carlisle -%% Copyright (C) 2000--2015 David Carlisle, LaTeX3 Project +%% Copyright (C) 2000-2019 David Carlisle, LaTeX3 Project %% %% This file is part of the Standard LaTeX `Graphics Bundle'. %% It may be distributed under the terms of the LaTeX Project Public diff --git a/macros/latex-dev/required/graphics/trig.pdf b/macros/latex-dev/required/graphics/trig.pdf Binary files differindex 2ad8cb7b53..25f75bf255 100644 --- a/macros/latex-dev/required/graphics/trig.pdf +++ b/macros/latex-dev/required/graphics/trig.pdf diff --git a/macros/latex-dev/required/tools/README.md b/macros/latex-dev/required/tools/README.md new file mode 100644 index 0000000000..aa0e7c9f46 --- /dev/null +++ b/macros/latex-dev/required/tools/README.md @@ -0,0 +1,54 @@ +The LaTeX `tools` bundle +======================== + +Release 2019-10-01 pre-release 3 + +Overview +-------- + +This bundle consists of packages providing a range of basic tools for +LaTeX users. It is a required part of a LaTeX installation. + +Installation +------------ + +We no longer distribute installation instructions for the various TeX +implementations. All modern TeX systems include `tools` as-standard, and end +users should in general use the release versions supplied in this way. + +Release distribution is carried out only through the CTAN archives. + +Reporting Bugs +-------------- + +If you wish to report a problem or bug in the `tools` bundle +please use the [Issue Tracker for LaTeX2e on +GitHub](https://github.com/latex3/latex2e/issues) +and follow the guidelines that pop up if you press the "New issue" button. + +In particular, to check that you are really seeing a bug, please write +a short, self-contained document that shows the problem. This should +include the `latexbug` package, which will warn if your test file is +not suitable for one or the other reason. See the [CONTRIBUTING +guide](https://github.com/latex3/latex2e/blob/master/CONTRIBUTING.md) +for further details, or if you need to obtain the `latexbug` package. + +If the bug turns out to be with third-party software then please +contact the developer, and not us! + +License +------- + +The contents of this bundle are distributed under the [LaTeX Project +Public License](https://www.latex-project.org/lppl/lppl-1-3c/), +version 1.3c or later. + +Copyright +--------- + +Copyright is maintained on each of these packages by the author(s) +of the package. + +----- + +<p>Copyright (C) 1993-2019 The LaTeX Project <br /> diff --git a/macros/latex-dev/required/tools/afterpage.dtx b/macros/latex-dev/required/tools/afterpage.dtx new file mode 100644 index 0000000000..3fa341aa53 --- /dev/null +++ b/macros/latex-dev/required/tools/afterpage.dtx @@ -0,0 +1,385 @@ +% \iffalse meta-comment +% +% Copyright (C) 1993-2019 +% +% The LaTeX3 Project and any individual authors listed elsewhere +% in this file. +% +% This file is part of the Standard LaTeX `Tools Bundle'. +% ------------------------------------------------------- +% +% It may be distributed and/or modified under the +% conditions of the LaTeX Project Public License, either version 1.3c +% of this license or (at your option) any later version. +% The latest version of this license is in +% https://www.latex-project.org/lppl.txt +% and version 1.3c or later is part of all distributions of LaTeX +% version 2005/12/01 or later. +% +% The list of all files belonging to the LaTeX `Tools Bundle' is +% given in the file `manifest.txt'. +% +% \fi +% \iffalse +%% File: afterpage.dtx Copyright (C) 1994 1994 1995 David Carlisle +% +%<package>\NeedsTeXFormat{LaTeX2e} +%<package>\ProvidesPackage{afterpage} +%<package> [2014/10/28 v1.08 After-Page Package (DPC)] +% +%<*driver> +\documentclass{ltxdoc} +\usepackage{afterpage} +\GetFileInfo{afterpage.sty} +\begin{document} +\title{The \textsf{afterpage} package\thanks{This file + has version number \fileversion, last + revised \filedate.}} +\author{David Carlisle} +\date{\filedate} +\MaintainedByLaTeXTeam{tools} +\maketitle +\DocInput{afterpage.dtx} +\end{document} +%</driver> +% \fi +% +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% \changes{v1.00}{1993/01/25}{Initial version} +% \changes{v1.05}{1993/07/14}{First public version} +% \changes{v1.06}{1994/02/01}{Update for LaTeX2e} +% \changes{v1.07}{1994/05/23}{Documentation Changes} +% \changes{v1.08}{1995/10/27} +% {Use \cs{par} not \cs{endgraf}, for tools/1579} +% \changes{v1.08}{1995/10/27} +% {Try and do something sensible with nested \cs{clearpage}, +% for tools/1880} +% \changes{v1.08}{1995/10/27} +% {Try and do something sensible with footnotes, for tools/1884} +% +% +% This package implements a command, |\afterpage|, that causes the +% commands specified in its argument to be expanded after the current +% page is output.\footnote{This is really a pre-release, to see whether +% people like the idea of a command like this. This implementation is +% \emph{not} particularly robust. This implementation does not work in +% two column mode, and can get `confused' by \LaTeX's floating +% environments.} +% +% \begin{enumerate} +% \item Sometimes \LaTeX's float positioning mechanism gets overloaded, +% and all floating |figure|s and |table|s drift to the end of the +% document. One may flush out all the unprocessed floats by issuing a +% |\clearpage| command, but this has the effect of making the current +% page end prematurely. Now you can issue |\afterpage{\clearpage}| and +% the current page will be filled up with text as usual, but then a +% |\clearpage| command will flush out all the floats before the next +% text page begins. +% \item An earlier mechanism to help with float placement was the +% optional argument |[H]| (meaning {\bf HERE!}) which was originally +% added to the standard floating environments by |here.sty|, and is now +% provided by |float.sty|. However some |[H]| users have commented that +% they did not really mean `Here!' They actually wanted `Somewhere +% close'. This can now be achieved by\\ +% |\afterpage{\clearpage\begin{figure}[H] |\ldots +% |\end{figure}}|\\ +% This ensures that the figure is at the top of the next page. (The +% |\clearpage| stops any other figures drifting past the |[H]| figure.) +% \item Floating longtables. |longtable.sty| provides the |longtable| +% environment, a multi-page version of |tabular|. Many |longtable| users +% have told me that it is difficult to set the text surrounding the long +% table, and that they wanted a `floating' version. As, presumably, +% |longtable|s are long, they are probably too large to hold in memory, +% and float in the way that the |table| environment is floated, however +% if the table is in a separate file, say |ltfile.tex|, you can now +% use one of:\\ +% |\afterpage{\clearpage\input{ltfile}}|\\ +% |\afterpage{\clearpage\input{ltfile}\clearpage}|.\\ +% The first form lets text appear on the same page as the end of the +% longtable, the second ensures that the surrounding text starts again +% on a new page. +% \end{enumerate} +% +% \StopEventually{} +% +% \begin{macrocode} +%<*package> +% \end{macrocode} +% +% \begin{macro}{\afterpage} +% The token register used to save the old output routine. +% \begin{macrocode} +\newtoks\AP@output +\global\AP@output\expandafter{\the\output} +% \end{macrocode} +% +% A box register used to save any part of the next page which has +% already been processed. +% \begin{macrocode} +\newbox\AP@partial +% \end{macrocode} +% +% A box register used to save any footnote texts that are `tied' to +% the text that gets saved in |\AP@partial|. +% \begin{macrocode} +\newbox\AP@footins +% \end{macrocode} +% +% The following macro attempts to get safely into vertical mode, and +% then invokes a special output routine to grab the current page into +% |\AP@partial|. +% \begin{macrocode} +\def\AP@savetop{% +% \end{macrocode} +% Now begins a test to see what state we are in. |\AP@noindent| will +% be defined so as to return to this state (well, almost!) after +% afterpage has finished. +% \begin{macrocode} + \ifvmode +% \end{macrocode} +% Vertical mode. This is the simplest case, do nothing. +% \begin{macrocode} + \let\AP@noindent\empty + \else\ifhmode +% \end{macrocode} +% Horizontal mode. +% `Back out' into vertical mode, removing the indentation box as we go. +% If in fact there was no indentation box, the output routine was +% invoked by |\noindent| (what bad luck!) so we have to remember to +% re-insert the |\noindent| before the paragraph is seen again. +% |\everypar| tokens have already been inserted, so don't insert them +% again. +% \begin{macrocode} + \setbox\z@\lastbox + \edef\AP@noindent + {{\everypar{}\ifvoid\z@\noindent\else\indent\fi}}% + \par + \else +% \end{macrocode} +% The remaining (even worse) possibility that the output routine +% was triggered by the start of displaymath within a paragraph. +% +% Come out of displaymath with |$$|, then adjust the spacing (getting +% into vmode at the same time). |\AP@noindent| will restart display math +% later. |\everydisplay| tokens have already been inserted (they apply +% to the math list that will be started by |\AP@noindent|, even though +% they were triggered by the display math that was closed by the lines +% below!). Save the values |\prevgraf| and |\predisplaysize| for use in +% the re-started math list. +% \begin{macrocode} + \abovedisplayshortskip\z@\abovedisplayskip\z@ + \belowdisplayshortskip\z@\belowdisplayskip\z@ + \xdef\AP@disp{% + \predisplaysize\the\predisplaysize + \prevgraf\the\prevgraf\relax}% + $$\vskip-\baselineskip\vskip-\parskip + \edef\AP@noindent{% +% \end{macrocode} +% Do not insert |\everydisplay| tokens again. +% \begin{macrocode} + \toks@{\the\everydisplay}\everydisplay{}% +% \end{macrocode} +% Start displaymath mode with no spurious paragraph line above it. +% Restore |\prevgraf| and |\predisplaysize|. Use |\aftergroup| to +% restore the correct setting for |\everydisplay| after this display +% has finished. +% \begin{macrocode} + {\everypar{}\noindent}$$\AP@disp\aftergroup\noexpand\AP@ed}% + \fi\fi +% \end{macrocode} +% Now switch the output routine and remove everything from the current +% page into the box |\AP@partial|. +% \begin{macrocode} + \begingroup + \nointerlineskip\null + \output{% + \global\setbox\AP@partial\vbox{% + \unvbox\@cclv + \global\setbox\@ne\lastbox}% +% \end{macrocode} +% If the text that is saved in |\AP@partial| had footnotes, we'd +% better grab them as well otherwise they may come out on a page +% with the `afterpage' text, before the page that has the +% footnote mark! (Added at v1.08.) +% \begin{macrocode} + \global\setbox\AP@footins\box\footins}% +% \end{macrocode} +% Having defined the output routine, trigger it\ldots +% \begin{macrocode} + \eject + \endgroup} +% \end{macrocode} +% +% |\AP@| stores all the commands that must be executed after the page +% break. +% \begin{macrocode} +\let\AP@\relax +% \end{macrocode} +% +% Restore the |\everydisplay| register. |\ignorespaces| prevents a space +% or newline after |$$| creating rogue a indentation or paragraph. +% \begin{macrocode} +\def\AP@ed{\everydisplay\expandafter{\the\toks@}\ignorespaces} +% \end{macrocode} +% +% Remove the current vertical list, insert the commands |\AP@| +% at the top of the page, and then re-insert the saved text. +% \begin{macrocode} +\def\AP@@{% + \AP@savetop + \global\expandafter\let\expandafter\AP@\expandafter\relax\AP@ + \par +% \end{macrocode} +% The text originally at the top of this page is now stored in the box +% |\AP@partial|, including |\topskip| glue. Now we want to unbox +% |\AP@partial|, placing the baseline of the first row |\baselineskip| +% below the baseline of the last line coming from the afterpage text. +% If we assumed nothing has too much height or depth (and |\topskip| is +% rigid), it would be fairly trivial to position the contents of +% |\AP@partial| so that the baseline of the first row was +% |\baselineskip| below the last row just added. +% +% In this version, I thought it might be fun to try to exactly achieve +% the |\baselineskip|--or--|\lineskip| calculation that \TeX\ normally +% does internally. The call to |\addboxcontents| does the right thing +% (I hope). +% \begin{macrocode} + \addboxcontents\AP@partial +% \end{macrocode} +% Now re-insert any footnote text. This may not be quite the right +% place, as the text that has just been unboxed may break over a page +% in its new position. Also it may not be the right number if the text +% from |\afterpage| itself contains footnotes. Too bad! +% \begin{macrocode} + \ifvoid\AP@footins\else + \insert\footins{\unvbox\AP@footins}\fi +% \end{macrocode} +% Now repair things if we started off in horizontal mode. +% \begin{macrocode} + \AP@noindent} +% \end{macrocode} +% +% If |\AP@| is not |\relax| then the current page already has some +% `afterpage' commands, so just add the new commands to the end of the +% list. Otherwise save the commands in |\AP@|. (within a local group), +% and switch the output routine. (The new output routine just calls the +% old one if it is invoked by a \LaTeX{} float. +% \begin{macrocode} +\long\def\afterpage#1{% + \ifx\AP@\relax + \gdef\AP@{{#1\par}}% + \global\output{% + \the\AP@output + \ifnum\outputpenalty>-\@Mi + \global\output\expandafter{\the\AP@output}% + \aftergroup\AP@@ + \fi}% + \else + \expandafter\gdef\expandafter\AP@\expandafter{\AP@{#1\par}}% + \fi} +% \end{macrocode} +% +% If we have got to the end of the document or clearpage +% just put the stuff out without any trickery. +% \begin{macrocode} +\let\AP@clearpage\clearpage +\def\clearpage{% + \ifx\AP@\relax + \AP@clearpage + \else + \global\output\expandafter{\the\AP@output}% + \AP@clearpage +% \end{macrocode} +% At this point (since v1.08) Need to clear |\AP@| \emph{before} +% using its expansion, as otherwise hit an infinite loop. Sigh. +% \begin{macrocode} + \global\expandafter\let\expandafter\AP@\expandafter\relax + \expandafter\expandafter\AP@ + \fi} +\let\AP@enddocument\enddocument +\def\enddocument{% + \ifx\AP@\relax\else + \global\output\expandafter{\the\AP@output}% + \AP@clearpage + \global\expandafter\let\expandafter\AP@\expandafter\relax + \expandafter\expandafter\AP@ + \fi + \AP@enddocument} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\addboxcontents} +% Given a vbox |#1|, add to the current vertical list such that the end +% result is equivalent to the list that \TeX\ would have built had the +% contents of |#1| (apart from any initial glue) been added individually +% to the current list. + +% So essentially, the problem is that of unboxing |#1|, but replacing +% the glue at the top of |#1| with (something equivalent to) the +% |\baselineskip| or |\lineskip| glue that \TeX\ would normally have +% placed before the first box in |#1|. Also |\prevdepth| must be set at +% the end. +% \begin{macrocode} +\def\addboxcontents#1{{% +% \end{macrocode} +% Perhaps I shouldn't use grouping here, as I probably don't really want +% to save |#1|. If it is removed, |\splittopskip| and |\splitmaxdepth| +% would need to be restored by hand. +% +% First replace any glue at the top by |\vskip 0pt|. +% \begin{macrocode} + \splittopskip\z@ + \splitmaxdepth\maxdimen + \setbox#1\vbox{\break\unvbox#1}% + \setbox\z@\vsplit#1to\z@ +% \end{macrocode} +% Put the breakpoint back. +% \begin{macrocode} + \setbox#1\vbox{\break\unvbox#1}% +% \end{macrocode} +% Set |\skip@| to be height of |#1| (without top glue) +% \begin{macrocode} + \skip@\ht#1% +% \end{macrocode} +% Now make the first baseline of the first row be |\vsize| from the top. +% (This assumes that the first row has height less than |\vsize|.) +% \begin{macrocode} + \splittopskip\vsize + \setbox\z@\vsplit#1to\z@ +% \end{macrocode} +% Subtract the new height of |#1| from |\skip@|, and add back on +% |\splittopskip|, so |\skip@| is now the height of the first row of +% |#1| This may still be 0pt if (eg) a mark or whatsit is between the +% top glue and the first box. Save (this height${}-{}$|\splittopskip|) +% in |\skip\tw@|. +% \begin{macrocode} + \advance\skip@-\ht#1% + \skip\tw@\skip@ + \advance\skip@\splittopskip +% \end{macrocode} +% Now fake \TeX's |\baselineskip| calculation. +% \begin{macrocode} + \advance\skip@\prevdepth + \advance\skip@-\baselineskip + \advance\skip\tw@\ifdim-\skip@<\lineskiplimit\lineskip\else-\skip@\fi +% \end{macrocode} +% Finally add the glue. +% \begin{macrocode} + \vskip\skip\tw@ +% \end{macrocode} +% Now unbox the box, setting |\prevdepth| by hand, as |\unvbox| (unlike +% |\box|) does not automatically set it. +% \begin{macrocode} + \global\dimen@i\dp#1% + \unvbox#1}% + \prevdepth\dimen@i} +% \end{macrocode} +% \end{macro} +% +% \begin{macrocode} +%</package> +% \end{macrocode} +% +% \Finale +% diff --git a/macros/latex-dev/required/tools/afterpage.ins b/macros/latex-dev/required/tools/afterpage.ins new file mode 100644 index 0000000000..9764bdac6d --- /dev/null +++ b/macros/latex-dev/required/tools/afterpage.ins @@ -0,0 +1,75 @@ +%% +%% This file will generate fast loadable files and documentation +%% driver files from the doc files in this package when run through +%% LaTeX or TeX. +%% +%% Copyright (C) 1993-2019 +%% The LaTeX3 Project and any individual authors listed elsewhere +%% in this file. +%% +%% This file is part of the Standard LaTeX `Tools Bundle'. +%% ------------------------------------------------------- +%% +%% It may be distributed and/or modified under the +%% conditions of the LaTeX Project Public License, either version 1.3c +%% of this license or (at your option) any later version. +%% The latest version of this license is in +%% https://www.latex-project.org/lppl.txt +%% and version 1.3c or later is part of all distributions of LaTeX +%% version 2005/12/01 or later. +%% +%% As this file contains legal notices, it is NOT PERMITTED to modify +%% this file in any way that the legal information placed into +%% generated files is changed (i.e., the files generated when the +%% original file is executed). This restriction does not apply if +%% (parts of) the content is reused in a different WORK producing its +%% own generated files. +%% +%% The list of all files belonging to the `Tools Bundle' is +%% given in the file `manifest.txt'. +%% +%% +%% --------------- start of docstrip commands ------------------ +%% +\input docstrip + +\keepsilent + +\usedir{tex/latex/tools} + +\preamble + +This is a generated file. + +The source is maintained by the LaTeX Project team and bug +reports for it can be opened at https://latex-project.org/bugs/ +(but please observe conditions on bug reports sent to that address!) + +Copyright (C) 1993-2019 +The LaTeX3 Project and any individual authors listed elsewhere +in this file. + +This file was generated from file(s) of the Standard LaTeX `Tools Bundle'. +-------------------------------------------------------------------------- + +It may be distributed and/or modified under the +conditions of the LaTeX Project Public License, either version 1.3c +of this license or (at your option) any later version. +The latest version of this license is in + https://www.latex-project.org/lppl.txt +and version 1.3c or later is part of all distributions of LaTeX +version 2005/12/01 or later. + +This file may only be distributed together with a copy of the LaTeX +`Tools Bundle'. You may however distribute the LaTeX `Tools Bundle' +without such generated files. + +The list of all files belonging to the LaTeX `Tools Bundle' is +given in the file `manifest.txt'. + +\endpreamble + + +\generate{\file{afterpage.sty}{\from{afterpage.dtx}{package}}} + +\endbatchfile diff --git a/macros/latex-dev/required/tools/afterpage.pdf b/macros/latex-dev/required/tools/afterpage.pdf Binary files differnew file mode 100644 index 0000000000..3cd429ce02 --- /dev/null +++ b/macros/latex-dev/required/tools/afterpage.pdf diff --git a/macros/latex-dev/required/tools/array-2016-10-06.sty b/macros/latex-dev/required/tools/array-2016-10-06.sty new file mode 100644 index 0000000000..0b619362d4 --- /dev/null +++ b/macros/latex-dev/required/tools/array-2016-10-06.sty @@ -0,0 +1,341 @@ +%% +%% This is an old release of `array.sty', +%% +%% Copyright 1993-2016 +%% The LaTeX3 Project and any individual authors listed elsewhere +%% in this file. +%% +%% This file was generated from file(s) of the Standard LaTeX `Tools Bundle'. +%% -------------------------------------------------------------------------- +%% +%% It may be distributed and/or modified under the +%% conditions of the LaTeX Project Public License, either version 1.3c +%% of this license or (at your option) any later version. +%% The latest version of this license is in +%% http://www.latex-project.org/lppl.txt +%% and version 1.3c or later is part of all distributions of LaTeX +%% version 2005/12/01 or later. +%% +%% +%% Package `array' to use with LaTeX 2e +%% Copyright (C) 1989-1998 Frank Mittelbach, all rights reserved. +\NeedsTeXFormat{LaTeX2e}[1995/06/01] +\ProvidesPackage{array} + [2016/10/06 v2.4d Tabular extension package (FMi)] +%% + +\def\@addtopreamble#1{\xdef\@preamble{\@preamble #1}} +\def\@testpach{\@chclass + \ifnum \@lastchclass=6 \@ne \@chnum \@ne \else + \ifnum \@lastchclass=7 5 \else + \ifnum \@lastchclass=8 \tw@ \else + \ifnum \@lastchclass=9 \thr@@ + \else \z@ + \ifnum \@lastchclass = 10 \else + \edef\@nextchar{\expandafter\string\@nextchar}% + \@chnum + \if \@nextchar c\z@ \else + \if \@nextchar l\@ne \else + \if \@nextchar r\tw@ \else + \z@ \@chclass + \if\@nextchar |\@ne \else + \if \@nextchar !6 \else + \if \@nextchar @7 \else + \if \@nextchar <8 \else + \if \@nextchar >9 \else + 10 + \@chnum + \if \@nextchar m\thr@@\else + \if \@nextchar p4 \else + \if \@nextchar b5 \else + \z@ \@chclass \z@ \@preamerr \z@ \fi \fi \fi \fi + \fi \fi \fi \fi \fi \fi \fi \fi \fi \fi \fi \fi} +\def\@xexpast#1*#2#3#4\@@{% + \@tempcnta #2 + \toks@={#1}\@temptokena={#3}% + \let\the@toksz\relax \let\the@toks\relax + \def\@tempa{\the@toksz}% + \ifnum\@tempcnta >0 \@whilenum\@tempcnta >0\do + {\edef\@tempa{\@tempa\the@toks}\advance \@tempcnta \m@ne}% + \let \@tempb \@xexpast \else + \let \@tempb \@xexnoop \fi + \def\the@toksz{\the\toks@}\def\the@toks{\the\@temptokena}% + \edef\@tempa{\@tempa}% + \expandafter \@tempb \@tempa #4\@@} +\def\prepnext@tok{\advance \count@ \@ne + \toks\count@{}} +\def\save@decl{\toks\count@ \expandafter{\@nextchar}} +\def\insert@column{% + \the@toks \the \@tempcnta + \ignorespaces \@sharp \unskip + \the@toks \the \count@ \relax} +\newdimen\col@sep +\def\@acol{\@addtopreamble{\hskip\col@sep}} +\def\@mkpream#1{\gdef\@preamble{}\@lastchclass 4 \@firstamptrue + \let\@sharp\relax \let\@startpbox\relax \let\@endpbox\relax + \@xexpast #1*0x\@@ + \count@\m@ne + \let\the@toks\relax + \prepnext@tok + \expandafter \@tfor \expandafter \@nextchar + \expandafter :\expandafter =\@tempa \do + {\@testpach + \ifcase \@chclass \@classz \or \@classi \or \@classii + \or \save@decl \or \or \@classv \or \@classvi + \or \@classvii \or \@classviii \or \@classix + \or \@classx \fi + \@lastchclass\@chclass}% + \ifcase\@lastchclass + \@acol \or + \or + \@acol \or + \@preamerr \thr@@ \or + \@preamerr \tw@ \@addtopreamble\@sharp \or + \or + \else \@preamerr \@ne \fi + \def\the@toks{\the\toks}} +\def\@classx{% + \ifcase \@lastchclass + \@acolampacol \or + \@addamp \@acol \or + \@acolampacol \or + \or + \@acol \@firstampfalse \or + \@addamp + \fi} +\def\@classz{\@classx + \@tempcnta \count@ + \prepnext@tok + \@addtopreamble{\ifcase \@chnum + \hfil + \d@llarbegin + \insert@column + \d@llarend \hfil \or + \hskip1sp\d@llarbegin \insert@column \d@llarend \hfil \or + \hfil\hskip1sp\d@llarbegin \insert@column \d@llarend \or + $\vcenter + \@startpbox{\@nextchar}\insert@column \@endpbox $\or + \vtop \@startpbox{\@nextchar}\insert@column \@endpbox \or + \vbox \@startpbox{\@nextchar}\insert@column \@endpbox + \fi}\prepnext@tok} +\def\@classix{\ifnum \@lastchclass = \thr@@ + \@preamerr \thr@@ \fi + \@classx} +\def\@classviii{\ifnum \@lastchclass >\z@ + \@preamerr 4\@chclass 6 \@classvi \fi} +\def\@arrayrule{\@addtopreamble \vline} +\def\@classvii{\ifnum \@lastchclass = \thr@@ + \@preamerr \thr@@ \fi} +\def\@classvi{\ifcase \@lastchclass + \@acol \or + \@addtopreamble{\hskip \doublerulesep}\or + \@acol \or + \@classvii + \fi} +\def\@classii{\advance \count@ \m@ne + \save@decl\prepnext@tok} +\def\@classv{\save@decl + \@addtopreamble{\d@llarbegin\the@toks\the\count@\relax\d@llarend}% + \prepnext@tok} +\def\@classi{\@classvi + \ifcase \@chnum \@arrayrule \or + \@classv \fi} +\def\@startpbox#1{\bgroup + \setlength\hsize{#1}\@arrayparboxrestore + \everypar{% + \vrule \@height \ht\@arstrutbox \@width \z@ + \everypar{}}% + } +\def\@endpbox{\@finalstrut\@arstrutbox \egroup\hfil} +\def\@array[#1]#2{% + \@tempdima \ht \strutbox + \advance \@tempdima by\extrarowheight + \setbox \@arstrutbox \hbox{\vrule + \@height \arraystretch \@tempdima + \@depth \arraystretch \dp \strutbox + \@width \z@}% + \begingroup + \@mkpream{#2}% + \xdef\@preamble{\noexpand \ialign \@halignto + \bgroup \@arstrut \@preamble + \tabskip \z@ \cr}% + \endgroup + \@arrayleft + \if #1t\vtop \else \if#1b\vbox \else \vcenter \fi \fi + \bgroup + \let \@sharp ##\let \protect \relax + \lineskip \z@ + \baselineskip \z@ + \m@th + \let\\\@arraycr \let\tabularnewline\\\let\par\@empty \@preamble} +\def\arraybackslash{\let\\\tabularnewline} +\newdimen \extrarowheight +\extrarowheight=0pt +\def\@arstrut{\unhcopy\@arstrutbox} +\def\@arraycr{\relax\iffalse{\fi\ifnum 0=`}\fi + \@ifstar \@xarraycr \@xarraycr} +\def\@xarraycr{\@ifnextchar [% + \@argarraycr {\ifnum 0=`{}\fi\cr}} +\def\@argarraycr[#1]{\ifnum0=`{}\fi\ifdim #1>\z@ + \expandafter\@xargarraycr\else + \expandafter\@yargarraycr\fi{#1}} +\def\@xargarraycr#1{\unskip + \@tempdima #1\advance\@tempdima \dp\@arstrutbox + \vrule \@depth\@tempdima \@width\z@ \cr} +\def\@yargarraycr#1{\cr\noalign{\vskip #1}} +\long\def\multicolumn#1#2#3{% + \multispan{#1}\begingroup + \def\@addamp{\if@firstamp \@firstampfalse \else + \@preamerr 5\fi}% + \@mkpream{#2}\@addtopreamble\@empty + \endgroup + \def\@sharp{#3}% + \@arstrut \@preamble + \null + \ignorespaces} +\let\d@llarbegin\begingroup +\let\d@llarend\endgroup +\def\array{\col@sep\arraycolsep + \def\d@llarbegin{$}\let\d@llarend\d@llarbegin\def\@halignto{}% + \@tabarray} +\def\@tabarray{\@ifnextchar[{\@array}{\@array[c]}} +\def\tabular{\def\@halignto{}\@tabular} +\expandafter\def\csname tabular*\endcsname#1{% + \setlength\dimen@{#1}% + \edef\@halignto{to\the\dimen@}\@tabular} +\def\@tabular{% + \leavevmode + \hbox \bgroup $\col@sep\tabcolsep \let\d@llarbegin\begingroup + \let\d@llarend\endgroup + \@tabarray} +\def\endarray{\crcr \egroup \egroup \gdef\@preamble{}} +\def\endtabular{\endarray $\egroup} +\expandafter\let\csname endtabular*\endcsname=\endtabular +\let\@ampacol=\relax \let\@expast=\relax +\let\@arrayclassiv=\relax \let\@arrayclassz=\relax +\let\@tabclassiv=\relax \let\@tabclassz=\relax +\let\@arrayacol=\relax \let\@tabacol=\relax +\let\@tabularcr=\relax \let\@@endpbox=\relax +\let\@argtabularcr=\relax \let\@xtabularcr=\relax +\def\@preamerr#1{\def\@tempd{{..} at wrong position: }% + \PackageError{array}{% + \ifcase #1 Illegal pream-token (\@nextchar): `c' used\or %0 + Missing arg: token ignored\or %1 + Empty preamble: `l' used\or %2 + >\@tempd token ignored\or %3 + <\@tempd changed to !{..}\or %4 + Only one column-spec. allowed.\fi}\@ehc} %5 +\def\newcolumntype#1{% + \edef\NC@char{\string#1}% + \@ifundefined{NC@find@\NC@char}% + {\@tfor\next:=<>clrmbp@!|\do{\if\noexpand\next\NC@char + \PackageWarning{array}% + {Redefining primitive column \NC@char}\fi}% + \NC@list\expandafter{\the\NC@list\NC@do#1}}% + {\PackageWarning{array}{Column \NC@char\space is already defined}}% + \@namedef{NC@find@\NC@char}##1#1{\NC@{##1}}% + \@ifnextchar[{\newcol@{\NC@char}}{\newcol@{\NC@char}[0]}} +\def\newcol@#1[#2]#3{\expandafter\@reargdef + \csname NC@rewrite@#1\endcsname[#2]{\NC@find#3}} +\def\NC@#1{% + \@temptokena\expandafter{\the\@temptokena#1}\futurelet\next\NC@ifend} +\def\NC@ifend{% + \ifx\next\relax + \else\@tempswatrue\expandafter\NC@rewrite\fi} +\def\NC@do#1{% + \expandafter\let\expandafter\NC@rewrite + \csname NC@rewrite@\string#1\endcsname + \expandafter\let\expandafter\NC@find + \csname NC@find@\string#1\endcsname + \expandafter\@temptokena\expandafter{\expandafter}% + \expandafter\NC@find\the\@temptokena#1\relax} +\def\showcols{{\def\NC@do##1{\let\NC@do\NC@show}\the\NC@list}} +\def\NC@show#1{% + \typeout{Column #1\expandafter\expandafter\expandafter\NC@strip + \expandafter\meaning\csname NC@rewrite@#1\endcsname\@@}} +\def\NC@strip#1:#2->#3 #4\@@{#2 -> #4} +\newtoks\NC@list +\newcolumntype{*}[2]{} +\long\@namedef{NC@rewrite@*}#1#2{% + \count@#1\relax + \loop + \ifnum\count@>\z@ + \advance\count@\m@ne + \@temptokena\expandafter{\the\@temptokena#2}% + \repeat + \NC@find} +\let\@xexpast\relax +\let\@xexnoop\relax +\def\save@decl{\toks \count@ = \expandafter\expandafter\expandafter + {\expandafter\@nextchar\the\toks\count@}} +\def\@mkpream#1{\gdef\@preamble{}\@lastchclass 4 \@firstamptrue + \let\@sharp\relax \let\@startpbox\relax \let\@endpbox\relax + \@temptokena{#1}\@tempswatrue + \@whilesw\if@tempswa\fi{\@tempswafalse\the\NC@list}% + \count@\m@ne + \let\the@toks\relax + \prepnext@tok + \expandafter \@tfor \expandafter \@nextchar + \expandafter :\expandafter =\the\@temptokena \do + {\@testpach + \ifcase \@chclass \@classz \or \@classi \or \@classii + \or \save@decl \or \or \@classv \or \@classvi + \or \@classvii \or \@classviii + \or \@classx + \or \@classx \fi + \@lastchclass\@chclass}% + \ifcase\@lastchclass + \@acol \or + \or + \@acol \or + \@preamerr \thr@@ \or + \@preamerr \tw@ \@addtopreamble\@sharp \or + \or + \else \@preamerr \@ne \fi + \def\the@toks{\the\toks}} +\let\@classix\relax +\def\@classviii{\ifnum \@lastchclass >\z@\ifnum\@lastchclass=\tw@\else + \@preamerr 4\@chclass 6 \@classvi \fi\fi} +\def\@classv{\save@decl + \expandafter\NC@ecs\@nextchar\extracolsep{}\extracolsep\@@@ + \@addtopreamble{\d@llarbegin\the@toks\the\count@\relax\d@llarend}% + \prepnext@tok} +\def\NC@ecs#1\extracolsep#2#3\extracolsep#4\@@@{\def\@tempa{#2}% + \ifx\@tempa\@empty\else\toks\count@={#1\tabskip#2\relax#3}\fi} +\def\@tabarray{\@ifnextchar[{\@@array}{\@@array[c]}} +\let\@@array\@array +\def\endarray{\crcr \egroup \egroup \@arrayright \gdef\@preamble{}} +\let\@arrayleft\@empty +\let\@arrayright\@empty +\newlength{\extratabsurround} +\setlength{\extratabsurround}{2pt} +\newlength{\backup@length} +\newcommand{\firsthline}{% + \multicolumn1c{% + \global\backup@length\ht\@arstrutbox + \global\advance\backup@length\dp\@arstrutbox + \global\advance\backup@length\arrayrulewidth + \raise\extratabsurround\copy\@arstrutbox + }\\[-\backup@length]\hline +} +\newcommand{\lasthline}{\hline\multicolumn1c{% + \global\backup@length2\ht\@arstrutbox + \global\advance\backup@length2\dp\@arstrutbox + \global\advance\backup@length\arrayrulewidth + }\\[-\backup@length]% + \multicolumn1c{% + \lower\extratabsurround\copy\@arstrutbox + }% +} +\CheckCommand*\@xhline{\ifx\reserved@a\hline + \vskip\doublerulesep + \vskip-\arrayrulewidth + \fi + \ifnum0=`{\fi}} +\renewcommand*\@xhline{\ifx\reserved@a\hline + \vskip\doublerulesep + \fi + \ifnum0=`{\fi}} +\endinput +%% +%% End of file `array.sty'. diff --git a/macros/latex-dev/required/tools/array.dtx b/macros/latex-dev/required/tools/array.dtx new file mode 100644 index 0000000000..5590b0a136 --- /dev/null +++ b/macros/latex-dev/required/tools/array.dtx @@ -0,0 +1,3092 @@ +% \iffalse meta-comment +% +% Copyright (C) 1993-2019 +% +% The LaTeX3 Project and any individual authors listed elsewhere +% in this file. +% +% This file is part of the Standard LaTeX `Tools Bundle'. +% ------------------------------------------------------- +% +% It may be distributed and/or modified under the +% conditions of the LaTeX Project Public License, either version 1.3c +% of this license or (at your option) any later version. +% The latest version of this license is in +% https://www.latex-project.org/lppl.txt +% and version 1.3c or later is part of all distributions of LaTeX +% version 2005/12/01 or later. +% +% The list of all files belonging to the LaTeX `Tools Bundle' is +% given in the file `manifest.txt'. +% +% \fi +%\iffalse % this is a METACOMMENT ! +% +%% Package `array' to use with LaTeX 2e +%% Copyright (C) 1989-1998 Frank Mittelbach, all rights reserved. +%<+package>\NeedsTeXFormat{LaTeX2e}[1995/06/01] +%<+package>\providecommand\DeclareRelease[3]{} +%<+package>\providecommand\DeclareCurrentRelease[2]{} +%<+package> +%<+package>\DeclareRelease{}{2016-10-06}{array-2016-10-06.sty} +%<+package>\DeclareCurrentRelease{}{2019-10-01} +%<+package> +%<+package>\ProvidesPackage{array} +%<+package> [2019/08/31 v2.4l Tabular extension package (FMi)] +% +% \fi +% +%% +% +% +% \changes{v2.4g}{2018/04/07}{Renamed internal \cs{mcell@box} to +% \cs{ar@mcellbox} and \cs{align@mcell} to \cs{ar@align@mcell} +% to avoid conflict with makecell package} +% +% \changes{v2.4c}{2008/09/09}{(WR) Typo fix in documentation} +% +% \changes{v2.3c}{1995/11/02}{(DPC) minor doc changes} +% +% \changes{v2.3a}{1994/10/16}{Added code for \cs{firsthline} and +% friends} +% +% \changes{v2.2c}{1994/03/14}{removed check for \cs{@tfor} bug} +% +% \changes{v1.0b}{1987/06/04}{`@classi (faster), +% `@classvi (new) A in preamble means +% \&\& in `halign.} +% +% \changes{v1.1a}{1987/07/05}{New concept: +% preamblechar: c,l,r,C,L,R,A,p,t,{\tt !|},@,!!} +% \changes{v1.1b}{1987/09/21}{Again p like original \LaTeX{} and z for +% centered `parbox.} +% +% \changes{v1.2a}{1987/09/27}{Completely new implementation.} +% \changes{v1.2b}{1987/10/06}{{\tt !|} does no longer generate space at +% start or end of the preamble. Otherwise `hline +% is too long.} +% \changes{v1.2b}{1987/10/06}{Enlarged `@arstrutbox by 1pt (Test-Impl) +% with dimen `@strutheight.} +% \changes{v1.2c}{1987/10/22}{New dimen parameter `extrarowheight +% (default: 0pt).} +% \changes{v1.2c}{1987/10/22}{Enlarged `@arstrutbox by `extrarowheight. +% Thus you may avoid large characters to +% overprint a `hline.} +% \changes{v1.2c}{1987/10/22}{Introduced `m@th in `@array to allow +% non-zero values of `mathsurround.} +% \changes{v1.2d}{1987/11/02}{Completed the documentation.} +% \changes{v1.2e}{1987/11/03}{Bug fixed: A at start of preamble resulted +% in an error since `@mkpream generated +% `@arstrut \& ... as a preamble.} +% \changes{v1.2f}{1987/11/09}{`@testpach documented.} +% +% \changes{v1.3a}{1987/11/11}{Again a new implementation, with a new +% concept (cf. the documentation).} +% \changes{v1.3b}{1988/03/17}{`@decl expands now into `@empty, i.e., it +% disappears when the preamble is generated, +% except when the user specifies A\{\} or +% B\{\}.} +% +% \changes{v1.4a}{1988/03/18}{Test implementation of use of token +% registers in order to do without `protect.} +% \changes{v1.4b}{1988/03/19}{Changed erroneous class numbers: +% 5 -!> 6 +% 6 -!> 7 +% 7 -!> 5 +% Corresponding changes in the macros.} +% \changes{v1.4c}{1988/03/19}{Everything except p,z now works with token +% registers.} +% +% \changes{v1.9a}{1988/03/20}{Last (so I hope) major change: 1) Options +% B,A now called !>,<. These options now point +% to the column they modify.} +% \changes{v1.9a}{1988/03/20}{2) `protect is no longer necessary. But +% still the macro `@expast needs top be +% modified. `multicolumn still does not work.} +% \changes{v1.9b}{1988/04/29}{inserted missing `fi in `@testpach. +% Corrected \LaTeX bug in `@tfor.} +% \changes{v1.9c}{1988/05/07}{Re-introduced `@endpbox. +% `multicolumn now works!! Version number still +% 1.9 since the documentation is still not +% finished.} +% \changes{v1.9c}{1988/05/07}{1) `def `the@toks \{`the ...\} remaining +% only in `@mkpream. 2) Removed `@classiii and +% replaced by `save@decl.} +% \changes{v1.9c}{1988/05/07}{3) `insert@column contains only `@tempcnta +% and `count@ counters. 4) `@@startpbox and +% `@@endpbox now totally obsolete.} +% \changes{v1.9d}{1988/05/10}{Replaced `number by `the where the `toks +% registers' contents are used.} +% \changes{v1.9e}{1988/05/11}{Re-introduced `@xargarraycr and +% `@yargarraycr, since `endtemplate seems to +% be `outer.} +% \changes{v1.9f}{1988/05/20}{Small changes finally carried out: +% 1) `par!=`@empty. +% 2) \{..ifnum0!=!`\}... $\to$ `bgroup and +% analogously `egroup.} +% \changes{v1.9g}{1988/02/24}{Inserted again \{..ifnum0!=!`\}.., +% c.f. Appendix D of the \protect\TeX{}book.} +% \changes{v1.9h}{1988/06/28}{No longer necessary to read in the file +% twice.} +% \changes{v1.9i}{1988/06/28}{Corrected typo in german version.} +% \changes{v1.9j}{1988/11/23}{In a `r' column an extra `kern`z@ is +% needed.} +% \changes{v1.9j}{1988/11/23}{Otherwise the `hfil on the left side +% will be removed by the `unskip in +% `insert@column if the entry is empty.} +% \changes{v1.9k}{1988/06/28}{Corrected typo in german version.} +% \changes{v1.9k}{1989/01/16}{`begin{Macro} changed to `begin{macro} in +% documentation.} +% +% \changes{v2.0a}{1989/05/12}{{\tt\textbackslash @thetoks} changed to +% {\tt\textbackslash the@toks}.} +% \changes{v2.0a}{1989/05/12}{source changed to reflect new doc.sty +% conventions.} +% \changes{v2.0a}{1989/05/12}{t option renamed to p to be compatible to +% the original.} +% \changes{v2.0a}{1989/05/12}{File renamed from arraye.sty to +% array.sty.} +% \changes{v2.0b}{1989/05/17}{Three forgotten end macro added.} +% \changes{v2.0b}{1989/05/17}{All lines shortened to 72 or less.} +% \changes{v2.2a}{1994/02/03}{Upgrade to \LaTeXe} +% +% \DoNotIndex{\@depth,\@ehc,\@fortmp,\@height,\@ifnextchar,\@ifstar} +% \DoNotIndex{\@ifundefined,\@ne,\@nil,\@tempa,\@tempb} +% \DoNotIndex{\@tempcnta,\@tempd,\@tempdima,\@whilenum,\@width,\\} +% \DoNotIndex{\@tforloop} +% \DoNotIndex{\advance} +% \DoNotIndex{\baselineskip,\begingroup,\bgroup} +% \DoNotIndex{\cr,\crcr,\csname} +% \DoNotIndex{\def,\do,\docdate,\dp} +% \DoNotIndex{\edef,\egroup,\else,\endcsname,\endinput,\expandafter} +% \DoNotIndex{\fi,\filedate,\fileversion} +% \DoNotIndex{\gdef} +% \DoNotIndex{\hbox,\hfil,\hsize,\hskip,\ht} +% \DoNotIndex{\if,\ifcase,\ifdim,\ifnum,\ifx,\ignorespaces} +% \DoNotIndex{\kern} +% \DoNotIndex{\leavevmode,\let,\lineskip} +% \DoNotIndex{\m@ne,\multispan} +% \DoNotIndex{\newcount,\newdimen,\noalign} +% \DoNotIndex{\or} +% \DoNotIndex{\relax} +% \DoNotIndex{\setbox,\space,\strutbox} +% \DoNotIndex{\tabskip,\thr@@,\the,\toks,\toks@,\tw@,\typeout} +% \DoNotIndex{\unhcopy,\unskip} +% \DoNotIndex{\vbox,\vcenter,\vline,\vrule,\vtop,\vskip} +% \DoNotIndex{\xdef} +% \DoNotIndex{\z@} +% +% \GetFileInfo{array.sty} +% +% \title{A new implementation of \LaTeX's \textsf{tabular} +% and \textsf{array} environment\thanks{This file +% has version number \fileversion, last +% revised \filedate.}} +% \author{Frank Mittelbach +% \and +% David Carlisle\thanks{David kindly agreed on the inclusion +% of the \texttt{\textbackslash{}newcolumntype} implementation, +% formerly in +% \texttt{newarray.sty} into this package }} +% +% \date{Printed \today} +% +% \MaintainedByLaTeXTeam{tools} +% \maketitle +% +% \MakeShortVerb{\=} +% +% \begin{abstract} +% This article describes an extended implementation of the \LaTeX\ +% \textsf{array}-- and \textsf{tabular}--environments. The special +% merits of this implementation are further options to format columns +% and the fact that fragile \LaTeX--commands don't have to be +% =\protect='ed any more within those environments. +% +% The major part of the code for this package dates back to 1988---so +% does some of its documentation. +% \end{abstract} +% +% +% +% \section{Introduction} +% +% This new implementation of the \textsf{array}-- and +% \textsf{tabular}--environments is part of a larger project in which +% we are trying to improve the \LaTeX\--code in some aspects and to +% make \LaTeX\ even easier to handle. +% +% The reader should be familiar with the general structure of the +% environments +% mentioned above. Further information can be found in +% \cite{bk:lamport} and \cite{bk:GMS94}. +% The additional options which can be used in the +% preamble as well as those which now have a slightly different meaning +% are described in table~\ref{tab:opt}. +% +% \DescribeMacro\extrarowheight +% Additionally we introduce a new +% parameter called =\extrarowheight=. If it takes a positive +% length, the value of the parameter is added to the normal height of +% every row of the table, while +% the depth will remain the same. This is important for tables +% with horizontal lines because those lines normally touch the +% capital letters. +% For example, we used =\setlength{\extrarowheight}{1pt}= +% in table~\ref{tab:opt}. +% +% \begin{table}[!t] +% \begin{center} +% \setlength{\extrarowheight}{1pt} +% \begin{tabular}{|>{\tt}c|m{9cm}|} +% \hline +% \multicolumn{2}{|c|}{Unchanged options}\\ +% \hline +% l & Left adjusted column. \\ +% c & Centered adjusted column. \\ +% r & Right adjusted column. \\ +% p\{width\} & Equivalent to =\parbox[t]{width}=. \\ +% @\{decl.\} & Suppresses inter-column space and inserts +% \texttt{decl.}\ instead. \\ +% \hline +% \multicolumn{2}{|c|}{New options}\\ +% \hline +% m\{width\} & Defines a column of width \texttt{width}. +% Every entry will be centered in proportion to +% the rest of the line. It is somewhat like +% =\parbox{width}=. \\ +% \hline +% b\{width\} & Coincides with =\parbox[b]{width}=. \\ +% \hline +% >\{decl.\} & Can be used before an \texttt{l}, \texttt{r}, +% \texttt{c}, \texttt{p}, \texttt{m} or a +% \texttt{b} option. It inserts \texttt{decl.}\ +% directly in front of the entry of the column. +% \\ +% \hline +% <\{decl.\} & Can be used after an \texttt{l}, \texttt{r}, +% \texttt{c}, =p{..}=, =m{..}= or a =b{..}= +% option. It inserts \texttt{decl.}\ right +% after the entry of the column. \\ +% \hline +% | & Inserts a vertical line. The distance between +% two columns will be enlarged by the width of +% the line +% in contrast to the original definition of +% \LaTeX. \\ +% \hline +% !\{decl.\} & Can be used anywhere and corresponds with the +% \texttt{|} option. The difference is that +% \texttt{decl.} is inserted instead of a +% vertical line, so this option doesn't +% suppress the normally inserted space between +% columns in contrast to =@{...}=.\\ +% \hline\hline +% w\{align\}\{width\} & Sets the cell content in a box of the +% specified \texttt{width} aligned according to +% the \texttt{align} parameter which could be +% either \texttt{l}, \texttt{c} or +% \texttt{r}. Works essentially like +% =\makebox[=width=][=align=]{=cell=}= so +% silently overprints if the cell content is +% wider than the specified width. If that is +% not desired use \texttt{W} instead.\\ +% \hline +% W\{align\}\{width\} & Like \texttt{w} but spits out an overfull +% box warning (and an overfullrule marker in +% draft mode) when the cell content is too wide +% to fit. This also means that the alignment is +% different if there is too much material, +% because it then always protrudes to the right!\\ +% \hline +% \end{tabular} +% \end{center} +% \caption{The preamble options.} \label{tab:opt} +% \end{table} +% +% +% We will discuss a few examples using the new preamble options before +% dealing with the implementation. +% \begin{itemize} +% \item +% If you want to use a special font (for example =\bfseries=) in a +% flushed left column, this can be done with =>{\bfseries}l=. You +% do not have to begin every entry of the column with =\bfseries= +% any more. +% \item +% In columns which have been generated with \texttt{p}, \texttt{m} +% or \texttt{b}, the default value of =\parindent= is +% \textsf{0pt}. +% This can be changed with \\ +% =>{\setlength{\parindent}{1cm}}p=. +% \item +% The \texttt{>}-- and \texttt{<}--options were originally +% developed for the following application: +% =>{$}c<{$}= generates a column in math +% mode in a \textsf{tabular}--environment. If you use this type +% of a preamble in an \textsf{array}--environment, you get a +% column in LR mode because the additional \$'s cancel the +% existing \$'s. +% \item +% One can also think of more complex applications. A problem +% which has +% been mentioned several times in \TeX{}hax can be solved with +% =>{\centerdots}c=\linebreak[0]=<{\endcenterdots}=. +% To center decimals at their +% decimal points you (only?) have to define the following macros: +% \begin{verbatim} +%{\catcode`\.\active\gdef.{\egroup\setbox2\hbox\bgroup}} +%\def\centerdots{\catcode`\.\active\setbox0\hbox\bgroup} +%\def\endcenterdots{\egroup\ifvoid2 \setbox2\hbox{0}\fi +% \ifdim \wd0>\wd2 \setbox2\hbox to\wd0{\unhbox2\hfill}\else +% \setbox0\hbox to\wd2{\hfill\unhbox0}\fi +% \catcode`\.12 \box0.\box2} +%\end{verbatim} +% Warning: The code is bad, it doesn't work with more than one +% dot in a cell and doesn't work when the tabular is used in the +% argument of some other command. A much better version is +% provided in the \texttt{dcolumn.sty} by David Carlisle. +% \item +% Using =c!{\hspace{1cm}}c= you get space between two +% columns which is enlarged by one centimeter, while +% =c@{\hspace{1cm}}c= gives you exactly one centimeter +% space between two columns. +% +% \item +% A declaration like =w{l}{3cm}= (or even shorter =wl{3cm}=) +% works like an =l= column except that the width will always be +% =3cm= regardless of the cell content. Same with =w{c}= or +% =w{r}=. This means that it is easy to set up tables in which all +% columns have predefined widths. +% \end{itemize} +% +% \subsection{Defining new column specifiers} +% +% \DeleteShortVerb{\=} +% \MakeShortVerb{\"} +% \DescribeMacro{\newcolumntype} +% Whilst it is handy to be able to type +% \begin{quote} +% ">{"\meta{some declarations}"}{c}<{"\meta{some more +% declarations}"}" +% \end{quote} +% if you have a one-off column in a table, it is rather inconvenient +% if you often use columns of this form. The new version allows you +% to define a new column specifier, say \texttt{x}, which will expand to +% the primitives column specifiers.\footnote{This command was named +% \texttt{\textbackslash{}newcolumn} in the \texttt{newarray.sty}. +% At the moment \texttt{\textbackslash{}newcolumn} is still supported +% (but gives a warning). In later releases it will vanish.} Thus we +% may define +% \begin{quote} +% "\newcolumntype{x}{>{"\meta{some declarations}"}{c}<{"\meta{some +% more declarations}"}}"\hspace*{-3cm} ^^A no overfull from this line +% \end{quote} +% One can then use the \texttt{x} column specifier in the preamble +% arguments of all \texttt{array} or \texttt{tabular} environments in +% which you want columns of this form. +% +% It is common to need math-mode and LR-mode columns in the same +% alignment. If we define: +% \begin{quote} +% "\newcolumntype{C}{>{$}c<{$}}" \\ +% "\newcolumntype{L}{>{$}l<{$}}" \\ +% "\newcolumntype{R}{>{$}r<{$}}" +% \end{quote} +% Then we can use \texttt{C} to get centred LR-mode in an +% \texttt{array}, or centred math-mode in a \texttt{tabular}. +% +% The example given above for `centred decimal points' could be +% assigned to a \texttt{d} specifier with the following command. +% \begin{quote} +% "\newcolumntype{d}{>{\centerdots}c<{\endcenterdots}}" +% \end{quote} +% +% The above solution always centres the dot in the +% column. This does not look too good if the column consists of large +% numbers, but to only a few decimal places. An alternative definition +% of a \texttt{d} column is +% \begin{quote} +% "\newcolumntype{d}[1]{>{\rightdots{#1}}r<{\endrightdots}}" +% \end{quote} +% where the appropriate macros in this case are:\footnote{The package +% \texttt{dcolumn.sty} contains more robust macros based on these +% ideas.} +% \begin{verbatim} +% \def\coldot{.}% Or if you prefer, \def\coldot{\cdot} +% {\catcode`\.=\active +% \gdef.{$\egroup\setbox2=\hbox to \dimen0 \bgroup$\coldot}} +% \def\rightdots#1{% +% \setbox0=\hbox{$1$}\dimen0=#1\wd0 +% \setbox0=\hbox{$\coldot$}\advance\dimen0 \wd0 +% \setbox2=\hbox to \dimen0 {}% +% \setbox0=\hbox\bgroup\mathcode`\.="8000 $} +% \def\endrightdots{$\hfil\egroup\box0\box2} +%\end{verbatim} +% Note that "\newcolumntype" takes the same optional argument as +% "\newcommand" which declares the number of arguments of the column +% specifier being defined. Now we can specify "d{2}" in our preamble +% for a column of figures to at most two decimal places. +% +% A rather different use of the "\newcolumntype" system takes +% advantage of the fact that the replacement text in the +% "\newcolumntype" command may refer to more than one column. Suppose +% that a document contains a lot of \texttt{tabular} environments that +% require the same preamble, but you wish to experiment with different +% preambles. Lamport's original definition allowed you to do the +% following (although it was probably a mis-use of the system). +% \begin{quote} +% "\newcommand{\X}{clr}"\\ +% "\begin{tabular}{\X}" \ldots +% \end{quote} +% \texttt{array.sty} takes great care \textbf{not} to expand the +% preamble, and so the above does not work with the new scheme. With +% the new version this functionality is returned: +% \begin{quote} +% "\newcolumntype{X}{clr}"\\ +% "\begin{tabular}{X}" \ldots +% \end{quote} +% +% The replacement text in a "\newcolumntype" command may refer to any of +% the primitives of \texttt{array.sty} see table \ref{tab:opt} on page +% \pageref{tab:opt}, or to any new letters defined in other +% "\newcolumntype" commands. +% +% +% \DescribeMacro{\showcols}A list of all the currently active +% "\newcolumntype" definitions is sent to the terminal and log file if +% the "\showcols" command is given. +% +% +% \subsection{Special variations of \texttt{\textbackslash hline}} +% +% The family of \texttt{tabular} environments allows +% vertical positioning with respect to the baseline of +% the text in which the environment appears. By default the +% environment appears centered, but this can be changed to +% align with the first or last line in the environment by +% supplying a \texttt{t} or \texttt{b} value to the +% optional position argument. However, this does not work +% when the first or last element in the environment is a +% "\hline" command---in that case the environment is +% aligned at the horizontal rule. +% +% \pagebreak[3] +% +% Here is an example: +% \begin{center} +% \begin{minipage}[t]{.4\linewidth} +% Tables +% \begin{tabular}[t]{l} +% with no\\ hline \\ commands \\ used +% \end{tabular} versus \\ tables +% \begin{tabular}[t]{|l|} +% \hline +% with some \\ hline \\ commands \\ +% \hline +% \end{tabular} used. +% \end{minipage} +% \begin{minipage}[t]{.5\linewidth} +% \begin{verbatim} +% Tables +% \begin{tabular}[t]{l} +% with no\\ hline \\ commands \\ used +% \end{tabular} versus tables +% \begin{tabular}[t]{|l|} +% \hline +% with some \\ hline \\ commands \\ +% \hline +% \end{tabular} used. +% \end{verbatim} +% \end{minipage} +% \end{center} +% +% \DescribeMacro\firsthline +% \DescribeMacro\lasthline +% Using "\firsthline" and "\lasthline" will +% cure the problem, and the tables will align properly as long +% as their first or last line does not contain extremely large +% objects. +% \begin{center} +% \begin{minipage}[t]{.4\linewidth} +% Tables +% \begin{tabular}[t]{l} +% with no\\ line \\ commands \\ used +% \end{tabular} versus \\ tables +% \begin{tabular}[t]{|l|} +% \firsthline +% with some \\ line \\ commands \\ +% \lasthline +% \end{tabular} used. +% \end{minipage} +% \begin{minipage}[t]{.5\linewidth} +% \begin{verbatim} +% Tables +% \begin{tabular}[t]{l} +% with no\\ line \\ commands \\ used +% \end{tabular} versus tables +% \begin{tabular}[t]{|l|} +% \firsthline +% with some \\ line \\ commands \\ +% \lasthline +% \end{tabular} used. +% \end{verbatim} +% \end{minipage} +% \end{center} +% \DescribeMacro\extratabsurround +% The implementation of these two commands contains an extra +% dimension, which is called "\extratabsurround", to add some +% additional space at the top and the bottom of such an environment. +% This is useful if such tables are nested. +% +% \section{Final Comments} +% +% \subsection{Handling of rules} +% +% There are two possible approaches to the handling of horizontal and +% vertical rules in tables: +% \begin{enumerate} +% \item rules can be placed into the available space without +% enlarging the table, or +% \item rules can be placed between columns or rows thereby enlarging +% the table. +% \end{enumerate} +% \texttt{array.sty} implements the second possibility while the +% default implementation in the \LaTeX{} kernel implements the first +% concept. Both concepts have their merits but one has to be aware of +% the individual implications. +% \begin{itemize} +% \item +% With standard \LaTeX{} adding rules to a table will not affect the +% width or height of the table (unless double rules are used), e.g., +% changing a preamble from \verb=lll= to \verb=l|l|l= does not +% affect the document other than adding rules to the table. In +% contrast, with \texttt{array.sty} a table that just fit the +% \verb=\textwidth= might now produce an overfull box. +% \item +% With standard \LaTeX{} modifying the width of rules could result +% in ugly looking tables because without adjusting the +% \verb=\tabcolsep=, etc.\ the space between rule and column could +% get too small (or too large). In fact even overprinting of text is +% possible. In contrast, with \texttt{array.sty} modifying any such +% length usually works well as the actual visual white space (from +% \verb=\tabcolsep=, etc.) does not depend on the width of the +% rules. +% \item +% With standard \LaTeX{} boxed tabulars actually have strange +% corners because the horizontal rules end in the middle of the +% vertical ones. This looks very unpleasant when a large +% \verb=\arrayrulewidth= is chosen. In that case a simple table like +%\begin{verbatim} +%\setlength{\arrayrulewidth}{5pt} +%\begin{tabular}{|l|} +% \hline A \\ \hline +%\end{tabular} +%\end{verbatim} +% will produce something like +% \begin{center} +%\setlength{\arrayrulewidth}{5pt} +%\begin{tabular}{@{}l@{}} +% \hline \null\hskip-.5\arrayrulewidth\vline +% \hskip\tabcolsep +% A\hskip\tabcolsep +% \vline\hskip-.5\arrayrulewidth\null \\ \hline +%\end{tabular} +% \quad +% instead of +% \quad +%\begin{tabular}{|l|} +% \hline A \\ \hline +%\end{tabular} +% \end{center} +% \end{itemize} +% +% \subsection{Comparisons with older versions of \texttt{array.sty}} +% +% There are some differences in the way version 2.1 treats incorrect +% input, even if the source file does not appear to use any of the +% extra features of the new version. +% \begin{itemize} +% \item A preamble of the form "{wx*{0}{abc}yz}" was treated by +% versions prior to 2.1 as "{wx}". Version 2.1 treats it as "{wxyz}" +% \item An incorrect positional argument such as \texttt{[Q]} was +% treated as \texttt{[c]} by \texttt{array.sty}, but is now treated as +% \texttt{[t]}. +% \item A preamble such as "{cc*{2}}" with an error in +% a $*$-form will generate different errors in the new version. In +% both cases the error message is not particularly helpful to the +% casual user. +% \item Repeated \texttt{<} or \texttt{>} constructions +% generated an error in earlier versions, but are now allowed in +% this package. ">{"\meta{decs1}"}>{"\meta{decs2}"}" is treated the +% same as ">{"\meta{decs2}\meta{decs1}"}". +% \item The "\extracolsep" +% command does not work with the old versions of \texttt{array.sty}, +% see the comments in \texttt{array.bug}. With version 2.1 +% "\extracolsep" may again be used in \texttt{@}-expressions as in +% standard \LaTeX, and also in \texttt{!}-expressions (but see the +% note below). +% \end{itemize} +% +% Prior to version 2.4f the space added by the optional argument to "\\" +% was added inside an m-cell if the last column was of type +% \texttt{m}. As a result that cell was vertically centered with that +% space inside, resulting in a strange offset. Since 2.4f, this space +% is now added after centering the cell. +% +% A similar problem happened when "\extrarowheight" was used. For that +% reason m-cells now manually position the cell content which +% allows to ignore this extra space request during the vertical aligment. +% +% +% \subsection{Bugs and Features} +% +% \begin{itemize} +% \item Error messages generated when parsing the column specification +% refer to the preamble argument \textbf{after} it has been re-written +% by the "\newcolumntype" system, not to the preamble entered by the +% user. This seems inevitable with any system based on +% pre-processing and so is classed as a \textbf{feature}. +% +% \item The treatment of multiple \texttt{<} or \texttt{>} +% declarations may seem strange at first. Earlier implementations +% treated ">{"\meta{decs1}"}>{"\meta{decs2}"}" the same as +% ">{"\meta{decs1}\meta{decs2}"}". However this did not give the +% user the opportunity of overriding the settings of a +% "\newcolumntype" defined using these declarations. For example, +% suppose in an \texttt{array} environment we use a \texttt{C} +% column defined as above. The \texttt{C} specifies a centred text +% column, however ">{\bfseries}C", which re-writes to +% ">{\bfseries}>{$}c<{$}" would not specify a bold column as might +% be expected, as the preamble would essentially expand to +% "\hfil$\bfseries$#$ $\hfil" and so the column entry would not be in the +% scope of the "\bfseries"\,! The present version switches the order +% of repeated declarations, and so the above example now produces a +% preamble of the form "\hfil$" "$\bfseries#$" "$\hfil", and the +% dollars cancel each other out without limiting the scope of the +% "\bfseries". +% +% \item The use of "\extracolsep" has been subject to the following +% two restrictions. There must be at most one "\extracolsep" +% command per "@", or "!" expression and the command must be +% directly entered into the "@" expression, not as part of a macro +% definition. Thus "\newcommand{\ef}{\extracolsep{\fill}}" \ldots +% "@{\ef}" does not work with this package. However you can use +% something like +% "\newcolumntype{e}{@{\extracolsep{\fill}}" instead. +% +% \item As noted by the \LaTeX{} book, for the purpose of +% "\multicolumn" each column with the exception of the first one +% consists of the entry and the \emph{following} inter-column +% material. This means that in a tabular with the preamble +% "|l|l|l|l|" input such as "\multicolumn{2}{|c|}" in +% anything other than the first column is incorrect. + +% In the standard array/tabular implementation this error is not so +% noticeable as that version contains negative spacing so that each +% "|" takes up no horizontal space. But since in this package the +% vertical lines take up their natural width one sees two lines if +% two are specified. +% +% \end{itemize} +% +% +% +% \changes{v2.2b}{1994/02/04}{Removed interactive prompt} +% +% \StopEventually{ +% +% +% \begin{thebibliography}{1} +% \bibitem{bk:GMS94} \textsc{M.~Goossens}, \textsc{F.~Mittelbach} +% and \textsc{A.~Samarin}. +% \newblock The \LaTeX{} Companion. +% \newblock +% Addison-Wesley, Reading, Massachusetts, 1994. +% \bibitem{bk:knuth} \textsc{D. E. Knuth}. +% \newblock The \TeX{}book (Computers \& Typesetting Volume A). +% \newblock +% Addison-Wesley, Reading, Massachusetts, 1986. +% \bibitem{bk:lamport} \textsc{L. Lamport}. +% \newblock +% \LaTeX\ --- A Document Preparation System. +% \newblock +% Addison-Wesley, Reading, Massachusetts, 1986. +% \end{thebibliography} +% +% } ^^A end of \StopEventually +% +% +% +% +% \section{The documentation driver file} +% +% The first bit of code contains the documentation driver file for +% \TeX{}, i.e., the file that will produce the documentation you are +% currently reading. It will be extracted from this file by the +% \texttt{docstrip} program. +% \begin{macrocode} +%<*driver> +\NeedsTeXFormat{LaTeX2e}[1995/12/01] +\documentclass{ltxdoc} + +\AtBeginDocument{\DeleteShortVerb{\|}} % undo the default is not used + + \usepackage{array} + + % Allow large table at bottom + \renewcommand{\bottomfraction}{0.7} + +\EnableCrossrefs + %\DisableCrossrefs % Say \DisableCrossrefs if index is ready + +\RecordChanges % Gather update information + +\CodelineIndex % Index code by line number + + %\OnlyDescription % comment out for implementation details + %\OldMakeindex % use if your MakeIndex is pre-v2.9 +\begin{document} + \DocInput{array.dtx} +\end{document} +%</driver> +% \end{macrocode} +% +% +% \section{The construction of the preamble} +% +% \DeleteShortVerb{\"} +% \MakeShortVerb{\=} +% +% It is obvious that those environments will consist mainly of an +% =\halign=, because \TeX\ typesets tables using this primitive. +% That is why we will now take a look at the algorithm which determines +% a preamble for a =\halign= starting with a given user preamble +% using the options mentioned above. +% +% +% The current version is defined at the top of the file looking +% something like this +% \begin{macrocode} +%<*package> +%\NeedsTeXFormat{LaTeX2e}[1994/05/13] +%\ProvidesPackage{array}[\filedate\space version\fileversion] +% \end{macrocode} +% +% The most interesting macros of this implementation are without doubt +% those which are responsible for the construction of the preamble for +% the =\halign=. The underlying algorithm was developed by +% \textsc{Lamport} (resp.\ \textsc{Knuth}, see texhax V87\#??), and it +% has been extended and improved. +% +% The user preamble will be read \textsf{token} by \textsf{token}. A +% \textsf{token} is a single character like \texttt{c} or a block +% enclosed in ={...}=. For example the preamble of +% =\begin{tabular}=\linebreak[0]={lc||c@{\hspace{1cm}}}= consists of +% the \textsf{token} \texttt{l}, \texttt{c}, \texttt{|}, \texttt{|}, +% \texttt{@} and =\hspace{1cm}=. +% +% The currently used \textsf{token} and the one, used before, are needed +% to decide on how the construction of the preamble has to be +% continued. +% In the example mentioned above the \texttt{l} causes the preamble +% to begin with =\hskip\tabcolsep=. Furthermore +% =# \hfil= would be appended to define a flush left column. +% The next \textsf{token} is a \texttt{c}. Because it was preceded by an +% \texttt{l} it generates a new column. This is done with +% =\hskip \tabcolsep & \hskip \tabcolsep=. The column which is to +% be centered will be appended with =\hfil # \hfil=. +% The \textsf{token} \texttt{|} would then add a space of +% =\hskip \tabcolsep= +% and a vertical line because the last +% \textsf{tokens} was a \texttt{c}. +% The following \textsf{token} \texttt{|} would only add a space +% =\hskip \doublerulesep= because it was preceded by the +% \textsf{token} \texttt{|}. We will not discuss our example further but +% rather take a look at the general case of constructing preambles. +% +% The example shows that the desired preamble for the +% =\halign= can be constructed as soon as the action of all +% combinations +% of the preamble \textsf{tokens} are specified. There are 18 such +% \textsf{tokens} +% so we have $19 \cdot 18 \string= 342$ combinations if we count the +% beginning of +% the preamble as a special \textsf{token}. Fortunately, there are many +% combinations which generate the same spaces, so we can define +% \textsf{token} classes. We will identify a +% \textsf{token} within a class with a number, so we can insert the +% formatting (for example of a column). +% Table~\ref{tab:Klassen} lists all \textsf{token} classes and +% their corresponding numbers. +% \begin{table}[ht] +% \begin{center} +% \begin{tabular}[t]{>{\ttfamily}ccc} +% \textsf{token} & =\@chclass= & =\@chnum= \\[2mm] +% c & 0 & 0 \\ +% l & 0 & 1 \\ +% r & 0 & 2 \\ +% p-arg & 0 & 3 \\ +% t-arg & 0 & 4 \\ +% b-arg & 0 & 5 \\ +% | & 1 & 0 \\ +% !-arg & 1 & 1 \\ +% <-arg & 2 & --- \\ +% >-arg & 3 & --- +% \end{tabular} +% \kern3mm \vrule \kern3mm% +% \begin{tabular}[t]{>{\ttfamily}ccc} +% \textsf{token} & =\@chclass= & =\@chnum= \\[2mm] +% Start & 4 & --- \\ +% @-arg & 5 & --- \\ +% ! & 6 & --- \\ +% @ & 7 & --- \\ +% < & 8 & --- \\ +% > & 9 & --- \\ +% p & 10 & 3 \\ +% t & 10 & 4 \\ +% b & 10 & 5 +% \end{tabular} +% \end{center} +% \caption{Classes of preamble \textsf{tokens}} +% \label{tab:Klassen} +% \end{table} +% +% +% \begin{macro}{\@chclass} +% \begin{macro}{\@chnum} +% \begin{macro}{\@lastchclass} +% The class and the number of the current \textsf{token} are saved in +% the +% \textsf{count} registers =\@chclass= +% and =\@chnum=, while the class of the previous +% \textsf{token} is stored in the +% \textsf{count} register =\@lastchclass=. +% All of the mentioned registers are already allocated in +% \texttt{latex.tex}, +% which is the reason why the following three lines of code are +% commented out. +% Later throughout the text I will not mention it again explicitly +% whenever I use a =%= sign. These parts are already defined in +% \texttt{latex.tex}. +% \begin{macrocode} +% \newcount \@chclass +% \newcount \@chnum +% \newcount \@lastchclass +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% +% +% +% \begin{macro}{\@addtopreamble} +% We will save the already constructed preamble for +% the =\halign= +% in the global macro =\@preamble=. This will then be +% enlarged with +% the command =\@addtopreamble=. +% \begin{macrocode} +\def\@addtopreamble#1{\xdef\@preamble{\@preamble #1}} +% \end{macrocode} +% \end{macro} +% +% +% +% +% +% \subsection{The character class of a \textsf{token}} +% +% \begin{macro}{\@testpach} +% \changes{v2.0a}{1989/05/12}{p option renamed to m (middle).} +% \changes{v2.0a}{1989/05/12}{t option renamed to p to be compatible to +% the original.} +% With the help of =\@lastchclass= we can now define a macro +% which determines the class and the number of a given preamble +% \textsf{token} +% and assigns them to the registers +% =\@chclass= and =\@chnum=. +% \changes{v2.0f}{1992/02/29}{Argument removed since implicitly known} +% \begin{macrocode} +\def\@testpach{\@chclass +% \end{macrocode} +% First we deal with the cases in which the \textsf{token} +% (=#1=) is the argument of \texttt{!}, \texttt{@}, \texttt{<} or +% \texttt{>}. We can see this from the value of =\@lastchclass=: +% \begin{macrocode} + \ifnum \@lastchclass=6 \@ne \@chnum \@ne \else + \ifnum \@lastchclass=7 5 \else + \ifnum \@lastchclass=8 \tw@ \else + \ifnum \@lastchclass=9 \thr@@ +% \end{macrocode} +% Otherwise we will assume that the \textsf{token} belongs to the +% class $0$ +% and assign the corresponding number to =\@chnum= if our +% assumption is correct. +% \begin{macrocode} + \else \z@ +% \end{macrocode} +% If the last \textsf{token} was a \texttt{p}, \texttt{m} or a +% \texttt{b}, =\@chnum= already has the right value. This is the +% reason for the somewhat curious choice of the \textsf{token} +% numbers in class $10$. +% \begin{macrocode} + \ifnum \@lastchclass = 10 \else +% \end{macrocode} +% Otherwise we will check if =\@nextchar= is either a \texttt{c}, +% \texttt{l} or an \texttt{r}. Some applications change the +% catcodes of certain characters like ``\texttt{@}'' in +% \texttt{amstex.sty}. As a result the tests below would fail since +% they assume non-active character tokens. Therefore we evaluate +% =\@nextchar= once thereby turning the first token of its +% replacement text into a char. At this point here this should have +% been the only char present in =\@nextchar= which put into via a +% =\def=. +% \changes{v2.0f}{1992/02/29}{Ensure to test a char which is not active} +% \begin{macrocode} + \edef\@nextchar{\expandafter\string\@nextchar}% + \@chnum + \if \@nextchar c\z@ \else + \if \@nextchar l\@ne \else + \if \@nextchar r\tw@ \else +% \end{macrocode} +% If it is a different \textsf{token}, we know that the class was +% not $0$. We assign the value $0$ to =\@chnum= because this value +% is needed for the \texttt{|}--\textsf{token}. Now we must check +% the remaining classes. Note that the value of =\@chnum= is +% insignificant here for most classes. +% \begin{macrocode} + \z@ \@chclass + \if\@nextchar |\@ne \else + \if \@nextchar !6 \else + \if \@nextchar @7 \else + \if \@nextchar <8 \else + \if \@nextchar >9 \else +% \end{macrocode} +% The remaining permitted \textsf{tokens} are \texttt{p}, +% \texttt{m} and \texttt{b} (class $10$). +% \begin{macrocode} + 10 + \@chnum + \if \@nextchar m\thr@@\else + \if \@nextchar p4 \else + \if \@nextchar b5 \else +% \end{macrocode} +% Now the only remaining possibility is a forbidden \textsf{token}, +% so we choose class $0$ and number $0$ and give an error message. +% Then we finish the macro by closing all =\if='s. +% \begin{macrocode} + \z@ \@chclass \z@ \@preamerr \z@ \fi \fi \fi \fi + \fi \fi \fi \fi \fi \fi \fi \fi \fi \fi \fi \fi} +% \end{macrocode} +% \end{macro} +% +% +% +% +% +% \subsection{Multiple columns ($*$--form)} +% +% \begin{macro}{\@xexpast} +% \begin{macro}{\the@toks} +% \begin{macro}{\the@toksz} +% \label{@xexpast} Now we discuss the macro that deletes all forms +% of type =*{=\textit{N\/}=}{=\textit{String\/}=}= from a user +% preamble and replaces them with \textit{N} copies of +% \textit{String}. Nested $*$--expressions are dealt with +% correctly, that means $*$--expressions are not substituted if +% they are in explicit braces, as in =@{*}=. +% +% This macro is called via +% =\@xexpast=\meta{preamble}=*0x\@@=. +% The $*$--expression =*0x= is being used to terminate the +% recursion, +% as we shall see later, and =\@@= serves as an argument +% delimiter. =\@xexpast= has four arguments. The first +% one is the part of the +% user preamble before the first $*$--expression while the second +% and third ones are the arguments of the first $*$--expression +% (that is \textit{N} and \textit{String} in the notation mentioned +% above). +% The fourth argument is the rest of the preamble. +% \begin{macrocode} +\def\@xexpast#1*#2#3#4\@@{% +% \end{macrocode} +% The number of copies of \textit{String} (=#2=) that are to be +% produced will be saved in a \textsf{count} register. +% \begin{macrocode} + \@tempcnta #2 +% \end{macrocode} +% We save the part of the preamble which does not +% contain a $*$--form (=#1=) +% in a \PlainTeX\ \textsf{token} register. +% We also save \textit{String} (=#3=) using a \LaTeX\ +% \textsf{token} register. +% \begin{macrocode} + \toks@={#1}\@temptokena={#3}% +% \end{macrocode} +% Now we have to use a little trick to produce \textit{N} copies of +% \textit{String}. +% We could try =\def\@tempa{#1}= and then +% \textit{N} times =\edef\@tempa{\@tempa#3}=. This would have the +% undesired effect that all macros within =#1= and =#3= +% would be expanded, although, for example, constructions like +% =@{..}= are not supposed to be changed. +% That is why we =\let= two control sequences to +% be equivalent to =\relax=. +% \begin{macrocode} + \let\the@toksz\relax \let\the@toks\relax +% \end{macrocode} +% Then we ensure that =\@tempa= contains +% ={\the@toksz\the@toks...\the@toks}= (the macro +% =\the@toks= exactly \textit{N\/} times) as substitution text. +% \begin{macrocode} + \def\@tempa{\the@toksz}% + \ifnum\@tempcnta >0 \@whilenum\@tempcnta >0\do + {\edef\@tempa{\@tempa\the@toks}\advance \@tempcnta \m@ne}% +% \end{macrocode} +% If \textit{N\/} was greater than zero we prepare for another call +% of =\@xexpast=. Otherwise we assume we have reached the end of +% the user preamble, because we had appended =*0x\@@= when we first +% called =\@xexpast=. In other words: if the user inserts +% =*{0}{..}= in his preamble, \LaTeX\ ignores the rest of it. +% \begin{macrocode} + \let \@tempb \@xexpast \else + \let \@tempb \@xexnoop \fi +% \end{macrocode} +% Now we will make sure that the part of the user preamble, which +% was already dealt with, will be saved again in =\@tempa=. +% \begin{macrocode} + \def\the@toksz{\the\toks@}\def\the@toks{\the\@temptokena}% + \edef\@tempa{\@tempa}% +% \end{macrocode} +% We have now evaluated the first $*$--expression, and the user +% preamble up to this point +% is saved in =\@tempa=. We will put the contents of +% =\@tempa= and the rest of the user preamble together and work +% on the result with =\@tempb=. This macro either corresponds +% to =\@xexpast=, so that the next +% $*$--expression is handled, or to the macro =\@xexnoop=, +% which only ends the recursion by deleting its argument. +% \begin{macrocode} + \expandafter \@tempb \@tempa #4\@@} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\@xexnoop} +% So the first big problem is solved. Now it is easy to +% specify =\@xexnoop=. +% Its argument is delimited by =\@@= and it simply expands to +% nothing. +% \begin{macrocode} +% \def\@xexnoop#1\@@{} +% \end{macrocode} +% \end{macro} +% +% +% +% +% \section{The insertion of declarations +% (\texttt{>}, \texttt{<}, \texttt{!}, \texttt{@})} +% +% +% The preamble will be enlarged with the help of =\xdef=, but the +% arguments of \texttt{>}, \texttt{<},~\texttt{!}\ and \texttt{@} are +% not supposed to be expanded during the construction (we want an +% implementation that doesn't need a =\protect=). So we have to find a +% way to inhibit the expansion of those arguments. +% +% We will solve this problem with \textsf{token} registers. We need +% one register for every \texttt{!}\ and \texttt{@}, while we need two +% for every \texttt{c}, \texttt{l}, \texttt{r}, \texttt{m}, \texttt{p} +% or \texttt{b}. This limits the number of columns of a table because +% there are only 256 \textsf{token} registers. But then, who needs +% tables with more than 100 columns? +% +% One could also find a solution which only needs two or three +% \textsf{token} registers by proceeding similarly as in the macro +% =\@xexpast= (see page \pageref{@xexpast}). The advantage of our +% approach is the fact that we avoid some of the problems that arise +% with the other method\footnote{Maybe there are also historical +% reasons.}. +% +% So how do we proceed? Let us assume that we had =!{foo}= in the +% user preamble and say we saved \texttt{foo} in +% \textsf{token} register $5$. Then we call +% =\@addtopreamble{\the@toks5}= where +% =\the@toks= is defined in a way that it does not expand +% (for example it could be equivalent to =\relax=). Every +% following call +% of =\@addtopreamble= leaves =\the@toks5= unchanged in +% =\@preamble=. If the construction of the preamble is completed +% we change the definition of =\the@toks= to +% =\the\toks= and expand =\@preamble= for the last time. +% During this process all parts of the form +% =\the@toks=\meta{Number} +% will be substituted by the contents of the respective \textsf{token} +% registers. +% +% As we can see from this informal discussion the construction of the +% preamble has to take place within a group, so that the +% \textsf{token} registers we use will be freed later on. For that +% reason we keep all assignments to =\@preamble= global; therefore the +% replacement text of this macro will remain the same after we leave +% the group. +% +% \begin{macro}{\count@} +% We further need a \textsf{count} register to remember which +% \textsf{token} register is to be used next. This will be +% initialized with $-1$ if we want to begin with the \textsf{token} +% register $0$. We use the \PlainTeX\ scratch register =\count@= +% because everything takes place locally. All we have to do is +% insert =\the@toks= =\the= =\count@= into the preamble. +% =\the@toks= will remain unchanged and =\the\count@= expands into +% the saved number. +% \end{macro} +% +% \begin{macro}{\prepnext@tok} +% The macro =\prepnext@tok= is in charge of preparing the next +% \textsf{token} register. For that purpose we increase +% =\count@= by $1$: +% \begin{macrocode} +\def\prepnext@tok{\advance \count@ \@ne +% \end{macrocode} +% Then we locally delete any contents the +% \textsf{token} register might have. +% \begin{macrocode} + \toks\count@{}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\save@decl} +% During the construction of the preamble the current +% \textsf{token} is always saved in the macro =\@nextchar= (see the +% definition of =\@mkpream= on page \pageref{@mkpream}). The macro +% =\save@decl= saves it into the next free \textsf{token} register, +% i.e.\ in =\toks\count@=. +% \changes{v2.0c}{1990/08/14}{\cs{relax} removed and added elsewhere.} +% \begin{macrocode} +\def\save@decl{\toks\count@ \expandafter{\@nextchar}} +% \end{macrocode} +% The reason for the use of =\relax= is the following +% hypothetical situation in the preamble: +% \quad =..\the\toks1\the\toks2..= \quad \TeX\ expands +% =\the\toks2= first in order to find out if the digit =1= +% is followed by other digits. E.g.\ a =5= saved in the +% \textsf{token} register $2$ would lead \TeX\ to insert the contents +% of \textsf{token} register $15$ instead of $1$ later on. +% +% The example above referred to an older version of =\save@decl= which +% inserted a =\relex= inside the token register. This is now moved to +% the places where the actual token registers are inserted (look for +% =\the@toks=) because the old version would still make =@= +% expressions to moving arguments since after expanding the second +% register while looking for the end of the number the contents of the +% token register is added so that later on the whole register will be +% expanded. This serious bug was found after nearly two years +% international use of this package by Johannes Braams. +% \end{macro} +% +% +% +% How does the situation look like, if we want to add another column +% to the preamble, i.e.\ if we have found a \texttt{c}, \texttt{l}, +% \texttt{r}, \texttt{p}, \texttt{m} or \texttt{b} in the user +% preamble? In this case we have the problem of the \textsf{token} +% register from =>{..}= and =<{..}= having to be inserted at this +% moment because formatting instructions like =\hfil= have to be set +% around them. On the other hand it is not known yet, if any =<{..}= +% instruction will appear in the user preamble at all. +% +% We solve this problem by adding two \textsf{token} registers at a +% time. This explains, why we have freed the \textsf{token} registers +% in =\prepnext@tok=. +% +% \begin{macro}{\insert@column} +% \begin{macro}{\@sharp} +% We now define the macro =\insert@column= which will do +% this work for us. +% \begin{macrocode} +\def\insert@column{% +% \end{macrocode} +% Here, we assume that the \textsf{count} register +% =\@tempcnta= has saved the value $=\count@= - 1$. +% \begin{macrocode} + \the@toks \the \@tempcnta +% \end{macrocode} +% Next follows the =#= sign which specifies the place +% where the text of the column shall be inserted. To avoid +% errors during the expansions in +% =\@addtopreamble= we hide this sign in the command +% =\@sharp= which is temporarily occupied with +% =\relax= during the build-up of the preamble. +% To remove unwanted spaces before and after the column text, we set +% an =\ignorespaces= in front and a =\unskip= afterwards. +% \changes{v2.0e}{1991/02/07}{Added \{\} around \cs{@sharp} for new ftsel} +% \changes{v2.0h}{1992/06/22}{Removed \{\} again in favour of +% \cs{d@llarbegin}} +% \begin{macrocode} + \ignorespaces \@sharp \unskip +% \end{macrocode} +% Then the second \textsf{token} register follows whose number should +% be saved in =\count@=. +% We make sure that there will be no further expansion after reading +% the number, by finishing with =\relax=. The case above is not +% critical since it is ended by =\ignorespaces=. +% \changes{v2.0c}{1990/08/14}{\cs{relax} added to avoid problem +% \cs{the}\cs{toks0}\cs{the}\cs{toks1}.} +% \begin{macrocode} + \the@toks \the \count@ \relax} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% +% +% +% \subsection{The separation of columns} +% +% \begin{macro}{\@addamp} +% In the preamble a =&= has to be inserted between any two columns; +% before the first column there should not be a =&=. As the user +% preamble may start with a \texttt{|} we have to remember somehow +% if we have already inserted a =#= (i.e.\ a column). This is done +% with the boolean variable =\if@firstamp= that we test in +% =\@addamp=, the macro that inserts the =&=. +% \begin{macrocode} +% \newif \@iffirstamp +% \def\@addamp{\if@firstamp \@firstampfalse +% \else \@addtopreamble &\fi} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@acol} +% \begin{macro}{\@acolampacol} +% \begin{macro}{\col@sep} +% We will now define some abbreviations for the extensions, +% appearing most often in the preamble build-up. +% Here =\col@sep= is a \textsf{dimen} register which is set +% equivalent to =\arraycolsep= in an \textsf{array}--environment, +% otherwise it is set equivalent to =\tabcolsep=. +% \begin{macrocode} +\newdimen\col@sep +\def\@acol{\@addtopreamble{\hskip\col@sep}} +% \def\@acolampacol{\@acol\@addamp\@acol} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% +% +% \subsection{The macro \texttt{\textbackslash @mkpream}} +% +% \begin{macro}{\@mkpream} +% \emph{The code below has been replaced long time ago by an +% extended version further down but the code and its documentation +% was left here for reference. It is now commented out to avoid +% confusion.} +% \begin{macro}{\the@toks} +% \label{@mkpream} +% Now we can define the macro which builds up the preamble for the +% =\halign=. +% First we initialize =\@preamble=, =\@lastchclass= +% and the boolean variable =\if@firstamp=. +% \begin{macrocode} +%\def\@mkpream#1{\gdef\@preamble{}\@lastchclass 4 \@firstamptrue +% \end{macrocode} +% During the build-up of the preamble we cannot directly use the +% =#= sign; this would lead to an error message in the next +% =\@addtopreamble= call. +% Instead, we use the command =\@sharp= at places where later +% a =#= will be. +% This command is at first given the meaning =\relax=; +% therefore it will not be expanded when the preamble +% is extended. +% In the macro =\@array=, shortly before the =\halign= +% is carried out, =\@sharp= is given its final meaning. +% +% In a similar way, +% we deal with the commands =\@startpbox= and +% =\@endpbox=, although the reason is different here: these +% macros expand in many \textsf{tokens} which would delay the +% build-up of the preamble. +% \begin{macrocode} +% \let\@sharp\relax\let\@startpbox\relax\let\@endpbox\relax +% \end{macrocode} +% Two more are needed to deal with the code that handles struts +% for extra space after a row from =\\[<space>]= +% (=\do@row@strut=) and code that manages m-cells depending on +% their heights (=\ar@align@mcell=). +% \changes{v2.4e}{2016/10/07}{Fixing SX68732} +% \changes{v2.4f}{2017/11/04}{Managing m-cells without \cs{vcenter}} +% \begin{macrocode} +% \let\do@row@strut\relax +% \let\ar@align@mcell\relax +% \end{macrocode} +% Now we remove possible $*$-forms in the user preamble with the +% command =\@xexpast=. As we already know, this command saves +% its result in the macro =\@tempa=. +% \begin{macrocode} +% \@xexpast #1*0x\@@ +% \end{macrocode} +% Afterwards we initialize all registers and macros, that we need +% for the build-up of the preamble. +% Since we want to start with the \textsf{token} register $0$, +% =\count@= has to contain the value $-1$. +% \begin{macrocode} +% \count@\m@ne +% \let\the@toks\relax +% \end{macrocode} +% Then we call up =\prepnext@tok= in order to prepare the +% \textsf{token} register $0$ for use. +% \begin{macrocode} +% \prepnext@tok +% \end{macrocode} +% To evaluate the user preamble (without stars) saved in +% =\@tempa= we use the \LaTeX--macro =\@tfor=. +% The strange appearing construction with =\expandafter= is +% based on the fact that we have to put the replacement text of +% =\@tempa= and not the macro =\@tempa= to this +% \LaTeX--macro. +% \begin{macrocode} +% \expandafter \@tfor \expandafter \@nextchar +% \expandafter :\expandafter =\@tempa \do +% \end{macrocode} +% The body of this loop (the group after the =\do=) +% is executed for one \textsf{token} at a time, whereas +% the current \textsf{token} is saved in =\@nextchar=. +% At first we evaluate the current \textsf{token} with the already +% defined macro =\@testpach=, i.e.\ we assign to +% =\@chclass= the character class and to =\@chnum= +% the character number of this \textsf{token}. +% \changes{v2.0f}{1992/02/29}{\cs{@testpach} now without arg} +% \begin{macrocode} +% {\@testpach +% \end{macrocode} +% Then we branch out depending on the value of =\@chclass= into +% different macros that extend the preamble respectively. +% \begin{macrocode} +% \ifcase \@chclass \@classz \or \@classi \or \@classii +% \or \save@decl \or \or \@classv \or \@classvi +% \or \@classvii \or \@classviii \or \@classix +% \or \@classx \fi +% \end{macrocode} +% Two cases deserve our special attention: Since the current +% \textsf{token} cannot have the character class $4$ (start) we +% have skipped this possibility. If the character class is $3$, +% only the content of =\@nextchar= has to be saved into the current +% \textsf{token} register; therefore we call up =\save@decl= +% directly and save a macro name. After the preamble has been +% extended we assign the value of =\@chclass= to the counter +% =\@lastchclass= to assure that this information will be available +% during the next run of the loop. +% \begin{macrocode} +% \@lastchclass\@chclass}% +% \end{macrocode} +% After the loop has been finished space must still be added to +% the created preamble, depending on the last \textsf{token}. +% Depending on the value of =\@lastchclass= we perform +% the necessary operations. +% \begin{macrocode} +% \ifcase\@lastchclass +% \end{macrocode} +% If the last class equals $0$ we add a +% =\hskip \col@sep=. +% \begin{macrocode} +% \@acol \or +% \end{macrocode} +% If it equals $1$ we do not add any additional space so that the +% horizontal lines do not exceed the vertical ones. +% \begin{macrocode} +% \or +% \end{macrocode} +% Class $2$ is treated like class $0$ because a =<{...}= can +% only directly follow after class $0$. +% \begin{macrocode} +% \@acol \or +% \end{macrocode} +% Most of the other possibilities can only appear if the user +% preamble was defective. Class $3$ is not allowed since after a +% =>{..}= there must always follow a \texttt{c}, \texttt{l}, +% \texttt{r}, \texttt{p},\texttt{m} or \texttt{b}. We report an +% error and ignore the declaration given by ={..}=. +% \begin{macrocode} +% \@preamerr \thr@@ \or +% \end{macrocode} +% If =\@lastchclass= is $4$ the user preamble has been empty. +% To continue, we insert a =#= in the preamble. +% \begin{macrocode} +% \@preamerr \tw@ \@addtopreamble\@sharp \or +% \end{macrocode} +% Class $5$ is allowed again. In this case +% (the user preamble ends with =@{..}=) we need not +% do anything. +% \begin{macrocode} +% \or +% \end{macrocode} +% Any other case means that the arguments to =@=, \texttt{!}, +% \texttt{<}, \texttt{>}, \texttt{p}, \texttt{m} or \texttt{b} have +% been forgotten. So we report an error and ignore the last +% \textsf{token}. +% \begin{macrocode} +% \else \@preamerr \@ne \fi +% \end{macrocode} +% Now that the build-up of the preamble is almost finished we can +% insert the \textsf{token} registers and therefore redefine +% =\the@toks=. The actual insertion, though, is performed +% later. +% \begin{macrocode} +% \def\the@toks{\the\toks}} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% +% +% \section{The macros \texttt{\textbackslash @classz} +% to \texttt{\textbackslash @classx}} +% +% The preamble is extended by the macros =\@classz= to +% =\@classx= which are called by =\@mkpream= +% depending on =\@lastchclass= +% (i.e. the character class of the last \textsf{token}). +% \begin{macro}{\@classx} +% First we define =\@classx= because of its important r\^ole. +% When it is called we find that the current +% \textsf{token} is \texttt{p}, \texttt{m} or \texttt{b}. +% That means that a new column has to start. +% \begin{macrocode} +\def\@classx{% +% \end{macrocode} +% Depending on the value of =\@lastchclass= different actions +% must take place: +% \begin{macrocode} + \ifcase \@lastchclass +% \end{macrocode} +% If the last character class was $0$ we separate the columns by +% =\hskip\col@sep= followed by =&= and another +% =\hskip\col@sep=. +% \begin{macrocode} + \@acolampacol \or +% \end{macrocode} +% If the last class was class $1$ --- that means that a vertical +% line was +% drawn, --- before this line a =\hskip\col@sep= was inserted. +% Therefore there has to be only a =&= followed by +% =\hskip\col@sep=. But this =&= may be inserted only +% if this is not the first column. This process is controlled +% by =\if@firstamp= in the macro =\addamp=. +% \begin{macrocode} + \@addamp \@acol \or +% \end{macrocode} +% Class $2$ is treated like class $0$ because =<{...}= can only +% follow after class $0$. +% \begin{macrocode} + \@acolampacol \or +% \end{macrocode} +% Class $3$ requires no actions because all things necessary have +% been done by the preamble \textsf{token} \texttt{>}. +% \begin{macrocode} + \or +% \end{macrocode} +% Class $4$ means that we are at the beginning of the preamble. +% Therefore we start the preamble with =\hskip\col@sep= and +% then call =\@firstampfalse=. This makes sure that a later +% =\@addamp= inserts the character +% =&= into the preamble. +% \begin{macrocode} + \@acol \@firstampfalse \or +% \end{macrocode} +% For class $5$ \textsf{tokens} only the character =&= is inserted +% as a column separator. Therefore we call =\@addamp=. +% \begin{macrocode} + \@addamp +% \end{macrocode} +% Other cases are impossible. For an example +% $=\@lastchclass= \string= 6$---as it might appear in a +% preamble of the form =...!p...=---\texttt{p} would have +% been taken as an argument of \texttt{!}\ by =\@testpach=. +% \begin{macrocode} + \fi} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\@classz} +% If the character class of the last \textsf{token} is $0$ we have +% \texttt{c}, \texttt{l}, \texttt{r} or an argument of \texttt{m}, +% \texttt{b} or\ \texttt{p}. In the first three cases the preamble +% must be extended the same way as if we had class $10$. The +% remaining two cases do not require any action because the space +% needed was generated by the last \textsf{token} (i.e.\ +% \texttt{m}, \texttt{b} or \texttt{p}). Since =\@lastchclass= has +% the value $10$ at this point nothing happens when =\@classx= is +% called. So the macro =\@chlassz= may start like this: +% \begin{macrocode} +\def\@classz{\@classx +% \end{macrocode} +% According to the definition of =\insert@column= we must store +% the number of the \textsf{token} register in which a preceding +% =>{..}= might have stored its argument into +% =\@tempcnta=. +% \begin{macrocode} + \@tempcnta \count@ +% \end{macrocode} +% To have $=\count@= \string= =\@tmpcnta= + 1$ we prepare +% the next \textsf{token} register. +% \begin{macrocode} + \prepnext@tok +% \end{macrocode} +% Now the preamble must be extended with the column whose format +% can be determined by =\@chnum=. +% \begin{macrocode} + \@addtopreamble{\ifcase \@chnum +% \end{macrocode} +% If =\@chnum= has the value $0$ a centered column has to be +% generated. +% So we begin with stretchable space. +% \begin{macrocode} + \hfil +% \end{macrocode} +% We also add a space of 1sp just in case the first thing in the +% cell is a command doing an =\unskip=. +% \changes{v2.4k}{2018/12/30}{Add extra \cs{hskip} to guard against an +% \cs{unskip} at the start of a c-column cell (gh/102)} +% \begin{macrocode} + \hskip1sp% +% \end{macrocode} +% The command =\d@llarbegin= follows expanding into =\begingroup= +% (in the \textsf{tabular}--environment) or into =$=. Doing this +% (provided an appropriate setting of =\d@llarbegin=) we achieve +% that the contents of the columns of an \textsf{array}--environment +% are set in math mode while those of a \textsf{tabular}--environment +% are set in LR mode. +% \begin{macrocode} + \d@llarbegin +% \end{macrocode} +% Now we insert the contents of the two \textsf{token} registers +% and the symbol +% for the column entry (i.e.\ =#= or +% more precise =\@sharp=) using =\insert@column=. +% \begin{macrocode} + \insert@column +% \end{macrocode} +% We end this case with =\d@llarend= and =\hfil= where =\d@llarend= +% again is either =$= or =\endgroup=. +% The strut to enforce a regular row height is placed between the two. +% \changes{v2.4e}{2016/10/07}{Fixing SX68732} +% \begin{macrocode} + \d@llarend \do@row@strut \hfil \or +% \end{macrocode} +% The templates for \texttt{l} and \texttt{r} (i.e.\ =\@chnum= $1$ +% or $2$) are generated the same way. Since one =\hfil= is +% missing the text is moved to the relevant side. +% The =\kern\z@= is needed in case of an empty column +% entry. Otherwise +% the =\unskip= in =\insert@column= removes the +% =\hfil=. Changed to =\hskip1sp= so that it interacts better with +% =\@bsphack=. +% \changes{v2.3f}{1996/04/22} +% {(DPC) Extra \cs{kern} keeps tabcolsep in empty l columns +% internal/2122} +% \changes{v2.3i}{1996/06/14} +% {Change both \cs{kern}\cs{z@} to \cs{hskip}1sp for latex/2160} +% \changes{v2.4e}{2016/10/07}{Fixing SX68732} +% \begin{macrocode} + \hskip1sp\d@llarbegin \insert@column \d@llarend \do@row@strut \hfil \or + \hfil\hskip1sp\d@llarbegin \insert@column \d@llarend \do@row@strut \or +% \end{macrocode} +% The templates for \texttt{p}, \texttt{m} and \texttt{b} mainly +% consist of a \textsf{box}. In case of \texttt{m} it is generated +% by =\vcenter=. This command is allowed only in math +% mode. Therefore we start with a~=$=. +% \changes{v2.4f}{2017/11/04}{Managing m-cells without \cs{vcenter}} +% \begin{macrocode} + \setbox\ar@mcellbox\vbox +% \end{macrocode} +% The part of the templates which is the same in all three cases +% (\texttt{p}, \texttt{m} and \texttt{b}) +% is built by the macros =\@startpbox= and +% =\@endpbox=. =\@startpbox= has an argument: +% the width of the column which is stored in the current +% \textsf{token} (i.e.\ =\@nextchar=). +% Between these two macros we find the well known +% =\insert@column=. +% The strut is places after the box +% \changes{v2.4e}{2016/10/07}{Fixing SX68732} +% \changes{v2.4f}{2017/11/04}{Managing m-cells without \cs{vcenter}} +% \begin{macrocode} + \@startpbox{\@nextchar}\insert@column \@endpbox + \ar@align@mcell + \do@row@strut \or +% \end{macrocode} +% The templates for \texttt{p} and \texttt{b} are generated in the +% same way though we do not need the =$= characters because we use +% =\vtop= or =\vbox=. +% \changes{v2.4e}{2016/10/07}{Fixing SX68732} +% \begin{macrocode} + \vtop \@startpbox{\@nextchar}\insert@column \@endpbox\do@row@strut \or + \vbox \@startpbox{\@nextchar}\insert@column \@endpbox\do@row@strut +% \end{macrocode} +% Other values for =\@chnum= are impossible. Therefore we +% end the arguments to =\@addtopreamble= and =\ifcase=. +% Before we come to the end of =\@classz= we have to +% prepare the next \textsf{token} register. +% \begin{macrocode} + \fi}\prepnext@tok} +% \end{macrocode} +% \end{macro} +% + +% +% \begin{macro}{\ar@mcellbox} +% When dealing with m-cells we need a box to measure the cell +% height. +% \changes{v2.4f}{2017/11/04}{Managing m-cells without \cs{vcenter}} +% \begin{macrocode} +\newbox\ar@mcellbox +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\ar@align@mcell} +% M-cells are supposed to be vertically centered within the table +% row. In the original implementation that was done using +% =\vcenter= but the issue with that approach is that it centers +% the material based on the math-axis. In most situations that +% comes out quit right, but if, for example, an m-cell has only a +% single line worth of material inside it will be positioned +% differently to a =l=, =c= or =r= cell or to a =p= or =b= cell +% with the same content. +% +% For that reason the new implementation does the centering +% manually: First we check the height of the cell and if that is +% less or equal to =\ht\@arstrutbox= we assume that this is a +% single line cell. In that case we don't do any vertical maneuvre +% and simply output the box, i.e., make it behave like a single +% line p-cell. +% \changes{v2.4f}{2017/11/04}{Managing m-cells without \cs{vcenter}} +% \begin{macrocode} +\def\ar@align@mcell{% + \ifdim \ht\ar@mcellbox > \ht\@arstrutbox +% \end{macrocode} +% Otherwise we realign vertically by lowering the box. The question +% is how much do we need to move down? If there is any +% =\arraystretch= in place then the first line will have some +% unusual height and we don't want to consider that when finding +% the middle point. So we substract from the cell height the height +% of that strut. But of course we want to include the normal height +% of the first line (which would be something like =\ht\strutbox=) +% so we need to add that. On the other hand, when centering around +% the mid-point of the cell, we also need to account for the depth +% of the last line (which is nominally something like +% =\dp\strutbox=). Both together equals =\baselineskip= so that is +% what we add and then lower the cell by half of the resulting value. +% \begin{macrocode} + \begingroup + \dimen@\ht\ar@mcellbox + \advance\dimen@-\ht\@arstrutbox + \advance\dimen@\baselineskip + \lower.5\dimen@\box\ar@mcellbox + \endgroup + \else % assume one line and align at baseline + \box\ar@mcellbox + \fi} +% \end{macrocode} +% \end{macro} +% + +% +% \begin{macro}{\@classix} +% \emph{The code below has been replaced long time ago by an +% extended version further down but the code and its documentation +% was left here for reference. It is now commented out to avoid +% confusion.} +% +% In case of class $9$ (\texttt{>}--\textsf{token}) we first check +% if the character class of the last +% \textsf{token} was $3$. In this case we have a +% user preamble of the form =..>{...}>{...}..= which +% is not allowed. We only give an error message and continue. +% So the declarations defined by the first =>{...}= +% are ignored. +% \begin{macrocode} +%\def\@classix{\ifnum \@lastchclass = \thr@@ +% \@preamerr \thr@@ \fi +% \end{macrocode} +% Furthermore, we call up =\@class10= because afterwards always a +% new column is started by \texttt{c}, \texttt{l}, \texttt{r}, +% \texttt{p}, \texttt{m} or \texttt{b}. +% \begin{macrocode} +% \@classx} +% \end{macrocode} +% \end{macro} +% +% +% +% \begin{macro}{\@classviii} +% \emph{The code below has been replaced long time ago by an +% extended version further down but the code and its documentation +% was left here for reference. It is now commented out to avoid +% confusion.} +% +% If the current \textsf{token} is a \texttt{<} the last character +% class must be $0$. In this case it is not necessary to extend the +% preamble. Otherwise we output an error message, set =\@chclass= +% to $6$ and call =\@classvi=. By doing this we achieve that +% \texttt{<} is treated like \texttt{!}. +% \begin{macrocode} +%\def\@classviii{\ifnum \@lastchclass >\z@ +% \@preamerr 4\@chclass 6 \@classvi \fi} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@arrayrule} +% There is only one incompatibility with the original definition: +% the definition of =\@arrayrule=. In the original a line without +% width\footnote{So the space between \texttt{cc} and \texttt{c|c} +% is equal.} is created by multiple insertions of +% =\hskip .5\arrayrulewidth=. +% We only insert a vertical line into the +% preamble. This is done to prevent problems with \TeX's main +% memory when generating tables with many vertical lines in them +% (especially in the case of \textsf{floats}). +% \begin{macrocode} +\def\@arrayrule{\@addtopreamble \vline} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@classvii} +% As a consequence it follows that in case of class $7$ +% (=@= \textsf{token}) the preamble need not to be extended. +% In the original definition $=\@lastchclass= \string= 1$ +% is treated by inserting =\hskip .5\arrayrulewidth=. +% We only check if the last \textsf{token} was of class $3$ which is +% forbidden. +% \begin{macrocode} +\def\@classvii{\ifnum \@lastchclass = \thr@@ +% \end{macrocode} +% If this is true we output an error message and +% ignore the declarations stored +% by the last =>{...}=, because these are overwritten +% by the argument of \texttt{@}. +% \begin{macrocode} + \@preamerr \thr@@ \fi} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\@classvi} +% If the current \textsf{token} is a regular \texttt{!}\ and the +% last class was $0$ or $2$ we extend the preamble with +% =\hskip\col@sep=. If the last \textsf{token} was of class $1$ +% (for instance \texttt{|}) we extend with =\hskip \doublerulesep= +% because the construction =!{...}= has to be treated like +% \texttt{|}. +% \begin{macrocode} +\def\@classvi{\ifcase \@lastchclass + \@acol \or + \@addtopreamble{\hskip \doublerulesep}\or + \@acol \or +% \end{macrocode} +% Now =\@preamerr...= should follow because a +% user preamble of the form =..>{..}!.= is not allowed. +% To save memory we call =\@classvii= instead which also +% does what we want. +% \begin{macrocode} + \@classvii +% \end{macrocode} +% If =\@lastchclass= is $4$ or $5$ nothing has to be done. +% Class $6$ to $10$ are not possible. +% So we finish the macro. +% \begin{macrocode} + \fi} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@classii} +% \begin{macro}{\@classiii} +% In the case of character classes $2$ and $3$ (i.e.\ the argument +% of \texttt{<} or \texttt{>}) we only have to store the current +% \textsf{token} (=\@nextchar=) into the corresponding +% \textsf{token} register since the preparation and +% insertion of these registers +% are done by the macro =\@classz=. +% This is equivalent to calling =\save@decl= in the case of +% class $3$. To save command identifiers we do this call up +% in the macro =\@mkpream=. +% +% Class $2$ exhibits a more complicated situation: the +% \textsf{token} registers have already been inserted by +% =\@classz=. So the value of =\count@= is too high +% by one. Therefore we decrease =\count@= by $1$. +% \begin{macrocode} +\def\@classii{\advance \count@ \m@ne +% \end{macrocode} +% Next we store the current \textsf{token} into the correct +% \textsf{token} register by calling =\save@decl= and then +% increase the value of =\count@= again. At this point we +% can save memory once more (at the cost of time) if we use the +% macro =\prepnext@tok=. +% \begin{macrocode} + \save@decl\prepnext@tok} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% +% \begin{macro}{\@classv} +% \emph{The code below has been replaced long time ago by an +% extended version further down but the code and its documentation +% was left here for reference. It is now commented out to avoid +% confusion.} +% +% If the current \textsf{token} is of class $5$ then it is an +% argument of a \texttt{@} \textsf{token}. It must be stored into a +% \textsf{token} register. +% \begin{macrocode} +%\def\@classv{\save@decl +% \end{macrocode} +% We extend the preamble with a command which inserts this +% \textsf{token} register into the preamble when its construction +% is finished. The user expects that this argument is worked out in +% math mode if it was used in an +% \textsf{array}--environment. Therefore we surround it with +% =\d@llar...='s. +% \changes{v2.0c}{1990/08/14}{\cs{relax} added to avoid problem +% `the`toks0`the`toks1.} +% \begin{macrocode} +% \@addtopreamble{\d@llarbegin\the@toks\the\count@\relax\d@llarend}% +% \end{macrocode} +% Finally we must prepare the next \textsf{token} register. +% \begin{macrocode} +% \prepnext@tok} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@classi} +% In the case of class $0$ we were able to generate the necessary +% space between columns by using the macro =\@classx=. +% Analogously the macro =\@classvi= can be used for class $1$. +% \begin{macrocode} +\def\@classi{\@classvi +% \end{macrocode} +% Depending on =\@chnum= a vertical line +% \begin{macrocode} + \ifcase \@chnum \@arrayrule \or +% \end{macrocode} +% or (in case of =!{...}=) the current \textsf{token} --- stored +% in =\@nextchar= --- has to be inserted into the preamble. +% This corresponds to calling =\@classv=. +% \begin{macrocode} + \@classv \fi} +% \end{macrocode} +% \end{macro} +% +% +% +% \begin{macro}{\@startpbox} +% In =\@classz= the macro =\@startpbox= is used. +% The width of the \textsf{parbox} is passed as an argument. +% =\vcenter=, =\vtop= or =\vbox= are already in the +% preamble. So we start with the braces for the wanted box. +% \changes{v2.4i}{2018/09/13}{Add group to prevent color leak (gh/72)} +% \begin{macrocode} +\def\@startpbox#1{\bgroup + \color@begingroup +% \end{macrocode} +% The argument is the width of the box. This information has to be +% assigned to =\hsize=. +% Then we assign default values to several parameters used in a +% \textsf{parbox}. +% \changes{v2.3k}{1998/05/12}{Use \cs{setlength} to set \cs{hsize}, +% so that the calc package can be applied here (pr/2793)} +% \begin{macrocode} + \setlength\hsize{#1}\@arrayparboxrestore +% \end{macrocode} +% Our main problem is to obtain the same distance between succeeding +% lines of the \textsf{parbox}. +% We have to remember that the distance between two \textsf{parboxes} +% should be defined by =\@arstrut=. That means that it can be +% greater than the distance in a \textsf{parbox}. +% Therefore it is not enough to set a =\@arstrut= at the +% beginning and at the end of the \textsf{parbox}. This would +% dimension the distance +% between first and second line and the distance between the two +% last lines of the \textsf{parbox} wrongly. +% To prevent this we set an invisible rule of height +% =\@arstrutbox= +% at the beginning of the \textsf{parbox}. This has no effect on the +% depth of the first line. At the end of the \textsf{parbox} we set +% analogously another invisible rule which only affects the depth +% of the last line. It is necessary to wait inserting this strut +% until the paragraph actually starts to allow for things like +% =\parindent= changes via =>{...}=. +% \changes{v2.1c}{1992/12/14}{Use `everypar to insert strut} +% \begin{macrocode} + \everypar{% + \vrule \@height \ht\@arstrutbox \@width \z@ + \everypar{}}% + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@endpbox} +% If there are any declarations defined by =>{...}= +% and =<{...}= +% they now follow in the macro =\@classz= --- the contents +% of the column in between. +% So the macro =\@endpbox= must insert the \textsf{specialstrut} +% mentioned earlier and then close the group opened by +% =\@startpbox=. +% \changes{v2.2d}{1994/05/16}{Use \LaTeXe \cs{@finalstrut}} +% \changes{v2.3g}{1996/05/07}{Add \cs{hfil} for tools/2120} +% \changes{v2.4i}{2018/09/13}{Add group to prevent color leak (gh/72)} +% \begin{macrocode} +\def\@endpbox{\@finalstrut\@arstrutbox \color@endgroup \egroup\hfil} +% \end{macrocode} +% \end{macro} +% +% +% \section{Building and calling \texttt{\textbackslash halign}} +% +% \begin{macro}{\@array} +% After we have discussed the macros needed for the evaluation +% of the user preamble we can define the macro =\@array= +% which uses these macros to create a =\halign=. +% It has two arguments. The first one is a position argument +% which can be \texttt{t}, \texttt{b} or \texttt{c}; the +% second one describes the wanted preamble, +% e.g.\ it has the form =|c|c|c|=. +% \begin{macrocode} +\def\@array[#1]#2{% +% \end{macrocode} +% First we define a \textsf{strut} whose size basically corresponds +% to a normal \textsf{strut} multiplied by the factor +% =\arraystretch=. +% This \textsf{strut} is then inserted into every row and enforces +% a minimal distance between two rows. +% Nevertheless, when using horizontal lines, large letters +% (like accented capital letters) still collide with such lines. +% Therefore at first we add to the height of a normal \textsf{strut} +% the value of the parameter =\extrarowheight=. +% \begin{macrocode} + \@tempdima \ht \strutbox + \advance \@tempdima by\extrarowheight + \setbox \@arstrutbox \hbox{\vrule + \@height \arraystretch \@tempdima + \@depth \arraystretch \dp \strutbox + \@width \z@}% +% \end{macrocode} +% Then we open a group, in which the user preamble is evaluated by +% the macro =\@mkpream=. As we know this must happen locally. +% This macro creates a preamble for a =\halign= and saves +% its result globally in the control sequence =\@preamble=. +% \begin{macrocode} + \begingroup + \@mkpream{#2}% +% \end{macrocode} +% We again redefine =\@preamble= so that a call up of =\@preamble= +% now starts the =\halign=. Thus also the arguments of \texttt{>}, +% \texttt{<}, \texttt{@} and \texttt{!}, saved in the +% \textsf{token} registers are inserted into the preamble. The +% =\tabskip= at the beginning and end of the preamble is set to +% \textsf{0pt} (in the beginning by the use of =\ialign=). Also the +% command =\@arstrut= is build in, which inserts the +% =\@arstrutbox=, defined above. Of course, the opening brace after +% =\ialign= has to be implicit as it will be closed in =\endarray= +% or another macro. +% \changes{v2.3m}{1998/12/31}{Added \cs{noexpand} in front of \cs{ialign} +% to guard against interesting :-) changes to \cs{halign} done to support +% text glyphs in math} +% +% The =\noexpand= in front of =\ialign= does no harm in standard \LaTeX{} +% and was added since some experimental support for using text glyphs in math +% redefines =\halign= with the result that is becomes expandable with +% disastrous results in cases like this. +% In the kernel definition for this macro the problem does +% not surface because there =\protect= is set (which is not necessary in this +% implementation as there is no arbitrary user input that can get expanded) and +% the experimental code made the redefinition robust. Whether this is the right +% approach is open to question; consider the =\noexpand= a courtesy to allow an +% unsupported redefinition of a \TeX{} primitive for the moment (as people rely +% on that experimental code). +% \begin{macrocode} + \xdef\@preamble{\noexpand \ialign \@halignto + \bgroup \@arstrut \@preamble + \tabskip \z@ \cr}% +% \end{macrocode} +% What we have not explained yet is the macro =\@halignto= +% that was just used. Depending on its replacement text the +% =\halign= becomes a =\halign= \texttt{to} \meta{dimen}. +% Now we close the group again. Thus +% =\@startpbox= and =\@endpbox= as well as all +% \textsf{token} registers get their former meaning back. +% \begin{macrocode} + \endgroup +% \end{macrocode} +% To support the \texttt{delarray.sty} package we include a hook +% into this part of the code which is a no-op in the main package. +% \changes{v2.1a}{1992/07/03}{Hook for delarray added} +% \begin{macrocode} + \@arrayleft +% \end{macrocode} +% Now we decide depending on the position argument in which +% \textsf{box} the =\halign= is to be put. (=\vcenter= may be used +% because we are in math mode.) +% \changes{v2.1a}{1992/07/03}{Wrong spec is now equiv to [t]} +% \begin{macrocode} + \if #1t\vtop \else \if#1b\vbox \else \vcenter \fi \fi +% \end{macrocode} +% Now another implicit opening brace appears; then definitions +% which shall stay local follow. While constructing the +% =\@preamble= in =\@mkpream= the =#= sign must be +% hidden in the macro =\@sharp= which is =\let= to +% =\relax= at that moment (see definition of =\@mkpream= +% on page~\pageref{@mkpream}). +% All these now get their actual meaning. +% \begin{macrocode} + \bgroup + \let \@sharp ##\let \protect \relax +% \end{macrocode} +% With the above defined \textsf{struts} we fix down the distance +% between rows by setting =\lineskip= and =\baselineskip= +% to \textsf{0pt}. Since there have to be set =$='s +% around every column in the \textsf{array}--environment +% the parameter =\mathsurround= should +% also be set to \textsf{0pt}. This prevents additional space between +% the rows. The +% \PlainTeX--macro =\m@th= does this. +% \begin{macrocode} + \lineskip \z@ + \baselineskip \z@ + \m@th +% \end{macrocode} +% Beside, we have to assign a special meaning (which we still have +% to specify) to the line separator =\\=. We also have to +% redefine the command =\par= in such a way that empty lines in +% =\halign= cannot do any damage. We succeed in doing so +% by choosing something that will disappear when expanding. +% After that we only have to call up =\@preamble= to +% start the wanted =\halign=. +% \changes{1994/12/08}{v2.3b}{add \cs{tabularnewline}} +% \begin{macrocode} + \let\\\@arraycr \let\tabularnewline\\\let\par\@empty \@preamble} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\arraybackslash} +% \changes{v2.4a}{2003/12/17}{(DPC) Macro added (from tabularx)} +% Restore =\\= for use in array and tabular environment (after +% =\raggedright= etc.). +% \begin{macrocode} +\def\arraybackslash{\let\\\tabularnewline} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\extrarowheight} +% The \textsf{dimen} parameter used above also needs to be +% allocated. As a default value we use \textsf{0pt}, to ensure +% compatibility with standard \LaTeX. +% \begin{macrocode} +\newdimen \extrarowheight +\extrarowheight=0pt +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@arstrut} +% Now the insertion of =\@arstrutbox= through =\@arstut= +% is easy since we know exactly in which mode \TeX\ is while working +% on the =\halign= preamble. +% \begin{macrocode} +\def\@arstrut{\unhcopy\@arstrutbox} +% \end{macrocode} +% \end{macro} +% +% +% \section{The line separator \texttt{\textbackslash\textbackslash}} +% +% \begin{macro}{\@arraycr} +% In the macro =\@array= the line separator =\\= is +% =\let= to the command =\@arraycr=. +% Its definition starts with a special brace which I have directly +% copied from the original definition. It is +% necessary, because the =\futurlet= in =\@ifnextchar= +% might +% expand a following =&= \textsf{token} in a construction like +% =\\ &=. This would otherwise end the alignment template at a +% wrong time. On the other hand we have to be careful to avoid +% producing a real group, i.e.\ ={}=, because the command will also +% be used for the array environment, i.e.\ in math mode. In that +% case an extra ={}= would produce an ord atom which could mess up +% the spacing. For this reason we use a combination that does not +% really produce a group at all but modifies the master counter so +% that a =&= will not be considered belonging to the current +% =\halign= while we are looking for a =*= or =[=. +% For further information see +% \cite[Appendix D]{bk:knuth}. +% \changes{v2.3c}{1995/04/23}{Avoid adding an ord atom in math} +% \begin{macrocode} +\def\@arraycr{\relax\iffalse{\fi\ifnum 0=`}\fi +% \end{macrocode} +% Then we test whether the user is using the star form and ignore +% a possible star (I also disagree with this procedure, because a +% star does not make any sense here). +% \begin{macrocode} + \@ifstar \@xarraycr \@xarraycr} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@xarraycr} +% In the command =\@xarraycr= we test if an optional argument +% exists. +% \begin{macrocode} +\def\@xarraycr{\@ifnextchar [% +% \end{macrocode} +% If it does, we branch out into the macro =\@argarraycr= if +% not we close the special brace (mentioned above) and end the row +% of the =\halign= with a =\cr=. +% \changes{v2.3c}{1995/04/23}{Avoid adding an ord atom in math} +% \begin{macrocode} + \@argarraycr {\ifnum 0=`{}\fi\cr}} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\@argarraycr} +% If additional space is requested by the user this case is treated +% in the macro =\@argarraycr=. First we close the special brace +% and then we test if the additional space is positive. +% \changes{v2.3c}{1995/04/23}{Avoid adding an ord atom in math} +% \begin{macrocode} +\def\@argarraycr[#1]{\ifnum0=`{}\fi\ifdim #1>\z@ +% \end{macrocode} +% If this is the case we create an invisible vertical rule with +% depth =\dp\@arstutbox=${}+{}$\meta{wanted\ space}. +% Thus we achieve that all vertical lines specified +% in the user preamble by a \texttt{|} are now +% generally drawn. +% Then the row ends with a =\cr=. +% +% If the space is negative we end the row at once with a =\cr= +% and move back up with a =\vskip=. +% +% While testing these macros I found out that the +% =\endtemplate= +% created by =\cr= and =&= is something like an +% =\outer= primitive and therefore it should not appear in +% incomplete =\if= statements. Thus the following solution was +% chosen which hides the =\cr= in other macros when \TeX\ +% is skipping conditional text. +% \changes{v2.3c}{1995/04/23}{Use \cs{expandafter}'s in conditional} +% \begin{macrocode} + \expandafter\@xargarraycr\else + \expandafter\@yargarraycr\fi{#1}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@xargarraycr} +% \begin{macro}{\@yargarraycr} +% The following macros were already explained above. +% \changes{v2.4e}{2016/10/07}{Fixing SX68732} +% \begin{macrocode} +\def\@xargarraycr#1{\unskip\gdef\do@row@strut + {\@tempdima #1\advance\@tempdima \dp\@arstrutbox + \vrule \@depth\@tempdima \@width\z@\global\let\do@row@strut\relax}% +% \end{macrocode} +% If the last column is a =\multicolumn= cell then we need to +% insert the row strut now as it isn't inside the template (as that +% got =\omit=ted). +% \changes{v2.4h}{2018/04/30}{Fixing issue 42} + % \begin{macrocode} + \ifnum\@multicnt >\z@ \do@row@strut \fi + \cr} +\let\do@row@strut\relax +% \end{macrocode} +% +% \begin{macrocode} +\def\@yargarraycr#1{\cr\noalign{\vskip #1}} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% +% +% +% \section{Spanning several columns} +% +% \begin{macro}{\multicolumn} +% If several columns should be held together with a special format +% the command =\multicolumn= must be used. It has three +% arguments: the number of columns to be covered; the format for +% the result column and the actual column entry. +% \changes{v2.3j}{1998/01/29}{Command made \cs{long} to match +% kernel change for pr/2180} +% \begin{macrocode} +\long\def\multicolumn#1#2#3{% +% \end{macrocode} +% First we combine the given number of columns into a single one; +% then we start a new block so that the following definition is kept +% local. +% \begin{macrocode} + \multispan{#1}\begingroup +% \end{macrocode} +% Since a =\multicolumn= should only describe the format of a +% result column, we redefine =\@addamp= in such a way that one gets +% an error message if one uses more than one \texttt{c}, +% \texttt{l}, \texttt{r}, \texttt{p}, \texttt{m} or \texttt{b} in +% the second argument. One should consider that this definition is +% local to the build-up of the preamble; an \textsf{array}-- or +% \textsf{tabular}--environment in the third argument of the +% =\multicolumn= is therefore worked through correctly as well. +% \begin{macrocode} + \def\@addamp{\if@firstamp \@firstampfalse \else + \@preamerr 5\fi}% +% \end{macrocode} +% Then we evaluate the second argument with the help of +% =\@mkpream=. +% Now we still have to insert the contents of the \textsf{token} +% register into the =\@preamble=, i.e.\ we have to say +% =\xdef\@preamble{\@preamble}=. This is achieved shorter by +% writing: +% \begin{macrocode} + \@mkpream{#2}\@addtopreamble\@empty +% \end{macrocode} +% After the =\@preamble= is created we forget all local +% definitions and occupations of the \textsf{token} registers. +% \begin{macrocode} + \endgroup +% \end{macrocode} +% In the special situation of =\multicolumn= =\@preamble= +% is not needed as preamble for a =\halign= but it is directly +% inserted into our table. Thus instead of =\sharp= +% there has to be the column entry (=#3=) wanted by the user. +% \begin{macrocode} + \def\@sharp{#3}% +% \end{macrocode} +% Now we can pass the =\@preamble= to \TeX\ . For safety +% we start with an =\@arstrut=. This should usually be in the +% template for the first column however we do not know if this +% template was overwritten by our =\multicolumn=. +% We also add a =\null= at the right end to prevent any following +% =\unskip= (for example from =\\[..]=) to remove the =\tabcolsep=. +% \changes{v2.2e}{1994/06/01}{Added \cs{null}} +% \begin{macrocode} + \@arstrut \@preamble + \null + \ignorespaces} +% \end{macrocode} +% \end{macro} +% +% +% +% \section{The Environment Definitions} +% +% After these preparations we are able to define the environments. They +% only differ in the initialisations of =\d@llar...=, =\col@sep= +% and =\@halignto=. +% +% \begin{macro}{\@halignto} +% \begin{macro}{\d@llarbegin} +% \begin{macro}{\d@llarend} +% =\d@llar= has to be +% locally asigned since otherwise nested \textsf{tabular} and \textsf{array} +% environments (via =\multicolumn=) are impossible. +% For 25 years or so =\@halignto= was set globally (to save space on the +% save stack, but that was a mistake: if there is a tabular in the +% output routine (e.g., in the running header) then that tabular is +% able overwrite the =\@halignto= +% setting of a tabular in the main text resulting in a very weird error. +% \changes{v2.4d}{2016/10/06}{\cs{@halignto} set locally (pr/4488)} +% \changes{v2.0g}{1992/06/18}{`d@llarbegin defined on toplevel.} +% When the new font selection scheme is in force we have to +% we surround all =\halign= entries +% with braces. See remarks in TUGboat 10\#2. Actually we are going +% to use =\begingroup= and =\endgroup=. However, this is only +% necessary when we are in text mode. In math the surrounding +% dollar signs will already serve as the necessary extra grouping +% level. Therefore we switch the settings of =\d@llarbegin= and +% =\d@llarend= between groups and dollar signs. +% \begin{macrocode} +\let\d@llarbegin\begingroup +\let\d@llarend\endgroup +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% +% +% \begin{macro}{\array} +% Our new definition of =\array= then reads: +% \changes{v2.0d}{1990/08/20}{`d@llar local to preamble.} +% \changes{v2.4d}{2016/10/06}{\cs{@halignto} set locally (pr/4488)} +% \begin{macrocode} +\def\array{\col@sep\arraycolsep + \def\d@llarbegin{$}\let\d@llarend\d@llarbegin\def\@halignto{}% +% \end{macrocode} +% Since there might be an optional argument we call another +% macro which is also used by the other environments. +% \begin{macrocode} + \@tabarray} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@tabarray} +% \emph{The code below has been replaced long time ago by an +% extended version further down but the code and its documentation +% was left here for reference. It is now commented out to avoid +% confusion.} +% +% This macro tests for a optional bracket and then calls up +% =\@array= or =\@array[c]= (as default). +% \begin{macrocode} +%\def\@tabarray{\@ifnextchar[{\@array}{\@array[c]}} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\tabular} +% \begin{macro}{\tabular*} +% The environments \textsf{tabular} and \textsf{tabular$*$} differ +% only in the initialisation of the command =\@halignto=. Therefore +% we define +% \changes{v2.4d}{2016/10/06}{\cs{@halignto} set locally (pr/4488)} +% \begin{macrocode} +\def\tabular{\def\@halignto{}\@tabular} +% \end{macrocode} +% and analogously for the star form. We evaluate the argument first +% using =\setlength= so that users of the \texttt{calc} package can +% write code like\\ =\begin{tabular*}{(\columnwidth-1cm)/2}...= +% \changes{v2.3l}{1998/05/13}{Use \cs{setlength} evaluate arg +% so that the calc package can be applied here (pr/2793)} +% \changes{v2.4d}{2016/10/06}{\cs{@halignto} set locally (pr/4488)} +% \begin{macrocode} +\expandafter\def\csname tabular*\endcsname#1{% + \setlength\dimen@{#1}% + \edef\@halignto{to\the\dimen@}\@tabular} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\@tabular} +% The rest of the job is carried out by the =\@tabular= macro: +% \begin{macrocode} +\def\@tabular{% +% \end{macrocode} +% First of all we have to make sure that we start out in +% \textsf{hmode}. Otherwise we might find our table dangling by +% itself on a line. +% \begin{macrocode} + \leavevmode +% \end{macrocode} +% It should be taken into consideration that the macro =\@array= +% must be called in math mode. Therefore we open a \textsf{box}, +% insert a =$= and then assign the correct values to =\col@sep= and +% =\d@llar...=. +% \changes{v2.0d}{1990/08/20}{`d@llar local to preamble.} +% \begin{macrocode} + \hbox \bgroup $\col@sep\tabcolsep \let\d@llarbegin\begingroup + \let\d@llarend\endgroup +% \end{macrocode} +% Now everything \textsf{tabular} specific is done and we are able to +% call the =\@tabarray= macro. +% \begin{macrocode} + \@tabarray} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\endarray} +% \emph{The code below has been replaced long time ago by an +% extended version further down but the code and its documentation +% was left here for reference. It is now commented out to avoid +% confusion.} +% +% When the processing of \textsf{array} is finished we have to +% close the =\halign= +% and afterwards the surrounding \textsf{box} selected by +% =\@array=. To save \textsf{token} space we then redefine +% =\@preamble= +% because its replacement text isn't longer needed. +% \begin{macrocode} +%\def\endarray{\crcr \egroup \egroup \gdef\@preamble{}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\endtabular} +% \begin{macro}{\endtabular*} +% To end a \textsf{tabular} or \textsf{tabular$*$} environment we +% call up =\endarray=, close the math mode and then the surrounding +% =\hbox=. +% \begin{macrocode} +\def\endtabular{\endarray $\egroup} +\expandafter\let\csname endtabular*\endcsname=\endtabular +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% +% +% \section{Last minute definitions} +% +% +% If this file is used as a package file we should =\let= all macros +% to =\relax= that were used in the original but are no longer +% necessary. +% \begin{macrocode} +\let\@ampacol=\relax \let\@expast=\relax +\let\@arrayclassiv=\relax \let\@arrayclassz=\relax +\let\@tabclassiv=\relax \let\@tabclassz=\relax +\let\@arrayacol=\relax \let\@tabacol=\relax +\let\@tabularcr=\relax \let\@@endpbox=\relax +\let\@argtabularcr=\relax \let\@xtabularcr=\relax +% \end{macrocode} +% +% \begin{macro}{\@preamerr} +% We also have to redefine the error routine =\@preamerr= since +% new kind of errors are possible. +% The code for this macro is not perfect yet; +% it still needs too much memory. +% \begin{macrocode} +\def\@preamerr#1{\def\@tempd{{..} at wrong position: }% + \PackageError{array}{% + \ifcase #1 Illegal pream-token (\@nextchar): `c' used\or %0 + Missing arg: token ignored\or %1 + Empty preamble: `l' used\or %2 + >\@tempd token ignored\or %3 + <\@tempd changed to !{..}\or %4 + Only one column-spec. allowed.\fi}\@ehc} %5 +% \end{macrocode} +% \end{macro} +% +% +% +% \section +% [Defining your own column specifiers] +% {Defining your own column specifiers\footnotemark} +% +% \footnotetext{The code and the documentation in this section was +% written by David. So far only the code from newarray was plugged +% into array so that some parts of the documentation still claim +% that this is newarray and even worse, some parts of the code are +% unnecessarily doubled. This will go away in a future release. For +% the moment we thought it would be more important to bring both +% packages together.} +% \changes{v2.1a}{1992/07/03}{Newcolumn stuff added} +% +% \DeleteShortVerb{\=} +% \MakeShortVerb{\"} +% +% \begin{macro}{\newcolumn} +% In \texttt{newarray.sty} the macro for specifying new columns was +% named "\newcolumn". When the functionality was added to +% \texttt{array.sty} the command was renamed "\newcolumntype". +% Initially both names were supported, but now (In versions of this +% package distributed for \LaTeXe) the old name is not defined. +% \changes{v2.2a}{1994/02/03}{Now made `newcolumn an error} +% \changes{v2.2a}{1994/02/04}{Removed `newcolumn} +% \begin{macrocode} +%<*ncols> +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\newcolumntype} +% \changes{v2.1b}{1992/06/07}{Macro renamed from `newcolumn} As +% described above, the "\newcolumntype" macro gives users the chance +% to define letters, to be used in the same way as the primitive +% column specifiers, `c' `p' etc. +% \begin{macrocode} +\def\newcolumntype#1{% +% \end{macrocode} +% "\NC@char" was added in V2.01 so that active characters, like "@" in +% AMS\LaTeX\ may be used. This trick was stolen from \texttt{array.sty} +% 2.0h. Note that we need to use the possibly active token, +% "#1", in several places, as that is the token that actually +% appears in the preamble argument. +% \begin{macrocode} + \edef\NC@char{\string#1}% +% \end{macrocode} +% First we check whether there is already a definition for this column. +% Unlike "\newcommand" we give a warning rather than an error if it is +% defined. If it is a new column, add "\NC@do" \meta{column} to +% the list "\NC@list". +% \begin{macrocode} + \@ifundefined{NC@find@\NC@char}% + {\@tfor\next:=<>clrmbp@!|\do + {% +% \end{macrocode} +% We use \cs{noexpand} on the tokens from the list in case one or +% the other (typically \texttt{@}, \texttt{!} or \texttt{|}) has +% been made active. +% \changes{v2.4l}{2019/08/31}{Add a necessary \cs{expandafter} (github/148)} +% \begin{macrocode} + \if\expandafter\noexpand\next\NC@char + \PackageWarning{array}% + {Redefining primitive column \NC@char}\fi}% + \NC@list\expandafter{\the\NC@list\NC@do#1}}% + {\PackageWarning{array}{Column \NC@char\space is already defined}}% +% \end{macrocode} +% Now we define a macro with an argument delimited by the new column +% specifier, this is used to find occurrences of this specifier in the +% user preamble. +% \begin{macrocode} + \@namedef{NC@find@\NC@char}##1#1{\NC@{##1}}% +% \end{macrocode} +% If an optional argument was not given, give a default argument of 0. +% \begin{macrocode} + \@ifnextchar[{\newcol@{\NC@char}}{\newcol@{\NC@char}[0]}} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\newcol@} +% We can now define the macro which does the rewriting, +% "\@reargdef" takes the same arguments as "\newcommand", but +% does not check that the command is new. For a column, say `D' with +% one argument, define a command "\NC@rewrite@D" with one +% argument, which recursively calls "\NC@find" on the user preamble +% after replacing the first token or group with the replacement text +% specified in the "\newcolumntype" command. "\NC@find" will find the +% next occurrence of `D' as it will be "\let" equal to +% "\NC@find@D" by "\NC@do". +% \begin{macrocode} +\def\newcol@#1[#2]#3{\expandafter\@reargdef + \csname NC@rewrite@#1\endcsname[#2]{\NC@find#3}} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\NC@} +% Having found an occurrence of the new column, save the preamble +% before the column in "\@temptokena", then check to see if we +% are at the end of the preamble. (A dummy occurrence of the column +% specifier will be placed at the end of the preamble by "\NC@do". +% \begin{macrocode} +\def\NC@#1{% + \@temptokena\expandafter{\the\@temptokena#1}\futurelet\next\NC@ifend} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\NC@ifend} +% We can tell that we are at the end as "\NC@do" will place a "\relax" +% after the dummy column. +% \begin{macrocode} +\def\NC@ifend{% +% \end{macrocode} +% If we are at the end, do nothing. (The whole preamble will now be in +% "\@temptokena".) +% \begin{macrocode} + \ifx\next\relax +% \end{macrocode} +% Otherwise set the flag "\if@tempswa", and rewrite the column. +% "\expandafter" introduced 1n V2.01 +% \begin{macrocode} + \else\@tempswatrue\expandafter\NC@rewrite\fi} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\NC@do} +% If the user has specified `C' and `L' as new columns, the list of +% rewrites (in the token register "\NC@list") will look like +% "\NC@do *" "\NC@do C" "\NC@do L". +% So we need to define "\NC@do" as a one argument macro which +% initialises the rewriting of the specified column. Let us assume that +% `C' is the argument. +% \begin{macrocode} +\def\NC@do#1{% +% \end{macrocode} +% First we let "\NC@rewrite" and "\NC@find" be +% "\NC@rewrite@C" and "\NC@find@C" respectively. +% \begin{macrocode} + \expandafter\let\expandafter\NC@rewrite + \csname NC@rewrite@\string#1\endcsname + \expandafter\let\expandafter\NC@find + \csname NC@find@\string#1\endcsname +% \end{macrocode} +% Clear the token register "\@temptokena" after putting the present +% contents of the register in front of the token "\NC@find". At the +% end we place the tokens `"C\relax"' which "\NC@ifend" will use +% to detect the end of the user preamble. +% \begin{macrocode} + \expandafter\@temptokena\expandafter{\expandafter}% + \expandafter\NC@find\the\@temptokena#1\relax} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\showcols} +% This macro is useful for debugging "\newcolumntype" specifications, +% it is the equivalent of the primitive "\show" command for macro +% definitions. All we need to do is locally redefine "\NC@do" to take +% its argument (say `C') and then "\show" the (slightly modified) +% definition of "\NC@rewrite@C". Actually as the the list always +% starts off with "\NC@do *" and we do not want to print the +% definition of the $*$-form, define "\NC@do" to throw away the first +% item in the list, and then redefine itself to print the rest of the +% definitions. +% \begin{macrocode} +\def\showcols{{\def\NC@do##1{\let\NC@do\NC@show}\the\NC@list}} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\NC@show} +% If the column `C' is defined as above, then +% "\show\NC@rewrite@C" would output\\ +% "\long macro: ->\NC@find >{$}c<{$}". +% We want to strip the "long macro: ->" and the "\NC@find". So first we +% use "\meaning" and then apply the macro "\NC@strip" to the tokens so +% produced and then "\typeout" the required string. +% \begin{macrocode} +\def\NC@show#1{% + \typeout{Column #1\expandafter\expandafter\expandafter\NC@strip + \expandafter\meaning\csname NC@rewrite@#1\endcsname\@@}} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\NC@strip} +% Delimit the arguments to "\NC@strip" with `\texttt{:}', `\texttt{->}', +% a space, and "\@@" to pull out the required parts of the output from +% "\meaning". +% \begin{macrocode} +\def\NC@strip#1:#2->#3 #4\@@{#2 -> #4} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\NC@list} +% Allocate the token register used for the rewrite list. +% \begin{macrocode} +\newtoks\NC@list +% \end{macrocode} +% \end{macro} +% +% \subsection{The $*$--form} +% We view the $*$-form as a slight generalisation of the system +% described in the previous subsection. The idea is to define a $*$ +% column by a command of the form: +% \begin{verbatim} +% \newcolumntype{*}[2]{% +% \count@=#1\ifnum\count@>0 +% \advance\count@ by -1 #2*{\count@}{#2}\fi} +% \end{verbatim} +% \begin{macro}{\NC@rewrite@*}\label{NC@rewrite@*} +% \changes{v2.4b}{2005/08/23}{Fix occasional spurious space (PR/3755)} +% This does not work however as "\newcolumntype" takes great care not +% to expand anything in the preamble, and so the "\if" is never +% expanded. "\newcolumntype" sets up various other parts of the +% rewrite correctly though so we can define: +% \begin{macrocode} +\newcolumntype{*}[2]{} +% \end{macrocode} +% Now we must correct the definition of "\NC@rewrite@*". The +% following is probably more efficient than a direct translation of +% the idea sketched above, we do not need to put a $*$ in the preamble +% and call the rewrite recursively, we can just put "#1" copies of +% "#2" into "\@temptokena". (Nested $*$ forms will be expanded +% when the whole rewrite list is expanded again, see "\@mkpream") +% \begin{macrocode} +\long\@namedef{NC@rewrite@*}#1#2{% +% \end{macrocode} +% Store the number. +% \begin{macrocode} + \count@#1\relax +% \end{macrocode} +% Put "#1" copies of "#2" in the token register. +% \begin{macrocode} + \loop + \ifnum\count@>\z@ + \advance\count@\m@ne + \@temptokena\expandafter{\the\@temptokena#2}% + \repeat +% \end{macrocode} +% "\NC@do" will ensure that "\NC@find" is "\let" equal +% to "\NC@find@*". +% \begin{macrocode} + \NC@find} +% \end{macrocode} +% \end{macro} +% +% \subsection{Modifications to internal macros of \texttt{array.sty}} +% +% \begin{macro}{\@xexpast} +% \begin{macro}{\@xexnoop} +% These macros are used to expand $*$-forms in +% \texttt{array.sty}. "\let" them to "\relax" to save space. +% \begin{macrocode} +\let\@xexpast\relax +\let\@xexnoop\relax +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\save@decl} +% We do not assume that the token register is free, we add the new +% declarations to the front of the register. This is to allow user +% preambles of the form, ">{foo}>{bar}..". Users are not encouraged to +% enter such expressions directly, but they may result from the +% rewriting of "\newcolumntype"'s. +% \begin{macrocode} +\def\save@decl{\toks \count@ = \expandafter\expandafter\expandafter + {\expandafter\@nextchar\the\toks\count@}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@mkpream} +% The main modification to "\@mkpream" is to replace the call to +% "\@xexpast" (which expanded $*$-forms) by a loop which expands +% all "\newcolumntype" specifiers. +% \changes{v2.4e}{2016/10/07}{Fixing SX68732} +% \changes{v2.4f}{2017/11/04}{Managing m-cells without \cs{vcenter}} +% \begin{macrocode} +\def\@mkpream#1{\gdef\@preamble{}\@lastchclass 4 \@firstamptrue + \let\@sharp\relax +% \end{macrocode} +% +% \changes{v2.4j}{2018/11/13}{Do not expand argument of +% \cs{@startpbox} while building the tabular preamble (sx/459285)} +% The "\@startpbox" (which is called for "p", "m" or "b" columns) +% receives a user supplied argument: the width of the +% paragraph-column. Normally that is something harmless like a length or a +% simple length expression, but with the calc package involved it +% could break under an "\edef" operation, which is how the preamble +% is constructed. We now make use of "\unexpanded" here to prevent that. The +% "\expandafter" gymnastics is necessary to expand the "#1" at least +% once (since it will get "\@nextchar" as its value and need its +% content! +% \begin{macrocode} + \def\@startpbox##1{\unexpanded\expandafter{\expandafter + \@startpbox\expandafter{##1}}}\let\@endpbox\relax + \let\do@row@strut\relax + \let\ar@align@mcell\relax +% \end{macrocode} +% Now we remove possible $*$-forms and user-defined column +% specifiers in the user preamble by repeatedly executing the list +% "\NC@list" until the re-writes have no more effect. The +% expanded preamble will then be in the token register +% "\@temptokena". Actually we need to know at this point that +% this is not "\toks0". +% \begin{macrocode} + \@temptokena{#1}\@tempswatrue + \@whilesw\if@tempswa\fi{\@tempswafalse\the\NC@list}% +% \end{macrocode} +% Afterwards we initialize all registers and macros, that we need +% for the build-up of the preamble. +% \begin{macrocode} + \count@\m@ne + \let\the@toks\relax + \prepnext@tok +% \end{macrocode} +% Having expanded all tokens defined using "\newcolumntype" (including +% "*"), we evaluate the remaining tokens, which are saved in +% "\@temptokena". We use the \LaTeX--macro "\@tfor" to inspect each +% token in turn. +% \begin{macrocode} + \expandafter \@tfor \expandafter \@nextchar + \expandafter :\expandafter =\the\@temptokena \do +% \end{macrocode} +% "\@testpatch" does not take an argument since \texttt{array.sty} 2.0h. +% \begin{macrocode} + {\@testpach + \ifcase \@chclass \@classz \or \@classi \or \@classii + \or \save@decl \or \or \@classv \or \@classvi + \or \@classvii \or \@classviii +% \end{macrocode} +% In \texttt{newarray.sty} class 9 is equivalent to class 10. +% \begin{macrocode} + \or \@classx + \or \@classx \fi + \@lastchclass\@chclass}% + \ifcase\@lastchclass + \@acol \or + \or + \@acol \or + \@preamerr \thr@@ \or + \@preamerr \tw@ \@addtopreamble\@sharp \or + \or + \else \@preamerr \@ne \fi + \def\the@toks{\the\toks}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@classix} +% \texttt{array.sty} does not allow repeated \texttt{>} +% declarations for the same column. This is allowed in +% \texttt{newarray.sty} as documented in the introduction. Removing +% the test for this case makes class 9 equivalent to class 10, and +% so this macro is redundant. It is "\let" to "\relax" to save +% space. +% \begin{macrocode} +\let\@classix\relax +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@classviii} +% In \texttt{newarray.sty} explicitly allow class 2, as repeated +% \texttt{<} expressions are accepted by this package. +% \begin{macrocode} +\def\@classviii{\ifnum \@lastchclass >\z@\ifnum\@lastchclass=\tw@\else + \@preamerr 4\@chclass 6 \@classvi \fi\fi} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@classv} +% Class 5 is \texttt{@}-expressions (and is also called by class 1) +% This macro was incorrect in Version~1. Now we do not expand the +% "@"-expression, but instead explicitly replace an +% "\extracolsep" command by an assignment to "\tabskip" by a +% method similar to the "\newcolumntype" system described above. +% "\d@llarbegin" "\d@llarend" were introduced in V2.01 to match +% \texttt{array.sty} 2.0h. +% \begin{macrocode} +\def\@classv{\save@decl + \expandafter\NC@ecs\@nextchar\extracolsep{}\extracolsep\@@@ + \@addtopreamble{\d@llarbegin\the@toks\the\count@\relax\d@llarend}% + \prepnext@tok} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NC@ecs} +% Rewrite the first occurrence of "\extracolsep{1in}" to +% "\tabskip1in\relax". As a side effect discard any tokens after a +% second "\extracolsep", there is no point in the user entering two of +% these commands anyway, so this is not really a restriction. +% \begin{macrocode} +\def\NC@ecs#1\extracolsep#2#3\extracolsep#4\@@@{\def\@tempa{#2}% + \ifx\@tempa\@empty\else\toks\count@={#1\tabskip#2\relax#3}\fi} +%</ncols> +% \end{macrocode} +% \end{macro} +% +% +% \subsection{Support for the \texttt{delarray.sty}} +% +% The \texttt{delarray.sty} package extends the array syntax by +% supporting the notation of delimiters. To this end we extend the +% array parsing mechanism to include a hook which can be used by this +% (or another) package to do some additional parsing. +% +% \begin{macro}{\@tabarray} +% This macro tests for an optional bracket and then calls up +% "\@@array" or "\@@array[c]" (as default). +% \begin{macrocode} +%<*package> +\def\@tabarray{\@ifnextchar[{\@@array}{\@@array[c]}} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\@@array} +% This macro tests could then test an optional delimiter before the +% left brace of the main preamble argument. Here in the main package +% it simply is let to be "\@array". +% \begin{macrocode} +\let\@@array\@array +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\endarray} +% \begin{macro}{\@arrayright} +% We have to declare the hook we put into "\@array" above. +% A similar hook `"\@arrayright"' will be inserted into the +% "\endarray" to gain control. Both defaults to empty. +% \begin{macrocode} +\def\endarray{\crcr \egroup \egroup \@arrayright \gdef\@preamble{}} +\let\@arrayleft\@empty +\let\@arrayright\@empty +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \subsection{Support for \texttt{\textbackslash firsthline} and +% \texttt{\textbackslash lasthline}} +% +% The Companion~\cite[p.137]{bk:GMS94} suggests two additional +% commands to control the alignments in case of tabulars with +% horizontal lines. They are now added to this package. +% +% \begin{macro}{\extratabsurround} +% The extra space around a table when "\firsthline" or "\lasthline" +% are used. +% \begin{macrocode} +\newlength{\extratabsurround} +\setlength{\extratabsurround}{2pt} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\backup@length} +% This register will be used internally by "\firsthline" and +% "\lasthline". +% \begin{macrocode} +\newlength{\backup@length} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\firsthline} +% \changes{v2.3h}{1996/05/25}{Complete reimplementation} +% This code can probably be improved but for the moment it should +% serve. +% +% We start by producing a single tabular row without any visible +% content that will produce the external reference point in case +% "[t]" is used. +% \begin{macrocode} +\newcommand{\firsthline}{% + \multicolumn1c{% +% \end{macrocode} +% Within this row we calculate "\backup@length" to be the height +% plus depth of a standard line. In addition we have to add the +% width of the "\hline", something that was forgotten in the +% original definition. +% \begin{macrocode} + \global\backup@length\ht\@arstrutbox + \global\advance\backup@length\dp\@arstrutbox + \global\advance\backup@length\arrayrulewidth +% \end{macrocode} +% Finally we do want to make the height of this first line be a bit +% larger than usual, for this we place the standard array strut +% into it but raised by "\extratabsurround" +% \begin{macrocode} + \raise\extratabsurround\copy\@arstrutbox +% \end{macrocode} +% Having done all this we end the line and back up by the value of +% "\backup@length" and then finally place our "\hline". This should +% place the line exactly at the right place but keep the reference +% point of the whole tabular at the baseline of the first row. +% \begin{macrocode} + }\\[-\backup@length]\hline +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\lasthline} +% \changes{v2.3h}{1996/05/25}{Complete reimplementation} +% For "\lasthline" the situation is even worse and I got it +% completely wrong initially. +% +% The problem in this case is that if the optional argument "[b]" +% is used we do want the reference point of the tabular be at the +% baseline of the last row but at the same time do want the the +% depth of this last line increased by "\extratabsurround" without +% changing the placement "\hline". +% +% We start by placing the rule followed by an invisible row. +% \begin{macrocode} +\newcommand{\lasthline}{\hline\multicolumn1c{% +% \end{macrocode} +% We now calculate "\backup@length" to be the height and depth of +% two lines plus the width of the rule. +% \begin{macrocode} + \global\backup@length2\ht\@arstrutbox + \global\advance\backup@length2\dp\@arstrutbox + \global\advance\backup@length\arrayrulewidth +% \end{macrocode} +% This will bring us back to the baseline of the second last row: +% \begin{macrocode} + }\\[-\backup@length]% +% \end{macrocode} +% Thus if we now add another invisible row the reference point of +% that row will be at the baseline of the last row (and will be the +% reference for the whole tabular). Since this row is invisible we +% can enlarge its depth by the desired amount. +% \begin{macrocode} + \multicolumn1c{% + \lower\extratabsurround\copy\@arstrutbox + }% +} +% \end{macrocode} +% \end{macro} +% +% +% \subsection{Getting the spacing around rules right} +% +% Beside a larger functionality \texttt{array.sty} has one +% important difference to the standard \texttt{tabular} and +% \texttt{array} environments: horizontal and vertical rules make a +% table larger or wider, e.g., \verb=\doublerulesep= really denotes +% the space between two rules and isn't measured from the middle of +% the rules. +% +% \begin{macro}{\@xhline} +% For vertical rules this is implemented by the definitions above, +% for horizontal rules we have to take out the backspace. +% \changes{v2.3d}{1995/11/19}{fix space between double rules pr/1945} +% \begin{macrocode} +\CheckCommand*\@xhline{\ifx\reserved@a\hline + \vskip\doublerulesep + \vskip-\arrayrulewidth + \fi + \ifnum0=`{\fi}} +\renewcommand*\@xhline{\ifx\reserved@a\hline + \vskip\doublerulesep + \fi + \ifnum0=`{\fi}} +%</package> +% \end{macrocode} +% \end{macro} + +% \subsection{Implementing column types \texttt{w} and \texttt{W}} +% +% In TugBoat 38/2 an extension was presented that implemented two +% aditional column types \texttt{w} and \texttt{W}. These have now +% been added to the package itself. +% +% +% \begin{macro}{\ar@cellbox} +% For \texttt{w} and \texttt{W} column types we need a box to +% temporarily hold the cell content. +% \changes{v2.4f}{2017/11/07}{Macro added} +% \begin{macrocode} +\newsavebox\ar@cellbox +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\newcolumntype w} +% The \texttt{w} column type has two arguments: the first holds the +% alignment which is either "l", "c", or "r" and the second is the +% nominal width of the column. +% \changes{v2.4f}{2017/11/07}{Column type added} +% \begin{macrocode} +\newcolumntype{w}[2]{% +% \end{macrocode} +% Before the cell content we start an "lrbox"-environment to +% collect the cell material into the previously allocated box +% "\ar@cellbox". +% \begin{macrocode} + >{\begin{lrbox}\ar@cellbox}% +% \end{macrocode} +% Then comes a specifier for the cell content. We use "c", but +% that doesn't matter as in the end we will always put a box of a +% specific width ("#2") into the cells of that column, so "l" or +% "r" would give the same result. There is only a difference if +% there are also very wide "\multicolumn" rows overwriting the +% setting in which case "c" seems to be slightly better. +% \begin{macrocode} + c% +% \end{macrocode} +% At the end of the cell we end the "lrbox" environment so that all +% of the cell content is now in box "\ar@cellbox". As a final step we +% put that box into a "\makebox" using the optional arguments of +% that command to achieve the correct width and the desired +% alignment within that width. +% \begin{macrocode} + <{\end{lrbox}% + \makebox[#2][#1]{\usebox\ar@cellbox}}} +% \end{macrocode} +% \end{macro} + +% +% +% \begin{macro}{\newcolumntype W} +% The \texttt{W} is similar but in this case we want a warning if +% the cell content is too wide. +% \changes{v2.4f}{2017/11/07}{Column type added} +% \begin{macrocode} +\newcolumntype{W}[2] + {>{\begin{lrbox}\ar@cellbox}% + c% + <{\end{lrbox}% + \let\hss\hfil + \makebox[#2][#1]{\unhbox\ar@cellbox}}} +% \end{macrocode} +% This is a bit sneaky, as it temporarily disables "\hss", but +% given that we know what goes into that box it should be +% sufficient. +% \end{macro} +% +% +% \PrintIndex +% \PrintChanges +% +% \Finale +% +\endinput + diff --git a/macros/latex-dev/required/tools/array.pdf b/macros/latex-dev/required/tools/array.pdf Binary files differnew file mode 100644 index 0000000000..dfb2f3cc61 --- /dev/null +++ b/macros/latex-dev/required/tools/array.pdf diff --git a/macros/latex-dev/required/tools/bm.dtx b/macros/latex-dev/required/tools/bm.dtx new file mode 100644 index 0000000000..2216dcea07 --- /dev/null +++ b/macros/latex-dev/required/tools/bm.dtx @@ -0,0 +1,1705 @@ +% \iffalse meta-comment +% +% Copyright (C) 1993-2019 +% +% The LaTeX3 Project and any individual authors listed elsewhere +% in this file. +% +% This file is part of the Standard LaTeX `Tools Bundle'. +% ------------------------------------------------------- +% +% It may be distributed and/or modified under the +% conditions of the LaTeX Project Public License, either version 1.3c +% of this license or (at your option) any later version. +% The latest version of this license is in +% https://www.latex-project.org/lppl.txt +% and version 1.3c or later is part of all distributions of LaTeX +% version 2005/12/01 or later. +% +% The list of all files belonging to the LaTeX `Tools Bundle' is +% given in the file `manifest.txt'. +% +% \fi +% +% \iffalse +%% Copyright 1996 1997 1998 1999 2002 2003 2004 2016 2017 2019 +%% David Carlisle Frank Mittelbach +%% +%% Development of this package was commissioned by Y&Y Inc. +% +% +%<*dtx> + \ProvidesFile{bm.dtx} +%</dtx> +%<package>\NeedsTeXFormat{LaTeX2e} +%<package>\ProvidesPackage{bm} +%<driver>\ProvidesFile{bm.drv} +% \fi +% \ProvidesFile{bm.dtx} + [2019/07/24 v1.2d Bold Symbol Support (DPC/FMi)] +% +% \iffalse +%<*driver> +\documentclass{ltxdoc} +\usepackage{bm} +\begin{document} +\DocInput{bm.dtx} +\end{document} +%</driver> +% \fi +% +% +% \GetFileInfo{bm.dtx} +% +% \title{The \textsf{bm} package\thanks{This file +% has version number \fileversion, last +% revised \filedate.}\ \thanks{Development of this package +% was commissioned by Y\&Y.}} +% +% \date{\filedate} +% \author{David Carlisle with support by Frank Mittelbach} +% \MaintainedByLaTeXTeam{tools} +% \maketitle +% +% \section{Introduction} +% +% This package defines commands to access bold math +% symbols. The basic command is |\bm| which may be used to make the +% math expression in its argument be typeset using bold fonts. +% +% The syntax of |\bm| is:\\ +% |\bm|\marg{math expression}\\ +% So |$\alpha \not= \bm{\alpha}$| produces $\alpha \not= \bm{\alpha}$. +% +% |\bm| goes to some trouble to preserve the spacing, so that for +% instance |\bm<| is a bold $\bm<$ but with the correct |\mathrel| +% spacing that \TeX\ gives to $<$. The calculations that \TeX\ needs to +% do for |\bm| can be quite involved and so a definition form is +% provided. +% +% |\DeclareBoldMathCommand|%^^A +% \oarg{math version}\marg{cmd}\marg{math expression} +% +% Defines |\cmd| to be the bold form of the math expression. +% The \meta{math version} defaults to `bold' (i.e., |\boldmath|). +% +% For relatively simple expressions, the resulting definitions are very +% efficient, for instance after:\\ +% |\DeclareBoldMathCommand\balpha{\alpha}|\\ +% |\balpha| is a single `mathchardef' token producing a bold alpha, +% and so is just as fast to execute as |\alpha|. +% +% The above command is mainly intended for use in packages. +% For occasional use in \LaTeX\ documents, and for compatibility +% with the plain \TeX\ support for the mathtime fonts, a `user-level' +% version, |\bmdefine| is provided that is equivalent to:\\ +% |\DeclareBoldMathCommand[bold]|. +% +% If there is a `heavy' math version defined (usually accessed by a +% user-command |\heavymath|) then a similar command |\hm| +% is defined which access these `ultra bold' fonts. Currently this is +% probably only useful with the `mathtime plus' font collection. +% Definitions of commands that use these fonts may be made by +% specifying the optional argument `heavy' to |\DeclareBoldMathCommand|. +% Again an abbreviation, |\hmdefine|, is provided, equivalent to:\\ +% |\DeclareBoldMathCommand[heavy]|. +% +% The command names (but not the implementation) are taken from Michael +% Spivak's macros to support the mathtime fonts for plain \TeX. In those +% original macros, the syntax for |\bmdefine| was +% |\bmdefine\balpha{\bm\alpha}| (with a nested |\bm|). This syntax also +% works with this package. +% +% \section{Font allocation} +% In order to access bold fonts in the simplest and quickest possible +% manner, the package normally allocates symbol fonts for bold +% (and possibly heavy) fonts into the `normal' math version. +% By default it allocates at most four fonts for |\bm| and at most +% three fonts for |\hm|. This means that if the mathtime plus font set +% is being used, seven additional symbol fonts will be used, in addition +% to the basic four that \LaTeX\ already declares. The mathtime +% package also declares an extra symbol font, bringing the total to +% twelve. The maximum number of symbol \emph{and} math alphabet fonts +% that can be used in a math version is sixteen. So the above allocation +% scheme does not leave room for many extra math symbols (such as the +% AMS symbols) or math alphabets (such as |\mathit|). +% +% Before loading the \textsf{bm} package you may define |\bmmax| +% and |\hmmax| to be suitable values, for instance you may want +% to set |\newcommand\hmmax{0}| if you will not be using |\hm| +% much, but you do have a heavy math version defined. +% +% Even if |\bmmax| is set to zero, |\bm| will still access the correct +% bold fonts (by accessing the fonts via |\boldmath|) but this method +% is slower, and does not work with delimiters. Delimiters can only be +% made bold if the bold font has been allocated. +% +% Conversely if you have a non standard font set that makes available +% extra math delimiters and accents in bold and medium weights you may +% want to \emph{increase} |\bmmax| so that fonts are allocated for +% your font set. +% +% \section{Features} +% In most cases this package should work in a fairly self explanatory +% way, but there are some things that might not be obvious. +% +% \subsection{Interaction with Math Alphabet Commands} +% +% As mentioned above, |\bm| goes to some trouble to try to make a +% command that is just like its argument, but using a bold font. +% This does not always produce the effect that you might expect. +%\begin{verbatim} +% $1 g \bm{g}$ +% $2 \mathrm{g \bm{g}}$ +% $3 {g} \bm{{g}}$ +% $4 \mathrm{{g} \bm{{g}}}$ +% $5 \mathrm{g} \bm{\mathrm{g}}$ +%\end{verbatim} +% produces the following: +% \begin{flushleft} +% $1 g \bm{g}$ +% $2 \mathrm{g \bm{g}}$ +% $3 {g} \bm{{g}}$ +% $4 \mathrm{{g} \bm{{g}}}$ +% $5 \mathrm{g} \bm{\mathrm{g}}$ +% \end{flushleft} +% In math mode `g' is effectively a command that produces the letter `g' +% from the `letters' alphabet, unless a Math Alphabet command is in +% effect, in which case the `g' comes from the specified alphabet. +% |\bm{g}| makes an equivalent command, but which defaults to a bold +% letter alphabet. So in the first example |\bm{g}| is bold math italic, +% but in the second example the |\mathrm| applies to both |g| and +% |\bm{g}| in the same way, and so they are both roman. +% +% |\bm| only inspects the `top level' definition of a command, for more +% complicated expressions, and anything inside a |{ }| group, |\bm| +% forces bold fonts by essentially the same (slow) technique used by the +% AMS |\boldsymbol| command (but |\bm| still takes more care of the +% spacing). So the third example produces identical output to the first +% (but \TeX\ takes more time producing it). +% +% In the fourth example the |\mathrm{\bm{g}}| is essentially +% equivalent to |\mathrm{\mbox{\boldmath$g$}}|. Currently math alphabet +% settings are not passed down to `nested' math lists, and so in this +% example, the |\mathrm| has no effect, and a bold math italic $\bm g$ +% is obtained. +% +% Similarly the last example is equivalent to +% |$\mbox{\boldmath$\mathrm{g}$}}| and so in this case, one obtains a +% bold roman \textbf{g}. +% +% \subsection{Delimiters} +% \TeX\ can treat character tokens in two\footnote +% {Well more than two really.} +% ways. If there is a preceding +% |\left| or |\right| it can treat them as a delimiter, otherwise it can +% treat them as a standard character. For example |\left<\right>| +% produces $\left<\right>$, which is totally different from |<>|, which +% produces $<>$. +% +% \TeX\ can only do this for character tokens. Commands such as +% |\langle| do not act in this way. This means that |\bm| has to decide +% whether to treat a character as a delimiter or not. The rule it uses +% is, it makes a delimiter command for a character if the previous +% token in the argument was |\left| or |\right|. So |\left\bm{<}| does +% not work, but |\bm{\left<}| does. +% +% \subsection{Command Arguments} +% +% Normally if a command takes arguments the full command, including +% any arguments, should be included in |\bm|. +% +% So |\bm{\overbrace{abc}}| (producing \smash{$\bm{\overbrace{abc}}$}) +% not +% |\bm{\overbrace}{abc}|. If you do not include all the arguments you +% will typically get the error message:\\ +% |Runaway argument?|\\ +% |! Forbidden control sequence found while scanning use of| +% \texttt{\ldots} +% +% However commands defined in terms of the \TeX\ accent and +% radical primitives \emph{may} be used without their arguments. +% So |\bm{\hat}{a}| produces $\bm{\hat}{a}$, a bold accent over a +% non-bold $a$ (compare $\hat{a}$) +% whereas |\bm{\hat{a}}| makes both the $a$ and the accent bold, +% $\bm{\hat{a}}$. +% Similarly, although the \LaTeX\ command |\sqrt| must be used with its +% arguments, |\sqrtsign| may be used as in |\bm\sqrtsign{abc}| to +% produce $\bm\sqrtsign{abc}$ rather than $\sqrtsign{abc}$ or +% $\bm{\sqrtsign{abc}}$ +% +% If you really need to make a command with arguments use bold fonts +% without making all of the arguments bold, you can explicitly +% reset the math version in the argument, eg:\\ +% $\begin{array}{ccc} +% |\sqrt{xyz}|&|\bm{\sqrt{xyz}}|&|\bm{\sqrt{\mbox{\unboldmath$xyz$}}}|\\ +% \sqrt{xyz}& \bm{\sqrt{xyz}}& \bm{\sqrt{\mbox{\unboldmath$xyz$}}} +% \end{array}$ +% +% \subsection{Bold fonts} +% This package interrogates the font allocations of the bold and heavy +% math versions, to determine which bold fonts are available. +% This means that it is best to load the package \emph{after} +% any packages that define new symbol fonts, or (like the +% \textsf{mathtime} package) completely change the symbol font +% allocations. +% +% If no bold font appears to be available for a particular symbol, +% |\bm| will use `poor man's bold' that is, overprinting the same +% character in slightly offset +% positions to give an appearance of boldness. +% +% In the standard Computer Modern font set, there is no bold +% `large symbols' font. In the `mathptm' and (standard) mathtime +% font sets there are no bold math fonts. In the `mathtime plus' +% font set there are suitable fonts for bold and heavy math setting, +% and so |\bm| and |\hm| work well. Similarly in the basic Lucida +% New Math font set there are no bold math fonts, so |\bm| will +% use `poor man's bold. However if the Lucida Expert set is used, +% Then |\bm| will detect, and use the bold math fonts that are +% available. +% +% As discussed above, one may set |\bmmax| higher or lower than its +% default value of four to control the font allocation system. Finer +% control may be gained by explicitly declaring bold symbol fonts. +% Suppose you have a symbol font `xyz' that is available in medium and +% bold weights, then you would declare this to \LaTeX\ via:\\ +% |\DeclareSymbolFont{extras} {OMS}{xyz}{m}{n}|\\ +% |\SetSymbolFont{extras}{bold}{OMS}{xyz}{bx}{n}|\\ +% At this point the symbols will be available in the normal math +% version, and their bold variants in |\boldmath|. If you also +% declare:\\ +% |\DeclareSymbolFont{boldextras}{OMS}{xyz}{bx}{n}|\\ +% That is, declare a symbol font whose name is formed by prefixing +% `bold' (or `heavy') to an existing symbol font, then |\bm| (or +% |\hm|) will use this font directly, rather then accessing the +% `extras' symbol font via |\boldmath|. +% +% \subsection{Strange failures} +% In order to get the correct spacing, |\bm| has to `investigate' the +% definition of the commands in its argument. It is possible that +% some strange constructions could `confuse' this investigation. +% If this happens then \LaTeX\ will almost certainly stop with a strange +% error. This should not happen with any of the math symbols +% defined in the base \LaTeX\ or AMS distributions, or any commands +% defined in terms of those symbols using normal \LaTeX\ math +% constructs. However if some command does fail to work inside |\bm| +% you should always be able to surround it with an extra set of braces +% |\bm{{\cmd}}| rather than |\bm{\cmd}|. |\bm| will not then attempt +% to set the correct spacing, so you may need to set it explicitly, +% for instance, for a relation, |\bm{\mathrel{\cmd}}|. +% +% \subsection{AMS package \textsf{amsbsy}} +% The |\bm| command shares some functionality with the |\boldsymbol| +% command from the AMS \LaTeX\ collection. To aid in moving documents +% between these two packages, this package defines |\boldsymbol| and +% |\heavysymbol| as alternative names for |\bm| and |\hm|. +% +% \StopEventually{} +% +% \section{Implementation} +% +% \changes{v0.01}{1996/12/01} +% {Initial DPC attempt, +% remove all assumptions about mathtime encoding} +% \changes{v0.02}{1996/12/02} +% {Add \cs{mathchoice} stuff} +% \changes{v0.03}{1996/12/12} +% {Completely reimplement (again). Add \cs{bmdefine}.} +% \changes{v0.04}{1996/12/12} +% {Add \cs{hm} and support for special active mathcode.} +% \changes{v0.05}{1996/12/12} +% {Assorted fixes} +% \changes{v0.99}{1997/01/16} +% {First public version} +% \changes{v1.0a}{1997/02/14} +% {First ctan version (same as 0.99b)} +% \changes{v1.0b}{1997/04/14} +% {Add to tools bundle.} +% \changes{v1.0g}{1999/07/05} +% {minor doc changes latex/3058} +% +% +% +% The commands |\bm| and |\hm| work by defining a number of additional +% symbol fonts corresponding to the standard ones +% `operators', `letters', `symbols', and `largesymbols'. +% The names for these symbols fonts are produced by prefixing the usual +% name with `bold' or `heavy'. +% +% For maximum flexibility we get the font definitions by looking in the +% corresponding math versions, i.e., into |\mv@bold| and if defined into +% |\mv@heavy|. +% +% \begin{macrocode} +%<*package> +% \end{macrocode} +% \changes{v0.09}{1996/12/19} +% {Always define \cs{bm} even if no bold math} +% +% \begin{macro}{\bm@table} +% \changes{v0.10}{1997/01/04} +% {Macro added} +% \changes{v0.12}{1997/01/10} +% {Ensure do not allocate too many math group slots.} +% \changes{v0.99a}{1997/01/17} +% {Let \cs{hm} use font allocated for \cs{bm}} +% \changes{v0.99b}{1997/01/19} +% {Restore NFSS internals} +% \begin{macro}{\bm@boldtable} +% \begin{macro}{\bm@heavytable} +% The table, |\bm@table|, (which is locally |\let| to either the bold +% or heavy version) defines, for each \meta{math group} (\meta{fam}), +% the `offset' to the bold version of the specified symbol font. +% If there is no bold symbol font defined, the offset will be +% set to zero if there is a bold font assigned to this slot in the +% bold math version, or $-1$ if the font in the bold math version +% is the same as the one in the normal math version. In this case +% a `poor man's bold' system of overprinting is used to achieve +% boldness where this is possible. +% +% The settings are made at the time this package is read, and so +% it is best to load this package late, after any font loading packages +% have been loaded. Symbol fonts loaded after this package will get the +% offset of zero, so they will still be made bold by |\bm| as long as an +% appropriate font is declared for the bold math version. +% +% |\bm@boldtable| and |\bm@heavytable| are set up using very similar +% code, which is temporarily defined to |\bm|, to save wasting a csname. +% Similarly |\bm@pmb|\ldots\ (which will be defined later) are used +% as scratch macros. +% +% The general plan. Run through the fonts allocated to the normal math +% version. Ignore \meta{math alphabet} allocations\footnote{For now?} +% but for each math symbol font, look in the math version specified by +% |#1| (bold or heavy). If the font there is different, then allocate +% a new symbol font in the normal math version to access that bold font +% and place the numerical difference between the allocations of the bold +% and normal font into the table being built (|\bm@boldtable|, if |#1| +% is bold). If the symbol allocation is already greater than |\bmmax| +% do not allocate a new symbol font, but rather set the offset in the +% table to zero. |\bm| will detect this, and use |\boldmath| on its +% argument in this case, so the bold font will be accessed but more +% slowly than using a direct access to a bold font allocated into the +% normal math version. If the font allocated in the bold math version is +% the same as the font in the normal math version, set the offset to +% $-1$, which is a flag value that causes |\bm| to use `poor man's bold' +% overprinting three copies of the symbol, offset slightly to give an +% appearance of boldness. +% +% Fonts containing delimiters and math accents \emph{must} be allocated +% into the normal math version if they are to be used with |\bm|. (In +% these cases |\bm| will produce the normal weight symbol, rather than +% using |\boldmath| or poor man's bold.) +% +% \begin{macrocode} +\def\bm#1#2{% +% \end{macrocode} +% This code can not work inside a group, as that would affect any symbol +% font allocations, so instead use some scratch macros to save and +% restore the definitions of commands we need to change locally. +% \begin{macrocode} + \let\bm@pmb\install@mathalphabet + \let\bm@pmb@\getanddefine@fonts + \let\bm@pmb@@\or + \edef\bm@general{\f@encoding/\f@family/\f@series/\f@shape/\f@size}% +% \end{macrocode} +% +% |#2| specifies the maximum number of fonts to allocate +% (either |\bmmax| or |\hmmax|). First check against |\count18| +% that there are that many slots left, and if not reduce accordingly. +% Put the resulting value in |\@tempcnta|. +% \begin{macrocode} + \@tempcnta#2% + \count@-\count18% + \advance\count@-\@tempcnta + \advance\count@15\relax + \ifnum\count@<\z@ + \advance\@tempcnta\count@ + \fi +% \end{macrocode} +% Make |\or| non-expandable, so we can build an |\ifcase| bit-by-bit +% in a sequence of |\edef|s. +% \begin{macrocode} + \let\or\relax +% \end{macrocode} +% +% Initialise the table (to |\@gobble| to remove the first |\or|). +% \begin{macrocode} + \expandafter\let\csname bm@#1table\endcsname\@gobble +% \end{macrocode} +% +% Helper macro that adds the next entry to the table being built. +% \begin{macrocode} + \def\bm@define##1{% + \expandafter\xdef\csname bm@#1table\endcsname{% + \csname bm@#1table\endcsname\or##1}}% +% \end{macrocode} +% +% Each symbol font is recorded in the math version list by a sequence +% such as:\\ +% | \getanddefine@fonts \symsymbols \OMS/cmsy/m/n|\\ +% Where the first argument is a chardef token carrying the number +% allocated (to symbols, in this example), and the second argument is a +% csname whose \emph{name} denotes the font used. +% So locally redefine |\getanddefine@fonts| to compare |#2| with +% the name in the appropriate slot in the bold math version. +% \begin{macrocode} + \def\getanddefine@fonts##1##2{% + \def\@tempa{##2}% +% \end{macrocode} +% +% \begin{macrocode} + \def\@tempb####1##1####2####3\@nil{\def\@tempb{####2}}% +% \end{macrocode} +% +% \begin{macrocode} + \expandafter\expandafter\expandafter + \@tempb\csname mv@#1\endcsname\@nil +% \end{macrocode} +% +% Now |\@tempa| and |\@tempb| contain the names of the fonts allocated +% to this slot in the two math versions. +% \begin{macrocode} + \ifx\@tempa\@tempb +% \end{macrocode} +% If they are the same, set this offset to $-1$, as a flag to use +% poor man's bold. +% \begin{macrocode} + \bm@define\m@ne + \else +% \end{macrocode} +% Else make a new name by adjoining |#1| to the name of the symbol font +% eg, |\symboldsymbols| to match |\symsymbols|. If that font has already +% been allocated, or if |\@tempcnta| is positive so we can allocate a +% new slot for this font, then the table will be +% set with the offset between the two fonts. otherwise set the offset to +% zero (so |\boldmath| will be used to access the font). +% \begin{macrocode} + \edef\@tempa{sym#1\expandafter\@gobblefour\string##1}% + \ifnum\@tempcnta<% + \expandafter\ifx\csname\@tempa\endcsname\relax + \@ne + \else + \m@ne + \fi +% \end{macrocode} +% +% \begin{macrocode} + \bm@define\z@ + \else +% \end{macrocode} +% +% If the font is not yet allocated, allocate it now, using +% an internal hack into |\DeclareMathSymbolFont|. +% +% However before allocating it look in the bold math version +% to see if it is the same, and if so use that. For example +% with Mathtime the `operators' font in the `heavy' math version +% is different from that in `normal', but it is the same as +% the font in `bold' (Times bold). So rather than allocate +% |\symheavyoperators| just set it equal to |\symboldoperators|. +% \begin{macrocode} + \expandafter\ifx\csname\@tempa\endcsname\relax + \begingroup + \escapechar\m@ne + \edef\@tempb{\endgroup + \noexpand\split@name + \expandafter\string\@tempb}% + \@tempb/\@nil +% \end{macrocode} +% +% \begin{macrocode} + \expandafter\ifx + \csname symbold\expandafter\@gobblefour\string##1\endcsname + \relax +% \end{macrocode} +% If no font has been allocated for |\bm| yet, then allocate it now. +% \begin{macrocode} + \expandafter\new@mathgroup\csname\@tempa\endcsname + \expandafter\new@symbolfont\csname\@tempa\endcsname + \f@encoding\f@family\f@series\f@shape +% \end{macrocode} +% Reduce by one the number of fonts we can still allocate. +% \begin{macrocode} + \advance\@tempcnta\m@ne +% \end{macrocode} +% +% \begin{macrocode} + \else +% \end{macrocode} +% Else do a similar look into the bold mathgroup. +% Use |\bm@expand| as a scratch macro to save on string space. +% \begin{macrocode} + \def\bm@expand####1##1####2####3\@nil{\def\bm@expand{####2}}% + \expandafter\expandafter\expandafter + \bm@expand\csname mv@bold\endcsname\@nil +% \end{macrocode} +% +% \begin{macrocode} + \ifx\bm@expand\@tempb +% \end{macrocode} +% If the font just found (in heavy) is the same as the font in bold +% use the slot (in normal) previously allocated for the bold font. +% (That clear?) +% \begin{macrocode} + \expandafter\let\csname\@tempa\expandafter\endcsname + \csname symbold\expandafter + \@gobblefour\string##1\endcsname +% \end{macrocode} +% +% \begin{macrocode} + \else +% \end{macrocode} +% Otherwise allocate a new slot for it. +% \begin{macrocode} + \expandafter\new@mathgroup\csname\@tempa\endcsname + \expandafter\new@symbolfont\csname\@tempa\endcsname + \f@encoding\f@family\f@series\f@shape + \advance\@tempcnta\m@ne +% \end{macrocode} +% +% \begin{macrocode} + \fi + \fi +% \end{macrocode} +% +% \begin{macrocode} + \else +% \end{macrocode} +% If the font has been allocated already, use the existing allocation. +% \begin{macrocode} + \PackageInfo{bm}% + {Symbol font \@tempa\space already defined.\MessageBreak + Not overwriting it}% + \fi +% \end{macrocode} +% Whether the font has just been allocated, or whether it was previously +% allocated, compute the offset and add it to the table. +% \begin{macrocode} + \count@\csname\@tempa\endcsname + \advance\count@-##1% + \bm@define{\the\count@\relax}% + \fi + \fi}% +% \end{macrocode} +% +% The math version list also contains information about math alphabet +% commands, but we want to ignore those here, so \ldots +% \begin{macrocode} + \let\install@mathalphabet\@gobbletwo +% \end{macrocode} +% +% Having set up the local definitions, execute the list for the normal +% math version. +% \begin{macrocode} + \mv@normal +% \end{macrocode} +% +% So now the offsets are all entered into the table, separated by +% |\or|. +% Finish off the definition by making this an |\ifcase|. Add a default +% value of zero, so that any symbol fonts declared later will also +% work, as long as a bold version is assigned to the bold math version. +% \begin{macrocode} + \expandafter\xdef\csname bm@#1table\endcsname{% + \noexpand\ifcase\@tempcnta + \csname bm@#1table\endcsname + \noexpand\else + \z@ + \noexpand\fi}% +% \end{macrocode} +% +% Put things back as they were. +% \begin{macrocode} + \expandafter\split@name\bm@general\@nil + \let\install@mathalphabet\bm@pmb + \let\getanddefine@fonts\bm@pmb@ + \let\or\bm@pmb@@} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\bmmax} +% To save declaring too many symbol fonts, do not auto-declare +% any more than |\bmmax| bold symbol fonts into the normal math +% version. Any bold fonts not so allocated will be accessed via +% |\boldmath| which is slower and doesn't work for delimiters +% and accents. It may be set in the preamble with |\newcommand| +% but use |\chardef| here for a slight efficiency gain. +% +% If this is set to a higher value before this +% package is loaded, keep that value. +% \begin{macrocode} +\ifx\bmmax\@undefined + \chardef\bmmax=4 +\fi +% \end{macrocode} +% +% If there is no bold math version, It is very easy to set up +% the table, no need to use all the tricky code above. +% Also, at the end of the package redefine the internal macro +% that |\bm| uses to call |\boldmath|, to use poor man's bold +% instead. +% \begin{macrocode} +\ifx\mv@bold\@undefined + \def\bm@boldtable{\m@ne} + \AtEndOfPackage{% + \def\bm@gr@up#1#2{% + \bm@pmb{#2}}} +\else +% \end{macrocode} +% Otherwise use the definition of |\bm| above to set up |\bm@boldtable| +% by comparing the fonts available in the normal and bold math versions. +% \begin{macrocode} + \bm{bold}\bmmax +% \end{macrocode} +% +% \begin{macro}{\mathbf} +% As the bold font has been defined as a symbol font, make |\mathbf| +% access that rather than have it allocate a new math group for the +% same font. (Just in case there were no free slots wrap this +% in an extra test.) +% \begin{macrocode} + \@ifundefined{symboldoperators} + {} + {\DeclareSymbolFontAlphabet\mathbf{boldoperators}} +% \end{macrocode} +% \end{macro} +% +% \begin{macrocode} +\fi +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\hmmax} +% +% Same for heavy (but default to three this time (enough for mathtime +% plus, as no heavy operators font). +% \begin{macrocode} +\ifx\hmmax\@undefined + \chardef\hmmax=3 +\fi +% \end{macrocode} +% +% Similarly if there is a heavy math version, set up |\bm@heavytable|. +% (If there is no heavy math version, do nothing here, as |\hm| will be +% set to |\bm| later, once that is defined.) +% \begin{macrocode} +\ifx\mv@heavy\@undefined +\else + \bm{heavy}\hmmax +\fi +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\bm@general} +% \changes{v1.0d}{1997/11/15} +% {extra code to support prime lookahead and breqn} +% \changes{v1.0h}{2002/11/22}{Pass math version as third (new) argument} +% \changes{v1.2d}{2019/07/24} +% {guard against active underscore} +% +% |\bm| is pretty much |\bmdefine\bm@command| followed by executing +% |\bm@command|. It would in principle be possible to execute the +% emboldened tokens directly, rather than building up a macro first, +% but (as I learned the hard way) it's difficult to do this in the midst +% of all these nested |\if| constructs. +% First extract the central bit of code for |\hm| |\bm| |\hmdefine| and +% |\bmdefine|. Note that in the case of the inline versions they take +% an argument and brace it, rather than relying on |\bm@general| to pick +% up the argument. This makes the code robust with respect to premature +% expansion. +% \begin{macrocode} +\begingroup +\catcode`\'=\active +\catcode`\_=\active +\@firstofone{\endgroup +\def\bm@general#1#2#3#4#5{% + \begingroup +% \end{macrocode} +% \changes{v1.0d}{1997/11/15} +% {make nested \cs{bm} vanish completely, not leave a brace group} +% First locally disable |\bm| and |\hm|, as they would mess things +% up terribly, and the original Spivak versions used the syntax +% |\bmdefine\balpha{\bm\alpha}|. +% \begin{macrocode} + \let\bm\@firstofone + \let\hm\@firstofone +% \end{macrocode} +% Now initialise the commands used to save the tokens constructed. +% \begin{macrocode} + \global\let\bm@command\@empty + \let\@let@token\@empty +% \end{macrocode} +% As we want to expand the macros to look at their definition +% turn off protection. Otherwise the |\protect| will be carried over +% and apply to the wrong token, eg |{|. +% \begin{macrocode} + \let\protect\@empty + \let\@typeset@protect\@empty +% \end{macrocode} +% Set up either bold or heavy +% \begin{macrocode} + \def\bm@mathchoice{\bm@m@thchoice#1}% + \def\bm@group{\bm@gr@up#1}% + \let\bm@table#2% +% \end{macrocode} +% Make sure |\left| and |\right| are really non expandable, +% and not |\ifx| equal to anything else. +% \changes{v1.0d}{1997/11/15} +% {make sure \cs{left} is primitive} +% \begin{macrocode} + \let\left\holdinginserts +% \end{macrocode} +% These three save on the number of |\ifx| tests below. +% \changes{v1.1a}{2003/09/01}{Forgotten to check for \cs{hskip} (pr/3572)} +% \begin{macrocode} + \let\right\left + \let\mskip\mkern + \let\hskip\kern +% \end{macrocode} +% Definition of |'| locally modified so as not to use |\futurelet| +% in the look ahead, but to make the |\prime| available at the top level +% to be made bold, or heavy or whatever. +% |'| is locally active for this definition. +% \changes{v1.0d}{1997/11/15} +% {prime code added} +% \changes{v1.0d}{1997/11/15} +% {prime code added} +% \changes{v1.2d}{2019/07/24} +% {guard against active underscore} +% \begin{macrocode} + \let\bm@prime\copy + \let_\relax + \def'{\bm@prime\prime\relax}% +% \end{macrocode} +% For optional argument commands. This expandable version of +% |\@ifnextchar| is not 100\% safe, but works for |\sqrt| unless +% you put something really strange in the arguments. +% \changes{v0.11}{1997/01/06} +% {\cs{@ifnextchar} made safe.} +% \begin{macrocode} + \def\@ifnextchar##1##2##3##4{% + \if##1##4% + \expandafter\@firstoftwo + \else + \expandafter\@secondoftwo + \fi + {##2##4}{##3{##4}}}% +% \end{macrocode} +% For Vladimir Volovich\ldots +% \changes{v1.0f}{1998/12/10} +% {Errors and warnings made safe. tools/2917} +% \begin{macrocode} + \def\GenericWarning##1##2{% + \unvcopy{\GenericWarning{##1}{##2}}}% + \def\GenericError##1##2##3##4{% + \unvcopy{\GenericError{##1}{##2}{##3}{##4}}}% +% \end{macrocode} +% For AMS definitions. +% \begin{macrocode} + \let\DN@\copy + \let\FN@\copy + \let\next@\copy + \global\let\bm@first\@empty +% \end{macrocode} +% For AMS version of |\sqrt|: don't expand just wrap in brace group +% so that it can be made bold in a safe but slow way. Do the same for +% internal accent command +% \changes{v1.1b}{2003/10/05}{AMS \cs{sqrt} not working} +% +% \changes{v1.1c}{2004/02/26}{\cs{accentV} made safe (pr/3625)} +% Code for AMS accent allows bm to be used (just) with accent +% but stops the nested accents stacking correctly, this can be +% corrected by using an extra brace group as usual. +% |\bm{{\hat{\hat{F}}}}| +% \begin{macrocode} + \ifx\uproot@\undefined\else + \def\root##1\of##2{{\root##1\of{##2}}}% + \fi + \def\mathaccentV##1{\mathaccent"\accentclass@}% +% \end{macrocode} +% For breqn definitions. +% \begin{macrocode} + \let\@ifnext\@ifnextchar + \let\measure@lhs\copy + \let \rel@break\copy + \let \bin@break\copy + \let \after@open\copy + \let \after@close\copy +% \end{macrocode} +% Make sure things like |\pounds| take the `math branch' even +% in |\bmdefine| (which is not executed in math mode). +% \begin{macrocode} + \let\ifmmode\iftrue +% \end{macrocode} +% We have to ensure that the math alphabets have definitions that +% correspond the the ``bold'' math version we are going to switch +% to. As these definitions are globally assigned when a math +% version is changed it is likely that right now we have those of +% the normal math version active. Argument |#3| holds either +% |\mv@bold| or |\mv@heavy| and we execute that after redefining +% |\install@mathalphabet| and |\getanddefine@fonts| suitably. +% The definitions are reverted back to their original the moment +% the scanning is done +% \changes{v1.0h}{2002/11/22}{Get math alphabets right (pr/3476)} +% \begin{macrocode} + \let\install@mathalphabet\def + \let\getanddefine@fonts\@gobbletwo + #3% +% \end{macrocode} +% The last redefinition just makes |\mathit| type commands re-insert +% themselves (more or less) as if they are allowed to expand +% they die horribly if the expansions are put into |\mathchoice| +% and so executed more than once. +% \begin{macrocode} + \def\select@group##1##2##3##4{{% + \protect##1{##4}}}% + \def\use@mathgroup##1##2##3{{% + \protect\use@mathgroup##1{##2}{##3}}}% +% \end{macrocode} +% +% So now start looking at the argument. +% \changes{v0.10}{1997/01/04} +% {Use \cs{bm@end}} +% \begin{macrocode} + \bm@expand#5\bm@end + \endgroup +% \end{macrocode} +% +% Finally outside the group either execute |\bm@command| (for |\bm|) +% or save its definition (for |\bmdefine|). +% \begin{macrocode} + #4} +% \end{macrocode} +% End of the |\@firstofone| above, and the scope of the active |'|. +% \begin{macrocode} +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\bm} +% \changes{v1.0d}{1997/11/15} +% {Make \cs{bm} grab its argument even when protected} +% Set up the bold (rather than heavy) version, and run |\bm@command| +% right at the end, to execute the emboldened argument. +% The argument is grabbed by the top level function, and explicitly +% braced, so that |\bm| works even if the braces are omitted round +% its argument in a `moving argument'. +% \changes{v1.0h}{2002/11/22}{Pass math version as third (new) argument} +% \begin{macrocode} +\DeclareRobustCommand\bm{% + \bm@general\boldmath\bm@boldtable\mv@bold\bm@command} +\protected@edef\bm#1{\bm{#1}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\DeclareBoldMathCommand} +% \changes{v0.07}{1996/12/14} +% {Macro added} +% \begin{macro}{\bm@declare} +% \changes{v0.07}{1996/12/14} +% {Macro added} +% |DeclareBoldMathCommand|%^^A +% \oarg{mathversion}\marg{command}\marg{math expression}\\ +% looks like |\bm| except at the end the specified command is +% globally defined to be |\bm@command|. +% The \meta{mathversion} defaults to `bold'. +% \begin{macrocode} +\def\DeclareBoldMathCommand{\@testopt\bm@declare{bold}} +% \end{macrocode} +% +% \changes{v1.0h}{2002/11/22}{Pass math version as third (new) argument} +% \begin{macrocode} +\def\bm@declare[#1]#2{% + \expandafter\bm@general + \csname #1math\expandafter\endcsname + \csname bm@#1table\expandafter\endcsname + \csname mv@#1\endcsname + {\bm@define#2}} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\bmdefine} +% |\bmdefine| Shorthand for |\DeclareBoldMathCommand[bold]|. +% +% |\bm| is empty within the definition, so that either\\ +% |\bmdefine\balpha{\bm\alpha}| or |\bmdefine\balpha{\alpha}| \\ +% may be used. (The former just for compatibility with the original +% version for plain \TeX). +% \begin{macrocode} +\def\bmdefine{\DeclareBoldMathCommand[bold]} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\hm} +% \changes{v1.0d}{1997/11/15} +% {Make \cs{hm} grab its argument even when protected} +% \begin{macro}{\hmdefine} +% Same again for |\hm|. +% \begin{macrocode} +\ifx\mv@heavy\@undefined +% \end{macrocode} +% +% If there is no heavy math version defined, let |\hm| be defined +% as |\bm|. Currently there is no warning given, perhaps there should +% be, or even an error? +% \begin{macrocode} + \let\hm\bm + \let\heavymath\boldmath + \let\bm@heavytable\bm@boldtable +% \end{macrocode} +% +% \begin{macrocode} +\else +% \end{macrocode} +% +% Otherwise define |\hm| and |\hmdefine| in direct analogy with the +% above. +% \changes{v1.0h}{2002/11/22}{Pass math version as third (new) argument} +% \begin{macrocode} + \DeclareRobustCommand\hm{% + \bm@general\heavymath\bm@heavytable\mv@heavy\bm@command} + \protected@edef\hm#1{\hm{#1}} +% \end{macrocode} +% +% \begin{macrocode} + \def\hmdefine{\DeclareBoldMathCommand[heavy]} +% \end{macrocode} +% +% \begin{macrocode} +\fi +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\bm@end} +% \changes{v0.10}{1997/01/04} +% {Macro added} +% Normally speaking |\outer| declarations should be avoided at all +% costs. (\LaTeX\ redefines all of plain \TeX's allocation macros +% to be non-outer.) However this is one place where it seems like a +% good idea. If a command taking an argument is put in |\bm| without +% its argument, then the |\@@end| terminating token would be taken as +% the argument, and so the rest of the paragraph would be gobbled up +% and the \LaTeX\ would die horribly. So make the internal terminating +% token |\outer|. (The actual test for termination is made against +% |\@@end| not |\bm@end| as this macro will be expanded by the look-ahead +% system.) +% \begin{macrocode} +\outer\def\bm@end{\@@end} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\bm@expand} +% \changes{v0.11}{1997/01/06} +% {Double up.} +% \begin{macro}{\bm@exp@nd} +% \changes{v0.11}{1997/01/06} +% {Macro added} +% |\afterassignment| trick to fully expand the following tokens until +% the first non-expandable token is revealed. This may discard a space +% token (which is what \TeX\ is looking for) but that doesn't matter in +% math mode. The expansion lookahead is done twice in case any stray +% space tokens have crept in.\footnote{The need for this was noticed +% while testing \cs{sqrt}. The definition of \cs{root} inherited from +% plain \TeX\ has an anomalous space token, that is normally harmless +% (just wastes memory), but which killed earlier versions of this +% package.} +% \begin{macrocode} +\def\bm@expand{\afterassignment\bm@exp@nd\count@`\a} +% \end{macrocode} +% +% \begin{macrocode} +\def\bm@exp@nd{\afterassignment\bm@test\count@`\a} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\bm@test} +% Normally we will grab the non-expandable token as a macro argument +% but better check it is not |{| first. Save the previous token +% so we can check later if it was |\left|, in which case use the delcode +% rather than the mathcode if the current token is a character. +% \begin{macrocode} +\def\bm@test{% + \let\bm@previous\@let@token + \futurelet\@let@token\bm@test@} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\bm@test@} +% If looking at a single token, switch to |\bm@test@token|, else if +% looking at a |{ }| group, grab the whole group with |\bm@group|. +% A |\bgroup| token will take the wrong branch here (currently not +% trapped). +% \begin{macrocode} +\def\bm@test@{% + \ifx\@let@token\bgroup + \expandafter\bm@group + \else + \expandafter\bm@test@token + \fi} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\bm@gr@up} +% \changes{v1.0c}{1997/10/09} +% {Extra brace around argument for \cs{over}} +% If faced with a group, +% If we are in math mode, stick it in a |\boldsymbol| like construct +% and then recurse on |\bm@expand|. +% Otherwise just use |\bfseries\boldmath|. +% The actual test is deferred till `run time'. +% Here and elsewhere could deal with the inner list with an inner call +% to |\bm|, but that doesn't seem to gain very much, and complicates the +% code quite a bit. +% +% |#1| is either |\boldmath| or |\heavymath|. +% Need to add an extra set of explicit braces around |#2| as otherwise +% the math style commands applied in |\mathchoice| might only apply +% to the first half of an |\over| construction. +% \begin{macrocode} +\def\bm@gr@up#1#2{% + \bm@add{{\bm@gr@@p#1{{#2}}}}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\bm@gr@@p} +% |#1| is either |\boldmath| or |\heavymath|. +% \begin{macrocode} +\def\bm@gr@@p#1#2{% + \ifmmode + \bm@mchoice#1{#2}{#2}{#2}{#2}% + \else + \bfseries#1#2% + \fi} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\bm@test@token} +% If not facing a |{ }| group then test to see what we have. +% Basic idea: Trap |\mathchardef| tokens, character tokens, and calls to +% |\mathchar|, |\mathaccent|, etc, and change the \emph{math-group} +% (fam) to point at the bold version. +% Other things just copy straight over to the command being built. +% (Anything inside a |\mathop| or similar will end up being made bold +% as the |\mathop| will be copied over, but its argument will be made +% bold by the group code above. +% \begin{macrocode} +\def\bm@test@token#1{% + \let\bm@next\@empty +% \end{macrocode} +% +% Stop here. Note that it is vital that the terminating token +% is non-expandable and defined, rather than the usual \LaTeX\ +% terminators |\@nil| or |\@@|. (Worse still would be a `quark' +% like |docstrip|'s |\qStop|.) +% \begin{macrocode} + \ifx#1\@@end +% \end{macrocode} +% +% |\bm@mathchoice| uses macro arguments, so need to make the tail +% recursion explicit here. All the other cases recurse by way of +% |\afterassignment| which means all the trailing |\fi| are eaten +% while making the assignment. +% \begin{macrocode} + \else\ifx#1\mathchoice + \let\bm@next\bm@mathchoice +% \end{macrocode} +% +% The main point: Find these expressions, and change the mathgroup. +% \begin{macrocode} + \else\ifx#1\mathchar + \afterassignment\bm@mathchar\count@ + \else\ifx#1\mathaccent + \afterassignment\bm@mathaccent\count@ + \else\ifx#1\delimiter + \afterassignment\bm@delimiter\count@ + \else\ifx#1\radical + \afterassignment\bm@radical\count@ +% \end{macrocode} +% +% Need to trap spaces otherwise digits will get turned to bold +% mathchars. +% \changes{v1.1a}{2003/09/01}{Forgotten to check for \cs{hskip} (pr/3572)} +% \begin{macrocode} + \else\ifx#1\mkern + \bm@register#1{\muskip\z@}% + \else\ifx#1\kern + \bm@register#1\skip@ + \else\ifx#1\penalty + \bm@register#1\count@ +% \end{macrocode} +% +% \changes{v1.0f}{1998/12/10} +% {Add possibility to copy brace group unmodified. tools/2917} +% |\vcopy| is a flag to copy the next group unchanged to the +% result command. +% \begin{macrocode} + \else\ifx#1\unvcopy + \let\bm@next\bm@add +% \end{macrocode} +% +% \begin{macrocode} + \else\ifcat\noexpand#1\relax +% \end{macrocode} +% Other command, look if it's a mathchardef token (otherwise just add +% it). +% \changes{v1.2a}{2016/02/27} +% {Additional quotes for testing \cs{Umathchar}} +% \begin{macrocode} + \xdef\meaning@{\meaning#1}% + \expandafter\bm@mchar@test\meaning@""""\@nil#1% +% \end{macrocode} +% \changes{v1.0d}{1997/11/15} +% {New active \cs{mathcode} code.} +% Character token. +% If it is of catcode 11 or 12, get its mathcode. +% If that is |"8000| replace the token by its active version, and then +% let bm expansion look again at the character. Being really active +% this time, it will expand away (probably). +% +% If the previous token was |\left| or |\right|, get the delcode +% instead of the mathcode. +% \begin{macrocode} + \else\ifcat.\ifcat a#1.\else#1\fi + \count@\mathcode`#1\relax + \ifnum\count@=\mathcode`\'% + \begingroup\uccode`\~`#1\uppercase{\endgroup + \def\bm@next{\bm@expand~}}% + \else + \ifx\bm@previous\left + \count@\delcode`#1\relax + \bm@delimiter + \else +% \end{macrocode} +% \changes{v1.2b}{2016/07/07} +% {Check for mathchar values being reported as if via \cs{Umathchar}} +% Here we need to check for LuaTeX merging mathchar values with Umathchar. +% \begin{macrocode} + \ifnum\count@>"8000 + \Umathcharnumdef\@tempa\count@ + \xdef\meaning@{\meaning\@tempa}% + \expandafter\bm@mchar@test\meaning@""""\@nil\@tempa + \else + \bm@mathchar + \fi +% \end{macrocode} +% +% \begin{macrocode} + \fi + \fi + \else +% \end{macrocode} +% And final possibility: +% a character token of catcode other than 11 or 12. +% \begin{macrocode} + \bm@add{#1}% + \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi + \bm@next} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\bm@define} +% \changes{v0.08}{1996/12/18} +% {Defined commands now always robust} +% End code for |\bmdefine|. Define the given command name to the +% robust form of the accumulated code. +% +% If |\bm@command| is equal to |\@gtempa| then it is a macro whose +% expansion is a single call to |\mathchar|, so that can be optimised +% with a |\mathchardef|. +% \begin{macrocode} +\def\bm@define#1{% + \begingroup + \ifx\bm@command\@gtempa + \def\mathchar{\global\mathchardef#1}% + \bm@command + \else +% \end{macrocode} +% Rather than simply |\let#1\bm@command|, make the defined command +% robust. |\bm@first| is normally empty, but might be something like +% |\DOTSI| which needs to be lifted to the top level, in front +% of any |\protect| because of the lookahead mechanism used +% in the \textsf{amsmath} package. +% \begin{macrocode} + \toks@\expandafter{\bm@command}% + \xdef#1{\bm@first\noexpand\bm@protect\noexpand#1{\the\toks@}}% + \fi + \endgroup} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\bm@protect} +% \changes{v0.08}{1996/12/18} +% {macro added} +% Commands defined by |\bmdefine| re-insert themselves +% if protection is enabled. +% \begin{macrocode} +\def\bm@protect#1{% + \ifx\protect\@typeset@protect + \expandafter\@firstofone + \else + \protect#1\expandafter\@gobble + \fi} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\bm@mchoice} +% |\boldsymbol|, more or less. +% |#1| is either |\boldmath| or |\heavymath|. +% \begin{macrocode} +\def\bm@mchoice#1#2#3#4#5{% + \mathchoice{\hbox{#1$\displaystyle\m@th#2$}}% + {\hbox{#1$\textstyle\m@th#3$}}% + {\hbox{#1$\scriptstyle\m@th#4$}}% + {\hbox{#1$\scriptscriptstyle\m@th#5$}}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\bm@m@thchoice} +% Action if you find a |\mathchoice|. Add the bold version to +% |\bm@command| then recurse. +% +% |#1| is either |\boldmath| or |\heavymath|. +% \begin{macrocode} +\def\bm@m@thchoice#1#2#3#4#5{% + \bm@add{\bm@mchoice#1{#2}{#3}{#4}{#5}}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\bm@register} +% \changes{v0.07}{1996/12/14} +% {Macro added} +% Combined code for setting up |\bm@r@gister| with the correct +% register type. +% \begin{macrocode} +\def\bm@register#1#2{% + \def\@tempa{#1\the#2}% + \afterassignment\bm@r@gister#2} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\bm@r@gister} +% \changes{v0.06}{1996/12/12} +% {Support \cs{mskip}} +% \changes{v0.07}{1996/12/14} +% {Combine all register macros} +% |\mkern| itself would transfer to |\bm@command| without any special +% test, but any explicit dimension following would be converted to +% |\mathchar|. So trap this and grab the muskip as a muskip. +% This is used in |\iiint|. |\penalty| was needed for the +% AMS version of |\colon|, and so do most of the others as well. +% \begin{macrocode} +\def\bm@r@gister{% + \bm@xadd{\@tempa\space}} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\bm@mathchar} +% \changes{v0.10}{1997/01/04} +% {Modify to use \cs{boldmath} or \cs{pmb} if needed.} +% Change the family (math group) of a mathcode and then +% use the modified code with |\mathchar|. If there is no +% suitable bold font in the current math version, use the original +% unmodified mathcode, but switch to |\boldmath| (if there is a bold +% font there) or use `poor man's bold'. Note that these other +% possibilities are only possible here, not for the otherwise similar +% code for |\delimiter| or |\mathaccent|, as those commands +% must work with fonts from the same math version. +% +% Finally recurse down the list. +% \begin{macrocode} +\def\bm@mathchar{% +% \end{macrocode} +% +% \begin{macrocode} + \@tempcntb\count@ + \let\@tempa\bm@group +% \end{macrocode} +% +% |\bm@changefam| will isolate the math group from the mathcode +% and look up the offset in the current table. +% \begin{macrocode} + \bm@changefam{}% +% \end{macrocode} +% +% If the mathcode has changed, then just add the new |\mathchar| +% (saving |\@gtempa| allows |\bmdefine| to optimise this to a +% mathchardef if it turns out to be the only symbol in the argument). +% \begin{macrocode} + \ifnum\count@>\@tempcntb +% \end{macrocode} +% +% \begin{macrocode} + \ifx\bm@command\@empty + \xdef\@gtempa{\mathchar\the\count@\space}% + \fi + \bm@xadd{\mathchar\the\count@\space}% + \else +% \end{macrocode} +% +% Otherwise grab the math class from the math code +% and add that (locally zapping |\bm@expand| as we don't want +% to recurse at this point). +% \begin{macrocode} + \begingroup + \divide\count@"1000 + \let\bm@expand\relax + \bm@xadd\bm@class + \endgroup +% \end{macrocode} +% |\@tempa| will be |\bm@group| (which applies |\boldmath| and +% |\mathchoice|) unless it was changed by |\bm@changefam| to |\bm@pmb| +% (which applies a `poor man's bold' construction in a |\mathchoice|). +% \begin{macrocode} + \edef\@tempb{% + \noexpand\@tempa{\mathchar\the\count@\space}}% + \@tempb + \fi} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\bm@umathchar} +% \changes{v1.2a}{2016/02/27} +% {Macro added} +% \changes{v1.2a}{2017/01/16} +% {Test for zero table entry (\cs{boldmath}) added} +% Version of \verb|\bm@mathchar| for \verb|\Umathchar|, this is easier +% as no need to take apart the number, the match class and fam are provided +% as distinct arguments. +% \begin{macrocode} +\def\bm@umathchar#1#2#3{% +\@tempcnta#2\relax +\count@\bm@table +\ifnum\count@=\z@ + \bm@gr@up\boldmath{\Umathchar#1 #2 #3 }% +\else + \ifnum\count@=\m@ne + \else + \advance\@tempcnta\count@ + \fi + \bm@xadd{\Umathchar#1\space + \the\@tempcnta\space\space + #3\space}% +\fi} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\bm@pmb} +% \changes{v0.10}{1997/01/04} +% {Macro added} +% Add a poor man's bold construction to the list being built. +% \begin{macrocode} +\def\bm@pmb#1{% + \bm@add{\bm@pmb@{#1}}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\bm@pmb@} +% \changes{v0.10}{1997/01/04} +% {Macro added} +% |\pmb| variant. (See \TeX{}Book, or AMS \textsf{amsbsy} package). +% This one takes a bit more care to use smaller offsets in subscripts. +% \begin{macrocode} +\def\bm@pmb@#1{{% + \setbox\tw@\hbox{$\m@th\mkern.4mu$}% + \mathchoice + \bm@pmb@@\displaystyle\@empty{#1}% + \bm@pmb@@\textstyle\@empty{#1}% + \bm@pmb@@\scriptstyle\defaultscriptratio{#1}% + \bm@pmb@@\scriptscriptstyle\defaultscriptscriptratio{#1}}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\bm@pmb@@} +% \changes{v0.10}{1997/01/04} +% {Macro added} +% Helper macro. Box |#3| and set it three times in the style |#1|, +% offset by an amount reduced by the ratio specified in |#2|. +% \begin{macrocode} +\def\bm@pmb@@#1#2#3{{% + \setbox\z@\hbox{$\m@th#1#3$}% + \dimen@#2\wd\tw@ + \rlap{\copy\z@}% + \kern\dimen@ + \raise1.5\dimen@\rlap{\copy\z@}% + \kern\dimen@ + \box\z@}}% +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\bm@class} +% \changes{v0.10}{1997/01/04} +% {Macro added} +% Convert a numeric math class back to a math class command. +% |\mathord| is omitted in class $0$ and $7$ to save space and so +% things work out right in constructions such as |x^a| where +% |x^\mathord{a}| would not work. +% \begin{macrocode} +\def\bm@class{% + \ifcase\count@ + \or + \mathop\or + \mathbin\or + \mathrel\or + \mathopen\or + \mathclose\or + \mathpunct\or + \fi} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\bm@add} +% \changes{v0.07}{1996/12/14} +% {macro added} +% A version of |\g@addto@macro| that internally uses a |\begingroup| +% rather than a brace group\footnote{This bug is fixed in the \LaTeX\ +% kernel of 1996/12/01}, to save creating a mathord. +% +% As need to redefine it anyway, save some tokens by making +% it specific to |\bm@command|, and to execute |\bm@expand| +% to continue the loop. +% \begin{macrocode} +\def\bm@add#1{% + \begingroup + \toks@\expandafter{\bm@command#1}% + \xdef\bm@command{\the\toks@}% + \endgroup + \bm@expand} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\bm@xadd} +% An |\xdef| version of |\bm@add|. +% \begin{macrocode} +\def\bm@xadd#1{% + \begingroup + \toks@\expandafter{\bm@command}% + \xdef\bm@command{\the\toks@#1}% + \endgroup + \bm@expand} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\bm@mathaccent} +% \changes{v1.0e}{1997/11/21} +% {Use bm on argument group, as spotted on c.t.t.} +% |\mathaccent| version of |\bm@mathchar|. +% \begin{macrocode} +\def\bm@mathaccent{% + \bm@changefam{}% +% \end{macrocode} +% The next four lines were added a v1.0e. Without them |\bm{\hat{A}}| +% makes the accent bold using |\bm| but the group |{A}| is made bold +% via a |\mathchoice| construction as for any other group, as |\bm| +% does not attempt to parse inside brace groups. While that produces +% something acceptable for lower case letters, it produces +% $\bm{\hat{{A}}}$ which is not too good. The braces may simply be +% omitted: +% |\bm{\hat A}| would work, producing $\bm{\hat A}$, however I did not +% want to document such a restriction, so now modify bm so that such +% brace groups are handled gracefully. +% +% It would be possible to locally make mathaccents take an argument +% during the bm look-ahead, so the brace groups would then vanish +% during expansion, however I would then need to explicitly skip past +% \meta{filler} and also make sure that the end of parse token +% was not gobbled in marginal cases like |$\bm\hat$|. +% +% So instead do the following which gets rid of \meta{filler} +% with a redefinition of |\relax|, and just locally changes +% |\bm@group| so that instead of doing a |\mathchoice| it simply adds +% |\bgroup| and |\egroup| around the tokens, and lets bm modify the +% tokens of the `argument'. This means that |\bm{\hat{A}}| now produces +%\begin{verbatim} +% \mathaccent 29790 \bgroup \mathchar 30017 \egroup +%\end{verbatim} +% The inner math list is a single mathchar, and so \TeX\ will not box +% it, and the math accent will correctly position, taking into account +% the skewchar information. +% +% As the normal bm lookahead is used, it is automatic that the parse +% will end without trying to go past |\bm@end|. +% +% One disadvantage is that the group will mean that |\bm@previous| +% will not be correctly updated. However that is only used for +% delimiter checking, so can not matter here. +% \begin{macrocode} + \begingroup + \def\bm@group##1{\endgroup\bm@xadd{\bgroup}##1\egroup}% + \def\bm@test@token{\endgroup\bm@test@token}% + \let\relax\@empty +% \end{macrocode} +% +% \begin{macrocode} + \bm@xadd{\mathaccent\the\count@\space}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\bm@delimiter} +% \changes{v1.0d}{1997/11/15} +% {Support \cs{left}. null delimiter.} +% Change both families (math groups) of a delcode and then +% use the modified code with |\delimiter|. Don't change code `0' +% as that denotes a null delimiter. +% \begin{macrocode} +\def\bm@delimiter{% + \ifnum\count@>\z@ + \bm@changefam{}% + \bm@changefam{000}% + \fi + \bm@xadd{\delimiter\the\count@\space}}% +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\bm@radical} +% Same for |\radical|. +% \begin{macrocode} +\def\bm@radical{% + \bm@changefam{}% + \bm@changefam{000}% + \bm@xadd{\radical\the\count@\space}}% +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\bm@mchar@} +% Catcode 12 |\mathchar|, for |\ifx| tests. +% \begin{macrocode} +\edef\bm@mchar@{\meaning\mathchar} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\bm@umchar@} +% \changes{v1.2a}{2016/02/27} +% {Macro added} +% Catcode 12 |\Umathchar|, for |\ifx| tests. +% \begin{macrocode} +\edef\bm@umchar@{\string\U\expandafter\@gobble\meaning\mathchar} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\bm@mchar@test} +% Test if the |\meaning| starts with |\mathchar|. If it does, grab the +% value into |\count@| and call |\bm@mathchar|, else just copy the +% command into the accumulated tokens. +% |#1|, |#2|, |#3| are all |\meaning| produced tokens, or `dummy tokens' +% added at the time this is called. |#4| is the original token, in case +% decide not to use the |\meaning|. +% \changes{v1.2a}{2016/02/27} +% {Additional arguments added} +% \begin{macrocode} +\def\bm@mchar@test#1"#2"#3"#4"#5\@nil#6{% + \xdef\meaning@{#1}% + \ifx\meaning@\bm@mchar@ + \count@"#2\relax + \bm@mathchar + \else +% \end{macrocode} +% Test for \verb|\Umathchar|. +% \begin{macrocode} + \ifx\meaning@\bm@umchar@ + \bm@umathchar{"#2}{"#3}{"#4}% + \else +% \end{macrocode} +% Some other command: copy it straight over. If it is the first thing +% added, and it is a |\relax| token, save it in |\bm@first| for use +% in |\bm@define|. +% \begin{macrocode} + \ifx\bm@previous\@empty + \ifx\relax#6% + \gdef\bm@first{#6}% + \fi + \fi + \bm@add{#6}% + \fi + \fi} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\bm@changefam} +% \changes{v0.10}{1997/01/04} +% {Rewrite for new \cs{bm@table} system} +% Pull out one specified hex digit and passes +% it to |\bm@modify| to change. argument is empty normally but |000| to +% access the second math group in a delimiter code. +% \begin{macrocode} +\def\bm@changefam#1{% + \@tempcnta\count@ + \divide\@tempcnta"1000#1 % + \multiply\@tempcnta"1000#1 % + \advance\@tempcnta-\count@ + \divide\@tempcnta-"100#1 % +% \end{macrocode} +% Having isolated the required math group (fam), look up +% the offset in the current table. +% \begin{macrocode} + \@tempcnta\bm@table +% \end{macrocode} +% If the offset is $-1$, keep |\count@| unchanged, but set |\@tempa| +% to use poor man's bold. Otherwise increment |\count@| to change the +% math group specified. +% \begin{macrocode} + \ifnum\@tempcnta=\m@ne + \let\@tempa\bm@pmb + \else + \multiply\@tempcnta"100#1 % + \advance\count@\@tempcnta + \fi} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\bm@prime} +% \changes{v1.0d}{1997/11/15} +% {Macro added} +% Support |'|. Earlier versions did not make the prime bold in a'. +% +% |\bm{a''}| will now produce (with the normal encodings) +%\begin{verbatim} +% \mathchar 30049 +% \bm@prime \mathchar 1584 \relax +% \bm@prime \mathchar 1584 \relax +%\end{verbatim} +% So |\bm@prime| does essentially the same as the active definition of +% |'|, which is to start a superscript group then keep adding |\prime| +% for each |'| (or |\bm@prime|) following. Here modified to grab a +% |\relax| delimited argument and use that instead of |\prime|. +% |\bm@prime| is locally |\let| to |'| so the |\ifx| tests in |\pr@m@s| +% don't need changing. +% \begin{macrocode} +\def\bm@prime{^\bgroup + \let\bm@prime'% + \def\prim@s##1\relax{##1\futurelet\@let@token\pr@m@s}% + \prim@s} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\boldsymbol} +% \changes{v1.0b}{1997/04/14} +% {Macro added} +% \begin{macro}{\heavysymbol} +% Finally, to ease conversion of documents between this package and +% the \textsf{amsbsy} package: +% \begin{macrocode} +\let\boldsymbol\bm +% \end{macrocode} +% +% \begin{macrocode} +\let\heavysymbol\hm +% \end{macrocode} +% \end{macro} +% \end{macro} +% \begin{macrocode} +%</package> +% \end{macrocode} +% +% \Finale +% diff --git a/macros/latex-dev/required/tools/bm.ins b/macros/latex-dev/required/tools/bm.ins new file mode 100644 index 0000000000..a148cb93ef --- /dev/null +++ b/macros/latex-dev/required/tools/bm.ins @@ -0,0 +1,75 @@ +%% +%% This file will generate fast loadable files and documentation +%% driver files from the doc files in this package when run through +%% LaTeX or TeX. +%% +%% Copyright (C) 1993-2019 +%% The LaTeX3 Project and any individual authors listed elsewhere +%% in this file. +%% +%% This file is part of the Standard LaTeX `Tools Bundle'. +%% ------------------------------------------------------- +%% +%% It may be distributed and/or modified under the +%% conditions of the LaTeX Project Public License, either version 1.3c +%% of this license or (at your option) any later version. +%% The latest version of this license is in +%% https://www.latex-project.org/lppl.txt +%% and version 1.3c or later is part of all distributions of LaTeX +%% version 2005/12/01 or later. +%% +%% As this file contains legal notices, it is NOT PERMITTED to modify +%% this file in any way that the legal information placed into +%% generated files is changed (i.e., the files generated when the +%% original file is executed). This restriction does not apply if +%% (parts of) the content is reused in a different WORK producing its +%% own generated files. +%% +%% The list of all files belonging to the `Tools Bundle' is +%% given in the file `manifest.txt'. +%% +%% +%% --------------- start of docstrip commands ------------------ +%% +\input docstrip + +\keepsilent + +\usedir{tex/latex/tools} + +\preamble + +This is a generated file. + +The source is maintained by the LaTeX Project team and bug +reports for it can be opened at https://latex-project.org/bugs/ +(but please observe conditions on bug reports sent to that address!) + +Copyright (C) 1993-2019 +The LaTeX3 Project and any individual authors listed elsewhere +in this file. + +This file was generated from file(s) of the Standard LaTeX `Tools Bundle'. +-------------------------------------------------------------------------- + +It may be distributed and/or modified under the +conditions of the LaTeX Project Public License, either version 1.3c +of this license or (at your option) any later version. +The latest version of this license is in + https://www.latex-project.org/lppl.txt +and version 1.3c or later is part of all distributions of LaTeX +version 2005/12/01 or later. + +This file may only be distributed together with a copy of the LaTeX +`Tools Bundle'. You may however distribute the LaTeX `Tools Bundle' +without such generated files. + +The list of all files belonging to the LaTeX `Tools Bundle' is +given in the file `manifest.txt'. + +\endpreamble + + +\generate{\file{bm.sty}{\from{bm.dtx}{package}}} + +\endbatchfile diff --git a/macros/latex-dev/required/tools/bm.pdf b/macros/latex-dev/required/tools/bm.pdf Binary files differnew file mode 100644 index 0000000000..a0d1d017d1 --- /dev/null +++ b/macros/latex-dev/required/tools/bm.pdf diff --git a/macros/latex-dev/required/tools/calc.dtx b/macros/latex-dev/required/tools/calc.dtx new file mode 100644 index 0000000000..0bc90f736b --- /dev/null +++ b/macros/latex-dev/required/tools/calc.dtx @@ -0,0 +1,1357 @@ +% \iffalse meta-comment +% +% Copyright (C) 1993-2019 +% +% The LaTeX3 Project and any individual authors listed elsewhere +% in this file. +% +% This file is part of the Standard LaTeX `Tools Bundle'. +% ------------------------------------------------------- +% +% It may be distributed and/or modified under the +% conditions of the LaTeX Project Public License, either version 1.3c +% of this license or (at your option) any later version. +% The latest version of this license is in +% https://www.latex-project.org/lppl.txt +% and version 1.3c or later is part of all distributions of LaTeX +% version 2005/12/01 or later. +% +% The list of all files belonging to the LaTeX `Tools Bundle' is +% given in the file `manifest.txt'. +% +% \fi +% \iffalse +%% File `calc.dtx'. +%% Copyright (C) 1992--1995 +%% Kresten Krab Thorup and Frank Jensen. +%% Copyright (C) 1997--2007 +%% Kresten Krab Thorup, Frank Jensen and the LaTeX3 Project. +%% +%% The original authors (fj@hugin.dk and krab@daimi.aau.dk) have +%% contributed this package to the LaTeX distribution. +%% Problems with this package should now be sent using latexbug.tex to +%% the normal LaTeX bug report address. +% +%<*dtx> + \ProvidesFile{calc.dtx} +%</dtx> +%<package>\NeedsTeXFormat{LaTeX2e} +%<package>\ProvidesPackage{calc} +%<driver> \ProvidesFile{calc.drv} +% \fi +% \ProvidesFile{calc.dtx} + [2017/05/25 v4.3 Infix arithmetic (KKT,FJ)] +% +% \iffalse +%<*driver> +\documentclass{ltxdoc} +\EnableCrossrefs +\RecordChanges +\usepackage{calc} +\begin{document} +\DocInput{calc.dtx} +\end{document} +%</driver> +% \fi +% +% \GetFileInfo{calc.dtx} +% +% \title{The \texttt{calc} package\\Infix notation +% arithmetic in \LaTeX\thanks{We thank Frank Mittelbach for his +% valuable comments and suggestions which have greatly improved +% this package.}} +% \author{Kresten Krab Thorup, Frank Jensen (and Chris Rowley)} +% \date{\filedate} +% +% \MaintainedByLaTeXTeam{tools} +% \maketitle +% +% \changes{v4.0d}{1997/11/08} +% {Contributed to tools distribution} +% \changes{v4.1a}{1998/06/07} +% {Added text sizes: CAR} +% \changes{v4.1a}{1998/06/07} +% {Attempt to make user-syntax robust: CAR} +% +% \newenvironment{calc-syntax} +% {\par +% \parskip\medskipamount +% \def\is{\ \hangindent3\parindent$\longrightarrow$~}% +% \def\alt{\ $\vert$~}% +% \rightskip 0pt plus 1fil +% \def\<##1>{\mbox{\NormalSpaces$\langle$##1\/$\rangle$}}% +% \IgnoreSpaces\obeyspaces% +% }{\par\vskip\parskip} +% {\obeyspaces\gdef\NormalSpaces{\let =\space}\gdef\IgnoreSpaces{\def {}}} +% +% \def\<#1>{$\langle$#1\/$\rangle$}% +% \def\s#1{\ensuremath{[\![#1]\!]}} +% \def\savecode#1{\hbox{${}_{\hookrightarrow[#1]}$}} +% \def\gassign{\Leftarrow} +% \def\lassign{\leftarrow} +% +% \begin{abstract} +% The \texttt{calc} package reimplements the \LaTeX\ commands +% |\setcounter|, |\addtocounter|, |\setlength|, and |\addtolength|. +% Instead of a simple value, these commands now accept an infix +% notation expression. +% \end{abstract} +% +% \section{Introduction} +% +% Arithmetic in \TeX\ is done using low-level operations such as +% |\advance| and |\multiply|. This may be acceptable when developing +% a macro package, but it is not an acceptable interface for the +% end-user. +% +% This package introduces proper infix notation arithmetic which is +% much more familiar to most people. The infix notation is more +% readable and easier to modify than the alternative: a sequence of +% assignment and arithmetic instructions. One of the arithmetic +% instructions (|\divide|) does not even have an equivalent in +% standard \LaTeX. +% +% The infix expressions can be used in arguments to macros (the +% \texttt{calc} package doesn't employ category code changes to +% achieve its goals).\footnote{However, it therefore assumes that the +% category codes of the special characters, such as \texttt{(*/)} +% in its syntax do not change.} +% +% \section{Informal description} +% +% Standard \LaTeX\ provides the following set of commands to +% manipulate counters and lengths \cite[pages 194 and~216]{latexman}. +% \begin{itemize} +% \item[]\hskip-\leftmargin +% |\setcounter{|\textit{ctr}|}{|\textit{num}|}| sets the +% value of the counter \textit{ctr} equal to (the value of) +% \textit{num}. (Fragile) +% \item[]\hskip-\leftmargin +% |\addtocounter{|\textit{ctr}|}{|\textit{num}|}| +% increments the value of the counter \textit{ctr} by (the +% value of) \textit{num}. (Fragile) +% +% \item[]\hskip-\leftmargin +% |\setlength{|\textit{cmd}|}{|\textit{len}|}| sets the value of +% the length command \textit{cmd} equal to (the value of) \textit{len}. +% (Robust) +% \item[]\hskip-\leftmargin +% |\addtolength{|\textit{cmd}|}{|\textit{len}|}| sets the value of +% the length command \textit{cmd} equal to its current value plus +% (the value of) \textit{len}. (Robust) +% \end{itemize} +% (The |\setcounter| and |\addtocounter| commands have global effect, +% while the |\setlength| and |\addtolength| commands obey the normal +% scoping rules.) In standard \LaTeX, the arguments to these commands +% must be simple values. The \texttt{calc} package extends these +% commands to accept infix notation expressions, denoting values of +% appropriate types. Using the \texttt{calc} package, \textit{num} is +% replaced by \<integer expression>, and \textit{len} is replaced by +% \<glue expression>. The formal syntax of \<integer expression> and +% \<glue expression> is given below. +% +% In addition to these commands to explicitly set a length, many \LaTeX\ +% commands take a length argument. After loading this package, most of +% these commands will accept a \<glue expression>. This includes +% the optional width argument of |\makebox|, the width argument of +% |\parbox|, |minipage|, and a |tabular| |p|-column, and many similar +% constructions. (This package does not redefine any of these commands, +% but they are defined by default to read their arguments by |\setlength| +% and so automatically benefit from the enhanced |\setlength| command +% provided by this package.) +% +% In the following, we shall use standard \TeX\ terminology. The +% correspondence between \TeX\ and \LaTeX\ terminology is as follows: +% \LaTeX\ counters correspond to \TeX's count registers; they hold +% quantities of type \<number>. \LaTeX\ length commands correspond to +% \TeX's dimen (for rigid lengths) and skip (for rubber lengths) +% registers; they hold quantities of types \<dimen> and \<glue>, +% respectively. +% +% \TeX\ gives us primitive operations to perform arithmetic on registers as +% follows: +% \begin{itemize} +% \item addition and subtraction on all types of quantities without +% restrictions; +% \item multiplication and division by an \emph{integer} can be +% performed on a register of any type; +% \item multiplication by a \emph{real} number (i.e., a number with a +% fractional part) can be performed on a register of any type, +% but the stretch and shrink components of a glue quantity are +% discarded. +% \end{itemize} +% The \texttt{calc} package uses these \TeX\ primitives but provides a +% more user-friendly notation for expressing the arithmetic. +% +% An expression is formed of numerical quantities (such as explicit +% constants and \LaTeX\ counters and length commands) and binary +% operators (the tokens `\texttt{+}', `\texttt{-}', `\texttt{*}', and +% `\texttt{/}' with their usual meaning) using the familiar infix +% notation; parentheses may be used to override the usual precedences +% (that multiplication/division have higher precedence than +% addition/subtraction). +% +% Expressions must be properly typed. This means, e.g., that a dimen +% expression must be a sum of dimen terms: i.e., you cannot say +% `\texttt{2cm+4}' but `\texttt{2cm+4pt}' is valid. +% +% In a dimen term, the dimension part must come first; the same holds +% for glue terms. Also, multiplication and division by non-integer +% quantities require a special syntax; see below. +% +% Evaluation of subexpressions at the same level of precedence +% proceeds from left to right. Consider a dimen term such as +% ``\texttt{4cm*3*4}''. First, the value of the factor \texttt{4cm} is +% assigned to a dimen register, then this register is multiplied +% by~$3$ (using |\multiply|), and, finally, the register is multiplied +% by~$4$ (again using |\multiply|). This also explains why the +% dimension part (i.e., the part with the unit designation) must come +% first; \TeX\ simply doesn't allow untyped constants to be assigned +% to a dimen register. +% +% The \texttt{calc} package also allows multiplication and division by +% real numbers. However, a special syntax is required: you must use +% |\real{|\<decimal constant>|}|\footnote{Actually, instead of +% \<decimal constant>, the more general \<optional signs>\<factor> can +% be used. However, that doesn't add any extra expressive power to +% the language of infix expressions.} or +% |\ratio{|\<dimen expression>|}{|\<dimen expression>|}| to denote a +% real value to be used for multiplication/division. The first form has +% the obvious meaning, and the second form denotes the number obtained +% by dividing the value of the first expression by the value of the +% second expression. +% +% A later addition to the package (in June 1998) allows an additional +% method of specifying a factor of type dimen by setting some text +% (in LR-mode) and measuring its dimensions: these are denoted as +% follows. +%\begin{quote} +% |\widthof{|\<text>|}|\quad +% |\heightof{|\<text>|}|\quad +% |\depthof{|\<text>|}| +%\end{quote} +% These calculate the natural sizes of the \<text> in exactly the +% same way as is done for the commands |\settowidth| etc.~on +% Page~216 of the manual~\cite{latexman}. +% In August 2005 the package was further extended to provide the command +%\begin{quote} +% |\totalheightof{|\<text>|}| +%\end{quote} +% This command does exactly what you'd expect from its name. +% Additionally the package also provides the command +%\begin{quote} +% |\settototalheight{|\<cmd>|}{|\<text>|}| +%\end{quote} +% +% +% Note that there is a small difference in the usage of these two +% methods of accessing text dimensions. After +% |\settowidth{\txtwd}{Some text}| you can use: +%\begin{verbatim} +% \setlength{\parskip}{0.68\txtwd} +%\end{verbatim} +% whereas using the more direct access to the width of the text +% requires the longer form for multiplication, thus: +%\begin{verbatim} +% \setlength{\parskip}{\widthof{Some text} * \real{0.68}} +%\end{verbatim} +% +% \TeX\ discards the stretch and shrink components of glue when glue +% is multiplied by a real number. So, for example, +%\begin{verbatim} +% \setlength{\parskip}{3pt plus 3pt * \real{1.5}} +%\end{verbatim} +% will set the paragraph separation to 4.5pt with no stretch or +% shrink. Incidentally, note how spaces can be used to enhance +% readability. When \TeX\ is scanning for a \<number> etc.\ it is +% common to terminate the scanning with a space token or by inserting +% \cs{relax}. As of version~4.3 \textsf{calc} allows \cs{relax} tokens +% to appear in places where they would usually be used for terminating +% \TeX's scanning. In short this is just before any of \texttt{+-*/)} +% or at the end of the expression being evaluated. +% +% When \TeX\ performs arithmetic on integers, any fractional part of +% the results are discarded. For example, +%\begin{verbatim} +% \setcounter{x}{7/2} +% \setcounter{y}{3*\real{1.6}} +% \setcounter{z}{3*\real{1.7}} +%\end{verbatim} +% will assign the value~$3$ to the counter~\texttt{x}, the value~$4$ +% to~\texttt{y}, and the value~$5$ to~\texttt{z}. This truncation +% also applies to \emph{intermediate} results in the sequential +% computation of a composite expression; thus, the following command +%\begin{verbatim} +% \setcounter{x}{3 * \real{1.6} * \real{1.7}} +%\end{verbatim} +% will assign~$6$ to~\texttt{x}. +% +% As an example of the use of |\ratio|, consider the problem of +% scaling a figure to occupy the full width (i.e., |\textwidth|) of +% the body of a page. Assume that the original dimensions of the +% figure are given by the dimen (length) variables, |\Xsize| and +% |\Ysize|. The height of the scaled figure can then be expressed by +%\begin{verbatim} +% \setlength{\newYsize}{\Ysize*\ratio{\textwidth}{\Xsize}} +%\end{verbatim} +% +% +% +% Another new feature introduced in August 2005 was $\max$ and $\min$ +% operations with associated macros +%\begin{quote} +% |\maxof{|\<\textit{type} expression>|}{|\<\textit{type} expression>|}| +% \\ +% |\minof{|\<\textit{type} expression>|}{|\<\textit{type} expression>|}| +%\end{quote} +% When \textit{type} is either \meta{glue} or \meta{dimen} these macros +% are allowed only as part of addition or subtraction but when +% \textit{type} is \meta{integer} they can also be used when +% multiplying and dividing. In the latter case they follow the +% same syntax rules as |\ratio| and |\real| which means they must come +% after the |*| or the |/|. Thus +%\begin{verbatim} +% \setcounter{x}{3*\maxof{4+5}{3*4}+\minof{2*\real{1.6}}{5-1}} +%\end{verbatim} +% will assign $3\times\max(9,12)+\min(3,4)=39$ to |x|. Similarly +%\begin{verbatim} +% \setlength{\parindent}{% +% \minof{3pt}{\parskip}*\real{1.5}*\maxof{2*\real{1.6}}{2-1}} +%\end{verbatim} +% will assign $\min(13.5\textrm{pt},4.5\cs{parskip})$ to \cs{parindent} +% +% +% +% \section{Formal syntax} +% +% The syntax is described by the following set of rules. +% Note that the definitions of \<number>, \<dimen>, \<glue>, +% \<decimal constant>, and \<plus or minus> are +% as in Chapter~24 of The \TeX book~\cite{texbook}; and \<text> +% is LR-mode material, as in the manual~\cite{latexman}. +% We use \textit{type} as a meta-variable, standing for +% `integer', `dimen', and `glue'.\footnote{This version of the +% \texttt{calc} package doesn't support evaluation of muglue expressions.} +% +% \begin{calc-syntax} +% \<\textit{type} expression>^^A +% \is \<\textit{type} term>^^A +% \alt \<\textit{type} expression> \<plus or minus> \<\textit{type} term> +% +% \<\textit{type} term>^^A +% \is \<\textit{type} term> \<\textit{type} scan stop> +% \alt \<\textit{type} factor>^^A +% \alt \<\textit{type} term> \<multiply or divide> \<integer>^^A +% \alt \<\textit{type} term> \<multiply or divide> \<real number>^^A +% \alt \<\textit{type} term> \<multiply or divide>^^A +% \<$\max$ or $\min$ integer>^^A +% +% \<\textit{type} scan stop>^^A +% \is \<empty>^^A +% \alt \<optional space>^^A +% \alt |\relax| +% +% \<\textit{type} factor>^^A +% \is \<\textit{type}>^^A +% \alt \<text dimen factor>^^A +% \alt \<$\max$ or $\min$ \textit{type}>^^A +% \alt |(|$_{12}$ \<\textit{type} expression> |)|$_{12}$ +% +% \<integer> \is \<number> +% +% \<$\max$ or $\min$ \textit{type}> \is \<$\max$ or $\min$ command>^^A +% |{| \<\textit{type} expression> |}|^^A +% |{| \<\textit{type} expression> |}| +% +% \<$\max$ or $\min$ command> \is |\maxof|^^A +% \alt |\minof| +% +% \<text dimen factor>^^A +% \is \<text dimen command>|{| \<text> |}| +% +% \<text dimen command>^^A +% \is |\widthof|^^A +% \alt |\heightof|^^A +% \alt |\depthof|^^A +% \alt |\totalheightof|^^A +% +% \<multiply or divide>^^A +% \is |*|$_{12}$^^A +% \alt |/|$_{12}$ +% +% \<real number>^^A +% \is |\ratio{| \<dimen expression> |}{| \<dimen expression> |}|^^A +% \alt |\real{| \<optional signs> \<decimal constant> |}| +% +% \<plus or minus>^^A +% \is |+|$_{12}$^^A +% \alt |-|$_{12}$ +% +% \<decimal constant>^^A +% \is |.|$_{12}$^^A +% \alt |,|$_{12}$^^A +% \alt \<digit> \<decimal constant>^^A +% \alt \<decimal constant> \<digit> +% +% \<digit>^^A +% \is |0|$_{12}$^^A +% \alt |1|$_{12}$^^A +% \alt |2|$_{12}$^^A +% \alt |3|$_{12}$^^A +% \alt |4|$_{12}$^^A +% \alt |5|$_{12}$^^A +% \alt |6|$_{12}$^^A +% \alt |7|$_{12}$^^A +% \alt |8|$_{12}$^^A +% \alt |9|$_{12}$ +% +% \<optional signs>^^A +% \is \<optional spaces>^^A +% \alt \<optional signs> \<plus or minus> \<optional spaces> +% +% \end{calc-syntax} +% +% +% Relying heavily on \TeX\ to do the underlying assignments, it is +% only natural for \texttt{calc} to simulate \TeX's parsing machinery +% for these quantities. Therefore it a)~imposes the same restrictions +% on the catcode of syntax characters as \TeX\ and b)~tries to expand +% its argument fully. a)~means that implicit characters for the tokens +% |*|$_{12}$, |/|$_{12}$, |(|$_{12}$, and |)|$_{12}$ will not +% work\footnote{e\TeX\ also assumes these catcodes when parsing a +% \cs{numexpr}, \cs{dimexpr}, \cs{glueexpr}, or \cs{muglueexpr} and +% does not allow implicit characters.} but because of~b), the +% expansion should allow you to use macros that expand to explicit +% syntax characters. +% +% +% \StopEventually{ +% \begin{thebibliography}{1} +% \bibitem{texbook} +% \textsc{D. E. Knuth}. +% \newblock \textit{The \TeX{}book} (Computers \& Typesetting Volume A). +% \newblock Addison-Wesley, Reading, Massachusetts, 1986. +% \bibitem{latexman} +% \textsc{L. Lamport}. +% \newblock \textit{\LaTeX, A Document Preparation System.} +% \newblock Addison-Wesley, Reading, Massachusetts, Second +% edition 1994/1985. +% \end{thebibliography} +% \PrintChanges +% } +% +% \section{The evaluation scheme} +% \label{evaluation:scheme} +% +% In this section, we shall for simplicity consider only expressions +% containing `$+$' (addition) and `$*$' (multiplication) operators. +% It is trivial to add subtraction and division. +% +% An expression $E$ is a sum of terms: $T_1+\cdots+T_n$; a term is a +% product of factors: $F_1*\cdots*F_m$; a factor is either a simple +% numeric quantity~$f$ (like \<number> as described in the \TeX book), +% or a parenthesized expression~$(E')$. +% +% Since the \TeX\ engine can only execute arithmetic operations in a +% machine-code like manner, we have to find a way to translate the +% infix notation into this `instruction set'. +% +% Our goal is to design a translation scheme that translates~$X$ (an +% expression, a term, or a factor) into a sequence of \TeX\ instructions +% that does the following [Invariance Property]: correctly +% evaluates~$X$, leaves the result in a global register~$A$ (using a +% global assignment), and does not perform global assignments to the +% scratch register~$B$; moreover, the code sequence must be balanced +% with respect to \TeX\ groups. We shall denote the code sequence +% corresponding to~$X$ by \s{X}. +% +% In the replacement code specified below, we use the following +% conventions: +% \begin{itemize} +% \item $A$ and $B$ denote registers; all assignments to~$A$ will +% be global, and all assignments to~$B$ will be local. +% \item ``$\gassign$'' means global assignment to the register on +% the lhs. +% \item ``$\lassign $'' means local assignment to the register on +% the lhs. +% \item ``\savecode C'' means ``save the code~$C$ until the current +% group (scope) ends, then execute it.'' This corresponds to +% the \TeX-primitive |\aftergroup|. +% \item ``$\{$'' denotes the start of a new group, and ``$\}$'' +% denotes the end of a group. +% \end{itemize} +% +% Let us consider an expression $T_1+T_2+\cdots+T_n$. Assuming that +% \s{T_k} ($1\le k\le n$) attains the stated goal, the following code +% clearly attains the stated goal for their sum: +% \begin{eqnarray*} +% \s{T_1+T_2+\cdots+T_n}&\Longrightarrow& +% \{\,\s{T_1}\,\} \; B\lassign A \quad +% \{\,\s{T_2}\,\} \; B\lassign B+A \\ +% &&\qquad \ldots \quad \{\,\s{T_n}\,\} \; B\lassign B+A +% \quad A\gassign B +% \end{eqnarray*} +% Note the extra level of grouping enclosing each of \s{T_1}, \s{T_2}, +% \ldots,~\s{T_n}. This will ensure that register~$B$, used to +% compute the sum of the terms, is not clobbered by the intermediate +% computations of the individual terms. Actually, the group +% enclosing~\s{T_1} is unnecessary, but it turns out to be simpler if +% all terms are treated the same way. +% +% The code sequence ``$\{\,\s{T_2}\,\}\;B\lassign B+A$'' can be translated +% into the following equivalent code sequence: +% ``$\{\savecode{B\lassign B+A}\,\s{T_2}\,\}$''. This observation turns +% out to be the key to the implementation: The ``$\savecode{B\lassign +% B+A}$'' is generated \emph{before} $T_2$ is translated, at the same +% time as the `$+$' operator between $T_1$ and~$T_2$ is seen. +% +% Now, the specification of the translation scheme is straightforward: +% \begin{eqnarray*} +% \s{f}&\Longrightarrow&A\gassign f\\[\smallskipamount] +% \s{(E')}&\Longrightarrow&\s{E'}\\[\smallskipamount] +% \s{T_1+T_2+\cdots+T_n}&\Longrightarrow& +% \{\savecode{B\lassign A}\,\s{T_1}\,\} \quad +% \{\savecode{B\lassign B+A}\,\s{T_2}\,\} \\ +% &&\qquad \ldots \quad \{\savecode{B\lassign B+A}\,\s{T_n}\,\} +% \quad A\gassign B +% \\[\smallskipamount] +% \s{F_1*F_2*\cdots*F_m}&\Longrightarrow& +% \{\savecode{B\lassign A}\,\s{F_1}\,\} \quad +% \{\savecode{B\lassign B*A}\,\s{F_2}\,\}\\ +% &&\qquad \ldots \quad \{\savecode{B\lassign B*A}\,\s{F_m}\,\} +% \quad A\gassign B +% \end{eqnarray*} +% By structural induction, it is easily seen that the stated property +% is attained. +% +% By inspection of this translation scheme, we see that we have to +% generate the following code: +% \begin{itemize} +% \item we must generate ``$\{\savecode{B\lassign +% A}\{\savecode{B\lassign A}$'' at the left border of an +% expression (i.e., for each left parenthesis and the implicit +% left parenthesis at the beginning of the whole expression); +% \item we must generate ``$\}A\gassign B\}A\gassign B$'' at the +% right border of an expression (i.e., each right parenthesis +% and the implicit right parenthesis at the end of the full +% expression); +% \item `\texttt{*}' is replaced by ``$\}\{\savecode{B\lassign +% B*A}$''; +% \item `\texttt{+}' is replaced by +% ``$\}A\gassign B\}\{\savecode{B\lassign +% B+A}\{\savecode{B\lassign A}$''; +% \item when we see (expect) a numeric quantity, we insert the +% assignment code ``$A\gassign$'' in front of the quantity and let +% \TeX\ parse it. +% \end{itemize} +% +% \section{Implementation} +% +% For brevity define +% \begin{calc-syntax} +% \<numeric> \is \<number> \alt \<dimen> \alt \<glue> \alt \<muglue> +% \end{calc-syntax} +% So far we have ignored the question of how to determine the type of +% register to be used in the code. However, it is easy to see that +% (1)~`$*$' always initiates an \<integer factor>, (2)~all +% \<numeric>s in an expression, except those which are part of an +% \<integer factor>, are of the same type as the whole expression, and +% all \<numeric>s in an \<integer factor> are \<number>s. +% +% We have to ensure that $A$ and~$B$ always have an appropriate type +% for the \<numeric>s they manipulate. We can achieve this by having +% an instance of $A$ and~$B$ for each type. Initially, $A$~and~$B$ +% refer to registers of the proper type for the whole expression. +% When an \<integer factor> is expected, we must change $A$ and~$B$ to +% refer to integer type registers. We can accomplish this by +% including instructions to change the type of $A$ and~$B$ to integer +% type as part of the replacement code for~`$*$; if we append such +% instructions to the replacement code described above, we also ensure +% that the type-change is local (provided that the type-changing +% instructions only have local effect). However, note that the +% instance of~$A$ referred to in $\savecode{B\lassign B*A}$ is the +% integer instance of~$A$. +% +% We shall use |\begingroup| and |\endgroup| for the open-group and +% close-group characters. This avoids problems with spacing in math +% (as pointed out to us by Frank Mittelbach). +% +% \subsection{Getting started} +% +% Now we have enough insight to do the actual implementation in \TeX. +% First, we announce the macro package.\footnote{Code moved to top of file} +% \begin{macrocode} +%<*package> +%\NeedsTeXFormat{LaTeX2e} +%\ProvidesPackage{calc}[\filedate\space\fileversion] +% \end{macrocode} +% +% \subsection{Assignment macros} +% +% \begin{macro}{\calc@assign@generic} +% \changes{v4.2}{2005/08/06}{Removed a few redundant \cs{expandafter}s} +% The |\calc@assign@generic| macro takes four arguments: (1~and~2) the +% registers to be used +% for global and local manipulations, respectively; (3)~the lvalue +% part; (4)~the expression to be evaluated. +% +% The third argument (the lvalue) will be used as a prefix to a +% register that contains the value of the specified expression (the +% fourth argument). +% +% In general, an lvalue is anything that may be followed by a variable +% of the appropriate type. As an example, |\linepenalty| and +% |\global\advance\linepenalty| may both be followed by an \<integer +% variable>. +% +% The macros described below refer to the registers by the names +% |\calc@A| and |\calc@B|; this is accomplished by +% |\let|-assignments. +% +% As discovered in Section~\ref{evaluation:scheme}, we have to +% generate code as +% if the expression is parenthesized. As described below, +% |\calc@open| is the macro that replaces a left parenthesis by its +% corresponding \TeX\ code sequence. When the scanning process sees +% the exclamation point, it generates an |\endgroup| and stops. As we +% recall from Section~\ref{evaluation:scheme}, the correct expansion +% of a right +% parenthesis is ``$\}A\gassign B\}A\gassign B$''. The remaining +% tokens of this expansion are inserted explicitly, except that the +% last assignment has been replaced by the lvalue part (i.e., +% argument~|#3| of |\calc@assign@generic|) followed by |\calc@B|. +% \begin{macrocode} +\def\calc@assign@generic#1#2#3#4{\let\calc@A#1\let\calc@B#2% + \calc@open(#4!% + \global\calc@A\calc@B\endgroup#3\calc@B} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\calc@assign@count} +% \begin{macro}{\calc@assign@dimen} +% \begin{macro}{\calc@assign@skip} +% We need three instances of the |\calc@assign@generic| macro, +% corresponding to the types \<integer>, \<dimen>, and \<glue>. +% \begin{macrocode} +\def\calc@assign@count{\calc@assign@generic\calc@Acount\calc@Bcount} +\def\calc@assign@dimen{\calc@assign@generic\calc@Adimen\calc@Bdimen} +\def\calc@assign@skip{\calc@assign@generic\calc@Askip\calc@Bskip} +% \end{macrocode} +% \end{macro}\end{macro}\end{macro} +% These macros each refer to two registers, one +% to be used globally and one to be used locally. +% We must allocate these registers. +% \begin{macrocode} +\newcount\calc@Acount \newcount\calc@Bcount +\newdimen\calc@Adimen \newdimen\calc@Bdimen +\newskip\calc@Askip \newskip\calc@Bskip +% \end{macrocode} +% +% \subsection{The \LaTeX\ interface} +% +% \begin{macro}{\setcounter} +% \begin{macro}{\addtocounter} +% \changes{v4.2}{2005/08/06} +% {Fix to make \cs{addtocounter} work with \texttt{amstext}} +% \begin{macro}{\steptocounter} +% \changes{v4.2}{2005/08/06} +% {Avoid redundant processing. PR/3795} +% \begin{macro}{\setlength} +% \begin{macro}{\addtolength} +% As promised, we redefine the following standard \LaTeX\ commands: +% |\setcounter|, +% |\addtocounter|, |\setlength|, and |\addtolength|. +% \begin{macrocode} +\def\setcounter#1#2{\@ifundefined{c@#1}{\@nocounterr{#1}}% + {\calc@assign@count{\global\csname c@#1\endcsname}{#2}}} +% \end{macrocode} +% \begin{macrocode} + \def\addtocounter#1#2{\@ifundefined{c@#1}{\@nocounterr{#1}}% + {\calc@assign@count{\global\advance\csname c@#1\endcsname}{#2}}}% +% \end{macrocode} +% We also fix \cs{stepcounter} to not go through the whole \texttt{calc} +% process. +% \begin{macrocode} + \def\stepcounter#1{\@ifundefined {c@#1}% + {\@nocounterr {#1}}% + {\global\advance\csname c@#1\endcsname \@ne + \begingroup + \let\@elt\@stpelt \csname cl@#1\endcsname + \endgroup}}% +% \end{macrocode} +% If the \texttt{amstext} package is loaded we must add the +% |\iffirstchoice@| switch as well. We patch the commands this +% way since it's good practice when we know how many arguments they take. +% \begin{macrocode} +\@ifpackageloaded{amstext}{% + \expandafter\def\expandafter\stepcounter + \expandafter#\expandafter1\expandafter{% + \expandafter\iffirstchoice@\stepcounter{#1}\fi + } + \expandafter\def\expandafter\addtocounter + \expandafter#\expandafter1\expandafter#\expandafter2\expandafter{% + \expandafter\iffirstchoice@\addtocounter{#1}{#2}\fi + } +}{} +% \end{macrocode} +% \begin{macrocode} +\DeclareRobustCommand\setlength{\calc@assign@skip} +\DeclareRobustCommand\addtolength[1]{\calc@assign@skip{\advance#1}} +% \end{macrocode} +% (|\setlength| and |\addtolength| are robust according to +% \cite{latexman}.) +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \subsection{The scanner} +% +% We evaluate expressions by explicit scanning of characters. We do +% not rely on active characters for this. +% +% The scanner consists of two parts, |\calc@pre@scan| and +% |\calc@post@scan|; |\calc@pre@scan| consumes left parentheses, and +% |\calc@post@scan| consumes binary operator, |\real|, |\ratio|, and +% right parenthesis tokens. +% +% \begin{macro}{\calc@pre@scan} +% \begin{macro}{\@calc@pre@scan} +% \changes{v4.2}{2005/08/06} +% {Added macro and force expansion} +% +% Note that this is called at least once on every use of calc +% processing, even when none of the extended syntax is present; it +% therefore needs to be made very efficient. +% +% It reads the initial part of expressions, until some \<text dimen +% factor> or \<numeric> is seen; in fact, anything not explicitly +% recognized here is taken to be a \<numeric> of some sort as this +% allows unary +% `\texttt{+}' and unary `\texttt{-}' to be treated easily and +% correctly\footnote{In the few contexts where signs are allowed: +% this could, I think, be extended (CAR).} but means that anything +% illegal will simply generate a \TeX-level error, often a +% reasonably comprehensible one! +% +% The |\romannumeral-`\a| part is a little trick which forces expansion +% in case |#1| is a normal macro, something that occurs from time to +% time. A conditional test inside will possibly leave a trailing +% \cs{fi} but this remnant is removed later when \cs{calc@post@scan} +% performs the same trick. +% +% The many |\expandafter|s are needed to efficiently end the nested +% conditionals so that |\calc@textsize| and |\calc@maxmin@addsub| can +% process their argument. +% \changes{v4.1a}{1998/06/07} +% {Added code for text sizes: CAR} +% \changes{v4.1b}{1998/07/07} +% {Correction to ifx true case} +% \changes{v4.2}{2005/08/06} +% {Added \cs{maxof} and \cs{minof} operations} +% \begin{macrocode} +\def\calc@pre@scan#1{% + \expandafter\@calc@pre@scan\romannumeral-`\a#1} +\def\@calc@pre@scan#1{% + \ifx(#1% + \expandafter\calc@open + \else + \ifx\widthof#1% + \expandafter\expandafter\expandafter\calc@textsize + \else + \ifx\maxof#1% + \expandafter\expandafter\expandafter\expandafter + \expandafter\expandafter\expandafter\calc@maxmin@addsub + \else + \calc@numeric% no \expandafter needed for this one. + \fi + \fi + \fi + #1} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\calc@open} +% \begin{macro}{\calc@initB} +% |\calc@open| is used when there is a left parenthesis right ahead. +% This parenthesis is replaced by \TeX\ code corresponding to the code +% sequence ``$\{\savecode{B\lassign A}\{\savecode{B\lassign A}$'' +% derived in Section~\ref{evaluation:scheme}. Finally, +% |\calc@pre@scan| is +% called again. +% \begin{macrocode} +\def\calc@open({\begingroup\aftergroup\calc@initB + \begingroup\aftergroup\calc@initB + \calc@pre@scan} +\def\calc@initB{\calc@B\calc@A} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \begin{macro}{\calc@numeric} +% |\calc@numeric| assigns the following value to |\calc@A| and then +% transfers control to |\calc@post@scan|. +% \begin{macrocode} +\def\calc@numeric{\afterassignment\calc@post@scan \global\calc@A} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\widthof} +% \begin{macro}{\heightof} +% \begin{macro}{\depthof} +% \changes{v4.1a}{1998/06/07} +% {Added macros: CAR} +% \begin{macro}{\totalheightof} +% \changes{v4.2}{2005/08/06} +% {Added macro} +% \changes{v4.2}{2005/08/06} +% {Added informative message for reserved macros} +% +% These do not need any particular definition when they are scanned +% so, for efficiency and robustness, we make them all equivalent to +% the same harmless (I hope) unexpandable command.\footnote{If this +% level of safety is not needed then the code can be sped up: +% CAR.} Thus the test in |\@calc@pre@scan| finds any of them. +% +% As we have to check for these commands explicitly we must ensure +% that our definition wins. Using \cs{newcommand} gives an error when +% loading \texttt{calc} and may be mildly surprising. This should be +% a little more informative. +% \begin{macrocode} +\@for\reserved@a:=widthof,heightof,depthof,totalheightof,maxof,minof\do +{\@ifundefined{\reserved@a}{}{% + \PackageError{calc}{% + The\space calc\space package\space reserves\space the\space + command\space name\space `\@backslashchar\reserved@a'\MessageBreak + but\space it\space has\space already\space been\space defined\space + with\space the\space meaning\MessageBreak + `\expandafter\meaning\csname\reserved@a\endcsname'.\MessageBreak + This\space original\space definition\space will\space be\space lost}% + {If\space you\space need\space a\space command\space with\space + this\space definition,\space you\space must\space use\space a\space + different\space name.}}% +} +\let\widthof\ignorespaces +\let\heightof\ignorespaces +\let\depthof\ignorespaces +\let\totalheightof\ignorespaces +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\calc@textsize} +% \changes{v4.1a}{1998/06/07} +% {Added macro: CAR} +% \changes{v4.1a}{1998/06/07} +% {Added macro: CAR} +% \changes{v4.2}{2005/08/06} +% {Extended macro with \cs{totalheightof}} +% The presence of the above four commands invokes this code, where +% we must distinguish them from each other. +% This implementation is somewhat optimized by using low-level +% code from the commands |\settowidth|, etc.\footnote{It is based on +% suggestions by Donald Arseneau and David Carlisle.} +% +% Within the text argument we must restore the normal meanings of +% the four user-level commands since arbitrary material can appear +% in here, including further uses of calc. +% \begin{macrocode} +\def\calc@textsize #1#2{% + \begingroup + \let\widthof\wd + \let\heightof\ht + \let\depthof\dp + \def\totalheightof{\ht\dp}% +% \end{macrocode} +% We must expand the argument one level if it's \cs{totalheightof} +% and it doesn't hurt the other three. +% \begin{macrocode} + \expandafter\@settodim\expandafter{#1}% + {\global\calc@A}% + {% + \let\widthof\ignorespaces + \let\heightof\ignorespaces + \let\depthof\ignorespaces + \let\totalheightof\ignorespaces + #2}% + \endgroup + \calc@post@scan} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\calc@post@scan} +% \begin{macro}{\@calc@post@scan} +% \changes{v4.2}{2005/08/06}{Added macro and force expansion} +% \changes{v4.3}{2007/08/22}{Discard terminating \cs{relax} tokens and +% avoid extra error message from \cs{calc@next}} +% The macro |\calc@post@scan| is called right after a value has been +% read. At this point, a binary operator, a sequence of right +% parentheses, an optional \cs{relax}, and the end-of-expression mark +% (`|!|') is allowed.\footnote{Is \texttt{!} a good choice, CAR?} +% Depending on our findings, we call a suitable macro to generate the +% corresponding \TeX\ code (except when we detect the +% end-of-expression marker: then scanning ends, and control is +% returned to |\calc@assign@generic|). +% +% This macro may be optimized by selecting a different order of +% |\ifx|-tests. The test for `\texttt{!}' (end-of-expression) is +% placed first as it will always be performed: this is the only test +% to be performed if the expression consists of a single \<numeric>. +% This ensures that documents that do not use the extra expressive +% power provided by the \texttt{calc} package only suffer a minimum +% slowdown in processing time. +% \begin{macrocode} +\def\calc@post@scan#1{% + \expandafter\@calc@post@scan\romannumeral-`\a#1} +\def\@calc@post@scan#1{% + \ifx#1!\let\calc@next\endgroup \else + \ifx#1+\let\calc@next\calc@add \else + \ifx#1-\let\calc@next\calc@subtract \else + \ifx#1*\let\calc@next\calc@multiplyx \else + \ifx#1/\let\calc@next\calc@dividex \else + \ifx#1)\let\calc@next\calc@close \else + \ifx#1\relax\let\calc@next\calc@post@scan \else + \def\calc@next{\calc@error#1}% + \fi + \fi + \fi + \fi + \fi + \fi + \fi + \calc@next} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\calc@add} +% \begin{macro}{\calc@subtract} +% \begin{macro}{\calc@generic@add} +% \begin{macro}{\calc@addAtoB} +% \begin{macro}{\calc@subtractAfromB} +% The replacement code for the binary operators `\texttt{+}' and +% `\texttt{-}' follow a common pattern; the only difference is the +% token that is stored away by |\aftergroup|. After this replacement +% code, control is transferred to |\calc@pre@scan|. +% \begin{macrocode} +\def\calc@add{\calc@generic@add\calc@addAtoB} +\def\calc@subtract{\calc@generic@add\calc@subtractAfromB} +\def\calc@generic@add#1{\endgroup\global\calc@A\calc@B\endgroup + \begingroup\aftergroup#1\begingroup\aftergroup\calc@initB + \calc@pre@scan} +\def\calc@addAtoB{\advance\calc@B\calc@A} +\def\calc@subtractAfromB{\advance\calc@B-\calc@A} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\real} +% \begin{macro}{\ratio} +% \begin{macro}{\calc@ratio@x} +% \begin{macro}{\calc@real@x} +% The multiplicative operators, `\texttt{*}' and `\texttt{/}', may be +% followed by a |\real|, |\ratio|, |\minof|, or |\maxof| token. The +% last two of these control sequences are defined by \texttt{calc} as +% they are needed by the scanner for addition or subtraction while the +% first two are not defined (at least not by the \texttt{calc} +% package); this, +% unfortunately, leaves them highly non-robust. We therefore +% equate them to |\relax| but only if they have not already been +% defined\footnote{Suggested code from David Carlisle.} +% (by some other package: dangerous but possible!); this +% will also make them appear to be undefined to a \LaTeX{} user +% (also possibly dangerous). +% \changes{v4.1a}{1998/06/07} +% {Added macro set-ups to make them robust but undefined: CAR} +% \begin{macrocode} +\ifx\real\@undefined\let\real\relax\fi +\ifx\ratio\@undefined\let\ratio\relax\fi +% \end{macrocode} +% In order to test for |\real| or |\ratio|, we define these +% two.\footnote{May not need the extra names, CAR?} +% \begin{macrocode} +\def\calc@ratio@x{\ratio} +\def\calc@real@x{\real} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \begin{macro}{\calc@multiplyx} +% \changes{v4.2}{2005/08/06} +% {Added $\protect\max$ and $\protect\min$ operations} +% \begin{macro}{\calc@dividex} +% \changes{v4.2}{2005/08/06} +% {Added $\protect\max$ and $\protect\min$ operations} +% Test which operator followed |*| or |/|. If none followed it's just +% a standard multiplication or division. +% \begin{macrocode} +\def\calc@multiplyx#1{\def\calc@tmp{#1}% + \ifx\calc@tmp\calc@ratio@x \let\calc@next\calc@ratio@multiply \else + \ifx\calc@tmp\calc@real@x \let\calc@next\calc@real@multiply \else + \ifx\maxof#1\let\calc@next\calc@maxmin@multiply \else + \let\calc@next\calc@multiply + \fi + \fi + \fi + \calc@next#1} +\def\calc@dividex#1{\def\calc@tmp{#1}% + \ifx\calc@tmp\calc@ratio@x \let\calc@next\calc@ratio@divide \else + \ifx\calc@tmp\calc@real@x \let\calc@next\calc@real@divide \else + \ifx\maxof#1\let\calc@next\calc@maxmin@divide \else + \let\calc@next\calc@divide + \fi + \fi + \fi + \calc@next#1} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\calc@multiply} +% \begin{macro}{\calc@divide} +% \begin{macro}{\calc@generic@multiply} +% \begin{macro}{\calc@multiplyBbyA} +% \begin{macro}{\calc@divideBbyA} +% The binary operators `\texttt{*}' and `\texttt{/}' also insert code +% as determined above. Moreover, the meaning of |\calc@A| and +% |\calc@B| is changed as factors following a multiplication and +% division operator always have integer type; the original meaning of +% these macros will be restored when the factor has been read and +% evaluated. +% \begin{macrocode} +\def\calc@multiply{\calc@generic@multiply\calc@multiplyBbyA} +\def\calc@divide{\calc@generic@multiply\calc@divideBbyA} +\def\calc@generic@multiply#1{\endgroup\begingroup + \let\calc@A\calc@Acount \let\calc@B\calc@Bcount + \aftergroup#1\calc@pre@scan} +\def\calc@multiplyBbyA{\multiply\calc@B\calc@Acount} +\def\calc@divideBbyA{\divide\calc@B\calc@Acount} +% \end{macrocode} +% Since the value to use in the multiplication/division operation is +% stored in the |\calc@Acount| register, the |\calc@multiplyBbyA| and +% |\calc@divideBbyA| macros use this register. +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\calc@close} +% |\calc@close| generates code for a right parenthesis (which was +% derived to be ``$\}A\gassign B\}A\gassign B$'' in +% Section~\ref{evaluation:scheme}). After this code, the control is +% returned to +% |\calc@post@scan| in order to look for another right parenthesis or +% a binary operator. +% \begin{macrocode} +\def\calc@close + {\endgroup\global\calc@A\calc@B + \endgroup\global\calc@A\calc@B + \calc@post@scan} +% \end{macrocode} +% \end{macro} +% +% \subsection{Calculating a ratio} +% +% \begin{macro}{\calc@ratio@multiply} +% \begin{macro}{\calc@ratio@divide} +% When |\calc@post@scan| encounters a |\ratio| control sequence, it hands +% control to one of the macros |\calc@ratio@multiply| or |\calc@ratio@divide|, +% depending on the preceding character. Those macros both forward the +% control to the macro |\calc@ratio@evaluate|, which performs two steps: (1) it +% calculates the ratio, which is saved in the global macro token +% |\calc@the@ratio|; (2) it makes sure that the value of |\calc@B| will be +% multiplied by the ratio as soon as the current group ends. +% +% The following macros call |\calc@ratio@evaluate| which multiplies +% |\calc@B| by the ratio, but |\calc@ratio@divide| flips the arguments +% so that the `opposite' fraction is actually evaluated. +% \begin{macrocode} +\def\calc@ratio@multiply\ratio{\calc@ratio@evaluate} +\def\calc@ratio@divide\ratio#1#2{\calc@ratio@evaluate{#2}{#1}} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \begin{macro}{\calc@Ccount} +% \begin{macro}{\calc@numerator} +% \begin{macro}{\calc@denominator} +% We shall need two registers for temporary usage in the +% calculations. We can save one register since we can reuse +% |\calc@Bcount|. +% \begin{macrocode} +\newcount\calc@Ccount +\let\calc@numerator=\calc@Bcount +\let\calc@denominator=\calc@Ccount +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \begin{macro}{\calc@ratio@evaluate} +% Here is the macro that handles the actual evaluation of ratios. The +% procedure is +% this: First, the two expressions are evaluated and coerced to +% integers. The whole procedure is enclosed in a group to be able to +% use the registers |\calc@numerator| and |\calc@denominator| for temporary +% manipulations. +% \begin{macrocode} +\def\calc@ratio@evaluate#1#2{% + \endgroup\begingroup + \calc@assign@dimen\calc@numerator{#1}% + \calc@assign@dimen\calc@denominator{#2}% +% \end{macrocode} +% Here we calculate the ratio. First, we check for negative numerator +% and/or denominator; note that \TeX\ interprets two minus signs the +% same as a plus sign. Then, we calculate the integer part. +% The minus sign(s), the integer part, and a decimal point, form the +% initial expansion of the |\calc@the@ratio| macro. +% \begin{macrocode} + \gdef\calc@the@ratio{}% + \ifnum\calc@numerator<0 \calc@numerator-\calc@numerator + \gdef\calc@the@ratio{-}% + \fi + \ifnum\calc@denominator<0 \calc@denominator-\calc@denominator + \xdef\calc@the@ratio{\calc@the@ratio-}% + \fi + \calc@Acount\calc@numerator + \divide\calc@Acount\calc@denominator + \xdef\calc@the@ratio{\calc@the@ratio\number\calc@Acount.}% +% \end{macrocode} +% Now we generate the digits after the decimal point, one at a time. +% When \TeX\ scans these digits (in the actual multiplication +% operation), it forms a fixed-point number with 16~bits for +% the fractional part. We hope that six digits is sufficient, even +% though the last digit may not be rounded correctly. +% \begin{macrocode} + \calc@next@digit \calc@next@digit \calc@next@digit + \calc@next@digit \calc@next@digit \calc@next@digit + \endgroup +% \end{macrocode} +% Now we have the ratio represented (as the expansion of the global +% macro |\calc@the@ratio|) in the syntax \<decimal constant> +% \cite[page~270]{texbook}. This is fed to |\calc@multiply@by@real| +% that will +% perform the actual multiplication. It is important that the +% multiplication takes place at the correct grouping level so that the +% correct instance of the $B$ register will be used. Also note that +% we do not need the |\aftergroup| mechanism in this case. +% \begin{macrocode} + \calc@multiply@by@real\calc@the@ratio + \begingroup + \calc@post@scan} +% \end{macrocode} +% \end{macro} +% The |\begingroup| inserted before the |\calc@post@scan| will be +% matched by the |\endgroup| generated as part of the replacement of a +% subsequent binary operator or right parenthesis. +% \begin{macro}{\calc@next@digit} +% \begin{macrocode} +\def\calc@next@digit{% + \multiply\calc@Acount\calc@denominator + \advance\calc@numerator -\calc@Acount + \multiply\calc@numerator 10 + \calc@Acount\calc@numerator + \divide\calc@Acount\calc@denominator + \xdef\calc@the@ratio{\calc@the@ratio\number\calc@Acount}} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\calc@multiply@by@real} +% In the following code, it is important that we first assign the +% result to a dimen register. Otherwise, \TeX\ won't allow us to +% multiply with a real number. +% \begin{macrocode} +\def\calc@multiply@by@real#1{\calc@Bdimen #1\calc@B \calc@B\calc@Bdimen} +% \end{macrocode} +% (Note that this code wouldn't work if |\calc@B| were a muglue +% register. This is the real reason why the \texttt{calc} package +% doesn't support muglue expressions. To support muglue expressions +% in full, the |\calc@multiply@by@real| macro must use a muglue register +% instead of |\calc@Bdimen| when |\calc@B| is a muglue register; +% otherwise, a dimen register should be used. Since integer +% expressions can appear as part of a muglue expression, it would be +% necessary to determine the correct register to use each time a +% multiplication is made.) +% \end{macro} +% +% \subsection{Multiplication by real numbers} +% +% \begin{macro}{\calc@real@multiply} +% \begin{macro}{\calc@real@divide} +% This is similar to the |\calc@ratio@evaluate| macro above, except that +% it is considerably simplified since we don't need to calculate the +% factor explicitly. +% \begin{macrocode} +\def\calc@real@multiply\real#1{\endgroup + \calc@multiply@by@real{#1}\begingroup + \calc@post@scan} +\def\calc@real@divide\real#1{\calc@ratio@evaluate{1pt}{#1pt}} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \subsection{$\max$ and $\min$ operations} +% +% \begin{macro}{\maxof} +% \begin{macro}{\minof} +% \changes{v4.2}{2005/08/06} +% {Added macros} +% With version 4.2, the $\max$ and $\min$ operators were +% added to \texttt{calc}. The user functions for them are \cs{maxof} and +% \cs{minof} respectively. +% These macros are internally similar to \cs{widthof} etc.\ in that they +% are unexpandable and easily recognizable by the scanner. +% \begin{macrocode} +\let\maxof\@@italiccorr +\let\minof\@@italiccorr +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% +% \begin{macro}{\calc@Cskip} +% \begin{macro}{\ifcalc@count@} +% The $\max$ and $\min$ operations take two arguments so we need an extra +% \<skip> register. We also add a switch for determining when to perform +% a \<skip> or a \<count> assignment. +% \begin{macrocode} +\newskip\calc@Cskip +\newif\ifcalc@count@ +% \end{macrocode} +% \end{macro} +% \end{macro} +% \begin{macro}{\calc@maxmin@addsub} +% \begin{macro}{\calc@maxmin@generic} +% \changes{v4.2}{2005/08/06}{Macros added} +% When doing addition or subtraction with a $\max$ or $\min$ operator, we +% first check if |\calc@A| is a \<count> register or not and then set the +% switch. Then call the real function which sets |\calc@A| to the desired +% value and continue as usual with |\calc@post@scan|. +% \begin{macrocode} +\def\calc@maxmin@addsub#1#2#3{\begingroup + \ifx\calc@A\calc@Acount% + \calc@count@true + \else + \calc@count@false + \fi + \calc@maxmin@generic#1{#2}{#3}% + \endgroup + \calc@post@scan +} +% \end{macrocode} +% Check the switch and do either \<count> or \<skip> assignments. Note that +% |\maxof| and |\minof| are not set to |>| and |<| until after the +% assignments, which ensures we can nest them without problems. Then set +% |\calc@A| to the correct one. +% \begin{macrocode} +\def\calc@maxmin@generic#1#2#3{% + \begingroup + \ifcalc@count@ + \calc@assign@count\calc@Ccount{#2}% + \calc@assign@count\calc@Bcount{#3}% + \def\minof{<}\def\maxof{>}% + \global\calc@A\ifnum\calc@Ccount#1\calc@Bcount + \calc@Ccount\else\calc@Bcount\fi + \else + \calc@assign@skip\calc@Cskip{#2}% + \calc@assign@skip\calc@Bskip{#3}% + \def\minof{<}\def\maxof{>}% + \global\calc@A\ifdim\calc@Cskip#1\calc@Bskip + \calc@Cskip\else\calc@Bskip\fi + \fi + \endgroup +} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\calc@maxmin@divmul} +% \begin{macro}{\calc@maxmin@multiply} +% \begin{macro}{\calc@maxmin@divide} +% \changes{v4.2}{2005/08/06}{Macros added} +% When doing division or multiplication we must be using \<count> registers +% so we set the switch. Other than that it is almost business as usual when +% multiplying or dividing. |#1| is the instruction to either multiply or +% divide |\calc@B| by |\calc@A|, |#2| is either |\maxof| or |\minof| which +% is waiting in the input stream and |#3| and |#4| are the calc expressions. +% We end it all as usual by calling |\calc@post@scan|. +% \begin{macrocode} +\def\calc@maxmin@divmul#1#2#3#4{% + \endgroup\begingroup + \calc@count@true + \aftergroup#1% + \calc@maxmin@generic#2{#3}{#4}% + \endgroup\begingroup + \calc@post@scan +} +% \end{macrocode} +% The two functions called when seeing a |*| or a |/|. +% \begin{macrocode} +\def\calc@maxmin@multiply{\calc@maxmin@divmul\calc@multiplyBbyA} +\def\calc@maxmin@divide {\calc@maxmin@divmul\calc@divideBbyA} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \section{Reporting errors} +% \begin{macro}{\calc@error} +% \changes{v4.0d}{1997/11/08} +% {Use \cs{PackageError} for error messages (DPC)} +% \changes{v4.0e}{1997/11/11} +% {typo fixed} +% If |\calc@post@scan| reads a character that is not one of `\texttt{+}', +% `\texttt{-}', `\texttt{*}', `\texttt{/}', or `\texttt{)}', an error +% has occurred, and this is reported to the user. Violations in the +% syntax of \<numeric>s will be detected and reported by \TeX. +% \changes{v4.1a}{1998/06/07} +% {Improved, I hope, error message: CAR} +% \begin{macrocode} +\def\calc@error#1{% + \PackageError{calc}% + {`#1' invalid at this point}% + {I expected to see one of: + - * / )}} +% \end{macrocode} +% \end{macro} +% +% \section{Other additions} +% \begin{macro}{\@settodim} +% \changes{v4.2}{2005/08/06} +% {Changed kernel macro} +% \begin{macro}{\settototalheight} +% \changes{v4.2}{2005/08/06} +% {Added macro} +% The kernel macro \cs{@settodim} is changed so that it runs through a list +% containing \cs{ht}, \cs{wd}, and \cs{dp} and than advance the length +% one step at a time. We just have to use a scratch register in case the +% user decides to put in a \cs{global} prefix on the length register. +% A search on the internet confirmed that some people do that kind of thing. +% \begin{macrocode} +\def\@settodim#1#2#3{% + \setbox\@tempboxa\hbox{{#3}}% + \dimen@ii=\z@ + \@tf@r\reserved@a #1\do{% + \advance\dimen@ii\reserved@a\@tempboxa}% + #2=\dimen@ii + \setbox\@tempboxa\box\voidb@x} +% \end{macrocode} +% Now the user level macro is straightforward. +% \begin{macrocode} +\def\settototalheight{\@settodim{\ht\dp}} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% That's the end of the package. +% \begin{macrocode} +%</package> +% \end{macrocode} +% +% \Finale +\endinput + diff --git a/macros/latex-dev/required/tools/calc.pdf b/macros/latex-dev/required/tools/calc.pdf Binary files differnew file mode 100644 index 0000000000..694dfa5023 --- /dev/null +++ b/macros/latex-dev/required/tools/calc.pdf diff --git a/macros/latex-dev/required/tools/changes.txt b/macros/latex-dev/required/tools/changes.txt new file mode 100644 index 0000000000..e169707750 --- /dev/null +++ b/macros/latex-dev/required/tools/changes.txt @@ -0,0 +1,1671 @@ +======================================================================= +This file lists changes to the LaTeX2e files in reverse chronological order. +It is provided for convenience only. It therefore makes no claims to +completeness or accuracy and it contains some references to files that +are not part of the distribution. +======================================================================= + + +2019-09-09 Frank Mittelbach <Frank.Mittelbach@latex-project.org> + + * varioref.dtx (subsection{Options}: + Option arabic added + +2019-08-31 Frank Mittelbach <Frank.Mittelbach@latex-project.org> + + * array.dtx: Add a necessary \expandafter so that redefinitions + of primitive specifiers give a warning (github/148) + +2019-08-25 Frank Mittelbach <Frank.Mittelbach@latex-project.org> + + * varioref.dtx: \labelformat and \Ref now available in the kernel + so removed from this package but only if running on new kernel + + (subsection{Options}): + Provide options space and nospace + + (subsection{Defining the main macros}): + Don't drop a preceding space completely but reinsert it later + after setting a label; + Command \vp@gerefstar, \vref@star and \Vref@star added to support + hyperref better + + (subsubsection{Supporting ranges}): + Added \vpagerefcompare, \vpagrefnearby and \vpagerefcomparenearby + +2019-03-01 Frank Mittelbach <Frank.Mittelbach@latex-project.org> + + * multicol.dtx (subsection{The output routines}): + Provide minrows counter for balancing. + +2019-02-06 David Carlisle <David.Carlisle@latex-project.org> + + * longtable.dtx: Document the extra color groups + +######################### +# 2019-01-05 Release +######################### + +2019-01-05 David Carlisle <David.Carlisle@latex-project.org> + + * xr.dtx: Fix to last update to avoid breaking \include handling. + (gh/106) + +2018-12-30 Frank Mittelbach <Frank.Mittelbach@latex-project.org> + + * array.dtx (section{The macros \texttt{\textbackslash @classz}): + Add extra \hskip1sp to guard against an \unskip at the start of + a c-column cell (gh/102) + +2018-12-27 Frank Mittelbach <Frank.Mittelbach@latex-project.org> + + * multicol.dtx (subsection{The output routines}): + Removed dead code, the case where this can go wrong is too + obscure to worry about it (gh/101) + +######################### +# 2018-12-01 Release +######################### + +2018-11-13 <Frank.Mittelbach@latex-project.org> + + * array.dtx: Do not expand argument of \@startpbox + while building the tabular preamble (sx/459285) + +2018-11-09 Frank Mittelbach <Frank.Mittelbach@latex-project.org> + + * multicol.dtx: + Support star with \docolaction (test first then execute) + +2018-10-13 Frank Mittelbach <Frank.Mittelbach@latex-project.org> + + * trace.dtx (section{Implementation}): + Only reset \tracingoutput if not set by \showoutput earlier + +2018-10-01 David Carlisle <David.Carlisle@latex-project.org> + + * xr.dtx: Update to handle \if tests in the aux file. + https://tex.stackexchange.com/a/452321 + +2018-09-13 Frank Mittelbach <Frank.Mittelbach@latex-project.org> + + * array.dtx (section{The macros \@classz): + Add group to prevent color leak (github/72) + +######################### +# 2018-04-01 PL 5 Release +######################### + +2018-06-26 Frank Mittelbach <Frank.Mittelbach@latex-project.org> + + * multicol.dtx (subsection{Not balancing the columns}): + Re-add end penalty for multicols* environment to guard + against leftovers (git/53) + +2018-04-30 Frank Mittelbach <Frank.Mittelbach@latex-project.org> + + * array.dtx Explicitly place the row strut inside \\ before + hitting \cr in case the last cell is a multicolumn cell + (issue 42) + +2018-04-20 Frank Mittelbach <Frank.Mittelbach@latex-project.org> + + * multicol.dtx: restoring column status when leaving a boxed + multicols so that any further \docolaction will know the + currect column (issue/39) + +2018-04-07 Frank Mittelbach <Frank.Mittelbach@latex-project.org> + + * array.dtx: Renamed internal \mcell@box to + \ar@mcellbox and \align@mcell to \ar@align@mcell + to avoid conflict with makecell package + +2018-01-28 Frank Mittelbach <Frank.Mittelbach@latex-project.org> + + * multicol.dtx: use a single output routine that does both + balancing and cutting rather than changing them + +2017-11-07 Frank Mittelbach <Frank.Mittelbach@latex-project.org> + + * array.dtx: fixed bug reported on stack exchange SX68732 about + bad vertical placement with last column being an m-column + + * array.dtx: fixed bug with m-cells when \extrarowheight is used + + * array.dtx: added w and W column types to support lcr columns with + fixed width + (see TUB paper in 38/2: https://www.latex-project.org/publications ) + +2017-09-28 David Carlisle <latex-bugs@latex-project.org> + + * tabularx.dtx: set \linewidth as well as \hsize in the column + widths documentation. + +2017-04-11 Frank Mittelbach <Frank.Mittelbach@latex-project.org> + + * multicol.dtx: Make \clearpage behave like \newpage (pr/4511) + +2017-01-16 David Carlisle <latex-bugs@latex-project.org> + + * bm.dtx: further fixes to luatex code branch for + https://tex.stackexchange.com/questions/349001 + +2016-10-06 Frank Mittelbach <Frank.Mittelbach@latex-project.org> + + * array.dtx: Fixed a 25 year old bug that surfaced for the first time. + \@halignto needs to be managed locally (pr/4488) + +2016-07-07 David Carlisle <latex-bugs@latex-project.org> + + * bm.dtx: additional tests to cope with luatex's new treatment of + \mathchar. + +2016-07-01 David Carlisle <latex-bugs@latex-project.org> + + * tabularx.dtx: show [tcb] optional argument in tabularx + syntax description. + +2016-06-07 David Carlisle <latex-bugs@latex-project.org> + + * shellesc.dtx: typos in messages, and + improve use with plain etex or luatex + +2016-04-29 David Carlisle <latex-bugs@latex-project.org> + + * shellesc.dtx: in classic tex code accidentally defined + \ShellEscape twice instead of defining \DelayedShellEscape + (Ulrike Fischer) + +2016-04-07 Frank Mittelbach <Frank.Mittelbach@latex-project.org> + + * multicol.dtx: Reset \boxmaxdepth back to \maxdimen when outputting + pages (issue SX302532). + +2016-02-27 David Carlisle <latex-bugs@latex-project.org> + + * bm.dtx: add initial support for \Umathchardef defined tokens. + +2016-02-16 Frank Mittelbach <Frank.Mittelbach@latex-project.org> + + * varioref.dtx: Delay generating a "may loop" warning or error + until we know that we aren't using \reftextfaraway + -- thanks to Morten Hoegholm for the fix + +2016-02-09 Frank Mittelbach <Frank.Mittelbach@latex-project.org> + + * varioref.dtx: revamped some of the documentation to better + explain how varioref could be used in a multi-lingual context + +2016-02-08 Frank Mittelbach <Frank.Mittelbach@latex-project.org> + + * multicol.dtx: Ensure we are back in vmode before using + \prevdepth (pr/4448) + \col@number already initialized in the kernel, so not initializing + it in the package in case the document is in two-column (pr/4435) + +2016-02-03 David Carlisle <latex-bugs@latex-project.org> + + * tabularx.dtx: support end code of {foo\endtabulax bar} again + (Reported by Ulrike Fischer) + +2016-02-02 David Carlisle <latex-bugs@latex-project.org> + + * shellesc.dtx: Documentation typos (via Johannes_B at tex.sx) + +2016-01-08 David Carlisle <latex-bugs@latex-project.org> + + * shellesc.dtx: Added new package + +2015-09-22 Frank Mittelbach <Frank.Mittelbach@latex-project.org> + + * varioref.dtx: Fixed blunder from 2005 - galician option + clearly never used + +2015-08-19 Frank Mittelbach <Frank.Mittelbach@latex-project.org> + + * multicol.dtx: Reset \@textfloatsheight after page finishes (sx261884) + +2015-04-02 Joseph Wright <joseph.wright@morningstar2.co.uk> + * TDS-style zip improvements + +2015-04-02 Joseph Wright <latex-team@latex-project.org> + * Update CTAN link in README + +2015-03-31 Frank Mittelbach <Frank.Mittelbach@latex-project.org> + + * multicol.dtx: Another rewrite of \remove@discardable@items to + capture the case of \vspace (remove) and \vspace* (keep) correctly + +2015-03-25 Frank Mittelbach <Frank.Mittelbach@latex-project.org> + + * multicol.dtx: additional tracing info if forced breaks result in + overflow of column heights + +2015-03-23 Frank Mittelbach <latex-bugs@latex-project.org> + + * multicol.dtx: Detect when columns get too large during balancing + because the user requested more forced breaks than available + columns. + + Fixed the logic for removing excess white space at column bottoms + (this is a source of trouble for sure) + +2015-03-07 Frank Mittelbach <latex-bugs@latex-project.org> + + * multicol.dtx: - Use only `0.0001fil' for stretching in \vfilmaxdepth + - Set \boxmaxdepth in multi@column@out to avoid material getting too + far down + - Redesign the implementation of \end{multicols*} + +2014-11-07 Joseph Wright <latex-bugs@latex-project.org> + + * Rename 00readme.txt to README (named README.txt in the development + repository) + +2014-10-28 Frank Mittelbach <latex-bugs@latex-project.org> + + * multicol.dtx: In \end{multicols*} only add vertical space if not + doing already doing \raggedcolumns and add \null to hide the final + fill if added so that it doesn't get removed again. + +2014-10-28 Frank Mittelbach <latex-bugs@latex-project.org> + * afterpage.dtx, array.dtx, bm.dtx, calc.dtx, dcolumn.dtx, + delarray.dtx, enumerate.dtx, ftnright.dtx, hhline.dtx, layout.dtx, + longtable.dtx, multicol.dtx, showkeys.dtx, tabularx.dtx, + theorem.dtx, trace.dtx, varioref.dtx, verbatim.dtx, xspace.dtx + + Fixed typos found by Karl Berry in documentation (no version number change) + +2014-09-12 Frank Mittelbach <latex-bugs@latex-project.org> + + * multicol.dtx: change ragged columns to not just fill the + column but also back up by \maxdepth if they otherwise become + overfull as adding glue at the bottom means the column will + never have any depth and before they had. (pr/4395) + + \maxdepth is applied to all column boxes. That was initially not + necessary as \splitmaxdepth was doing the trick. However, the + moment those boxes get reboxed this information is lost and + resulted in some subtle errors. (pr/4395) + + Suppress even really bad overfull warnings while looping + +2014-08-24 Frank Mittelbach <latex-bugs@latex-project.org> + + * multicol.dtx: set \prevdepth to 0pt (in the right place) + after adding the multicol material. Was not happening in boxed mode. + Test for excessive depth of columns using > not = (which nearly + ever will be correct) + +2014-07-03 <latex-bugs@latex-project.org> + + * varioref.dtx: correct Romanian default text as suggested + +2014-06-19 Frank Mittelbach <latex-bugs@latex-project.org> + + * multicol.dtx: color-leak fix introduced a spacing problem in + boxed mode as the added color commands were hiding any space + at the bottom of the box material (which thus didn't get + discarded) + +2014-05-14 David Carlisle <latex-bugs@latex-project.org> + + * readme.txt: rename to 00readme.txt. + +2014-05-13 David Carlisle <latex-bugs@latex-project.org> + + * tabularx.dtx: If \endtabularx not found, act as if it was at the start of + the end code. + +2014-04-24 David Carlisle <david.carlisle@latex-project.org> + + * showkeys.dtx: modify \cite redefinition so {} in the optional argument + works (tools/4162) + +2014-04-23 Frank Mittelbach <latex-bugs@latex-project.org> + + * multicol.dtx: Support \docolaction + +2014-04-22 Frank Mittelbach <latex-bugs@latex-project.org> + + * multicol.dtx: + Bug fix: color leak (https://tex.stackexchange.com/questions/138783) + Bug fix: space at column bottom (https://tex.stackexchange.com/questions/121692) + Bug fix: Reset \@mparbottom after page finishes + +2014-04-22 David Carlisle <david.carlisle@latex-project.org> + + * tabularx.dtx: allow code before \endtabularx (pr/3722) + +2012-02-06 David Carlisle <david.carlisle@latex-project.org> + + * tabularx.dtx: Avoid exceeding maxdimen + https://tex.stackexchange.com/questions/29194/how-to-typeset-tabularx-with-34-columns-error-message + +2011-12-20 Frank Mittelbach <latex-bugs@latex-project.org> + + * multicol.dtx: RL language support fixed + Support for \enlargethispage + Balancing concept improved + Bug fix: Only re-add output penalty if it was + explicit in the source. + +2011/11/24 David Carlisle <david.carlisle@latex-project.org> + + * showkeys.dtx: revert change made at v3.14 because of tools/4173 + +2011-10-02 Frank Mittelbach <latex-bugs@latex-project.org> + + * varioref.dtx: Previous fix need one more expansion +% (pr/4159,pr/4171) + +2010-11-12 Frank Mittelbach <latex-bugs@latex-project.org> + + * varioref.dtx: Avoid even \protected@edef in \vref@pagenum + to pacify french babel (pr/4093) + +2010-10-24 Frank Mittelbach <latex-bugs@latex-project.org> + + * multicol.dtx: right-to-left language support added + +2010-08-06 Frank Mittelbach <latex-bugs@latex-project.org> + + * multicol.dtx: typo corrections only -- thanks to Laurent Lyaudet + +2010-08-04 Frank Mittelbach <latex-bugs@latex-project.org> + + * varioref.dtx: Correct spacing -- same mistake as in \vref (pr/4123) + Defaults for esperanto added + +2010-04-06 Will Robertson <will.robertson@latex-project.org> + + * xspace.dtx: Improve edge case for xspace (tools/3895) + +2010-02-25 Frank Mittelbach <latex-bugs@latex-project.org> + + * ftnright.dtx: Check for split footnotes (pr/4099) + +2009-09-13 Frank Mittelbach <latex-bugs@latex-project.org> + + * varioref.dtx: Use \protected@edef to avoid problems + in complicated setups, e.g., microtype (pr/4080) + +2009-06-12 Frank Mittelbach <latex-bugs@latex-project.org> + + * varioref.dtx: Incorrect text in \reftextafter (pr/4070) + +2008-04-16 Frank Mittelbach <latex-bugs@latex-project.org> + + * varioref.dtx: clarified customization with Babel in use. + +2007-09-07 Frank Mittelbach <latex-bugs@latex-project.org> + + * varioref.dtx: Added defaults for islandic + +2007-05-26 Frank Mittelbach <latex-bugs@latex-project.org> + + * varioref.dtx: fixed missspellings of \extrasbazil and \extrasportuges + +2006-09-19 Frank Mittelbach <latex-bugs@latex-project.org> + + * multicol.dtx: Make the color of the rule between columns (if + any) a hook called \columnseprulecolor. Defaults to \normalcolor + +2006-05-23 Frank Mittelbach <latex-bugs@latex-project.org> + + * varioref.dtx: support for bulgarian added. + +2006-05-14 Frank Mittelbach <latex-bugs@latex-project.org> + + * varioref.dtx: support for croatian added. + +2006-05-08 Morten Hoegholm <latex-bugs@latex-project.org> + + * xspace.dtx: Bug fix for verbatim in output routine. + +2006-02-23 Frank Mittelbach <latex-bugs@latex-project.org> + + * multicol.dtx: Added \@minipagefalse to \end@dblfloat. Otherwise + that switch may end up being true after a figure* has ended, + messing up spacing afterwards randomly. + +2006-02-12 Morten Hoegholm <latex-bugs@latex-project.org> + + * xspace.dtx: Modified so the \@let@token can be \outer. Avoid + re-doing eTeX setup step multiple times for the original call of + \xspace. + +2006-01-09 Morten Hoegholm <latex-bugs@latex-project.org> + + * showkeys.dtx: Make \tag* and starred AMS environments work + (pr/3693). Fix varioref support so \vref* also works + (pr/3373). Added \showkeyslabelformat to avoid hard-wiring the + label format. + +2005-12-02 Frank Mittelbach <latex-bugs@latex-project.org> + + * varioref.dtx: Bahasa Malaysia defaults added. + +2005-11-26 Frank Mittelbach <latex-bugs@latex-project.org> + + * varioref.dtx: Single hyphen rather than -- in range for spanish + and galician. + +2005-11-10 Frank Mittelbach <latex-bugs@latex-project.org> + + * varioref.dtx: Added a few more brazil strings + Added a few more finnish strings + Added further galician defaults (and corrected spelling) + Corrections in italian strings + +2005-10-04 Morten Hoegholm <latex-bugs@latex-project.org> + + * xspace.dtx: Improved expansion method. Added use of higher level + functions for conditional processing. Simplified the code so that + difference between eTeX and non-eTeX is minimal. + +2005-09-27 Frank Mittelbach <latex-bugs@latex-project.org> + + * varioref.dtx: corrected typo in documentation + +2005-09-14 Frank Mittelbach <latex-bugs@latex-project.org> + + * varioref.dtx: corrected one default for polish + +2005-08-23 Morten Hoegholm <latex-bugs@latex-project.org> + + * array.dtx: Removed spurious space. + +2005-08-06 Morten Hoegholm <latex-bugs@latex-project.org> + + * calc.dtx: Improved expansion of arguments, added new + commands \maxof, \minof, \totalheightof and + \settototalheight. + +2005-07-26 Morten Hoegholm <latex-bugs@latex-project.org> + + * xspace.dtx: Improve test by exiting if \@let@token is a + letter. Add \xspaceremoveexception. + +2005-07-24 Frank Mittelbach <latex-bugs@latex-project.org> + + * varioref.dtx: small change in italian. + small fix in german and ngerman (pr/3793) + +2005-06-09 Frank Mittelbach <latex-bugs@latex-project.org> + + * varioref.dtx: fixed bug in Dutch localization (pr/3791) + added localization for romanian (pr/3790) + +2005-05-07 Morten Hoegholm <latex-bugs@latex-project.org> + + * xspace.dtx: Improve handling of active characters. + +2005-04-24 Frank Mittelbach <latex-bugs@latex-project.org> + + * varioref.dtx: Ukranian defaults added (by Mykola Lyakhovych) + +2005-04-09 Frank Mittelbach <latex-bugs@latex-project.org> + + * varioref.dtx: Basque defaults added (by I\~naki Larra\~naga + Murgoitio) + +2004-12-07 Morten Hoegholm <latex-bugs@latex-project.org> + + * xspace.dtx: Make extensible (tools/3712), fix active + characters (tools/3747) and update documentation. + +2004-10-30 Frank Mittelbach <latex-bugs@latex-project.org> + + * varioref.dtx: Added missing defaults for italian (by Lapo Mori) + +2004-07-03 Frank Mittelbach <latex-bugs@latex-project.org> + + * multicol.dtx: fixing errors that happen only if multicol is + compiled with a special combination of docstrip modules. + +2004-05-08 Frank Mittelbach <latex-bugs@latex-project.org> + + * varioref.dtx: Use \@nil for testing in \is@pos@num + +2004-02-27 Frank Mittelbach <latex-bugs@latex-project.org> + + * varioref.dtx: fixed a bug in magyar option + +2004-02-15 Frank Mittelbach <latex-bugs@latex-project.org> + + * multicol.dtx: Avoid self-referencing definition of + \@footnotetext (pr/3618) + +2003-12-29 Frank Mittelbach <latex-bugs@latex-project.org> + + * fileerr.dtx: attempt to set exit code when reading x.tex (pr/3538) + +2003-12-19 David Carlisle <latex-bugs@latex-project.org> + + * array.dtx: add \arraybackslash + +2003-10-05 Frank Mittelbach <latex-bugs@latex-project.org> + + * bm.dtx: AMS version of \sqrt not working + +2003-09-01 Frank Mittelbach <latex-bugs@latex-project.org> + + * bm.dtx: Forgotten to check for \hskip (pr/3572) + +2003-08-22 Rainer Schoepf <latex-bugs@latex-project.org> + + * verbatim.dtx: Added \@noligs again, as I can be sure that + it is defined in the LaTeX kernel, so that other packages + can rely on \@noligs always being used. + +2003-04-30 Frank Mittelbach <latex-bugs@latex-project.org> + + * trace.dtx: added option full to trace everything; set a few more + switches back to no-tracing on exit; make \tracingall trace full + even when full is not specified + +2003-04-17 Frank Mittelbach <latex-bugs@latex-project.org> + + * multicol.dtx: Catch problem with \columnbreak + in last line (found by Ulrike Fischer) + +2003-04-08 Frank Mittelbach <latex-bugs@latex-project.org> + + * multicol.dtx: Collect one additional line per column to account + for vanishing space at column breaks + +2003-03-29 Frank Mittelbach <latex-bugs@latex-project.org> + + * varioref.dtx (subsection{Options}): + Afrikaans option contributed by Danie Els <dnjels@sun.ac.za>. + +2003-03-18 Frank Mittelbach <latex-bugs@latex-project.org> + + * multicol.dtx: changed the tracing output a bit + +2003-03-15 Frank Mittelbach <latex-bugs@latex-project.org> + + * multicol.dtx: + Further corrections to the micro-spacing around the boxes produced + by multicols, so that grid typesetting (given right values for + other parameters) becomes a possibility. + Also added option "grid" which currently does nothing except + producing a warning if the grid might got lost. + +2003-02-17 Frank Mittelbach <latex-bugs@latex-project.org> + + * multicol.dtx: + Add a kern to cancel potential depth of previous line at the + beginning of a multicols and also suppsed \lineskip + + \multicolovershoot set back to 0pt as a default 2pt was simply + wrong in some applications (pr/3465) + +2003-01-10 Frank Mittelbach <latex-bugs@latex-project.org> + + * varioref.dtx: changed error message when possible loop was + detected. + + * somedefs.dtx: added version number to \ProvidesPackage line + (pr/3490) + + * varioref.dtx: typo added a blank line into one macro + +2003-01-08 Frank Mittelbach <latex-bugs@latex-project.org> + + * varioref.dtx: Use \vref@label instead of \label to avoid + problems with amsmath. (pr/3489) + +2002-11-22 Frank Mittelbach <latex-bugs@latex-project.org> + + * bm.dtx: Get math alphabets right (pr/3476) + +2002-11-06 Frank Mittelbach <latex-bugs@latex-project.org> + + * varioref.dtx: Changed default for \reftextbefore for options + english and american. + This is an incompatible change, but the original was bad English! + Changed default for \reftext...range for dutch as well. + +2002-06-18 Frank Mittelbach <latex-bugs@latex-project.org> + + * fileerr.dtx: added space after ! better to match TeX's error + style (pr/3414) + + * varioref.dtx: Use \vpageref inside \ref not \@vpageref + to get spacing correct (pr/3403) + +2002-06-14 Frank Mittelbach <latex-bugs@latex-project.org> + + * varioref.dtx: added \labelformat to support references that + automatically add "text" around the referenced number. + + added \Ref and \Vref to generated references at the beinning of a + sentence (might be needed if \reformat is used) + + added \vpagerefnum to support referencing the "number" within + commands like \refpageafter, e.g. + + \renewcommand\reftextfaceafter {on page~\thevpagerefnum} + + texts for "slovak" and "slovene" options added + +2001-09-04 Frank Mittelbach <latex-bugs@latex-project.org> + + * varioref.dtx: correct typo in name \vref -> \vr@f + +2001-07-24 Frank Mittelbach <latex-bugs@latex-project.org> + + * trace.dtx: use ltxdoc not ltugboat class for docu + +2001-05-28 Chris Rowley <latex-bugs@latex-project.org> + + * dcolumn.dtx: + + Documentation of centring improved (pr/3315) + +2001-04-16 Frank Mittelbach <latex-bugs@latex-project.org> + + * varioref.dtx: changed my mind and also added \vpagerefrange* + + * trace.dtx: added package to tools distribution + +2001-04-12 Frank Mittelbach <latex-bugs@latex-project.org> + + * varioref.dtx (subsection{Defining the main macros}): Added + \vref* and \vpageref* which do not add a space in front of the + generated text (ever) so that they can be used in situations like + (\vref{foo} ...) without added a space after the open parenthesis. + +2001-01-12 Frank Mittelbach <latex-bugs@latex-project.org> + + * varioref.dtx: Updated nynorsk defaults + +2000-12-30 Frank Mittelbach <latex-bugs@latex-project.org> + + * varioref.dtx: Updated Danish defaults + +2000-10-23 Chris Rowley <latex-bugs@latex-project.org> + + * longtable.dtx: + + Added a \noexpand (as in array.sty) for mathtext.sty + +2000-09-25 Johannes Braams <latex-bugs@latex-project.org> + + * layout.dtx: Added the option italian as suggested by Claudio + Beccari, back in august 1998... + +2000-09-21 Johannes Braams <latex-bugs@latex-project.org> + + * layout.dtx: Added the option german as proposed by Karsten + Tinnefeld <karsten@tinnefeld.com> in PR 3259 + +2000-08-23 Frank Mittelbach <latex-bugs@latex-project.org> + + * varioref.dtx: Updated defaults for catalan + +2000-08-21 Chris Rowley <latex-bugs@latex-project.org> + + * verbatim.dtx: + +2000-07-10 Frank Mittelbach <latex-bugs@latex-project.org> + + * multicol.dtx: fixed color problem with rules between columns + (their color did depend on the color of the text at the break) + +2000-07-09 Frank Mittelbach <latex-bugs@latex-project.org> + + * varioref.dtx: Don't output space if optional argument + to \vpageref is empty (pr/3230) + +2000-06-11 Frank Mittelbach <latex-bugs@latex-project.org> + + * multicol.dtx (subsection{The output routines}): when + doing boxed mode do not restrict height of columns to \@colroom + (pr/3212) + +2000-05-05 Frank Mittelbach <latex-bugs@latex-project.org> + + * multicol.dtx (subsection{Starting and ): Detect and fix + problem if a multicols ends at the top of a page + +2000-04-16 Frank Mittelbach <latex-bugs@latex-project.org> + + * varioref.dtx: added defaults for Czech + +2000-04-15 Frank Mittelbach <latex-bugs@latex-project.org> + + * ftnright.dtx: Don't use math mode for footnote symbol + (pr/3172) + +2000-01-11 Frank Mittelbach <latex-bugs@latex-project.org> + + * varioref.dtx: added naustrian and ngerman options + +2000-01-07 Rainer Schoepf <latex-bugs@latex-project.org> + + * verbatim.dtx: Disable hyphenation even if the font allows it. + +1999-12-14 Rainer Schoepf <latex-bugs@latex-project.org> + +1999-12-02 Frank Mittelbach <latex-bugs@latex-project.org> + + * varioref.dtx: even more portugese defaults + +1999-11-25 Frank Mittelbach <latex-bugs@latex-project.org> + + * varioref.dtx: added portuguese defaults + +1999-10-21 Frank Mittelbach <latex-bugs@latex-project.org> + + * multicol.dtx: allow multi-paragraph footnotes again. This functionality + was lost when the footnotes got reimplemented some time ago. (Problem + reported by Niels Ferguson) + +1999-09-03 Frank Mittelbach <latex-bugs@latex-project.org> + + * DEFAULT.hea: updated for LPPL 1.2 + + * DEFAULT.pre: updated for LPPL 1.2 + +1999-07-19 Frank Mittelbach <latex-bugs@latex-project.org> + + * multicol.dtx: + Added some additional tracing code. + When balancing check that last column doesn't contain a forced + page break; if it does reject the solution. + +1999-07-09 Frank Mittelbach <latex-bugs@latex-project.org> + + * updated headers to reflect LPPL 1.1 + +1999-06-18 Frank Mittelbach <latex-bugs@latex-project.org> + + * multicol.dtx: added documentation for \columnsep + +1999-06-12 Frank Mittelbach <latex-bugs@latex-project.org> + + * multicol.dtx: minor documentation updates + +1999-05-27 Frank Mittelbach <latex-bugs@latex-project.org> + + * tools.ins: added colbreak guard for multicol.sty + +1999-05-26 Frank Mittelbach <latex-bugs@latex-project.org> + + * multicol.dtx (subsection{Manual column breaking}): + Added a \columnbreak command to allow manual column breaks. + +1999-05-01 Frank Mittelbach <latex-bugs@latex-project.org> + + * multicol.dtx: reworded license text slightly + +1999-03-22 Frank Mittelbach <latex-bugs@latex-project.org> + + * multicol.dtx: re-add \cs{mark} command which was commented out + by mistake at some point in 1998 (pr/2978) + +1999-03-05 David Carlisle <latex-bugs@latex-project.org> + + * enumerate.dtx: extension hook tools/2916} + + * verbatim.dtx: Add \begingroup/\endgroup to definition of + \verbatim(*)/\endverbatim(*) so that they can safely be + used without \begin/\end. Suggested by Donald Arseneau. + +1999-03-04 Rainer Schoepf <latex-bugs@latex-project.org> + + * manifest.txt: Corrected typo. + +1999-03-03 Rainer Schoepf <latex-bugs@latex-project.org> + + * tools.ins: New copyright info and preamble. + +1999-02-16 Frank Mittelbach <latex-bugs@latex-project.org> + + * multicol.dtx: fixed reference to ltx3info.tex in license + +1999-02-13 David Carlisle <latex-bugs@latex-project.org> + + * readme.txt: lppl + +1999-02-10 Frank Mittelbach <latex-bugs@latex-project.org> + + * multicol.dtx: changed license text + +1998-12-31 Frank Mittelbach <latex-bugs@latex-project.org> + + * array.dtx: Added \noexpand in front of \ialign + to guard against interesting :-) changes to \halign done to support + text glyphs in math + +1998-12-03 Johannes Braams <latex-bugs@latex-project.org> + + * ftnright.dtx: Made \@makecol colorsafe by adding + \color@begingroup, \color@endgroup and \normalcolor. + +1998-11-27 Frank Mittelbach <latex-bugs@latex-project.org> + + * varioref.dtx: taken out fix for (pr/1866) as it produce undesired + results (see comments in doc of \vref) (pr/2909) + + * varioref.dtx: Added two new user commands \vrefrange and + \vpagerefrange to support referencing a range of labels. + Also added customising commands \reftextlabelrange and + \reftextpagerange to support the above commands. + Added draft and final option (draft will turn errors into warnings). + Added austrian defaults (same a german). + Added greek defaults. + Removed incorrect warning for italian. + Added hungarian defaults. + Added russian defaults. + Added utility command \vrefpagenum and used it to shorten code + this will also fix a problem that in certain circumstances varioref + was not warning that another run was needed. + +1998-09-16 Frank Mittelbach <latex-bugs@latex-project.org> + + * multicol.dtx: test if document ends in middle of multicols + and if so issue an error message instead of dying with an OR loop + pr/2873 + +1998-08-17 Frank Mittelbach <latex-bugs@latex-project.org> + + * multicol.dtx: new logic for dealing with \@footnotetext macro: + instead of redefining its definition completely, thereby possibly + overwriting a class change, we locally set \columnwidth to \textwidth + and then call the original definition. this will also solves a problem + with the situation of a footnote inside multicols inside a minipage + would vanish. + + * varioref.dtx: added defaults for greek contributed by + Apostolos Syropoulos <apostolo@obelix.ee.duth.gr> + +1998-06-22 Frank Mittelbach <latex-bugs@latex-project.org> + + * layout.dtx: renamed \bs to \LayOutbs to avoid possible conflicts + with other packages using this command. Originally the package + redefined \bs in case it already had a definition. + Also rename \type to \LayOuttype for the same reason. + + Added \@doendpe to definition of + \endverbatim(*) (pr/3234) + +1998-06-17 Chris Rowley <latex-bugs@latex-project.org> + + * calc.dtx: + + Added \widthof etc + + Made \ratio and \real robust + + Enhanced documentation +2004-02-27 <david.carlisle@latex-project.org> + + * bm.sty: fix for "new" AMS math accent code. tools/3256 + +2004-02-01 <david.carlisle@latex-project.org> + + * longtable.dtx: \nobreak after table head, for tools/3484 + +1998-05-13 David Carlisle <latex-bugs@latex-project.org> + + * tabularx.dtx: Use \setlength so calc syntax may be used in + the width argument. tools/2793. + + * longtable.dtx: Use \setlength so calc syntax may be used in p + arguments. tools/2793. + +1998-05-13 Frank Mittelbach <latex-bugs@latex-project.org> + + * array.dtx: also allow calc syntax in first arg of tabular* + (pr/2793) + +1998-05-12 Frank Mittelbach <latex-bugs@latex-project.org> + + * array.dtx: set the \hsize for p columns (and others) via + \setlength so that calc syntax can be applied (pr/2793) + +1998-05-10 Frank Mittelbach <latex-bugs@latex-project.org> + + * varioref.dtx: support for amsmath displays (pr2175) + Actually this probably should be fixed in amsmath instead. + +1998-04-25 Frank Mittelbach <latex-bugs@latex-project.org> + + * varioref.dtx: added galician defaults contributed by Matthias + Moebius. + +1998-03-09 Frank Mittelbach <latex-bugs@latex-project.org> + + * varioref.dtx: replace ~ by \nobreak\space so that \vref obeys + setting of \frenchspacing (pr/1866) + +1998-01-29 Frank Mittelbach <latex-bugs@latex-project.org> + + * multicol.dtx: Removed group around contents of optional argument + to \begin{multicols}{2}[...] so that the use of \section within + this argument works better. + + * array.dtx: made \multicolumn long to match kernel change for + pr/2180 (forgotten at that time) + +1998-01-19 Frank Mittelbach <latex-bugs@latex-project.org> + + * multicol.dtx (subsection{Not balancing the columns}): + added support for a version of multicols (star form) that doesn't + balance the columns on the last page. + Fixed a bit of the documentation (so that a toc is possible). + +1997-12-19 Frank Mittelbach <latex-bugs@latex-project.org> + + * array.dtx: moving a docstrip guard. this doesn't change + the style but prevents some code being added at the end of + the driver file + +1997-12-14 Frank Mittelbach <latex-bugs@latex-project.org> + + * multicol.dtx: redefine \@footnotetext only within environment + not globally any longer. pr/2689 + some docu updates + + * fileerr.dtx: fixed file date. pr/2689 + +1997-12-06 Frank Mittelbach <latex-bugs@latex-project.org> + + * varioref.dtx: added default for polish language. + +1997-11-22 David Carlisle <latex-bugs@latex-project.org> + + * bm.dtx: Make \bm{\hat{A}} work like \bm{\hat A} (from c.t.t). + +1997-11-18 Frank Mittelbach <latex-bugs@latex-project.org> + + * multicol.dtx: now finally set \columnwidth to width of column + pr2664 + +1997-11-16 David Carlisle <latex-bugs@latex-project.org> + + * bm.dtx: support mathcode hex 8000 (like prime) properly. + Support null delimiter \left. constructions. + Support breqn package. + +1997-11-11 David Carlisle <latex-bugs@latex-project.org> + + * calc.dtx: Fix error message inserted at the weekend. + +1997-11-08 David Carlisle <latex-bugs@latex-project.org> + + * manifest.txt: add calc. + + * Makefile (FILES): add calc + + * tools.ins: add calc. + + * calc.dtx: Contributed to the distribution by + Kresten Krab Thorup and Frank Jensen. One minor change, use + \PackageError rather than the primitive \errormessge. + +1997-10-16 David Carlisle <latex-bugs@latex-project.org> + + * longtable.dtx: avoid using % in aux file. tools/2631 + +1997-10-13 David Carlisle <latex-bugs@latex-project.org> + + * xspace.dtx: test for space token added for tools/2632 + +1997-10-09 David Carlisle <latex-bugs@latex-project.org> + + * bm.dtx: Add extra braces around group code so \bm{\frac..} does + the right thing. (Spotted on c.t.t) + +1997-10-06 David Carlisle <latex-bugs@latex-project.org> + + * dcolumn.dtx: Document use of math mode. tools/2616. + +1997-09-18 David Carlisle <latex-bugs@latex-project.org> + + * tabularx.dtx: Fix \write catch for tools/2607. + (Fix page 401 of TeXBook at same time...) + +1997-07-09 Rainer Schoepf <latex-bugs@latex-project.org> + + * verbatim.dtx: Documentation fixes by Andreas Schwab + <schwab@issan.informatik.uni-dortmund.de>. + + * tabularx.dtx: Documentation fixes by Andreas Schwab + <schwab@issan.informatik.uni-dortmund.de>. + + * showkeys.dtx: Documentation fixes by Andreas Schwab + <schwab@issan.informatik.uni-dortmund.de>. + + * multicol.dtx: Documentation fixes by Andreas Schwab + <schwab@issan.informatik.uni-dortmund.de>. + + * longtable.dtx: Documentation fixes by Andreas Schwab + <schwab@issan.informatik.uni-dortmund.de>. + + * layout.dtx: Documentation fixes by Andreas Schwab + <schwab@issan.informatik.uni-dortmund.de>. + + * delarray.dtx: Documentation fixes by Andreas Schwab + <schwab@issan.informatik.uni-dortmund.de>. + + * array.dtx: Documentation fixes by Andreas Schwab + <schwab@issan.informatik.uni-dortmund.de>. + +1997-07-07 Frank Mittelbach <latex-bugs@latex-project.org> + + * tools.ins: added q.tex and r.tex files so that "run" and + "quit" mode is now also supported. + + * fileerr.dtx: added q.tex and r.tex files so that "run" and + "quit" mode is now also supported. + +1997-06-28 David Carlisle <latex-bugs@latex-project.org> + + * longtable.dtx: New email address for David K. + +1997-06-13 David Carlisle <latex-bugs@latex-project.org> + + * showkeys.dtx: support cite package for tools/2490 + +1997-06-12 Frank Mittelbach <latex-bugs@latex-project.org> + + * varioref.dtx: added support for catalan + +1997-06-05 Rainer Schoepf <latex-bugs@latex-project.org> + + * multicol.dtx: Applied improvement of documentation, kindly done + by Robin Fairbairns. + +1997-05-13 Rainer Schoepf <latex-bugs@latex-project.org> + + * fontsmpl.dtx: Replaced \@changed@x@err by + \TextSymbolUnavailable, according to the change in ltoutenc.dtx. + +1997-04-30 Rainer Schoepf <latex-bugs@latex-project.org> + + * verbatim.dtx (\verbatiminput): Added code to check for + existence of file to be input and print error message if not. + +1997-04-14 David Carlisle <latex-bugs@latex-project.org> + + * tools.ins: add bm + + * bm.dtx: Add to tools bundle. + Add \boldsymbol as alias for \bm + +1997-02-26 David Carlisle <latex-bugs@latex-project.org> + + * tabularx.dtx: Spurious brace removed. Jean-Pierre Drucbert. + +1997-02-20 David Carlisle <latex-bugs@latex-project.org> + + * tabularx.dtx: improve behaviour in case table too wide. + +1996-12-06 David Carlisle <latex-bugs@latex-project.org> + + * xspace.dtx: alltt support. tools/2322. + +1996-11-21 David Carlisle <latex-bugs@latex-project.org> + + * longtable.dtx: new page break control. + +1996-11-02 David Carlisle <latex-bugs@latex-project.org> + + * readme.txt: Add old docstrip note. + +1996-11-01 David Carlisle <latex-bugs@latex-project.org> + + * showkeys.dtx: colour option. tools/2297. + + * tools.ins: new style. + +1996-10-24 David Carlisle <latex-bugs@latex-project.org> + + * xspace.dtx: Fix guards for driver document. tools/2206 + +1996-09-25 Rainer Schoepf <latex-bugs@latex-project.org> + + * verbatim.dtx (\verbatiminput): Added \@addtofilelist and + \ProvidesFile so that the name of the file read in appears in the + \listfiles output. + +1996-09-23 David Carlisle <latex-bugs@latex-project.org> + + * dcolumn.dtx: Fix case where no decimal point is used + in the `new' case of a the third argument being n.m. + +Fri Sep 6 15:24:17 1996 David Carlisle <carlisle@cs.man.ac.uk> + + * showkeys.dtx: more changes following from /2252. + +Fri Aug 30 18:09:48 1996 David Carlisle <carlisle@cs.man.ac.uk> + + * showkeys.dtx: more fudges for AMS tools/2252, and extra + group from Donald A. tools/2147 + +Wed Jul 10 11:15:30 1996 David Carlisle <carlisle@cs.man.ac.uk> + + * showkeys.dtx: Missing percent added for tools/2215 + +1996-06-14 David Carlisle <latex-bugs@latex-project.org> + + * array.dtx: change \kern\z@ to \hskip1sp for latex/2160 + A few long lines wrapped. + +1996-06-04 Rainer Schoepf <latex-bugs@latex-project.org> + + * verbatim.dtx: \verbatim@noligs@list now processed after + \dospecials (PR 2138). + +1996-05-25 Frank Mittelbach <latex-bugs@latex-project.org> + + * array.dtx (subsection{Support for + \texttt{\textbackslash firsthline} and ): + Complete reimplementation after Mark Wooding pointed out that + they were everything else than correct --- hope i got it + right this time :-) + +1996-05-24 David Carlisle <latex-bugs@latex-project.org> + + * longtable.dtx: Add a warning to re run LaTeX \AtEndDocument if + any longtable has failed to align on this run. + +1996-05-17 David Carlisle <latex-bugs@latex-project.org> + + * xspace.dtx: Add / to list of punctuation characters. + + * showkeys.dtx: use \protected@edef rather than \def + so that the expansion of any macros is printed. tools/2147 + +1996-05-07 David Carlisle <latex-bugs@latex-project.org> + + * longtable.dtx: add \hfil to match array package change. + + * array.dtx: add \hfil to \@endpbox for tools/2120 (and to match + kernel version). + +1996-04-22 David Carlisle <latex-bugs@latex-project.org> + + * array.dtx: Extra \kern\z@ for empty l colummns. latex/2122 + +1996-04-16 David Carlisle <latex-bugs@latex-project.org> + + * longtable.dtx: Version 4.02 using new algorithm of David Kastrup + to align tables without \setlongtables command. + +1996-02-28 David Carlisle <latex-bugs@latex-project.org> + + * dcolumn.dtx: New feature (tools/2093) D{.}{.}{3.2} specifies a + column of figures that should be centred, assuming 3 places to + the left of the decimal point and 2 to the right. + +1996-02-01 David Carlisle <latex-bugs@latex-project.org> + + * longtable.dtx: allow \multicolumn and \hline to work inside + tabulars inside longtables. tools/2068 + +1996-01-13 Frank Mittelbach <latex-bugs@latex-project.org> + + * multicol.dtx: + Explain why with \OnlyDescription there will be an unresolved + reference pr/2047. + +1996-01-03 David Carlisle <latex-bugs@latex-project.org> + + * longtable.dtx: (Martin Schr"oder) remove ! which causes a + makeindex error in \changes entry. tools/2035 + +1996-01-01 Frank Mittelbach <latex-bugs@latex-project.org> + + * ftnright.dtx: + Finally got around to take out ltxdoc and use article for + documentation. pr/536 + Also cleaned up use of ProvidesPackage. + +1995-12-28 Frank Mittelbach <latex-bugs@latex-project.org> + + * array.dtx: + Fixed section headings so that a toc is possible. pr/2033. + + * multicol.dtx: + Fixed index entries. pr/2036 + +1995-12-12 David Carlisle <latex-bugs@latex-project.org> + + * tools.dst: Add trap for old docstrip. + +1995-11-23 David Carlisle <latex-bugs@latex-project.org> + + * theorem.dtx: Fix \@newctr usage (Ulrik Vieth) + + * layout.dtx: Documentation fixes (J"org Knappen). + + * indentfirst.dtx: (Ulrik Vieth) Fix \GetFileInfo usage. + In the documentation. + +1995-11-22 David Carlisle <latex-bugs@latex-project.org> + + * tools.dst: New style concurrent generation. + + * showkeys.dtx: Fix \harvarditem: add SK code after the implicit + \item (as for \cite) not before. + +1995-11-19 Frank Mittelbach <latex-bugs@latex-project.org> + + * theorem.dtx: + Ensure that there is an error message if one of the counters + in newtheorem are undefined pr/1861. + + * array.dtx (subsection{Getting the spacing around rules right}): + ensure that the space between \hline\hline is visually \doublerulesep + and does not depend of the rulewidth (as it does with standard latex) + pr/1945 + Added some documentation about rule handling concepts. + +1995-11-09 David Carlisle <latex-bugs@latex-project.org> + + * longtable.dtx: (Anil K Goel) Really measure the size of the + first row of the table not `assume' the size from the array + strut. (Avoids really bad first page break with two headings) + + * showkeys.dtx: Take more care over redefining \protect commands + +1995-11-02 David Carlisle <latex-bugs@latex-project.org> + + * array.dtx: Minor doc changes, no more ooverfull hboxes... + +1995-10-30 Johannes Braams <latex-bugs@latex-project.org> + + * layout.dtx : Added command \layout* wbhich recomputes the values + it needs before making the picture of the layout. (PR 1465) + +1995-10-30 David Carlisle <latex-bugs@latex-project.org> + + * showkeys.dtx: Fix for tools/1744 (notref/varioref case) + Add final and draft options + Fix inner vmode case which could cause extra white space + to be added. + +1995-10-29 Johannes Braams <latex-bugs@latex-project.org> + + * layout.dtx (section{The implementation}): Added the options + spanish, braziolian and portugues, as provided by + Ausberto S. Castro V. <ascv@inf.ufrgs.br> (PR 1837) + +1995-10-27 David Carlisle <latex-bugs@latex-project.org> + + * afterpage.dtx: tools/1579/1880/1884 + +1995-10-19 Frank Mittelbach <latex-bugs@latex-project.org> + + * varioref.dtx: + Added defaults for Italian pr/1888 + + * multicol.dtx: + Added \@largefloatcheck so that floats being too large + will produce a warning. pr/1890 + +1995-09-22 Rainer Schoepf <latex-bugs@latex-project.org> + + * verbatim.dtx: Corrected vertical spacing if verbatim is nested + in quote (and other) environment. This error was introduced with + version v1.3c (1990/02/26). Clarified documentation on how to + define new verbatim-like environments. + +1995-08-06 Frank Mittelbach <latex-bugs@latex-project.org> + + * tools.dst: + Updated copying conditions so that it is allowed to distribute + unpacked files together with the sources. + +1995-08-04 Frank Mittelbach <latex-bugs@latex-project.org> + + * multicol.dtx: + Changed class used for documentation from + article to ltxdoc. pr/1788 + +1995-06-25 Johannes Braams <latex-bugs@latex-project.org> + + * layout.dtx : The june 1995 release of LaTeX no longer needs two + hash marks when defining a newcommand inside the argument of + \DeclareOption. + +1995-06-15 David Carlisle <latex-bugs@latex-project.org> + + * longtable.dtx: replace ## by # in \DeclareOption, latex/1557 + +1995-05-25 David Carlisle <latex-bugs@latex-project.org> + + * longtable.dtx: Modify Caption handling again. + +1995-05-16 Frank Mittelbach <latex-bugs@latex-project.org> + + * varioref.dtx: + Updated \DeclareOption declarations to reflect ##1 -> #1 change. pr/1557 + +1995-05-07 Frank Mittelbach <latex-bugs@latex-project.org> + + * fontsmpl.dtx: + Removed \pagestyle{empty} so that all pages produced by fontsmpl.tex + are numbered. pr/1559 + +1995-05-03 Rainer Schoepf <latex-bugs@latex-project.org> + + * verbatim.dtx: Removed extra backslash in argument to \cs. + +1995-05-02 David Carlisle <latex-bugs@latex-project.org> + + * longtable.dtx: Explitly reset page height for tools/1584. + Modify caption handling. + +1995-04-26 Rainer Schoepf <latex-bugs@latex-project.org> + + * verbatim.dtx: Removed \fileversion and \filedate. + +1995-04-25 David Carlisle <latex-bugs@latex-project.org> + + * longtable.dtx: Modify brace hacks cf tools/1571 + Allow 1100 longtables in a single document---A bug reported on a + `real document' by Mike Van Geest! + + * showkeys.dtx: Fix inner horz mode case. + Add option handling: notref and notcite to stop the + redefinitions of those commands. + +1995-04-23 Frank Mittelbach <latex-bugs@latex-project.org> + + * array.dtx (section{The line separator \\}): + Fixed a serious bug that was present right from the beginning: + in some cases the last column of an array line could get an extra + math ord messing up the spacing. pr/1571. + (subsection{Bugs and Features}): + Added comment about the fact that a column (execpt for the first) refers to + the column specifier plus intercolumn material to the *right*. + Therefore \multicolumn{2}{|c|} is normally incorrect. pr/1443 + +1995-04-08 Johannes Braams <latex-bugs@latex-project.org> + + * layout.dtx : Added the options 'integers' and 'reals'. The + default is the option 'integers'; this results in the 'old' + behaviour, where the values of parameters are presented + truncated. Using the option 'reals' will switch to presenting the + real val;ues of the parameters. This also affects the definition + of \Show and \Type. + +1995-04-06 Frank Mittelbach <latex-bugs@latex-project.org> + + * varioref.dtx (subsection{Options}): + Added norsk and nynorsk strings. + Modified Warning message about undefined Option texts. + +1995-04-03 Johannes Braams <latex-bugs@latex-project.org> + + * layout.dtx : Simplified the definition of \Show and \Type, the + effect is that now the complete value is shown (PR #1520) + +1995-03-20 David Carlisle <latex-bugs@latex-project.org> + + * tabularx.dtx: Allow \tabularx to be used inside + \newenvironment definitions + +1995-03-17 David Carlisle <latex-bugs@latex-project.org> + + * showkeys.dtx: Fix for tools/1434 (showkeys affecting footnote + placement) + +1995-03-16 Frank Mittelbach <latex-bugs@latex-project.org> + + * multicol.dtx: + Fixed colour support (thanks to David) + Clarified copyright notice. + Updated driver file. + +1995-03-16 David Carlisle <latex-bugs@latex-project.org> + + * showkeys.dtx: Fix for tools/1181 (Bad placement in with \item + and \bibitem) and tools/1496 (Working with new ams*) + +1995-03-14 Johannes Braams <latex-bugs@latex-project.org> + + * layout.dtx : Added the options french and francais (thanks to + Eric Picheral <Eric.Picheral@univ-rennes1.fr> who provided the + translations); introduced \notshown + +1995-01-10 Frank Mittelbach <latex-bugs@latex-project.org> + + * varioref.dtx: + Added swedish strings. + +1994-12-08 David Carlisle <latex-bugs@latex-project.org> + + * longtable.dtx: Add \tabularnewline. + + * array.dtx: Add \tabularnewline. + +1994-11-22 David Carlisle <latex-bugs@latex-project.org> + + * tools.dst: Avoid generating error messages on `.tex'. + +1994-11-15 David Carlisle <latex-bugs@latex-project.org> + + * xspace.dtx: Make robust, add ! + +1994-10-29 Johannes Braams <latex-bugs@latex-project.org> + + * layout.dtx : Some of the dutch words should really be one word + instead of two (PR #1078) + +1994-10-25 Rainer Schoepf <latex-bugs@latex-project.org> + + * verbatim.dtx: Changed code for handling verbatim as first thing + after an \item command. (This change had already been done in the + LaTeX2e kernel.) + + * verbatim.dtx: Removed extra \typeout lines. + +1994-10-15 Frank Mittelbach <latex-bugs@latex-project.org> + + * array.dtx (subsection{Support for ...): + Added \firsthline and \lasthline from Companion. + +1994-10-03 Frank Mittelbach <latex-bugs@latex-project.org> + + * multicol.dtx: + Correct change from 26 of August. Leave old code only add the new + one. + +1994-09-27 Frank Mittelbach <latex-bugs@latex-project.org> + + * varioref.dtx: + Added strings for breton language, this also means adding a new option. + +1994-09-25 Frank Mittelbach <latex-bugs@latex-project.org> + + * varioref.dtx: + Added danish strings. + +1994-09-23 Frank Mittelbach <latex-bugs@latex-project.org> + + * varioref.dtx (subsection{Options}): + Added finnish strings. + +1994-09-09 David Carlisle <latex-bugs@latex-project.org> + + * showkeys.dtx: add \citefullauthor for (forthcoming) natbib. + +1994-09-08 Johannes Braams <latex-bugs@latex-project.org> + + * layout.dtx: Stored texts in control sequences to allow the use + of other languages. Added the options english (default) and + dutch. + + * tools.dst: Added the layout package + +1994-09-07 David Carlisle <latex-bugs@latex-project.org> + + * showkeys.dtx: Version 3, supports varioref ref styles, and + natbib and harvard citation styles. + Also modify `internal vertical mode' case, to cope with modified + \caption behaviour in the LaTeX2e classes. + Modify \GetFileInfo usage, as suggested by Patrick Daly. + +1994-08-26 Frank Mittelbach <latex-bugs@latex-project.org> + + * multicol.dtx (subsection{The output routines}): + Check explicitly for void boxes before assigning the current column + width to their width, because void boxes will not change. + Extract the kept marks before adding a penalty -10000 to the output box + when balancing, otherwise no marks will be found. (This bug was + introduced recently. + +1994-08-08 Frank Mittelbach <latex-bugs@latex-project.org> + + * tools.dst: + Added a better informational message about the problems + that can arise when LaTeX tries to generate the file `.tex' + +1994-07-24 Frank Mittelbach <latex-bugs@latex-project.org> + + * varioref.dtx (subsection{Options}): + Added dutch defaults as suggested by Frank Poppe. + Explicitly expand label argument before passing it to \label, so that + varioref will work with babel. + Correct misspelling in spanish option. + +1994-07-14 Johannes Braams <latex-bugs@latex-project.org> + + * layout.dtx: Moved the identification code to the front of the + file. + Needed to interchange to calls to \ttfamily and \footnotsize as + \footnotesize calls \normalfont in compatibility mode. + Added a check for negative arrowlength to \InsideHArrow + +1994-06-30 David Carlisle <latex-bugs@latex-project.org> + + * longtable.dtx: Obey a \nofiles declaration. Remove special + handling of letter class, not needed for the latex2e version of + letter. + + * showkeys.dtx: Correct \ProvidesPackage usage (previously had two + \providesPackage commands), + +1994-06-21 Frank Mittelbach <latex-bugs@latex-project.org> + + * varioref.dtx (subsection{Options}): + Added french defaults as suggested by Daniel Flippo. + +1994-06-20 Frank Mittelbach <latex-bugs@latex-project.org> + + * varioref.dtx: + Correction was buggy, brace placed incorrectly. + +1994-06-11 Frank Mittelbach <latex-bugs@latex-project.org> + + * varioref.dtx: + \vpageref[above][one ]{one} didn't work because first + optional argument wasn't passed (found by Patrick Daly). + +1994-06-07 Frank Mittelbach <latex-bugs@latex-project.org> + + * multicol.dtx (section{New macros and hacks for version 1.2}): + Updated float commands to contain \color@endgroup etc. so + that they work together with the color.sty package. + (Found by SPQR) + +1994-06-01 Frank Mittelbach <latex-bugs@latex-project.org> + + * array.dtx: + Added \null to the end of \multicolumn. This fixes + a bug that was long fixed in the original but never made it + into array.sty. + Use PackageError/Warning interface. + +1994-06-01 David Carlisle <latex-bugs@latex-project.org> + + * somedefs.dtx: Use new style error commands. + +1994-05-28 Frank Mittelbach <latex-bugs@latex-project.org> + + * multicol.dtx: + Do not alloc \col@number any longer. + Use Standard Warning/info messages. + + * fileerr.dtx: + Added file to the collection. + +1994-05-28 David Carlisle <latex-bugs@latex-project.org> + + * manifest.txt: First draft. + + * readme.txt: First draft. +1994-05-27 Frank Mittelbach <latex-bugs@latex-project.org> + + * varioref.dtx: + Warning about looping pages displayed in wrong order + (found by Wolfgang Christen). + (subsection{Defining the main macros}): + Added help message for loop error. + Use PackageError rather than \errmessage. + Use DeclareRobustCommand. + Added \NeedTeXFormat. + +1994-05-26 Frank Mittelbach <latex-bugs@latex-project.org> + + * multicol.dtx (subsection{Starting and ): + fixed bug with "premulticols" not being a register + (tried to \the a string in tracing mode) + +1994-05-18 Frank Mittelbach <latex-bugs@latex-project.org> + + * varioref.dtx: + Added defaults for brazil. + +1994-05-16 Frank Mittelbach <latex-bugs@latex-project.org> + + * array.dtx (section{The macros \texttt{\protect): + Use \@finalstrut in \@endpbox + +1994-03-23 Braams J.L. <latex-bugs@latex-project.org> + + * layout.dtx : repaired bug in twosided mode. + + Changed vertical positioning of the arrows identifying + \amrginparsep and \marginparwidth + + Repaired bug in the preparation of the table of dimensions. + + Produce two pages in twoside mode + + Removed use of \wlog + +1994-03-14 Frank Mittelbach <latex-bugs@latex-project.org> + + * array.dtx: + Removed identification \typeout's. + Removed the check for the old version of the \@tfor macro. + +1994-02-28 Frank Mittelbach <latex-bugs@latex-project.org> + + * array.dtx: + Moved the driver code in front so that the documentation can be + processed by simply running the file through LaTeX2e. + + * ftnright.dtx: + Moved the driver code in front so that the documentation can be + processed by simply running the file through LaTeX2e. + + * multicol.dtx: + Balance code rewritten; many changes to documentation etc. + Changed driver code slightly. + Moved the driver code in front so that the documentation can be + processed by simply running the file through LaTeX2e. + + * theorem.dtx: + Changed driver code slightly. + Moved the driver code in front so that the documentation can be + processed by simply running the file through LaTeX2e. + diff --git a/macros/latex-dev/required/tools/dcolumn.dtx b/macros/latex-dev/required/tools/dcolumn.dtx new file mode 100644 index 0000000000..38a4ab0da2 --- /dev/null +++ b/macros/latex-dev/required/tools/dcolumn.dtx @@ -0,0 +1,361 @@ +% \iffalse meta-comment +% +% Copyright (C) 1993-2019 +% +% The LaTeX3 Project and any individual authors listed elsewhere +% in this file. +% +% This file is part of the Standard LaTeX `Tools Bundle'. +% ------------------------------------------------------- +% +% It may be distributed and/or modified under the +% conditions of the LaTeX Project Public License, either version 1.3c +% of this license or (at your option) any later version. +% The latest version of this license is in +% https://www.latex-project.org/lppl.txt +% and version 1.3c or later is part of all distributions of LaTeX +% version 2005/12/01 or later. +% +% The list of all files belonging to the LaTeX `Tools Bundle' is +% given in the file `manifest.txt'. +% +% \fi +% \iffalse +%% File: dcolumn.dtx Copyright (C) 1992-1996 1999-2001 David Carlisle +% +%<*dtx> + \ProvidesFile{dcolumn.dtx} +%</dtx> +%<package>\NeedsTeXFormat{LaTeX2e} +%<package>\ProvidesPackage{dcolumn} +%<driver>\ProvidesFile{dcolumn.drv} +% \fi +% \ProvidesFile{dcolumn.dtx} + [2014/10/28 v1.06 decimal alignment package (DPC)] +% +% \iffalse +%<*driver> +\documentclass{ltxdoc} + \usepackage{dcolumn} + \DeleteShortVerb{\|} +\begin{document} + \DocInput{dcolumn.dtx} +\end{document} +%</driver> +% \fi +% +% \GetFileInfo{dcolumn.dtx} +% +% \title{The \textsf{dcolumn} package\thanks{This file +% has version number \fileversion, last +% revised \filedate.}} +% \author{David Carlisle} +% \date{\filedate} +% \author{David Carlisle} +% \MaintainedByLaTeXTeam{tools} +% \maketitle +% +% +% \changes{v1.00}{1992/02/17}{Initial version} +% \changes{v1.01}{1992/06/12}{Re-issue for the new doc and docstrip.} +% \changes{v1.02}{1994/03/14}{Re-issue for LaTeX2e} +% \changes{v1.03}{1996/02/28}{New feature, after tools/2093} +% \changes{v1.05}{1999/07/05} +% {Minor doc changes latex/3058} +% \changes{v1.06}{2001/05/28} +% {More doc changes (suggested by BNB, done by CAR) latex/3315} +% +% +% +% \begin{abstract} +% This package defines a system for defining columns of entries in an +% \texttt{array} or \texttt{tabular} which are to be aligned on a +% `decimal point'. +% \end{abstract} +% +% \MakeShortVerb{\"} +% +% This package defines {\tt D} to be a column specifier with three +% arguments.\\ +% "D{"\meta{sep.tex}"}{"\meta{sep.dvi}"}{"\meta{decimal +% places}"}" +% +% \meta{sep.tex} should be a single character, this is used as the +% separator in the {\tt .tex} file. Thus it will usually be `{\tt.}' or +% `{\tt,}'. +% +% \mbox{\meta{sep.dvi}} is used as the separator in the output, this may +% be the same as the first argument, but may be any math-mode +% expression, such as "\cdot". It should be noted that \texttt{dcolumn} +% always uses math mode for the digits as well as the separator. +% +% \meta{decimal places} should be the maximum number of decimal places +% in the column. If this is negative, any number of decimal places can +% be used in the column, and all entries will be centred on +% (the leading edge of) the +% separator. Note that this can cause a column to be too wide, compare +% the first two columns in the example below. If this argument is +% positive, the column uses macros equivalent to "\rightdots" +% "\endrightdots" of {\tt array.sty}, otherwise the macros are +% essentially equivalent to "\centerdots" "\endcenterdots". +% +% You may not want to use all three entries in the {\tt array} or {\tt +% tabular} preamble, so you may define your own preamble specifiers +% using "\newcolumntype". +% +% For example we may say: +% +% \noindent"\newcolumntype{d}[1]{D{.}{\cdot}{#1}}" +% +% {\tt d} takes a single argument specifying the number of decimal +% places, and the {\tt .tex} file should use {\tt.}, with $\cdot$ being +% used in the output. +% +% \noindent"\newcolumntype{.}{D{.}{.}{-1}}" +% +% {\tt .} specifies a column of entries to be centred on the~$.$. +% +% \noindent"\newcolumntype{,}{D{,}{,}{2}}" +% +% {\tt ,} specifies takes a column of entries with at most two decimal +% places after a~$,$. +% +% \newcolumntype{d}[1]{D{.}{\cdot}{#1}} +% \newcolumntype{.}{D{.}{.}{-1}} +% \newcolumntype{,}{D{,}{,}{2}} +% +% The following table begins "\begin{tabular}{|d{-1}|d{2}|.|,|}" +% +% \begin{center} +% \begin{tabular}{|d{-1}|d{2}|.|,|} +% 1.2 & 1.2 &1.2 &1,2 \\ +% 1.23 & 1.23 &12.5 &300,2 \\ +% 1121.2& 1121.2&861.20 &674,29 \\ +% 184 & 184 &10 &69 \\ +% .4 & .4 & &,4 \\ +% & &.4 & +% \end{tabular} +% \end{center} +% +% Note that the first column, which had a negative \meta{decimal places} +% argument is wider than the second column, so that the decimal point +% appears in the middle of the column. +% Also note that this package deals correctly with entries with no +% decimal part, no integer part, and blank entries. +% +% If you have table headings (inserted with "\multicolumn{1}{c}{..}" +% to over-ride the "D" column type) then it may be that neither of the +% above `centred' or `right aligned' forms is quite what you want. +% \begin{center}\small +% \begin{tabular}[t]{|D..{-1}|D..{1}|D..{5.1}|} +%\multicolumn{1}{|c|}{head}& +%\multicolumn{1}{c|}{head}& +%\multicolumn{1}{c|}{head}\\[3pt] +% 1.2 & 1.2 &1.2 \\ +% 11212.2& 11212.2&11212.2 \\ +% .4 & .4 &.4 +% \end{tabular} +% \hfill +% \begin{tabular}[t]{|D..{-1}|D..{1}|D..{1.1}|} +%\multicolumn{1}{|c|}{wide heading}& +%\multicolumn{1}{c|}{wide heading}& +%\multicolumn{1}{c|}{wide heading}\\[3pt] +% 1.2 & 1.2 &1.2 \\ +% .4 & .4 &.4 +% \end{tabular} +% \end{center} +% +% In both of these tables the first column is set with "D{.}{.}{-1}" +% to produce a column centered on the ".", and the second column is +% set with "D{.}{.}{1}" to produce a right aligned column. +% +% The centered column produces columns that are wider than necessary +% to fit in the numbers under a heading as it has to ensure that the +% decimal point is centred. The right aligned column two does not have +% this drawback, but under a wide heading a column of small right +% aligned figures looks a bit odd. +% +% In version v1.03 a third possibility is introduced. The third +% \meta{decimal places} argument may specify \emph{both} the number of +% digits to the left and to the right of the decimal place. The third +% column in the first table above is set with "D{.}{.}{5.1}" and in the +% second table, "D{.}{.}{1.1}", to specify +% `five places to the left and one to the right' and `one place to the +% left and% one to the right' respectively. (You may use `,' or other +% tokens, not necessarily `.' in this argument.) The column of figures +% is then positioned such that a number with the specified numbers of +% digits is centred in the column. +% +% This notation also enables columns that are centred on the mid-point +% of the separator, rather than its leading edge; for example +% "D{+}{\,\pm\,}{3,3}" will give nice, symmetric layout of up to three +% digits on either side of a $\pm$ sign. +% +% \StopEventually{} +% +% +% \section{The Macros} +% +% \begin{macrocode} +%<*package> +% \end{macrocode} +% +% First we load {\tt array.sty} if it not already loaded. +% \begin{macrocode} +\RequirePackage{array} +% \end{macrocode} +% +% The basic ideas behind these macros are explained in the documentation +% for {\tt array.sty}. However they use three +% tricks which may be useful in other contexts. +% \begin{itemize} +% \item The separator is surrounded in extra "{ }", so that it is set +% with "\mathord" spacing, otherwise, for instance a `,' would have +% extra space after it. +% \item The separator is not given its special definition by making it +% active, as this would not work for an entry such as "& .5 &", as the +% first token of an alignment entry is read {\em before\/} the preamble +% part, in case it is an "\omit", in which case the preamble is to be +% omitted. Instead we switch the mathcode to (hex) 8000, which makes the +% token act as if it were active. +% \item Although \verb|\mathcode`.="8000| makes {\tt.} act as if it +% were active, it is still not allowed in constructions such as +% "\def.{}", even in math-mode, so we have to construct an active +% version of the separator, this is done by making it the uppercase of +% "~", and then using the construct\\ +% "\uppercase{\def~}{"\meta{definition}"}".\\ +% Note that the \meta{definition} is not uppercased, so the definition +% can refer to the standard, non-active use of the separator. +% \end{itemize} +% +% \begin{macro}{\DC@} +% \changes{v1.03}{1996/02/28}{New feature, after tools/2093} +% Set up uppercase tables as required, and then grab the first part of +% the numerical argument into "\count@". +% \begin{macrocode} +\def\DC@#1#2#3{% + \uccode`\~=`#1\relax + \m@th + \afterassignment\DC@x\count@#3\relax{#1}{#2}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\DC@x} +% \changes{v1.03}{1996/02/28}{Macro added} +% If "\count@" is negative, centre on the decimal point. If it is +% positive either "#1" will be empty in which case bad out decimal +% part to the number of digits specified by "\count@" or (new feature +% in v1.03) it is none empty in which case "\count@" contains the +% number of digits to the left of the point, and "#1" contains a junk +% token (probably ".") followed by the number of digits to the right +% of the point. In either of these latter cases, "\DC@right" is used. +% \begin{macrocode} +\def\DC@x#1\relax#2#3{% + \ifnum\z@>\count@ + \expandafter\DC@centre + \else + \expandafter\DC@right + \fi + {#2}{#3}{#1}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\DC@centre} +% If centering on the decimal point, just need to box up the two halves. +% \begin{macrocode} +\def\DC@centre#1#2#3{% + \let\DC@end\DC@endcentre + \uppercase{\def~}{$\egroup\setbox\tw@=\hbox\bgroup${#2}}% + \setbox\tw@=\hbox{${\phantom{{#2}}}$}% + \setbox\z@=\hbox\bgroup$\mathcode`#1="8000 } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\DC@endcentre} +% and then pad out the smaller of the two boxes so there is the same +% amount of stuff either side of the point. +% \begin{macrocode} +\def\DC@endcentre{$\egroup + \ifdim \wd\z@>\wd\tw@ + \setbox\tw@=\hbox to\wd\z@{\unhbox\tw@\hfill}% + \else + \setbox\z@=\hbox to\wd\tw@{\hfill\unhbox\z@}\fi + \box\z@\box\tw@} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\DC@right} +% \changes{v1.03}{1996/02/28}{Re-implemented, after tools/2093} +% This deals with both the cases where a specified number of decimal +% places is given. +% \begin{macrocode} +\def\DC@right#1#2#3{% + \ifx\relax#3\relax +% \end{macrocode} +% If "#3" is empty, add "\hfill" to right align the column, and +% Just set "\DC@rl" to begin a group, so nothing fancy is done with +% the whole number part. +% \begin{macrocode} + \hfill + \let\DC@rl\bgroup + \else +% \end{macrocode} +% Otherwise set "\DC@rl" so that the whole number part is put in a +% box "\count@" times as wide as a digit. +% In order to share code with the other branch, then move "#3" (the +% number of decimal places) into "\count@" throwing away the `.' from +% the user syntax. +% \changes{v1.04}{1996/09/23}{Add \cs{hfill} so integer part +% is still flush right if no decimal point used.} +% \begin{macrocode} + \edef\DC@rl{to\the\count@\dimen@ii\bgroup\hss\hfill}% + \count@\@gobble#3\relax + \fi +% \end{macrocode} +% +% \begin{macrocode} + \let\DC@end\DC@endright +% \end{macrocode} +% Box 2 contains the decimal part, set to "\dimen@" which is +% calculated below to be "\count@" times the width of a digit, plus +% the with of the `decimal point'. +% \begin{macrocode} + \uppercase{\def~}{$\egroup\setbox\tw@\hbox to\dimen@\bgroup${#2}}% + \setbox\z@\hbox{$1$}\dimen@ii\wd\z@ + \dimen@\count@\dimen@ii + \setbox\z@\hbox{${#2}$}\advance\dimen@\wd\z@ + \setbox\tw@\hbox to\dimen@{}% +% \end{macrocode} +% Box 0 contains the whole number part, either just at its natural +% size for right aligned columns, or set to (the old value of) +% "\count@" times the width of a digit. "\DC@rl" defined above +% determines the two cases. +% \begin{macrocode} + \setbox\z@\hbox\DC@rl$\mathcode`#1="8000 } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\DC@endright} +% \changes{v1.03}{1996/02/28}{Re-implemented, after tools/2093} +% Just finish off the second box, and then put out both boxes. +% \begin{macrocode} +\def\DC@endright{$\hfil\egroup\box\z@\box\tw@} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{D} +% The user interface, define the {\tt D} column to take three arguments. +% For special purposes, you may need to directly access "\DC@" rather +% than the "D" column, eg to get a bold version you could use +%\begin{verbatim} +% \newcolumntype{E}[3]{>{\boldmath\DC@{#1}{#2}{#3}}c<{\DC@end}} +%\end{verbatim} +% \begin{macrocode} +\newcolumntype{D}[3]{>{\DC@{#1}{#2}{#3}}c<{\DC@end}} +%</package> +% \end{macrocode} +% \end{macro} +% +% +% \Finale +\endinput diff --git a/macros/latex-dev/required/tools/dcolumn.pdf b/macros/latex-dev/required/tools/dcolumn.pdf Binary files differnew file mode 100644 index 0000000000..b169bf93aa --- /dev/null +++ b/macros/latex-dev/required/tools/dcolumn.pdf diff --git a/macros/latex-dev/required/tools/delarray.dtx b/macros/latex-dev/required/tools/delarray.dtx new file mode 100644 index 0000000000..8814fc2a58 --- /dev/null +++ b/macros/latex-dev/required/tools/delarray.dtx @@ -0,0 +1,206 @@ +% \iffalse meta-comment +% +% Copyright (C) 1993-2019 +% +% The LaTeX3 Project and any individual authors listed elsewhere +% in this file. +% +% This file is part of the Standard LaTeX `Tools Bundle'. +% ------------------------------------------------------- +% +% It may be distributed and/or modified under the +% conditions of the LaTeX Project Public License, either version 1.3c +% of this license or (at your option) any later version. +% The latest version of this license is in +% https://www.latex-project.org/lppl.txt +% and version 1.3c or later is part of all distributions of LaTeX +% version 2005/12/01 or later. +% +% The list of all files belonging to the LaTeX `Tools Bundle' is +% given in the file `manifest.txt'. +% +% \fi +% \iffalse +%% File: delarray.dtx Copyright (C) 1991-1994 David Carlisle +% +%<package>\NeedsTeXFormat{LaTeX2e} +%<package>\ProvidesPackage{delarray} +%<package> [2014/10/28 v1.01 array delimiter package (DPC)] +% +%<*driver> +\documentclass{ltxdoc} +\usepackage{delarray} +\GetFileInfo{delarray.sty} +\begin{document} +\title{The \textsf{delarray} package\thanks{This file + has version number \fileversion, last + revised \filedate.}} +\author{David Carlisle} +\date{\filedate} + \MaintainedByLaTeXTeam{tools} + \maketitle + \DocInput{delarray.dtx} +\end{document} +%</driver> +% \fi +% +% +% \changes{v1.00}{1992/07/06} +% {Initial version after merging of newarray.sty to array.sty} +% +% \changes{v1.01}{1994/03/14} +% {Update to LaTeX2e} +% +% +% \section{Examples} +% +% +% The addition to {\tt array.sty} added in {\tt delarray.sty} is +% a system of implicit |\left| |\right| pairs. If you want an array +% surrounded by parentheses, you can enter:\\ +% |\begin{array}({cc})| \ldots +% \[ \begin{array}({cc})a&b\\c&d\end{array} \] +% +% Similarly if an environment equivalent to \PlainTeX's |\cases| could +% be defined by:\\ +% |\begin{array}\{{lL}.| \ldots +% +% \newcolumntype{L}{>{$}l<{$}} +% \[ f(x)=\begin{array}\{{lL}. +% 0 &if $x=0$\\ +% \sin(x)/x&otherwise +% \end{array} \] +% Here |L| is supposed to denote a column of left aligned L-R text. It +% may be defined via: |\newcolumntype{L}{>{$}l<{$}}|, as discussed in +% {\tt array.sty}. +% Note that as the delimiters must always be used in pairs, the `|.|' +% must be used to denote a `null delimiter'. +% +% This feature is especially useful if the |[t]| or |[b]| +% arguments are also used. In these cases the result is not equivalent +% to surrounding the environment by |\left|\ldots|\right|, as +% can be seen from the following example: +% \[ +% \begin{array}[t]({c}) 1\\2\\3 \end{array} +% \begin{array}[c]({c}) 1\\2\\3 \end{array} +% \begin{array}[b]({c}) 1\\2\\3 \end{array} +% \quad\mbox{not}\quad +% \left(\begin{array}[t]{c} 1\\2\\3 \end{array}\right) +% \left(\begin{array}[c]{c} 1\\2\\3 \end{array}\right) +% \left(\begin{array}[b]{c} 1\\2\\3 \end{array}\right) +% \] +% \begin{verbatim} +% \begin{array}[t]({c}) 1\\2\\3 \end{array} +% \begin{array}[c]({c}) 1\\2\\3 \end{array} +% \begin{array}[b]({c}) 1\\2\\3 \end{array} +% \quad\mbox{not}\quad +% \left(\begin{array}[t]{c} 1\\2\\3 \end{array}\right) +% \left(\begin{array}[c]{c} 1\\2\\3 \end{array}\right) +% \left(\begin{array}[b]{c} 1\\2\\3 \end{array}\right) +% \end{verbatim} +% +% +% \StopEventually{} +% +% \section{The Macros} +% +% \begin{macrocode} +%<*package> +% \end{macrocode} +% +% \begin{macrocode} +\RequirePackage{array}[1994/02/03] +% \end{macrocode} +% +% \begin{macro}{\@tabarray} +% This macro tests for an optional bracket and then calls up +% |\@@array| or |\@@array[c]| (as default). +% \begin{macrocode} +\def\@tabarray{\@ifnextchar[{\@@array}{\@@array[c]}} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\@@array} +% This macro tests for an optional delimiter before the left brace +% of the main preamble argument. If there is no delimiter, +% |\@arrayleft| and |\@arrayright| are made a no-ops, and +% |\@array| is called with the positional argument. Otherwise +% call |\@del@array|. +% \begin{macrocode} +\def\@@array[#1]{\@ifnextchar\bgroup + {\let\@arrayleft\relax\let\@arrayright\relax\@array[#1]}% + {\@del@array[#1]}} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\@del@array} +% We now know that we have an {\tt array} (or {\tt tabular}) with +% delimiters. +% \begin{macrocode} +\def\@del@array[#1]#2#3#4{% +% \end{macrocode} +% The following line is completely redundant but it does catch errors +% involving delimiters before the processing of the alignment begins. +% A common error is likely to be omitting the `.' in a +% |\cases|-type construction. This causes the first token of the +% alignment to be gobbled, possibly causing lots of spurious errors +% before the cause of the error, the missing delimiter, is discovered as +% |\@arrayright| puts the alignment and the delimiters together. +% \begin{macrocode} + \setbox\z@\hbox{$\left#2\right#4$}% +% \end{macrocode} +% In the case of a `c' argument we do not need to rebox the alignment, +% so we can define |\@arrayleft| and |\@arrayright| just to +% insert the delimiters. +% \begin{macrocode} + \if#1c\def\@arrayleft{\left#2}\def\@arrayright{\right#4}% +% \end{macrocode} +% Otherwise we (should) have a {\tt[t]} or {\tt[b]} argument, so first we +% store the alignment, without delimiters in box0. +% \begin{macrocode} + \else\def\@arrayleft{\setbox\z@}% +% \end{macrocode} +% Then after the alignment is finished: +% \begin{macrocode} + \def\@arrayright{% +% \end{macrocode} +% Calculate the amount the box needs to be lowered (this will be +% negative in the case of |[b]|). A little bit of arithmetic cf.\ +% the \TeX{}Book, Appendix G, rule 8. We calculate the amount this +% way, rather than just taking the difference between the depth of box0 +% and the depth of the box defined below, as the depth of that box may +% be affected by the delimiters if |\delimitershortfall| or +% |\delimiterfactor| have non-standard values. +% \begin{macrocode} + \dimen@=\dp\z@ + \advance\dimen@-\ht\z@ + \divide \dimen@ by \tw@ + \advance\dimen@ by\fontdimen22 \textfont\tw@ +% \end{macrocode} +% Now lower the alignment and the delimiters into place. +% \begin{macrocode} + \lower\dimen@\hbox{$\left#2\vcenter{\unvbox\z@}\right#4$}}% +% \end{macrocode} +% End the |\if#1c| +% \begin{macrocode} + \fi +% \end{macrocode} +% Now that we have defined |\@arrayleft| and |\@arrayright|, call +% |\@array|. +% \begin{macrocode} + \@array[#1]{#3}} +% \end{macrocode} +% \end{macro} +% +% \begin{macrocode} +%</package> +% \end{macrocode} +% +% +% \subsection{newarray.sty} +% All the features of the old {\tt newarray} style option have been +% merged into the {\tt array} or {\tt delarray} options. +% \changes{v1.00}{1992/07/06} +% {Stop generating a `shell' newarray.sty} +% +% +% \Finale +\endinput diff --git a/macros/latex-dev/required/tools/delarray.pdf b/macros/latex-dev/required/tools/delarray.pdf Binary files differnew file mode 100644 index 0000000000..6f80eb57c4 --- /dev/null +++ b/macros/latex-dev/required/tools/delarray.pdf diff --git a/macros/latex-dev/required/tools/enumerate.dtx b/macros/latex-dev/required/tools/enumerate.dtx new file mode 100644 index 0000000000..984d36d415 --- /dev/null +++ b/macros/latex-dev/required/tools/enumerate.dtx @@ -0,0 +1,335 @@ +% \iffalse meta-comment +% +% Copyright (C) 1993-2019 +% +% The LaTeX3 Project and any individual authors listed elsewhere +% in this file. +% +% This file is part of the Standard LaTeX `Tools Bundle'. +% ------------------------------------------------------- +% +% It may be distributed and/or modified under the +% conditions of the LaTeX Project Public License, either version 1.3c +% of this license or (at your option) any later version. +% The latest version of this license is in +% https://www.latex-project.org/lppl.txt +% and version 1.3c or later is part of all distributions of LaTeX +% version 2005/12/01 or later. +% +% The list of all files belonging to the LaTeX `Tools Bundle' is +% given in the file `manifest.txt'. +% +% \fi +% \iffalse +%% File: enumerate.dtx Copyright 1993 1994 1999 David Carlisle +% +%<*dtx> + \ProvidesFile{enumerate.dtx} +%</dtx> +%<package>\NeedsTeXFormat{LaTeX2e} +%<package>\ProvidesPackage{enumerate} +%<driver> \ProvidesFile{enumerate.drv} +% \fi +% \ProvidesFile{enumerate.dtx} + [2015/07/23 v3.00 enumerate extensions (DPC)] +% +% \iffalse +%<*driver> +\documentclass{ltxdoc} +\usepackage{enumerate} +\begin{document} +\DocInput{enumerate.dtx} +\end{document} +%</driver> +% \fi +% +% \GetFileInfo{enumerate.dtx} +% \title{The \textsf{enumerate} package\thanks{This file +% has version number \fileversion, last +% revised \filedate.}} +% \author{David Carlisle} +% \date{\filedate} +% \MaintainedByLaTeXTeam{tools} +% \maketitle +% +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% +% \changes{v1.00}{1990/00/00}{First version (since lost)} +% \changes{v2.00}{1991/07/25}{New Algorithm} +% \changes{v2.01}{1992/06/26}{Re-issue for the new doc and docstrip.} +% \changes{v2.02}{1994/01/31}{Update for LaTeX2e} +% \changes{v3.00}{1999/03/05}{Add extension hook for tools/2916} +% \changes{v3.00}{2015/07/23}{Documentation fixes tools/2916} +% +% \begin{abstract} +% This package gives the enumerate environment an optional argument +% which determines the style in which the counter is printed. +% +% An occurrence of one of the tokens |A a I i| or |1| produces the value +% of the counter printed with (respectively) |\Alph \alph \Roman \roman| +% or |\arabic|. +% +% These letters may be surrounded by any strings involving any other +% \TeX\ expressions, however the tokens |A a I i 1| must be inside a +% |{ }| group if they are not to be taken as special. +% \end{abstract} +% +% \section{Examples} +%\showboxdepth=10 +% \showboxbreadth=10 +% \[ +% \parbox{2.2in}{\hbadness2000 +% \begin{enumerate}[EX i.] +% \item one one one one one one one +% one one one one one\label{LA} +% \item two +% \begin{enumerate}[{example} a)] +% \item one of two one of two one of two\label{LB} +% \item two of two +% \end{enumerate} +% \end{enumerate} +% \begin{enumerate}[{A}-1] +% \item one\label{LC} +% \item two +% \end{enumerate}} +% \hspace{20pt} +% \vcenter{\hsize=2.4in +% \begin{verbatim} +% \begin{enumerate}[EX i.] +% \item one one one one one one one +% one one one one\label{LA} +% \item two +% \begin{enumerate}[{example} a)] +% \item one of two one of two +% one of two\label{LB} +% \item two of two +% \end{enumerate} +% \end{enumerate} +% +% \begin{enumerate}[{A}-1] +% \item one\label{LC} +% \item two +% \end{enumerate} +% \end{verbatim} +% }\] +% +% |\label| and |\ref| may be used as with the standard {\tt +% enumerate} environment. |\ref| only produces the counter value, +% not the whole label. |\ref| prints the value in the same style +% as |\item|, as determined by the presence of one of the tokens +% |A a I i 1| in the optional argument. In the above example +% |\ref{LA}|, |\ref{LB}| and |\ref{LC}| produce +% `\ref{LA}', `\ref{LB}' and `\ref{LC}' respectively. +% +% \StopEventually{} +% +%\section{Macros} +% +% \begin{macrocode} +%<*package> +% \end{macrocode} +% +% \begin{macro}{\@enlab} +% Internal token register used to build up the label command from the +% optional argument. +% \begin{macrocode} +\newtoks\@enLab +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@enQmark} +% This just expands to a `?'. |\ref| will produce this, if no counter +% is printed. +% \begin{macrocode} +\def\@enQmark{?} +% \end{macrocode} +% \end{macro} +% +% The next four macros build up the command that will print the item +% label. They each gobble one token or group from the optional argument, +% and add corresponding tokens to the register |\@enLab|. They each end +% with a call to |\@enloop|, which starts the processing of the next +% token. +% \begin{macro}{\@enLabel} +% Add the counter to the label. |#2| will be one of the `special' +% tokens |A a I i 1|, and is thrown away. |#1| will be a command +% like |\Roman|. +% \begin{macrocode} +\def\@enLabel#1#2{% + \edef\@enThe{\noexpand#1{\@enumctr}}% + \@enLab\expandafter{\the\@enLab\csname the\@enumctr\endcsname}% + \@enloop} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@enSpace} +% \begin{macro}{\@enSp@ce} +% Add a space to the label. The tricky bit is to gobble the space token, +% as you can not do this with a macro argument. +% \begin{macrocode} +\def\@enSpace{\afterassignment\@enSp@ce\let\@tempa= } +\def\@enSp@ce{\@enLab\expandafter{\the\@enLab\space}\@enloop} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\@enGroup} +% Add a |{ }| group to the label. +% \begin{macrocode} +\def\@enGroup#1{\@enLab\expandafter{\the\@enLab{#1}}\@enloop} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@enOther} +% Add anything else to the label +% \begin{macrocode} +\def\@enOther#1{\@enLab\expandafter{\the\@enLab#1}\@enloop} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@enloop} +% \begin{macro}{\@enloop@} +% The body of the main loop. +% Eating tokens this way instead of using |\@tfor| lets you see +% spaces and {\bf all} braces. |\@tfor| would treat {\tt a} and +% |{a}| as special, but not |{{a}}|. +% \begin{macrocode} +\def\@enloop{\futurelet\@entemp\@enloop@} +% \end{macrocode} +% \begin{macrocode} +\def\@enloop@{% + \ifx A\@entemp \def\@tempa{\@enLabel\Alph }\else + \ifx a\@entemp \def\@tempa{\@enLabel\alph }\else + \ifx i\@entemp \def\@tempa{\@enLabel\roman }\else + \ifx I\@entemp \def\@tempa{\@enLabel\Roman }\else + \ifx 1\@entemp \def\@tempa{\@enLabel\arabic}\else + \ifx \@sptoken\@entemp \let\@tempa\@enSpace \else + \ifx \bgroup\@entemp \let\@tempa\@enGroup \else + \ifx \@enum@\@entemp \let\@tempa\@gobble \else + \let\@tempa\@enOther +% \end{macrocode} +% Hook for possible extensions +% \begin{macrocode} + \@enhook +% \end{macrocode} +% +% \begin{macrocode} + \fi\fi\fi\fi\fi\fi\fi\fi +% \end{macrocode} +% \end{macro} +% Process the current token, then look at the next. +% \begin{macrocode} + \@tempa} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@enhook} +% Hook for possible extensions. +% Some packages may want to extend the number of special characters +% that are associated with counter representations. This feature +% was requested to enable Russian alphabetic counting, but here +% I give an example of a footnote symbol counter, triggered by |*|. +% +% To enable a new counter type based on a letter, you just need +% to add a new |\ifx| clause by analogy with the code above. +% So for example to make |*| trigger footnote symbol counting. +% a package should do the following. +% +% Initialise the hook, in case the package is loaded before +% \textsf{enumerate}. +%\begin{verbatim} +% \providecommand\@enhook{} +%\end{verbatim} +% +% Add to the hook a new |\ifx| clause that associates |*| with the +% |\fnsymbol| counter command. +%\begin{verbatim} +% \g@addto@macro\@enhook{% +% \ifx *\@entemp +% \def\@tempa{\@enLabel\fnsymbol}% +% \fi} +%\end{verbatim} +% This code sequence should work whether it is loaded before or after +% this enumerate package. Any number of new counter types may be added +% in this way. +% +% At this point we just need initialise the hook, taking care not +% to over write any definitions another package may already have added. +% \begin{macrocode} +\providecommand\@enhook{} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\enumerate} +% The new {\tt enumerate} environment. This is the first half of the +% original enumerate environment. If there is an optional argument, call +% |\@@enum@| to define the label commands, otherwise call +% |\@enum@| which is the second half of the original definition. +% \begin{macrocode} +\def\enumerate{% + \ifnum \@enumdepth >3 \@toodeep\else + \advance\@enumdepth \@ne + \edef\@enumctr{enum\romannumeral\the\@enumdepth}\fi + \@ifnextchar[{\@@enum@}{\@enum@}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@@enum@} +% Handle the optional argument.. +% \begin{macrocode} +\def\@@enum@[#1]{% +% \end{macrocode} +% Initialise the loop which will break apart the optional argument. +% The command to print the label is built up in |\@enlab|. +% |\@enThe| will be used to define |\theenum|\,$n$. +% \begin{macrocode} + \@enLab{}\let\@enThe\@enQmark +% \end{macrocode} +% The |\@enum@| below is never expanded, it is used to detect the end +% of the token list. +% \begin{macrocode} + \@enloop#1\@enum@ +% \end{macrocode} +% Issue a warning if we did not find one of the `special' tokens. +% \begin{macrocode} + \ifx\@enThe\@enQmark\@warning{The counter will not be printed.% + ^^J\space\@spaces\@spaces\@spaces The label is: \the\@enLab}\fi +% \end{macrocode} +% Define |\labelenum|$\,n$ and |\theenum|$\,n$. +% \begin{macrocode} + \expandafter\edef\csname label\@enumctr\endcsname{\the\@enLab}% + \expandafter\let\csname the\@enumctr\endcsname\@enThe +% \end{macrocode} +% Set the counter to 7 so that we get the width of `vii' if roman +% numbering is in force then set |\leftmargin|$\,n$. to the width of the +% label plus |\labelsep|. +% \begin{macrocode} + \csname c@\@enumctr\endcsname7 + \expandafter\settowidth + \csname leftmargin\romannumeral\@enumdepth\endcsname + {\the\@enLab\hspace{\labelsep}}% +% \end{macrocode} +% Finally call |\@enum@| which is the second half of the original +% definition. +% \begin{macrocode} + \@enum@} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@enum@} +% All the list parameters have now been defined, so call |\list|. This +% is taken straight from the original definition of |\enumerate|. +% \begin{macrocode} +\def\@enum@{\list{\csname label\@enumctr\endcsname}% + {\usecounter{\@enumctr}\def\makelabel##1{\hss\llap{##1}}}} +% \end{macrocode} +% \end{macro} +% +% \begin{macrocode} +%</package> +% \end{macrocode} +% +% \Finale +% +\endinput diff --git a/macros/latex-dev/required/tools/enumerate.pdf b/macros/latex-dev/required/tools/enumerate.pdf Binary files differnew file mode 100644 index 0000000000..70a69f6ce1 --- /dev/null +++ b/macros/latex-dev/required/tools/enumerate.pdf diff --git a/macros/latex-dev/required/tools/fileerr.dtx b/macros/latex-dev/required/tools/fileerr.dtx new file mode 100644 index 0000000000..3b5895a5f6 --- /dev/null +++ b/macros/latex-dev/required/tools/fileerr.dtx @@ -0,0 +1,123 @@ +% \iffalse meta-comment +% +% Copyright (C) 1993-2019 +% +% The LaTeX3 Project and any individual authors listed elsewhere +% in this file. +% +% This file is part of the Standard LaTeX `Tools Bundle'. +% ------------------------------------------------------- +% +% It may be distributed and/or modified under the +% conditions of the LaTeX Project Public License, either version 1.3c +% of this license or (at your option) any later version. +% The latest version of this license is in +% https://www.latex-project.org/lppl.txt +% and version 1.3c or later is part of all distributions of LaTeX +% version 2005/12/01 or later. +% +% The list of all files belonging to the LaTeX `Tools Bundle' is +% given in the file `manifest.txt'. +% +% \fi +% \def\fileversion{v1.1a} \def\filedate{2003/12/28} +% \iffalse This is a METACOMMENT +% Doc-Source file to use with LaTeX2e +% Copyright (C) 1994-2004 Frank Mittelbach, all rights reserved. +% \fi +% \title{File not found error\thanks{This file has version +% \fileversion\ last revised \filedate}} +% \author{Frank Mittelbach} +% \MaintainedByLaTeXTeam{tools} +% \maketitle +% +% \changes{v1.0e}{97/07/07}{Added q and r replies (PR/2525).} +% +% \section{Introduction} +% When \LaTeXe{} is unable to find a file it will ask for an +% alternative file name. However, sometimes the problem is +% only noticed by \TeX{}, and in that case \TeX{} insists on +% getting a valid file name; any other attempt to leave this +% error loop will fail.\footnote{On some systems, \TeX{} +% accepts a special character denoting the end of file to +% return from this loop, e.g.\ Control-D on UNIX or Control-Z +% on DOS.} Many users try to respond in the same way as to +% normal error messages, e.g.\ by typing \meta{return}, or |s| +% or |x|, but \TeX{} will interpret this as a file name and +% will ask again. +% \par To provide a graceful exit out of this loop, we define +% a number of files which emulate the normal behavior of +% \TeX{} in the error loop as far as possible. +% \par After installing these files the user can respond with +% |h|, |q|, |r|, |s|, |e|, |x|, and on some systems also with +% \meta{return} to \TeX's missing file name question. +% \StopEventually{} +% +% \section{The documentation driver} +% This code will generate the documentation. Since it is the +% first piece of code in the file, the documentation can be +% obtained by simply processing this file with \LaTeXe. +% \begin{macrocode} +%<*driver> +\documentclass{ltxdoc} +\begin{document} \DocInput{fileerr.dtx} \end{document} +%</driver> +% \end{macrocode} +% \section{The files} +% +% \subsection{Asking for help with {\tt h}} +% When the user types |h| in the file error loop \TeX{} will +% look for the file |h.tex|. In this file we put a message +% informing the user about the situation (we use |^^J| to +% start new lines in the message) and then finish with a +% normal |\errmessage| command thereby bringing up \TeX's +% normal error mechanism. +% \begin{macrocode} +%<*help> +\newlinechar=`\^^J +\message{! The file name provided could not be found.^^J% +Use `<enter>' to continue processing,^^J% +`S' to scroll future errors^^J% +`R' to run without stopping,^^J% +`Q' to run quietly,^^J% +or `X' to terminate TeX} +\errmessage{} +%</help> +% \end{macrocode} +% +% \subsection{Scrolling this and further errors with {\tt s}} +% For the response |s| we put a message into the file |s.tex| +% and start |\scrollmode| to scroll further error messages in +% this run. On systems that allow |.tex| as a file name we +% can also trap a single \meta{return} from the user. +% \begin{macrocode} +%<+scroll|return|run,batch> \message{File ignored} +%<+scroll> \scrollmode +%<+run> \nonstopmode +%<+batch> \batchmode +% \end{macrocode} +% +% \subsection{Exiting the run with {\tt x} or {\tt e}} +% +% If the user enters |x| or |e| to stop \TeX{}, we need to put +% something into the corresponding file which will force \TeX{} to +% give up. We achieve this by turning off terminal output and then +% asking \TeX{} to stop: first by using the internal \LaTeX{} name +% |\@@end|, and if that doesn't work because something other than +% \LaTeX{} is used, by trying the \TeX{} primitive |\end|. The +% |\errmessage| is there to ensure that \TeX{}'s internal "history" +% variable is set to |error_message_issued|. This in turn will +% hopefully set the exit code on those operating systems that +% implement return codes (though there is no guarantee for this). +% \changes{v1.1a}{2003/12/28}{Attempt to set exit code (pr/3538).} +% \begin{macrocode} +%<+edit|exit> \batchmode \errmessage{}\csname @@end\endcsname \end +% \end{macrocode} +% We end every file with an explicit |\endinput| which prevents +% the docstrip program from putting the character table into +% the generated files. +% \begin{macrocode} +\endinput +% \end{macrocode} +%% +% \Finale diff --git a/macros/latex-dev/required/tools/fileerr.pdf b/macros/latex-dev/required/tools/fileerr.pdf Binary files differnew file mode 100644 index 0000000000..2bd1aff4b3 --- /dev/null +++ b/macros/latex-dev/required/tools/fileerr.pdf diff --git a/macros/latex-dev/required/tools/fontsmpl.dtx b/macros/latex-dev/required/tools/fontsmpl.dtx new file mode 100644 index 0000000000..961bdda71f --- /dev/null +++ b/macros/latex-dev/required/tools/fontsmpl.dtx @@ -0,0 +1,338 @@ +% \iffalse meta-comment +% +% Copyright (C) 1993-2019 +% +% The LaTeX3 Project and any individual authors listed elsewhere +% in this file. +% +% This file is part of the Standard LaTeX `Tools Bundle'. +% ------------------------------------------------------- +% +% It may be distributed and/or modified under the +% conditions of the LaTeX Project Public License, either version 1.3c +% of this license or (at your option) any later version. +% The latest version of this license is in +% https://www.latex-project.org/lppl.txt +% and version 1.3c or later is part of all distributions of LaTeX +% version 2005/12/01 or later. +% +% The list of all files belonging to the LaTeX `Tools Bundle' is +% given in the file `manifest.txt'. +% +% \fi +% \title{A font sampler} +% \author{Alan Jeffrey} +% \date{v0.11} +% +% \MaintainedByLaTeXTeam{tools} +% \maketitle +% +% +%% +% +% \changes{v0.01}{1994/05/01}{Created this test document as part of +% accents.dtx.} +% \changes{v0.02}{1994/05/12}{Added the t1enc and ot1enc packages.} +% \changes{v0.03}{1994/05/14}{Moved fontsmpl to its own dtx file.} +% \changes{v0.03}{1994/05/14}{Removed the t1enc and ot1enc packages.} +% \changes{v0.04}{1994/05/14}{Removed some debugging code, improved +% documentation.} +% \changes{v0.05}{1994/05/14}{Tidied up some more. Removed the fontenc +% package.} +% \changes{v0.06}{1994/10/27}{Added testing for all the commands in +% ltoutenc.} +% \changes{v0.06}{1994/10/27}{Switched off error for `commands not +% defined in this encoding'.} +% \changes{v0.07}{1994/10/29}{Added testing for \cs{dots}, +% \cs{copyright} and \cs{textregistered}.} +% \changes{v0.07}{1994/10/29}{Replaced ??? for missing characters by +% \textbf{?}.} +% \changes{v0.08}{1994/10/30}{Added testing for \cs{k} and \cs{t}.} +% \changes{v0.08}{1994/10/30}{Removed testing for any glyphs not in +% usrguide.} +% \changes{v0.08}{1994/10/30}{Allowed overfull boxes in the accent test +% to extend out into the right margin.} +% \changes{v0.10}{1995/09/19}{Corrected placement of docstrip guard.} +% \changes{v0.11}{1997/05/13}{Replaced \cs{@changed@x@err} by +% \cs{TextSymbolUnavailable}, according to the change in +% \texttt{ltoutenc.dtx}.} +% +% \section{Introduction} +% +% This document describes the font test document |fontsmpl.tex| and the +% accompanying package |fontsmpl.sty|. This produces a test of a font +% family, printing a sample text, a table of accents, and a sample of +% commands such as |\pounds|. +% +% It can be used in two ways. The |fontsmpl| package provides the +% command |\fontsample|, which produces a sample of the current font. +% +% The |fontsmpl| document prompts interactively for a font family (for +% example `|cmr|') and produces a sample of that family. +% +% \StopEventually{} +% +% \section{Documentation} +% +% This docstrip document has three docstrip options: +% \begin{itemize} +% \item |document| the code for |fontsmpl.tex|. +% \item |package| the code for |fontsmpl.sty|. +% \item |driver| this documentation. +% \end{itemize} +% The code for the driver is: +% \begin{macrocode} +%<*driver> +\NeedsTeXFormat{LaTeX2e} +\documentclass{ltxdoc} +\begin{document} + \DocInput{fontsmpl.dtx} +\end{document} +%</driver> +% \end{macrocode} +% +% \section{Font sample document} +% +% The sample document prompts for a family, and uses the |fontsmpl| +% package. If there is a file |fontsmpl.cfg|, this is loaded. +% \changes{v0.9}{1995/05/07}{Removed \cs{pagestyle} empty} +% \begin{macrocode} +%<*document> +\NeedsTeXFormat{LaTeX2e} +\documentclass{article} +\usepackage{fontsmpl} +\makeatletter +\InputIfFileExists{fontsmpl.cfg}{}{} +\makeatother +\typein[\family]{Please enter a family name (for example `cmr').} +\title{Test of \LaTeX{} font family `\family'} +\author{Font sample produced with `fontsmpl'} +\raggedright +\begin{document} +\maketitle +\fontfamily{\family}\selectfont +\fontencoding{T1}\selectfont\fontsample +\fontencoding{OT1}\selectfont\fontsample +\itshape +\fontencoding{T1}\selectfont\fontsample +\fontencoding{OT1}\selectfont\fontsample +\slshape +\fontencoding{T1}\selectfont\fontsample +\fontencoding{OT1}\selectfont\fontsample +\scshape +\fontencoding{T1}\selectfont\fontsample +\fontencoding{OT1}\selectfont\fontsample +\upshape\bfseries +\fontencoding{T1}\selectfont\fontsample +\fontencoding{OT1}\selectfont\fontsample +\itshape +\fontencoding{T1}\selectfont\fontsample +\fontencoding{OT1}\selectfont\fontsample +\slshape +\fontencoding{T1}\selectfont\fontsample +\fontencoding{OT1}\selectfont\fontsample +\scshape +\fontencoding{T1}\selectfont\fontsample +\fontencoding{OT1}\selectfont\fontsample +\end{document} +%</document> +% \end{macrocode} +% +% \section{Font sample package} +% +% The |fontsmpl| package is a \LaTeXe{} package. +% \begin{macrocode} +%<*package> +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{fontsmpl}[1994/10/29 Font sample package] +% \end{macrocode} +% +% \begin{macro}{\fontsample} +% The |\fontsample| command prints out a sample text, a +% selection of glyphs, and a table of accents. +% \begin{macrocode} +\newcommand{\fontsample}{% + Test of font \f@encoding/\f@family/\f@series/\f@shape. + \fontsampletext + \fontsampleglyphs + \fontsampleaccents +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\fontsampletext} +% A sample text, taken from Knuth's |testfont.tex|. +% \begin{macrocode} +\newcommand{\fontsampletext}{% + Some text: + \begin{quote}\begin{flushleft} + On November 14, 1885, Senator \& Mrs.~Leland Stanford called + together at their San Francisco mansion the 24~prominent men who + had been chosen as the first trustees of The Leland Stanford + Junior University. They handed to the board the Founding Grant + of the University, which they had executed three days before. + This document---with various amendments, legislative acts, and + court decrees---remains as the University's charter. In bold, + sweeping language it stipulates that the objectives of the + University are ``to qualify students for personal success and + direct usefulness in life; and to promote the publick welfare by + exercising an influence in behalf of humanity and civilization, + teaching the blessings of liberty regulated by law, and + inculcating love and reverence for the great principles of + government as derived from the inalienable rights of man to life, + liberty, and the pursuit of happiness.'' + \\ + (!`THE DAZED BROWN FOX QUICKLY GAVE 12345--67890 JUMPS!) + \\ + ?`But aren't Kafka's Schlo\ss\ + and \AE sop's \OE uvres often na\"\i ve vis-\`a-vis the + d\ae monic ph\oe nix's official r\^ole in fluffy s\t ouffl\'es? + \\ + + \end{flushleft}\end{quote} +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\fontsampleglyphs} +% \begin{macro}{\fontsampleglyph} +% A list of sample glyph commands. +% \begin{macrocode} +\newcommand{\fontsampleglyphs}{% + Some glyphs: + \begin{quote}\begin{flushleft} + \fontsampleglyph{\#} + \fontsampleglyph{\$} + \fontsampleglyph{\%} + \fontsampleglyph{\&} + \fontsampleglyph{\AA} + \fontsampleglyph{\AE} + \fontsampleglyph{\DH} + \fontsampleglyph{\DJ} + \fontsampleglyph{\L} + \fontsampleglyph{\NG} + \fontsampleglyph{\OE} + \fontsampleglyph{\O} + \fontsampleglyph{\P} + \fontsampleglyph{\SS} + \fontsampleglyph{\S} + \fontsampleglyph{\TH} + \fontsampleglyph{\_} + \fontsampleglyph{\aa} + \fontsampleglyph{\ae} + \fontsampleglyph{\copyright} + \fontsampleglyph{\dag} + \fontsampleglyph{\ddag} + \fontsampleglyph{\dh} + \fontsampleglyph{\dj} + \fontsampleglyph{\dots} + \fontsampleglyph{\guillemotleft} + \fontsampleglyph{\guillemotright} + \fontsampleglyph{\guilsinglleft} + \fontsampleglyph{\guilsinglright} + \fontsampleglyph{\i} + \fontsampleglyph{\j} + \fontsampleglyph{\l} + \fontsampleglyph{\ng} + \fontsampleglyph{\oe} + \fontsampleglyph{\o} + \fontsampleglyph{\pounds} + \fontsampleglyph{\quotedblbase} + \fontsampleglyph{\quotesinglbase} + \fontsampleglyph{\ss} + \fontsampleglyph{\textasciicircum} + \fontsampleglyph{\textasciitilde} + \fontsampleglyph{\textbackslash} + \fontsampleglyph{\textbar} + \fontsampleglyph{\textbullet} + \fontsampleglyph{\textcompwordmark} + \fontsampleglyph{\textemdash} + \fontsampleglyph{\textendash} + \fontsampleglyph{\textexclamdown} + \fontsampleglyph{\textgreater} + \fontsampleglyph{\texthyphenchar} + \fontsampleglyph{\textless} + \fontsampleglyph{\textperiodcentered} + \fontsampleglyph{\textquestiondown} + \fontsampleglyph{\textquotedblleft} + \fontsampleglyph{\textquotedblright} + \fontsampleglyph{\textquotedbl} + \fontsampleglyph{\textquoteleft} + \fontsampleglyph{\textquoteright} + \fontsampleglyph{\textvisiblespace} + \fontsampleglyph{\th} + \fontsampleglyph{\{} + \fontsampleglyph{\}} + \end{flushleft}\end{quote} +} +\newcommand{\fontsampleglyph}[1]{% + \ifx#1\@undefined + {\typewriterfont\string#1}~is~undefined + \else + {\typewriterfont\string#1}~is~`#1' + \fi +} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\fontsampleaccents} +% \begin{macro}{\fontsampleaccent} +% A sample of accents. +% \begin{macrocode} +\newcommand{\fontsampleaccents}{% + Some accents: + \begin{quote}\begin{flushleft} + \fontsampleaccent{\"} \\ + \fontsampleaccent{\'} \\ + \fontsampleaccent{\.} \\ + \fontsampleaccent{\=} \\ + \fontsampleaccent{\H} \\ + \fontsampleaccent{\^} \\ + \fontsampleaccent{\`} \\ + \fontsampleaccent{\b} \\ + \fontsampleaccent{\c} \\ + \fontsampleaccent{\d} \\ + \fontsampleaccent{\k} \\ + \fontsampleaccent{\u} \\ + \fontsampleaccent{\v} \\ + \fontsampleaccent{\~} + \end{flushleft}\end{quote} +} +\newcommand{\fontsampleaccent}[1]{% + \makebox[1em][r]{\typewriterfont\string#1} + \makebox[15em][l]{% + #1A#1C#1D#1E#1G#1I#1L#1N% + #1O#1R#1S#1T#1U#1Y#1Z% + #1a#1c#1d#1e#1g#1\i#1i#1l#1n% + #1o#1r#1s#1t#1u#1y#1z% + } +} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\typewriterfont} +% Not all sites have the T1 typewriter fonts, so we set the +% typewriter font to be a fixed font. +% \begin{macrocode} +\DeclareFixedFont{\typewriterfont} + {\encodingdefault}{\ttdefault}{\mddefault}{\updefault}{10} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\TextSymbolUnavailable} +% Switch off the error message from missing glyphs. +% \begin{macrocode} +\def\TextSymbolUnavailable#1{% + \textbf{?}\PackageInfo{fontsmpl}{% + Command \protect#1 undefined in encoding \f@encoding% + }% +} +%</package> +% \end{macrocode} +% \end{macro} +%\Finale +\endinput + + diff --git a/macros/latex-dev/required/tools/fontsmpl.pdf b/macros/latex-dev/required/tools/fontsmpl.pdf Binary files differnew file mode 100644 index 0000000000..20626d2340 --- /dev/null +++ b/macros/latex-dev/required/tools/fontsmpl.pdf diff --git a/macros/latex-dev/required/tools/ftnright.dtx b/macros/latex-dev/required/tools/ftnright.dtx new file mode 100644 index 0000000000..5739172f85 --- /dev/null +++ b/macros/latex-dev/required/tools/ftnright.dtx @@ -0,0 +1,1018 @@ +% \iffalse meta-comment +% +% Copyright (C) 1993-2019 +% +% The LaTeX3 Project and any individual authors listed elsewhere +% in this file. +% +% This file is part of the Standard LaTeX `Tools Bundle'. +% ------------------------------------------------------- +% +% It may be distributed and/or modified under the +% conditions of the LaTeX Project Public License, either version 1.3c +% of this license or (at your option) any later version. +% The latest version of this license is in +% https://www.latex-project.org/lppl.txt +% and version 1.3c or later is part of all distributions of LaTeX +% version 2005/12/01 or later. +% +% The list of all files belonging to the LaTeX `Tools Bundle' is +% given in the file `manifest.txt'. +% +% \fi +%\iffalse % this is a METACOMMENT ! +% +%% Package `ftnright' to use with LaTeX 2e +%% Copyright (C) 1989-2004 Frank Mittelbach, all rights reserved. +%<+package>\NeedsTeXFormat{LaTeX2e}[1995/06/01] +%<+package>\ProvidesPackage{ftnright} +%<+package> [2014/10/28 v1.1f footnote layout package (FMi)] +% +% \fi +%% +%% +% +% +% \DoNotIndex{\;} +%^^A \DoNotIndex{\@cclv} +%^^A \DoNotIndex{\@colht} +%^^A \DoNotIndex{\@colroom} +% \DoNotIndex{\@combinedblfloats} +% \DoNotIndex{\@combinefloats} +% \DoNotIndex{\@dblfloatplacement} +% \DoNotIndex{\@deferlist} +% \DoNotIndex{\@empty} +%^^A \DoNotIndex{\@fcolmadefalse} +%^^A \DoNotIndex{\@firstcolumnfalse} +%^^A \DoNotIndex{\@firstcolumntrue} +% \DoNotIndex{\@freelist} +% \DoNotIndex{\@ixpt} +%^^A \DoNotIndex{\@leftcolumn} +%^^A \DoNotIndex{\@m} +%^^A \DoNotIndex{\@makecol} +%^^A \DoNotIndex{\@makefntext} +%^^A \DoNotIndex{\@maxdepth} +% \DoNotIndex{\@midlist} +%^^A \DoNotIndex{\@outputbox} +%^^A \DoNotIndex{\@outputdblcol} +%^^A \DoNotIndex{\@outputpage} +% \DoNotIndex{\@ptsize} +%^^A \DoNotIndex{\@setsize} +% \DoNotIndex{\@spaces} +%^^A \DoNotIndex{\@startcolumn} +%^^A \DoNotIndex{\@startdblcolumn} +% \DoNotIndex{\@tempdima} +% \DoNotIndex{\@textbottom} +% \DoNotIndex{\@texttop} +%^^A \DoNotIndex{\@thefnmark} +% \DoNotIndex{\@viiipt} +% \DoNotIndex{\@whilesw} +% \DoNotIndex{\@width} +%^^A \DoNotIndex{\@xstartcol} +% \DoNotIndex{\@xpt} +% \DoNotIndex{\advance} +% \DoNotIndex{\begingroup} +% \DoNotIndex{\box} +%^^A \DoNotIndex{\boxmaxdepth} +%^^A \DoNotIndex{\columnseprule} +%^^A \DoNotIndex{\columnwidth} +% \DoNotIndex{\count} +% \DoNotIndex{\def} +% \DoNotIndex{\dimen} +% \DoNotIndex{\dp} +% \DoNotIndex{\else} +% \DoNotIndex{\endgroup} +% \DoNotIndex{\fi} +% \DoNotIndex{\filedate} +% \DoNotIndex{\filename} +% \DoNotIndex{\fileversion} +%^^A \DoNotIndex{\footins} +%^^A \DoNotIndex{\footnoterule} +%^^A \DoNotIndex{\footnotesep} +%^^A \DoNotIndex{\footnotesize} +%^^A \DoNotIndex{\ftn@amount} +% \DoNotIndex{\gdef} +% \DoNotIndex{\global} +% \DoNotIndex{\hbox} +% \DoNotIndex{\hfil} +% \DoNotIndex{\hss} +% \DoNotIndex{\ht} +%^^A \DoNotIndex{\if@fcolmade} +%^^A \DoNotIndex{\if@firstcolumn} +% \DoNotIndex{\ifcase} +%^^A \DoNotIndex{\ifvoid} +% \DoNotIndex{\ifx} +%^^A \DoNotIndex{\insert} +% \DoNotIndex{\ixpt} +% \DoNotIndex{\let} +% \DoNotIndex{\llap} +% \DoNotIndex{\long} +%^^A \DoNotIndex{\maxdepth} +%^^A \DoNotIndex{\newdimen} +%^^A \DoNotIndex{\newskip} +% \DoNotIndex{\noindent} +% \DoNotIndex{\normalsize} +% \DoNotIndex{\or} +%^^A \DoNotIndex{\parindent} +%^^A \DoNotIndex{\preparefootins} +%^^A \DoNotIndex{\rcol@footinsskip} +%^^A \DoNotIndex{\saved@footinsskip} +% \DoNotIndex{\setbox} +% \DoNotIndex{\skip} +% \DoNotIndex{\space} +%^^A \DoNotIndex{\strutbox} +%^^A \DoNotIndex{\textheight} +%^^A \DoNotIndex{\textwidth} +% \DoNotIndex{\unvbox} +% \DoNotIndex{\vbox} +% \DoNotIndex{\viiipt} +% \DoNotIndex{\vrule} +% \DoNotIndex{\vskip} +%^^A \DoNotIndex{\wlog} +% \DoNotIndex{\xdef} +% \DoNotIndex{\xpt} +% \DoNotIndex{\z@} +% +% \changes{v1.1a}{1994/01/24}{Upgrades for LaTeX2e} +% \changes{v1.1b}{1994/01/24}{Driver moved in front} +% \changes{v1.1c}{1996/01/01}{Use article.cls for documentation} +% +% \renewcommand{\.}{\penalty500} %^^A for certain breaks +% +% \setlength{\hfuzz}{2pt} ^^A allow small overshot in verbatim +% +% \GetFileInfo{ftnright.sty} +% +% \title{Footnotes in a multi-column layout\thanks +% {The \LaTeX{} package {\tt \filename} which is described +% in this article has the version number \fileversion{} dated +% \filedate.}} +% \author{Frank Mittelbach} +% +% +% \maketitle +% +% \pageshrink 1pt %^^A compensate for the \thanks marker +% +% +% \section{Preface to version 1.1} +% +% The new release is a basically unchanged version of the original. I +% upgraded the macros so that they work with \LaTeXe{} and used some +% of the additional flexibility introduced therein. For example, the +% command |\preparefootins| is now automatically called at +% |\begin{document}|, thus allowing the user to adjust the +% |\textheight| in the preamble. +% +% It is not surprisingly that I was forced to change some of the +% macros because they dig deep into \LaTeX{}'s output routines. +% Fortunately this is something normally not necessary when upgrading +% other \LaTeX~2.09 styles to \LaTeXe{} packages. +% +% I also upgraded the documentation to conform to the \LaTeXe{} +% terminology, e.g., this is a package since document classes will not +% know about it. However it is very likely that i have missed some +% necessary corrections. +% +% \section{Introduction} +% +% +% The placement of footnotes in a multicolumn layout always bothered +% me. The approach taken by \LaTeX{} (i.e., placing the footnotes +% separately under each column) might be all right if nearly no +% footnotes are present. But it looks clumsy when both columns contain +% footnotes, especially when they occupy different amounts of space. +% +% In the multicolumn package~\cite{art:FMi89b}, I used page-wide +% footnotes at the bottom of the page, but again the result doesn't +% look very pleasant since short footnotes produce undesired gaps of +% white space. Of course, the main goal of this package was a +% balancing algorithm for columns which would allow switching between +% different numbers of columns on the same page. With this feature, +% the natural place for footnotes seems to be the bottom of the +% page\footnote{You cannot use column footnotes at the bottom, since +% the number of columns can differ on one page.} but looking at some +% of the results it seems best to avoid footnotes in such a layout +% entirely. +% +% +% Another possibility is to turn footnotes into endnotes, i.e., +% printing them at the end of every chapter or the end of the entire +% document. But I assume everyone who has ever read a book using such +% a layout will agree with me, that it is a pain to search back and +% forth, so that the reader is tempted to ignore the endnotes +% entirely. +% +% When I wrote the article about ``Future extensions of +% \TeX{}''~\cite{inproc:FMi90} I was again dissatisfied with the +% outcome of the footnotes, and since this article should show certain +% aspects of high quality typesetting, I decided to give the footnote +% problem a try and modified the \LaTeX{} output routine for this +% purpose. The layout I used was inspired by the yearbook of the +% Gutenberg Gesellschaft Mainz \cite{book:GG}. Later on, I found that +% it is also recommended by Jan White \cite{book:JWh88}. On the layout +% of footnotes I also consulted books by Jan Tschichold +% \cite{book:JTs87} and Manfred Simoneit \cite{book:MSi89}, books I +% would recommend to everyone being able to read German texts. +% +% +% \subsection{Description of the new layout} +% +% The result of this effort is presented in this paper and the reader +% can judge for himself whether it was successful or +% not.\footnote{Please note, that this option only changed the +% placement of footnotes. Since this article also makes use of the +% {\tt doc} package \cite{bk:GMS94}, that assigns tiny numbers to +% code lines sprinkled throughout the text, the resulting design is +% not perfect. This package is now a standard part of \LaTeXe.} +% The main idea for this layout is to assemble the +% footnotes of all columns on a page and place them all together at +% the bottom of the right column. Allowing for enough space between +% footnotes and text, and in addition, setting the footnotes in +% smaller type\footnote{The standard layout in \TUB{} uses the same +% size for footnotes and text, giving the footnotes, in my opinion, +% much too much prominence.} I decided that one could omit the +% footnote separator rule which is used in most publications prepared +% with \TeX{}.\footnote{People who prefer the rule can add it by +% redefining the command {\tt\bslash footnoterule} +% \cite[p.~156]{book:LLa86}. Please, note, that this command should +% occupy no space, so that a negative space should be used to +% compensate for the width of the rule used.} Furthermore, I decided +% to place the footnote markers\footnote{\label{thisftn}The tiny +% numbers or symbols, e.g., the `\ref{thisftn}' in front of this +% footnote.} at the baseline instead of raising them as +% superscripts.\footnote{Of course, this is done only for the mark +% preceding the footnote text and not the one used within the main +% text where a raised number or symbol set in smaller type will help +% to keep the flow of thoughts, uninterrupted.} +% +% All in all, I think this generates a neat layout, and surprisingly +% enough, the necessary changes to the \LaTeX{} output routine are +% nevertheless astonishingly simple. +% +% \subsection{The use of the package} +% +% This package might be used together with any other package +% for \LaTeX{} which does not change the three internals changed by +% {\tt \filename}.\footnote{These are the macros {\tt\bslash +% @startcolumn}, {\tt\bslash @makecol}, and {\tt\bslash @outputdblcol}, +% as we will see below. Of course, the package will take only effect +% with a document class using a two-column layout (like {\tt ltugboat}) +% or when the user additionally specifies {\tt twocolumn} as a +% document class option in the {\tt\bslash documentclass} command.} In +% most cases, it is best to use this package as the very last +% package in the preamble to make sure that its +% settings are not overwritten by other packages. +% +% It is unfortunate that the current \LaTeX{} has nearly no provisions +% to make such changes without overwriting the internal routines. In +% the \LaTeX3 implementation, we will certainly add some hooks that +% will make such changes more easy. +% +% +% \subsection{Limitations} +% +% If in the first column there is more than a full column worth of footnote +% material the material will be split resulting in footnotes out of +% order. This issue is now detected and generates an error but the package is +% unable to gracefully handle it. This gives you two options: either rearrange +% your input so that it will use less footnotes in the first column (or add +% some pagebreaks at suitable places) or allow explicitly for more material to +% be gathered. The latter can be achieved by adding +%\begin{verbatim} +%\makeatletter +%\def\preparefootins{% +% \global\rcol@footinsskip\skip\footins +% \global\skip\footins\z@ +% \global\count\footins\z@ +% \global\dimen\footins2\textheight} +%\makeatother +%\end{verbatim} +% to the preamble of your document. However, with this you allow two columns +% worth of footnote material and that means that some of your footnotes are +% likely to be detached from their reference and show up on a later page! +% +% \StopEventually{ +% +% \begin{small} +% \begin{thebibliography}{1} +% +% \bibitem{bk:GMS94} \textsc{M.~Goossens}, \textsc{F.~Mittelbach} +% and \textsc{A.~Samarin}. +% \newblock The \LaTeX{} Companion. +% \newblock +% Addison-Wesley, Reading, Massachusetts, 1994. +% +% \bibitem{book:GG} +% Hans-Joachim Koppitz, editor. +% \newblock {\em {Gutenberg Jahrbuch}}. +% \newblock Gutenberg-Gesellschaft, Mainz. +% +% \bibitem{book:LLa86} +% Leslie Lamport. +% \newblock {\em {\LaTeX:} A Document Preparation System}. +% \newblock Addison-Wesley, Reading, Massachusetts, 1986. +% +% \bibitem{src:ltxiii94} +% \LaTeX3 project. +% \newblock \LaTeXe distribution, 1994. +% \newblock Sources for {\LaTeXe} the successor to \LaTeX~2.09. +% +% \bibitem{art:FMi89b} +% Frank Mittelbach +% \newblock An environment for multi-column output. +% \newblock {\em TUGboat}, 10(3):407--415, November 1989. +% +% \bibitem{inproc:FMi90} +% Frank Mittelbach +% \newblock E-{\TeX}: Guidelines to future {\TeX} extensions. +% \newblock In Lincoln K. Durst, editor, {\em \TUB}, 11(3): +% {\em 1990 TUG Annual Meeting Proceedings}, pages +% 337--345, September 1990. +% +% \bibitem{book:MSi89} +% Manfred Siemoneit. +% \newblock {\em Typographisches {G}estalten}. +% \newblock Polygraph Verlag, Frankfurt am Main, second edition, 1989. +% +% \bibitem{book:JTs87} +% Jan Tschichold. +% \newblock {\em {Ausgew\"ahlte Aufs\"atze \"uber Fragen der Gestalt des +% Buches}}. +% \newblock Birkh\"auser Verlag, Basel, 1987. +% \newblock Second printing. +% +% \bibitem{book:JWh88} +% Jan White. +% \newblock {\em Graphic Design for the Electronic Age}. +% \newblock Watson Guptill, Xerox Press, New York, 1988. +% +% \end{thebibliography} +% \end{small} +% +% \onecolumn +% \PrintIndex +% \PrintChanges +% } +% +% +% +% \section{The documentation driver} +% +% The first bit of code contains the documentation driver file for +% \TeX{}, i.e., the file that will produce the documentation you are +% currently reading. It will be extracted from this file by the {\tt +% docstrip} program. If you don't want to make any changes to the +% presentation you can alternatively process the \texttt{.dtx} file +% directly with \LaTeXe{} to obtain the documentation. +% \changes{v1.0d}{1992/04/19}{Added driver file to source} +% \changes{v1.0e}{1993/05/13}{Added history generation} +% \begin{macrocode} +%<*driver> +\documentclass[twocolumn]{article} + +\usepackage{ftnright} +\usepackage{doc} +\AtBeginDocument{\MakeShortVerb{\|}} + +\newcommand{\TUB}{{\sl TUGboat\/}} +\renewcommand\DescribeMacro[1]{\fbox + {\PrintDescribeMacro{#1}}} +\renewcommand\DescribeEnv[1]{\fbox + {\PrintDescribeEnv{#1}}} +\renewcommand\PrintMacroName[1]{} + +\setlength{\parindent}{1em} +\setlength{\parskip} + {2pt plus1pt minus1pt} +\setlength{\headsep}{20pt} +\setlength{\columnsep}{1.5pc} +\renewcommand{\bottomfraction}{.4} + +\flushbottom +\CodelineIndex +\RecordChanges % produce history +\EnableCrossrefs + +\setcounter{IndexColumns}{2} +\IndexPrologue{\section{Index} + All numbers denote code lines where + the corresponding entry is used, + underlined entries point to the + definition.} + +\begin{document} + \DocInput{ftnright.dtx} +\end{document} +%</driver> +% \end{macrocode} +% +% \section{The Implementation} +% +% +% As usual, we start by identifying the current version of this package +% file in the transcript file.\footnote{Nico Poppelier suggested +% omitting the {\tt\bslash typeout} statements in the production +% version of the files to avoid showing all that unnecessary +% information to the user. While I accept his criticism as valid, I +% decided that this information should at least be placed into the +% transcript file to make it easier to detect problems arising from +% the use of older versions. This happens now automatically as the command +% \texttt{\string\ProvidesPackage} will only write to the transcript file.} +% This actually happens at the very top of this file so it is commented out +% here. +%\begin{verbatim} +%\ProvidesPackage{ftnright}[\filedate\space +% LaTeX2e package \fileversion] +%\end{verbatim} +% +% To implement the layout described, above we have to distinguish +% between the left and the right column on a page. For this purpose +% \LaTeX{} maintains the switch |\if@firstcolumn|. When assembling +% material for the left (i.e., the first) column, footnotes should +% take up no space, since they are held over for the second column. In +% the second column these footnotes are combined with the ones found +% there and placed a suitable distance from the main text at the +% bottom of this column. +% +% This means that we have to change certain parameters for the +% insertion |\footins| when we construct the second column. The right +% place to do this is in the \LaTeX{} macro |\@outputdblcol| which we +% are going to change later on. What settings for the insertion +% parameters are appropriate? For setting the first column +% |\count|\.|\footins| and |\skip|\.|\footins| should both be zero +% since footnotes are held over while for the second column +% |\count|\.|\footins| should be $1000$ and the |\skip|\.|\footins| +% has to be set to the desired separation between main text and +% footnotes.\footnote{A value of $1000$ means that there is a +% one-to-one relationship between the real size of the footnote and +% the size finally occupied by the footnote on the current page.} +% +% +% We will allow one column of footnotes (i.e., the right column) at +% most, so that |\dimen|\.|\footins| has to equal |\textheight|. In +% principle, it would be possible to allow for even more footnotes, +% but this would complicate matters enormously.\footnote{It is not +% possible to make {\tt\bslash dimen\bslash footins} larger than +% {\tt\bslash textheight} directly, because this would result in a +% full left column (with text) and more than one column of footnotes. +% Instead, one has to make footnotes visible to the page generation +% algorithm again at the moment when a full column of footnotes is +% assembled, but we still have some space left in the first column. It +% is a nice enhancement, and, I suppose, it is of some value for +% preparing publications in certain disciplines, so here is the +% challenge~\ldots} +% +% +% \begin{macro}{\preparefootins} +% \begin{macro}{\saved@footinsskip} +% Since a document usually starts with a left column, we have to +% set |\count| and |\skip|\.|\footins| on top-level to zero. For +% this purpose, we define a macro |\preparefootins| which will +% first save the current value of |\skip|\.|\footins| in a safe +% place. This saved value will be used later for the second column. +% In this way, it is possible for the user or a designer of a +% document class to adjust this parameter without fiddling with the +% code of this package file. +% \begin{macrocode} +%<*package> +\def\preparefootins{% + \global\rcol@footinsskip\skip\footins + \global\skip\footins\z@ + \global\count\footins\z@ +% \end{macrocode} +% We will also assign |\textheight| to |\dimen|\.|\footins| to +% allow the user to change this parameter in the preamble. +% \begin{macrocode} + \global\dimen\footins\textheight} +% \end{macrocode} +% It is necessary to make the assignments above |\global| because +% we are going to use this macro in the output routine which has an +% implicit grouping level to keep the changes made by it local. +% \end{macro} +% Of course, we have to allocate the {\sf skip} register that we +% used above: +% \begin{macrocode} +\newskip\rcol@footinsskip +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\@outputdblcol} +% Now we have all the necessary tools available to tackle +% |\@outputdblcol|. We have to remember that when +% |\if@firstcolumn| equals |\iftrue|, we are currently starting to +% build the second column, i.e., that the first column is already +% assembled. Therefore, the macro will start with the following +% code: +% \begin{macrocode} +\def\@outputdblcol{\if@firstcolumn + \global\@firstcolumnfalse +% \end{macrocode} +% After changing the switch, we save the first column (which was +% placed by preceding macros in |\@outputbox|) in the box register +% |\@leftcolumn|. Since we are inside the output routine, all those +% assignments have to be |\global| to take any effect. +% \begin{macrocode} + \global\setbox\@leftcolumn\box\@outputbox +% \end{macrocode} +% Then, we make the footnotes visible to the page generation +% algorithm by setting |\count\footins| to $1000$ (|\@m| is an +% abbreviation for this number) and |\skip\footins| to its saved +% value (i.e., |\rcol@footinsskip|). +% \begin{macrocode} + \global\count\footins\@m + \global\skip\footins\rcol@footinsskip +% \end{macrocode} +% We also have to reinsert all footnotes left over from the first +% column to make sure that they are reconsidered by the page +% generation algorithm of \TeX{} using the new values for |\count| +% and |\skip|\.|\footins|. But this will be done later in the +% macro |\@startcolumn|. +% +% If we have just finished the right column, i.e., when +% |\if@firstcolumn| equals |\iffalse|, we will reset the |\footins| +% parameters as explained above using the utility macro +% |\preparefootins|. +% \begin{macrocode} + \else \preparefootins +% \end{macrocode} +% Then, we compose both columns in |\@outputbox|, combine them with +% all page-wide floats for this page (|\@combinedblfloats|), attach +% header and footer, and ship out the result (|\@outputpage|). +% Finally we look to see whether it is possible to generate +% following pages consisting only of page-wide +% floats.\footnote{This part is copied directly from the original +% \LaTeX{} macro. Details about the used macros, their interfaces +% and meanings can be found in the \LaTeXe{} source +% code~\cite{src:ltxiii94}.} +% \begin{macrocode} + \global\@firstcolumntrue + \setbox\@outputbox\vbox{\hbox to\textwidth + {\hbox to\columnwidth + {\box\@leftcolumn\hss}% + \hfil\vrule\@width\columnseprule\hfil + \hbox to\columnwidth + {\box\@outputbox\hss}}}% + \@combinedblfloats\@outputpage + \begingroup + \@dblfloatplacement\@startdblcolumn + \@whilesw\if@fcolmade\fi + {\@outputpage\@startdblcolumn}% + \endgroup + \fi} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\@startcolumn} +% \changes{v1.0b}{1990/08/11}{Macro added to correct float problems} +% There is a fundamental flaw in \LaTeX's output routine for float +% columns and float pages: split footnotes, i.e., footnotes which +% are only partly typeset on the preceding page are not resolved. +% They are held over until \LaTeX{} starts a page (or column) +% containing text besides floats again. For our current layout, +% this would mean, that if \LaTeX{} decided to make the right +% column of a page a float column, footnotes from the left column +% would appear on a later page. A real cure for this problem would +% be to rewrite two-thirds of \LaTeX{}'s output routine, so I am +% leaving this open for the interested reader. +% +% \begin{figure}[b] +% \fbox{%^^A +% \newlength{\puzzlewd}%^^A +% \setlength{\puzzlewd}{\columnwidth}%^^A +% \addtolength{\puzzlewd}{-2.1\fboxsep}%^^A +% \begin{minipage}{\puzzlewd} +% \vspace{17pt} +% \begin{center} +% \bf Puzzle: +% \end{center} +% \vspace{-3pt} +% \small +% \begin{quote} +% \rightskip \leftmargini plus 2.5em +% Given a simple \TeX{} document containing only straight text, is +% it possible for the editor, after +% deleting one sentence, to end up with a document +% producing an extra page? +% +% We assume that the deleted text contains no \TeX{} macros and +% that the document was prepared +% with a standard macro package like the one used for \TUB\/ production. +% \end{quote} +% \vspace{7pt} +% \begin{flushright} +% The answer will be given in the next issue. +% \end{flushright} +% \vspace{7pt} +% \end{minipage}} +% \end{figure} +% +% But the problem shows up even if only one float is contributed to +% the right column since \LaTeX{} assumes that the whole column is +% usable, whereas some of it might actually be already devoted to +% footnotes from the left column. So we have to change the output +% routine at least in the part that contributes floats to the next +% column. The macro involved is called |\@startcolumn|. The first +% thing we do is to check and see whether any deferred floats +% exists. +% \begin{macrocode} +\def\@startcolumn{% + \ifx\@deferlist\@empty +% \end{macrocode} +% If not, we set the switch |\if@fcolmade| to {\tt false} which +% says that we did not succeed in making a float column. Then, we +% set |\@colroom| to |\@colht|. The register |\@colht| holds the +% amount of space that is available for floats, text, and footnotes +% in one column, i.e., it equals |\textheight| minus the space +% devoted to page-wide floats. |\@colroom| is a similar register +% which holds the value |\@colht| minus space for column floats +% that are already contributed to the current column. Of course, +% both values should be equal when we start a new column. +% \begin{macrocode} + \global\@fcolmadefalse + \global\@colroom\@colht + \else +% \end{macrocode} +% If there are floats waiting for a change to be processed, the +% situation is more difficult. In this case, we have to reduce both +% |\@colht| and |\@colroom| by the amount of space that will be +% needed for the footnotes from the left column. So we must check +% whether such footnotes are present. As we have not reinserted +% them in |\@outputdblcol|, we can check the |\footins| box. +% \begin{macrocode} + \ifvoid\footins\else +% \end{macrocode} +% If there are some, we measure the space that will be occupied by +% them. This measurement is not really exact. If we have a full +% column of footnotes, it will be too high, but this does matter +% since we need it only for an upper bound on the free space +% available for floats. +% \begin{macrocode} + \ftn@amount\ht\footins + \advance\ftn@amount\dp\footins + \advance\ftn@amount\skip\footins + \fi +% \end{macrocode} +% We then reduce the |\@colht| by this amount and again assign +% |\@colroom| the value of |\@colht|. If no footnotes are present, +% we subtract zero, so there is no harm in doing this operation +% all the time. +% \begin{macrocode} + \global\advance\@colht-\ftn@amount + \global\@colroom\@colht +% \end{macrocode} +% Now, we call another internal \LaTeX{} macro that will try to +% contribute floats to the next column. It will use the register +% |\@colht| when trying to build up a float column, which is the +% reason for reducing this register. If it succeeds, it will set the +% switch |\if@fcolmade| to {\tt true}, otherwise, to {\tt false}. If +% no float column is possible, it will try to place some or all of +% the deferred floats to the top or the bottom of the next column, +% thereby, using and reducing the value of the register |\@colroom|. +% \begin{macrocode} + \@xstartcol +% \end{macrocode} +% Afterwards, we have to restore the correct values for |\@colht| +% and |\@colroom| again, but this time, they may differ, so that we +% have to |\advance| both registers separately by |\ftn@amount|. +% \begin{macrocode} + \global\advance\@colht\ftn@amount + \global\advance\@colroom\ftn@amount + \fi +% \end{macrocode} +% Now, after doing the things depending on the status of the +% |\@deferlist|, we have to incorporate the left over footnotes in +% the new column. First we check whether a float column was +% produced by |\@xstartcol| or not. +% \begin{macrocode} + \if@fcolmade +% \end{macrocode} +% If so, we do something awful. To make use of the |\@makecol| +% macro, which attaches footnotes to |\box| $255$ and places the +% result in the box register |\@outputbox|, we have to assign +% |\@outputbox| (i.e., the result of |\@xstartcol|) to |\box| +% $255$.\footnote{In German, we call this ``from the back through +% the chest into the eyes''.} +% \begin{macrocode} + \setbox\@cclv\box\@outputbox + \@makecol + \else +% \end{macrocode} +% If no float column was produced, we reinsert the held over +% footnotes so that they can be reconsidered by the page generation +% algorithm of \TeX. But it is necessary to ensure that this +% operation is done only when footnotes are actually +% present.\footnote{Otherwise, we might get an undesired extra +% vertical space coming from {\tt\bslash skip\bslash footins}, even +% if there are no footnotes on the page.} +% \begin{macrocode} + \ifvoid\footins\else + \insert\footins{\unvbox\footins}\fi + \fi} +% \end{macrocode} +% \begin{macro}{\ftn@amount} +% Of course, we also have to allocate the {\sf dimen} register. It +% will be automatically initialized to zero. +% \begin{macrocode} +\newdimen\ftn@amount +% \end{macrocode} +% \end{macro} +% \end{macro} + + +% \begin{macro}{\@xstartcol} +% \changes{v1.1a}{1994/01/24}{Macro reintroduced} +% The macro |\@xtsartcol| was removed in \LaTeXe{} but we introduce +% it here again for the moment. +% \begin{macrocode} +\def\@xstartcol{% + \@tryfcolumn \@deferlist + \if@fcolmade + \else + \begingroup + \let \@tempb \@deferlist + \global \let \@deferlist \@empty + \let \@elt \@scolelt + \@tempb + \endgroup + \fi +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@makecol} +% The other internal macro that we have to change is |\@makecol|, a +% macro that is called whenever one column of material is assembled +% and column floats and footnotes have to be added. Again, we have +% to distinguish between actions for the first and the second +% column. +% \begin{macrocode} +\def\@makecol{\if@firstcolumn +% \end{macrocode} +% For the first column, we leave the footnotes in their box and +% simply save the contents of box $255$ in the |\box| register +% |\@outputbox|. +% \begin{macrocode} + \setbox\@outputbox\box\@cclv +% \end{macrocode} +% +% But if the user erroneously forgot to specify a twocolumn layout, we +% will always typeset the first column, so that the footnotes are +% never printed. Therefore we better check for this special case +% and output the footnotes on a separate page in an +% emergency.\footnote{Otherwise, the footnotes are held over for +% ever, preventing \TeX{} from finishing the document successfully. +% Instead, \TeX{} will produce infinity many empty pages at the end +% of the document, trying in vain to output the held over +% footnotes. This problem was found by Rainer Sch\"opf when we +% prepared the paper for the Cork conference.} +% \changes{v1.0c}{1990/08/24}{Introduced crude recovery if +% twocolumn false.} +% \changes{v1.0d}{1992/06/19}{Better help message} +% \begin{macrocode} + \if@twocolumn \else + \ifvoid\footins \else + \@latexerr{ftnright package + used in one-column mode}% + {The ftnright package was designed to + work with LaTeX's standard^^Jtwocolumn + option. It does *not* work with the + multicol package.^^JSo please specify + `twocolumn' in the + \noexpand\documentclass command.}% + \shipout\box\footins \fi\fi +% \end{macrocode} +% What we also need to check is if there is so much footnote material that +% it resulted in a footnote being split. If that happens the whole +% algorithm falls apart and the footnotes get out of sync. For the +% moment we simply detect it here, perhaps some better scheme can be +% implemented. One way to avoid this is to allow more than |\textheight| of +% footnotes in |\preparefootins|. However, that isn't such a good idea +% either as that means that a footnote from column one, might end up +% completely on a later page. +% \changes{v1.1f}{2010/02/25}{Check for split footnotes (pr/4099)} +% \begin{macrocode} + \ifnum\insertpenalties>\z@ + \@latexerr{ftnright package + scrambled footnotes}% + {There is too much footnote material in + the first column and ftnright^^Jis + unable to cope with this.^^JYou need + to reduce the amount to get a properly + formatted page.}% + \fi + \else +% \end{macrocode} +% When we construct the second column, we must first check whether +% footnotes are actually present. If not, we perform the same +% actions as before. +% \begin{macrocode} + \ifvoid\footins + \setbox\@outputbox\box\@cclv + \else +% \end{macrocode} +% But, if footnotes are present, it may be possible that the whole +% column consists of footnotes, i.e., |\box| $255$ is empty. In +% this case, there is no use in placing any glue (|\skip\footins|) +% in front,\footnote{In fact, it would be a mistake since this glue +% was not taken into account when the footnotes where assembled, so +% it would produce an overfull box.} so we have to check for this +% possibility. +% \begin{macrocode} + \setbox\@outputbox\vbox + {\ifvoid\@cclv \else + \unvbox\@cclv + \vskip\skip\footins\fi +% \end{macrocode} +% But in any case, we place the |\footnoterule| in front of the +% footnotes even if this macro is not used by this +% package.\footnote{This decision is certainly open to criticism, +% since there is nothing to separate. On the other hand, a rule or +% some other ornament in front of the footnotes is part of the +% design which should be used consistently throughout a document. +% As a last argument in favor of the rule, consider the situation +% where \LaTeX{} decided to place only floats and footnotes into +% the right hand column. In this case a separator again seems +% adequate. In this situation one can even argue that it is +% necessary to put in the {\tt \bslash skip\.\bslash footins}.} +% This ends the if-statement testing whether footnotes are present +% or not. It also ends the code which differs depending on the +% column number. +% \changes{v1.1d}{1998/12/02}{Added the color@group macros and +% \texttt{\protect\bslash normalcolor} to make this colorsafe} +% \begin{macrocode} + \color@begingroup + \normalcolor + \footnoterule\unvbox\footins + \color@endgroup}\fi + \fi +% \end{macrocode} +% Now the column floats are added at the top and the bottom, and +% the |\@outputbox| is adjusted to the full column height so that +% the glue inside will stretch in certain situations.\footnote{It +% is an interesting question as to whether the current layout works +% well with bottom floats or not. Actually, I would prefer to place +% the footnotes below the bottom floats instead of above, as it is +% done here. At least when the floats are part of the document and +% not puzzles thrown in. But I was too lazy to implement it +% because I seldom use floats. If somebody implements this layout +% (some parts of this macro have to be changed) I would be +% interested in seeing the code and some sample results.} Again, +% this code is copied verbatim from the original source, so I won't +% dwell on details.\footnote{I only changed {\tt\bslash dimen128} +% into {\tt\bslash @tempdima} which is, besides being faster and +% shorter, only a cosmetic change. The use of this hardwired {\sf +% dimen} register seems to indicate that this part of \LaTeX{} was +% written very early and left unchanged since then: an interesting +% fact for software archaeologists.}\footnote{For the \LaTeXe{} +% upgrade I had to add the support for the +% {\tt\string\enlargethispage} command---let's hope I did it in the +% correct way.} +% \changes{v1.1a}{1994/01/24}{Upgrades for LaTeX2e} +% \begin{macrocode} + \xdef\@freelist{\@freelist\@midlist}% + \global \let \@midlist \@empty + \@combinefloats + \ifvbox\@kludgeins + \@makespecialcolbox + \else + \setbox\@outputbox\vbox to\@colht + {\boxmaxdepth\maxdepth + \@texttop + \@tempdima\dp\@outputbox + \unvbox\@outputbox + \vskip-\@tempdima + \@textbottom}% + \fi + \global\maxdepth\@maxdepth} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\footnotesize} +% \changes{v1.1a}{1994/01/24}{Upgrades for LaTeX2e} +% Now we can tackle the remaining small changes to the standard +% layout. I decided to use a smaller size for footnotes but with a +% slightly larger leading than usual. This means that we have to +% redefine the |\footnotesize| macro which depends on options like +% {\tt 11pt} etc. Fortunately, there is a simple way to find out +% the main size of the document: the macro |\@ptsize| contains $0$, +% $1$, or $2$ standing for $10$, $11$, or $12$ points document text +% size.\footnote{In the new release I used the definitions from the +% class option files \texttt{size1?.clo} and modified them +% slightly. In the previous release there was no correction for the +% list parameters etc., thus giving you incorrect spacing if +% somebody used display lists in footnotes.} +% \begin{macrocode} +\ifcase \@ptsize +\renewcommand\footnotesize{% + \@setfontsize\footnotesize\@viiipt{9.9}% + \abovedisplayskip 6\p@\@plus2\p@\@minus4\p@ + \abovedisplayshortskip \z@ \@plus\p@ + \belowdisplayshortskip + 3\p@\@plus\p@\@minus2\p@ + \def\@listi{\leftmargin\leftmargini + \topsep 3\p@ \@plus\p@ \@minus\p@ + \parsep 2\p@ \@plus\p@ \@minus\p@ + \itemsep \parsep}% + \belowdisplayskip \abovedisplayskip +} +\or +\renewcommand\footnotesize{% + \@setfontsize\footnotesize\@ixpt{11.1}% + \abovedisplayskip 8\p@\@plus2\p@\@minus4\p@ + \abovedisplayshortskip \z@ \@plus\p@ + \belowdisplayshortskip + 4\p@ \@plus2\p@ \@minus2\p@ + \def\@listi{\leftmargin\leftmargini + \topsep 4\p@ \@plus2\p@\@minus2\p@ + \parsep 2\p@ \@plus\p@ \@minus\p@ + \itemsep \parsep}% + \belowdisplayskip \abovedisplayskip +} +\or +\renewcommand\footnotesize{% + \@setfontsize\footnotesize\@xpt{12.3}% + \abovedisplayskip10\p@\@plus2\p@\@minus5\p@ + \abovedisplayshortskip \z@ \@plus3\p@ + \belowdisplayshortskip + 6\p@ \@plus3\p@ \@minus3\p@ + \def\@listi{\leftmargin\leftmargini + \topsep 6\p@ \@plus2\p@ \@minus2\p@ + \parsep 3\p@ \@plus2\p@ \@minus\p@ + \itemsep \parsep}% + \belowdisplayskip \abovedisplayskip +} +\fi +% \end{macrocode} +% \end{macro} +% +% +% +% \begin{macro}{\footnoterule} +% Setting footnotes in smaller type and separating them with +% sufficient space from the main text allow us to omit the +% |\footnoterule| normally used. +% \begin{macrocode} +\let\footnoterule\@empty +% \end{macrocode} +% \end{macro} +% +% +% +% \begin{macro}{\footnotesep} +% \changes{v1.1a}{1994/01/24}{Upgrades for LaTeX2e} +% Individual footnotes are separated from each other by a more or +% less baseline skip of the text size. This can be specified with +% the following code: +% \begin{macrocode} +\AtBeginDocument + {\global\footnotesep\ht\strutbox} +% \end{macrocode} +% The use of the \LaTeXe{} hook |\AtBeginDocument| is a big help +% since it allows us to defer everything that might depend on user +% setting inside the preamble to the |\begin{document}| environment +% start. +% \end{macro} +% +% +% +% \begin{macro}{\@makefntext} +% And finally, a small but nice change, to the mark at the +% beginning of the footnote text. We will place it at the baseline +% instead of raising it as a superscript. Additionally, it will get +% a dot as punctuation. +% \changes{v1.0c}{1990/08/24}{Added dot as recommended by Tschichold.} +% \changes{v1.1e}{2000/04/14}{Don't use math mode for footnote symbol +% (pr/3172)} +% \begin{macrocode} +\long\def\@makefntext#1{\parindent 1em + \noindent\hbox to 2em{}% + \llap{\@thefnmark.\,\,}#1} +% \end{macrocode} +% \end{macro} +% +% +% \section{Initialisation} +% +% We defined the macro |\preparefootins| above, but we also have to use +% it to prepare typesetting the first column. As a default for the +% separation of footnotes and text on the second column, we use the +% following: +% \begin{macrocode} +\setlength{\skip\footins} + {10pt plus 5pt minus 3pt} +\AtBeginDocument{\preparefootins} +%</package> +% \end{macrocode} +% Of course, this value can be changed by the user as +% described in the introduction. +% +% \Finale +% +% +% + +\endinput diff --git a/macros/latex-dev/required/tools/ftnright.pdf b/macros/latex-dev/required/tools/ftnright.pdf Binary files differnew file mode 100644 index 0000000000..0a2e5747b5 --- /dev/null +++ b/macros/latex-dev/required/tools/ftnright.pdf diff --git a/macros/latex-dev/required/tools/hhline.dtx b/macros/latex-dev/required/tools/hhline.dtx new file mode 100644 index 0000000000..1da01d757b --- /dev/null +++ b/macros/latex-dev/required/tools/hhline.dtx @@ -0,0 +1,322 @@ +% \iffalse meta-comment +% +% Copyright (C) 1993-2019 +% +% The LaTeX3 Project and any individual authors listed elsewhere +% in this file. +% +% This file is part of the Standard LaTeX `Tools Bundle'. +% ------------------------------------------------------- +% +% It may be distributed and/or modified under the +% conditions of the LaTeX Project Public License, either version 1.3c +% of this license or (at your option) any later version. +% The latest version of this license is in +% https://www.latex-project.org/lppl.txt +% and version 1.3c or later is part of all distributions of LaTeX +% version 2005/12/01 or later. +% +% The list of all files belonging to the LaTeX `Tools Bundle' is +% given in the file `manifest.txt'. +% +% \fi +% \iffalse +%% File: hhline.dtx Copyright (C) 1991-1994 David Carlisle +% +%<package>\NeedsTeXFormat{LaTeX2e} +%<package>\ProvidesPackage{hhline} +%<package> [2014/10/28 v2.03 Table rule package (DPC)] +% +%<*driver> +\documentclass{ltxdoc} +\usepackage{hhline} +\GetFileInfo{hhline.sty} +\begin{document} +\title{The \textsf{hhline} package\thanks{This file + has version number \fileversion, last + revised \filedate.}} +\author{David Carlisle} +\date{\filedate} + \MaintainedByLaTeXTeam{tools} + \maketitle + \DeleteShortVerb{\|} + \DocInput{hhline.dtx} +\end{document} +%</driver> +% \fi +% +% +% \changes{v1.00}{1991/06/04}{Initial Version} +% \changes{v2.00}{1991/11/06} +% {Add tilde which allows \cmd\cline-like constructions.} +% \changes{v2.01}{1992/06/26} +% {Re-issue for the new doc and docstrip.} +% \changes{v2.02}{1994/03/14} +% {Update for LaTeX2e.} +% \changes{v2.03}{1994/05/23} +% {New style warning.} +% +% +% +% \MakeShortVerb{\"} +% +% \begin{abstract} +% "\hhline" produces a line like "\hline", or a double line like +% "\hline\hline", except for its interaction with vertical lines. +% \end{abstract} +% +% \arrayrulewidth=1pt +% \doublerulesep=3pt +% +% \section{Introduction} +% The argument to "\hhline" is similar to the preamble of an {\tt +% array} or {\tt tabular}. It consists of a list of tokens with the +% following meanings: +% \[ +% \begin{tabular}{cl} +% "=" & A double hline the width of a column.\\ +% "-" & A single hline the width of a column.\\[10pt] +% "~" & A column with no hline.\\[10pt] +% +% "|" & A vline which `cuts' through a double (or single) hline.\\ +% ":" & A vline which is broken by a double hline.\\[10pt] +% +% "#" & A double hline segment between two vlines.\\ +% "t" & The top half of a double hline segment.\\ +% "b" & The bottom half of a double hline segment.\\ +% +% "*" & "*{3}{==#}" expands to "==#==#==#", +% as in the {\tt*}-form for the preamble. +% \end{tabular} +% \] +% If a double vline is specified ("||" or "::") then the hlines +% produced by "\hhline" are broken. To obtain the effect of an hline +% `cutting through' the double vline, use a "#" or omit the vline +% specifiers, depending on whether or not you wish the double vline to +% break. +% +% The tokens {\tt t} and {\tt b} must be used between two vertical +% rules. "|tb|" produces the same lines as "#", but is much less +% efficient. The main use for these are to make constructions like +% "|t:" (top left corner) and ":b|" (bottom right corner). +% +% If "\hhline" is used to make a single hline, then the argument +% should only contain the tokens "-", "~" and "|" (and +% {\tt*}-expressions). +% +% An example using most of these features is: +% \[ +% \vcenter{\hsize=2in\begin{verbatim} +% \begin{tabular}{||cc||c|c||} +% \hhline{|t:==:t:==:t|} +% a&b&c&d\\ +% \hhline{|:==:|~|~||} +% 1&2&3&4\\ +% \hhline{#==#~|=#} +% i&j&k&l\\ +% \hhline{||--||--||} +% w&x&y&z\\ +% \hhline{|b:==:b:==:b|} +% \end{tabular} +% \end{verbatim} +% } +% \qquad +% \begin{tabular}{||cc||c|c||} +% \hhline{|t:==:t:==:t|} +% a&b&c&d\\ +% \hhline{|:==:|~|~||} +% 1&2&3&4\\ +% \hhline{#==#~|=#} +% i&j&k&l\\ +% \hhline{||--||--||} +% w&x&y&z\\ +% \hhline{|b:==:b:==:b|} +% \end{tabular} +% \] +% +% The lines produced by \LaTeX's "\hline" consist of a single (\TeX\ +% primitive) "\hrule". The lines produced by "\hhline" are made +% up of lots of small line segments. \TeX\ will place these very +% accurately in the {\tt .dvi} file, but the program that you use to +% print the {\tt .dvi} file may not line up these segments exactly. (A +% similar problem can occur with diagonal lines in the {\tt picture} +% environment.) +% +% If this effect causes a problem, you could try a different driver +% program, or if this is not possible, increasing "\arrayrulewidth" +% may help to reduce the effect. +% +% \StopEventually{} +% +% \section{The Macros} +% +% \begin{macrocode} +%<*package> +% \end{macrocode} +% +% \begin{macro}{\HH@box} +% Makes a box containing a double hline segment. The most common case, +% both rules of length "\doublerulesep" will be stored in "\box1", this +% is not initialised until "\hhline" is called as the user may change +% the parameters "\doublerulesep" and "\arrayrulewidth". The two +% arguments to "\HH@box" are the widths (ie lengths) of the top and +% bottom rules. +% \begin{macrocode} +\def\HH@box#1#2{\vbox{% + \hrule \@height \arrayrulewidth \@width #1 + \vskip \doublerulesep + \hrule \@height \arrayrulewidth \@width #2}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\HH@add} +% Build up the preamble in the register "\toks@". +% \begin{macrocode} +\def\HH@add#1{\toks@\expandafter{\the\toks@#1}} +% \end{macrocode} +% \end{macro} + +% \begin{macro}{\HH@xexpast} +% \begin{macro}{\HH@xexnoop} +% We `borrow' the version of "\@xexpast" from Mittelbach's array.sty, +% as this allows "#" to appear in the argument list. +% \begin{macrocode} +\def\HH@xexpast#1*#2#3#4\@@{% + \@tempcnta #2 + \toks@={#1}\@temptokena={#3}% + \let\the@toksz\relax \let\the@toks\relax + \def\@tempa{\the@toksz}% + \ifnum\@tempcnta >0 \@whilenum\@tempcnta >0\do + {\edef\@tempa{\@tempa\the@toks}\advance \@tempcnta \m@ne}% + \let \@tempb \HH@xexpast \else + \let \@tempb \HH@xexnoop \fi + \def\the@toksz{\the\toks@}\def\the@toks{\the\@temptokena}% + \edef\@tempa{\@tempa}% + \expandafter \@tempb \@tempa #4\@@} + +\def\HH@xexnoop#1\@@{} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\hhline} +% Use a simplified version of "\@mkpream" to break apart the argument +% to "\hhline". Actually it is oversimplified, It assumes that the +% vertical rules are at the end of the column. If you were to specify +% "c|@{xx}|" in the array argument, then "\hhline" would not be +% able to access the first vertical rule. (It ought to have an "@" +% option, and add "\leaders" up to the width of a box containing the +% "@"-expression. We use a loop made with "\futurelet" rather +% than "\@tfor" so that we can use "#" to denote the crossing of +% a double hline with a double vline.\\ +% "\if@firstamp" is true in the first column and false otherwise.\\ +% "\if@tempswa" is true if the previous entry was a vline +% (":", "|" or "#"). +% \begin{macrocode} +\def\hhline#1{\omit\@firstamptrue\@tempswafalse +% \end{macrocode} +% Put two rules of width "\doublerulesep" in "\box1" +% \begin{macrocode} +\global\setbox\@ne\HH@box\doublerulesep\doublerulesep +% \end{macrocode} +% If Mittelbach's {\tt array.sty} is loaded, we do not need the negative +% "\hskip"'s around vertical rules. +% \begin{macrocode} + \xdef\@tempc{\ifx\extrarowheight\HH@undef\hskip-.5\arrayrulewidth\fi}% +% \end{macrocode} +% Now expand the {\tt*}-forms and add dummy tokens ( "\relax" and +% "`" ) to either end of the token list. Call "\HH@let" to start +% processing the token list. +% \begin{macrocode} + \HH@xexpast\relax#1*0x\@@\toks@{}\expandafter\HH@let\@tempa`} +% \end{macrocode} +% \end{macro} + +% \begin{macro}{\HH@let} +% Discard the last token, look at the next one. +% \begin{macrocode} +\def\HH@let#1{\futurelet\@tempb\HH@loop} +% \end{macrocode} +% \end{macro} + +% \begin{macro}{\HH@loop} +% The main loop. Note we use "\ifx" rather than "\if" in +% version~2 as the new token "~" is active. +% \begin{macrocode} +\def\HH@loop{% +% \end{macrocode} +% If next token is "`", stop the loop and put the lines into this row +% of the alignment. +% \begin{macrocode} + \ifx\@tempb`\def\next##1{\the\toks@\cr}\else\let\next\HH@let +% \end{macrocode} +% "|", add a vertical rule (across either a double or +% single hline). +% \begin{macrocode} + \ifx\@tempb|\if@tempswa\HH@add{\hskip\doublerulesep}\fi\@tempswatrue + \HH@add{\@tempc\vline\@tempc}\else +% \end{macrocode} +% ":", add a broken vertical rule (across a double hline). +% \begin{macrocode} + \ifx\@tempb:\if@tempswa\HH@add{\hskip\doublerulesep}\fi\@tempswatrue + \HH@add{\@tempc\HH@box\arrayrulewidth\arrayrulewidth\@tempc}\else +% \end{macrocode} +% "#", add a double hline segment between two vlines. +% \begin{macrocode} + \ifx\@tempb##\if@tempswa\HH@add{\hskip\doublerulesep}\fi\@tempswatrue + \HH@add{\@tempc\vline\@tempc\copy\@ne\@tempc\vline\@tempc}\else +% \end{macrocode} +% "~", A column with no hline (this gives an effect similar to +% \verb+\cline+). +% \begin{macrocode} + \ifx\@tempb~\@tempswafalse + \if@firstamp\@firstampfalse\else\HH@add{&\omit}\fi + \HH@add{\hfil}\else +% \end{macrocode} +% "-", add a single hline across the column. +% \begin{macrocode} + \ifx\@tempb-\@tempswafalse + \if@firstamp\@firstampfalse\else\HH@add{&\omit}\fi + \HH@add{\leaders\hrule\@height\arrayrulewidth\hfil}\else +% \end{macrocode} +% "=", add a double hline across the column. +% \begin{macrocode} + \ifx\@tempb=\@tempswafalse + \if@firstamp\@firstampfalse\else\HH@add{&\omit}\fi +% \end{macrocode} +% Put in as many copies of "\box1" as possible with +% "\leaders", this may leave gaps at the ends, so put an extra box +% at each end, overlapping the "\leaders". +% \begin{macrocode} + \HH@add + {\rlap{\copy\@ne}\leaders\copy\@ne\hfil\llap{\copy\@ne}}\else +% \end{macrocode} +% "t", add the top half of a double hline segment, in a "\rlap" +% so that it may be used with {\tt b}. +% \begin{macrocode} + \ifx\@tempb t\HH@add{\rlap{\HH@box\doublerulesep\z@}}\else +% \end{macrocode} +% "b", add the bottom half of a double hline segment in a "\rlap" +% so that it may be used with {\tt t}. +% \begin{macrocode} + \ifx\@tempb b\HH@add{\rlap{\HH@box\z@\doublerulesep}}\else +% \end{macrocode} +% Otherwise ignore the token, with a warning. +% \begin{macrocode} + \PackageWarning{hhline}% + {\meaning\@tempb\space ignored in \noexpand\hhline argument% + \MessageBreak}% + \fi\fi\fi\fi\fi\fi\fi\fi\fi +% \end{macrocode} +% Go around the loop again. +% \begin{macrocode} + \next} +% \end{macrocode} +% \end{macro} +% +% \begin{macrocode} +%</package> +% \end{macrocode} +% +% \Finale +\endinput diff --git a/macros/latex-dev/required/tools/hhline.pdf b/macros/latex-dev/required/tools/hhline.pdf Binary files differnew file mode 100644 index 0000000000..d4ccc822d4 --- /dev/null +++ b/macros/latex-dev/required/tools/hhline.pdf diff --git a/macros/latex-dev/required/tools/indentfirst.dtx b/macros/latex-dev/required/tools/indentfirst.dtx new file mode 100644 index 0000000000..16b99653cd --- /dev/null +++ b/macros/latex-dev/required/tools/indentfirst.dtx @@ -0,0 +1,77 @@ +% \iffalse meta-comment +% +% Copyright (C) 1993-2019 +% +% The LaTeX3 Project and any individual authors listed elsewhere +% in this file. +% +% This file is part of the Standard LaTeX `Tools Bundle'. +% ------------------------------------------------------- +% +% It may be distributed and/or modified under the +% conditions of the LaTeX Project Public License, either version 1.3c +% of this license or (at your option) any later version. +% The latest version of this license is in +% https://www.latex-project.org/lppl.txt +% and version 1.3c or later is part of all distributions of LaTeX +% version 2005/12/01 or later. +% +% The list of all files belonging to the LaTeX `Tools Bundle' is +% given in the file `manifest.txt'. +% +% \fi +% \iffalse +%% File: indent.dtx Copyright (C) 1991-1994 David Carlisle +% +%<package>\NeedsTeXFormat{LaTeX2e} +%<package>\ProvidesPackage{indentfirst} +%<package> [1995/11/23 v1.03 Indent first paragraph (DPC)] +% +%<*driver> +\documentclass{ltxdoc} +\usepackage{indentfirst} +\GetFileInfo{indentfirst.sty} +\begin{document} +\title{The \textsf{indentfirst} package\thanks{This file + has version number \fileversion, last + revised \filedate.}} +\author{David Carlisle} +\date{\filedate} +\MaintainedByLaTeXTeam{tools} +\maketitle +\DocInput{indentfirst.dtx} +\end{document} +%</driver> +% \fi +% +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% \changes{v1.00}{1991/01/02}{Initial version} +% \changes{v1.01}{1992/06/26}{Re-issue for the new doc and docstrip} +% \changes{v1.02}{1994/01/31}{Re-issue for LaTeX2e} +% \changes{v1.03}{1995/11/23}{Typo fixes in documentation} +% +% \begin{abstract} +% Make the first line of all sections etc., be indented by the usual +% paragraph indentation. This should work with all the standard document +% classes. +% \end{abstract} +% +% \CheckSum{4}^^A Still I think a record:-) +% +% \StopEventually{} +% +% \begin{macro}{\if@afterindent} +% \LaTeX\ uses the switch |\if@afterindent| to decide whether to indent +% after a section heading. We just need to make sure that this is always +% true. +% \begin{macrocode} +%<*package> +\let\@afterindentfalse\@afterindenttrue +\@afterindenttrue +%</package> +% \end{macrocode} +% \end{macro} +% +% \Finale +% diff --git a/macros/latex-dev/required/tools/indentfirst.pdf b/macros/latex-dev/required/tools/indentfirst.pdf Binary files differnew file mode 100644 index 0000000000..8ac0d1f3e8 --- /dev/null +++ b/macros/latex-dev/required/tools/indentfirst.pdf diff --git a/macros/latex-dev/required/tools/layout.dtx b/macros/latex-dev/required/tools/layout.dtx new file mode 100644 index 0000000000..848eb54fb2 --- /dev/null +++ b/macros/latex-dev/required/tools/layout.dtx @@ -0,0 +1,1025 @@ +% \iffalse meta-comment +% +% Copyright (C) 1993-2019 +% +% The LaTeX3 Project and any individual authors listed elsewhere +% in this file. +% +% This file is part of the Standard LaTeX `Tools Bundle'. +% ------------------------------------------------------- +% +% It may be distributed and/or modified under the +% conditions of the LaTeX Project Public License, either version 1.3c +% of this license or (at your option) any later version. +% The latest version of this license is in +% https://www.latex-project.org/lppl.txt +% and version 1.3c or later is part of all distributions of LaTeX +% version 2005/12/01 or later. +% +% The list of all files belonging to the LaTeX `Tools Bundle' is +% given in the file `manifest.txt'. +% +% \fi +%\iffalse +% This file is built for \LaTeXe, so we make sure an error is +% generated when it is used with another format +%<*dtx> +\ProvidesFile{layout.dtx} +%</dtx> +%<+package>\NeedsTeXFormat{LaTeX2e} +%<+package>\ProvidesPackage{layout} +%<+driver>\ProvidesFile{layout.drv} +%\ProvidesFile{layout.dtx} + [2014/10/28 v1.2c Show layout parameters] +% +% A short driver is provided that can be extracted if necessary by +% the \textsf{DocStrip} program provided with \LaTeXe. +% \begin{macrocode} +%<*driver> +\documentclass{ltxdoc} + +\usepackage{layout} + +\newcommand\Lopt[1]{\textsf{#1}} +\pagestyle{myheadings} +\DisableCrossrefs +\begin{document} +\DocInput{layout.dtx} +\end{document} +%</driver> +% \end{macrocode} +%\fi +% \changes{v1.1c}{1994/07/13}{Moved Identification code to the front +% and removed the permanent use of \cs{filedate} and friends} +% \changes{v1.1d}{1994/09/08}{Stored texts in control sequences to +% allow other languages} +% +% \GetFileInfo{layout.dtx} +% \title{Displaying page layout variables} +% \author{Kent McPherson a.o.\thanks{Converted for \LaTeXe\ by +% Johannes Braams and modified by Hideo Umeki}} +% \date{\filedate} +% +% \markboth{layout package version \fileversion\space as of \filedate} +% {layout package version \fileversion\space as of \filedate} +% +% \MaintainedByLaTeXTeam{tools} +% \maketitle +% +% \section{Introduction} +% +% This \LaTeXe\ package is a reimplementation of +% \texttt{layout.sty} by Kent McPherson. It defines the command +% |\layout| which produces an overview of the layout of the current +% document. The command |\layout*| recomputes the values it uses to +% produce the overview. +% +% The figure on the next page shows the output of the |\layout| +% command for this document. +% +% \begin{figure}[p] +% \layout +% \end{figure} +% +% \StopEventually{} +% +% \section{The implementation} +% +% \changes{v1.1b}{1994/03/23}{removed the \cs{wlog} as +% \cs{ProvidesPackage} does that now} +% \changes{v1.1d}{1994/09/08}{Added language options dutch and +% english} +% +% This package prints a figure to illustrate the layout that is +% implemented by the document class. In the figure several words +% appear. They are stored in control sequences to be able to select +% a different language. +% \changes{v1.1e}{1994/10/29}{The dutch texts should be one word.} +% \changes{v1.1f}{1995/03/14}{Added \cs{notshown}} +% \changes{v1.1f}{1995/03/14}{Added option french} +% \changes{v1.1j}{1995/10/29}{Added the options spanish, brazilian and +% portuguese} +% \changes{v1.1k}{1995/11/23}{Documentation fixes} +% \changes{v1.2}{1998/04/13}{Redesign of the output by Hideo Umeki} +% \changes{v1.2c}{2000/09/21}{Added option german} +% \changes{v1.2c}{2000/09/25}{Added option for italian by Claudio Beccari} +% \begin{macrocode} +%<*package> +\DeclareOption{dutch}{% + \def\Headertext{Kopregel} + \def\Bodytext{Broodtekst} + \def\Footertext{Voetregel} + \def\MarginNotestext{Marge\\Notities} + \def\oneinchtext{een inch} + \def\notshown{niet getoond} + } +\DeclareOption{german}{% + \def\Headertext{Kopfzeile} + \def\Bodytext{Haupttext} + \def\Footertext{Fu{\ss}zeile} + \def\MarginNotestext{Rand-\\ notizen} + \def\oneinchtext{ein Zoll} + \def\notshown{ohne Abbildung} + } +\DeclareOption{ngerman}{\ExecuteOptions{german}} +\DeclareOption{english}{% + \def\Headertext{Header} + \def\Bodytext{Body} + \def\Footertext{Footer} + \def\MarginNotestext{Margin\\Notes} + \def\oneinchtext{one inch} + \def\notshown{not shown} + } +\DeclareOption{french}{% + \def\Headertext{Ent\^{e}te} + \def\Bodytext{Corps} + \def\Footertext{Pied de page} + \def\MarginNotestext{Marge\\Notes} + \def\oneinchtext{un pouce} + \def\notshown{non affich\'{e}} + } +\DeclareOption{francais}{\ExecuteOptions{french}} +\DeclareOption{spanish}{% + \def\Headertext{Encabezamiento} + \def\Bodytext{Cuerpo} + \def\Footertext{Pie de p\'agina} + \def\MarginNotestext{Notas\\ Marginales} + \def\oneinchtext{una pulgada} + \def\notshown{no mostradas} + } +\DeclareOption{portuguese}{% + \def\Headertext{Cabe\c{c}alho} + \def\Bodytext{Corpo} + \def\Footertext{Rodap\'e} + \def\MarginNotestext{Notas\\ Marginais} + \def\oneinchtext{uma polegada} + \def\notshown{n\~ao mostradas} + } +\DeclareOption{brazilian}{% + \def\Headertext{Cabe\c{c}alho} + \def\Bodytext{Corpo} + \def\Footertext{Rodap\'e} + \def\MarginNotestext{Notas\\ Marginais} + \def\oneinchtext{uma polegada} + \def\notshown{n\~ao mostradas} + } +\DeclareOption{italian}{% + \def\Headertext{Testatina} + \def\Bodytext{Corpo} + \def\Footertext{Piedino} + \def\MarginNotestext{Note\\ Marginali} + \def\oneinchtext{un pollice} + \def\notshown{non mostrato} + } +% \end{macrocode} +% +% This package has an option \Lopt{verbose}. Using it will make the +% command |\layout| type some of the parameters on the terminal. +% \begin{macrocode} +\DeclareOption{verbose}{\let\LayOuttype\typeout} +\DeclareOption{silent}{\let\LayOuttype\@gobble} +% \end{macrocode} +% +% \changes{v1.1h}{1995/04/07}{Added the options \Lopt{integers} +% (default) and \Lopt{reals}} +% +% The normal behaviour of this package when showing the values of +% the parameters is to truncate them. However, if you want to see +% the real parameter values you can use the option \Lopt{reals} to +% get that effect. +% \changes{v1.1i}{1995/06/25}{\LaTeX\ release 1995/06/01 no longer +% needs double hashmarks in the argument of \cs{DeclareOption}} +% \begin{macrocode} +\def\lay@value{} +\DeclareOption{integers}{% + \renewcommand*{\lay@value}[2]{% + \expandafter\number\csname #1@#2\endcsname pt}} +\DeclareOption{reals}{% + \renewcommand*{\lay@value}[2]{\the\csname #2\endcsname}} +% \end{macrocode} +% +% The default language is English, the default mode is +% \Lopt{silent} and the default way of showing parameter values is +% to use integers. +% \begin{macrocode} +\ExecuteOptions{english,silent,integers} +\ProcessOptions +% \end{macrocode} +% +% \begin{macro}{\LayOutbs} +% Define |\LayOutbs| to produce a backslash. We use a definition +% which also works with OT1 fonts. +% \changes{v1.2b}{1998/06/21}{Renamed \cs{bs} to avoid possible conflicts +% with other packages} +% \begin{macrocode} +\newcommand\LayOutbs{} +\chardef\LayOutbs`\\ +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\ConvertToCount} +% This macro stores the value of a \emph{length} register in a +% \emph{count} register. +% \begin{macrocode} +\def\ConvertToCount#1#2{% +% \end{macrocode} +% First copy the value +% \begin{macrocode} + #1=#2 +% \end{macrocode} +% Then divide it by 65536. +% \begin{macrocode} + \divide #1 by 65536} +% \end{macrocode} +% The result of this is that the \emph{count} register holds the +% value of the \emph{length} register in points. +% \end{macro} +% +% \begin{macro}{\SetToHalf} +% \begin{macro}{\SetToQuart} +% Small macros used in computing positions. +% \begin{macrocode} +\def\SetToHalf#1#2{#1=#2\relax\divide#1by\tw@} +\def\SetToQuart#1#2{#1=#2\relax\divide#1by4} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\Identify} +% A small macro used in identifying dimensions. +% \begin{macrocode} +\def\Identify#1{% + \put(\PositionX,\PositionY){\circle{20}} + \put(\PositionX,\PositionY){\makebox(0,0){\tiny #1}} +} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\InsideHArrow} +% This macro is used to produce two horizontal arrows inside a box. +% The argument gives the width of the box. +% \changes{v1.1c}{1994/07/14}{Added check for a negative arrow length} +% \begin{macrocode} +\def\InsideHArrow#1{{% + \ArrowLength = #1 + \divide\ArrowLength by \tw@ + \advance\ArrowLength by -10 + \advance\PositionX by -10 + \ifnum\ArrowLength<\z@ + \put(\PositionX,\PositionY){\vector(1,0){-\ArrowLength}} + \advance\PositionX by 20 + \put(\PositionX,\PositionY){\vector(-1,0){-\ArrowLength}} + \else + \put(\PositionX,\PositionY){\vector(-1,0){\ArrowLength}} + \advance\PositionX by 20 + \put(\PositionX,\PositionY){\vector(+1,0){\ArrowLength}} + \fi +}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\InsideVArrow} +% This macro is used to produce two vertical arrows inside a box. +% The argument gives the height of the box. +% \begin{macrocode} +\def\InsideVArrow#1{{% + \ArrowLength = #1 + \divide\ArrowLength by \tw@ + \advance\ArrowLength by -10 + \advance\PositionY by -10 + \put(\PositionX,\PositionY){\vector(0,-1){\ArrowLength}} + \advance\PositionY by 20 + \put(\PositionX,\PositionY){\vector(0,+1){\ArrowLength}} +}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\OutsideHArrow} +% This macro is used to produce two horizontal arrows to delimit a +% length. The first argument is the position for the right arrow, +% the second argument gives the length and the third specifies the +% length of the arrows. +% \begin{macrocode} +\def\OutsideHArrow#1#2#3{{% + \PositionX = #1 + \advance\PositionX by #3 + \put(\PositionX,\PositionY){\vector(-1,0){#3}} + \PositionX = #1 \advance\PositionX-#2 + \advance\PositionX by -#3 + \put(\PositionX,\PositionY){\vector(+1,0){#3}} +}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\OutsideVArrow} +% This macro is used to produce two vertical arrows to delimit a +% length. The first argument is the position for the lower arrow, +% the second argument gives the length and the third and fourth +% specify the lenghts of the lower and upper arrow. +% \begin{macrocode} +\def\OutsideVArrow#1#2#3#4{{% + \PositionY = #1 + \advance\PositionY by -#3 + \put(\PositionX,\PositionY){\vector(0,+1){#3}} + \PositionY = #1 + \advance\PositionY#2 + \advance\PositionY#4 + \put(\PositionX,\PositionY){\vector(0,-1){#4}} +}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\Show} +% \changes{v1.1g}{1995/04/03}{Simplified the definition, now show +% complete value} +% \changes{v1.1h}{1995/04/07}{Use \cs{lay@value} to show the value +% because of the option which decides which of two ways of doing it +% should be used} +% +% Macro used in the table that shows the setting of the parameters. +% \begin{macrocode} +\def\Show#1#2{\LayOutbs #2 = \lay@value{#1}{#2}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\Type} +% \changes{v1.1g}{1995/04/03}{Simplified the definition, now show +% complete value} +% \changes{v1.1h}{1995/04/07}{Use \cs{lay@value} to show the value +% because of the option which decides which of two ways of doing it +% should be used} +% \changes{v1.2b}{1998/06/21}{Renamed \cs{type} to \cs{LayOuttype} +% to avoid possible conflicts with other packages} +% +% Macro used to show a setting of a parameter on the terminal. +% \begin{macrocode} +\def\Type#1#2{% + \LayOuttype{#2 = \lay@value{#1}{#2}}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\oneinch} +% A constant, giving the length of an inch in points (approximately) +% \begin{macrocode} +\newcount\oneinch +\oneinch=72 +% \end{macrocode} +% \end{macro} +% +% Because the overview of the layout is produced in a figure +% environment we need to allocate a number of counters that are +% used to store the values of various dimensions. +% +% \begin{macro}{\cnt@paperwidth} +% \begin{macro}{\cnt@paperheight} +% The dimensions of the paper +% \begin{macrocode} +\newcount\cnt@paperwidth +\newcount\cnt@paperheight +\ConvertToCount\cnt@paperwidth\paperwidth +\ConvertToCount\cnt@paperheight\paperheight +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\cnt@hoffset} +% \begin{macro}{\cnt@voffset} +% the offsets, +% \begin{macrocode} +\newcount\cnt@hoffset +\newcount\cnt@voffset +\ConvertToCount\cnt@hoffset\hoffset +\ConvertToCount\cnt@voffset\voffset +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\cnt@textheight} +% \begin{macro}{\cnt@textwidth} +% dimensions of the text area, +% \begin{macrocode} +\newcount\cnt@textheight +\newcount\cnt@textwidth +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\cnt@topmargin} +% \begin{macro}{\cnt@oddsidemargin} +% \begin{macro}{\cnt@evensidemargin} +% margins, +% \begin{macrocode} +\newcount\cnt@topmargin +\newcount\cnt@oddsidemargin +\newcount\cnt@evensidemargin +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\cnt@headheight} +% \begin{macro}{\cnt@headsep} +% dimensions of the running heads, +% \begin{macrocode} +\newcount\cnt@headheight +\newcount\cnt@headsep +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\cnt@marginparsep} +% \begin{macro}{\cnt@marginparwidth} +% \begin{macro}{\cnt@marginparpush} +% marginal paragraphs, +% \begin{macrocode} +\newcount\cnt@marginparsep +\newcount\cnt@marginparwidth +\newcount\cnt@marginparpush +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\cnt@footskip} +% the distance between the running footers and the text, +% \begin{macrocode} +\newcount\cnt@footskip +% \end{macrocode} +% \end{macro} +% and the height of the footers, which is needed here to display a +% box, but which isn't used by \LaTeX. +% \begin{macro}{\fheight} +% \begin{macrocode} +\newcount\fheight +\fheight=12 +% \end{macrocode} +% \end{macro} +% +% Apart from integer representations of the page layout parameters +% we also need registers to store reference values in. +% +% \begin{macro}{\ref@top} +% The position of the top of the `printable area' is +% one inch below the top of the paper by default. The value of +% |\ref@top| is relative to the lower left corner of the picture +% environment that will be used. +% +% \begin{macrocode} +\newcount\ref@top +\ref@top=\cnt@paperheight \advance\ref@top by -\oneinch +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\ref@hoffset} +% \begin{macro}{\ref@voffset} +% For the offsets, +% \begin{macrocode} +\newcount\ref@hoffset +\newcount\ref@voffset +% \end{macrocode} +% The |\hoffset| and |\voffset| values are added to the default +% offset of one inch. +% \begin{macrocode} +\ref@hoffset=\cnt@hoffset \advance\cnt@hoffset by \oneinch +\ref@voffset=\cnt@voffset +% \end{macrocode} +% +% |\cnt@voffset| is converted to be relative to the origin of the +% picture. +% \begin{macrocode} +\cnt@voffset=\ref@top +\advance\cnt@voffset by -\ref@voffset +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\ref@head} +% and the text areas, running heads, +% \begin{macrocode} +\newcount\ref@head +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\ref@body} +% body of the text +% \begin{macrocode} +\newcount\ref@body +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\ref@foot} +% and running footers. +% \begin{macrocode} +\newcount\ref@foot +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\ref@margin} +% \begin{macro}{\ref@marginwidth} +% \begin{macro}{\ref@marginpar} +% These are different for even and odd pages, so they are computed +% by |\layout|. +% \begin{macrocode} +\newcount\ref@margin +\newcount\ref@marginwidth +\newcount\ref@marginpar +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% +% The following are a number of scratch registers, used in the +% positioning of the various pices of the picture. +% \begin{macrocode} +\newcount\Interval +\newcount\ExtraYPos +\newcount\PositionX +\newcount\PositionY +\newcount\ArrowLength +% \end{macrocode} +% +% \begin{macro}{\lay@getvalues} +% \changes{v1.1j}{1995/10/30}{Added macro to compute values at later +% time} +% All values that might change during the document are computed by +% calling the macro |\lay@getvalues|. By default this macro is +% executed at |\begin{document}|. +% \begin{macrocode} +\def\lay@getvalues{% + \ConvertToCount\cnt@textheight\textheight + \ConvertToCount\cnt@textwidth\textwidth + \ConvertToCount\cnt@topmargin\topmargin + \ConvertToCount\cnt@oddsidemargin\oddsidemargin + \ConvertToCount\cnt@evensidemargin\evensidemargin + \ConvertToCount\cnt@headheight\headheight + \ConvertToCount\cnt@headsep\headsep + \ConvertToCount\cnt@marginparsep\marginparsep + \ConvertToCount\cnt@marginparwidth\marginparwidth + \ConvertToCount\cnt@marginparpush\marginparpush + \ConvertToCount\cnt@footskip\footskip + \ref@head=\ref@top + \advance\ref@head by -\ref@voffset + \advance\ref@head by -\cnt@topmargin + \advance\ref@head by -\cnt@headheight + \ref@body=\ref@head + \advance\ref@body by -\cnt@headsep + \advance\ref@body by -\cnt@textheight + \ref@foot=\ref@body + \advance\ref@foot by -\cnt@footskip + } +\AtBeginDocument{\lay@getvalues} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\computevalues} +% +% \begin{macro}{\layout} +% \begin{macro}{\layout*} +% The command |\layout| makes the picture and table that display +% the current settings of the layout parameters. +% +% \changes{v1.1b}{1994/03/23}{Produce two pages in twoside mode} +% \changes{v1.1j}{1995/10/30}{Added \cs{layout*}} +% \begin{macrocode} +\newcommand\layout{% + \@ifstar{\lay@getvalues\lay@xlayout}{\lay@xlayout}} +\def\lay@xlayout{% + \lay@layout + \if@twoside + \lay@layout + \fi} +% \end{macrocode} +% +% \begin{macro}{\lay@layout} +% The internal macro |\lay@layout| does all the dirty work. +% \begin{macrocode} +\newcommand\lay@layout{% + \thispagestyle{empty} +% \end{macrocode} +% +% The actions of |\layout| depend on the pagestyle. +% \begin{macrocode} + \if@twoside + \ifodd\count\z@ +% \end{macrocode} +% +% Here we deal with an odd page in the twosided case. +% +% \begin{macrocode} + \typeout{Two-sided document style, odd page.} +% \end{macrocode} +% +% So we compute |\ref@marginwidth|, |\ref@marginpar| and +% |\ref@margin|. +% \changes{v1.1}{1994/02/23}{Added check for reversemargin} +% \begin{macrocode} + \ref@marginwidth=\cnt@oddsidemargin + \ref@marginpar=\oneinch + \advance\ref@marginpar by \ref@hoffset + \advance\ref@marginpar by \cnt@oddsidemargin + \ref@margin\ref@marginpar + \if@reversemargin + \advance\ref@marginpar by -\cnt@marginparsep + \advance\ref@marginpar by -\cnt@marginparwidth + \else + \advance\ref@marginpar by \cnt@textwidth + \advance\ref@marginpar by \cnt@marginparsep + \fi +% \end{macrocode} +% +% \begin{macrocode} + \else +% \end{macrocode} +% +% Here we deal with an even page in the twosided case. +% +% \begin{macrocode} + \typeout{Two-sided document style, even page.} +% \end{macrocode} +% +% So we compute |\ref@marginwidth|, |\ref@marginpar| and +% |\ref@margin|. +% \changes{v1.1}{1994/02/23}{Added check for reversemargin} +% \begin{macrocode} + \ref@marginwidth=\cnt@evensidemargin + \ref@marginpar=\oneinch + \advance\ref@marginpar by \ref@hoffset + \advance\ref@marginpar by \cnt@evensidemargin + \ref@margin\ref@marginpar + \if@reversemargin + \advance\ref@marginpar by \cnt@textwidth + \advance\ref@marginpar by \cnt@marginparsep + \else + \advance\ref@marginpar by -\cnt@marginparsep + \advance\ref@marginpar by -\cnt@marginparwidth + \fi +% \end{macrocode} +% +% \begin{macrocode} + \fi + \else +% \end{macrocode} +% +% Finally we the case for single sided printing. +% +% \changes{v1.1}{1994/02/23}{Added check for reversemargin} +% \begin{macrocode} + \typeout{One-sided document style.} + \ref@marginwidth=\cnt@oddsidemargin + \ref@marginpar=\oneinch + \advance\ref@marginpar by \ref@hoffset + \advance\ref@marginpar by \cnt@oddsidemargin + \ref@margin\ref@marginpar + \if@reversemargin + \advance\ref@marginpar by -\cnt@marginparsep + \advance\ref@marginpar by -\cnt@marginparwidth + \else + \advance\ref@marginpar by \cnt@textwidth + \advance\ref@marginpar by \cnt@marginparsep + \fi + \fi +% \end{macrocode} +% +% +% Now we begin the picture environment; dividing all the lengths by +% two is done by setting |\unitlength| to \texttt{0.5pt} +% \begin{macrocode} + \setlength{\unitlength}{.5pt} + \begin{picture}(\cnt@paperwidth,\cnt@paperheight) + \centering + \thicklines +% \end{macrocode} +% +% First we have the pagebox and reference lines, +% +% \begin{macrocode} + \put(0,0){\framebox(\cnt@paperwidth,\cnt@paperheight){\mbox{}}} + \put(0,\cnt@voffset){\dashbox{10}(\cnt@paperwidth,0){\mbox{}}} + \put(\cnt@hoffset,0){\dashbox{10}(0,\cnt@paperheight){\mbox{}}} +% \end{macrocode} +% +% then the header, +% +% \begin{macrocode} + \put(\ref@margin,\ref@head){% + \framebox(\cnt@textwidth,\cnt@headheight)% + {\footnotesize\Headertext}} +% \end{macrocode} +% +% the body of the text area, +% +% \begin{macrocode} + \put(\ref@margin,\ref@body){% + \framebox(\cnt@textwidth,\cnt@textheight){\Bodytext}} +% \end{macrocode} +% +% the footer +% +% \begin{macrocode} + \put(\ref@margin,\ref@foot){% + \framebox(\cnt@textwidth,\fheight){\footnotesize\Footertext}} +% \end{macrocode} +% +% and the space for marginal notes. +% +% \begin{macrocode} + \put(\ref@marginpar,\ref@body){% + \framebox(\cnt@marginparwidth,\cnt@textheight)% + {\footnotesize\shortstack{\MarginNotestext}}} +% \end{macrocode} +% +% Then we start putting in `arrows' to mark the various parameters. +% From here we use |\thinlines|. +% \begin{macrocode} + \thinlines +% \end{macrocode} +% +% |\PositionX| and |\PositionY| will be the coordinates of the center of +% the arrow displaying |\textwidth|. +% \begin{macrocode} + \SetToHalf\PositionX\cnt@textwidth + \advance\PositionX by \ref@margin +% \end{macrocode} +% The arrow should be a bit above the bottom of the `body box'. +% \begin{macrocode} + \PositionY = \ref@body + \advance\PositionY by 50 +% \end{macrocode} +% An identifying number is put here, in a circle. +% \begin{macrocode} + \Identify{8} +% \end{macrocode} +% Then the arrow is drawn. +% \begin{macrocode} + \InsideHArrow\cnt@textwidth +% \end{macrocode} +% +% Now the |\textheight| +% \begin{macrocode} + \SetToHalf\PositionY\cnt@textheight + \advance\PositionY by \ref@body +% \end{macrocode} +% +% The x-position of the arrow is at $4/5$ of the width of the `body +% box'. +% \begin{macrocode} + \PositionX = \cnt@textwidth + \divide\PositionX by 5 + \multiply \PositionX by 4 + \advance\PositionX by \ref@margin +% \end{macrocode} +% +% An identifying number is put here, in a circle. +% \begin{macrocode} + \Identify{7} + \InsideVArrow\cnt@textheight +% \end{macrocode} +% +% +% The |\hoffset|, +% \changes{v1.2}{1998/04/13}{\cs{PositionY} for label 1 is +% fixed at 50} +% \begin{macrocode} + \PositionY = 50 + \SetToHalf\PositionX\cnt@hoffset + \Identify{1} + \InsideHArrow\cnt@hoffset +% \end{macrocode} +% +% +% The width of the margin. +% \changes{v1.2}{1998/04/13}{The direction of the arrows should be +% switched by the sign of \cs{oddsidemargin}} +% \begin{macrocode} + \SetToQuart\PositionY\cnt@textheight + \advance\PositionY by \ref@body + \ifnum\ref@marginwidth > 0 + \OutsideHArrow\ref@margin\ref@marginwidth{20} + \PositionX = \cnt@hoffset + \else + \OutsideHArrow\cnt@hoffset{-\ref@marginwidth}{20} + \PositionX = \ref@margin + \fi + \advance\PositionX by -30 + \Identify{3} +% \end{macrocode} +% +% the |\marginparwidth|, +% \begin{macrocode} + \SetToQuart\PositionY\cnt@textheight + \advance\PositionY by \ref@body +% \end{macrocode} +% This arrow has to be bit below the one for the |\oddsidemargin| +% or\\ |\evensidemargin|. +% \begin{macrocode} + \advance\PositionY by 30 + \SetToHalf\PositionX\cnt@marginparwidth + \advance\PositionX by \ref@marginpar + \Identify{10} + \InsideHArrow\cnt@marginparwidth +% \end{macrocode} +% +% +% The |\marginparsep|, this depends on single or double sided +% printing. +% \begin{macrocode} + \advance\PositionY by 30 + \if@twoside +% \end{macrocode} +% +% Twosided mode, reversemargin; +% \changes{v1.1b}{1994/03/23}{\cs{OutSideHArrow} should be +% \cs{OutsideHArrow}} +% \changes{v1.2}{1998/04/13}{Added check for reversemargin} +% \begin{macrocode} + \if@reversemargin + \ifodd\count\z@ + \OutsideHArrow\ref@margin\cnt@marginparsep{20} + \PositionX = \ref@margin + \else + \OutsideHArrow\ref@marginpar\cnt@marginparsep{20} + \PositionX = \ref@marginpar + \fi + \else +% \end{macrocode} +% Not reversemargin; +% \begin{macrocode} + \ifodd\count\z@ + \OutsideHArrow\ref@marginpar\cnt@marginparsep{20} + \PositionX = \ref@marginpar + \else + \OutsideHArrow\ref@margin\cnt@marginparsep{20} + \PositionX = \ref@margin + \fi + \fi + \else +% \end{macrocode} +% +% Single sided mode. +% \changes{v1.2}{1998/04/13}{Added check for reversemargin} +% \begin{macrocode} + \if@reversemargin + \OutsideHArrow\ref@margin\cnt@marginparsep{20} + \PositionX = \ref@margin + \else + \OutsideHArrow\ref@marginpar\cnt@marginparsep{20} + \PositionX = \ref@marginpar + \fi + \fi +% \end{macrocode} +% \changes{v1.2}{1998/04/13}{The \cs{PositionX} of the label 9 is +% changed to the left side of the arrows} +% \begin{macrocode} + \advance\PositionX by -\cnt@marginparsep + \advance\PositionX by -30 + \Identify{9} +% \end{macrocode} +% +% Identify the |\footskip|. The arrow will be located on $1/8$th of +% the |\textwidth|. +% \changes{v1.2}{1998/04/13}{The \cs{PositionY} of the label 11 is +% changed to the upper side of the arrows} +% \begin{macrocode} + \PositionX = \cnt@textwidth + \divide\PositionX by 8 + \advance\PositionX by \ref@margin + \OutsideVArrow\ref@foot\cnt@footskip{20}{20} + \PositionY = \ref@foot + \advance\PositionY by \cnt@footskip + \advance\PositionY by 30 + \Identify{11} +% \end{macrocode} +% +% Identify the |\voffset|. The arrow will be located a bit to the +% left of the edge of the paper. +% \begin{macrocode} + \PositionX = \cnt@paperwidth + \advance\PositionX by -50 + \PositionY = \cnt@paperheight + \ExtraYPos = \PositionY + \advance\ExtraYPos by -\cnt@voffset + \advance\PositionY by \cnt@voffset + \divide\PositionY by \tw@ + \Identify{2} + \InsideVArrow\ExtraYPos +% \end{macrocode} +% +% Identify |\topmargin|, |\headheight| and |\headsep|. +% +% The arrows will be located on $1/8$th of the |\textwidth|, with +% intervals of the same size, stored in |\Interval|. +% \begin{macrocode} + \Interval = \cnt@textwidth + \divide\Interval by 8 + \PositionX = \ref@margin + \advance\PositionX by \Interval +% \end{macrocode} +% First the |\topmargin|. If |\topmargin| has a positive value, the +% arrow is upward. Otherwise, it is downward. The number label is +% always placed at the base of the arrow. +% \changes{v1.2}{1998/04/13}{The direction of the arrows should be +% switched by the sign of \cs{topmargin}} +% \begin{macrocode} + \ifnum\cnt@topmargin > \z@ + \ExtraYPos = \ref@head + \advance\ExtraYPos\cnt@headheight + \OutsideVArrow\ExtraYPos\cnt@topmargin{20}{20} + \PositionY = \ExtraYPos + \advance\PositionY by \cnt@topmargin + \else + \ExtraYPos = \cnt@voffset + \OutsideVArrow\ExtraYPos{-\cnt@topmargin}{20}{20} + \PositionY = \ExtraYPos + \advance\PositionY by -\cnt@topmargin + \fi + \advance\PositionY by 30 + \Identify{4} + \advance\PositionX by \Interval +% \end{macrocode} +% Then the |\headheight| +% \changes{v1.2}{1998/04/13}{The \cs{PositionY} of the label 5 is +% fixed} +% \begin{macrocode} + \OutsideVArrow\ref@head\cnt@headheight{20}{20} + \PositionY = \ref@head + \advance\PositionY by \cnt@headheight + \advance\PositionY by 30 + \Identify{5} + \advance\PositionX by \Interval +% \end{macrocode} +% and finally the |\headsep| +% \changes{v1.2}{1998/04/13}{The \cs{PositionY} of the label 6 is +% fixed} +% \begin{macrocode} + \ExtraYPos=\ref@body + \advance\ExtraYPos\cnt@textheight + \OutsideVArrow\ExtraYPos\cnt@headsep{20}{20} + \PositionY = \ref@body + \advance\PositionY by \cnt@textheight + \advance\PositionY by -30 + \Identify{6} +% \end{macrocode} +% +% Here we can end the picture environment and insert a little +% space. +% \begin{macrocode} + \end{picture} + + \medskip +% \end{macrocode} +% +% Below the picture we put a table to show the actual values of the +% parameters. Note that fractional points are truncated, i.e., +% \texttt{72.27pt} is displayed as \texttt{72pt} +% +% The table is typeset inside a box with a depth of 0 to always +% keep it on the same page as the picture. +% \changes{v1.1b}{1994/03/23}{Showing oddside and evenside margins was +% defective} +% \changes{v1.1c}{1994/07/14}{in compatibility mode \cs{footnotesize} +% calls \cs{normalfont}; therefore we need to switch to a tt font +% later} +% \changes{v1.1f}{1995/03/14}{introduced \cs{notshown}} +% \begin{macrocode} + \vtop to 0pt{% + \@minipagerestore\footnotesize\ttfamily + \begin{tabular}{@{}rl@{\hspace{20pt}}rl} + 1 & \oneinchtext\ + \LayOutbs\texttt{hoffset} + & 2 & \oneinchtext\ + \LayOutbs\texttt{voffset} \\ + 3 & \if@twoside + \ifodd\count\z@ \Show{cnt}{oddsidemargin} + \else \Show{cnt}{evensidemargin} + \fi + \else + \Show{cnt}{oddsidemargin} + \fi & 4 & \Show{cnt}{topmargin} \\ + 5 & \Show{cnt}{headheight} & 6 & \Show{cnt}{headsep} \\ + 7 & \Show{cnt}{textheight} & 8 & \Show{cnt}{textwidth} \\ + 9 & \Show{cnt}{marginparsep}&10& \Show{cnt}{marginparwidth} \\ + 11& \Show{cnt}{footskip} & & \Show{cnt}{marginparpush} + \rlap{(\notshown)}\\ + & \Show{ref}{hoffset} & & \Show{ref}{voffset} \\ + & \Show{cnt}{paperwidth} & & \Show{cnt}{paperheight} \\ + + \end{tabular}\vss} +% \end{macrocode} +% When the option \Lopt{verbose} was used the following lines will +% show dimensions on the terminal. +% \begin{macrocode} + \Type{ref}{hoffset} + \Type{ref}{voffset} + \Type{cnt}{textheight} + \Type{cnt}{textwidth} +% \end{macrocode} +% Finally we start a new page. +% \begin{macrocode} + \newpage +} +%</package> +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \Finale +\endinput diff --git a/macros/latex-dev/required/tools/layout.pdf b/macros/latex-dev/required/tools/layout.pdf Binary files differnew file mode 100644 index 0000000000..2c06d2b63c --- /dev/null +++ b/macros/latex-dev/required/tools/layout.pdf diff --git a/macros/latex-dev/required/tools/longtable.dtx b/macros/latex-dev/required/tools/longtable.dtx new file mode 100644 index 0000000000..9a3b5c03b8 --- /dev/null +++ b/macros/latex-dev/required/tools/longtable.dtx @@ -0,0 +1,2154 @@ +% \iffalse meta-comment +% +% Copyright (C) 1993-2019 +% +% The LaTeX3 Project and any individual authors listed elsewhere +% in this file. +% +% This file is part of the Standard LaTeX `Tools Bundle'. +% ------------------------------------------------------- +% +% It may be distributed and/or modified under the +% conditions of the LaTeX Project Public License, either version 1.3c +% of this license or (at your option) any later version. +% The latest version of this license is in +% https://www.latex-project.org/lppl.txt +% and version 1.3c or later is part of all distributions of LaTeX +% version 2005/12/01 or later. +% +% The list of all files belonging to the LaTeX `Tools Bundle' is +% given in the file `manifest.txt'. +% +% \fi +% \iffalse +%% File: longtable.dtx Copyright (C) 1990-2019 David Carlisle +% +%<*dtx> + \ProvidesFile{longtable.dtx} +%</dtx> +%<package>\NeedsTeXFormat{LaTeX2e}[1995/06/01] +%<package>\ProvidesPackage{longtable} +%<driver> \ProvidesFile{longtable.drv} +% \fi +% \ProvidesFile{longtable.dtx} + [2019/02/06 v4.12 Multi-page Table package (DPC)] +% +% \iffalse +%<*driver> +\documentclass{ltxdoc} +\usepackage{longtable} +\begin{document} +\DocInput{longtable.dtx} +\end{document} +%</driver> +% \fi +% +% \GetFileInfo{longtable.dtx} +% \title{The \textsf{longtable} package\thanks{This file +% has version number \fileversion, last +% revised \filedate.}} +% \author{David Carlisle\thanks{The new algorithm for aligning `chunks' +% of a table used in version 4 of this package was devised coded +% and documented by David Kastrup.}} +% \date{\filedate} +% +% \let\package\textsf +% \let\env\textsf +% \providecommand\finalclearpage{\clearpage} +% +% \MaintainedByLaTeXTeam{tools} +% \maketitle +% +% \begin{abstract} +% This package defines the \env{longtable} environment, a multi-page +% version of \env{tabular}. +% \end{abstract} +% +% \DeleteShortVerb{\|} +% \MakeShortVerb{\"} +% +% \changes{v0.00}{1989/11/06} +% {`Version 0' distributed as longtab.sty +% always used just one chunk for the whole table} +% +% \changes{v1.00}{1990/12/20} +% {Initial version} +% +% \changes{v2.00}{1991/06/17} +% {Support NFSS and array.sty} +% +% \changes{v3.00}{1992/03/16} +% {New implementation. tables may now start anywhere on the page.} +% +% \changes{v3.01}{1992/04/06} +% {(Michel Goossens) If a chunk ends on a line in which the first +% entry is empty, weird errors occur. Added special begin and end +% groups, (\cs{ifnum}0 ) stuff as explained in Appendix D.} +% +% \changes{v3.02}{1992/04/09} +% {(Michel Goossens) Longtable fails if the table counter is reset +% during a document. Now use an internal counter, but still +% increment table so \cs{caption} and \cs{label} work out right.} +% +% \changes{v3.03}{1992/06/25} +% {Add \cs{@ifundefined\{reset@font\}} so that the documentation may +% be processed with old versions of \LaTeX.} +% \changes{v3.03}{1992/06/25} +% {Modify the treatment of \cs{d@llar} to match the new versions of +% Mittelbach's array.sty (array.sty v2.0h)} +% +% \changes{v3.04}{1992/11/12} +% {(Jean-Pierre Drucbert) Longtable failed when used with +% \cs{includeonly}.} +% \changes{v3.04}{1992/11/12} +% {Fix bug which stopped \cs{kill} working correctly in headings.} +% \changes{v3.04}{1992/11/12} +% {(Graham Gough) Made \cs{setlongtables} issue a warning message.} +% \changes{v3.04}{1992/11/12} +% {(Sebastian Rahtz) longtable ran out of memory on really long +% tables. Another bug introduced in V3.} +% +% \changes{v3.05}{1992/11/20} +% {(Juergen Peus) Table was hard coded into the captions, Now the +% captions use \cs{fnum@table}, so \cs{tablename} will be used.} +% +% \changes{v3.06}{1993/01/21} +% {(Ingo Hoffmann) longtable fails with letter style. +% The table counter is not defined, and the .aux file is not used in +% the same way. This version will use a .lta file for letter style.} +% +% \changes{v3.07}{1993/06/09} +% {Allow the \LaTeX\ syntax \cs{setcounter}\{LTchunksize\}\{10\}} +% +% \changes{v3.08}{1993/06/09} +% {Update for \LaTeXe} +% +% \changes{v3.09}{1994/03/15} +% {New ltxdoc style} +% +% \changes{v3.11}{1994/05/22} +% {Option handling added, new style errors and warnings} +% +% \changes{v3.12}{1994/06/30} +% {Remove special letter class handling from v3.06, not needed for +% new letter class} +% +% \changes{v4.00}{1996/04/08} +% {(DK) New algorithm to align chunks devised and coded by David +% Kastrup} +% +% \changes{v4.02}{1996/04/16} +% {(DPC/DK) documentation improvements} +% +% \changes{v4.06}{1997/06/28} +% {(DK) new email address} +% +% +% +% \makeatletter +% \def\@oddfoot{\normalfont\rmfamily\dotfill Page \thepage\dotfill} +% \def\@oddhead{\dotfill{\normalfont\ttfamily longtable.sty}\dotfill} +% \def\ps@titlepage{\let\@oddhead\@empty} +% \makeatother +% +% +% \setlength\LTleft\parindent +% \setlength\LTright\fill +% \setcounter{LTchunksize}{10} +% +% \def\v{\char`} +% +% ^^A \vbox to 100pt makes the page breaks the same on the first run. +% \changes{v3.08}{1993/06/09} +% {No need to use \cs{vbox} with \LaTeXe\ minipage} +% \noindent\begin{minipage}[t][130pt]{\textwidth} +% \listoftables +% \end{minipage} +% +% \section{Introduction} +% +% The \package{longtable} package defines a new environment, +% \DescribeEnv{longtable} +% \env{longtable}, which has most of the features of the \env{tabular} +% environment, but produces tables which may be broken by \TeX's +% standard page-breaking algorithm. It also shares some features with +% the \env{table} environment. In particular it uses the same counter, +% \texttt{table}, and has a similar "\caption" command. Also, the +% standard "\listoftables" command lists tables produced by either the +% \env{table} or \env{longtable} environments. +% +% The following example uses most of the features of the \env{longtable} +% environment. An edited listing of the input for this example appears +% in Section~\ref{listing}. +% +% \textbf{Note:} Various parts of the following table will +% \textbf{not} line up correctly until this document has been run +% through \LaTeX\ several times. This is a characteristic feature of +% this package, as described below. +% +% \begin{longtable}{@{*}r||p{1in}@{*}} +% KILLED & LINE!!!! \kill +% \caption +% [An optional table caption (used in the list of tables)] +% {A long table\label{long}}\\ +% \hline\hline +% \multicolumn{2}{@{*}c@{*}}% +% {This part appears at the top of the table}\\ +% \textsc{First}&\textsc{Second}\\ +% \hline\hline +% \endfirsthead +% \caption[]{(continued)}\\ +% \hline\hline +% \multicolumn{2}{@{*}c@{*}}% +% {This part appears at the top of every other page}\\ +% \textbf{First}&\textbf{Second}\\ +% \hline\hline +% \endhead +% \hline +% This goes at the&bottom.\\ +% \hline +% \endfoot +% \hline +% These lines will&appear\\ +% in place of the & usual foot\\ +% at the end& of the table\\ +% \hline +% \endlastfoot +% \env{longtable} columns are specified& in the \\ +% same way as in the \env{tabular}& environment.\\ +% "@{*}r||p{1in}@{*}"& in this case.\\ +% Each row ends with a& "\\" command.\\ +% The "\\" command has an& optional\\ +% argument, just as in& the\\ +% \env{tabular}&environment.\\[10pt] +% See the effect of "\\[10pt]"&?\\ +% Lots of lines& like this.\\ +% Lots of lines& like this.\\ +% Lots of lines& like this.\\ +% Lots of lines& like this.\\ +% Also "\hline" may be used,& as in \env{tabular}.\\ +% \hline +% That was a "\hline"&.\\ +% \hline\hline +% That was "\hline\hline"&.\\ +% \multicolumn{2}{||c||}% +% {This is a \ttfamily\v\\multicolumn\v{2\v}\v{||c||\v}}\\ +% If a page break occurs at a "\hline" then& a line is drawn\\ +% at the bottom of one page and at the& top of the next.\\ +% \hline +% The "[t] [b] [c]" argument of \env{tabular}& can not be used.\\ +% The optional argument may be one of& "[l] [r] [c]"\\ +% to specify whether the table should be& adjusted\\ +% to the left, right& or centrally.\\ +% \hline\hline +% Lots of lines& like this.\\ +% Lots of lines& like this.\\ +% Lots of lines& like this.\\ +% Lots of lines& like this.\\ +% Lots of lines& like this.\\ +% Lots of lines& like this.\\ +% Lots of lines& like this.\\ +% Lots of lines& like this.\\ +% Lots of lines& like this.\\ +% Lots of lines& like this.\\ +% Lots of lines& like this.\\ +% Lots of lines& like this.\\ +% Lots of lines& like this.\\ +% Lots of lines& like this.\\ +% Lots of lines& like this.\\ +% Lots of lines& like this.\\ +% Lots of lines& like this.\\ +% Lots of lines& like this.\\ +% Lots of lines& like this.\\ +% Lots of lines& like this.\\ +% Some lines may take up a lot of space, like this: & +% \raggedleft This last column is a ``p'' column so this +% ``row'' of the table can take up several lines. Note however that +% \TeX\ will never break a page within such a row. Page breaks only +% occur between rows of the table or at "\hline" commands. +% \tabularnewline +% Lots of lines& like this.\\ +% Lots of lines& like this.\\ +% Lots of lines& like this.\\ +% Lots of lines& like this.\\ +% Lots of lines& like this.\\ +% Lots of lines& like this.\\ +% Lots of lines& like this.\\ +% \hline +% Lots\footnote{This is a footnote.} of lines& like this.\\ +% Lots of lines& like this\footnote{\env{longtable} takes special +% precautions, so that footnotes may also be used in `p' columns.}\\ +% \hline +% Lots of lines& like this.\\ +% Lots of lines& like this. +% \end{longtable} +% +% \section{Chunk Size} +% +% \DescribeMacro{LTchunksize} +% In order to \TeX\ multi-page tables, it is necessary to break up the +% table into smaller chunks, so that \TeX\ does not have to keep +% everything in memory at one time. By default \env{longtable} uses 20 +% rows per chunk, but this can be set by the user, with e.g., +% "\setcounter{LTchunksize}{10}".\footnote +% {You can also use the plain \TeX\ syntax +% {\ttfamily\v\\LTchunksize=10.}} +% These chunks do not affect page breaking, +% thus if you are using a \TeX\ with a lot of memory, you can set +% "LTchunksize" to be several pages of the table. \TeX\ will run +% faster with a large "LTchunksize". However, if necessary, +% \env{longtable} can work with "LTchunksize" set to 1, in which case +% the memory taken up is negligible. +% Note that if you use the commands for setting the table head or foot +% (see below), the "LTchunksize" must be at least as large as the +% number of rows in each of the head or foot sections. +% +% This document specifies "\setcounter{LTchunksize}{10}". If you look +% at the previous table, after the \emph{first} run of \LaTeX\ you will +% see that various parts of the table do not line up. +% \LaTeX\ will also have printed a warning that the column +% widths had changed. \env{longtable} writes information onto the +% ".aux" file, so that it can line up the different chunks. +% Prior to version~4 of this package, this information was not used +% unless a "\setlongtables" command was issued, however, now the +% information is always used, using a new algorithm\footnote{Due to +% David Kastrup.} and so "\setlongtables" is no longer needed. It is +% defined (but does nothing) for the benefit of old documents that +% use it. +% +% \begin{table} +% \centering +% \begin{tabular}{||l|l|l||} +% \hline\hline +% A&\env{tabular}& environment\\ +% \hline +% within&a floating&\env{table}\\ +% \hline\hline +% \end{tabular} +% \caption{A floating table} +% \end{table} +% +% \section{Captions and Headings} +% +% At the start of the table one may specify lines which are to appear at +% the top of every page (under the headline, but before the other lines +% of the table). +% \DescribeMacro{\endhead} +% The lines are entered as normal, but the last "\\" command is +% replaced by a "\endhead" command. +% \DescribeMacro{\endfirsthead} +% If the first page should have a different heading, then this should be +% entered in the same way, and terminated with the "\endfirsthead" +% command. The "LTchunksize" should be at least as large as the +% number of rows in the heading. +% \DescribeMacro{\endfoot} +% There are also "\endfoot" and "\endlastfoot" +%\DescribeMacro{\endlastfoot} +% commands which are used in the same way (at the \emph{start} of the +% table) to specify rows (or an "\hline") to appear at the bottom of +% each page. In certain situations, you may want to place lines which +% logically belong in the table body at the end of the \env{firsthead}, +% or the beginning of the \env{lastfoot}. This helps to control which +% lines appear on the first and last page of the table. +% +% \DescribeMacro{\caption}% +% The "\caption{...}" command is essentially equivalent to\\ +% "\multicolumn{n}{c}{\parbox{\LTcapwidth}{...}}"\\ +% where \texttt{n} is the number of columns of the table. You may set +% the width of the caption with a command such as +% "\setlength{\LTcapwidth}{2in}" +% in the preamble of your document. The default is 4in. "\caption" also +% writes the information to produce an entry in the list of tables. As +% with the "\caption" command in the \env{figure} and \env{table} +% environments, an optional argument specifies the text to appear in the +% list of tables if this is different from the text to appear in the +% caption. Thus the caption for table \ref{long} was specified as +% {\ttfamily +% "\caption"[An optional table caption +% (used in the list of tables)]\v{A long +% table"\label{long}"\v}}. +% +% You may wish the caption on later pages to be different to that on the +% first page. In this case put the "\caption" command in the first +% heading, and put a subsidiary caption in a "\caption[]" command in +% the main heading. If the optional argument to "\caption" is empty, +% no entry is made in the list of tables. Alternatively, if you do not +% want the table number to be printed each time, use the "\caption*" +% command. +% +% The captions are set based on the code for the \package{article} +% class. +% If you have redefined the standard "\@makecaption" command to produce +% a different format for the captions, you may +% need to make similar changes to the \package{longtable} version, +% "\LT@makecaption". See the code section for more details. +% +% A more convenient method of customising captions is given by the +% \package{caption(2)} package, which provides commands for customising +% captions, and arranges that the captions in standard environments, and +% many environments provided by packages (including \package{longtable}) +% are modified in a compatible manner. +% +% You may use the "\label" command so that you can cross reference +% \env{longtable}s with "\ref". Note however, that the "\label" command +% should not be used in a heading that may appear more than once. Place +% it either in the \env{firsthead}, or in the body of the table. It +% should not be the \emph{first} command in any entry. +% +% \section{Multicolumn entries} +% +% The "\multicolumn" command may be used in \env{longtable} in exactly +% the same way as for \env{tabular}. So you may want to skip this +% section, which is rather technical, however coping with "\multicolumn" +% is one of the main problems for an environment such as +% \env{longtable}. The main effect that a user will see is that +% certain combinations of "\multicolumn" entries will result in a +% document needing more runs of \LaTeX\ before the various `chunks' of +% a table align. +% +% The examples in this section are set with "LTchunksize" set to the +% minimum value of one, to demonstrate the effects when "\multicolumn" +% entries occur in different chunks. +% +% \begin{table}[!htp] +% \begin{center} +% \LTchunksize=1 +% \makeatletter +% +% \global\let\LT@save@row\relax +% \let\LT@warn\@gobble +% \let\LT@final@warn\relax +% +% \newcommand\ltexample[1]{ +% \stepcounter{LT@tables} +% \expandafter\let\csname LT@\romannumeral\c@LT@tables\endcsname +% \LT@save@row +% \addtocounter{LT@tables}{-1} +% \begin{longtable}{|c|c|c|} +% \caption{A difficult {\cs{multicolumn}} combination: +% pass #1\label{pass#1}}\\ +% \hline +% 1&2&3\\ +% \multicolumn{3}{|c|}{wide multicolumn spanning 1--3}\\ +% \multicolumn{2}{|c|}{multicolumn 1--2}&3\\ +% wide 1&2&3\\ +% \hline +% \end{longtable} +% } +% +% \ltexample{1} +% +% \ltexample{2} +% +% \ltexample{3} +% +% \ltexample{4} +% +% \end{center} +% \end{table} +% +% Consider Table~\ref{pass1}. +% In the second chunk, \env{longtable} sees the wide +% multicolumn entry. At this point it thinks that the first two +% columns are very narrow. All +% the width of the multicolumn entry is assumed to be in the +% third column. (This is a `feature' of \TeX's primitive "\halign" +% command.) \env{longtable} then passes the information that there +% is a wide third column to the later chunks, with the result that the +% first pass over the table is too wide. +% +% If the `saved row' from this first pass was re-inserted into the +% table on the next pass, the table would line up in two passes, but +% would be much two wide. +% +% \DescribeMacro{\kill}% +% The solution to this problem used in Versions 1~and~2, was to use a +% "\kill" line. If a line is "\kill"ed, by using "\kill" rather than +% "\\" at the end of the line, it is used in calculating +% column widths, but removed from the final table. Thus entering +% "\kill"ed copies of the last two rows before the wide multicolumn +% entry would mean that "\halign" `saw' the wide entries in the first +% two columns, and so would not widen the third column by so much to +% make room for the multicolumn entry. +% +% In Version~3, a new solution was introduced. If the saved row in +% the ".aux" file was not being used, \env{longtable} used a special +% `draft' form of "\multicolumn", this modified the definition, so the +% spanning entry was never considered to be wider than the columns it +% spanned. So after the first pass, the ".aux" file stored the +% widest normal entry for each column, no column was widened due to +% "\span"ned columns. By default \env{longtable} ignored the ".aux" +% file, and so each run of \LaTeX\ was considered a first pass. Once the +% "\setlongtables" declaration was given, the saved row in the ".aux" +% file, and the proper definition of "\multicolumn" were used. If any +% "\multicolumn" entry caused one of the columns to be widened, this +% information could not be passed back to earlier chunks, and so the +% table would not correctly line up until the third pass. This algorithm +% always converged in three passes as described above, but in examples +% such as the ones in Tables \ref{pass1}--\ref{pass4}, the final +% widths were not optimal as the width of column~2, which is +% determined by a "\multicolumn" entry was not known when the final +% width for column~3 was fixed, due to the fact that \emph{both} +% "\multicolumn" commands were switched from `draft' mode to `normal' +% mode at the same time. +% +% Version~4 alleviates the problem considerably. +% The first pass of the table will +% indeed have the third column much too wide. However, on the next pass +% \env{longtable} will notice the error and reduce the column width +% accordingly. If this has to propagate to chunks before the +% "\multicolumn" one, an additional pass will, of course, be +% needed. It is possible to construct tables where this rippling up of +% the correct widths takes several passes to `converge' and produce a +% table with all chunks aligned. However in +% order to need many passes one needs to construct a table with +% many overlapping "\multicolumn" entries, all being wider than the +% natural widths of the columns they span, and all occurring in +% different chunks. In the typical case the algorithm will converge +% after three or four passes, and, the benefits of not needing to edit +% the document before the final run to add "\setlongtables", and the +% better choice of final column widths in the case of multiple +% "\multicolumn" entries will hopefully more than pay for the extra +% passes that may possibly be needed. +% +% So Table~\ref{pass1} converges after 4~passes, as seen in +% Table~\ref{pass4}. +% +% You can still speed the convergence by introducing judicious "\kill" +% lines, if you happen to have constellations like the above. +% +% If you object even to \LaTeX-ing a file twice, you should +% make the first line of +% every \env{longtable} a "\kill" line that contains the widest entry +% to be used in each column. All chunks will then line up on the first +% pass. +% +% \section{Adjustment} +% +% The optional argument of \env{longtable} controls the +% horizontal alignment of the table. The possible options are "[c]", +% "[r]" and "[l]", for centring, +% right and left adjustment, respectively. +% \DescribeMacro{\LTleft} +% Normally centring is the default, but this document specifies +% \DescribeMacro{\LTright} +%\begin{verbatim} +% \setlength\LTleft\parindent +% \setlength\LTright\fill +%\end{verbatim} +% in the preamble, +% which means that the tables are set flush left, but +% indented by the usual paragraph indentation. Any lengths can be +% specified for these two parameters, but at least one of them should be +% a rubber length so that it fills up the width of the page, unless +% rubber lengths are added between the columns using the +% "\extracolsep" command. +% For instance +%\begin{verbatim} +% \begin{tabular*}{\textwidth}{@{\extracolsep{...}}...} +%\end{verbatim} +% produces a full width table, to get a similar effect with +% \env{longtable} specify +%\begin{verbatim} +% \setlength\LTleft{0pt} +% \setlength\LTright{0pt} +% \begin{longtable}{@{\extracolsep{...}}...} +%\end{verbatim} +% +% \section{Changes} +% +% This section highlights the major changes since version~2. A more +% detailed change log may be produced at the end of the code listing +% if the "ltxdoc.cfg" file specifies +%\begin{verbatim} +% \AtBeginDocument{\RecordChanges} +% \AtEndDocument{\PrintChanges} +%\end{verbatim} +% +% Changes made between versions 2 and 3. +% \begin{itemize} +% \item The mechanism for adding the head and foot of the table has been +% completely rewritten. With this new mechanism, \env{longtable} does +% not need to issue a "\clearpage" at the start of the table, and so the +% table may start half way down a page. Also the "\endlastfoot" command +% which could not safely be implemented under the old scheme, has been +% added. +% \item \env{longtable} now issues an error if started in the scope of +% "\twocolumn", or the \env{multicols} environment. +% \item The separate documentation file "longtable.tex" has been +% merged with the package file, "longtable.dtx" using Mittelbach's +% \package{doc} package. +% \item Support for footnotes has been added. Note however that +% "\footnote" will not work in the `head' or `foot' sections of the +% table. In order to put a footnote in those sections (e.g., inside a +% caption), use "\footnotemark" at that point, and "\footnotetext" +% anywhere in the table \emph{body} that will fall on the same page. +% \item The treatment of "\multicolumn" has changed, making +% "\kill" lines unnecessary, at the price of sometimes requiring a +% third pass through \LaTeX. +% \item The "\newpage" command now works inside a \env{longtable}. +% \end{itemize} +% +% Changes made between versions 3 and 4. +% \begin{itemize} +% \item A new algorithm is used for aligning chunks. As well as the +% widest width in each column, \package{longtable} remembers which +% chunk produced this maximum. This allows it to check that the +% maximum is still achieved in later runs. As \package{longtable} can +% now deal with columns shrinking as the file is edited, the +% "\setlongtables" system is no longer needed and is disabled. +% +% \item An extra benefit of the new algorithm's ability to deal with +% `shrinking' columns is that it can give better (narrower) column +% widths in the case of overlapping "\multicolumn" entries in +% different chunks than the previous algorithm produced. +% +% \item The `draft' multicolumn system has been removed, along with +% related commands such as "\LTmulticolumn". +% +% \item The disadvantage of the new algorithm is that it can take more +% passes. The theoretical maximum is approximately twice the length +% of a `chain' of columns with overlapping "\multicolumn" entries, +% although in practice it usually converges as fast as the old +% version. (Which always converged in three passes once +% "\setlongtables" was activated.) +% +% \item "\\*" and "\nopagebreak" commands may be used to control page +% breaking. +% +% \end{itemize} +% +% +% \section{Summary} +% +% ^^A Allow the table to stick into the left margin. +% \setlength{\LTleft}{0pt plus 1fill minus 1fill} +% \setlength{\LTright}{0pt} +% +% \begin{longtable}{@{}l@{\hspace{10pt}}p{.8\linewidth}@{}} +% \caption[A summary of \env{longtable} commands]% +% {\normalsize A summary of \env{longtable} commands}\\ +% \multicolumn{2}{c}{\textbf{Parameters}}\\* +% \hline +% "\LTleft"& +% Glue to the left of the table. \hfill("\fill")\\ +% "\LTright"& +% Glue to the right of the table. \hfill("\fill")\\ +% "\LTpre"& +% Glue before the the table. \hfill("\bigskipamount")\\ +% "\LTpost"& +% Glue after the the table. \hfill("\bigskipamount")\\ +% "\LTcapwidth"& +% The width of a parbox containing the caption.\hfill(4in)\\ +% "LTchunksize"& +% The number of rows per chunk. \hfill(20)\\[5pt] +% \multicolumn{2}{c}{\textbf{Optional +% arguments to} \ttfamily\v\\begin\v{longtable\v}}\\* +% \hline +% \it none& Position as specified by "\LTleft" and "\LTright".\\ +% "[c]"& Centre the table.\\ +% "[l]"& Place the table flush left.\\ +% "[r]"& Place the table flush right.\\[5pt] +% \pagebreak[2] +% \multicolumn{2}{c}{\textbf{Commands +% to end table rows}}\\* +% \hline +% "\\"& +% Specifies the end of a row\\ +% "\\"\oarg{dim}& Ends row, then adds vertical space +% (as in the \env{tabular} environment).\\ +% "\\*"& +% The same as "\\" but disallows a page break after the row.\\ +% "\tabularnewline"& +% Alternative to "\\" for use in the scope of "\raggedright" and +% similar commands that redefine "\\".\\ +% "\kill"& +% Row is `killed', but is used in calculating widths.\\ +% "\endhead"& +% Specifies rows to appear at the top of every page.\\ +% "\endfirsthead"& +% Specifies rows to appear at the top the first page.\\ +% "\endfoot"& +% Specifies rows to appear at the bottom of every page.\\ +% "\endlastfoot"& +% Specifies rows to appear at the bottom of the last page.\\[5pt] +% \multicolumn{2}{c}{\textbf{\env{longtable} caption commands}}\\* +% \hline +% "\caption"\marg{caption}& +% Caption `Table ?: \meta{caption}', and a `\meta{caption}' +% entry in the list of tables.\\ +% "\caption"\oarg{lot}\marg{caption}& +% Caption `Table ?: \meta{caption}', and a `\meta{lot}' +% entry in the list of tables.\\ +% "\caption[]"\marg{caption}& +% Caption `Table ?: \meta{caption}', +% but no entry in the list of tables.\\ +% "\caption*"\marg{caption}& +% Caption `\meta{caption}', but no entry in the list of tables.\\[5pt] +% \multicolumn{2}{c}{%^^A +% \textbf{Commands available at the start of a row}}\\* +% \hline +% "\pagebreak"& +% Force a page break.\\* +% "\pagebreak"\oarg{val}& A `hint' between 0 and 4 +% of the desirability of a break.\\ +% "\nopagebreak"& Prohibit a page break.\\* +% "\nopagebreak"\oarg{val}& A `hint' between 0 and 4 of the undesirability +% of a break.\\ +% "\newpage"& +% Force a page break.\\[5pt] +% \multicolumn{2}{c}{\textbf{Footnote commands +% available inside \env{longtable}}}\\* +% \hline +% "\footnote"& +% Footnotes, but may not be used in the table head \& foot.\\* +% "\footnotemark"& +% Footnotemark, may be used in the table head \& foot.\\* +% "\footnotetext"& +% Footnote text, use in the table body.\\[5pt] +% \multicolumn{2}{c}{\textbf{Setlongtables}}\\ +% \hline +% "\setlongtables"& Obsolete command. Does nothing now. +% \end{longtable} +% +% +% \finalclearpage +% \section{Verbatim highlights from Table \protect\ref{long}} +% \label{listing} +% \begingroup\catcode`\/=0 +% \begin{verbatim} +% \begin{longtable}{@{*}r||p{1in}@{*}} +% KILLED & LINE!!!! \kill +% \caption[An optional table caption /ldots]{A long table\label{long}}\\ +% \hline\hline +% \multicolumn{2}{@{*}c@{*}}% +% {This part appears at the top of the table}\\ +% \textsc{First}&\textsc{Second}\\ +% \hline\hline +% \endfirsthead +% \caption[]{(continued)}\\ +% \hline\hline +% \multicolumn{2}{@{*}c@{*}}% +% {This part appears at the top of every other page}\\ +% \textbf{First}&\textbf{Second}\\ +% \hline\hline +% \endhead +% \hline +% This goes at the&bottom.\\ +% \hline +% \endfoot +% \hline +% These lines will&appear\\ +% in place of the & usual foot\\ +% at the end& of the table\\ +% \hline +% \endlastfoot +% \env{longtable} columns are specified& in the \\ +% same way as in the \env{tabular}& environment.\\ +% /ldots +% \multicolumn{2}{||c||}{This is a /ldots}\\ +% /ldots +% Some lines may take/ldots& +% \raggedleft This last column is a ``p'' column/ldots +% \tabularnewline +% /ldots +% Lots of lines& like this.\\ +% /ldots +% \hline +% Lots\footnote{/ldots} of lines& like this.\\ +% Lots of lines& like this\footnote{/ldots}\\ +% \hline +% Lots of lines& like this.\\ +% /ldots +% \end{longtable} +% \end{verbatim} +% \endgroup +% +% \StopEventually{} +% +% \finalclearpage +% \section{The Macros} +% +% \begin{macrocode} +%<*package> +% \end{macrocode} +% +% \subsection{Initial code} +% +% Before declaring the package options, we must define some defaults +% here. +% +% \begin{macro}{\LT@err} +% The error generating command +% \begin{macrocode} +\def\LT@err{\PackageError{longtable}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\LT@warn} +% The warning generating command +% \begin{macrocode} +\def\LT@warn{\PackageWarning{longtable}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\LT@final@warn} +% \changes{v4.04}{1996/05/24} +% {Macro added} +% If any \env{longtable}s have not aligned, generate a warning at the +% end of the run at "\AtEndDocument". +% \begin{macrocode} +\def\LT@final@warn{% + \AtEndDocument{% + \LT@warn{Table \@width s have changed. Rerun LaTeX.\@gobbletwo}}% + \global\let\LT@final@warn\relax} +% \end{macrocode} +% \end{macro} +% +% \subsection{Options} +% +% The first two options deal with error handling. They are compatible +% with the options used by the \texttt{tracefnt} package. +% +% \begin{macro}{errorshow} +% \emph{Only} show errors on the terminal. `warnings' are just sent to +% the log file. +% \changes{v3.14}{1995/04/25} +% {Change string from LT to longtable} +% \begin{macrocode} +\DeclareOption{errorshow}{% + \def\LT@warn{\PackageInfo{longtable}}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{pausing} +% \changes{v3.14}{1995/04/25} +% {Change string from LT to longtable} +% \changes{v3.15}{1995/06/15} +% {Use single hash for latex/1557} +% Make every warning message into an error so \TeX\ stops. +% May be useful for debugging. +% \begin{macrocode} +\DeclareOption{pausing}{% + \def\LT@warn#1{% + \LT@err{#1}{This is not really an error}}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{set} +% \begin{macro}{final} +% \changes{v4.01}{1996/04/11} +% {(DPC) make set and final options no op} +% The next options are just alternative syntax for the +% "\setlongtables" declaration. +% \begin{macrocode} +\DeclareOption{set}{} +\DeclareOption{final}{} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% +% \begin{macrocode} +\ProcessOptions +% \end{macrocode} +% +% \subsection{User Settable Parameters} +% +% \begin{macro}{\LTleft} +% \begin{macro}{\LTright} +% Glue to the left and right of the table, default "\fill" (ie +% centred). +% \begin{macrocode} +\newskip\LTleft \LTleft=\fill +\newskip\LTright \LTright=\fill +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\LTpre} +% \begin{macro}{\LTpost} +% Glue before and after the \env{longtable}. "\bigskip" by default. +% \begin{macrocode} +\newskip\LTpre \LTpre=\bigskipamount +\newskip\LTpost \LTpost=\bigskipamount +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\LTchunksize} +% Chunk size (The number of rows taken per "\halign"). Default 20. +% \begin{macrocode} +\newcount\LTchunksize \LTchunksize=20 +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\c@LTchunksize} +% Added in V3.07 to allow the \LaTeX\ syntax +% "\setcounter{LTchunksize}{10}". +% \begin{macrocode} +\let\c@LTchunksize\LTchunksize +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\LTcapwidth} +% Width of the "\parbox" containing the caption. Default 4in. +% \begin{macrocode} +\newdimen\LTcapwidth \LTcapwidth=4in +% \end{macrocode} +% \end{macro} +% +% \subsection{Internal Parameters} +% +% \begin{macro}{\LT@head} +% \begin{macro}{\LT@firsthead} +% \begin{macro}{\LT@foot} +% \begin{macro}{\LT@lastfoot} +% Boxes for the table head and foot. +% \begin{macrocode} +\newbox\LT@head +\newbox\LT@firsthead +\newbox\LT@foot +\newbox\LT@lastfoot +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\LT@cols} +% Counter for number of columns. +% \begin{macrocode} +\newcount\LT@cols +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\LT@rows} +% Counter for rows up to chunksize. +% \begin{macrocode} +\newcount\LT@rows +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\c@LT@tables} +% Counter for the tables, added in V3.02. Previous versions just used +% the \LaTeX\ counter "table", but this fails if "table" is +% reset during a document, eg \package{report} class resets it every +% chapter. +% +% This was changed from "\newcount\LT@tables" in V3.04. \LaTeX\ counters +% are preserved correctly when "\includeonly" is used. In the rest of +% the file "\LT@tables" has been replaced by "\c@LT@tables" without +% further comment. +% \begin{macrocode} +\newcounter{LT@tables} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\c@LT@chunks} +% \changes{v4.00}{1996/04/08} +% {(DK) Chunk counter added} +% We need to count through the chunks of our tables from Version~4 on. +% \begin{macrocode} +\newcounter{LT@chunks}[LT@tables] +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\c@table} +% \begin{macro}{\fnum@table} +% \begin{macro}{\tablename} +% If the "table" counter is not defined (eg in "letter" style), define +% it. (Added in V3.06.) +% \begin{macrocode} +\ifx\c@table\undefined + \newcounter{table} + \def\fnum@table{\tablename~\thetable} +\fi +\ifx\tablename\undefined + \def\tablename{Table} +\fi +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\LT@out} +% In a normal style, "longtable" uses the ".aux" file to record the +% column widths. With "letter.sty", use a separate ".lta" file. +% (Added in V3.06.) +% +% Not needed for new letter class. +%\begin{verbatim} +%\ifx\startlabels\undefined +% \let\@auxout\@auxout +%\else +% {\@input{\jobname.lta}}% +% \newwrite\@auxout +% \immediate\openout\@auxout=\jobname.lta +%\fi +%\end{verbatim} +% \end{macro} +% +% \begin{macro}{\LT@p@ftn} +% Temporary storage for footnote text in a `p' column. +% \begin{macrocode} +\newtoks\LT@p@ftn +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\LT@end@pen} +% Special penalty for the end of the table. Done this way to save using +% up a count register. +% \begin{macrocode} +\mathchardef\LT@end@pen=30000 +% \end{macrocode} +% \end{macro} +% +% \subsection{The \env{longtable} environment} +% +% \begin{macro}{\longtable} +% Called by "\begin{longtable}". This implementation does not work in +% multiple column formats. "\par" added at V3.04. +% \begin{macrocode} +\def\longtable{% + \par + \ifx\multicols\@undefined + \else + \ifnum\col@number>\@ne + \@twocolumntrue + \fi + \fi + \if@twocolumn + \LT@err{longtable not in 1-column mode}\@ehc + \fi + \begingroup +% \end{macrocode} +% Check for an optional argument. +% \begin{macrocode} + \@ifnextchar[\LT@array{\LT@array[x]}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\LT@array} +% Start setting the alignment. +% Based on "\@array" from the \LaTeX\ kernel +% and the \package{array} package. +% +% Since Version 3.02, \package{longtable} has used the internal counter +% "\c@LT@tables". The \LaTeX\ counter "table" is still incremented +% so that "\caption" works correctly. +% \begin{macrocode} +\def\LT@array[#1]#2{% + \refstepcounter{table}\stepcounter{LT@tables}% +% \end{macrocode} +% Set up the glue around the table if an optional argument given. +% \begin{macrocode} + \if l#1% + \LTleft\z@ \LTright\fill + \else\if r#1% + \LTleft\fill \LTright\z@ + \else\if c#1% + \LTleft\fill \LTright\fill + \fi\fi\fi +% \end{macrocode} +% Set up these internal commands for \env{longtable}. +% \changes{v3.13}{1994/12/08} +% {add \cs{tabularnewline}} +% \changes{v3.14}{1995/04/25} +% {(Mike Van Geest) rename \cs{LT@mc} to +% \cs{LT@mcol} to allow 1100 tables} +% \changes{v4.01}{1996/04/11} +% {(DPC) don't need multicolumn warning} +%\begin{verbatim} +% \global\let\LT@mcw@rn\relax +%\end{verbatim} +% \begin{macrocode} + \let\LT@mcol\multicolumn +% \end{macrocode} +% \changes{v3.17}{1996/01/31} +% {Reset \cs{hline} and \cs{multicolumn} in nested tabular +% and array, for tools/2068} +% Now redefine "\@tabarray" to restore "\hline" and "\multicolumn" so +% that arrays and tabulars nested in longtable (or in page headings on +% longtable pages) work out OK. Saving the original definitions done +% here so that you can load the \package{array} package before or after +% \package{longtable}. +% \begin{macrocode} + \let\LT@@tabarray\@tabarray + \let\LT@@hl\hline + \def\@tabarray{% + \let\hline\LT@@hl +% \end{macrocode} +%\begin{verbatim} +% \let\multicolumn\LT@mcol +%\end{verbatim} +% \begin{macrocode} + \LT@@tabarray}% + \let\\\LT@tabularcr\let\tabularnewline\\% + \def\newpage{\noalign{\break}}% +% \end{macrocode} +% \changes{v4.05}{1996/11/12} +% {\cs{nopagebreak} and \cs{pagebreak} added} +% More or less standard definitions, but first start a "\noalign". +% \begin{macrocode} + \def\pagebreak{\noalign{\ifnum`}=0\fi\@testopt{\LT@no@pgbk-}4}% + \def\nopagebreak{\noalign{\ifnum`}=0\fi\@testopt\LT@no@pgbk4}% +% \end{macrocode} +% +% \begin{macrocode} + \let\hline\LT@hline \let\kill\LT@kill\let\caption\LT@caption + \@tempdima\ht\strutbox +% \end{macrocode} +% +% \changes{v4.08}{1998/01/20} +% {Move \cs{@endpbox} definition earlier and define \cs{@@endpbox} +% and \cs{@@startpbox} for non-array case. tools/2736} +% \begin{macrocode} + \let\@endpbox\LT@endpbox +% \end{macrocode} +% Set up internal commands according to Lamport or Mittelbach. +% \begin{macrocode} + \ifx\extrarowheight\@undefined +% \end{macrocode} +% Initialise these commands as in \env{tabular} from the \LaTeX\ kernel. +% \begin{macrocode} + \let\@acol\@tabacol + \let\@classz\@tabclassz \let\@classiv\@tabclassiv + \def\@startpbox{\vtop\LT@startpbox}% + \let\@@startpbox\@startpbox + \let\@@endpbox\@endpbox + \let\LT@LL@FM@cr\@tabularcr + \else +% \end{macrocode} +% Initialise these commands as in \package{array}. "\d@llar" +% replaced by "\d@llarbegin" "\d@llarend" in V3.03 to match +% \package{array} V2.0h. We do not need to set "\d@llarbegin" and +% "\d@llarend" as the \package{array} package gives them the correct +% values at the top level. +% \begin{macrocode} + \advance\@tempdima\extrarowheight + \col@sep\tabcolsep + \let\@startpbox\LT@startpbox\let\LT@LL@FM@cr\@arraycr + \fi +% \end{macrocode} +% The rest of this macro is mainly based on \package{array} package, but +% should work for the standard \env{tabular} too. +% \begin{macrocode} + \setbox\@arstrutbox\hbox{\vrule + \@height \arraystretch \@tempdima + \@depth \arraystretch \dp \strutbox + \@width \z@}% + \let\@sharp##\let\protect\relax +% \end{macrocode} +% Interpret the preamble argument. +% \begin{macrocode} + \begingroup + \@mkpream{#2}% +% \end{macrocode} +% We need to rename "\@preamble" here as F.M.'s scheme uses +% "\global", and we may need to nest "\@mkpream", eg for +% "\multicolumn" +% or an \env{array}. +% We do not need to worry about nested \env{longtable}s though! +% \begin{macrocode} + \xdef\LT@bchunk{% +% \end{macrocode} +% \changes{v4.00}{1996/04/08} +% {(DK) Increment Chunk counter} +% \begin{macrocode} + \global\advance\c@LT@chunks\@ne + \global\LT@rows\z@\setbox\z@\vbox\bgroup +% \end{macrocode} +% \changes{v4.05}{1996/11/12} +% {\cs{LT@setprevdepth} added} +% The following line was added in v4.05. +% In order to get the "\penalties" to work at chunk boundaries +% Need to take more care about where and when "\lineskip" glue +% is added. The following does nothing at top of table, and in +% header chunks, but in normal body chunks it sets "\prevdepth" +% (to 0pt, but any value would do) so that "\lineskip" glue will +% be added. the important thing to note is that the glue will be +% added \emph{after} any vertical material coming from "\noalign". +% \begin{macrocode} + \LT@setprevdepth +% \end{macrocode} +% +% \changes{v4.10}{2000/10/22} +% {\cs{noexpand} added (as in array.sty) for mathtext.sty, CAR} +% \begin{macrocode} + \tabskip\LTleft \noexpand\halign to\hsize\bgroup +% \tabskip\LTleft\halign to\hsize\bgroup + \tabskip\z@ \@arstrut \@preamble \tabskip\LTright \cr}% + \endgroup +% \end{macrocode} +% Find out how many columns we have (store in "\LT@cols"). +% \begin{macrocode} + \expandafter\LT@nofcols\LT@bchunk&\LT@nofcols +% \end{macrocode} +% Get the saved row from "\LT@i"\ldots"\LT@ix" (from the +% ".aux" file), or make a new blank row. +% \begin{macrocode} + \LT@make@row +% \end{macrocode} +% A few more internal commands for \env{longtable}. +% \begin{macrocode} + \m@th\let\par\@empty + \everycr{}\lineskip\z@\baselineskip\z@ +% \end{macrocode} +% Start the first chunk. +% \begin{macrocode} + \LT@bchunk} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\LT@no@pgbk} +% \changes{v4.05}{1996/11/12} +% {Macro added} +% Can simplify the standard "\@no@pgbk" as this is vmode only +% but then need to close the "\noalign". +% \begin{macrocode} +\def\LT@no@pgbk#1[#2]{\penalty #1\@getpen{#2}\ifnum`{=0\fi}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\LT@start} +% This macro starts the process of putting the table on the current +% page. It is not called until either a "\\" or "\endlongtable" command +% ends a chunk, as we do not know until that point which of the four +% possible head or foot sections have been specified. +% +% It begins by redefining itself, so that the table is only started +% once! Until V3.04, was redefined to "\relax", now use "\endgraf" to +% force the page-breaker to wake up. +% \begin{macrocode} +\def\LT@start{% + \let\LT@start\endgraf + \endgraf\penalty\z@\vskip\LTpre +% \end{macrocode} +% Start a new page if there is not enough room for the table head, foot, +% and one extra line. +% \begin{macrocode} + \dimen@\pagetotal + \advance\dimen@ \ht\ifvoid\LT@firsthead\LT@head\else\LT@firsthead\fi + \advance\dimen@ \dp\ifvoid\LT@firsthead\LT@head\else\LT@firsthead\fi + \advance\dimen@ \ht\LT@foot +% \end{macrocode} +% \changes{v3.16}{1995/11/09} +% {Measure the first line of the table} +% At this point I used to add "\ht\@arstrutbox" and "\dp\@arstrutbox" +% as a measure of a row size. However this can fail spectacularly +% for "p" columns which might be much larger. Previous versions could +% end up with the table starting with a foot, then a page break then +% a head \emph{then} a `first head'! So now measure the first line of +% the table accurately by "\vsplit"ting it out of the first chunk. +% \begin{macrocode} + \dimen@ii\vfuzz + \vfuzz\maxdimen + \setbox\tw@\copy\z@ + \setbox\tw@\vsplit\tw@ to \ht\@arstrutbox + \setbox\tw@\vbox{\unvbox\tw@}% + \vfuzz\dimen@ii + \advance\dimen@ \ht + \ifdim\ht\@arstrutbox>\ht\tw@\@arstrutbox\else\tw@\fi + \advance\dimen@\dp + \ifdim\dp\@arstrutbox>\dp\tw@\@arstrutbox\else\tw@\fi +% \end{macrocode} +% +% \begin{macrocode} + \advance\dimen@ -\pagegoal + \ifdim \dimen@>\z@\vfil\break\fi +% \end{macrocode} +% Store height of page minus table foot in "\@colroom". +% \changes{v3.14}{1995/05/02} +% {Set \cs{@colroom}, for tools/1584} +% \begin{macrocode} + \global\@colroom\@colht +% \end{macrocode} +% If the foot is non empty, reduce the "\vsize" and "\@colroom" +% accordingly. +% \begin{macrocode} + \ifvoid\LT@foot\else + \advance\vsize-\ht\LT@foot + \global\advance\@colroom-\ht\LT@foot + \dimen@\pagegoal\advance\dimen@-\ht\LT@foot\pagegoal\dimen@ + \maxdepth\z@ + \fi +% \end{macrocode} +% Put the table head on the page, and then switch to the new output +% routine. +% \changes{v4.11}{2004/02/01} +% {\cs{nobreak}, for tools/3484} +% \begin{macrocode} + \ifvoid\LT@firsthead\copy\LT@head\else\box\LT@firsthead\fi\nobreak + \output{\LT@output}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\endlongtable} +% Called by "\end{longtable}". +% \begin{macrocode} +\def\endlongtable{% +% \end{macrocode} +% Essentially add a final "\\". But as we now know the number of +% actual chunks, we first strip away all entries referring to a +% maximum entry beyond the table (this can only happen if a table has +% been shortened, or the table numbering has gone awry). In that case +% we at least start collecting valid new information with the last +% chunk of this table, by removing the width constraint. +% \changes{v4.01}{1996/04/11} +% {(DPC) use \cs{noalign} to sneak in \cs{LT@entry@chop}} +% \begin{macrocode} + \crcr + \noalign{% + \let\LT@entry\LT@entry@chop + \xdef\LT@save@row{\LT@save@row}}% + \LT@echunk + \LT@start + \unvbox\z@ + \LT@get@widths +% \end{macrocode} +% Write the dummy row to the ".aux" file. +% Since V3.06, use ".lta" for "letter.sty". +% \changes{v3.12}{1994/06/30} +% {Do not write if \cs{nofiles} in operation.} +% \begin{macrocode} + \if@filesw + {\let\LT@entry\LT@entry@write\immediate\write\@auxout{% +% \end{macrocode} +% Since Version 3.02, \package{longtable} has used the internal counter +% "\c@LT@tables" rather than the \LaTeX\ counter \textsf{table}. This +% information looks entirely different from version~3 +% information. Still, we don't need to rename the macro name because +% later code will consider the information to have no columns, and +% thus will throw the old data away. +% \begin{macrocode} + \gdef\expandafter\noexpand + \csname LT@\romannumeral\c@LT@tables\endcsname + {\LT@save@row}}}% + \fi +% \end{macrocode} +% At this point used to +% issue a warning if a "\multicolumn" has been set in draft mode. +% \changes{v4.01}{1996/04/11} +% {(DPC) No need for multicolumn warnings} +%\begin{verbatim} +% \LT@mcw@rn +%\end{verbatim} +% If the last chunk has different widths than the first, warn the user. +% Also trigger a warning to rerun \LaTeX\ at the end of the document. +% \changes{v4.04}{1996/05/24} +% {Use \cs{LT@final@warn}} +% \begin{macrocode} + \ifx\LT@save@row\LT@@save@row + \else + \LT@warn{Column \@width s have changed\MessageBreak + in table \thetable}% + \LT@final@warn + \fi +% \end{macrocode} +% Force one more go with the \env{longtable} output routine. +% \begin{macrocode} + \endgraf\penalty -\LT@end@pen +% \end{macrocode} +% Now close the group to return to the standard routine. +% \begin{macrocode} + \endgroup +% \end{macrocode} +% Reset "\@mparbottom" to allow marginpars close to the end of the +% table.\footnote{This can not be the correct. However if it is omitted, +% there is a problem with marginpars, for example on page~3 of this +% document. Any Output Routine Gurus out there?} +% \begin{macrocode} + \global\@mparbottom\z@ + \pagegoal\vsize + \endgraf\penalty\z@\addvspace\LTpost +% \end{macrocode} +% Footnotes. As done in the \package{multicol} package. +% \begin{macrocode} + \ifvoid\footins\else\insert\footins{}\fi} +% \end{macrocode} +% \end{macro} +% +% \subsection{Counting Columns} +% +% Columns are counted by examining "\@preamble", rather than simply +% getting "\@mkpream" to increment the counter as it builds the +% preamble so that this package works with many of the packages which +% add extra column specifiers to \LaTeX's standard ones. +% +% Version~1 counted "\@sharp"'s to calculate the number of columns, +% this was changed for Version~2 as it does not work with the NFSS. Now +% count "&"'s. ("lfonts.new" (and now the Standard \LaTeX\ definition) +% defines "\@tabclassz" so that "\@sharp" is inside a group.) +% +% \begin{macro}{\LT@nofcols} +% Find the next "&", then look ahead to see what is next. +% \begin{macrocode} +\def\LT@nofcols#1&{% + \futurelet\@let@token\LT@n@fcols} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\LT@n@fcols} +% Add one, then stop at an "\LT@nofcols" or look for the next +% "&". The "\expandafter" trick was added in Version~3, also the +% name changed from "\@LT@nofcols" to preserve the "\LT@" naming +% convention. +% \begin{macrocode} +\def\LT@n@fcols{% + \advance\LT@cols\@ne + \ifx\@let@token\LT@nofcols + \expandafter\@gobble + \else + \expandafter\LT@nofcols + \fi} +% \end{macrocode} +% \end{macro} +% +% \subsection{The {\ttfamily\bslash\bslash} and \cs{kill} Commands} +% +% \begin{macro}{\LT@tabularcr} +% \changes{v4.05}{1996/11/12} +% {Code re-organised for the *-form processing.} +% The internal definition of "\\". +% In the "*" form, insert a "\nobreak" after the next "\cr" (or "\crcr"). +% +% This star form processing was finally added in v4.05. For the previous +% six or seven years the comment at this point said +% \begin{quote}\small +% This definition also accepts "\\*", which acts in the same way as +% "\\". \env{tabular} does this, but \env{longtable} probably ought to +% make "\\*" prevent page breaking. +% \end{quote} +% +% "{\ifnum0=`}\fi" added in version 3.01, required if the first entry +% is empty. +% The above in fact is not good enough, as with \package{array} package +% it can introduce a "{}" group in math mode, which changes the spacing. +% So use the following variant. Added in v3.14. +% \changes{v3.14}{1995/04/25} +% {More fun with \cs{ifnum} cf tools/1571} +% \begin{macrocode} +\def\LT@tabularcr{% + \relax\iffalse{\fi\ifnum0=`}\fi + \@ifstar + {\def\crcr{\LT@crcr\noalign{\nobreak}}\let\cr\crcr + \LT@t@bularcr}% + {\LT@t@bularcr}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\LT@crcr} +% \changes{v4.05}{1996/11/12} +% {Macro added} +% \begin{macrocode} +\let\LT@crcr\crcr +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\LT@setprevdepth} +% \changes{v4.05}{1996/11/12} +% {Macro added} +% This will be redefined to set the "\prevdepth" +% at the start of a chunk. +% \begin{macrocode} +\let\LT@setprevdepth\relax +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\LT@t@bularcr} +% \begin{macrocode} +\def\LT@t@bularcr{% +% \end{macrocode} +% Increment the counter, and do \env{tabular}'s "\\" or finish the +% chunk.\\ The "\expandafter" trick was added in Version~3. +% Set the "\prevdepth" at the start of a new chunk. (Done here +% so not set in header chunks). +% \begin{macrocode} + \global\advance\LT@rows\@ne + \ifnum\LT@rows=\LTchunksize + \gdef\LT@setprevdepth{% + \prevdepth\z@\global + \global\let\LT@setprevdepth\relax}% + \expandafter\LT@xtabularcr + \else + \ifnum0=`{}\fi + \expandafter\LT@LL@FM@cr + \fi} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\LT@xtabularcr} +% This just looks for an optional argument. +% \begin{macrocode} +\def\LT@xtabularcr{% + \@ifnextchar[\LT@argtabularcr\LT@ntabularcr} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\LT@ntabularcr} +% The version with no optional argument. +% "\ifnum0=`{\fi}" added in version 3.01. Changed in 3.14. +% \begin{macrocode} +\def\LT@ntabularcr{% + \ifnum0=`{}\fi + \LT@echunk + \LT@start + \unvbox\z@ + \LT@get@widths + \LT@bchunk} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\LT@argtabularcr} +% The version with an optional argument. +% "\ifnum0=`{\fi}" added in version 3.01. Changed in 3.14. +% \begin{macrocode} +\def\LT@argtabularcr[#1]{% + \ifnum0=`{}\fi + \ifdim #1>\z@ + \unskip\@xargarraycr{#1}% + \else + \@yargarraycr{#1}% + \fi +% \end{macrocode} +% Add the dummy row, and finish the "\halign". +% \begin{macrocode} + \LT@echunk + \LT@start + \unvbox\z@ + \LT@get@widths + \LT@bchunk} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\LT@echunk} +% \changes{v4.05}{1996/11/12} +% {\cs{unskip} added for pagebreak support} +% This ends the current chunk, and removes the dummy row. +% \begin{macrocode} +\def\LT@echunk{% + \crcr\LT@save@row\cr\egroup + \global\setbox\@ne\lastbox +% \end{macrocode} +% The following line was added in v4.05. +% \package{longtable} relies on "\lineskip" glue (which is 0pt) to +% provide break points between each row so the table may be split +% into pages. +% +% Previous releases left the "\lineskip" glue at the end of each chunk +% that had been added when the dummy row was added. There was no glue +% at the start of the next chunk as \TeX\ normally does not put +% "\lineskip" glue at the top of a box. This meant that normally the +% chunks fitted together perfectly, however "\noalign" material at a +% chunk boundary came before the first row of the next chunk +% but after the lineskip glue at the end of this chunk. This is the +% wrong place, e.g., it means even a "\penalty10000" does not stop a +% break as the "\lineskip" glue in the previous item on the list +% provides a legal breakpoint. So now remove the "\lineskip" glue that +% was before the dummy row and introduce "\LT@setprevdepth" to set the +% "\prevdepth" at the start of the next chunk, to make sure "\lineskip" +% glue is added later. +% \begin{macrocode} + \unskip + \egroup} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\LT@entry} +% \changes{v4.00}{1996/04/08} +% {(DK) Macro added} +% \changes{v4.01}{1996/04/11} +% {(DPC) Use \cs{ifhmode} trick to determine first entry} +% We here give the `basic' definition of "\LT@entry", namely that used +% in alignment templates. It has a "\kern" only if the maximum is +% imposed from a different chunk. +% The "\ifhmode" test reveals the first entry, when we don't want to add +% an "&". +% \begin{macrocode} +\def\LT@entry#1#2{% + \ifhmode\@firstofone{&}\fi\omit + \ifnum#1=\c@LT@chunks + \else + \kern#2\relax + \fi} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\LT@entry@chop} +% \changes{v4.00}{1996/04/08} +% {(DK) Macro added} +% This definition for the argument of "\LT@save@row" is used to scrap +% all those maxima which could not be verified because they occur +% after the end of the table. This can happen only if a table has been +% shortened (or the sequencing got mixed up) since the +% previous run. +% Note that this is premature: the last chunk still is going to be +% set, and with the chopped limits. +% \begin{macrocode} +\def\LT@entry@chop#1#2{% + \noexpand\LT@entry + {\ifnum#1>\c@LT@chunks + 1}{0pt% + \else + #1}{#2% + \fi}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\LT@entry@write} +% \changes{v4.07}{1997/10/16} +% {Avoid use of percent. tools/2631} +% To write an entry for the "aux" file, we use a slightly +% surprising definition which has the sole purpose of avoiding +% overfull lines (which might break \TeX{}'s limits when reading the +% "aux" file, probably you'd need to have a few hundred columns before +% this happened but\ldots). +% \begin{macrocode} +\def\LT@entry@write{% + \noexpand\LT@entry^^J% + \@spaces} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\LT@kill} +% This ends the current chunk as above, but strips off two rows, the +% `dummy row' and the `killed row' before starting the next chunk. +% Since V3.04, the old chunk is reboxed at the start of the box +% containing the next chunk. This allows "\kill" to be used in headers, +% which must be processed in a single box. +% \begin{macrocode} +\def\LT@kill{% + \LT@echunk + \LT@get@widths + \expandafter\LT@rebox\LT@bchunk} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\LT@rebox} +% Drop the old chunk (box0) back at the top of the new chunk, removing +% the killed row. This macro added at V3.04. +% \begin{macrocode} +\def\LT@rebox#1\bgroup{% + #1\bgroup + \unvbox\z@ + \unskip + \setbox\z@\lastbox} +% \end{macrocode} +% \end{macro} +% +% \subsection{The Dummy Row} +% +% The dummy row is kept inside of the macro "\LT@save@row". +% +% \begin{macro}{\LT@blank@row} +% \begin{macro}{\LT@build@blank} +% \changes{v4.00}{1996/04/08} +% {(DK) Macro added} +% \changes{v4.01}{1996/04/11} +% {(DPC) Don't mess with \cs{multicolumn} on draft passes} +% Create a blank row if we are not using the info in the ".aux" file. +% \begin{macrocode} +\def\LT@blank@row{% + \xdef\LT@save@row{\expandafter\LT@build@blank + \romannumeral\number\LT@cols 001 }} +% \end{macrocode} +% Whoops! What's that supposed to be? A drop-in replacement for the +% first task of Appendix~D in the \TeX book. The "\romannumeral" +% produces "\LT@cols" instances of "m" followed by "i". The below +% macro then replaces the "m"s by appropriate entries. +% \begin{macrocode} +\def\LT@build@blank#1{% + \if#1m% + \noexpand\LT@entry{1}{0pt}% + \expandafter\LT@build@blank + \fi} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\LT@make@row} +% \changes{v4.00}{1996/04/08} +% {(DK) New implementation} +% \changes{v4.01}{1996/04/11} +% {(DPC) Make this the default behaviour, not needing +% \cs{setlongtables}} +% +% Prior to version 4, by default did not use information in the +% ".aux" file but now we can define "\LT@make@row" to use the ".aux" +% file, even on the `draft' passes. +% \begin{macrocode} +\def\LT@make@row{% + \global\expandafter\let\expandafter\LT@save@row + \csname LT@\romannumeral\c@LT@tables\endcsname + \ifx\LT@save@row\relax + \LT@blank@row +% \end{macrocode} +% Now a slightly difficult part comes. Before we decide making the +% template from the ".aux" file info we check that the number of +% fields has remained the same. If it hasn't, either the table format +% has changed, or we have the wrong table altogether. In both cases, +% we decide to better drop all gathered information and start over. +% \changes{v4.01}{1996/04/11} +% {(DPC) Use \cs{if} test rather than \cs{ifx}\cs{@empty}} +% +% The expansion between "!"\ldots"!" below will be empty if the number +% of "\LT@entry" macros +% including arguments in "\LT@save@row" is equal to "\LT@cols". If it +% is not empty, we throw the row away and start from scratch. +% \begin{macrocode} + \else + {\let\LT@entry\or + \if!% + \ifcase\expandafter\expandafter\expandafter\LT@cols + \expandafter\@gobble\LT@save@row + \or + \else + \relax + \fi + !% + \else + \aftergroup\LT@blank@row + \fi}% + \fi} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\setlongtables} +% Redefine "\LT@make@row" to use information in the ".aux" file, +% if there is a saved row for this table with the right number of +% columns. +% +% Since Version 3.02, \package{longtable} has used the internal counter +% "\c@LT@tables" rather than the \LaTeX\ counter \textsf{table}. +% The warning message was added at V3.04, as was the "\global", to stop +% save-stack overflow. +% +% Since Version 4.01 "\setlongtables" does nothing as it is not +% needed, but is defined as "\relax" for the benefit of old documents. +% \changes{v3.12}{1994/06/30} +% {Warning altered to fit line on terminal.} +% \changes{v4.01}{1996/04/11} +% {(DPC) make into no op} +% \begin{macrocode} +\let\setlongtables\relax +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\LT@get@widths} +% This is the heart of \package{longtable}. If it were not for the table +% head and foot, this macro together with the modified "\\" command +% would form the basis of quite a simple little package file for long +% tables. It is closely modelled on the "\endvrulealign" macro of +% appendix D of the \TeX book. +% \begin{macrocode} +\def\LT@get@widths{% +% \end{macrocode} +% "\global" added at V3.04, to stop save-stack overflow. +% \begin{macrocode} +% \end{macrocode} +% Loop through the last row, discarding glue, and saving box widths. At +% V3.04 changed the scratch box to 2, as the new "\kill" requires that +% "\box0" be preserved. +% \begin{macrocode} + \setbox\tw@\hbox{% + \unhbox\@ne + \let\LT@old@row\LT@save@row + \global\let\LT@save@row\@empty + \count@\LT@cols + \loop + \unskip + \setbox\tw@\lastbox + \ifhbox\tw@ + \LT@def@row + \advance\count@\m@ne + \repeat}% +% \end{macrocode} +% Remember the widths if we are in the first chunk. +% \begin{macrocode} + \ifx\LT@@save@row\@undefined + \let\LT@@save@row\LT@save@row + \fi} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\LT@def@row} +% \changes{v4.00}{1996/04/08} +% {(DK) New implementation} +% Add a column to the dummy row. Name changed from "\defLT@save@row" +% in Version~3, to preserve the "\LT@" naming convention. +% \begin{macrocode} +\def\LT@def@row{% +% \end{macrocode} +% We start by picking the respective entry from our old row. +% These redefinitions of "\LT@entry" are local to the group started +% in "\LT@get@widths". +% \begin{macrocode} + \let\LT@entry\or + \edef\@tempa{% + \ifcase\expandafter\count@\LT@old@row + \else + {1}{0pt}% + \fi}% +% \end{macrocode} +% Now we tack the right combination in front of "\LT@save@row": +% \begin{macrocode} + \let\LT@entry\relax + \xdef\LT@save@row{% + \LT@entry + \expandafter\LT@max@sel\@tempa + \LT@save@row}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\LT@max@sel} +% \changes{v4.00}{1996/04/08} +% {(DK) macro added} +% \changes{v4.01}{1996/04/11} +% {(DPC) minor modifications} +% And this is how to select the right combination. Note that we take +% the old maximum information only if the size does not change in +% \emph{either} direction. If the size has grown, we of course have a +% new maximum. If the size has shrunk, the old maximum (which was +% explicitly not enforced because of being in the current chunk) is +% invalid, and we start with this chunk as the new size. Note that +% even in the case of equality we \emph{must} use the "\the\wd\tw@" +% construct instead of "#2" because "#2" might be read in from the +% file, and so could have "\catcode"~11 versions of "p" and~"t" in~it +% which we want to be replaced by their `proper' "\catcode"~12 versions. +% \begin{macrocode} +\def\LT@max@sel#1#2{% + {\ifdim#2=\wd\tw@ + #1% + \else + \number\c@LT@chunks + \fi}% + {\the\wd\tw@}} +% \end{macrocode} +% \end{macro} +% +% \subsection{The \cs{hline} Command} +% +% \begin{macro}{\LT@hline} +% "\hline" and "\hline\hline" both produce \emph{two} lines. +% The only difference being the glue and penalties between them. +% This is so that a page break at a "\hline" produces a line on both +% pages.\footnote +% {\env{longtable} has always done this, but perhaps it would be +% better if hlines were \emph{omitted} at a page break, as the head and +% foot usually put a hline here anyway.} +% Also this "\hline" is more like a "\cline{1-\LT@cols}". +% \env{tabular}'s "\hline" would draw lines the full width of the page. +% \begin{macrocode} +\def\LT@hline{% + \noalign{\ifnum0=`}\fi + \penalty\@M + \futurelet\@let@token\LT@@hline} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\LT@@hline} +% This code is based on "\cline". Two copies of the line are produced, +% as described above. +% \begin{macrocode} +\def\LT@@hline{% + \ifx\@let@token\hline + \global\let\@gtempa\@gobble + \gdef\LT@sep{\penalty-\@medpenalty\vskip\doublerulesep}% + \else + \global\let\@gtempa\@empty + \gdef\LT@sep{\penalty-\@lowpenalty\vskip-\arrayrulewidth}% + \fi + \ifnum0=`{\fi}% + \multispan\LT@cols + \unskip\leaders\hrule\@height\arrayrulewidth\hfill\cr + \noalign{\LT@sep}% + \multispan\LT@cols + \unskip\leaders\hrule\@height\arrayrulewidth\hfill\cr + \noalign{\penalty\@M}% + \@gtempa} +% \end{macrocode} +% \end{macro} +% +% \subsection{Captions} +% +% \begin{macro}{\LT@caption} +% The caption is "\multicolumn{\LT@cols}{c}{"\meta{a parbox with the +% table's caption}"}" +% \begin{macrocode} +\def\LT@caption{% + \noalign\bgroup + \@ifnextchar[{\egroup\LT@c@ption\@firstofone}\LT@capti@n} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\LT@c@ption} +% Caption command (with [optional argument]). "\protect" added in +% Version~3. "\fnum@table" added at V3.05. +% \changes{v3.14}{1995/05/02} +% {Call \cs{LT@makecaption} not \cs{LT@mkcaption}} +% \changes{v3.14}{1995/05/24} +% {Add new control argument} +% \begin{macrocode} +\def\LT@c@ption#1[#2]#3{% + \LT@makecaption#1\fnum@table{#3}% + \def\@tempa{#2}% + \ifx\@tempa\@empty\else + {\let\\\space + \addcontentsline{lot}{table}{\protect\numberline{\thetable}{#2}}}% + \fi} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\LT@capti@n} +% Caption command (no [optional argument]) +% \changes{v3.14}{1995/05/02} +% {Call \cs{LT@makecaptionx} not \cs{LT@mkcaption}} +% \changes{v3.14}{1995/05/24} +% {Call \cs{LT@makecaption} with \cs{@gobble} or \cs{@firstofone}} +% \begin{macrocode} +\def\LT@capti@n{% + \@ifstar + {\egroup\LT@c@ption\@gobble[]}% + {\egroup\@xdblarg{\LT@c@ption\@firstofone}}} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\LT@makecaption} +% Put the caption in a box of width 0pt, so that it never affects the +% column widths. Inside that is a "\parbox" of width +% "\LTcapwidth". +% \changes{v3.14}{1995/05/02} +% {Renamed from \cs{LT@mkcaption}, +% and modified to call \cs{@makecaption}} +% \changes{v3.14}{1995/05/02} +% {Use the first arg to remove counter for star form} +% \begin{macrocode} +\def\LT@makecaption#1#2#3{% + \LT@mcol\LT@cols c{\hbox to\z@{\hss\parbox[t]\LTcapwidth{% +% \end{macrocode} +% Based on article class "\@makecaption", "#1" is "\@gobble" in star +% form, and "\@firstofone" otherwise. +% \begin{macrocode} + \sbox\@tempboxa{#1{#2: }#3}% + \ifdim\wd\@tempboxa>\hsize + #1{#2: }#3% + \else + \hbox to\hsize{\hfil\box\@tempboxa\hfil}% + \fi + \endgraf\vskip\baselineskip}% + \hss}}} +% \end{macrocode} +% \end{macro} +% +% +% \subsection{The Output Routine} +% +% The method used here for interfacing a special purpose output routine +% to the standard \LaTeX\ routine is lifted straight out of +% F.~Mittelbach's \package{multicol} package. +% +% \begin{macro}{\LT@output} +% Actually this is not so bad, with FM leading the way. +% \begin{macrocode} +\def\LT@output{% + \ifnum\outputpenalty <-\@Mi + \ifnum\outputpenalty > -\LT@end@pen +% \end{macrocode} +% If this was a float or a marginpar we complain. +% \begin{macrocode} + \LT@err{floats and marginpars not allowed in a longtable}\@ehc + \else +% \end{macrocode} +% We have reached the end of the table, on the scroll at least, +% \begin{macrocode} + \setbox\z@\vbox{\unvbox\@cclv}% + \ifdim \ht\LT@lastfoot>\ht\LT@foot +% \end{macrocode} +% The last foot might not fit, so:\footnote{An alternative would be to +% vsplit off a bit of the last chunk, so that the last page did not just +% have head and foot sections, but it is hard to do this in a consistent +% manner.} +% \begin{macrocode} + \dimen@\pagegoal + \advance\dimen@-\ht\LT@lastfoot + \ifdim\dimen@<\ht\z@ + \setbox\@cclv\vbox{\unvbox\z@\copy\LT@foot\vss}% + \@makecol + \@outputpage + \setbox\z@\vbox{\box\LT@head}% +% \end{macrocode} +% End of "\ifdim\dimen@<\ht\@cclc". +% \begin{macrocode} + \fi +% \end{macrocode} +% End of "\ifdim \ht\LT@lastfoot > \ht\LT@foot". +% \begin{macrocode} + \fi +% \end{macrocode} +% Reset "\@colroom". +% \changes{v3.14}{1995/05/02} +% {Reset \cs{@colroom}, for tools/1584} +% \begin{macrocode} + \global\@colroom\@colht + \global\vsize\@colht +% \end{macrocode} +% Put the last page of the table on to the main vertical list. +% \begin{macrocode} + \vbox + {\unvbox\z@\box\ifvoid\LT@lastfoot\LT@foot\else\LT@lastfoot\fi}% +% \end{macrocode} +% End of "\ifnum\outputpenalty > -\LT@end@pen". +% \begin{macrocode} + \fi +% \end{macrocode} +% Else "\outputpenalty > -\@Mi". +% \begin{macrocode} + \else +% \end{macrocode} +% If we have not reached the end of the table, +% \begin{macrocode} + \setbox\@cclv\vbox{\unvbox\@cclv\copy\LT@foot\vss}% + \@makecol + \@outputpage +% \end{macrocode} +% Reset "\vsize". +% \changes{v3.14}{1995/05/02} +% {Reset \cs{vsize}, for tools/1584} +% \begin{macrocode} + \global\vsize\@colroom +% \end{macrocode} +% Put the head at the top of the next page. +% \changes{v4.11}{2004/02/01} +% {\cs{nobreak}, for tools/3484} +% \begin{macrocode} + \copy\LT@head\nobreak +% \end{macrocode} +% End of "\ifnum\outputpenalty <-\@Mi". +% \begin{macrocode} + \fi} +% \end{macrocode} +% \end{macro} +% +% \subsection{Commands for the the table head and foot} +% +% \begin{macro}{\LT@end@hd@ft} +% The core of "\endhead" and friends. Store the current chunk in the +% box specified by "#1". Issue an error if the table has already +% started. Then start a new chunk. +% \begin{macrocode} +\def\LT@end@hd@ft#1{% + \LT@echunk +% \end{macrocode} +% Changed from "\relax" to "\endgraf" at V3.04, see "\LT@start". +% \begin{macrocode} + \ifx\LT@start\endgraf + \LT@err + {Longtable head or foot not at start of table}% + {Increase LTchunksize}% + \fi + \setbox#1\box\z@ + \LT@get@widths + \LT@bchunk} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\endfirsthead} +% \begin{macro}{\endhead} +% \begin{macro}{\endfoot} +% \begin{macro}{\endlastfoot} +% Call "\LT@end@hd@ft" with the appropriate box. +% \begin{macrocode} +\def\endfirsthead{\LT@end@hd@ft\LT@firsthead} +\def\endhead{\LT@end@hd@ft\LT@head} +\def\endfoot{\LT@end@hd@ft\LT@foot} +\def\endlastfoot{\LT@end@hd@ft\LT@lastfoot} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \subsection{The \cs{multicolumn} command} +% +% Earlier versions needed a special `draft' form of "\multicolumn". +% This is not needed in version~4, and so these commands have been +% removed. +% +% \begin{macro}{\LTmulticolumn} +% \changes{v4.01}{1996/04/11} +% {(DPC) macro removed} +% \end{macro} +% +% \begin{macro}{\LT@mcwarn} +% \changes{v4.01}{1996/04/11} +% {(DPC) macro removed} +% \end{macro} +% +% \subsection{Footnotes} +% +% The standard "\footnote" command works in a "c" column, but we +% need to modify the definition in a "p" column to overcome the +% extra level of boxing. These macros are based on the \package{array} +% package, but should be OK for the standard \env{tabular}. +% +% \begin{macro}{\LT@startpbox} +% \changes{v4.09}{1998/05/13} +% {Use \cs{setlength}, so that calc extensions apply. tools/2793} +% Add extra code to switch the definition of "\@footnotetext". +% \begin{macrocode} +\def\LT@startpbox#1{% + \bgroup +% \end{macrocode} +% \changes{v4.12}{2019/02/06}{Color group to match array package} +% \begin{macrocode} + \color@begingroup + \let\@footnotetext\LT@p@ftntext + \setlength\hsize{#1}% + \@arrayparboxrestore + \vrule \@height \ht\@arstrutbox \@width \z@} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\LT@endpbox} +% After the parbox is closed, expand "\LT@p@ftn" which will execute a +% series of\\ +% "\footnotetext["\meta{num}"]{"\meta{note}"}"\\ +% commands. After being lifted out of the parbox, they can migrate on +% their own from here. +% \changes{v3.10}{1994/05/15} +% {Use \cs{@finalstrut}} +% \changes{v4.03}{1996/05/07} +% {Use \cs{hfil} for tools/2120} +% \begin{macrocode} +\def\LT@endpbox{% + \@finalstrut\@arstrutbox +% \end{macrocode} +% \changes{v4.12}{2019/02/06}{Color group to match array package} +% \begin{macrocode} + \color@endgroup + \egroup + \the\LT@p@ftn + \global\LT@p@ftn{}% + \hfil} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\LT@p@ftntext} +% Inside the `p' column, just save up the footnote text in a token +% register. +% \begin{macrocode} +\def\LT@p@ftntext#1{% + \edef\@tempa{\the\LT@p@ftn\noexpand\footnotetext[\the\c@footnote]}% + \global\LT@p@ftn\expandafter{\@tempa{#1}}}% +% \end{macrocode} +% \end{macro} +% +% \begin{macrocode} +%</package> +% \end{macrocode} +% +% \Finale +\endinput + diff --git a/macros/latex-dev/required/tools/longtable.ins b/macros/latex-dev/required/tools/longtable.ins new file mode 100644 index 0000000000..1fc3c12dfa --- /dev/null +++ b/macros/latex-dev/required/tools/longtable.ins @@ -0,0 +1,75 @@ +%% +%% This file will generate fast loadable files and documentation +%% driver files from the doc files in this package when run through +%% LaTeX or TeX. +%% +%% Copyright (C) 1993-2019 +%% The LaTeX3 Project and any individual authors listed elsewhere +%% in this file. +%% +%% This file is part of the Standard LaTeX `Tools Bundle'. +%% ------------------------------------------------------- +%% +%% It may be distributed and/or modified under the +%% conditions of the LaTeX Project Public License, either version 1.3c +%% of this license or (at your option) any later version. +%% The latest version of this license is in +%% https://www.latex-project.org/lppl.txt +%% and version 1.3c or later is part of all distributions of LaTeX +%% version 2005/12/01 or later. +%% +%% As this file contains legal notices, it is NOT PERMITTED to modify +%% this file in any way that the legal information placed into +%% generated files is changed (i.e., the files generated when the +%% original file is executed). This restriction does not apply if +%% (parts of) the content is reused in a different WORK producing its +%% own generated files. +%% +%% The list of all files belonging to the `Tools Bundle' is +%% given in the file `manifest.txt'. +%% +%% +%% --------------- start of docstrip commands ------------------ +%% +\input docstrip + +\keepsilent + +\usedir{tex/latex/tools} + +\preamble + +This is a generated file. + +The source is maintained by the LaTeX Project team and bug +reports for it can be opened at https://latex-project.org/bugs/ +(but please observe conditions on bug reports sent to that address!) + +Copyright (C) 1993-2019 +The LaTeX3 Project and any individual authors listed elsewhere +in this file. + +This file was generated from file(s) of the Standard LaTeX `Tools Bundle'. +-------------------------------------------------------------------------- + +It may be distributed and/or modified under the +conditions of the LaTeX Project Public License, either version 1.3c +of this license or (at your option) any later version. +The latest version of this license is in + https://www.latex-project.org/lppl.txt +and version 1.3c or later is part of all distributions of LaTeX +version 2005/12/01 or later. + +This file may only be distributed together with a copy of the LaTeX +`Tools Bundle'. You may however distribute the LaTeX `Tools Bundle' +without such generated files. + +The list of all files belonging to the LaTeX `Tools Bundle' is +given in the file `manifest.txt'. + +\endpreamble + + +\generate{\file{longtable.sty}{\from{longtable.dtx}{package}}} + +\endbatchfile diff --git a/macros/latex-dev/required/tools/longtable.pdf b/macros/latex-dev/required/tools/longtable.pdf Binary files differnew file mode 100644 index 0000000000..87a022140c --- /dev/null +++ b/macros/latex-dev/required/tools/longtable.pdf diff --git a/macros/latex-dev/required/tools/manifest.txt b/macros/latex-dev/required/tools/manifest.txt new file mode 100644 index 0000000000..8b0f9e32d0 --- /dev/null +++ b/macros/latex-dev/required/tools/manifest.txt @@ -0,0 +1,111 @@ +% \iffalse meta-comment +% +% Copyright 1993-2016 +% The LaTeX3 Project and any individual authors listed elsewhere +% in this file. +% +% This file is part of the Standard LaTeX `Tools Bundle'. +% ------------------------------------------------------- +% +% It may be distributed and/or modified under the +% conditions of the LaTeX Project Public License, either version 1.3c +% of this license or (at your option) any later version. +% The latest version of this license is in +% https://www.latex-project.org/lppl.txt +% and version 1.3c or later is part of all distributions of LaTeX +% version 2005/12/01 or later. +% +% The list of all files belonging to the LaTeX `Tools Bundle' is +% given in the file `manifest.txt'. +% +% \fi +% +% CONTENTS OF THE TOOLS BUNDLE +% ============================ + +tools-overview.tex + Overview of the content of the tools bundle. + +array.dtx + Extended versions of the environments array, tabular and tabular*. +dcolumn.dtx + Alignment on `decimal points' in tabular entries. Requires array. +delarray.dtx + Adds `large delimiters' around arrays. Requires array. +hhline.dtx + Finer control over horizontal rules in tables. Requires array. +longtable.dtx + Multipage tables. (Does not require array, but uses the extended + features if both are loaded.) +tabularx.dtx + Defines tabularx environment (similar to tabular*) but modifies + column widths, not inter-column space, to achieve a desired + table width. + +afterpage.dtx + Place text after the current page. + +bm.dtx + Access bold math symbols. + +calc.dtx + Infix arithmetic expresions. Contributed to the distribution by + Kresten Krab Thorup and Frank Jensen. + +enumerate.dtx + Extended version of the enumerate environment. + +fileerr.dtx + Suite of small files which may be used to control TeX's + missing file error loop. + +fontsmpl.dtx + Package and test file for producing `font samples' + +ftnright.dtx + Place footnotes in the right hand column in two-column mode. + +indentfirst.dtx + Indent the first paragraph of sections etc. + +layout.dtx + Produces an overview of the layout of the current document. + +multicol.dtx + Typeset text in columns, with the length of the final columns + `balanced'. + +rawfonts.dtx + Preload fonts under the old internal font names of LaTeX2.09. + Not recomended for new packages, but may help when updating old + files. + +shellesc.dtx + Unified interface for accessing system commands. + +showkeys.dtx + Draft mode showing the `keys' used by \label, \ref, \cite etc. + +somedefs.dtx + Selective handling of package options. (Used in rawfonts.sty.) + +theorem.dtx + Flexible definition of `theorem-like' environments. + +trace.dtx + The package helps to suppress and to control the amount of tracing + output (\tracingall) by taming calc and making NFSS less noisy. + +varioref.dtx + `Smart' handling of page references. + +verbatim.dtx + Flexible version of verbatim environment. + +xr.dtx + eXternall References. Extend \ref to access \label commands in + other documents. + +xspace.dtx + Smart space command that avoids the common mistake of missing + spaces after command names. diff --git a/macros/latex-dev/required/tools/multicol-2017-04-11.sty b/macros/latex-dev/required/tools/multicol-2017-04-11.sty new file mode 100644 index 0000000000..e8558e4ce0 --- /dev/null +++ b/macros/latex-dev/required/tools/multicol-2017-04-11.sty @@ -0,0 +1,1042 @@ +%% +%% This is an old release of `multicol.sty', +%% +%% The source is maintained by the LaTeX Project team and bug +%% reports for it can be opened at http://latex-project.org/bugs.html +%% (but please observe conditions on bug reports sent to that address!) +%% +%% Copyright 1993-2016 +%% The LaTeX3 Project and any individual authors listed elsewhere +%% in this file. +%% +%% This file was generated from file(s) of the Standard LaTeX `Tools Bundle'. +%% -------------------------------------------------------------------------- +%% +%% It may be distributed and/or modified under the +%% conditions of the LaTeX Project Public License, either version 1.3c +%% of this license or (at your option) any later version. +%% The latest version of this license is in +%% http://www.latex-project.org/lppl.txt +%% and version 1.3c or later is part of all distributions of LaTeX +%% version 2005/12/01 or later. +%% +%% +%% Package `multicol' to use with LaTeX2e +%% Copyright 1989-2016 Frank Mittelbach +%% +%% In addition to the terms of LPPL any distributed version +%% (unchanged or modified) of multicol has to keep the statement +%% about the moral obligation for using multicol. In case of major +%% changes where this would not be appropriate the author of the +%% changed version should contact the copyright holder. +%% +%% +%% Moral obligation for using multicol: +%% ------------------------------------ +%% +%% Users of multicol who wish to include or use multicol or a modified +%% version in a proprietary and commercially market product are asked +%% under certain conditions (see below) for the payment of a license +%% fee. The size of this fee is to be determined, in each instance, +%% by the commercial user, depending on his/her judgment of the value of +%% multicol for his/her product. +%% +%% +%% The conditions for this are as follows: +%% +%% The producer of a proprietary and commercially market product +%% that involves typesetting using multicol is asked to determine +%% the value of a license fee for using multicol if +%% +%% - the product is a document and the producer has decided to +%% include multicol to typeset (parts of) the document or has +%% directed the author of the document to include multicol (for +%% example, by providing a class file to be used by the author) +%% +%% - the product is a LaTeX class or package that includes multicol +%% +%% +%% There is no moral obligation in case +%% +%% - the product is a document but producer has not directed +%% the author to include multicol (in that case the moral obligation +%% lies with the author of the document) +%% +%% - the product does not involve typesetting, e.g., consists, for +%% example, of distributing multicol and its documentation. +%% +%% - the product is not proprietary, i.e., is made available as free +%% software itself (which doesn't prohibit its commercial marketing) +%% +%% - multicol is used for non-commercial purposes +%% +%% +%% Determining a license fee might result in a license fee of zero +%% (i.e., no payment) in case a producer has determined that the use +%% of multicol has no enhancing effect on the product. This is a +%% plausible scenario, i.e., in the above two cases the producer is +%% only asked to evaluate the value of multicol for the product +%% not for the payment of a license fee per se (which might or might +%% not follow from this evaluation). +%% +%% The license fee, if any, can be payed either to the LaTeX3 fund +%% (see ltx3info.txt in the base LaTeX distribution) or to the author of +%% the program who can be contacted at +%% +%% Frank.Mittelbach@latex-project.org +%% +\NeedsTeXFormat{LaTeX2e}[1997/12/01] +\ProvidesPackage{multicol} + [2017/04/11 v1.8q multicolumn formatting (FMi)] +%% +\DeclareOption{twocolumn} + {\PackageWarning{multicol}{May not work + with the twocolumn option}} +\newcount\c@tracingmulticols +\DeclareOption{errorshow} + {\c@tracingmulticols\z@} +\DeclareOption{infoshow} + {\c@tracingmulticols\@ne} +\DeclareOption{balancingshow} + {\c@tracingmulticols\tw@} +\DeclareOption{markshow} + {\c@tracingmulticols\thr@@} +\DeclareOption{debugshow} + {\c@tracingmulticols5\relax} +\let\mc@gridwarn\maxdimen +\DeclareOption{grid}{\def\mc@gridwarn{\maxdepth}} +\DeclareOption{colaction}{% + \def\mc@col@status@write{% + \protected@write\@auxout{}% + {\string\mc@col@status + {\ifmc@firstcol 1\else 2\fi}}% + \mc@firstcolfalse}% + \def\mc@lastcol@status@write{% + \protected@write\@auxout{}% + {\string\mc@col@status{3}}}% +} +\let\mc@col@status@write\relax +\let\mc@lastcol@status@write\relax +\ProcessOptions +\def\multicols#1{\col@number#1\relax + \ifnum\col@number<\tw@ + \PackageWarning{multicol}% + {Using `\number\col@number' + columns doesn't seem a good idea.^^J + I therefore use two columns instead}% + \col@number\tw@ \fi + \ifnum\col@number>10 + \PackageError{multicol}% + {Too many columns}% + {Current implementation doesn't + support more than 10 columns.% + \MessageBreak + I therefore use 10 columns instead}% + \col@number10 \fi + \ifx\@footnotetext\mult@footnotetext\else + \let\orig@footnotetext\@footnotetext + \let\@footnotetext\mult@footnotetext + \fi + \@ifnextchar[\mult@cols{\mult@cols[]}} +\long\def\mult@footnotetext#1{\begingroup + \columnwidth\textwidth + \orig@footnotetext{#1}\endgroup} +\def\mult@cols[#1]{\@ifnextchar[% + {\mult@@cols{#1}}% + {\mult@@cols{#1}[\premulticols]}} +\def\mult@@cols#1[#2]{% + \par + \ifinner \@boxedmulticolstrue + \else + \ifnum \doublecol@number>\z@ + \@boxedmulticolstrue + \fi + \fi + \mult@info\z@ + {Starting environment with + \the\col@number\space columns% + \if@boxedmulticols\MessageBreak + (boxed mode)\fi + }% + \enough@room{#2}% + #1\par\addvspace\multicolsep + \ifdim \prevdepth = -\@m\p@ + \else + \@tempcnta\prevdepth + \@tempcntb\baselineskip + \divide\@tempcnta\@tempcntb + \advance\@tempcnta\@ne + \dimen@\prevdepth + \advance\dimen@ -\@tempcnta\baselineskip + \advance\dimen@ \topskip + \kern-\dimen@ + \fi + \begingroup + \prepare@multicols + \if@boxedmulticols + \setbox\mult@box\vbox\bgroup + \color@setgroup + \fi + \ignorespaces} +\newif\if@boxedmulticols +\@boxedmulticolsfalse +\newbox\mult@box +\def\enough@room#1{% + \if@boxedmulticols\else + \par + \bgroup\@nobreakfalse\addpenalty\z@\egroup + \page@free \pagegoal + \advance \page@free -\pagetotal + \@tempskipa#1\relax + \mult@info\z@ + {Current page:\MessageBreak + height=% + \the\pagegoal: used \the\pagetotal + \space -> free=\the\page@free + \MessageBreak + needed \the\@tempskipa + \space(for #1)}% + \ifdim \page@free <#1\newpage \fi + \fi} +\def\prepare@multicols{% + \multicol@leftmargin\@totalleftmargin + \@totalleftmargin\z@ + \parshape\z@ + \doublecol@number\col@number + \multiply\doublecol@number\tw@ + \advance\doublecol@number\mult@rightbox + \if@boxedmulticols + \let\l@kept@firstmark\kept@firstmark + \let\l@kept@botmark\kept@botmark + \global\let\kept@firstmark\@empty + \global\let\kept@botmark\@empty + \else + \nointerlineskip {\topskip\z@\null}% + \output{% + \global\setbox\partial@page\vbox + {% + \ifvoid\partial@page\else + \PackageError{multicol}% + {Error saving partial page}% + {The part of the page before + the multicols environment was + nearly full with^^Jthe result + that starting the environment + will produce an overfull + page. Some^^Jtext may be lost! + Please increase \premulticols + either generally or for this% + ^^Jenvironment by specifying a + suitable value in the second + optional argument to^^Jthe + multicols environment.} + \unvbox\partial@page + \box\last@line + \fi + \unvbox\@cclv + \global\setbox\last@line\lastbox + }% + \prep@keptmarks + \global\let\kept@topmark\firstmark + }\eject + \advance\@colroom-\ht\partial@page + \set@mult@vsize\relax + \output{\multi@column@out}% + \init@mult@footins + \reinsert@footnotes + \def\clearpage{% + \ifx\@deferlist\@empty\else + \PackageError{multicol}% + {Deferred floats not cleared}% + {A \string\clearpage\space inside multicols acts like + \string\newpage\space and doesn't clear floats.\MessageBreak + Move it before the multicols environment if you need it.}% + \fi + \newpage}% + \fi + \vbadness\@Mi \hbadness5000 + \tolerance\multicoltolerance + \pretolerance\multicolpretolerance + \setemergencystretch\col@number\hsize + \set@floatcmds + \advance\baselineskip\multicolbaselineskip + \hsize\linewidth \advance\hsize\columnsep + \advance\hsize-\col@number\columnsep + \divide\hsize\col@number + \full@width\linewidth + \linewidth\hsize + \columnwidth\hsize +} +\def\init@mult@footins{% + \multiply\count\footins\col@number + \multiply\skip \footins\col@number +} +\def\set@mult@vsize#1{% + \vsize\@colroom + \@tempdima\baselineskip + \advance\@tempdima-\topskip + \advance\vsize\@tempdima + \vsize\col@number\vsize + \advance\vsize-\@tempdima + \advance\vsize\col@number\baselineskip + #1\advance\vsize + \c@collectmore\baselineskip} +\newdimen\multicol@leftmargin +\def\endmulticols{\par + \if@boxedmulticols + \remove@discardable@items\color@endgroup\egroup + \balance@columns + \return@nonemptymark{first}% + \kept@firstmark + \return@nonemptymark{bot}% + \kept@botmark + \page@sofar + \global\let\kept@firstmark + \l@kept@firstmark + \global\let\kept@botmark + \l@kept@botmark + \mult@info\tw@ + {Restore kept marks to\MessageBreak + first: \meaning\kept@firstmark + \MessageBreak bot\space\space: + \meaning\kept@botmark }% + \else + \ifdim\pagegoal=\maxdimen + \ifvoid\colbreak@box\else + \mult@info\@ne{Re-adding forced + break(s) for splitting}% + \unvbox\colbreak@box\fi + \fi + \penalty\z@ + \output{\balance@columns@out}% + \eject + \ifvbox\partial@page + \unvbox\partial@page\fi + \global\let\kept@firstmark\@empty + \global\let\kept@botmark\@empty + \mult@info\tw@ + {Make kept marks empty}% + \fi + \@checkend{multicols}% + \endgroup + \global\c@unbalance\z@ + \if@boxedmulticols\else + \reinsert@footnotes + \ifdim \pagegoal=\maxdimen + \global\vsize\@colroom + \else + \enough@room\postmulticols + \fi + \fi + \addvspace\multicolsep + \prevdepth\z@ + \mult@info\z@ + {Ending environment + \if@boxedmulticols + \space(boxed mode)\fi + }} +\newcount\c@unbalance +\newcount\c@collectmore +\newcount\doublecol@number +\newcount\multicoltolerance +\newcount\multicolpretolerance +\newdimen\full@width +\newdimen\page@free +\newdimen\premulticols +\newdimen\postmulticols +\newskip\multicolsep +\newskip\multicolbaselineskip +\newbox\partial@page +\newbox\last@line +\c@unbalance = 0 +\c@collectmore = 0 +\multicoltolerance = 9999 +\multicolpretolerance = -1 +\premulticols = 50pt +\postmulticols= 20pt +\multicolsep = 12pt plus 4pt minus 3pt +\multicolbaselineskip=0pt +\def\process@cols#1#2{\count@#1\relax + \loop + #2% + \advance\count@\tw@ + \ifnum\count@<\doublecol@number + \repeat} +\def\page@sofar{% + \process@cols\mult@rightbox + {\ifvoid\count@ + \setbox\count@\hbox to\hsize{}% + \else + \wd\count@\hsize + \fi}% + \count@\col@number \advance\count@\m@ne + \mult@info\z@ + {Column spec: \the\full@width\space = indent + + columns + sep =\MessageBreak + \the\multicol@leftmargin\space + + \the\col@number\space + x \the\hsize\space + + \the\count@\space + x \the\columnsep + }% +\ifvmode\else\errmessage{Multicol Error}\fi + \nointerlineskip + \setbox\z@\hbox{p}\global\dimen\tw@\dp\z@ + \moveright\multicol@leftmargin + \hbox to\full@width{% + \mc@align@columns + \rlap{\phantom p}% + }% + \prevdepth\z@ + \kern-\dimen\tw@ + \ifdim\dimen\tw@ > \mc@gridwarn + \PackageWarning{multicol}% + {Very deep columns!\MessageBreak + Grid alignment might be broken}% + \fi +} +\def\columnseprulecolor{\normalcolor} +\def\reinsert@footnotes{\ifvoid\footins\else + \insert\footins{}\fi} +\def\vfilmaxdepth{\vskip \z@ \@plus .0001fil + \@minus \maxdepth} +\def\multi@column@out{% + \ifnum\outputpenalty <-\@M + \speci@ls \else + \ifvoid\colbreak@box\else + \mult@info\@ne{Re-adding forced + break(s) for splitting}% + \setbox\@cclv\vbox{% + \unvbox\colbreak@box + \penalty-\@Mv + \unvbox\@cclv}% + \fi + \splittopskip\topskip + \splitmaxdepth\maxdepth + \boxmaxdepth\maxdepth + \dimen@\@colroom + \divide\skip\footins\col@number + \ifvoid\footins \else + \leave@mult@footins + \fi + \let\ifshr@kingsaved\ifshr@king + \ifvbox \@kludgeins + \advance \dimen@ -\ht\@kludgeins + \ifdim \wd\@kludgeins>\z@ + \shr@nkingtrue + \fi + \fi + \process@cols\mult@gfirstbox{% + \setbox\count@ + \vsplit\@cclv to\dimen@ + \set@keptmarks + \setbox\count@ + \vbox to\dimen@ + {\unvbox\count@ + \ifshr@nking\vfilmaxdepth\fi}% + }% + \setbox\mult@rightbox + \vsplit\@cclv to\dimen@ + \set@keptmarks + \setbox\mult@rightbox\vbox to\dimen@ + {\unvbox\mult@rightbox + \ifshr@nking\vfilmaxdepth\fi}% + \let\ifshr@king\ifshr@kingsaved + \ifvoid\@cclv \else + \unvbox\@cclv + \ifnum\outputpenalty=\@M + \else + \penalty\outputpenalty + \fi + \ifvoid\footins\else + \PackageWarning{multicol}% + {I moved some lines to + the next page.\MessageBreak + Footnotes on page + \thepage\space might be wrong}% + \fi + \ifnum \c@tracingmulticols>\thr@@ + \hrule\allowbreak \fi + \fi + \ifx\@empty\kept@firstmark + \let\firstmark\kept@topmark + \let\botmark\kept@topmark + \else + \let\firstmark\kept@firstmark + \let\botmark\kept@botmark + \fi + \let\topmark\kept@topmark + \mult@info\tw@ + {Use kept top mark:\MessageBreak + \meaning\kept@topmark + \MessageBreak + Use kept first mark:\MessageBreak + \meaning\kept@firstmark + \MessageBreak + Use kept bot mark:\MessageBreak + \meaning\kept@botmark + \MessageBreak + Produce first mark:\MessageBreak + \meaning\firstmark + \MessageBreak + Produce bot mark:\MessageBreak + \meaning\botmark + \@gobbletwo}% + \boxmaxdepth\maxdimen + \setbox\@cclv\vbox{\unvbox\partial@page + \page@sofar}% + \@makecol\@outputpage + \global\let\kept@topmark\botmark + \global\let\kept@firstmark\@empty + \global\let\kept@botmark\@empty + \mult@info\tw@ + {(Re)Init top mark:\MessageBreak + \meaning\kept@topmark + \@gobbletwo}% + \global\@colroom\@colht + \global \@mparbottom \z@ + \global \@textfloatsheight \z@ + \process@deferreds + \@whilesw\if@fcolmade\fi{\@outputpage + \global\@colroom\@colht + \process@deferreds}% + \mult@info\@ne + {Colroom:\MessageBreak + \the\@colht\space + after float space removed + = \the\@colroom \@gobble}% + \set@mult@vsize \global + \fi} +\def\leave@mult@footins{% + \advance\dimen@-\skip\footins + \advance\dimen@-\ht\footins +} +\def\speci@ls{% + \ifnum\outputpenalty <-\@Mi + \ifnum \outputpenalty<-\@MM + \PackageError{multicol}{Document end + inside multicols environment}\@ehd + \@specialoutput + \else + \ifnum\outputpenalty = -\@Mv + \mult@info\@ne{Forced column + break seen}% + \global\advance\vsize-\pagetotal + \global\setbox\colbreak@box + \vbox{% + \ifvoid\colbreak@box + \else + \unvbox\colbreak@box + \penalty-\@Mv + \fi + \boxmaxdepth\maxdepth + \setbox\@cclv\vbox{% + \unvbox\@cclv + \remove@discardable@items}% + \dimen@\dp\@cclv + \unvbox\@cclv + \kern-\dimen@ + }% + \reinsert@footnotes + \else + \PackageWarningNoLine{multicol}% + {Floats and marginpars not + allowed inside `multicols' + environment!}% + \unvbox\@cclv\reinsert@footnotes + \xdef\@freelist{\@freelist\@currlist}% + \gdef\@currlist{}% + \fi + \fi + \else \@doclearpage \fi +} +\def\process@deferreds{% + \@floatplacement + \@tryfcolumn\@deferlist + \if@fcolmade\else + \begingroup + \let\@tempb\@deferlist + \gdef\@deferlist{}% + \let\@elt\@scolelt + \@tempb \endgroup + \fi} +\newif\ifshr@nking +\def\raggedcolumns{% + \@bsphack\shr@nkingtrue\@esphack} +\def\flushcolumns{% + \@bsphack\shr@nkingfalse\@esphack} +\def\balance@columns@out{% + \setbox\mult@box\vbox{% + \ifvoid\colbreak@box\else + \unvbox\colbreak@box + \penalty-\@Mv + \mult@info\@ne{Re-adding + forced break(s) in balancing}% + \fi + \unvbox\@cclv + \remove@discardable@items + }% + \balance@columns + \iftoo@bad + \mult@info\@ne + {Balancing failed ... + cut a normal page}% + \setbox\@cclv\vbox + {\vskip\topskip + \vskip-\splittopskip + \unvbox\mult@box}% + \multi@column@out + \else + \global\vsize\@colroom + \global\advance\vsize\ht\partial@page + \ifvbox\@kludgeins\insert\@kludgeins + {\unvbox\@kludgeins}\fi + \unvbox\partial@page + \return@nonemptymark{first}\kept@firstmark + \return@nonemptymark{bot}\kept@botmark + \page@sofar + \penalty\z@ + \fi +} +\def\balance@columns{% + \get@keptmarks\mult@box + \setbox\mult@box\vbox{% + \penalty-\@M + \unvbox\mult@box + }% + \@tempdima\topskip + \splittopskip\@tempdima + \@plus\multicolundershoot + \@minus\multicolovershoot + \splitmaxdepth\maxdepth + \boxmaxdepth\maxdepth + \setbox\@tempboxa\vsplit\mult@box to\z@ + \@tempdima\ht\mult@box + \advance\@tempdima\dp\mult@box + \divide\@tempdima\col@number + \count@\@tempdima + \divide\count@\baselineskip + \dimen@\count@\baselineskip + \advance\dimen@\topskip + \ifdim \dimen@ >\@tempdima + \advance\dimen@-\baselineskip + \fi + \advance\dimen@\c@unbalance\baselineskip + \mult@info\@ne + {Balance columns\on@line: + \ifnum\c@unbalance=\z@\else + (off balance=\number\c@unbalance)\fi + \@gobbletwo}% + \ifnum\dimen@<\topskip + \mult@info\@ne + {Start value + \the\dimen@ \space -> + \the\topskip \space (corrected)}% + \dimen@\topskip + \fi + \vbadness\@M + \vfuzz \maxdimen + \last@try-\p@ + \loop + {\process@cols\mult@grightbox + {\global\setbox\count@ + \box\voidb@x}}% + \global\setbox\mult@grightbox + \copy\mult@box + \too@badfalse + \forcedbreak@leftoverfalse + {\process@cols\mult@firstbox{% + \global\setbox\count@ + \vsplit\mult@grightbox to\dimen@ + \global\setbox\count@ + \vbox to\dimen@ + {\unvbox\count@}% + \ifnum\c@tracingmulticols>\@ne + \@tempcnta\count@ + \advance\@tempcnta-\mult@grightbox + \divide\@tempcnta \tw@ + \message{^^JColumn + \number\@tempcnta\space + badness: \the\badness\space}% + \fi + \ifnum\badness>\c@columnbadness + \ifnum\c@tracingmulticols>\@ne + \message{too bad + (>\the\c@columnbadness)}% + \fi + \too@badtrue + \fi + }}% + \global\setbox\mult@grightbox + \vbox{\unvbox\mult@grightbox}% + \setbox\mult@nat@firstbox + \vbox{\unvcopy\mult@firstbox}% + \ifnum\c@tracingmulticols>\@ne + \message{^^JFirst column + = \the\dimen@\space + (\the\ht\mult@nat@firstbox)}\fi + \ifnum\c@tracingmulticols>\@ne + \message{<> last column = + \the\ht\mult@grightbox^^J}% + \fi + \ifdim\ht\mult@grightbox >\dimen@ + \too@badtrue + \ifnum\c@tracingmulticols>\@ne + \typeout{Rejected: last + column too large!}% + \fi + \else + \setbox\@tempboxa + \copy\mult@grightbox + \setbox\z@\vsplit\@tempboxa to\maxdimen + \ifvoid\@tempboxa + \global\setbox\mult@grightbox + \vbox to\dimen@ + {\unvbox\mult@grightbox}% + \ifnum\c@tracingmulticols>\@ne + \message{Final badness: + \the\badness}% + \fi + \ifnum\badness>\c@finalcolumnbadness + \global\setbox\mult@grightbox + \vbox to\dimen@ + {\unvbox\mult@grightbox\vfil}% + \ifnum\c@tracingmulticols>\@ne + \message{ setting natural + (> \the\c@finalcolumnbadness)}% + \fi + \fi + \else + \@tempdima\@colroom + \advance\@tempdima \maxbalancingoverflow + \ifdim \dimen@ < \@tempdima + \too@badtrue + \ifnum\c@tracingmulticols>\@ne + \typeout{Rejected: unprocessed + forced break(s) in last column!}% + \fi + \else + \forcedbreak@leftovertrue + \ifnum\c@tracingmulticols>\@ne + \typeout{Failed: columns too large + with unprocessed forced break(s)!}% + \fi + \fi + \fi + \fi + \ifdim\ht\mult@nat@firstbox<\dimen@ + \ifdim\ht\mult@nat@firstbox>\last@try + \too@badtrue + \ifnum\c@tracingmulticols>\@ne + \typeout{Retry: using natural + height of first column!}% + \fi + \dimen@\ht\mult@nat@firstbox + \last@try\dimen@ + \advance\dimen@-\p@ + \fi + \fi + \iftoo@bad + \advance\dimen@\p@ + \repeat + \ifforcedbreak@leftover + \too@badtrue + \else + \if@boxedmulticols\else + \ifdim\dimen@>\@colroom + \dimen@\@colroom + \fi + \fi + \process@cols\mult@rightbox + {\@tempcnta\count@ + \advance\@tempcnta\@ne + \vfuzz\z@ + \setbox\count@\vbox to\dimen@ + {% + \vskip \z@ + \@plus-\multicolundershoot + \@minus-\multicolovershoot + \unvbox\@tempcnta + \ifshr@nking\vfilmaxdepth\fi + }% + \ifnum\badness>\@M + \vfuzz\maxdimen % no overfull warning + \setbox\@tempboxa \vbox to\dimen@ + {\vskip-\maxbalancingoverflow + \unvcopy\count@}% + \ifnum\badness>\@M + \mult@info\@ne + {Balanced column more than + \the\maxbalancingoverflow\space + too large}% + \too@badtrue + \else + \mult@info\@ne + {Balanced column + too large, but less than + \the\maxbalancingoverflow}% + \fi + \fi + }% + \fi +} +\newdimen\maxbalancingoverflow +\maxbalancingoverflow=12pt + +\newbox\mult@rightbox +\newbox\mult@grightbox +\newbox\mult@gfirstbox +\newbox\mult@firstbox +\newbox\@tempa\newbox\@tempa +\newbox\@tempa\newbox\@tempa +\newbox\@tempa\newbox\@tempa +\newbox\@tempa\newbox\@tempa +\newbox\@tempa\newbox\@tempa +\newbox\@tempa\newbox\@tempa +\newbox\@tempa\newbox\@tempa +\newbox\@tempa\newbox\@tempa +\newbox\@tempa +\let\@tempa\relax +\@ifundefined{emergencystretch} + {\newdimen\emergencystretch}{} +\def\setemergencystretch#1#2{% + \emergencystretch 4pt + \multiply\emergencystretch#1} + +\def\set@floatcmds{% + \let\@dblfloat\@dbflt + \def\end@dblfloat{\@endfloatbox + \@largefloatcheck + \outer@nobreak + \ifnum\@floatpenalty<\z@ + \@cons\@deferlist\@currbox + \fi + \ifnum\@floatpenalty=-\@Mii + \@Esphack + \fi}} +\def\kept@topmark{{}{}} +\let\kept@firstmark\@empty +\let\kept@botmark\@empty +\def\return@nonemptymark#1#2{% + \ifx#2\@empty + \else + \mult@info\tw@ + {Returned #1 mark:\MessageBreak + \meaning#2}% + \toks@\expandafter{#2}% + \mark{\the\toks@}% + \nobreak + \fi} +\def\get@keptmarks#1{% + \begingroup + \vbadness\@M + \setbox#1\copy#1% + \setbox#1\vsplit#1to\maxdimen + \set@keptmarks + \endgroup +} +\def\set@keptmarks{% + \ifx\kept@firstmark\@empty + \expandafter\gdef\expandafter + \kept@firstmark + \expandafter{\splitfirstmark}% + \ifx\kept@firstmark\@empty\else + \mult@info\tw@ + {Set kept first mark:\MessageBreak + \meaning\kept@firstmark% + \@gobbletwo}% + \fi + \fi + \expandafter\def\expandafter\@tempa + \expandafter{\splitbotmark}% + \ifx\@tempa\@empty\else + \global\let\kept@botmark\@tempa + \mult@info\tw@ + {Set kept bot mark:\MessageBreak + \meaning\kept@botmark% + \@gobbletwo}% + \fi}% +\def\prep@keptmarks{% + \if@boxedmulticols \else + \get@keptmarks\partial@page + \fi} +\skip0=0pt +\edef\the@zero@skip{\the\skip0} +\def\remove@discardable@items{% + \unpenalty + \edef\@tempa{\the\lastskip}% + \unskip + \ifx\@tempa\the@zero@skip + \edef\@tempb{\the\lastskip}% + \ifx\@tempb\the@zero@skip + \else + \unskip + \ifnum \lastpenalty=\@M + \vskip\@tempb\vskip\@tempa\relax + \else + \remove@discardable@items + \fi + \fi + \else + \remove@discardable@items + \fi +} +\newif\iftoo@bad +\def\too@badtrue{\global\let\iftoo@bad\iftrue} +\def\too@badfalse{\global\let\iftoo@bad\iffalse} +\newif\ifforcedbreak@leftover +\newcount\c@columnbadness +\c@columnbadness=10000 +\newcount\c@finalcolumnbadness +\c@finalcolumnbadness=9999 + +\newdimen\last@try + +\newdimen\multicolovershoot +\newdimen\multicolundershoot +\multicolovershoot=0pt +\multicolundershoot=2pt +\newbox\mult@nat@firstbox +\def\mult@info#1#2{% + \ifnum\c@tracingmulticols>#1% + \GenericWarning + {(multicol)\@spaces\@spaces}% + {Package multicol: #2}% + \fi +} + \@namedef{multicols*}{% + \ifinner + \PackageWarning{multicol}% + {multicols* inside a box does + not make sense.\MessageBreak + Going to balance anyway}% + \else + \let\balance@columns@out + \multi@column@out + \fi + \begin{multicols} +} +\@namedef{endmulticols*}{% + \par + \ifdim\lastskip>\z@ \vskip-\lastskip \fi + \ifdim \prevdepth>\z@ + \vskip-\ifdim\prevdepth>\boxmaxdepth + \boxmaxdepth + \else \prevdepth \fi + \fi + \ifshr@nking\else + \vfil + \fi + \end{multicols}} +\mathchardef\@Mv=10005 +\def\columnbreak{% + \ifnum\col@number<\tw@ + \PackageError{multicol}% + {\noexpand\columnbreak outside multicols}% + {This command can only be used within + a multicols or multicols* environment.}% + \else + \ifvmode + \penalty -\@Mv\relax + \else + \@bsphack + \vadjust{\penalty -\@Mv\relax}% + \@esphack + \fi + \fi} +\newbox\colbreak@box +\def\LR@column@boxes{% + \process@cols\mult@gfirstbox{% + \ifdim\dp\count@>\dimen\tw@ + \global\dimen\tw@\dp\count@ \fi + \mc@col@status@write + \box\count@ + \hss{\columnseprulecolor\vrule + \@width\columnseprule}\hss}% + \ifdim\dp\mult@rightbox>\dimen\tw@ + \global\dimen\tw@\dp\mult@rightbox \fi + \mc@lastcol@status@write + \box\mult@rightbox +} + +\def\RL@column@boxes{% + \process@cols\mult@gfirstbox{% + \hskip\hsize + \hss{\columnseprulecolor\vrule + \@width\columnseprule}\hss + }% + \hskip\hsize + \process@cols\mult@gfirstbox{% + \ifdim\dp\count@>\dimen\tw@ + \global\dimen\tw@\dp\count@ \fi + \hskip-\hsize + \mc@col@status@write + \box\count@ + \hskip-\hsize + \hskip-\columnsep + }% + \ifdim\dp\mult@rightbox>\dimen\tw@ + \global\dimen\tw@\dp\mult@rightbox \fi + \hskip-\hsize + \mc@lastcol@status@write + \box\mult@rightbox + \hskip-\hsize + \hskip\full@width + } +\newcommand\RLmulticolcolumns + {\let\mc@align@columns + \RL@column@boxes} +\newcommand\LRmulticolcolumns + {\let\mc@align@columns + \LR@column@boxes} +\LRmulticolcolumns +\newcount\mc@col@check@num + +\newcommand\docolaction[4][1]{% + \ifx\mc@col@status@write\relax + \PackageError{multicol}% + {Option 'colaction' not selected}% + {\string\docolaction\space + requires the use of the 'colaction' + option on the package}% + \fi + \global\advance\mc@col@check@num\@ne + \edef\mc@col@type{\expandafter\ifx + \csname mc@col-\the\mc@col@check@num + \endcsname\relax + 0\else + \csname mc@col-\the\mc@col@check@num + \endcsname + \fi}% + \ifcase \mc@col@type\relax + \ifcase #1\or #2\or#3\or#4\fi + \or + #2% % 1 First col + \or + #3% % 2 any middle col + \or + #4% % 3 last col + \else + \ERROR + \fi + \edef\next{\write\@auxout + {\string\mc@set@col@status + {mc@col-\the\mc@col@check@num}% + {\mc@col@type}}}% + \next +} +\def\mc@col@status#1{% + \gdef\mc@curr@col@status{#1}} +\def\mc@set@col@status#1#2{% + \global\expandafter\let\csname #1\endcsname + \mc@curr@col@status} +\AtEndDocument{\def\mc@set@col@status#1#2{% + \ifnum #2=\mc@curr@col@status\else + \@tempswatrue + \fi}% +} +\newif\ifmc@firstcol +\mc@firstcoltrue +\endinput +%% +%% End of file `multicol.sty'. diff --git a/macros/latex-dev/required/tools/multicol.dtx b/macros/latex-dev/required/tools/multicol.dtx new file mode 100644 index 0000000000..d68f471fcd --- /dev/null +++ b/macros/latex-dev/required/tools/multicol.dtx @@ -0,0 +1,4450 @@ +% \iffalse meta-comment +% +% +% This file is part of the Standard LaTeX `Tools Bundle'. +% ------------------------------------------------------- +% +% It may be distributed and/or modified under the +% conditions of the LaTeX Project Public License, either version 1.3c +% of this license or (at your option) any later version. +% The latest version of this license is in +% https://www.latex-project.org/lppl.txt +% and version 1.3c or later is part of all distributions of LaTeX +% version 2005/12/01 or later. +% +% The list of all files belonging to the LaTeX `Tools Bundle' is +% given in the file `manifest.txt'. +% +% \fi +% +% \iffalse This is a METACOMMENT +% +%% Package `multicol' to use with LaTeX2e +%% Copyright 1989-2019 Frank Mittelbach +%% +%% In addition to the terms of LPPL any distributed version +%% (unchanged or modified) of multicol has to keep the statement +%% about the moral obligation for using multicol. In case of major +%% changes where this would not be appropriate the author of the +%% changed version should contact the copyright holder. +%% +%% +%% Moral obligation for using multicol: +%% ------------------------------------ +%% +%% Users of multicol who wish to include or use multicol or a modified +%% version in a proprietary and commercially market product are asked +%% under certain conditions (see below) for the payment of a license +%% fee. The size of this fee is to be determined, in each instance, +%% by the commercial user, depending on his/her judgment of the value of +%% multicol for his/her product. +%% +%% +%% The conditions for this are as follows: +%% +%% The producer of a proprietary and commercially market product +%% that involves typesetting using multicol is asked to determine +%% the value of a license fee for using multicol if +%% +%% - the product is a document and the producer has decided to +%% include multicol to typeset (parts of) the document or has +%% directed the author of the document to include multicol (for +%% example, by providing a class file to be used by the author) +%% +%% - the product is a LaTeX class or package that includes multicol +%% +%% +%% There is no moral obligation in case +%% +%% - the product is a document but producer has not directed +%% the author to include multicol (in that case the moral obligation +%% lies with the author of the document) +%% +%% - the product does not involve typesetting, e.g., consists, for +%% example, of distributing multicol and its documentation. +%% +%% - the product is not proprietary, i.e., is made available as free +%% software itself (which doesn't prohibit its commercial marketing) +%% +%% - multicol is used for non-commercial purposes +%% +%% +%% Determining a license fee might result in a license fee of zero +%% (i.e., no payment) in case a producer has determined that the use +%% of multicol has no enhancing effect on the product. This is a +%% plausible scenario, i.e., in the above two cases the producer is +%% only asked to evaluate the value of multicol for the product +%% not for the payment of a license fee per se (which might or might +%% not follow from this evaluation). +%% +%% The license fee, if any, can be payed either to the LaTeX3 fund +%% (see ltx3info.txt in the base LaTeX distribution) or to the author of +%% the program who can be contacted at +%% +%% Frank.Mittelbach@latex-project.org +%% +%<*dtx> + \ProvidesFile{multicol.dtx} +%</dtx> +%<package>\NeedsTeXFormat{LaTeX2e}[2018-04-01] +%<package> +%<package>\providecommand\DeclareRelease[3]{} +%<package>\providecommand\DeclareCurrentRelease[2]{} +%<package> +%<package>\DeclareRelease{}{2017-04-11}{multicol-2017-04-11.sty} +%<package>\DeclareCurrentRelease{}{2018-04-01} +%<package> +%<package>\ProvidesPackage{multicol} +%<driver> \ProvidesFile{multicol.drv} +% \fi +% \ProvidesFile{multicol.dtx} + [2019/03/01 v1.8w multicolumn formatting (FMi)] +% +% +%% +% +% \changes{v1.5n}{1997/06/05}{Applied improvement of documentation, +% kindly done by Robin Fairbairns.} +% \changes{v1.4h}{1992/06/04}{Added mark tracing with +% tracingmulticols$\ge2$} +% \changes{v1.4a}{1992/02/11}{Added support for multicol in inner mode} +% \changes{v1.0d}{1989/05/17}{All lines shortened to 72 or less.} +% \changes{v1.0e}{1989/06/21}{Redefinition of description env. to use +% \cs{descriptionmargin}\quotechar=5pt +% in documentation.} +% \changes{v1.0f}{1989/07/11}{Changed \cs{z@} to 0pt in redefinition of +% description.} +% \changes{v1.1a}{1989/09/20}{\cs{multicolssep} changed to \cs{multicolsep}.} +% +% \def\description{\list{}{\labelwidth 0pt \leftmargin\descriptionmargin +% \itemindent-\leftmargin \let\makelabel\descriptionlabel}} +% \newdimen\descriptionmargin \descriptionmargin=5pt +% +% \DoNotIndex{\@M,\@Mi,\@bsphack,\@cclv,\@colht,\@currlist,\@deferlist} +% \DoNotIndex{\@elt,\@esphack,\@floatplacement} +% \DoNotIndex{\@ifundefined,\@ifnextchar,\@makecol} +% \DoNotIndex{\@ne,\@outputpage,\@scolelt,\@spaces,\@tempb,\@tempcnta} +% \DoNotIndex{\@width} +% \DoNotIndex{\addvspace,\advance,\allowbreak} +% \DoNotIndex{\baselineskip,\begingroup,\box,\columnsep,\copy,\count} +% \DoNotIndex{\count@,\def,\dimen@,\divide,\docdate} +% \DoNotIndex{\edef,\eject,\egroup,\else,\endgroup,\endinput} +% \DoNotIndex{\fi,\fileversion,\filedate} +% \DoNotIndex{\gdef,\global} +% \DoNotIndex{\hbox,\hfil,\hrule,\ht,\hss} +% \DoNotIndex{\ifdim,\ifnum,\ifvoid,\ignorespaces,\insert,\immediate} +% \DoNotIndex{\let,\loop} +% \DoNotIndex{\maxdepth,\message,\multiply} +% \DoNotIndex{\newbox,\newcount,\newdimen,\newskip,\number,\newpage} +% \DoNotIndex{\outputpenalty,\p@,\penalty} +% \DoNotIndex{\relax,\repeat,\setbox,\skip,\space,\splitmaxdepth} +% \DoNotIndex{\splittopskip,\string,\sixt@@n} +% \DoNotIndex{\the,\thepage,\thr@@,\topskip,\tw@,\typeout} +% \DoNotIndex{\unvbox,\vbox,\vfill,\vsplit,\voidb@x,\vrule} +% \DoNotIndex{\write,\wd} +% \DoNotIndex{\z@} +% +% \MakeShortVerb{\|} +% \newcommand{\mc}{\textsf{multicols}} +% \newcommand{\TUB}{{\sl TUGboat\/}} +% \newcommand{\TB}{{\sl\TeX book\/}} +% +% +% \setcounter{StandardModuleDepth}{2} +% \setcounter{collectmore}{3} +% +% \GetFileInfo{multicol.dtx} +% \title{An environment for multicolumn output\thanks{This file +% has version number \fileversion, last +% revised \filedate.}% +% \thanks{Note: This package is released under terms which affect +% its use in commercial applications. Please see the details at +% the top of the source file.}} +% \author{Frank Mittelbach\\ +% {\rm Email:} see top of the source file} +% \date{Printed \today} +% +% \MaintainedByLaTeXTeam{tools} +% \maketitle +% +% \begin{abstract} +% This article describes the use and the implementation of the \mc{} +% environment. This environment allows switching between +% one and multicolumn format on the same page. Footnotes are handled +% correctly (for the most part), but will be placed at the bottom of +% the page and not under each column. \LaTeX{}'s float mechanism, +% however, is partly disabled in this implementation. At the +% moment only page-wide floats (i.e., star-forms) can be used within +% the scope of the environment. +% \end{abstract} +% +% \begin{multicols}{3}[\section*{Preface to version 1.8}] +% The 1.8 release improves on the balancing approach. If due to a +% limited number of break points (e.g., due to large objects) the +% balanced columns exceed the available vertical space, then +% balancing is canceled and a normal page is produced first. Some +% overflow is allowed (controlled by the parameter +% |\maxbalancingoverflow| which defaults to 12pt). This ensures +% that we only cut a normal page if we get enough material carried +% over to next page. +% +% Also added was support for |\enlargethispage|. This means it is +% now possible to request a page to be artificially enlarged or +% shortened. Note that if you enlarge pages by more than one line +% you may have to increase the \textsf{collectmore} counter value to +% ensure that enough material is being picked up. +% +% This command was used on the second page of this manual to shorten +% it by one line, in order to get rid of a number of widow lines on +% the following pages. +% +% There are also some small enhancements to the balancing algorithm +% including a ways to require a minimum number of rows in the result. +% +% Finally, version 1.8 adds the command |\docolaction| to help with +% more complicated actions that depend on the current column. This +% command expects 3 arguments: code that is executed if we are in +% the ``first'' column, code to execute if we end up in any +% ``middle'' column (if there are more than two) and finally code to +% execute if we are in the ``last'' column. Thus +%\begin{verbatim} +% \docolaction{first} +% {middle}{last} +%\end{verbatim} +% would typeset a different word depending the type of column this +% code is executed. Using it like this is probably pointless, but +% you can imagine applications like writing something into the +% nearest margin, etc. +% +% As this feature needs at least two \LaTeX{} runs to produce correct +% results and as it adds to the processing complexity it is only +% made available if one add the option \texttt{colaction} when +% loading the package. +% +% \end{multicols} +% +% +% \begin{multicols}{3}[\section*{Preface to version 1.7 +% (right to left support)}] +% The 1.7 release adds support for languages that are typeset +% right-to-left. For those languages the order of the columns on the page +% also need to be reversed---something that wasn't supported before. The next +% paragraph demonstrates the result (as it is typeset as if we are writing +% in a left-to-right language--- so read the rightmost column +% first). The change is initialized via +% |\RLmulticolcolumns| and returning to left-right (default) +% is done via |\LRmulticolcolumns|. +% \end{multicols} +% +% \RLmulticolcolumns +% +% \begin{multicols}{3} +% Right-to-left typesetting will only reverse the column orders. Any +% other support needed will have to be provided by other means, +% e.g., using appropriate fonts and reversing the writing directions +% within the columns. As footnotes are typeset in full measure the +% footnote rule needs to be redefined as if they are below a single +% column, i.e., using |\textwidth| not |\columnwidth|. For example: +%\begin{verbatim} +%\renewcommand \footnoterule{% +% \kern-3pt\hbox to\textwidth +% {\hskip .6\textwidth +% \hrulefill }% +% \kern2.6pt} +%\end{verbatim} +% \end{multicols} +% +% \LRmulticolcolumns +% +% \begin{multicols}{3}[\section*{Preface to version 1.5 + 1.6}] +% \hbadness=10000 +% The 1.5 release contains two major changes: \mc{} will now +% support up to 10 columns and two more tuning possibilities have +% been added to the balancing routine. The balancing routine now +% checks the badness +% of the resulting columns and rejects solutions that are larger +% than a certain threshold. +% At the same time \mc{} has been upgraded to run under \LaTeXe{}. +% +% Later changes to 1.5 include |\columnbreak| and |multicols*|. +% +% For version 1.6 micro-spacing around the boxes produced by \mc{} +% has been improved to allow for baseline-grid typesetting. +% \end{multicols} +% +% +% \setcounter{collectmore}{2} +% \begin{multicols}{3}[\section{Introduction}] +% \hbadness=10000 +% Switching between two-column and one-column layout is possible in +% \LaTeX{}, but every use of |\twocolumn| or |\onecolumn| +% starts a new page. Moreover, the last page of two-column output +% isn't balanced and this often results in an empty, or nearly +% empty, right column. When I started to write macros for +% \textsf{doc.sty} (see ``The \texttt{doc}--Option'', \TUB\ +% volume 10~\#2, pp.~245--273) I thought that it would be nice to +% place the index +% on the same page as the bibliography. And balancing the last page +% would not only look better, it also would save space; provided of +% course that it is also possible to start the next article on the +% same page. Rewriting the index environment was comparatively easy, +% but the next goal, designing an environment which takes care of +% footnotes, floats, etc., was a harder task. It took me a whole +% weekend\footnote{I started with the algorithm given in the \TeX +% book on page 417. Without this help a weekend would not have been +% enough. (This remark was made in the documentation of the initial +% release, since then several hundreds more hours went into +% improving the original code.)} to get together the few lines of +% code below and there is +% still a good chance that I missed something after all. +% +% Try it and, hopefully, enjoy it; and {\em please\/} direct bug +% reports and suggestions back to Mainz. +% \end{multicols} +% +% +% \setcounter{collectmore}{0} +% \begin{multicols}{3}[\section{The User Interface}] +% \hbadness=10000 +% To use the environment one simply says\\*[2mm] +% \hspace*{2mm}|\begin{multicols}{|\meta{number}|}| +% \hspace*{12mm}\meta{multicolumn text}\\ +% \hspace*{2mm}|\end{multicols}|\\[2mm] +% where \meta{number} is the required number of columns and +%^^A\meta{multicolumn text} +% $\langle${\it multi\-column text\/}$\rangle$ may contain arbitrary +% \LaTeX{} commands, except that floats and marginpars are not +% allowed in the current implementation\footnote{This is dictated by +% lack of time. To implement floats one has to reimplement the +% whole \LaTeX{} output routine.}. +% +% \enlargethispage{-1\baselineskip} +% +% \DescribeMacro\premulticols +% As its first action, the \textsf{multicols} environment measures the +% current page to determine whether there is enough room for some +% portion of multicolumn output. This is controlled by the +% \meta{dimen} variable |\premulticols| which can be changed by +% the user with ordinary \LaTeX{} commands. +% \DescribeMacro\multicolsep +% If the space is less than |\premulticols|, a new page is +% started. Otherwise, a |\vskip| of |\multicolsep| is +% added.\footnote{Actually the added space may be less because we use +% \cs{addvspace} (see the \LaTeX{} manual for further +% information about this command).} +% +% \DescribeMacro\postmulticols +% When the end of the \mc{} environment is encountered, an +% analogous mechanism is employed, but now we test whether there is a +% space larger than |\postmulticols| available. Again we add +% |\multicolsep| or start a new page. +% +% It is often convenient to spread some text over all columns, just +% before the multicolumn output, without any page break in between. To +% achieve this the \mc{} environment has an optional second +% argument which can be used for this purpose. For example, the text +% you are now reading was started with +% \begin{verbatim} +% \begin{multicols}{3} +% [\section{The User +% Interface}] ... +%\end{verbatim} +% If such text is unusually long (or short) the value of +% |\premulticols| might need adjusting to prevent a bad page +% break. We therefore provide a third argument which can be used to +% overwrite the default value of |\premulticols| just for this +% occasion. So if you want to combine some longer single column text +% with a multicols environment you could write +% \begin{verbatim} +% \begin{multicols}{3} +% [\section{Index} +% This index contains ...] +% [6cm] +% ... +%\end{verbatim} +% +% +% \DescribeMacro\columnsep +% The space between columns is controlled by the length parameter +% |\columnsep|. The width for the individual columns is automatically +% calculated from this parameter and the current |\linewidth|. In this +% article a value of \textsf{\the\columnsep} was used. +% +% +% \DescribeMacro\columnseprule +% Separation of columns with vertical rules is achieved by setting the +% parameter |\columnseprule| to some positive value. In this +% article a value of \textsf{.4pt} was used. +% +% \DescribeMacro\columnseprulecolor +% The color of the rules separating the columns can be specified through +% |\columnseprulecolor|. The default value is |\normalcolor|. +% +% \DescribeMacro\multicolbaselineskip +% Since narrow columns tend to need adjustments in interline spacing +% we also provide a \meta{skip} parameter called +% |\multicolbaselineskip| which is added to the +% |\baselineskip| parameter inside the \mc{} +% environment. Please use this parameter with care or leave it alone; +% it is intended only for package file designers since even small +% changes might produce totally unexpected changes to your document. +% +% +% \subsection{Balancing columns} +% +% +% Besides the previously mentioned parameters, some others are +% provided to influence the layout of the columns generated. +% +% Paragraphing in \TeX{} is controlled by several parameters. One of +% the most important is called |\tolerance|: this controls the +% allowed `looseness' (i.e.\ the amount of blank space between words). +% Its default value is 200 (the \LaTeX{} |\fussy|) which is too +% small for narrow columns. On the other hand the |\sloppy| +% declaration (which sets |\tolerance| to $10000=\infty$) is too +% large, allowing really bad spacing.\footnote{Look at the next +% paragraph, it was set with the \cs{sloppy} declaration.} +% +% \begin{sloppypar} +% \DescribeMacro\multicoltolerance \DescribeMacro\multicolpretolerance +% We therefore use a |\multicoltolerance| parameter for the +% |\tolerance| value inside the \mc{} environment. Its default value +% is 9999 which is less than infinity but `bad' enough for most +% paragraphs in a multicolumn environment. Changing its value should +% be done outside the \mc{} environment. Since |\tolerance| is set +% to |\multicoltolerance| at the beginning of every \textsf{multicols} +% environment one can locally overwrite this default by assigning +% \verb*+\tolerance = +\meta{desired value}. There also exists a +% |\multicolpretolerance| parameter holding the value for +% |\pretolerance| within a \mc{} environment. Both parameters are +% usually used only by package designers. +% \end{sloppypar} +% +% Generation of multicolumn output can be divided into two parts. In +% the first part we are collecting material for a page, shipping it +% out, collecting material for the next page, and so on. As a second +% step, balancing will be done when the end of the \mc{} environment +% is reached. +% In the first step \TeX{} might consider more material whilst +% finding the final column content than it actually uses when shipping out the +% page. This might cause a problem if a footnote is encountered in +% the part of the input considered, but not used, on the current page. +% In this case the footnote might show up on the current page, while the +% footnotemark corresponding to this footnote might be set on the next +% one.\footnote{The reason behind this behavior is the asynchronous +% character of the \TeX{} {\it page\_builder}. +% However, this +% could be avoided by defining very complicated output +% routines which don't use \TeX{} primitives like +% \cs{insert} but do everything by hand. +% This is clearly beyond the scope of a weekend problem.} +% Therefore the \mc{} environment gives a warning +% message\footnote{This message will be generated even if there are no +% footnotes in this part of the text.} whenever it is unable to use +% all the material considered so far. +% +% If you don't use footnotes too often the chances of something +% actually going wrong are very slim, but if this happens you can help +% \TeX{} by using a |\pagebreak| command in the final document. +% Another way to influence the behavior of \TeX{} in this respect is +% given by the counter variable `\textsf{collectmore}'. If you use the +% |\setcounter| declaration to set this counter to \meta{number}, +% \TeX{} will consider \meta{number} more (or less) lines before +% making its final decision. So a value of $-1$ may solve all your +% problems at the cost of slightly less optimal columns. +% +% +% In the second step (balancing columns) we have other bells and +% whistles. First of all you can say |\raggedcolumns| if you +% don't want the bottom lines to be aligned. +% The default is |\flushcolumns|, so \TeX{} will normally try to +% make both +% the top and bottom baselines of all columns align. +% +% If there is only a small amount of material available for balancing +% then you may end up with very few lines per column. In an extreme +% case there may be only one line which looks distinctly odd. In that +% case it might be better to have more material distributed to the +% earlier columns even if that means that later columns are empty or +% partially empty. This is controlled through the counter +% `\textsf{minrows}' (default 1). If set to a higher value then the +% balancing will have at least that many rows in the first column (and +% also all further columns until it runs outs of material). +% +% Additionally you can set another counter, the `\textsf{unbalance}' +% counter, to some positive \meta{number}. This will make all but the +% right-most column \meta{number} of lines longer than they would +% normally have been. `Lines' in this context refer to normal text +% lines (i.e.\ one |\baselineskip| apart); thus, if your columns +% contain displays, +% for example, you may need a higher \meta{number} +% to shift something from one column into another. A negative value can make sense if +% you have set \textsf{minrows} and want to locally adjust that. +% +% Unlike `\textsf{collectmore},' the `\textsf{unbalance}' counter is reset +% to zero at the end of the environment so it only applies to one +% \mc{} environment. +% +% The two methods may be combined but I suggest using these features +% only when fine tuning important publications. +% +% Two more general tuning possibilities were added with version~1.5. +% \TeX{} allows to measure the badness of a column in terms of an +% integer value, where 0 means optimal and any higher value means a +% certain amount of extra white space. 10000 is considered to be +% infinitely bad (\TeX{} does not distinguish any further). In addition +% the special value 100000 means overfull (i.e., the column contains +% more text than could possibly fit into it). +% +% The new release now measures every generated column and ignores +% solutions where at least one column has a badness being larger than +% the value of the counter \textsf{columnbadness}. The default value for +% this counter is 10000, thus \TeX{} will accept all solutions except +% those being overfull. +% By setting the counter to a smaller value you can force the algorithm +% to search for solutions that do not have columns with a lot of white +% space. +% +% However, if the setting is too low, the algorithm may not find any +% acceptable solution at all and will then finally choose the extreme +% solution of placing all text into the first column. +% +% Often, when columns are balanced, it is impossible to find a solution +% that distributes the text evenly over all columns. If that is the case +% the last column usually has less text than the others. In the earlier +% releases this text was stretched to produce a column with the same +% height as all others, sometimes resulting in really ugly looking +% columns. +% +% In the new release this stretching is only done if the badness of +% the final column is not larger than the value of the counter +% \textsf{finalcolumnbadness}. The default setting is 9999, thus preventing +% the stretching for all columns that \TeX{} would consider infinitely +% bad. In that case the final column is allowed to run short which gives +% a much better result. +% +% And there are two more parameters of some experimental nature, one +% called |\multicolovershoot| the other |\multicolundershoot|. They +% control the amount of space a column within the \mc{} environment is +% allowed to be ``too full'' or ``too short'' without affecting the +% column badness. They are set to 0pt and 2pt, respectively. +% +% Finally, when doing the balancing at the end, columns may become +% higher than the remaining available space. In that case the +% algorithm aborts and instead generates a normal page. However, if the +% amount is not too large, e.g., a line or so, then it might be better to +% keep everything on the same page instead of starting a new page with +% just one line after balancing. So the parameter +% |\maxbalancingoverflow| governs this process: only when the excess +% gets larger than its value balancing is aborted. +% +% \subsection{Not balancing the columns} +% +% Although this package was written to solve the problem of balancing +% columns, I got repeated requests to provide a version where all +% white space is automatically placed in the last column or +% columns. Since version v1.5q this now exists: if you use +% \texttt{multicols*} instead of the usual environment the columns on +% the last page are not balanced. Of course, this environment only +% works on top-level, e.g., inside a box one has to balance to +% determine a column height in absence of a fixed value. +% +% +% \subsection{Manually breaking columns} +% +% Another request often voiced was: ``How do I tell \LaTeX{} that it +% should break the first column after this particular line?''. The +% |\pagebreak| command (which works with the two-column option of +% \LaTeX{}) is of no use here since it would end the collection phase +% of \mc{} and thus all columns on that page. So with version 1.5u +% the |\columnbreak| command was added. If used within a paragraph it +% marks the end of the current line as the desired breakpoint. You can +% observe its effect on +% the previous page where three lines of text have been artificially +% forced into the second column (resulting in some white +% space between paragraphs in the first column). +% +% \subsection{Floats inside a \mc{} environment} +% +% Within the \mc{} environment the usual star float commands are +% available but their function is somewhat different as in the +% two-column mode of standard \LaTeX. Stared floats, e.g., +% \texttt{figure*}, denote page wide floats that are handled in a similar +% fashion as normal floats outside the \mc{} environment. However, +% they will never show up on the page where they are encountered. In +% other words, one can influence their placement by specifying a +% combination of \texttt{t}, \texttt{b}, and/or \texttt{p} in their optional +% argument, but \texttt{h} doesn't work because the first possible place +% is the top of the next page. One should also note, that this means +% that their placement behavior is determined by the values of +% |\topfraction|, etc.\ rather than by |\dbl...|. +% +% +% \subsection{Support for right-to-left typesetting} +% +% In right-to-left typesetting the order of the columns on the page +% also need to be reversed, i.e., the first column has to appear on the far +% right and the last column on the left. This is supported through the +% commands |\RLmulticolcolumns| (switching to right-to-left typesetting) +% and |\LRmulticolcolumns| (switching to left-to-right typesetting) the +% latter being the default. +% +% \subsection{Warnings} +% +% Under certain circumstances the use of the \mc{} environment may +% result in some +% warnings from \TeX{} or \LaTeX{}. Here is a list +% of the important ones and the possible cause: +% \begin{description} +% +% \item[] {\hspace*{-\labelsep}\tt Underfull \string\hbox\space +% (badness ...)} +% +% As the columns are often very narrow \TeX{} wasn't able to find a +% good way to break the paragraph. Underfull denotes a loose line but +% as long as the badness value is below $10000$ the result is probably +% acceptable. +% +% \item[] +% {\hspace*{-\labelsep}\tt Underfull \string\vbox\space ... while +% \string\output\space is active} +% +% If a column contains a character with an unusual depth, for +% example a `(', in the bottom line then this message may show up. It +% usually has no significance as long as the value is not more than a +% few points. +% +% \item[] {\hspace*{-\labelsep}\tt LaTeX Warning: I moved some lines +% to the next page} +% +% As mentioned above, \mc{} sometimes screws up the footnote +% numbering. As a precaution, whenever there is a footnote on a +% page where \mc{} had to leave a remainder for the following +% page this warning appears. Check the footnote numbering on this +% page. If it turns out that it is wrong, you have to manually break +% the page using |\newpage| or |\pagebreak[..]|. +% +% \item[] {\hspace*{-\labelsep}\tt Floats and marginpars not allowed +% inside `multicols' environment!} +% +% This message appears if you try to use the |\marginpar| command or +% an unstarred version of the \textsf{figure} or \textsf{table} environment. +% Such floats will disappear! +% +% \item[] {\hspace*{-\labelsep}\tt Very deep columns! +% Grid alignment might be broken} +% +% This message can only appear if the option \texttt{grid} was +% chosen. In that case it will show up if a column has a very large +% depth so that \mc{} is unable to back up to its baseline. This +% is only relevant if one tries to produce a document where all +% text lines are aligned at an invisible grid, something that +% requires careful adjustment of many parameters and macros, e.g., +% heading definitions. +% +% \end{description} +% +% +% \subsection{Tracing the output} +% +% To understand the reasoning behind the decisions \TeX{} makes when +% processing a \mc{} environment, a tracing mechanism is provided. +% If you set the counter `\texttt{tracingmulticols}' +% to a positive \meta{number} you then +% will get some tracing information on the terminal and in the +% transcript file: +% \begin{description} +% \item[$\meta{number}=1$.] \TeX{} will now tell you, whenever it +% enters or leaves a \mc{} environment, the number of columns it +% is working on and its decision about starting a new page before +% or after the environment. +% \item[$\meta{number}=2$.] +% In this case you also get information from the balancing routine: +% the heights tried for the left and right-most columns, +% information about shrinking if the |\raggedcolumns| +% declaration is in force and the value of the `\textsf{unbalance}' +% counter if positive. +% \item[$\meta{number}= 3$.] Setting \meta{number}\pagebreak[2] to +% this value will additionally trace the mark handling +% algorithm. It will show what marks are found, what marks are +% considered, etc. To fully understand this information you will +% probably have to read carefully trough the implementation. +% \item[$\meta{number}\geq 4$.] Setting \meta{number}\pagebreak[2] to +% such a high value will additionally place an |\hrule| into your +% output, separating the part of text which had already been +% considered on the previous page from the rest. Clearly this +% setting should {\em not\/} be used for the final output. It will +% also activate even more debugging code for mark handling. +% \end{description} +% +% +% \end{multicols} +% +% \begin{multicols}{3}[\section{Prefaces to older versions} +% \subsection{Preface to version 1.4}] +% \hbadness=10000 +% Beside fixing some bugs as mentioned in the \textsf{multicol.bug} file +% this new release enhances the \mc{} environment by allowing for +% balancing in arbitrary contexts. It is now, for example, possible +% to balance text within a \mc{} or a \textsf{minipage} as shown in +% \ref{tab:newcmds} where a \textsf{multicols} environment within a +% \textsf{quote} environment was used. It is now even possible to nest +% \mc{} environments. +% +% The only restriction to such inner \mc{} environments (nested, or +% within \TeX's internal vertical mode) is that such variants will +% produce a box with the balanced material in it, so that they can +% not be broken across pages or columns. +% +% Additionally I rewrote the algorithm for balancing so that it will +% now produce slightly better results. +% +% I updated the source documentation but like to apologize in +% advance for some `left over' parts that slipped through the +% revision. +% +% A note to people who like to improve the balancing algorithm of +% \mc{}: The balancing routine is now placed into a single macro +% which is called |\balance@columns|. This means that one can easily +% try different balancing routines by rewriting this macro. The +% interface for it is explained in table \ref{tab:balance}. There are +% several improvements possible, one can think of integrating the +% |\badness| function of \TeX3, define a faster algorithm for finding +% the right column height, etc. If somebody thinks he/she has an +% enhancement I would be pleased to learn about it. But please obey +% the copyright notice and don't change \textsf{multicol.dtx} directly! +% \begin{table*} +% \begin{quote} +% \begin{multicols}{2} +% \raggedcolumns +% The macro |\balance@columns| that contains the code for balancing +% gathered material is a macro without parameters. It assumes that +% the material for balancing is stored in the box |\mult@box| which +% is a |\vbox|. It also ``knows'' about all parameters set up by the +% \mc{} environment, like |\col@number|, etc. It can also assume +% that |\@colroom| is the still available space on the current page. +% +% When it finishes it must return the individual columns in boxes +% suitable for further processing with |\page@sofar|. This means +% that the left column should be stored in box register +% |\mult@gfirstbox|, the next +% in register |\mult@firstbox|${}+2$, \ldots, +% only the last one as an exception in +% register |\mult@grightbox|. Furthermore it has to set up +% the two macros +% |\kept@firstmark| and |\kept@botmark| to hold the values for the +% first and bottom mark as found in the individual columns. There +% are some helper functions defined in section \ref{sec:v14} which +% may be used for this. Getting the marks right ``by hand'' is +% non-trivial and it may pay off to first take a look at the +% documentation and implementation of |\balance@columns| below +% before trying anew. +% \end{multicols} +% \end{quote} +% \vspace*{-3ex} +% \vspace*{-0ex} +% \caption{Interface description for \cs{balance@columns}} +% \label{tab:balance} +% \end{table*} +% \end{multicols} +% +% \begin{multicols}{3}[\subsection{Preface to version 1.2}] +% \hbadness=10000 +% After the article about the \mc{} environment was published in +% \TUB\ 10\#3, I got numerous requests for these macros. However, I +% also got a changed version of my style file, together with a +% letter asking me if I would include the changes to get better +% paragraphing results in the case of narrow lines. The main +% differences to my original style option were additional parameters +% (like |\multicoladjdemerits| to be used for |\adjdemerits|, etc.) +% which would influence the line breaking algorithm. +% +% But actually resetting such parameters to zero or even worse to a +% negative value won't give better line breaks inside the \mc{} +% environment. \TeX{}s line breaking algorithm will only look at +% those possible line breaks which can be reached without a badness +% higher than the current value of |\tolerance| (or |\pretolerance| +% in the first pass). If this isn't possible, then, as a last +% resort, \TeX{} will produce overfull boxes. All those (and only +% those) possible break points will be considered and finally the +% sequence which results in the fewest demerits will be chosen. This +% means that a value of $-1000$ for |\adjdemerits| instructs \TeX{} +% to prefer visibly incompatible lines instead of producing better +% line breaks. +% +% However, with \TeX{} 3.0 it is possible to get decent line breaks +% even in small columns by setting |\emergencystretch| to an +% appropriate value. I implemented a version which is capable of +% running both in the old and the new \TeX{} (actually it will +% simply ignore the new feature if it is not available). The +% calculation of |\emergencystretch| is probably incorrect. I +% made a few tests but of course one has to have much more experience +% with the new possibilities to achieve the maximum quality. +% +% Version 1.1a had a nice `feature': the penalty for using the +% forbidden floats was their ultimate removal from \LaTeX{}s +% |\@freelist| so that after a few |\marginpar|s inside the \mc{} +% environment floats where disabled forever. (Thanks to Chris +% Rowley for pointing this out.) I removed this misbehavior and at +% the same time decided to allow at least floats spanning all +% columns, e.g., generated by the |figure*| environment. You can +% see the new functionality in table~\ref{tab:newcmds} which was +% inserted at this very point. +% \begin{table*} +% \small +% \setlength{\multicolsep}{0pt} +% \begin{quote} +% \begin{multicols}{2} +% |\setemergencystretch|: This is a hook for people who like +% to play around. It is supposed to set the +% |\emergencystretch| \meta{dimen} register provided in the +% new \TeX{} 3.0. The first argument is the number of columns and +% the second one is the current |\hsize|. At the moment the +% default definition is $4\texttt{pt} \times |#1|$, i.e.\ the +% |\hsize| isn't used at all. But maybe there are better +% formulae. +% +% \setlength{\emergencystretch}{20pt} |\set@floatcmds|: This is +% the hook for the experts who like to implement a full float +% mechanism for the \mc{} environment. The |@| in the name +% should signal that this might not be easy. +% \end{multicols} +% \end{quote} +% \vspace*{-1ex} +% \vspace*{-0ex} +% \caption[]{The new commands of \textsf{multicol.sty} version 1.2. +% Both commands might be removed if good solutions to these +% open problems are found. I hope that these commands will +% prevent that nearly identical style files derived from +% this one are floating around.} +% \label{tab:newcmds} +% \end{table*} +% However single column floats are still forbidden and I don't think +% I will have time to tackle this problem in the near future. As an +% advice for all who want to try: wait for \TeX{} 3.0. It has a few +% features which will make life much easier in multi-column +% surroundings. Nevertheless we are working here at the edge of +% \TeX{}s capabilities, really perfect solutions would need a +% different approach than it was done in \TeX{}s page builder. +% +% The text below is nearly unchanged, I only added documentation at +% places where new code was added. +% \end{multicols} +% +% \changes{v1.5l}{1996/01/13}{Try hard to explain unresolved reference +% that happens if \cs{OnlyDescription} is used} +% +% \StopEventually{\PrintIndex \PrintChanges +% \ifx\Finale\relax +% \typeout{**********************************} +% \typeout{* Info: Typesetting this document with +% \protect\OnlyDescription\space will} +% \typeout{* Info: result in one unresolved +% reference to `sec:v14'.} +% \typeout{* Info: --- tough, it's just not there in this case!} +% \typeout{**********************************} +% \fi +% } +% +% +% \begin{multicols}{2}[\section{The Implementation} +% We are now switching to two-column output to show the +% abilities of this environment (and bad layout decisions). +% \subsection{The documentation driver file} +% ][10\baselineskip] +% +% \hbadness=10000 +% +% +% The next bit of code contains the documentation driver file for +% \TeX{}, i.e., the file that will produce the documentation you are +% currently reading. It will be extracted from this file by the \texttt{docstrip} program. +% Since this is the first code in this file one can produce the +% documentation +% simply by running \LaTeX{} on the \texttt{.dtx} file. +% \begin{macrocode} +%<*driver> +\documentclass{ltxdoc} +% \end{macrocode} +% We use the \texttt{balancingshow} option when loading \mc{} so +% that full tracing is produced. This has to be done before the +% \texttt{doc} package is loaded, since \texttt{doc} otherwise +% requires \mc{} without any options. +% \begin{macrocode} +\usepackage{multicol}[1999/05/25] +\usepackage{doc} +% \end{macrocode} +% First we set up the page layout suitable for +% this article. +% \begin{macrocode} +\setlength{\textwidth}{39pc} +\setlength{\textheight}{54pc} +\setlength{\parindent}{1em} +\setlength{\parskip}{0pt plus 1pt} +\setlength{\oddsidemargin}{0pc} +\setlength{\marginparwidth}{0pc} +\setlength{\topmargin}{-2.5pc} +\setlength{\headsep}{20pt} +\setlength{\columnsep}{1.5pc} +% \end{macrocode} +% We want a rule between columns. +% \begin{macrocode} +\setlength\columnseprule{.4pt} +% \end{macrocode} +% We also want to ensure that a new \mc{} environment finds enough +% space at the bottom of the page. +% \begin{macrocode} +\setlength\premulticols{6\baselineskip} +% \end{macrocode} +% When balancing columns we disregard solutions that +% are too bad. Also, if the last column is too bad +% we typeset it without stretch. +% \begin{macrocode} +\setcounter{columnbadness}{7000} +\setcounter{finalcolumnbadness}{7000} +% \end{macrocode} +% The index is supposed to come out in four columns. +% And we don't show macro names in the margin. +% \begin{macrocode} +\setcounter{IndexColumns}{4} +\let\DescribeMacro\SpecialUsageIndex +\let\DescribeEnv\SpecialEnvIndex +\renewcommand\PrintMacroName[1]{} +\CodelineIndex +%\DisableCrossrefs % Partial index +\RecordChanges % Change log +% \end{macrocode} +% Line numbers are very small for this article. +% \begin{macrocode} +\renewcommand{\theCodelineNo} + {\scriptsize\rm\arabic{CodelineNo}} +\settowidth\MacroIndent{\scriptsize\rm 00\ } + +\begin{document} + \typeout + {**************************************** + ^^J* Expect some Under- and overfull boxes. + ^^J****************************************} + \DocInput{multicol.dtx} +\end{document} +%</driver> +% \end{macrocode} +% +% +% \end{multicols} +% +% \begin{multicols}{2}[\subsection{Identification and +% option processing}] +% +% +% We start by identifying the package. Since it makes use of features +% only available in \LaTeXe{} we ensure that this format is available. +% (Now this is done earlier in the file.) +% \begin{macrocode} +%<*package> +% \NeedsTeXFormat{LaTeX2e} +% \ProvidesPackage{multicol}[..../../.. +% v... multicolumn formatting] +% \end{macrocode} +% +%^^A \subsection{Option processing} +% +% Next we declare options supported by \mc{}. Two-column mode +% and \mc{} do not work together so we warn about possible +% problems. However, since you can revert to |\onecolumn| +% in which case \mc{} does work, we don't make this an error. +% \begin{macrocode} +\DeclareOption{twocolumn} + {\PackageWarning{multicol}{May not work + with the twocolumn option}} +% \end{macrocode} +% Tracing is done using a counter. However +% it is also possible to invoke the tracing +% using the options declared below. +% \begin{macrocode} +\newcount\c@tracingmulticols +\DeclareOption{errorshow} + {\c@tracingmulticols\z@} +\DeclareOption{infoshow} + {\c@tracingmulticols\@ne} +\DeclareOption{balancingshow} + {\c@tracingmulticols\tw@} +\DeclareOption{markshow} + {\c@tracingmulticols\thr@@} +\DeclareOption{debugshow} + {\c@tracingmulticols5\relax} +% \end{macrocode} +% The next option is intended for typesetting on a |\baselineskip| +% grid. Right now it doesn't do anything other than warning if it +% thinks that the grid got lost. +% \changes{v1.6a}{2003/03/15}{New option grid} +% \begin{macrocode} +\let\mc@gridwarn\maxdimen +\DeclareOption{grid}{\def\mc@gridwarn{\maxdepth}} +% \end{macrocode} +% +% \changes{v1.8e}{2014/04/23}{Support \cs{docolaction}} +% Next option enables the |\docolaction| command. As this changes +% the \texttt{.aux} file content this is not automatically enabled. +% \begin{macrocode} +\DeclareOption{colaction}{% + \def\mc@col@status@write{% + \protected@write\@auxout{}% + {\string\mc@col@status + {\ifmc@firstcol 1\else 2\fi}}% + \mc@firstcolfalse}% + \def\mc@lastcol@status@write{% + \protected@write\@auxout{}% + {\string\mc@col@status{3}}}% +} +\let\mc@col@status@write\relax +\let\mc@lastcol@status@write\relax +% \end{macrocode} +% +% \begin{macrocode} +\ProcessOptions +% \end{macrocode} +% +% +% \end{multicols} +% +% \begin{multicols}{2}[\subsection{Starting and +% Ending the \mc{} Environment}] +% +% \begin{macro}{\multicols} +% As mentioned before, the \mc{} environment has one mandatory +% argument (the number of columns) and up to two optional ones. We +% start by reading the number of columns into the |\col@number| +% register. +% \begin{macrocode} +\def\multicols#1{\col@number#1\relax +% \end{macrocode} +% If the user forgot the argument, \TeX{} will complain about a +% missing number at this point. The error recovery mechanism will +% then use zero, which isn't a good choice in this case. So we +% should now test whether everything is okay. The minimum is two +% columns at the moment. +% \changes{v1.3b}{1990/10/09}{Minimum of two columns} +% \begin{macrocode} + \ifnum\col@number<\tw@ + \PackageWarning{multicol}% + {Using `\number\col@number' + columns doesn't seem a good idea.^^J + I therefore use two columns instead}% + \col@number\tw@ \fi +% \end{macrocode} +% We have only enough box registers for ten columns, so we need to +% check that the user hasn't asked for more. +% \changes{v1.4k}{1992/06/27}{Maximum of 5 columns (temp)} +% \changes{v1.5a}{1992/11/04}{Allow 10 columns again} +% \begin{macrocode} + \ifnum\col@number>10 + \PackageError{multicol}% + {Too many columns}% + {Current implementation doesn't + support more than 10 columns.% + \MessageBreak + I therefore use 10 columns instead}% + \col@number10 \fi +% \end{macrocode} +% Within the environment we need a special version of the +% kernel |\@footnotetext| command since the original sets the +% the |\hsize| to |\columnwidth| which is not correct in the +% multicol environment. Here |\columnwidth| refers to the width of +% the individual column and the footnote should be in |\textwidth|. +% Since |\@footnotetext| has a different definition inside a +% minipage environment we do not redefine it directly. Instead we +% locally set |\columnwidth| to |\textwidth| and call the original +% (current) definition stored in |\orig@footnotetext|. +% \changes{v1.5p}{1997/12/14}{Redefinition of \cs{@footnotetext} +% only within env pr/2689.} +% \changes{v1.5r}{1998/08/17}{Use \cs{@footnotetext} but with +% local change to \cs{columnwidth}.} +% \changes{v1.5w}{1999/10/21}{Make \cs{@footnotetext} long to allow +% multi-paragraph footnotes.} +% If the \mc{} environment is nested inside another \mc{} +% environment then the redefinition has already happened. So be +% better test for this situation. Otherwise, we will get a \TeX{} +% stack overflow as this would generate a self-referencing definition. +% \changes{v1.6e}{2004/02/14}{Avoid self-referencing definition of +% \cs{@footnotetext} (pr/3618)}. +% \begin{macrocode} + \ifx\@footnotetext\mult@footnotetext\else + \let\orig@footnotetext\@footnotetext + \let\@footnotetext\mult@footnotetext + \fi +% \end{macrocode} +% Now we can safely look for the optional arguments. +% \begin{macrocode} + \@ifnextchar[\mult@cols{\mult@cols[]}} +% \end{macrocode} +% \end{macro} +% +% +% +% \begin{macro}{\mult@footnotetext} +% +% \begin{macrocode} +\long\def\mult@footnotetext#1{\begingroup + \columnwidth\textwidth + \orig@footnotetext{#1}\endgroup} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\mult@cols} +% The |\mult@cols| macro grabs the first optional argument +% (if any) and looks for the second one. +% \begin{macrocode} +\def\mult@cols[#1]{\@ifnextchar[% +% \end{macrocode} +% This argument should be a \meta{dimen} denoting the minimum free +% space needed on the current page to start the environment. If the +% user didn't supply one, we use |\premulticols| as a +% default. +% \begin{macrocode} + {\mult@@cols{#1}}% + {\mult@@cols{#1}[\premulticols]}} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\mult@@cols} +% After removing all arguments from the input we are able +% to start with |\mult@@cols|. +% \begin{macrocode} +\def\mult@@cols#1[#2]{% +% \end{macrocode} +% First thing we do is to decide whether or not this is an +% unbounded multicols environment, i.e. one that may split across +% pages, or one that has to be typeset into a box. If we are in +% \TeX's ``inner'' mode (e.g., inside a box already) then we have a +% boxed version of multicols therefore we set the |@boxedmulticols| +% switch to true. The \mc{} should start in vertical mode. If we +% are not already there we now force it with |\par| since otherwise +% the test for ``inner'' mode wouldn't show if we are in a box. +% \changes{v1.4f}{1992/04/28}{\cs{par} added to allow for correct inner test} +% \begin{macrocode} + \par + \ifinner \@boxedmulticolstrue +% \end{macrocode} +% Otherwise we check |\doublecol@number|. This counter is zero +% outside a multicols environment but positive inside (this happens +% a little later on). In the second case we need to process the +% current multicols also in ``boxed mode'' and so change the switch +% accordingly. +% \begin{macrocode} + \else + \ifnum \doublecol@number>\z@ + \@boxedmulticolstrue + \fi + \fi +% \end{macrocode} +% Then we look to see if statistics are requested: +% \begin{macrocode} + \mult@info\z@ + {Starting environment with + \the\col@number\space columns% +% \end{macrocode} +% In boxed mode we add some more info. +% \changes{v1.4f}{1992/04/28}{\cs{on@line} added to tracing info} +% \begin{macrocode} + \if@boxedmulticols\MessageBreak + (boxed mode)\fi + }% +% \end{macrocode} +% Then we measure the current page to see whether a useful portion +% of the multicolumn environment can be typeset. This routine +% might start a new page. +% \changes{v1.4a}{1992/02/14}{Forgotten braces added} +% \begin{macrocode} + \enough@room{#2}% +% \end{macrocode} +% Now we output the first argument and produce vertical space +% above the columns. (Note that this argument corresponds to the +% first optional argument of the \textsf{multicols} environment.) +% For many releases this argument was typeset in a group to get +% a similar effect as |\twocolumn[..]| where the argument is +% also implicitly surrounded by braces. However, this conflicts +% with local changes done by things like sectioning commands (which +% account for the majority of commands used in that argument) +% messing up vertical spacing etc.\ later in the document so that +% from version v1.5q on this argument is again typeset at the outer +% level. +% \changes{v1.4e}{1992/03/16}{Typeset optional arg inside group} +% \changes{v1.5q}{1998/01/19}{And removed the group again six years later} +% \begin{macrocode} + #1\par\addvspace\multicolsep +% \end{macrocode} +% When the last line of a paragraph had a positive depth then this +% depth normally taken into account by the baselineskip calculation +% for the next line. However, the columns produced by a following +% \texttt{multicol} are rigid and thus the distance from the +% baseline of a previous text line to the first line in a +% \texttt{multicol} would differ depending on the depth of the +% previous line. To account for this we add a negative space unless +% the depth is \texttt{-1000pt} which signals something special to +% \TeX and is not supposed to be a real depth. +% \changes{v1.5z1}{2003/02/17}{Add a kern to cancel potential depth of +% previous line} +% \begin{macrocode} + \ifdim \prevdepth = -\@m\p@ + \else +% \end{macrocode} +% The actual generation of this corrective space is a little bit +% more complicated as it doesn't make sense to always back up to +% the previous baseline (in case an object with a very large depth +% was placed there, e.g., a centered tabular). So we only back up +% to the extend that we are within the |\baselineskip| grid. We +% know that the box produced by \mc{} has |\topskip| at its top so +% that also needs to be taken into account. +% \changes{v1.6a}{2003/03/15}{Adjust spacing} +% \begin{macrocode} + \@tempcnta\prevdepth + \@tempcntb\baselineskip + \divide\@tempcnta\@tempcntb + \advance\@tempcnta\@ne + \dimen@\prevdepth + \advance\dimen@ -\@tempcnta\baselineskip + \advance\dimen@ \topskip + \kern-\dimen@ + \fi +% \end{macrocode} +% We start a new grouping level to hide all subsequent changes +% (done in |\prepare@multicols| for example). +% \begin{macrocode} + \begingroup + \prepare@multicols +% \end{macrocode} +% If we are in boxed mode we now open a box to typeset all material +% from the multicols body into it, otherwise we simply go ahead. +% \changes{v1.4g}{1992/05/07}{\cs{global} was probably wrong but at least +% unnecessary} +% \begin{macrocode} + \if@boxedmulticols + \setbox\mult@box\vbox\bgroup +% \end{macrocode} +% +% \changes{v1.8c}{2013/11/03}{Add \cs{color@setgroup} to prevent color leak} +% \begin{macrocode} + \color@setgroup +% \end{macrocode} +% \changes{v1.5?}{1994/?/?}{Penalty moved to later point} +% We may have to reset some parameters at this point, +% perhaps |\@parboxrestore| +% would be the right action but I leave it for the moment. +% \changes{v1.4l}{1992/08/17}{\cs{@totalleftmargin} now in +% \cs{prepare@multicols}} +% \begin{macrocode} + \fi +% \end{macrocode} +% We finish by suppressing initial spaces. +% \begin{macrocode} + \ignorespaces} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\if@boxedmulticols} +% Here is the switch and the box for ``boxed'' multicols code. +% \begin{macrocode} +\newif\if@boxedmulticols +\@boxedmulticolsfalse +\newbox\mult@box +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\enough@room} +% \changes{v1.0c}{1989/05/12}{Penalty 0 added to empty the contribution +% list.} +% The |\enough@room| macro used +% above isn't perfect but works reasonably well in this context. We +% measure the free space on the current page by subtracting +% |\pagetotal| from |\pagegoal|. This isn't entirely +% correct since it doesn't take the `shrinking' (i.e.\ +% |\pageshrink|) into account. The `recent contribution list' +% might be nonempty so we start with |\par| and an explicit +% |\penalty|.\footnote{See the documentation of +% \cs{endmulticols} for further details.} +% Actually, we use |\addpenalty| to ensure that a following +% |\addvspace| will `see' the vertical space that might be +% present. +% The use of |\addpenalty| will have the effect that all items from +% the recent contributions will be moved to the main vertical list +% and the |\pagetotal| value will be updated correctly. However, +% the penalty will be placed in front of any dangling glue item +% with the result that the main vertical list may already be +% overfull even if \TeX{} is not invoking the output routine. +% \changes{v1.3b}{1990/10/09}{Do \cs{penalty} with \cs{addpenalty}} +% \changes{v1.4e}{1992/03/16}{But ignore \cs{@nobreak} in \cs{addpenalty}} +% \begin{macrocode} +\def\enough@room#1{% +% \end{macrocode} +% Measuring makes only sense when we are not in ``boxed mode'' so +% the routine does nothing if the switch is true. +% \begin{macrocode} + \if@boxedmulticols\else + \par +% \end{macrocode} +% \label{mac:enoughroom} +% To empty the contribution list the first release contained a +% penalty zero but this had the result that |\addvspace| couldn't +% detect preceding glue. So this was changed to |\addpenalty|. But +% this turned out to be not enough as |\addpenalty| will not add a +% penalty when |@nobreak| is true. Therefore we force this switch +% locally to false. As a result there may be a break between +% preceding text and the start of a multicols environment, but this +% seems acceptable since there is the optional argument for exactly +% this reason. +% \begin{macrocode} + \bgroup\@nobreakfalse\addpenalty\z@\egroup + \page@free \pagegoal + \advance \page@free -\pagetotal +% \end{macrocode} +% To be able to output the value we need to assign it to a register +% first since it might be a register (default) in which case we +% need to use |\the| or it might be a plain value in which case +% |\the| would be wrong. +% \changes{v1.5e}{1994/05/26}{Assign arg to skip register to be able +% to output value} +% \begin{macrocode} + \@tempskipa#1\relax +% \end{macrocode} +% Now we test whether tracing information is required: +% \begin{macrocode} + \mult@info\z@ + {Current page:\MessageBreak + height=% + \the\pagegoal: used \the\pagetotal + \space -> free=\the\page@free + \MessageBreak + needed \the\@tempskipa + \space(for #1)}% +% \end{macrocode} +% Our last action is to force a page break if there isn't enough +% room left. +% \begin{macrocode} + \ifdim \page@free <#1\newpage \fi + \fi} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\prepare@multicols} +% When preparing for multicolumn output several things must +% be done. +% \begin{macrocode} +\def\prepare@multicols{% +% \end{macrocode} +% We start saving the current |\@totalleftmargin| and then +% resetting the |\parshape| in case we are inside some list +% environment. The correct indentation for the \mc{} environment in +% such a case will be produced by moving the result to the right by +% |\multicol@leftmargin| later on. If we would use the value of of +% |\@totalleftmargin| directly then lists inside the \mc{} +% environment could cause a shift of the output. +% \changes{v1.4l}{1992/08/17}{saved \cs{@totalleftmargin}} +% \begin{macrocode} + \multicol@leftmargin\@totalleftmargin + \@totalleftmargin\z@ + \parshape\z@ +% \end{macrocode} +% We also set the register |\doublecol@number| for later use. This +% register should contain $2\times |\col@number|$. This is also an +% indicator that we are within a \mc{} environment as mentioned +% above. +% \changes{v1.5a}{1992/11/04}{Add offset to \cs{doublecolnumber}} +% \begin{macrocode} + \doublecol@number\col@number + \multiply\doublecol@number\tw@ + \advance\doublecol@number\mult@rightbox +% \end{macrocode} +% +% \begin{macrocode} + \if@boxedmulticols + \let\l@kept@firstmark\kept@firstmark + \let\l@kept@botmark\kept@botmark + \global\let\kept@firstmark\@empty + \global\let\kept@botmark\@empty + \else +% \end{macrocode} +% We add an empty box to the main vertical list to ensure that we +% catch any insertions (held over or inserted at the top of the +% page). Otherwise it might happen that the |\eject| is discarded +% without calling the output routine. Inside the output routine we +% remove this box again. Again this code applies only if we are on +% the main vertical list and not within a box. +% However, it is not enough to turn off interline spacing, we also +% have to clear |\topskip| before adding this box, since |\topskip| +% is always inserted before the first box on a page which would +% leave us with an extra space of |\topskip| if \mc{} start on a +% fresh sheet. +% \changes{v1.3c}{1991/03/03}{\cs{null} inserted and removed in output} +% \changes{v1.4a}{1992/02/11}{Conditional code for boxed mode added.} +% \changes{v1.4o}{1992/11/22}{\cs{topskip} locally zeroed.} +% \begin{macrocode} + \nointerlineskip {\topskip\z@\null}% + \output{% + \global\setbox\partial@page\vbox + {% +% \end{macrocode} +% Now we have to make sure that we catch one special situation which +% may result in loss of text! If the user has a huge amount of +% vertical material within the first optional argument that is larger +% then |\premulticols| and we are near the bottom of the page then it +% can happen that not the |\eject| is triggering this special output +% routine but rather the overfull main vertical list. In that case +% we get another breakpoint through the |\eject| penalty. As a result +% this special output routine would be called twice and the contents +% of |\partial@page|, i.e.\ the material before the \mc{} +% environment gets lost. There are several solutions to avoid this +% problem, but for now we will simply detect this and inform the user +% that he/she has to enlarge the |\premulticols| by using a suitable +% value for the second argument. +% \changes{v1.4a}{1992/02/11}{Checking for text losses.} +% \begin{macrocode} +%<*check> + \ifvoid\partial@page\else + \PackageError{multicol}% + {Error saving partial page}% + {The part of the page before + the multicols environment was + nearly full with^^Jthe result + that starting the environment + will produce an overfull + page. Some^^Jtext may be lost! + Please increase \premulticols + either generally or for this% + ^^Jenvironment by specifying a + suitable value in the second + optional argument to^^Jthe + multicols environment.} + \unvbox\partial@page + \box\last@line + \fi +%</check> + \unvbox\@cclv + \global\setbox\last@line\lastbox + }% +% \end{macrocode} +% Finally we need to record the marks that are present within the +% |\partial@page| so that we can construct correct first and bottom +% marks later on. This is done by the following code. +% \changes{v1.4a}{1992/02/14}{kept marks initiated} +% \begin{macrocode} + \prep@keptmarks +% \end{macrocode} +% Finally we have to initialize |\kept@topmark| which should +% ideally be initialized with the mark that is current on ``top'' +% of this page. Unfortunately we can't use |\topmark| because this +% register will not always contain what its name promises because +% \LaTeX{} sometimes calls the output routine for float +% management.\footnote{During such a call the \cs{botmark} +% gets globally copied to \cs{topmark} by the \TeX{} +% program.} Therefore we use the second best solution by +% initializing it with |\firstmark|. In fact, for our purpose this +% doesn't matter as we use |\kept@topmark| only to initialize +% |\firstmark| and |\botmark| of a following page if we don't find +% any marks on the current one. +% \changes{v1.4i}{1992/06/18}{\cs{kept@topmark} initialized.} +% \begin{macrocode} + \global\let\kept@topmark\firstmark + }\eject +% \end{macrocode} +% The next thing to do is to assign a new value to |\vsize|. +% \LaTeX{} maintains the free room on the page (i.e.\ the page +% height without the space for already contributed floats) in the +% register |\@colroom|. We must subtract the height of +% |\partial@page| to put the actual free room into this +% variable. +% \begin{macrocode} + \advance\@colroom-\ht\partial@page +% \end{macrocode} +% Then we have to calculate the |\vsize| value to use during column +% assembly. |\set@mult@vsize| takes an argument which allows to +% make the setting local (|\relax|) or global (|\global|). The +% latter variant is used inside the output routine below. At this +% point here we have to make a local change to |\vsize| because we +% want to get the original value for |\vsize| restored in case +% this \mc{} environment ends on the same page where it has started. +% \changes{v1.4p}{1992/11/26}{Use different \cs{vsize} setting} +% \changes{v1.4p}{1992/11/26}{Code moved to \cs{set@mult@vsize}} +% \begin{macrocode} + \set@mult@vsize\relax +% \end{macrocode} +% Now we switch to a new |\output| routine which will be used +% to put the gathered column material together. +% \begin{macrocode} + \output{\multi@column@out}% +% \end{macrocode} +% Finally we handle the footnote insertions. We have to multiply +% the magnification factor and the extra skip by the number of +% columns since each footnote reduces the space for every column +% (remember that we have page-wide footnotes). If, on the other +% hand, footnotes are typeset at the very end of the document, our +% scheme still works since |\count\footins| is zero then, so it +% will not change. +% To allow even further customization the setting of the |\footins| +% parameters is done in a separate macro. +% \changes{v1.5?}{1994/?/?}{Use \cs{init@mult@footins}} +% \begin{macrocode} + \init@mult@footins +% \end{macrocode} +% For the same reason (page-wide footnotes), the \meta{dimen} +% register controlling the maximum space used for footnotes isn't +% changed. Having done this, we must reinsert all the footnotes +% which are already present (i.e.\ those encountered when the +% material saved in |\partial@page| was first processed). This +% will reduce the free space (i.e.\ |\pagetotal|) by the +% appropriate amount since we have changed the magnification +% factor, etc.\ above. +% \begin{macrocode} + \reinsert@footnotes +% \end{macrocode} +% Inside \mc{} a |\clearpage| is fairly useless as we aren't supporting +% floats. In fact, it can cause harm as it doesn't know about the +% |\partial@page| and may therefore result in making columns too long. +% So we change that to behave like |\newpage| but also check if there +% are any deferred floats. If so, perhaps the user tried to place them through +% that |\clearpage| (but that needs to be done before starting the \mc{} +% environment. +% \changes{v1.8q}{2017/04/11}{Make \cs{clearpage} behave like \cs{newpage} (pr/4511)} +% \begin{macrocode} + \def\clearpage{% + \ifx\@deferlist\@empty\else + \PackageError{multicol}% + {Deferred floats not cleared}% + {A \string\clearpage\space inside multicols acts like + \string\newpage\space and doesn't clear floats.\MessageBreak + Move it before the multicols environment if you need it.}% + \fi + \newpage}% +% \end{macrocode} +% All the code above was only necessary for the unrestricted \mc{} +% version, i.e.\ the one that allows page breaks. If we are within +% a box there is no point in setting up special output routines or +% |\vsize|, etc. +% \begin{macrocode} + \fi +% \end{macrocode} +% But now we are coming to code that is necessary in all cases. We +% assign new values to |\vbadness|, |\hbadness| and |\tolerance| +% since it's rather hard for \TeX{} to produce `good' paragraphs +% within narrow columns. +% \changes{v1.2a}{1990/02/05}{\cs{vbadness} 10001 now.} +% \begin{macrocode} + \vbadness\@Mi \hbadness5000 + \tolerance\multicoltolerance +% \end{macrocode} +% Since nearly always the first pass will fail we ignore it +% completely telling \TeX{} to hyphenate directly. In fact, we now +% use another register to keep the value for the multicol +% pre-tolerance, so that a designer may allow to use +% |\pretolerance|. +% \changes{v1.2a}{1990/02/05}{\cs{pretolerance} -1 because it nearly never +% succeeds.} +% \changes{v1.4e}{1992/03/20}{Using} +% \begin{macrocode} + \pretolerance\multicolpretolerance +% \end{macrocode} +% For use with the new \TeX{} we set |\emergencystretch| to +% $|\col@number| \times 4pt$. However this is only a guess +% so at the moment this is done in a macro +% |\setemergencystretch| which gets the current |\hsize| +% and the number of columns as arguments. Therefore users are able +% to figure out their own formula. +% \changes{v1.2a}{1990/02/05}{\cs{setemergencystretch} added.} +% \begin{macrocode} + \setemergencystretch\col@number\hsize +% \end{macrocode} +% Another hook to allow people adding their own extensions without +% making a new package is |\set@floatcmds| which handles any +% redefinitions of \LaTeX{}s internal float commands to work with +% the \mc{} environment. At the moment it is only used to redefine +% |\@dblfloat| and |\end@dblfloat|. +% \changes{v1.2a}{1990/02/05}{\cs{set@floatcmds} added.} +% \begin{macrocode} + \set@floatcmds +% \end{macrocode} +% Additionally, we advance |\baselineskip| by +% |\multicolbaselineskip| to allow corrections for narrow +% columns. +% \begin{macrocode} + \advance\baselineskip\multicolbaselineskip +% \end{macrocode} +% \changes{v1.0e}{1989/06/21}{\cs{textwidth} changed to \cs{linewidth}.} +% \changes{v1.0e}{1989/06/21}{So this file will +% work with the `twocolumn' command.} +% The |\hsize| of the columns is given by the formula: +% \[ +% { |\linewidth| - (|\col@number|-1) +% \times +% |\columnsep| +% \over +% |\col@number|} +% \] +% The formula above has changed from release to release. We now +% start with the current value of |\linewidth| so that the column +% width is properly calculated when we are inside a minipage or a +% list or some other environment. +% This will be achieved with: +% \begin{macrocode} + \hsize\linewidth \advance\hsize\columnsep + \advance\hsize-\col@number\columnsep + \divide\hsize\col@number +% \end{macrocode} +% We also set |\linewidth| and |\columnwidth| to |\hsize| In the past +% |\columnwidth| was left unchanged. This is inconsistent, +% but |\columnwidth| is used only by floats (which +% aren't allowed in their current implementation) and by the +% |\footnote| macro. Since we want page-wide +% footnotes\footnote{I'm not sure that I really want page-wide +% footnotes. But balancing of the last page can +% only be achieved with this approach or with a +% multi-path algorithm which is complicated and +% slow. But it's a challenge to everybody to +% prove me wrong! Another possibility is to +% reimplement a small part of the {\it +% fire\_up\/} procedure in \TeX{} (the program). +% I think that this is the best solution if you +% are interested in complex page makeup, but it +% has the disadvantage that the resulting +% program cannot be called \TeX{} thereafter.} +% this simple trick saved us from rewriting the |\footnote| +% macros. However, some applications referred to |\columnwidth| as +% the ``width of the current column'' to typeset displays +% (the \texttt{amsmath} package, for example) and to allow the use +% of such applications together with \texttt{multicol} this is now +% changed. +% +% Before we change |\linewidth| to the new value we record its old +% value in some register called |\full@width|. This value is +% used later on when we package all columns together. +% \changes{v1.0e}{1989/06/21}{Setting of \cs{columnwidth} removed.} +% \changes{v1.5o}{1997/11/16}{Setting of \cs{columnwidth} added again +% pr/2664.} +% \begin{macrocode} + \full@width\linewidth + \linewidth\hsize + \columnwidth\hsize +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\init@mult@footins} +% This macro is used to set up the parameters associated +% with footnote floats. It can be redefined by applications that +% require different amount of spaces when typesetting footnotes. +% \begin{macrocode} +\def\init@mult@footins{% + \multiply\count\footins\col@number + \multiply\skip \footins\col@number +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\set@mult@vsize} +% +% Since we have to set |\col@umber| columns on one page, +% each with a height of |\@colroom|, we have to assign +% $ +% |\vsize| = |\col@number| \times |\@colroom| +% $ +% in order to collect enough material before entering the +% |\output| routine again. In fact we have to add another +% $ +% (|\col@number|-1) \times (|\baselineskip|-|\topskip|) +% $ +% if you think about it. +% \changes{v1.4p}{1992/11/26}{Macro added.} +% \begin{macrocode} +\def\set@mult@vsize#1{% + \vsize\@colroom + \@tempdima\baselineskip + \advance\@tempdima-\topskip + \advance\vsize\@tempdima + \vsize\col@number\vsize + \advance\vsize-\@tempdima +% \end{macrocode} +% But this might not be enough since we use |\vsplit| later to +% extract the columns from the gathered material. Therefore we add +% some `extra lines,' one for each column plus a corrective action +% depending on the value of the `\texttt{collectmore}' counter. +% The final value is assigned globally if |#1| is |\global| because +% we want to use this macro later inside the output routine too. +% \changes{v1.6c}{2003/04/08}{Collect one line per column more} +% \begin{macrocode} + \advance\vsize\col@number\baselineskip + #1\advance\vsize + \c@collectmore\baselineskip} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\multicol@leftmargin} +% Here is the dimen register we need for saving away the outer +% value of |\@totalleftmargin|. +% \begin{macrocode} +\newdimen\multicol@leftmargin +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\@Mvi} +% In versions prior to 1.8r the balancing at the end of the +% environment was done by changing the output routine from +% |\multi@column@out| to |\balance@column@out|. As it turned out +% that this has a couple of issues when the last columns should not +% be balanced after all (for example because they contained several +% |\columnbreak| commands we now stay with one output routine for +% the environment and only signal that we reached the end of the +% environment by marking it with a special penalty that we can check +% for later. +% \changes{v1.8r}{2018/01/28}{Macro added} +% \begin{macrocode} +\mathchardef\@Mvi=10006 % 10005 is \columnbreak +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\endmulticols} +% When the end of the \mc{} environment is sensed we have to +% balance the gathered material. Depending on whether or not we are +% inside a boxed multicol different things must happen. But first +% we end the current paragraph with a |\par| command. +% \begin{macrocode} +\def\endmulticols{\par + \if@boxedmulticols +% \end{macrocode} +% In boxed mode we have to close the box in which we have gathered +% all material for the columns. But before we do this we need to +% remove any space at the end of the box as we don't want to use +% this in balancing. Because of the |\color@endgroup| this can't be +% done later in |\balance@columns| as the color command will hide +% it. +% \changes{v1.8c}{2013/11/03}{Add \cs{color@endgroup} to prevent color leak} +% \changes{v1.8f}{2014/06/19}{Discard spaces before adding \cs{color@endgroup}} +% \begin{macrocode} + \remove@discardable@items\color@endgroup\egroup +% \end{macrocode} +% Now we call |\balance@columns| the routine that balances material +% stored in the box |\mult@box|. +% \changes{v1.5?}{1994/?/?}{Splitting off zero box moved to +% \cs{balance@columns}} +% \begin{macrocode} + \balance@columns +% \end{macrocode} +% After balancing the result has to be returned by the command +% |\page@sofar|. But before we do this we reinsert any marks found +% in box |\mult@box|. +% \begin{macrocode} + \return@nonemptymark{first}% + \kept@firstmark + \return@nonemptymark{bot}% + \kept@botmark + \page@sofar +% \end{macrocode} +% +% \begin{macrocode} + \global\let\kept@firstmark + \l@kept@firstmark + \global\let\kept@botmark + \l@kept@botmark +%<*marktrace> + \mult@info\tw@ + {Restore kept marks to\MessageBreak + first: \meaning\kept@firstmark + \MessageBreak bot\space\space: + \meaning\kept@botmark }% +%</marktrace> +% \end{macrocode} +% This finishes the code for the ``boxed'' case. +% \begin{macrocode} + \else +% \end{macrocode} +% If there was a |\columnbreak| on the very last line all material +% will have been moved to the |\colbreak@box|. Thus the the galley +% will be empty and no output routine gets called so that the text +% is lost. To avoid this problem (though unlikely) we check if the +% current galley is empty and the |\colbreak@box| contains text and +% if so return that to the galley. If the galley is non-empty any +% material in |\colbreak@box| is added in the output routine since +% it needs to be put in front. +% \changes{v1.6d}{2003/04/17}{Catch problem with \cs{columnbreak} in +% last line} +% \begin{macrocode} + \ifdim\pagegoal=\maxdimen + \ifvoid\colbreak@box\else + \mult@info\@ne{Re-adding forced + break(s) for splitting}% + \unvbox\colbreak@box\fi + \fi +% \end{macrocode} +% If we are in an unrestricted \mc{} environment we end the current +% paragraph above with |\par| but this isn't sufficient since \TeX{}s +% {\it page\_builder} will not totally empty the contribution +% list.\footnote{This once caused a puzzling bug where some of the +% material was balanced twice, resulting in some overprints. The +% reason was the \cs{eject} which was placed at the end of +% the contribution list. Then the {\it page\_builder} was called +% (an explicit \cs{penalty} will empty the contribution +% list), but the line with the \cs{eject} didn't fit onto +% the current page. It was then reconsidered after the output +% routine had ended, causing a second break after one line.} +% Therefore we must also add an explicit |\penalty|. Now the +% contribution list will be emptied and, if its material doesn't +% all fit onto the current page then the output routine will be +% called before we change it. +% \changes{v1.3b}{1990/10/09}{Do \cs{penalty} with \cs{addpenalty}} +% \changes{v1.4e}{1992/03/16}{But ignore \cs{@nobreak} in \cs{addpenalty}} +% \changes{v1.5c}{1993/04/18}{Again use \cs{penalty}} +% At this point we need to use |\penalty| not |\addpenalty| to +% ensure that a) the recent contributions are emptied and b) that +% the very last item on the main vertical list is a valid break +% point so that \TeX{} breaks the page in case it is overfull. +% \begin{macrocode} + \penalty\z@ +% \end{macrocode} +% Now it's safe to call the output routine in order to balance +% the columns. We do this by calling it with a special penalty. +% \changes{v1.8r}{2018/01/28}{Use special penalty to signal end of environment} +% \begin{macrocode} + \penalty-\@Mvi +% \end{macrocode} +% If the \mc{} environment body was completely empty or if a +% multi-page \mc{} just ends at a page boundary we have the unusual +% case that the |\eject| will have no effect (since the main +% vertical list is empty)---thus no output routine is called at +% all. As a result the material preceding the \mc{} (stored in +% |\partial@page| will get lost if we don't put this back by hand. +% \changes{v1.4m}{1992/09/04}{Check \cs{partial@page} being emptied} +% \begin{macrocode} + \ifvbox\partial@page + \unvbox\partial@page\fi +% \end{macrocode} +% After the output routine has acted we restore +% the kept marks to their initial value. +% \begin{macrocode} + \global\let\kept@firstmark\@empty + \global\let\kept@botmark\@empty +%<*marktrace> + \mult@info\tw@ + {Make kept marks empty}% +%</marktrace> + \fi +% \end{macrocode} +% The output routine above will take care of the |\vsize| and +% reinsert the balanced columns, etc. But it can't reinsert the +% |\footnotes| because we first have to restore the +% |\footins| parameter since we are returning to one column +% mode. This will be done in the next line of code; we simply close +% the group started in |\multicols|. +% +% To fix an obscure bug which is the result of the current +% definition of the |\begin| \ldots\ |\end| macros, we check that +% we are still (logically speaking) in the \mc{} environment. If, +% for example, we forget to close some environment inside the +% \mc{} environment, the following |\endgroup| would be +% incorrectly considered to be the closing of this environment. +% \changes{v1.3c}{1991/03/14}{Check closing env.} +% \begin{macrocode} + \@checkend{multicols}% + \endgroup +% \end{macrocode} +% We also set the `\textsf{unbalance}' counter to its default. This is +% done globally since \LaTeX{} counters are always changed this +% way.\footnote{Actually, we are still in a group started by the +% \cs{begin} macro, so \cs{global} must be used +% anyway.} +% \begin{macrocode} + \global\c@unbalance\z@ +% \end{macrocode} +% Now it's time to return any footnotes if we are in unrestricted +% mode. In boxed mode footnotes are kept inside, but in that case +% we have to write another column status into the \texttt{.aux} +% file to support \cs{docolaction} in case we have nested +% environments. +% \changes{v1.8s}{2018/04/20}{Support for \cs{docolaction} (issue/39)} +% \begin{macrocode} + \if@boxedmulticols + \mc@col@status@write + \else + \reinsert@footnotes +% \end{macrocode} +% We also take a look at the amount of free space on the current +% page to see if it's time for a page break. The vertical space +% added thereafter will vanish if |\enough@room| starts a new +% page. +% +% But there is one catch. If the |\end{multicols}| is at the top of +% which can happen if there is a break point just before it (such +% as end ending environment) which was chosen. In that case we +% would do the next page using the internal |\vsize| for multicol +% collection which is a disaster. So we better catch this +% case. Fortunately we can detect it by looking at |\pagegoal|. +% \changes{v1.5x}{2000/05/05}{Detect and fix problem if a multicols +% ends at the top of a page} +% \begin{macrocode} + \ifdim \pagegoal=\maxdimen + \global\vsize\@colroom + \else + \enough@room\postmulticols + \fi + \fi + \addvspace\multicolsep +% \end{macrocode} +% There is one more thing to do: the balanced result of the +% environment is supposed to have a |\prevdepth| of zero as we +% backed up by its real prevdepth within |\page@sofar|. However if +% the balancing happened in the output routine then \TeX{} reverts +% to the |\prevdepth| that was current before the OR once the OR has +% finished. In short |\prevdepth| is something you can't set +% globally it is alway local to the current list being built. Thus +% we need to set it back to zero here to avoid incorrect spacing. +% \changes{v1.8h}{2014/09/12}{Set \cs{prevdepdth} for current vlist +% when returning from multicols environment} +% \begin{macrocode} + \prevdepth\z@ +% \end{macrocode} +% If statistics are required we finally report that we have +% finished everything. +% \begin{macrocode} + \mult@info\z@ + {Ending environment + \if@boxedmulticols + \space(boxed mode)\fi + }} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\c@unbalance} +% \SpecialMainIndex{\c@collectmore} +% \SpecialMainIndex{\col@number} +% \SpecialMainIndex{\doublecol@number} +% \SpecialMainIndex{\premulticols} +% \SpecialMainIndex{\multicoltolerance} +% \SpecialMainIndex{\multicolpretolerance} +% \SpecialMainIndex{\page@free} +% \SpecialMainIndex{\premulticols} +% \SpecialMainIndex{\postmulticols} +% \SpecialMainIndex{\multicolsep} +% \SpecialMainIndex{\multicolbaselineskip} +% \SpecialMainIndex{\partial@page} +% Let us end this section by allocating all the registers used so +% far. +% \begin{macrocode} +\newcount\c@unbalance +\newcount\c@collectmore +% \end{macrocode} +% In the new \LaTeX{} release |\col@number| is already allocated by +% the kernel, so we don't allocate it again. +% \begin{macrocode} +%\newcount\col@number +\newcount\doublecol@number +\newcount\multicoltolerance +\newcount\multicolpretolerance +\newdimen\full@width +\newdimen\page@free +\newdimen\premulticols +\newdimen\postmulticols +\newskip\multicolsep +\newskip\multicolbaselineskip +\newbox\partial@page +\newbox\last@line +% \end{macrocode} +% And here are their default values: +% \begin{macrocode} +\c@unbalance = 0 +\c@collectmore = 0 +% \end{macrocode} +% To allow checking whether some macro is used within the \mc{} +% environment the counter |\col@number| gets a default of |1| +% outside the the environment. +% \changes{v1.3d}{1991/10/23}{\cs{col@number} set to one} +% \changes{v1.8o}{2016/02/08}{\cs{col@number} already initialized in the +% kernel, so not initializing it in the package +% in case the document is in two-column (pr/4435)} +% \begin{macrocode} +%\col@number = 1 +\multicoltolerance = 9999 +\multicolpretolerance = -1 +\premulticols = 50pt +\postmulticols= 20pt +\multicolsep = 12pt plus 4pt minus 3pt +\multicolbaselineskip=0pt +% \end{macrocode} +% \end{macro} +% +% \end{multicols} +% +% \begin{multicols}{2}[\subsection{The output routines}] +% +% We first start with some simple macros. When typesetting the page we +% save the columns either in the box registers 0, 2, 4,\ldots\ +% (locally) or 1, 3, 5,\ldots\ (globally). This is \PlainTeX{} policy +% to avoid an overflow of the save stack. +% +% \begin{macro}{\process@cols} +% Therefore we define a |\process@cols| macro to help us in +% using these registers in the output routines below. It has two +% arguments: the first one is a number; the second one is the +% processing information. It loops starting with |\count@=#1| +% (|\count@| is a scratch register defined in \PlainTeX), +% processes argument |#2|, adds two to |\count@|, +% processes argument |#2| again, etc.\ until |\count@| is +% higher than |\doublecol@number|. It might be easier to +% understand it through an example, so we define it now and +% explain its usage afterwards. +% \begin{macrocode} +\def\process@cols#1#2{\count@#1\relax + \loop +%<*debug> + \typeout{Looking at box \the\count@} +%</debug> + #2% + \advance\count@\tw@ + \ifnum\count@<\doublecol@number + \repeat} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\page@sofar} +% We now define |\page@sofar| to give an example of the +% |\process@cols| macro. |\page@sofar| should output everything +% prepared by the balancing routine |\balance@columns|. +% \begin{macrocode} +\def\page@sofar{% +% \end{macrocode} +% |\balance@columns| prepares its output in the even numbered +% scratch box registers. +% Now we output the columns gathered assuming that they are saved +% in the box registers 2 (left column), 4 (second column), \ldots\ +% However, the last column (i.e.\ the right-most) should be saved in +% box register 0.\footnote{You will see the reason for this numbering +% when we look at the output routines +% \cs{multi@column@out} and +% \cs{balance@columns@out}.} +% First we ensure that the columns have equal width. We use +% |\process@cols| for this purpose, starting with +% $|\count@|=|\mult@rightbox|$. Therefore |\count@| loops through +% |\mult@rightbox|, $|\mult@rightbox| + 2$,\ldots +% (to |\doublecol@number|). +% \changes{v1.5a}{1992/11/04}{New box mechanism} +% \begin{macrocode} + \process@cols\mult@rightbox +% \end{macrocode} +% We have to check if the box in question is void, because the +% operation |\wd|\meta{number} on a void box will \emph{not} change +% its dimension (sigh). +% \changes{v1.5h}{1994/08/26}{Check for void boxes} +% \changes{v1.5i}{1994/10/02}{But don't remove original code.} +% \begin{macrocode} + {\ifvoid\count@ + \setbox\count@\hbox to\hsize{}% + \else + \wd\count@\hsize + \fi}% +% \end{macrocode} +% Now we give some tracing information. +% \changes{v1.4l}{1992/08/17}{use \cs{multicol@leftmargin} instead of +% \cs{@totalleftmargin}} +% \changes{v1.6b}{2003/03/15}{Different info display} +% \begin{macrocode} + \count@\col@number \advance\count@\m@ne + \mult@info\z@ + {Column spec: \the\full@width\space = indent + + columns + sep =\MessageBreak + \the\multicol@leftmargin\space + + \the\col@number\space + x \the\hsize\space + + \the\count@\space + x \the\columnsep + }% +% \end{macrocode} +% At this point we should always be in vertical mode. +% \begin{macrocode} +\ifvmode\else\errmessage{Multicol Error}\fi +% \end{macrocode} +% Now we put all columns together in an |\hbox| of width +% |\full@width| (shifting it by |\multicol@leftmargin| to the right +% so that it will be placed correctly if we are within a list +% environment) +% and separating the columns with a rule if desired. +% \changes{v1.5a}{1992/11/04}{New box mechanism} +% \changes{v1.5z}{2000/07/10}{Ensure that column rule has always +% \cs{normalcolor}} +% \changes{v1.6f}{2006/09/19}{Make the color of the rule a hook} +% \changes{v1.4l}{1992/08/17}{use \cs{multicol@leftmargin} instead of +% \cs{@totalleftmargin}} +% +% The box containing the columns has a large height and thus will +% always result in using |\lineskip| if the normal |\baselineskip| +% calculations are used. We therefore better cancel that process. +% \changes{v1.5z1}{2003/02/17}{Suppress interline glue at this point} +% \begin{macrocode} + \nointerlineskip +% \end{macrocode} +% As mentioned earlier we want to have the reference point of the +% box we put on the page being at the baseline of the last line of +% the columns but we also want to ensure that the box has no depth +% so that any following skip is automatically starting from that +% baseline. +% We achieve this by recording the depths of all columns and then +% finally backing up by the maximum. (perhaps a simpler method +% would be to assemble the box in a register and set the depth of +% that box to zero (not checked). +% +% We need a global scratch register for this; using standard \TeX{} +% conventions we choose |\dimen2| and initialize it with the depth +% of the character ``p'' since that is one of the depths that +% compete for the maximum. +% \changes{v1.6a}{2003/03/15}{Preparing for adjusting \cs{prevdepth}} +% \begin{macrocode} + \setbox\z@\hbox{p}\global\dimen\tw@\dp\z@ + \moveright\multicol@leftmargin + \hbox to\full@width{% +% \end{macrocode} +% If the document is written in a language that is typeset right-to-left +% then, of course, the multicol columns should be also typeset +% right-to-left. To support this we call |\mc@align@columns| which +% with execute different code depending on the typesetting direction. +% \changes{v1.7b}{2011/12/18}{RL language support fixed} +% \begin{macrocode} + \mc@align@columns +% \end{macrocode} +% The depths of the columns depend on their last lines. To ensure +% that we will always get a similar look as far as the rules are +% concerned we force the depth to be at least the depth of a +% letter~`p' (which is what we set |\dimen2| to above). +% \begin{macrocode} + \rlap{\phantom p}% + }% +% \end{macrocode} +% The processed material might consist of a last line with a +% descender in which case the |\prevdepth| will be +% non-zero. However, this material is getting reformatted now so +% that this value is likely to be wrong. We therefore normalize the +% situation by pretending that the depth is zero. However, if |\page@sofar| +% is being called inside the OR then setting |\prevdepth| here has +% no long-lasting effect, we therefore have to repeat this once we +% return to the main vertical list. Here we set it only for those +% cases where the command is used within a list and then followed by +% something else. +% \changes{v1.8g}{2014/08/24}{Resetting \cs{prevdepth} in the right place} +% \begin{macrocode} + \prevdepth\z@ +% \end{macrocode} +% Now after typesetting the box we back up to its baseline by using +% the value stored in |\dimen2| (which will hold the largest depth +% found on any column). +% \changes{v1.8g}{2003/03/15}{Now adjusting \cs{prevdepth}} +% \begin{macrocode} + \kern-\dimen\tw@ +% \end{macrocode} +% However, in case one of the columns was unusually deep \TeX{} may +% have tried some corrective actions in which case backing up by +% the saved value will not bring us back to the baseline. A good +% indication for this is a depth of |\maxdepth| though it is not an +% absolute proof. If the option \texttt{grid} is used +% |\mc@gridwarn| will expand to this, otherwise to |\maxdimen| in +% which case this warning will not show up. +% \changes{v1.8g}{2014/08/24}{Warn if value is exceeded not when equal} +% \begin{macrocode} + \ifdim\dimen\tw@ > \mc@gridwarn + \PackageWarning{multicol}% + {Very deep columns!\MessageBreak + Grid alignment might be broken}% + \fi +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\columnseprulecolor} +% \changes{v1.6f}{2006/09/19}{Make the color of the rule a hook} +% By default the vertical rule between columns will be in |\normalcolor|. +% \begin{macrocode} +\def\columnseprulecolor{\normalcolor} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\reinsert@footnotes} +% Before we tackle the bigger output routines we define just one +% more macro which will help us to find our way through the +% mysteries later. |\reinsert@footnotes| will do what its name +% indicates: it reinserts the footnotes present in +% |\footinbox| so that they will be reprocessed by \TeX{}'s +% {\it page\_builder}. +% +% Instead of actually reinserting the footnotes we insert an empty +% footnote. This will trigger insertion mechanism as well and since +% the old footnotes are still in their box and we are on a fresh page +% |\skip| |footins| should be correctly taken into account. +% \changes{v1.3c}{1990/03/03}{\cs{unbox}ing avoided.} +% \begin{macrocode} +\def\reinsert@footnotes{\ifvoid\footins\else + \insert\footins{}\fi} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\vfilmaxdepth} +% This curious definition is used as the space at the bottom of a +% column if we implement |\raggedcolumns|. Normally one only appends +% |\vfill| in that case but this is actually wrong for columns that +% are more or less full: by adding a glue at the bottom such a +% column doesn't have any depth any more but without it the material +% would be allowed a depth of |\maxdepth|. So we allow shrinking by +% that amount. This only makes a difference if the box would +% otherwise become overfull and shrinking never exceeds the +% specified value, so we should be fine. +% \changes{v1.8h}{2014/09/12}{Macro added (pr/4395)} +% \changes{v1.8j}{2015/03/07}{Use only `0.0001fil' for stretching} +% \begin{macrocode} +\def\vfilmaxdepth{\vskip \z@ \@plus .0001fil + \@minus \maxdepth} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\multi@column@out} +% Now we can't postpone the difficulties any longer. The +% |\multi@column@out| routine will be called in two situations. +% Either the page is full (i.e., we have collected enough material +% to generate all the required columns) or a float or marginpar or +% a |\clearpage| is +% sensed. In the latter case the |\outputpenalty| is less +% than $-10000$, otherwise the penalty which triggered the output +% routine is higher. Therefore it's easy to distinguish both +% cases: we simply test this register. +% \changes{v1.5c}{1993/04/18}{Support \cs{clearpage}} +% \begin{macrocode} +\def\multi@column@out{% + \ifnum\outputpenalty <-\@M +% \end{macrocode} +% If this was a |\clearpage|, a float or a marginpar we call +% |\speci@ls| +% \begin{macrocode} + \speci@ls \else +% \end{macrocode} +% otherwise we construct the final page. +% \changes{v1.5u}{1999/05/25}{Support \cs{columnbreak}} +% \changes{v1.5v}{1999/07/18}{Added debug statements for +% column break support} +% For the next block of code see comments in section~\ref{sec:colbreak}. +% \begin{macrocode} + \ifvoid\colbreak@box\else + \mult@info\@ne{Re-adding forced + break(s) for splitting}% + \setbox\@cclv\vbox{% + \unvbox\colbreak@box + \penalty-\@Mv + \unvbox\@cclv}% + \fi +% \end{macrocode} +% Let us now consider the +% normal case. We have to |\vsplit| the columns from the +% accumulated material in box 255. Therefore we first assign +% appropriate values to |\splittopskip| and |\splitmaxdepth|. +% \begin{macrocode} + \splittopskip\topskip + \splitmaxdepth\maxdepth +% \end{macrocode} +% We also need to restrict |\boxmaxdepth| so that re-boxing is not +% generating boxes with arbitrary depth. +% \changes{v1.8j}{2015/03/07}{Set \cs{boxmaxdepth}} +% \begin{macrocode} + \boxmaxdepth\maxdepth +% \end{macrocode} +% Then we calculate the current column height (in |\dimen@|). +% Note that the height of |\partial@page| is already +% subtracted from |\@colroom| so we can use its value as a +% starter. +% \begin{macrocode} + \dimen@\@colroom +% \end{macrocode} +% But we must also subtract the space occupied by footnotes on the +% current page. Note that we first have to reset the skip register +% to its normal value. +% Again, the actual action is carried out in a utility macro, so that +% other applications can modify it. +% \changes{v1.5?}{1994/?/?}{Use \cs{leave@mult@footins}} +% \begin{macrocode} + \divide\skip\footins\col@number + \ifvoid\footins \else + \leave@mult@footins + \fi +% \end{macrocode} +% And there is one more adjustment that we have to make: if the +% user has issue a |\enlargethispage| command then the height the +% |\@kludgeins| box will be the negation of the size by which the +% page should be enlarged. If the star form of this command has +% been used then we also need to shrink the resulting column. + +% That local change will be reverted at the end of the output +% routine So for the next page the original state will be +% reestablished. However, in theory there is a possibility to sneak +% in a whole multicols environment into the running header +% definition. If that happens then it will also be affected by this +% change---too bad I think. +% \changes{v1.8a}{2011/12/20}{Support for \cs{enlargethispage}} +% \changes{v1.8v}{2018/12/27}{Removed dead code, the case where this +% can go wrong is too obscure to worry about it (gh/101)} +% \begin{macrocode} + \ifvbox \@kludgeins + \advance \dimen@ -\ht\@kludgeins +% \end{macrocode} +% The star form of |\enlargethispage| makes the width of the box +% greater than zero (sneaky isn't it?). +% \begin{macrocode} + \ifdim \wd\@kludgeins>\z@ + \shr@nkingtrue + \fi + \fi +% \end{macrocode} +% Now we are able to |\vsplit| off all but the last column. +% Recall that these columns should be saved in the box registers 2, +% 4,\ldots\ (plus offset). +% \changes{v1.5a}{1992/11/04}{New box mechanism} +% \begin{macrocode} + \process@cols\mult@gfirstbox{% + \setbox\count@ + \vsplit\@cclv to\dimen@ +% \end{macrocode} +% After splitting we update the kept marks. +% \begin{macrocode} + \set@keptmarks +% \end{macrocode} +% If |\raggedcolumns| is in force we add a |vfill| at the bottom by +% unboxing the split box. +% But we need to unbox anyway to ensure that at the end of the box +% we do not have unwanted space. This can sneak in in certain +% situations, for example, if two lists follow each other and we +% break between them. While such space is usually zero it still has +% an effect because it hides depth of the last line in the column +% and that will result in incorrect placement. +% \changes{v1.3c}{1990/03/03}{\cs{unbox}ing avoided.} +% \changes{v1.8b}{2013/08/28}{And 20odd years later conclude that +% this was wrong and unboxing is always needed.} +% \changes{v1.8b}{2013/08/28}{Remove discardable items at the +% end of split boxes} +% \changes{v1.8h}{2014/09/12}{Use \cs{vfilmaxdepth}} +% \changes{v1.8k}{2015/03/22}{\cs{remove@discardable@items} removed} +% \begin{macrocode} + \setbox\count@ + \vbox to\dimen@ + {\unvbox\count@ + \ifshr@nking\vfilmaxdepth\fi}% + }% +% \end{macrocode} +% Then the last column follows. +% \changes{v1.5a}{1992/11/04}{New box mechanism} +% \changes{v1.8b}{2013/08/28}{Remove discardable items at the +% end of split boxes} +% \changes{v1.8h}{2014/09/12}{Use \cs{vfilmaxdepth}} +% \changes{v1.8k}{2015/03/22}{\cs{remove@discardable@items} removed} +% \begin{macrocode} + \setbox\mult@rightbox + \vsplit\@cclv to\dimen@ + \set@keptmarks + \setbox\mult@rightbox\vbox to\dimen@ + {\unvbox\mult@rightbox + \ifshr@nking\vfilmaxdepth\fi}% +% \end{macrocode} +% Having done this we hope that box 255 is emptied. If not, we +% reinsert its contents. +% \changes{v1.8a}{2011/12/20}{Only re-add output penalty if it was +% explicitly set} +% \begin{macrocode} + \ifvoid\@cclv \else + \unvbox\@cclv + \ifnum\outputpenalty=\@M + \else + \penalty\outputpenalty + \fi +% \end{macrocode} +% In this case a footnote that happens to fall into the leftover +% bit will be typeset on the wrong page. Therefore we warn the user +% if the current page contains footnotes. The older versions of +% \mc{} produced this warning regardless of whether or not +% footnotes were present, resulting in many unnecessary warnings. +% \changes{v1.3c}{1991/02/17}{Check if footnotes are actually present +% before issuing a warning.} +% \begin{macrocode} + \ifvoid\footins\else + \PackageWarning{multicol}% + {I moved some lines to + the next page.\MessageBreak + Footnotes on page + \thepage\space might be wrong}% + \fi +% \end{macrocode} +% If the `\textsf{tracingmulticols}' counter is 4 or higher we also +% add a rule. +% \begin{macrocode} + \ifnum \c@tracingmulticols>\thr@@ + \hrule\allowbreak \fi + \fi +% \end{macrocode} +% To get a correct marks for the current page we have to (locally) +% redefine |\firstmark| and |\botmark|. +% If |\kept@firstmark| is non-empty then |\kept@botmark| must be +% non-empty too so we can use their values. Otherwise we use the +% value of |\kept@topmark| which was first initialized when we +% gathered the |\partical@page| and later on was updated to the +% |\botmark| for the preceding page. +% +% \changes{v1.4a}{1992/02/14}{\cs{botmark} set to \cs{splitbotmark}} +% \begin{macrocode} + \ifx\@empty\kept@firstmark + \let\firstmark\kept@topmark + \let\botmark\kept@topmark + \else + \let\firstmark\kept@firstmark + \let\botmark\kept@botmark + \fi +% \end{macrocode} +% We also initialize |\topmark| with |\kept@topmark|. This will make +% this mark okay for all middle pages of the \mc{} environment. +% \changes{v1.5d}{1993/09/15}{reinit \cs{topmark}} +% \begin{macrocode} + \let\topmark\kept@topmark +%<*marktrace> + \mult@info\tw@ + {Use kept top mark:\MessageBreak + \meaning\kept@topmark + \MessageBreak + Use kept first mark:\MessageBreak + \meaning\kept@firstmark + \MessageBreak + Use kept bot mark:\MessageBreak + \meaning\kept@botmark + \MessageBreak + Produce first mark:\MessageBreak + \meaning\firstmark + \MessageBreak + Produce bot mark:\MessageBreak + \meaning\botmark + \@gobbletwo}% +%</marktrace> +% \end{macrocode} +% With a little more effort we could have done better. If we had, +% for example, recorded the shrinkage of the material in +% |\partial@page| it would be now possible to try higher +% values for |\dimen@| (i.e.\ the column height) to overcome +% the problem with the nonempty box 255. But this would make the +% code even more complex so I skipped it in the current +% implementation. +% +% Now we use \LaTeX{}'s standard output +% mechanism.\footnote{This will produce a lot of overhead since both +% output routines are held in memory. The correct +% solution would be to redesign the whole output +% routine used in \LaTeX.} +% Admittedly this is a funny way to do it. +% +% Within the OR |\boxmaxdepth| needs to be unrestricted so we set it back +% now as it was changed above. +% \changes{v1.8p}{2016/04/07}{Reset \cs{boxmaxdepth}} +% \begin{macrocode} + \boxmaxdepth\maxdimen + \setbox\@cclv\vbox{\unvbox\partial@page + \page@sofar}% +% \end{macrocode} +% The macro |\@makecol| adds all floats assigned for the current +% page to this page. |\@outputpage| ships out the resulting box. +% Note that it is just possible that such floats are present even +% if we do not allow any inside a \mc{} environment. +% \begin{macrocode} + \@makecol\@outputpage +% \end{macrocode} +% After the page is shipped out we have to prepare the kept marks +% for the following page. |\kept@firstmark| and |\kept@botmark| +% reinitialized by setting them to |\@empty|. The value of +% |\botmark| is then assigned to |\kept@topmark|. +% \changes{v1.4g}{1992/06/03}{Only change \cs{kept@topmark} if +% \cs{kept@botmark} non-empty} +% \changes{v1.4i}{1992/06/18}{Set \cs{kept@topmark} to \cs{botmark}} +% \begin{macrocode} + \global\let\kept@topmark\botmark + \global\let\kept@firstmark\@empty + \global\let\kept@botmark\@empty +%<*marktrace> + \mult@info\tw@ + {(Re)Init top mark:\MessageBreak + \meaning\kept@topmark + \@gobbletwo}% +%</marktrace> +% \end{macrocode} +% Now we reset |\@colroom| to |\@colht| which is \LaTeX's +% saved value of |\textheight|. +% We also have to reset the recorded position of the last +% |\marginpar| as well as the recorded size of in-text floats +% as we are now on a new page. +% \changes{v1.8d}{2014/04/23}{Reset \cs{@mparbottom} after page finishes} +% \changes{v1.8n}{2015/08/19}{Reset \cs{@textfloatsheight} after page finishes} +% \begin{macrocode} + \global\@colroom\@colht + \global \@mparbottom \z@ + \global \@textfloatsheight \z@ +% \end{macrocode} +% Then we process deferred floats waiting for their chance to be +% placed on the next page. +% \begin{macrocode} + \process@deferreds + \@whilesw\if@fcolmade\fi{\@outputpage + \global\@colroom\@colht + \process@deferreds}% +% \end{macrocode} +% If the user is interested in statistics we inform him about the +% amount of space reserved for floats. +% \begin{macrocode} + \mult@info\@ne + {Colroom:\MessageBreak + \the\@colht\space + after float space removed + = \the\@colroom \@gobble}% +% \end{macrocode} +% Having done all this we must prepare to tackle the next page. +% Therefore we assign a new value to |\vsize|. New, because +% |\partial@page| is now empty and |\@colroom| might be +% reduced by the space reserved for floats. +% \changes{v1.4p}{1992/11/26}{Use different \cs{vsize} setting} +% \begin{macrocode} + \set@mult@vsize \global +% \end{macrocode} +% The |\footins| skip register will be adjusted when the output +% group is closed. +% \changes{v1.3c}{1991/03/03}{Unnecessary code removed} +% \begin{macrocode} + \fi} +% \end{macrocode} +% \end{macro} +% +% +% +% \begin{macro}{\leave@mult@footins} +% This macro is used to subtract the amount of space +% occupied by footnotes for the current space from the +% space available for the current column. The space current column +% is stored in |\dimen@|. See above for the description of the default +% action. +% \changes{v1.5?}{1994/?/?}{Macro added} +% \begin{macrocode} +\def\leave@mult@footins{% + \advance\dimen@-\skip\footins + \advance\dimen@-\ht\footins +} +% \end{macrocode} +% \end{macro} +% +% +% +% \begin{macro}{\speci@ls} +% We left out two macros: |\process@deferreds| and +% |\speci@ls|. +% \changes{v1.5c}{1993/04/18}{Support \cs{clearpage}} +% \begin{macrocode} +\def\speci@ls{% + \ifnum\outputpenalty <-\@Mi +% \end{macrocode} +% If the document ends in the middle of a multicols environment, e.g., +% if the user forgot the |\end{multicols}|, \TeX{} adds a very +% negative penalty to the end of the galley which is intended to signal +% the output routine that it is time to prepare for shipping out +% everything remaining. Since inside multicols the output routine of +% \LaTeX{} is disabled sometimes we better check for this case: if we +% find a very negative penalty we produce an error message and run +% the default output routine for this case. +% \changes{v1.5s}{1998/09/10}{check for \cs{stop} penalty pr/2873} +% \begin{macrocode} + \ifnum \outputpenalty<-\@MM + \PackageError{multicol}{Document end + inside multicols environment}\@ehd + \@specialoutput + \else +% \end{macrocode} +% \changes{v1.5u}{1999/05/25}{Support \cs{columnbreak}} +% \changes{v1.5v}{1999/07/18}{Added debug statements for +% column break support} +% For the next block of code see comments in section~\ref{sec:colbreak}. +% \begin{macrocode} + \ifnum\outputpenalty = -\@Mv + \mult@info\@ne{Forced column + break seen}% + \global\advance\vsize-\pagetotal + \global\setbox\colbreak@box + \vbox{% + \ifvoid\colbreak@box + \else + \unvbox\colbreak@box + \penalty-\@Mv + \fi +% \end{macrocode} +% As this is the place of a forced break we now remove vertical +% white space just in front of it (or some of it at least) as it is +% quite likely that the break is not exactly in the right place, +% e.g., after a display environment (if LaTeX would break here by +% its own it would break before the space following the display). +% +% Thus we rebox box 255 once (using |\maxdepth| and calling +% |\remove@discardable@items| inside). The depth of 255 will then +% give us the depth the box would have had if it would have been a +% natural break. We then unbox 255 to get it into the +% |\colbreak@box| and then back up by this depth. This will position +% the bottom of the box at its natural baseline which is useful for +% balancing later on. +% \changes{v1.8k}{2015/03/21}{Remove discardable items just before a +% forced break} +% \begin{macrocode} + \boxmaxdepth\maxdepth + \setbox\@cclv\vbox{% + \unvbox\@cclv + \remove@discardable@items}% + \dimen@\dp\@cclv + \unvbox\@cclv + \kern-\dimen@ + }% + \reinsert@footnotes + \else +% \end{macrocode} +% Another special case is reaching the end of the \mc{} +% environment which is signaled by |-\@Mvi|. +% \changes{v1.8r}{2018/01/28}{Handling end of env through special penalty} +% \begin{macrocode} + \ifnum\outputpenalty = -\@Mvi + \mult@info\@ne{End penalty of multicols seen}% +% \end{macrocode} +% If we are at this point then have have to run the balancing code +% (which was previously its own output routine). First we pretend +% that we had a normal forced breakpoint and then call +% |\balance@column@out|. The latter may be let to |\multi@column@out| +% if we are inside \texttt{multicols*} in which case we would get a loop +% if the |\outputpenalty| is not changed---this could be cleaned up +% in a better way; basically it is like this, because of the older +% code was using different ORs and I simply reused most of it. +% \begin{macrocode} + \outputpenalty\@M % pretend we had a natural forced break + \balance@columns@out + \else +% \end{macrocode} +% If we encounter a float or a marginpar in the current +% implementation we simply warn the user that this is not allowed. +% Then we reinsert the page and its footnotes. +% \begin{macrocode} + \PackageWarningNoLine{multicol}% + {Floats and marginpars not + allowed inside `multicols' + environment!}% + \unvbox\@cclv\reinsert@footnotes +% \end{macrocode} +% Additionally we empty the |\@currlist| to avoid later error +% messages when the \LaTeX{} output routine is again in force. +% But first we have to place the boxes back onto the +% |\@freelist|. (|\@elt|s default is |\relax| so +% this is possible with |\xdef|.) +% \changes{v1.2a}{1990/02/05}{Float boxes freed.} +% \begin{macrocode} + \xdef\@freelist{\@freelist\@currlist}% + \gdef\@currlist{}% + \fi + \fi + \fi +% \end{macrocode} +% If the penalty is $-10001$ it will come from a |\clearpage| and +% we will execute |\@doclearpage| to get rid of any deferred +% floats. +% \begin{macrocode} + \else \@doclearpage \fi +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\process@deferreds} +% |\process@deferreds| is a simplified version of \LaTeX{}'s +% |\@startpage|. We first call the macro +% |\@floatplacement| to save the current user parameters in +% internal registers. Then we start a new group and save the +% |\@deferlist| temporarily in the macro |\@tempb|. +% \begin{macrocode} +\def\process@deferreds{% + \@floatplacement + \@tryfcolumn\@deferlist + \if@fcolmade\else + \begingroup + \let\@tempb\@deferlist +% \end{macrocode} +% Our next action is to (globally) empty |\@deferlist| and +% assign a new meaning to |\@elt|. Here |\@scolelt| is a +% macro that looks at the boxes in a list to decide whether they +% should be placed on the next page (i.e.\ on |\@toplist| or +% |\@botlist|) or should wait for further processing. +% \begin{macrocode} + \gdef\@deferlist{}% + \let\@elt\@scolelt +% \end{macrocode} +% Now we call |\@tempb| which has the form +% \begin{center} +% |\@elt|\meta{box register}|\@elt|^^A +% \meta{box register}\ldots{} +% \end{center} +% So |\@elt| (i.e.\ |\@scolelt|) will distribute the +% boxes to the three lists. +% \begin{macrocode} + \@tempb \endgroup + \fi} +% \end{macrocode} +% \end{macro} +% +% +% +% \begin{macro}{ifshr@nking} +% \begin{macro}{\raggedcolumns} +% \begin{macro}{\flushcolumns} +% \changes{v1.1a}{1989/09/20}{\cs{flushedcolumns} renamed to \cs{flushcolumns}.} +% The |\raggedcolumns| and |\flushcolumns| +% declarations are defined with the help of a new |\if...| +% macro. +% \begin{macrocode} +\newif\ifshr@nking +% \end{macrocode} +% The actual definitions are simple: we just switch to \textsf{true} +% or \textsf{false} depending on the desired action. To avoid extra +% spaces in the output we enclose these changes in +% |\@bsphack|\ldots{}\allowbreak|\@esphack|. +% \begin{macrocode} +\def\raggedcolumns{% + \@bsphack\shr@nkingtrue\@esphack} +\def\flushcolumns{% + \@bsphack\shr@nkingfalse\@esphack} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% +% +% \begin{macro}{\balance@columns@out} +% Now for the last part of the show: the column balancing output +% routine. Since this code is called with an explicit penalty +% (|\eject|) there is no need to check for something special (eg +% floats). We start by balancing the material gathered. +% \begin{macrocode} +\def\balance@columns@out{% +% \end{macrocode} +% For this we need to put the contents of box 255 into |\mult@box|. +% \changes{v1.5u}{1999/05/25}{Support \cs{columnbreak}} +% \changes{v1.5v}{1999/07/18}{Added debug statements for column break +% support} For the next block of code see also comments in +% section~\ref{sec:colbreak}. All forced breaks except the last are +% inside |\colbreak@box| so all we have to do is to concatenate this +% box with box |\@cclv| and put a penalty in between. Here we test if +% |\colbreak@box| is void so that the message is only generated if +% we really add forced breaks and the penalty. +% \changes{v1.8k}{2015/03/21}{Use \cs{@Mv} and not \cs{break} in case +% this forced break is not used on this page} +% \begin{macrocode} + \setbox\mult@box\vbox{% + \ifvoid\colbreak@box\else + \unvbox\colbreak@box + \penalty-\@Mv + \mult@info\@ne{Re-adding + forced break(s) in balancing}% + \fi + \unvbox\@cclv +% \end{macrocode} +% The last column again is a forced break, so here we discard white +% space as well as that is normally unwanted. +% \changes{v1.8k}{2015/03/21}{Add \cs{remove@discardable@items} at the +% end of the last column when balancing.} +% \begin{macrocode} + \remove@discardable@items + }% + \balance@columns +% \end{macrocode} +% If during balancing the columns got too long the flag +% |\iftoo@bad| is set to true. +% \changes{v1.8a}{2011/12/20}{Balancing concept improved} +% \begin{macrocode} + \iftoo@bad + \mult@info\@ne + {Balancing failed ... + cut a normal page}% +% \end{macrocode} +% In that case we put the material back in box 255 so that we can +% cut a normal page. The curious set of +% |\vskip|s we add is necessary to cancel out the |\splittopskip| +% that got added for balancing. +% \begin{macrocode} + \setbox\@cclv\vbox + {\vskip\topskip + \vskip-\splittopskip + \unvbox\mult@box +% \end{macrocode} +% We also have to re-add the end of environment penalty since after +% this page we may want balance the remaining material. +% \changes{v1.8r}{2018/01/28}{Re-add the final penalty} +% \begin{macrocode} + \penalty-\@Mvi + }% +% \end{macrocode} +% We then call the standard multicol output routine which will +% produce a normal page for us (remember we are still within the +% OR so some part of the code in |\multi@column@out| is actually not +% doing anything---perhaps this should be cleaned up at some point). +% This also means that if there was an |\enlargethispage| present +% it will apply to this page as |\multi@column@out| will look at +% the status of |\@kludgeins|. +% \begin{macrocode} + \multi@column@out +% \end{macrocode} +% Because balancing made the columns too long we are sure that there +% will be some material remaining which was put back onto the main +% vertical list by |\multi@column@out|. This will also put the +% explicit |\eject| penalty back so the current +% |\balance@columns@out| output routine will be called again (so we +% better do not add another penalty or else the OR will be called +% twice and we may get scrambled results). +% \changes{v1.8k}{2015/03/21}{No additional penalty here} +% \begin{macrocode} + \else +% \end{macrocode} +% If the balancing went ok, we are in the position +% to apply |\page@sofar|. But first we have to set |\vsize| to a +% value suitable for one column output. +% \begin{macrocode} + \global\vsize\@colroom + \global\advance\vsize\ht\partial@page +% \end{macrocode} +% We also have to look at |\@kludgeins| and generate a new +% |\insert| in case there was one present due to an +% |\enlargethispage| command. +% \changes{v1.8a}{2011/12/20}{Support for \cs{enlargethispage}} +% \begin{macrocode} + \ifvbox\@kludgeins\insert\@kludgeins + {\unvbox\@kludgeins}\fi +% \end{macrocode} +% Then we |\unvbox| the |\partial@page| (which may be void if we +% are not processing the first page of this \mc{} environment. +% \begin{macrocode} + \unvbox\partial@page +% \end{macrocode} +% Then we return the first and bottom mark and the gathered +% material to the main vertical list. +% \begin{macrocode} + \return@nonemptymark{first}\kept@firstmark + \return@nonemptymark{bot}\kept@botmark + \page@sofar +% \end{macrocode} +% We need to add a penalty at this point which allows to break at +% this point since calling the output routine may have removed the +% only permissible break point thereby ``glueing'' any following +% skip to the balanced box. In case there are any weird settings +% for |\multicolsep| etc. this could produce funny results. +% \changes{v1.5c}{1993/04/18}{added penalty at output routine exit} +% \begin{macrocode} + \penalty\z@ + \fi +} +% \end{macrocode} +% As we already know, reinserting of footnotes will be done in the +% macro |\endmulticols|. +% \end{macro} +% +% +% \begin{macro}{\balance@columns} +% This macro now does the actual balancing. +% \begin{macrocode} +\def\balance@columns{% +% \end{macrocode} +% We start by setting the kept marks by updating them with any +% marks from this box. This has to be done \emph{before} we add a +% penalty of $-10000$ to the top of the box, otherwise only an +% empty box will be considered. +% \changes{v1.5h}{1994/08/26}{Get kept marks first} +% \begin{macrocode} + \get@keptmarks\mult@box +% \end{macrocode} +% We then continue by resetting trying to remove any discardable +% stuff at the end of |\mult@box|. This is rather experimental. We +% also add a forced break point at the very beginning, so that we +% can split the box to height zero later on, thereby adding a known +% |\splittopskip| glue at the beginning. +% \changes{v1.8k}{2015/03/21}{\cs{remove@discardable@items} removed} +% \begin{macrocode} + \setbox\mult@box\vbox{% + \penalty-\@M + \unvbox\mult@box + }% +% \end{macrocode} +% Then follow values assignments to get the |\vsplit|ting right. +% We use the natural part of |\topskip| as the natural part for +% |\splittopskip| and allow for a bit of undershoot and overshoot +% by adding some stretch and shrink. +% \changes{v1.5?}{1994/?/?}{Allow columns to come out a bit long or short} +% \begin{macrocode} + \@tempdima\topskip + \splittopskip\@tempdima + \@plus\multicolundershoot + \@minus\multicolovershoot + \splitmaxdepth\maxdepth +% \end{macrocode} +% We also have to set |\boxmaxdepth| which normally allows to +% build boxes with arbitrary depth, but as we are building text +% columns we really want to restrict the depth. This is necessary as +% we sometimes rebox the boxes generated by |\vsplit| and then the +% restriction posed by |\splitmaxdepth| gets lost. +% \changes{v1.8h}{2014/09/12}{All column boxes should obey +% \cs{maxdepth} (pr/4395)} +% \begin{macrocode} + \boxmaxdepth\maxdepth +% \end{macrocode} +% The next step is a bit tricky: when \TeX{} assembles material in +% a box, the first line isn't preceded by interline glue, i.e. +% there is no parameter like |\boxtopskip| in \TeX{}. This means +% that the baseline of the first line in our box is at some +% unpredictable point depending on the height of the largest +% character in this line. But of course we want all columns to +% align properly at the baselines of their first lines. For this +% reason we have opened |\mult@box| with a |\penalty| \textsf{-10000}. +% This will now allow us to split off from |\mult@box| a tiny bit +% (in fact nothing since the first possible break-point is the +% first item in the box). The result is that |\splittopskip| is +% inserted at the top of |\mult@box| which is exactly what we like +% to achieve. +% \changes{v1.5?}{1994/?/?}{Do splitting to zero here} +% \begin{macrocode} + \setbox\@tempboxa\vsplit\mult@box to\z@ +% \end{macrocode} +% Next we try to find a suitable starting point for the calculation +% of the column height. It should be less than the height finally +% chosen, but large enough to reach this final value in only a few +% iterations. The formula which is now implemented will try to +% start with the nearest value which is a multiple of +% |\baselineskip|. The coding is slightly tricky in \TeX{} and +% there are perhaps better ways \ldots +% \changes{v1.4d}{1992/03/04}{New algorithm for start height} +% \begin{macrocode} + \@tempdima\ht\mult@box + \advance\@tempdima\dp\mult@box + \divide\@tempdima\col@number +% \end{macrocode} +% The code above sets |\@tempdima| to the length of a column if we +% simply divide the whole box into equal pieces. To get to the next +% lower multiple of |\baselineskip| we convert this dimen to a +% number (the number of scaled points) then divide this by +% |\baselineskip| (also in scaled points) and then multiply this +% result with |\baselineskip| assigning the result to |\dimen@|. +% This makes |\dimen@| $\leq$ to |\@tempdimena|. +% \begin{macrocode} + \count@\@tempdima + \divide\count@\baselineskip + \dimen@\count@\baselineskip +% \end{macrocode} +% Next step is to correct our result by taking into account the +% difference between |\topskip| and |\baselineskip|. We start by +% adding |\topskip|; if this makes the result too large then we +% have to subtract one |\baselineskip|. +% \begin{macrocode} + \advance\dimen@\topskip + \ifdim \dimen@ >\@tempdima + \advance\dimen@-\baselineskip + \fi +% \end{macrocode} +% As a further restriction we want to see a minimum number of +% rows in the balanced result based on the setting of the counter +% |minrows|. If the starting value is lower we adjust. +% \changes{v1.8w}{2019/03/01}{Provide minrows counter for balancing} +% \begin{macrocode} + \@tempdima\dimexpr + \topskip +\c@minrows\baselineskip-\baselineskip\relax + \ifnum\dimen@<\@tempdima + \mult@info\@ne + {Start value + \the\dimen@ \space -> + \the\@tempdima \space (corrected for minrows)}% + \dimen@\@tempdima + \fi +% \end{macrocode} +% At the user's request we start with a higher value (or lower, but +% this usually only increases the number of tries). +% \begin{macrocode} + \advance\dimen@\c@unbalance\baselineskip +% \end{macrocode} +% We type out statistics if we were asked to do so. +% \changes{v1.4f}{1992/04/28}{\cs{on@line} added to tracing info} +% \begin{macrocode} + \mult@info\@ne + {Balance columns\on@line: + \ifnum\c@unbalance=\z@\else + (off balance=\number\c@unbalance)\fi + \@gobbletwo}% +% \end{macrocode} +% But we don't allow nonsense values for a start. +% \begin{macrocode} + \ifnum\dimen@<\topskip + \mult@info\@ne + {Start value + \the\dimen@ \space -> + \the\topskip \space (corrected)}% + \dimen@\topskip + \fi +% \end{macrocode} +% Now we try to find the final column height. We start by setting +% |\vbadness| to infinity (i.e.\ $10000$) to suppress +% underfull box reports while we are trying to find an acceptable +% solution. We do not need to do it in a group since at the end of +% the output routine everything will be restored. The setting of +% the final columns will nearly always produce underfull boxes with +% badness $10000$ so there is no point in warning the user about +% it. +% \changes{v1.2a}{1990/02/05}{Group around main loop removed.} +% \begin{macrocode} + \vbadness\@M +% \end{macrocode} +% We also allow for overfull boxes while we trying to split the +% columns. They can easily happen if we have objects with unusual depth. +% \changes{v1.8h}{2014/09/12}{Do not report overfull} +% \begin{macrocode} + \vfuzz \maxdimen +% \end{macrocode} +% The variable |\last@try| will hold the dimension used in the +% previous trial splitting. We initialize it with a negative value. +% \changes{v1.5?}{1994/?/?}{Initialize \cs{last@try}} +% \begin{macrocode} + \last@try-\p@ + \loop +% \end{macrocode} +% In order not to clutter up \TeX{}'s valuable main memory with +% things that are no longer needed, we empty all globally used box +% registers. This is necessary if we return to this point after an +% unsuccessful trial. We use |\process@cols| for this purpose, +% starting with |\mult@grightbox|. Note the extra braces around +% this macro call. They are needed since \PlainTeX{}'s +% |\loop|\ldots{}\allowbreak|\repeat| mechanism cannot be nested on +% the same level of grouping. +% \changes{v1.5a}{1992/11/04}{New box mechanism} +% \begin{macrocode} + {\process@cols\mult@grightbox + {\global\setbox\count@ + \box\voidb@x}}% +% \end{macrocode} +% The contents of box |\mult@box| are now copied globally to +% box~|\mult@grightbox|. (This will be the right-most column, as +% we shall see later.) +% \begin{macrocode} + \global\setbox\mult@grightbox + \copy\mult@box +% \end{macrocode} +% We start with the assumption that the trial will be successful. +% If we end up with a solution that is too bad we set +% |too@bad| to \texttt{true}. We also assume that all forced breaks +% (if any) will be used during balancing. If this is not the case +% we record this in |forcedbreak@leftover|. +% \changes{v1.5b}{1992/11/05}{New badness mechanism} +% \changes{v1.8k}{2015/03/21}{Init \cs{ifforcedbreak@leftover}} +% \begin{macrocode} +%<*badness> + \too@badfalse + \forcedbreak@leftoverfalse +%</badness> +% \end{macrocode} +% Using |\vsplit| we extract the other columns from box register +% |\mult@grightbox|. This leaves box register |\mult@box| +% untouched so that we can start over again if this trial was +% unsuccessful. +% \begin{macrocode} + {\process@cols\mult@firstbox{% + \global\setbox\count@ + \vsplit\mult@grightbox to\dimen@ +% \end{macrocode} +% After splitting we need to ensure that there isn't any space at +% the bottom, so we rebox once more. +% \changes{v1.8b}{2013/08/28}{Remove discardable items at the +% end of split boxes} +% \changes{v1.8k}{2015/03/21}{Do not use \cs{remove@discardable@items} +% here} +% \begin{macrocode} + \global\setbox\count@ + \vbox to\dimen@ + {\unvbox\count@}% +% \end{macrocode} +% After every split we check the badness of the resulting column, +% normally the amount of extra white in the column. +% \begin{macrocode} +%<*badness> + \ifnum\c@tracingmulticols>\@ne + \@tempcnta\count@ + \advance\@tempcnta-\mult@grightbox + \divide\@tempcnta \tw@ + \message{^^JColumn + \number\@tempcnta\space + badness: \the\badness\space}% + \fi +% \end{macrocode} +% If this badness is larger than the allowed column badness +% we reject this solution by setting |too@bad| to \texttt{true}. +% \begin{macrocode} + \ifnum\badness>\c@columnbadness + \ifnum\c@tracingmulticols>\@ne + \message{too bad + (>\the\c@columnbadness)}% + \fi + \too@badtrue + \fi +%</badness> + }}% +% \end{macrocode} +% There is one subtle point here: while all other constructed boxes +% have a depth that is determined by |\splitmaxdepth| and/or +% |\boxmaxdepth| the last box +% will get a natural depth disregarding the original setting and +% the value of |\splitmaxdepth| or |\boxmaxdepth|. This means that +% we may end up with a very large depth in box |\mult@grightbox| +% which would +% make the result of the testing incorrect. So we change the value +% by unboxing the box into itself. +% \begin{macrocode} + \global\setbox\mult@grightbox + \vbox{\unvbox\mult@grightbox}% +% \end{macrocode} +% We also save a copy |\mult@firstbox| at its ``natural'' size +% for later use. +% \begin{macrocode} + \setbox\mult@nat@firstbox + \vbox{\unvcopy\mult@firstbox}% +% \end{macrocode} +% After |\process@cols| has done its job we have the following +% situation: +% \begin{center} +% \begin{tabular}{r@{$\:\:\longleftarrow\:\:$}l} +% box |\mult@rightbox| & all material \\ +% box |\mult@gfirstbox| & first column \\ +% box |\mult@gfirstbox|${}+2$ & second column \\ +% \multicolumn{1}{c}{$\vdots$} & +% \multicolumn{1}{c}{$\vdots$} \\ +% box |\mult@grightbox| & last column +% \end{tabular} +% \end{center} +% We report the height of the first column, in brackets +% the natural size is given. +% \changes{v1.5?}{1994/?/?}{Show natural size} +% \begin{macrocode} + \ifnum\c@tracingmulticols>\@ne + \message{^^JFirst column + = \the\dimen@\space + (\the\ht\mult@nat@firstbox)}\fi +% \end{macrocode} +% If |\raggedcolumns| is in force older releases of this file also +% shrank the first column to its natural height at this point. +% This was done so that the first column doesn't run short compared +% to later columns but it is actually producing incorrect results +% (overprinting of text) in boundary cases, so since version v1.5q +% |\raggedcolumns| means allows for all columns to run slightly short. +% \changes{v1.5q}{1998/01/19}{Do not reset \cs{mult@firstbox} (pr2739)} +% \begin{macrocode} +% \ifshr@nking +% \global\setbox\mult@firstbox +% \copy\mult@nat@firstbox +% \fi +% \end{macrocode} +% Then we give information about the last column.\footnote{With +% \TeX{} version 3.141 it is now possible to use \LaTeX's +% \cs{newlinechar} in the \cs{message} command, but +% people with older \TeX{} versions will now get +% \texttt{\string^\string^J} instead of a new line on the screen.} +% \changes{v1.4a}{1992/02/12}{Changed to proper \cs{endlinechar} in\cs{message}} +% \begin{macrocode} + \ifnum\c@tracingmulticols>\@ne + \message{<> last column = + \the\ht\mult@grightbox^^J}% +% \end{macrocode} +% Some tracing code that we don't compile into the production version +% unless asked for. It will produce huge listings of the boxes +% involved in balancing in the transcript file. +% \changes{v1.6f}{2004/07/03}{need to use \cs{mult@grightbox} in the loop} +% \begin{macrocode} +%<*debug> + \ifnum\c@tracingmulticols>4 + {\showoutput + \batchmode + \process@cols\mult@grightbox + {\showbox\count@}}% + \errorstopmode + \fi +%</debug> + \fi +% \end{macrocode} +% We check whether our trial was successful. The test used is very +% simple: we merely compare the first and the last column. Thus +% the intermediate columns may be longer than the first if +% |\raggedcolumns| is used. If the right-most column is +% longer than the first then we start over with a larger value for +% |\dimen@|. +% \changes{v1.3c}{1991/03/03}{\cs{global}\cs{advance} left over from older code} +% \begin{macrocode} + \ifdim\ht\mult@grightbox >\dimen@ +% \end{macrocode} +% If the height of the last box is too large we mark this trial as +% unsuccessful. +% \changes{v1.5v}{1999/07/18}{Added tracing statements for +% trial unsuccessful} +% \begin{macrocode} +%<*badness> + \too@badtrue + \ifnum\c@tracingmulticols>\@ne + \typeout{Rejected: last + column too large!}% + \fi + \else +% \end{macrocode} +% \changes{v1.5v}{1999/07/18}{Check last column if it contains forced +% break and reject trial if that is the case} +% +% To ensure that there isn't a forced break in the last column we +% try to split off a box of size |\maxdimen| from |\mult@grightbox| +% (or rather from a copy of it). This should result in a void box +% after the split, unless there was a forced break somewhere within +% the column in which case the material after the break would have +% stayed in the box. +% \begin{macrocode} + \setbox\@tempboxa + \copy\mult@grightbox + \setbox\z@\vsplit\@tempboxa to\maxdimen + \ifvoid\@tempboxa +% \end{macrocode} +% Thus if |\@tempboxa| is void we have a valid solution. +% In this case we take a closer +% look at the last column to decide if this column should be made +% as long as all other columns or if it should be allowed to be +% shorter. +% For this we first have to rebox the column into a box of the +% appropriate height. If tracing is enabled we then display the +% badness for this box. +% \begin{macrocode} + \global\setbox\mult@grightbox + \vbox to\dimen@ + {\unvbox\mult@grightbox}% + \ifnum\c@tracingmulticols>\@ne + \message{Final badness: + \the\badness}% + \fi +% \end{macrocode} +% We then compare this badness with the allowed badness for the final +% column. If it does not exceed this value we use the box, otherwise +% we rebox it once more and add some glue at the bottom. +% \changes{v1.8h}{2014/09/12}{Use \cs{vfilmaxdepth}} +% \changes{v1.8j}{2015/03/07}{Use \cs{vfil} in this case} +% \begin{macrocode} + \ifnum\badness>\c@finalcolumnbadness + \global\setbox\mult@grightbox + \vbox to\dimen@ + {\unvbox\mult@grightbox\vfil}% + \ifnum\c@tracingmulticols>\@ne + \message{ setting natural + (> \the\c@finalcolumnbadness)}% + \fi + \fi +% \end{macrocode} +% If |\@tempboxa| above was not void our trial was unsuccessful and +% we report this fact and try again. +% \changes{v1.6f}{2004/07/03}{\texttt{/colbreak} guard in the wrong position} +% \begin{macrocode} + \else +% \end{macrocode} +% If we have unprocessed forced breaks we normally reiterate with a +% larger column size to fit them in eventually. However, if there +% are simply too many of them (e.g., 3 forced breaks but only 2 +% columns to balance) then this will never succeed and and we would +% continue growing the columns until we hit the largest possible +% column size. So in addition we check how big the column size is +% compared to available room and if we exceed this by +% |\maxbalancingoverflow| we give up and instead of balancing cut +% another normal page. To be indicate this case we set +% |forcedbreak@leftover| to true. +% \changes{v1.8k}{2015/03/21}{Watch out for columns growing too far in +% case of forced breaks} +% \changes{v1.8l}{2015/03/25}{Added additional tracing if column overflows} +% \begin{macrocode} + \@tempdima\@colroom + \advance\@tempdima \maxbalancingoverflow + \ifdim \dimen@ < \@tempdima + \too@badtrue + \ifnum\c@tracingmulticols>\@ne + \typeout{Rejected: unprocessed + forced break(s) in last column!}% + \fi + \else + \forcedbreak@leftovertrue + \ifnum\c@tracingmulticols>\@ne + \typeout{Failed: columns too large + with unprocessed forced break(s)!}% + \fi + \fi + \fi + \fi +% \end{macrocode} +% If the natural height of the first box is smaller than the +% current trial size but is larger than the previous trial size it +% is likely that we have missed a potentially better +% solution. (This could have happened if for some reason our first +% trial size was too high.) In that case we dismiss this trial and +% restart using the natural height for the next trial. +% \begin{macrocode} + \ifdim\ht\mult@nat@firstbox<\dimen@ + \ifdim\ht\mult@nat@firstbox>\last@try + \too@badtrue + \ifnum\c@tracingmulticols>\@ne + \typeout{Retry: using natural + height of first column!}% + \fi + \dimen@\ht\mult@nat@firstbox + \last@try\dimen@ + \advance\dimen@-\p@ + \fi + \fi +% \end{macrocode} +% Finally the switch |too@bad| is tested. If it was made true +% either earlier on or due to a rightmost column being too large +% we try again with a slightly larger value for |\dimen@|. +% \begin{macrocode} + \iftoo@bad +%</badness> + \advance\dimen@\p@ + \repeat +% \end{macrocode} +% If we come out of the loop with the switch |forcedbreak@leftover| +% set to true then balancing has failed and we should cut a normal +% page. We indicate this below with |\too@badtrue| when any of the +% columns get too high, so we set this flag here too in order to +% get the same processing logic.\footnote{Should get cleaned up as +% we now have two different routes to reach this part of the +% processing.} +% \changes{v1.8k}{2015/03/21}{} +% \begin{macrocode} + \ifforcedbreak@leftover + \too@badtrue + \else +% \end{macrocode} +% At that point |\dimen@| holds the height that was determined by +% the balancing loop. +% If that height for the columns turns out to be larger +% than the available space (which is |\@colroom|) we squeeze the +% columns into the space assuming that they will have enough +% shrinkability to allow this.\footnote{This might be wrong, since +% the shrinkability that accounts for the amount of material might +% be present only in some columns. But it is better to try then to +% give up directly.} +% However, this squeezing should only be done if we are balancing +% columns on the main galley and \emph{not} if we are building a +% boxed multicol (in the latter case the current |\@colroom| is +% irrelevant since the produced box might be moved anywhere at a +% later stage). +% \changes{v1.3c}{1991/03/03}{Limit column height to \cs{@colroom}} +% \changes{v1.5q}{1998/01/19}{Removed setting \cs{dimen@} (pr2739)} +% \changes{v1.5y}{2000/06/10}{Limit column height only in unrestricted +% mode (pr/3212)} +% \begin{macrocode} + \if@boxedmulticols\else + \ifdim\dimen@>\@colroom + \dimen@\@colroom + \fi + \fi +% \end{macrocode} +% Then we move the contents of the odd-numbered box registers to +% the even-numbered ones, shrinking them if requested. +% We have to use |\vbox| not |\vtop| (as it was done in +% the first versions) since otherwise the resulting boxes will have +% no height (\TB\/ page 81). This would mean that extra +% |\topskip| is added when the boxes are returned to the +% page-builder via |\page@sofar|. +% \changes{v1.3a}{1990/05/20}{Changed \cs{vtop} to \cs{vbox}.} +% \begin{macrocode} + \process@cols\mult@rightbox + {\@tempcnta\count@ + \advance\@tempcnta\@ne +% \end{macrocode} +% when putting the final column together we want overfull +% information: +% \begin{macrocode} + \vfuzz\z@ + \setbox\count@\vbox to\dimen@ + {% +% \end{macrocode} +% +% \changes{v1.8h}{2014/09/12}{Use \cs{vfilmaxdepth}} +% \begin{macrocode} + \vskip \z@ + \@plus-\multicolundershoot + \@minus-\multicolovershoot + \unvbox\@tempcnta + \ifshr@nking\vfilmaxdepth\fi + }% +% \end{macrocode} +% If the resulting box is overfull there was too much material to +% fit into the available space. The question though is how much? If +% it wasn't more than |\maxbalancingoverflow| we accept it still to +% avoid getting very little material for the next page (which we +% would then have difficulties to balance). +% \changes{v1.8a}{2011/12/20}{Balancing concept improved} +% \begin{macrocode} + \ifnum\badness>\@M + \vfuzz\maxdimen % no overfull warning + \setbox\@tempboxa \vbox to\dimen@ + {\vskip-\maxbalancingoverflow + \unvcopy\count@}% + \ifnum\badness>\@M + \mult@info\@ne + {Balanced column more than + \the\maxbalancingoverflow\space + too large}% +% \end{macrocode} +% Fail the balancing attempt: +% \begin{macrocode} + \too@badtrue + \else +% \end{macrocode} +% Otherwise report that there is a problem but within the accepted +% boundary. +% \begin{macrocode} + \mult@info\@ne + {Balanced column + too large, but less than + \the\maxbalancingoverflow}% + \fi + \fi + }% +% \end{macrocode} +% Finally end the |\ifforcedbreak@leftover| conditional. +% \changes{v1.8k}{2015/03/21}{Finish the new conditional} +% \begin{macrocode} + \fi +} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\maxbalancingoverflow} +% Amount that balancing is allowed to overflow the available column +% space. We default to 12pt which means about one line in most +% layouts. +% \changes{v1.8a}{2011/12/20}{\cs{maxbalancingoverflow} parameter added} +% \begin{macrocode} +\newdimen\maxbalancingoverflow +\maxbalancingoverflow=12pt +% \end{macrocode} +% \end{macro} + +% \end{multicols} +% +% \begin{multicols}{2}[\subsection{The box allocations}] +% +% \begin{macro}{\mult@rightbox} +% \begin{macro}{\mult@grightbox} +% \begin{macro}{\mult@firstbox} +% \begin{macro}{\mult@gfirstbox} +% Early releases of these macros used the first box registers +% 0, 2, 4,\ldots\ for global boxes and 1, 3, 5,\ldots\ for the +% corresponding local boxes. (You might still find some traces +% of this setup in the documentation, sigh.) This produced a problem +% at the moment we had more than 5 columns because then officially +% allocated boxes were overwritten by the algorithm. +% The new release now uses private box registers +% \begin{macrocode} +\newbox\mult@rightbox +\newbox\mult@grightbox +\newbox\mult@gfirstbox +\newbox\mult@firstbox +\newbox\@tempa\newbox\@tempa +\newbox\@tempa\newbox\@tempa +\newbox\@tempa\newbox\@tempa +\newbox\@tempa\newbox\@tempa +\newbox\@tempa\newbox\@tempa +\newbox\@tempa\newbox\@tempa +\newbox\@tempa\newbox\@tempa +\newbox\@tempa\newbox\@tempa +\newbox\@tempa +\let\@tempa\relax +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% +% +% \end{multicols} +% +% +% \begin{multicols}{2}[\section{New macros and hacks for version 1.2}] +% +% \begin{macro}{\emergencystretch} +% \begin{macro}{\setemergencystretch} +% If we don't use \TeX{} 3.0 |\emergencystretch| is undefined +% so in this case we simply add it as an unused \meta{dimen} +% register. +% \changes{v1.4j}{1992/06/25}{Setting of \cs{emergencystretch} on top +% removed.} +% \begin{macrocode} +\@ifundefined{emergencystretch} + {\newdimen\emergencystretch}{} +% \end{macrocode} +% \changes{v1.2a}{1990/02/05}{Macro added.} +% My tests showed that the following formula worked pretty well. +% Nevertheless the |\setemergencystretch| macro also gets +% |\hsize| as second argument to enable the user to try +% different formulae. +% \begin{macrocode} +\def\setemergencystretch#1#2{% + \emergencystretch 4pt + \multiply\emergencystretch#1} +% \end{macrocode} +% \end{macro} +% \end{macro} + + +% \begin{macro}{\set@floatcmds} +% \changes{v1.2a}{1990/02/05}{Macro added.} +% \changes{v1.5g}{1994/06/07}{Updated since floats have changed} +% \changes{v1.5j}{1994/06/07}{Updated since floats have changed again} +% \changes{v1.5l}{1995/10/19}{Added \cs{@largefloatcheck}} +% \changes{v1.6g}{2006/02/23}{Added \cs{@minipagefalse}} +% \changes{v1.6h}{2008/12/05}{Use \cs{@endfloatbox} to better support +% the modifications done by the float package} +% Even if this should be used as a hook we use a |@| in the +% name since it is more for experts. +% \begin{macrocode} +\def\set@floatcmds{% + \let\@dblfloat\@dbflt + \def\end@dblfloat{\@endfloatbox + \@largefloatcheck + \outer@nobreak +% \end{macrocode} +% This is cheap (deferring the floats until after the current page) +% but any other solution would go deep into \LaTeX's output +% routine and I don't like to work on it until I know which parts +% of the output routine have to be reimplemented anyway for +% \LaTeX3. +% \begin{macrocode} + \ifnum\@floatpenalty<\z@ +% \end{macrocode} +% We have to add the float to the |\@deferlist| because we assume +% that outside the \mc{} environment we are in one column mode. +% This is not entirely correct, I already used the \mc{} +% environment inside of \LaTeX{}s |\twocolumn| declaration but it +% will do for most applications. +% \begin{macrocode} + \@cons\@deferlist\@currbox + \fi + \ifnum\@floatpenalty=-\@Mii + \@Esphack + \fi}} +% \end{macrocode} +% \end{macro} +% +% \end{multicols} +% +% \begin{multicols}{2}[\subsection{Maintaining the mark registers}] +% \label{sec:v14} +% +% This section contains the routines that set the marks so that they +% will be handled correctly. They have been introduced with version~1.4. +% +% \begin{macro}{\kept@topmark} +% \changes{v1.4h}{1992/06/04}{Init to double brace pair} +% \begin{macro}{\kept@firstmark} +% \begin{macro}{\kept@botmark} +% First thing we do is to reserve three macro names to hold the +% replacement text for \TeX's primitives |\firstmark|, |\botmark| and +% |\topmark|. We initialize the first two to be empty and +% |\kept@topmark| to contain two empty pair of braces. This is +% necessary since |\kept@topmark| is supposed to contain the last +% mark from a preceding page and in \LaTeX{} any ``real'' mark must +% contain two parts representing left and right mark information. +% \begin{macrocode} +\def\kept@topmark{{}{}} +\let\kept@firstmark\@empty +\let\kept@botmark\@empty +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% +% +% \begin{macro}{\return@nonemptymark} +% Sometimes we want to return the value of a ``kept'' mark into a +% |\mark| node on the main vertical list. This is done by the +% function |\return@nonemptymark|. As the name suggests it only acts +% if the replacement text of the kept mark is non-empty. This is done +% to avoid adding an empty mark when no mark was actually present. If +% we would nevertheless add such a mark it would be regarded as a +% valid |\firstmark| later on. +% \begin{macrocode} +\def\return@nonemptymark#1#2{% + \ifx#2\@empty + \else +% \end{macrocode} +% For debugging purposes we take a look at the value of the kept mark +% that we are about to return. This code will get stripped out for +% production. +% \begin{macrocode} +%<*marktrace> + \mult@info\tw@ + {Returned #1 mark:\MessageBreak + \meaning#2}% +% \nobreak +% \fi +%</marktrace> +% \end{macrocode} +% Since the contents of the mark may be arbitrary \LaTeX{} code we +% better make sure that it doesn't get expanded any further. (Some +% expansion have been done already during the execution of +% |\markright| or |\markboth|.) We therefore use the usual mechanism +% of a toks register to prohibit expansion.\footnote{Due to the +% current definition of \cs{markright} etc.\ it wouldn't +% help to define the \cs{protect} command to prohibit +% expansion as any \cs{protect} has already vanished due to +% earlier expansions.} +% \changes{v1.4n}{1992/09/10}{Make marks robust} +% \changes{v1.5t}{1999/03/22}{re-add \cs{mark} command which was commented out +% by mistake at some point in 1998 (pr/2978)} +% \begin{macrocode} + \toks@\expandafter{#2}% + \mark{\the\toks@}% +% \end{macrocode} +% We don't want any breakpoint between such a returned mark and the +% following material (which is usually just the box where the mark +% came from). +% \begin{macrocode} + \nobreak + \fi} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\get@keptmarks} +% If we have some material in a box register we may want to get the +% first and the last mark out of this box. This can be done with +% |\get@keptmarks| which takes one argument: the box register number +% or its nick name defined by |\newbox|. +% \begin{macrocode} +\def\get@keptmarks#1{% +% \end{macrocode} +% For debugging purposes we take a look at the current dimensions +% of the box since in earlier versions of the code I made some +% mistakes in this area. +% \begin{macrocode} +%<*debug> + \typeout{Mark box #1 before: + ht \the\ht#1, dp \the\dp#1}% +%</debug> +% \end{macrocode} +% Now we open a new group and locally copy the box to itself. As a +% result any operation, i.e.\ |\vsplit|, will only have a local +% effect. Without this trick the box content would get lost up to +% the level where the last assignment to the box register was done. +% \begin{macrocode} + \begingroup + \vbadness\@M + \setbox#1\copy#1% +% \end{macrocode} +% Now we split the box to the maximal possible dimension. This +% should split off the full contents of the box so that effectively +% everything is split off. As a result |\splitfirstmark| and +% |\splitbotmark| will contain the first and last mark in the box +% respectively. +% \begin{macrocode} + \setbox#1\vsplit#1to\maxdimen +% \end{macrocode} +% Therefore we can now set the kept marks which is a global +% operation and afterwards close the group. This will restore the +% original box contents. +% \begin{macrocode} + \set@keptmarks + \endgroup +% \end{macrocode} +% For debugging we take again a look at the box dimension which +% shouldn't have changed. +% \begin{macrocode} +%<*debug> + \typeout{Mark box #1 \space after: + ht \the\ht#1, dp \the\dp#1}% +%</debug> +} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\set@keptmarks} +% The macro |\set@keptmarks| is responsible for setting +% |\kept@firstmark| and |\kept@botmark|, by checking the current +% values for |\splitfirstmark| and |\splitbotmark|. +% \begin{macrocode} +\def\set@keptmarks{% +% \end{macrocode} +% If |\kept@firstmark| is empty we assume that it isn't set. This +% is strictly speaking not correct as we loose the ability to have +% marks that are explicitly empty, but for standard \LaTeX{} +% application it is sufficient. If it is non-empty we don't change +% the value---within the output routines it will then be restored +% to |\@empty|. +% \begin{macrocode} + \ifx\kept@firstmark\@empty +% \end{macrocode} +% We now put the contents of |\splitfirstmark| into +% |\kept@firstmark|. In the case that there wasn't any mark at all +% |\kept@firstmark| will not change by that operation. +% \begin{macrocode} + \expandafter\gdef\expandafter + \kept@firstmark + \expandafter{\splitfirstmark}% +% \end{macrocode} +% When debugging we show the assignment but only when something +% actually happened. +% \begin{macrocode} +%<*marktrace> + \ifx\kept@firstmark\@empty\else + \mult@info\tw@ + {Set kept first mark:\MessageBreak + \meaning\kept@firstmark% + \@gobbletwo}% + \fi +%</marktrace> + \fi +% \end{macrocode} +% We always try to set the bottom mark to the |\splitbotmark| but +% of course only when there has been a |\splitbotmark| at all. +% Again, we assume that an empty |\splitbotmark| means that the +% split off box part didn't contain any marks at all. +% \begin{macrocode} + \expandafter\def\expandafter\@tempa + \expandafter{\splitbotmark}% + \ifx\@tempa\@empty\else + \global\let\kept@botmark\@tempa +%<*marktrace> + \mult@info\tw@ + {Set kept bot mark:\MessageBreak + \meaning\kept@botmark% + \@gobbletwo}% +%</marktrace> + \fi}% +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\prep@keptmarks} +% The |\prep@keptmarks| function is used to initialize the kept +% marks from the contents of |\partial@page|, i.e.\ the box that +% holds everything from the top of the current page prior to +% starting the \mc{} environment. However, such a box is only +% available if we are not producing a boxed \mc{}. +% \begin{macrocode} +\def\prep@keptmarks{% + \if@boxedmulticols \else + \get@keptmarks\partial@page + \fi} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\remove@discardable@items} +% There are situations when we may have some space at the end of a +% column and this macro here will attempt to get rid of it. The +% typical \LaTeX{} sequence is a series of self-canceling glues so +% if we remove them recursively we are usually fine. +% +% Special care is needed with handling |\vspace*| as that +% corresponds to |\penalty10000|, |\vskip <skip>|, followed by +% |\vskip 0pt|. If we see this sequence going backwards in the the +% vertical list we assume that this is a ``desired'' space. We +% therefore stop the recursion and reinsert the spaces. +% +% As the multicol code sometimes add an explicit penalty at the end +% of a column we first attempt to remove it in case it is there. +% \changes{v1.8m}{2015/03/31}{Another rewrite of +% \cs{remove@discardable@items} hopefully okay now} +% \begin{macrocode} +\skip0=0pt +\edef\the@zero@skip{\the\skip0} +\def\remove@discardable@items{% + \unpenalty +% \end{macrocode} +% Save a previous skip (if there) and then remove it, we can't +% really tell the difference between no skip an a skip of zero but +% that's life. +% \begin{macrocode} + \edef\@tempa{\the\lastskip}% +%\typeout{s1=\@tempa}% + \unskip +% \end{macrocode} +% If it was a zero skip (or none) we save the next previous skip +% (if any). +% \begin{macrocode} + \ifx\@tempa\the@zero@skip + \edef\@tempb{\the\lastskip}% +%\typeout{s2=\@tempb}% +% \end{macrocode} +% If this one again was zero (or more likely not there in the first +% place) we stop. +% \begin{macrocode} + \ifx\@tempb\the@zero@skip + \else +% \end{macrocode} +% Otherwise we remove this ``real'' skip. Then we look if it was +% preceded by a penalty of 10000 (i.e., a |\nobreak|) +% \begin{macrocode} + \unskip +%\typeout{p=\lastpenalty}% + \ifnum \lastpenalty=\@M +% \end{macrocode} +% If so this was a |\vspace*| or something equivalent to +% it. Therefore we reintroduce the skips and stop. Otherwise we +% recurse. +% \begin{macrocode} + \vskip\@tempb\vskip\@tempa\relax + \else + \remove@discardable@items + \fi + \fi + \else +% \end{macrocode} +% If the first skip was a non-zero skip we recurse as well. +% \begin{macrocode} + \remove@discardable@items + \fi +} +% \end{macrocode} +% \end{macro} +% +% \begin{macrocode} +%<*badness> +\newif\iftoo@bad +\def\too@badtrue{\global\let\iftoo@bad\iftrue} +\def\too@badfalse{\global\let\iftoo@bad\iffalse} +% \end{macrocode} +% +% \changes{v1.8k}{2015/03/21}{The new switch} +% \begin{macrocode} +\newif\ifforcedbreak@leftover +% \end{macrocode} +% +% \begin{macro}{\c@minrows} +% \changes{v1.8w}{2019/03/01}{Provide minrows counter for balancing} +% \begin{macrocode} +\newcount\c@minrows +\c@minrows=1 +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\c@columnbadness} +% \begin{macro}{\c@finalcolumnbadness} +% \begin{macrocode} +\newcount\c@columnbadness +\c@columnbadness=10000 +\newcount\c@finalcolumnbadness +\c@finalcolumnbadness=9999 + +\newdimen\last@try + +% \end{macrocode} +% +% \changes{v1.5z1}{2003/02/17}{Change wrong default for +% \cs{multicolovershoot} to zero (pr/3465).} +% \begin{macrocode} +\newdimen\multicolovershoot +\newdimen\multicolundershoot +\multicolovershoot=0pt +\multicolundershoot=2pt +\newbox\mult@nat@firstbox +%</badness> +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\mult@info} +% A helper for producing info messages +% \begin{macrocode} +\def\mult@info#1#2{% + \ifnum\c@tracingmulticols>#1% + \GenericWarning + {(multicol)\@spaces\@spaces}% + {Package multicol: #2}% + \fi +} +% \end{macrocode} +% \end{macro} +% +% \end{multicols} +% +% +% \begin{multicols}{2}[\section{Fixing the +% \cs{columnwidth}}] +% +% \begin{macro}{\@footnotetext} +% \changes{v1.5o}{1997/11/16}{Redefinition added pr/2664.} +% \changes{v1.5r}{1998/08/17}{Use \cs{@footnotetext} but with +% local change to \cs{columnwidth}.} +% \begin{macro}{\mult@footnotetext} +% \changes{v1.5r}{1998/08/17}{Macro removed again.} +% If we store the current column width in |\columnwidth| we have +% to redefine the internal |\@footnotetext| macro to use |\textwidth| +% for the width of the footnotes rather than using the original +% definition. +% +% Starting with version v1.5r this is now done in a way that the original +% definition is still used, except that locally |\columnwidth| is set to +% |\textwidth|. +% +% This solves two problems: first redefinitions of |\@footnotetext| +% done by a class will correctly survive and second if multicols is +% used inside a minipage environment the special definition of +% |\@footnotetext| in that environment will be picked up and not the +% one for the main galley (the latter would result in all footnotes +% getting lost in that case). +% +% See the definition of the |\multicols| command further up for the exact +% code. +% \end{macro} +% \end{macro} +% \end{multicols} +% +% +% \begin{multicols*}{2}[\section{Further extensions}] +% +% This section does contain code for extensions added to this package +% over time. Not all of them may be active, some might sit dormant and +% wait for being activated in some later release. +% +% \subsection{Not balancing the columns} +% +% This is fairly trivial to implement. we just have to disable the +% balancing output routine and replace it by the one that ships out +% the other pages. +% +% \begin{macro}{\multicols*} +% \changes{v1.5q}{1998/01/19}{Macro added} +% The code for this environment was suggested by Matthias Clasen. +% \begin{macrocode} +%<*nobalance> + \@namedef{multicols*}{% +% \end{macrocode} +% If we are not on the main galley, i.e., inside a box of some +% sort, that approach will not work since we don't have a vertical +% size for the box so we better warn that we balance anyway. +% \begin{macrocode} + \ifinner + \PackageWarning{multicol}% + {multicols* inside a box does + not make sense.\MessageBreak + Going to balance anyway}% + \else +% \end{macrocode} +% If we aren't balancing we change the |\balance@columns@out| to +% work like the normal output routine that cuts normal +% pages. However, there is a catch: In case the last page we cut +% (after seeing the end of the environment) is actually larger than +% a page (for example, if it contains more |\columnbreak| commands +% than columns) we end up with some leftover material that is +% returned to the main galley, but now the environment end penalty +% is missing. So we add another one here too. Of course that +% shouldn't be done if there is really only a single final page, +% but fortunately in that case we have just finished a page and any +% penalty on the recent contributions will be discarded, thus the +% extra one is harmless---puh. +% \changes{v1.8t}{2018/06/26}{Re-add end penalty for +% \texttt{multicols*} environment to guard against leftovers (git/53)} +% \begin{macrocode} + \def\balance@columns@out + {\multi@column@out \penalty-\@Mvi }% + \fi + \begin{multicols} +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\endmulticols*} +% When ending the environment we simply end the inner +% \texttt{multicols} environment, except that we better also stick +% in some stretchable vertical glue so that the last column still +% containing text is not vertically stretched out. +% +% We do this as follows: first we ensure that we are back in vertical mode +% and then we cancel out |\lastskip| if it was +% positive (in case of a negative glue we assume that it was +% deliberate, for a deliberate positive glue one needs to use +% |\vspace*|). We can't simply use |\remove@discardable@items| here +% as this only works inside boxes but we are here on the main +% vertical list. +% +% Then we back up by |\prevdepth| but not more than |\boxmaxdepth| +% so that a baseline of the last box is now at the bottom. This way +% the material will align properly in case something like |\vfill| +% spreads it out after all. +% Finally we append |\vfil| to put white space at the bottom of the +% column, but we only do this if we aren't anyway doing |\raggedcolumns|. +% \changes{v1.5q}{1998/01/19}{Macro added} +% \changes{v1.8h}{2014/09/12}{Use \cs{vfilmaxdepth}} +% \changes{v1.8i}{2014/10/28}{Add \cs{null} to hide the final fill and only add +% vertical space if not doing \cs{raggedcolumns}} +% \changes{v1.8j}{2015/03/07}{Redesign the whole approach.} +% \changes{v1.8k}{2015/03/21}{And a bit more redesign because of the +% change in \cs{remove@discardable@items}} +% \changes{v1.8o}{2016/02/08}{Ensure we are back in vmode before using +% \cs{prevdepth} (pr/4448)} +% \begin{macrocode} +\@namedef{endmulticols*}{% + \par + \ifdim\lastskip>\z@ \vskip-\lastskip \fi + \ifdim \prevdepth>\z@ + \vskip-\ifdim\prevdepth>\boxmaxdepth + \boxmaxdepth + \else \prevdepth \fi + \fi + \ifshr@nking\else + \vfil + \fi + \end{multicols}} +%</nobalance> +% \end{macrocode} +% \end{macro} +% +% +% \subsection{Manual column breaking} \label{sec:colbreak} +% +% The problem with manual page breaks within \mc{} is the fact that +% during collection of material for all columns a page-forcing penalty +% (i.e. -10000 or higher) would stop the collecting pass which is not +% quite what is desired. On the other hand, using a penalty like -9999 +% would mean that there would be occasions where the |\vsplit|ing +% operations within \mc{} would ignore that penalty and still choose a +% different break point. +% +% For this reason the current implementation +% uses a completely different approach. In a nutshell it extends the \LaTeX{} +% output routine handling by introducing an additional penalty flag +% (i.e., a penalty which is forcing but higher than -10000 so that the +% output routine can look at this value and thus knows why it has been +% called). +% +% Inside the output routine we test for this value and if it appears +% we do two things: save the galley up to this point in a special box +% for later use and reduce the |\vsize| by the height of the material +% seen. This way the forcing penalty is now hidden in that box and we +% can restart the collection process for the remaining +% columns. (This is done in |\speci@ls| above.) +% +% In the output routines that do the |\vsplit|ting either for +% balancing or for a full page we simply combine box~255 with the +% saved box thus getting a single box for splitting which now +% contains forcing breaks in the right positions. +% +% +% \begin{macro}{\columnbreak} +% \changes{v1.5u}{1999/05/25}{Macro added} +% |\columnbreak| is modeled after |\pagebreak| except that we +% generate a penalty -10005. +% \begin{macrocode} +\mathchardef\@Mv=10005 +\def\columnbreak{% +% \end{macrocode} +% We have to ensure that it is only used within a \mc{} +% environment since if that penalty would be seen by the unmodified +% \LaTeX{} output routine strange things would happen. +% \begin{macrocode} + \ifnum\col@number<\tw@ + \PackageError{multicol}% + {\noexpand\columnbreak outside multicols}% + {This command can only be used within + a multicols or multicols* environment.}% + \else + \ifvmode + \penalty -\@Mv\relax + \else + \@bsphack + \vadjust{\penalty -\@Mv\relax}% + \@esphack + \fi + \fi} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\colbreak@box} +% \changes{v1.5u}{1999/05/25}{Macro added} +% Need a box to collect the galley up to the column break. +% \begin{macrocode} +\newbox\colbreak@box +%</package> +% \end{macrocode} +% \end{macro} +% +% +% \subsection{Supporting right-to-left languages} \label{sec:RL} +% +% +% \changes{v1.7a}{2010/10/24}{RL language support added} +% \changes{v1.7b}{2011/12/18}{RL language support fixed} +% +% \begin{macro}{\LR@column@boxes} +% |\LR@column@boxes| is called when we are assembling the columns for left +% to right typesetting. When we start we are inside an |\hbox| of +% full width. +% Left to right typesetting is fairly easy, we basically output +% each column box intermixed with vertical rules and proper +% spacing. As this happens inside a box of a defined width the +% rules and the columns automatically get into the right positions. +% \begin{macrocode} +\def\LR@column@boxes{% +% \end{macrocode} +% We loop through the columns with |\process@cols| +% \begin{macrocode} + \process@cols\mult@gfirstbox{% +% \end{macrocode} +% If the depth of the current box is larger than the maximum found +% so far in |\dimen2| we update that register for later use. +% \changes{v1.6a}{2003/03/15}{Preparing for adjusting \cs{prevdepth}} +% \begin{macrocode} + \ifdim\dp\count@>\dimen\tw@ + \global\dimen\tw@\dp\count@ \fi +% \end{macrocode} +% If the \texttt{colaction} option is given we write out status +% information about the current column, otherwise the next command +% does nothing. +% \changes{v1.8e}{2014/04/23}{Support \cs{docolaction}} +% \begin{macrocode} + \mc@col@status@write +% \end{macrocode} +% The typeset box followed by the column rule material +% \begin{macrocode} + \box\count@ + \hss{\columnseprulecolor\vrule + \@width\columnseprule}\hss}% +% \end{macrocode} +% As you will have noticed, we started with box register +% |\mult@gfirstbox| (i.e.\ +% the left column). So this time |\count@| looped through 2, +% 4,\ldots\ (plus the appropriate offset). +% Finally we add box |\mult@rightbox| and we are done. +% \changes{v1.5a}{1992/11/04}{New box mechanism} +% \changes{v1.6a}{2003/03/15}{Preparing for adjusting \cs{prevdepth}} +% Again we may have to update |\dimen\tw@|. +% \begin{macrocode} + \ifdim\dp\mult@rightbox>\dimen\tw@ + \global\dimen\tw@\dp\mult@rightbox \fi +% \end{macrocode} +% If the \texttt{colaction} option is given we write out status +% information about the last column, otherwise the next command +% does nothing. +% \changes{v1.8e}{2014/04/23}{Support \cs{docolaction}} +% \begin{macrocode} + \mc@lastcol@status@write + \box\mult@rightbox +} +% \end{macrocode} +% \end{macro} + +% \begin{macro}{\RL@column@boxes} +% Assembling the boxes for right to left typesetting is far more +% complicated. When I first tried to build a solution for this my +% thinking was that all that is necessary to do is to reverse the +% order of the columns. But such an approach produces a subtle bug: +% If we work this way then the first column put on the page will be +% the last column of the text to read. and this means that the +% order in which \TeX{} executes write statements or assembles mark +% material will not happen in the order of the textual flow. So if, +% for example each column contains a section command then these +% sections will appear in reverse order in the table of content. +% +% For this reason some amount of gymnastics is needed to add the +% columns in their natural flow. +% \begin{macrocode} +\def\RL@column@boxes{% +% \end{macrocode} +% First step is to put all rules in the right place (without adding +% the comes which are instead represented by a space of |\hsize|. +% \begin{macrocode} + \process@cols\mult@gfirstbox{% + \hskip\hsize + \hss{\columnseprulecolor\vrule + \@width\columnseprule}\hss + }% + \hskip\hsize +% \end{macrocode} +% At this point in the code our typesetting reference point is at +% the right end of the rightmost column (or rather where that column +% should appear). +% +% We are now typesetting all columns by first backing up by their +% width (which is |\hsize|) then typesetting the box and then +% backing up again, but this time further, i.e., also across the +% column separation. That will then enable us to typeset the next +% column using the same approach until we are done with all but the +% final column. +% \begin{macrocode} + \process@cols\mult@gfirstbox{% + \ifdim\dp\count@>\dimen\tw@ + \global\dimen\tw@\dp\count@ \fi + \hskip-\hsize +% \end{macrocode} +% +% \changes{v1.8e}{2014/04/23}{Support \cs{docolaction}} +% \begin{macrocode} + \mc@col@status@write + \box\count@ + \hskip-\hsize + \hskip-\columnsep + }% +% \end{macrocode} +% The approach for the final column is similar only that we do not +% have to back up over any column gap. +% \begin{macrocode} + \ifdim\dp\mult@rightbox>\dimen\tw@ + \global\dimen\tw@\dp\mult@rightbox \fi + \hskip-\hsize +% \end{macrocode} +% +% \changes{v1.8e}{2014/04/23}{Support \cs{docolaction}} +% \begin{macrocode} + \mc@lastcol@status@write + \box\mult@rightbox + \hskip-\hsize +% \end{macrocode} +% However we do have to move the reference point to its right +% place: to make the rules appear at the expected places, we should +% get the typesetting position to the far right again. As we at the +% moment at the far left we skip to the far right like this: +% \begin{macrocode} + \hskip\full@width + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\RLmulticolcolumns} +% \begin{macro}{\LRmulticolcolumns} +% \begin{macro}{\mc@align@columns} +% Macros to switch between left-right and right-left typesetting. In LR +% typesetting the |\LR@column@boxes| is used to combine +% the columns. When typesetting right to left the |\RL@column@boxes| +% is used instead. +% \begin{macrocode} +\newcommand\RLmulticolcolumns + {\let\mc@align@columns + \RL@column@boxes} +\newcommand\LRmulticolcolumns + {\let\mc@align@columns + \LR@column@boxes} +% \end{macrocode} +% The default is left-to-right: +% \begin{macrocode} +\LRmulticolcolumns +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% +% +% \subsection{Supporting \texttt{\textbackslash docolaction}} +% +% \changes{v1.8e}{2014/04/23}{Support \cs{docolaction}} +% +% Whenever we want to do something that depends on the current +% column we execute \verb=\docolaction=. This command takes one +% optional and three mandatory arguments. The mandatory ones denote +% what to do if this is a ``left'', ``middle'', or ``right'' column +% and the optional one is simply there to say what to do if we don't +% know (default is to use the ``left'' column action in that case). +% +% \begin{macro}{\mc@col@check@num} +% We use one counter \verb=\mc@col@check@num= to generate us unique +% label names. Each time we execute \verb=\docolaction= we increment +% this counter to get a new name. +% \begin{macrocode} +\newcount\mc@col@check@num +% \end{macrocode} +% \end{macro} +% +% The generated ``labels'' are named +%\begin{verbatim} +%\mc@col-\the\mc@col@check@num +%\end{verbatim} +% and they hold as values the +% numbers 1, 2, or 3 denoting the current column type. + +% \begin{macro}{\docolaction} +% +% The \verb=\docolaction= scans for a star and optional argument +% and 3 mandatory ones, but we do this in chunks (not having xparse +% available). +% +% \changes{v1.8u}{2018/11/09}{Support star with \cs{docolaction}} +% \begin{macrocode} +\newcommand\docolaction{% +% \end{macrocode} +% First check is the support is enabled. +% \begin{macrocode} + \ifx\mc@col@status@write\relax + \PackageError{multicol}% + {Option 'colaction' not selected}% + {\string\docolaction\space + requires the use of the 'colaction' + option on the package}% + \fi +% \end{macrocode} +% Then prepare \verb=\mc@col@type=. +% \begin{macrocode} + \global\advance\mc@col@check@num\@ne + \edef\mc@col@type{\expandafter\ifx + \csname mc@col-\the\mc@col@check@num + \endcsname\relax + 0\else + \csname mc@col-\the\mc@col@check@num + \endcsname + \fi}% +% \end{macrocode} +% Finally check for a star, record this information and then call +% \verb=\@docolaction= to do the rest. +% \begin{macrocode} + \@ifstar + {\@docolactionstartrue \@docolaction}% + {\@docolactionstarfalse\@docolaction}% +} +% \end{macrocode} +% +% \begin{macrocode} +\newcommand\@docolaction[4][1]{% +% \end{macrocode} +% +% How does the column number get associated with our label? We +% do do this by writing another line into the aux file. Here are the +% preparations. +% \begin{macrocode} + \edef\@docolactioncheck{\write\@auxout + {\string\mc@set@col@status + {mc@col-\the\mc@col@check@num}% + {\mc@col@type}}}% +% \end{macrocode} +% Where we do the actual \verb=\write= depends on the whether or +% not we gave seen a \texttt{*}. If yes, we do it first and then +% execute the code argument, otherwise we execute that code first +% and check at the point after that. +% \begin{macrocode} + \if@docolactionstar \@docolactioncheck \fi +% \end{macrocode} +% We prefix with 0 so that an unknown label (that returns +% \verb=\relax=) will result in case 0 +% \begin{macrocode} + \ifcase \mc@col@type\relax +% \end{macrocode} +% If column is unknown we use the default action or the action +% denoted by the optional argument (so that arg can take the value +% 1, 2, 3). +% \begin{macrocode} + \ifcase #1\or #2\or#3\or#4\fi + \or +% \end{macrocode} +% Otherwise we know (or think we know) that this is a first, middle, +% or last column: +% \begin{macrocode} + #2% % 1 First col + \or + #3% % 2 any middle col + \or + #4% % 3 last col + \else + \ERRORwrongdefaultgiven + \fi +% \end{macrocode} +% \begin{macrocode} + \if@docolactionstar \else \@docolactioncheck \fi +} +% \end{macrocode} +% \end{macro} +% +% Here is the if used above: +% \begin{macrocode} +\newif\if@docolactionstar +% \end{macrocode} +% +% Because of extra data writing to the aux file the aux file will +% now contain something like the following after the document is +% processed the first time: +%\begin{verbatim} +%\relax +%\mc@col@status{1} +%\mc@set@col@status{lcol-1}{0} +%\mc@col@status{2} +%\mc@set@col@status{lcol-2}{0} +%\mc@col@status{3} +%\mc@set@col@status{lcol-3}{0} +%\mc@col@status{1} +%\mc@col@status{2} +%\mc@col@status{3} +%\mc@set@col@status{lcol-4}{0} +%\end{verbatim} +% The \verb=\mc@col@status= line denotes the column type and has been +% written out just before corresponding the column box was placed +% onto the page. +% The\verb=\mc@set@col@status= lines have been written out as part +% of shipping the column boxes out, e.g., +% \verb=\mc@set@col@status{lcol-1}{0}= was therefore somewhere within +% the first column as it appears between \verb=\mc@col@status{1}= +% and \verb=\mc@col@status{2}= +% The second argument in that line is the value used in the previous +% run (or zero if there was no previous run. We can use this to +% determine if a rerun is necessary. +% +% Thus with this knowledge we can set things up to get the labels +% working. +% +% +% \begin{macro}{\mc@col@status} +% +% When the aux file is read in \verb=\mc@col@status= is used to set +% \verb=\mc@curr@col@status=: +% \begin{macrocode} +\def\mc@col@status#1{% + \gdef\mc@curr@col@status{#1}} +% \end{macrocode} +% \end{macro} +% +% +% +% \begin{macro}{\mc@set@col@status} +% +% And when \verb=\mc@set@col@status= is executed we can simply set +% up the label by associating it with the \verb=\mc@curr@col@status= +% and ignore the second argument: +% \begin{macrocode} +\def\mc@set@col@status#1#2{% + \global\expandafter\let\csname #1\endcsname + \mc@curr@col@status} +% \end{macrocode} +% The above definition is being used when the \texttt{.aux} file is +% read in at the beginning. At the end we need a different +% definition to test if another typesetting run is needed. There we +% compare the value used in the current run (stored in the second +% argument) with the value used on the next run. If those two values +% differ we set \verb=@tempswa= to false which will trigger the +% ``Label(s) may have changed'' warning. +% \begin{macrocode} +\AtEndDocument{\def\mc@set@col@status#1#2{% + \ifnum #2=\mc@curr@col@status\else + \@tempswatrue + \fi}% +} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{mc@firstcol} +% Finally, as part of determining in which column we are, we used a +% switch inside |\mc@col@status@write| to determine if we are in the +% first column or not. +% \begin{macrocode} +\newif\ifmc@firstcol +\mc@firstcoltrue +% \end{macrocode} +% \end{macro} +% \end{multicols*} +% +% \Finale +% +\endinput + + diff --git a/macros/latex-dev/required/tools/multicol.ins b/macros/latex-dev/required/tools/multicol.ins new file mode 100644 index 0000000000..9fd6cbe6e9 --- /dev/null +++ b/macros/latex-dev/required/tools/multicol.ins @@ -0,0 +1,77 @@ +%% +%% This file will generate fast loadable files and documentation +%% driver files from the doc files in this package when run through +%% LaTeX or TeX. +%% +%% Copyright (C) 1993-2019 +%% The LaTeX3 Project and any individual authors listed elsewhere +%% in this file. +%% +%% This file is part of the Standard LaTeX `Tools Bundle'. +%% ------------------------------------------------------- +%% +%% It may be distributed and/or modified under the +%% conditions of the LaTeX Project Public License, either version 1.3c +%% of this license or (at your option) any later version. +%% The latest version of this license is in +%% https://www.latex-project.org/lppl.txt +%% and version 1.3c or later is part of all distributions of LaTeX +%% version 2005/12/01 or later. +%% +%% As this file contains legal notices, it is NOT PERMITTED to modify +%% this file in any way that the legal information placed into +%% generated files is changed (i.e., the files generated when the +%% original file is executed). This restriction does not apply if +%% (parts of) the content is reused in a different WORK producing its +%% own generated files. +%% +%% The list of all files belonging to the `Tools Bundle' is +%% given in the file `manifest.txt'. +%% +%% +%% --------------- start of docstrip commands ------------------ +%% +\input docstrip + +\keepsilent + +\usedir{tex/latex/tools} + +\preamble + +This is a generated file. + +The source is maintained by the LaTeX Project team and bug +reports for it can be opened at https://latex-project.org/bugs/ +(but please observe conditions on bug reports sent to that address!) + +Copyright (C) 1993-2019 +The LaTeX3 Project and any individual authors listed elsewhere +in this file. + +This file was generated from file(s) of the Standard LaTeX `Tools Bundle'. +-------------------------------------------------------------------------- + +It may be distributed and/or modified under the +conditions of the LaTeX Project Public License, either version 1.3c +of this license or (at your option) any later version. +The latest version of this license is in + https://www.latex-project.org/lppl.txt +and version 1.3c or later is part of all distributions of LaTeX +version 2005/12/01 or later. + +This file may only be distributed together with a copy of the LaTeX +`Tools Bundle'. You may however distribute the LaTeX `Tools Bundle' +without such generated files. + +The list of all files belonging to the LaTeX `Tools Bundle' is +given in the file `manifest.txt'. + +\endpreamble + + +\generateFile{multicol.sty}{t}{% + \from{multicol.dtx}{package,badness,check,marktrace,nobalance}} + + +\endbatchfile diff --git a/macros/latex-dev/required/tools/multicol.pdf b/macros/latex-dev/required/tools/multicol.pdf Binary files differnew file mode 100644 index 0000000000..e614cb3386 --- /dev/null +++ b/macros/latex-dev/required/tools/multicol.pdf diff --git a/macros/latex-dev/required/tools/rawfonts.dtx b/macros/latex-dev/required/tools/rawfonts.dtx new file mode 100644 index 0000000000..0fd7dd5006 --- /dev/null +++ b/macros/latex-dev/required/tools/rawfonts.dtx @@ -0,0 +1,219 @@ +% \iffalse meta-comment +% +% Copyright (C) 1993-2019 +% +% The LaTeX3 Project and any individual authors listed elsewhere +% in this file. +% +% This file is part of the Standard LaTeX `Tools Bundle'. +% ------------------------------------------------------- +% +% It may be distributed and/or modified under the +% conditions of the LaTeX Project Public License, either version 1.3c +% of this license or (at your option) any later version. +% The latest version of this license is in +% https://www.latex-project.org/lppl.txt +% and version 1.3c or later is part of all distributions of LaTeX +% version 2005/12/01 or later. +% +% The list of all files belonging to the LaTeX `Tools Bundle' is +% given in the file `manifest.txt'. +% +% \fi +% \title{The \textsf{rawfonts} package} +% \date{v0.01} +% \author{Alan Jeffrey} +% \MaintainedByLaTeXTeam{tools} +% \maketitle +% +% +% \section*{Overview} +% +% The |rawfonts| \LaTeXe{} package is used to provide emulation +% of \LaTeX~2.09 documents which used low-level commands such as +% |\tenrm|. If you say: +% \begin{verbatim} +% \usepackage{rawfonts} +% \end{verbatim} +% then over sixty fonts such as |\tenrm| will be loaded into \LaTeX. +% This has a large overhead, for example this document uses: +% \begin{verbatim} +% 8221 words of font info for 30 fonts +% \end{verbatim} +% but when run with the |rawfonts| package it uses: +% \begin{verbatim} +% 19294 words of font info for 73 fonts +% \end{verbatim} +% That is |rawfonts| can cause your document to load twice as many +% fonts. (This overhead is why \LaTeXe{} does not define |\tenrm| and +% friends by default.) +% +% If you want to only load a small +% number of fonts, you can use the |only| +% option, for example to only load |\tenrm| and |\tensf|: +% \begin{verbatim} +% \usepackage[only,tenrm,tensf]{rawfonts} +% \end{verbatim} +% The |rawfonts| package is intended mainly for use with \LaTeX~2.09 +% documents, and you might want to have the package loaded every time +% you use \LaTeXe{} in compatibility mode. In this case, you should add +% the line: +% \begin{verbatim} +% \RequirePackage{rawfonts} +% \end{verbatim} +% to your |latex209.cfg| \LaTeX~2.09 compatibility configuration file. +% +% \StopEventually{} +% +% \section*{Implementation} +% +% The driver for the documentation you're now reading. +% \begin{macrocode} +%<*driver> +\documentclass{ltxdoc} +\begin{document} +\DocInput{rawfonts.dtx} +\end{document} +%</driver> +% \end{macrocode} +% This is a \LaTeXe{} package. +% \begin{macrocode} +%<*package> +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{rawfonts} + [1994/05/08 Low-level LaTeX 2.09 font compatibility] +% \end{macrocode} +% The |rawfonts| package uses the |somedefs| package. +% \begin{macrocode} +\RequirePackage{somedefs} +% \end{macrocode} +% By default, all the fonts are loaded, but the |only| option says +% that only the ones specified as options should be. +% \begin{macrocode} +\UseAllDefinitions +\DeclareOption{only}{\UseSomeDefinitions} +\DeclareOption*{\UseDefinition{\CurrentOption}} +\ProcessOptions +% \end{macrocode} +% The rest of the code loads fonts. Five point: +% \begin{macrocode} +\ProvidesDefinition{\DeclareFixedFont{\fivrm}{OT1}{cmr}{m}{n}{\@vpt}} +\ProvidesDefinition{\DeclareFixedFont{\fivmi}{OML}{cmm}{m}{it}{\@vpt}} +\ProvidesDefinition{\DeclareFixedFont{\fivsy}{OMS}{cmsy}{m}{n}{\@vpt}} +\ProvidesDefinition{\DeclareFixedFont{\fivly}{U}{lasy}{m}{n}{\@vpt}} +% \end{macrocode} +% Six point: +% \begin{macrocode} +\ProvidesDefinition{\DeclareFixedFont{\sixrm}{OT1}{cmr}{m}{n}{\@vipt}} +\ProvidesDefinition{\DeclareFixedFont{\sixmi}{OML}{cmm}{m}{it}{\@vipt}} +\ProvidesDefinition{\DeclareFixedFont{\sixsy}{OMS}{cmsy}{m}{n}{\@vipt}} +\ProvidesDefinition{\DeclareFixedFont{\sixly}{U}{lasy}{m}{n}{\@vipt}} +% \end{macrocode} +% Seven point: +% \begin{macrocode} +\ProvidesDefinition{\DeclareFixedFont{\sevrm}{OT1}{cmr}{m}{n}{\@viipt}} +\ProvidesDefinition{\DeclareFixedFont{\sevmi}{OML}{cmm}{m}{it}{\@viipt}} +\ProvidesDefinition{\DeclareFixedFont{\sevsy}{OMS}{cmsy}{m}{n}{\@viipt}} +\ProvidesDefinition{\DeclareFixedFont{\sevit}{OT1}{cmr}{m}{it}{\@viipt}} +\ProvidesDefinition{\DeclareFixedFont{\sevly}{U}{lasy}{m}{n}{\@viipt}} +% \end{macrocode} +% Eight point: +% \begin{macrocode} +\ProvidesDefinition{\DeclareFixedFont{\egtrm}{OT1}{cmr}{m}{n}{\@viiipt}} +\ProvidesDefinition{% + \DeclareFixedFont{\egtmi}{OML}{cmm}{m}{it}{\@viiipt}} +\ProvidesDefinition{% + \DeclareFixedFont{\egtsy}{OMS}{cmsy}{m}{n}{\@viiipt}} +\ProvidesDefinition{% + \DeclareFixedFont{\egtit}{OT1}{cmr}{m}{it}{\@viiipt}} +\ProvidesDefinition{\DeclareFixedFont{\egtly}{U}{lasy}{m}{n}{\@viiipt}} +% \end{macrocode} +% Nine point: +% \begin{macrocode} +\ProvidesDefinition{\DeclareFixedFont{\ninrm}{OT1}{cmr}{m}{n}{\@ixpt}} +\ProvidesDefinition{\DeclareFixedFont{\ninmi}{OML}{cmm}{m}{it}{\@ixpt}} +\ProvidesDefinition{\DeclareFixedFont{\ninsy}{OMS}{cmsy}{m}{n}{\@ixpt}} +\ProvidesDefinition{\DeclareFixedFont{\ninit}{OT1}{cmr}{m}{it}{\@ixpt}} +\ProvidesDefinition{\DeclareFixedFont{\ninbf}{OT1}{cmr}{bx}{n}{\@ixpt}} +\ProvidesDefinition{\DeclareFixedFont{\nintt}{OT1}{cmtt}{m}{n}{\@ixpt}} +\ProvidesDefinition{\DeclareFixedFont{\ninly}{U}{lasy}{m}{n}{\@ixpt}} +% \end{macrocode} +% Ten point: +% \begin{macrocode} +\ProvidesDefinition{\DeclareFixedFont{\tenrm}{OT1}{cmr}{m}{n}{\@xpt}} +\ProvidesDefinition{\DeclareFixedFont{\tenmi}{OML}{cmm}{m}{it}{\@xpt}} +\ProvidesDefinition{\DeclareFixedFont{\tensy}{OMS}{cmsy}{m}{n}{\@xpt}} +\ProvidesDefinition{\DeclareFixedFont{\tenit}{OT1}{cmr}{m}{it}{\@xpt}} +\ProvidesDefinition{\DeclareFixedFont{\tensl}{OT1}{cmr}{m}{sl}{\@xpt}} +\ProvidesDefinition{\DeclareFixedFont{\tenbf}{OT1}{cmr}{bx}{n}{\@xpt}} +\ProvidesDefinition{\DeclareFixedFont{\tentt}{OT1}{cmtt}{m}{n}{\@xpt}} +\ProvidesDefinition{\DeclareFixedFont{\tensf}{OT1}{cmss}{m}{n}{\@xpt}} +\ProvidesDefinition{\DeclareFixedFont{\tenly}{U}{lasy}{m}{n}{\@xpt}} +\ProvidesDefinition{\DeclareFixedFont{\tenex}{OMX}{cmex}{m}{n}{\@xpt}} +% \end{macrocode} +% Eleven point: +% \begin{macrocode} +\ProvidesDefinition{\DeclareFixedFont{\elvrm}{OT1}{cmr}{m}{n}{\@xipt}} +\ProvidesDefinition{\DeclareFixedFont{\elvmi}{OML}{cmm}{m}{it}{\@xipt}} +\ProvidesDefinition{\DeclareFixedFont{\elvsy}{OMS}{cmsy}{m}{n}{\@xipt}} +\ProvidesDefinition{\DeclareFixedFont{\elvit}{OT1}{cmr}{m}{it}{\@xipt}} +\ProvidesDefinition{\DeclareFixedFont{\elvsl}{OT1}{cmr}{m}{sl}{\@xipt}} +\ProvidesDefinition{\DeclareFixedFont{\elvbf}{OT1}{cmr}{bx}{n}{\@xipt}} +\ProvidesDefinition{\DeclareFixedFont{\elvtt}{OT1}{cmtt}{m}{n}{\@xipt}} +\ProvidesDefinition{\DeclareFixedFont{\elvsf}{OT1}{cmss}{m}{n}{\@xipt}} +\ProvidesDefinition{\DeclareFixedFont{\elvly}{U}{lasy}{m}{n}{\@xipt}} +% \end{macrocode} +% Twelve point: +% \begin{macrocode} +\ProvidesDefinition{\DeclareFixedFont{\twlrm}{OT1}{cmr}{m}{n}{\@xiipt}} +\ProvidesDefinition{\DeclareFixedFont{\twlmi}{OML}{cmm}{m}{it}{\@xiipt}} +\ProvidesDefinition{\DeclareFixedFont{\twlsy}{OMS}{cmsy}{m}{n}{\@xiipt}} +\ProvidesDefinition{\DeclareFixedFont{\twlit}{OT1}{cmr}{m}{it}{\@xiipt}} +\ProvidesDefinition{\DeclareFixedFont{\twlsl}{OT1}{cmr}{m}{sl}{\@xiipt}} +\ProvidesDefinition{\DeclareFixedFont{\twlbf}{OT1}{cmr}{bx}{n}{\@xiipt}} +\ProvidesDefinition{\DeclareFixedFont{\twltt}{OT1}{cmtt}{m}{n}{\@xiipt}} +\ProvidesDefinition{\DeclareFixedFont{\twlsf}{OT1}{cmss}{m}{n}{\@xiipt}} +\ProvidesDefinition{\DeclareFixedFont{\twlly}{U}{lasy}{m}{n}{\@xiipt}} +% \end{macrocode} +% Fourteen point: +% \begin{macrocode} +\ProvidesDefinition{\DeclareFixedFont{\frtnrm}{OT1}{cmr}{m}{n}{\@xivpt}} +\ProvidesDefinition{% + \DeclareFixedFont{\frtnmi}{OML}{cmm}{m}{it}{\@xivpt}} +\ProvidesDefinition{% + \DeclareFixedFont{\frtnsy}{OMS}{cmsy}{m}{n}{\@xivpt}} +\ProvidesDefinition{% + \DeclareFixedFont{\frtnbf}{OT1}{cmr}{bx}{n}{\@xivpt}} +\ProvidesDefinition{\DeclareFixedFont{\frtnly}{U}{lasy}{m}{n}{\@xivpt}} +% \end{macrocode} +% Seventeen point: +% \begin{macrocode} +\ProvidesDefinition{% + \DeclareFixedFont{\svtnrm}{OT1}{cmr}{m}{n}{\@xviipt}} +\ProvidesDefinition{% + \DeclareFixedFont{\svtnmi}{OML}{cmm}{m}{it}{\@xviipt}} +\ProvidesDefinition{% + \DeclareFixedFont{\svtnsy}{OMS}{cmsy}{m}{n}{\@xviipt}} +\ProvidesDefinition{% + \DeclareFixedFont{\svtnbf}{OT1}{cmr}{bx}{n}{\@xviipt}} +\ProvidesDefinition{\DeclareFixedFont{\svtnly}{U}{lasy}{m}{n}{\@xviipt}} +% \end{macrocode} +% Twenty point: +% \begin{macrocode} +\ProvidesDefinition{\DeclareFixedFont{\twtyrm}{OT1}{cmr}{m}{n}{\@xxpt}} +\ProvidesDefinition{\DeclareFixedFont{\twtymi}{OML}{cmm}{m}{it}{\@xxpt}} +\ProvidesDefinition{\DeclareFixedFont{\twtysy}{OMS}{cmsy}{m}{n}{\@xxpt}} +\ProvidesDefinition{\DeclareFixedFont{\twtyly}{U}{lasy}{m}{n}{\@xxpt}} +% \end{macrocode} +% Twenty-five point: +% \begin{macrocode} +\ProvidesDefinition{\DeclareFixedFont{\twfvrm}{OT1}{cmr}{m}{n}{\@xxvpt}} +% \end{macrocode} +% That's it. +% \begin{macrocode} +%</package> +% \end{macrocode} +% +% \Finale +% +% \endinput diff --git a/macros/latex-dev/required/tools/rawfonts.pdf b/macros/latex-dev/required/tools/rawfonts.pdf Binary files differnew file mode 100644 index 0000000000..316f3b8c76 --- /dev/null +++ b/macros/latex-dev/required/tools/rawfonts.pdf diff --git a/macros/latex-dev/required/tools/shellesc.dtx b/macros/latex-dev/required/tools/shellesc.dtx new file mode 100644 index 0000000000..061ea4457c --- /dev/null +++ b/macros/latex-dev/required/tools/shellesc.dtx @@ -0,0 +1,243 @@ +% \iffalse +%% Source File: shellesc.dtx +%% Copyright (C) 2015-2019 +%% +%% The LaTeX3 Project and any individual authors listed elsewhere +%% in this file. +%% +%% This file may be distributed under the terms of the LPPL. +%% See README for details. +% +%<*dtx> + \ProvidesFile{shellesc.dtx} +%</dtx> +%<package>\ifx\ProvidesPackage\undefined +%<package>\def\next#1#2[#3]{\wlog{#2 #3}} +%<package>\ifx\PackageInfo\undefined\def\PackageInfo#1#2{\wlog{#1: #2}}\fi +%<package>\ifx\PackageWarning\undefined\def\PackageWarning#1#2{\wlog{#1: #2}}\fi +%<package>\expandafter\next\fi +%<package>\ProvidesPackage{shellesc} +%<driver> \ProvidesFile{shellesc.drv} +% \fi +% \ProvidesFile{shellesc.dtx} + [2016/06/07 v0.02b unified shell escape interface for LaTeX] +% +% \iffalse +%<*driver> +\documentclass{ltxdoc} +\begin{document} +\DocInput{shellesc.dtx} +\end{document} +%</driver> +% \fi +% +% \GetFileInfo{shellesc.dtx} +% +% \title{The \textsf{shellesc} Package\thanks{This file +% has version number \fileversion, last +% revised \filedate.}} +% \author{LaTeX3 project} +% \date{\filedate} +% \maketitle +% +% \changes{v0.1b}{2016/02/02}{Doc typo fixes (JB)} +% \changes{v0.2a}{2016/06/07}{Improve use with plain TeX} +% \section{Introduction} +% +% +% For many years web2c based \TeX\ implementations have used the syntax +% of the \verb|\write| command to access system commands by using a +% special stream 18 (streams above 15 can not be allocated to files in +% classical \TeX\ so stream 18 would otherwise just print to the +% terminal). +% +% This is a useful extension that did not break the strict rules on +% extensions in classical \TeX. This package provides a simple +% macro level interface hiding the \verb|write18| implementation +% so a command to remove a file on a unix-like system could be +% specified using \verb|\ShellEscape{rm file.txt}| (or \verb|del| in +% windows). Note that by default system access is not allowed and +% latex will typically need to be called with the \verb|--shell-escape| +% command line option. +% +% The package may be used with standard \texttt{latex} or +% \texttt{pdflatex} or \texttt{xetex}, however it is mostly motivated by +% \texttt{lualatex} as from Lua\TeX~0.87 onwards Lua\TeX\ does \emph{not} +% support the \verb|\write18| syntax to access system commands: it has +% 256 write streams and stream 18 can be associated to a file and +% (without this package) has no special significance. This packge +% defines the same \verb|\ShellEscape| syntax in Lua\LaTeX, but the +% implementation is via Lua and the \verb|os.execute| function. +% +% \verb|\ShellEscape| in fact corresponds to \verb|\immediate\write18| +% (or \verb|\directlua|). Very rarely you may need to delay a system +% command until the current page is output (when page numbers are +% known) for this classically you could use \verb|\write18| (or +% (\verb|\latelua|). This package provides \verb|\DelayedShellEscape| +% as a common syntax for this use. +% +% To aid porting existing documents to Lua\TeX~0.87 this package does +% overload the \verb|\write| command so that +% \verb|\write18{rm file.txt}| +% will work with Lua\TeX. Note that the redefinition of \verb|\write| +% can not detect whether \verb|\immediate| has been used, +% \verb|\immediate| will work as normal when writing to file streams +% or the terminal but the special case of stream 18 which is defined to +% use \verb|os.execute| always uses \verb|\directlua| (so corresponds +% to \verb|\immediate\write18|. In the rare situations that you need +% non-immediate \verb|\write18| in a document being ported to current +% Lua\TeX, you will need to change to use the +% \verb|\DelayedShellEscape| command. +% +% \section{Implementation} +% +% \begin{macrocode} +%<*package> +% \end{macrocode} +% +% \subsection{Status Check} +% +% +% \changes{v0.2a}{2016/06/07}{spelling in messages} +% \begin{macrocode} +\ifcase + \ifx\pdfshellescape\@undefined + \ifx\shellescape\@undefined + \ifx\directlua\@undefined + \z@ + \else + \directlua{% + tex.sprint((status.shell_escape or os.execute()) .. " ")} + \fi + \else + \shellescape + \fi + \else + \pdfshellescape + \fi + \PackageWarning{shellesc}{Shell escape disabled} +\or + \PackageInfo {shellesc}{Unrestricted shell escape enabled} +\else + \PackageInfo {shellesc}{Restricted shell escape enabled} +\fi +% \end{macrocode} +% +% \subsection{The shellesc package interface} +% +% \begin{macro}{\ShellEscape} +% Execute the supplied tokens as a system dependent command, assuming +% such execution is allowed. +% \begin{macrocode} +\ifx\lastsavedimageresourcepages\@undefined + \protected\def\ShellEscape{\immediate\write18 } +% \end{macrocode} +% +% \begin{macrocode} +\else + \protected\def\ShellEscape#1{% + \directlua{os.execute("\luaescapestring{#1}")}} +\fi +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\DelayedShellEscape} +% \changes{v0.1c}{2016/04/29}{Define \cs{DelayedShellEscape} not \cs{ShellEscape}(UF)} +% Execute the supplied tokens as a system dependent command, when this +% node is shipped out with the completed page, assuming +% such execution is allowed. +% \begin{macrocode} +\ifx\lastsavedimageresourcepages\@undefined + \protected\def\DelayedShellEscape{\relax\write18 } +% \end{macrocode} +% +% \begin{macrocode} +\else + \protected\def\DelayedShellEscape#1{% + \latelua{os.execute("\luaescapestring{#1}")}} +\fi +% \end{macrocode} +% \end{macro} +% +% +% +% \subsection{The write18 package interface} +% +% In web2c based engines other than Lua\TeX, |\write18| may be used +% directly. The same was true in older LuaTeX, but from version 0.85 +% onwards that is not available. +% +% The above |shellesc| package interface is recommended for new code, +% however for ease of porting existing documents and packages to newer +% Lua\TeX\ releases, a |\write18| interface is provided here via a +% call to Lua's |os.execute|. +% +% Note that as currently written this always does an \emph{immediate} +% call to the system. +% +% |\immediate| is supported but ignored, |\immediate\write18| and +% |\write18| both execute immediately. To use a delayed execution at +% the next shipout, use the |\DelayedShellEscape| command defined +% above. +% +% Note that it would be easy to make |\wriete18| defined here use +% delayed execution, just use |\DelayedShellEscape| instead of +% |ShellEscape| in the definition below. However detecting +% |\immediate| is tricky so the choice here is to always use the +% immediate form, which is overwhelmingly more commonly used with +% |\write18|. +% +% Stop at this point if not a recent Lua\TeX. +% \begin{macrocode} +\ifx\lastsavedimageresourcepages\@undefined\expandafter\endinput\fi +% \end{macrocode} +% +% \begin{macrocode} +\directlua{% +% \end{macrocode} +% +% \begin{macrocode} +shellesc = shellesc or {} +% \end{macrocode} +% +% Lua function to use the token scanner to grab the following \TeX\ +% number, and then test if stream 18 is being used, and then insert an +% appropriate \TeX\ command to handle the following brace group in +% each case. +% \begin{macrocode} +local function write_or_execute() + local s = token.scan_int() + if (s==18) then + tex.sprint(\the\numexpr\catcodetable@atletter\relax, + "\string\\ShellEscape ") + else + tex.sprint(\the\numexpr\catcodetable@atletter\relax, + "\string\\shellesc@write " .. s) + end +end +% \end{macrocode} +% +% \begin{macrocode} +shellesc.write_or_execute=write_or_execute +% \end{macrocode} +% +% \begin{macrocode} +} +% \end{macrocode} +% +% \begin{macrocode} +\let\shellesc@write\write +% \end{macrocode} +% +% \begin{macrocode} +\protected\def\write{\directlua{shellesc.write_or_execute()}} +% \end{macrocode} +% +% +% +% \begin{macrocode} +%</package> +% \end{macrocode} +% +% \Finale +% diff --git a/macros/latex-dev/required/tools/shellesc.pdf b/macros/latex-dev/required/tools/shellesc.pdf Binary files differnew file mode 100644 index 0000000000..043016f2b9 --- /dev/null +++ b/macros/latex-dev/required/tools/shellesc.pdf diff --git a/macros/latex-dev/required/tools/showkeys.dtx b/macros/latex-dev/required/tools/showkeys.dtx new file mode 100644 index 0000000000..6e2516856d --- /dev/null +++ b/macros/latex-dev/required/tools/showkeys.dtx @@ -0,0 +1,905 @@ +% \iffalse meta-comment +% +% Copyright (C) 1993-2019 +% +% The LaTeX3 Project and any individual authors listed elsewhere +% in this file. +% +% This file is part of the Standard LaTeX `Tools Bundle'. +% ------------------------------------------------------- +% +% It may be distributed and/or modified under the +% conditions of the LaTeX Project Public License, either version 1.3c +% of this license or (at your option) any later version. +% The latest version of this license is in +% https://www.latex-project.org/lppl.txt +% and version 1.3c or later is part of all distributions of LaTeX +% version 2005/12/01 or later. +% +% The list of all files belonging to the LaTeX `Tools Bundle' is +% given in the file `manifest.txt'. +% +% \fi +% \iffalse +%% File: showkeys.dtx Copyright (C) 1992-1997 David Carlisle +%% File: showkeys.dtx Copyright (C) 2006-2019 David Carlisle, LaTeX3 Project +% +%<*dtx> + \ProvidesFile{showkeys.dtx} +%</dtx> +%<package>\NeedsTeXFormat{LaTeX2e} +%<package>\ProvidesPackage{showkeys} +%<driver> \ProvidesFile{showkeys.drv} +% \fi +% \ProvidesFile{showkeys.dtx} + [2014/10/28 v3.17 Show cite and label keys (DPC, MH)] +% +% \iffalse +%<*driver> +\documentclass{ltxdoc} +\usepackage +% [notcite,notref,color] + {showkeys} +\setlength{\belowcaptionskip}{\baselineskip} +\setlength{\abovecaptionskip}{0pt} +\begin{document} +\DocInput{showkeys.dtx} +\end{document} +%</driver> +% \fi +% +% \GetFileInfo{showkeys.dtx} +% \title{The \textsf{showkeys} package\thanks{This file +% has version number \fileversion, last +% revised \filedate.}} +% \author{David Carlisle \and Morten H\o gholm} +% \date{\filedate} +% \MaintainedByLaTeXTeam{tools} +% \maketitle +% +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% +% +% \changes{v1.01}{1992/08/25}{Initial version} +% \changes{v1.02}{1994/01/05} +% {Fix incorrect initialisation (FGBDA19@CC1.KULEUVEN.AC.BE)} +% \changes{v2.00}{1994/01/31}{new version for LaTeX2e} +% \changes{v2.01}{1994/06/30}{Fix \cs{ProvidesPackage} usage.} +% \changes{v3.00}{1994/09/07} +% {Support harvard, varioref and natbib packages,} +% \changes{v3.02}{1995/03/17} +% {Support new AMS files} +% +% \section{Introduction}\label{sec:intro} +% +% |showkeys.sty| modifies the |\label|, |\ref|, |\pageref|, |\cite|, and +% |\bibitem| commands so that the `internal' key is printed. The package +% tries hard to position these labels so that the formatting of the rest +% of the document is unchanged. |\label| and |\bibitem| cause the +% key to appear in a box either in the margin, or in a \TeX\ box of zero +% width, which may possibly over-print other text. The |\ref|, +% |\pageref| and |\cite| commands print their arguments in small type, +% raised just above the line, like this: \ref{sec:intro}. +% This package works with the \textsf{fleqn} option, the packages +% in the AMS-\LaTeX\ collection, and the \textsf{varioref}, +% \textsf{natbib} and \textsf{harvard} packages. +% +% \changes{v2.00}{1992/01/31} +% {leqno or ams* may now be loaded after showkeys} +% +% \section{Package Options}\label{options} +% Some people have commented that the printing of the |\ref| and +% |\cite| keys is less useful than the printing of the |\label| keys +% and so \textsf{showkeys} now supports two options that can be given +% in the |\usepackage| command: +% \begin{description} +% \item[notref] to stop the redefinition of |\ref| and |\pageref|, +% and related commands from the \textsf{varioref} package. +% \item[notcite] to stop the redefinition of |\cite| and related +% commands from the \textsf{harvard} and \textsf{natbib} packages. +% \end{description} +% So if the package is loaded with |\usepackage[notref]{showkeys}| +% then |\ref| will have its standard definition, but |\label| will +% print its key argument (usually in the margin). +% +% If you find the printed keys distracting, but don't want to use the +% above options to stop them altogether you may use: +% \begin{description} +% \item[color] Print the keys in a distinguishing colour. The default +% value is a light grey. +% \end{description} +% The colours may be changed by redefining the following two colours +% after the package is loaded. +% |refkey| (also used for |\cite|) and +% |labelkey| (also used for |\bibitem|). +% The defaults are: +%\begin{verbatim} +% \definecolor{refkey}{gray}{.75} +% \definecolor{labelkey}{gray}{.75} +%\end{verbatim} +% +% If this option is used the \textsf{color} package will be loaded. +% +% The package accepts two further options. +% \begin{description} +% \item[final] to suporess the action of this package, for `final' +% versions. +% \item[draft] the normal behaviour of this package. +% \end{description} +% Clearly there is not much point in entering the |final| option +% directly in the |\usepackage| command, as just not loading this +% package would have the same effect, and execute more quickly, +% however the |final| option may be useful as it may be used once in +% the |documentclass| command to affect any number of packages that +% may be loaded. The |draft| option does not do anything, but is there +% to honour an informal convention that packages have these options in +% pairs. +% +% You can also control the appearance of the typeset label with the +% command |\showkeyslabelformat|, which takes one argument. The default is +% \begin{verbatim} +% \providecommand*\showkeyslabelformat[1]{% +% \fbox{\normalfont\small\ttfamily#1}} +% \end{verbatim} +% The command is called inside a group so you can put in local +% modifications of |\fboxsep|, for instance, without them leaking to +% the rest of the document. +% +% +% \section{More Examples}\label{examples} +% The only other similar package that I could find in the macro index, +% \cite{DMJ:mi}, was |showlabels.sty|, \cite{GN:sl}. After the first +% draft of this package was written, I found \cite{anon:sk} on my local +% installation! I think the current package is more robust than +% \cite{anon:sk}, but I thought that |showkeys| was rather a good name, +% so I have stolen it for this file. +% +% \begin{enumerate} +% \item \label{e^1}This has |\label| immediately after |\item|. +% \item This has the |\label| at the end.\label{e^2} +% \end{enumerate} +% +% \[ +% \mbox{A minipage :- }\left\{ +% \begin{minipage}{3in} +% Within environments like this |minipage|, we cannot use +% |\marginpar|\footnotemark, +% so the appearance is slightly different. Here is that |enumerate| +% environment again: +% +% \begin{enumerate} +% \item \label{m&e^1}This has |\label| immediately after |\item|. +% \item This has the |\label| at the end.\label{m&e^2} +% \end{enumerate} +% \end{minipage} +% \right. +% \] +% +% Displayed math (without |equation| counter). +% \[0=0\label{disp}\] +% +% Some text referring to the maths on page~\pageref{disp}, and the +% item~\ref{e^1}.\footnotetext{Actually \texttt{\string\marginpar} is +% not used at all in this package now.} +% +% If |showkeys| thinks that the current environment is going to produce +% an ``equation number'', then it does not show the label where the +% |\label| command occurs, but tries to put it in the margin, as shown +% with equation~\ref{eq:xx}. +% The package `knows' about the standard |equation| and |eqnarray| +% environments, and also all the numbered alignment environments offered +% by the AMS\LaTeX\ package, |amsmath|. +% +% ^^A (|amstex.sty| must be loaded before |showkeys.sty| +% ^^A for this to work.) +% \changes{v2.00}{1992/01/31} +% {leqno or ams* may now be loaded after showkeys} +% +% \begin{equation} +% 1=1\label{eq:xx} +% \end{equation} +% +% \begin{eqnarray} +% 2&=&2\label{eqnar:a}\\ +% 3&=&3\nonumber\\ +% 4&=&4\label{eqnar:b} +% \end{eqnarray} +% +% +% \begin{figure}[ht] +% Within a |figure| environment, the |\label| must not come before the +% |\caption| command. If you place |\label| inside the argument of +% |\caption| the label will be shown like this: +% +% \caption{Within the caption argument.\label{cap:a}} +% +% If you place |\label| immediately after the |\caption| command it will +% be shown like this: +% +% \caption{Immediately after the caption argument.}\label{cap:b} +% +% If you place the |\label| command at some random point after the +% |\caption| command, it may be shown like: +% +% \caption{In vertical mode not immediately after a box.} +% \vspace{2pt} +% +% \label{cap:c} +% \end{figure} +% +% +% \begin{thebibliography}{9} +% +% \bibitem{GN:sl} +% Gil Neiger, \emph{showlabels.sty}, +% Undated package, similar to this one, but shows labels +% inline, affecting the formatting of the document. +% +% \bibitem{anon:sk} +% Anonymous, \emph{showkeys.sty}, +% Package, dated 14 May 1988. Very similar to this one, +% also uses |\marginpar| in outer vertical mode. +% +% \bibitem{DMJ:mi} +% David M. Jones, \emph{\TeX\ Macro Index}, +% A catalogue of \TeX\ macros, including \LaTeX\ packages, +% available from all good \TeX\ archives. +% +% \end{thebibliography} +% +% \StopEventually{} +% +% \section{The Macros} +% +% \begin{macrocode} +%<*package> +% \end{macrocode} +% +% +% First we handle the options. Normally all related commands are +% defined to show their `keys'. But since v3.03 one can specify: +% +% \texttt{notref} to stop the redefinition of |\ref| (and |\pageref|, +% and related commands from \textsf{varioref} package), +% +% \texttt{notcite} to stop the redefinition of |\cite| and related +% commands from the \textsf{harvard} and \textsf{natbib} packages. +% +% \changes{v3.03}{1995/04/25} +% {Add option handling.} +% \begin{macrocode} +\DeclareOption{notref}{\let\SK@ref\@empty} +\DeclareOption{notcite}{\let\SK@cite\@empty} +% \end{macrocode} +% +% \begin{macro}{\SK@refcolor} +% \begin{macro}{\SK@labelcolor} +% Colour commands. Normally no-op. +% \begin{macrocode} +\let\SK@refcolor\relax +\let\SK@labelcolor\relax +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \changes{v3.11}{1996/11/01} +% {Colour support added, inspired by tools/2297} +% |color| option loads the \textsf{color} package and defines the +% colours. Delayed to the end of the package as package loading not +% allowed in this option section. +% \begin{macrocode} +\DeclareOption{color}{\AtEndOfPackage{% + \RequirePackage{color}% + \definecolor{refkey}{gray}{.75}% + \definecolor{labelkey}{gray}{.75}% + \def\SK@refcolor{\color{refkey}}% + \def\SK@labelcolor{\color{labelkey}}}} +% \end{macrocode} +% +% \changes{v3.04}{1995/10/30} +% {final and draft options handling.} +% \changes{v3.15}{2007/08/07} +% {Fix \cs{showkeyslabelformat} for final option PR/3918.} +% Allow |final| to be specified in the document class options +% to suppress the loading of this package. +% \begin{macrocode} +\DeclareOption{final}{% + \providecommand*\showkeyslabelformat[1]{}% + \endinput} +\DeclareOption{draft}{} +% \end{macrocode} +% +% \begin{macrocode} +\ProcessOptions +% \end{macrocode} +% +% \changes{v2.00}{1992/01/31} +% {\cmd{reset@font} is now standard} +% +% \begin{macro}{\SK@label} +% \begin{macro}{\SK@bibitem} +% \begin{macro}{\SK@lbibitem} +% The saved original definitions +% \begin{macrocode} +\let\SK@label\label +\let\SK@bibitem\@bibitem +\let\SK@lbibitem\@lbibitem +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% +% +% \begin{macro}{\label} +% \changes{v3.09}{1996/08/30} +% {Add extra group so brace hack works. Donald Arseneau tools/2147} +% The new definition, print the argument, and then do the old +% definition. +% \begin{macrocode} +\def\label#1{% + \@bsphack + \SK@\SK@@label{#1}% + \begingroup + \SK@label{#1}% + \endgroup + \@esphack} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@bibitem} +% \begin{macro}{\@lbibitem} +% \changes{v3.02}{1995/03/17} +% {New label code.} +% For |\bibitem|, position the \textsf{showkeys} code as for a standard +% list with |\item| and |\label|. +% \begin{macrocode} +\def\@bibitem#1{% + \SK@bibitem{#1}\SK@\SK@@label{#1}\ignorespaces} +% \end{macrocode} +% +% \begin{macrocode} +\def\@lbibitem[#1]#2{% + \SK@lbibitem[{#1}]{#2}\SK@\SK@@label{#2}\ignorespaces} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\SK@} +% \changes{v3.07}{1996/05/17} +% {use \cs{protected@edef} for tools/2147} +% Grab hold of |#2| via |\meaning| so characters like |&| and +% |^| do not cause problems later, and pass the result on to the command +% |#1|. +% \begin{macrocode} +\def\SK@#1#2{% + \protected@edef\@tempa{#2}% + \expandafter#1\meaning\@tempa\SK@} +% \end{macrocode} +% \end{macro} +% +% +% +% \begin{macro}{\showkeyslabelformat} +% \changes{v3.13}{2006/01/09}{Added command} +% \begin{macrocode} +\providecommand*\showkeyslabelformat[1]{% + \fbox{\normalfont\small\ttfamily#1}} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\SK@@label} +% \changes{v3.13}{2006/01/09}{Do not hardwire label format} +% Strip off the initial segment of the |\meaning| output, and then put +% the rest either in a |\marginpar| or in a box of size 0pt, +% hopefully not disturbing the surrounding text. +% \begin{macrocode} +\def\SK@@label#1>#2\SK@{% +% \end{macrocode} +% Need to work globally as in some cases like alignments, and |fleqn|, +% the counter will be printed in a different group to the |\label| +% command. +% \begin{macrocode} + \gdef\SK@lab{\smash{\SK@labelcolor\showkeyslabelformat{#2}}}% + \ifvmode + \if@inlabel +% \end{macrocode} +% \changes{v3.02}{1995/03/17} +% {New code for `in label' case.} +% If the |\label| is straight after |\item| (|\bibitem| is handled by +% this case as well) then the item label has not been added to the page +% yet. It is hanging around in the box |\@labels| waiting for the +% paragraph to start. So just need to attach the label to this box. +% \begin{macrocode} + \global\setbox\@labels\hbox{% + \llap{\SK@lab\SK@lab@relax + \kern\@totalleftmargin\kern\marginparsep}% + \box\@labels}% +% \end{macrocode} +% +% \begin{macrocode} + \else +% \end{macrocode} +% \changes{v3.10}{1996/09/06} +% {Save prevdepth and restore later} +% If we insert a box into the main vertical list, do not want to +% change |\prevdepth| as that would affect vertical spacing in the +% document. (The box itself should not cause any difference in break +% points as there is a node there anyway coming from the |\write| to +% the aux file. +% \begin{macrocode} + \dimen@\prevdepth + \nointerlineskip +% \end{macrocode} +% The inner vertical mode cases are mainly designed to do the right +% thing with float captions, but seem to work OK in other cases as well. +% \begin{macrocode} + \ifinner + \skip@\lastskip\unskip +% \end{macrocode} +% In inner vertical mode, attach the label to the right of the +% immediately preceding box, if it is a box before the current point. +% Otherwise just put it in a box of zero dimensions, with no interline +% skip. (This may slightly move the surrounding text (but perhaps not +% now that |\prevdepth| is restored.) +% \changes{v3.00}{1994/09/07} +% {Back up over a previous skip because of the new +% \cs{belowcaptionskip}} +% \changes{v3.04}{1995/10/30} +% {\cs{advance} added, to total two successive skips.} +% \changes{v3.04}{1995/10/30} +% {\cs{nointerlineskip} called before \cs{ifvoid} test, not just +% void case} +% \changes{v3.04}{1995/10/30} +% {\cs{marginparskip} added in inner vmode case} +% \begin{macrocode} + \advance\skip@\lastskip\unskip + \setbox\z@\lastbox +% \end{macrocode} +% \changes{v3.10}{1996/09/06} +% {Inner vertical mode case, put it in the margin.} +% \changes{v3.14}{2006/09/25} +% {The label put in the margin shouldn't make box 255 wider (PR/3884).} +% \begin{macrocode} + \ifvoid\z@ + \llap{\SK@lab\SK@lab@relax\kern\marginparsep}% + \else + \hbox{\box\z@\rlap{\kern\marginparsep\SK@labx}}% + \fi + \vskip\skip@ + \else +% \end{macrocode} +% In outer vertical mode, previously used a |\vadjust| at the start of +% the next paragraph (and before that used |\marginpar|). These +% methods sometimes cause extra space, eg if paragraph starts with a +% math display, so now just insert the box directly, taking care not +% to change |\prevdepth|. +% \changes{v3.02}{1995/03/17} +% {Use \cs{vadjust} instead of \cs{marginpar}} +% \changes{v3.10}{1996/09/06} +% {Insert the box directly} +% \begin{macrocode} + \llap{\SK@lab\SK@lab@relax\kern\marginparsep}% + \fi +% \end{macrocode} +% Restore |\prevdepth|. +% \begin{macrocode} + \prevdepth\dimen@ +% \end{macrocode} +% +% \begin{macrocode} + \fi + \else +% \end{macrocode} +% If we are in an numbered equation-style environment, do nothing as the +% code to print the number will also print the label, otherwise just +% stick the label at the current point, in a box of zero dimensions. +% \changes{v3.02}{1995/03/17} +% {Add \cs{ifmmode} test} +% \begin{macrocode} + \csname SK@\@currenvir\endcsname + \ifSK@equation\else + \ifmmode + \SK@labx + \else +% \end{macrocode} +% Inner horizontal mode. Not much we can do, just stick it here. +% \changes{v3.03}{1995/04/25} +% {Fix inner horizontal mode case (broken in 3.02)} +% \begin{macrocode} + \ifinner + \rlap\SK@lab + \else +% \end{macrocode} +% In outer horizontal mode use |\vadjust| to get to the margin. +% \changes{v3.02}{1995/03/17} +% {Use \cs{vadjust} in horizontal mode} +% \begin{macrocode} + \vadjust{\llap{\SK@lab\kern\marginparsep}}% + \fi + \SK@lab@relax + \fi + \fi + \fi} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\tagform@} +% \changes{v2.00}{1992/01/31} +% {Defer tests to begin document} +% \changes{v3.02}{1995/03/17} +% {Support new AMS files} +% \begin{macro}{\@eqnnum} +% \changes{v3.13}{2006/01/09} +% {Change to also work correctly for \texttt{leqno} option.} +% \begin{macro}{\maketag@@@} +% \changes{v3.13}{2006/01/09} +% {Support for \cs{tag*} tools/3693.} +% Firstly we grab |\@eqnnum|. +% \begin{macrocode} +\AtBeginDocument{% + \let\SK@eqnnum\@eqnnum +% \end{macrocode} +% Then check for \textsf{amsmath} where we grab the internal commands +% |\tagform@| and |\maketag@@@|. Redefine them and redefine |\@eqnnum| +% as well. +% \begin{macrocode} + \@ifpackageloaded{amsmath}{% + \let\SK@tagform@\tagform@ + \let\SK@maketag@@@\maketag@@@ + \iftagsleft@ + \def\tagform@#1{% + \ifx\df@label\@empty + \SK@lab@relax + \else + \expandafter\SK@@label\meaning\df@label\SK@ + \fi + \llap{\SK@lab\kern\marginparsep}% + \SK@lab@relax\SK@tagform@{#1}}% + \def\maketag@@@#1{% + \ifx\df@label\@empty + \SK@lab@relax + \else + \expandafter\SK@@label\meaning\df@label\SK@ + \fi + \llap{\SK@lab\kern\marginparsep}\SK@lab@relax + \SK@maketag@@@{#1}% + }% + \def\@eqnnum{% + \llap{\SK@lab\kern\displaywidth\kern\marginparsep}% + \SK@lab@relax\SK@eqnnum}% + \else +% \end{macrocode} +% Almost the same for tags on the right, except we use |\rlap| and +% typeset it after the tag. +% \begin{macrocode} + \def\tagform@#1{% + \ifx\df@label\@empty + \SK@lab@relax + \else + \expandafter\SK@@label\meaning\df@label\SK@ + \fi +% \end{macrocode} +% \changes{v3.08}{1996/07/10}{Missing percent added. /2215} +% \begin{macrocode} + \SK@tagform@{#1}% + \rlap{\kern\marginparsep\SK@lab}\SK@lab@relax}% + \def\maketag@@@#1{% + \ifx\df@label\@empty + \SK@lab@relax + \else + \expandafter\SK@@label\meaning\df@label\SK@ + \fi + \SK@maketag@@@{#1}% + \rlap{\kern\marginparsep\SK@lab}\SK@lab@relax + }% + \def\@eqnnum{\SK@eqnnum\rlap{\kern\marginparsep\SK@lab}% + \SK@lab@relax}% + \fi + }% +% \end{macrocode} +% If \textsf{amsmath} wasn't loaded we check explicitly if the +% \texttt{leqno} option was used in |\documentclass| and redefine +% accordingly. +% \begin{macrocode} + {% + \@ifundefined{ver@leqno.clo}{% + \def\@eqnnum{\SK@eqnnum\rlap{\kern\marginparsep\SK@lab}% + \SK@lab@relax}% + }{% + \def\@eqnnum{% + \llap{\SK@lab\kern\displaywidth\kern\marginparsep}% + \SK@lab@relax\SK@eqnnum}% + }% + }% +} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\SK@labx} +% Print the label, and then globally reset the print command to +% |\relax|. +% \begin{macrocode} +\def\SK@labx{\rlap\SK@lab\global\let\SK@lab\relax} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\SK@lab@relax} +% Clear the label. +% \changes{v1.02}{1994/01/05}{Execute to initialise correctly} +% \begin{macrocode} +\def\SK@lab@relax{\global\let\SK@lab\relax}\SK@lab@relax +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\SK@equation} +% \begin{macro}{\SK@eqnarray} +% The following environments print an equation number, so |\label| +% should not print its argument at the point where it appears. +% Note this will fail to show the label if you are in an |eqnarray| +% environment, and use |\label| together with |\nonumber| This might +% just about make sense if you are going to use |\pageref|, but that is +% too bad\ldots +% \begin{macrocode} +\newif\ifSK@equation +\let\SK@equation\SK@equationtrue +\let\SK@eqnarray\SK@equationtrue +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\eqnarray} +% \changes{v3.09}{1996/08/30} +% {Fix eqnarray AMS incompatibility. tools/2252} +% When the AMS packages are loaded |showkeys| assumes environments +% work `The AMS way' However |eqnarray| (unlike |equation|) is not +% redefined, so here we need to remove some of the AMS hacks. +% \begin{macrocode} +\toks@\expandafter{\eqnarray} +\edef\eqnarray{\let\noexpand\tagform@\noexpand\SK@tagform@\the\toks@} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\SK@align} +% \begin{macro}{\SK@alignat} +% \begin{macro}{\SK@xalignat} +% \begin{macro}{\SK@xxalignat} +% \begin{macro}{\SK@gather} +% \begin{macro}{\SK@multline} +% \begin{macro}{\SK@flalign} +% \changes{v3.02}{1995/03/17} +% {Add \cs{SK@flalign}} +% The AMS environments +% \begin{macrocode} +\let\SK@align\SK@equationtrue +\let\SK@alignat\SK@equationtrue +\let\SK@xalignat\SK@equationtrue +\let\SK@xxalignat\SK@equationtrue +\let\SK@gather\SK@equationtrue +\let\SK@multline\SK@equationtrue +\let\SK@flalign\SK@equationtrue +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\SK@align*} +% \begin{macro}{\SK@alignat*} +% \begin{macro}{\SK@flalign*} +% \begin{macro}{\SK@gather*} +% \begin{macro}{\SK@multline*} +% \begin{macro}{\SK@equation*} +% \changes{v3.13}{2006/01/09} +% {Add the starred AMS environments for tools/3697.} +% Starred versions of the AMS environments. +% \begin{macrocode} +\expandafter\let\csname SK@align*\endcsname\SK@equationtrue +\expandafter\let\csname SK@alignat*\endcsname\SK@equationtrue +\expandafter\let\csname SK@flalign*\endcsname\SK@equationtrue +\expandafter\let\csname SK@gather*\endcsname\SK@equationtrue +\expandafter\let\csname SK@multline*\endcsname\SK@equationtrue +\expandafter\let\csname SK@equation*\endcsname\SK@equationtrue +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\SK@def} +% \changes{v3.05}{1995/11/09} +% {Macro added} +% This macro redefines a command |#1|. The new definition can make use +% of the old definition as |\SK@|\emph{old name}. If |#1| is really a +% |\protect|'ed command with the real definition in a `\emph{space}' +% command then the `space' version is used as the old definition. +% Need to test this for each command as some package may have changed +% the status of a command to being `protected'. +% The new definition is made as if with |\DeclareRobustCommand|, but +% with |\def| syntax for the argument specification. +% \begin{macrocode} +\def\SK@def#1{% + \edef\@tempa{\expandafter\@gobble\string#1}% + \@ifundefined{\@tempa\space}% + {\expandafter\let\csname SK@\@tempa\endcsname#1}% + {\expandafter\let\csname SK@\@tempa\expandafter\endcsname + \csname\@tempa\space\endcsname}% + \expandafter\def\expandafter#1\expandafter{% + \expandafter\protect\csname\@tempa\space\endcsname}% + \expandafter\def\csname\@tempa\space\endcsname} +% \end{macrocode} +% \end{macro} +% +% The next section redefines |\ref| and |\pageref| (unless the +% \texttt{notref} option was given). +% \begin{macrocode} +\ifx\SK@ref\@empty +% \end{macrocode} +% Even if \texttt{notref} option is used, need to fudge the +% \textsf{varioref} commands as they use |\label| internally. +% \changes{v3.04}{1995/10/30} +% {improve varioref support in notref option case, for +% tools/1744} +% \changes{v3.13}{2006/01/09}{Updated varioref support, for latex/3373} +% \changes{v3.15}{2006/06/19} +% {Prevent loss of brackets} +% \begin{macrocode} +\AtBeginDocument{% + \@ifpackageloaded{varioref}{% + \SK@def\@@vpageref#1[#2]#3{{% + \let\label\SK@label + \SK@@@vpageref{#1}[{#2}]{#3}}}% + \def\vr@f#1{% + \leavevmode\unskip\vref@space + \ref{#1}% + {\let\label\SK@label + \vpageref[\unskip]{#1}}}% + }{}} +\else +% \end{macrocode} +% +% \begin{macro}{\ref} +% \begin{macro}{\pageref} +% Save the redefinition to |\begin{document}| so that this package can +% work with packages that redefine |\cite|. Tested with harvard and +% natbib packages. Also add code at this point to support varioref. +% \changes{v3.00}{1994/09/07} +% {Delay \cs{ref} redefinition.} +% \changes{v3.03}{1995/04/25} +% {Make redefinition conditional on notref option} +% \changes{v3.15}{2006/06/19} +% {Prevent loss of brackets} +% \begin{macrocode} +\AtBeginDocument{% + \SK@def\ref#1{\SK@\SK@@ref{#1}\SK@ref{#1}}% + \SK@def\pageref#1{\SK@\SK@@ref{#1}\SK@pageref{#1}}% +% \end{macrocode} +% varioref support. +% \begin{macrocode} + \@ifpackageloaded{varioref}{% + \SK@def\@@vpageref#1[#2]#3{{% + \let\label\SK@label\let\ref\SK@ref\let\pageref\SK@pageref + \leavevmode\unskip\SK@\SK@@ref{#3}\SK@@@vpageref{#1}[{#2}]{#3}}}% + \def\vr@f#1{% + \leavevmode\unskip\vref@space + \ref{#1}% + \let\label\SK@label\let\ref\SK@ref\let\pageref\SK@pageref + \vpageref[\unskip]{#1}}% + }{}} +% \end{macrocode} +% +% \begin{macrocode} +\fi +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% Now redefine |\cite| unless \texttt{notcite} option given. +% \begin{macrocode} +\ifx\SK@cite\@empty +% \end{macrocode} +% \changes{v3.06}{1995/11/22} +% {Fix \cs{harvarditem} support} +% \begin{macrocode} +\AtBeginDocument{% + \ifx\HAR@checkdef\@undefined\else + \expandafter\let\expandafter + \SK@HAR@bi\csname\string\harvarditem\endcsname + \expandafter\def\csname\string\harvarditem\endcsname[#1]#2#3#4{% + \SK@HAR@bi[{#1}]{#2}{#3}{#4}\SK@\SK@@label{#4}}% + \fi} +\else +% \end{macrocode} +% +% \begin{macro}{\cite} +% \changes{v3.00}{1994/09/07} +% {Delay \cs{cite} redefinition.} +% \changes{v3.03}{1995/04/25} +% {Make redefinition conditional on notcite option} +% \begin{macrocode} +\AtBeginDocument{% + \ifx\HAR@checkdef\@undefined +% \end{macrocode} +% Standard (non-harvard) support, including extra cite commands from +% \textsf{natbib} and \textsf{cite}. +% \changes{v3.01}{1994/09/09} +% {Add \cs{citefullauthor}} +% \changes{v3.12}{1997/06/12} +% {Support cite package. tools/2490} +% \changes{v3.17}{2014/04/24} +% {redefine \cs{@citex} rather than \cs{cite} for tools/4162} +% +% If \textsf{cite} or \textsf{overcite} is being used, redefine |\citen| +% rather than |\cite| so as not to spoil the space and punctuation +% calculations done by those packages. +% \begin{macrocode} + \ifx\citen\@undefined + \SK@def\@citex[#1]#2{\SK@citex[{#1}]{#2}}% + \else + \SK@def\citen#1{\SK@\SK@@ref{#1}\SK@citen{#1}}% + \fi + \SK@def\citeauthor#1{\SK@\SK@@ref{#1}\SK@citeauthor{#1}}% + \SK@def\citefullauthor#1{\SK@\SK@@ref{#1}\SK@citefullauthor{#1}}% + \SK@def\citeyear#1{\SK@\SK@@ref{#1}\SK@citeyear{#1}}% + \else +% \end{macrocode} +% In the \textsf{harvard} style do \emph{not} redefine individual cite +% commands. Just redefine one internal command that is used in all the +% citation forms. +% \begin{macrocode} + \SK@def\HAR@checkdef#1#2{% + \expandafter\SK@\expandafter\SK@@ref\expandafter{#1}% + \SK@HAR@checkdef{#1}{#2}}% + \expandafter\let\expandafter + \SK@HAR@bi\csname\string\harvarditem\endcsname +% \end{macrocode} +% \changes{v3.06}{1995/11/22} +% {Fix \cs{harvarditem} support} +% \begin{macrocode} + \expandafter\def\csname\string\harvarditem\endcsname[#1]#2#3#4{% + \SK@HAR@bi[{#1}]{#2}{#3}{#4}\SK@\SK@@label{#4}}% + \fi} +% \end{macrocode} +% +% \changes{v3.17}{2014/04/24} +% {Change name, redefine \cs{@citex} rather than \cs{cite} for tools/4162} +% \begin{macrocode} +\def\SK@citex[#1]#2{% + \SK@\SK@@ref{#2}\SK@@citex[{#1}]{#2}} +% \end{macrocode} +% +% \begin{macrocode} +\fi +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\SK@@ref} +% This is much simpler than the printing of the label, as we know +% that we can be in horizontal mode. +% Note extra group for colour safety. +% \changes{v3.14}{2006/09/25} +% {Add fix for pdf\TeX.} +% \changes{v3.16}{2011/11/24} +% {revert change made at v3.14 because of tools/4173} +% \begin{macrocode} +\def\SK@@ref#1>#2\SK@{% + \leavevmode\vbox to\z@{{% + \vss + \SK@refcolor + \rlap{\vrule\raise .75em% + \hbox{\underbar{\normalfont\footnotesize\ttfamily#2}}}}}} +% \end{macrocode} +% \end{macro} +% +% \begin{macrocode} +%</package> +% \end{macrocode} +% +% \Finale +% diff --git a/macros/latex-dev/required/tools/showkeys.pdf b/macros/latex-dev/required/tools/showkeys.pdf Binary files differnew file mode 100644 index 0000000000..6b2817a982 --- /dev/null +++ b/macros/latex-dev/required/tools/showkeys.pdf diff --git a/macros/latex-dev/required/tools/somedefs.dtx b/macros/latex-dev/required/tools/somedefs.dtx new file mode 100644 index 0000000000..f73a45b787 --- /dev/null +++ b/macros/latex-dev/required/tools/somedefs.dtx @@ -0,0 +1,172 @@ +% \iffalse meta-comment +% +% Copyright (C) 1993-2019 +% +% The LaTeX3 Project and any individual authors listed elsewhere +% in this file. +% +% This file is part of the Standard LaTeX `Tools Bundle'. +% ------------------------------------------------------- +% +% It may be distributed and/or modified under the +% conditions of the LaTeX Project Public License, either version 1.3c +% of this license or (at your option) any later version. +% The latest version of this license is in +% https://www.latex-project.org/lppl.txt +% and version 1.3c or later is part of all distributions of LaTeX +% version 2005/12/01 or later. +% +% The list of all files belonging to the LaTeX `Tools Bundle' is +% given in the file `manifest.txt'. +% +% \fi +% \title{The \textsf{somedefs} toolkit package} +% \date{long time ago in a different century\ldots} +% \author{Alan Jeffrey} +% \MaintainedByLaTeXTeam{tools} +% \maketitle +% +% +% \changes{v0.03}{1994/06/01}{Use new style error commands. DPC} +% \changes{v0.02}{1994/05/10}{Added a \cmd\relax, to stop arguments to +% \cmd\newcommand\ being unbraced by \cmd\ProvidesCommand. Added +% an error message for commands which are requested but never +% defined. Spotted by DPC.} +% +% \section*{Overview} +% +% This is an example `programmers toolkit' package, for use by package +% writers. It allows package writers to provide options which switch +% definitions on and off. For example, a package |fred| might define a +% large number of commands, including |\foo| and |\baz|, so: +% \begin{verbatim} +% \usepackage{fred} +% \end{verbatim} +% would use a lot of memory, even if |\foo| and |\baz| were the only +% commands needed. However, if the author of |fred| used the |somedefs| +% package, then the user would be able to say: +% \begin{verbatim} +% \usepackage[only,foo,baz]{fred} +% \end{verbatim} +% and only the commands |\foo| and |\baz| would be defined. +% +% To use the |somedefs| package in your own packages or classes, you +% say: +% \begin{verbatim} +% \RequirePackage{somedefs} +% \end{verbatim} +% You can then use four new commands: +% \begin{flushleft}\begin{itemize} +% \item |\UseAllDefinitions| which says that all the commands in the +% file should be defined. +% \item |\UseSomeDefinitions| which says that only the commands +% specified by |\UseDefinition| should be defined. +% \item |\UseDefinition{|\meta{name}|}| which says that the command +% |\name| should be defined. +% \item |\ProvidesDefinition{|\meta{definition}|}| which provides one +% definition, of the form |\definingcommand{\command}...| +% \end{itemize}\end{flushleft} +% For example, the package |fred| could say: +% \begin{verbatim} +% \RequirePackage{somedefs} +% \UseAllDefinitions +% \DeclareOption{only}{\UseSomeDefinitions} +% \DeclareOption*{\UseDefinition{\CurrentOption}} +% \ProcessOptions +% \ProvidesDefinition{\newcommand{\foo}{...}} +% \ProvidesDefinition{\newcommand{\baz}{...}} +% \end{verbatim} +% One of the commands |\UseAllDefinitions| or |\UseSomeDefinitions| +% should always be used. You may have some commands which need other +% commands, in which case you have to declare the options by hand. For +% example, if the command |\bar| needs the command |\foo|, you could +% say: +% \begin{verbatim} +% \DeclareOption{bar}{\UseDefinition{bar}\UseDefinition{foo}} +% \end{verbatim} +% For a longer example of the use of the |somedefs| package, look at the +% |rawfonts| package. +% +% \StopEventually{} +% +% \section*{Implementation} +% +% The driver for the documentation you're now reading. +% \begin{macrocode} +%<*driver> +\documentclass{ltxdoc} +\begin{document} +\DocInput{somedefs.dtx} +\end{document} +%</driver> +% \end{macrocode} +% This is a \LaTeXe{} package. +% \begin{macrocode} +%<*package> +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{somedefs}[1994/06/01 v0.03 Toolkit for optional definitions] +% \end{macrocode} +% \begin{macro}{\UseSomeDefinitions} +% \begin{macro}{\UseAllDefinitions} +% \begin{macro}{\UseDefinition} +% \begin{macro}{\ProvidesDefinition} +% \begin{macro}{\@providesdefinition} +% \begin{macro}{\@provides@definition} +% \begin{macro}{\@unprovided@definition} +% The package works by having |\UseDefinition{|\meta{name}|}| define +% |\name| to be |\@unprovided@definition|. +% If |\UseSomeDefinitions| has been called, +% then |\ProvidesDefinition| looks to see if |\name| +% is |\@unprovided@definition|. If +% |\UseAllDefinitions| has been called, then |\ProvidesDefinition| +% does nothing. If neither has been called, then +% |\ProvidesDefinition| produces an error message. +% \begin{macrocode} +\def\UseSomeDefinitions{% + \let\ProvidesDefinition\@providesdefinition +} +\def\UseAllDefinitions{% + \let\ProvidesDefinition\@firstofone +} +\def\UseDefinition#1{% + \expandafter\let\csname#1\endcsname\@unprovided@definition +} +\def\ProvidesDefinition#1{% + \PackageError{somedefs}% + {No \noexpand\UseSomeDefinitions or \string\UseAllDefinitions}% + {The package which used the `somedefs' package has an error.}% +} +\def\@providesdefinition#1{\@provides@definition#1\relax + \@provides@definition} +\def\@provides@definition#1#2#3\@provides@definition{% + \ifx#2\@unprovided@definition + #1#2#3% + \fi +} +\def\@unprovided@definition{% + \PackageError{somedefs}% + {Package `somedefs' error: this command was never defined}% + {You have requested a command which does not exist.}% +} +\@onlypreamble\UseSomeDefinitions +\@onlypreamble\UseAllDefinitions +\@onlypreamble\UseDefinition +\@onlypreamble\ProvidesDefinition +\@onlypreamble\@providesdefinition +\@onlypreamble\@provides@definition +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% That's it! +% \begin{macrocode} +%</package> +% \end{macrocode} +% +% \Finale +% +% \endinput diff --git a/macros/latex-dev/required/tools/somedefs.pdf b/macros/latex-dev/required/tools/somedefs.pdf Binary files differnew file mode 100644 index 0000000000..b701b5a16e --- /dev/null +++ b/macros/latex-dev/required/tools/somedefs.pdf diff --git a/macros/latex-dev/required/tools/tabularx.dtx b/macros/latex-dev/required/tools/tabularx.dtx new file mode 100644 index 0000000000..ff8f3cec9a --- /dev/null +++ b/macros/latex-dev/required/tools/tabularx.dtx @@ -0,0 +1,968 @@ +% \iffalse meta-comment +% +% Copyright (C) 1993-2019 +% +% The LaTeX3 Project and any individual authors listed elsewhere +% in this file. +% +% This file is part of the Standard LaTeX `Tools Bundle'. +% ------------------------------------------------------- +% +% It may be distributed and/or modified under the +% conditions of the LaTeX Project Public License, either version 1.3c +% of this license or (at your option) any later version. +% The latest version of this license is in +% https://www.latex-project.org/lppl.txt +% and version 1.3c or later is part of all distributions of LaTeX +% version 2005/12/01 or later. +% +% The list of all files belonging to the LaTeX `Tools Bundle' is +% given in the file `manifest.txt'. +% +% \fi +% \iffalse +%% File: tabularx.dtx Copyright (C) 1991-1999 2012 2014 2016 2017 David Carlisle +% +%<*dtx> + \ProvidesFile{tabularx.dtx} +%</dtx> +%<package>\NeedsTeXFormat{LaTeX2e} +%<package>\ProvidesPackage{tabularx} +%<driver> \ProvidesFile{tabularx.drv} +% \fi +% \ProvidesFile{tabularx.dtx} + [2016/02/03 v2.11b `tabularx' package (DPC)] +% \iffalse +%<*driver> +\documentclass{ltxdoc} +\usepackage[infoshow]{tabularx} +\begin{document} + \DocInput{tabularx.dtx} +\end{document} +%</driver> +% \fi +% +% \changes{v1.00}{1992/01/30}{Initial version.} +% \changes{v1.01}{1992/07/07}{Re-issue for the new doc and docstrip.} +% \changes{v1.02}{1992/07/17}{Added some support for \cmd\verb} +% \changes{v1.03}{1992/08/17} +% {Added \cs{ifnum0}!=`\{\cs{fi}\} brackets after report by +% Andreas Maassen} +% \changes{v1.04}{1992/09/02} +% {fixed \cmd\verb, and support footnotes.} +% \changes{v1.05}{1992/11/06} +% {preserve all LaTeX counters} +% \changes{v1.06}{1993/08/02} +% {(Martin Schroeder) Support the optional [t] or [b] argument. +% Also now works with delarray.sty.} +% \changes{v1.07}{1993/08/27} +% {Modifications to make this style compatible with calc.sty.} +% \changes{v2.00}{1994/03/14} +% {Update to LaTeX2e} +% \changes{v2.01}{1994/05/22} +% {New Tracing format.} +% +% +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% +% +% \GetFileInfo{tabularx.dtx} +% \title{The \textsf{tabularx} package\thanks{This file +% has version number \fileversion, last +% revised \filedate.}} +% \author{David Carlisle} +% \date{\filedate} +% \MaintainedByLaTeXTeam{tools} +% \maketitle +% \DeleteShortVerb{\|} +% \MakeShortVerb{\"} +% +% \begin{abstract} +% A new environment, {\ttfamily tabularx}, is defined, which takes the +% same arguments as {\ttfamily tabular*}, but modifies the widths of +% certain columns, rather than the inter column space, to set a table +% with the requested total width. The columns that may stretch are +% marked with the new token {\ttfamily X} in the preamble argument. +% +% This package requires the {\ttfamily array} package. +% \end{abstract} +% +% \section{Introduction} +% This package implements a version of the {\ttfamily tabular} +% environment in which the widths of certain columns are calculated so +% that the table is a specified width. Requests for such an +% environment seem to occur quite regularly in {\ttfamily +% comp.text.tex}. +% +% \DescribeEnv{tabularx} +% "\begin{tabularx}{"\meta{width}"}["\meta{pos}"]{"\meta{preamble}"}"\\ +% The arguments of "tabularx" are essentially the same as those of +% the standard "tabular*" environment. However rather than adding space +% between the columns to achieve the desired width, it adjusts the +% widths of some of the columns. The columns which are affected by the +% {\ttfamily tabularx} environment should be denoted with the letter +% {\ttfamily X} in the preamble argument. The {\ttfamily X} column +% specification will be converted to "p{"\meta{some value}"}" once the +% correct column width has been calculated. +% +% \section{Examples} +% +% The following table is set with +% "\begin{tabularx}{250pt}{|c|X|c|X|} ...". +% +% \begin{center} +% \begin{tabularx}{250pt}{|c|X|c|X|} +% \hline +% \multicolumn{2}{|c|}{Multicolumn entry!}& +% THREE& +% FOUR\\ +% \hline +% one& +% \raggedright\arraybackslash The width of this column depends on the +% width of the table.\footnote +% {You can now use {\ttfamily \bslash footnote} inside {\ttfamily +% tabularx}!}& +% three& +% \raggedright\arraybackslash Column four will act in the same way as +% column two, with the same width.\\ +% \hline +% \end{tabularx} +% \end{center} +% If we change the first line to "\begin{tabularx}{300pt}{|c|X|c|X|}" we +% get: +% \begin{center} +% \begin{tabularx}{300pt}{|c|X|c|X|} +% \hline +% \multicolumn{2}{|c|}{Multicolumn entry!}& +% THREE& +% FOUR\\ +% \hline +% one& +% \raggedright\arraybackslash The width of this column depends on the +% width of the table.& +% three& +% \raggedright\arraybackslash Column four will act in the same way as +% column two, with the same width.\\ +% \hline +% \end{tabularx} +% \end{center} +% +% \edef\mytt{\expandafter\noexpand\csname +% mdseries\endcsname\noexpand\ttfamily} +% \section{Differences between {\mytt tabularx} and {\mytt tabular*}} +% These two environments take the same arguments, to produce a table of +% a specified width. The main differences between them are: +% \begin{itemize} +% \item {\ttfamily tabularx} modifies the widths of the \emph{columns}, +% whereas {\ttfamily tabular*} modifies the widths of the inter-column +% \emph{spaces}. +% \item {\ttfamily tabular} and {\ttfamily tabular*} environments may be +% nested with no restriction, however if one {\ttfamily tabularx} +% environment occurs inside another, then the inner one {\em must\/} be +% enclosed by "{ }". +% \item The body of the {\ttfamily tabularx} environment is in fact the +% argument to a command, and so certain constructions which are not +% allowed in command arguments (like "\verb") may not be used.\footnote +% {Since Version 1.02, {\ttfamily\bslash verb and \ttfamily\bslash +% verb*} may be used, but they may treat spaces incorrectly, and the +% argument can not contain an unmatched {\ttfamily\char`\{} or +% {\ttfamily\char`\}}, or a {\ttfamily\char`\%} character.} +% \item {\ttfamily tabular*} uses a primitive capability of \TeX\ to +% modify the inter column space of an alignment. {\ttfamily tabularx} +% has to set the table several times as it searches for the best column +% widths, and is therefore much slower. Also the fact that the body is +% expanded several times may break certain \TeX\ constructs. +% \end{itemize} +% +% \section{Customising the behaviour of {\mytt tabularx}} +% +% \subsection{Terminal output} +% \DescribeMacro{\tracingtabularx} +% If this declaration is made, say in the document preamble, then all +% following {\ttfamily tabularx} environments will print information +% about column widths as they repeatedly re-set the tables to find the +% correct widths. +% +% As an alternative to using the "\tracingtabularx" declaration, either +% of the options "infoshow" or "debugshow" may be given, either in the +% "\usepackage" command that loads "tabularx", or as a global option +% in the "\documentclass" command. +% +% \subsection{The environment used to typeset the {\mytt X} columns} +% By default the {\ttfamily X} specification is turned into +% "p{"\meta{some value}"}". Such narrow columns often +% require a special format, this may be achieved using the ">" syntax +% of {\ttfamily array.sty}. So for example you may give a specification +% of ">{\small}X". Another format which is useful in narrow columns is +% ragged right, however \LaTeX's "\raggedright" macro redefines +% "\\" in a way which conflicts with its use in a tabular or array +% environments. +%\DescribeMacro{\arraybackslash} +% For this reason this package introduces the command "\arraybackslash", +% this may be used after a "\raggedright", "\raggedleft" or +% "\centering" declaration. Thus a {\ttfamily tabularx} preamble may +% specify\\ +% ">{\raggedright\arraybackslash}X". +% +% \DescribeMacro{\newcolumntype} +% These preamble specifications may of course be saved using the +% command, "\newcolumntype", defined in {\ttfamily array.sty}. Thus we +% may say\\ +% "\newcolumntype{Y}{>{\small\raggedright\arraybackslash}X}"\\ +% and then use {\ttfamily Y} in the {\ttfamily tabularx} preamble +% argument. +% +% \DescribeMacro{\tabularxcolumn} +% The {\ttfamily X} columns are set using the {\ttfamily p} column which +% corresponds to "\parbox[t]". You may want them set using, say, the +% {\ttfamily m} column, which corresponds to "\parbox[c]". It is not +% possible to change the column type using the ">" syntax, so another +% system is provided. "\tabularxcolumn" should be defined to be a macro +% with one argument, which expands to the {\ttfamily tabular} preamble +% specification that you want to correspond to {\ttfamily X}. The +% argument will be replaced by the calculated width of a column. +% +% The default is "\newcommand{\tabularxcolumn}[1]{p{#1}}". So we may +% change this with a command such as:\\ +% "\renewcommand{\tabularxcolumn}[1]{>{\small}m{#1}}" +% +% \subsection{Column widths} +% Normally all {\ttfamily X} columns in a single table are set to the +% same width, however it is possible to make {\ttfamily tabularx} set +% them to different widths. +% A preamble argument of +% "{>{\hsize=.5\hsize\linewidth=\hsize}X"\\ +% " >{\hsize=1.5\hsize\linewidth=\hsize}X}"\\ +% specifies two columns, the second will be three times as wide as the +% first. However if you want to play games like this you should follow +% the following two rules. +% \begin{itemize} +% \item Make sure that the sum of the widths of all the {\ttfamily X} +% columns is unchanged. (In the above example, the new widths still add +% up to twice the default width, the same as two standard {\ttfamily X} +% columns.) +% \item Do not use "\multicolumn" entries which cross any {\ttfamily X} +% column. +% \end{itemize} +% As with most rules, these may be broken if you know what you are +% doing. +% +% \subsection{If the algorithm fails\ldots} +% It may be that the widths of the `normal' columns of the table +% already total more than the requested total +% width. \textsf{tabularx} refuses to set the +% \texttt{X} columns to a negative width, so in this case you get a +% warning ``X Columns too narrow (table too wide)''. +% +% The \texttt{X} columns will in this case be set to a width of 1em +% and so the table itself will be wider than the requested total width +% given in the argument to the environment. +% This behaviour of the package can be customised slightly +% as noted in the documentation of the code section. +% +% \StopEventually{} +% +% \section{The Macros} +% +% \begin{macrocode} +%<*package> +% \end{macrocode} +% +% \changes{v2.00}{1994/02/07} +% {New Option Handling} +% \begin{macrocode} +\DeclareOption{infoshow}{\AtEndOfPackage\tracingtabularx} +\DeclareOption{debugshow}{\AtEndOfPackage\tracingtabularx} +\ProcessOptions +% \end{macrocode} +% +% This requires {\ttfamily array.sty}. +% \changes{v2.00}{1994/02/07} +% {Use LaTeX2e's \cmd{\RequirePackage} to load array} +% \begin{macrocode} +\RequirePackage{array}[1994/02/03] +% \end{macrocode} +% +% First some registers etc.\ that we need. +% \begin{macrocode} +\newdimen\TX@col@width +\newdimen\TX@old@table +\newdimen\TX@old@col +\newdimen\TX@target +\newdimen\TX@delta +\newcount\TX@cols +\newif\ifTX@ +% \end{macrocode} +% +% Now a trick to get the body of an environment into a token register, +% without doing any expansion. This does not do any real checking of +% nested environments, so if you should need to nest one {\ttfamily +% tabularx} inside another, the inner one must be surrounded by "{ }". +% +% \begin{macro}{\tabularx} +% Prior to v1.06, this macro took two arguments, which were saved in +% separate registers before the table body was saved by "\TX@get@body". +% Unfortunately this disables the "[t]" optional argument. Now just save +% the width specification separately, then clear the token register +% "\toks@". +% Finally call "\TX@get@body" to begin saving the body of the table. +% The "{\ifnum0=`}\fi" was added at v1.03, to allow "tabularx" to appear +% inside a "\halign".^^A +% \setbox0=\hbox{\footnotesize"\iffalse{\fi\ifnum0=`}\fi"}^^A +% \setbox2=\hbox{\footnotesize"\ifnum0=`{}\fi"}^^A +% \footnote{This adds an extra level of grouping, +% which is not really needed. Instead, I could use \box0\ here, and +% \box2\ below, however the code here would then have to be moved after +% the first line, because of the footnote to page 386 of the \TeX{}Book, +% and I do not think I should be writing code that is so obscure as to +% be documented in a footnote in an appendix called ``Dirty Tricks''!} +% +% This mechanism of grabbing an environment body does have the +% disadvantage (shared with the AMS alignment environments) that you +% can not make extension environments by code such as +%\begin{verbatim} +%\newenvironment{foo}{\begin{tabularx}{XX}}{\end{tabularx}} +%\end{verbatim} +% as the code is looking for a literal string "\end{tabularx}" to stop +% scanning. Since version 2.02, one may avoid this problem by using +% "\tabularx" and "\endtabularx" directly in the definition: +%\begin{verbatim} +%\newenvironment{foo}{\tabularx{XX}}{\endtabularx} +%\end{verbatim} +% The scanner now looks for the end of the current environment ("foo" in +% this example.) There are some restrictions on this usage, the +% principal one being that "\endtabularx" must not be inside any "{ }" pairs +% ao that the code before "\endtabularx" may be extracted and added to the table body +% (prior to version 2.09 "\endtabularx" had to be +% the \emph{first} token of the `end code' of the environment). +% \begin{macrocode} +\def\tabularx#1{% +% \end{macrocode} +% \changes{v2.02}{1995/03/20} +% {New local setting of \cs{TX@}} +% \changes{v4.09}{1998/05/13} +% {Use \cs{setlength}, so that calc extensions apply. tools/2793} +% Allow "\tabularx" "\endtabularx" (but not "\begin{tabularx}" +% "\end{tabularx}") to be used in "\newenvironment" definitions. +% \begin{macrocode} +\edef\TX@{\@currenvir}% + {\ifnum0=`}\fi +% \end{macrocode} +% "\relax" added at v1.05 so that non-expandable length tokens, like +% "\textwidth" do not generate an extra space, and an overfull box. +% "\relax" removed again at v4.09 in favour of "\setlength" so if you +% use the calc package you can use a width of "(\textwidth-12pt)/2". +% \begin{macrocode} + \setlength\TX@target{#1}% + \TX@typeout{Target width: #1 = \the\TX@target.}% + \toks@{}\TX@get@body} +% \end{macrocode} +% \end{macro} +% + +% \begin{macro}{\endtabularx} +% This does not do very much\ldots +% \changes{v2.02}{1995/03/20} +% {Macro added} +% \begin{macrocode} +\let\endtabularx\relax +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\TX@get@body} +% Place all tokens as far as the first "\end" into a token register. +% Then call "\TX@find@end" to see if we are at "\end{tabularx}". +% \begin{macrocode} +\long\def\TX@get@body#1\end + {\toks@\expandafter{\the\toks@#1}\TX@find@end} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\TX@find@end} +% If we are at "\end{tabularx}", call "\TX@endtabularx", otherwise +% add "\end{...}" to the register, and call "\TX@get@body" again. +% \begin{macrocode} +\def\TX@find@end#1{% + \def\@tempa{#1}% + \ifx\@tempa\TX@\expandafter\TX@endtabularx + \else\toks@\expandafter + {\the\toks@\end{#1}}\expandafter\TX@get@body\fi} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\TX@find@endtabularxa} +% \changes{v2.09}{2014/04/22}{macro added} +% \changes{v2.10}{2014/05/13}{macro modified to test for missing \cs{endtabularx}} +% \changes{v2.11}{2016/01/03}{Fix to previous change to guard against empty arg 2. (Ulrike Fischer)} +% split up the end code, and extract the part that lives in the table body. +% \begin{macrocode} +\long\def\TX@find@endtabularxa + #1\endtabularx#2\endtabularx#3\TX@find@endtabularxa{% + \ifx\TX@#2\relax\else + \toks@\expandafter{\the\toks@#1}% + \fi} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\TX@find@endtabularxb} +% \changes{v2.09}{2014/04/22}{macro added} +% \changes{v2.10}{2014/05/13}{macro modified to test for missing \cs{endtabularx}} +% split up the end code, and extract the part that lives outside the table body. +% \begin{macrocode} +\long\def\TX@find@endtabularxb + #1\endtabularx#2\endtabularx#3\TX@find@endtabularxb{% + \ifx\TX@#2% + \expandafter\@firstoftwo + \else + \expandafter\@secondoftwo + \fi + {#1}{#2}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\TX@find@endtabularxbb} +% \changes{v2.10}{2014/05/13}{macro added} +% Helper to avoid needing 15 consecutive "expandafter" +% \begin{macrocode} +\def\TX@find@endtabularxbb{% + \expandafter\expandafter\expandafter + \TX@find@endtabularxb +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\TX@} +% The string {\ttfamily tabularx} as a macro for testing with "\ifx". +% \begin{macrocode} +\def\TX@{tabularx} +% \end{macrocode} +% \end{macro} +% +% Now that all the parts of the table specification are stored in +% registers, we can begin the work of setting the table. +% +% The algorithm for finding the correct column widths is as follows. +% Firstly set the table with each {\ttfamily X} column the width of the +% final table. Assuming that there is at least one {\ttfamily X} column, +% this will produce a table that is too wide. Divide the excess width by +% the number of {\ttfamily X} columns, and reduce the column width by +% this amount. Reset the table. If the table is not now the correct +% width, a "\multicolumn" entry must be `hiding' one of the {\ttfamily +% X} columns, and so there is one less {\ttfamily X} column affecting +% the width of the table. So we reduce by 1 the number of X columns and +% repeat the process. +% +% \begin{macro}{\TX@endtabularx} +% Although I have tried to make {\ttfamily tabularx} look like an +% environment, it is in fact a command, all the work is done by this +% macro. +% \begin{macrocode} +\def\TX@endtabularx{% +% \end{macrocode} +% \changes{v2.09}{2014/04/22}{call to \cs{TX@find@endtabularxa} added} +% \changes{v2.10}{2014/05/13}{macro modified to test for missing \cs{endtabularx}} +% \begin{macrocode} + \expandafter\expandafter\expandafter + \TX@find@endtabularxa\csname end\TX@\endcsname + \endtabularx\TX@\endtabularx\TX@find@endtabularxa +% \end{macrocode} +% Define the {\ttfamily X} column, with an internal version of the +% "\newcolumntype" command. The "\expandafter" commands enable +% "\NC@newcol" to get the {\em expansion} of\\ +% "\tabularxcolumn{\TX@col@width}" as its +% argument. This will be the definition of an {\ttfamily X} column, as +% discussed in section 4. +% \begin{macrocode} + \expandafter\TX@newcol\expandafter{\tabularxcolumn{\TX@col@width}}% +% \end{macrocode} +% Initialise the column width, and the number of {\ttfamily X} columns. +% The number of {\ttfamily X} columns is set to one, which means that +% the initial count will be one too high, but this value is decremented +% before it is used in the main loop. +% +% Since v1.02, switch the definition of "\verb". +% \begin{macrocode} + \let\verb\TX@verb +% \end{macrocode} +% Since v1.05, save the values of all \LaTeX\ counters, the list +% "\cl@@ckpt" contains the names of all the \LaTeX\ counters that have +% been defined so far. We expand "\setcounter" at this point, as it +% results in fewer tokens being stored in "\TX@ckpt", but the actual +% resetting of the counters occurs when "\TX@ckpt" is expanded after +% each trial run. +% Actually since v1.07, use something equivalent to the expansion of the +% original definition of "\setcounter", so that "tabularx" works in +% conjunction with "calc.sty". +% \begin{macrocode} + \def\@elt##1{\global\value{##1}\the\value{##1}\relax}% + \edef\TX@ckpt{\cl@@ckpt}% + \let\@elt\relax + \TX@old@table\maxdimen + \TX@col@width\TX@target + \global\TX@cols\@ne +% \end{macrocode} +% Typeout some headings (unless this is disabled). +% \begin{macrocode} + \TX@typeout@ + {\@spaces Table Width\@spaces Column Width\@spaces X Columns}% +% \end{macrocode}% +% First attempt. Modify the {\ttfamily X} definition to count {\ttfamily +% X} columns. +% \begin{macrocode} + \TX@trial{\def\NC@rewrite@X{% + \global\advance\TX@cols\@ne\NC@find p{\TX@col@width}}}% +% \end{macrocode} +% Repeatedly decrease column width until table is the correct width, +% or stops shrinking, or the columns become two narrow. +% If there are no multicolumn entries, this will only take one attempt. +% \begin{macrocode} + \loop + \TX@arith + \ifTX@ + \TX@trial{}% + \repeat +% \end{macrocode} +% One last time, with warnings back on (see appendix D) +% use {\ttfamily tabular*} to put it in a box of the right size, in case +% the algorithm failed to find the correct size. +% +% Since v1.04, locally make "\footnotetext" save its argument in a token +% register. +% Since v1.06, "\toks@" contains the preamble specification, +% and possible optional argument, as well as the table body. +% \begin{macrocode} + {\let\@footnotetext\TX@ftntext\let\@xfootnotenext\TX@xftntext + \csname tabular*\expandafter\endcsname\expandafter\TX@target + \the\toks@ + \csname endtabular*\endcsname}% +% \end{macrocode} +% Now the alignment is finished, and the "}" has restored the original +% meaning of "\@footnotetext" expand the register "\TX@ftn" which will +% execute a series of\\ +% "\footnotetext["\meta{num}"]{"\meta{note}"}"\\ +% commands. We need to be careful about clearing the register as we may +% be inside a nested {\ttfamily tabularx}. +% \begin{macrocode} + \global\TX@ftn\expandafter{\expandafter}\the\TX@ftn +% \end{macrocode} +% Now finish off the {\ttfamily tabularx} environment. Note that we need +% "\end{tabularx}" here as the "\end{tabularx}" in the user's +% file is never expanded. Now use "\TX@" rather than "tabularx". +% \changes{v2.02}{1995/03/20} +% {Close the environment \cs{TX@} rather than `tabularx'} +% +% We also need to finish off the group started by "{\ifnum0=`}\fi" in +% the macro "\tabularx". +% \begin{macrocode} + \ifnum0=`{\fi}% +% \end{macrocode} +% \changes{v2.09}{2014/04/22}{call to \cs{TX@find@endtabularxb} added} +% \changes{v2.10}{2014/05/13}{macro modified to test for missing \cs{endtabularx}} +% \begin{macrocode} + \expandafter\expandafter\expandafter + \TX@find@endtabularxbb + \expandafter\end\expandafter{\TX@}% + \endtabularx\TX@\endtabularx\TX@find@endtabularxb +} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\TX@arith} +% Calculate the column width for the next try, setting the flag +% "\ifTX@" to false if the loop should be aborted. +% \begin{macrocode} +\def\TX@arith{% + \TX@false +% \end{macrocode} +% \changes{v2.08}{2012/02/06}{Avoid exceeding maxdimen during trials} +% \begin{macrocode} + \@tempdimb\maxdimen + \divide\@tempdimb\TX@cols + \ifdim\TX@col@width>\@tempdimb + \TX@typeout@{Don't exceed \maxdimen}% + \wd\@tempboxa\maxdimen + \fi + \ifdim\TX@old@table=\wd\@tempboxa +% \end{macrocode} +% If we have reduced the column width, but the table width has not +% changed, we stop the loop, and output the table (which will cause an +% over-full alignment) with the previous value of "\TX@col@width". +% \begin{macrocode} + \TX@col@width\TX@old@col + \TX@typeout@{Reached minimum width, backing up.}% + \else +% \end{macrocode} +% Otherwise calculate the amount by which the current table is too wide. +% \begin{macrocode} + \dimen@\wd\@tempboxa + \advance\dimen@ -\TX@target + \ifdim\dimen@<\TX@delta +% \end{macrocode} +% If this amount is less than "\TX@delta", stop. ("\TX@delta" +% should be non-zero otherwise we may miss the target due to rounding +% error.) +% \begin{macrocode} + \TX@typeout@{Reached target.}% + \else +% \end{macrocode} +% Reduce the number of effective {\ttfamily X} columns by one. (Checking +% that we do not get 0, as this would produce an error later.) Then +% divide excess width by the number of effective columns, and calculate +% the new column width. Temporarily store this value (times $-1$) in +% "\dimen@". +% \begin{macrocode} + \ifnum\TX@cols>\@ne + \advance\TX@cols\m@ne + \fi + \divide\dimen@\TX@cols + \advance\dimen@ -\TX@col@width + \ifdim \dimen@ >\z@ +% \end{macrocode} +% If the new width would be too narrow, abort the loop. At the moment +% too narrow, means less than 0\,pt! +% +% Prior to v2.03, if the loop was aborted here, the X columns were left +% with the width of the previous run, but this may make the table far +% too wide as initial guesses are always too big. Now force to +% "\TX@error@width" which defaults to be 1em. If you want to +% get the old behaviour stick\\ +% "\renewcommand\TX@error@width{\TX@col@width}"\\ +% in a package file loaded after \textsf{tabularx}. +% \changes{v2.03}{1997/02/20}{Improve warning message and force to 1em.} +% \begin{macrocode} + \PackageWarning{tabularx}% + {X Columns too narrow (table too wide)\MessageBreak}% + \TX@col@width\TX@error@width\relax + \else +% \end{macrocode} +% Otherwise save the old settings, and set the new column width. Set the +% flag to true so that the table will be set, and the loop will be +% executed again. +% \begin{macrocode} + \TX@old@col\TX@col@width + \TX@old@table\wd\@tempboxa + \TX@col@width-\dimen@ + \TX@true + \fi + \fi + \fi} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\TX@error@width} +% \changes{v2.03}{1997/02/20}{macro added.} +% \changes{v2.04}{1997/02/26}{spurious brace removed.} +% If the calculated width is negative, use this instead. +% \begin{macrocode} +\def\TX@error@width{1em} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\TX@delta} +% Accept a table that is within "\hfuzz" of the correct width. +% \begin{macrocode} +\TX@delta\hfuzz +% \end{macrocode} +% \end{macro} +% +% Initialise the {\ttfamily X} column. The definition can be empty here, +% as it is set for each {\ttfamily tabularx} environment. +% \begin{macrocode} +\newcolumntype{X}{} +% \end{macrocode} +% +% \begin{macro}{\tabularxcolumn} +% The default definition of {\ttfamily X} is "p{#1}". +% \begin{macrocode} +\def\tabularxcolumn#1{p{#1}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\TX@newcol} +% A little macro just used to cut down the number of "\expandafter" +% commands needed. +% \begin{macrocode} +\def\TX@newcol{\newcol@{X}[0]} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\TX@trial} +% Make a test run. +% \begin{macrocode} +\def\TX@trial#1{% + \setbox\@tempboxa\hbox{% +% \end{macrocode} +% Any extra commands. This is used on the first run to count the number +% of {\ttfamily X} columns. +% \begin{macrocode} + #1\relax +% \end{macrocode} +% Since v1.04, make "\footnotetext" gobble its arguments. Also locally +% clear "\TX@vwarn" so that the warning is generated by the {\ttfamily +% final} run, and does not appear in the middle of the table if +% "\tracingtabularx". +% \begin{macrocode} + \let\@footnotetext\TX@trial@ftn + \let\TX@vwarn\@empty +% \end{macrocode} +% Do not nest {\ttfamily tabularx} environments during trial runs. This +% would waste time, and the global setting of "\TX@cols" would break the +% algorithm. +% \begin{macrocode} + \expandafter\let\expandafter\tabularx\csname tabular*\endcsname + \expandafter\let\expandafter\endtabularx\csname endtabular*\endcsname +% \end{macrocode} +% Added at v1.05: disable "\write"s during a trial run. This trick is +% from the \TeX{}Book.\footnote{Actually the \TeX{}Book trick does +% not work correctly, so changed for v2.05.} +% \changes{v2.05}{1997/09/18} +% {New \cs{write} trick. tools/2607} +% \changes{v2.07}{1999/01/07} +% {Newer \cs{write} trick. tools/2792} +% \begin{macrocode} + \def\write{\begingroup + \def\let{\afterassignment\endgroup\toks@}% + \afterassignment\let\count@}% +% \end{macrocode} +% Turn off warnings (see appendix D). Also prevent them being turned +% back on by setting the parameter names to be registers. +% \begin{macrocode} + \hbadness\@M + \hfuzz\maxdimen + \let\hbadness\@tempcnta + \let\hfuzz\@tempdima +% \end{macrocode} +% Make the table, and finish the hbox. +% Since v1.06, "\toks@" contains the preamble specification, +% and possible optional argument, as well as the table body. +% \begin{macrocode} + \expandafter\tabular\the\toks@ + \endtabular}% +% \end{macrocode} +% Since v1.05 reset all \LaTeX\ counters, by executing "\TX@ckpt". +% \begin{macrocode} + \TX@ckpt +% \end{macrocode} +% Print some statistics. +% Added "\TX@align" in v1.05, to line up the columns. +% \begin{macrocode} + \TX@typeout@{\@spaces + \expandafter\TX@align + \the\wd\@tempboxa\space\space\space\space\space\@@ + \expandafter\TX@align + \the\TX@col@width\space\space\space\space\space\@@ + \@spaces\the\TX@cols}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\TX@align} +% Macro added at v1.05, to improve the printing of the tracing info. +% \begin{macrocode} +\def\TX@align#1.#2#3#4#5#6#7#8#9\@@{% + \ifnum#1<10 \space\fi + \ifnum#1<100 \space\fi + \ifnum#1<\@m\space\fi + \ifnum#1<\@M\space\fi + #1.#2#3#4#5#6#7#8\space\space} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\arraybackslash} +% "\\" hack. +% \changes{v2.08}{2012/02/06}{Don't define this if already defined by newer array package and use tabularnewline now this is in 2e.} +% \begin{macrocode} +\ifx\arraybackslash\@undefined +\def\arraybackslash{\let\\\tabularnewline} +\fi +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\tracingtabularx} +% Print statistics on column and table widths. +% \begin{macrocode} +\def\tracingtabularx{% + \def\TX@typeout{\PackageWarningNoLine{tabularx}}% + \def\TX@typeout@##1{\typeout{(tabularx) ##1}}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\TX@typeout} +% The default is to be to be quiet +% \begin{macrocode} +\let\TX@typeout\@gobble +\let\TX@typeout@\@gobble +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\TX@ftn} +% A token register for saving footnote texts. +% \begin{macrocode} +\newtoks\TX@ftn +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\TX@ftntext} +% \begin{macro}{\TX@xftntext} +% Inside the alignment just save up the footnote text in a token +% register. +% \begin{macrocode} +\long\def\TX@ftntext#1{% + \edef\@tempa{\the\TX@ftn\noexpand\footnotetext + [\the\csname c@\@mpfn\endcsname]}% + \global\TX@ftn\expandafter{\@tempa{#1}}}% +\long\def\TX@xftntext[#1]#2{% + \global\TX@ftn\expandafter{\the\TX@ftn\footnotetext[#1]{#2}}} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\TX@trial@ftn} +% On trial runs, gobble footnote texts. +% \begin{macrocode} +\long\def\TX@trial@ftn#1{} +% \end{macrocode} +% \end{macro} +% +% This last section was added at Version 1.02. Previous versions +% documented the fact that "\verb" did not work inside {\ttfamily +% tabularx}, but that did not stop people using it! This usually put +% \LaTeX\ into an irrecoverable error position, with error messages that +% did not mention the cause of the error. The `poor man's "\verb"' (and +% "\verb*") defined here is based on page 382 of the \TeX{}Book. As +% explained there, doing verbatim this way means that spaces are not +% treated correctly, and so "\verb*" may well be useless, however I +% consider this section of code to be error-recovery, rather than a real +% implementation of verbatim. +% +% The mechanism is quite general, and any macro which wants to allow a +% form of "\verb" to be used within its argument may +% "\let\verb=\TX@verb". (Making sure to restore the real definition +% later!) +% +% "\verb" and "\verb*" are subject to the following restrictions: +% \begin{enumerate} +% \item Spaces in the argument are not read verbatim, but may be skipped +% according to \TeX's usual rules. +% \item Spaces will be added to the output after control words, even if +% they were not present in the input. +% \item Unless the argument is a single space, any trailing space, +% whether in the original argument, or added as in (2), +% will be omitted. +% \item The argument must not end with "\", so "\verb|\|" is not +% allowed, however, because of (3), "\verb|\ |" produces +% "\". +% \item The argument must be balanced with respect to "{" and "}". So +% "\verb|{|" is not allowed. +% \item A comment character like "%" will not appear verbatim. It will +% act as usual, commenting out the rest of the input line! +% \item The combinations "?`" and "!`" will appear as +% {\ttfamily?`} and {\ttfamily!`} if the {\ttfamily cmtt} font is +% being used. +% \end{enumerate} +% +% \begin{macro}{\TX@verb} +% The internal definition of "\verb". Spaces will be replaced by "~", so +% for the star-form, "\let" "~" be \verb*| |, which we obtain as +% "\uppercase{*}". Use "{\ifnum0=`}\fi" rather than "\bgroup" to allow +% "&" to appear in the argument. +% \begin{macrocode} +{\uccode`\*=`\ % +\uppercase{\gdef\TX@verb{% + \leavevmode\null\TX@vwarn + {\ifnum0=`}\fi\ttfamily\let\\\ignorespaces + \@ifstar{\let~*\TX@vb}{\TX@vb}}}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\TX@vb} +% Get the `almost verbatim' text using "\meaning". The `"!"' is added to +% the front of the user supplied text, to ensure that the whole argument +% does not consist of a single "{ }" group. \TeX\ would strip the outer +% braces from such a group. The `"!"' will be removed later. +% +% Originally I followed Knuth, and had "\def\@tempa{##1}", however this +% did not allow "#" to appear in the argument. So in v1.04, I changed +% this to to use a token register, and "\edef". This allows "#" appear, +% but makes each one appear twice!, so later we loop through, replacing +% "##" by "#". +% \begin{macrocode} +\def\TX@vb#1{\def\@tempa##1#1{\toks@{##1}\edef\@tempa{\the\toks@}% + \expandafter\TX@v\meaning\@tempa\\ \\\ifnum0=`{\fi}}\@tempa!} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\TX@v} +% Strip the initial segment of the "\meaning", including the `"!"' +% added earlier. +% \begin{macrocode} +\def\TX@v#1!{\afterassignment\TX@vfirst\let\@tempa= } +% \end{macrocode} +% \end{macro} +% +% As explained above we are going to replace "##" pairs by "#". To do +% this we need non-special "#" tokens. Make "*" into a parameter +% token so that we can define macros with arguments. The normal meanings +% will be restored by the "\endgroup" later. +% \begin{macrocode} +\begingroup +\catcode`\*=\catcode`\# +\catcode`\#=12 +% \end{macrocode} +% +% \begin{macro}{\TX@vfirst} +% As a special case, prevent the first character from being dropped. +% This makes "\verb*| |" produce \verb*| |. Then call "\TX@v@". +% This is slightly tricky since v1.04, as I have to ensure that an +% actual "#" rather than a command "\let" to "#" is passed on if the +% first character is "#". +% \begin{macrocode} +\gdef\TX@vfirst{% + \if\@tempa#% + \def\@tempb{\TX@v@#}% + \else + \let\@tempb\TX@v@ + \if\@tempa\space~\else\@tempa\fi + \fi + \@tempb} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\TX@v@} +% Loop through the "\meaning", replacing all spaces by "~". If the last +% character is a space it is dropped, so that "\verb*|\LaTeX|" produces +% "\LaTeX" not \verb*|\LaTeX |. The rewritten tokens are then further +% processed to replace "##" pairs. +% \begin{macrocode} +\gdef\TX@v@*1 *2{% + \TX@v@hash*1##\relax\if*2\\\else~\expandafter\TX@v@\fi*2} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\TX@v@hash} +% The inner loop, replacing "##" by "#". +% \begin{macrocode} +\gdef\TX@v@hash*1##*2{*1\ifx*2\relax\else#\expandafter\TX@v@hash\fi*2} +% \end{macrocode} +% \end{macro} +% +% As promised, we now restore the normal meanings of "#" and "*". +% \begin{macrocode} +\endgroup +% \end{macrocode} +% +% \begin{macro}{\TX@vwarn} +% Warn the user the first time this "\verb" is used. +% \begin{macrocode} +\def\TX@vwarn{% + \@warning{\noexpand\verb may be unreliable inside tabularx}% + \global\let\TX@vwarn\@empty} +% \end{macrocode} +% \end{macro} +% +% \begin{macrocode} +%</package> +% \end{macrocode} +% +% \Finale +\endinput diff --git a/macros/latex-dev/required/tools/tabularx.ins b/macros/latex-dev/required/tools/tabularx.ins new file mode 100644 index 0000000000..06308d7735 --- /dev/null +++ b/macros/latex-dev/required/tools/tabularx.ins @@ -0,0 +1,74 @@ +%% +%% This file will generate fast loadable files and documentation +%% driver files from the doc files in this package when run through +%% LaTeX or TeX. +%% +%% Copyright (C) 1993-2019 +%% The LaTeX3 Project and any individual authors listed elsewhere +%% in this file. +%% +%% This file is part of the Standard LaTeX `Tools Bundle'. +%% ------------------------------------------------------- +%% +%% It may be distributed and/or modified under the +%% conditions of the LaTeX Project Public License, either version 1.3c +%% of this license or (at your option) any later version. +%% The latest version of this license is in +%% https://www.latex-project.org/lppl.txt +%% and version 1.3c or later is part of all distributions of LaTeX +%% version 2005/12/01 or later. +%% +%% As this file contains legal notices, it is NOT PERMITTED to modify +%% this file in any way that the legal information placed into +%% generated files is changed (i.e., the files generated when the +%% original file is executed). This restriction does not apply if +%% (parts of) the content is reused in a different WORK producing its +%% own generated files. +%% +%% The list of all files belonging to the `Tools Bundle' is +%% given in the file `manifest.txt'. +%% +%% +%% --------------- start of docstrip commands ------------------ +%% +\input docstrip + +\keepsilent + +\usedir{tex/latex/tools} + +\preamble + +This is a generated file. + +The source is maintained by the LaTeX Project team and bug +reports for it can be opened at https://latex-project.org/bugs/ +(but please observe conditions on bug reports sent to that address!) + +Copyright (C) 1993-2019 +The LaTeX3 Project and any individual authors listed elsewhere +in this file. + +This file was generated from file(s) of the Standard LaTeX `Tools Bundle'. +-------------------------------------------------------------------------- + +It may be distributed and/or modified under the +conditions of the LaTeX Project Public License, either version 1.3c +of this license or (at your option) any later version. +The latest version of this license is in + https://www.latex-project.org/lppl.txt +and version 1.3c or later is part of all distributions of LaTeX +version 2005/12/01 or later. + +This file may only be distributed together with a copy of the LaTeX +`Tools Bundle'. You may however distribute the LaTeX `Tools Bundle' +without such generated files. + +The list of all files belonging to the LaTeX `Tools Bundle' is +given in the file `manifest.txt'. + +\endpreamble + +\generate{\file{tabularx.sty}{\from{tabularx.dtx}{package}}} + +\endbatchfile diff --git a/macros/latex-dev/required/tools/tabularx.pdf b/macros/latex-dev/required/tools/tabularx.pdf Binary files differnew file mode 100644 index 0000000000..83d15b9119 --- /dev/null +++ b/macros/latex-dev/required/tools/tabularx.pdf diff --git a/macros/latex-dev/required/tools/theorem.dtx b/macros/latex-dev/required/tools/theorem.dtx new file mode 100644 index 0000000000..6f745d016e --- /dev/null +++ b/macros/latex-dev/required/tools/theorem.dtx @@ -0,0 +1,1144 @@ +% \iffalse meta-comment +% +% Copyright (C) 1993-2019 +% +% The LaTeX3 Project and any individual authors listed elsewhere +% in this file. +% +% This file is part of the Standard LaTeX `Tools Bundle'. +% ------------------------------------------------------- +% +% It may be distributed and/or modified under the +% conditions of the LaTeX Project Public License, either version 1.3c +% of this license or (at your option) any later version. +% The latest version of this license is in +% https://www.latex-project.org/lppl.txt +% and version 1.3c or later is part of all distributions of LaTeX +% version 2005/12/01 or later. +% +% The list of all files belonging to the LaTeX `Tools Bundle' is +% given in the file `manifest.txt'. +% +% \fi +% +%% +% +% +\def\FMithmInfo{2014/10/28 v2.2c Theorem extension package (FMi)} +% +% \ProvidesFile{theorem.dtx}[\FMithmInfo] +%\iffalse % this is a METACOMMENT ! +%% +%% Package `theorem' to use with LaTeX2e +%% Copyright (C) 1989-1995 Frank Mittelbach, all rights reserved. +%<+package>\@ifundefined{theorem@style}{}{\endinput} +%<+package>\NeedsTeXFormat{LaTeX2e}[1995/06/01] +%<+package>\ProvidesPackage{theorem} +%<+package> [\FMithmInfo] +% +% \fi +% +% \changes{v1.0}{87/05/07}{First draft.} +% \changes{v1.0a}{87/05/07}{`thistheoremstyle' added.} +% \changes{v1.1a}{87/07/29}{New concept: redefine the internal +% \protect\LaTeX{} commands `@xnthm' etc.} +% \changes{v1.1b}{87/07/31}{`theoremfont' used to specify font.} +% \changes{v1.2a}{88/01/08}{`@endtheorem' now globally defined.} +% \changes{v1.2b}{88/01/11}{`newtheorem' only allowed in the preamble.} +% \changes{v1.3a}{88/02/14}{`theoremfont' now a toks register.} +% +% \changes{v2.0a}{88/11/16}{New implementation and new documentation.} +% \changes{v2.0a}{88/11/16}{No layout changes but internal modifications +% old substyles won't work.} +% \changes{v2.0b}{89/01/30}{`global' used for all definitions.} +% \changes{v2.0c}{89/06/15}{Documentation translated to English. +% Thanks to LLL and Nina} +% \changes{v2.1a}{90/02/15}{Support for new font selection.} +% \changes{v2.2a}{94/02/03}{Cleanup for LaTeX2e} +% +% \DoNotIndex{\@endparenv,\@ifdefinable,\@ifnextchar,\@ifundefined} +% \DoNotIndex{\@namedef,\@nameuse,\@spaces,\@tempa,\@warning} +% \DoNotIndex{\ } +% \DoNotIndex{\begingroup,\bfseries} +% \DoNotIndex{\csname} +% \DoNotIndex{\def,\do,\docdate} +% \DoNotIndex{\endcsname,\endgroup,\endinput,\endtrivlist,\expandafter} +% \DoNotIndex{\filedate,\fileversion} +% \DoNotIndex{\gdef,\global} +% \DoNotIndex{\hbox,\hskip} +% \DoNotIndex{\ignorespaces,\input,\itshape,\item} +% \DoNotIndex{\labelsep,\let,\llap} +% \DoNotIndex{\makeatletter} +% \DoNotIndex{\noexpand} +% \DoNotIndex{\refstepcounter,\relax,\rlap} +% \DoNotIndex{\setlength,\slshape,\space,\string,\strut} +% \DoNotIndex{\the,\trivlist,\typeout} +% \DoNotIndex{\vbox} +% \DoNotIndex{\xdef} +% +% \def\deflabel#1{\ttfamily #1\hfill} +% \def\deflist#1{\begin{list}{}{\settowidth\labelwidth{\ttfamily #1}% +% \setlength\leftmargin\labelwidth +% \addtolength\leftmargin\labelsep +% \let\makelabel\deflabel}} +% \def\enddeflist{\end{list}} +% \def\envfont{\normalfont\ttfamily} +% +% \MakeShortVerb{\|} +% +% \newcommand{\TUB}{{\sl TUGboat\/}} +% +% \GetFileInfo{theorem.dtx} +% \title{An Extension of the +% \LaTeX{} theorem environment\thanks{This file +% has version number \fileversion, last +% revised \filedate.}} +% \author{Frank Mittelbach} +% +% \MaintainedByLaTeXTeam{tools} +% \maketitle +% +% \begin{abstract} +% The macros described in this paper yield an extension of the +% \LaTeX{} theorem mechanism. It is designed is to satisfy the +% different requirements of various journals. Thus, the +% layout of the ``theorems'' can be manipulated by determining a +% ``style''. This article describes not only the use, but +% also the definition, of the necessary macros. +% \end{abstract} +% +% \section*{Preface to version 2.2} +% +% For \LaTeXe{} this package did not need any fundamental changes. I +% only modified the messages generated so that theorem layout styles +% will show up with the |\listfiles| command and cleaned the section +% on the New Font Selection Scheme since this is now included in +% \LaTeX. +% +% \section*{Preface to version 2.1} +% +% This version is identical to 2.0g described in \TUB\ 10\#3 except +% for some internal defaults which are now set depending on the used +% font selection scheme. +% +% This was done to avoid unpleasant surprises if the new font selection +% scheme is in force. For further details see +% section~\ref{sec:newfonts} and \cite{bk:GMS94}. +% +% \section{Introduction} +% +% For our purposes here, ``theorems'' are labelled enunciations, +% often set off from the main text by extra space and a font change. +% Theorems, corollaries, conjectures, definitions, and remarks +% are all instances of ``theorems''. The ``header'' of these structures +% is composed of a label (such as \textsc{Theorem} or \textsc{Remark}) +% and a number which serializes an item in the sequence of items +% with the same label. +% +% Shortly after the introduction of \LaTeX{} at the Fachbereich +% Mathematik in Mainz, the desire to manipulate the layout of +% ``theorems'' arose. In Mainz, the following two conventions came +% into general use: +% \begin{enumerate} +% \item The number of the theorem is shown in the margin. +% \item There is a line break at +% the end of the theorem header. +% \end{enumerate} +% +% Additionally, some journals require different formats which depend on +% the ``sort of theorem'': e.g.\ often remarks and definitions are set +% in |\upshape|, while |\itshape| is employed for main theorems. +% +% Confronted with these requirements, a theorem environment was +% developed in Mainz which allows separate determination of the +% layout of the ``theorems sets'', comparable to |\pagestyle|. +% +% +% \section{The user interface} +% \subsection{Defining new theorem sets} +% +% \DescribeMacro\newtheorem +% As in the original \LaTeX{} version, the command |\newtheorem| +% defines a new ``theorem set'' or ``theorem-like structure''. +% Two required arguments name the new environment and give the text +% to be typeset with each instance of the new ``set'', while +% an optional argument determines how +% the ``set'' is enumerated: +% \begin{description} +% \item[\ttfamily \bslash newtheorem\{foo\}\{bar\}] +% The theorem set {\envfont foo} (whose name is \texttt{bar}) +% uses its own counter. +% \item[\ttfamily \bslash newtheorem\{foo2\}{[foo]}\{bar2\}] +% The theorem set {\envfont foo2} (printed name \texttt{bar2}) +% uses the same counter as the theorem set \texttt{foo}. +% \item[\ttfamily \bslash newtheorem\{foo3\}\{bar3\}{[section]}] +% The theorem set {\envfont foo3} (printed name \texttt{bar3}) is +% enumerated within the counter \texttt{section}, i.e.\ with every +% new |\section| the enumeration begins again with 1, and +% the enumeration is composed from the section-number and the +% theorem counter itself. +% \end{description} +% +% \DescribeMacro\theoremstyle +% Additionally, the command |\theoremstyle| can define the layout +% of various, or all, theorem sets. It should be noted that any +% theorem set defined by |\newtheorem| is typeset in the +% |\theoremstyle| that is current at the time of the definition. +% Thus, the following +% \begin{verbatim} +% \theoremstyle{break} \newtheorem{Cor}{Corollary} +% \theoremstyle{plain} \newtheorem{Exa}{Example}[section] +%\end{verbatim} ^^A No blank at line start +% leads to the result that the set {\envfont Cor} is formatted in the +% style \texttt{break}, while the set {\envfont Exa} and all the +% following ones are formatted in the style \texttt{plain}, unless +% another |\theoremstyle| follows. Since the definitions installed by +% |\newtheorem| are global, one also can limit |\theoremstyle| locally +% by grouping braces. +% +% \DescribeMacro\theorembodyfont +% The choice of the font for the theorem body is completely +% independent of the chosen |\theoremstyle|; this has proven to +% be very advantageous. For example, +% \begin{verbatim} +% {\theorembodyfont{\upshape} \newtheorem{Rem}{Remark}} +%\end{verbatim} +% defines a theorem set {\envfont Rem}, which will be set in +% |\upshape| in the current layout (which in our example is +% \texttt{plain}). As with |\theoremstyle|, the |\theorembodyfont| +% chosen is that current at the time of |\newtheorem|. If +% |\theorembodyfont| is not specified or one defines +% |\theorembodyfont{}|, then the font used will be that defined by the +% |\theoremstyle|. +% +% \DescribeMacro\theoremheaderfont It is also possible to customize +% the font used for the theorem headers. This is, however, a global +% declaration, and therefore there should be at most one +% |\theoremheaderfont| declaration in the preamble.\footnote{If it is +% actually necessary to have different header fonts, one has to define +% new theorem styles (substituting the desired font) or specify the +% information directly in the \texttt{\bslash newtheorem} declaration +% (the unclean variant).} +% +% \DescribeMacro\theorempreskipamount +% \DescribeMacro\theorempostskipamount Two additional parameters +% affect the vertical space around the theorem environments: +% |\theorempreskipamount| and |\theorempostskipamount| define, +% respectively, the spacing before and after such an environment. +% These parameters apply for all theorem sets and can be manipulated +% with the ordinary length macros. They are rubber lengths, +% (`\textsf{skips}'), and therefore can contain \texttt{plus} and +% \texttt{minus} parts. +% +% Since the definition of theorem sets should---most sensibly---be +% placed in the preamble, we only allow installation there. +% It is therefore possible to release the memory used here after +% |\begin{document}|, in order to make room for other +% applications. +% +% +% \subsection{Existing theorem styles} +% +% The following theorem styles exist to date: +% \begin{deflist}{marginbreak} +% \item[plain] +% This theorem style emulates the original \LaTeX{} definition, +% except that additionally the parameters +% |\theorem...skipamount| are used. +% \item[break] +% In this style, the theorem header is followed by a line +% break. +% \item[marginbreak] +% The theorem number is set in the margin, and there is a line +% break as in \texttt{break}. +% \item[changebreak] +% Like \texttt{break}, but with header number and text +% interchanged. +% \item[change] +% Header number and text are interchanged, without a line break. +% \item[margin] +% The number is set in the left margin, without a line break. +% \end{deflist} +% All styles (except \texttt{plain}) select |\slshape| as the default +% |\theorembodyfont|. +% +% +% \subsection{Examples} +% +% Given the above theorem sets {\envfont Cor}, {\envfont Exa} +% and {\envfont Rem}, +% suppose that the preamble also contains the declarations: +% \begin{verbatim} +% \theoremstyle{marginbreak} \newtheorem{Lem}[Cor]{Lemma} +% \theoremstyle{change} +% \theorembodyfont{\itshape} \newtheorem{Def}[Cor]{Definition} +% +% \theoremheaderfont{\scshape} +%\end{verbatim} +% Then the following are some typical examples of the typeset output +% resulting from their use. +% +% \begin{Cor} +% This is a sentence typeset in the theorem environment {\envfont +% Cor}. +% \end{Cor} +% +% \begin{Exa} +% This is a sentence typeset in the theorem environment {\envfont +% Exa}. +% \end{Exa} +% +% \begin{Rem} +% This is a sentence typeset in the theorem environment {\envfont +% Rem}. +% \end{Rem} +% +% \begin{Lem}[Ben User] +% This is a sentence typeset in the theorem environment {\envfont +% Lem}. +% \end{Lem} +% +% \begin{Def}[Very impressive Definition] +% This is a sentence typeset in the theorem environment {\envfont +% Def}. +% \end{Def} +% +% The last two examples show the effect of the optional argument to +% a theorem environment (it is the text typeset in parentheses). +% +% +% \section{Special Considerations} +% \label{sec:newfonts} +% +% Theoremheader and body are implemented as a unit. This means that +% the |\theoremheaderfont| will inherit characteristics of the +% |\theorembodyfont| in \LaTeXe. Thus, if for example +% |\theorembodyfont| is |\itshape| and |\theoremheaderfont| +% is |\bfseries| the font selected for the header will have the +% characteristics `bold extended italic'. If this is not desired one +% should set the |\theoremheaderfont| to something like +% \begin{verbatim} +% \theoremheaderfont{\normalfont\bfseries} +%\end{verbatim} +% i.e.\ supplying all necessary font information explicitly. +% +% +% +% \section{Acknowledgements} +% +% The publication of this set of macros was only possible with the +% help of Christina Busse (translating the manuscript into English), +% Joachim Pense (playing the r\^ole of typist), Chris Rowley +% (looking everything over) and many others providing useful +% suggestions. +% +% \StopEventually{% +% \begin{thebibliography}{9} +% \bibitem{bk:GMS94} \textsc{M.~Goossens}, \textsc{F.~Mittelbach} +% and \textsc{A.~Samarin}. +% \newblock The \LaTeX{} Companion. +% \newblock +% Addison-Wesley, Reading, Massachusetts, 1994. +% \bibitem{latex:source} \textsc{Lamport, Leslie.} \newblock +% \texttt{latex.tex}, version 2.09, date +% Feb. 1990. +% \end{thebibliography} +% \PrintIndex +% \PrintChanges} +% +% +% \section{The documentation driver file} +% +% The next bit of code contains the documentation driver file for +% \TeX{}, i.e., the file that will produce the documentation you are +% currently reading. It will be extracted from this file by the +% \texttt{docstrip} program. Since it is the first code in the file +% one can alternatively process this file directly with \LaTeXe{} to +% obtain the documentation. +% +% \begin{macrocode} +%<*driver> +\documentclass{ltxdoc} + +\usepackage{theorem} + +%<+driver>% The next few lines define theorem sets which are used +%<+driver>% in the example section of the documentation. + +\theoremstyle{break} \newtheorem{Cor}{Corollary} +\theoremstyle{plain} \newtheorem{Exa}{Example}[section] +{\theorembodyfont{\upshape}\newtheorem{Rem}{Remark}} +\theoremstyle{marginbreak} \newtheorem{Lem}[Cor]{Lemma} +\theoremstyle{change} +\theorembodyfont{\itshape} \newtheorem{Def}[Cor]{Definition} + +\theoremheaderfont{\scshape} + +\RecordChanges + +\begin{document} + \DocInput{theorem.dtx} +\end{document} +%</driver> +% \end{macrocode} +% +% \section{Definition of the Macros} +% +% If the file has been loaded before, we abort immediately. If not the +% package announces itself (this is actually done at the very top if +% the file---the way it is done isn't good style so don't copy it). +% \changes{v2.0e}{89/07/19}{Spaces removed from `typeout'.} +% \changes{v2.2b}{95/11/19}{Announce moved to top of file} +% \begin{macrocode} +%<*package> +%\@ifundefined{theorem@style}{}{\endinput} +%\def\FMithmInfo{1995/11/19 v2.2b Theorem extension package (FMi)} +%\ProvidesPackage{theorem}[\FMithmInfo] +% \end{macrocode} +% +% +% \subsection{Definition of theorem styles and fonts} +% +% All the definitions in this file are done globally to allow +% inputting this file inside a group. +% +% \begin{macro}{\theoremstyle} +% Before a theorem style can be installed, the chosen style must be +% known. For that reason, we must test to see that +% |\th@|\meta{style} is known or, more precisely, that it is +% different from |\relax|. If the style is not known then +% |\th@plain| is used. +% \begin{macrocode} +\gdef\theoremstyle#1{% + \@ifundefined{th@#1}{\@warning + {Unknown theoremstyle `#1'. Using `plain'}% + \theorem@style{plain}}% +% \end{macrocode} +% We save the theorem style to be used in the token register +% |\theorem@style|. +% \begin{macrocode} + {\theorem@style{#1}}% +% \end{macrocode} +% Now we ``evaluate'' the theorem style: this means, we call the +% macro |\th@|\meta{style} which will activate the relevant +% definitions which are contained in a separate file. This is done +% in a group to suppress changes to the current font. This could +% otherwise pose problems together with the new font selection +% scheme\footnote{When I printed the original article using the new +% font selection scheme I ended with a document with slanted +% typefaces (text headings and all) simply because one of the +% theorem styles used \texttt{\bslash sl} at toplevel.} if the +% |\th@|\meta{style} is evaluated a second time. +% \changes{v2.1a}{90/02/15}{Group added around `th@..} +% \changes{v2.1a}{90/02/15}{Reseting of `..@begintheorem removed.} +% \begin{macrocode} + \begingroup + \csname th@\the\theorem@style \endcsname + \endgroup} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\@begintheorem} +% \changes{v2.1a}{90/02/15}{Relaxed at toplevel.} +% \begin{macro}{\@opargbegintheorem} +% \changes{v2.1a}{90/02/15}{Relaxed at toplevel.} +% We reset |\@begintheorem| and |\@opargbegintheorem| to +% |\relax| since these commands are no longer necessary at +% toplevel. This will save a few tokens. +% \begin{macrocode} +\global\let\@begintheorem\relax +\global\let\@opargbegintheorem\relax +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\theorem@style} +% Obviously the \textsf{token} register used above has to be +% allocated. To assure the utmost compatibility with the +% original \LaTeX{} definition, we set the default theorem style to +% \texttt{plain}, which implements the usual \LaTeX{} convention. +% \changes{v2.0f}{89/07/20}{Unnecessary `global' removed.} +% \begin{macrocode} +\newtoks\theorem@style +\global\theorem@style{plain} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\theorembodyfont} +% \begin{macro}{\theorem@bodyfont} +% If the |\theorembodyfont| is set by the user then it should not +% interact with the default font set in the theorem style. When the +% new font selection is in force this may happen if, for example, +% the default is |\itshape| and the new |\theorembodyfont| is +% |\sffamily|. So we add a |\reset@font| command in front of the +% user definition. +% \changes{v2.0f}{89/07/20}{Unnecessary `global' removed.} +% \changes{v2.0g}{89/09/19}{`theoremfont to `theorembodyfont.} +% \changes{v2.1c}{92/06/22}{`reset@font added and logic changed.} +% \changes{v2.1d}{92/10/28}{Reset to empty if arg is empty} +% \begin{macrocode} +\gdef\theorembodyfont#1{% +% \end{macrocode} +% We check if the argument supplied is empty and if so put nothing +% into the |\theorem@bodyfont| token register to allow for +% |\theorembodyfont{}| as a mean of using the default of the +% current |\theoremstyle|. +% \begin{macrocode} + \def\@tempa{#1}% + \ifx\@tempa\@empty + \theorem@bodyfont{}% + \else + \theorem@bodyfont{\reset@font#1}% + \fi + } +\newtoks\theorem@bodyfont +\global\theorem@bodyfont{} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% +% \begin{macro}{\theoremheaderfont} +% \changes{v2.0g}{89/09/19}{Macro added.} +% The font for the theorem headers is handled differently because +% this definition applies to all theorem styles. +% \begin{macrocode} +\gdef\theoremheaderfont#1{\gdef\theorem@headerfont{#1}% +% \end{macrocode} +% After using the macro once it is redefined to produce an error +% message. +% \begin{macrocode} + \gdef\theoremheaderfont##1{% + \typeout{\string\theoremheaderfont\space should be used + only once.}}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\theorem@headerfont} +% \changes{v2.0g}{89/09/19}{Macro added.} +% To set the |\theorem@headerfont| default we first test if +% the new fontselection scheme is in force. +% \changes{v2.1a}{90/02/15}{Support for new font selection.} +% \begin{macrocode} +\ifx\upshape\undefined +% \end{macrocode} +% If not we define it to expand into |\bfseries|. We don't use +% |\let| just in case a following style option redefines this +% macro. +% \begin{macrocode} +\gdef\theorem@headerfont{\bfseries} +% \end{macrocode} +% Otherwise we reset the current shape before calling |\bfseries|. +% \begin{macrocode} +\else \gdef\theorem@headerfont{\normalfont\bfseries}\fi +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\th@plain} +% \begin{macro}{\th@break} +% \begin{macro}{\th@marginbreak} +% \begin{macro}{\th@changebreak} +% \begin{macro}{\th@change} +% \begin{macro}{\th@margin} +% The different styles are defined in macros such as +% |\th@plain|. Since memory space is precious in +% ``non-Big-versions'', we have to avoid offering too many unused +% definitions. Therefore we define these styles in separate files +% that can be loaded on demand. Thus the commands themselves only +% load these files. We use |\@input@| a \LaTeXe{} internal command +% that ensures that the file will be listed with |\listfiles| +% \changes{v2.2a}{94/02/02}{Use `@input@ to load theorem layout files} +% \begin{macrocode} +\gdef\th@plain{\@input@{thp.sty}} +\gdef\th@break{\@input@{thb.sty}} +\gdef\th@marginbreak{\@input@{thmb.sty}} +\gdef\th@changebreak{\@input@{thcb.sty}} +\gdef\th@change{\@input@{thc.sty}} +\gdef\th@margin{\@input@{thm.sty}} +% \end{macrocode} +% This list will be expanded when new styles become +% available. For testing, just append new theorem substyles +% as document options. +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% +% +% +% \subsection{Definition of a new theorem set} +% +% As already pointed out, a new theorem environment can be defined in +% three different ways: +% \begin{verbatim} +% \newtheorem{Lem}{Lemma} +% \newtheorem{Lem}{Lemma}[section] +% \newtheorem{Lem}[Theorem]{Lemma} +%\end{verbatim} +% The function of the macro |\newtheorem| is to recognize these cases +% and then to branch into one of the three macros |\@ynthm|, |\@xnthm| +% or |\@othm|. This mechanism is adopted unchanged from +% \cite{latex:source}; the essential point here is that, for example, +% in the second case, the arguments \texttt{Lem}, \texttt{Lemma} and +% \texttt{section} are passed over to the macro |\@xnthm|. +% +% We inspect this case first because the others present fewer problems, +% and thus are easily derived from this one. +% +% \begin{macro}{\@xnthm} +% For our example arguments, the macro |\@xnthm| must fulfill +% the following: +% \begin{itemize} +% \item +% Define a new \LaTeX-counter `Lem' +% \item +% reset this counter within a |\section| +% \item +% define the macro |\theLem| +% \item +% define the environment macros |\Lem| and +% |\endLem| using the current +% |\theoremstyle| and |\theorem@bodyfont|. +% \end{itemize} +% Obviously, all this should happen only if the first argument +% of |\@xnthm| (i.e.\ \texttt{Lem} in our example) is chosen so +% as not to conflict with any previously defined commands or +% environments. This test is performed by the \LaTeX{} macro +% |\@ifdefinable|. +% \begin{macrocode} +\gdef\@xnthm#1#2[#3]{\expandafter\@ifdefinable\csname #1\endcsname +% \end{macrocode} +% Therefore, the first argument of |\@ifdefinable| is the +% expansion (in the example, |\Lem|) of +% |\csname||#1\endcsname|. The second argument is +% executed only if the test has been completed successfully. +% \begin{macrocode} + {% +% \end{macrocode} +% Now we define the new counter. The names of the \LaTeX{} +% macros employed should speak for themselves: +% \changes{v2.2b}{1995/10/07}{Use \cs{@newctr}} +% \changes{v2.2c}{1995/11/23}{Use \cs{@newctr} properly.} +% \begin{macrocode} + \@definecounter{#1}\@newctr{#1}[#3]% +% \end{macrocode} +% Using |\@newctr| will give a proper error message if the counter +% in |#3| is not defined. +% In defining `|\theLem|' we must generate the desired macro +% name by use of |\expandafter| and |\csname|. +% \begin{macrocode} + \expandafter\xdef\csname the#1\endcsname +% \end{macrocode} +% An |\xdef| is used in order to make the definition global, +% and to ensure that it contains the replacement texts of +% |\@thmcountersep| and |\@thmcounter|.\footnote{These +% two macros can be defined by the document style. Their default +% values produce a `\texttt{.}' as separation and an arabic +% representation of the number.} However, not everything should be +% expanded. For example, it saves space to use |\thesection| +% instead of its---at times---lengthy expansion. +% \begin{macrocode} + {\expandafter \noexpand \csname the#3\endcsname + \@thmcountersep \@thmcounter{#1}}% +% \end{macrocode} +% Thus with the defaults of \LaTeX{}, |\theLem| would be +% replaced by the command sequence |\thesection.\arabic{Lem}|. +% +% We will now look at the definition of the macro which is executed +% at the beginning of the actual environment (in our example this +% macro is |\Lem|). It should be noted that we use an +% ``|\expandafter| trick'' to expand only certain parts of the +% replacement text at the time of the definition. +% \begin{macrocode} + \def\@tempa{\global\@namedef{#1}}% + \expandafter \@tempa \expandafter{% +% \end{macrocode} +% First, the macro that contains the current definitions of +% |\@begintheorem| and |\@opargtheorem| should be called +% up. The name of this macro---as is already known---has the form +% |\th@|\meta{theorem\ style}; therefore, it must be called by +% \begin{macrocode} + \csname th@\the \theorem@style +% \end{macrocode} +% In addition the default theorem font should be changeable, i.e.\ +% we have to insert the contents of |\theorem@bodyfont|. For +% that reason, we expand even further, beyond |\endcsname|, +% and thus insert the contents of the \textsf{token} register +% |\theorem@bodyfont| in the replacement text. +% \begin{macrocode} + \expandafter \endcsname \the \theorem@bodyfont +% \end{macrocode} +% Now it is time to call the macro |\@thm| which takes over +% the further processing. It has two arguments: the current +% counter name (in our example, \texttt{Lem}), and the text of the +% label (in our example, \texttt{Lemma}). +% \begin{macrocode} + \@thm{#1}{#2}}% +% \end{macrocode} +% With this, the `sub-definition' is complete. The macro +% |\@endtheorem| ends a theorem environment and is, so far, nothing +% but an |\endtrivlist|. (Hence it is defined globally, and not +% within the theorem styles.\footnote{This has to be changed as +% soon as theorem styles that change \texttt{\bslash @endtheorem} +% exist. In such a case, all existing styles must be changed as +% well since they will have to reset the macro.}) Therefore, we can +% set it equivalent to the macro that ends the theorem set (in our +% example, |\endLem|). However, if some day theorem styles exist +% that do change |\@endtheorem|, we would have to use the +% commented-out line instead. +% \begin{macrocode} + \global \expandafter \let \csname end#1\endcsname \@endtheorem +% \global\@namedef{end#1}{\@endtheorem}% +% \end{macrocode} +% With these commands all the required definitions are employed, +% unless the test |\@ifdefinable| has failed. Therefore, we +% end the second argument of this macro and with it the definition +% of |\@xnthm|. +% \begin{macrocode} + }} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@ynthm} +% The definition of |\@ynthm| is completely analogous. In +% this case the new counter that is defined is not reset within +% another counter; thus the definition of |\the...| +% is simplified: +% \begin{macrocode} +\gdef\@ynthm#1#2{\expandafter\@ifdefinable\csname #1\endcsname + {\@definecounter{#1}% + \expandafter\xdef\csname the#1\endcsname{\@thmcounter{#1}}% +% \end{macrocode} +% The rest of the definition corresponds literally to that of +% |\@xnthm|: +% \begin{macrocode} + \def\@tempa{\global\@namedef{#1}}\expandafter \@tempa + \expandafter{\csname th@\the \theorem@style \expandafter + \endcsname \the\theorem@bodyfont \@thm{#1}{#2}}% + \global \expandafter \let \csname end#1\endcsname \@endtheorem}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@othm} +% The definition of |\@othm| does not contain anything new. +% \begin{macrocode} +\gdef\@othm#1[#2]#3{% +% \end{macrocode} +% \changes{v2.2b}{95/10/07}{Build in check for counter defined} +% We do not define a new counter but instead use one that has +% already been defined. Thus the only definition we need is that +% of this pseudo-counter (i.e.\ |\the|\meta{env.\ name}). +% First we check if |#2| corresponds to a known counter name. +% \begin{macrocode} + \expandafter\ifx\csname c@#2\endcsname\relax + \@nocounterr{#2}% + \else + \expandafter\@ifdefinable\csname #1\endcsname + {\expandafter \xdef \csname the#1\endcsname + {\expandafter \noexpand \csname the#2\endcsname}% +% \end{macrocode} +% All other parts of the definition can be adopted from +% |\@xnthm|. We have to remember, though, that in this case +% the name of the current counter and the theorem label have moved +% to the second and third arguments. +% \begin{macrocode} + \def\@tempa{\global\@namedef{#1}}\expandafter \@tempa + \expandafter{\csname th@\the \theorem@style \expandafter + \endcsname \the\theorem@bodyfont \@thm{#2}{#3}}% + \global \expandafter \let \csname end#1\endcsname \@endtheorem}% + \fi} +% \end{macrocode} +% \end{macro} +% +% \subsection{Macros that are employed in a {\envfont theorem} +% environment} +% +% \begin{macro}{\@thm} +% The macro |\@thm| has to increase the current counter. Then, +% depending on whether the environment has (or does not have) an +% optional argument, it has to branch into either |\@begintheorem| +% or |\@opargtheorem|. +% \begin{macrocode} +\gdef\@thm#1#2{\refstepcounter{#1}% +% \end{macrocode} +% Now we start a {\envfont trivlist} environment, and give +% |\@topsep| and |\@topsepadd| the values of the \textsf{skip} +% registers |\theorempreskipamount| and |\theorempostskipamount|. +% The value in |\@topsep| is the vertical space that is inserted by +% the first (and only) |\item| in our |\trivlist| whilst +% |\@topsepadd| is inserted by |\@endparenv| at the end of that +% {\envfont trivlist} environment. By using these registers, we +% obtain the desired space around a {\envfont theorem} environment. +% \begin{macrocode} + \trivlist + \@topsep \theorempreskipamount % used by first \item + \@topsepadd \theorempostskipamount % used by \@endparenv +% \end{macrocode} +% Now we have to test whether an optional argument has been given. +% \changes{v2.0d}{89/07/18}{Forgotten percent added.} +% \begin{macrocode} + \@ifnextchar [% +% \end{macrocode} +% If there is an optional argument, we will call |\@ythm|, and +% move the arguments read back into the input stream. +% \begin{macrocode} + {\@ythm{#1}{#2}}% +% \end{macrocode} +% If not, we call |\@begintheorem|. Its first argument is the +% name of the theorem set (hence the second argument of +% |\@thm|). Its second argument is the macro that produces the +% current number. +% \begin{macrocode} + {\@begintheorem{#2}{\csname the#1\endcsname}\ignorespaces}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@xthm} +% \begin{macro}{\@ythm} +% Both these macros were originally called by |\@thm|. We do +% not need |\@xthm| anymore, hence we reset it to +% |\relax|. The definition of |\@ythm| has not changed at +% all from its definition in \LaTeX. In order to make the macros +% easier to understand, we will +% nevertheless present it (commented out). +% \begin{macrocode} +\global\let\@xthm\relax +% \def\@ythm#1#2[#3]{\@opargbegintheorem{#2}{\csname +% the#1\endcsname}{#3}\ignorespaces} +%</package> +% \end{macrocode} +% The primitive |\ignorespaces| in |\@ythm| and +% |\@thm| is needed to remove the spaces between the +% |\begin{...}| and the actual text. +% \end{macro} +% \end{macro} +% +% +% \subsection{Definition of the theorem substyles} +% +% As already pointed out, the theorem substyles, defined below, are +% only loaded when necessary. Note that all these substyles, except +% \texttt{plain}, have |\slshape| as the default body font. +% +% \subsubsection{The \texttt{plain} style} +% +% \label{dok:th@plain} As the following macros use |@|, we have +% to locally set the |\catcode| of this symbol to ``letter''. +% This happens within a group, so that we do not have to worry about +% which |\catcode| that symbol had before. +% \begin{macrocode} +%<*thp> +\begingroup \makeatletter +% \end{macrocode} +% Since we are now within a group, we must make all definitions +% globally. First we make sure that \texttt{theorem.sty} is loaded. +% This will allow us to use this file as a document style option +% without having to call \texttt{theorem} itself as an option. At the +% same time, we assure that at least version 2 is loaded, since +% |\theorem@style| was not defined in earlier versions. +% \begin{macrocode} +\@ifundefined{theorem@style}{\input{theorem.sty}}{} +\ProvidesFile{thp.sty} + [\FMithmInfo] +% \end{macrocode} +% +% +% \begin{macro}{\th@plain} +% \begin{macro}{\@begintheorem} +% \begin{macro}{\@opargbegintheorem} +% |\theoremstyle{plain}| corresponds to the original +% definition, except that the distances to the surrounding text are +% determined by the parameters |\theorempreskipamount| and +% |\theorempostskipamount|. +% First we set the default body font. +% \begin{macrocode} +\gdef\th@plain{\normalfont\itshape +% \end{macrocode} +% Then we define |\@begintheorem| and +% |\@opargbegintheorem|. These two macros define how the +% header of a theorem is typeset. |\@opargbegintheorem| will +% be called if a \textsf{theorem} environment with an optional +% argument is encountered; otherwise, the header is constructed by +% calling |\@begintheorem|. If one of these macros is +% executed, we are within a \textsf{trivlist} environment started by +% |\@thm|. So the theorem header is produced with an +% |\item| command. +% +% Instead of specifying the header font directly, all standard +% theorem styles use the |\theorem@headerfont| macro to allow +% customization. The extra space (|\labelsep|) is necessary +% because of problems in the \textsf{trivlist} environment. +% \begin{macrocode} + \def\@begintheorem##1##2{% + \item[\hskip\labelsep \theorem@headerfont ##1\ ##2]}% +% \end{macrocode} +% The definition of |\@opargbegintheorem| is completely +% analogous. The only difference is the fact that there exists a +% third argument (which is the optional parameter of the +% environment and contains additional information about the +% theorem). Customarily we enclose it in parentheses. +% \begin{macrocode} +\def\@opargbegintheorem##1##2##3{% + \item[\hskip\labelsep \theorem@headerfont ##1\ ##2\ (##3)]}} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \noindent +% We conclude with an |\endgroup| to restore the +% |\catcode| of |@|. +% \begin{macrocode} +\endgroup +%</thp> +% \end{macrocode} +% +% +% \subsubsection{The \texttt{break} style} +% +% This style option is stored in the file |thb.sty|. +% For the next two lines see the documentation for |\th@plain| on +% page~\pageref{dok:th@plain}. +% \begin{macrocode} +%<*thb> +\begingroup \makeatletter +\@ifundefined{theorem@style}{\input{theorem.sty}}{} +\ProvidesFile{thb.sty} + [\FMithmInfo] +% \end{macrocode} +% +% \begin{macro}{\th@break} +% |\theoremstyle{break}| produces a line break after the name +% of the theorem. The font is |\slshape|. Hence, we define +% |\th@break| as follows: +% \begin{macrocode} +\gdef\th@break{\normalfont\slshape + \def\@begintheorem##1##2{\item[% +% \end{macrocode} +% We run into the following problem: it is not possible to create +% the header with |\item[|\meta{title}|]| and then start +% a new line by, for example, |\mbox{}\\|. Such a definition +% will fail whenever a list environment follows immediately. With +% the above construction, the |\mbox{}| causes the switch +% |@inlabel| (cf.\ definition of |\list| and +% |\trivlist| in \cite{latex:source}) to be set to \texttt{false} +% and so the following list will insert additional vertical +% space (|\topskip|). This is quite annoying. Therefore, we +% create the line break within the |\item|. In order to ensure +% that the text will begin at the proper position in the following +% line, we simply pretend that the label does not take any +% room.\footnote{This will lead to problems whenever very high +% symbols occurring in the line tower into the +% heading. So, something else has to be done here sometime.} +% \begin{macrocode} + \rlap{\vbox{\hbox{\hskip \labelsep\theorem@headerfont ##1\ ##2}% + \hbox{\strut}}}]}% +% \end{macrocode} +% Again, the definition of |\@opargbegintheorem| is +% completely analogous. +% \begin{macrocode} +\def\@opargbegintheorem##1##2##3{% + \item[\rlap{\vbox{\hbox{\hskip \labelsep \theorem@headerfont + ##1\ ##2\ (##3)}% + \hbox{\strut}}}]}} +\endgroup +%</thb> +% \end{macrocode} +% \end{macro} +% +% +% \subsubsection{The \texttt{changebreak} style} +% +% \begin{macrocode} +% This style option is stored in the file |thcb.sty|. +% \begin{macrocode} +%<*thcb> +\begingroup \makeatletter +\@ifundefined{theorem@style}{\input{theorem.sty}}{} +\ProvidesFile{thcb.sty} + [\FMithmInfo] +% \end{macrocode} +% +% \begin{macro}{\th@changebreak} +% The \texttt{change-break} theorem style is like \texttt{break} +% but with interchange of theorem name and theorem number. Thus we +% define |\th@changebreak| as follows: +% \begin{macrocode} +\gdef\th@changebreak{\normalfont\slshape + \def\@begintheorem##1##2{\item + [\rlap{\vbox{\hbox{\hskip\labelsep \theorem@headerfont ##2\ ##1}% + \hbox{\strut}}}]}% +\def\@opargbegintheorem##1##2##3{% + \item[\rlap{\vbox{\hbox{\hskip\labelsep \theorem@headerfont + ##2\ ##1\ (##3)}% + \hbox{\strut}}}]}} +\endgroup +%</thcb> +% \end{macrocode} +% \end{macro} +% +% +% \subsubsection{The \texttt{change} style} +% +% This style option is stored in the file |thc.sty|. +% \begin{macrocode} +%<*thc> +\begingroup \makeatletter +\@ifundefined{theorem@style}{\input{theorem.sty}}{} +\ProvidesFile{thc.sty} + [\FMithmInfo] +% \end{macrocode} +% +% \begin{macro}{\th@change} +% The \texttt{change} theorem style corresponds to the +% \texttt{change break} style without a linebreak after the header. +% To say it in another way, it's the same as the \texttt{plain} +% style but with number and name interchanged and |\slshape| as the +% default font. +% \begin{macrocode} +\gdef\th@change{\normalfont\slshape + \def\@begintheorem##1##2{\item + [\hskip\labelsep \theorem@headerfont ##2\ ##1]}% +\def\@opargbegintheorem##1##2##3{% + \item[\hskip\labelsep \theorem@headerfont ##2\ ##1\ (##3)]}} +\endgroup +%</thc> +% \end{macrocode} +% \end{macro} +% +% +% \subsubsection{The \texttt{marginbreak} style} +% +% This style option is the one used most often at Mainz. It is saved +% in the file |thmb.sty|. +% \begin{macrocode} +%<*thmb> +\begingroup \makeatletter +\@ifundefined{theorem@style}{\input{theorem.sty}}{} +\ProvidesFile{thmb.sty} + [\FMithmInfo] +% \end{macrocode} +% +% \begin{macro}{\th@marginbreak} +% The \texttt{margin break} style is nearly the same as the +% \texttt{change break} style. The only difference is the placement +% of the theorem number. We use |\llap| to place it in the left +% margin. +% +% In this style |\labelsep| denotes the separation between the +% number and the text. +% \begin{macrocode} +\gdef\th@marginbreak{\normalfont\slshape + \def\@begintheorem##1##2{\item + [\rlap{\vbox{\theorem@headerfont + \hbox{\llap{##2}\hskip\labelsep ##1}% + \hbox{\strut}}}]}% +\def\@opargbegintheorem##1##2##3{% + \item[\rlap{\vbox{\theorem@headerfont + \hbox{\llap{##2}\hskip\labelsep ##1\ (##3)}% + \hbox{\strut}}}]}} +\endgroup +%</thmb> +% \end{macrocode} +% \changes{v2.1c}{90/02/17}{`endgroup outside macrocode env.} +% \end{macro} +% +% +% +% \subsubsection{The \texttt{margin} style} +% +% This style option is stored in the file |thm.sty|. +% \begin{macrocode} +%<*thm> +\begingroup \makeatletter +\@ifundefined{theorem@style}{\input{theorem.sty}}{} +\ProvidesFile{thm.sty} + [\FMithmInfo] +% \end{macrocode} +% +% \begin{macro}{\th@margin} +% Again this is only a variant of the theorem styles described +% above without any new ideas. +% \begin{macrocode} +\gdef\th@margin{\normalfont\slshape + \def\@begintheorem##1##2{\item + [\theorem@headerfont \llap{##2}\hskip\labelsep ##1]}% +\def\@opargbegintheorem##1##2##3{% + \item[\theorem@headerfont \llap{##2}\hskip\labelsep ##1\ (##3)]}} +\endgroup +%</thm> +% \end{macrocode} +% \end{macro} +% +% +% +% +% \subsection{Final Definitions} +% +% \begin{macro}{\theorempreskipamount} +% \begin{macro}{\theorempostskipamount} +% The \textsf{skip} parameters that regulate the vertical empty space +% before and after the {\envfont theorem} environment have +% to be allocated as well. +% \changes{v2.0f}{89/07/20}{Unnecessary `global' removed.} +% \begin{macrocode} +%<*package> +\newskip\theorempreskipamount +\newskip\theorempostskipamount +% \end{macrocode} +% Since we have used the same values for all theorem sets, we now can +% assign them. +% \begin{macrocode} +\global\setlength\theorempreskipamount{12pt plus 5pt minus 3pt} +\global\setlength\theorempostskipamount{8pt plus 3pt minus 1.5pt} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% +% \begin{macro}{\@endtheorem} +% The same holds for the macro |\@endtheorem|, which ends a +% {\envfont theorem} environment. Since it is the same for all +% theorem sets, it is removed from the macros |\th@|\meta{style}. +% It simply ends the {\envfont trivlist} environment, which was +% begun in |\@thm|. +% \begin{macrocode} +\global\let\@endtheorem=\endtrivlist +% \end{macrocode} +% \end{macro} +% +% +% +% \begin{macro}{\@preamblecmds} +% All macros defined above are to be used only in the preamble. +% Therefore, we insert them in |\@preamblecmds| which will disable +% them at begin document. This is done by the internal \LaTeXe{} +% command |\@onlypreamble|. +% \changes{v2.0g}{89/09/19}{`theoremheaderfont and `theorembodyfont +% added.} +% \changes{v2.2a}{94/02/03}{Use \LaTeXe{} interface} +% \begin{macrocode} +\@onlypreamble\@xnthm +\@onlypreamble\@ynthm +\@onlypreamble\@othm +\@onlypreamble\newtheorem +\@onlypreamble\theoremstyle +\@onlypreamble\theorembodyfont +\@onlypreamble\theoremheaderfont +% \end{macrocode} +% \end{macro} +% +% Finally we declare the \texttt{plain} theorem style to be the default. +% \changes{v2.1b}{90/06/04}{Fixed missing `item by declaring default +% style.} +% \begin{macrocode} +\theoremstyle{plain} +%</package> +% \end{macrocode} +% +% \Finale + +\endinput diff --git a/macros/latex-dev/required/tools/theorem.pdf b/macros/latex-dev/required/tools/theorem.pdf Binary files differnew file mode 100644 index 0000000000..0d14dda327 --- /dev/null +++ b/macros/latex-dev/required/tools/theorem.pdf diff --git a/macros/latex-dev/required/tools/tools-overview.pdf b/macros/latex-dev/required/tools/tools-overview.pdf Binary files differnew file mode 100644 index 0000000000..9e651744df --- /dev/null +++ b/macros/latex-dev/required/tools/tools-overview.pdf diff --git a/macros/latex-dev/required/tools/tools-overview.tex b/macros/latex-dev/required/tools/tools-overview.tex new file mode 100644 index 0000000000..6a00580302 --- /dev/null +++ b/macros/latex-dev/required/tools/tools-overview.tex @@ -0,0 +1,217 @@ +\NeedsTeXFormat{LaTeX2e} +\ProvidesFile{tools-overview.tex}[2015/03/31 v1.0 Tools overview] + +% Copyright (C) 2006-2019 +% +% The LaTeX3 Project and any individual authors listed elsewhere +% in this file. +% +% Copyright (c) 2006-2014 Heiko Oberdiek +% (c) 2015-2019 The LaTeX3 Project +% +% This file is part of the Standard LaTeX `Tools Bundle'. +% ------------------------------------------------------- +% +% It may be distributed and/or modified under the +% conditions of the LaTeX Project Public License, either version 1.3c +% of this license or (at your option) any later version. +% The latest version of this license is in +% https://www.latex-project.org/lppl.txt +% and version 1.3c or later is part of all distributions of LaTeX +% version 2005/12/01 or later. +% +% The list of all files belonging to the LaTeX `Tools Bundle' is +% given in the file `manifest.txt'. +% +% This file is derived from `tools.tex' and `tools-overview.cls' +% from the `latex-tds' bundle maintained by Heiko Oberdiek. +% +\documentclass[a4paper,12pt]{article} + +% page layout +\usepackage[ + ignoreall, + hmargin=1in, + vmargin={.75in,1in}, +]{geometry} + +\pagestyle{empty} + +\usepackage{calc}[2005/08/06] + +\usepackage{hyperref} +\hypersetup{ + colorlinks, + filecolor=blue, + pdftitle={LaTeX's Tools Bundle}, + pdfsubject={Overview}, + pdfauthor={Heiko Oberdiek}, + pdfcreator={Project `latex-tds'}, +} +\title{Contents of \LaTeX's Tools Bundle} + +\makeatletter + +\let\TO@document\document +\let\TO@enddocument\enddocument + +\def\document{% + \TO@document + \maketitle + \toks@={}% + \setlength{\maxlen}{0pt}% +} +\newlength{\maxlen} +\def\enddocument{% + \begin{list}{}{% + \setlength{\leftmargin}{\maxlen + \labelsep}% + \setlength{\labelwidth}{\maxlen}% + \setlength{\partopsep}{0pt}% + }% + \the\toks@ + \end{list}% + \TO@enddocument +} +\newcommand{\entry}[2]{% + \outline{#1}% + \toks@\expandafter{% + \the\toks@ + \item[% + \href{file:#1.pdf}{\printpackage{#1}}% + \hfill + ]% + #2% + }% + \setlength{\maxlen}{% + \maxof{\maxlen}{\widthof{\printpackage{#1}}}% + }% + \global\maxlen\maxlen +} +\newcommand*{\printpackage}[1]{% + \textbf{\large #1:}% +} +\newcommand*{\outline}[1]{% + \pdfoutline + attr {/C[0 0 1]} + user {% + <<% + /S/GoToR% + /F(#1.pdf)% + /NewWindow true% + /D[0/XYZ null null null]% + >>% + }% + {[#1]}\relax +} +\renewcommand*{\maketitle}{% + \begingroup + \par + \centering + \bfseries + \LARGE + \@title + \par + \endgroup + \vspace{2em}% +} + +\providecommand*{\cs}[1]{% + \texttt{\textbackslash#1}% +} + +\makeatother + +\begin{document} +\entry{afterpage}{% + Place text after the current page. +}% +\entry{array}{% + Extended versions of the environments array, tabular and tabular*. +}% +\entry{bm}{% + Access bold math symbols. +}% +\entry{calc}{% + Infix arithmetic expresions. Contributed to the distribution by + Kresten Krab Thorup and Frank Jensen. +}% +\entry{dcolumn}{% + Alignment on \emph{decimal points} in tabular entries. Requires array. +}% +\entry{delarray}{% + Adds \emph{large delimiters} around arrays. Requires array. +}% +\entry{enumerate}{% + Extended version of the enumerate environment. +}% +\entry{fileerr}{% + Suite of small files which may be used to control \TeX{}'s + missing file error loop. +}% +\entry{fontsmpl}{% + Package and test file for producing \emph{font samples} +}% +\entry{ftnright}{% + Place footnotes in the right hand column in two-column mode. +}% +\entry{hhline}{% + Finer control over horizontal rules in tables. Requires array. +}% +\entry{indentfirst}{% + Indent the first paragraph of sections etc. +}% +\entry{layout}{% + Produces an overview of the layout of the current document. +}% +\entry{longtable}{% + Multipage tables. (Does not require array, but uses the extended + features if both are loaded.) +}% +\entry{multicol}{% + Typeset text in columns, with the length of the final columns + \emph{balanced}. +}% +\entry{rawfonts}{% + Preload fonts under the old internal font names of \LaTeX{}2.09. + Not recomended for new packages, but may help when updating old + files. +}% +\entry{shellesc}{% + Unified interface to ``shell escape'' i.e., access to system commands + based on \texttt{\string\write18} or \texttt{os.execute} depending + on the system in use. +}% +\entry{showkeys}{% + Draft mode showing the \emph{keys} used by \cs{label}, \cs{ref}, \cs{cite} etc. +}% +\entry{somedefs}{% + Selective handling of package options. (Used in rawfonts.sty.) +}% +\entry{tabularx}{% + Defines tabularx environment (similar to tabular*) but modifies + column widths, not inter-column space, to achieve a desired + table width. +}% +\entry{theorem}{% + Flexible definition of \emph{theorem-like} environments. +}% +\entry{trace}{% + The package helps to suppress and to control the amount of tracing + output (\cs{tracingall}) by taming calc and making NFSS less noisy. +}% +\entry{varioref}{% + \emph{Smart} handling of page references. +}% +\entry{verbatim}{% + Flexible version of verbatim environment. +}% +\entry{xr}{% + eXternall References. Extend \cs{ref} to access \cs{label} commands in + other documents. +}% +\entry{xspace}{% + Smart space command that avoids the common mistake of missing + spaces after command names. +}% + +\end{document} diff --git a/macros/latex-dev/required/tools/tools.ins b/macros/latex-dev/required/tools/tools.ins new file mode 100644 index 0000000000..12625e8166 --- /dev/null +++ b/macros/latex-dev/required/tools/tools.ins @@ -0,0 +1,217 @@ +%% +%% This file will generate fast loadable files and documentation +%% driver files from the doc files in this package when run through +%% LaTeX or TeX. +%% +%% Copyright (C) 1993-2019 +%% The LaTeX3 Project and any individual authors listed elsewhere +%% in this file. +%% +%% This file is part of the Standard LaTeX `Tools Bundle'. +%% ------------------------------------------------------- +%% +%% It may be distributed and/or modified under the +%% conditions of the LaTeX Project Public License, either version 1.3c +%% of this license or (at your option) any later version. +%% The latest version of this license is in +%% https://www.latex-project.org/lppl.txt +%% and version 1.3c or later is part of all distributions of LaTeX +%% version 2005/12/01 or later. +%% +%% As this file contains legal notices, it is NOT PERMITTED to modify +%% this file in any way that the legal information placed into +%% generated files is changed (i.e., the files generated when the +%% original file is executed). This restriction does not apply if +%% (parts of) the content is reused in a different WORK producing its +%% own generated files. +%% +%% The list of all files belonging to the `Tools Bundle' is +%% given in the file `manifest.txt'. +%% +%% +%% --------------- start of docstrip commands ------------------ +%% +\input docstrip + +\def\SimplePackage#1{% + \generate{\file{#1.sty}{\from{#1.dtx}{package}}}} + +\keepsilent + +\usedir{tex/latex/tools} + +\preamble + +This is a generated file. + +The source is maintained by the LaTeX Project team and bug +reports for it can be opened at https://latex-project.org/bugs/ +(but please observe conditions on bug reports sent to that address!) + + +Copyright (C) 1993-2019 +The LaTeX3 Project and any individual authors listed elsewhere +in this file. + +This file was generated from file(s) of the Standard LaTeX `Tools Bundle'. +-------------------------------------------------------------------------- + +It may be distributed and/or modified under the +conditions of the LaTeX Project Public License, either version 1.3c +of this license or (at your option) any later version. +The latest version of this license is in + https://www.latex-project.org/lppl.txt +and version 1.3c or later is part of all distributions of LaTeX +version 2005/12/01 or later. + +This file may only be distributed together with a copy of the LaTeX +`Tools Bundle'. You may however distribute the LaTeX `Tools Bundle' +without such generated files. + +The list of all files belonging to the LaTeX `Tools Bundle' is +given in the file `manifest.txt'. + +\endpreamble + +% Array files +%%%%%%%%%%%%% +\generate{\file{array.sty}{\from{array.dtx}{package,ncols}}} + +\SimplePackage{delarray} + +\batchinput{tabularx.ins} + +\SimplePackage{dcolumn} + +\SimplePackage{hhline} + +\batchinput{longtable.ins} + +% Multicolumn +%%%%%%%%%%%%% +\batchinput{multicol.ins} + +% Bold Math Symbols +%%%%%%%%%%%%%%%%%%% +\batchinput{bm.ins} + +% Footnote Right +%%%%%%%%%%%%%%% +\SimplePackage{ftnright} + +% Theorem files +%%%%%%%%%%%%%%% +\generate{% + \file{theorem.sty}{\from{theorem.dtx}{package}} + \file{thb.sty}{\from{theorem.dtx}{thb}} + \file{thcb.sty}{\from{theorem.dtx}{thcb}} + \file{thc.sty}{\from{theorem.dtx}{thc}} + \file{thp.sty}{\from{theorem.dtx}{thp}} + \file{thmb.sty}{\from{theorem.dtx}{thmb}} + \file{thm.sty}{\from{theorem.dtx}{thm}}} + +% Verbatim +%%%%%%%%%% +\generate{% + \file{verbatim.sty}{\from{verbatim.dtx}{package}} + \file{verbtest.tex}{\from{verbatim.dtx}{testdriver}}} + +% Smart Page references +%%%%%%%%%%%%%%%%%%%%%%% +\batchinput{varioref.ins} + +% External references +%%%%%%%%%%%%%%%%%%%%% +\SimplePackage{xr} + +% Smart Space command +%%%%%%%%%%%%%%%%%%%%% +\SimplePackage{xspace} + +% Show \label \ref keys +%%%%%%%%%%%%%%%%%%%%%%% +\SimplePackage{showkeys} + +% Load fonts under old names +%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\SimplePackage{rawfonts} + +% Selective Option handling +%%%%%%%%%%%%%%%%%%%%%%%%%%% +\SimplePackage{somedefs} + + +% Font sample +%%%%%%%%%%%%% +\generate{% + \file{fontsmpl.sty}{\from{fontsmpl.dtx}{package}} + \file{fontsmpl.tex}{\from{fontsmpl.dtx}{document}}} + +% After Page Package +%%%%%%%%%%%%%%%%%%%% +\batchinput{afterpage.ins} + +% Enumerate Package +%%%%%%%%%%%%%%%%%%%% +\SimplePackage{enumerate} + + +% Indent first paragraphs +%%%%%%%%%%%%%%%%%%% +\SimplePackage{indentfirst} + + +% Show the layout of a document class +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\SimplePackage{layout} + + +% Infix Arithmetic +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\SimplePackage{calc} + +% Debugging +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\SimplePackage{trace} + +% Shell Escape +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\SimplePackage{shellesc} + +% File-Error files +%%%%%%%%%%%%%%%%%% +\generate{% + \file{h.tex}{\from{fileerr.dtx}{help}} + \file{s.tex}{\from{fileerr.dtx}{scroll}} + \file{e.tex}{\from{fileerr.dtx}{edit}} + \file{q.tex}{\from{fileerr.dtx}{batch}} + \file{r.tex}{\from{fileerr.dtx}{run}} + \file{x.tex}{\from{fileerr.dtx}{exit}}} + + +\Msg{***********************************************************} +\Msg{*} +\Msg{* To finish the installation you have to move the following} +\Msg{* files into a directory searched by TeX:} +\Msg{*} +\Msg{* All the files with extension `.sty' and `.tex'} +\Msg{* Note there also may be a file .tex which is `invisible'} +\Msg{* on some operating systems.} +\Msg{*} +\Msg{* To produce the documentation run the .dtx files through LaTeX.} +\Msg{*} +\Msg{* Happy TeXing} +\Msg{***********************************************************} + + +\Msg{} +\Msg{* Finally trying to make a file `.tex'.} +\Msg{* (Placed at the end of this run, as this} +\Msg{* may fail on some operating systems.)} + +\let\oldopenout\openout +\def\openout{\batchmode\immediate\oldopenout} + +\generate{\file{.tex}{\from{fileerr.dtx}{return}}} + +\endbatchfile diff --git a/macros/latex-dev/required/tools/trace.dtx b/macros/latex-dev/required/tools/trace.dtx new file mode 100644 index 0000000000..e808fdd431 --- /dev/null +++ b/macros/latex-dev/required/tools/trace.dtx @@ -0,0 +1,733 @@ +% \iffalse meta-comment +% +% Copyright (C) 1993-2019 +% +% The LaTeX3 Project and any individual authors listed elsewhere +% in this file. +% +% This file is part of the Standard LaTeX `Tools Bundle'. +% ------------------------------------------------------- +% +% It may be distributed and/or modified under the +% conditions of the LaTeX Project Public License, either version 1.3c +% of this license or (at your option) any later version. +% The latest version of this license is in +% https://www.latex-project.org/lppl.txt +% and version 1.3c or later is part of all distributions of LaTeX +% version 2005/12/01 or later. +% +% The list of all files belonging to the LaTeX `Tools Bundle' is +% given in the file `manifest.txt'. +% +% \fi +% \iffalse +%% +%% (C) Copyright (C) 1999-2019 Frank Mittelbach +%% All rights reserved. +%% +%<*dtx> + \ProvidesFile{trace.dtx} +%</dtx> +%<package>\NeedsTeXFormat{LaTeX2e} +%<package>\ProvidesPackage{trace} +%<driver>\ProvidesFile{trace.drv} +% \fi +% \ProvidesFile{trace.dtx} + [2018/10/13 v1.1e trace LaTeX code] +% +% \iffalse +%<*driver> +\documentclass{ltxdoc} +\usepackage{doc} +\setcounter{StandardModuleDepth}{1} + +\usepackage{shortvrb} +\MakeShortVerb\| + +\DeclareRobustCommand\eTeX{\ensuremath{\varepsilon}-\kern-.125em\TeX} + +\begin{document} +\DocInput{trace.dtx} +\end{document} +%</driver> +% \fi +% +% +% \GetFileInfo{trace.dtx} +% +% \title{The \textsf{trace} package\thanks{This file +% has version number \fileversion, last +% revised \filedate.}} +% \author{Frank Mittelbach} +% \date{\filedate} +% \MaintainedByLaTeXTeam{tools} +% \maketitle +% +% +% +% \section{Introduction} +% +% When writing new macros one often finds that they do not work as +% expected (at least I do :-). If this happens and one can't +% immediately figure out why there is a problem one has to start doing +% some serious debugging. \TeX{} offers a lot of bells and whistles to +% control what is being traced but often enough I find myself applying +% the crude command |\tracingall| which essentially means ``give me +% whatever tracing information is available''. +% +% In fact I normally use \eTeX{} in such a case, since that \TeX{} +% extension offers me a number of additional tracing possibilities +% which I find extremely helpful. The most important ones are +% |\tracingassigns|, which will show you changes to register values +% and changes to control sequences when they happen, and +% |\tracinggroups|, which will tell you what groups are entered +% or left (very useful if your grouping got out of sync). +% +% So what I really write is +%\begin{verbatim} +% \tracingassigns=1\tracinggroups=1\tracingall +%\end{verbatim} +% That in itself is already a nuisance (since it is a mouthful) but +% there is a worse catch: when using |\tracingall| you do get a awful +% lot of information and some of it is really useless. +% +% For example, if \LaTeX{} has to load a new font it enters some +% internal routines of NFSS which scan font definition tables etc. +% And 99.9\% of the time you are not at all interested in that part of the +% processing but in the two lines before and the five lines +% after. However, you have to scan through a few hundred lines of +% output to find the lines you need. +% +% Another example is the \texttt{calc} package. A simple statement +% like |\setlength| |\linewidth| |{1cm}| inside your macro will result +% in +% +% \renewcommand\MacroFont{\fontencoding\encodingdefault +% \fontfamily\ttdefault +% \fontseries\mddefault +% \fontshape\updefault +% \footnotesize}% +%\begin{verbatim} +% \setlength ->\protect \setlength +% {\relax} +% +% \setlength ->\calc@assign@skip +% +% \calc@assign@skip ->\calc@assign@generic \calc@Askip \calc@Bskip +% +% \calc@assign@generic #1#2#3#4->\let \calc@A #1\let \calc@B #2\expandafter \calc +% @open \expandafter (#4!\global \calc@A \calc@B \endgroup #3\calc@B +% #1<-\calc@Askip +% #2<-\calc@Bskip +% #3<-\linewidth +% #4<-1cm +% {\let} +% {\let} +% {\expandafter} +% {\expandafter} +% +% \calc@open (->\begingroup \aftergroup \calc@initB \begingroup \aftergroup \calc +% @initB \calc@pre@scan +% {\begingroup} +% {\aftergroup} +% {\begingroup} +% {\aftergroup} +% +% \calc@pre@scan #1->\ifx (#1\expandafter \calc@open \else \ifx \widthof #1\expan +% dafter \expandafter \expandafter \calc@textsize \else \calc@numeric \fi \fi #1 +% #1<-1 +% {\ifx} +% {false} +% {\ifx} +% {false} +% +% \calc@numeric ->\afterassignment \calc@post@scan \global \calc@A +% {\afterassignment} +% {\global} +% {\fi} +% {\fi} +% +% \calc@post@scan #1->\ifx #1!\let \calc@next \endgroup \else \ifx #1+\let \calc@ +% next \calc@add \else \ifx #1-\let \calc@next \calc@subtract \else \ifx #1*\let +% \calc@next \calc@multiplyx \else \ifx #1/\let \calc@next \calc@dividex \else \i +% fx #1)\let \calc@next \calc@close \else \calc@error #1\fi \fi \fi \fi \fi \fi \ +% calc@next +% #1<-! +% {\ifx} +% {true} +% {\let} +% {\else} +% {\endgroup} +% {restoring \calc@next=undefined} +% +% \calc@initB ->\calc@B \calc@A +% {\skip44} +% {\global} +% {\endgroup} +% {restoring \skip44=0.0pt} +% +% \calc@initB ->\calc@B \calc@A +% {\skip44} +% {\dimen27} +%\end{verbatim} +% +% \noindent Do you still remember what I was talking about? +% +% No? We're trying to find a problem in macro code without having to scan +% too many uninteresting lines. To make this possible we have to +% redefine a number of key commands to turn tracing off temporarily in +% the hope that this will reduce the amount of noise during the +% trace. For example, if we change one of the \texttt{calc} internals +% slightly, the above tracing output can be reduced to: +% +%\begin{verbatim} +% \setlength ->\protect \setlength +% {\relax} +% +% \setlength ->\calc@assign@skip +% +% \calc@assign@skip ->\calc@assign@generic \calc@Askip \calc@Bskip +% +% \calc@assign@generic #1#2#3#4->\let \calc@A #1\let \calc@B #2\expandafter \calc +% @open \expandafter (#4!\global \calc@A \calc@B \endgroup #3\calc@B +% #1<-\calc@Askip +% #2<-\calc@Bskip +% #3<-\linewidth +% #4<-1cm +% {\let} +% {\let} +% {\expandafter} +% {\expandafter} +% +% \calc@open (->\begingroup \conditionally@traceoff \aftergroup \calc@initB \begi +% ngroup \aftergroup \calc@initB \calc@pre@scan +% {\begingroup} +% +% \conditionally@traceoff ->\tracingrestores \z@ \tracingcommands \z@ \tracingpag +% es \z@ \tracingmacros \z@ \tracingparagraphs \z@ +% {\tracingrestores} +% {\tracingcommands} +% {restoring \tracingrestores=1} +% +% \calc@initB ->\calc@B \calc@A +% {\skip44} +% {\dimen27} +%\end{verbatim} +% +% \noindent\label{conttraceoffexample} +% Still a lot of noise but definitely preferable to the +% original case. +% +% I redefined those internals that I found most annoyingly +% noisy. There are probably many others that could be treated in a +% similar fashion, so if you think you found one worth adding please +% drop me a short note. +% +% \[ * \quad * \quad * \] +% +% \DescribeMacro\traceon +% \DescribeMacro\traceoff +% The package defines the two macros |\traceon| and |\traceoff| to +% unconditionally turn tracing on or off, respectively. |\traceon| is +% like |\tracingall| but additionally adds |\tracingassigns| and +% |\tracinggroups| if the \eTeX{} program (in extended mode) is +% used. And |\traceoff| will turn tracing off again, a command which +% is already badly missing in plain \TeX{}, since it is often not +% desirable to restrict the tracing using extra groups in the +% document. +% +% \DescribeMacro\conditionally@traceon +% \DescribeMacro\conditionally@traceoff +% There are also two internal macros that turn tracing on and off, but +% only if the user requested tracing in the first place. These are the +% ones that are used internally within the code below. +% +% Since the package overwrites some internals of other packages you +% should load it as the last package in your preamble using +% |\usepackage{trace}|. +% +% The package offers the option \texttt{logonly} that suppresses +% terminal output during tracing (unless |\tracingall| is used). This +% is useful if the \TeX{} implementation used gets rather slow when +% writing a lot of information to the terminal. +% +% It also offers the option \texttt{full} in which case |\traceon| +% will trace all parts of the code, i.e., essentially work like +% |\tracingall|. +% +% \section{A sample file} +% +% The following small test file shows the benefits of the +% \texttt{trace} package. If one uncomments the line loading the +% package, the amount of tracing data will be drastically reduced. +% Without the \texttt{trace} package we get 6594 lines in the log +% file; adding the package will reduce this to 1618 lines. +% +%\begin{verbatim} +% \documentclass{article} +% \usepackage{calc} +% %\usepackage{trace} % uncomment to see difference +% +% \begin{document} +% \ifx\traceon\undefined \tracingall \else \traceon \fi +% +% \setlength\linewidth{1cm} +% +% $foo=\bar a$ +% +% \small \texttt{\$} \stop +%\end{verbatim} +% +% \StopEventually{} +% +% \section{Implementation} +% +% \renewcommand\MacroFont{\fontencoding\encodingdefault +% \fontfamily\ttdefault +% \fontseries\mddefault +% \fontshape\updefault +% \small} +% +% This package is for use with \LaTeX{} (though something similar +% could be produced for other formats). +% \begin{macrocode} +%<*package> +\NeedsTeXFormat{LaTeX2e}[1998/12/01] +% \end{macrocode} +% +% The package has a option that suppresses tracing on the +% terminal, i.e., if used will not set |\tracingonline| to +% one. This has been added in version 1.1a since some \TeX{} +% implementations get rather slow when outputting to a terminal. +% \begin{macrocode} +\DeclareOption{logonly} + {\let\tracingonline@p\z@} +% \end{macrocode} +% The default is showing the tracing information on the terminal. +% \begin{macrocode} +\let\tracingonline@p\@ne +% \end{macrocode} +% +% If the option |full| is selected then all code should be traced, +% i.e., the commands |\conditionally@traceoff| and +% |\conditionally@traceon| should do nothing. We set them to +% |\@empty| not |\relax| since the latter might produce a math ord +% in certain circumstances. We also have to make sure that +% |\traceon| (as defined further down) is not redefining +% |\conditionally@traceoff| again. To make this all work these +% redefinitions have to wait until the end of the package. +% \changes{v1.1c}{2003/04/30}{Option ``full'' added} +% \begin{macrocode} +\DeclareOption{full} + {\AtEndOfPackage{\let\conditionally@traceoff\@empty + \let\conditionally@traceon\@empty + \let\traceon\tr@ce@n + }} +% \end{macrocode} +% +% \begin{macrocode} +\ProcessOptions\relax +% \end{macrocode} +% +% +% +% \begin{macro}{\if@tracing} +% We need a switch to determine if we want any tracing at +% all. Otherwise, if we use |\traceoff|\ldots|\traceon| +% internally, we would unconditionally turn on tracing even when no +% tracing was asked for in the first place. +% \begin{macrocode} +\newif\if@tracing +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\traceon} +% This macro ensures that |\conditionally@traceoff| is actually +% turning off switches (since |\tracinall| might have disabled it) +% and then calls |\tr@ce@n| to setup tracing. +% \begin{macrocode} +\def\traceon{\let\conditionally@traceoff\unconditionally@traceoff + \tr@ce@n} +% \end{macrocode} +% \end{macro} + +% \begin{macro}{\tr@ce@n} +% \changes{v1.1c}{2003/04/30}{Macro added} +% \begin{macro}{\conditionally@traceoff} +% As stated in the introduction, the amount of tracing being done +% should depend on the formatter we use. Initially first test if we are +% running with \eTeX{} in extended mode. In the latter case the command +% |\tracinggroups| is defined. +% But for a number of years now \LaTeX{} only works with \eTeX{} so +% we drop that part of the code. For now I leave it in the file +% together with its documentation, but commented out. +% \begin{macrocode} +%\ifx\tracinggroups\undefined +% \end{macrocode} +% +% If we are using standard \TeX{} then |\tr@ce@n| is more or less +% another name for |\tracingall|. The only differences are that we +% set the above |@tracing| switch to true and reorder the +% assignments within it somewhat so that it will output no tracing +% information about itself. In contrast, |\tracingall| itself produces +% +%\begingroup +% \renewcommand\MacroFont{\fontencoding\encodingdefault +% \fontfamily\ttdefault +% \fontseries\mddefault +% \fontshape\updefault +% \footnotesize}% +%\begin{verbatim} +% {vertical mode: \tracingstats} +% {\tracingpages} +% {\tracinglostchars} +% {\tracingmacros} +% {\tracingparagraphs} +% {\tracingrestores} +% {\errorcontextlines} +% +% \showoutput ->\tracingoutput \@ne \showboxbreadth \maxdimen \showboxdepth \maxd +% imen \errorstopmode \showoverfull +% {\tracingoutput} +% {\showboxbreadth} +% {\showboxdepth} +% {\errorstopmode} +% +% \showoverfull ->\tracingonline \@ne +% {\tracingonline} +%\end{verbatim} +%\endgroup +% +% \noindent Which is quite a lot given that none of it is of any +% help to the task at hand. In contrast |\tr@ce@n| will produce +% nothing whatsoever since the noise generating switches are set at +% the very end. +% \begin{macrocode} +% \def\tr@ce@n{% +% \end{macrocode} +% We start by setting the |@tracing| switch to signal that tracing +% is asked for. This is then followed by setting the various +% tracing primitives of \TeX. +% \begin{macrocode} +% \@tracingtrue +% \tracingstats\tw@ +% \tracingpages\@ne +% \tracinglostchars\@ne +% \tracingparagraphs\@ne +% \errorcontextlines\maxdimen +% \tracingoutput\@ne +% \showboxbreadth\maxdimen +% \showboxdepth\maxdimen +% \errorstopmode +% \tracingmacros\tw@ +% \tracingrestores\@ne +% \tracingcommands\tw@ +% \end{macrocode} +% The setting of |\tracingonline| depends on the option +% \texttt{logonly}: +% \begin{macrocode} +% \tracingonline\tracingonline@p +% } +% \end{macrocode} +% +% Now what should |\conditionally@traceoff| do in this case? Should +% it revert all settings changed by |\tr@ce@n|? It should not, since +% our goal is to shorten the trace output, thus setting all of the +% uninteresting values back makes the output unnecessarily +% longer. Therefore we restrict ourselves to those |\tracing...| +% internals that really contribute to listings like the above. +% +% And one additional point is worth mentioning. The order in which +% we turn the tracing internals off has effects on the output we +% see. So what needs to be turned off first? Either +% |\tracingrestores| or |\tracingcommands|; it makes no difference +% which, as long as they both come first. This is because those two +% are the only tracing switches that produce output while tracing +% the command |\conditionally@traceoff| itself (see example on +% page~\pageref{conttraceoffexample}). +% +% In principle we would need to test the |@tracing| switch to see +% if there is anything to turn off; after all, this is the +% conditional trace off. However this would lead to +% extra output if we are currently tracing so we skip the test and +% instead accept that in case we are not doing any tracing we +% unnecessarily set the tracing primitives back to zero (i.e., the +% value they already have). +% \changes{v1.1c}{2003/04/30}{Turn off \cs{tracingoutput}} +% \begin{macrocode} +% \def\conditionally@traceoff{% +% \tracingrestores\z@ +% \tracingcommands\z@ +% \tracingpages\z@ +% \tracingmacros\z@ +% \tracingparagraphs\z@ +% \tracingoutput\z@ +% \showboxbreadth\m@ne +% \showboxdepth\m@ne +% \end{macrocode} +% +% As remarked above there are more tracing switches set by +% |\tr@ce@n|, however there is no point in resetting +% |\tracinglostchars| so we leave it alone. +% \changes{v1.1c}{2003/04/30}{Reset \cs{tracingstats} to one} +% \begin{macrocode} +% \tracingstats\@ne +%% \tracinglostchars\z@ +% \end{macrocode} +% Since this is the command that only conditionally turns off +% tracing we do not touch the |@tracing| switch. This way a +% |\conditionally@traceon| will be able to turn the tracing on +% again. +% \begin{macrocode} +% } +% \end{macrocode} +% +% That covers the case for the standard \TeX{} program. If +% |\tracingsgroups| was defined we assume that we are running with +% \eTeX{} in extended mode. +% \begin{macrocode} +%\else +% \end{macrocode} +% +% In that case |\tr@ce@n| does more than |\tracingall|: it also +% turns on tracing of assignments and tracing of +% grouping.\footnote{These are my personal preference settings; +% \eTeX{} does in fact offer some more tracing switches and perhaps +% one or or more of them should be added here as well.} +% To keep tracing at a minimum |\tracingassigns| should be turned +% on last (in fact like before we disassemble |\tracingall| +% and reorder it partially). +% \begin{macrocode} + \def\tr@ce@n{% + \@tracingtrue + \tracingstats\tw@ + \tracingpages\@ne + \tracinglostchars\@ne + \tracingparagraphs\@ne + \errorcontextlines\maxdimen +% \end{macrocode} +% We only change |\tracingoutput| if it hasn't already been enabled by +% |\showoutput|. If that's not the case, we set it to 2 so that we +% can distingush the two cases. +% \changes{v1.1e}{2018/10/13}{Only reset \cs{tracingoutput} if not +% set by \cs{showoutput} earlier} +% \begin{macrocode} + \ifnum\tracingoutput=\@ne + \else + \tracingoutput\tw@ + \showboxbreadth\maxdimen + \showboxdepth\maxdimen + \fi +% \end{macrocode} +% +% \begin{macrocode} + \errorstopmode + \tracingmacros\tw@ + \tracinggroups\@ne + \tracingrestores\@ne + \tracingcommands\tw@ + \tracingassigns\@ne + \tracingonline\tracingonline@p + } +% \end{macrocode} +% +% When turning tracing off again we now also have to turn off those +% additional tracing switches. But what to turn off in what order? +% Since |\tracingassigns| is quite noisy (two lines of output per +% assignment) and the whole command expansion consists of +% assignments, we had best start with this switch and follow it again +% by |\tracingrestores| and |\tracingcommands|. The rest can be in +% any order, it doesn't make a difference. +% +% With the same reasoning as before we omit testing for the +% |@tracing| switch and always set the primitives back to zero. +% \changes{v1.1c}{2003/04/30}{Turn off \cs{tracingoutput}} +% \changes{v1.1c}{2003/04/30}{Reset \cs{tracingstats} to one} +% \begin{macrocode} + \def\conditionally@traceoff{% + \tracingassigns\z@ + \tracingrestores\z@ + \tracingcommands\z@ + \tracingpages\z@ + \tracingmacros\z@ +% \end{macrocode} +% If |\tracingoutput| is 2 it was set above, if it is 1 it was set +% by |\showoutput| and we leave it alone and if it is 0 there is +% nothing to do as well. +% \changes{v1.1e}{2018/10/13}{Only reset \cs{tracingoutput} if not +% set by \cs{showoutput} earlier} +% \begin{macrocode} + \ifnum\tracingoutput=\tw@ + \tracingoutput\z@ + \showboxbreadth\m@ne + \showboxdepth\m@ne + \fi +% \end{macrocode} +% +% \begin{macrocode} + \tracingstats\@ne + \tracingparagraphs\z@ + \tracinggroups\z@ + } +% \end{macrocode} +% +% This concludes the part that depends on the formatter being +% used. +% \begin{macrocode} +%\fi +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% +% \begin{macro}{\unconditionally@traceoff} +% \changes{v1.1c}{2003/04/30}{Macro added} +% A saved version of whatever |\conditionally@traceoff| was defined +% to be. We need this since the latter might get disabled by +% |\tracingall| or by the \texttt{full} option. +% \begin{macrocode} +\let\unconditionally@traceoff\conditionally@traceoff +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\tracingall} +% \changes{v1.1c}{2003/04/30}{Macro added} +% We redefine |\tracingall| to trace the same stuff than |\tr@ce@n| (i.e., +% more when \eTeX{} is being used) and ensure that everything gets +% traced by disabling |\conditionally@traceoff|. And, of course, +% |\tracingall| should always report on the terminal. +% \begin{macrocode} +\def\tracingall{\let\conditionally@traceoff\@empty + \let\tracingonline@p\@ne + \tr@ce@n +} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\traceoff} +% \begin{macro}{\conditionally@traceon} +% Above we have defined |\conditionally@traceoff| and |\traceon| so +% now we have to define their counterparts. +% +% To stop tracing unconditionally we call +% |\unconditionally@traceoff| and then reset the |@tracing| switch +% to false. +% \begin{macrocode} +\def\traceoff{\unconditionally@traceoff \@tracingfalse} +% \end{macrocode} +% +% Now the |\conditionally@traceon| command will look at the +% |@tracing| switch and if it is true it will call |\traceon| to +% restart tracing (note that the latter command unnecessarily sets +% the switch to true as well). The reason for the |\expandafter| is +% to get rid of the |\fi| primitive which would otherwise show up in +% the tracing output (and perhaps puzzle somebody). +% \begin{macrocode} +\def\conditionally@traceon{\if@tracing \expandafter \traceon \fi} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% +% The rest of the package now consists of redefinitions of certain +% commands to make use of |\conditionally@traceoff|. +% +% \subsection{Taming \texttt{calc}} +% +% \begin{macro}{\calc@open} +% Near the start of parsing a calc expression the macro |\calc@open| +% is called. Since it already involves a group it is perfectly +% suitable for our task---we don't even have to restart the tracing as +% this is done automatically for us. +% \begin{macrocode} +\def\calc@open({\begingroup + \conditionally@traceoff + \aftergroup\calc@initB + \begingroup\aftergroup\calc@initB + \calc@pre@scan} +% \end{macrocode} +% \end{macro} +% +% +% \subsection{Making NFSS less noisy} +% +% \begin{macro}{\define@newfont} +% Whenever NFSS determines that the font currently asked for is not +% already loaded, it will start looking through font definition +% files and then load the font. This results in a very large number +% of tracing lines which are not normally of interest (unless there +% is a bug in that area---something we hope should have been found +% by now). Again the code already contains its own group so we only +% have to turn the tracing off. +% \begin{macrocode} +\def\define@newfont{% + \begingroup + \conditionally@traceoff + \let\typeout\@font@info + \escapechar\m@ne + \expandafter\expandafter\expandafter + \split@name\expandafter\string\font@name\@nil + \try@load@fontshape % try always + \expandafter\ifx + \csname\curr@fontshape\endcsname \relax + \wrong@fontshape\else + \extract@font\fi + \endgroup} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\frozen@everymath} +% \begin{macro}{\frozen@everydisplay} +% At the beginning of every math formula NFSS will check whether or +% not the math fonts are properly set up and if not will load +% whatever is needed. So we surround that part of the code +% with |\conditionally@traceoff| and |\conditionally@traceon| +% thereby avoiding all this uninteresting output. +% \begin{macrocode} +\frozen@everymath = + {\conditionally@traceoff \check@mathfonts \conditionally@traceon + \the\everymath} +\frozen@everydisplay = + {\conditionally@traceoff \check@mathfonts \conditionally@traceon + \the\everydisplay} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% +% +% \section{Checking for italic corrections} +% +% \begin{macro}{\maybe@ic@} +% When executing |\textit| or its friends, \LaTeX{} looks ahead to +% determine whether or not to add an italic correction at the +% end. This involves looping through the |\nocorrlist| which +% outputs a lot of tracing lines we are normally not interested +% in. So we disable tracing for this part of the processing. +% \changes{v1.1d}{2014/04/21}{Use \cs{ifmaybe@ic} not +% \cs{if@tempswa} as the kernel does (pr/4200)} +% \begin{macrocode} +\def \maybe@ic@ {% + \ifdim \fontdimen\@ne\font>\z@ + \else + \conditionally@traceoff + \maybe@ictrue + \expandafter\@tfor\expandafter\reserved@a\expandafter:\expandafter=% + \nocorrlist + \do \t@st@ic + \ifmaybe@ic \sw@slant \fi + \conditionally@traceon + \fi +} +% \end{macrocode} +% \end{macro} +% +% \begin{macrocode} +%</package> +% \end{macrocode} +% +% +% \Finale +% +% \endinput diff --git a/macros/latex-dev/required/tools/trace.pdf b/macros/latex-dev/required/tools/trace.pdf Binary files differnew file mode 100644 index 0000000000..5eb99c3e24 --- /dev/null +++ b/macros/latex-dev/required/tools/trace.pdf diff --git a/macros/latex-dev/required/tools/varioref-2016-02-16.sty b/macros/latex-dev/required/tools/varioref-2016-02-16.sty new file mode 100644 index 0000000000..78aa06db6b --- /dev/null +++ b/macros/latex-dev/required/tools/varioref-2016-02-16.sty @@ -0,0 +1,779 @@ +%% +%% This is file `varioref.sty', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% varioref.dtx (with options: `package') +%% +%% This is a generated file. +%% +%% The source is maintained by the LaTeX Project team and bug +%% reports for it can be opened at https://latex-project.org/bugs/ +%% (but please observe conditions on bug reports sent to that address!) +%% +%% Copyright 1993-2017 +%% The LaTeX3 Project and any individual authors listed elsewhere +%% in this file. +%% +%% This file was generated from file(s) of the Standard LaTeX `Tools Bundle'. +%% -------------------------------------------------------------------------- +%% +%% It may be distributed and/or modified under the +%% conditions of the LaTeX Project Public License, either version 1.3c +%% of this license or (at your option) any later version. +%% The latest version of this license is in +%% https://www.latex-project.org/lppl.txt +%% and version 1.3c or later is part of all distributions of LaTeX +%% version 2005/12/01 or later. +%% +%% This file may only be distributed together with a copy of the LaTeX +%% `Tools Bundle'. You may however distribute the LaTeX `Tools Bundle' +%% without such generated files. +%% +%% The list of all files belonging to the LaTeX `Tools Bundle' is +%% given in the file `manifest.txt'. +%% +%% Package varioref to use with LaTeX2e +%% Copyright (C) 1992-2016 Frank Mittelbach, all rights reserved. +%% +%% For additions or updates to the language options please contact +%% the author at +%% +%% frank.mittelbach@latex-project.org +%% +%% In case of bugs, please use "latexbug.tex" (category tools) to report them. +%% +\NeedsTeXFormat{LaTeX2e}[1995/05/16] +\ProvidesPackage{varioref} + [2016/02/16 v1.5c package for extended references (FMi)] +%% + + +\def\vref@addto#1#2{% + #2% + \@temptokena{#2}% + \ifx#1\undefined + \edef#1{\the\@temptokena}% + \else + \toks@\expandafter{#1}% + \edef#1{\the\toks@\the\@temptokena}% + \fi + \@temptokena{}\toks@\@temptokena +} +\@onlypreamble\vref@addto +\def\vref@excuse#1{% + \PackageWarningNoLine{varioref}{Sorry, language `#1' + not supported% + \MessageBreak + in this version. + English strings used by default. + \MessageBreak + Please modify \protect\reftext... commands manually.% + \MessageBreak\MessageBreak + If you can suggest translations for + this language,% + \MessageBreak + please mail them + to the author of this package}} +\@onlypreamble\vref@excuse +\def\vref@stringwarning#1{% + \PackageWarningNoLine{varioref}{Sorry, there is no proper + translation for the string\MessageBreak + produced by \protect#1\on@line.\MessageBreak + English string used instead.\MessageBreak + \MessageBreak + If you can suggest translations for + the current\MessageBreak + language, please mail them + to the author of this\MessageBreak package}} +\DeclareOption{afrikaans} + {\vref@addto\extrasafrikaans{% + \def\reftextfaceafter {op die \reftextvario{regterbladsy}% + {bladsy langsaan}}% + \def\reftextfacebefore{op die \reftextvario{linkerbladsy}% + {bladsy langsaan}}% + \def\reftextafter {op die \reftextvario{volgende bladsy}% + {bladsy hierna}}% + \def\reftextbefore {op die \reftextvario{vorige bladsy}% + {bladsy hiervoor}}% + \def\reftextcurrent {op \reftextvario{hierdie}% + {die huidige} bladsy}% + \def\reftextfaraway#1{op bladsy~\pageref{#1}}% + \def\reftextpagerange#1#2{op bladsye~\pageref{#1}--\pageref{#2}}% + \def\reftextlabelrange#1#2{\ref{#1} tot~\ref{#2}}% + }} +\DeclareOption{american} + {\vref@addto\extrasamerican{% + \def\reftextfaceafter {on the \reftextvario{facing}{next} page}% + \def\reftextfacebefore{on the \reftextvario{facing}{preceding} + page}% + \def\reftextafter {on the \reftextvario{following}{next} page}% + \def\reftextbefore {on the \reftextvario{preceding}{previous} page}% + \def\reftextcurrent {on \reftextvario{this}{the current} page}% + \def\reftextfaraway#1{on page~\pageref{#1}}% + \def\reftextpagerange#1#2{on pages~\pageref{#1}--\pageref{#2}}% + \def\reftextlabelrange#1#2{\ref{#1} to~\ref{#2}}% + }} +\DeclareOption{austrian} + {\vref@addto\extrasaustrian{% + \def\reftextfaceafter {auf der n\"achsten Seite}% + \def\reftextfacebefore{auf der vorherigen Seite}% + \let\reftextafter \reftextfaceafter + \let\reftextbefore \reftextfacebefore + \def\reftextcurrent {auf dieser Seite}% + \def\reftextfaraway#1{auf Seite~\pageref{#1}}% + \def\reftextpagerange#1#2{auf Seiten~\pageref{#1}--\pageref{#2}}% + \def\reftextlabelrange#1#2{\ref{#1} bis~\ref{#2}}% + }} +\DeclareOption{naustrian} + {\vref@addto\extrasnaustrian{% + \def\reftextfaceafter {auf der n\"achsten Seite}% + \def\reftextfacebefore{auf der vorherigen Seite}% + \let\reftextafter \reftextfaceafter + \let\reftextbefore \reftextfacebefore + \def\reftextcurrent {auf dieser Seite}% + \def\reftextfaraway#1{auf Seite~\pageref{#1}}% + \def\reftextpagerange#1#2{auf Seiten~\pageref{#1}--\pageref{#2}}% + \def\reftextlabelrange#1#2{\ref{#1} bis~\ref{#2}}% + }} +\DeclareOption{basque} + {\vref@addto\extrasbasque{% + \def\reftextfaceafter {hurrengo orrialdean}% + \def\reftextfacebefore{aurreko orrialdean}% + \let\reftextafter \reftextfaceafter + \let\reftextbefore \reftextfacebefore + \def\reftextcurrent {uneko orrialdean}% + \def\reftextfaraway#1{~\pageref{#1}. orrialdean}% + \def\reftextpagerange#1#2{~\pageref{#1}--\pageref{#2} orrialdeetan}% + \def\reftextlabelrange#1#2{\ref{#1}.etik \ref{#2}.eraino}% + }} +\DeclareOption{bahasam} + {\vref@addto\extrasbahasam{% + \def\reftextfaceafter {pada muka surat \reftextvario{bertentangan}{berikutnya}}% + \def\reftextfacebefore{pada muka surat \reftextvario{bertentangan}{sebelumnya} }% + \def\reftextafter {pada muka surat berikutnya}% + \def\reftextbefore {pada muka surat sebelumnya}% + \def\reftextcurrent {pada muka surat ini}% + \def\reftextfaraway#1{pada muka surat~\pageref{#1}}% + \def\reftextpagerange#1#2{pada muka surat~\pageref{#1}--\pageref{#2}}% + \def\reftextlabelrange#1#2{\ref{#1}--\ref{#2}}% + }} +\DeclareOption{brazil} + {\vref@addto\extrasbrazil{% + \def\reftextfaceafter {na \reftextvario{p\'agina oposta}{pr\'oxima + p\'agina}}% + \def\reftextfacebefore{na p\'agina \reftextvario{oposta}{anterior}}% + \def\reftextafter {na \reftextvario{p\'agina seguinte}{pr\'oxima + p\'agina}}% + \def\reftextbefore{na p\'agina \reftextvario{anterior}{precedente}}% + \def\reftextcurrent {\reftextvario{nesta p\'agina}{na p\'agina + corrente}}% + \def\reftextfaraway#1{na p\'agina~\pageref{#1}}% + \def\reftextpagerange#1#2{nas p\'aginas~\pageref{#1}--\pageref{#2}}% + \def\reftextlabelrange#1#2{\ref{#1} a~\ref{#2}}% + }} +\DeclareOption{breton} + {\vref@excuse{breton}% + \vref@addto\extrasbreton{% + \def\reftextfaceafter {war ar bajenn \reftextvario{a-dal}{da heul}}% + \def\reftextfacebefore{war ar bajenn \reftextvario{a-dal}{a-raok}}% + \def\reftextafter {war ar bajenn da heul}% + \def\reftextbefore {war ar bajenn a-raok}% + \def\reftextcurrent {war ar \reftextvario{bajenn-ma\~n}% + {bajenn war-wel}}% + \def\reftextfaraway#1{war ar bajenn~\pageref{#1}}% + \def\reftextpagerange#1#2{\vref@stringwarning\reftextpagerange + on pages~\pageref{#1}--\pageref{#2}}% + \def\reftextlabelrange#1#2{\vref@stringwarning\reflabelpagerange + \ref{#1} to~\ref{#2}}% + }} +\DeclareOption{bulgarian}% + {\vref@addto\extrasbulgarian{% + \def\reftextfaceafter{\cyrn\cyra\ + \reftextvario{\cyrs\cyrery\cyrs\cyre\cyrd\cyrn\cyra\cyrt\cyra}% + {\cyrs\cyrl\cyre\cyrd\cyrv\cyra\cyrshch\cyra\cyrt\cyra} + \cyrs\cyrt\cyrr\cyra\cyrn\cyri\cyrc\cyra}% + \def\reftextfacebefore{\cyrn\cyra\ + \reftextvario{\cyrs\cyrery\cyrs\cyre\cyrd\cyrn\cyra\cyrt\cyra}% + {\cyrp\cyrr\cyre\cyrd\cyrn\cyra\cyrt\cyra} + \cyrs\cyrt\cyrr\cyra\cyrn\cyri\cyrc\cyra}% + \def\reftextafter{\cyrn\cyra\ + \reftextvario{\cyrs\cyrl\cyre\cyrd\cyrv\cyra\cyrshch\cyra\cyrt\cyra}% + {\cyrs\cyrl\cyre\cyrd\cyrv\cyra\cyrshch\cyra\cyrt\cyra} + \cyrs\cyrt\cyrr\cyra\cyrn\cyri\cyrc\cyra}% + \def\reftextbefore{\cyrn\cyra\ + \reftextvario{\cyrp\cyrr\cyre\cyrd\cyrn\cyra\cyrt\cyra}% + {\cyrp\cyrr\cyre\cyrd\cyri\cyrsh\cyrn\cyra\cyrt\cyra} + \cyrs\cyrt\cyrr\cyra\cyrn\cyri\cyrc\cyra}% + \def\reftextcurrent{\cyrn\cyra\ + \reftextvario{\cyrt\cyra\cyrz\cyri}% + {\cyrt\cyre\cyrk\cyru\cyrshch\cyra\cyrt\cyra} + \cyrs\cyrt\cyrr\cyra\cyrn\cyri\cyrc\cyra}% + \def\reftextfaraway#1{\cyrn\cyra\ \cyrs\cyrt\cyrr\cyra\cyrn\cyri\cyrc\cyra + ~\pageref{#1}}% + \def\reftextpagerange#1#2{\cyrn\cyra\ + \cyrs\cyrt\cyrr\cyra\cyrn\cyri\cyrc\cyri + ~\pageref{#1}--\pageref{#2}}% + \def\reftextlabelrange#1#2{\ref{#1} \cyrd\cyro~\ref{#2}}% + }} +\DeclareOption{catalan} + {\vref@addto\extrascatalan{% + \def\reftextfaceafter {a la p\`agina seg\"uent}% + \def\reftextfacebefore{a la p\`agina anterior}% + \let\reftextafter \reftextfaceafter + \let\reftextbefore \reftextfacebefore + \def\reftextcurrent {en aquesta p\`agina}% + \def\reftextfaraway#1{a la p\`agina~\pageref{#1}}% + \def\reftextpagerange#1#2{a les + p\`agines~\pageref{#1}--\pageref{#2}}% + \def\reftextlabelrange#1#2{\ref{#1} a~\ref{#2}}% + }} +\DeclareOption{croatian} + {\vref@addto\extrascroatian{% + \def\reftextfaceafter {na sljede\'coj stranici}% + \def\reftextfacebefore{na prethodnoj stranici}% + \let\reftextafter \reftextfaceafter + \let\reftextbefore \reftextfacebefore + \def\reftextcurrent {na ovoj stranici}% + \def\reftextfaraway#1{na stranici~\pageref{#1}}% + \def\reftextpagerange#1#2{na stranicama~\pageref{#1}--\pageref{#2}}% + \def\reftextlabelrange#1#2{\ref{#1} do~\ref{#2}}% + }} +\DeclareOption{czech} + {%\vref@excuse{czech}% + \vref@addto\extrasczech{% + \def\reftextfaceafter {na n\'a\-sle\-du\-j\'\i c\'\i\ stran\v{e}}% + \def\reftextfacebefore{na p\v{r}ed\-choz\'\i\ stran\v{e}}% + \def\reftextafter {na n\'a\-sle\-du\-j\'\i c\'\i\ stran\v{e}}% + \def\reftextbefore {na p\v{r}ed\-choz\'\i\ stran\v{e}}% + \def\reftextcurrent {na t\'eto stran\v{e}}% + \def\reftextfaraway#1{na stran\v{e}~\pageref{#1}}% + \def\reftextpagerange#1#2{na stran\'ach~\pageref{#1}\--\pageref{#2}}% + \def\reftextlabelrange#1#2{\ref{#1} a\v{z}~\ref{#2}}% + }} +\DeclareOption{danish} + {\vref@addto\extrasdanish{% + \def\reftextfaceafter {p\aa{} \reftextvario{modst\aa ende}% + {n\ae ste} side}% + \def\reftextfacebefore{p\aa{} \reftextvario{modst\aa ende}% + {forrige} side}% + \def\reftextafter {p\aa{} \reftextvario{den f\o lgende}% + {n\ae ste} side}% + \def\reftextbefore {p\aa{} \reftextvario{forrige side} + {foreg\aa ende side}}% + \def\reftextcurrent {p\aa{} denne side}% + \def\reftextfaraway#1{p\aa{} side~\pageref{#1}}% + \def\reftextpagerange#1#2{p\aa{} side~\pageref{#1}--\pageref{#2}}% + \def\reftextlabelrange#1#2{\ref{#1} til~\ref{#2}}% + }} +\DeclareOption{dutch} + {\vref@addto\extrasdutch{% + \def\refpagename{pagina}% + \def\reftextfaceafter {op de \reftextvario{rechter \refpagename}% + {\refpagename\ hiernaast}}% + \def\reftextfacebefore{op de \reftextvario{linker \refpagename}% + {\refpagename\ hiernaast}}% + \def\reftextafter {op de \reftextvario{volgende \refpagename}% + {\refpagename\ hierna}}% + \def\reftextbefore {op de \reftextvario{vorige \refpagename}% + {\refpagename\ hiervoor}}% + \def\reftextcurrent {op deze \refpagename}% + \def\reftextfaraway#1{op \refpagename~\pageref{#1}}% + \def\reftextpagerange#1#2{op pagina's~\pageref{#1}--\pageref{#2}}% + \def\reftextlabelrange#1#2{\ref{#1}--\ref{#2}}% + }} +\DeclareOption{english} + {\vref@addto\extrasenglish{% + \def\reftextfaceafter {on the \reftextvario{facing}{next} page}% + \def\reftextfacebefore{on the \reftextvario{facing}{preceding} + page}% + \def\reftextafter {on the \reftextvario{following}{next} page}% + \def\reftextbefore {on the \reftextvario{preceding}{previous} page}% + \def\reftextcurrent {on \reftextvario{this}{the current} page}% + \def\reftextfaraway#1{on page~\pageref{#1}}% + \def\reftextpagerange#1#2{on pages~\pageref{#1}--\pageref{#2}}% + \def\reftextlabelrange#1#2{\ref{#1} to~\ref{#2}}% + }} +\DeclareOption{esperanto} + {\vref@addto\extrasesperanto{% + \def\reftextfaceafter{en la + \reftextvario{flanka}{sekva} pa\^go}% + \def\reftextfacebefore{en la + \reftextvario{flanka}{anta\u ua} pa\^go}% + \def\reftextafter{en la sekva pa\^go}% + \def\reftextbefore{en la anta\u ua pa\^go}% + \def\reftextcurrent{\reftextvario{\^ci-pa\^ge}% + {en \^ci tiu pa\^go}}% + \def\reftextfaraway#1{en pa\^go~\pageref{#1}}% + \def\reftextpagerange#1#2{en pa\^goj~\pageref{#1} \^gis \pageref{#2}}% + \def\reftextlabelrange#1#2{\ref{#1} \^gis~\ref{#2}}% + }} +\DeclareOption{finnish} + {\vref@addto\extrasfinnish{% + \def\reftextfaceafter {\reftextvario{viereisell\"a}% + {seuraavalla} sivulla}% + \def\reftextfacebefore{\reftextvario{viereisell\"a}% + {edellisell\"a} sivulla}% + \def\reftextafter {seuraavalla sivulla}% + \def\reftextbefore {edellisell\"a sivulla}% + \def\reftextcurrent {t\"all\"a sivulla}% + \def\reftextfaraway#1{sivulla~\pageref{#1}}% + \def\reftextpagerange#1#2{sivuilla~\pageref{#1}--\pageref{#2}}% + \def\reftextlabelrange#1#2{\ref{#1}--\ref{#2}}% + }} +\DeclareOption{french} + {\vref@addto\extrasfrench{% + \def\reftextfaceafter {page \reftextvario{ci-contre}{suivante}}% + \def\reftextfacebefore{page \reftextvario{ci-contre}% + {pr\'ec\'edente}}% + \def\reftextafter {page suivante}% + \def\reftextbefore {page pr\'ec\'edente}% + \def\reftextcurrent {de la pr\'esente page}% + \def\reftextfaraway#1{page~\pageref{#1}}% + \def\reftextpagerange#1#2{pages~\pageref{#1}--\pageref{#2}}% + \def\reftextlabelrange#1#2{\ref{#1} \`a~\ref{#2}}% + }} +\DeclareOption{galician} + {\vref@addto\extrasgalician{% + \def\reftextfaceafter {na p\'axina oposta}% + \def\reftextfacebefore\reftextfaceafter + \def\reftextafter {na p\'axina seguinte}% + \def\reftextbefore {na p\'axina anterior}% + \def\reftextcurrent {nesta p\'axina}% + \def\reftextfaraway#1{na p\'axina~\pageref{#1}}% + \def\reftextpagerange#1#2{% + nas p\'axinas~\pageref{#1}-\pageref{#2}}% + \def\reftextlabelrange#1#2{\ref{#1} a~\ref{#2}}% + }} +\DeclareOption{german} + {\vref@addto\extrasgerman{% + \def\reftextfaceafter {auf der n\"achsten Seite}% + \def\reftextfacebefore{auf der vorherigen Seite}% + \let\reftextafter \reftextfaceafter + \let\reftextbefore \reftextfacebefore + \def\reftextcurrent {auf dieser Seite}% + \def\reftextfaraway#1{auf Seite~\pageref{#1}}% + \def\reftextpagerange#1#2{auf den Seiten~\pageref{#1}--\pageref{#2}}% + \def\reftextlabelrange#1#2{\ref{#1} bis~\ref{#2}}% + }} +\DeclareOption{ngerman} + {\vref@addto\extrasngerman{% + \def\reftextfaceafter {auf der n\"achsten Seite}% + \def\reftextfacebefore{auf der vorherigen Seite}% + \let\reftextafter \reftextfaceafter + \let\reftextbefore \reftextfacebefore + \def\reftextcurrent {auf dieser Seite}% + \def\reftextfaraway#1{auf Seite~\pageref{#1}}% + \def\reftextpagerange#1#2{auf den Seiten~\pageref{#1}--\pageref{#2}}% + \def\reftextlabelrange#1#2{\ref{#1} bis~\ref{#2}}% + }} +\DeclareOption{greek} + {\vref@addto\extrasgreek{% + \def\reftextfaceafter {sthn \reftextvario{paro'usa}% + {ep'omenh} sel'ida}% + \def\reftextfacebefore{sthn \reftextvario{paro'usa}{prohgo'umenh} + sel'ida}% + \def\reftextafter {sthn ep'omenh sel'ida}% + \def\reftextbefore {sthn prohgo'umenh sel'ida}% + \def\reftextcurrent {s'' aut'h th sel'ida}% + \def\reftextfaraway#1{sth sel'ida\nobreakspace\pageref{#1}}% + \def\reftextpagerange#1#2{stis sel'ides\nobreakspace + \pageref{#1}---\pageref{#2}}% + \def\reftextlabelrange#1#2{\ref{#1} ws\nobreakspace\ref{#2}}% + }} +\DeclareOption{icelandic} + {\vref@addto\extrasicelandic{% + \def\reftextfaceafter {\'{a} \reftextvario{n{\ae}stu}% + {n{\ae}stu} s\'{i}{\dh}u}% + \def\reftextfacebefore{\'{a} \reftextvario{fyrri}% + {fyrri} s\'{i}{\dh}u}% + \def\reftextafter {\'{a} \reftextvario{n{\ae}stu}% + {n{\ae}stu} s\'{i}{\dh}u}% + \def\reftextbefore {\'{a} \reftextvario{fyrri}{fyrri} s\'{i}{\dh}u}% + \def\reftextcurrent {\'{a} \reftextvario{{\th}essari}% + {{\th}essari} s\'{i}{\dh}u}% + \def\reftextfaraway#1{\'{a} s\'{i}{\dh}u~\pageref{#1}}% + \def\reftextpagerange#1#2{\'{a} s\'{i}{\dh}um~\pageref{#1}--\pageref{#2}}% + \def\reftextlabelrange#1#2{\ref{#1} til~\ref{#2}}% + }} +\DeclareOption{italian} + {\vref@addto\extrasitalian{% + \def\reftextfaceafter {\reftextvario{a fronte}% + {nella pagina successiva}}% + \def\reftextfacebefore{\reftextvario{a fronte}% + {nella pagina precedente}}% + \def\reftextafter {nella pagina \reftextvario{seguente}% + {successiva}}% + \def\reftextbefore {nella pagina precedente}% + \def\reftextcurrent {in questa pagina}% + \def\reftextfaraway#1{a pagina~\pageref{#1}}% + \def\reftextpagerange#1#2{nelle pagine~\pageref{#1}--\pageref{#2}}% + \def\reftextlabelrange#1#2{da~\ref{#1} a~\ref{#2}}% + }} +\DeclareOption{magyar} + {\vref@addto\extrasmagyar{% + \def\reftextafter {a k\"o\-vet\-kez\H{o} ol\-da\-lon}% + \def\reftextbefore{az el\H{o}\-z\H{o} ol\-da\-lon}% + \def\reftextfaceafter {\reftextvario{a t\'ul\-ol\-da\-lon}% + {a k\"o\-vet\-kez\H{o} ol\-da\-lon}}% + \def\reftextfacebefore{\reftextvario{a t\'ul\-ol\-da\-lon}% + {az el\H{o}\-z\H{o} ol\-da\-lon}}% + \def\reftextcurrent {ezen az ol\-da\-lon}% + \def\reftextfaraway#1{\aza{\pageref{#1}} \pageref{#1}.~ol\-da\-lon}% + \def\reftextpagerange#1#2{\vref@stringwarning\reftextpagerange + on pages~\pageref{#1}--\pageref{#2}}% + \def\reftextlabelrange#1#2{\vref@stringwarning\reflabelpagerange + \ref{#1} to~\ref{#2}}% + }% + \AtBeginDocument{\providecommand\aza[1]{a/az% + \PackageError{varioref}{% + Proper definition for command \noexpand\aza missing}% + {You need to (re)define the command \noexpand\aza that + takes one argument (a number or a \noexpand\pageref command) + and produces the string `a' or `az' depending on the argument + value. It should also accept an optional argument (default `l') + to denote whether or not the string should be lowercase or + uppercase.}}}% + } +\DeclareOption{norsk} + {\vref@addto\extrasnorsk{% + \def\reftextfaceafter {p\aa{} neste side}% + \def\reftextfacebefore{p\aa{} forrige side}% + \def\reftextafter {p\aa{} neste side}% + \def\reftextbefore {p\aa{} forrige side}% + \def\reftextcurrent {p\aa{} denne siden}% + \def\reftextfaraway#1{p\aa{} side~\pageref{#1}}% + \def\reftextpagerange#1#2{p\aa{} side~\pageref{#1}--\pageref{#2}}% + \def\reftextlabelrange#1#2{\ref{#1} til~\ref{#2}}% + }} +\DeclareOption{nynorsk} + {\vref@addto\extrasnynorsk{% + \def\reftextfaceafter {p\aa{} neste side}% + \def\reftextfacebefore{p\aa{} f\o{}rre side}% + \def\reftextafter {p\aa{} neste side}% + \def\reftextbefore {p\aa{} f\o{}rre side}% + \def\reftextcurrent {p\aa{} denne sida}% + \def\reftextfaraway#1{p\aa{} side~\pageref{#1}}% + \def\reftextpagerange#1#2{p\aa{} side~\pageref{#1}--\pageref{#2}}% + \def\reftextlabelrange#1#2{\ref{#1} til~\ref{#2}}% + }} +\DeclareOption{polish} + {\vref@addto\extraspolish{% + \def\reftextfaceafter {na \reftextvario{s\aob{}siedniej}% + {nast\eob{}pnej} stronie}% + \def\reftextfacebefore{na \reftextvario{s\aob{}siedniej}% + {poprzedniej} stronie}% + \def\reftextafter {na nast\eob{}pnej stronie}% + \def\reftextbefore {na poprzedniej stronie}% + \def\reftextcurrent {na \reftextvario{tej + samej}{bie\zkb{}\aob{}cej} stronie}% + \def\reftextfaraway#1{na stronie~\pageref{#1}}% + \def\reftextpagerange#1#2{na stronach~\pageref{#1}--\pageref{#2}}% + \def\reftextlabelrange#1#2{od~\ref{#1} do~\ref{#2}}% + }} +\DeclareOption{portuges} + {\vref@addto\extrasportuges{% + \def\reftextfaceafter {na \reftextvario{p\'agina ao lado}{pr\'oxima + p\'agina}}% + \def\reftextfacebefore{na p\'agina \reftextvario{ao lado}{anterior}}% + \def\reftextafter {na \reftextvario{p\'agina seguinte}{pr\'oxima + p\'agina}}% + \def\reftextbefore{na p\'agina \reftextvario{anterior}{precedente}}% + \def\reftextcurrent {nesta p\'agina}% + \def\reftextfaraway#1{na p\'agina~\pageref{#1}}% + \def\reftextpagerange#1#2{nas p\'aginas~\pageref{#1}--\pageref{#2}}% + \def\reftextlabelrange#1#2{\ref{#1} a~\ref{#2}}% + }} +\DeclareOption{romanian} + {\vref@addto\extrasromanian{% + \def\reftextfaceafter {pe pagina \reftextvario{opus\u{a}}{urm\u{a}toarei}}% + \def\reftextfacebefore{pe pagina \reftextvario{opus\u{a}}{precedentei}}% + \def\reftextafter {\reftextvario{pe pagina urm\u{a}toare}% + {pe urm\u{a}toarea pagin\u{a}}}% + \def\reftextbefore {pe pagina \reftextvario{precedent\u{a}}% + {precedentei}}% + \def\reftextcurrent {pe aceast\u{a} pagin\u{a}}% + \def\reftextfaraway#1{pe pagina~\pageref{#1}}% + \def\reftextpagerange#1#2{pe paginile~\pageref{#1}--\pageref{#2}}% + \def\reftextlabelrange#1#2{\ref{#1} la~\ref{#2}}% + }} +\DeclareOption{russian} + {\vref@addto\extrasrussian{% + \def\reftextfaceafter{\cyrn\cyra\ \reftextvario{\cyrp\cyrr\cyro + \cyrt\cyri\cyrv\cyro\cyrp\cyro\cyrl\cyro\cyrzh\cyrn\cyro\cyrishrt}% + {\cyrs\cyrl\cyre\cyrd\cyru\cyryu\cyrshch\cyre\cyrishrt}\ \cyrs\cyrt + \cyrr\cyra\cyrn\cyri\cyrc\cyre}% + \def\reftextfacebefore{\cyrn\cyra\ \reftextvario{\cyrp\cyrr\cyro + \cyrt\cyri\cyrv\cyro\cyrp\cyro\cyrl\cyro\cyrzh\cyrn\cyro\cyrishrt}% + {\cyrp\cyrr\cyre\cyrd\cyrery\cyrd\cyru\cyrshch\cyre\cyrishrt}\ + \cyrs\cyrt\cyrr\cyra\cyrn\cyri\cyrc\cyre}% + \def\reftextafter{\cyrn\cyra\ \cyrs\cyrl\cyre\cyrd\cyru\cyryu\cyrshch + \cyre\cyrishrt\ \cyrs\cyrt\cyrr\cyra\cyrn\cyri\cyrc\cyre}% + \def\reftextbefore{\cyrn\cyra\ \reftextvario{\cyrp\cyrr\cyre\cyrd + \cyrsh\cyre\cyrs\cyrt\cyrv\cyru\cyryu\cyrshch\cyre\cyrishrt}% + {\cyrp\cyrr\cyre\cyrd\cyrery\cyrd\cyru\cyrshch\cyre\cyrishrt}% + \ \cyrs\cyrt\cyrr\cyra\cyrn\cyri\cyrc\cyre}% + \def\reftextcurrent{\cyrn\cyra\ \reftextvario{\cyrerev\cyrt\cyro + \cyrishrt}{\cyrd\cyra\cyrn\cyrn\cyro\cyrishrt}\ \cyrs\cyrt\cyrr + \cyra\cyrn\cyri\cyrc\cyre}% + \def\reftextfaraway#1{\cyrn\cyra\ \cyrs.~\pageref{#1}}% + \def\reftextpagerange#1#2{\cyrn\cyra\ \cyrs\cyrt\cyrr\cyra\cyrn + \cyri\cyrc\cyra\cyrh~\pageref{#1}--\pageref{#2}}% + \def\reftextlabelrange#1#2{\cyrs~\ref{#1}\ \cyrp\cyro~\ref{#2}}% + }} +\DeclareOption{slovak} + {\vref@addto\extrasslovak{% + \def\reftextfaceafter {na \reftextvario{proti\v lahlej}% + {nasleduj\'ucej} strane}% + \def\reftextfacebefore{na \reftextvario{proti\v lahlej}% + {predch\'adzaj\'ucej} strane}% + \def\reftextafter {na \reftextvario{nasleduj\'ucej}% + {\v dal\v sej} strane}% + \def\reftextbefore {na \reftextvario{predch\'adzaj\'ucej}% + {predo\v slej} strane}% + \def\reftextcurrent {na tejto strane}% + \def\reftextfaraway#1{na strane~\pageref{#1}}% + \def\reftextpagerange#1#2{na stran\'ach~\pageref{#1}--\pageref{#2}}% + \def\reftextlabelrange#1#2{\ref{#1} a\v z~\ref{#2}}% + }} +\DeclareOption{slovene} + {\vref@addto\extrasslovene{% + \def\reftextfaceafter {na naslednji strani}% + \def\reftextfacebefore{na prej\v{s}nji strani}% + \let\reftextafter \reftextfaceafter + \let\reftextbefore \reftextfacebefore + \def\reftextcurrent {na \reftextvario{tej}{trenutni} strani}% + \def\reftextfaraway#1{na strani~\pageref{#1}}% + \def\reftextpagerange#1#2{na straneh~\pageref{#1}--\pageref{#2}}% + \def\reftextlabelrange#1#2{od~\ref{#1} do~\ref{#2}}% + }} +\DeclareOption{spanish} + {\vref@addto\extrasspanish{% + \def\reftextfaceafter {en la p\'agina siguiente}% + \def\reftextfacebefore{en la p\'agina anterior}% + \let\reftextafter \reftextfaceafter + \let\reftextbefore \reftextfacebefore + \def\reftextcurrent {en esta p\'agina}% + \def\reftextfaraway#1{en la p\'agina~\pageref{#1}}% + \def\reftextpagerange#1#2{en las p\'aginas~\pageref{#1}% + -\pageref{#2}}% + \def\reftextlabelrange#1#2{\ref{#1} a~\ref{#2}}% + }} +\DeclareOption{swedish} + {\vref@addto\extrasswedish{% + \def\reftextfaceafter {p\aa\ \reftextvario{motst\aa ende}% + {n\"{a}sta} sida}% + \def\reftextfacebefore{p\aa\ \reftextvario{motst\aa ende}% + {f\"{o}reg\aa ende} sida}% + \def\reftextafter {p\aa\ \reftextvario{f\"{o}ljande}% + {n\"{a}sta} sida}% + \def\reftextbefore {p\aa\ f\"{o}reg\aa ende sida}% + \def\reftextcurrent {p\aa\ denna sida}% + \def\reftextfaraway#1{p\aa\ sidan~\pageref{#1}}% + \def\reftextpagerange#1#2{p\aa\ + sidorna~\pageref{#1}--\pageref{#2}}% + \def\reftextlabelrange#1#2{\ref{#1} till~\ref{#2}}% + }} +\DeclareOption{turkish} + {\vref@excuse{turkish}% + \vref@addto\extrasturkish{% + \def\reftextfaceafter {on the \reftextvario{facing}{next} page}% + \def\reftextfacebefore{on the \reftextvario{facing}{preceding} + page}% + \def\reftextafter {on the \reftextvario{following}{next} page}% + \def\reftextbefore {on the \reftextvario{preceding}{previous} page}% + \def\reftextcurrent {on \reftextvario{this}{the current} page}% + \def\reftextfaraway#1{on page~\pageref{#1}}% + \def\reftextpagerange#1#2{on pages~\pageref{#1}--\pageref{#2}}% + \def\reftextlabelrange#1#2{\ref{#1} to~\ref{#2}}% + }} +\DeclareOption{ukrainian} + {\vref@addto\extrasukrainian{% + \def\reftextfaceafter{\cyrn\cyra\ \reftextvario{\cyrp\cyrr\cyro + \cyrt\cyri\cyrl\cyre\cyrzh\cyrn\cyrii\cyrishrt}% + {\cyrn\cyra\cyrs\cyrt\cyru\cyrp\cyrn\cyrii\cyrishrt}\ \cyrs\cyrt + \cyro\cyrr\cyri\cyrn\cyrc\cyrii}% + \def\reftextfacebefore{\cyrn\cyra\ \reftextvario{\cyrp\cyrr\cyro + \cyrt\cyri\cyrl\cyre\cyrzh\cyrn\cyrii\cyrishrt}% + {\cyrp\cyro\cyrp\cyre\cyrr\cyre\cyrd\cyrn\cyrii\cyrishrt}\ + \cyrs\cyrt\cyro\cyrr\cyrii\cyrn\cyrc\cyrii}% + \def\reftextafter{\cyrn\cyra\ \cyrn\cyra\cyrs\cyrt\cyru\cyrp\cyrn + \cyrii\cyrishrt\ \cyrs\cyrt\cyro\cyrr\cyrii\cyrn\cyrc\cyrii}% + \def\reftextbefore{\cyrn\cyra\ \cyrp\cyro\cyrp\cyre\cyrr\cyre\cyrd + \cyrn\cyrii\cyrishrt\ \cyrs\cyrt\cyro\cyrr\cyrii\cyrn\cyrc\cyrii}% + \def\reftextcurrent{\cyrn\cyra\ \reftextvario{\cyrc\cyrii\cyrishrt}% + {\cyrd\cyra\cyrn\cyrii\cyrishrt}\ \cyrs\cyrt\cyro\cyrr\cyrii\cyrn + \cyrc\cyrii}% + \def\reftextfaraway#1{\cyrn\cyra\ \cyrs.~\pageref{#1}}% + \def\reftextpagerange#1#2{\cyrn\cyra\ \cyrs\cyrt\cyro\cyrr\cyrii + \cyrn\cyrk\cyra\cyrh~\pageref{#1}--\pageref{#2}}% + \def\reftextlabelrange#1#2{\cyrz~\ref{#1}\ \cyrd\cyro~\ref{#2}}% + }} +\DeclareOption{francais}{% + \typeout{Please use `french' instead of `francais'}% + \ExecuteOptions{french}} +\DeclareOption{germanb}{% + \typeout{Please use `german' instead of `germanb'}% + \ExecuteOptions{german}} +\DeclareOption{draft}{\AtEndOfPackage\vrefwarning} +\DeclareOption{final}{\AtEndOfPackage\vrefshowerrors} % the default +\ExecuteOptions{english,final} +\ProcessOptions* +\newcounter{vrcnt} +\DeclareRobustCommand\vpageref{\@ifstar + {\let\vref@space\relax\vp@geref}% + {\let\vref@space\space\vp@geref}} +\def\vp@geref{\@ifnextchar[% + \@vpageref{\@vpageref[\reftextcurrent]}% +} +\let\vref@space\space +\def\@vpageref[#1]{\@ifnextchar[% + {\@@vpageref{#1}}{\@@vpageref{#1}[\unskip\vref@space]}} +\def\@@vpageref#1[#2]#3{% + \leavevmode\unskip + \global\advance\c@vrcnt\@ne + \vref@pagenum\@tempa{\the\c@vrcnt @vr}% + \vref@pagenum\@tempb{\the\c@vrcnt @xvr}% + \vref@label{\the\c@vrcnt @xvr}% + \ifx\@tempa\@tempb + \let\vref@may@loop\relax + \else + \edef\vref@may@loop{% + \noexpand\vref@err{\noexpand\vref or \noexpand\vpageref + at page boundary + \@tempb-\@tempa\space (may loop)% + }% + }% + \fi + \vrefpagenum\thevpagerefnum{#3}% + \vref@space + \ifx\@tempa\thevpagerefnum + \def\@tempc{#1}% + \ifx\@tempc\@empty + \unskip + \else + #1% + \fi + \else + #2% + \is@pos@number\thevpagerefnum + {% + \is@pos@number\@tempa + {\@tempcnta\@tempa + \advance\@tempcnta\@ne + }% + {\@tempcnta\maxdimen}% + \ifnum \thevpagerefnum =\@tempcnta + \ifodd\@tempcnta + \if@twoside + \reftextfaceafter + \else + \reftextafter + \fi + \else + \reftextafter + \fi + \else + \advance\@tempcnta-2 + \ifnum \thevpagerefnum =\@tempcnta + \ifodd\@tempcnta + \reftextbefore + \else + \if@twoside + \reftextfacebefore + \else + \reftextbefore + \fi + \fi + \else + \let\vref@may@loop\relax % added + \reftextfaraway{#3}% + \fi + \fi + }% + {% + \let\vref@may@loop\relax %added + \reftextfaraway{#3}}% + \fi + \vref@label{\the\c@vrcnt @vr}% + \vref@may@loop +} +\def\vref@label#1{\@bsphack + \protected@write\@auxout{}% + {\string\newlabel{#1}{{}{\thepage}}}% + \@esphack} +\let\thevpagerefnum\@empty +\def\vrefwarning{\def\vref@err{\PackageWarning{varioref}}} +\def\vrefshowerrors{\def\vref@err##1{\PackageError{varioref}{##1}% + {Please check the pages in question. You might need to replace + the \string\vref\MessageBreak + or \noexpand\vpageref by a normal \noexpand\(page)ref to + stop LaTeX running forever.}}} +\DeclareRobustCommand\vref{\@ifstar + {\let\vref@space\relax\vr@f}% + {\let\vref@space\nobreakspace\vr@f}} +\def\vr@f#1{% + \leavevmode\unskip\vref@space + \ref{#1}% + \vpageref[\unskip]{#1}} +\def\is@pos@number#1{\is@pos@num0#1\space\@nil} +\def\is@pos@num{\afterassignment\is@pos@num@ \count@} +\def\is@pos@num@#1\@nil{% + \ifx\@nil#1\@nil + \expandafter\@firstoftwo \else + \expandafter\@secondoftwo \fi} +\def\reftextvario#1#2{\ifodd\c@vrcnt #1\else#2\fi} +\def\fullref#1{\ref{#1} \reftextfaraway{#1}} +\def\vref@pagenum#1#2{% + \@ifundefined{r@#2}{\@namedef{r@#2}{{??}{??}}}{}% + \expandafter\expandafter\expandafter\vref@@pagenum + \csname r@#2\endcsname{}{}\@nil#1% +} +\def\vref@@pagenum#1#2#3\@nil#4{% + \def#4{#2}% +} +\def\vrefpagenum#1#2{% + \@ifundefined{r@#2}% + {\G@refundefinedtrue + \@latex@warning{Reference `#2' on page \thepage \space + undefined}}{}% + \vref@pagenum{#1}{#2}} +\newcommand\@svpagerefrange[3][\reftextcurrent]{% + \vrefpagenum\@tempa{#2}% + \vrefpagenum\@tempb{#3}% + \ifx\@tempa\@tempb + \vpageref*[{#1}]{#2}% + \else + \reftextpagerange{#2}{#3}% + \fi +} +\newcommand\@vpagerefrange[3][\reftextcurrent]{% + \vrefpagenum\@tempa{#2}% + \vrefpagenum\@tempb{#3}% + \ifx\@tempa\@tempb + \vpageref[{#1}]{#2}% + \else + \reftextpagerange{#2}{#3}% + \fi +} +\newcommand\vpagerefrange{\@ifstar\@svpagerefrange\@vpagerefrange} +\newcommand\vrefrange[3][\reftextcurrent] + {\reftextlabelrange{#2}{#3} \vpagerefrange[{#1}]{#2}{#3}} +\def\refstepcounter#1{\stepcounter{#1}% + \protected@edef\@currentlabel + {\csname p@#1\expandafter\endcsname\csname the#1\endcsname}% +} +\def\labelformat#1{\expandafter\def\csname p@#1\endcsname##1} +\DeclareRobustCommand\Ref[1]{\protected@edef\@tempa{\ref{#1}}% + \expandafter\MakeUppercase\@tempa} +\DeclareRobustCommand\Vref{\@ifstar + {\let\vref@space\relax\Vr@f}% + {\let\vref@space\nobreakspace\Vr@f}} +\def\Vr@f#1{% + \leavevmode\unskip\vref@space + \Ref{#1}% + \vpageref[\unskip]{#1}} +\endinput +%% +%% End of file `varioref.sty'. diff --git a/macros/latex-dev/required/tools/varioref.dtx b/macros/latex-dev/required/tools/varioref.dtx new file mode 100644 index 0000000000..049bd0d55e --- /dev/null +++ b/macros/latex-dev/required/tools/varioref.dtx @@ -0,0 +1,2447 @@ +% \iffalse meta-comment +% +% Copyright (C) 1993-2019 +% +% The LaTeX3 Project and any individual authors listed elsewhere +% in this file. +% +% This file is part of the Standard LaTeX `Tools Bundle'. +% ------------------------------------------------------- +% +% It may be distributed and/or modified under the +% conditions of the LaTeX Project Public License, either version 1.3c +% of this license or (at your option) any later version. +% The latest version of this license is in +% https://www.latex-project.org/lppl.txt +% and version 1.3c or later is part of all distributions of LaTeX +% version 2008 or later. +% +% The list of all files belonging to the LaTeX `Tools Bundle' is +% given in the file `manifest.txt'. +% +% \fi +% \iffalse +%% Package varioref to use with LaTeX2e +%% Copyright (C) 1992-2019 Frank Mittelbach, all rights reserved. +%% +%% For additions or updates to the language options please contact +%% the author at +%% +%% frank.mittelbach@latex-project.org +%% +%% or open an issue at https://github.com/latex3/latex2e. +%% +% +%<package>\NeedsTeXFormat{LaTeX2e}[1995/05/16] +%<package>\providecommand\DeclareRelease[3]{} +%<package>\providecommand\DeclareCurrentRelease[2]{} +%<package> +%<package>\DeclareRelease{}{2016-02-16}{varioref-2016-02-16.sty} +%<package>\DeclareCurrentRelease{}{2019-10-01} +%<package> +%<package>\ProvidesPackage{varioref} +%<package> [2019/09/08 v1.6b package for extended references (FMi)] +% \fi +% +%% +% +% +% \changes{v1.0a}{1993/12/06}{Upgrade to LaTeX2e} +% \changes{v1.0g}{1994/05/27}{Use \cmd\DeclareRobustCommand} +% \changes{v1.5c}{2016/02/09}{Revamped some of the documentation to better +% explain how varioref could be used in a multi-lingual context} +% \changes{v1.6a}{2019/08/25}{\cs{labelformat} and \cs{Ref} now available in the kernel +% so removed from this package but only in new kernel} +% +% +% \newcommand\NewIn[1]{\marginpar{\fbox{\fbox{\sffamily\tabular{l}New +% in\\#1\endtabular}}}} +% \newcommand\ChangedIn[1]{\marginpar{\fbox{\fbox{\sffamily\tabular{l}Changed +% in\\#1\endtabular}}}} +% +% \providecommand\pkg[1]{\texttt{#1}} +% \providecommand\option[1]{\texttt{#1}} +% \providecommand\meta[1]{$\langle§\textit{#1}$\rangle$} +% +% +% \makeatletter +% \def\allowtofu{^^A +%\def\UTFviii@undefined@err##1{^^A +% \PackageWarning{inputenc}{Unicode character \expandafter +% \UTFviii@splitcsname\string##1\relax +% \MessageBreak +% not set up for use with LaTeX}^^A +% \raisebox{.8pt}{\fboxsep1pt\kern.1pt\fbox{$\cdot$}\kern.1pt}^^A +% }} +% \makeatother +% +% \title{The \pkg{varioref} package\thanks{This file +% has version number \fileversion, last +% revised \filedate.}} +% \author{Frank Mittelbach} +% \date{\filedate} +% +% \MaintainedByLaTeXTeam{tools} +% \maketitle +% +% +% \begin{abstract} +% This package defines the commands |\vref|, |\vpageref|, +% |\vrefrange|, and |\vpagerefrange| for +% \LaTeXe. |\vref| is similar to |\ref| but adds an additional +% page reference, like `on the facing page' or `on page 27' whenever +% the corresponding |\label| is not on the same page. The command +% |\vpageref| is a variation to |\pageref| with a similar +% functionality. The |\v...range| commands take two labels as arguments +% and produce strings which depend on whether or not these labels +% fall onto a single page or on different pages. +% Generated strings are customizable so that these +% commands are usable with various languages. +% \end{abstract} +% +% +% \columnsep=2\columnsep +% \begin{multicols}{2} +% \tableofcontents +% \end{multicols} +% +% \section{Introduction} +% +% In many cases it is helpful when referring to a figure or table to +% put both a |\ref| and a |\pageref| command into the document +% especially when there are one or more pages between the reference +% and the object. Therefore some people use a command like +% \begin{verbatim} +% \newcommand{\fullref}[1]{\ref{#1} on page~\pageref{#1}} +%\end{verbatim} +% which reduces the number of key strokes, necessary to make such a +% complete reference. But since one never knows where the referenced +% object finally falls, using such a device may result in a page +% reference to the current page which is disturbing and therefore +% should be avoided. +% +% +% +% \section{Loading the package} +% +% +% The suggested way of loading the package these days is by +% \emph{always} using +% the package option \option{nospace}, +% \NewIn{2019} +% i.e., +% \begin{verbatim} +% \usepackage[nospace]{varioref} +%\end{verbatim} +% See below for an explanation of why this is needed. There are some +% other options that you may want to use additionally; they are +% explained \vpageref{options}. +% +% +% +% \section{The user interface} +% +%\DescribeMacro\vref The implementation of |\vref| below produces only +% a |\ref| when reference and |\label| are on the same page. It will +% additionally produce one of the strings `on the facing page', `on +% the preceding page', or `on the following page', if label and +% reference differ by one and it will produce both |\ref| and +% |\pageref| when the difference is larger. The word `facing' is used +% when label and reference both fall onto a double spread. However, +% if a special page numbering scheme is used instead of the usual +% arabic numbering (e.g., |\pagenumbering{roman}|) then there will be +% no distinction between one or many pages off. +% +%\DescribeMacro\vpageref Sometimes one wants to refer only to page +% number and again such a reference should normally be suppressed if +% we are referring to the current page. For this purpose the package +% defines the |\vpageref| command. It will produce the same strings as +% |\vref| except that it doesn't start with the |\ref|. A further +% difference is that +% it will produce the string that is saved in |\reftextcurrent| if +% label and reference fall onto the same page (and no optional +% argument is used). By defining +% |\reftextcurrent| to produce ``on this page'' or something similar, +% we can avoid that +% \begin{verbatim} +% ... see the example \vpageref{ex:foo} which shows ... +%\end{verbatim} +% comes out as ``\ldots~see the example which shows~\ldots'', which +% could be misleading. +% +% A space in front of |\vpageref| it will be ignored if +% the command doesn't produce any text at all. +% +% But in fact |\vpageref| allows even more control. If has two +% optional arguments. With the first one, one can specify the text +% that should be used if label and reference fall on the same page. +% This is very helpful if both are near to each other, so that they +% may or may not be separated by a page break. In such a case we +% usually know (!) whether the reference is before or after the label +% so that we can say something like +% \begin{verbatim} +% ... see the example \vpageref[above]{ex:foo} which shows ... +%\end{verbatim} +% which will then come out as ``\ldots~see the example above which +% shows~\ldots'' if we are still on the same page, but as ``\ldots~see +% the example on the page before which shows~\ldots'' (or something +% similar depending on the settings of the |\reftext..before| +% commands) when there was a page break in the meantime. One warning +% however, if you use |\vpageref| with the optional argument to refer +% to a figure or table, keep in mind that depending on the float +% placement parameters the float may show up on top of the current +% page and therefore before the reference even if it came after it in +% the source file. +% +% But maybe you prefer to say ``\ldots~see the above example'' if +% example and reference fall onto the same page, i.e., reverse the +% word order. In fact, in some languages the word order automatically +% changes in that case. To allow for this variation the second +% optional argument can be used. It specifies the text preceding the +% generated reference if object and reference do not fall onto the +% same page. Thus one would write +% \begin{verbatim} +% ... see the \vpageref[above example][example]{ex:foo} +% which shows ... +%\end{verbatim} +% to achieve the desired effect. +% +% +% \DescribeMacro\vrefrange +% This command is similar to |\vref| but it +% takes two mandatory arguments denoting a range to refer to (e.g., a +% sequences of figures or a sequence of equations, etc.). So if +% |fig:a| is your first figure in the sequence and |fig:c| your last +% you can write +%\begin{verbatim} +% ... see figures \vrefrange{fig:a}{fig:c} ... +%\end{verbatim} +% which would then be formatted as +% \begin{quote} +% \ldots\ see figures 3.4 to 3.6 on pages 23--24 \ldots +% \end{quote} +% or, if they happen to all fall onto the next page, as +% \begin{quote} +% \ldots\ see figures 3.4 to 3.6 on the following page \ldots +% \end{quote} +% i.e., the command is deciding what to say depending on where the two +% labels are placed in relation to each other; it is essentially +% implemented using |\vpagerefrange| described below. +% The optional argument the command may take is the text to use in case +% both labels are placed on the current page. +% +% +% \DescribeMacro\vpagerefrange This command is similar to |\vpageref| +% but takes two mandatory arguments which are two labels denoting a +% range. If both labels fall onto the same page, the command acts +% exactly like |\vpageref| (with a single label), otherwise it produces +% something like ``on pages~15--18'' (see customization possibilities +% below). The optional argument it may take is the text to use in case +% both labels are placed on the current page. + +% \DescribeMacro\vrefpagenum This macro is provided to allow the user +% to write their own small commands which implement functions similar +% to those provided by the two previous commands. It takes two +% arguments: the second is a label (i.e., as used in |\label| or +% |\ref|) and the first is an arbitrary command name (make sure you +% use our own) that receives the page number related to this label. +% So if you have two (or more) labels you could retrieve their page +% numbers, compare them and then decide what to print. For example, +% the following not very serious definition (also using the +% \pkg{ifthen} package) +%\begin{verbatim} +% \newcommand\amusingversion[2]{the definition% +% \vrefpagenum\firstnum{#1}% +% \vrefpagenum\secondnum{#2}% +% \ifthenelse{\equal\firstnum\secondnum}% +% {s of \ref{#1} and \ref{#2} \vpageref{#1}}% +% { of \ref{#1} \vpageref{#1} and of \ref{#2} \vpageref{#2}}% +% } +% +% ...\amusingversion{foo}{bar} +%\end{verbatim} +% will print something like +% \begin{quote} +% \ldots the definitions of 3 and 4 on the previous page +% \end{quote} +% in the case both labels are on the same page but something like +% \begin{quote} +% \ldots the definition of 3 on the next page and of 4 on page~13 +% \end{quote} +% in case they are on different pages. +% +% \DescribeMacro\vpagerefcompare +% \NewIn{2019} +% For this kind of application the package also provides +% |\vpagerefcompare| as a command that takes four argument: two labels for +% comparison and a \meta{true} and \meta{false} argument. One of them +% is executed depending on whether the two labels are on the same page +% or on different pages. With its help the above definition could be +% shortened to +%\begin{verbatim} +% \newcommand\amusingversion[2]{the definition% +% \vpagerefcompare{#1}{#2}% +% {s of \ref{#1} and \ref{#2} \vpageref{#1}}% +% { of \ref{#1} \vpageref{#1} and of \ref{#2} \vpageref{#2}}% +% } +%\end{verbatim} +% and you don't have to load the \pkg{ifthen} package any longer to +% make it work. +% +% \DescribeMacro\vpagerefnearby +% \NewIn{2019} +% Another command for conditional processing is |\vpagerefnearby|. It +% takes three arguments: a label and a \meta{true} and \meta{false} +% argument. It compares the page reference to the label with the +% current page number and if both are arabic number and only differ by +% $\pm1$ the \meta{true} argument is executed otherwise the +% \meta{false} argument. In other words it tells you if a |\vpageref| +% to the label would result in a textual reference to the previous, +% current or next page.\footnote{There is also a +% \cs{vpagerefcomparenearby} but this is only meant for package +% writers, so it is only documented in the implementation section.} + +% +% +% If you don't use the \texttt{nospace} option the user commands +% |\vref|, |\vpageref|, and |\vpagerefrange| all work by first +% removing any space on their left and then inserting some space of +% their own (|\vref|, for example, a nonbreakable space). That seemed +% like a good idea back then, but it has the disadvantage that you +% can't use these macros in situations where you definitely do not +% want any space before the generated text. E.g., in situations like +% |(\vref{foo} ...)| you end up with a space after the open +% parenthesis. +% +% \DescribeMacro{\vref*} +% \DescribeMacro{\vpageref*} +% \DescribeMacro{\vpagerefrange*} +% Since it was too late to change the default in 2001 I added star +% versions of the macros which do not add any space before the +% generated text (they do nevertheless remove space at the left). +% +% However, that too has problems (one is that \pkg{hyperref} +% \ChangedIn{2019} +% introduced the star forms as a means to generating references +% without hyperlinks (which is clearly the more important +% application). +% So these days I recommend to always call the package with the option +% \option{nospace} which prevents \pkg{varioref} from messing with the +% space in front. Of course you are then responsible to always add it +% when necessary, but that does make the source more readable so it is +% a good thing. This also has the advantage that the star forms are +% now unnecessary again and can be used in the way implemeented by +% \pkg{hyperref} if both packages are used together. +% +% In fact it would be much nicer to make that the +% default but the package has been used by many people for so many +% years that changing the default would break way to many older documents. +% +% +% \DescribeMacro\labelformat +% A reference via |\ref| produces by default the data associated with +% the corresponding |\label| command (typically a number); any +% additional formatting has to be provided by the user. With +% |\labelformat| it is possible to declare scuch formatting for each +% ``reference'' counter, e.g., +%\begin{verbatim} +% \labelformat{section}{section~#1} +% \labelformat{equation}{equation~(#1)}} +%\end{verbatim} +% +% +% \DescribeMacro\Vref +% \DescribeMacro\Ref +% A side effect of using |\labelformat| is that, depending on the +% defined formatting, it becomes impossible to use |\ref| at the +% beginning of a sentence (if its replacement text starts with a +% lowercase letter). +% \ChangedIn{2019} +% For that reason \pkg{varioref} provided the commands |\Ref| and +% |\Vref|. They behave like |\ref| and |\vref| except that they +% uppercase the first token of the generated string. These days +% |\labelformat| and |\Ref| are already provided by the \LaTeX{} +% kernel; only |\Vref| is still defined within the \pkg{varioref} +% package. +% +% To make |\Ref| or |\Vref| work properly the very first token in the +% second argument of |\labelformat| has to be a simple \textsc{ascii} +% or UTF-8 letter, otherwise the capitalization will fail or worse, +% you will end up with some error messages. If you actually need +% something more complicated in this place (e.g., an accented letter +% not written as a UTF-8 character) you have to explicitly surround it +% with braces, to identify the part that needs to be capitalized. For +% example, for figure references in the Hungarian language you might +% want to write |\labelformat{figure}{{\'a}bra~\thefigure}| or use +% |\labelformat{figure}{ábra~\thefigure}| which avoids the brace +% problem. +% +% \DescribeMacro\thevpagerefnum +% If you like to have |\vref| suppress the page number on pages where +% label and reference fall onto the same page, but prefer reference to +% page numbers otherwise then |\thevpagerefnum| can be used. This macro +% hold the current page ``number'' when |\vpageref| and friends are +% executed. Thus, by defining, for example +%\begin{verbatim} +%\renewcommand\reftextfaceafter {on page~\thevpagerefnum} +%\renewcommand\reftextfacebefore{on page~\thevpagerefnum} +%\renewcommand\reftextafter {on page~\thevpagerefnum} +%\renewcommand\reftextbefore {on page~\thevpagerefnum} +%\end{verbatim} +% textual references can be suppressed. +% +% \section{Multi-lingual usage} +% +% The package works well together with the babel system if it is +% loaded \textit{after} the babel package, e.g., a document in English +% (default), French and German text could load the packages as +% follows: +%\begin{verbatim} +% \usepackage[ngerman,french,english]{babel,varioref} +%\end{verbatim} +% (or in two separate lines if you prefer one |\usepackage| line per +% package). Depending on the current babel language |\vref| and +% friends would then generate strings in different languages. If the +% language options are given as global options to the document class +% then it is enough to use +%\begin{verbatim} +% \usepackage{babel,varioref} +%\end{verbatim} +% to achieve the same effect. +% +% If more than one language is specified with \pkg{varioref} then +% it will start using the last language selected. Switching of +% languages is managed through Babel; nevertheless all languages of +% interest need to be specified when \pkg{varioref} is loaded so +% that it can integrate their strings into the Babel system. +% +% +% \section{Customization} +% +% The package supports all options defined by the babel package to +% translate the fixed strings into other languages than English. +% (Some languages need updating, however---help is appreciated.) It +% also supports languages currently not in babel (those can only be +% used standalone, obviously); check the section on options later~on. +% +% +% \pagebreak[3] +% +% You can also modify some or all of the strings by redefining the +% following commands after the package has been loaded. +%\DescribeMacro\reftextbefore +%\DescribeMacro\reftextfacebefore +%\DescribeMacro\reftextafter +%\DescribeMacro\reftextfaceafter Backward references use +% |\reftextbefore| if the label is on the preceding page but invisible +% and |\reftextfacebefore| if it is one the facing page (i.e., if the +% current page number is odd). Similarly |\reftextafter| is used +% when the label comes on the next page but one has to turn the page +% and |\reftextfaceafter| if it is on the following but facing page. +% +% In fact, |\reftextface...| is used only if the user or the document +% class specified two-sided printing. +% +%\DescribeMacro\reftextfaraway Finally we have |\reftextfaraway| which +% is used whenever label and reference differ by more than one or when +% they aren't numeric. This macro is a bit different because it takes +% one argument, the symbolic reference string so that one cane make +% use of |\pageref| in its replacement text. +% +% +%\DescribeMacro\reftextvario To allow a bit random variation in the +% generated strings one can use the command |\reftextvario| inside the +% string macros. It takes two arguments and selects one or the other +% for printing depending on the number of already seens |\vref| or +% |\vpageref| commands. As an example see the definitions of +% |\reftextbefore| etc.\ \vpageref[below]{reftextbefore}. +% +% The commands |\vrefrange| and |\vpagerefrange| produce their text +% \NewIn{1998} +% using two macros described below. By redefining them one can modify +% the results to accommodate special requirements. +% +% +% They both take two mandatory arguments denoting the first and the +% last label of the range. +% +% +% \DescribeMacro\reftextpagerange This macro produces text that +% describes the page range of the two labels, e.g., the default +% for English is ``|on pages~\pageref{#1}--\pageref{#2}}|''. +% +% +% \DescribeMacro\reftextlabelrange This macro produces text that +% describes the range of figures, tables, or whatever the labels refer +% to, the default for English is ``|\ref{#1} to~\ref{#2}|''. +% +% \subsection{\ldots\ if Babel is used} +% +% \begin{itshape} If babel is being used then the above commands need to be +% changed using the Babel mechanism, e.g., +%\begin{verbatim} +% \addto\extrasngerman{% +% \renewcommand\reftextfaceafter {auf der n\"achsten Seite}% +% ... } +%\end{verbatim} +% Otherwise babel will reintroduce its own defaults whenever the language is +% changed (which happens in particular during |\begin{document}| where the +% main language is selected). +% \end{itshape} +% +% +% +% +% \section{Options} \label{options} +% +% As mentioned above the package supports all standard options offered +% by the Babel system to customize the strings produced, it may also +% have a few not supported by babel, for a full list look +% in section\vref{sec:impoptions}. In addition it offers the option +% \texttt{draft} to turn error messages into warnings during +% development. The default \texttt{final} produces error message when +% a generated string falls onto a page boundary (see next section). +% +% Newly introduced in 2019 are the options \option{space} (default) +% and \option{nospace}. While the former is the default to allow +% \NewIn{2019} +% documents written in the last twenty years to continue to work +% correctly, I nowadays, suggest that you always use the package with +% the option \option{nospace}. This will stop \pkg{varioref} from +% meddling with the spaces preceding commands and thus make the star +% forms |\vref*| and |\vpageref*| unnecessary. +% +% This means that the star forms can then be used as defined by +% \pkg{hyperref} for suppressing a hyperlink when both packages are +% used together (which is a rather typical scenario these days). +% +% +% \section{A few warnings} +% +% Defining commands like the ones described above poses some +% interesting problems. Suppose, for example, that a generated text +% like `on the next page' gets broken across pages. If this happens it +% is very difficult to find an acceptable solution and in fact can +% even result in a document that will always change from one state to +% another (i.e., inserting one string, finding that this is wrong, +% inserting another string on the next run which makes the first +% string correct again, inserting \ldots). The current implementation +% of \pkg{varioref} therefore issues an error message whenever the +% generated text is broken across page boundaries, e.g., +% \begin{quote} +% table 5 on the current \meta{page break} page +% \end{quote} +% would would result in an error, which needs to be resolved by the +% user by replacing the |\vref| command with an ordinary |\ref| just +% before the final run. This is not +% completely satisfactory but in such case no solution really is. +% \DescribeMacro\vrefwarning +% During document preparation, while one is still changing the text, +% such error messages can be turned into warnings by placing a +% |\vrefwarning| command in the preamble. This is equivalent to +% specifying ``draft'' as an option to the package. +% \DescribeMacro\vrefshowerrors +% |\vrefshowerrors| ensures that varioref stops when detecting a +% possible loop. This is the default and equivalent to specifying +% ``final'' as an option. +% +% At the end final a warning: every use of |\vref| will internally +% generate two macro names to keep track of the string positions +% within the document. As a result you may run out of name space or +% main memory\footnote{Not really that likely these days, but one +% never knows \ldots. In any case \TeX{} will process your document a +% tiny bit faster.} if you make heavy use of this macro on a small +% \TeX{} installation. +%\DescribeMacro\fullref For this reason the primitive command +% |\fullref| is also provided. This command can be used whenever you +% know for sure that label and reference can't fall onto nearby pages. +% +% \StopEventually{\PrintIndex\PrintChanges} +% +% +% \section{The documentation driver file} +% +% The next bit of code contains the documentation driver file for +% \TeX{}, i.e., the file that will produce the documentation you are +% currently reading. It will be extracted from this file by the +% \pkg{docstrip} program. +% \begin{macrocode} +%<*driver> +\documentclass{ltxdoc} +\usepackage{multicol,varioref} +\GetFileInfo{varioref.sty} +\setlength\hfuzz{1pt} % ignore slight overfulls +\EnableCrossrefs +%\DisableCrossrefs % Say \DisableCrossrefs if index is ready + +\RecordChanges % Gather update information +%\OnlyDescription % comment out for implementation details +\begin{document} + \DocInput{varioref.dtx} +\end{document} +%</driver> +% \end{macrocode} +% +% +% \section{The implementation} +% +% The main implementation idea is to generate an internal label +% command for every |\vpageref| and compare the page reference of this +% label with the page reference of the user-requested label. Since +% this means one additional macro name for each use of |\vpageref| or +% |vref| (which is implemented in terms of |\vpageref|) the memory +% requirements of this package may be high in terms of main and macro +% name memory. Since the information held in the internal labels is +% used only once one could envision a different scheme if suitable +% primitives for this kind of ``one place information'' would be +% provided by \LaTeX. This type of data structure is planned for +% \LaTeX3 but for the moment we have to live with the memory +% restrictions. +% +% We start by checking if this file was already loaded. If not we +% identify the current version. This is actually done at the top +% of the file, so we comment it out here +% \changes{v0.1h}{1993/08/15}{Small documentation changes} +% \begin{macrocode} +%<*package> +%\NeedsTeXFormat{LaTeX2e}[1994/06/01] +%\ProvidesPackage{varioref}[\filedate\space\fileversion\space +% LaTeX2e package for extended references (FMi)] +% \end{macrocode} +% +% +% \begin{macro}{\vref@addto} +% \changes{v1.0b}{1994/01/31}{Avoid using babel `addto} +% \changes{v1.0b}{1994/01/31}{The babel commands are starting +% with extras} +% To support the use of babel we want to add the additional strings +% to the |\extras|\meta{language} commands. Since |\addto| in the +% current implementation of babel has a bug that does not allow to +% use arguments containing hashmarks we do this by hand. +% \begin{macrocode} +\def\vref@addto#1#2{% + #2% + \@temptokena{#2}% + \ifx#1\undefined + \edef#1{\the\@temptokena}% + \else + \toks@\expandafter{#1}% + \edef#1{\the\toks@\the\@temptokena}% + \fi + \@temptokena{}\toks@\@temptokena +} +\@onlypreamble\vref@addto +% \end{macrocode} +% \end{macro} +% +% +% \subsection{Options}\label{sec:impoptions} +% +% \begin{macro}{\vref@excuse} +% Excuse that we don't know the strings for a certain language. +% \changes{v1.0q}{1995/04/06}{Use `PackageWarning} +% \begin{macrocode} +\def\vref@excuse#1{% + \PackageWarningNoLine{varioref}{Sorry, language `#1' + not supported% + \MessageBreak + in this version. + English strings used by default. + \MessageBreak + Please modify \protect\reftext... commands manually.% + \MessageBreak\MessageBreak + If you can suggest translations for + this language,% + \MessageBreak + please mail them + to the author of this package}} +\@onlypreamble\vref@excuse +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\vref@stringwarning} +% And we sometimes just don't know some strings~\ldots +% \changes{v1.2a}{1998/08/01}{Macro added} +% \begin{macrocode} +\def\vref@stringwarning#1{% + \PackageWarningNoLine{varioref}{Sorry, there is no proper + translation for the string\MessageBreak + produced by \protect#1\on@line.\MessageBreak + English string used instead.\MessageBreak + \MessageBreak + If you can suggest translations for + the current\MessageBreak + language, please mail them + to the author of this\MessageBreak package}} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\reftextfaceafter} +% \begin{macro}{\reftextfacebefore} +% \begin{macro}{\reftextafter} +% \begin{macro}{\reftextbefore} +% \begin{macro}{\reftextcurrent} +% \label{reftextbefore} The options do set the macros that +% generate the textual strings. Note, that they do not start with a +% space, the space is already added in the main macro below. +% \changes{v1.2a}{1998/08/22}{Added american defaults for +% \cs{reftextpagerange} and \cs{reftextlabelrange}} +% \changes{v1.4d}{2002/11/11}{Changed default for \cs{reftextbefore}} +% +% Afrikaans option contributed by Danie Els +% (\texttt{dnjels@sun.ac.za}). +% \changes{v1.4g}{2003/03/29}{Added afrikaans option} +% \begin{macrocode} +\DeclareOption{afrikaans} + {\vref@addto\extrasafrikaans{% + \def\reftextfaceafter {op die \reftextvario{regterbladsy}% + {bladsy langsaan}}% + \def\reftextfacebefore{op die \reftextvario{linkerbladsy}% + {bladsy langsaan}}% + \def\reftextafter {op die \reftextvario{volgende bladsy}% + {bladsy hierna}}% + \def\reftextbefore {op die \reftextvario{vorige bladsy}% + {bladsy hiervoor}}% + \def\reftextcurrent {op \reftextvario{hierdie}% + {die huidige} bladsy}% + \def\reftextfaraway#1{op bladsy~\pageref{#1}}% + \def\reftextpagerange#1#2{op bladsye~\pageref{#1}--\pageref{#2}}% + \def\reftextlabelrange#1#2{\ref{#1} tot~\ref{#2}}% + }} +% \end{macrocode} +% +% \begin{macrocode} +\DeclareOption{american} + {\vref@addto\extrasamerican{% + \def\reftextfaceafter {on the \reftextvario{facing}{next} page}% + \def\reftextfacebefore{on the \reftextvario{facing}{preceding} + page}% + \def\reftextafter {on the \reftextvario{following}{next} page}% + \def\reftextbefore {on the \reftextvario{preceding}{previous} page}% + \def\reftextcurrent {on \reftextvario{this}{the current} page}% + \def\reftextfaraway#1{on page~\pageref{#1}}% + \def\reftextpagerange#1#2{on pages~\pageref{#1}--\pageref{#2}}% + \def\reftextlabelrange#1#2{\ref{#1} to~\ref{#2}}% + }} +% \end{macrocode} +% Arabic option text was contributed by Ihab Samir Mattar +% (\texttt{dr\_kremlin@hotmail.com}). As our standard documentation +% workflow uses pdf\TeX{} the Arabic letters can't be displayed +% easily, so you will see missing glyphs below. To see the real +% letters you have to look at the source or package file. +% \changes{v1.6b}{2019/09/8}{Option arabic added} +% \begin{allowtofu} +% \begin{macrocode} +\DeclareOption{arabic} + {\vref@addto\extrasarabic{% + \def\reftextfaceafter {بالصÙØØ© \reftextvario{المقابلة}{اللاØقة}}% + \def\reftextfacebefore{بالصÙØØ© \reftextvario{المقابلة}{المÙنْصَرÙÙ…ÙŽØ©ÙŒ}}% + \def\reftextafter {بالصÙØØ© \reftextvario{اللاØقة}{التالية}}% + \def\reftextbefore {بالصÙØØ© \reftextvario{السابقة}{المÙنْصَرÙÙ…ÙŽØ©ÙŒ}}% + \def\reftextcurrent {ب\reftextvario{الصÙØØ© الØالية}{هذه الصÙØØ©}}% + \def\reftextfaraway#1{بالصÙØØ© رقم~\pageref{#1}}% + \def\reftextpagerange#1#2{بالصÙØات~\pageref{#1}--\pageref{#2}}% + \def\reftextlabelrange#1#2{\ref{#1} Øتى~\ref{#2}}% + }} +% \end{macrocode} +% \end{allowtofu} +% \changes{v1.2a}{1998/11/27}{Added austrian defaults (identical to german)} +% The austrian defaults are the same as the german ones. +% \begin{macrocode} +\DeclareOption{austrian} + {\vref@addto\extrasaustrian{% + \def\reftextfaceafter {auf der n\"achsten Seite}% + \def\reftextfacebefore{auf der vorherigen Seite}% + \let\reftextafter \reftextfaceafter + \let\reftextbefore \reftextfacebefore + \def\reftextcurrent {auf dieser Seite}% + \def\reftextfaraway#1{auf Seite~\pageref{#1}}% + \def\reftextpagerange#1#2{auf Seiten~\pageref{#1}--\pageref{#2}}% + \def\reftextlabelrange#1#2{\ref{#1} bis~\ref{#2}}% + }} +% \end{macrocode} +% \changes{v1.2d}{2000/01/11}{Added naustrian defaults (identical to german)} +% The naustrian defaults are the same but needed for ``Neue Rechtschreibung''. +% \begin{macrocode} +\DeclareOption{naustrian} + {\vref@addto\extrasnaustrian{% + \def\reftextfaceafter {auf der n\"achsten Seite}% + \def\reftextfacebefore{auf der vorherigen Seite}% + \let\reftextafter \reftextfaceafter + \let\reftextbefore \reftextfacebefore + \def\reftextcurrent {auf dieser Seite}% + \def\reftextfaraway#1{auf Seite~\pageref{#1}}% + \def\reftextpagerange#1#2{auf Seiten~\pageref{#1}--\pageref{#2}}% + \def\reftextlabelrange#1#2{\ref{#1} bis~\ref{#2}}% + }} +% \end{macrocode} +% Text for basque defaults was contributed by +% I\~naki Larra\~naga Murgoitio (aka dooteo) +% (|<dooteo@euskalgnu.org>|). +% \changes{v1.4k}{2005/04/09}{Basque defaults added.} +% \begin{macrocode} +\DeclareOption{basque} + {\vref@addto\extrasbasque{% + \def\reftextfaceafter {hurrengo orrialdean}% + \def\reftextfacebefore{aurreko orrialdean}% + \let\reftextafter \reftextfaceafter + \let\reftextbefore \reftextfacebefore + \def\reftextcurrent {uneko orrialdean}% + \def\reftextfaraway#1{~\pageref{#1}. orrialdean}% + \def\reftextpagerange#1#2{~\pageref{#1}--\pageref{#2} orrialdeetan}% + \def\reftextlabelrange#1#2{\ref{#1}.etik \ref{#2}.eraino}% + }} +% \end{macrocode} +% Text for the Bahasa Malaysia defaults was contributed by +% Bob Margolis 2005-12-02. +% +% Notes: pada muka surat translates as ``on the page'' though BM has no +% definite (or indefinite) article; adjectives and other modifiers follow +% the noun (clause); bertentangan is ``opposite'' in the sense of +% ``facing''; berikutnya is ``next'' (in this context - actually +% next-to-this, literally); berikutnya also translates as ``following +% this'' sebelumnya is ``preceding''; also ``previous'' ``ini'' translates, +% literally, as ``this'' but is also used in the sense of current page. +% \changes{v1.4o}{2005/12/02}{Bahasa Malaysia defaults added.} +% \begin{macrocode} +\DeclareOption{bahasam} + {\vref@addto\extrasbahasam{% + \def\reftextfaceafter {pada muka surat \reftextvario{bertentangan}{berikutnya}}% + \def\reftextfacebefore{pada muka surat \reftextvario{bertentangan}{sebelumnya} }% + \def\reftextafter {pada muka surat berikutnya}% + \def\reftextbefore {pada muka surat sebelumnya}% + \def\reftextcurrent {pada muka surat ini}% + \def\reftextfaraway#1{pada muka surat~\pageref{#1}}% + \def\reftextpagerange#1#2{pada muka surat~\pageref{#1}--\pageref{#2}}% + \def\reftextlabelrange#1#2{\ref{#1}--\ref{#2}}% + }} +% \end{macrocode} +% Text for brazil defaults was contributed by +% Alcino Dall Igna Junior\\ +% (|adij@di.ufpe.br|). +% \changes{v1.0g}{1994/05/18}{Brazil defaults added.} +% \changes{v1.4o}{2005/11/07}{Added a few more brazil strings} +% \changes{v1.4r}{2007/05/26}{Misspelling of \cs{extrasbrazil}} +% \begin{macrocode} +\DeclareOption{brazil} + {\vref@addto\extrasbrazil{% + \def\reftextfaceafter {na \reftextvario{p\'agina oposta}{pr\'oxima + p\'agina}}% + \def\reftextfacebefore{na p\'agina \reftextvario{oposta}{anterior}}% + \def\reftextafter {na \reftextvario{p\'agina seguinte}{pr\'oxima + p\'agina}}% + \def\reftextbefore{na p\'agina \reftextvario{anterior}{precedente}}% + \def\reftextcurrent {\reftextvario{nesta p\'agina}{na p\'agina + corrente}}% + \def\reftextfaraway#1{na p\'agina~\pageref{#1}}% + \def\reftextpagerange#1#2{nas p\'aginas~\pageref{#1}--\pageref{#2}}% + \def\reftextlabelrange#1#2{\ref{#1} a~\ref{#2}}% + }} +% \end{macrocode} +% Text for Breton defaults was contributed by +% Christian ROLLAND\\ +% (|Christian.Rolland@univ-brest.fr|). +% \changes{v1.0o}{1994/09/27}{Added defaults for breton} +% \begin{macrocode} +\DeclareOption{breton} + {\vref@excuse{breton}% + \vref@addto\extrasbreton{% + \def\reftextfaceafter {war ar bajenn \reftextvario{a-dal}{da heul}}% + \def\reftextfacebefore{war ar bajenn \reftextvario{a-dal}{a-raok}}% + \def\reftextafter {war ar bajenn da heul}% + \def\reftextbefore {war ar bajenn a-raok}% + \def\reftextcurrent {war ar \reftextvario{bajenn-ma\~n}% + {bajenn war-wel}}% + \def\reftextfaraway#1{war ar bajenn~\pageref{#1}}% + \def\reftextpagerange#1#2{\vref@stringwarning\reftextpagerange + on pages~\pageref{#1}--\pageref{#2}}% + \def\reftextlabelrange#1#2{\vref@stringwarning\reflabelpagerange + \ref{#1} to~\ref{#2}}% + }} +% \end{macrocode} +% Text for Bulgarian defaults was contributed by +% Georgi Boshnakov\\ (|georgi.boshnakov@gmail.com|). +% \changes{v1.4q}{2006/05/23}{Added defaults for bulgarian} +% \begin{macrocode} +\DeclareOption{bulgarian}% + {\vref@addto\extrasbulgarian{% + \def\reftextfaceafter{\cyrn\cyra\ + \reftextvario{\cyrs\cyrery\cyrs\cyre\cyrd\cyrn\cyra\cyrt\cyra}% + {\cyrs\cyrl\cyre\cyrd\cyrv\cyra\cyrshch\cyra\cyrt\cyra} + \cyrs\cyrt\cyrr\cyra\cyrn\cyri\cyrc\cyra}% + \def\reftextfacebefore{\cyrn\cyra\ + \reftextvario{\cyrs\cyrery\cyrs\cyre\cyrd\cyrn\cyra\cyrt\cyra}% + {\cyrp\cyrr\cyre\cyrd\cyrn\cyra\cyrt\cyra} + \cyrs\cyrt\cyrr\cyra\cyrn\cyri\cyrc\cyra}% + \def\reftextafter{\cyrn\cyra\ + \reftextvario{\cyrs\cyrl\cyre\cyrd\cyrv\cyra\cyrshch\cyra\cyrt\cyra}% + {\cyrs\cyrl\cyre\cyrd\cyrv\cyra\cyrshch\cyra\cyrt\cyra} + \cyrs\cyrt\cyrr\cyra\cyrn\cyri\cyrc\cyra}% + \def\reftextbefore{\cyrn\cyra\ + \reftextvario{\cyrp\cyrr\cyre\cyrd\cyrn\cyra\cyrt\cyra}% + {\cyrp\cyrr\cyre\cyrd\cyri\cyrsh\cyrn\cyra\cyrt\cyra} + \cyrs\cyrt\cyrr\cyra\cyrn\cyri\cyrc\cyra}% + \def\reftextcurrent{\cyrn\cyra\ + \reftextvario{\cyrt\cyra\cyrz\cyri}% + {\cyrt\cyre\cyrk\cyru\cyrshch\cyra\cyrt\cyra} + \cyrs\cyrt\cyrr\cyra\cyrn\cyri\cyrc\cyra}% + \def\reftextfaraway#1{\cyrn\cyra\ \cyrs\cyrt\cyrr\cyra\cyrn\cyri\cyrc\cyra + ~\pageref{#1}}% + \def\reftextpagerange#1#2{\cyrn\cyra\ + \cyrs\cyrt\cyrr\cyra\cyrn\cyri\cyrc\cyri + ~\pageref{#1}--\pageref{#2}}% + \def\reftextlabelrange#1#2{\ref{#1} \cyrd\cyro~\ref{#2}}% + }} +% \end{macrocode} +% Text for catalan defaults was contributed by Robert Fuster\\ +% (\verb=rfuster@mat.upv.es=). +% \changes{v1.1c}{1997/06/12}{Added defaults for catalan} +% \changes{v1.2g}{2000/08/22}{Updated defaults for catalan} +% \begin{macrocode} +\DeclareOption{catalan} + {\vref@addto\extrascatalan{% + \def\reftextfaceafter {a la p\`agina seg\"uent}% + \def\reftextfacebefore{a la p\`agina anterior}% + \let\reftextafter \reftextfaceafter + \let\reftextbefore \reftextfacebefore + \def\reftextcurrent {en aquesta p\`agina}% + \def\reftextfaraway#1{a la p\`agina~\pageref{#1}}% + \def\reftextpagerange#1#2{a les + p\`agines~\pageref{#1}--\pageref{#2}}% + \def\reftextlabelrange#1#2{\ref{#1} a~\ref{#2}}% + }} +% \end{macrocode} +% Text for croatian defaults was contributed by \v{S}ime Ungar +% (\verb=ungar@math.hr=). +% \changes{v1.4p}{2006/05/13}{Added defaults for croatian} +% \begin{macrocode} +\DeclareOption{croatian} + {\vref@addto\extrascroatian{% + \def\reftextfaceafter {na sljede\'coj stranici}% + \def\reftextfacebefore{na prethodnoj stranici}% + \let\reftextafter \reftextfaceafter + \let\reftextbefore \reftextfacebefore + \def\reftextcurrent {na ovoj stranici}% + \def\reftextfaraway#1{na stranici~\pageref{#1}}% + \def\reftextpagerange#1#2{na stranicama~\pageref{#1}--\pageref{#2}}% + \def\reftextlabelrange#1#2{\ref{#1} do~\ref{#2}}% + }} +% \end{macrocode} +% Defaults for the Czech option provided by Milan Vancura +% \verb=<milan@suse.cz>=. +% \changes{v1.2e}{2000/04/04}{Added czech defaults} +% \begin{macrocode} +\DeclareOption{czech} + {%\vref@excuse{czech}% + \vref@addto\extrasczech{% + \def\reftextfaceafter {na n\'a\-sle\-du\-j\'\i c\'\i\ stran\v{e}}% + \def\reftextfacebefore{na p\v{r}ed\-choz\'\i\ stran\v{e}}% + \def\reftextafter {na n\'a\-sle\-du\-j\'\i c\'\i\ stran\v{e}}% + \def\reftextbefore {na p\v{r}ed\-choz\'\i\ stran\v{e}}% + \def\reftextcurrent {na t\'eto stran\v{e}}% + \def\reftextfaraway#1{na stran\v{e}~\pageref{#1}}% + \def\reftextpagerange#1#2{na stran\'ach~\pageref{#1}\--\pageref{#2}}% + \def\reftextlabelrange#1#2{\ref{#1} a\v{z}~\ref{#2}}% + }} +% \end{macrocode} +% Defaults for Danish provided by Torsten Martinsen +% (\verb=tmar91@kom.auc.dk=). Further defaults by Ole Laursen +% (\verb=olau@hardworking.dk=). +% \changes{v1.0n}{1994/09/25}{Added Danish defaults} +% \changes{v1.2h}{2000/12/30}{Updates to Danish defaults} +% \begin{macrocode} +\DeclareOption{danish} + {\vref@addto\extrasdanish{% + \def\reftextfaceafter {p\aa{} \reftextvario{modst\aa ende}% + {n\ae ste} side}% + \def\reftextfacebefore{p\aa{} \reftextvario{modst\aa ende}% + {forrige} side}% + \def\reftextafter {p\aa{} \reftextvario{den f\o lgende}% + {n\ae ste} side}% + \def\reftextbefore {p\aa{} \reftextvario{forrige side} + {foreg\aa ende side}}% + \def\reftextcurrent {p\aa{} denne side}% + \def\reftextfaraway#1{p\aa{} side~\pageref{#1}}% + \def\reftextpagerange#1#2{p\aa{} side~\pageref{#1}--\pageref{#2}}% + \def\reftextlabelrange#1#2{\ref{#1} til~\ref{#2}}% + }} +% \end{macrocode} +% Default string for dutch have been contributed by Frank Poppe +% (\verb=POPPE@SWOV.NL=). +% This option currently supports one additional string macro +% |\refpagename| so that you can easily change to |bladzijde| +% instead of |pagina| if you prefer this word for ``page''. +% However, I will not guarantee that this will survive future +% versions of this package, so use it on your own risk (you can +% always update the full strings to be on the safe side). +% \changes{v1.0l}{1994/07/07}{Added dutch defaults} +% \changes{v1.2a}{1998/08/22}{Added dutch defaults for +% \cs{reftextpagerange} and \cs{reftextlabelrange}} +% \begin{macrocode} +\DeclareOption{dutch} + {\vref@addto\extrasdutch{% + \def\refpagename{pagina}% + \def\reftextfaceafter {op de \reftextvario{rechter \refpagename}% + {\refpagename\ hiernaast}}% + \def\reftextfacebefore{op de \reftextvario{linker \refpagename}% + {\refpagename\ hiernaast}}% + \def\reftextafter {op de \reftextvario{volgende \refpagename}% + {\refpagename\ hierna}}% + \def\reftextbefore {op de \reftextvario{vorige \refpagename}% + {\refpagename\ hiervoor}}% + \def\reftextcurrent {op deze \refpagename}% + \def\reftextfaraway#1{op \refpagename~\pageref{#1}}% +% \end{macrocode} +% Concerning the next defaults I received the following comment by +% Frederik Fouvry \texttt{<fouvry@coli.uni-sb.de>}: +% ``In the Dutch options (where I can exert a proper language +% judgement ;-), `t/m' is not used in formal (scientific) texts. I +% would either use `--' or `tot en met' (the abbreviation written +% out). '' +% \changes{v1.4d}{2002/11/11}{Changed default for \cs{reftextlabelrange}} +% \changes{v1.4m}{2005/06/09}{Fixed \cs{reftextlabelrange} (pr/3791)} +% \begin{macrocode} + \def\reftextpagerange#1#2{op pagina's~\pageref{#1}--\pageref{#2}}% + \def\reftextlabelrange#1#2{\ref{#1}--\ref{#2}}% + }} +% \end{macrocode} +% \changes{v1.2a}{1998/08/22}{Added english defaults for +% \cs{reftextpagerange} and \cs{reftextlabelrange}} +% \changes{v1.4d}{2002/11/11}{Changed default for \cs{reftextbefore}} +% \begin{macrocode} +\DeclareOption{english} + {\vref@addto\extrasenglish{% + \def\reftextfaceafter {on the \reftextvario{facing}{next} page}% + \def\reftextfacebefore{on the \reftextvario{facing}{preceding} + page}% + \def\reftextafter {on the \reftextvario{following}{next} page}% + \def\reftextbefore {on the \reftextvario{preceding}{previous} page}% + \def\reftextcurrent {on \reftextvario{this}{the current} page}% + \def\reftextfaraway#1{on page~\pageref{#1}}% + \def\reftextpagerange#1#2{on pages~\pageref{#1}--\pageref{#2}}% + \def\reftextlabelrange#1#2{\ref{#1} to~\ref{#2}}% + }} +% \end{macrocode} +% +% The esperanto strings were suggested by Albert Reiner +% (\verb=areiner@tph.tuwien.ac.at=). +% \changes{v1.4x}{2010/08/04}{Defaults for esperanto added} +% \begin{macrocode} +\DeclareOption{esperanto} + {\vref@addto\extrasesperanto{% + \def\reftextfaceafter{en la + \reftextvario{flanka}{sekva} pa\^go}% + \def\reftextfacebefore{en la + \reftextvario{flanka}{anta\u ua} pa\^go}% + \def\reftextafter{en la sekva pa\^go}% + \def\reftextbefore{en la anta\u ua pa\^go}% + \def\reftextcurrent{\reftextvario{\^ci-pa\^ge}% + {en \^ci tiu pa\^go}}% + \def\reftextfaraway#1{en pa\^go~\pageref{#1}}% + \def\reftextpagerange#1#2{en pa\^goj~\pageref{#1} \^gis \pageref{#2}}% + \def\reftextlabelrange#1#2{\ref{#1} \^gis~\ref{#2}}% + }} +% \end{macrocode} +% The finnish strings were suggested by Matti Rintala +% (\verb=bitti@cs.tut.fi=) and Hillevi Gavel +% \verb=Hillevi.Gavel@mdh.se=. +% \changes{v1.0m}{1994/09/23}{Added finnish strings} +% \changes{v1.4o}{2005/11/07}{Added a few more finnish strings} +% \begin{macrocode} +\DeclareOption{finnish} + {\vref@addto\extrasfinnish{% + \def\reftextfaceafter {\reftextvario{viereisell\"a}% + {seuraavalla} sivulla}% + \def\reftextfacebefore{\reftextvario{viereisell\"a}% + {edellisell\"a} sivulla}% + \def\reftextafter {seuraavalla sivulla}% + \def\reftextbefore {edellisell\"a sivulla}% + \def\reftextcurrent {t\"all\"a sivulla}% + \def\reftextfaraway#1{sivulla~\pageref{#1}}% + \def\reftextpagerange#1#2{sivuilla~\pageref{#1}--\pageref{#2}}% +% \end{macrocode} +% Can't combine numbers with the necessary suffix well. +% \begin{macrocode} + \def\reftextlabelrange#1#2{\ref{#1}--\ref{#2}}% + }} +% \end{macrocode} +% French defaults are provided by Daniel Flippo +% (\verb=Daniel.Flipo@univ-lille1.fr=). +% \changes{v1.0j}{1994/06/21}{Added french defaults} +% \changes{v1.2a}{1998/08/22}{Added french defaults for +% \cs{reftextpagerange} and \cs{reftextlabelrange}} +% \begin{macrocode} +\DeclareOption{french} + {\vref@addto\extrasfrench{% + \def\reftextfaceafter {page \reftextvario{ci-contre}{suivante}}% + \def\reftextfacebefore{page \reftextvario{ci-contre}% + {pr\'ec\'edente}}% + \def\reftextafter {page suivante}% + \def\reftextbefore {page pr\'ec\'edente}% + \def\reftextcurrent {de la pr\'esente page}% + \def\reftextfaraway#1{page~\pageref{#1}}% + \def\reftextpagerange#1#2{pages~\pageref{#1}--\pageref{#2}}% + \def\reftextlabelrange#1#2{\ref{#1} \`a~\ref{#2}}% + }} +% \end{macrocode} +% Galician defaults are provided by Matthias Moebius\\ +% (\texttt{Matthias.Moebius@uni-konstanz.de}). +% \changes{v1.1f}{1998/04/25}{Added galician defaults} +% \changes{v1.4o}{2005/11/10}{Added further galician defaults} +% \changes{v1.4o}{2005/11/26}{Some further corrections} +% \changes{v1.5b}{2015/09/22}{Fixed blunder from 2005 - +% galician option clearly never used} +% \begin{macrocode} +\DeclareOption{galician} + {\vref@addto\extrasgalician{% + \def\reftextfaceafter {na p\'axina oposta}% + \def\reftextfacebefore\reftextfaceafter + \def\reftextafter {na p\'axina seguinte}% + \def\reftextbefore {na p\'axina anterior}% + \def\reftextcurrent {nesta p\'axina}% + \def\reftextfaraway#1{na p\'axina~\pageref{#1}}% + \def\reftextpagerange#1#2{% + nas p\'axinas~\pageref{#1}-\pageref{#2}}% + \def\reftextlabelrange#1#2{\ref{#1} a~\ref{#2}}% + }} +% \end{macrocode} +% There are no good variants for German (I think and still think but +% this is a matter of taste :-). +% \changes{v1.0b}{1994/01/31}{Replace in incorrect `def by `let} +% The following definitions were recently suggested to me but since +% the original are in for a long time i don't want to change them +% now since that could make a lot of documents change their formatting. +% If you fancy them, add a redefinition of the corresponding macro(s) +% to the preamble of your document. +%\begin{verbatim} +% \def\reftextfaceafter {auf der \reftextvario +% {gegen\"uberliegenden}{anderen} Seite}% +% \def\reftextfacebefore {auf der \reftextvario +% {gegen\"uberliegenden}{anderen} Seite}% +% \def\reftextafter {auf der \reftextvario +% {n\"achsten}{folgenden} Seite}% +% \def\reftextbefore {auf der \reftextvario +% {vorigen}{vorhergehenden} Seite}% +% \def\reftextcurrent {\reftextvario +% {auf dieser}{diese} Seite}% +%\end{verbatim} +% \changes{v1.4n}{2005/07/24}{Small change} +% \begin{macrocode} +\DeclareOption{german} + {\vref@addto\extrasgerman{% + \def\reftextfaceafter {auf der n\"achsten Seite}% + \def\reftextfacebefore{auf der vorherigen Seite}% + \let\reftextafter \reftextfaceafter + \let\reftextbefore \reftextfacebefore + \def\reftextcurrent {auf dieser Seite}% + \def\reftextfaraway#1{auf Seite~\pageref{#1}}% + \def\reftextpagerange#1#2{auf den Seiten~\pageref{#1}--\pageref{#2}}% + \def\reftextlabelrange#1#2{\ref{#1} bis~\ref{#2}}% + }} +% \end{macrocode} +% \changes{v1.2d}{2000/01/11}{Added ngerman defaults (identical to german)} +% \changes{v1.4n}{2005/07/24}{Small change} +% The ngerman defaults are the same but needed for ``Neue Rechtschreibung'' +% (i.e., a different set of hyphenation patterns). +% \begin{macrocode} +\DeclareOption{ngerman} + {\vref@addto\extrasngerman{% + \def\reftextfaceafter {auf der n\"achsten Seite}% + \def\reftextfacebefore{auf der vorherigen Seite}% + \let\reftextafter \reftextfaceafter + \let\reftextbefore \reftextfacebefore + \def\reftextcurrent {auf dieser Seite}% + \def\reftextfaraway#1{auf Seite~\pageref{#1}}% + \def\reftextpagerange#1#2{auf den Seiten~\pageref{#1}--\pageref{#2}}% + \def\reftextlabelrange#1#2{\ref{#1} bis~\ref{#2}}% + }} +% \end{macrocode} +% Defaults for greek suggested by Apostolos Syropoulos\\ +% (\verb=apostolo@obelix.ee.duth.gr=). +% \changes{v1.2a}{1998/08/22}{Added defaults for greek} +% \begin{macrocode} +\DeclareOption{greek} + {\vref@addto\extrasgreek{% + \def\reftextfaceafter {sthn \reftextvario{paro'usa}% + {ep'omenh} sel'ida}% + \def\reftextfacebefore{sthn \reftextvario{paro'usa}{prohgo'umenh} + sel'ida}% + \def\reftextafter {sthn ep'omenh sel'ida}% + \def\reftextbefore {sthn prohgo'umenh sel'ida}% + \def\reftextcurrent {s'' aut'h th sel'ida}% + \def\reftextfaraway#1{sth sel'ida\nobreakspace\pageref{#1}}% + \def\reftextpagerange#1#2{stis sel'ides\nobreakspace + \pageref{#1}---\pageref{#2}}% + \def\reftextlabelrange#1#2{\ref{#1} ws\nobreakspace\ref{#2}}% + }} +% \end{macrocode} +% Icelandic defaults suggested by Thorhallur Sverrisson +% (\verb=thorhs@basis.is=). +% \changes{v1.4t}{2007/09/07}{Added defaults for icelandic} +% \begin{macrocode} +\DeclareOption{icelandic} + {\vref@addto\extrasicelandic{% + \def\reftextfaceafter {\'{a} \reftextvario{n{\ae}stu}% + {n{\ae}stu} s\'{i}{\dh}u}% + \def\reftextfacebefore{\'{a} \reftextvario{fyrri}% + {fyrri} s\'{i}{\dh}u}% + \def\reftextafter {\'{a} \reftextvario{n{\ae}stu}% + {n{\ae}stu} s\'{i}{\dh}u}% + \def\reftextbefore {\'{a} \reftextvario{fyrri}{fyrri} s\'{i}{\dh}u}% + \def\reftextcurrent {\'{a} \reftextvario{{\th}essari}% + {{\th}essari} s\'{i}{\dh}u}% + \def\reftextfaraway#1{\'{a} s\'{i}{\dh}u~\pageref{#1}}% + \def\reftextpagerange#1#2{\'{a} s\'{i}{\dh}um~\pageref{#1}--\pageref{#2}}% + \def\reftextlabelrange#1#2{\ref{#1} til~\ref{#2}}% + }} +% \end{macrocode} +% Defaults for Italian suggested by Giovanni Pensa +% (\verb=pensa@dsi.unimi.it=) with i{\TeX}nici. +% \changes{v1.1b}{1995/10/19}{Added defaults for Italian} +% \changes{v1.2a}{1998/08/22}{Removed incorrect warning} +% \changes{v1.4k}{2004/10/30}{Added missing defaults supplied by Lapo Mori} +% \changes{v1.4n}{2005/07/24}{Small change} +% \changes{v1.4u}{2009/03/21}{Correction for \cs{reftextfaraway} suggested +% by Lorenzo Pantieri} +% \begin{macrocode} +\DeclareOption{italian} + {\vref@addto\extrasitalian{% + \def\reftextfaceafter {\reftextvario{a fronte}% + {nella pagina successiva}}% + \def\reftextfacebefore{\reftextvario{a fronte}% + {nella pagina precedente}}% + \def\reftextafter {nella pagina \reftextvario{seguente}% + {successiva}}% + \def\reftextbefore {nella pagina precedente}% + \def\reftextcurrent {in questa pagina}% + \def\reftextfaraway#1{a pagina~\pageref{#1}}% + \def\reftextpagerange#1#2{nelle pagine~\pageref{#1}--\pageref{#2}}% + \def\reftextlabelrange#1#2{da~\ref{#1} a~\ref{#2}}% + }} +% \end{macrocode} +% Defaults for Hungarian by Jeff Goldberg +% (\verb=jeffrey@goldmark.org=). +% There is a problem with the use of the definite article +% \textit{a} or \textit{az} in Hungarian before expansions +% of |\vref| or |\ref|. The problem is that the word +% should be \textit{az} if the number following would begin with +% a vowel if spelled out, and \textit{a} if the number would begin +% with a consonant. +% +% The option assumes that there is a command |\aza| defined which +% helps resolving this problem.\footnote{This information is actually quite +% old but unfortunately never made it into varioref. In case any work +% has been undertaken to resolve this please inform the author about it.} +% \changes{v1.2a}{1998/08/22}{Added defaults for magyar} +% \changes{v1.4j}{2005/01/22}{Defined \cs{reftextfaceafter} and +% \cs{reftextfacebefore} instead of \cs{reftextafter} and \cs{reftextbefore}} +% \begin{macrocode} +\DeclareOption{magyar} + {\vref@addto\extrasmagyar{% + \def\reftextafter {a k\"o\-vet\-kez\H{o} ol\-da\-lon}% + \def\reftextbefore{az el\H{o}\-z\H{o} ol\-da\-lon}% + \def\reftextfaceafter {\reftextvario{a t\'ul\-ol\-da\-lon}% + {a k\"o\-vet\-kez\H{o} ol\-da\-lon}}% + \def\reftextfacebefore{\reftextvario{a t\'ul\-ol\-da\-lon}% + {az el\H{o}\-z\H{o} ol\-da\-lon}}% + \def\reftextcurrent {ezen az ol\-da\-lon}% +% \end{macrocode} +% The following suggested patch has not been added yet (pending changes +% in babel system). +%\begin{verbatim} +% \def\reftextfaraway#1{a~\csname @@magyar@az@lowxu\endcsname +% {\pageref{#1}}.~ol\-da\-lon}% +% \def\reftextpagerange#1#2{a~\csname @@magyar@az@lowxu\endcsname +% {\pageref{#1}}% +% --\pageref{#2}.~ol\-da\-la\-kon}% +% \def\reftextlabelrange#1#2{{}\csname @@magyar@told\endcsname\ref{#1}+tol +% \ref{#2}-ig}% Dat: `{}' is here for anti-\capitalize +%\end{verbatim} +% \begin{macrocode} + \def\reftextfaraway#1{\aza{\pageref{#1}} \pageref{#1}.~ol\-da\-lon}% + \def\reftextpagerange#1#2{\vref@stringwarning\reftextpagerange + on pages~\pageref{#1}--\pageref{#2}}% + \def\reftextlabelrange#1#2{\vref@stringwarning\reflabelpagerange + \ref{#1} to~\ref{#2}}% + }% +% \end{macrocode} +% The |\AtBeginDocument| needs to be executed when the option is +% processed and not inside the babel interface. +% \changes{v1.4i}{2004/02/27}{Moved \cs{AtBeginDocument}} +% \begin{macrocode} + \AtBeginDocument{\providecommand\aza[1]{a/az% + \PackageError{varioref}{% + Proper definition for command \noexpand\aza missing}% + {You need to (re)define the command \noexpand\aza that + takes one argument (a number or a \noexpand\pageref command) + and produces the string `a' or `az' depending on the argument + value. It should also accept an optional argument (default `l') + to denote whether or not the string should be lowercase or + uppercase.}}}% + } +% \end{macrocode} +% The Norwegian and `nynorsk' translations have been provided by +% Dag F Langmyhr \verb=<dag@ifi.uio.no>= and Karl Ove Hufthammer +% \verb=<huftis@bigfoot.com>=. +% \changes{v1.0q}{1995/04/06}{Added defaults for norsk} +% \changes{v1.0q}{1995/04/06}{Added defaults for nynorsk} +% \changes{v1.2a}{1998/08/22}{Updated defaults for norsk} +% \changes{v1.2a}{1998/08/22}{Updated defaults for nynorsk} +% \changes{v1.2a}{1998/08/22}{Added norsk defaults for +% \cs{reftextpagerange} and \cs{reftextlabelrange}} +% \changes{v1.2a}{1998/08/22}{Added nynorsk defaults for +% \cs{reftextpagerange} and \cs{reftextlabelrange}} +% \changes{v1.2i}{2001/01/12}{Updated nynorsk defaults} +% \begin{macrocode} +\DeclareOption{norsk} + {\vref@addto\extrasnorsk{% + \def\reftextfaceafter {p\aa{} neste side}% + \def\reftextfacebefore{p\aa{} forrige side}% + \def\reftextafter {p\aa{} neste side}% + \def\reftextbefore {p\aa{} forrige side}% + \def\reftextcurrent {p\aa{} denne siden}% + \def\reftextfaraway#1{p\aa{} side~\pageref{#1}}% + \def\reftextpagerange#1#2{p\aa{} side~\pageref{#1}--\pageref{#2}}% + \def\reftextlabelrange#1#2{\ref{#1} til~\ref{#2}}% + }} +\DeclareOption{nynorsk} + {\vref@addto\extrasnynorsk{% + \def\reftextfaceafter {p\aa{} neste side}% + \def\reftextfacebefore{p\aa{} f\o{}rre side}% + \def\reftextafter {p\aa{} neste side}% + \def\reftextbefore {p\aa{} f\o{}rre side}% + \def\reftextcurrent {p\aa{} denne sida}% + \def\reftextfaraway#1{p\aa{} side~\pageref{#1}}% + \def\reftextpagerange#1#2{p\aa{} side~\pageref{#1}--\pageref{#2}}% + \def\reftextlabelrange#1#2{\ref{#1} til~\ref{#2}}% + }} +% \end{macrocode} +% The polish translations have been provided by +% Tomasz Michniewski \\ +% \verb=<tomekm@ias.wat.waw.pl>=. +% The use of the command \verb=\eob= and \verb=aob= etc.\ +% requires appropriate definitions as provided, for example, by +% the babel system. This should probably be handled differently +% but it would require modifications in babel's language support. +% \changes{v1.1d}{1997/12/06}{Added defaults for polish} +% \changes{v1.2a}{1998/08/22}{Added polish defaults for +% \cs{reftextpagerange} and \cs{reftextlabelrange}} +% \changes{v1.4n}{2005/09/14}{Changed default for \cs{reftextfaraway}} +% \begin{macrocode} +\DeclareOption{polish} + {\vref@addto\extraspolish{% + \def\reftextfaceafter {na \reftextvario{s\aob{}siedniej}% + {nast\eob{}pnej} stronie}% + \def\reftextfacebefore{na \reftextvario{s\aob{}siedniej}% + {poprzedniej} stronie}% + \def\reftextafter {na nast\eob{}pnej stronie}% + \def\reftextbefore {na poprzedniej stronie}% + \def\reftextcurrent {na \reftextvario{tej + samej}{bie\zkb{}\aob{}cej} stronie}% + \def\reftextfaraway#1{na stronie~\pageref{#1}}% + \def\reftextpagerange#1#2{na stronach~\pageref{#1}--\pageref{#2}}% + \def\reftextlabelrange#1#2{od~\ref{#1} do~\ref{#2}}% + }} +% \end{macrocode} +% The portuguese default text has been provided by +% Jos\'e Carlos Oliveira Santos \verb=jcsantos@fc.up.pt=. +% \changes{v1.2b}{1999/11/25}{Added portuguese defaults} +% \changes{v1.2c}{1999/12/02}{Added more portuguese defaults} +% \changes{v1.4r}{2007/05/26}{Misspelling of \cs{extrasportuges}} +% \begin{macrocode} +\DeclareOption{portuges} + {\vref@addto\extrasportuges{% + \def\reftextfaceafter {na \reftextvario{p\'agina ao lado}{pr\'oxima + p\'agina}}% + \def\reftextfacebefore{na p\'agina \reftextvario{ao lado}{anterior}}% + \def\reftextafter {na \reftextvario{p\'agina seguinte}{pr\'oxima + p\'agina}}% + \def\reftextbefore{na p\'agina \reftextvario{anterior}{precedente}}% + \def\reftextcurrent {nesta p\'agina}% + \def\reftextfaraway#1{na p\'agina~\pageref{#1}}% + \def\reftextpagerange#1#2{nas p\'aginas~\pageref{#1}--\pageref{#2}}% + \def\reftextlabelrange#1#2{\ref{#1} a~\ref{#2}}% + }} +% \end{macrocode} +% Updates to the default text for Romanian have been suggested by Florin Oprina +% (\verb=<florin.oprina@gmail.com>=). +% \changes{v1.4v}{2009/06/13}{Incorrect text in \cs{reftextafter} (pr/4070)} +% \changes{v1.5a}{2014/07/03}{Correct text in \cs{reftextbefore}} +% \begin{macrocode} +\DeclareOption{romanian} + {\vref@addto\extrasromanian{% + \def\reftextfaceafter {pe pagina \reftextvario{opus\u{a}}{urm\u{a}toarei}}% + \def\reftextfacebefore{pe pagina \reftextvario{opus\u{a}}{precedentei}}% + \def\reftextafter {\reftextvario{pe pagina urm\u{a}toare}% + {pe urm\u{a}toarea pagin\u{a}}}% + \def\reftextbefore {pe pagina \reftextvario{precedent\u{a}}% + {precedentei}}% + \def\reftextcurrent {pe aceast\u{a} pagin\u{a}}% + \def\reftextfaraway#1{pe pagina~\pageref{#1}}% + \def\reftextpagerange#1#2{pe paginile~\pageref{#1}--\pageref{#2}}% + \def\reftextlabelrange#1#2{\ref{#1} la~\ref{#2}}% + }} +% \end{macrocode} +% The text for russian was taken from the book in Russian by +% I.~A.~Kotelnikov and P.~Z.~Chebotaev, and adapted +% to the encoding-independent form by Vladimir Volovich +% (\verb=vvv@vsu.ru=). +% \changes{v1.2a}{1998/11/23}{Added russian strings} +% \changes{v1.2a}{1998/11/24}{Added defaults for +% \cs{reftextpagerange} and \cs{reftextlabelrange}} +% \begin{macrocode} +\DeclareOption{russian} + {\vref@addto\extrasrussian{% + \def\reftextfaceafter{\cyrn\cyra\ \reftextvario{\cyrp\cyrr\cyro + \cyrt\cyri\cyrv\cyro\cyrp\cyro\cyrl\cyro\cyrzh\cyrn\cyro\cyrishrt}% + {\cyrs\cyrl\cyre\cyrd\cyru\cyryu\cyrshch\cyre\cyrishrt}\ \cyrs\cyrt + \cyrr\cyra\cyrn\cyri\cyrc\cyre}% + \def\reftextfacebefore{\cyrn\cyra\ \reftextvario{\cyrp\cyrr\cyro + \cyrt\cyri\cyrv\cyro\cyrp\cyro\cyrl\cyro\cyrzh\cyrn\cyro\cyrishrt}% + {\cyrp\cyrr\cyre\cyrd\cyrery\cyrd\cyru\cyrshch\cyre\cyrishrt}\ + \cyrs\cyrt\cyrr\cyra\cyrn\cyri\cyrc\cyre}% + \def\reftextafter{\cyrn\cyra\ \cyrs\cyrl\cyre\cyrd\cyru\cyryu\cyrshch + \cyre\cyrishrt\ \cyrs\cyrt\cyrr\cyra\cyrn\cyri\cyrc\cyre}% + \def\reftextbefore{\cyrn\cyra\ \reftextvario{\cyrp\cyrr\cyre\cyrd + \cyrsh\cyre\cyrs\cyrt\cyrv\cyru\cyryu\cyrshch\cyre\cyrishrt}% + {\cyrp\cyrr\cyre\cyrd\cyrery\cyrd\cyru\cyrshch\cyre\cyrishrt}% + \ \cyrs\cyrt\cyrr\cyra\cyrn\cyri\cyrc\cyre}% + \def\reftextcurrent{\cyrn\cyra\ \reftextvario{\cyrerev\cyrt\cyro + \cyrishrt}{\cyrd\cyra\cyrn\cyrn\cyro\cyrishrt}\ \cyrs\cyrt\cyrr + \cyra\cyrn\cyri\cyrc\cyre}% + \def\reftextfaraway#1{\cyrn\cyra\ \cyrs.~\pageref{#1}}% + \def\reftextpagerange#1#2{\cyrn\cyra\ \cyrs\cyrt\cyrr\cyra\cyrn + \cyri\cyrc\cyra\cyrh~\pageref{#1}--\pageref{#2}}% + \def\reftextlabelrange#1#2{\cyrs~\ref{#1}\ \cyrp\cyro~\ref{#2}}% + }} +% \end{macrocode} +% The text for slovak defaults was contributed by Miroslav Sedivy\\ +% (\verb=<miro@slovensko.com>=). +% \changes{v1.4b}{2002/03/11}{Contributed defaults added} +% \begin{macrocode} +\DeclareOption{slovak} + {\vref@addto\extrasslovak{% + \def\reftextfaceafter {na \reftextvario{proti\v lahlej}% + {nasleduj\'ucej} strane}% + \def\reftextfacebefore{na \reftextvario{proti\v lahlej}% + {predch\'adzaj\'ucej} strane}% + \def\reftextafter {na \reftextvario{nasleduj\'ucej}% + {\v dal\v sej} strane}% + \def\reftextbefore {na \reftextvario{predch\'adzaj\'ucej}% + {predo\v slej} strane}% + \def\reftextcurrent {na tejto strane}% + \def\reftextfaraway#1{na strane~\pageref{#1}}% + \def\reftextpagerange#1#2{na stran\'ach~\pageref{#1}--\pageref{#2}}% + \def\reftextlabelrange#1#2{\ref{#1} a\v z~\ref{#2}}% + }} +% \end{macrocode} +% The text for slovene defaults was contributed by Roman Maurer\\ +% (\verb=<roman.maurer@amis.net>=). +% \changes{v1.4a}{2002/03/05}{Contributed defaults added} +% \begin{macrocode} +\DeclareOption{slovene} + {\vref@addto\extrasslovene{% + \def\reftextfaceafter {na naslednji strani}% + \def\reftextfacebefore{na prej\v{s}nji strani}% + \let\reftextafter \reftextfaceafter + \let\reftextbefore \reftextfacebefore + \def\reftextcurrent {na \reftextvario{tej}{trenutni} strani}% + \def\reftextfaraway#1{na strani~\pageref{#1}}% + \def\reftextpagerange#1#2{na straneh~\pageref{#1}--\pageref{#2}}% + \def\reftextlabelrange#1#2{od~\ref{#1} do~\ref{#2}}% + }} +% \end{macrocode} +% Text for spanish defaults was contributed by Julio Sanchez +% (\verb=jsanchez@gmv.es=) and Fernando Dobladez (\verb=<ferd@fuego.com>=). +% \changes{v1.0f}{1994/03/16}{Inserted missing hash mark} +% \changes{v1.0k}{1994/06/05}{Corrected misspelled cmd `extrasspanish} +% \changes{v1.4a}{2002/03/05}{Missing defaults added} +% \changes{v1.4o}{2005/11/26}{Single hyphen in range} +% \begin{macrocode} +\DeclareOption{spanish} + {\vref@addto\extrasspanish{% + \def\reftextfaceafter {en la p\'agina siguiente}% + \def\reftextfacebefore{en la p\'agina anterior}% + \let\reftextafter \reftextfaceafter + \let\reftextbefore \reftextfacebefore + \def\reftextcurrent {en esta p\'agina}% + \def\reftextfaraway#1{en la p\'agina~\pageref{#1}}% + \def\reftextpagerange#1#2{en las p\'aginas~\pageref{#1}% + -\pageref{#2}}% + \def\reftextlabelrange#1#2{\ref{#1} a~\ref{#2}}% + }} +% \end{macrocode} +% The text for swedish was contributed by Mats Dahlgren +% (\verb=matsd@sssk.se=). +% \changes{v1.0p}{1995/01/10}{Added swedish strings} +% \changes{v1.2a}{1998/08/22}{Added swedish defaults for +% \cs{reftextpagerange} and \cs{reftextlabelrange}} +% \begin{macrocode} +\DeclareOption{swedish} + {\vref@addto\extrasswedish{% + \def\reftextfaceafter {p\aa\ \reftextvario{motst\aa ende}% + {n\"{a}sta} sida}% + \def\reftextfacebefore{p\aa\ \reftextvario{motst\aa ende}% + {f\"{o}reg\aa ende} sida}% + \def\reftextafter {p\aa\ \reftextvario{f\"{o}ljande}% + {n\"{a}sta} sida}% + \def\reftextbefore {p\aa\ f\"{o}reg\aa ende sida}% + \def\reftextcurrent {p\aa\ denna sida}% + \def\reftextfaraway#1{p\aa\ sidan~\pageref{#1}}% + \def\reftextpagerange#1#2{p\aa\ + sidorna~\pageref{#1}--\pageref{#2}}% + \def\reftextlabelrange#1#2{\ref{#1} till~\ref{#2}}% + }} +\DeclareOption{turkish} + {\vref@excuse{turkish}% + \vref@addto\extrasturkish{% + \def\reftextfaceafter {on the \reftextvario{facing}{next} page}% + \def\reftextfacebefore{on the \reftextvario{facing}{preceding} + page}% + \def\reftextafter {on the \reftextvario{following}{next} page}% + \def\reftextbefore {on the \reftextvario{preceding}{previous} page}% + \def\reftextcurrent {on \reftextvario{this}{the current} page}% + \def\reftextfaraway#1{on page~\pageref{#1}}% + \def\reftextpagerange#1#2{on pages~\pageref{#1}--\pageref{#2}}% + \def\reftextlabelrange#1#2{\ref{#1} to~\ref{#2}}% + }} +% \end{macrocode} +% The text for Ukrainian defaults was contributed by Mykola Lyakhovych\\ +% (\verb=<lyakhovych@mail.ru>=). +% \changes{v1.4l}{2005/04/24}{Contributed defaults added} +% \begin{macrocode} +\DeclareOption{ukrainian} + {\vref@addto\extrasukrainian{% + \def\reftextfaceafter{\cyrn\cyra\ \reftextvario{\cyrp\cyrr\cyro + \cyrt\cyri\cyrl\cyre\cyrzh\cyrn\cyrii\cyrishrt}% + {\cyrn\cyra\cyrs\cyrt\cyru\cyrp\cyrn\cyrii\cyrishrt}\ \cyrs\cyrt + \cyro\cyrr\cyri\cyrn\cyrc\cyrii}% + \def\reftextfacebefore{\cyrn\cyra\ \reftextvario{\cyrp\cyrr\cyro + \cyrt\cyri\cyrl\cyre\cyrzh\cyrn\cyrii\cyrishrt}% + {\cyrp\cyro\cyrp\cyre\cyrr\cyre\cyrd\cyrn\cyrii\cyrishrt}\ + \cyrs\cyrt\cyro\cyrr\cyrii\cyrn\cyrc\cyrii}% + \def\reftextafter{\cyrn\cyra\ \cyrn\cyra\cyrs\cyrt\cyru\cyrp\cyrn + \cyrii\cyrishrt\ \cyrs\cyrt\cyro\cyrr\cyrii\cyrn\cyrc\cyrii}% + \def\reftextbefore{\cyrn\cyra\ \cyrp\cyro\cyrp\cyre\cyrr\cyre\cyrd + \cyrn\cyrii\cyrishrt\ \cyrs\cyrt\cyro\cyrr\cyrii\cyrn\cyrc\cyrii}% + \def\reftextcurrent{\cyrn\cyra\ \reftextvario{\cyrc\cyrii\cyrishrt}% + {\cyrd\cyra\cyrn\cyrii\cyrishrt}\ \cyrs\cyrt\cyro\cyrr\cyrii\cyrn + \cyrc\cyrii}% + \def\reftextfaraway#1{\cyrn\cyra\ \cyrs.~\pageref{#1}}% + \def\reftextpagerange#1#2{\cyrn\cyra\ \cyrs\cyrt\cyro\cyrr\cyrii + \cyrn\cyrk\cyra\cyrh~\pageref{#1}--\pageref{#2}}% + \def\reftextlabelrange#1#2{\cyrz~\ref{#1}\ \cyrd\cyro~\ref{#2}}% + }} +% \end{macrocode} +% We support francais as an alternative to french since people +% might be used to it, but we discurrage it. +% \begin{macrocode} +\DeclareOption{francais}{% + \typeout{Please use `french' instead of `francais'}% + \ExecuteOptions{french}} +\DeclareOption{germanb}{% + \typeout{Please use `german' instead of `germanb'}% + \ExecuteOptions{german}} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% +% During document preparation errors due to |\vref| are usually of +% not much interest. For this reason the draft option turns them into +% warnings by issuing a |\vrefwarning| command. The final option +% (default) stops with an error message when varioref detects a possible +% loop. +% \changes{v1.1h}{1998/08/01}{Added draft and final options} +% \begin{macrocode} +\DeclareOption{draft}{\AtEndOfPackage\vrefwarning} +\DeclareOption{final}{\AtEndOfPackage\vrefshowerrors} % the default +% \end{macrocode} +% +% +% Whether or not \pkg{varioref} uses its own white space and +% removes the one in the source document is handeled by the +% following two options. For historical reasons the default is to +% handle the space, but the recommendation these days is to use +% \texttt{nospace}. +% \changes{v1.6a}{2019/08/25}{Provide options \texttt{space} and \texttt{nospace}} +% \begin{macrocode} +\newif\if@vrefhandlespace +\DeclareOption{space} {\@vrefhandlespacetrue} +\DeclareOption{nospace}{\@vrefhandlespacefalse} +% \end{macrocode} +% +% +% +% +% After all options are declared we execute the default option +% \texttt{english} to set up the defaults and then call +% |\ProcessOptions*| to handle any option passed to the package. +% The star form is used since we want to execute the options in the +% order they are given (in case this isn't used together with the +% \pkg{babel} package). +% \begin{macrocode} +\ExecuteOptions{english,final,space} +\ProcessOptions* +% \end{macrocode} +% +% +% \subsection{Defining the main macros} +% +% \begin{macro}{\vr@cnt} +% To generate new labels we use a counter and construct the +% internal label names by prefixing the current counter value with +% the string |vr@|. We need a \LaTeX{} counter to get |\include|s +% handled correctly. +% \changes{v0.1e}{1992/11/15}{use LaTeX counter} +% \begin{macrocode} +\newcounter{vrcnt} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\vpageref} +% \changes{v1.3a}{2001/04/12}{Scan for star form} +% \begin{macro}{\vp@geref} +% The command |\vpageref| generates the appropriate string by first +% parsing the optional arguments (if any) and then compares the +% internal and the user label. This command should be robust since +% the user might put it anywhere. +% +% We now start by scanning for a star and then call either +% |\vp@gerefstar| or |\vp@geref|. +% The space handling logic is a bit twisted these days: if the +% option \texttt{space} is +% in force then preceding spaces in the document are removed and +% the star means that the command should not add its own +% space. However, with option \texttt{nospace} any space already in the +% source will be left alone and the command doesn't add its own +% space either. Thus in this case the star form doesn't +% have any effect and below |\vp@gerefstar| is let to +% |\vp@geref|. This allows a package like \pkg{hyperef} to redefine +% it and useit for its own tasks (like denoting that no link should +% be produced). +% \begin{macrocode} +\DeclareRobustCommand\vpageref{\@ifstar + {\let\vref@maybe@space\@empty\vp@gerefstar}% + {\let\vref@maybe@space\space \vp@geref}} +% \end{macrocode} +% +% \begin{macrocode} +\def\vp@geref{\@ifnextchar[% +% \end{macrocode} +% The default for the first optional argument is the string hidden +% in the macro |\reftextcurrent|. +% \begin{macrocode} + \@vpageref{\@vpageref[\reftextcurrent]}% +} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\vref@space} +% \changes{v1.4a}{2002/03/06}{Default added} +% A default for |\vref@space|. This isn't really needed except in +% the case that somebody has hooked into the \pkg{varioref} +% interfaces at a lower level (which isn't really supported, +% but\ldots). So giving a default will prevent an error message in +% that case (and should hopefully produce the same behavior as before). +% \begin{macrocode} +\let\vref@space\space +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@vpageref} +% More parsing\ldots +% \begin{macrocode} +\def\@vpageref[#1]{\@ifnextchar[% +% \end{macrocode} +% By default the second optional argument is empty. +% \changes{v1.0h}{1994/06/11}{Pass first argument in both cases} +% \changes{v1.0i}{1994/06/20}{Do it correctly} +% \changes{v1.6a}{2019/08/25}{Default for optional argumet changed} +% \begin{macrocode} + {\@@vpageref{#1}}{\@@vpageref{#1}[]}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@@vpageref} +% The |\@@vpageref| macro finally generates the references by +% comparing the value of an internal label with the value of the +% user label. +% \changes{v1.0h}{1994/06/11}{Change internal interface} +% \begin{macrocode} +\def\@@vpageref#1[#2]#3{% +% \end{macrocode} +% First it switches to horizontal mode if necessary. If there was a +% preceding space we remember its size in |\@tempskipa| and then remove it for +% reinsertion later. +% \changes{v1.6a}{2019/08/25}{Don't drop a preceding space completely +% but reinsert it later after setting a label} +% \begin{macrocode} + \leavevmode + \@tempskipa\lastskip \unskip +% \end{macrocode} +% Then it advances the counter |\c@vrcnt| by one which is used to +% generate internal label names. +% \begin{macrocode} + \global\advance\c@vrcnt\@ne +% \end{macrocode} +% Then it checks if for the current value of |\c@vrcnt| a label +% command was issued in the last run. If not it pretends that there +% was one with the value |{??}{??}|. Thereafter it stores the +% pageref value for this label in the macro |\@tempa|. +% \begin{macrocode} + \vref@pagenum\@tempa{\the\c@vrcnt @vr}% +% \end{macrocode} +% Here we check that the generated text is not going across a page +% boundary. +% \changes{v0.1f}{1993/01/01}{Add another label to catch cross-overs} +% \begin{macrocode} + \vref@pagenum\@tempb{\the\c@vrcnt @xvr}% +% \end{macrocode} +% \changes{v1.0l}{1994/07/07}{Explicitly expand `label argument for +% babel} +% In version 1.0l the label string has been turned around so that +% the number comes first. This was done to allow easy explicit +% expansion of the number before it is passed to the |\label| +% command. In the babel system the argument of |label| was not +% expanded with the result that wrong label strings have been +% generated. This is a general problem that might need a completely +% different solution in babel but for now the change below (and in +% some other places in the code) should solve the problem for this +% special combination of packages. +% +% These days we actually use |\vref@label| instead of |\label| as +% this avoids problems with Babel or \pkg{amsmath} redefining +% the latter command. +% \changes{v1.4e}{2003/01/08}{Use \cs{vref@label} instead of +% \cs{label} (pr/3489)} +% \begin{macrocode} + \vref@label{\the\c@vrcnt @xvr}% +% \end{macrocode} +% Since we have removed +% any leading space above we now insert a space here after the +% label. It is done here so that it is still visible from following +% code---the space before the label would be hidden. +% What kind of space depends on the options to the +% package. If \texttt{space} was specified, we insert our own +% space, namely |\vref@maybe@space|. This will typeset a space +% unless the star form of the current command was used. +% \begin{macrocode} + \if@vrefhandlespace + \vref@maybe@space + \else +% \end{macrocode} +% But if \texttt{nospace} is in force we simply use the same space +% value that was used in the source document (unless that was zero +% or non-existent. +% \begin{macrocode} + \ifdim\@tempskipa=\z@ \else + \hskip\@tempskipa + \fi + \fi +% \end{macrocode} +% \changes{v1.1g}{1998/05/10}{Test if inside AMS display (pr2175)} +% Inside displays of the \pkg{amsmath} package the |\label| command +% is redefined which makes the test for loops incorrect if a |\vref| +% is used in, say, |\intertext|. So we test this condition first and +% only do the test if |\label| doesn't have a special meaning. +% [This is no longer necessary as |\label| isn't used any more] +% \begin{macrocode} +% \ifx\label\label@in@display\else + \ifx\@tempa\@tempb + \let\vref@may@loop\relax + \else +% \end{macrocode} +% If both points do not fall onto the same page with either issue +% an error or a warning message. +% However, we do no longer issue that warning now but wait until we +% are sure that both labels aren't ``far away'' because in that +% case it doesn't matter. So we just save that info in a macro now. +% \changes{v1.0g}{1994/05/27}{Looping pages shown in wrong order} +% \changes{v1.5c}{2016/02/16}{Delay generating the looping warning +% until we know more} +% \begin{macrocode} + \edef\vref@may@loop{% + \noexpand\vref@err{\noexpand\vref or \noexpand\vpageref + at page boundary + \@tempb-\@tempa\space (may loop)% + }% + }% + \fi +% \fi +% \end{macrocode} +% Same game for the user requested label; this time the page +% reference is saved in |\thevpagerefnum|. +% \changes{v1.4c}{2002/06/14}{Use \cs{thevpagerefnum} instead of \cs{@tempb}} +% \begin{macrocode} + \vrefpagenum\thevpagerefnum{#3}% +% \end{macrocode} +% Now after the internal label has served its purpose if would be +% nice to free the memory it occupies by using something like +% \begin{verbatim} +% \global\expandafter\let +% \csname r@\the\c@vrcnt @vr\endcsname\@empty +%\end{verbatim} +% But this is not possible because it would result in getting +% `Labels may have changed\ldots' warnings for every run. Now we +% are ready to produce the textual strings. +% \begin{macrocode} + \ifx\@tempa\thevpagerefnum +% \end{macrocode} +% If they are the same we insert the first argument into the input +% stream. Otherwise we insert the second argument. Recall that +% those are the two optional arguments of |...|. However, if the +% user explicitly requested an empty text string using the optional +% argument we cancel any preceding space since in this case we are +% otherwise likely to end up with spaces one before and one after +% |\vpageref|. +% \changes{v1.2f}{2000/07/07}{Don't output space if optional argument +% empty (pr/3230)} +% \begin{macrocode} + \def\@tempc{#1}% + \ifx\@tempc\@empty + \unskip + \else + #1% + \fi + \else +% \end{macrocode} +% If |#2| is empty we do nothing otherwise we insert it followed by +% a space. +% \begin{macrocode} + \def\@tempc{#2}% + \ifx\@tempc\@empty \else + #2\vref@space + \fi +% \end{macrocode} +% Now we check if the page number of the referenced object (stored +% in |\thevpagerefnum| is a single positive number. +% \begin{macrocode} + \is@pos@number\thevpagerefnum + {% +% \end{macrocode} +% If so, we check if the current position (stored in |\@tempa|) is +% a positive number. If this is the case we assign this number to +% the counter register |\@tempcnta| and add one to it. +% \begin{macrocode} + \is@pos@number\@tempa + {\@tempcnta\@tempa + \advance\@tempcnta\@ne + }% +% \end{macrocode} +% If it is not a positive number we assign the largest possible +% number to |\@tempcnta| and thereby pretending that label and +% reference are miles away from each other. +% \begin{macrocode} + {\@tempcnta\maxdimen}% +% \end{macrocode} +% Now we are ready to check if reference and object are on nearby +% pages. |\thevpagerefnum| will expand to the page number of the object +% (and we know that this is a number) and |\@tempcnta| is either +% one higher than the reference page or completely out of bounds. +% So if both represent the same value then the object lies one page +% after its reference. +% \begin{macrocode} + \ifnum \thevpagerefnum =\@tempcnta +% \end{macrocode} +% Thus if the object falls onto an odd page then the reference is +% on the facing even page (and so we insert |\reftextfaceafter|), +% otherwise the object can not be seen from the reference (and we +% in insert |\reftextafter|). Don't be surprised if we are not +% using |\thevpagerefnum| in the check. Since |\@tempcnta| has the same +% value it is faster to use the register instead of parsing the +% macro contents anew. +% \begin{macrocode} + \ifodd\@tempcnta +% \end{macrocode} +% In fact we are going to use |\reftextfaceafter| only if we are +% doing two-sided printing, otherwise |\reftextafter| is always +% used. +% Since the value of |\if@twoside| is evaluated before reading in +% packages we could do better (saving some tokens) by defining +% the current macro in dependence of this boolean. +% \begin{macrocode} + \if@twoside + \reftextfaceafter + \else + \reftextafter + \fi + \else + \reftextafter + \fi +% \end{macrocode} +% If the object is not on the page following the reference we check +% if it is on the page before the reference. In \LaTeX{} this +% situation is not too common, for example with floats it normally +% does not occur, but of course it isn't impossible if you more +% than one reference to the same object, or if you have back +% references to sections, theorems, etc. To test this we now +% subtract two from the current value of |\@tempcnta| (which was +% set to one higher as the reference page number). Note, that +% subtraction is also possible if the value was |\maxdimen| --- we +% still get something that is much larger than any sensible page +% number. +% \begin{macrocode} + \else + \advance\@tempcnta-2 +% \end{macrocode} +% If now |\thevpagerefnum| and |\@tempcnta| have the same value then the +% object lies one page before the reference. +% \begin{macrocode} + \ifnum \thevpagerefnum =\@tempcnta +% \end{macrocode} +% Again we have to check for odd or even pages to distinguish +% between the facing and the non-facing situation. +% \begin{macrocode} + \ifodd\@tempcnta + \reftextbefore + \else +% \end{macrocode} +% Again the |\reftextfacebefore| only if |@twoside| evaluates to +% true. +% \begin{macrocode} + \if@twoside + \reftextfacebefore + \else + \reftextbefore + \fi + \fi +% \end{macrocode} +% If the above test also returns false then we have object and +% references on pages which are far away or don't contain simple +% page numbers. Therefore we generate the |\reftextfaraway| string +% and drop any possible ``looping warning'' in |\vref@may@loop|. +% Recall that this is a macro which has the user label as an +% argument. +% \begin{macrocode} + \else + \let\vref@may@loop\relax % added + \reftextfaraway{#3}% + \fi + \fi + }% +% \end{macrocode} +% We do the same if our first test (that the page with the object +% has a positive page number) turns out to be false. +% \begin{macrocode} + {% + \let\vref@may@loop\relax %added + \reftextfaraway{#3}}% + \fi +% \end{macrocode} +% Finally we generate the internal label so that it can be check on +% the next run. This means that we compare the position after the +% string with the position of the referenced object. There is one +% thing to note: to conserve space we locally make |\@currentlabel| +% empty since we are only interested in the page number value of +% this internal label. +% \changes{v1.0l}{1994/07/07}{Explicitly expand \cs{label} argument for babel} +% +% These days we actually use |\vref@label| instead of |\label| as +% this avoids problems with Babel or \pkg{amsmath} redefining +% the latter command. +% \changes{v1.4e}{2003/01/08}{Use \cs{vref@label} instead of +% \cs{label} (pr/3489)} +% \changes{v1.5c}{2016/02/16}{} +% \begin{macrocode} + \vref@label{\the\c@vrcnt @vr}% +% \end{macrocode} +% Finally we run |\vref@may@loop| which is either |\relax| or generates +% a ``may loop'' warning or error as appropriate. +% \begin{macrocode} + \vref@may@loop +} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\vp@gerefstar} +% The default code for the star form is identical to the previous +% macro |\vp@geref|. It only produces a different result because +% before calling it we set |\vref@maybe@space| to do nothing. +% +% The \pkg{hyperref} package can then change the meaning of this +% command to suppress a hyperlink. +% +% It is is also a good way to check if we are running with a new +% \pkg{varioref} by testing +%\begin{verbatim} +% \ifdefined\vp@gerefstar +% ... code fore noew varioref +% \else +% ... code for old varioref +% \fi +%\end{verbatim} +% +% \changes{v1.6a}{2019/08/25}{Command added to support hyperref better} +% \begin{macrocode} +\let\vp@gerefstar\vp@geref +% \end{macrocode} +% \end{macro} +% +% + +% \begin{macro}{\vref@label} +% \changes{v1.4e}{2003/01/08}{Macro added (pr/3489)} +% This macro is like |\label| in the kernel but without passing on +% |\@currentlabel|, ie useful if all we are interested in is the +% page number. It also has the effect that it is unaffected by +% \pkg{amsmath} or Babel redefining the |\label| command. +% \begin{macrocode} +\def\vref@label#1{\@bsphack + \protected@write\@auxout{}% + {\string\newlabel{#1}{{}{\thepage}}}% + \@esphack} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\vpagerefnum} +% \changes{v1.4c}{2002/06/14}{Macro added} +% This macro allows to define |\reftextafter| and friends to refer +% to the page number rather than producing a textual reference. +% \begin{macrocode} +\let\thevpagerefnum\@empty +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\vrefwarning} +% \changes{v0.1g}{1993/02/14}{Macro added} +% \begin{macro}{\vrefshowerrors} +% \changes{v1.1h}{1998/08/01}{Macro added} +% \begin{macro}{\vref@err} +% \changes{v0.1g}{1993/02/14}{Macro added} +% When the |\vref| command detects a possible crossing over a page +% boundary it will call |\vref@err| to generate an error message. +% During document preparation one can turn such errors into +% warnings by issuing a |\vrefwarning| declaration. +% \changes{v1.0g}{1993/02/14}{Macro added} +% \begin{macrocode} +\def\vrefwarning{\def\vref@err{\PackageWarning{varioref}}} +% \end{macrocode} +% \begin{macrocode} +\def\vrefshowerrors{\def\vref@err##1{\PackageError{varioref}{##1}% + {Please check the pages in question. You might need to replace + the \string\vref\MessageBreak + or \noexpand\vpageref by a normal \noexpand\(page)ref to + stop LaTeX running forever.}}} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% +% +% \begin{macro}{\vref} +% We start by scanning for a star form and then continue in a +% different macro depending on the result. +% \changes{v1.3a}{2001/04/12}{Scan for star form} +% \changes{v1.6a}{2019/08/25}{Adjusted for new spacing regime} +% \begin{macrocode} +\DeclareRobustCommand\vref{\@ifstar + {\vref@star}{\vr@f}} +% \end{macrocode} +% \end{macro} + + + +% \begin{macro}{\vref@star} +% +% The star form is easy (and just a convenient shortcut), just call +% |\ref| followed by |\vpageref| and pass the optional argument to +% the latter. We don't support the second optional argument of +% |\vpageref|, it that is needed one has to call both commands +% explicitly +% \changes{v1.6a}{2019/08/25}{Command added to support hyperref better} +% \begin{macrocode} +\newcommand\vref@star[2][]{% + \ref{#2} + \vpageref[#1]{#2}} +% \end{macrocode} +% \end{macro} + +% \begin{macro}{\vr@f} +% The normal case is a little bit more elaborated \ldots +% \changes{v1.3c}{2001/09/04}{Correct typo in name} +% \changes{v1.6a}{2019/08/25}{Adjusted for new spacing regime} +% \begin{macrocode} +\def\vr@f{% + \leavevmode +% \end{macrocode} +% If option \texttt{space} is used then we remove a preceding space +% and add our own unbreakable space instead. Otherwise we don't do +% any space-handling. +% \begin{macrocode} + \if@vrefhandlespace + \unskip \nobreakspace + \fi +% \end{macrocode} +% The use of|\nobreakspace| or |~| after the |\unskip| means that +% this command will always produce a normal space while +% something like |\nobreak\space| will +% react to settings of |\nonfrenchspacing|. +% Unfortunately the latter will also act in cases where one really +% wants a normal space, e.g., in |Fig.~\vref{..}|, resulting in +% a large extra space after the dot. For this reason the first solution +% is used. +% \changes{v1.1e}{1998/03/09}{Don't use \cs{nobreakspace} (pr/1866)} +% \changes{v1.2a}{1998/11/27}{Use \cs{nobreakspace} (pr/2909)} +% \changes{v1.2a}{1998/11/27}{Add \cs{leavevmode}} +% +% After having handled (or not handled) the spacing we call +% |\vref@star| to scan the optional arguments and do the rest. +% If that command has been altered by \pkg{hyperref} then the +% current one needs altering too and does the argument scanning explicitly. +% \begin{macrocode} + \vref@star % in hyperref this needs to be explicit +} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\is@pos@number} +% The utility macro |\is@pos@number| takes three arguments: a +% string that is tested for being a valid non-negative integer and the +% actions to be taken in case the test comes out true or false. +% +% We start by passing the string to the macro |\is@pos@num| after +% prefixing it with a \texttt{0} and adding a space after it. To have +% a well-defined ending point we also add |\@nil| at the end. +%\label{isposnumber} +% \begin{macrocode} +\def\is@pos@number#1{\is@pos@num0#1\space\@nil} +% \end{macrocode} +% Now we parse the enlarged string into a counter register. To get +% control back after everything that is regarded by \TeX{} as a +% number is put into that register we assign |\is@pos@num@| to the +% |\afterassignment| token. Since the string started with 0, we +% can be sure that the register assignment will be carried out +% without an error message. In case of counter assignments leading +% zeros are discarded. +% \begin{macrocode} +\def\is@pos@num{\afterassignment\is@pos@num@ \count@} +% \end{macrocode} +% Now we have to check whether or not the whole string was parsed +% into that register or some remainder was left over. Since we have +% added a |\@nil| token at the very end we can use that to delimit +% the argument of |\is@pos@num@|. Note, that the added space in +% |\is@pos@number| \vpageref[above]{isposnumber} gets parsed away +% by the counter assignment. If it would be missing, and the full +% string would consist of a number, \TeX{}would try to replace +% |\@nil| by its definition to see if it would contain additional +% digits and thus we would be in trouble at this point. +% \begin{macrocode} +\def\is@pos@num@#1\@nil{% +% \end{macrocode} +% Now we have to check if the argument is empty. We can do this +% with an |\ifx| (i.e., in an expandable way) since we know for +% sure that it can not start with |\@nil|. +% \changes{v1.4j}{2004/05/08}{Use \cs{@nil} for testing} +% \begin{macrocode} + \ifx\@nil#1\@nil +% \end{macrocode} +% Depending on the result we execute the second or third argument +% of the command |\is@pos@number| using a technique that removes +% the |\else| or |\fi| from the input stream first, so that in +% principle input stream parsing could be done from within the +% arguments. +% \begin{macrocode} + \expandafter\@firstoftwo \else + \expandafter\@secondoftwo \fi} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\reftextvario} +% This macro gives a little bit of random variation in the text +% because the outcome depends on the number of |\vref| commands +% seen before. +% \begin{macrocode} +\def\reftextvario#1#2{\ifodd\c@vrcnt #1\else#2\fi} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\fullref} +% And here is the primitive command that always produces a |\ref| +% and a |\pageref|. +% \begin{macrocode} +\def\fullref#1{\ref{#1} \reftextfaraway{#1}} +% \end{macrocode} +% \end{macro} +% +% +% \subsubsection{Supporting ranges} +% +% \begin{macro}{\vref@pagenum} +% \changes{v1.2a}{1998/08/01}{Macro added} +% This command takes a label as |#1| extracts the page number +% associated with it and saves the result in a csname which is +% passed as |#1|. If the label isn't associated with a page number +% it essentially associates it with |??| for both the label number +% and the page, thus defining the label this way. This means that +% no label warning is generated for this label in case it is +% undefined. +% \begin{macrocode} +\def\vref@pagenum#1#2{% + \@ifundefined{r@#2}{\@namedef{r@#2}{{??}{??}}}{}% +% \end{macrocode} +% Extracting and saving the page number turned out to be a source of subtle +% bugs. Initially it was done through an |\edef| with a bunch of +% |\expandafter| commands inside. This posed a problem if the page number +% itself contained code which needed protection (e.g., pr/4080) so this got +% changed to use |\protected@edef|. However, that in turn failed with Babel +% (pr/4093) +% if the label contained active characters, e.g., a ``:'' in French. So now +% we use even more |\expandafter| commands to avoid any expansion other +% than what is absolutely required---I'm sure there is now a simpler way +% to code this, but \ldots\ in fact we didn't use enough initially resulting in another +% bug (pr/4159): +% \changes{v1.4w}{2009/09/13}{Use \cs{protected@edef} to avoid problems +% in complicated setups, e.g., microtype (pr/4080)} +% \changes{v1.4y}{2010/11/12}{Avoid even \cs{protected@edef} to pacify french +% babel (pr/4093)} +% \changes{v1.4z}{2011/10/02}{Previous fix need one more expansion +% (pr/4159,pr/4171)} +% \begin{macrocode} + \expandafter\expandafter\expandafter\vref@@pagenum + \csname r@#2\endcsname{}{}\@nil#1% +} +\def\vref@@pagenum#1#2#3\@nil#4{% + \def#4{#2}% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\vrefpagenum} +% \changes{v1.2a}{1998/08/01}{Macro added} +% Same as the above but this time we generate a warning for +% undefined labels. +% \begin{macrocode} +\def\vrefpagenum#1#2{% + \@ifundefined{r@#2}% + {\G@refundefinedtrue + \@latex@warning{Reference `#2' on page \thepage \space + undefined}}{}% + \vref@pagenum{#1}{#2}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\vpagerefrange} +% \begin{macro}{\@vpagerefrange} +% \begin{macro}{\@svpagerefrange} +% \changes{v1.2a}{1998/08/01}{Macro added} +% \changes{v1.3b}{2001/04/14}{Scan for star form} +% \changes{v1.4s}{2007/08/07} +% {Prevent loss of brackets} +% If both labels refer to the same page then we produce a +% |\vpageref|. Otherwise we produce the result of +% |\reftextpagerange|. +% +% One could think of making this command even more clever by +% producing a special string if the difference between the two page +% number is one (but this is not done). +% +% We need two versions to implement a star form: +% \begin{macrocode} +\newcommand\@svpagerefrange[3][\reftextcurrent]{% + \vrefpagenum\@tempa{#2}% + \vrefpagenum\@tempb{#3}% + \ifx\@tempa\@tempb + \vpageref*[{#1}]{#2}% + \else + \reftextpagerange{#2}{#3}% + \fi +} +% \end{macrocode} +% And the same but using |\vpageref|: +% \begin{macrocode} +\newcommand\@vpagerefrange[3][\reftextcurrent]{% + \vrefpagenum\@tempa{#2}% + \vrefpagenum\@tempb{#3}% + \ifx\@tempa\@tempb + \vpageref[{#1}]{#2}% + \else + \reftextpagerange{#2}{#3}% + \fi +} +% \end{macrocode} +% And here we put things together. +% \begin{macrocode} +\newcommand\vpagerefrange{\@ifstar\@svpagerefrange\@vpagerefrange} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% +% +% \begin{macro}{\vrefrange} +% \changes{v1.2a}{1998/08/01}{Macro added} +% \changes{v1.4s}{2006/08/07} +% {Prevent loss of brackets} +% \begin{macrocode} +\newcommand\vrefrange[3][\reftextcurrent] + {\reftextlabelrange{#2}{#3} \vpagerefrange[{#1}]{#2}{#3}} +% \end{macrocode} +% \end{macro} +% +% +% +% \begin{macro}{\Vref} +% \changes{v1.4a}{2002/02/24}{Macro added} +% |\Vref| is the counterpart to |\vref| with |\ref| replaced by +% |\Ref| in its definition. +% \changes{v1.6a}{2019/08/25}{Adjusted for new spacing regime} +% \begin{macrocode} +\DeclareRobustCommand\Vref{\@ifstar + {\Vref@star}% + {\Vr@f}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\Vref@star} +% \changes{v1.6a}{2019/08/25}{Command added to support hyperref better} +% \begin{macrocode} +\newcommand\Vref@star[2][]{% + \Ref{#2} + \vpageref[#1]{#2}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\Vr@f} +% \changes{v1.4a}{2002/02/24}{Macro added} +% \changes{v1.4x}{2010/08/04}{Correct spacing -- same mistake as in \cs{vref} +% (pr/4123)} +% \changes{v1.6a}{2019/08/25}{Adjusted for new spacing regime} +% \begin{macrocode} +\def\Vr@f{% + \if@vrefhandlespace + \unskip \vref@space + \fi + \Vref@star % in hyperref this needs to be explicit +} +% \end{macrocode} +% \end{macro} + + +% \begin{macro}{\vpagerefcompare} +% +% \changes{v1.6a}{2019/08/25}{Macro added} +% \begin{macrocode} +\DeclareRobustCommand\vpagerefcompare[2]{% label1, label2, TRUE, FALSE + \vrefpagenum\@tempa{#1}% + \vrefpagenum\@tempb{#2}% + \ifx\@tempa\@tempb + \expandafter\@firstoftwo + \else + \expandafter\@secondoftwo + \fi +} +% \end{macrocode} +% \end{macro} +% +% +% +% \begin{macro}{\vpagerefnearby} +% \changes{v1.6a}{2019/08/25}{Macro added} +% Test if |\vpageref| is going to be at most $\pm1$ off from +% current page. +% \begin{macrocode} +\DeclareRobustCommand\vpagerefnearby[1]{% label, TRUE, FALSE + \leavevmode + \@tempskipa\lastskip \unskip + \global\advance\c@vrcnt\tw@ % keep oddness to not disturb \vrefvario + \vref@label{\the\c@vrcnt @vn}% + \ifdim\@tempskipa=\z@ \else + \hskip\@tempskipa + \fi + \vref@pagenum\@tempa{\the\c@vrcnt @vn}% + \is@pos@number\@tempa + {% + \vrefpagenum\@tempb{#1}% + \is@pos@number\@tempb + {% + \ifcase\numexpr \@tempa -\@tempb+1\relax + \or \or \else \expandafter \@thirdofthree \fi + \@firstoftwo + }% + {\@secondoftwo}% + }% + {\@secondoftwo}% +} +% \end{macrocode} +% \end{macro} +% + +% \begin{macro}{\vpagerefcomparenearby} +% \changes{v1.6a}{2019/08/25}{Macro added} +% True if the two pages have arabic page numbers are at most off by +% one so that |\vpageref| would produce a special string. +% +% This is n some sense a general version of |\vpagerefnearby| for +% use in more complex situations. I.e., if you try to determine if +% a larger set of references would be close to the current page and +% you use each time |\vpagerefnearby| then you generate a lot of +% internal labels for the current point. Thus by setting the label +% yourself you can save processing time and space. On the other +% hand you have to be careful to place the label into the right +% place which can be a bit complicated if you look at the +% definition of |\vpagerefnearby| that does all this automatically +% for you. This is why the current macro is not discussed in the +% user interface section as it is really just for package +% developers. +% \begin{macrocode} +\DeclareRobustCommand\vpagerefcomparenearby[2]{% label1, label2, TRUE, FALSE + \vrefpagenum\@tempa{#1}% + \is@pos@number\@tempa + {% + \vrefpagenum\@tempb{#2}% + \is@pos@number\@tempb + {% + \ifcase\numexpr \@tempa -\@tempb+1\relax + \or \or \else \expandafter \@thirdofthree \fi + \@firstoftwo + }% + {\@secondoftwo}% + }% + {\@secondoftwo}% +} +% \end{macrocode} +% \end{macro} + +% +% +% \subsubsection{Compatibility with older \LaTeX{} formats} +% +% +% \begin{macro}{\labelformat} +% \begin{macro}{\Ref} +% \begin{macro}{\refstepcounter} +% We don't need to define \cs{labelformat} and \cs{Ref} or change the +% definition of \cs{refstepcounter} any longer because this is now +% done in the \LaTeX{} kernel. However, if this package is used +% together with an older kernel, this is not true, so for this +% special case we keep the definitions. +% \begin{macrocode} +\ifx\labelformat\@undefined % assume we are in an older kernel + \def\labelformat#1{\expandafter\def\csname p@#1\endcsname##1} + \DeclareRobustCommand\Ref[1]{\protected@edef\@tempa{\ref{#1}}% + \expandafter\MakeUppercase\@tempa} + \def\refstepcounter#1{\stepcounter{#1}% + \protected@edef\@currentlabel + {\csname p@#1\expandafter\endcsname\csname the#1\endcsname}} +\fi +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macrocode} +%</package> +% \end{macrocode} +% \Finale +% +\endinput + diff --git a/macros/latex-dev/required/tools/varioref.ins b/macros/latex-dev/required/tools/varioref.ins new file mode 100644 index 0000000000..e436202e4d --- /dev/null +++ b/macros/latex-dev/required/tools/varioref.ins @@ -0,0 +1,76 @@ +%% +%% This file will generate fast loadable files and documentation +%% driver files from the doc files in this package when run through +%% LaTeX or TeX. +%% +%% Copyright (C) 1993-2019 +%% The LaTeX3 Project and any individual authors listed elsewhere +%% in this file. +%% +%% This file is part of the Standard LaTeX `Tools Bundle'. +%% ------------------------------------------------------- +%% +%% It may be distributed and/or modified under the +%% conditions of the LaTeX Project Public License, either version 1.3c +%% of this license or (at your option) any later version. +%% The latest version of this license is in +%% https://www.latex-project.org/lppl.txt +%% and version 1.3c or later is part of all distributions of LaTeX +%% version 2008 or later. +%% +%% As this file contains legal notices, it is NOT PERMITTED to modify +%% this file in any way that the legal information placed into +%% generated files is changed (i.e., the files generated when the +%% original file is executed). This restriction does not apply if +%% (parts of) the content is reused in a different WORK producing its +%% own generated files. +%% +%% The list of all files belonging to the `Tools Bundle' is +%% given in the file `manifest.txt'. +%% +%% +%% --------------- start of docstrip commands ------------------ +%% +\input docstrip + +\keepsilent + +\usedir{tex/latex/tools} + +\preamble + +This is a generated file. + +The source is maintained by the LaTeX Project team and bug +reports for it can be opened at https://latex-project.org/bugs/ +(but please observe conditions on bug reports sent to that address!) + +Copyright (C) 1993-2019 +The LaTeX3 Project and any individual authors listed elsewhere +in this file. + +This file was generated from file(s) of the Standard LaTeX `Tools Bundle'. +-------------------------------------------------------------------------- + +It may be distributed and/or modified under the +conditions of the LaTeX Project Public License, either version 1.3c +of this license or (at your option) any later version. +The latest version of this license is in + https://www.latex-project.org/lppl.txt +and version 1.3c or later is part of all distributions of LaTeX +version 2005/12/01 or later. + +This file may only be distributed together with a copy of the LaTeX +`Tools Bundle'. You may however distribute the LaTeX `Tools Bundle' +without such generated files. + +The list of all files belonging to the LaTeX `Tools Bundle' is +given in the file `manifest.txt'. + +\endpreamble + + +\generateFile{varioref.sty}{t}{\from{varioref.dtx}{package}} + + +\endbatchfile diff --git a/macros/latex-dev/required/tools/varioref.pdf b/macros/latex-dev/required/tools/varioref.pdf Binary files differnew file mode 100644 index 0000000000..2346645c1b --- /dev/null +++ b/macros/latex-dev/required/tools/varioref.pdf diff --git a/macros/latex-dev/required/tools/verbatim.dtx b/macros/latex-dev/required/tools/verbatim.dtx new file mode 100644 index 0000000000..1dc8682f79 --- /dev/null +++ b/macros/latex-dev/required/tools/verbatim.dtx @@ -0,0 +1,1858 @@ +% \iffalse meta-comment +% +% Copyright (C) 1993-2019 +% +% The LaTeX3 Project and any individual authors listed elsewhere +% in this file. +% +% This file is part of the Standard LaTeX `Tools Bundle'. +% ------------------------------------------------------- +% +% It may be distributed and/or modified under the +% conditions of the LaTeX Project Public License, either version 1.3c +% of this license or (at your option) any later version. +% The latest version of this license is in +% https://www.latex-project.org/lppl.txt +% and version 1.3c or later is part of all distributions of LaTeX +% version 2005/12/01 or later. +% +% The list of all files belonging to the LaTeX `Tools Bundle' is +% given in the file `manifest.txt'. +% +% \fi +% +%\iffalse % this is a METACOMMENT ! +% +% +%% Package `verbatim' to use with LaTeX2e +%% Copyright (C) 1989--2003 by Rainer Sch\"opf. All rights reserved. +% +% Copying of this file is authorized only if either +% (1) you make absolutely no changes to your copy, including name, or +% (2) if you do make changes, you name it something other than +% verbatim.dtx. +% This restriction helps ensure that all styles developed here +% remain identical. +% +% +% +% \section{Producing the documentation} +% +% We provide a short driver file that can be extracted by the +% \textsf{DocStrip} program using the conditional `\textsf{driver}'. +% +% \begin{macrocode} +%<*driver> +\documentclass{ltxdoc} + +\pagestyle{myheadings} + +\title{A New Implementation of \LaTeX{}'s \\ \texttt{verbatim} + and \texttt{verbatim*} Environments.} +\author{Rainer Sch\"opf\\ + \and + Bernd Raichle\\ + \and + Chris Rowley} + +\date{2001/03/12} +\begin{document} +\markboth{Verbatim style option}{Verbatim style option} +\MaintainedByLaTeXTeam{tools} +\maketitle + \DocInput{verbatim.dtx} +\end{document} +%</driver> +% \end{macrocode} +% +% +%\fi +% +% +% \changes{v1.5q}{2003/08/22}{Reintroduced \cs{@noligs}, by popular +% request.} +% \changes{v1.5i}{1996/06/04}{Move setting of verbatim font and +% \cs{@noligs}.} +% \changes{v1.5g}{1995/04/26}{Removed \cs{fileversion} and +% \cs{filedate} from running head in +% driver file, as these are no longer +% defined.} +% \changes{v1.5f}{1994/10/25}{Removed extra \cs{typeout} commands.} +% \changes{v1.5e}{1994/06/10}{Added missing closing verbtest guard.} +% \changes{v1.5d}{1994/05/30}{\cs{NeedsTeXFormat} and +% \cs{ProvidesPackage} added.} +% \changes{v1.5d}{1994/05/30}{\cs{addto@hook} removed, now in kernel.} +% \changes{v1.5a}{1993/10/12}{Included \cs{newverbtext} command, as +% written by Chris Rowley.} +% \changes{v1.5}{1993/10/11}{Included vrbinput style option by Bernd +% Raichle.} +% +% \changes{v1.4j}{1992/06/30}{Used \cs{lowercase}\{\cs{endgroup} +% \ldots\} trick proposed by Bernd Raichle; changed all \cs{gdef} +% to \cs{def} since no longer necessary.} +% \changes{v1.4g}{1991/11/21}{Several improvements in the +% documentation.} +% \changes{v1.4f}{1991/08/05}{Corrected bug in documentation. +% Found by Bernd Raichle.} +% \changes{v1.4e}{1991/07/24}{Avoid reading this file twice.} +% \changes{v1.4d}{1991/04/24}{\cs{penalty}\cs{interlinepenalty} added to +% definition of \cs{par} in \cs{@verbatim}. +% Necessary to avoid page breaks in +% the scope of a \cs{samepage} declaration.} +% \changes{v1.4c}{1990/10/18}{Added \cs{leavevmode} to definition of +% backquote macro.} +% \changes{v1.4b}{1990/07/14}{Converted nearly all \cs{verb}'s to +% \texttt{\protect\string!|\ldots\protect\string!|}.} +% \changes{v1.4a}{1990/04/04}{Added a number of percent characters +% to suppress blank space at the end of some code lines.} +% \changes{v1.4}{1990/03/07}{\cs{verb} rewritten.} +% +% \changes{v1.3a}{1990/02/04}{Removed \texttt{verbatimwrite} environment +% from the code. Now only shown as an example.} +% +% \changes{v1.2g}{1990/02/01}{Revised documentation.} +% \changes{v1.2e}{1990/01/15}{Added \cs{every@verbatim} hook.} +% \changes{v1.2d}{1989/11/29}{Use token register \cs{@temptokena} +% instead of macro \cs{@tempb}.} +% \changes{v1.2d}{1989/11/29}{Use token register \cs{verbatim@line} +% instead of macro \cs{@tempd}.} +% \changes{v1.2b}{1989/10/25}{\cs{verbatimfile} renamed to +% \cs{verbatiminput}. Suggested by Reinhard Wonneberger.} +% +% \changes{v1.1a}{1989/10/16}{\cs{verb} added.} +% \changes{v1.1}{1989/10/09}{Made the code more modular (as suggested by +% Chris Rowley): introduced +% \cs{verbatim@addtoline}, etc. Added +% \cs{verbatimwrite} environment.} +% +% \changes{v1.0e}{1989/07/17}{Fixed bug in \cs{verbatimfile} (*-form +% handling, discovered by Dirk Kreimer).} +% \changes{v1.0d}{1989/05/16}{Revised documentation, fixed silly bug +% in \cs{verbatim@@@}.} +% \changes{v1.0c}{1989/05/12}{Added redefinition of \cs{@sverb}, change +% in end-of-line handling.} +% \changes{v1.0b}{1989/05/09}{Change in \cs{verbatim@rescan}.} +% \changes{v1.0a}{1989/05/07}{Change in \cs{verbatim@@testend}.} +% +% +% \DoNotIndex{\ ,\!,\C,\[,\\,\],\^,\`,\{,\},\~} +% \DoNotIndex{\@M,\@empty,\@flushglue,\@gobble,\@ifstar,\@ifundefined} +% \DoNotIndex{\@namedef,\@spaces,\@tempa,\@tempb,\@tempc,\@tempd} +% \DoNotIndex{\@temptokena,\@totalleftmargin,\@warning,\active} +% \DoNotIndex{\aftergroup,\arabic,\begingroup,\catcode,\char,\closein} +% \DoNotIndex{\csname,\def,\do,\docdate,\dospecials,\edef,\else} +% \DoNotIndex{\endcsname,\endgraf,\endgroup,\endinput,\endlinechar} +% \DoNotIndex{\endtrivlist,\expandafter,\fi,\filedate,\fileversion} +% \DoNotIndex{\frenchspacing,\futurelet,\if,\ifcat,\ifeof,\ifnum} +% \DoNotIndex{\ifx,\immediate,\item,\kern,\lccode,\leftskip,\let} +% \DoNotIndex{\lowercase,\m@ne,\makeatletter,\makeatother,\newread} +% \DoNotIndex{\newread,\next,\noexpand,\noindent,\openin,\parfillskip} +% \DoNotIndex{\parindent,\parskip,\penalty,\read,\relax,\rightskip} +% \DoNotIndex{\sloppy,\space,\string,\the,\toks@,\trivlist,\tt,\typeout} +% \DoNotIndex{\vskip,\write,\z@} +% +% \begin{abstract} +% This package reimplements the \LaTeX{} \texttt{verbatim} and +% \texttt{verbatim*} environments. +% In addition it provides a \texttt{comment} environment +% that skips any commands or text between +% |\begin{comment}| +% and the next |\end{comment}|. +% It also defines the command \texttt{verbatiminput} to input a whole +% file verbatim. +% \end{abstract} +% +% \section{Usage notes} +% +% \let\docDescribeMacro\DescribeMacro +% \let\docDescribeEnv\DescribeEnv +% \def\DescribeMacro#1{} +% \def\DescribeEnv#1{} +% \LaTeX's \texttt{verbatim} and \texttt{verbatim*} environments +% have a few features that may give rise to problems. These are: +% \begin{itemize} +% \item +% Due to the method used to detect the closing |\end{verbatim}| +% (i.e.\ macro parameter delimiting) you cannot leave spaces +% between the |\end| token and |{verbatim}|. +% \item +% Since \TeX{} has to read all the text between the +% |\begin{verbatim}| and the |\end{verbatim}| before it can output +% anything, long verbatim listings may overflow \TeX's memory. +% \end{itemize} +% Whereas the first of these points can be considered +% only a minor nuisance the other one is a real limitation. +% +% +% \DescribeEnv{verbatim} +% \DescribeEnv{verbatim*} +% This package file contains a reimplementation of the \texttt{verbatim} +% and \texttt{verbatim*} environments which overcomes these +% restrictions. +% There is, however, one incompatibility between the old and the +% new implementations of these environments: the old version +% would treat text on the same line as the |\end{verbatim}| +% command as if it were on a line by itself. +% \begin{center} +% \bf This new version will simply ignore it. +% \end{center} +% (This is the price one has to pay for the removal of the old +% \texttt{verbatim} environment's size limitations.) +% It will, however, issue a warning message of the form +% \begin{verbatim} +%LaTeX warning: Characters dropped after \end{verbatim*}! +%\end{verbatim} +% This is not a real problem since this text can easily be put +% on the next line without affecting the output. +% +% This new implementation also solves the second problem mentioned +% above: it is possible to leave spaces (but \emph{not} begin a new +% line) between the |\end| and the |{verbatim}| or |{verbatim*}|: +% \begin{verbatim} +%\begin {verbatim*} +% test +% test +%\end {verbatim*} +%\end{verbatim} +% +% \DescribeEnv{comment} +% Additionally we introduce a \texttt{comment} environment, with the +% effect that the text between |\begin{comment}| and |\end{comment}| +% is simply ignored, regardless of what it looks like. +% At first sight this seems to be quite different from the purpose +% of verbatim listing, but actually the implementation of these two +% concepts turns out to be very similar. +% Both rely on the fact that the text between |\begin{...}| and +% |\end{...}| is read by \TeX{} without interpreting any commands or +% special characters. +% The remaining difference between \texttt{verbatim} and +% \texttt{comment} is only that the text is to be typeset in the +% first case and to be thrown away in the latter. Note that these +% environments cannot be nested. +% +% \DescribeMacro{\verbatiminput} +% |\verbatiminput| is a command with one argument that inputs a file +% verbatim, i.e.\ the command |verbatiminput{xx.yy}| +% has the same effect as\\[2pt] +% \hspace*{\MacroIndent}|\begin{verbatim}|\\ +% \hspace*{\MacroIndent}\meta{Contents of the file \texttt{xx.yy}}\\ +% \hspace*{\MacroIndent}|\end{verbatim}|\\[2pt] +% This command has also a |*|-variant that prints spaces as \verb*+ +. +% +% +% \StopEventually{} +% +% +% \section{Interfaces for package writers} +% +% The \texttt{verbatim} environment of \LaTeXe{} does not +% offer a good interface to programmers. +% In contrast, this package provides a simple mechanism to +% implement similar features, the \texttt{comment} environment +% implemented here being an example of what can be done and how. +% +% +% \subsection{Simple examples} +% +% It is now possible to use the \texttt{verbatim} environment to define +% environments of your own. +% E.g., +%\begin{verbatim} +% \newenvironment{myverbatim}% +% {\endgraf\noindent MYVERBATIM:% +% \endgraf\verbatim}% +% {\endverbatim} +%\end{verbatim} +% can be used afterwards like the \texttt{verbatim} environment, i.e. +% \begin{verbatim} +%\begin {myverbatim} +% test +% test +%\end {myverbatim} +%\end{verbatim} +% Another way to use it is to write +% \begin{verbatim} +%\let\foo=\comment +%\let\endfoo=\endcomment +%\end{verbatim} +% and from that point on environment \texttt{foo} is the same as the +% comment environment, i.e.\ everything inside its body is ignored. +% +% You may also add special commands after the |\verbatim| macro is +% invoked, e.g. +%\begin{verbatim} +%\newenvironment{myverbatim}% +% {\verbatim\myspecialverbatimsetup}% +% {\endverbatim} +%\end{verbatim} +% though you may want to learn about the hook |\every@verbatim| at +% this point. +% \changes{v1.5h}{1995/09/21}{Clarified documentation on use of other +% environments to define new verbatim-type ones.} +% However, there are still a number of restrictions: +% \begin{enumerate} +% \item +% You must not use the |\begin| or the |\end| command inside a +% definition, e.g.~the following two examples will \emph{not} work: +%\begin{verbatim*} +%\newenvironment{myverbatim}% +%{\endgraf\noindent MYVERBATIM:% +% \endgraf\begin{verbatim}}% +%{\end{verbatim}} +%\newenvironment{fred} +%{\begin{minipage}{30mm}\verbatim} +%{\endverbatim\end{minipage}} +%\end{verbatim*} +% If you try these examples, \TeX{} will report a +% ``runaway argument'' error. +% More generally, it is not possible to use +% |\begin|\ldots\allowbreak|\end| +% or the related environments in the definition of the new +% environment. Instead, the correct way to define this environment +% would be +% \begin{verbatim*} +%\newenvironment{fred} +%{\minipage{30mm}\verbatim} +%{\endverbatim\endminipage} +%\end{verbatim*} +% \item +% You can\emph{not} use the \texttt{verbatim} environment inside +% user defined \emph{commands}; e.g., +% \changes{v1.4g}{1991/11/21}{Corrected wrong position of optional +% argument to \cs{newcommand}. Discovered by Piet van Oostrum.} +% \begin{verbatim*} +%\newcommand{\verbatimfile}[1]% +% {\begin{verbatim}\input{#1}\end{verbatim}} +%\end{verbatim*} +% does \emph{not} work; nor does +% \begin{verbatim} +%\newcommand{\verbatimfile}[1]{\verbatim\input{#1}\endverbatim} +%\end{verbatim} +% \item The name of the newly defined environment must not contain +% characters with category code other than $11$ (letter) or +% $12$ (other), or this will not work. +% \end{enumerate} +% +% +% \subsection{The interfaces} +% +% \DescribeMacro{\verbatim@font} +% Let us start with the simple things. +% Sometimes it may be necessary to use a special typeface for your +% verbatim text, or perhaps the usual computer modern typewriter shape +% in a reduced size. +% +% You may select this by redefining the macro |\verbatim@font|. +% This macro is executed at the beginning of every verbatim text to +% select the font shape. +% Do not use it for other purposes; if you find yourself abusing this +% you may want to read about the |\every@verbatim| hook below. +% +% By default, |\verbatim@font| switches to the typewriter font and +% disables the ligatures contained therein. +% +% +% \DescribeMacro{\every@verbatim} +% \DescribeMacro{\addto@hook} +% There is a hook (i.e.\ a token register) called |\every@verbatim| +% whose contents are inserted into \TeX's mouth just before every +% verbatim text. +% Please use the |\addto@hook| macro to add something to this hook. +% It is used as follows:\\[2pt] +% \hspace*{\MacroIndent}|\addto@hook|\meta{name of the hook}^^A +% |{|\meta{commands to be added}|}| +% \vspace*{2pt} +% +% +% +% \DescribeMacro{\verbatim@start} +% After all specific setup, like switching of category codes, has been +% done, the |\verbatim@start| macro is called. +% This starts the main loop of the scanning mechanism implemented here. +% Any other environment that wants to make use of this feature should +% execute this macro as its last action. +% +% +% \DescribeMacro{\verbatim@startline} +% \DescribeMacro{\verbatim@addtoline} +% \DescribeMacro{\verbatim@processline} +% \DescribeMacro{\verbatim@finish} +% These are the things that concern the start of a verbatim +% environment. +% Once this (and other) setup has been done, the code in this package +% reads and processes characters from the input stream in the +% following way: +% \begin{enumerate} +% \item Before the first character of an input line is read, it +% executes the macro |\verbatim@startline|. +% \item After some characters have been read, the macro +% |\verbatim@addtoline| is called with these characters as its only +% argument. +% This may happen several times per line (when an |\end| command is +% present on the line in question). +% \item When the end of the line is reached, the macro +% |\verbatim@processline| is called to process the characters that +% |\verbatim@addtoline| has accumulated. +% \item Finally, there is the macro |\verbatim@finish| that is called +% just before the environment is ended by a call to the |\end| +% macro. +% \end{enumerate} +% +% +% To make this clear let us consider the standard \texttt{verbatim} +% environment. +% In this case the three macros above are defined as follows: +% \begin{enumerate} +% \item |\verbatim@startline| clears the character buffer +% (a token register). +% \item |\verbatim@addtoline| adds its argument to the character +% buffer. +% \item |\verbatim@processline| typesets the characters accumulated +% in the buffer. +% \end{enumerate} +% With this it is very simple to implement the \texttt{comment} +% environment: +% in this case |\verbatim@startline| and |\verbatim@processline| are +% defined to be +% no-ops whereas |\verbatim@addtoline| discards its argument. +% +% +% Let's use this to define a variant of the |verbatim| +% environment that prints line numbers in the left margin. +% Assume that this would be done by a counter called |VerbatimLineNo|. +% Assuming that this counter was initialized properly by the +% environment, |\verbatim@processline| would be defined in this case as +% \begin{verbatim} +%\def\verbatim@processline{% +% \addtocounter{VerbatimLineNo}{1}% +% \leavevmode +% \llap{\theVerbatimLineNo\ \hskip\@totalleftmargin}% +% \the\verbatim@line\par} +%\end{verbatim} +% +% A further possibility is to define a variant of the |verbatim| +% environment that boxes and centers the whole verbatim text. +% Note that the boxed text should be less than a page otherwise you +% have to change this example. +% +%\begin{verbatim} +%\def\verbatimboxed#1{\begingroup +% \def\verbatim@processline{% +% {\setbox0=\hbox{\the\verbatim@line}% +% \hsize=\wd0 +% \the\verbatim@line\par}}% +% \setbox0=\vbox{\parskip=0pt\topsep=0pt\partopsep=0pt +% \verbatiminput{#1}}% +% \begin{center}\fbox{\box0}\end{center}% +% \endgroup} +%\end{verbatim} +% +% As a final nontrivial example we describe the definition of an +% environment called \texttt{verbatimwrite}. +% It writes all text in its body to a file whose name is +% given as an argument. +% We assume that a stream number called |\verbatim@out| has already +% been reserved by means of the |\newwrite| macro. +% +% Let's begin with the definition of the macro |\verbatimwrite|. +% \begin{verbatim} +%\def\verbatimwrite#1{% +%\end{verbatim} +% First we call |\@bsphack| so that this environment does not influence +% the spacing. +% Then we open the file and set the category codes of all special +% characters: +% \begin{verbatim} +% \@bsphack +% \immediate\openout \verbatim@out #1 +% \let\do\@makeother\dospecials +% \catcode`\^^M\active +%\end{verbatim} +% The default definitions of the macros +% \begin{verbatim} +% \verbatim@startline +% \verbatim@addtoline +% \verbatim@finish +%\end{verbatim} +% are also used in this environment. +% Only the macro |\verbatim@processline| has to be changed before +% |\verbatim@start| is called: +% \begin{verbatim} +% \def\verbatim@processline{% +% \immediate\write\verbatim@out{\the\verbatim@line}}% +% \verbatim@start} +%\end{verbatim} +% The definition of |\endverbatimwrite| is very simple: +% we close the stream and call |\@esphack| to get the spacing right. +% \begin{verbatim} +%\def\endverbatimwrite{\immediate\closeout\verbatim@out\@esphack} +%\end{verbatim} +% +% \section{The implementation} +% +% \let\DescribeMacro\docDescribeMacro +% \let\DescribeEnv\docDescribeEnv +% +% \changes{v1.4e}{1991/07/24}{Avoid reading this file twice.} +% The very first thing we do is to ensure that this file is not read +% in twice. To this end we check whether the macro |\verbatim@@@| is +% defined. If so, we just stop reading this file. The `package' +% guard here allows most of the code to be excluded when extracting +% the driver file for testing this package. +% \begin{macrocode} +%<*package> +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{verbatim} + [2014/10/28 v1.5q LaTeX2e package for verbatim enhancements] +\@ifundefined{verbatim@@@}{}{\endinput} +% \end{macrocode} +% +% We use a mechanism similar to the one implemented for the +% |\comment|\ldots\allowbreak|\endcomment| macro in \AmSTeX: +% We input one line at a time and check if it contains the |\end{...}| +% tokens. +% Then we can decide whether we have reached the end of the verbatim +% text, or must continue. +% +% +% \subsection{Preliminaries} +% +% \begin{macro}{\every@verbatim} +% The hook (i.e.\ token register) |\every@verbatim| +% is initialized to \meta{empty}. +% \begin{macrocode} +\newtoks\every@verbatim +\every@verbatim={} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\@makeother} +% \changes{v1.1a}{1989/10/16}{\cs{@makeother} added.} +% |\@makeother| takes as argument a character and changes +% its category code to $12$ (other). +% \begin{macrocode} +\def\@makeother#1{\catcode`#112\relax} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\@vobeyspaces} +% \changes{v1.5}{1993/10/11}{Changed definition to not use \cs{gdef}.} +% \changes{v1.1a}{1989/10/16}{\cs{@vobeyspaces} added.} +% The macro |\@vobeyspaces| causes spaces in the input +% to be printed as spaces in the output. +% \begin{macrocode} +\begingroup + \catcode`\ =\active% + \def\x{\def\@vobeyspaces{\catcode`\ \active\let \@xobeysp}} + \expandafter\endgroup\x +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\@xobeysp} +% \changes{v1.1a}{1989/10/16}{\cs{@xobeysp} added.} +% The macro |\@xobeysp| produces exactly one space in +% the output, protected against breaking just before it. +% (|\@M| is an abbreviation for the number $10000$.) +% \begin{macrocode} +\def\@xobeysp{\leavevmode\penalty\@M\ } +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\verbatim@line} +% \changes{v1.2d}{1989/11/29}{Introduced token register +% \cs{verbatim@line}.} +% We use a newly defined token register called |\verbatim@line| +% that will be used as the character buffer. +% \begin{macrocode} +\newtoks\verbatim@line +% \end{macrocode} +% \end{macro} +% +% The following four macros are defined globally in a way suitable for +% the \texttt{verbatim} and \texttt{verbatim*} environments. +% \begin{macro}{\verbatim@startline} +% \begin{macro}{\verbatim@addtoline} +% \begin{macro}{\verbatim@processline} +% |\verbatim@startline| initializes processing of a line +% by emptying the character buffer (|\verbatim@line|). +% \begin{macrocode} +\def\verbatim@startline{\verbatim@line{}} +% \end{macrocode} +% |\verbatim@addtoline| adds the tokens in its argument +% to our buffer register |\verbatim@line| without expanding +% them. +% \begin{macrocode} +\def\verbatim@addtoline#1{% + \verbatim@line\expandafter{\the\verbatim@line#1}} +% \end{macrocode} +% Processing a line inside a \texttt{verbatim} or \texttt{verbatim*} +% environment means printing it. +% \changes{v1.2c}{1989/10/31}{Changed \cs{@@par} to \cs{par} in +% \cs{verbatim@processline}. Removed \cs{leavevmode} and \cs{null} +% (i.e.\ the empty \cs{hbox}).} +% Ending the line means that we have to begin a new paragraph. +% We use |\par| for this purpose. Note that |\par| +% is redefined in |\@verbatim| to force \TeX{} into horizontal +% mode and to insert an empty box so that empty lines in the input +% do appear in the output. +% \changes{v1.2f}{1990/01/31}{\cs{verbatim@startline} removed.} +% \begin{macrocode} +\def\verbatim@processline{\the\verbatim@line\par} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\verbatim@finish} +% As a default, |\verbatim@finish| processes the remaining +% characters. +% When this macro is called we are facing the following problem: +% when the |\end{verbatim}| +% command is encountered |\verbatim@processline| is called +% to process the characters preceding the command on the same +% line. If there are none, an empty line would be output if we +% did not check for this case. +% +% If the line is empty |\the\verbatim@line| expands to +% nothing. To test this we use a trick similar to that on p.\ 376 +% of the \TeX{}book, but with |$|\ldots|$| instead of +% the |!| tokens. These |$| tokens can never have the same +% category code as a |$| token that might possibly appear in the +% token register |\verbatim@line|, as such a token will always have +% been read with category code $12$ (other). +% Note that |\ifcat| expands the following tokens so that +% |\the\verbatim@line| is replaced by the accumulated +% characters +% \changes{v1.2d}{1989/11/29}{Changed \cs{ifx} to \cs{ifcat} test.} +% \changes{v1.1b}{1989/10/18}{Corrected bug in if test (found by CRo).} +% \begin{macrocode} +\def\verbatim@finish{\ifcat$\the\verbatim@line$\else + \verbatim@processline\fi} +% \end{macrocode} +% \end{macro} +% +% +% \subsection{The \texttt{verbatim} and \texttt{verbatim*} environments} +% +% \begin{macro}{\verbatim@font} +% \changes{v1.2f}{1990/01/31}{\cs{@lquote} macro removed.} +% \changes{v1.1b}{1989/10/18}{\cs{@noligs} removed. Code inserted +% directly into \cs{verbatim@font}.} +% \changes{v1.1a}{1989/10/16}{\cs{verbatim@font} added.} +% \changes{v1.1a}{1989/10/16}{\cs{@noligs} added.} +% \changes{v1.1a}{1989/10/16}{\cs{@lquote} added.} +% We start by defining the macro |\verbatim@font| that is +% to select the font and to set font-dependent parameters. +% Then we expand |\@noligs| (defined in the \LaTeXe{} kernel). Among +% possibly other things, it will go through |\verbatim@nolig@list| +% to avoid certain ligatures. +% |\verbatim@nolig@list| is a macro defined in the \LaTeXe{} kernel +% to expand to +% \begin{verbatim} +% \do\`\do\<\do\>\do\,\do\'\do\- +%\end{verbatim} +% All the characters in this list can be part of a ligature in some +% font or other. +% \changes{v1.2f}{1990/01/31}{\cs{@lquote} macro removed.} +% \changes{v1.4c}{1990/10/18}{Added \cs{leavevmode}.} +% \changes{v1.4k}{1992/07/13}{Replaced Blank after $96$ by \cs{relax}. +% (Proposed by Dan Dill.)} +% \changes{v1.5}{1993/10/11}{Definition changed according to new code +% in latex.tex and to avoid global definition.} +% \changes{v1.5c}{1994/02/07}{Changed to use new font switching +% commands.} +% \changes{v1.5m}{2000/01/07}{Disable hyphenation even if the font +% allows it.} +% \changes{v1.5q}{2003/08/22}{Use \cs{@noligs}, as it is by now properly +% defined in the \LaTeXe{} kernel.} +% \begin{macrocode} +\def\verbatim@font{\normalfont\ttfamily + \hyphenchar\font\m@ne + \@noligs} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\@verbatim} +% \changes{v1.1a}{1989/10/16}{\cs{@verbatim} added.} +% The macro |\@verbatim| sets up things properly. +% First of all, the tokens of the |\every@verbatim| hook +% are inserted. +% Then a \texttt{trivlist} environment is started and its first +% |\item| command inserted. +% Each line of the \texttt{verbatim} or \texttt{verbatim*} +% environment will be treated as a separate paragraph. +% \changes{v1.2e}{1990/01/15}{Added \cs{every@verbatim} hook.} +% \changes{v1.5b}{1994/01/24}{Removed optional argument of \cs{item}.} +% \begin{macrocode} +\def\@verbatim{\the\every@verbatim + \trivlist \item \relax +% \end{macrocode} +% \changes{v1.5b}{1994/01/24}{Set \texttt{@inlabel} switch to false.} +% \changes{v1.5f}{1994/10/25}{Removed setting of \texttt{@inlabel} +% switch again.} +% \changes{v1.3c}{1990/02/26}{Removed extra vertical space. +% Suggested by Frank Mittelbach.} +% \changes{v1.5h}{1995/09/21}{Added the space again, since it is +% necessary for correct vertical spacing if \texttt{verbatim} +% is nested inside \texttt{quote}.} +% The following extra vertical space is for compatibility with the +% \LaTeX kernel: otherwise, using the |verbatim| package changes +% the vertical spacing of a |verbatim| environment nested within a +% |quote| environment. +% \begin{macrocode} + \if@minipage\else\vskip\parskip\fi +% \end{macrocode} +% \changes{v1.4k}{1992/07/13}{Added setting for +% \cs{@beginparpenalty}. Suggested by Frank Mittelbach.} +% The paragraph parameters are set appropriately: +% the penalty at the beginning of the environment, +% left and right margins, paragraph indentation, the glue to +% fill the last line, and the vertical space between paragraphs. +% The latter space has to be zero since we do not want to add +% extra space between lines. +% \begin{macrocode} + \@beginparpenalty \predisplaypenalty + \leftskip\@totalleftmargin\rightskip\z@ + \parindent\z@\parfillskip\@flushglue\parskip\z@ +% \end{macrocode} +% \changes{v1.1b}{1989/10/18}{Added resetting of \cs{parshape} +% if at beginning of a list. +% (Problem pointed out by Chris Rowley.)} +% There's one point to make here: +% the \texttt{list} environment uses \TeX's |\parshape| +% primitive to get a special indentation for the first line +% of the list. +% If the list begins with a \texttt{verbatim} environment +% this |\parshape| is still in effect. +% Therefore we have to reset this internal parameter explicitly. +% We could do this by assigning $0$ to |\parshape|. +% However, there is a simpler way to achieve this: +% we simply tell \TeX{} to start a new paragraph. +% As is explained on p.~103 of the \TeX{}book, this resets +% |\parshape| to zero. +% \changes{v1.1c}{1989/10/19}{Replaced explicit resetting of +% \cs{parshape} by \cs{@@par}.} +% \begin{macrocode} + \@@par +% \end{macrocode} +% We now ensure that |\par| has the correct definition, +% namely to force \TeX{} into horizontal mode +% and to include an empty box. +% This is to ensure that empty lines do appear in the output. +% Afterwards, we insert the |\interlinepenalty| since \TeX{} +% does not add a penalty between paragraphs (here: lines) +% by its own initiative. Otherwise a |verbatim| environment +% could be broken across pages even if a |\samepage| +% declaration were present. +% +% However, in a top-aligned minipage, this will result in an extra +% empty line added at the top. Therefore, a slightly more +% complicated construct is necessary. +% One of the important things here is the inclusion of +% |\leavevmode| as the first macro in the first line, for example, +% a blank verbatim line is the first thing in a list item. +% \changes{v1.2c}{1989/10/31}{Definition of \cs{par} added. +% Ensures identical behaviour for +% verbatim and \cs{verbatiminput}. +% Problem pointed out by Chris.} +% \changes{v1.4d}{1991/04/24}{\cs{penalty}\cs{interlinepenalty} added. +% Necessary to avoid page breaks in +% the scope of a \cs{samepage} declaration.} +% \changes{v1.5b}{1994/01/24}{Improved definition of \cs{par} to work +% under all circumstances.} +% \changes{v1.5f}{1994/10/25}{\cs{leavevmode} added for first line.} +% \begin{macrocode} + \def\par{% + \if@tempswa + \leavevmode\null\@@par\penalty\interlinepenalty + \else + \@tempswatrue + \ifhmode\@@par\penalty\interlinepenalty\fi + \fi}% +% \end{macrocode} +% But to avoid an error message when the environment +% doesn't contain any text, we redefine |\@noitemerr| +% which will in this case be called by |\endtrivlist|. +% \changes{v1.4j}{1992/06/30}{Introduced warning instead of error +% for empty body of verbatim text. +% Suggested by Nelson Beebe.} +% \begin{macrocode} + \def\@noitemerr{\@warning{No verbatim text}}% +% \end{macrocode} +% Now we call |\obeylines| to make the end of line character +% active, +% \begin{macrocode} + \obeylines +% \end{macrocode} +% change the category code of all special characters, +% to $12$ (other). +% \changes{v1.5i}{1996/06/04}{Moved \cs{verbatim@font} after +% \cs{dospecials}.} +% \begin{macrocode} + \let\do\@makeother \dospecials +% \end{macrocode} +% and switch to the font to be used. +% \begin{macrocode} + \verbatim@font +% \end{macrocode} +% To avoid a breakpoint after the labels box, we remove the penalty +% put there by the list macros: another use of |\unpenalty|! +% \changes{v1.5f}{1994/10/25}{Change to \cs{everypar} added.} +% \begin{macrocode} + \everypar \expandafter{\the\everypar \unpenalty}} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\verbatim} +% \begin{macro}{\verbatim*} +% Now we define the toplevel macros. +% |\verbatim| is slightly changed: +% after setting up things properly it calls +% |\verbatim@start|. +% \changes{v1.5l}{1999/12/14}{Added \cs{begingroup} for cases where +% \cs{verbatim} is used directly, rather than in \cs{begin}: see +% pr/3115.} +% This is done inside a group, so that |\verbatim| can be used +% directly, without |\begin|. +% \begin{macrocode} +\def\verbatim{\begingroup\@verbatim \frenchspacing\@vobeyspaces + \verbatim@start} +% \end{macrocode} +% |\verbatim*| is defined accordingly. +% \begin{macrocode} +\@namedef{verbatim*}{\begingroup\@verbatim\verbatim@start} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\endverbatim} +% \begin{macro}{\endverbatim*} +% To end the \texttt{verbatim} and \texttt{verbatim*} +% environments it is only necessary to finish the +% \texttt{trivlist} environment started in |\@verbatim| and +% close the corresponding group. +% \changes{v1.5l}{1999/12/14}{Added \cs{endgroup} for cases where +% \cs{endverbatim} is used directly, rather than in \cs{end}: see +% pr/3115.} +% \changes{v1.5n}{2000/08/03}{Added \cs{@endpetrue}: needed when +% faking such a \cs{end} (pr/3234).} +% \changes{v1.5o}{2000/08/23}{Changed \cs{@endpetrue} to \cs{@doendpe}: +% see (pr/3234).} +% \begin{macrocode} +\def\endverbatim{\endtrivlist\endgroup\@doendpe} +\expandafter\let\csname endverbatim*\endcsname =\endverbatim +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% +% \subsection{The \texttt{comment} environment} +% +% \begin{macro}{\comment} +% \begin{macro}{\endcomment} +% \changes{v1.1c}{1989/10/19}{Added \cs{@bsphack}/\cs{@esphack} to the +% \texttt{comment} environment. Suggested by Chris Rowley.} +% The |\comment| macro is similar to |\verbatim*|. +% However, we do not need to switch fonts or set special +% formatting parameters such as |\parindent| or |\parskip|. +% We need only set the category code of all special characters +% to $12$ (other) and that of |^^M| (the end of line character) +% to $13$ (active). +% The latter is needed for macro parameter delimiter matching in +% the internal macros defined below. +% In contrast to the default definitions used by the +% |\verbatim| and |\verbatim*| macros, +% we define |\verbatim@addtoline| to throw away its argument +% and |\verbatim@processline|, |\verbatim@startline|, +% and |\verbatim@finish| to act as no-ops. +% Then we call |\verbatim@|. +% But the first thing we do is to call |\@bsphack| so that +% this environment has no influence whatsoever upon the spacing. +% \changes{v1.1c}{1989/10/19}{Changed \cs{verbatim@start} to +% \cs{verbatim@}. Suggested by Chris Rowley.} +% \changes{v1.1c}{1989/10/19}{\cs{verbatim@startline} and +% \cs{verbatim@finish} are now +% also redefined to do nothing.} +% \begin{macrocode} +\def\comment{\@bsphack + \let\do\@makeother\dospecials\catcode`\^^M\active + \let\verbatim@startline\relax + \let\verbatim@addtoline\@gobble + \let\verbatim@processline\relax + \let\verbatim@finish\relax + \verbatim@} +% \end{macrocode} +% |\endcomment| is very simple: it only calls +% |\@esphack| to take care of the spacing. +% The |\end| macro closes the group and therefore takes care +% of restoring everything we changed. +% \begin{macrocode} +\let\endcomment=\@esphack +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% +% +% \subsection{The main loop} +% +% Here comes the tricky part: +% During the definition of the macros we need to use the special +% characters |\|, |{|, and |}| not only with their +% normal category codes, +% but also with category code $12$ (other). +% We achieve this by the following trick: +% first we tell \TeX{} that |\|, |{|, and |}| +% are the lowercase versions of |!|, |[|, and |]|. +% Then we replace every occurrence of |\|, |{|, and |}| +% that should be read with category code $12$ by |!|, |[|, +% and |]|, respectively, +% and give the whole list of tokens to |\lowercase|, +% knowing that category codes are not altered by this primitive! +% +% But first we have ensure that +% |!|, |[|, and |]| themselves have +% the correct category code! +% \changes{v1.3b}{1990/02/07}{Introduced \cs{vrb@catcodes} instead +% of explicit setting of category codes.} +% To allow special settings of these codes we hide their setting in +% the macro |\vrb@catcodes|. If it is already defined our new +% definition is skipped. +% \begin{macrocode} +\@ifundefined{vrb@catcodes}% + {\def\vrb@catcodes{% + \catcode`\!12\catcode`\[12\catcode`\]12}}{} +% \end{macrocode} +% This trick allows us to use this code for applications where other +% category codes are in effect. +% +% We start a group to keep the category code changes local. +% \begin{macrocode} +\begingroup + \vrb@catcodes + \lccode`\!=`\\ \lccode`\[=`\{ \lccode`\]=`\} +% \end{macrocode} +% \changes{v1.2f}{1990/01/31}{Code for TABs removed.} +% We also need the end-of-line character |^^M|, +% as an active character. +% If we were to simply write |\catcode`\^^M=\active| +% then we would get an unwanted active end of line character +% at the end of every line of the following macro definitions. +% Therefore we use the same trick as above: +% we write a tilde |~| instead of |^^M| and +% pretend that the +% latter is the lowercase variant of the former. +% Thus we have to ensure now that the tilde character has +% category code $13$ (active). +% \begin{macrocode} + \catcode`\~=\active \lccode`\~=`\^^M +% \end{macrocode} +% The use of the |\lowercase| primitive leads to one problem: +% the uppercase character `|C|' needs to be used in the +% code below and its case must be preserved. +% So we add the command: +% \begin{macrocode} + \lccode`\C=`\C +% \end{macrocode} +% Now we start the token list passed to |\lowercase|. +% We use the following little trick (proposed by Bernd Raichle): +% The very first token in the token list we give to |\lowercase| is +% the |\endgroup| primitive. This means that it is processed by +% \TeX{} immediately after |\lowercase| has finished its operation, +% thus ending the group started by |\begingroup| above. This avoids +% the global definition of all macros. +% \begin{macrocode} + \lowercase{\endgroup +% \end{macrocode} +% \begin{macro}{\verbatim@start} +% The purpose of |\verbatim@start| is to check whether there +% are any characters on the same line as the |\begin{verbatim}| +% and to pretend that they were on a line by themselves. +% On the other hand, if there are no characters remaining +% on the current line we shall just find an end of line character. +% |\verbatim@start| performs its task by first grabbing the +% following character (its argument). +% This argument is then compared to an active |^^M|, +% the end of line character. +% \begin{macrocode} + \def\verbatim@start#1{% + \verbatim@startline + \if\noexpand#1\noexpand~% +% \end{macrocode} +% If this is true we transfer control to |\verbatim@| +% to process the next line. We use +% |\next| as the macro which will continue the work. +% \begin{macrocode} + \let\next\verbatim@ +% \end{macrocode} +% Otherwise, we define |\next| to expand to a call +% to |\verbatim@| followed by the character just +% read so that it is reinserted into the text. +% This means that those characters remaining on this line +% are handled as if they formed a line by themselves. +% \begin{macrocode} + \else \def\next{\verbatim@#1}\fi +% \end{macrocode} +% Finally we call |\next|. +% \begin{macrocode} + \next}% +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\verbatim@} +% The three macros |\verbatim@|, |\verbatim@@|, +% and |\verbatim@@@| form the ``main loop'' of the +% \texttt{verbatim} environment. +% The purpose of |\verbatim@| is to read exactly one line +% of input. +% |\verbatim@@| and |\verbatim@@@| work together to +% find out whether the four characters +% |\end| (all with category code $12$ (other)) occur in that +% line. +% If so, |\verbatim@@@| will call +% |\verbatim@test| to check whether this |\end| is +% part of |\end{verbatim}| and will terminate the environment +% if this is the case. +% Otherwise we continue as if nothing had happened. +% So let's have a look at the definition of |\verbatim@|: +% \changes{v1.1a}{1989/10/16}{Replaced \cs{verbatim@@@} by \cs{@nil}.} +% \begin{macrocode} + \def\verbatim@#1~{\verbatim@@#1!end\@nil}% +% \end{macrocode} +% Note that the |!| character will have been replaced by a +% |\| with category code $12$ (other) by the |\lowercase| +% primitive governing this code before the definition of this +% macro actually takes place. +% That means that +% it takes the line, puts |\end| (four character tokens) +% and |\@nil| (one control sequence token) as a +% delimiter behind it, and +% then calls |\verbatim@@|. +% \end{macro} +% +% \begin{macro}{\verbatim@@} +% |\verbatim@@| takes everything up to the next occurrence of +% the four characters |\end| as its argument. +% \begin{macrocode} + \def\verbatim@@#1!end{% +% \end{macrocode} +% That means: if they do not occur in the original line, then +% argument |#1| is the +% whole input line, and |\@nil| is the next token +% to be processed. +% However, if the four characters |\end| are part of the +% original line, then +% |#1| consists of the characters in front of |\end|, +% and the next token is the following character (always remember +% that the line was lengthened by five tokens). +% Whatever |#1| may be, it is verbatim text, +% so |#1| is added to the line currently built. +% \begin{macrocode} + \verbatim@addtoline{#1}% +% \end{macrocode} +% The next token in the input stream +% is of special interest to us. +% Therefore |\futurelet| defines |\next| to be equal +% to it before calling |\verbatim@@@|. +% \begin{macrocode} + \futurelet\next\verbatim@@@}% +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\verbatim@@@} +% \changes{v1.1a}{1989/10/16}{Replaced \cs{verbatim@@@} by +% \cs{@nil} where used as delimiter.} +% |\verbatim@@@| will now read the rest of the tokens on +% the current line, +% up to the final |\@nil| token. +% \begin{macrocode} + \def\verbatim@@@#1\@nil{% +% \end{macrocode} +% If the first of the above two cases occurred, i.e.\ no +% |\end| characters were on that line, |#1| is empty +% and |\next| is equal to |\@nil|. +% This is easily checked. +% \begin{macrocode} + \ifx\next\@nil +% \end{macrocode} +% If so, this was a simple line. +% We finish it by processing the line we accumulated so far. +% Then we prepare to read the next line. +% \changes{v1.2f}{1990/01/31}{Added \cs{verbatim@startline}.} +% \begin{macrocode} + \verbatim@processline + \verbatim@startline + \let\next\verbatim@ +% \end{macrocode} +% Otherwise we have to check what follows these |\end| +% tokens. +% \begin{macrocode} + \else +% \end{macrocode} +% Before we continue, it's a good idea to stop for a moment +% and remember where we are: +% We have just read the four character tokens |\end| +% and must now check whether the name of the environment (surrounded +% by braces) follows. +% To this end we define a macro called |\@tempa| +% that reads exactly one character and decides what to do next. +% This macro should do the following: skip spaces until +% it encounters either a left brace or the end of the line. +% But it is important to remember which characters are skipped. +% The |\end|\meta{optional spaces}|{| characters +% may be part of the verbatim text, i.e.\ these characters +% must be printed. +% +% Assume for example that the current line contains +% \begin{verbatim*} +% \end {AVeryLongEnvironmentName} +%\end{verbatim*} +% As we shall soon see, the scanning mechanism implemented here +% will not find out that this is text to be printed until +% it has read the right brace. +% Therefore we need a way to accumulate the characters read +% so that we can reinsert them if necessary. +% The token register |\@temptokena| is used for this purpose. +% +% Before we do this we have to get rid of the superfluous +% |\end| tokens at the end of the line. +% \changes{v1.4j}{1992/06/30}{Removed use of \cs{toks@}. Suggested by +% Bernd Raichle.} +% To this end we define a temporary macro whose argument +% is delimited by |\end\@nil| (four character tokens +% and one control sequence token) to be used below +% on the rest of the line, after appending a |\@nil| token to it. +% (Note that this token can never appear in |#1|.) +% We use the following definition of +% |\@tempa| to get the rest of the line (after the first +% |\end|). +% \begin{macrocode} + \def\@tempa##1!end\@nil{##1}% +% \end{macrocode} +% We mentioned already that we use token register +% |\@temptokena| +% to remember the characters we skip, in case we need them again. +% We initialize this with the |\end| we have thrown away +% in the call to |\@tempa|. +% \begin{macrocode} + \@temptokena{!end}% +% \end{macrocode} +% We shall now call |\verbatim@test| +% to process the characters +% remaining on the current line. +% But wait a moment: we cannot simply call this macro +% since we have already read the whole line. +% Therefore we have to first expand the macro |\@tempa| to insert +% them again after the |\verbatim@test| token. +% A |^^M| character is appended to denote the end of the line. +% (Remember that this character comes disguised as a tilde.) +% \changes{v1.2}{1989/10/20}{Taken local definition of \cs{@tempa} out +% of \cs{verbatim@@@} and introduced +% \cs{verbatim@test} instead.} +% \begin{macrocode} + \def\next{\expandafter\verbatim@test\@tempa#1\@nil~}% +% \end{macrocode} +% That's almost all, but we still have to +% now call |\next| to do the work. +% \begin{macrocode} + \fi \next}% +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\verbatim@test} +% \changes{v1.2}{1989/10/20}{Introduced \cs{verbatim@test}.} +% We define |\verbatim@test| to investigate every token +% in turn. +% \begin{macrocode} + \def\verbatim@test#1{% +% \end{macrocode} +% First of all we set |\next| equal to |\verbatim@test| +% in case this macro must call itself recursively in order to +% skip spaces. +% \begin{macrocode} + \let\next\verbatim@test +% \end{macrocode} +% We have to distinguish four cases: +% \begin{enumerate} +% \item The next token is a |^^M|, i.e.\ we reached +% the end of the line. That means that nothing +% special was found. +% Note that we use |\if| for the following +% comparisons so that the category code of the +% characters is irrelevant. +% \begin{macrocode} + \if\noexpand#1\noexpand~% +% \end{macrocode} +% We add the characters accumulated in token register +% |\@temptokena| to the current line. Since +% |\verbatim@addtoline| does not expand its argument, +% we have to do the expansion at this point. Then we +% |\let| |\next| equal to |\verbatim@| +% to prepare to read the next line. +% \changes{v1.2f}{1990/01/31}{Added \cs{verbatim@startline}.} +% \begin{macrocode} + \expandafter\verbatim@addtoline + \expandafter{\the\@temptokena}% + \verbatim@processline + \verbatim@startline + \let\next\verbatim@ +% \end{macrocode} +% \item A space character follows. +% This is allowed, so we add it to |\@temptokena| +% and continue. +% \begin{macrocode} + \else \if\noexpand#1 + \@temptokena\expandafter{\the\@temptokena#1}% +% \end{macrocode} +% \changes{v1.2f}{1990/01/31}{Code for TABs removed.} +% \item An open brace follows. +% This is the most interesting case. +% We must now collect characters until we read the closing +% brace and check whether they form the environment name. +% This will be done by |\verbatim@testend|, so here +% we let |\next| equal this macro. +% Again we will process the rest of the line, character +% by character. +% \changes{v1.2}{1989/10/20}{Moved the initialization of +% \cs{@tempc} from \cs{verbatim@testend} into +% \cs{verbatim@test}.} +% The characters forming the name of the environment will +% be accumulated in |\@tempc|. +% We initialize this macro to expand to nothing. +% \changes{v1.3b}{1990/02/07}{\cs{noexpand} added.} +% \begin{macrocode} + \else \if\noexpand#1\noexpand[% + \let\@tempc\@empty + \let\next\verbatim@testend +% \end{macrocode} +% Note that the |[| character will be a |{| when +% this macro is defined. +% \item Any other character means that the |\end| was part +% of the verbatim text. +% Add the characters to the current line and prepare to call +% |\verbatim@| to process the rest of the line. +% \changes{v1.0f}{1989/10/09}{Fixed \cs{end} \cs{end} bug +% found by Chris Rowley} +% \begin{macrocode} + \else + \expandafter\verbatim@addtoline + \expandafter{\the\@temptokena}% + \def\next{\verbatim@#1}% + \fi\fi\fi +% \end{macrocode} +% \end{enumerate} +% The last thing this macro does is to call |\next| +% to continue processing. +% \begin{macrocode} + \next}% +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\verbatim@testend} +% |\verbatim@testend| is called when +% |\end|\meta{optional spaces}|{| was seen. +% Its task is to scan everything up to the next |}| +% and to call |\verbatim@@testend|. +% If no |}| is found it must reinsert the characters it read +% and return to |\verbatim@|. +% The following definition is similar to that of +% |\verbatim@test|: +% it takes the next character and decides what to do. +% \changes{v1.2}{1989/10/20}{Removed local definition of \cs{@tempa} +% from \cs{verbatim@testend} which now +% does the work itself.} +% \begin{macrocode} + \def\verbatim@testend#1{% +% \end{macrocode} +% Again, we have four cases: +% \begin{enumerate} +% \item |^^M|: As no |}| is found in the current line, +% add the characters to the buffer. To avoid a +% complicated construction for expanding +% |\@temptokena| +% and |\@tempc| we do it in two steps. Then we +% continue with |\verbatim@| to process the +% next line. +% \changes{v1.2f}{1990/01/31}{Added \cs{verbatim@startline}.} +% \begin{macrocode} + \if\noexpand#1\noexpand~% + \expandafter\verbatim@addtoline + \expandafter{\the\@temptokena[}% + \expandafter\verbatim@addtoline + \expandafter{\@tempc}% + \verbatim@processline + \verbatim@startline + \let\next\verbatim@ +% \end{macrocode} +% \item |}|: Call |\verbatim@@testend| to check +% if this is the right environment name. +% \changes{v1.3b}{1990/02/07}{\cs{noexpand} added.} +% \begin{macrocode} + \else\if\noexpand#1\noexpand]% + \let\next\verbatim@@testend +% \end{macrocode} +% \changes{v1.0f}{1989/10/09}{Introduced check for +% {\tt\string\verb!\string|!\string\!\string|} to fix +% single brace bug found by Chris Rowley} +% \item |\|: This character must not occur in the name of +% an environment. Thus we stop collecting characters. +% In principle, the same argument would apply to other +% characters as well, e.g., |{|. +% However, |\| is a special case, since it may be +% the first character of |\end|. This means that +% we have to look again for +% |\end{|\meta{environment name}|}|. +% Note that we prefixed the |!| by a |\noexpand| +% primitive, to protect ourselves against it being an +% active character. +% \changes{v1.3b}{1990/02/07}{\cs{noexpand} added.} +% \begin{macrocode} + \else\if\noexpand#1\noexpand!% + \expandafter\verbatim@addtoline + \expandafter{\the\@temptokena[}% + \expandafter\verbatim@addtoline + \expandafter{\@tempc}% + \def\next{\verbatim@!}% +% \end{macrocode} +% \item Any other character: collect it and continue. +% We cannot use |\edef| to define |\@tempc| +% since its replacement text might contain active +% character tokens. +% \begin{macrocode} + \else \expandafter\def\expandafter\@tempc\expandafter + {\@tempc#1}\fi\fi\fi +% \end{macrocode} +% \end{enumerate} +% As before, the macro ends by calling itself, to +% process the next character if appropriate. +% \begin{macrocode} + \next}% +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\verbatim@@testend} +% Unlike the previous macros |\verbatim@@testend| is simple: +% it has only to check if the |\end{|\ldots|}| +% matches the corresponding |\begin{|\ldots|}|. +% \begin{macrocode} + \def\verbatim@@testend{% +% \end{macrocode} +% We use |\next| again to define the things that are +% to be done. +% Remember that the name of the current environment is +% held in |\@currenvir|, the characters accumulated +% by |\verbatim@testend| are in |\@tempc|. +% So we simply compare these and prepare to execute +% |\end{|\meta{current environment}|}| +% macro if they match. +% Before we do this we call |\verbatim@finish| to process +% the last line. +% We define |\next| via |\edef| so that +% |\@currenvir| is replaced by its expansion. +% Therefore we need |\noexpand| to inhibit the expansion +% of |\end| at this point. +% \begin{macrocode} + \ifx\@tempc\@currenvir + \verbatim@finish + \edef\next{\noexpand\end{\@currenvir}% +% \end{macrocode} +% Without this trick the |\end| command would not be able +% to correctly check whether its argument matches the name of +% the current environment and you'd get an +% interesting \LaTeX{} error message such as: +% \begin{verbatim} +%! \begin{verbatim*} ended by \end{verbatim*}. +%\end{verbatim} +% But what do we do with the rest of the characters, those +% that remain on that line? +% We call |\verbatim@rescan| to take care of that. +% Its first argument is the name of the environment just +% ended, in case we need it again. +% |\verbatim@rescan| takes the list of characters to be +% reprocessed as its second argument. +% (This token list was inserted after the current macro +% by |\verbatim@@@|.) +% Since we are still in an |\edef| we protect it +% by means of|\noexpand|. +% \begin{macrocode} + \noexpand\verbatim@rescan{\@currenvir}}% +% \end{macrocode} +% If the names do not match, we reinsert everything read up +% to now and prepare to call |\verbatim@| to process +% the rest of the line. +% \begin{macrocode} + \else + \expandafter\verbatim@addtoline + \expandafter{\the\@temptokena[}% + \expandafter\verbatim@addtoline + \expandafter{\@tempc]}% + \let\next\verbatim@ + \fi +% \end{macrocode} +% Finally we call |\next|. +% \begin{macrocode} + \next}% +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\verbatim@rescan} +% In principle |\verbatim@rescan| could be used to +% analyse the characters remaining after the |\end{...}| +% command and pretend that these were read +% ``properly'', assuming ``standard'' category codes are in +% force.\footnote{Remember that they were all read with +% category codes $11$ (letter) and $12$ (other) so +% that control sequences are not recognized as such.} +% But this is not always possible (when there are unmatched +% curly braces in the rest of the line). +% Besides, we think that this is not worth the effort: +% After a \texttt{verbatim} or \texttt{verbatim*} environment +% a new line in the output is begun anyway, +% and an |\end{comment}| can easily be put on a line by itself. +% So there is no reason why there should be any text here. +% For the benefit of the user who did put something there +% (a comment, perhaps) +% we simply issue a warning and drop them. +% The method of testing is explained in Appendix~D, p.\ 376 of +% the \TeX{}book. We use |^^M| instead of the |!| +% character used there +% since this is a character that cannot appear in |#1|. +% The two |\noexpand| primitives are necessary to avoid +% expansion of active characters and macros. +% +% One extra subtlety should be noted here: remember that +% the token list we are currently building will first be +% processed by the |\lowercase| primitive before \TeX{} +% carries out the definitions. +% This means that the `|C|' character in the +% argument to the |\@warning| macro must be protected against +% being changed to `|c|'. That's the reason why we added the +% |\lccode`\C=`\C| assignment above. +% We can now finish the argument to |\lowercase| as well as the +% group in which the category codes were changed. +% \begin{macrocode} + \def\verbatim@rescan#1#2~{\if\noexpand~\noexpand#2~\else + \@warning{Characters dropped after `\string\end{#1}'}\fi}} +% \end{macrocode} +% \end{macro} +% +% \subsection{The \cs{verbatiminput} command} +% +% \begin{macro}{\verbatim@in@stream} +% We begin by allocating an input stream (out of the 16 available +% input streams). +%\iffalse +% Vorstellbar ist auch der Aufruf von |`verbatiminput| innerhalb eines +% |`verbatiminput| (z.B: wenn man |`input|-Anweisungen im zu lesenden +% File hat und auch diese Files automatisch lesen will). Dies kann +% man jedoch nur ermoeglichen, wenn man einen besseren Mechanismus +% verwendet als es das simple, statische |`newread| darstellt. +% Vorstellbar fuer eine neuere \LaTeX-Version ist eine (lokale) +% Allokation des Streams durch ein |`open| und eine Freigabe des +% Streams durch |`close| oder Verlassen der Gruppe. +%\fi +% \begin{macrocode} +\newread\verbatim@in@stream +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\verbatim@readfile} +% The macro |\verbatim@readfile| encloses the main loop by calls to +% the macros |\verbatim@startline| and |\verbatim@finish|, +% respectively. This makes sure +% that the user can initialize and finish the command when the file +% is empty or doesn't exist. The \texttt{verbatim} environment has a +% similar behaviour when called with an empty text. +% \begin{macrocode} +\def\verbatim@readfile#1{% + \verbatim@startline +% \end{macrocode} +% When the file is not found we issue a warning. +% \begin{macrocode} + \openin\verbatim@in@stream #1\relax + \ifeof\verbatim@in@stream + \typeout{No file #1.}% + \else +% \end{macrocode} +% At this point we pass the name of the file to |\@addtofilelist| +% so that its appears appears in the output of a |\listfiles| +% command. +% \changes{v1.5j}{1996/09/25}{Add \cs{@addtofilelist} and +% \cs{ProvidesFile} so that the name of the file +% read in appears in the \cs{listfiles} output (Omission pointed +% out by Patrick W.~Daly).} +% In addition, we use |\ProvidesFile| to make a log entry in the +% transcript file and to distinguish files read in via +% |\verbatiminput| from others. +% \begin{macrocode} + \@addtofilelist{#1}% + \ProvidesFile{#1}[(verbatim)]% +% \end{macrocode} +% While reading from the file it is useful to switch off the +% recognition of the end-of-line character. This saves us stripping +% off spaces from the contents of the line. +% \begin{macrocode} + \expandafter\endlinechar\expandafter\m@ne + \expandafter\verbatim@read@file + \expandafter\endlinechar\the\endlinechar\relax + \closein\verbatim@in@stream + \fi + \verbatim@finish +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\verbatim@read@file} +% All the work is done in |\verbatim@read@file|. It reads the input +% file line by line and recursively calls itself until the end of +% the file. +% \begin{macrocode} +\def\verbatim@read@file{% + \read\verbatim@in@stream to\next + \ifeof\verbatim@in@stream + \else +% \end{macrocode} +% For each line we call |\verbatim@addtoline| with the contents of +% the line. \hskip0pt plus 3cm\penalty0\hskip0pt plus -3cm +% |\verbatim@processline| is called next. +% \begin{macrocode} + \expandafter\verbatim@addtoline\expandafter{\next}% + \verbatim@processline +% \end{macrocode} +% After processing the line we call |\verbatim@startline| to +% initialize all before we read the next line. +% \begin{macrocode} + \verbatim@startline +% \end{macrocode} +% Without |\expandafter| each call of |\verbatim@read@file| uses +% space in \TeX's input stack.\footnote{A standard \TeX\ would +% report an overflow error if you try to read a file with more than +% ca.\ 200~lines. The same error occurs if the first line of code +% in \S 390 of \textsl{``TeX: The Program''\/} is missing.} +% \begin{macrocode} + \expandafter\verbatim@read@file + \fi +} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\verbatiminput} +% |\verbatiminput| first starts a group to keep font and category +% changes local. +% Then it calls the macro |\verbatim@input| with additional +% arguments, depending on whether an asterisk follows. +% \begin{macrocode} +\def\verbatiminput{\begingroup + \@ifstar{\verbatim@input\relax}% + {\verbatim@input{\frenchspacing\@vobeyspaces}}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\verbatim@input} +% \changes{1.5k}{1997/04/30}{Have \cs{verbatim@input} check for +% existence of file.} +% |\verbatim@input| first checks whether the file exists, using +% the standard macro |\IfFileExists| which leaves the name of the +% file found in |\@filef@und|. +% Then everything is set up as in the |\verbatim| macro. +% \begin{macrocode} +\def\verbatim@input#1#2{% + \IfFileExists {#2}{\@verbatim #1\relax +% \end{macrocode} +% Then it reads in the file, finishes off the \texttt{trivlist} +% environment started by |\@verbatim| and closes the group. +% This restores everything to its normal settings. +% \begin{macrocode} + \verbatim@readfile{\@filef@und}\endtrivlist\endgroup\@doendpe}% +% \end{macrocode} +% If the file is not found a more or less helpful message is +% printed. The final |\endgroup| is needed to close the group +% started in |\verbatiminput| above. +% \begin{macrocode} + {\typeout {No file #2.}\endgroup}} +%</package> +% \end{macrocode} +% \end{macro} +% +% +% \subsection{Getting verbatim text into arguments.} +% +% One way of achieving this is to define a macro (command) whose +% expansion is the required verbatim text. This command can then be +% used anywhere that the verbatim text is required. It can be used in +% arguments, even moving ones, but it is fragile (at least, the +% version here is). +% +% Here is some code which claims to provide this. It is a much revised +% version of something I (Chris) did about 2 years ago. Maybe it needs +% further revision. +% +% It is only intended as an extension to |\verb|, not to the +% \texttt{verbatim} environment. It should therefore, perhaps, treat +% line-ends similarly to whatever is best for |\verb|. +% +% \begin{macro}{\newverbtext} +% This is the command to produce a new macro whose expansion is +% verbatim text. This command itself cannot be used in arguments, +% of course! It is used as follows: +% +% \begin{verbatim} +% \newverbtext{\myverb}"^%{ &~_\}}@ #" +% \end{verbatim} +% +% The rules for delimiting the verbatim text are the same as those for +% |\verb|. +% +% \begin{macrocode} +%<*verbtext> +\def \newverbtext {% + \@ifstar {\@tempswatrue \@verbtext }{\@tempswafalse \@verbtext *}% +} +% \end{macrocode} +% \end{macro} +% I think that a temporary switch is safe here: if not, then +% suitable |\let|s can be used. +% \changes{v1.5i}{1996/06/04}{Moved processing of +% \cs{verbatim@nolig@list} after \cs{dospecials}.} +% \changes{v1.5p}{2001/03/12}{Added missing right brace in +% definition of \cs{@verbtext} (PR 3314).} +% \begin{macrocode} +\def \@verbtext *#1#2{% + \begingroup + \let\do\@makeother \dospecials + \let\do\do@noligs \verbatim@nolig@list + \@vobeyspaces + \catcode`#2\active + \catcode`~\active + \lccode`\~`#2% + \lowercase +% \end{macrocode} +% We use a temporary macro here and a trick so that the definition of +% the command itself can be done inside the group and be a local +% definition (there may be better ways to achieve this). +% \begin{macrocode} + {\def \@tempa ##1~% + {\whitespaces +% \end{macrocode} +% If these |\noexpand|s were |\noexpand\protect\noexpand|, would +% this make these things robust? +% \begin{macrocode} + \edef #1{\noexpand \@verbtextmcheck + \bgroup + \if@tempswa + \noexpand \visiblespaces + \fi + \noexpand \@verbtextsetup + ##1% + \egroup}% + }% + \expandafter\endgroup\@tempa + } +} +% \end{macrocode} +% This sets up the correct type of group for the mode: it must not +% be expanded at define time! +% \begin{macrocode} +\def \@verbtextmcheck {% + \relax\ifmmode + \hbox + \else + \leavevmode + \null + \fi +} +% \end{macrocode} +% This contains other things which should not be expanded during the +% definition. +% \begin{macrocode} +\def \@verbtextsetup {% + \frenchspacing + \verbatim@font + \verbtextstyle +} +% \end{macrocode} +% The command |\verbtextstyle| is a document-level hook which can be +% used to override the predefined typographic treatment of commands +% defined with |\newverbtext| commands. +% +% |\visiblespaces| and |\whitespaces| are examples of possible values +% of this hook. +% \begin{macrocode} +\let \verbtextstyle \relax +\def \visiblespaces {\chardef \ 32\relax} +\def \whitespaces {\let \ \@@space} +\let \@@space \ % +%</verbtext> +% \end{macrocode} +% +% +% \section{Testing the implementation} +% +% For testing the implementation and for demonstration we provide +% an extra file. It can be extracted by using the conditional +% `\textsf{testdriver}'. It uses a small input file called +% `\texttt{verbtest.tst}' that is distributed separately. +% Again, we use individual `+' guards. +% \begin{macrocode} +%<*testdriver> +\documentclass{article} + +\usepackage{verbatim} + +\newenvironment{myverbatim}% + {\endgraf\noindent MYVERBATIM:\endgraf\verbatim}% + {\endverbatim} + +\makeatletter + +\newenvironment{verbatimlisting}[1]% + {\def\verbatim@startline{\input{#1}% + \def\verbatim@startline{\verbatim@line{}}% + \verbatim@startline}% + \verbatim}{\endverbatim} + +\newwrite\verbatim@out + +\newenvironment{verbatimwrite}[1]% + {\@bsphack + \immediate\openout \verbatim@out #1 + \let\do\@makeother\dospecials\catcode`\^^M\active + \def\verbatim@processline{% + \immediate\write\verbatim@out{\the\verbatim@line}}% + \verbatim@start}% + {\immediate\closeout\verbatim@out\@esphack} + +\makeatother + +\addtolength{\textwidth}{30pt} + +\begin{document} + +\typeout{} +\typeout{===> Expect ``characters dropped'' + warning messages in this test! <====} +\typeout{} + +Text Text Text Text Text Text Text Text Text Text Text +Text Text Text Text Text Text Text Text Text Text Text +Text Text Text Text Text Text Text Text Text Text Text + \begin{verbatim} + test + \end{verbatim*} + test + \end{verbatim + test of ligatures: <`!`?`> + \endverbatim + test + \end verbatim + test + test of end of line: + \end + {verbatim} + \end{verbatim} Further text to be typeset: $\alpha$. +Text Text Text Text Text Text Text Text Text Text Text +Text Text Text Text Text Text Text Text Text Text Text +Text Text Text Text Text Text Text Text Text Text Text + \begin{verbatim*} + test + test + \end {verbatim*} +Text Text Text Text Text Text Text Text Text Text Text +Text Text Text Text Text Text Text Text Text Text Text +Text Text Text Text Text Text Text Text Text Text Text + \begin{verbatim*} bla bla + test + test + \end {verbatim*} +Text Text Text Text Text Text Text Text Text Text Text +Text Text Text Text Text Text Text Text Text Text Text +Text Text Text Text Text Text Text Text Text Text Text +Text Text Text Text Text Text Text Text Text Text Text + +First of Chris Rowley's fiendish tests: +\begin{verbatim} +the double end test<text> +\end\end{verbatim} or even \end \end{verbatim} +% +%not \end\ended?? +%\end{verbatim} + +Another of Chris' devils: +\begin{verbatim} +the single brace test<text> +\end{not the end\end{verbatim} +% +%not \end}ed?? +%\end{verbatim} +Back to my own tests: + \begin{myverbatim} + test + test + \end {myverbatim} rest of line +Text Text Text Text Text Text Text Text Text Text Text +Text Text Text Text Text Text Text Text Text Text Text +Text Text Text Text Text Text Text Text Text Text Text + +Test of empty verbatim: +\begin{verbatim} +\end{verbatim} +Text Text Text Text Text Text Text Text Text Text Text +Text Text Text Text Text Text Text Text Text Text Text +Text Text Text Text Text Text Text Text Text Text Text + \begin {verbatimlisting}{verbtest.tex} + Additional verbatim text + ... + \end{verbatimlisting} +And here for listing a file: + \verbatiminput{verbtest.tex} +And again, with explicit spaces: + \verbatiminput*{verbtest.tex} +Text Text Text Text Text Text Text Text Text Text Text +Text Text Text Text Text Text Text Text Text Text Text +Text Text Text Text Text Text Text Text Text Text Text + \begin{comment} + test + \end{verbatim*} + test + \end {comment + test + \endverbatim + test + \end verbatim + test + \end {comment} Further text to be typeset: $\alpha$. +Text Text Text Text Text Text Text Text Text Text Text +Text Text Text Text Text Text Text Text Text Text Text +Text Text Text Text Text Text Text Text Text Text Text + \begin{comment} bla bla + test + test + \end {comment} +Text Text Text Text Text Text Text Text Text Text Text +Text Text Text Text Text Text Text Text Text Text Text +Text Text Text Text Text Text Text Text Text Text Text +Text Text Text Text Text Text Text Text Text Text Text + +\begin{verbatimwrite}{verbtest.txt} +asfa<fa<df +sdfsdfasd +asdfa<fsa +\end{verbatimwrite} + +\end{document} +%</testdriver> +% \end{macrocode} +% +% +% \Finale +% +\endinput +%% diff --git a/macros/latex-dev/required/tools/verbatim.pdf b/macros/latex-dev/required/tools/verbatim.pdf Binary files differnew file mode 100644 index 0000000000..14ed89c8ec --- /dev/null +++ b/macros/latex-dev/required/tools/verbatim.pdf diff --git a/macros/latex-dev/required/tools/xr.dtx b/macros/latex-dev/required/tools/xr.dtx new file mode 100644 index 0000000000..417a98c1c1 --- /dev/null +++ b/macros/latex-dev/required/tools/xr.dtx @@ -0,0 +1,186 @@ +% \iffalse meta-comment +% +% Copyright (C) 1993-2019 +% +% The LaTeX3 Project and any individual authors listed elsewhere +% in this file. +% +% This file is part of the Standard LaTeX `Tools Bundle'. +% ------------------------------------------------------- +% +% It may be distributed and/or modified under the +% conditions of the LaTeX Project Public License, either version 1.3c +% of this license or (at your option) any later version. +% The latest version of this license is in +% https://www.latex-project.org/lppl.txt +% and version 1.3c or later is part of all distributions of LaTeX +% version 2005/12/01 or later. +% +% The list of all files belonging to the LaTeX `Tools Bundle' is +% given in the file `manifest.txt'. +% +% \fi +% \iffalse +%% File: xr.dtx Copyright (C) 1993-2019 David Carlisle +% +%<package>\NeedsTeXFormat{LaTeX2e} +%<package>\ProvidesPackage{xr} +%<package> [2019/07/22 v5.05 eXternal References (DPC)] +% +%<*driver> +\documentclass{ltxdoc} +\usepackage{xr} +\GetFileInfo{xr.sty} +\begin{document} +\title{The \textsf{xr} package\thanks{This file + has version number \fileversion, last + revised \filedate.}} +\author{David Carlisle\thanks{% + The Author of Versions 1--4 was Jean-Pierre Drucbert}} +\date{\filedate} +\MaintainedByLaTeXTeam{tools} +\maketitle +\DocInput{xr.dtx} +\end{document} +%</driver> +% \fi +% +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% +% \changes{v5.00}{1993/07/07} +% {First DPC version (by agreement with J-PD). New mechanism +% (\cmd{\read} instead of \cmd\input).} +% +% \changes{v5.01}{1993/07/20}{Fix bug added by DPC, v5.00 did not import +% aux files of \cmd\include'ed files. (Reported by J-PD)} +% +% \changes{v5.02}{1994/05/28}{Update for LaTeX2e} +% \changes{v5.03}{2018/10/01}{Fix for conditionals in aux file} +% \changes{v5.05}{2019/07/20}{include xcite} +% +% +% This package implements a system for eXternal References. +% +% If one document needs to refer to sections of another, say |aaa.tex|, +% then this package may be loaded in the main file, and the command\\ +% |\externaldocument{aaa}|\\ +% given in the preamble. +% +% Then you may use |\ref| and |\pageref| to refer to anything which has +% been given a |\label| in either |aaa.tex| or the main document. +% You may declare any number of such external documents. +% +% If any of the external documents, or the main document, use the same +% |\label| then an error will occur as the label will be multiply +% defined. To overcome this problem |\externaldocument| has an optional +% argument. If you declare |\externaldocument[A-]{aaa}| Then all +% references from |aaa| are prefixed by |A-|. So for instance, if a +% section of |aaa| had |\label{intro}|, then this could be referenced +% with |\ref{A-intro}|. The prefix need not be |A-|, it can be any +% string chosen to ensure that all the labels imported from external +% files are unique. Note however that if your style declares certain +% active characters (|:| in French, |"| in German) then these +% characters can not usually be used in |\label|, and similarly may not +% be used in the optional argument to |\externaldocument|. +% +% As first suggested in Enrico Gregorio's |xcite| package, the current version +% also allows |\cite| to reference |\bibitem| in the external document. +% For fcompatibility with |xcite|, |\externalcitedocument| is made available +% as an alias for |\externaldocument| +% +% \StopEventually{} +% +% \section{The macros} +% +% \begin{macrocode} +%<*package> +% \end{macrocode} +% +% Check for the optional argument. +% \begin{macrocode} +\def\externaldocument{\@ifnextchar[\XR@{\XR@[]}} +\let\externalcitedocument\externaldocument +% \end{macrocode} +% +% Save the optional prefix. Start processing the first |aux| file. +% \begin{macrocode} +\def\XR@[#1]#2{{% + \makeatletter + \def\XR@prefix{#1}% + \XR@next#2.aux\relax\\}} +% \end{macrocode} +% +% Process the next |aux| file in the list and remove it from the head of +% the list of files to process. +% \begin{macrocode} +\def\XR@next#1\relax#2\\{% + \edef\XR@list{#2}% + \XR@loop{#1}} +% \end{macrocode} +% +% Check whether the list of |aux| files is empty. +% \begin{macrocode} +\def\XR@aux{% + \ifx\XR@list\@empty\else\expandafter\XR@explist\fi} +% \end{macrocode} +% + +% Expand the list of aux files, and call |\XR@next| to process the first +% one. +% \begin{macrocode} +\def\XR@explist{\expandafter\XR@next\XR@list\\} +% \end{macrocode} +% +% If the |aux| file exists, loop through line by line, looking for +% |\newlabel| and |\@input|. Otherwise process the next file in the +% list. +% \begin{macrocode} +\def\XR@loop#1{\openin\@inputcheck#1\relax + \ifeof\@inputcheck + \PackageWarning{xr}{^^JNo file #1^^JLABELS NOT IMPORTED.^^J}% + \expandafter\XR@aux + \else + \PackageInfo{xr}{IMPORTING LABELS FROM #1}% + \expandafter\XR@read\fi} +% \end{macrocode} +% +% Read the next line of the aux file. +% \begin{macrocode} +\def\XR@read{% + \read\@inputcheck to\XR@line +% \end{macrocode} +% The |...| make sure that |\XR@test| always has sufficient arguments. +% \begin{macrocode} + \expandafter\XR@test\XR@line...\XR@} +% \end{macrocode} +% +% Look at the first token of the line. +% If it is |\newlabel|, do the |\newlabel|. If it is |\@input|, add the +% filename to the list of files to process. Otherwise ignore. +% Go around the loop if not at end of file. Finally process the next +% file in the list. +% +% 2018 update: make sure the arguments are handled outside the |\ifx| test, +% \begin{macrocode} +\long\def\XR@test#1#2#3#4\XR@{% + \let\XR@tempa\@gobbletwo + \ifx#1\newlabel + \let\XR@tempa\@firstoftwo + \else\ifx#1\bibcite + \let\XR@tempa\@firstoftwo + \else\ifx#1\@input + \let\XR@tempa\@secondoftwo + \fi\fi\fi + \XR@tempa{#1{\XR@prefix#2}{#3}}{\edef\XR@list{\XR@list#2\relax}}% + \ifeof\@inputcheck\expandafter\XR@aux + \else\expandafter\XR@read\fi} +% \end{macrocode} +% +% \begin{macrocode} +%</package> +% \end{macrocode} +% +% \Finale +% + diff --git a/macros/latex-dev/required/tools/xr.pdf b/macros/latex-dev/required/tools/xr.pdf Binary files differnew file mode 100644 index 0000000000..c051173362 --- /dev/null +++ b/macros/latex-dev/required/tools/xr.pdf diff --git a/macros/latex-dev/required/tools/xspace.dtx b/macros/latex-dev/required/tools/xspace.dtx new file mode 100644 index 0000000000..0745caf507 --- /dev/null +++ b/macros/latex-dev/required/tools/xspace.dtx @@ -0,0 +1,507 @@ +% \iffalse meta-comment +% +% Copyright (C) 1993-2019 +% +% The LaTeX3 Project and any individual authors listed elsewhere +% in this file. +% +% This file is part of the Standard LaTeX `Tools Bundle'. +% ------------------------------------------------------- +% +% It may be distributed and/or modified under the +% conditions of the LaTeX Project Public License, either version 1.3c +% of this license or (at your option) any later version. +% The latest version of this license is in +% https://www.latex-project.org/lppl.txt +% and version 1.3c or later is part of all distributions of LaTeX +% version 2005/12/01 or later. +% +% The list of all files belonging to the LaTeX `Tools Bundle' is +% given in the file `manifest.txt'. +% +% \fi +% \iffalse +%% File: xspace.dtx Copyright (C) 1991-1997 David Carlisle +%% File: xspace.dtx Copyright (C) 2004-2006 David Carlisle, +%% Morten H\o gholm +% +%<*dtx> + \ProvidesFile{xspace.dtx} +%</dtx> +%<package>\NeedsTeXFormat{LaTeX2e} +%<package>\ProvidesPackage{xspace} +%<driver>\ProvidesFile{xspace.drv} +% \fi +% \ProvidesFile{xspace.dtx} + [2014/10/28 v1.13 Space after command names (DPC,MH)] +% +% \iffalse +%<*driver> +\documentclass{ltxdoc} +\makeatletter +\providecommand*\eTeX{{% + \if b\expandafter\@car\f@series\@nil\boldmath\fi$\m@th + \varepsilon$-\TeX}} +\makeatother +\usepackage{xspace}[2006/05/08] +\begin{document} +\DocInput{xspace.dtx} +\end{document} +%</driver> +% \fi +% +% \GetFileInfo{xspace.dtx} +% \title{The \textsf{xspace} package\thanks{This file +% has version number \fileversion, last +% revised \filedate.}} +% \author{David Carlisle \and Morten H\o gholm} +% \date{\filedate} +% \MaintainedByLaTeXTeam{tools} +% \maketitle +% +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% +% \changes{v1.00}{1991/08/30}{Initial version} +% \changes{v1.01}{1992/06/26}{Re-issue for the new doc and docstrip} +% \changes{v1.02}{1994/01/31}{Re-issue for LaTeX2e (no change to +% code)} +% \changes{v1.07}{2004/12/07}{Make extensible. tools/3712} +% \changes{v1.07}{2004/12/07}{Fix active characters. tools/3747} +% \changes{v1.07}{2004/12/07}{Update documentation} +% \changes{v1.08}{2005/05/07}{Better fix for active characters} +% \changes{v1.09}{2005/07/26}{Improve test by exiting if +% \cs{@let@token} is a letter} +% \changes{v1.10}{2005/10/04}{Use higher level functions for +% conditional processing} +% \changes{v1.10}{2005/10/04}{Improve expansion method} +% +% \begin{abstract} +% |\xspace| should be used at the end of a macro designed to +% be used mainly in text. It adds a space unless the macro is +% followed by certain punctuation characters. +% \end{abstract} +% +% \section{Introduction} +% \newcommand{\gb}{Great Britain\xspace}\DescribeMacro{\xspace} +% After defining |\newcommand{\gb}{Great Britain\xspace}|, +% the command |\gb| will determine when to insert a space +% after itself and when not. Thus the input +% \begin{quote} +% |\gb is a very nice place to live.\\| \\ +% |\gb, a small island off the coast of France.\\|\\ +% |\gb\footnote{The small island off the coast of France.}|\\ +% |is a very nice place to live.| +% \end{quote} +% results in the output +% \begin{quote} +% \gb is a very nice place to live. \\ +% \gb, a small island off the coast of France.\\ +% \gb\footnote{The small island off the coast of France.} +% is a very nice place to live. +% \end{quote} +% |\xspace| saves the user from having to type \verb*+\ + or +% |{}| after most occurrences of a macro name in text. +% However if either of these constructions follows |\xspace|, +% a space is not added by |\xspace|. This means that it is +% safe to add |\xspace| to the end of an existing macro +% without making too many changes in your document. In particular, +% |\xspace| will always insert a space if the thing following it is +% a normal letter which is the usual case. +% +% Sometimes |\xspace| may make the wrong decision, and add a +% space when it is not required. There may be different +% reasons for this behavior but it can always be handled by +% following the macro with |{}|, as this has the effect of +% suppressing the space. +% +% +% \subsection{Adding new exceptions} +% +% One of the most common reasons for |\xspace| to add an +% unwanted space is when it is followed by a macro not on its +% list of exceptions. +% \DescribeMacro{\xspaceaddexceptions}% +% With |\xspaceaddexceptions| you can add new commands or +% characters to be recognized by |\xspace|'s scanning +% mechanism. Users of advanced footnote packages like +% \textsf{manyfoot} will often define new footnote macros +% that should not cause a command ``enhanced'' with |\xspace| +% to insert a space. If you define the additional footnote +% macros |\footnoteA| and |\footnoteB|, simply add the +% following line to your preamble: +% \begin{quote} +% |\xspaceaddexceptions{\footnoteA \footnoteB}| +% \end{quote} +% +% +% \subsection{Support for active characters} +% +% +% The other common instance of |\xspace| not working quite right +% happens with active characters. Generally this package must be +% loaded \emph{after} any language (or other) packages that make +% punctuation characters `active'. This makes it difficult for +% \textsf{xspace} to work flawlessly with the popular \textsf{babel} +% package especially since the punctuation characters can switch +% between being `active' and `other'. Starting at \textsf{xspace} +% version~1.08 there are two different ways to handle this depending +% on which engine your \LaTeX-format uses: +% \begin{description} +% \item[\TeX] The punctuation characters are added to the +% exception list in both their normal and active states thus +% ensuring that they are always recognized. +% \item[\eTeX] The characters are re-read when going through +% the exception list which means the internal comparison will test +% against the current state of the character. This works for +% whatever category code tricks some packages may use. +% \end{description} +% +% At the time of writing all major \TeX\ distributions are using +% \eTeX\ as engine for \LaTeX\ so usually everything should work out +% of the box. If you find that you're running normal \TeX\ and +% |\xspace| seems to be making the wrong choice then either use |{}| +% as described above to fix it or add the character to the list but +% with the desired category code. See the implementation for an example +% of how to do that. +% +% \subsection{Still not satisfied?} +% +% Some people don't like the default list of exceptions so they can +% remove one item at a time with the command +% \DescribeMacro{\xspaceremoveexception}^^A +% \cs{xspaceremoveexception}\marg{token}. Furthermore the command +% \DescribeMacro{\@xspace@hook}\cs{@xspace@hook} can be redefined to +% scan forward in the input stream in case you want to check more +% tokens. It is called after \cs{xspace} has determined if it needed +% to insert a space or if an exception was found (the default +% definition is for \cs{@xspace@hook} to be empty). Hence you can use +% \cs{unskip} to remove the space inserted if \cs{@let@token} matches +% something special. Below is an example of how one can make sure an +% endash gets a space inserted before it but a single dash not. +% \begin{verbatim} +% \xspaceremoveexception{-} +% \makeatletter +% \renewcommand*\@xspace@hook{% +% \ifx\@let@token-% +% \expandafter\@xspace@dash@i +% \fi +% } +% \def\@xspace@dash@i-{\futurelet\@let@token\@xspace@dash@ii} +% \def\@xspace@dash@ii{% +% \ifx\@let@token-% +% \else +% \unskip +% \fi +% -% +% } +% \makeatother +% \end{verbatim} +% +% +% \StopEventually{} +% +% \section{The Macros} +% +% |\xspace| peeks ahead for the next token. If the token is in our +% exception list we break the loop and do nothing; else we try to +% expand the token once and start over again. If this leads us to an +% unexpandable token without finding one of the exceptions we insert a +% space. +% +% \begin{macrocode} +%<*package> +% \end{macrocode} +% +% \begin{macro}{\xspace} +% |\xspace| just looks ahead, and then calls |\@xspace|. +% \changes{v1.03}{1994/11/15}{Make robust} +% \begin{macrocode} +\DeclareRobustCommand\xspace{\@xspace@firsttrue + \futurelet\@let@token\@xspace} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\if@xspace@first} +% \changes{v1.11}{2006/02/12}{Added macro} +% \begin{macro}{\@xspace@simple} +% \changes{v1.11}{2006/02/12}{Added macro} +% Some helpers to avoid multiple calls of |\@xspace@eTeX@setup|. +% \begin{macrocode} +\newif\if@xspace@first +\def\@xspace@simple{\futurelet\@let@token\@xspace} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\@xspace@exceptions@tlp} +% \changes{v1.07}{2004/12/07}{Added macro} +% The exception list. If the scanning mechanism finds one of +% these, it won't insert a space after the command. The +% \texttt{tlp} in the name means `token list pointer.' +% \begin{macrocode} +\def\@xspace@exceptions@tlp{% + ,.'/?;:!~-)\ \/\bgroup\egroup\@sptoken\space\@xobeysp + \footnote\footnotemark + \xspace@check@icr +} +% \end{macrocode} +% And here we get the non-empty definition of \cs{check@icr}. +% \changes{v1.13}{2009/10/20}{fix for "tools/3895": `text font commands fool xspace'} +% \begin{macrocode} +\begingroup + \text@command\relax + \global\let\xspace@check@icr\check@icr +\endgroup +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\xspaceaddexceptions} +% \changes{v1.07}{2004/12/07}{Added macro} +% The user command, which just adds tokens to the list. +% \begin{macrocode} +\newcommand*\xspaceaddexceptions{% + \g@addto@macro\@xspace@exceptions@tlp +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\xspaceremoveexception} +% \changes{v1.10}{2005/10/04}{Use higher level functions for +% conditional processing} +% This command removes an exception globally. +% \begin{macrocode} +\newcommand*\xspaceremoveexception[1]{% +% \end{macrocode} +% First check that it is in the list at all. +% \begin{macrocode} + \def\reserved@a##1#1##2##3\@@{% + \@xspace@if@q@nil@NF##2{% +% \end{macrocode} +% It's in the list, remove it. +% \begin{macrocode} + \def\reserved@a####1#1####2\@@{% + \gdef\@xspace@exceptions@tlp{####1####2}}% + \expandafter\reserved@a\@xspace@exceptions@tlp\@@ + }% + }% + \expandafter\reserved@a\@xspace@exceptions@tlp#1\@xspace@q@nil\@@ +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@xspace@break@loop} +% \changes{v1.08}{2005/04/28}{Added macro} +% \changes{v1.10}{2005/10/04}{Use quark instead} +% To stop the loop. +% \begin{macrocode} +\def\@xspace@break@loop#1\@nil{} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@xspace@hook} +% \changes{v1.09}{2005/07/26}{Added macro} +% A hook for users with special needs. +% \begin{macrocode} +\providecommand*\@xspace@hook{} +% \end{macrocode} +% \end{macro} +% +% Now we check if we're running \eTeX. We can't use \cs{@ifundefined} +% as that will lock catcodes and we need to change some of those. +% As there is a small risk that someone already set \cs{eTeXversion} +% to \cs{relax} by accident we make sure we check for that case but +% without setting it to \cs{relax} if it wasn't already. +% \begin{macrocode} +\begingroup\expandafter\expandafter\expandafter\endgroup + \expandafter\ifx\csname eTeXversion\endcsname\relax +% \end{macrocode} +% If we are running normal \TeX\ we add the most common cases of active +% punctuation characters. First we make them active. +% \begin{macrocode} + \begingroup + \catcode`\;=\active \catcode`\:=\active + \catcode`\?=\active \catcode`\!=\active +% \end{macrocode} +% The \texttt{alltt} environment also makes |,|, |'|, and |-| active +% so we add them as well. +% \begin{macrocode} + \catcode`\,=\active \catcode`\'=\active \catcode`\-=\active + \xspaceaddexceptions{;:?!,'-} + \endgroup + \let\@xspace@eTeX@setup\relax +% \end{macrocode} +% \begin{macro}{\@xspace@eTeX@setup} +% \changes{v1.10}{2005/10/04}{Added macro} +% \changes{v1.12}{2006/05/08}{Bug fix for verbatim in output routine} +% When we're running \eTeX, we have the advantage of \cs{scantokens} +% which will rescan tokens with current catcodes. This little +% expansion trick makes sure that the exception list is redefined to +% itself but with the contents of it exposed to the current catcode +% regime. That is why we must make sure the catcode of space is 10, +% since we have a \verb*|\ | inside the list. +% \begin{macrocode} +\else + \def\@xspace@eTeX@setup{% + \begingroup + \everyeof{}% + \endlinechar=-1\relax + \catcode`\ =10\relax + \makeatletter +% \end{macrocode} +% We may also be so unfortunate that the re-reading of the list takes +% place when the catcodes of |\|, |{| and |}| are ``other,'' e.g., if +% it takes place in a header and the output routine was called in the +% middle of a \texttt{verbatim} environment. +% \begin{macrocode} + \catcode`\\\z@ + \catcode`\{\@ne + \catcode`\}\tw@ + \scantokens\expandafter{\expandafter\gdef + \expandafter\@xspace@exceptions@tlp + \expandafter{\@xspace@exceptions@tlp}}% + \endgroup + } +\fi +% \end{macrocode} +% \end{macro} +% \begin{macro}{\@xspace} +% \changes{v1.03}{1994/11/15}{Add exclamation mark} +% \changes{v1.04}{1996/05/17}{Add slash} +% \changes{v1.05}{1996/12/06}{Add space for alltt etc. tools/2322} +% \changes{v1.06}{1997/10/13}{Add normal space. tools/2632} +% \changes{v1.07}{2004/12/07}{Now runs through a list of exceptions} +% \changes{v1.07}{2004/12/07}{Added \cs{footnote} and +% \cs{footnotemark}} +% \changes{v1.08}{2005/05/07}{Use recursive loop instead of \cs{@tfor}} +% \changes{v1.09}{2005/07/26}{Only check non-letters and add hook} +% \changes{v1.10}{2005/10/04}{Use higher level functions for +% conditional processing} +% \changes{v1.10}{2005/10/04}{Improve expansion method} +% If the next token is one of a specified list of characters, +% do nothing, otherwise add a space. With version~1.07 the +% approach was altered dramatically to run through the +% exception list |\@xspace@exceptions@tlp| and check each +% token one at a time. +% \begin{macrocode} +\def\@xspace{% +% \end{macrocode} +% Before we start checking the exception list it makes sense to +% perform a quick check on the token in question. Most of the time +% \cs{xspace} is used in regular text so \cs{@let@token} is set equal +% to a letter. In that case there is no point in checking the list +% because it will definitely not contain any tokens with catcode~11. +% +% You may wonder why there are special functions here instead of +% simpler \cs{ifx} conditionals. The reason is that a)~this way we +% don't have to add many, many \cs{expandafter}s to get the nesting +% right and b)~we don't get into trouble when \cs{@let@token} has been +% let equal to \cs{if} etc. +% \begin{macrocode} + \@xspace@lettoken@if@letter@TF \space{% +% \end{macrocode} +% Otherwise we start testing after setting up a few things. If running +% \eTeX{} we rescan the catcodes but only the first time around. +% \begin{macrocode} + \if@xspace@first + \@xspace@firstfalse + \let\@xspace@maybespace\space + \@xspace@eTeX@setup + \fi + \expandafter\@xspace@check@token + \@xspace@exceptions@tlp\@xspace@q@nil\@nil +% \end{macrocode} +% If an exception was found \cs{@xspace@maybespace} is let to +% \cs{relax} and we do nothing. +% \begin{macrocode} + \@xspace@token@if@equal@NNT \space \@xspace@maybespace +% \end{macrocode} +% Otherwise we check to see if we found something expandable and try +% again with that token one level expanded. If no expandable token is +% found we insert a space and then execute the hook. +% \begin{macrocode} + {% + \@xspace@lettoken@if@expandable@TF + {\expandafter\@xspace@simple}% + {\@xspace@maybespace\@xspace@hook}% + }% + }% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@xspace@check@token} +% \changes{v1.07}{2004/12/07}{Added macro} +% \changes{v1.08}{2005/05/07}{Made function recursive} +% \changes{v1.10}{2005/10/04}{Use higher level functions for +% conditional processing} +% \changes{v1.11}{2006/02/12}{Modified so the \cs{@let@token} can be +% \cs{outer}} +% This macro just checks the current item in the exception list +% against the \cs{@let@token}. If they are equal we make sure that no +% space is inserted and break the loop. +% \begin{macrocode} +\def\@xspace@check@token #1{% + \ifx\@xspace@q@nil#1% + \expandafter\@xspace@break@loop + \fi + \expandafter\ifx\csname @let@token\endcsname#1% + \let\@xspace@maybespace\relax + \expandafter\@xspace@break@loop + \fi + \@xspace@check@token +} +% \end{macrocode} +% \end{macro} +% +% That's all, folks! That is, if we were running \LaTeX3. In that case +% we would have had nice functions for all the conditionals but here +% we must define them ourselves. We also optimize them here as +% \cs{@let@token} will always be the argument in some cases. +% +% \begin{macro}{\@xspace@if@lettoken@letter@TF} +% \begin{macro}{\@xspace@if@lettoken@expandable@TF} +% \begin{macro}{\@xspace@cs@if@equal@NNF} +% First a few comparisons. +% \begin{macrocode} +\def\@xspace@lettoken@if@letter@TF{% + \ifcat\noexpand\@let@token @% letter + \expandafter\@firstoftwo + \else + \expandafter\@secondoftwo + \fi} +\def\@xspace@lettoken@if@expandable@TF{% + \expandafter\ifx\noexpand\@let@token\@let@token% + \expandafter\@secondoftwo + \else + \expandafter\@firstoftwo + \fi +} +\def\@xspace@token@if@equal@NNT#1#2{% + \ifx#1#2% + \expandafter\@firstofone + \else + \expandafter\@gobble + \fi} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \begin{macro}{\@xspace@q@nil} +% \begin{macro}{\@xspace@if@q@nil@NF} +% Some macros dealing with quarks. +% \begin{macrocode} +\def\@xspace@q@nil{\@xspace@q@nil} +\def\@xspace@if@q@nil@NF#1{% + \ifx\@xspace@q@nil#1% + \expandafter\@gobble + \else + \expandafter\@firstofone + \fi} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \begin{macrocode} +%</package> +% \end{macrocode} +% +% \Finale diff --git a/macros/latex-dev/required/tools/xspace.pdf b/macros/latex-dev/required/tools/xspace.pdf Binary files differnew file mode 100644 index 0000000000..bba3d6c5f4 --- /dev/null +++ b/macros/latex-dev/required/tools/xspace.pdf |