summaryrefslogtreecommitdiff
path: root/macros/latex/required
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /macros/latex/required
Initial commit
Diffstat (limited to 'macros/latex/required')
-rw-r--r--macros/latex/required/amscls/README206
-rw-r--r--macros/latex/required/amscls/amsalpha.bst1394
-rw-r--r--macros/latex/required/amscls/amsbooka.dtx590
-rw-r--r--macros/latex/required/amscls/amsbooka.ins78
-rw-r--r--macros/latex/required/amscls/amsclass.dtx5214
-rw-r--r--macros/latex/required/amscls/amsclass.ins81
-rw-r--r--macros/latex/required/amscls/amsdtx.dtx1223
-rw-r--r--macros/latex/required/amscls/amsdtx.ins77
-rw-r--r--macros/latex/required/amscls/amsmidx.dtx232
-rw-r--r--macros/latex/required/amscls/amsmidx.ins76
-rw-r--r--macros/latex/required/amscls/amsplain.bst1245
-rw-r--r--macros/latex/required/amscls/doc/00LICENSE.txt198
-rw-r--r--macros/latex/required/amscls/doc/amsart-template.tex89
-rw-r--r--macros/latex/required/amscls/doc/amsbook-template.tex134
-rw-r--r--macros/latex/required/amscls/doc/amsbooka.pdfbin0 -> 172376 bytes
-rw-r--r--macros/latex/required/amscls/doc/amsclass.pdfbin0 -> 373922 bytes
-rw-r--r--macros/latex/required/amscls/doc/amsdtx.pdfbin0 -> 253639 bytes
-rw-r--r--macros/latex/required/amscls/doc/amsmidx.pdfbin0 -> 74456 bytes
-rw-r--r--macros/latex/required/amscls/doc/amsproc-template.tex89
-rw-r--r--macros/latex/required/amscls/doc/amsthdoc.pdfbin0 -> 177495 bytes
-rw-r--r--macros/latex/required/amscls/doc/amsthdoc.tex851
-rw-r--r--macros/latex/required/amscls/doc/diffs-c.txt383
-rw-r--r--macros/latex/required/amscls/doc/install.txt126
-rw-r--r--macros/latex/required/amscls/doc/manifest.txt29
-rw-r--r--macros/latex/required/amscls/doc/thmtest.pdfbin0 -> 73682 bytes
-rw-r--r--macros/latex/required/amscls/doc/thmtest.tex247
-rw-r--r--macros/latex/required/amscls/doc/upref.pdfbin0 -> 62327 bytes
-rw-r--r--macros/latex/required/amscls/upref.dtx165
-rw-r--r--macros/latex/required/amscls/upref.ins76
-rw-r--r--macros/latex/required/amsmath/README.md98
-rw-r--r--macros/latex/required/amsmath/amsbsy.dtx238
-rw-r--r--macros/latex/required/amsmath/amsbsy.ins50
-rw-r--r--macros/latex/required/amsmath/amsbsy.pdfbin0 -> 161322 bytes
-rw-r--r--macros/latex/required/amsmath/amscd.dtx322
-rw-r--r--macros/latex/required/amsmath/amscd.ins50
-rw-r--r--macros/latex/required/amsmath/amscd.pdfbin0 -> 165741 bytes
-rw-r--r--macros/latex/required/amsmath/amsgen.dtx386
-rw-r--r--macros/latex/required/amsmath/amsgen.ins50
-rw-r--r--macros/latex/required/amsmath/amsgen.pdfbin0 -> 164340 bytes
-rw-r--r--macros/latex/required/amsmath/amsldoc-1.pdfbin0 -> 38239 bytes
-rw-r--r--macros/latex/required/amsmath/amsldoc-bb.pdfbin0 -> 452878 bytes
-rw-r--r--macros/latex/required/amsmath/amsldoc.pdfbin0 -> 453043 bytes
-rw-r--r--macros/latex/required/amsmath/amsldoc.tex2770
-rw-r--r--macros/latex/required/amsmath/amsmath.dtx6360
-rw-r--r--macros/latex/required/amsmath/amsmath.ins50
-rw-r--r--macros/latex/required/amsmath/amsmath.pdfbin0 -> 378623 bytes
-rw-r--r--macros/latex/required/amsmath/amsopn.dtx263
-rw-r--r--macros/latex/required/amsmath/amsopn.ins50
-rw-r--r--macros/latex/required/amsmath/amsopn.pdfbin0 -> 129152 bytes
-rw-r--r--macros/latex/required/amsmath/amstex.sty2025
-rw-r--r--macros/latex/required/amsmath/amstext.dtx302
-rw-r--r--macros/latex/required/amsmath/amstext.ins51
-rw-r--r--macros/latex/required/amsmath/amstext.pdfbin0 -> 193892 bytes
-rw-r--r--macros/latex/required/amsmath/amsxtra.dtx127
-rw-r--r--macros/latex/required/amsmath/amsxtra.ins51
-rw-r--r--macros/latex/required/amsmath/amsxtra.pdfbin0 -> 104538 bytes
-rw-r--r--macros/latex/required/amsmath/changes.txt119
-rw-r--r--macros/latex/required/amsmath/diffs-m.txt551
-rw-r--r--macros/latex/required/amsmath/manifest.txt32
-rw-r--r--macros/latex/required/amsmath/subeqn.pdfbin0 -> 101285 bytes
-rw-r--r--macros/latex/required/amsmath/subeqn.tex202
-rw-r--r--macros/latex/required/amsmath/technote.pdfbin0 -> 130465 bytes
-rw-r--r--macros/latex/required/amsmath/technote.tex233
-rw-r--r--macros/latex/required/amsmath/testmath.pdfbin0 -> 428683 bytes
-rw-r--r--macros/latex/required/amsmath/testmath.tex2342
-rw-r--r--macros/latex/required/babel/base/README.md148
-rw-r--r--macros/latex/required/babel/base/babel.dtx20065
-rw-r--r--macros/latex/required/babel/base/babel.ins249
-rw-r--r--macros/latex/required/babel/base/babel.pdfbin0 -> 693345 bytes
-rw-r--r--macros/latex/required/babel/base/bbcompat.dtx591
-rw-r--r--macros/latex/required/babel/base/bbidxglo.dtx124
l---------macros/latex/required/babel/contrib1
-rw-r--r--macros/latex/required/cyrillic/README.md67
-rw-r--r--macros/latex/required/cyrillic/changes.txt192
-rw-r--r--macros/latex/required/cyrillic/cyinpenc.dtx1838
-rw-r--r--macros/latex/required/cyrillic/cyinpenc.pdfbin0 -> 206017 bytes
-rw-r--r--macros/latex/required/cyrillic/cyoutenc.dtx611
-rw-r--r--macros/latex/required/cyrillic/cyoutenc.pdfbin0 -> 148216 bytes
-rw-r--r--macros/latex/required/cyrillic/cyrlatex.ins277
-rw-r--r--macros/latex/required/cyrillic/lcy.dtx382
-rw-r--r--macros/latex/required/cyrillic/lcy.pdfbin0 -> 198415 bytes
-rw-r--r--macros/latex/required/cyrillic/lcycmlh.fdd338
-rw-r--r--macros/latex/required/cyrillic/lcycmlh.pdfbin0 -> 125811 bytes
-rw-r--r--macros/latex/required/cyrillic/manifest.txt31
-rw-r--r--macros/latex/required/cyrillic/ot2.dtx218
-rw-r--r--macros/latex/required/cyrillic/ot2.pdfbin0 -> 112390 bytes
-rw-r--r--macros/latex/required/cyrillic/ot2cmams.fdd135
-rw-r--r--macros/latex/required/cyrillic/ot2cmams.pdfbin0 -> 99095 bytes
-rw-r--r--macros/latex/required/cyrillic/ot2cmlh.fdd342
-rw-r--r--macros/latex/required/cyrillic/ot2cmlh.pdfbin0 -> 129052 bytes
-rw-r--r--macros/latex/required/cyrillic/t2lhfnt.fdd997
-rw-r--r--macros/latex/required/cyrillic/t2lhfnt.pdfbin0 -> 135567 bytes
-rw-r--r--macros/latex/required/graphics/README.md132
-rw-r--r--macros/latex/required/graphics/cat.eps305
-rw-r--r--macros/latex/required/graphics/changes.txt945
-rw-r--r--macros/latex/required/graphics/color.dtx963
-rw-r--r--macros/latex/required/graphics/color.pdfbin0 -> 201390 bytes
-rw-r--r--macros/latex/required/graphics/drivers.dtx1701
-rw-r--r--macros/latex/required/graphics/drivers.pdfbin0 -> 263551 bytes
-rw-r--r--macros/latex/required/graphics/epsfig.dtx142
-rw-r--r--macros/latex/required/graphics/epsfig.pdfbin0 -> 154501 bytes
-rw-r--r--macros/latex/required/graphics/graphics-drivers.ins92
-rw-r--r--macros/latex/required/graphics/graphics.dtx1962
-rw-r--r--macros/latex/required/graphics/graphics.ins43
-rw-r--r--macros/latex/required/graphics/graphics.pdfbin0 -> 282361 bytes
-rw-r--r--macros/latex/required/graphics/graphicx.dtx939
-rw-r--r--macros/latex/required/graphics/graphicx.pdfbin0 -> 232400 bytes
-rw-r--r--macros/latex/required/graphics/grfguide.pdfbin0 -> 310578 bytes
-rw-r--r--macros/latex/required/graphics/grfguide.tex1031
-rw-r--r--macros/latex/required/graphics/keyval.dtx419
-rw-r--r--macros/latex/required/graphics/keyval.pdfbin0 -> 222532 bytes
-rw-r--r--macros/latex/required/graphics/lscape.dtx135
-rw-r--r--macros/latex/required/graphics/lscape.pdfbin0 -> 150124 bytes
-rw-r--r--macros/latex/required/graphics/rotating.dtx686
-rw-r--r--macros/latex/required/graphics/rotating.pdfbin0 -> 245644 bytes
-rw-r--r--macros/latex/required/graphics/rotex.pdfbin0 -> 162249 bytes
-rw-r--r--macros/latex/required/graphics/rotex.tex500
-rw-r--r--macros/latex/required/graphics/trig.dtx329
-rw-r--r--macros/latex/required/graphics/trig.pdfbin0 -> 191711 bytes
-rw-r--r--macros/latex/required/latexbug/README.md2
-rw-r--r--macros/latex/required/latexbug/changes.txt5
-rw-r--r--macros/latex/required/latexbug/latexbug.dtx976
-rw-r--r--macros/latex/required/latexbug/latexbug.ins65
-rw-r--r--macros/latex/required/latexbug/latexbug.pdfbin0 -> 186773 bytes
-rw-r--r--macros/latex/required/psnfss/00readme.txt264
-rw-r--r--macros/latex/required/psnfss/8r.enc143
l---------macros/latex/required/psnfss/README1
-rw-r--r--macros/latex/required/psnfss/changes.txt242
-rw-r--r--macros/latex/required/psnfss/charter.map7
-rw-r--r--macros/latex/required/psnfss/fpls.map5
-rw-r--r--macros/latex/required/psnfss/manifest.txt28
-rw-r--r--macros/latex/required/psnfss/mathtest.tex116
-rw-r--r--macros/latex/required/psnfss/pazo.map6
-rw-r--r--macros/latex/required/psnfss/pitest.tex66
-rw-r--r--macros/latex/required/psnfss/psfonts.dtx1014
-rw-r--r--macros/latex/required/psnfss/psfonts.ins24
-rw-r--r--macros/latex/required/psnfss/psnfss.map48
-rw-r--r--macros/latex/required/psnfss/psnfss2e.pdfbin0 -> 151708 bytes
-rw-r--r--macros/latex/required/psnfss/psnfss2e.tex887
-rw-r--r--macros/latex/required/psnfss/test0.tex118
-rw-r--r--macros/latex/required/psnfss/test1.tex51
-rw-r--r--macros/latex/required/psnfss/test2.tex39
-rw-r--r--macros/latex/required/psnfss/test3.tex43
-rw-r--r--macros/latex/required/psnfss/utopia.map7
-rw-r--r--macros/latex/required/tools/README.md81
-rw-r--r--macros/latex/required/tools/README.txt97
-rw-r--r--macros/latex/required/tools/afterpage.dtx385
-rw-r--r--macros/latex/required/tools/afterpage.ins75
-rw-r--r--macros/latex/required/tools/afterpage.pdfbin0 -> 189844 bytes
-rw-r--r--macros/latex/required/tools/array-2016-10-06.sty341
-rw-r--r--macros/latex/required/tools/array.dtx3084
-rw-r--r--macros/latex/required/tools/array.pdfbin0 -> 481007 bytes
-rw-r--r--macros/latex/required/tools/bm.dtx1697
-rw-r--r--macros/latex/required/tools/bm.ins75
-rw-r--r--macros/latex/required/tools/bm.pdfbin0 -> 306362 bytes
-rw-r--r--macros/latex/required/tools/calc.dtx1357
-rw-r--r--macros/latex/required/tools/calc.pdfbin0 -> 340594 bytes
-rw-r--r--macros/latex/required/tools/changes.txt1634
-rw-r--r--macros/latex/required/tools/dcolumn.dtx361
-rw-r--r--macros/latex/required/tools/dcolumn.pdfbin0 -> 199042 bytes
-rw-r--r--macros/latex/required/tools/delarray.dtx206
-rw-r--r--macros/latex/required/tools/delarray.pdfbin0 -> 183428 bytes
-rw-r--r--macros/latex/required/tools/enumerate.dtx335
-rw-r--r--macros/latex/required/tools/enumerate.pdfbin0 -> 199050 bytes
-rw-r--r--macros/latex/required/tools/fileerr.dtx123
-rw-r--r--macros/latex/required/tools/fileerr.pdfbin0 -> 180256 bytes
-rw-r--r--macros/latex/required/tools/fontsmpl.dtx338
-rw-r--r--macros/latex/required/tools/fontsmpl.pdfbin0 -> 144816 bytes
-rw-r--r--macros/latex/required/tools/ftnright.dtx1018
-rw-r--r--macros/latex/required/tools/ftnright.pdfbin0 -> 347086 bytes
-rw-r--r--macros/latex/required/tools/hhline.dtx322
-rw-r--r--macros/latex/required/tools/hhline.pdfbin0 -> 175718 bytes
-rw-r--r--macros/latex/required/tools/indentfirst.dtx77
-rw-r--r--macros/latex/required/tools/indentfirst.pdfbin0 -> 144776 bytes
-rw-r--r--macros/latex/required/tools/layout.dtx1025
-rw-r--r--macros/latex/required/tools/layout.pdfbin0 -> 246929 bytes
-rw-r--r--macros/latex/required/tools/longtable.dtx2150
-rw-r--r--macros/latex/required/tools/longtable.ins75
-rw-r--r--macros/latex/required/tools/longtable.pdfbin0 -> 349851 bytes
-rw-r--r--macros/latex/required/tools/manifest.txt111
-rw-r--r--macros/latex/required/tools/multicol-2017-04-11.sty1042
-rw-r--r--macros/latex/required/tools/multicol.dtx4415
-rw-r--r--macros/latex/required/tools/multicol.ins77
-rw-r--r--macros/latex/required/tools/multicol.pdfbin0 -> 488764 bytes
-rw-r--r--macros/latex/required/tools/rawfonts.dtx219
-rw-r--r--macros/latex/required/tools/rawfonts.pdfbin0 -> 135685 bytes
-rw-r--r--macros/latex/required/tools/shellesc.dtx240
-rw-r--r--macros/latex/required/tools/shellesc.pdfbin0 -> 167011 bytes
-rw-r--r--macros/latex/required/tools/showkeys.dtx905
-rw-r--r--macros/latex/required/tools/showkeys.pdfbin0 -> 242781 bytes
-rw-r--r--macros/latex/required/tools/somedefs.dtx172
-rw-r--r--macros/latex/required/tools/somedefs.pdfbin0 -> 156458 bytes
-rw-r--r--macros/latex/required/tools/tabularx.dtx968
-rw-r--r--macros/latex/required/tools/tabularx.ins74
-rw-r--r--macros/latex/required/tools/tabularx.pdfbin0 -> 254080 bytes
-rw-r--r--macros/latex/required/tools/theorem.dtx1144
-rw-r--r--macros/latex/required/tools/theorem.pdfbin0 -> 323171 bytes
-rw-r--r--macros/latex/required/tools/tools-overview.pdfbin0 -> 68286 bytes
-rw-r--r--macros/latex/required/tools/tools-overview.tex212
-rw-r--r--macros/latex/required/tools/tools.ins217
-rw-r--r--macros/latex/required/tools/trace.dtx733
-rw-r--r--macros/latex/required/tools/trace.pdfbin0 -> 212728 bytes
-rw-r--r--macros/latex/required/tools/varioref.dtx2147
-rw-r--r--macros/latex/required/tools/varioref.ins76
-rw-r--r--macros/latex/required/tools/varioref.pdfbin0 -> 335104 bytes
-rw-r--r--macros/latex/required/tools/verbatim.dtx1858
-rw-r--r--macros/latex/required/tools/verbatim.pdfbin0 -> 309038 bytes
-rw-r--r--macros/latex/required/tools/xr.dtx177
-rw-r--r--macros/latex/required/tools/xr.pdfbin0 -> 163122 bytes
-rw-r--r--macros/latex/required/tools/xspace.dtx507
-rw-r--r--macros/latex/required/tools/xspace.pdfbin0 -> 238006 bytes
211 files changed, 100762 insertions, 0 deletions
diff --git a/macros/latex/required/amscls/README b/macros/latex/required/amscls/README
new file mode 100644
index 0000000000..7273ec23ec
--- /dev/null
+++ b/macros/latex/required/amscls/README
@@ -0,0 +1,206 @@
+README file for AMS document classes amsart/book/proc 2.20.4 [2017/10/31]
+
+Copyright 2004, 2010, 2014-2017 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
+ 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.
+
+This work has the LPPL maintenance status `maintained'.
+
+The Current Maintainer of this work is the American Mathematical
+Society.
+
+American Mathematical Society
+Technical Support
+Publications Technical Group
+201 Charles Street
+Providence, RI 02904
+USA
+tel: (401) 455-4080
+ (800) 321-4267 (USA and Canada only)
+fax: (401) 331-3842
+email: tech-support@ams.org
+
+========================================================================
+
+See manifest.txt for a list of all the files in the distribution.
+
+The document classes amsart, amsbook, amsproc and related packages are
+provided by the American Mathematical Society for authors to use with
+LaTeX. They produce the overall layout and appearance of AMS
+publications.
+
+In order to use an AMS document class you need to have TeX software
+installed first. TeX is not an AMS product. If you need information
+on getting TeX see one of the following:
+
+ http://www.tug.org/
+ https://www.ams.org/tex/tex-resources.html
+
+User documentation for the AMS document classes is contained in the
+class-specific AMS Author Handbook, found at these locations:
+
+ https://www.ams.org/tex/author-handbook (individual handbooks)
+ http://mirror.ctan.org/tex-archive/info/amscls-doc.zip (full source)
+
+Additional documentation for the AMS document classes and the related
+theorem package is found in
+
+ diffs-c.txt
+ amsthdoc.pdf
+ thmtest.tex
+ thmtest.pdf
+
+which are included in the collection. Answers to some specific
+questions can be found in the AMS Author FAQ:
+
+ https://www.ams.org/tex/amsclass-faq.html
+
+The recommended procedure for making a custom document class based on an
+AMS class is to make a copy of the relevant .cls file using a different
+name and edit the copy---e.g., copy amsbook.cls to mybook.cls. (In
+general we advise against using \LoadClass, unless the base class is
+frozen or changes to the base class are under your control.)
+
+========================================================================
+RECENT CHANGES
+
+---amsclass.dtx 2.20.4 2017/10/31
+Changed \emailaddrname: replaced "E-mail" by "Email"
+
+---amsclass.dtx 2.20.3 2017/10/06
+Don't assume amsfonts is available when providing a fallback
+definition of \dh; instead, issue a warning and substitute "dh".
+
+---documentation files 2017/11/15
+instr-l.* removed; superseded by (class-specific) AMS Author Handbooks
+at https://www.ams.org/tex/author-handbook
+or http://mirror.ctan.org/tex-archive/info/amscls-doc.zip
+
+========================================================================
+PREVIOUS CHANGES
+
+---amsthdoc.tex 2.20.2 2015/04/10
+Completely rewritten, adding examples, workarounds, and notes on
+interaction with other packages and document classes.
+
+---amsclass.dtx 2.20.2 2015/03/10
+Patched definition of \[ for compatibility with the fixltx2e package
+and post-2014 versions of the LaTeX kernel. Thanks to David Carlisle.
+
+---amsclass.ins 2.25 2014/07/24
+ amsmidx.ins 1.1 2014/07/24
+ upref.ins 1.1 2014/07/24
+Superseded ams-c1.ins by individual .ins files per .dtx file
+
+---amsbooka.dtx 2.08 2014/07/11
+1. When chapter has an author, reset running heads to be author/left,
+ chapter title/right.
+2. Added \barefootnote and inchapterbibliography.
+3. Added (optional) \copyrightinfo per chapter.
+
+---amsclass.dtx 2.20.1 2009/07/02
+1. Added [2010] option as permissible year for \subjclass.
+2. Revised header block to explicitly recognize the LPPL.
+
+---ams-c1.ins 2.20 2004/08/03
+Added amsmidx package.
+
+---amsclass.dtx 2.20 2004/08/06
+1. Added facility for additional line(s) in copyright block.
+2. Corrected handling of section heading with no title.
+3. Got rid of spurious "Appendix" in t-of-c in \backmatter.
+4. Changed MR number formatting to use new style as on MathSciNet.
+5. Created commands for various style elements and substituted them
+ for hard-coded values to simplify building derived classes.
+6. Added sectioning and otherwise cleaned up commentary.
+
+---amsclass.faq - 2004/08/06
+Removed from distribution; replaced by on-line FAQ at
+http://www.ams.org/tex/amsclass-faq.html
+
+---amsdtx.dtx 2.06 2004/08/06
+1. Reworked indexing commands for compatibility with doc.sty.
+2. Added option environment for enhanced indexing.
+3. Improved formatting.
+
+---amsthdoc.tex 2.20 2004/08/03
+1. Substantially rewritten for clarity.
+2. Added documentation for \newtheoremstyle.
+
+---instr-l.tex 2.20 2004/08/05
+Substantially rewritten for clarity and to add instructions for new
+features; see note on amsclass.dtx regarding features.
+
+---mrabbrev.bib - 2004/08/05
+Removed from distribution; this is now available separately from
+http://www.ams.org/tools/mrabbrev.bib
+
+---thmtest.tex 2.01 2004/08/02
+1. Corrected counter for theorems with switched headers.
+2. Added section headings for clarity.
+3. Added example ending with a display and \qedhere.
+
+---upref.dtx 2.01 2004/07/29
+1. Added code to make package work with hyperref.
+2. Improved documentation.
+
+---amsclass.dtx 2.14 2004/04/26 (not released)
+1. Incorporated pending changes left by Michael Downes:
+ - Added trap in headings in case \thanks was set within \author,
+ and added \thanks@warning.
+ - Cleaned up and completed unfinished documentation.
+2. Added braces in \uppercasenonmath to limit scope.
+3. Added \contrib mechanism to handle "non-author" authors.
+4. Segregated definitions of administrative footnotes to permit easier
+ customization for AMS journals.
+5. Added explicit \bibliofont to permit easy change for special uses.
+6. Changed MR number formatting to correspond to new access numbers
+ used by MathSciNet.
+7. Added \@citestyle and \citeform to simplify font changes in citations.
+8. Added OT1 defaults for \DH, \dh, \DJ, \dj, required for author names.
+9. Added \markleft to permit changing of only left running head
+
+---amsclass.dtx 2.13 2002/12/04 (not released)
+1. Fixed handling of theorem head punctuation with \swapnumbers.
+2. Changed \proofname to \providecommand in case it's already defined.
+3. Made \small, \Small, etc., robust.
+4. Better spacing in \l@figure to prevent overprinting of figure number.
+5. Changed handling of author names to prevent internal line breaks.
+6. Added \@noparitemfalse in \dth@everypar to prevent weird results in
+ certain (rare) kinds of usage.
+7. Some other cosmetic changes.
+
+---amsthdoc.tex 2.02 2000/06/06
+Use article class instead of amsldoc (which is overkill).
+
+---amsldoc.cls - 2000/06/06
+Removed from distribution, no longer needed by amsthdoc.
+
+---amsclass.dtx 2.07 2000/06/05
+Guard against \\ in argument of \author.
+
+---amsclass.dtx 2.06 2000/06/02
+Avoid using \@elt in qed stack because LaTeX output routine falls over
+if triggered when something else is using \@elt.
+
+---amsclass.dtx 2.05 2000/05/16
+1. Added \indexintro.
+2. Fixed erroneous init for thm@preskip, thm@postskip.
+
+---amsclass.dtx 2.04 2000/03/10
+\newtoks fix for old versions of LaTeX. Added some commentary about \cal.
+
+---amsclass.dtx 2.03 2000/01/17
+1. Removed dependency on amsgen package.
+2. Added a warning about graphics for the draft option.
+3. Improved qedhere handling for article/amsthm combination.
+
+---amsclass.dtx 2.02 2000/01/17
+Some fixes for the fleqn/qedhere case.
+========================================================================
diff --git a/macros/latex/required/amscls/amsalpha.bst b/macros/latex/required/amscls/amsalpha.bst
new file mode 100644
index 0000000000..36c4d71bcd
--- /dev/null
+++ b/macros/latex/required/amscls/amsalpha.bst
@@ -0,0 +1,1394 @@
+%% filename: amsalpha.bst
+%% version: 2.0
+%% date: 2000/03/27
+%%
+%% American Mathematical Society
+%% Technical Support
+%% Publications Technical Group
+%% 201 Charles Street
+%% Providence, RI 02904
+%% USA
+%% tel: (401) 455-4080
+%% (800) 321-4267 (USA and Canada only)
+%% fax: (401) 331-3842
+%% email: tech-support@ams.org
+%%
+%% Copyright 1995, 2000, 2010 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
+%% 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.
+%%
+%% This work has the LPPL maintenance status `maintained'.
+%%
+%% The Current Maintainer of this work is the American Mathematical
+%% Society.
+%%
+%% ====================================================================
+
+% See the file btxbst.doc for extra documentation other than
+% what is included here. And see btxhak.tex for a description
+% of the BibTeX language and how to use it.
+
+% This defines the types of fields that can occur in a database entry
+% for this particular bibliography style. Except for `language',
+% this is the standard list from alpha.bst.
+
+%% Types of entries currently allowed in a BibTeX file:
+%%
+%% ARTICLE -- An article from a journal or magazine.
+%%
+%% BOOK -- A book with an explicit publisher.
+%%
+%% BOOKLET -- A work that is printed and bound,
+%% but without a named publisher or sponsoring institution.
+%%
+%% CONFERENCE -- The same as INPROCEEDINGS,
+%% included for Scribe compatibility.
+%%
+%% INBOOK -- A part of a book,
+%% which may be a chapter (or section or whatever) and/or a range of pages.
+%%
+%% INCOLLECTION -- A part of a book having its own title.
+%%
+%% INPROCEEDINGS -- An article in a conference proceedings.
+%%
+%% MANUAL -- Technical documentation.
+%%
+%% MASTERSTHESIS -- A Master's thesis.
+%%
+%% MISC -- Use this type when nothing else fits.
+%%
+%% PHDTHESIS -- A PhD thesis.
+%%
+%% PROCEEDINGS -- The proceedings of a conference.
+%%
+%% TECHREPORT -- A report published by a school or other institution,
+%% usually numbered within a series.
+%%
+%% UNPUBLISHED -- A document having an author and title, but not formally
+%% published.
+
+ENTRY
+ { address
+ author
+ booktitle
+ chapter
+ edition
+ editor
+ howpublished
+ institution
+ journal
+ key
+ language
+ month
+ mrnumber
+ note
+ number
+ organization
+ pages
+ publisher
+ school
+ series
+ title
+ type
+ volume
+ year
+ }
+ {}
+ { label extra.label sort.label bysame }
+
+% Removed after.sentence, after.block---not needed.
+
+INTEGERS { output.state before.all mid.sentence }
+
+FUNCTION {init.state.consts}
+{ #0 'before.all :=
+ #1 'mid.sentence :=
+}
+
+% Scratch variables:
+
+STRINGS { s t }
+
+% Utility functions
+
+FUNCTION {shows}
+{ duplicate$ ":::: `" swap$ * "'" * top$
+}
+
+FUNCTION {showstack}
+{"STACK====================================================================="
+top$
+stack$
+"ENDSTACK=================================================================="
+top$
+}
+
+FUNCTION {not}
+{ { #0 }
+ { #1 }
+ if$
+}
+
+FUNCTION {and}
+{ 'skip$
+ { pop$ #0 }
+ if$
+}
+
+FUNCTION {or}
+{ { pop$ #1 }
+ 'skip$
+ if$
+}
+
+FUNCTION {field.or.null}
+{ duplicate$ empty$
+ { pop$ "" }
+ 'skip$
+ if$
+}
+
+FUNCTION {emphasize}
+{ duplicate$ empty$
+ { pop$ "" }
+ { "\emph{" swap$ * "}" * }
+ if$
+}
+
+% n.dashify is used to make sure page ranges get the TeX code
+% (two hyphens) for en-dashes.
+
+FUNCTION {n.dashify}
+{ 't :=
+ ""
+ { t empty$ not }
+ { t #1 #1 substring$ "-" =
+ { t #1 #2 substring$ "--" = not
+ { "--" *
+ t #2 global.max$ substring$ 't :=
+ }
+ { { t #1 #1 substring$ "-" = }
+ { "-" *
+ t #2 global.max$ substring$ 't :=
+ }
+ while$
+ }
+ if$
+ }
+ { t #1 #1 substring$ *
+ t #2 global.max$ substring$ 't :=
+ }
+ if$
+ }
+ while$
+}
+
+% tie.or.space.connect connects two items with a ~ if the
+% second item is less than 3 letters long, otherwise it just puts an
+% ordinary space.
+
+FUNCTION {tie.or.space.connect}
+{ duplicate$ text.length$ #3 <
+ { "~" }
+ { " " }
+ if$
+ swap$ * *
+}
+
+FUNCTION {add.space.if.necessary}
+{ duplicate$ "" =
+ 'skip$
+ { " " * }
+ if$
+}
+
+% either.or.check gives a warning if two mutually exclusive fields
+% were used in the database.
+
+FUNCTION {either.or.check}
+{ empty$
+ 'pop$
+ { "can't use both " swap$ * " fields in " * cite$ * warning$ }
+ if$
+}
+
+% output.nonnull is called by output.
+
+FUNCTION {output.nonnull}
+% remove the top item from the stack because it's in the way.
+{ 's :=
+ output.state mid.sentence =
+% If we're in mid-sentence, add a comma to the new top item and write it
+ { ", " * write$ }
+% Otherwise, if we're at the beginning of a bibitem,
+ { output.state before.all =
+% just write out the top item from the stack;
+ 'write$
+% and the last alternative is that we're at the end of the current
+% bibitem, so we add a period to the top stack item and write it out.
+ { add.period$ " " * write$ }
+ if$
+ mid.sentence 'output.state :=
+ }
+ if$
+% Put the top item back on the stack that we removed earlier.
+ s
+}
+
+% Output checks to see if the stack top is empty; if not, it
+% calls output.nonnull to write it out.
+
+FUNCTION {output}
+{ duplicate$ empty$
+ 'pop$
+ 'output.nonnull
+ if$
+}
+
+% Standard warning message for a missing or empty field. For the user
+% we call any such field `missing' without respect to the distinction
+% made by BibTeX between missing and empty.
+
+FUNCTION {missing.warning}
+{ "missing " swap$ * " in " * cite$ * warning$ }
+
+% Output.check is like output except that it gives a warning on-screen
+% if the given field in the database entry is empty. t is the field
+% name.
+
+FUNCTION {output.check}
+{ 't :=
+ duplicate$ empty$
+ { pop$ t missing.warning }
+ 'output.nonnull
+ if$
+}
+
+FUNCTION {output.bibitem}
+{ newline$
+ "\bibitem[" write$
+ label write$
+ "]{" write$
+ cite$ write$
+ "}" write$
+ newline$
+% This empty string is the first thing that will be written
+% the next time write$ is called. Done this way because each
+% item is saved on the stack until we find out what punctuation
+% should be added after it. Therefore we need an empty first item.
+ ""
+ before.all 'output.state :=
+}
+
+FUNCTION {output.nonempty.mrnumber}
+{ duplicate$ missing$
+ { pop$ "" }
+ 'skip$
+ if$
+ duplicate$ empty$
+ 'pop$
+ { " \MR{" swap$ * "}" * write$ }
+ if$
+}
+
+FUNCTION {fin.entry}
+{ add.period$
+ write$
+ mrnumber output.nonempty.mrnumber
+ newline$
+}
+
+% Removed new.block, new.block.checka, new.block.checkb, new.sentence,
+% new.sentence.checka, and new.sentence.checkb functions here, since they
+% don't seem to be needed in the AMS style. Also moved some real
+% basic functions like `and' and 'or' earlier in the file.
+
+INTEGERS { nameptr namesleft numnames }
+
+% The extra section to write out a language field was added
+% for AMSPLAIN.BST. Not present in plain.bst.
+
+FUNCTION {format.language}
+{ language empty$
+ { "" }
+ { " (" language * ")" * }
+ if$
+}
+
+% This version of format.names puts names in the format
+%
+% First von Last, Jr.
+%
+% (i.e., first name first, no abbreviating to initials).
+
+FUNCTION {format.names}
+{ 's :=
+ #1 'nameptr :=
+ s num.names$ 'numnames :=
+ numnames 'namesleft :=
+ { namesleft #0 > }
+ { s nameptr "{ff~}{vv~}{ll}{, jj}" format.name$ 't :=
+ nameptr #1 >
+ { namesleft #1 >
+ { ", " * t * }
+ { numnames #2 >
+ { "," * }
+ 'skip$
+ if$
+ t "others" =
+ { " et~al." * }
+ { " and " * t * }
+ if$
+ }
+ if$
+ }
+ 't
+ if$
+ nameptr #1 + 'nameptr :=
+ namesleft #1 - 'namesleft :=
+ }
+ while$
+}
+
+FUNCTION {format.authors}
+{ author empty$
+ { "" }
+ { bysame "\bysame" =
+ { bysame }
+ { author format.names }
+ if$
+ }
+ if$
+}
+
+FUNCTION {format.editors}
+{ editor empty$
+ { "" }
+ { editor format.names
+ editor num.names$ #1 >
+ { " (eds.)" * }
+ { " (ed.)" * }
+ if$
+ }
+ if$
+}
+
+FUNCTION {format.nonauthor.editors}
+{ editor empty$
+ { "" }
+ { editor format.names
+ editor num.names$ #1 >
+ { ", eds." * }
+ { ", ed." * }
+ if$
+ }
+ if$
+}
+
+FUNCTION {format.title}
+{ title empty$
+ { "" }
+ { title "t" change.case$ emphasize }
+ if$
+}
+
+FUNCTION {format.journal.vol.year}
+{ journal empty$
+ { "" "journal name" missing.warning }
+ { journal
+ volume empty$
+ 'skip$
+ { " \textbf{" * volume * "}" * }
+ if$
+ year empty$
+ { "year" missing.warning }
+ { " (" * year * ")" * }
+ if$
+ }
+ if$
+}
+
+% For formatting the issue number for a journal article.
+
+FUNCTION {format.number}
+{ number empty$
+ { "" }
+ { "no.~" number * }
+ if$
+}
+
+% For formatting miscellaneous dates
+
+FUNCTION {format.date}
+{ year empty$
+ { month empty$
+ { "" }
+ { "there's a month but no year in " cite$ * warning$
+ month
+ }
+ if$
+ }
+ { month empty$
+ 'year
+ { month " " * year * }
+ if$
+ }
+ if$
+}
+
+%% The volume, series and number information is sort of tricky.
+%% This code handles it as follows:
+%% If the series is present, and the volume, but not the number,
+%% then we do "\emph{Book title}, Series Name, vol. 000"
+%% If the series is present, and the number, but not the volume,
+%% then we do "\emph{Book title}, Series Name, no. 000"
+%% If the series is present, and both number and volume,
+%% then we do "\emph{Book title}, vol. XX, Series Name, no. 000"
+%% Finally, if the series is absent,
+%% then we do "\emph{Book title}, vol. XX"
+%% or "\emph{Book title}, no. 000"
+%% and if both volume and number are present, give a warning message.
+
+FUNCTION {format.bookvolume.series.number}
+{ volume empty$
+ { "" % Push the empty string as a placeholder in case everything else
+ % is empty too.
+ series empty$
+ 'skip$
+ { pop$ series } % if series is not empty put in stack
+ if$
+ number empty$
+ 'skip$
+ { duplicate$ empty$ % if no preceding material,
+ 'skip$ % do nothing, otherwise
+ { ", " * } % add a comma and space to separate.
+ if$
+ "no." number tie.or.space.connect * % add the number information
+ }
+ if$
+ }
+%% If the volume is NOT EMPTY:
+ { "vol." volume tie.or.space.connect % vol. XX
+ number empty$
+ { series empty$
+ 'skip$
+ { series ", " * swap$ *} % Series Name, vol. XX
+ if$
+ }
+ { series empty$
+ { "can't use both volume and number if series info is missing"
+ warning$
+ "in BibTeX entry type `" type$ * "'" * top$
+ }
+ { ", " * series * ", no." * number tie.or.space.connect }
+ if$
+ }
+ if$
+ }
+ if$
+
+} % end of format.bookvolume.series.number
+
+%% format.inproc.title.where.editors is used by inproceedings entry types
+
+%% No case changing or emphasizing for the title. We want initial
+%% caps, roman.
+%% We add parentheses around the address (place where conference
+%% was held).
+%% Likewise we add parentheses around the editors' names.
+
+FUNCTION {format.inproc.title.address.editors}
+{ booktitle empty$
+ { "" }
+ { booktitle
+ address empty$
+ 'skip$
+ { add.space.if.necessary "(" * address * ")" * }
+ if$
+ editor empty$
+ 'skip$
+ { add.space.if.necessary "(" * format.nonauthor.editors * ")" * }
+ if$
+ }
+ if$
+}
+
+%% format.incoll.title.editors is similar to format.inproc... but
+%% omits the address. For collections that are not proceedings volumes.
+
+FUNCTION {format.incoll.title.editors}
+{ booktitle empty$
+ { "" }
+ { editor empty$
+ { booktitle }
+ { booktitle
+ add.space.if.necessary "(" * format.nonauthor.editors * ")" *
+ }
+ if$
+ }
+ if$
+}
+
+FUNCTION {format.edition}
+{ edition empty$
+ { "" }
+ { output.state mid.sentence =
+ { edition "l" change.case$ " ed." * }
+ { edition "t" change.case$ " ed." * }
+ if$
+ }
+ if$
+}
+
+INTEGERS { multiresult }
+
+FUNCTION {multi.page.check}
+{ 't :=
+ #0 'multiresult :=
+ { multiresult not
+ t empty$ not
+ and
+ }
+ { t #1 #1 substring$
+ duplicate$ "-" =
+ swap$ duplicate$ "," =
+ swap$ "+" =
+ or or
+ { #1 'multiresult := }
+ { t #2 global.max$ substring$ 't := }
+ if$
+ }
+ while$
+ multiresult
+}
+
+FUNCTION {format.pages}
+{ pages empty$
+ { "" }
+ { pages n.dashify }
+ if$
+}
+
+FUNCTION {format.book.pages}
+{ pages empty$
+ { "" }
+ { pages multi.page.check
+ { "pp.~" pages n.dashify * }
+ { "p.~" pages * }
+ if$
+ }
+ if$
+}
+
+FUNCTION {format.chapter.pages}
+{ chapter empty$
+ 'format.book.pages
+ { type empty$
+ { "ch.~" }
+ { type "l" change.case$ " " * }
+ if$
+ chapter *
+ pages empty$
+ 'skip$
+ { ", " * format.book.pages * }
+ if$
+ }
+ if$
+}
+
+FUNCTION {empty.misc.check}
+{ author empty$ title empty$ howpublished empty$
+ month empty$ year empty$ note empty$
+ and and and and and
+ key empty$ not and
+ { "all relevant fields are empty in " cite$ * warning$ }
+ 'skip$
+ if$
+}
+
+FUNCTION {format.thesis.type}
+{ type empty$
+ 'skip$
+ { pop$
+ type "t" change.case$
+ }
+ if$
+}
+
+FUNCTION {format.tr.number}
+{ type empty$
+ { "Tech. Report" }
+ 'type
+ if$
+ number empty$
+ { "t" change.case$ }
+ { number tie.or.space.connect }
+ if$
+}
+
+% The format.crossref functions haven't been paid much attention
+% at the present time (June 1990) and could probably use some
+% work. MJD
+
+FUNCTION {format.article.crossref}
+{ key empty$
+ { journal empty$
+ { "need key or journal for " cite$ * " to crossref " * crossref *
+ warning$
+ ""
+ }
+ { "in " journal * }
+ if$
+ }
+ { "in " key * }
+ if$
+ " \cite{" * crossref * "}" *
+}
+
+FUNCTION {format.crossref.editor}
+{ editor #1 "{vv~}{ll}" format.name$
+ editor num.names$ duplicate$
+ #2 >
+ { pop$ " et~al." * }
+ { #2 <
+ 'skip$
+ { editor #2 "{ff }{vv }{ll}{ jj}" format.name$ "others" =
+ { " et~al." * }
+ { " and " * editor #2 "{vv~}{ll}" format.name$ * }
+ if$
+ }
+ if$
+ }
+ if$
+}
+
+FUNCTION {format.book.crossref}
+{ volume empty$
+ { "empty volume in " cite$ * "'s crossref of " * crossref * warning$
+ "in "
+ }
+ { "vol." volume tie.or.space.connect
+ " of " *
+ }
+ if$
+ editor empty$
+ editor field.or.null author field.or.null =
+ or
+ { key empty$
+ { series empty$
+ { "need editor, key, or series for " cite$ * " to crossref " *
+ crossref * warning$
+ "" *
+ }
+ { series * }
+ if$
+ }
+ { key * }
+ if$
+ }
+ { format.crossref.editor * }
+ if$
+ " \cite{" * crossref * "}" *
+}
+
+FUNCTION {format.incoll.inproc.crossref}
+{ editor empty$
+ editor field.or.null author field.or.null =
+ or
+ { key empty$
+ { booktitle empty$
+ { "need editor, key, or booktitle for " cite$ * " to crossref " *
+ crossref * warning$
+ ""
+ }
+ { "in \emph{" booktitle * "}" * }
+ if$
+ }
+ { "in " key * }
+ if$
+ }
+ { "in " format.crossref.editor * }
+ if$
+ " \cite{" * crossref * "}" *
+}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+% The main functions for each entry type.
+
+% journal, vol and year are formatted together because they are
+% not separated by commas.
+
+FUNCTION {article}
+{ output.bibitem
+ format.authors "author" output.check
+ format.title "title" output.check
+ crossref missing$
+ { format.journal.vol.year "journal, volume, and year" output.check
+ format.number output
+ format.pages "pages" output.check
+ }
+ { format.article.crossref output.nonnull
+ format.pages "pages" output.check
+ }
+ if$
+ format.language *
+ note output
+ fin.entry
+}
+
+FUNCTION {book}
+{ output.bibitem
+ author empty$
+ { format.editors "author and editor" output.check }
+ { format.authors output.nonnull
+ crossref missing$
+ { "author and editor" editor either.or.check }
+ 'skip$
+ if$
+ }
+ if$
+ format.title "title" output.check
+ format.edition output
+ crossref missing$
+ { format.bookvolume.series.number output
+ publisher "publisher" output.check
+ address output
+ }
+ { format.book.crossref output.nonnull
+ }
+ if$
+ format.date "year" output.check
+ format.language *
+ note output
+ fin.entry
+}
+
+FUNCTION {booklet}
+{ output.bibitem
+ format.authors output
+ format.title "title" output.check
+ howpublished output
+ address output
+ format.date output
+ note output
+ fin.entry
+}
+
+FUNCTION {inbook}
+{ output.bibitem
+ author empty$
+ { format.editors "author and editor" output.check }
+ { format.authors output.nonnull
+ crossref missing$
+ { "author and editor" editor either.or.check }
+ 'skip$
+ if$
+ }
+ if$
+ format.title "title" output.check
+ format.edition output
+ crossref missing$
+ { format.bookvolume.series.number output
+ format.chapter.pages "chapter and pages" output.check
+ publisher "publisher" output.check
+ address output
+ }
+ { format.chapter.pages "chapter and pages" output.check
+ format.book.crossref output.nonnull
+ }
+ if$
+ format.date "year" output.check
+ format.language *
+ note output
+ fin.entry
+}
+
+FUNCTION {incollection}
+{ output.bibitem
+ format.authors "author" output.check
+ format.title "title" output.check
+ crossref missing$
+ { format.incoll.title.editors "booktitle" output.check
+ format.bookvolume.series.number output
+ publisher "publisher" output.check
+ address output
+ format.edition output
+ format.date "year" output.check
+ }
+ { format.incoll.inproc.crossref output.nonnull
+ }
+ if$
+ note output
+ format.book.pages output
+ format.language *
+ fin.entry
+}
+
+FUNCTION {inproceedings}
+{ output.bibitem
+ format.authors "author" output.check
+ format.title "title" output.check
+ crossref missing$
+ { format.inproc.title.address.editors "booktitle" output.check
+ format.bookvolume.series.number output
+ organization output
+ publisher output
+ format.date "year" output.check
+ }
+ { format.incoll.inproc.crossref output.nonnull
+ }
+ if$
+ note output
+ format.book.pages output
+ format.language *
+ fin.entry
+}
+
+FUNCTION {conference} { inproceedings }
+
+FUNCTION {manual}
+{ output.bibitem
+ author empty$
+ { organization empty$
+ 'skip$
+ { organization output.nonnull
+ address output
+ }
+ if$
+ }
+ { format.authors output.nonnull }
+ if$
+ format.title "title" output.check
+ author empty$
+ { organization empty$
+ { address output }
+ 'skip$
+ if$
+ }
+ { organization output
+ address output
+ }
+ if$
+ format.edition output
+ format.date output
+ note output
+ fin.entry
+}
+
+FUNCTION {mastersthesis}
+{ output.bibitem
+ format.authors "author" output.check
+ format.title "title" output.check
+ "Master's thesis" format.thesis.type output.nonnull
+ school "school" output.check
+ address output
+ format.date "year" output.check
+ note output
+ format.book.pages output
+ fin.entry
+}
+
+FUNCTION {misc}
+{ output.bibitem
+ format.authors output
+ format.title output
+ howpublished output
+ format.date output
+ note output
+ format.book.pages output
+ fin.entry
+ empty.misc.check
+}
+
+FUNCTION {phdthesis}
+{ output.bibitem
+ format.authors "author" output.check
+ format.title "title" output.check
+ "Ph.D. thesis" format.thesis.type output.nonnull
+ school "school" output.check
+ address output
+ format.date "year" output.check
+ note output
+ format.book.pages output
+ fin.entry
+}
+
+FUNCTION {proceedings}
+{ output.bibitem
+ editor empty$
+ { organization output }
+ { format.editors output.nonnull }
+ if$
+ format.title "title" output.check
+ format.bookvolume.series.number output
+ address empty$
+ { editor empty$
+ 'skip$
+ { organization output }
+ if$
+ publisher output
+ format.date "year" output.check
+ }
+ { address output.nonnull
+ editor empty$
+ 'skip$
+ { organization output }
+ if$
+ publisher output
+ format.date "year" output.check
+ }
+ if$
+ note output
+ fin.entry
+}
+
+FUNCTION {techreport}
+{ output.bibitem
+ format.authors "author" output.check
+ format.title "title" output.check
+ format.tr.number output.nonnull
+ institution "institution" output.check
+ address output
+ format.date "year" output.check
+ note output
+ fin.entry
+}
+
+FUNCTION {unpublished}
+{ output.bibitem
+ format.authors "author" output.check
+ format.title "title" output.check
+ note "note" output.check
+ format.date output
+ fin.entry
+}
+
+FUNCTION {default.type} { misc }
+
+MACRO {jan} {"January"}
+
+MACRO {feb} {"February"}
+
+MACRO {mar} {"March"}
+
+MACRO {apr} {"April"}
+
+MACRO {may} {"May"}
+
+MACRO {jun} {"June"}
+
+MACRO {jul} {"July"}
+
+MACRO {aug} {"August"}
+
+MACRO {sep} {"September"}
+
+MACRO {oct} {"October"}
+
+MACRO {nov} {"November"}
+
+MACRO {dec} {"December"}
+
+READ
+
+FUNCTION {sortify}
+{ purify$
+ "l" change.case$
+}
+
+INTEGERS { len }
+
+FUNCTION {chop.word}
+{ 's :=
+ 'len :=
+ s #1 len substring$ =
+ { s len #1 + global.max$ substring$ }
+ 's
+ if$
+}
+
+INTEGERS { et.al.char.used }
+
+FUNCTION {initialize.et.al.char.used}
+{ #0 'et.al.char.used :=
+}
+
+EXECUTE {initialize.et.al.char.used}
+
+FUNCTION {format.lab.names}
+{ 's :=
+ s num.names$ 'numnames :=
+ numnames #1 >
+ { numnames #4 >
+ { #3 'namesleft := }
+ { numnames 'namesleft := }
+ if$
+ #1 'nameptr :=
+ ""
+ { namesleft #0 > }
+ { nameptr numnames =
+ { s nameptr "{ff }{vv }{ll}{ jj}" format.name$ "others" =
+ { "{\etalchar{+}}" *
+ #1 'et.al.char.used :=
+ }
+ { s nameptr "{v{}}{l{}}" format.name$ * }
+ if$
+ }
+ { s nameptr "{v{}}{l{}}" format.name$ * }
+ if$
+ nameptr #1 + 'nameptr :=
+ namesleft #1 - 'namesleft :=
+ }
+ while$
+ numnames #4 >
+ { "{\etalchar{+}}" *
+ #1 'et.al.char.used :=
+ }
+ 'skip$
+ if$
+ }
+ { s #1 "{v{}}{l{}}" format.name$
+ duplicate$ text.length$ #2 <
+ { pop$ s #1 "{ll}" format.name$ #3 text.prefix$ }
+ 'skip$
+ if$
+ }
+ if$
+}
+
+FUNCTION {author.key.label}
+{ author empty$
+ { key empty$
+ { cite$ #1 #3 substring$ }
+ { key #3 text.prefix$ }
+ if$
+ }
+ { author format.lab.names }
+ if$
+}
+
+FUNCTION {author.editor.key.label}
+{ author empty$
+ { editor empty$
+ { key empty$
+ { cite$ #1 #3 substring$ }
+ { key #3 text.prefix$ }
+ if$
+ }
+ { editor format.lab.names }
+ if$
+ }
+ { author format.lab.names }
+ if$
+}
+
+FUNCTION {author.key.organization.label}
+{ author empty$
+ { key empty$
+ { organization empty$
+ { cite$ #1 #3 substring$ }
+ { "The " #4 organization chop.word #3 text.prefix$ }
+ if$
+ }
+ { key #3 text.prefix$ }
+ if$
+ }
+ { author format.lab.names }
+ if$
+}
+
+FUNCTION {editor.key.organization.label}
+{ editor empty$
+ { key empty$
+ { organization empty$
+ { cite$ #1 #3 substring$ }
+ { "The " #4 organization chop.word #3 text.prefix$ }
+ if$
+ }
+ { key #3 text.prefix$ }
+ if$
+ }
+ { editor format.lab.names }
+ if$
+}
+
+FUNCTION {calc.label}
+{ type$ "book" =
+ type$ "inbook" =
+ or
+ 'author.editor.key.label
+ { type$ "proceedings" =
+ 'editor.key.organization.label
+ { type$ "manual" =
+ 'author.key.organization.label
+ 'author.key.label
+ if$
+ }
+ if$
+ }
+ if$
+ duplicate$
+ year field.or.null purify$ #-1 #2 substring$
+ *
+ 'label :=
+ year field.or.null purify$ #-1 #4 substring$
+ *
+ sortify 'sort.label :=
+}
+
+FUNCTION {sort.format.names}
+{ 's :=
+ #1 'nameptr :=
+ ""
+ s num.names$ 'numnames :=
+ numnames 'namesleft :=
+ { namesleft #0 > }
+ { nameptr #1 >
+ { " " * }
+ 'skip$
+ if$
+ s nameptr "{vv{ } }{ll{ }}{ ff{ }}{ jj{ }}" format.name$ 't :=
+ nameptr numnames = t "others" = and
+ { "et al" * }
+ { t sortify * }
+ if$
+ nameptr #1 + 'nameptr :=
+ namesleft #1 - 'namesleft :=
+ }
+ while$
+}
+
+FUNCTION {sort.format.title}
+{ 't :=
+ "A " #2
+ "An " #3
+ "The " #4 t chop.word
+ chop.word
+ chop.word
+ sortify
+ #1 global.max$ substring$
+}
+
+FUNCTION {author.sort}
+{ author empty$
+ { key empty$
+ { "to sort, need author or key in " cite$ * warning$
+ ""
+ }
+ { key sortify }
+ if$
+ }
+ { author sort.format.names }
+ if$
+}
+
+FUNCTION {author.editor.sort}
+{ author empty$
+ { editor empty$
+ { key empty$
+ { "to sort, need author, editor, or key in " cite$ * warning$
+ ""
+ }
+ { key sortify }
+ if$
+ }
+ { editor sort.format.names }
+ if$
+ }
+ { author sort.format.names }
+ if$
+}
+
+FUNCTION {author.organization.sort}
+{ author empty$
+ { organization empty$
+ { key empty$
+ { "to sort, need author, organization, or key in " cite$ * warning$
+ ""
+ }
+ { key sortify }
+ if$
+ }
+ { "The " #4 organization chop.word sortify }
+ if$
+ }
+ { author sort.format.names }
+ if$
+}
+
+FUNCTION {editor.organization.sort}
+{ editor empty$
+ { organization empty$
+ { key empty$
+ { "to sort, need editor, organization, or key in " cite$ * warning$
+ ""
+ }
+ { key sortify }
+ if$
+ }
+ { "The " #4 organization chop.word sortify }
+ if$
+ }
+ { editor sort.format.names }
+ if$
+}
+
+FUNCTION {presort}
+{ calc.label
+ sort.label
+ " "
+ *
+ type$ "book" =
+ type$ "inbook" =
+ or
+ 'author.editor.sort
+ { type$ "proceedings" =
+ 'editor.organization.sort
+ { type$ "manual" =
+ 'author.organization.sort
+ 'author.sort
+ if$
+ }
+ if$
+ }
+ if$
+ *
+ " "
+ *
+ year field.or.null sortify
+ *
+ " "
+ *
+ title field.or.null
+ sort.format.title
+ *
+ #1 entry.max$ substring$
+ 'sort.key$ :=
+}
+
+ITERATE {presort}
+
+SORT
+
+STRINGS {
+ longest.label last.sort.label next.extra prev.author this.author
+}
+
+INTEGERS { longest.label.width last.extra.num }
+
+FUNCTION {initialize.longest.label}
+{ "" 'longest.label :=
+ #0 int.to.chr$ 'last.sort.label :=
+ "" 'next.extra :=
+ #0 'longest.label.width :=
+ #0 'last.extra.num :=
+ "abcxyz" 'prev.author :=
+ "" 'this.author :=
+}
+
+FUNCTION {forward.pass}
+{ last.sort.label sort.label =
+ { last.extra.num #1 + 'last.extra.num :=
+ last.extra.num int.to.chr$ 'extra.label :=
+ }
+ { "a" chr.to.int$ 'last.extra.num :=
+ "" 'extra.label :=
+ sort.label 'last.sort.label :=
+ }
+ if$
+ author empty$ { editor empty$ { "" } 'editor if$ } 'author if$
+ 'this.author :=
+ this.author prev.author =
+ { "\bysame" 'bysame := }
+ { "" 'bysame :=
+ this.author "" =
+ { "abcxyz" }
+ 'this.author
+ if$
+ 'prev.author :=
+ }
+ if$
+}
+
+FUNCTION {reverse.pass}
+{ next.extra "b" =
+ { "a" 'extra.label := }
+ 'skip$
+ if$
+ label extra.label * 'label :=
+ label width$ longest.label.width >
+ { label 'longest.label :=
+ label width$ 'longest.label.width :=
+ }
+ 'skip$
+ if$
+ extra.label 'next.extra :=
+}
+
+EXECUTE {initialize.longest.label}
+
+ITERATE {forward.pass}
+
+REVERSE {reverse.pass}
+
+FUNCTION {begin.bib}
+{ et.al.char.used
+ { "\newcommand{\etalchar}[1]{$^{#1}$}" write$ newline$ }
+ 'skip$
+ if$
+ preamble$ empty$
+ 'skip$
+ { preamble$ write$ newline$ }
+ if$
+ "\providecommand{\bysame}{\leavevmode\hbox to3em{\hrulefill}\thinspace}"
+ write$ newline$
+ "\providecommand{\MR}{\relax\ifhmode\unskip\space\fi MR }"
+ write$ newline$
+ "% \MRhref is called by the amsart/book/proc definition of \MR."
+ write$ newline$
+ "\providecommand{\MRhref}[2]{%"
+ write$ newline$
+ " \href{http://www.ams.org/mathscinet-getitem?mr=#1}{#2}"
+ write$ newline$
+ "}"
+ write$ newline$
+ "\providecommand{\href}[2]{#2}"
+ write$ newline$
+ "\begin{thebibliography}{" longest.label * "}" *
+ write$ newline$
+}
+
+EXECUTE {begin.bib}
+
+EXECUTE {init.state.consts}
+
+ITERATE {call.type$}
+
+FUNCTION {end.bib}
+{ newline$
+ "\end{thebibliography}" write$ newline$
+}
+
+EXECUTE {end.bib}
+%% \CharacterTable
+%% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
+%% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
+%% Digits \0\1\2\3\4\5\6\7\8\9
+%% Exclamation \! Double quote \" Hash (number) \#
+%% Dollar \$ Percent \% Ampersand \&
+%% Acute accent \' Left paren \( Right paren \)
+%% Asterisk \* Plus \+ Comma \,
+%% Minus \- Point \. Solidus \/
+%% Colon \: Semicolon \; Less than \<
+%% Equals \= Greater than \> Question mark \?
+%% Commercial at \@ Left bracket \[ Backslash \\
+%% Right bracket \] Circumflex \^ Underscore \_
+%% Grave accent \` Left brace \{ Vertical bar \|
+%% Right brace \} Tilde \~}
diff --git a/macros/latex/required/amscls/amsbooka.dtx b/macros/latex/required/amscls/amsbooka.dtx
new file mode 100644
index 0000000000..4ff8e24ae7
--- /dev/null
+++ b/macros/latex/required/amscls/amsbooka.dtx
@@ -0,0 +1,590 @@
+% \def\filename{amsbooka.dtx}
+% \def\fileversion{2.08}
+% \def\filedate{2014/07/11}
+%
+% \iffalse meta-comment
+%
+% American Mathematical Society
+% Technical Support
+% Publications Technical Group
+% 201 Charles Street
+% Providence, RI 02904
+% USA
+% tel: (401) 455-4080
+% (800) 321-4267 (USA and Canada only)
+% fax: (401) 331-3842
+% email: tech-support@ams.org
+%
+% Copyright 1995, 2008, 2014 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
+% 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.
+%
+% This work has the LPPL maintenance status `maintained'.
+%
+% The Current Maintainer of this work is the American Mathematical
+% Society.
+%
+% \fi
+%
+% \iffalse
+%<*driver>
+\documentclass{amsdtx}
+
+\CodelineIndex
+
+\begin{document}
+\title{The \pkg{amsbooka} package}
+\author{American Mathematical Society\\Barbara Beeton}
+\date{Version \fileversion, \filedate}
+\DocInput{amsbooka.dtx}
+\end{document}
+%</driver>
+% \fi
+%
+% \maketitle
+%
+% \MakeShortVerb\|
+%
+% \section{Introduction}
+%
+% This package is an add-on to the \amslatex/ document classes for
+% monographs. It provides the facility to include an author's name
+% with a part or chapter title of a monograph, and automatically pass
+% the author information on to the table of contents for presentation
+% in a style compatible with the regular (series-specific) TOC style.
+% It also provides facilities to add elements often associated with
+% separately authored chapters, including a copyright notice,
+% uunumbered footnotes, and a section-level bibliography.
+%
+% This package may become part of the \amslatex/ collection of
+% document classes and related packages.
+%
+% \StopEventually{}
+%
+% Standard file identification.
+% \begin{macrocode}
+\NeedsTeXFormat{LaTeX2e}% LaTeX 2.09 can't be used (nor non-LaTeX)
+[1995/06/01]% LaTeX date must be June 1995 or later
+\ProvidesPackage{amsbooka}[2014/07/11 v2.08 monograph part/chapter authors]
+% \end{macrocode}
+%
+% \section{User instructions}
+%
+% \textbf{Getting started:} The front matter of the book must include
+% (at least) a \cn{title} and \cn{\maketitle}. If these are absent,
+% an unintelligible error message will result. This is caused by
+% the redefinition of the \cn{author} command, which is ordinarily
+% expected to occur only in the book's front matter.
+%
+% \subsection{Chapter and part headings}
+%
+% A part or chapter with no associated author is input in the usual
+% way:\\[2pt]
+% \verb|\part{|\<full title>\verb|}|\\
+% \verb|\chapter[|\<short title>\verb|]{|\<full title>\verb|}|\\[2pt]
+% The part or chapter title will be set in the regular style for
+% the series.
+%
+% If an author is to be associated with a chapter, then the short
+% title \emph{must} be provided, and the author is included within
+% the full title, thus:\\[2pt]
+% \verb|\chapter[|\<short title>\verb|]{|\<full title>%
+% \verb| \author{|\<author name>\verb|}}|
+%
+% \vspace{2pt}
+%
+% This works for both \verb|\chapter| and \verb|\chapter*|.
+% Similarly, a part title with an associated author must include
+% the author as follows:\\[2pt]
+% \verb|\part{|\<full title>\verb| \author{|\<author name>\verb|}}|\\[2pt]
+% No short title is required for a part title with author.
+%
+% The author name will be set following the title and also included
+% in the table of contents, both in the appropriate style for the
+% series.
+%
+% When an author is specified for a chapter, the left-hand running
+% head will be the author name; the right-hand running head will
+% be the chapter title, taken from the short title. For a chapter
+% with no specified author, the running heads will be the same as
+% for an ``ordinary'' monograph: chapter title on the left and
+% section heading on the right, except that, if the chapter has
+% no sections, the chapter title will also appear on the right.
+%
+% By default, ``authored'' chapters will be numbered, but chapter
+% numbers will be omitted from the running heads. (Most volumes
+% encountered so far in this style are essentially collections.)
+% Chapter numbers can be restored to the running heads by using the
+% documentclass option \opt{[rhchapnum]}. In the present version
+% of \pkg{amsbooka} this is an all-or-nothing proposition, but
+% this decision may be reconsidered if an example emerges in which
+% there is justification for including chapter numbers in some
+% running heads but not in others.
+%
+% Similarly, the ``standard'' monograph running heads (chapter on
+% the left, section on the right) can be forced for all authored
+% chapters by specifying the documentclass option \opt{[rhchapsec]}.
+% With this option, chapter numbers will not be suppressed. Again,
+% this is an all-or-nothing choice.
+%
+% \subsection{Elements at the bottom of the first page}
+%
+% If information such as a previous publication or an alternate
+% source is noted, this should appear on the first page of the
+% chapter as an unnumbered footnote. Enter this immediately
+% after the \verb|\chapter| title, using this command:\\[2pt]
+% \verb|\barefootnote{|\<footnote text>\verb|}|
+%
+% \vspace{2pt}
+%
+% If a separate copyright notice is required for a chapter,
+% enter it as follows:\\[2pt]
+% \verb|\copyrightinfo{|\<year>\verb|}{|\<copyright holder>\verb|}|\\[2pt]
+% If this command is not input for a chapter, no notice will appear.
+%
+% \subsection{Bibliography within a chapter}
+%
+% The bibliography of a monograph usually appears as a separate chapter.
+% However, for collections addressed by the present package, each
+% individual chapter may have its own reference list, which should
+% be treated as a section.
+%
+% If the chapter bibliography has been prepared for \pkg{amsrefs},
+% specify \env{bibsection} to obtain the proper format. (See the
+% \pkg{amsrefs} documentation for details.)
+%
+% If the chapter bibliography has been prepared using \BibTeX,
+% substitute\\[2pt]
+% \verb|\begin{inchapterbibliography}|\\
+% \verb|...|\\
+% \verb|\end{inchapterbibliography}|\\[2pt]
+% for the usual \env{thebibliography} environment. The actual contents
+% of the bibliography should be included within the chapter file,
+% not read in from a separate \fn{.bbl} file. If the heading of
+% this section needs to be changed,\\[2pt]
+% \verb|\renewcommand{\bibname}{...}|
+%
+%
+% \section{Implementation}
+%
+% This package is meant for use with all AMS monograph series.
+% Two series, GSM and STML, have special requirements, so provide
+% matching strings that can be used to identify them. Other series
+% may be added to this list, so also provide a switch that can be
+% used to identify them collectively.
+% \begin{macrocode}
+\def\@gsm{gsm-l}
+\def\@stml{stml-l}
+\newif\if@ruledchapterhead
+\@ruledchapterheadfalse
+\ifx\@classname\@gsm \@ruledchapterheadtrue
+ \else\ifx\@classname\@stml \@ruledchapterheadtrue
+ \fi
+\fi
+% \end{macrocode}
+%
+% Some ramifications with running heads are best addressed with
+% defaults that can be overridden by options.
+%
+% First option: force ``standard'' (chapter/section) running heads.
+% \begin{macrocode}
+\newif\if@rhchapnum
+\@rhchapnumfalse
+\DeclareOption{rhchapnum}{\@rhchapnumtrue}
+% \end{macrocode}
+%
+% Next option: force ``standard'' (chapter/section) running heads.
+% This also turns on chapter numbers in the running heads.
+% \begin{macrocode}
+\newif\if@rhchapsec
+\@rhchapsecfalse
+\DeclareOption{rhchapsec}{\@rhchapsectrue \@rhchapnumtrue}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\ProcessOptions\relax
+% \end{macrocode}
+%
+% \subsection{Chapter headings}
+%
+% \begin{macro}{@schaptera}
+% \begin{macro}{@schapterb}
+% In order to associate an author name with an unnumbered chapter,
+% we need to redefine \cs{@schapter} to accept a bracketed optional
+% version for the running head. The original version, without
+% optional text, is still required for the bibliography and index
+% as well as for other unauthored chapters. Use the original
+% \cs{@schapter} for this by giving it another name, and check
+% again for the presence of a bracketed option.
+% \begin{macrocode}
+\let\@schapterb\@schapter
+\def\@schapter{\secdef\@schaptera\@schapterb}
+\def\@schaptera[#1]#2{\typeout{#1}%
+ \let\@secnumber\@empty
+ \def\@toclevel{0}%
+ \ifx\chaptername\appendixname \@tocwriteb\tocappendix{chapter}{#2}%
+ \else \@tocwriteb\tocchapter{chapter}{#2}\fi
+ \chaptermark{#1}%
+ \addtocontents{lof}{\protect\addvspace{10\p@}}%
+ \addtocontents{lot}{\protect\addvspace{10\p@}}%
+ \@makeschapterhead{#2}\@afterheading
+}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{@makechapterhead}
+% \begin{macro}{@makeschapterhead}
+% Redefine the commands \cs{@makechapterhead} and \cs{@makeschapterhead}
+% from the regular monograph document classes, handling special cases
+% as necessary.
+% \begin{macrocode}
+\def\@makechapterhead#1{%
+ \ifx\@classname\@gsm \@makegsmchapterhead{#1}%
+ \else \ifx\@classname\@stml \@makestmlchapterhead{#1}%
+ \else \@makeplainchapterhead{#1}%
+ \fi \fi
+}
+\newif\if@schapter \@schapterfalse
+\def\@makeschapterhead#1{%
+ \@schaptertrue
+ \ifx\@classname\@gsm \@makegsmchapterhead{#1}%
+ \else \ifx\@classname\@stml \@makestmlchapterhead{#1}%
+ \else \@makeplainschapterhead{#1}%
+ \fi \fi
+}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{@makeplainchapterhead}
+% \begin{macro}{@makeschapterhead}
+% The ``plain'' chapter head style is used for nearly all AMS
+% monograph series. The title is set in the usual style, with
+% the author name centered below in small caps.\\
+% The author name is set up to be the left-hand running head,
+% as it would be for a journal or proceedings article. This
+% will be effected only for chapters with an \cn{author}.
+% It can also be suppressed with the \opt{[rhchapsec]} option.\\
+% If a copyright notice is included, suppress it for the next
+% chapter.
+% \begin{macrocode}
+\def\@makeplainchapterhead#1{%
+ \global\topskip 7.5pc\relax
+ \@setcopyright
+ \let\copyrightyear\@empty
+ \begingroup
+ \def\title{}%
+ \def\author##1{%
+ \if@rhchapsec
+ \else \markleft{\MakeUppercase{##1}}%
+ \fi
+ \vskip1pc\fontsize{\@xiipt}{14}\mdseries\textsc{##1}}%
+ \fontsize{\@xivpt}{18}\bfseries\centering
+ \ifnum\c@secnumdepth>\m@ne
+ \leavevmode \hskip-\leftskip
+ \rlap{\vbox to\z@{\vss
+ \centerline{\normalsize\mdseries
+ \MakeUppercase{\chaptername}\enspace\thechapter}
+ \vskip 3pc}}\hskip\leftskip
+ \fi
+ #1\par \endgroup
+ \skip@34\p@ \advance\skip@-\normalbaselineskip
+ \vskip\skip@
+}
+\def\@makeschapterhead#1{%
+ \global\topskip 7.5pc\relax
+ \@setcopyright
+ \let\copyrightyear\@empty
+ \begingroup
+ \def\title{}%
+ \def\author##1{%
+ \if@rhchapsec
+ \else \markleft{\MakeUppercase{##1}}%
+ \fi
+ \vskip1pc\fontsize{\@xiipt}{14}\mdseries\textsc{##1}}%
+ \fontsize{\@xivpt}{18}\bfseries\centering
+ #1\par \endgroup
+ \skip@34\p@ \advance\skip@-\normalbaselineskip
+ \vskip\skip@
+}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{@makeruledchapterhead}
+% \begin{macro}{@makeruledschapterhead}
+% GSM and STML require a rule at the top of the page and a smaller
+% rule above the page number at the bottom. Other specs are
+% publication-specific.
+% \begin{macrocode}
+\def\@makeruledchapterhead#1{%
+ \global\topskip\normaltopskip
+ \begingroup
+ \def\author##1{%
+ \if@rhchapsec
+ \else \markleft{##1}%
+ \fi
+ \\ \hfil \\ \@chapauthorstyle ##1}%
+ \vbox to\topskip{%
+ \chapter@number
+ \vss
+ }\penalty\@M
+ \@chapheadstyle \raggedright
+ \noindent #1\par \endgroup
+ \if@index
+ \@indexstyle
+ \else
+ \@dropfolio
+ \@noindexstyle
+ \fi
+ \@afterheading
+}
+\def\@makeruledschapterhead#1{%
+ \global\topskip\normaltopskip
+ \begingroup
+ \def\author##1{%
+ \if@rhchapsec
+ \else \markleft{##1}%
+ \fi
+ \\ \hfil \\ \@chapauthorstyle ##1}%
+ \@chapheadstyle \raggedright
+ \noindent #1\par \endgroup
+ \if@index
+ \@indexstyle
+ \else
+ \@dropfolio
+ \@noindexstyle
+ \fi
+ \@afterheading
+}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{@makegsmchapterhead}
+% The style for GSM requires a rule at the top of the page, with
+% the chapter title flush left, bold, and the author information
+% below the title also flush left and bold but in a smaller size.
+% \begin{macrocode}
+\def\@makegsmchapterhead#1{%
+ \def\@chapheadstyle{\Huge\bfseries \hsize24pc
+ \top@space{11pc}}%
+ \def\@chapauthorstyle{\LARGE\bfseries}%
+ \def\@indexstyle{%
+ \ifx\@empty\indexintro
+ \bb@space{7.5pc}%
+ \else
+ \vspace{3pc}%
+ \begingroup \small
+ \parbox[t]{27pc}{\leftskip3pc\normalfont\indexintro\par}%
+ \endgroup
+ \bb@space{3pc}%
+ \fi
+ }%
+ \def\@noindexstyle{\bb@space{7.5pc}}%
+ \if@schapter
+ \@makeruledschapterhead{#1}%
+ \else
+ \@makeruledchapterhead{#1}%
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{@makestmlchapterhead}
+% The style for STML is similar to that for GSM, except for the
+% smaller page size and the author information set in lightface
+% in the LARGE size.
+% \begin{macrocode}
+\def\@makestmlchapterhead#1{%
+ \def\@chapheadstyle{\fontsize\@xxpt{22}\selectfont\bfseries\hsize 21pc
+ \top@par@space{9pc}}%
+ \def\@chapauthorstyle{\LARGE\mdseries}%
+ \def\@indexstyle{%
+ \ifx\@empty\indexintro
+ \bb@par@space{6.5pc}%
+ \else
+ \vspace{2.5pc}%
+ \begingroup \small
+ \parbox[t]{22.5pc}{\leftskip2.5pc\normalfont\indexintro\par}%
+ \endgroup
+ \bb@par@space{2.5pc}%
+ \fi
+ }%
+ \def\@noindexstyle{\bb@par@space{6.5pc}}%
+ \if@schapter
+ \@makeruledschapterhead{#1}%
+ \else
+ \@makeruledchapterhead{#1}%
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsection{Running heads}
+%
+% \begin{macro}{chapterrunhead}
+% Unless overridden by the \opt{[]} option, omit chapter numbers
+% from the right-hand running head with chapter title. (Explicit
+% line breaks with \verb|\\| are converted to spaces.)
+% \begin{macrocode}
+\if@rhchapnum
+\else
+ \def\chapterrunhead#1#2#3{%
+ \def\@tempa{#3}%
+ \begingroup \def\\{ \ignorespaces}%
+ \uppercasenonmath\@tempa\@tempa
+ \endgroup
+ }
+\fi
+% \end{macrocode}
+% \end{macro}
+%
+% \subsection{Part headings}
+%
+% \begin{macro}{@plainpart}
+% The ``plain'' part head style is used for nearly all AMS
+% monograph series. The title is set in the usual style, with
+% the author name centered below in italic.
+% \begin{macrocode}
+\def\partauthor{%
+ \def\author##1{\newline\phantom{Part 1.\enspace}{\mdseries\scshape##1}}}
+\def\@part[#1]#2{%
+ \ifnum \c@secnumdepth >-2\relax \refstepcounter{part}%
+ \addcontentsline{toc}{part}{\partname\ \thepart.%
+ \protect\partauthor\protect\enspace\protect\noindent#1}%
+ \else
+ \addcontentsline{toc}{part}{#1}\fi
+ \begingroup
+ \def\author##1{\\ \hfil \\ \fontsize{\@xivpt}{20}\mdseries\itshape ##1}%
+ \centering
+ \ifnum \c@secnumdepth >-2\relax
+ {\fontsize{\@xviipt}{22}\bfseries
+ \partname\ \thepart} \vskip 20\p@ \fi
+ \fontsize{\@xxpt}{25}\bfseries
+ #1\vfil\vfil\endgroup \newpage\thispagestyle{empty}}
+\def\@spart#1{\addcontentsline{toc}{part}%
+ {\protect\partauthor\protect\noindent#1}%
+ \begingroup
+ \def\author##1{\\ \hfil \\ \fontsize{\@xivpt}{20}\mdseries\itshape ##1}%
+ \centering
+ \fontsize{\@xxpt}{25}\bfseries
+ #1\vfil\vfil\endgroup \newpage\thispagestyle{empty}}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsection{Table of Contents}
+%
+% Allow more space for the page number than provided in \cls{amsbook};
+% that is only 1.6em, and results in unpleasantly long text.
+% \begin{macrocode}
+\setbox\z@\hbox{\kern1.5pc 999}
+\renewcommand{\@pnumwidth}{\wd\z@}
+% \end{macrocode}
+%
+% \begin{macro}{@tocline}
+% Replace the \cs{@tocline} command to include the \cn{author}
+% information. This will be set in small caps on the line following
+% the chapter title, with the same indentation as the title.
+% \begin{macrocode}
+\def\@tocline#1#2#3#4#5#6#7{\relax
+ \ifnum #1>\c@tocdepth % then omit
+ \else
+ \def\author##1{\newline\textsc{##1}}%
+ \par \addpenalty\@secpenalty\addvspace{#2}%
+ \begingroup \hyphenpenalty\@M
+ \@ifempty{#4}{%
+ \@tempdima\csname r@tocindent\number#1\endcsname\relax
+ }{%
+ \@tempdima#4\relax
+ }%
+ \parindent\z@ \leftskip#3\relax \advance\leftskip\@tempdima\relax
+ \rightskip\@pnumwidth plus.2\hsize \parfillskip-\@pnumwidth
+ #5\leavevmode\hskip-\@tempdima #6\nobreak\relax
+ \hfil\hbox to\@pnumwidth{\@tocpagenum{#7}}\par
+ \nobreak
+ \endgroup
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsection{Other features}
+%
+% \subsubsection{Copyright notice}
+% A copyright notice is sometimes wanted on separately authored
+% chapters of a ``composite'' monograph or volume of collected works.
+% Provide the ability to add this feature if required, using the
+% same command, \cn{copyrightinfo}, used for journal and proceedings
+% articles. \cn{copyrightinfo} is present in \cls{amsbook}, so it
+% suffices to set an appropriate default to suppress it unless it
+% is requested explicitly.
+% \begin{macrocode}
+\let\copyrightyear\@empty
+% \end{macrocode}
+%
+% For now, don't allow a copyright notice for GSM or STML or other
+% books with a similar design. The need is unlikely, but the more
+% important reason is that the style needs rethinking if such a
+% notice is to be included.
+% \begin{macrocode}
+\if@ruledchapterhead \def\copyrightinfo#1#2{}\fi
+% \end{macrocode}
+%
+% \begin{macro}{barefootnote}
+% \subsubsection{``Bare'' footnotes}
+% Unnumbered footnotes (such as those that appear on the first page
+% of a journal or proceedings article) are needed to provide information
+% regarding earlier publication and the like.
+% \begin{macrocode}
+\newcommand{\barefootnote}[1]{{%
+ \let\@makefnmark\relax \let\@thefnmark\relax
+ \@footnotetext{#1}}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{inchapterbibliography}
+% \subsubsection{Chapter-specific bibliography}
+% Separately authored chapters often have individual bibliographies,
+% which should be presented as sections, not chapters. For now,
+% disable the mark for the section header (copying the code from
+% the initial value in \cls{amsbook}); it should not appear as
+% the right-hand running head if the author/chapter title headers
+% are in effect. Still to be determined is whether the section title
+% ``Bibliography'' should appear in the running head if no author is
+% specified and the ``standard'' running heads are used.
+% \begin{macrocode}
+\newenvironment{inchapterbibliography}[1]{%
+ \let\sectionmark\@gobble
+ \@xp\section\@xp*\@xp{\bibname}%
+ \normalfont\footnotesize\labelsep .5em\relax
+ \renewcommand\theenumiv{\arabic{enumiv}}\let\p@enumiv\@empty
+ \list{\@biblabel{\theenumiv}}{\settowidth\labelwidth{\@biblabel{#1}}%
+ \leftmargin\labelwidth \advance\leftmargin\labelsep
+ \usecounter{enumiv}}%
+ \sloppy \clubpenalty\@M \widowpenalty\clubpenalty
+ \sfcode`\.=\@m
+}{%
+ \def\@noitemerr{\@latex@warning{Empty `inchapterbibliography' environment}}%
+ \endlist
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsection{Boilerplate}
+%
+% 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{566}
+% \Finale
diff --git a/macros/latex/required/amscls/amsbooka.ins b/macros/latex/required/amscls/amsbooka.ins
new file mode 100644
index 0000000000..8c04799b64
--- /dev/null
+++ b/macros/latex/required/amscls/amsbooka.ins
@@ -0,0 +1,78 @@
+%% filename: amsbooka.ins
+%% version: 2.0
+%% date: 2014/07/11
+%%
+%% American Mathematical Society
+%% Technical Support
+%% Publications Technical Group
+%% 201 Charles Street
+%% Providence, RI 02904
+%% USA
+%% tel: (401) 455-4080
+%% (800) 321-4267 (USA and Canada only)
+%% fax: (401) 331-3842
+%% email: tech-support@ams.org
+%%
+%% Copyright 2003, 2014 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
+%% 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.
+%%
+%% This work has the LPPL maintenance status `maintained'.
+%%
+%% The Current Maintainer of this work is the American Mathematical
+%% Society.
+%%
+%% ====================================================================
+
+\input docstrip
+
+\askforoverwritefalse
+
+\keepsilent
+
+\preamble
+This is a generated file.
+
+Copyright 1995, 2008, 2014 American Mathematical Society.
+
+American Mathematical Society
+Technical Support
+Publications Technical Group
+201 Charles Street
+Providence, RI 02904
+USA
+tel: (401) 455-4080
+ (800) 321-4267 (USA and Canada only)
+fax: (401) 331-3842
+email: tech-support@ams.org
+
+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
+ 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.
+
+This work has the LPPL maintenance status `maintained'.
+
+The Current Maintainer of this work is the American Mathematical
+Society.
+
+========================================================================
+
+\endpreamble
+
+\usedir{tex/latex/amsclass}
+
+\generate{
+ \file{amsbooka.sty}{\from{amsbooka.dtx}{}}
+}
+
+\endbatchfile
diff --git a/macros/latex/required/amscls/amsclass.dtx b/macros/latex/required/amscls/amsclass.dtx
new file mode 100644
index 0000000000..eb6abaf520
--- /dev/null
+++ b/macros/latex/required/amscls/amsclass.dtx
@@ -0,0 +1,5214 @@
+% \def\filename{amsclass.dtx}
+% \def\fileversion{2.20.4}
+% \def\filedate{2017/10/31}
+%
+% \iffalse meta-comment
+%
+% American Mathematical Society
+% Technical Support
+% Publications Technical Group
+% 201 Charles Street
+% Providence, RI 02904
+% USA
+% tel: (401) 455-4080
+% (800) 321-4267 (USA and Canada only)
+% fax: (401) 331-3842
+% email: tech-support@ams.org
+%
+% Copyright 1995, 1999, 2004, 2009, 2015-2017 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
+% 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.
+%
+% This work has the LPPL maintenance status `maintained'.
+%
+% The Current Maintainer of this work is the American Mathematical
+% Society.
+%
+% \fi
+%
+% \iffalse
+%<*driver>
+\documentclass{amsdtx}
+
+\CodelineIndex
+
+\begin{document}
+\title{%
+ The \cls{amsart}, \cls{amsproc}, and \cls{amsbook} document~classes}
+\author{American Mathematical Society\\Michael Downes\\
+ updated by Barbara Beeton}
+\date{Version \fileversion, \filedate}
+\DocInput{amsclass.dtx}
+\end{document}
+%</driver>
+% \fi
+%
+% \maketitle
+%
+% \MakeShortVerb\|
+%
+% \section{Introduction}
+% This file (\fn{amsclass.dtx}) is the master file for three \latex/
+% document classes, \cls{amsart}, \cls{amsproc}, and \cls{amsbook},
+% which are intended for articles and books containing mathematical
+% research. They produce output that follows the style conventions of
+% American Mathematical Society publications. The theorem setup
+% features of these document classes are also available in a separate
+% package, \pkg{amsthm}.
+%
+% \StopEventually{}
+%
+% \section{Implementation}
+%
+% Three document class files and one package file (\fn{amsthm.sty})
+% are produced from this source. Most of the code of the \fn{amsthm}
+% package is used in all four derived files. Most of the remaining
+% code is used in all three document class files. Fine tuning is done
+% with additional docstrip guards.
+%
+% The usual name, date, and version information. (Note: the reason
+% each \cs{ProvidesClass} command is placed on a line by itself, with
+% separate begin and end guards for docstripping, is to make
+% automatic update of file date and version slightly easier and more
+% robust.)
+%
+% \begin{macrocode}
+\NeedsTeXFormat{LaTeX2e}% LaTeX 2.09 can't be used (nor non-LaTeX)
+[1995/06/01]% LaTeX date must be June 1995 or later
+%<*amsart>
+\ProvidesClass{amsart}[2017/10/31 v2.20.4]
+%</amsart>
+%<*amsproc>
+\ProvidesClass{amsproc}[2017/10/31 v2.20.4]
+%</amsproc>
+%<*amsbook>
+\ProvidesClass{amsbook}[2017/10/31 v2.20.4]
+%</amsbook>
+% \end{macrocode}
+% For \pkg{amsthm} we need to guard against redundant loading via
+%\begin{verbatim}
+% \documentclass{amsart}
+% \usepackage{amsthm}
+%\end{verbatim}
+% because in that case the usual \cs{RequirePackage} mechanism for
+% avoiding redundant loading will not apply. We need to simulate the
+% loading of the \pkg{amsthm} package.
+% \begin{macrocode}
+%<*classes>
+\global\expandafter\let\csname ver@amsthm.sty\expandafter\endcsname
+ \csname ver@\@currname.\@currext\endcsname
+%</classes>
+%<*amsthm>
+\ProvidesPackage{amsthm}[2017/10/31 v2.20.4]
+%</amsthm>
+% \end{macrocode}
+%
+% The following code is shared by the classes and the \pkg{amsthm}
+% package. Cf.~\fn{amsgen.sty}.
+% \begin{macrocode}
+\let\@xp=\expandafter
+\let\@nx=\noexpand
+\def\@oparg#1[#2]{\@ifnextchar[{#1}{#1[#2]}}
+\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}
+\long\def\@ifnotempty#1{\@ifempty{#1}{}}
+\def\setboxz@h{\setbox\z@\hbox}
+\def\@addpunct#1{%
+ \relax\ifhmode
+ \ifnum\spacefactor>\@m \else#1\fi
+ \fi}
+% \end{macrocode}
+% \cn{nopunct} should have a value for \cn{spacefactor} that is
+% not used for \cn{frenchspacing}.
+% \begin{macrocode}
+\def\nopunct{\spacefactor 1007 }
+\def\frenchspacing{\sfcode`\.1006\sfcode`\?1005\sfcode`\!1004%
+ \sfcode`\:1003\sfcode`\;1002\sfcode`\,1001 }
+% \end{macrocode}
+%
+% If this class is loaded by a parent document class, then we want
+% to use the name of the parent class. Otherwise the name of the
+% current class file.
+% \begin{macrocode}
+%<*classes>
+\def\@tempa#1#2\@nil{\edef\@classname{#1}}
+\expandafter\@tempa\@currnamestack{}{}{}\@nil
+\ifx\@classname\@empty \edef\@classname{\@currname}\fi
+% \end{macrocode}
+%
+% \subsection{Support for conditional text}
+%
+% [This needs to be documented in the users' guide, including the
+% idea of using \verb'\for{5ed}{\linebreak}' to mark edition-specific
+% line and page breaks. [mjd,1999/12/27]]
+%
+% We would sometimes like to be able to mark fragments of text to be
+% conditionally discarded or typeset. For example in the title of a
+% section if we want to add a linebreak but prevent this linebreak
+% from also taking effect in the table of contents.
+%
+% Certain kinds of switches need to be built into the low-level
+% structure of our document class in order to be useful. For example,
+% inside the toc we need to arrange for an \qq{in-toc?} test to yield
+% true.
+%
+% \begin{macrocode}
+\def\@True{00}
+\def\@False{01}
+\newcommand\newswitch[2][False]{%
+ \expandafter\@ifdefinable\csname ?@#2\endcsname{%
+ \global\expandafter\let\csname ?@#2\expandafter\endcsname
+ \csname @#1\endcsname
+ }%
+}
+\newcommand{\setFalse}[1]{%
+ \expandafter\let\csname ?@#1\endcsname\@False
+}
+\newcommand{\setTrue}[1]{%
+ \expandafter\let\csname ?@#1\endcsname\@True
+}
+% \end{macrocode}
+% The empty switch is by default false; i.e., if you write
+%\begin{verbatim}
+% \for{}{...}
+%\end{verbatim}
+% the material will be discarded.
+% \begin{macrocode}
+\newswitch{}
+% \end{macrocode}
+%
+% To get a line break in a section title but not in the table of
+% contents line for that section, use
+% \verb'\except{toc}{\linebreak}'. (Presumably you are already giving
+% a shortened running head version separately, if applicable.)
+% \begin{macrocode}
+\DeclareRobustCommand{\except}[1]{%
+ \if\csname ?@#1\endcsname \expandafter\@gobble
+ \else \expandafter\@firstofone
+ \fi
+}
+\DeclareRobustCommand{\for}[1]{%
+ \if\csname ?@#1\endcsname \expandafter\@firstofone
+ \else \expandafter\@gobble
+ \fi
+}
+% \end{macrocode}
+%
+% The \cn{forany} command needs to run through a comma-separated list
+% of switch names and print its second argument if any of the
+% switches are true.
+% \begin{macrocode}
+\DeclareRobustCommand{\forany}[1]{%
+ \csname for@any@01\endcsname#1,?,\@nil
+}
+\@namedef{for@any@\@False}#1,{%
+ \csname for@any@%
+ \csname ?@\zap@space#1 \@empty\endcsname
+ \endcsname
+}
+\@namedef{?@?}{x}
+\@namedef{for@any@\@True}#1\@nil#2{#2}
+\def\for@any@x{\@car\@gobble}
+% \end{macrocode}
+%
+% \subsection{Options}
+% \subsubsection{Notes}
+% Options will be processed in the order they are declared;
+% cf.~\cs{ProcessOptions}.
+%
+% \subsubsection{Paper size}
+%
+% The option \opt{letterpaper} (default) sets the target paper width
+% and height to U.S. letter size, 8.5 in x 11 in. An option
+% \opt{a4paper} is also supported, but we don't include some of the
+% more unusual paper options (\opt{legalpaper}, \opt{a5paper},
+% \opt{executivepaper}) of the generic \cls{article} class. For A4
+% paper we not only change the paper size but also add 4pc to the
+% normal textheight of 50.5pc (the difference between 297mm and 11in
+% is 50pt).
+% \begin{macrocode}
+\DeclareOption{a4paper}{\paperheight 297mm\paperwidth 210mm
+ \textheight 54.5pc }
+\DeclareOption{letterpaper}{\paperheight 11in\paperwidth 8.5in }
+% \end{macrocode}
+%
+% The options \opt{landscape} and \opt{portrait} swap paper height
+% and width.
+% \begin{macrocode}
+\DeclareOption{landscape}{\@tempdima\paperheight
+ \paperheight\paperwidth \paperwidth\@tempdima}
+\DeclareOption{portrait}{}
+% \end{macrocode}
+%
+% \subsubsection{Two-sided or one-sided printing}
+%
+% For two-sided printing we set the switch \cs{if@twoside} which
+% will cause the margins to be adjusted so that the type blocks of
+% back-to-back pages will line up. The \cs{if@mparswitch} makes margin
+% paragraphs print in the outside margin.
+% \begin{macrocode}
+\DeclareOption{oneside}{\@twosidefalse \@mparswitchfalse}
+\DeclareOption{twoside}{\@twosidetrue \@mparswitchtrue}
+% \end{macrocode}
+%
+% \subsubsection{Draft or final version}
+%
+% The \opt{draft} option causes overfull lines to be marked with
+% a black slug in the right margin.
+% \begin{macrocode}
+\DeclareOption{draft}{\overfullrule5\p@
+ \ClassWarningNoLine{\@classname}{%
+ When the draft option is used, the
+ \protect\includegraphics\MessageBreak
+ command will print blank placeholder boxes\MessageBreak
+ for the graphics}%
+}
+\DeclareOption{final}{\overfullrule\z@ }
+% \end{macrocode}
+%
+% \subsubsection{Posting date}
+%
+% The date when an article is officially posted to the WWW is recorded
+% in a variable \cs{@dateposted} with the \cn{dateposted} command.
+%
+% \begin{macrocode}
+\def\dateposted#1{\def\@dateposted{#1}}%
+\let\@dateposted\@empty
+% \end{macrocode}
+%
+% \begin{macrocode}
+%<*amsart>
+\def\@setdateposted{%
+ \newline Article electronically published on \@dateposted}
+%</amsart>
+% \end{macrocode}
+%
+% \subsubsection{Logos}
+%
+% The following logo is used for regular journal articles. The one
+% for proceedings articles and the one for e-only journals are given
+% separately.
+% \begin{macrocode}
+%<*amsart>
+\def\article@logo{%
+ \set@logo{%
+ \publname
+% \end{macrocode}
+% Current volume might be empty when an article is first posted to
+% the WWW. In that case leave out the issue-specific info.
+% \begin{macrocode}
+ \ifx\@empty\currentvolume
+ \else \newline\volinfo, \pageinfo
+ \fi
+ \newline \@PII
+ \ifx\@empty\@dateposted \else \@setdateposted\fi
+ }%
+}
+\def\eonly@logo{%
+ \set@logo{%
+ \publname
+ \newline\volinfo, \pageinfo
+ \ifx\@empty\@dateposted \else \@setdateposted\fi
+ \newline \@PII
+ }%
+}
+%</amsart>
+% \end{macrocode}
+%
+% \begin{macrocode}
+%<*amsart|amsproc>
+\def\@logofont{\fontsize{6}{7\p@}\selectfont}
+\long\def\set@logo#1{%
+ \vbox to\headheight{%
+ \@parboxrestore \@logofont
+ \noindent#1\par\vss
+ }%
+}
+%</amsart|amsproc>
+% \end{macrocode}
+%
+% \begin{macrocode}
+%<*amsproc>
+\def\procart@logo{%
+ \set@logo{\publname
+ \ifx\@empty\volinfo \else\newline\volinfo\fi}%
+}
+%</amsproc>
+% \end{macrocode}
+%
+% \subsubsection{E-only journal}
+%
+% Electronic-only journals (for \cls{amsart} only) have different
+% information in the series logo than paper-only or dual journals.
+% Only the volume number is reported (no issue or year), and the
+% posting date is added following the page numbers. [bnb, 1996/10/31]
+%
+% This option will be invoked only from publication-specific \fn{.cls}
+% files.
+% \begin{macrocode}
+%<*amsart>
+\DeclareOption{e-only}{%
+ \def\volinfo{Volume \currentvolume}%
+ \dateposted{Xxxx XX, XXXX}%
+ \def\@setdateposted{\ (\@dateposted)}%
+ \let\article@logo\eonly@logo
+}
+%</amsart>
+% \end{macrocode}
+%
+% \subsubsection{Title page}
+%
+% The title and related information can optionally be printed on a
+% separate page.
+% \begin{macrocode}
+\newif\if@titlepage
+\DeclareOption{titlepage}{\@titlepagetrue}
+\DeclareOption{notitlepage}{\@titlepagefalse}
+% \end{macrocode}
+%
+% \subsubsection{Start on right- or left-hand page}
+%
+% For some book series, it's permissible to start chapters on a
+% left-hand page. Default to `openright', the usual AMS book style.
+% \begin{macrocode}
+%<*amsbook>
+\newif\if@openright
+\DeclareOption{openright}{\@openrighttrue}
+\DeclareOption{openany}{\@openrightfalse}
+\@openrighttrue
+%</amsbook>
+% \end{macrocode}
+%
+% \subsubsection{Two-column printing}
+%
+% Two-column layout is handled through a predefined internal switch.
+% \begin{macrocode}
+\DeclareOption{onecolumn}{\@twocolumnfalse}
+\DeclareOption{twocolumn}{\@twocolumntrue}
+% \end{macrocode}
+%
+% \subsubsection{The nomath option}
+%
+% The \opt{nomath} option causes most of the extra math features to
+% be omitted. Some utility functions will be defined below if this
+% option is specified.
+% \begin{macrocode}
+\DeclareOption{nomath}{}
+% \end{macrocode}
+%
+% \subsubsection{Some font options}
+%
+% The \opt{noamsfonts} option means to avoid declaring math alphabets
+% or symbol fonts for the extra math fonts in the AMSFonts set. If
+% these fonts are declared, it means that the corresponding \fn{.tfm}
+% files are required even for documents that do not use any symbols
+% from those fonts. So we allow optionally to not declare them, for
+% convenience of users who don't have those fonts on their system and
+% don't want the hassle of getting them.
+% \begin{macrocode}
+\DeclareOption{noamsfonts}{}
+% \end{macrocode}
+% The \opt{psamsfonts} option, passed on to the \pkg{amsfonts} package,
+% means that alternative \fn{.fd} files should be used that do not
+% refer to \fn{.tfm} files for sizes 6,8,9 (which are not present in
+% the PostScript (Type 1) AMS fonts set from Y\&Y/Blue Sky Research).
+% This should also trigger the \opt{cmex10} option of \pkg{amsmath},
+% to avoid trying to load sizes 7--9 of \fn{cmex}.
+% \begin{macrocode}
+\DeclareOption{psamsfonts}{%
+ \PassOptionsToPackage{psamsfonts}{amsfonts}%
+ \PassOptionsToPackage{cmex10}{amsmath}}
+% \end{macrocode}
+%
+% \subsubsection{Equation numbering on the left or right}
+%
+% The option \opt{leqno}---equation numbers on the left---is the
+% default in AMS styles. Therefore we provide also a \opt{reqno}
+% option.
+% \begin{macrocode}
+\newif\iftagsleft@
+\DeclareOption{leqno}{%
+ \tagsleft@true \PassOptionsToPackage{leqno}{amsmath}}
+\DeclareOption{reqno}{%
+ \tagsleft@false \PassOptionsToPackage{reqno}{amsmath}}
+% \end{macrocode}
+%
+% \subsubsection{Vertical centering of equation numbers}
+% For multiline equations the equation number is by default centered
+% vertically on the total height of the equation. To make the
+% equation number print on the first line (for left-hand
+% numbers) or the last line (right-hand numbers), there is a
+% \opt{tbtags} option `top/bottom tags'.
+% \begin{macrocode}
+\newif\ifctagsplit@
+\DeclareOption{centertags}{%
+ \ctagsplit@true \PassOptionsToPackage{centertags}{amsmath}}
+\DeclareOption{tbtags}{%
+ \ctagsplit@false \PassOptionsToPackage{tbtags}{amsmath}}
+% \end{macrocode}
+%
+% \subsubsection{Flush left displays}
+%
+% The option \opt{fleqn} causes displayed equations to print
+% aligned on the left instead of centered, with an indentation
+% of \cs{mathindent} from the prevailing left margin. If the
+% \pkg{amsmath} package is loaded, most of this code will be
+% overridden, but it seems we need it anyway because of the
+% possibility of the \opt{nomath} class option.
+%
+% \begin{macrocode}
+\DeclareOption{fleqn}{}%
+% \end{macrocode}
+%
+% \subsubsection{Dealing with font sizes}
+%
+% \begin{macro}{\@mainsize}
+% \begin{macro}{\@ptsize}
+% Instead of the miserly \cs{@ptsize} variable from \latex/'s
+% ancient history that contains only the last digit of the main
+% typesize, we set up a proper variable \cs{@mainsize} that
+% contains all the digits of the main typesize. Just in case it is
+% needed for someone using an old package, we will keep
+% \cs{@ptsize} also.
+% \begin{macrocode}
+\newcommand{\@mainsize}{10}
+\newcommand{\@ptsize}{0}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\larger}
+% \begin{macro}{\smaller}
+% This function is an easy byproduct of the work done to fold
+% typesize-specific code into the main class file. The range of font
+% sizes is \cn{normalsize}, \cn{small}, \cn{Small}, \cn{SMALL},
+% \cn{tiny}, \cn{Tiny}, \cn{large}, \cn{Large}, \cn{LARGE},
+% \cn{huge}, \cn{Huge}. Spaces are left at either end of the case
+% statement to accommodate adding \cn{TINY} and \cn{HUGE} in the
+% future but it's not clear that they're really needed.
+% \begin{macrocode}
+\newcommand{\larger}[1][1]{%
+ \count@\@currsizeindex \advance\count@#1\relax
+ \ifnum\count@<\z@ \count@\z@ \else\ifnum\count@>12 \count@12 \fi\fi
+% \end{macrocode}
+% The various size-changing commands \cn{normalsize}, etc., will take
+% care of updating \cs{@currsizeindex}.
+% \begin{macrocode}
+ \ifcase\count@
+ \Tiny\or\Tiny\or\tiny\or\SMALL\or\Small\or\small
+ \or\normalsize
+ \or\large\or\Large\or\LARGE\or\huge\or\Huge\else\Huge
+ \fi
+}
+\newcommand{\smaller}[1][1]{\larger[-#1]}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% The \cs{@adjustvertspacing} function adapts some vertical spacing
+% amounts to the current type size. We don't expect large sections of
+% vertical text to occur in the extraordinarily small or large type
+% sizes, so the \cs{@adjustvertspacing} function is only called in
+% the range between `footnote' size and `Large' size. Notice that no
+% shrinkability is used.
+% \begin{macrocode}
+\def\@adjustvertspacing{%
+% \end{macrocode}
+% \cs{big/med/smallskipamount} are generic space values that will be
+% used by the commands \cn{bigskip}, \cn{medskip}, \cn{smallskip}. We
+% also link the spacing around displayed equations to these amounts.
+% \begin{macrocode}
+ \bigskipamount.7\baselineskip plus.7\baselineskip
+ \medskipamount\bigskipamount \divide\medskipamount\tw@
+ \smallskipamount\medskipamount \divide\smallskipamount\tw@
+ \abovedisplayskip\medskipamount
+ \belowdisplayskip \abovedisplayskip
+% \end{macrocode}
+% The above-display short space is zero but with the same
+% stretchability as the above-display normal space. And the
+% below-display short space is similar, but has a base value equal to
+% \cs{smallskipamount}. Use of the multiplier |1| is an arcane \TeX{}
+% trick that coerces the skip value to a dimen value, i.e., gives us
+% the base value of the skip register without the stretch or shrink
+% values.
+% \begin{macrocode}
+ \abovedisplayshortskip\abovedisplayskip
+ \advance\abovedisplayshortskip-1\abovedisplayskip
+ \belowdisplayshortskip\abovedisplayshortskip
+ \advance\belowdisplayshortskip 1\smallskipamount
+% \end{macrocode}
+% The traditional value for \cs{jot} is 3pt, which we generalize
+% to \cs{baselineskip}/4. This is used to adjust interline spacing in
+% multiline displayed equations.
+% \begin{macrocode}
+ \jot\baselineskip \divide\jot 4 \relax
+}
+% \end{macrocode}%
+%
+% We fill out the range of typesize changing commands to a full
+% eleven: five large/huge commands and five small/tiny commands. (The
+% capitalization of the command names suggests that there should
+% actually be thirteen---add \cn{TINY} and \cn{HUGE}---but let's be
+% conservative and leave those out until a real need for them is
+% known to exist.) An unavoidable side effect is that \cn{tiny} now
+% selects 6pt instead of 5pt by default.
+%
+% In version 1.1 of \cls{amsart} and \cls{amsbook} \cn{small} was
+% the same as \cn{footnotesize} (\cls{amsproc} didn't exist in v. 1.1).
+%
+% The only size-changing command that is predefined by \latex/ is
+% \cn{normalsize}; that's why it's the only one for which we use
+% \cn{renewcommand} below.
+% \begin{macrocode}
+\renewcommand\normalsize{\@xsetfontsize\normalsize 6%
+ \@adjustvertspacing \let\@listi\@listI}
+\DeclareRobustCommand{\Tiny}{\@xsetfontsize\Tiny 1}
+\DeclareRobustCommand{\tiny}{\@xsetfontsize\tiny 2}
+\DeclareRobustCommand{\SMALL}{\@xsetfontsize\SMALL 3}
+\DeclareRobustCommand{\Small}{\@xsetfontsize\Small 4%
+ \@adjustvertspacing
+ \def\@listi{\topsep\smallskipamount \parsep\z@skip \itemsep\z@skip
+ \leftmargin=\leftmargini
+ \labelwidth=\leftmargini \advance\labelwidth-\labelsep
+ }%
+}
+\DeclareRobustCommand{\small}{\@xsetfontsize\small 5\@adjustvertspacing}
+% \end{macrocode}
+% For backward compatibility we had better define \cn{footnotesize}
+% and \cn{scriptsize}. Also there is the small discrepancy with
+% \cn{tiny} to worry about.
+% \begin{macrocode}
+\def\footnotesize{\Small}
+\def\scriptsize{\SMALL}
+% \end{macrocode}
+%
+% The sizes above 10pt use magstep values, stored in the functions
+% \cs{@xipt}, \cs{@xiipt}, etc.
+% \begin{macrocode}
+\DeclareRobustCommand{\large}{\@xsetfontsize\large 7\@adjustvertspacing}
+\DeclareRobustCommand{\Large}{\@xsetfontsize\Large 8\@adjustvertspacing}
+\DeclareRobustCommand{\LARGE}{\@xsetfontsize\LARGE 9}
+\DeclareRobustCommand{\huge}{\@xsetfontsize\huge{10}}
+\DeclareRobustCommand{\Huge}{\@xsetfontsize\Huge{11}}
+%\DeclareRobustCommand\HUGE{\@xsetfontsize\HUGE{12}}
+% \end{macrocode}
+%
+% So now we had better define the \cs{@xsetfontsize} function.
+% The size-changing commands use \cs{@setfontsize} instead of
+% \cn{fontsize} to (a)~give an error message if used in math mode and
+% (b)~set the \cs{@currsize} variable.
+% \begin{macrocode}
+\def\@xsetfontsize#1#2{%
+ \chardef\@currsizeindex#2\relax
+ \edef\@tempa{\@nx\@setfontsize\@nx#1%
+ \@xp\ifcase\@xp\@currsizeindex\@typesizes
+% \end{macrocode}
+% Add nonsense values 99/99 at the end just in case some extreme
+% error turns up.
+% \begin{macrocode}
+ \else{99}{99}\fi}%
+ \@tempa
+}
+% \end{macrocode}
+% For the record let's initialize \cs{@currsizeindex}.
+% \begin{macrocode}
+\chardef\@currsizeindex=6
+% \end{macrocode}
+%
+% Set page-breaking penalties to prevent all widows, orphans, and
+% hyphens at the end of a page.
+% \begin{macrocode}
+\widowpenalty=10000
+\clubpenalty=10000
+\brokenpenalty=10000
+% \end{macrocode}
+%
+% Set some default linespacing values. The variable \cs{linespacing}
+% is usually the normal interline space in the main text. It is used
+% to specify vertical space for elements such as section heads and
+% theorems in proportion to the normal interline space.
+% \begin{macrocode}
+\newdimen\linespacing
+\lineskip=1pt \lineskiplimit=1pt
+\normallineskip=1pt \normallineskiplimit=1pt
+\let\baselinestretch=\@empty
+% \end{macrocode}
+%
+% Settings for \cn{textheight} and \cn{textwidth}. We start with the
+% value 50.5pc specified in AMS journal specifications as the total
+% height of the type block and then subtract the running head height
+% and adjust for \cs{topskip} to get the proper value for the text
+% block.
+% \begin{macrocode}
+\headheight=8pt \headsep=14pt
+%<amsbook>\footskip=18pt
+%<amsart|amsproc>\footskip=12pt
+\textheight=50.5pc \topskip=10pt
+\textwidth=30pc
+\columnsep=10pt \columnseprule=0pt
+% \end{macrocode}
+% Some settings for marginpars.
+% \begin{macrocode}
+\marginparwidth=90pt
+\marginparsep=11pt
+\marginparpush=5pt
+% \end{macrocode}
+% To avoid setting text before begin-document, we postpone the
+% setting of \cs{footnotesep} using \cs{AtBeginDocument}.
+% \begin{macrocode}
+\AtBeginDocument{\settoheight{\footnotesep}{\footnotesize M$^1$}}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\skip\footins=7pt plus11pt
+\skip\@mpfootins=\skip\footins
+% \end{macrocode}
+%
+% \begin{macrocode}
+\fboxsep=3pt \fboxrule=.4pt
+% \end{macrocode}
+%
+% \begin{macrocode}
+\arrayrulewidth=.4pt \doublerulesep=2pt
+\labelsep=5pt \arraycolsep=\labelsep
+\tabcolsep=\labelsep \tabbingsep=\labelsep
+% \end{macrocode}
+%
+% \begin{macrocode}
+\floatsep=15pt plus 12pt \dblfloatsep=15pt plus 12pt
+\textfloatsep=\floatsep \dbltextfloatsep=15pt plus 12pt
+\intextsep=\floatsep
+% \end{macrocode}
+%
+% \begin{macrocode}
+\@fptop=0pt plus1fil \@dblfptop=0pt plus1fil
+\@fpbot=0pt plus1fil \@dblfpbot=0pt plus1fil
+\@fpsep=8pt plus2fil \@dblfpsep=8pt plus2fil\relax
+% \end{macrocode}
+% Note that \cs{parskip} gets no stretch; this is at variance with
+% the generic \latex/ classes.
+% \begin{macrocode}
+\parskip=0pt \relax
+% \end{macrocode}
+%
+% \cs{@parboxrestore}, used by \cs{@footnotetext}, sets
+% \cs{parindent} to |0pt|; since this is not what we want, we
+% make a new dimen \cs{normalparindent} and after calling
+% \cs{@parboxrestore}, \cs{@footnotetext} resets
+% \cs{parindent} back to normal.
+% \begin{macrocode}
+\newdimen\normalparindent
+%<amsart>\normalparindent=12pt
+%<amsproc|amsbook>\normalparindent=18pt
+\parindent=\normalparindent
+% \end{macrocode}
+%
+% \begin{macrocode}
+\partopsep=0pt \relax \parsep=0pt \relax \itemsep=0pt \relax
+% \end{macrocode}
+%
+% \begin{macrocode}
+\@lowpenalty=51 \@medpenalty=151 \@highpenalty=301
+\@beginparpenalty=-\@lowpenalty
+\@endparpenalty=-\@lowpenalty
+\@itempenalty=-\@lowpenalty
+% \end{macrocode}
+%
+% \subsubsection{Typesize-specific code}
+%
+% The class option \opt{12pt} sets the main typesize to 12 pt and
+% makes various adaptations, primarily sliding the size-changing
+% commands up the scale of magsteps. This makes it more likely that
+% someone with bitmapped fonts will have all the fonts and sizes
+% that they need. The \opt{8pt} option is for those who like to
+% conserve paper.
+%
+% By parameterizing some aspects it is possible to make a great deal
+% of the typesize-specific code automatically adapt to the selected
+% size. Then there is so little typesize-specific code remaining
+% that it no longer makes sense to put the code in separate \fn{.clo}
+% files. So instead of analogs for the generic \fn{size10,11,12.clo}
+% files we have the code for those options entirely contained in the
+% \fn{.cls} file in the form of declared options.
+%
+% Some miscellaneous remarks.
+%
+% ---If PostScript fonts are used, it may seem a little strange to
+% use fonts following the magstep'd point sizes 10.95, 14.4, 17.28,
+% 20.74, 24.88 instead of simply 11, 14, 17, 21, 25. But it is not
+% easy for us to make that distinction here in the document class
+% definitions of the fontsize changing commands. So we don't try.
+%
+% \begin{macrocode}
+\DeclareOption{10pt}{\def\@mainsize{10}\def\@ptsize{0}%
+ \def\@typesizes{%
+% \end{macrocode}
+% There should be 11 typesize/baselineskip pairs: five below
+% \cn{normalsize} and five above.
+% \begin{macrocode}
+ \or{5}{6}\or{6}{7}\or{7}{8}\or{8}{10}\or{9}{11}%
+ \or{10}{12}% normalsize
+ \or{\@xipt}{13}\or{\@xiipt}{14}\or{\@xivpt}{17}%
+ \or{\@xviipt}{20}\or{\@xxpt}{24}}%
+ \normalsize \linespacing=\baselineskip
+}
+%
+\DeclareOption{11pt}{\def\@mainsize{11}\def\@ptsize{1}%
+ \def\@typesizes{%
+ \or{6}{7}\or{7}{8}\or{8}{10}\or{9}{11}\or{10}{12}%
+ \or{\@xipt}{13}% normalsize
+ \or{\@xiipt}{14}\or{\@xivpt}{17}\or{\@xviipt}{20}%
+ \or{\@xxpt}{24}\or{\@xxvpt}{30}}%
+ \normalsize \linespacing=\baselineskip
+}
+%
+\DeclareOption{12pt}{\def\@mainsize{12}\def\@ptsize{2}%
+ \def\@typesizes{%
+ \or{7}{8}\or{8}{10}\or{9}{11}\or{10}{12}\or{\@xipt}{13}%
+ \or{\@xiipt}{14}% normalsize
+ \or{\@xivpt}{17}\or{\@xviipt}{20}\or{\@xxpt}{24}%
+ \or{\@xxvpt}{30}\or{\@xxvpt}{30}}%
+ \normalsize \linespacing=\baselineskip
+}
+%
+\DeclareOption{8pt}{\def\@mainsize{8}\def\@ptsize{8}%
+ \def\@typesizes{%
+ \or{5}{6}\or{5}{6}\or{5}{6}\or{6}{7}\or{7}{8}%
+ \or{8}{10}% normalsize
+ \or{9}{11}\or{10}{12}\or{\@xipt}{13}%
+ \or{\@xiipt}{14}\or{\@xivpt}{17}}%
+ \normalsize \linespacing=\baselineskip
+}
+%
+\DeclareOption{9pt}{\def\@mainsize{9}\def\@ptsize{9}%
+ \def\@typesizes{%
+ \or{5}{6}\or{5}{6}\or{6}{7}\or{7}{8}\or{8}{10}%
+ \or{9}{11}% normalsize
+ \or{10}{12}\or{\@xipt}{13}\or{\@xiipt}{14}%
+ \or{\@xivpt}{17}\or{\@xviipt}{20}}%
+ \normalsize \linespacing=\baselineskip
+}
+% \end{macrocode}
+%
+% \subsubsection{Running heads}
+% The normal application of pagestyle functions \cs{ps@xxx} is to
+% determine the contents of running heads and feet. The function
+% \cs{@mkboth} is used internally by commands \cn{chapter},
+% \cn{section}, and the like to set the running heads.
+% \begin{macrocode}
+\def\ps@empty{\let\@mkboth\@gobbletwo
+ \let\@oddhead\@empty \let\@evenhead\@empty
+ \let\@oddfoot\@empty \let\@evenfoot\@empty
+% \end{macrocode}
+% The current implementation in \cls{amsart}/\cls{amsproc}/\cls{amsbook}
+% of the vertical space at the top of an opening page uses \cs{topskip},
+% which means that we need to do some resetting here.
+% \begin{macrocode}
+ \global\topskip\normaltopskip}
+% \end{macrocode}
+% Pagestyle `plain' has the page numbers in the running feet.
+% \begin{macrocode}
+\def\ps@plain{\ps@empty
+ \def\@oddfoot{\normalfont\scriptsize \hfil\thepage\hfil}%
+ \let\@evenfoot\@oddfoot}
+% \end{macrocode}
+%
+% Pagestyle `headings' uses text from sectioning commands for
+% running heads. Empty running feet.
+% \begin{macrocode}
+\newswitch{runhead}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\ps@headings{\ps@empty
+ \def\@evenhead{%
+ \setTrue{runhead}%
+ \normalfont\scriptsize
+ \rlap{\thepage}\hfil
+ \def\thanks{\protect\thanks@warning}%
+ \leftmark{}{}\hfil}%
+ \def\@oddhead{%
+ \setTrue{runhead}%
+ \normalfont\scriptsize \hfil
+ \def\thanks{\protect\thanks@warning}%
+ \rightmark{}{}\hfil \llap{\thepage}}%
+ \let\@mkboth\markboth
+%<*amsbook>
+ \def\partmark{\@secmark\markboth\partrunhead\partname}%
+ \def\chaptermark{%
+ \@secmark\markboth\chapterrunhead{}}%
+ \def\sectionmark{%
+ \@secmark\markright\sectionrunhead\sectionname}%
+%</amsbook>
+}
+% \end{macrocode}
+%
+% \begin{macro}{\sectionname}
+% \begin{macro}{\subsectionname}
+% \begin{macro}{\subsubsectionname}
+% \begin{macro}{\paragraphname}
+% \begin{macro}{\subparagraphname}
+% Initialize section headings.
+% \begin{macrocode}
+\let\sectionname\@empty
+\let\subsectionname\@empty
+\let\subsubsectionname\@empty
+\let\paragraphname\@empty
+\let\subparagraphname\@empty
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% The default definitions of \cs{leftmark}, \cs{rightmark} are not
+% what we want: the section title (or whatever) reported in the
+% right-hand running head should report the section that is current
+% at the bottom of the right-hand page. And the left-hand running
+% head should report the status at the top of the page.
+% Cf.~\fn{amsppt.sty}.
+% \begin{macrocode}
+\def\leftmark{\expandafter\@firstoftwo\topmark{}{}}
+\def\rightmark{\expandafter\@secondoftwo\botmark{}{}}
+% \end{macrocode}
+%
+% Journal and Proceedings articles require an indication of the first
+% page so the logo and copyright line can appear.
+% \begin{macrocode}
+%<*amsart|amsproc>
+\def\ps@firstpage{\ps@plain
+ \def\@oddfoot{\normalfont\scriptsize \hfil\thepage\hfil
+% \end{macrocode}
+% Stick in the reset of \cs{topskip} here so it only gets executed
+% after the first page is completed.
+% \begin{macrocode}
+ \global\topskip\normaltopskip}%
+ \let\@evenfoot\@oddfoot
+ \def\@oddhead{\@serieslogo\hss}%
+ \let\@evenhead\@oddhead % in case an article starts on a left-hand page
+}
+%</amsart|amsproc>
+% \end{macrocode}
+%
+% \begin{macro}{\@nilgobble}
+% Something that apparently doesn't exist in the kernel?
+% \begin{macrocode}
+\long\def\@nilgobble#1\@nil{}
+% \end{macrocode}
+% \end{macro}
+%
+% A general section-marking function. Arg 1 is either \cn{markright}
+% or \cn{markboth} indicating which kind of marking action is desired
+% (this gives us some string pool/hash table savings by allowing the
+% \cs{@secmark} function to serve for both cases). Arg 2 is the
+% function that should be called in the running head to process the
+% remaining three args. Arg 3 is normally \cs{xxxname} (but could be
+% empty). Arg 4 is the section-title text. Assumption: whenever
+% \cs{@secmark} is called, the section-number variable
+% \cs{@secnumber} has been set to the value of the current section
+% number (possibly empty, in the case of a |*| section for example).
+% \begin{macrocode}
+%<*amsbook>
+\def\@secmark#1#2#3#4{%
+% \end{macrocode}
+% We want to apply expansion to \cs{xxxname} and \cs{thexxx} but not
+% to the other elements.
+% \begin{macrocode}
+ \begingroup \let\protect\@unexpandable@protect
+ \edef\@tempa{\endgroup \toks@{\protect#2{#3}{\@secnumber}}}%
+ \@tempa
+ \toks@\@xp{\the\toks@{#4}}%
+% \end{macrocode}
+% If a \cn{markright} operation is called for, use the current
+% left-mark via \cs{@temptokena}.
+% \begin{macrocode}
+ \afterassignment\@nilgobble\@temptokena\@themark{}\@nil
+ \edef\@tempa{\@nx\@mkboth{%
+ \ifx\markright#1\the\@temptokena\else\the\toks@\fi}{\the\toks@}}%
+ \@tempa}
+% \end{macrocode}
+% Init \cs{@secnumber}.
+% \begin{macrocode}
+\let\@secnumber\@empty
+%</amsbook>
+% \end{macrocode}
+%
+% Fix \cn{markboth} so that \cs{@secmark} can work without too much
+% thrashing.
+% \begin{macrocode}
+\def\markboth#1#2{%
+ \begingroup
+ \@temptokena{{#1}{#2}}\xdef\@themark{\the\@temptokena}%
+ \mark{\the\@temptokena}%
+ \endgroup
+ \if@nobreak\ifvmode\nobreak\fi\fi}
+% \end{macrocode}
+%
+% With the myheadings pagestyle, no automatic running heads will be
+% provided by the document class; only running heads specified by
+% the user through explicit \cn{markboth} or \cn{markright}
+% commands will be used.
+% \begin{macrocode}
+\def\ps@myheadings{\ps@headings \let\@mkboth\@gobbletwo}
+% \end{macrocode}
+%
+% Save normal topskip value in a skip register.
+% \begin{macrocode}
+\newskip\normaltopskip
+\normaltopskip=10pt \relax
+% \end{macrocode}
+%
+% We also want to turn off all section marks. First-level section
+% heads will be defined in \cs{ps@headings}.
+% \begin{macrocode}
+\let\sectionmark\@gobble
+\let\subsectionmark\@gobble
+\let\subsubsectionmark\@gobble
+\let\paragraphmark\@gobble
+% \end{macrocode}
+
+% \subsubsection{Unrecognized options}
+%
+% The \opt{makeidx} option is redundant; everything that it does in
+% the generic \latex/ classes is already done anyway in this class.
+% \begin{macrocode}
+\DeclareOption{makeidx}{}
+%</classes>
+% \end{macrocode}
+%
+% Unrecognized options for \pkg{amsthm} are treated as references
+% to auxiliary theorem setup (\fn{.thm}) files. This allows a user
+% to create theorem styles using internal commands (with |@| signs)
+% without having to be concerned about category coding.
+%
+% Here is an example from the file \fn{thmtest.tex} which is part
+% of this collection. See that file for further information.
+%\begin{verbatim}
+% \begin{filecontents}{exercise.thm}
+% \def\th@exercise{%
+% \normalfont % body font
+% \thm@headpunct{:}%
+% }
+% \end{filecontents}
+%\end{verbatim}
+%
+% This facility is available only when \pkg{amsthm} is used as an
+% independent package, not as part of an AMS document class.
+% \begin{macrocode}
+%<*amsthm>
+\DeclareOption*{\input{\CurrentOption .thm}}
+\ProcessOptions
+%</amsthm>
+% \end{macrocode}
+%
+% \subsection{Process options}
+%
+% Black boxes for overfull lines are turned off by default (the
+% \opt{final} option). This can be overridden with the \opt{draft}
+% option.
+% \begin{macrocode}
+%<*classes>
+\ExecuteOptions{leqno,centertags,letterpaper,portrait,%
+ 10pt,twoside,onecolumn,final}
+% \end{macrocode}
+% Options will be processed in the order of the associated
+% \cs{DeclareOption} commands.
+% \begin{macrocode}
+\ProcessOptions\relax
+% \end{macrocode}
+%
+% In compatibility mode, we want to load the frozen version of
+% \fn{amstex.sty} instead of the \pkg{amsmath} package. This is
+% rather a horrible kluge but I can't see anything better at the
+% moment. [mjd,1995/01/27]
+% \begin{macrocode}
+\if@compatibility
+ \def\@tempa{\RequirePackage{amstex}\relax}%
+\else
+ \@ifclasswith{\@classname}{nomath}{%
+ \let\@tempa\relax
+ }{%
+ \def\@tempa{\RequirePackage{amsmath}\relax}%
+ }%
+\fi
+\@tempa % load amstex.sty or amsmath.sty
+% \end{macrocode}
+% If the \opt{nomath} option was specified, then \cn{numberwithin}
+% and \cs{@emptytoks} remain to be defined.
+% \begin{macrocode}
+\@ifundefined{numberwithin}{%
+ \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}}}}%
+ }
+ \csname newtoks\endcsname\@emptytoks
+}{}
+% \end{macrocode}
+%
+% If the \opt{noamsfonts} option was called for, skip the
+% \pkg{amsfonts} package load.
+% \begin{macrocode}
+\if@compatibility
+\else
+ \@ifclasswith{\@classname}{noamsfonts}{%
+ % amsfonts package is not wanted
+ }{%
+ % amsfonts package IS wanted; test whether a recent enough version
+ % seems to be installed
+ \begingroup \fontencoding{U}\fontfamily{msa}\try@load@fontshape\endgroup
+ \global\@xp\let\csname U+msa\endcsname\relax % reset
+ \@ifundefined{U/msa/m/n}{%
+ \ClassError{\@classname}{%
+ Package `amsfonts' not installed, or version too old?\MessageBreak
+ Unable to get font info for the `msam' fonts in the expected form%
+ }{%
+ The amsfonts package will not be loaded, to avoid probable\MessageBreak
+ incompatibility problems. You can (a) use the `noamsfonts'
+ documentclass\MessageBreak
+ option next time, or (b) check that the amsfonts package is
+ installed\MessageBreak
+ correctly, and is not too old to be compatible.%
+ }%
+ }{%
+ \RequirePackage{amsfonts}[1995/01/01]\relax
+ }%
+ }
+\fi % end yesamsfonts branch
+% \end{macrocode}
+%
+% \subsection{Basic AMS style features}
+%
+% AMS style requires that blank pages between chapters be \emph{really}
+% blank: no running heads, no page numbers. To accomplish this,
+% redefine \cn{cleardoublepage} to do the right thing. [bnb, 1999/07/17]
+% \begin{macrocode}
+\let\cleardouble@page\cleardoublepage
+% \end{macrocode}
+% Postpone the redefinition of \cs{cleardoublepage} to begin-document
+% to work around difficulties with old versions of \fn{gsm-l.cls}.
+% \begin{macrocode}
+\AtBeginDocument{%
+ \ifx\cleardouble@page\cleardoublepage
+ \def\cleardoublepage{\clearpage{\pagestyle{empty}\cleardouble@page}}
+ \fi
+}
+% \end{macrocode}
+%
+% Now a utility macro to do \cn{uppercase} but sidestep any math, to
+% prevent uppercasing math variables. In order to be handled properly
+% the |$...$| or |\(...\)| must be on the outer level (not
+% enclosed in braces). We did not try to handle the possibility
+% |\begin{math}| |...| |\end{math}| in a title at the present time (too
+% complicated). Also we increase inter-word space in the uppercase
+% text.
+%
+% One other little problem: uppercasing of a few special characters
+% like the German {\ss} (\cn{ss}) and the undotted i and j (\cn{i}
+% and \cn{j}), used sometimes with accents. We redefine them to be
+% uppercase equivalents. (Undotted \cn{i} and \cn{j} in math would be
+% typed as \cn{imath} and \cn{jmath}.)
+%
+% Spaceskip is changed in accordance with recommendations for
+% increased interword spacing in all-caps text by e.g.\ `Words into
+% Type'.
+% \begin{macrocode}
+\newcommand{\uppercasenonmath}[1]{\toks@\@emptytoks
+% Insert an extra \@empty to avoid removing braces around arg \arg{1}.
+ \@xp\@skipmath\@xp\@empty#1$$%
+% \end{macrocode}
+% The \cs{protect} here is in case the shorttitle gets used for
+% shortauthors and we get redundant application of \cn{MakeUppercase}.
+% Double braces limit the scope so that later elements in title block
+% aren't uppercased, e.g., \cn{i} in an address. [bnb, 2004/04/01]
+% \begin{macrocode}
+ \edef#1{{\@nx\protect\@nx\@upprep\the\toks@}}%
+}
+% \end{macrocode}
+%
+% \begin{macro}{\@upprep}
+% Preparations for printing all-caps text.
+% \begin{macrocode}
+\newcommand{\@upprep}{%
+ \spaceskip1.3\fontdimen2\font plus1.3\fontdimen3\font
+ \upchars@}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\upchars@}
+% In all-caps text, esszet should print as SS, dotless i should print
+% as normal cap I, Mc should print with a small-caps (not lowercase)
+% c, and so forth.
+% \begin{macrocode}
+\newcommand{\upchars@}{%
+ \def\ss{SS}\def\i{I}\def\j{J}\def\ae{\AE}\def\oe{\OE}%
+ \def\o{\O}\def\aa{\AA}\def\l{\L}\def\Mc{M{\scshape c}}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\Mc}
+% The use of \cn{Mc} makes it possible for `Mc' to get special
+% treatment when uppercasing is applied.
+% \begin{macrocode}
+\providecommand{\Mc}{Mc}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@skipmath}
+% \begin{macro}{\@xskipmath}
+% \cs{@skipmath} searches for |$...$| in order to keep from applying
+% \cn{uppercase} to the contents. Then it calls \cs{@xskipmath} to
+% search for |\(...\)|.
+% \begin{macrocode}
+\newcommand{\@skipmath}{}
+\long\def\@skipmath#1$#2${%
+ \@xskipmath#1\(\)%
+ \@ifnotempty{#2}{\toks@\@xp{\the\toks@$#2$}\@skipmath\@empty}}%
+%
+\newcommand{\@xskipmath}{}
+\long\def\@xskipmath#1\(#2\){%
+% Expand away the added \@empty
+ \uppercase{\toks@\@xp\@xp\@xp{\@xp\the\@xp\toks@#1}}%
+ \@ifnotempty{#2}{\toks@\@xp{\the\toks@\(#2\)}\@xskipmath\@empty}}%
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\altucnm}
+% \begin{macrocode}
+\def\altucnm#1{%
+ \MakeTextUppercase{\toks@{#1}}%
+ \edef#1{\the\toks@}%
+}
+\AtBeginDocument{%
+ \@ifundefined{MakeTextUppercase}{}{\let\uppercasenonmath\altucnm}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% For older versions of \latex/ this might be needed too:
+% \begin{macrocode}
+\@ifundefined{MakeUppercase}{\let\MakeUppercase\uppercase}{}%
+% \end{macrocode}
+%
+% \begin{macro}{\today}
+% The command \cn{today} produces today's date in the form most
+% commonly used in the U.S.
+% \begin{macrocode}
+\newcommand{\today}{%
+ \relax\ifcase\month\or
+ January\or February\or March\or April\or May\or June\or
+ July\or August\or September\or October\or November\or December\fi
+ \space\number\day, \number\year}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsection{Old font commands}
+% The \cn{em} command is not redefined here (let's say, to give an
+% `obsolete' warning and recommend instead \cn{emph}) because there
+% is no alternative internal command \cs{emshape}.
+% \begin{macrocode}
+\DeclareOldFontCommand{\rm}{\normalfont\rmfamily}{\mathrm}
+\DeclareOldFontCommand{\sf}{\normalfont\sffamily}{\mathsf}
+\DeclareOldFontCommand{\tt}{\normalfont\ttfamily}{\mathtt}
+\DeclareOldFontCommand{\bf}{\normalfont\bfseries}{\mathbf}
+\DeclareOldFontCommand{\it}{\normalfont\itshape}{\mathit}
+\DeclareOldFontCommand{\sl}{\normalfont\slshape}{\@nomath\sl}
+\DeclareOldFontCommand{\sc}{\normalfont\scshape}{\@nomath\sc}
+% \end{macrocode}
+%
+% This warning might have been a good idea back in 1995 but I don't
+% think we can add it now [mjd,2000/03/10].
+%\begin{verbatim}
+%%\if@compatibility
+%%\else
+%% \def\@obsolete@fontswitch#1#2#3{%
+%% \@latex@warning@no@line{%
+%% Command {\string#1...}\on@line\space is obsolete;\MessageBreak
+%% the LaTeX2e equivalent is \string#3{...}}%
+%% \gdef#1{\@fontswitch\relax#3}%
+%% }
+%% \DeclareRobustCommand*\cal{%
+%% \@xp\@obsolete@fontswitch\csname cal \endcsname\relax\mathcal}
+%% \DeclareRobustCommand*\mit{%
+%% \@xp\@obsolete@fontswitch\csname mit \endcsname\relax\mathnormal}
+%%\fi
+%\end{verbatim}
+% There's too great a chance that some people out there have
+% documents that begin with
+%\begin{verbatim}
+%\documentclass{amsart}
+%...
+%\newcommand{\cal}{\mathcal}
+%\end{verbatim}
+% and such documents would now get error messages.
+%
+% Since \cs{cal} is not documented as a valid command for \LaTeXe/, I
+% think it is OK to leave the status as is for AMS document classes.
+% If you use \cs{documentstyle}, \cs{cal} will work. If you use
+% \cs{documentclass}, well, it's a good idea to update to
+% \cs{mathcal} instead of leaving old instances of \cs{cal}.
+%
+% \subsection{Top matter}
+% For the \cn{title} command, we support an optional argument to give
+% a shortened version of the title for running heads.
+% \begin{macrocode}
+\renewcommand*{\title}[2][]{\gdef\shorttitle{#1}\gdef\@title{#2}}
+% \end{macrocode}
+% The default value for the optional argument is `same as the
+% mandatory arg' but there doesn't seem to be an easy way to get that
+% effect with \ncn{[re]newcommand}. Here is how to use \cs{@dblarg}
+% in conjunction with the preceding \cn{newcommand}:
+% \begin{macrocode}
+\edef\title{\@nx\@dblarg
+ \@xp\@nx\csname\string\title\endcsname}
+% \end{macrocode}
+% The \cn{author} command accepts an optional argument similar to
+% that of the \cn{title} command.
+% Moved update of \cn{addresses} within scope of \cs{else} to avoid
+% adding anything if no authors, and thus avoiding output of ``Author
+% address'' on monograph titlepage. [bnb, 1996/11/03]
+% \begin{macrocode}
+\renewcommand{\author}[2][]{%
+ \ifx\@empty\authors
+ \gdef\authors{#2}%
+ \else
+ \g@addto@macro\authors{\and#2}%
+ \g@addto@macro\addresses{\author{}}%
+ \fi
+ \@ifnotempty{#1}{%
+ \ifx\@empty\shortauthors
+ \gdef\shortauthors{#1}%
+ \else
+ \g@addto@macro\shortauthors{\and#1}%
+ \fi
+ }%
+}
+\edef\author{\@nx\@dblarg
+ \@xp\@nx\csname\string\author\endcsname}
+% \end{macrocode}
+% Initialize some variables.
+% \begin{macrocode}
+\let\shortauthors\@empty \let\authors\@empty
+% \end{macrocode}
+%
+% \begin{macro}{\contrib}
+%
+% Contributors are similar to authors except that they are responsible
+% for only part of a work, e.g., an appendix. The optional argument
+% for the first contributor of a group identifies what has been
+% contributed. There can be more than one group of contributors;
+% each group is treated separately, using the same ``and'' conventions
+% within the group as for authors. Contributor groups are strung
+% together separated by a comma; if the word ``and'' is desired before
+% the final group of contributors, it must be included in the optional
+% argument for that group.
+% \begin{macrocode}
+%<*amsart|amsproc>
+\newif\ifresetcontrib \resetcontribfalse
+\newcommand\contrib[2][]{%
+ \def\@tempa{#1}%
+ \ifx\@empty\@tempa
+ \else
+ \ifresetcontrib \@xcontribs
+ \else \global\resetcontribtrue
+ \fi
+ \fi
+ \ifx\@empty\contribs
+ \gdef\contribs{#1 #2}%
+ \else
+ \g@addto@macro\contribs{\and#1 #2}%
+ \fi
+% \end{macrocode}
+% Accumulate contribs separately for the table of contents. Here,
+% this is just a dummy; it is fully defined for in-house processing.
+% \begin{macrocode}
+ \@wraptoccontribs{#1}{#2}%
+}
+\def\wraptoccontribs#1#2{}
+\def\@xcontribs{%
+ \author@andify\contribs
+ \ifx\@empty\xcontribs
+ \xdef\xcontribs{\contribs}%
+ \else
+ \xdef\xcontribs{\xcontribs, \contribs}%
+ \fi
+ \let\contribs\@empty
+}
+% \end{macrocode}
+% \end{macro}
+%
+% Initialize some more variables.
+% \begin{macrocode}
+\let\contribs\@empty \let\xcontribs\@empty \let\toccontribs\@empty
+%</amsart|amsproc>
+\let\addresses\@empty \let\thankses\@empty
+% \end{macrocode}
+%
+% The optional arguments of \cn{address}, \cn{curraddr}, \cn{email}
+% are to indicate which author the address applies to, if a document
+% has multiple authors and there is not a normal one-to-one
+% correspondence between authors and addresses.
+% \begin{macrocode}
+\newcommand{\address}[2][]{\g@addto@macro\addresses{\address{#1}{#2}}}
+\newcommand{\curraddr}[2][]{\g@addto@macro\addresses{\curraddr{#1}{#2}}}
+\newcommand{\email}[2][]{\g@addto@macro\addresses{\email{#1}{#2}}}
+\newcommand{\urladdr}[2][]{\g@addto@macro\addresses{\urladdr{#1}{#2}}}
+% \end{macrocode}
+%
+% Someone who does not look closely at the \cls{amsart} documentation
+% is likely to put the \cn{thanks} command inside that argument of
+% \cn{author}.
+% \begin{macrocode}
+\long\def\thanks@warning#1{%
+ \ClassError{\@classname}{%
+ \protect\thanks\space should be given separately, not inside author name.%
+ }\@ehb
+}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\renewcommand{\thanks}[1]{%
+ \@ifnotempty{#1}{\g@addto@macro\thankses{\thanks{#1}}}%
+}
+% \end{macrocode}
+%
+% The following example of addresses for three authors of a
+% tri-author paper illustrates the kind of complications that need to
+% be handled.
+%\begin{verbatim}
+% \author{Roland Campbell}
+% \address{Department of Mathematics\\
+% Pennsylvania State University\\
+% Pittsburgh, Pennsylvania 13593}
+% \email[R.~Campbell]{campr@@galois.psu.edu}
+%
+% \author{Mark M. Dane}
+% % Same address as R. Campbell
+% \curraddr[M.~Dane]{Atmospheric Research Station\\
+% Pala Lundi, Fiji}
+% \email[M.~Dane]{DaneMark@@ffr.choice}
+%
+% \author{Jeremiah Jones}
+% \address[J.~Jones]{Department of Philosophy\\
+% Freedman College\\
+% Periwinkle, Colorado 84320}
+% \email[J.~Jones]{id739e@@oseoi44 (Bitnet)}
+%\end{verbatim}
+% In an article, typesetting of the address information is done at
+% the end of the document, by calling \cs{@setaddresses}. This is done
+% through a parent function \cs{enddoc@text}, because some AMS journals
+% also print the abstract there instead of at the beginning, and it's
+% easier to redefine \cs{enddoc@text} than to try undoing material
+% already added to the \cs{AtEndDocument} hook.
+% \begin{macrocode}
+%<*amsart|amsproc>
+\def\enddoc@text{\ifx\@empty\@translators \else\@settranslators\fi
+ \ifx\@empty\addresses \else\@setaddresses\fi}
+\AtEndDocument{\enddoc@text}
+%</amsart|amsproc>
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\curraddrname{{\itshape Current address}}
+\def\emailaddrname{{\itshape Email address}}
+\def\urladdrname{{\itshape URL}}
+\def\@setaddresses{\par
+ \nobreak \begingroup
+%<amsart|amsproc>\footnotesize
+ \def\author##1{\nobreak\addvspace\bigskipamount}%
+% \end{macrocode}
+% Address is supposed to go all on one line, so we redefine |\\|
+% to just insert a comma instead of doing a line break.
+% \begin{macrocode}
+ \def\\{\unskip, \ignorespaces}%
+% \end{macrocode}
+% No page breaks in the address section is accomplished by
+% |\interlinepenalty\@M| and by the \cn{nobreak} before the \cn{bigskip}.
+% \begin{macrocode}
+ \interlinepenalty\@M
+ \def\address##1##2{\begingroup
+% \end{macrocode}
+% If there are two addresses for the same author, add a \cn{bigskip}
+% between them.
+% \begin{macrocode}
+ \par\addvspace\bigskipamount\indent
+% \end{macrocode}
+% If the name of the author to whom this address applies
+% was given, typeset it.
+% \begin{macrocode}
+ \@ifnotempty{##1}{(\ignorespaces##1\unskip) }%
+% \end{macrocode}
+% Now the main part of the address:
+% \begin{macrocode}
+ {\scshape\ignorespaces##2}\par\endgroup}%
+% \end{macrocode}
+% Current address:
+% \begin{macrocode}
+ \def\curraddr##1##2{\begingroup
+ \@ifnotempty{##2}{\nobreak\indent\curraddrname
+ \@ifnotempty{##1}{, \ignorespaces##1\unskip}\/:\space
+ ##2\par}\endgroup}%
+% \end{macrocode}
+% And then email. In versions 1.0 and 1.1 |@@| was required to print
+% a single \qc{\@} character; for bulletproofing we convert doubled
+% \qc{\@} characters if found.
+% \begin{macrocode}
+ \def\email##1##2{\begingroup
+ \@ifnotempty{##2}{\nobreak\indent\emailaddrname
+ \@ifnotempty{##1}{, \ignorespaces##1\unskip}\/:\space
+ \ttfamily##2\par}\endgroup}%
+% \end{macrocode}
+% URLaddr is simply a replica of the email address, with the
+% addition of a feature to enable |~| to print.
+% \begin{macrocode}
+ \def\urladdr##1##2{\begingroup
+ \def~{\char`\~}%
+ \@ifnotempty{##2}{\nobreak\indent\urladdrname
+ \@ifnotempty{##1}{, \ignorespaces##1\unskip}\/:\space
+ \ttfamily##2\par}\endgroup}%
+ \addresses
+ \endgroup
+}
+% \end{macrocode}
+%
+% Some other administrative info. For \cn{date} we can just use the
+% default definition provided by \latex/, except that we initialize
+% the date to empty instead of to \cn{today}.
+% \begin{macrocode}
+\let\@date\@empty
+\def\dedicatory#1{\def\@dedicatory{#1}}
+\let\@dedicatory=\@empty
+\def\keywords#1{\def\@keywords{#1}}
+\let\@keywords=\@empty
+% \end{macrocode}
+%
+% To allow various versions of the subject classification, accept an
+% optional value to identify the version, provide text for the two
+% currently in use, and give a warning if the version specified is
+% unknown. Default to 1991 version. [bnb, 1999/04/30]
+% \begin{macrocode}
+\newcommand*\subjclass[2][1991]{%
+ \def\@subjclass{#2}%
+ \@ifundefined{subjclassname@#1}{%
+ \ClassWarning{\@classname}{Unknown edition (#1) of Mathematics
+ Subject Classification; using '1991'.}%
+ }{%
+ \@xp\let\@xp\subjclassname\csname subjclassname@#1\endcsname
+ }%
+}
+\let\@subjclass=\@empty
+%<amsart>\def\commby#1{\def\@commby{(Communicated by #1)}}
+%<amsart>\let\@commby=\@empty
+% \end{macrocode}
+%
+% We handle translator names like author names, just in case there is
+% more than one translator. [mjd,1994/10/19]
+% \begin{macrocode}
+\def\translname{Translated by}
+\def\translator#1{%
+ \ifx\@empty\@translators \def\@translators{#1}%
+ \else\g@addto@macro\@translators{\and#1}\fi}
+\let\@translators=\@empty
+% \end{macrocode}
+%
+% \begin{macrocode}
+%<*amsart|amsproc>
+\def\@settranslators{\par\begingroup
+ \addvspace{6\p@\@plus9\p@}%
+ \hbox to\columnwidth{\hss\normalfont\normalsize
+ \translname{ }%
+ \andify\@translators \uppercasenonmath\@translators
+ \@translators}
+ \endgroup
+}
+%</amsart|amsproc>
+% \end{macrocode}
+%
+% The general function to convert a list of items in the form
+%\begin{verbatim}
+% A\and B\and C\and D
+%\end{verbatim}
+% to the form `A, B, C, and D' is \cs{xandlist}:
+%\begin{verbatim}
+% \xandlist{, }{ and }{, and }{A\and B\and C\and D}
+%\end{verbatim}
+% This is a completely expandable macro, with the return value being
+% the converted list. There is also a `no-execute' version whose
+% fourth argument should be a macro; the text to be converted will be
+% taken from that macro and after conversion will be put back as the
+% macro's new replacement text.
+%\begin{verbatim}
+% \nxandlist{, }{ and }{, and }\result
+%\end{verbatim}
+% I don't think I want to explain this except by recommending that
+% you watch it in operation with \cs{tracingmacros} if you're
+% interested. [mjd,1994/10/19]
+% \begin{macrocode}
+\newcommand{\xandlist}[4]{\@andlista{{#1}{#2}{#3}}#4\and\and}
+\def\@andlista#1#2\and#3\and{\@andlistc{#2}\@ifnotempty{#3}{%
+ \@andlistb#1{#3}}}
+\def\@andlistb#1#2#3#4#5\and{%
+ \@ifempty{#5}{%
+ \@andlistc{#2#4}%
+ }{%
+ \@andlistc{#1#4}\@andlistb{#1}{#3}{#3}{#5}%
+ }}
+\let\@andlistc\@iden
+\newcommand{\nxandlist}[4]{%
+ \def\@andlistc##1{\toks@\@xp{\the\toks@##1}}%
+ \toks@{\toks@\@emptytoks \@andlista{{#1}{#2}{#3}}}%
+ \the\@xp\toks@#4\and\and
+ \edef#4{\the\toks@}%
+ \let\@andlistc\@iden}
+% \end{macrocode}
+%
+% \begin{macro}{andify}
+%
+% The \cs{andify} function is provided as a convenient abbreviation
+% for the most common case. See also \cs{author@andify} (for
+% \cls{amsart} and \cls{amsproc} only), which gives better results
+% in cases with a large number of authors. Provide a substitutable
+% text string to simplify language-specific modifications.
+% \begin{macrocode}
+\def\@@and{and}
+\newcommand{\andify}{%
+ \nxandlist{\unskip, }{\unskip{} \@@and~}{\unskip, \@@and~}}
+% \end{macrocode}
+% Override the funny default definition of \cn{and} from \latex/.
+% This is not actually used by AMS classes, however.
+% \begin{macrocode}
+\def\and{\unskip{ }\@@and{ }\ignorespaces}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{maketitle}
+%
+% Set up the style of an article opening page. For books, see below.
+% For articles, we must add the copyright info footnote.
+% \begin{macrocode}
+%<*amsart|amsproc>
+\def\maketitle{\par
+ \@topnum\z@ % this prevents figures from falling at the top of page 1
+ \@setcopyright
+ \thispagestyle{firstpage}% this sets first page specifications
+% \end{macrocode}
+% Do some setup for the running heads here. If there are no author names,
+% we set the left-hand running head to the value of the right-hand running
+% head.
+% \begin{macrocode}
+ \uppercasenonmath\shorttitle
+ \ifx\@empty\shortauthors \let\shortauthors\shorttitle
+ \else \andify\shortauthors
+ \fi
+% \end{macrocode}
+% The following hook is used to activate the writing of author and
+% title information to an `issue table of contents' when multiple
+% articles are being processed for a journal issue or a proceedings
+% volume.
+% \begin{macrocode}
+ \@maketitle@hook
+ \begingroup
+ \@maketitle
+ \toks@\@xp{\shortauthors}\@temptokena\@xp{\shorttitle}%
+ \toks4{\def\\{ \ignorespaces}}% defend against questionable usage
+ \edef\@tempa{%
+ \@nx\markboth{\the\toks4
+ \@nx\MakeUppercase{\the\toks@}}{\the\@temptokena}}%
+ \@tempa
+ \endgroup
+ \c@footnote\z@
+ \@cleartopmattertags
+}
+\def\@cleartopmattertags{%
+ \def\do##1{\let##1\relax}%
+ \do\maketitle \do\@maketitle \do\title \do\@xtitle \do\@title
+ \do\author \do\@xauthor \do\address \do\@xaddress
+ \do\contrib \do\contribs \do\xcontribs \do\toccontribs
+ \do\email \do\@xemail \do\curraddr \do\@xcurraddr
+%<amsart> \do\commby \do\@commby
+ \do\dedicatory \do\@dedicatory \do\thanks \do\thankses
+ \do\keywords \do\@keywords \do\subjclass \do\@subjclass
+}
+%</amsart|amsproc>
+% \end{macrocode}
+% \end{macro}
+%
+% The hook \cs{@maketitle@hook} is placed into \cn{maketitle} rather
+% than \cs{@maketitle} because the latter tends to get redefined by
+% derived classes using this one as a base. The initial motivation
+% for this hook is to extract title and author information to an
+% external file, so we can't do it with \cs{AtBeginDocument}:
+% \cn{title} and \cn{author} commands might occur between
+% \verb'\begin{document}' and \cn{maketitle}.
+%
+% \begin{macrocode}
+%<*amsart|amsproc>
+\def\@maketitle@hook{\global\let\@maketitle@hook\@empty}
+%</amsart|amsproc>
+% \end{macrocode}
+%
+% Set up the style of an article opening page.
+% \begin{macrocode}
+%<*amsart|amsproc>
+\def\@maketitle{%
+% \end{macrocode}
+% Set font to normal, just in case.
+% \begin{macrocode}
+ \normalfont\normalsize
+% \end{macrocode}
+% Special footnotes are put here to ensure that they come first at
+% the bottom of the page.
+% \begin{macrocode}
+ \@adminfootnotes
+% \end{macrocode}
+% If |\pagestyle{myheadings}| was specified, \cs{@mkboth} will be a no-op.
+% \begin{macrocode}
+ \@mkboth{\@nx\shortauthors}{\@nx\shorttitle}%
+%<amsproc> \global\topskip8pc\relax % 10pc to base of first title line
+%<amsart> \global\topskip42\p@\relax % 5.5pc " " " " "
+ \@settitle
+ \ifx\@empty\authors \else \@setauthors \fi
+% \end{macrocode}
+% Likewise with \cs{@dedicatory} and \cs{@date}.
+% \begin{macrocode}
+ \ifx\@empty\@dedicatory
+ \else
+%<amsproc> \baselineskip26\p@
+%<amsart> \baselineskip18\p@
+ \vtop{\centering{\footnotesize\itshape\@dedicatory\@@par}%
+ \global\dimen@i\prevdepth}\prevdepth\dimen@i
+ \fi
+ \@setabstract
+% \end{macrocode}
+% Space before the main text should be 32 + 14 base-to-base; we
+% accomplish this by doing a vskip of that amount with \cs{baselineskip}
+% subtracted.
+% \begin{macrocode}
+ \normalsize
+ \if@titlepage
+ \newpage
+ \else
+ \dimen@34\p@ \advance\dimen@-\baselineskip
+ \vskip\dimen@\relax
+ \fi
+} % end \@maketitle
+% \end{macrocode}
+%
+% Segregate the definitions of administrative footnotes to permit
+% easier customization, especially for translation journals.
+% \begin{macrocode}
+\def\@adminfootnotes{%
+ \let\@makefnmark\relax \let\@thefnmark\relax
+%<amsart> \ifx\@empty\@date\else \@footnotetext{\@setdate}\fi
+ \ifx\@empty\@subjclass\else \@footnotetext{\@setsubjclass}\fi
+ \ifx\@empty\@keywords\else \@footnotetext{\@setkeywords}\fi
+% \end{macrocode}
+% In order to make multiple thanks footnotes work inside a single
+% \cs{@footnotetext} argument we need to make the first \cn{par} be
+% ignored. Cf.~\cs{@setthanks}.
+% \begin{macrocode}
+ \ifx\@empty\thankses\else \@footnotetext{%
+ \def\par{\let\par\@par}\@setthanks}%
+ \fi
+}
+%</amsart|amsproc>
+% \end{macrocode}
+%
+% \subsection{Journal/series logo for articles}
+%
+% \cs{publname} either will be defined by a parent class that is calling
+% \cls{amsart} or \cls{amsproc} as a base class, or will be absent, in
+% which case this can be used as a signal to omit the \cs{@serieslogo}.
+% A typical value for \cs{publname} would be
+%\begin{verbatim}
+% \def\publname{JOURNAL OF THE\newline
+% AMERICAN MATHEMATICAL SOCIETY}
+%\end{verbatim}
+%
+% Initialize \cs{publname} and \cs{@serieslogo} to no-op if
+% \cs{publname} is not already defined.
+% \begin{macrocode}
+%<*amsart|amsproc>
+\AtBeginDocument{%
+ \@ifundefined{publname}{%
+ \let\publname\@empty
+ \let\@serieslogo\@empty
+ }{%
+%<amsart> \def\@serieslogo{\article@logo}%
+%<amsproc> \def\@serieslogo{\procart@logo}%
+ }%
+}
+%</amsart|amsproc>
+% \end{macrocode}
+%
+% The \cs{number} prefix on current issue is to work around
+% inconsistencies in the form of issue numbers as passed in from
+% system level. Sometimes they will get passed in with a leading
+% zero, which we don't want to print if it happens to occur.
+% The |0| prevents an error if \cs{currentissue} happens to be empty.
+% \begin{macrocode}
+%<*amsart>
+\AtBeginDocument{%
+ \@ifundefined{volinfo}{%
+ \def\volinfo{%
+ Volume \currentvolume, Number \number0\currentissue
+% \end{macrocode}
+% Month/year is not included initially when a journal article is
+% posted on the WWW prior to print publication.
+% \begin{macrocode}
+ \if\@printyear , \currentmonth\ \currentyear\fi
+ }%
+ }{}%
+}
+\def\@printyear{TF}% boolean false
+%</amsart>
+% \end{macrocode}
+%
+% \begin{macrocode}
+%<*amsproc>
+\AtBeginDocument{%
+ \@ifundefined{volinfo}{\let\volinfo\@empty}{}
+}
+%</amsproc>
+% \end{macrocode}
+%
+% Default values for information such as volume, year, and so on are
+% provided as follows.
+% \begin{macrocode}
+%<*amsart|amsproc>
+\def\issueinfo#1#2#3#4{\def\currentvolume{#1}\def\currentissue{#2}%
+ \def\currentmonth{#3}\def\currentyear{#4}}
+\issueinfo{00}% volume number
+ {0}% % issue number
+ {Xxxx}% % month
+ {XXXX}% % year
+%</amsart|amsproc>
+% \end{macrocode}
+%
+% Copyright year may be different from issue year. Allow it to be
+% specified separately. It is probably more natural anyway, from the
+% user's perspective, to give the copyright year in the same command
+% when giving the name of the copyright holder.
+% \begin{macrocode}
+\newcommand{\copyrightinfo}[2]{%
+ \def\copyrightyear{#1}%
+ \@ifnotempty{#2}{\def\copyrightholder{#2}}%
+}
+\copyrightinfo{0000}{(copyright holder)}
+% \end{macrocode}
+%
+% Provide page span information. If negative number is given, convert
+% to roman numeral form.
+% \begin{macrocode}
+%<*amsart|amsproc>
+\def\pagespan#1#2{\setcounter{page}{#1}%
+ \ifnum\c@page<\z@ \pagenumbering{roman}\setcounter{page}{-#1}\fi
+ \def\start@page{#1}\def\end@page{#2}}
+\pagespan{000}{000}
+%</amsart|amsproc>
+% \end{macrocode}
+%
+% Formatting for journal page numbers. [bnb, 1996/09/11]
+% \begin{macrocode}
+%<*amsart>
+\AtBeginDocument{%
+ \@ifundefined{pageinfo}{%
+ \def\pageinfo{%
+ \ifnum\start@page=\z@
+ Pages 000--000
+ \else
+ \ifx\start@page\end@page
+ Page \start@page
+ \else
+ Pages \start@page--\end@page
+ \fi
+ \fi}%
+ }{}%
+}
+%</amsart>
+% \end{macrocode}
+%
+% Publisher Item Identifier (we started using them in journal logos
+% as of January 1997).
+% \begin{macrocode}
+%<amsart>\@ifundefined{ISSN}{\def\ISSN{0000-0000}}{}
+%<amsart>\newcommand\PII[1]{\def\@PII{#1}}
+%<amsart>\PII{S \ISSN(XX)0000-0}
+% \end{macrocode}
+%
+% \subsection{Copyright block}
+%
+% Doing the copyright info on the first page is a little tricky. We
+% want it to come at the bottom, after any footnotes and floating
+% inserts, but before the page number. If we simply put it into
+% \cs{@oddfoot} (in \cs{ps@plain}) its height will not be subtracted
+% from the height of the text and then the page number will be lower
+% than we want. So we do it as an insert.
+%
+% Through version 1.2, this code was included only for \pkg{amsart}
+% and \pkg{amsproc}; the formatting of some book series requires an
+% insert at the bottom of the text block, so this code has been
+% extended to all AMS document classes. [bnb, 1999/07/14]
+% \begin{macrocode}
+\newinsert\copyins
+% \end{macrocode}
+% We set the skip register associated with this insert to the
+% \emph{base-to-base} distance from the bottom of the page contents
+% to the base of the first line in the copyright info. See the
+% definition of \cs{@setcopyright}.
+% \begin{macrocode}
+\skip\copyins=1.5pc
+\count\copyins=1000 % magnification factor, 1000 = 100%
+\dimen\copyins=.5\textheight % maximum allowed per page
+% \end{macrocode}
+% \cn{copyins} is ignored if a float is input on the first page;
+% adding it to \cs{@reinserts} will make the output routine behave.
+% [bnb; 2004/06/09; B-365]
+% \begin{macrocode}
+\g@addto@macro\@reinserts{%
+ \ifvoid\copyins\else\insert\copyins{\unvbox\copyins}\fi
+}
+% \end{macrocode}
+% Put the contents into a \tex/ insert. This information is omitted
+% unless \cs{@serieslogo} is non-null. In other words it will
+% normally not print except when an AMS publication-specific document
+% class such as \cls{tran-l} is used.
+% And even if the series logo is printed, omit the copyright line
+% if requested by |\coprightinfo{}{}|. [bnb, 1996/10/17]
+% \begin{macrocode}
+\def\@copyinsfontsize{\fontsize{6}{7\p@}\normalfont\upshape}
+\newif\if@extracrline \@extracrlinefalse
+\let\@extracrline\@empty
+\relax
+\def\@setcopyright{%
+ \ifx\@empty\@serieslogo
+ \else\ifx\@empty\copyrightyear
+ \else
+ \insert\copyins{\hsize\textwidth
+ \parfillskip\z@\relax
+ \leftskip\z@\@plus.9\textwidth\relax \rightskip\z@\relax
+ \@copyinsfontsize
+% \end{macrocode}
+% The spacing between the preceding text and the copyright info is
+% done with a strut of height |\skip\copyins|. (Note that
+% \cs{lineskip} and \cs{baselineskip} are 0 in the \latex/ output
+% routine.) The negative vskip gives an effective distance of 0 from
+% the top of the box to the base of the first line (assuming
+% |\skip\copyins| is greater than the height of that line). Then the
+% apparent total height of the box will work well with \tex/'s
+% calculations involving |\skip\copyins| for how much room to leave
+% for this object. An extra 6pt is allowed when an additional line
+% is present; this adjustment was found adequate in some borderline
+% cases where tight pages reset with the additional line had text
+% lines moved to the next page, causing the paper length to expand
+% by a page. [bnb, 2004/05/07-06/24]
+% \begin{macrocode}
+ \everypar{}%
+ \vskip-\skip\copyins
+ \if@extracrline
+ \vskip-6pt
+ \fi
+ \nointerlineskip
+ \leavevmode\hfill\vrule\@width\z@\@height\skip\copyins
+ \copyright\copyrightyear\ \copyrightholder\ignorespaces
+ \if@extracrline \@extracrline \fi
+ \par
+% \end{macrocode}
+% This kern of 0pt forces the depth of the last line (if any) to be
+% added to the height of the box.
+% \begin{macrocode}
+ \kern\z@}%
+ \fi\fi
+}
+% \end{macrocode}
+%
+% When \cs{@combinefloats} is called, the box \cs{@outputbox} already
+% contains the main text of the page and any footnotes. Then \latex/
+% adds top and bottom figures. We want to add our copyright info at
+% the very bottom, but still inside of the vbox.
+% \begin{macrocode}
+\def\@combinefloats{%
+ \ifx \@toplist\@empty \else \@cflt \fi
+ \ifx \@botlist\@empty \else \@cflb \fi
+ \ifvoid\copyins \else \@cflci \fi
+}
+% \end{macrocode}
+% \subsubsection{combine-floats-copyright-insert}
+%
+% In the twocolumn/firstcolumn case, postpone adding the drop folio.
+% Put an empty box of the same height at the bottom of the left-hand
+% column to make the columns balance. Allow a smidge of stretch in
+% case the first page of a chapter has no internal stretch, so that
+% the drop folio will be flush to the bottom of the text block;
+% don't do this for a twocolumn page, to avoid an uneven bottom.
+% \begin{macrocode}
+\def\@cflci{%
+ \setbox\@outputbox\vbox{%
+ \unvbox\@outputbox
+ \vskip\skip\copyins
+ \if@twocolumn \else \vskip\z@ plus\p@ \fi
+ \hbox to\columnwidth{%
+ \hss\vbox to\z@{\vss
+% \end{macrocode}
+% In two-column layout, put an empty box in the first column
+% instead of the drop folio.
+% \begin{macrocode}
+ \if@twocolumn
+ \if@firstcolumn \else \unvbox\copyins \fi
+ \else
+ \unvbox\copyins
+ \fi
+ }}}%
+% \end{macrocode}
+% Now redo the insert to make sure we get the right amount of space
+% reserved for it in the second column.
+% \begin{macrocode}
+ \if@twocolumn \if@firstcolumn
+ \insert\copyins{\unvbox\copyins}%
+ \fi\fi
+% \end{macrocode}
+% Reset the \cs{copyins} flag so that a subsequent insert
+% (e.g.\ \cs{@dropfolio} in some book series) will work.
+% \begin{macrocode}
+ \global\count\copyins=999 \relax
+}
+% \end{macrocode}
+% [End of code to support inserts at end of text block.]
+%
+% For journals only, provide a switch that indicates the author has
+% agreed to revert copyright to the public domain; this results in
+% an addition to the copyright block on the article.
+% \begin{macrocode}
+%<*amsart>
+\newif\if@revertcopyright \@revertcopyrightfalse
+\newcommand{\revertcopyright}{%
+ \global\@revertcopyrighttrue
+ \global\@extracrlinetrue}
+% \end{macrocode}
+% Add notation regarding reversion of copyright to public domain if
+% author has agreed to it. Permit this to be set in a different
+% size than the copyright line (required for some author packages).
+% \begin{macrocode}
+\def\@revertcrfontsize{\fontsize{6}{7\p@}\normalfont\upshape}
+\def\@extracrline{%
+ \if@revertcopyright
+ \unskip\\
+ \@revertcrfontsize
+ Reverts to public domain 28 years from publication
+ \fi
+}
+%</amsart>
+% \end{macrocode}
+%
+% \subsection{Other top matter info}
+%
+% Some name setup.
+% \begin{macrocode}
+\newcommand{\abstractname}{Abstract}
+\newcommand{\keywordsname}{Key words and phrases}
+% \end{macrocode}
+% For now, support just the two most recent versions; earlier versions
+% were:
+% \begin{itemize}
+% \item \textup{1980} Mathematics Subject Classification
+% \item \textup{1980} Mathematics Subject Classification
+% \textup{(1985} Revision\textup{)}
+% \end{itemize}
+% Default to the 1991 edition, as that's what is in production at the
+% time this change is made. [bnb, 1999/04/30]
+% \begin{macrocode}
+\newcommand{\subjclassname}{%
+ \textup{1991} Mathematics Subject Classification}
+\@xp\let\csname subjclassname@1991\endcsname \subjclassname
+\@namedef{subjclassname@2000}{%
+ \textup{2000} Mathematics Subject Classification}
+\@namedef{subjclassname@2010}{%
+ \textup{2010} Mathematics Subject Classification}
+% \end{macrocode}
+% For the date we have a special little problem: We only want to add
+% the `Received by the editors' text for publication-specific
+% document classes such as \cls{tran-l}.
+% \begin{macrocode}
+%<amsbook>\def\@tempb{amsbook}
+%<amsproc>\def\@tempb{amsproc}
+%<amsart>\def\@tempb{amsart}
+\ifx\@classname\@tempb
+ \newcommand{\datename}{\textit{Date}:}
+\else
+ \newcommand{\datename}{Received by the editors}
+\fi
+% \end{macrocode}
+%
+% \begin{macrocode}
+%<*amsart|amsproc>
+\def\@settitle{\begin{center}%
+%<amsart> \baselineskip14\p@\relax
+%<amsproc> \Large
+ \bfseries
+%<amsart>\uppercasenonmath\@title
+ \@title
+ \end{center}%
+}
+%</amsart|amsproc>
+% \end{macrocode}
+%
+% For multiple authors we need to combine the author names into a
+% list of the form Author One, Author Two, \dots, and Author Last.
+% Change line breaking penalties to avoid a line break in the middle of
+% an author name if there are a lot of authors. This should probably
+% better be done by changing spaces within author names to
+% |\nolinebreak[3]\space|, but that would take more work.
+% [mjd,2000/12/27]
+% \begin{macrocode}
+%<*amsart|amsproc>
+\def\author@andify{%
+ \nxandlist {\unskip ,\penalty-1 \space\ignorespaces}%
+ {\unskip {} \@@and~}%
+ {\unskip ,\penalty-2 \space \@@and~}%
+}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\@setauthors{%
+ \begingroup
+ \def\thanks{\protect\thanks@warning}%
+ \trivlist
+%<amsart> \centering\footnotesize \@topsep30\p@\relax
+%<amsart> \advance\@topsep by -\baselineskip
+%<amsproc> \centering \fontsize{11}{13\p@}\selectfont\@topsep13\p@\relax
+ \item\relax
+ \author@andify\authors
+% \end{macrocode}
+% Make dbl-backslash robust to prevent problems if/when
+% \cs{MakeTextUppercase} expansion is applied.
+% \begin{macrocode}
+ \def\\{\protect\linebreak}%
+%<amsart> \MakeUppercase{\authors}%
+%<amsproc> \authors
+ \ifx\@empty\contribs
+ \else
+ ,\penalty-3 \space \@setcontribs
+ \@closetoccontribs
+ \fi
+ \endtrivlist
+ \endgroup
+}
+\def\@closetoccontribs{}
+\def\@setcontribs{%
+ \@xcontribs
+%<amsart> \MakeUppercase{\xcontribs}%
+%<amsproc> \xcontribs
+}
+\def\@setdate{\datename\ \@date\@addpunct.}
+\def\@setsubjclass{%
+ {\itshape\subjclassname.}\enspace\@subjclass\@addpunct.}
+\def\@setkeywords{%
+ {\itshape \keywordsname.}\enspace \@keywords\@addpunct.}
+%</amsart|amsproc>
+% \end{macrocode}
+%
+% The following definitions suffice for all the AMS document classes.
+% \begin{macrocode}
+\def\@setthanks{\def\thanks##1{\par##1\@addpunct.}\thankses}
+% \end{macrocode}
+%
+% `Abstract' can be changed to, say, `R\'esum\'e' (French) by
+% redefining \cn{abstractname}. This and other control sequence names
+% (\cn{refname}, \cn{contentsname}, \cn{appendixname}, and so on) are
+% compatible with the \pkg{babel} package (the AMS sometimes
+% publishes articles in languages other than English.)
+%
+% In AMS document classes, the abstract should be placed before
+% \cn{maketitle} (otherwise the desired ordering of frontmatter
+% elements cannot be ensured in all cases).
+% \begin{macrocode}
+\newbox\abstractbox
+% \end{macrocode}
+% We start by checking whether \cn{maketitle} has already been used
+% (in which case it was reset to \cs{relax}); if so, we give a
+% warning that the abstract should be placed before \cn{maketitle}.
+% \begin{macrocode}
+\newenvironment{abstract}{%
+ \ifx\maketitle\relax
+ \ClassWarning{\@classname}{Abstract should precede
+ \protect\maketitle\space in AMS document classes; reported}%
+ \fi
+ \global\setbox\abstractbox=\vtop \bgroup
+ \normalfont\Small
+ \list{}{\labelwidth\z@
+ \leftmargin3pc \rightmargin\leftmargin
+ \listparindent\normalparindent \itemindent\z@
+ \parsep\z@ \@plus\p@
+% \end{macrocode}
+% In order to get equation numbers indented with the rest of the
+% abstract, we have to do this:
+% \begin{macrocode}
+ \let\fullwidthdisplay\relax
+ }%
+ \item[\hskip\labelsep\scshape\abstractname.]%
+}{%
+ \endlist\egroup
+% \end{macrocode}
+% If the abstract was supposed to be typeset earlier, then
+% \cs{@setabstract} is now equal to \cs{relax}, and we had better
+% drop the contents of the abstract box onto the page immediately, to
+% salvage the situation as best we can.
+% \begin{macrocode}
+ \ifx\@setabstract\relax \@setabstracta \fi
+}
+% \end{macrocode}
+%
+% Because the abstract might be postponed until the end of an
+% article, we cannot simply use the fact of a preceding
+% \cn{maketitle} to tell whether \cs{endabstract} should immediately
+% put the abstract box contents on the page. So we use an auxiliary
+% function that will be reset to no-op once we have passed the point
+% where the abstract should normally be typeset.
+% \begin{macrocode}
+\def\@setabstract{\@setabstracta \global\let\@setabstract\relax}
+\def\@setabstracta{%
+ \ifvoid\abstractbox
+ \else
+ \skip@20\p@ \advance\skip@-\lastskip
+ \advance\skip@-\baselineskip \vskip\skip@
+ \box\abstractbox
+ \prevdepth\z@ % because \abstractbox is a vtop
+ \fi
+}
+% \end{macrocode}
+%
+% Title page environment does nothing much; information and
+% formatting to be provided by the user.
+% \begin{macrocode}
+\def\titlepage{%
+%<amsbook> \cleardoublepage
+%<amsart|amsproc> \clearpage
+ \thispagestyle{empty}\setcounter{page}{0}}
+\def\endtitlepage{\newpage}
+% \end{macrocode}
+%
+% \subsection{Macros for list labels}
+%
+% Through version 1.2, first-level enumerated item labels were formatted
+% with a following period, which is not AMS style. Effective with
+% version 2.0 these labels are formatted with parentheses. Anyone
+% requiring the period style will have to redefine \cs{labelenumi}.
+% \begin{macrocode}
+\def\labelenumi{(\theenumi)}
+\def\theenumi{\@arabic\c@enumi}
+\def\labelenumii{(\theenumii)}
+\def\theenumii{\@alph\c@enumii}
+\def\p@enumii{\theenumi}
+\def\labelenumiii{(\theenumiii)}
+\def\theenumiii{\@roman\c@enumiii}
+\def\p@enumiii{\theenumi(\theenumii)}
+\def\labelenumiv{(\theenumiv)}
+\def\theenumiv{\@Alph\c@enumiv}
+\def\p@enumiv{\p@enumiii\theenumiii}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\labelitemi{$\m@th\bullet$}
+\def\labelitemii{\bfseries --}% \upshape already done by \itemize
+\def\labelitemiii{$\m@th\ast$}
+\def\labelitemiv{$\m@th\cdot$}
+% \end{macrocode}
+%
+% \subsection{Verse and quotation environments}
+% \begin{macrocode}
+\newenvironment{verse}{\let\\\@centercr
+ \list{}{\itemsep\z@ \itemindent -1.5em\listparindent\itemindent
+ \rightmargin\leftmargin \advance\leftmargin 1.5em}\item[]%
+}{%
+ \endlist
+}
+\let\endverse=\endlist % for efficiency
+% \end{macrocode}
+% The left/right margins of the quotation environment are supposed to
+% be the same as for the abstract environment.
+% \begin{macrocode}
+\newenvironment{quotation}{\list{}{%
+ \leftmargin3pc \listparindent\normalparindent
+ \itemindent\z@
+ \rightmargin\leftmargin \parsep\z@ \@plus\p@}%
+ \item[]%
+}{%
+ \endlist
+}
+\let\endquotation=\endlist % for efficiency
+\newenvironment{quote}{%
+ \list{}{\rightmargin\leftmargin}\item[]%
+}{%
+ \endlist
+}
+\let\endquote=\endlist % for efficiency
+% \end{macrocode}
+%
+% \subsection{List environments}
+% Changed definition of \cs{trivlist}, \env{enumerate}, and
+% \env{itemize} in order to have \cn{makelabel} apply \cn{upshape}.
+% \begin{macrocode}
+\def\trivlist{\parsep\parskip\@nmbrlistfalse
+ \@trivlist \labelwidth\z@ \leftmargin\z@
+ \itemindent\z@
+ \let\@itemlabel\@empty
+ \def\makelabel##1{\upshape##1}}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\renewenvironment{enumerate}{%
+ \ifnum \@enumdepth >3 \@toodeep\else
+ \advance\@enumdepth \@ne
+ \edef\@enumctr{enum\romannumeral\the\@enumdepth}\list
+ {\csname label\@enumctr\endcsname}{\usecounter
+ {\@enumctr}\def\makelabel##1{\hss\llap{\upshape##1}}}\fi
+}{%
+ \endlist
+}
+\let\endenumerate=\endlist % for efficiency
+% \end{macrocode}
+%
+% \begin{macrocode}
+\renewenvironment{itemize}{%
+ \ifnum\@itemdepth>3 \@toodeep
+ \else \advance\@itemdepth\@ne
+ \edef\@itemitem{labelitem\romannumeral\the\@itemdepth}%
+ \list{\csname\@itemitem\endcsname}%
+ {\def\makelabel##1{\hss\llap{\upshape##1}}}%
+ \fi
+}{%
+ \endlist
+}
+\let\enditemize=\endlist % for efficiency
+% \end{macrocode}
+%
+% \begin{macrocode}
+\newcommand{\descriptionlabel}[1]{\hspace\labelsep \upshape\bfseries #1:}
+\newenvironment{description}{\list{}{%
+% \end{macrocode}
+% Adjust the indent of the first line to the desired value:
+% \begin{macrocode}
+ \advance\leftmargini6\p@ \itemindent-12\p@
+ \labelwidth\z@ \let\makelabel\descriptionlabel}%
+}{
+ \endlist
+}
+\let\enddescription=\endlist % for efficiency
+% \end{macrocode}
+%
+% \begin{macro}{\upn}
+% The command \cn{upn} can be used to force upright font for
+% punctuation or digits in italic text. For example
+%\begin{verbatim}
+% ... as numbered by \upn{``A''} or \upn{``1''} hereafter\upn{)}
+%\end{verbatim}
+% \begin{macrocode}
+\let\upn=\textup
+% \end{macrocode}
+% \end{macro}
+%
+% Since these margin settings are dependent on the fonts used, we
+% postpone them until begin-document. (This means that we cannot use
+% the values directly for calculations before begin-document.) Allow
+% for a reasonable maximum value; 13 = xiii = m should be adequate.
+% \begin{macrocode}
+\AtBeginDocument{%
+ \labelsep=5pt\relax
+ \setcounter{enumi}{13}\setcounter{enumii}{13}%
+ \setcounter{enumiii}{13}\setcounter{enumiv}{13}%
+ \settowidth\leftmargini{\labelenumi\hskip\labelsep}%
+ \advance\leftmargini by \normalparindent
+ \settowidth\leftmarginii{\labelenumii\hskip\labelsep}%
+ \settowidth\leftmarginiii{\labelenumiii\hskip\labelsep}%
+ \settowidth\leftmarginiv{\labelenumiv\hskip\labelsep}%
+ \setcounter{enumi}{0}\setcounter{enumii}{0}%
+ \setcounter{enumiii}{0}\setcounter{enumiv}{0}%
+ \leftmarginv=10pt \leftmarginvi=\leftmarginv
+ \leftmargin=\leftmargini
+ \labelwidth=\leftmargini \advance\labelwidth-\labelsep
+ \@listi}
+% \end{macrocode}
+%
+% In some contexts the space above/below lists needs to be
+% suppressed. So we put it into a variable \cs{listisep}.
+% \begin{macrocode}
+\newskip\listisep
+\listisep\smallskipamount
+\def\@listI{\leftmargin\leftmargini \parsep\z@skip
+ \topsep\listisep \itemsep\z@skip
+ \listparindent\normalparindent}
+\let\@listi\@listI
+% \end{macrocode}
+%
+% Is it necessary to reset \cs{parsep}, \cs{partopsep}, \cs{itemsep}
+% to their default values (0) in each of the subordinate list
+% setup functions? I don't believe so, but I leave the settings in
+% the listii function just in case some unusual nesting of
+% environments might cause trouble. [mjd,1994/09/22]
+% \begin{macrocode}
+\def\@listii{\leftmargin\leftmarginii
+ \labelwidth\leftmarginii \advance\labelwidth-\labelsep
+ \topsep\z@skip \parsep\z@skip \partopsep\z@skip \itemsep\z@skip}
+\def\@listiii{\leftmargin\leftmarginiii
+ \labelwidth\leftmarginiii \advance\labelwidth-\labelsep}
+\def\@listiv{\leftmargin\leftmarginiv
+ \labelwidth\leftmarginiv \advance\labelwidth-\labelsep}
+\def\@listv{\leftmargin\leftmarginv
+ \labelwidth\leftmarginv \advance\labelwidth-\labelsep}
+\def\@listvi{\leftmargin\leftmarginvi
+ \labelwidth\leftmarginvi \advance\labelwidth-\labelsep}
+% \end{macrocode}
+%
+% \subsection{Fleqn option}
+%
+% \begin{macrocode}
+\@ifclasswith{\@classname}{fleqn}{%
+ \let\@tempa\@iden
+ \AtBeginDocument{\mathindent\leftmargini}%
+}{\let\@tempa\@gobble}%
+\@ifpackageloaded{amsmath}{\let\@tempa\@gobble}{%
+ \@ifpackageloaded{amstex}{\let\@tempa\@gobble}{}%
+}
+\@tempa{%
+ \def\[{\relax
+ \ifmmode\@badmath
+ \else
+ \begin{trivlist}%
+ \@beginparpenalty\predisplaypenalty
+ \@endparpenalty\postdisplaypenalty
+ \item[]\leavevmode
+ \hbox to\linewidth\bgroup$\displaystyle
+% \end{macrocode}
+% Note that the \cs{m@th} should go at the end in \cn{]} just in
+% case an embedded small math formula inside \cn{text} occurs in
+% the display.
+%
+% Why the extra bgroup here? I think it's not needed.
+% [mjd,3-Feb-1994]
+% \begin{macrocode}
+ \hskip\mathindent\bgroup
+ \fi}%
+ \def\]{\relax
+ \ifmmode
+ \egroup \m@th$\hfil \egroup
+ \end{trivlist}%
+ \else \@badmath
+ \fi}%
+ \renewenvironment{equation}{%
+ \@beginparpenalty\predisplaypenalty
+ \@endparpenalty\postdisplaypenalty
+ \refstepcounter{equation}%
+ \@topsep\abovedisplayskip \trivlist
+ \item[]\leavevmode
+ \hbox to\linewidth\bgroup\hskip\mathindent$\displaystyle
+ }{%
+ \m@th$\hfil \displaywidth\linewidth \hbox{\@eqnnum}\egroup
+ \endtrivlist
+ }%
+ \renewenvironment{eqnarray}{%
+ \stepcounter{equation}\let\@currentlabel\theequation
+ \global\@eqnswtrue \global\@eqcnt\z@ \tabskip\mathindent
+ \let\\=\@eqncr \abovedisplayskip\topsep
+ \ifvmode \advance\abovedisplayskip\partopsep \fi
+ \belowdisplayskip\abovedisplayskip
+ \belowdisplayshortskip\abovedisplayskip
+ \abovedisplayshortskip\abovedisplayskip
+ $$\everycr{}\halign to\linewidth\bgroup
+ \hskip\@centering
+ $\displaystyle\tabskip\z@skip####\m@th$&%
+ \@eqnsel \global\@eqcnt\@ne
+ \hfil${}####{}\m@th$\hfil&%
+ \global\@eqcnt\tw@
+ $\displaystyle ####\m@th$\hfil\tabskip\@centering&%
+ \global\@eqcnt\thr@@
+ \hbox to \z@\bgroup\hss####\egroup\tabskip\z@skip\cr
+ }{%
+ \@@eqncr \egroup \global\advance\c@equation\m@ne$$%
+ \global\@ignoretrue
+ }%
+ \newdimen\mathindent
+ \mathindent\leftmargini
+}
+% \end{macrocode}
+%
+% \subsection{Redefined internal sectioning commands}
+%
+% In amsart.sty \cs{@startsection}, \cs{@sect},
+% and a couple of other things are redefined to fix a few hard-coded
+% things that would interfere with the desired style. The most
+% noteworthy difference is that all section headings will go into the
+% table of contents (governed by secnumdepth as usual), EVEN WHEN THE
+% |*| FORM IS USED. The only section heading not listed in the table of
+% contents is the heading for the toc itself.
+%
+% A second major departure from standard \latex/ is that when a
+% short form of a section title is given, it is used only for the
+% running heads; the table of contents still gets the full version of
+% the title. This is correct for AMS editorial practice. However if
+% one wants to get a line break into the table of contents it means
+% that the standard \latex/ method cannot be used. See the
+% \cn{except} and \cn{for} commands.
+% \begin{macrocode}
+\def\@startsection#1#2#3#4#5#6{%
+% \end{macrocode}
+% Section titles, if they are run-in with the following text, are
+% stored in a box instead of being typeset right away. They will be
+% typeset by \cs{everypar}, but if one section heading follows
+% right after another, this won't happen. So by doing
+% \cs{leavevmode} we force this to happen. (\cs{if@noskipsec}
+% is true if the previous section title has not yet been typeset.)
+% \begin{macrocode}
+ \if@noskipsec \leavevmode \fi
+ \par \@tempskipa #4\relax
+ \@afterindenttrue
+ \ifdim \@tempskipa <\z@ \@tempskipa -\@tempskipa \@afterindentfalse\fi
+ \if@nobreak \everypar{}\else
+ \addpenalty\@secpenalty\addvspace\@tempskipa\fi
+% Don't call \@ssect in the ifstar case:
+ \@ifstar{\@dblarg{\@sect{#1}{\@m}{#3}{#4}{#5}{#6}}}%
+ {\@dblarg{\@sect{#1}{#2}{#3}{#4}{#5}{#6}}}%
+}
+% \end{macrocode}
+%
+% We add \cn{textup} here in order to make section
+% numbers always roman, even if the rest of the section head is
+% italic.
+% \begin{macrocode}
+\def\@seccntformat#1{%
+ \protect\textup{\protect\@secnumfont
+ \csname the#1\endcsname
+ \protect\@secnumpunct
+ }%
+}
+% \end{macrocode}
+%
+% Some journals require a different font for section numbers. (As
+% coded here, this option permits only a change of weight, to
+% \cn{bfseries}.) The \cls{amsart} font is checked again later,
+% when processing \cn{section}, and if there is no section title,
+% it is made bold.
+% \begin{macrocode}
+%<amsbook|amsproc>\let\@secnumfont\@empty
+%<amsart>\def\@secnumfont{\mdseries}
+% \end{macrocode}
+%
+% For reference, here is the argument list for \cs{@sect}.
+%\begin{verbatim}
+% % #1 #2 #3 #4 #5 #6 #7 #8
+% {NAME}{LEVEL}{INDENT}{BEFORESKIP}{AFTERSKIP}{STYLE}[SHORTT]{TITLE}
+%\end{verbatim}
+% \begin{macrocode}
+\def\@sect#1#2#3#4#5#6[#7]#8{%
+% \end{macrocode}
+% Define \cs{@toclevel} for for \cs{@tocwrite} (to
+% \cs{@tochangmeasure}).
+% \begin{macrocode}
+ \edef\@toclevel{\ifnum#2=\@m 0\else\number#2\fi}%
+ \ifnum #2>\c@secnumdepth \let\@secnumber\@empty
+ \else \@xp\let\@xp\@secnumber\csname the#1\endcsname\fi
+% \end{macrocode}
+% If the value of afterskip $>0$, then this is not a run-in section
+% heading, and we want to suppress final punctuation.
+% \begin{macrocode}
+ \@tempskipa #5\relax
+% \end{macrocode}
+% \cs{@svsec} will be the section number plus some formatting if
+% the star form was not used and if the depth of numbering extends to
+% the current level. The user can change secnumdepth to control how
+% many levels of sectioning will be numbered.
+% \begin{macrocode}
+ \ifnum #2>\c@secnumdepth
+ \let\@svsec\@empty
+ \else
+ \refstepcounter{#1}%
+% \end{macrocode}
+% If the section heading is not run-in and there is no title, omit
+% final punctuation and space. If it is run-in, omit extra space.
+% \begin{macrocode}
+ \edef\@secnumpunct{%
+ \ifdim\@tempskipa>\z@ % not a run-in section heading
+ \@ifnotempty{#8}{.\@nx\enspace}%
+ \else
+ \@ifempty{#8}{.}{.\@nx\enspace}%
+ \fi
+ }%
+% \end{macrocode}
+% For \cls{amsart}, if a subsection has no title, make the section
+% number bold; otherwise leave it alone.
+% [bnb; 2004/06/08; per vwa, B-442]
+% \begin{macrocode}
+%<amsart> \@ifempty{#8}{%
+%<amsart> \ifnum #2=\tw@ \def\@secnumfont{\bfseries}\fi}{}%
+% \end{macrocode}
+% If the |*|-form was not used (\arg{2} less than 1000), we add
+% \cn{sectionname} or whatever as a prefix, separated by a space.
+% We need the ifundefined test in order to know whether the space
+% should be added or not. There must be a better way to do this
+% but I haven't thought of it yet.
+% \begin{macrocode}
+ \protected@edef\@svsec{%
+ \ifnum#2<\@m
+ \@ifundefined{#1name}{}{%
+ \ignorespaces\csname #1name\endcsname\space
+ }%
+ \fi
+ \@seccntformat{#1}%
+ }%
+ \fi
+ \ifdim \@tempskipa>\z@ % then this is not a run-in section heading
+ \begingroup #6\relax
+ \@hangfrom{\hskip #3\relax\@svsec}{\interlinepenalty\@M #8\par}%
+ \endgroup
+% \end{macrocode}
+%
+% Section headings don't set marks for the running heads in the article
+% style, only in the amsbook style. Assumption: \cs{sectionmark} is
+% defined to call \cs{@secnumber} as its penultimate argument.
+% \begin{macrocode}
+%<amsbook> \csname #1mark\endcsname{#7}%
+% \end{macrocode}
+% If \arg{2} (level) is greater than 1000 then we don't do a table
+% of contents entry. This happens only for the section heading above
+% the table of contents itself.
+% \begin{macrocode}
+ \ifnum#2>\@m \else \@tocwrite{#1}{#8}\fi
+ \else
+% \end{macrocode}
+% Otherwise we're doing a run-in heading; it is stored as \cs{@svsechd},
+% which will be typeset by \cs{everypar} as soon as some text is
+% encountered.
+% \begin{macrocode}
+ \def\@svsechd{#6\hskip #3\@svsec
+% \end{macrocode}
+% To allow for the possibility that the user wants an empty section
+% title, leaving just the section number, we check whether \arg{8}
+% is nonempty before adding the period.
+% \begin{macrocode}
+ \@ifnotempty{#8}{\ignorespaces#8\unskip
+% \end{macrocode}
+% The following test is to prevent a period being added if the
+% section title ended in a question mark or other punctuation.
+% \begin{macrocode}
+ \@addpunct.}%
+ \ifnum#2>\@m \else \@tocwrite{#1}{#8}\fi
+ }%
+ \fi
+% \end{macrocode}
+% In a previous version of \cls{amsart} \cs{@nobreaktrue} was added to
+% \cs{@xsect} for some reason. Let's keep that just in case it was done to
+% prevent a certain kind of bug. [mjd,17-Aug-1994]
+% \begin{macrocode}
+ \global\@nobreaktrue
+% \end{macrocode}
+% \cs{@xsect} does some more stuff based on whether this is a run-in
+% heading or not.
+% \begin{macrocode}
+ \@xsect{#5}}
+% \end{macrocode}
+%
+% Undefine \cs{@ssect} to save memory; it's not needed in \cls{amsart}.
+% \begin{macrocode}
+\let\@ssect\relax
+% \end{macrocode}
+%
+% \subsection{Chapters and sections}
+% Allocate counters for sectioning commands. Paragraph and subparagraph
+% counters are allocated but normally not used.
+% \begin{macrocode}
+\newcounter{part}
+%<amsbook>\newcounter{chapter}
+%<amsproc|amsart>\newcounter{section}
+%<amsbook>\newcounter{section}[chapter]
+%<amsbook>\def\thesection{\arabic{section}}
+\newcounter{subsection}[section]
+\newcounter{subsubsection}[subsection]
+\newcounter{paragraph}[subsubsection]
+\newcounter{subparagraph}[paragraph]
+% \end{macrocode}
+% Set numbering style for sectioning commands. In a couple of cases
+% resetting is unnecessary but we include the full list here for
+% completeness.
+% \begin{macrocode}
+\renewcommand\thepart {\arabic{part}}
+%<amsbook>\renewcommand\thechapter {\arabic{chapter}}
+\renewcommand\thesection {\arabic{section}}
+\renewcommand\thesubsection {\thesection.\arabic{subsection}}
+\renewcommand\thesubsubsection {\thesubsection .\arabic{subsubsection}}
+\renewcommand\theparagraph {\thesubsubsection.\arabic{paragraph}}
+\renewcommand\thesubparagraph {\theparagraph.\arabic{subparagraph}}
+% \end{macrocode}
+% Depth of section numbering; if \fn{secnumdepth} were 2 instead of
+% 3, \cn{subsubsection} would not be numbered.
+% \begin{macrocode}
+\setcounter{secnumdepth}{3}
+% \end{macrocode}
+%
+% The arguments of \cs{@startsection} are given for reference:
+%\begin{verbatim}
+% % #1 #2 #3 #4 #5 #6
+% {NAME}{LEVEL}{INDENT}{BEFORESKIP}{AFTERSKIP}{STYLE}
+%\end{verbatim}
+%
+% \begin{macrocode}
+\def\partname{Part}
+%<*amsart|amsproc>
+\def\part{\@startsection{part}{0}%
+ \z@{\linespacing\@plus\linespacing}{.5\linespacing}%
+ {\normalfont\bfseries\raggedright}}
+%</amsart|amsproc>
+% \end{macrocode}
+%
+% Specialsection correlates to our inhouse Z-head.
+% \begin{macrocode}
+\def\specialsection{\@startsection{section}{1}%
+%<amsart> \z@{\linespacing\@plus\linespacing}{.5\linespacing}%
+%<amsproc|amsbook> \z@{2\linespacing\@plus\linespacing}{.5\linespacing}%
+%<amsart> {\normalfont\centering}}
+%<amsproc|amsbook> {\large\scshape\centering}}
+% \end{macrocode}
+%
+% In the book class \cn{part} puts the part title on a separate
+% page.
+% \begin{macrocode}
+%<*amsbook>
+\def\part{\cleardoublepage \thispagestyle{empty}%
+ \null\vfil \markboth{}{}\secdef\@part\@spart}
+%
+\def\@part[#1]#2{%
+ \ifnum \c@secnumdepth >-2\relax \refstepcounter{part}%
+ \addcontentsline{toc}{part}{\partname\ \thepart.
+ \protect\enspace\protect\noindent#1}%
+ \else
+ \addcontentsline{toc}{part}{#1}\fi
+ \begingroup\centering
+ \ifnum \c@secnumdepth >-2\relax
+ {\fontsize{\@xviipt}{22}\bfseries
+ \partname\ \thepart} \vskip 20\p@ \fi
+ \fontsize{\@xxpt}{25}\bfseries
+ #1\vfil\vfil\endgroup \newpage\thispagestyle{empty}}
+
+\def\@spart#1{\addcontentsline{toc}{part}{\protect\noindent#1}%
+ \begingroup\centering
+ \fontsize{\@xxpt}{25}\bfseries
+ #1\vfil\vfil\endgroup \newpage\thispagestyle{empty}}
+%</amsbook>
+% \end{macrocode}
+%
+% The arguments of \cs{partrunhead} are \cs{partname},
+% \cs{thepart}, and the text of the part title. The first two were
+% fully expanded during the marking process. Use of a mere
+% interword space between the first two args makes it possible
+% to apply \cn{ignorespaces} and \cn{unskip} as shown here
+% to produce the desired results if one or the other is empty.
+% \begin{macrocode}
+%<*amsbook>
+\def\partrunhead#1#2#3{%
+ \@ifnotempty{#2}{\uppercase{\ignorespaces#1 #2\unskip}\@ifnotempty{#3}{. }}%
+ \def\@tempa{#3}%
+ \ifx\@empty\@tempa\else
+ \begingroup \def\\{ \ignorespaces}% defend against questionable usage
+ \uppercasenonmath\@tempa\@tempa
+ \endgroup
+ \fi
+}
+\let\chapterrunhead\partrunhead
+\let\sectionrunhead\partrunhead
+%</amsbook>
+% \end{macrocode}
+%
+% Section headings in the amsbook style differ from the amsart
+% style in a couple of ways: The ones that aren't centered are
+% indented on the left, instead of flush left; and the first
+% level, \cn{section}, is not small caps but bold.
+% Cf.~the definition of \cn{appendix}.
+% \begin{macrocode}
+\def\section{\@startsection{section}{1}%
+ \z@{.7\linespacing\@plus\linespacing}{.5\linespacing}%
+%<amsart> {\normalfont\scshape\centering}}
+%<amsbook|amsproc> {\normalfont\bfseries\centering}}
+% \end{macrocode}
+%
+% Negative value for \arg{5} is a signal to make a run-in heading instead
+% of doing a vskip after the heading.
+% \begin{macrocode}
+\def\subsection{\@startsection{subsection}{2}%
+%<amsart> \z@{.5\linespacing\@plus.7\linespacing}{-.5em}%
+%<amsbook|amsproc> \normalparindent{.5\linespacing\@plus.7\linespacing}{-.5em}%
+ {\normalfont\bfseries}}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\subsubsection{\@startsection{subsubsection}{3}%
+%<amsart> \z@{.5\linespacing\@plus.7\linespacing}{-.5em}%
+%<amsbook|amsproc> \normalparindent\z@{-.5em}%
+ {\normalfont\itshape}}
+% \end{macrocode}
+%
+% Fontdimen 2 of the current font is the ideal interword space of the
+% font. Thus the following spec says that the space after the
+% paragraph heading should be a normal interword space (but
+% nonstretching and nonshrinking).
+% \begin{macrocode}
+\def\paragraph{\@startsection{paragraph}{4}%
+%<amsart> \z@\z@{-\fontdimen2\font}%
+%<amsbook|amsproc> \normalparindent\z@{-\fontdimen2\font}%
+ \normalfont}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\subparagraph{\@startsection{subparagraph}{5}%
+ \z@\z@{-\fontdimen2\font}%
+ \normalfont}
+% \end{macrocode}
+%
+% \begin{macrocode}
+%<*amsart|amsproc>
+\def\appendix{\par\c@section\z@ \c@subsection\z@
+ \let\sectionname\appendixname
+ \def\thesection{\@Alph\c@section}}
+\def\appendixname{Appendix}
+%</amsart|amsproc>
+% \end{macrocode}
+%
+% A slower, but fully expandable definition of \cs{@Roman} to avoid
+% the nonexpandable \cn{uppercase} which is undesirable in certain
+% circumstances.
+% \begin{macrocode}
+\def\@Roman#1{\@xp\@slowromancap
+ \romannumeral#1@}%
+%
+\def\@slowromancap#1{\ifx @#1% then terminate
+ \else
+% \end{macrocode}
+% Note: \cs{if} is required here, not \cs{ifx}, because
+% \cs{romannumeral} returns category 12 letters!
+% \begin{macrocode}
+ \if i#1I\else\if v#1V\else\if x#1X\else\if l#1L\else\if
+ c#1C\else\if m#1M\else#1\fi\fi\fi\fi\fi\fi
+ \@xp\@slowromancap
+ \fi
+}
+% \end{macrocode}
+%
+% \subsection{Book features}
+% Books (monographs) comprise three distinct sections,
+% \cn{frontmatter}, \cn{mainmatter}, and \cn{backmatter}. The
+% \cn{frontmatter} would consist of the title page, copyright page,
+% table of contents, preface, etc. The \cn{mainmatter} would
+% be the body of the book. The \cn{backmatter} would include the
+% appendix, bibliography, glossary, and index.
+% \begin{macrocode}
+%<*amsbook>
+\def\frontmatter{\cleardoublepage\pagenumbering{roman}}
+\def\mainmatter{\cleardoublepage\pagenumbering{arabic}}
+\def\backmatter{%
+ \if@openright\cleardoublepage\else\clearpage\fi
+ \let\chaptername\relax}
+%</amsbook>
+% \end{macrocode}
+%
+% Book proceedings and monographs allow a signature to print at the
+% end of a preface.
+% \begin{macrocode}
+%<*!amsart>
+\def\aufm#1{\par\vspace*{12pt}{\flushright #1\par}}
+%</!amsart>
+% \end{macrocode}
+%
+% Monographs can have a special exercise environment.
+%
+% \begin{macrocode}
+%<*amsbook>
+\newenvironment{xcb}{%
+ \setcounter{enumi}{0}%
+ \settowidth{\leftmargini}{\labelenumi\hskip\labelsep}%
+ \setcounter{enumii}{4}% letter d
+ \settowidth{\leftmarginii}{\labelenumii\hskip\labelsep}%
+ \@startsection{section}% counter name; ignored because of the
+ % * below
+ {1}% sectioning level
+ {\z@}% indent to the left of the section title
+ {18\p@\@plus2\p@}% vertical space above
+ {1sp}% Space below of 13pt base-to-base, so none needs to be added
+ % here; but \z@ would cause the following text to be run-in, so we
+ % use 1sp instead.
+ {\bfseries}% The font of the subsection title
+ *% always unnumbered
+}{%
+ \par
+}
+%</amsbook>
+% \end{macrocode}
+%
+% \subsection{Book chapters}
+% The \cn{chapter} command is provided only in the \cls{amsbook} class,
+% not in \cls{amsart} or \cls{amsproc}.
+% \begin{macrocode}
+%<*amsbook>
+\def\chapter{%
+ \if@openright\cleardoublepage\else\clearpage\fi
+ \thispagestyle{plain}\global\@topnum\z@
+ \@afterindenttrue \secdef\@chapter\@schapter}
+% \end{macrocode}
+% \cs{@chapter} for numbered chapters.
+% \begin{macrocode}
+\def\@chapter[#1]#2{\refstepcounter{chapter}%
+ \ifnum\c@secnumdepth<\z@ \let\@secnumber\@empty
+ \else \let\@secnumber\thechapter \fi
+ \typeout{\chaptername\space\@secnumber}%
+ \def\@toclevel{0}%
+ \ifx\chaptername\appendixname \@tocwriteb\tocappendix{chapter}{#2}%
+ \else \@tocwriteb\tocchapter{chapter}{#2}\fi
+ \chaptermark{#1}%
+ \addtocontents{lof}{\protect\addvspace{10\p@}}%
+ \addtocontents{lot}{\protect\addvspace{10\p@}}%
+ \@makechapterhead{#2}\@afterheading}
+% \end{macrocode}
+% \cs{@schapter} for unnumbered chapters.
+% \begin{macrocode}
+\def\@schapter#1{\typeout{#1}%
+ \let\@secnumber\@empty
+ \def\@toclevel{0}%
+ \ifx\chaptername\appendixname \@tocwriteb\tocappendix{chapter}{#1}%
+ \else \@tocwriteb\tocchapter{chapter}{#1}\fi
+ \chaptermark{#1}%
+ \addtocontents{lof}{\protect\addvspace{10\p@}}%
+ \addtocontents{lot}{\protect\addvspace{10\p@}}%
+ \@makeschapterhead{#1}\@afterheading}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\newcommand\chaptername{Chapter}
+\newcommand\appendixname{Appendix}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\@makechapterhead#1{\global\topskip 7.5pc\relax
+ \begingroup
+ \fontsize{\@xivpt}{18}\bfseries\centering
+% \end{macrocode}
+% In order to keep the chapter number ``CHAPTER III'' from
+% getting in the way of the \cs{topskip} we put it inside
+% the paragraph containing the main title. Then we have to
+% do some laborious \cs{rlap}ing and \cs{hskip}ing to
+% position it correctly.
+% \begin{macrocode}
+ \ifnum\c@secnumdepth>\m@ne
+ \leavevmode \hskip-\leftskip
+ \rlap{\vbox to\z@{\vss
+ \centerline{\normalsize\mdseries
+ \uppercase\@xp{\chaptername}\enspace\thechapter}
+ \vskip 3pc}}\hskip\leftskip\fi
+ #1\par \endgroup
+ \skip@34\p@ \advance\skip@-\normalbaselineskip
+ \vskip\skip@ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\@makeschapterhead#1{\global\topskip 7.5pc\relax
+ \begingroup
+ \fontsize{\@xivpt}{18}\bfseries\centering
+ #1\par \endgroup
+ \skip@34\p@ \advance\skip@-\normalbaselineskip
+ \vskip\skip@ }
+%</amsbook>
+% \end{macrocode}
+% The \cn{appendix} command, following the \latex/ book, marks the
+% start of a division after \cn{mainmatter} and before
+% \cn{backmatter} that consists of appendixes.
+% \begin{macrocode}
+%<*amsbook>
+\def\appendix{\par
+ \c@chapter\z@ \c@section\z@
+ \let\chaptername\appendixname
+ \def\thechapter{\@Alph\c@chapter}}
+%</amsbook>
+% \end{macrocode}
+%
+% \subsection{Table of contents macros}
+%
+% \cn{tableofcontents} is like \cn{chapter} or \cn{section} except
+% for no number and no table of contents entry.
+%
+% \cs{@pnumwidth} is the maximum width for page numbers in a table of
+% contents. |1.6em| allows enough room for three digits.
+% \begin{macrocode}
+\newcommand{\@pnumwidth}{1.6em}
+% \end{macrocode}
+% \cs{@tocrmarg} is \cs{@pnumwidth} plus the desired minimum
+% space (|1em|) between page numbers and the preceding text.
+% \begin{macrocode}
+\newcommand{\@tocrmarg}{2.6em}
+%<amsart>\setcounter{tocdepth}{2}
+%<amsbook|amsproc>\setcounter{tocdepth}{1}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\newswitch{toc}
+\newswitch{lof}
+\newswitch{lot}
+% \end{macrocode}
+%
+% Since table of contents, list of figures and list of figures
+% are identical in design as far as the chapter heading and other
+% preliminaries go, we redefine \cs{@starttoc} to do the necessary
+% work, rather than defining a new macro (which would use up another
+% control sequence name).
+%
+% We define first the article form of \cs{@starttoc}, then the book
+% form.
+%
+% Owing to confusion about what font to use for \cn{contentsname}, a
+% symbolic name has been assigned to provide flexibility.
+% \begin{macrocode}
+%<*amsart|amsproc>
+\newcommand\contentsnamefont{\scshape}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\@starttoc#1#2{\begingroup
+ \setTrue{#1}%
+% \end{macrocode}
+% Remove the skip after the abstract so that we can substitute another.
+% \begin{macrocode}
+ \par\removelastskip\vskip\z@skip
+% \end{macrocode}
+% The first two arguments of \cs{@startsection} here are special values
+% that cause different internal branches to be taken.
+%\begin{verbatim}
+% Arguments: {} = name = empty
+% \@M = no number should be used and no table of contents entry
+% \z@ = indent amount
+% 12pt + 12pt = vskip before
+% 6pt = vskip after
+% \centering\contentsnamefont = format
+%\end{verbatim}
+% \begin{macrocode}
+ \@startsection{}\@M\z@{\linespacing\@plus\linespacing}%
+ {.5\linespacing}{\centering\contentsnamefont}{#2}%
+% \end{macrocode}
+% If we have a list of figures or list of tables we want to put
+% them in the main table of contents, but we don't want to put an
+% entry there for the main table of contents itself. So we check
+% to see if argument 2 is \cn{contentsname} and if it is then
+% we refrain from doing \cn{addcontentsline}.
+% \begin{macrocode}
+ \ifx\contentsname#2%
+ \else \addcontentsline{toc}{section}{#2}\fi
+ \makeatletter
+ \@input{\jobname.#1}%
+ \if@filesw
+ \@xp\newwrite\csname tf@#1\endcsname
+ \immediate\@xp\openout\csname tf@#1\endcsname \jobname.#1\relax
+ \fi
+ \global\@nobreakfalse \endgroup
+ \addvspace{32\p@\@plus14\p@}%
+ \let\tableofcontents\relax
+}
+%</amsart|amsproc>
+% \end{macrocode}
+% And here is the book form of \cs{@starttoc}.
+% \begin{macrocode}
+%<*amsbook>
+\def\@starttoc#1#2{%
+ \begingroup
+ \setTrue{#1}%
+% \end{macrocode}
+% Inside this group we change \cs{secdef} so that we can call
+% \cn{chapter} and only get the preliminary part of its definition
+% that we need.
+% \begin{macrocode}
+ \let\secdef\@gobbletwo \chapter
+% \end{macrocode}
+% If we have a list of figures or list of tables we want to put
+% them in the main table of contents, but we don't want to put an
+% entry there for the main table of contents itself. So we check
+% to see if argument 2 is \cn{contentsname} and if it is then
+% we refrain from doing \cn{addcontentsline}.
+% \begin{macrocode}
+ \let\@secnumber\@empty % for \@tocwrite and \chaptermark
+ \ifx\contentsname#2%
+ \else \@tocwrite{chapter}{#2}\fi
+% \end{macrocode}
+% Now we do the equivalent of \cs{@schapter}. Expand \arg{2} so that
+% it will be easy to apply uppercasing to it. (For \cs{@starttoc} we
+% assume that \arg{2} is always a control such as \cn{contentsname}.)
+% \begin{macrocode}
+ \typeout{#2}\@xp\chaptermark\@xp{#2}%
+ \@makeschapterhead{#2}\@afterheading
+% \end{macrocode}
+% Protect against document classes that have nonzero \cs{parskip}.
+% \begin{macrocode}
+ \parskip\z@skip
+% \end{macrocode}
+% And finally we read in the \fn{.toc} (or whatever) file.
+% \begin{macrocode}
+ \makeatletter
+ \@input{\jobname.#1}%
+ \if@filesw
+ \@xp\newwrite\csname tf@#1\endcsname
+ \immediate\@xp\openout\csname tf@#1\endcsname \jobname.#1\relax
+ \fi
+ \global\@nobreakfalse \endgroup
+ \newpage
+}
+%</amsbook>
+% \end{macrocode}
+%
+% Now it is easy to define \cn{tableofcontents} and its relatives.
+% \begin{macrocode}
+\def\contentsname{Contents}
+\def\listfigurename{List of Figures}
+\def\listtablename{List of Tables}
+\def\tableofcontents{%
+ \@starttoc{toc}\contentsname
+}
+\def\listoffigures{\@starttoc{lof}\listfigurename}
+\def\listoftables{\@starttoc{lot}\listtablename}
+% \end{macrocode}
+%
+% In order to automatically leave enough space for the `number' part
+% of toc entries, we compute the maximum width of the `number' part
+% for each sectioning level and pass that information to
+% \cs{@tocline} through the \fn{.aux} file.
+%
+% Init the tocindents if they are not yet set (first run).
+% \begin{macrocode}
+\AtBeginDocument{%
+ \@for\@tempa:=-1,0,1,2,3\do{%
+ \@ifundefined{r@tocindent\@tempa}{%
+ \@xp\gdef\csname r@tocindent\@tempa\endcsname{0pt}}{}%
+ }%
+}
+% \end{macrocode}
+%
+% \begin{macro}{\@writetocindents}
+% This function writes out the max toc indents to the aux file.
+% \begin{macrocode}
+\def\@writetocindents{%
+ \begingroup
+ \@for\@tempa:=-1,0,1,2,3\do{%
+ \immediate\write\@auxout{%
+ \string\newlabel{tocindent\@tempa}{%
+ \csname r@tocindent\@tempa\endcsname}}%
+ }%
+ \endgroup}
+%
+\AtEndDocument{\@writetocindents}
+% \end{macrocode}
+% \end{macro}
+%
+
+% \begin{macro}{\indentlabel}
+% This function is a no-op except in \cs{@tocwrite} where it is a
+% pointer to \cs{@tochangmeasure}.
+% \begin{macrocode}
+\let\indentlabel\@empty
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@tochangmeasure}
+% This function measures the hangindent part of a toc entry and
+% updates the current max for the given sectioning level, if
+% necessary. The max's at the end of the document will be written
+% in the form of a pseudo-label to the \fn{.aux} file by
+% \cs{@writetocindents}.
+%
+% We can assume that \cs{@tochangmeasure} is already inside a group
+% when called.
+% \begin{macrocode}
+\def\@tochangmeasure#1{\sbox\z@{#1}%
+ \ifdim\wd\z@>\csname r@tocindent\@toclevel\endcsname\relax
+ \@xp\xdef\csname r@tocindent\@toclevel\endcsname{\the\wd\z@}%
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@toclevel}
+% Initialize, for the record.
+% \begin{macrocode}
+\def\@toclevel{0}
+% \end{macrocode}
+% \end{macro}
+%
+% Since we don't have leader dots, we have \cs{@tocline} instead of
+% \cs{@dottedtocline}.
+% \begin{macrocode}
+\def\@tocline#1#2#3#4#5#6#7{\relax
+ \ifnum #1>\c@tocdepth % then omit
+ \else
+ \par \addpenalty\@secpenalty\addvspace{#2}%
+ \begingroup \hyphenpenalty\@M
+ \@ifempty{#4}{%
+ \@tempdima\csname r@tocindent\number#1\endcsname\relax
+ }{%
+ \@tempdima#4\relax
+ }%
+ \parindent\z@ \leftskip#3\relax \advance\leftskip\@tempdima\relax
+ \rightskip\@pnumwidth plus4em \parfillskip-\@pnumwidth
+ #5\leavevmode\hskip-\@tempdima #6\nobreak\relax
+ \hfil\hbox to\@pnumwidth{\@tocpagenum{#7}}\par
+ \nobreak
+ \endgroup
+ \fi}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\@tocpagenum#1{\hss{\mdseries #1}}
+% \end{macrocode}
+%
+% The function \cs{@tocwrite} writes the information of a section
+% heading to the \fn{.toc} file in a standard form. It allows
+% different functions to be substituted for \cs{numberline}, to get
+% greater control of toc formatting.
+% \begin{macrocode}
+\def\@tocwrite#1{\@xp\@tocwriteb\csname toc#1\endcsname{#1}}
+% \end{macrocode}
+% The \cn{chapter} command uses \cs{@tocwriteb} directly because of
+% the need to write slightly different things to the toc file
+% depending on the current value of \cn{chaptername}.
+% \begin{macrocode}
+\def\@tocwriteb#1#2#3{%
+ \begingroup
+ \def\@tocline##1##2##3##4##5##6{%
+ \ifnum##1>\c@tocdepth
+ \else \sbox\z@{##5\let\indentlabel\@tochangmeasure##6}\fi}%
+ \csname l@#2\endcsname{#1{\csname#2name\endcsname}{\@secnumber}{}}%
+ \endgroup
+ \addcontentsline{toc}{#2}%
+ {\protect#1{\csname#2name\endcsname}{\@secnumber}{#3}}}
+% \end{macrocode}
+%
+% Specs for monograph toc are as follows (tocdepth is 1, i.e.,
+% subsections and lower are not listed in toc).
+%\begin{verbatim}
+% Part: Space above 12pt plus2pt, indent 0pt, "Part" + wordspace +
+% number + "." + 1em + title (raggedright, no hangindent) + 1em +
+% page number in column 1.6em wide.
+%
+% Chapter: Space above 8pt, hangindent on ("Chapter 0" + "." + 1em),
+% + title (raggedright) + 1em + page number in column 1.6em wide.
+%
+% Appendix: Same as Chapter except for epithet "Appendix M"
+%
+% Section: Space above 0pt, hangindent on (1pc + "0.0" + "." + 1em),
+% + title (raggedright) + 1em + page number in column 1.6em wide.
+%\end{verbatim}
+%
+% Specs for article toc are as follows (tocdepth 2):
+%\begin{verbatim}
+% Section: Same as for monograph.
+%
+% Subsection: Space above 0pt, hangindent 6pc (number + "." + 1em),
+% + title (raggedright) + 1em + page number in column 1.6em wide.
+%
+% Subsubsection: Same as subsection but hangindent 8pc
+%\end{verbatim}
+%
+% Typical invocation of \cs{l@chapter}:
+%\begin{verbatim}
+% \contentsline{chapter}{%
+% \tocchapter{Chapter}{3}{Some title stuff}}{103}
+% -->\l@chapter-->
+% #1 #2 #3 #4 #5
+% \@tocline{0}{8pt}{0pt}{}{\bfseries}
+% #6 6a 6b 6c #7
+% {\tocchapter{Chapter}{3}{Some title stuff}}{103}
+%\end{verbatim}%
+% The \cs{tocchapter} is a slightly more useful form than
+% \cs{numberline} that allows control for optionally omitting strings
+% like `Chapter' or changing fonts for subcomponents of the toc
+% entry. Note that it is allowed to have appendix and chapter at the
+% same toc level, with \cs{tocappendix} instead of \cs{tocchapter}
+% written in the \fn{.toc} file.
+%
+% The arguments of \cs{@tocline} are as follows:
+%\begin{verbatim}
+% \@tocline{LEVEL}{VSPACE}{INDENT}{NUMBERWIDTH}{EXTRA}%
+% {TEXT}{PAGENUM}
+%\end{verbatim}%
+% where `numberwidth' is the width of the box allotted to contain the
+% section number, including any preceding word like `Chapter' or
+% `Part'. If this width arg is empty then an automatically computed
+% width (max over TOC of the numberwidths for this level) is used.
+% The `extra' argument is formatting such as font changes.
+% The `text' argument contains a section-command specific function
+% like \cs{tocsection} or \cs{tocchapter} which takes in turn three
+% arguments: epithet, number, topic.
+% \begin{macrocode}
+\def\l@section{\@tocline{1}{0pt}{1pc}{}{}}
+% \end{macrocode}
+% *** The indents do not agree between in-house and distributed ***\\
+% *** versions; no changes; get specs before revising. ***\\
+% The use of \cn{ignorespaces} in \cs{tocsection} and its relatives
+% means that if \arg{1} is empty, the following space will be also
+% removed.
+% \begin{macrocode}
+\newcommand{\tocsection}[3]{%
+ \indentlabel{\@ifnotempty{#2}{\ignorespaces#1 #2.\quad}}#3}
+\def\l@subsection{\@tocline{2}{0pt}{1pc}{5pc}{}}
+\let\tocsubsection\tocsection
+\def\l@subsubsection{\@tocline{3}{0pt}{1pc}{7pc}{}}
+\let\tocsubsubsection\tocsection
+\let\l@paragraph\l@subsubsection
+\let\tocparagraph\tocsection
+\let\l@subparagraph\l@subsubsection
+\let\tocsubparagraph\tocsection
+%
+\def\l@part{\@tocline{-1}{12pt plus2pt}{0pt}{}{\bfseries}}
+\let\tocpart\tocsection
+\def\l@chapter{\@tocline{0}{8pt plus1pt}{0pt}{}{}}
+\let\tocchapter\tocsection
+% \end{macrocode}
+% In this case we are pretty sure the word "Appendix" or similar is
+% present, so only check if arg 2 is empty:
+% \begin{macrocode}
+\newcommand{\tocappendix}[3]{%
+ \indentlabel{#1\@ifnotempty{#2}{ #2}.\quad}#3}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\l@figure{\@tocline{0}{3pt plus2pt}{0pt}{1.5pc}{}}
+\let\l@table=\l@figure
+% \end{macrocode}
+%
+% \subsection{Bibliography section or chapter}
+%
+% Following the \pkg{babel} package, we use \cn{refname} in articles
+% and \cn{bibname} in books.
+% \begin{macrocode}
+\def\refname{References}
+\def\bibname{Bibliography}
+% \end{macrocode}
+%
+% Restudy the following code; \cs{bibsetup} isn't used anywhere
+% although it's defined for the three different bibstyles.
+% Because some publications have different default label styles,
+% separate that out for easy tailoring of packages.
+% \begin{macrocode}
+\def\@defaultbiblabelstyle#1{#1.}
+\def\bibliographystyle#1{%
+ \if@filesw\immediate\write\@auxout{\string\bibstyle{#1}}\fi
+ \def\@tempa{#1}%
+ \def\@tempb{amsplain}%
+ \def\@tempc{}%
+ \ifx\@tempa\@tempb
+ \def\@biblabel##1{\@defaultbiblabelstyle{##1}}%
+ \def\bibsetup{}%
+ \else
+ \def\bibsetup{\labelsep6\p@}%
+ \ifx\@tempa\@tempc
+ \def\@biblabel##1{}%
+ \def\bibsetup{\labelwidth\z@ \leftmargin24\p@
+ \itemindent-\leftmargin
+ \labelsep\z@ }%
+ \fi
+ \fi}
+% \end{macrocode}
+%
+% Permit easy change of font size for unusual purpose, e.g., for
+% an author's ``life list'' in collected works. [bnb, 2004/04/01]
+% \begin{macrocode}
+\newcommand{\bibliofont}{\footnotesize}
+% \end{macrocode}
+%
+% \env{thebibliography} differs in some author packages only in the
+% shape of the title; make this easy to change. [bnb, 2004/05/22]
+% \begin{macrocode}
+\newcommand{\@bibtitlestyle}{%
+%<amsart|amsproc> \@xp\section\@xp*\@xp{\refname}%
+%<amsbook> \@xp\chapter\@xp*\@xp{\bibname}%
+}
+\newenvironment{thebibliography}[1]{%
+ \@bibtitlestyle
+ \normalfont\bibliofont\labelsep .5em\relax
+ \renewcommand\theenumiv{\arabic{enumiv}}\let\p@enumiv\@empty
+ \list{\@biblabel{\theenumiv}}{\settowidth\labelwidth{\@biblabel{#1}}%
+ \leftmargin\labelwidth \advance\leftmargin\labelsep
+ \usecounter{enumiv}}%
+ \sloppy \clubpenalty\@M \widowpenalty\clubpenalty
+ \sfcode`\.=\@m
+}{%
+% \end{macrocode}
+% Change error for empty list (no items) to warning, to allow authors
+% to leave their bibliography temporarily empty during writing:
+% \begin{macrocode}
+ \def\@noitemerr{\@latex@warning{Empty `thebibliography' environment}}%
+ \endlist
+}
+% \end{macrocode}
+%
+% The \cn{bysame} command prints a horizontal dash indicating
+% repetition of the author's name in consecutive bibliography
+% entries.
+% \begin{macrocode}
+\def\bysame{\leavevmode\hbox to3em{\hrulefill}\thinspace}
+% \end{macrocode}
+% We define \cn{newblock} even though it's not needed for AMS
+% publication style, just to avoid error messages when a non-AMS
+% \fn{.bst} file is used. This is a convenience for users; use of
+% \cn{newblock} is not recommended for submissions to the AMS.
+% \begin{macrocode}
+\def\newblock{}
+% \end{macrocode}
+%
+% \begin{macro}{\MR}
+% \begin{macro}{\MRhref}
+% Provide an MR number for a bibliography item. At the moment
+% [mjd,1995/08/07] this only prints the MR number, but later
+% we expect to extend it to write an HTML \cs{special} to the
+% \fn{.dvi} file.
+%
+% The presentation of the MR number has been simplified (from using
+% a bold volume number) coincident with the change in the MathSciNet
+% database to a 7-digit reference number from the volume:number form.
+%
+% Ensure that an old-style MR number does not break across lines if
+% it contains a space; editorial request. [bnb; 2004/04/01]
+% Countermanded, to permit break between reference number and an
+% old-style number following in parentheses. [bnb; 2004/06/11]
+% \begin{macrocode}
+\newcommand\MR[1]{\relax\ifhmode\unskip\spacefactor3000 \space\fi
+ MR~\MRhref{#1}{#1}}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\let\MRhref\@gobble
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\URL}
+% \begin{macro}{\URLhref}
+% \begin{macro}{\@URL}
+% Allows sticking in an arbitrary URL in a bibliography. Leading
+% ``http'' is not assumed. Call \cn{verb} to ensure that special
+% characters in the URL don't cause trouble.
+% \begin{macrocode}
+\newcommand\URL{\begingroup
+ \def\@sverb##1{%
+ \def\@tempa####1##1{\@URL{####1}\egroup\endgroup}%
+ \@tempa}%
+ \verb}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\let\URLhref\@gobble
+\def\@URL#1{\URLhref{#1}#1}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \subsection{Index section or chapter}
+%
+% Chapter or section heading for an index. Index is set up to be two
+% columns.
+% \begin{macrocode}
+\newif\if@restonecol
+% \end{macrocode}
+%
+% \begin{macrocode}
+%<*amsbook>
+\def\indexchap#1{\global\topskip 7.5pc\relax
+ \twocolumn[{\fontsize{\@xivpt}{18}\bfseries\centering
+ \vskip\topskip\hbox{}\vskip-\baselineskip% adjust top space
+ #1\par
+% \end{macrocode}
+% After \cs{twocolumn} finishes operating, the top material is left in an
+% insert register, and topskip will now be applied above the
+% following material. So we should set it to the normal
+% after-chapter-title space (34pt)---cf.~\cs{@makeschapterhead}.
+% \begin{macrocode}
+ \global\topskip 34\p@\relax
+ \ifx\@empty\indexintro
+ \else
+ \begingroup \normalsize
+ \skip@\topskip \advance\skip@ -\baselineskip
+ \vskip\skip@
+ \parbox[t]{24pc}{\normalfont\indexintro\par}%
+ \endgroup
+ \global\topskip 24\p@\relax
+ \fi
+ }]%
+}
+\newcommand{\indexintro}{}
+%</amsbook>
+% \end{macrocode}
+%
+% \env{theindex} differs in some author packages only in the
+% shape of the title; make this easy to change. [bnb, 2004/05/22]
+% \begin{macrocode}
+\newcommand{\@indextitlestyle}{%
+%<*amsbook>
+ \let\@makeschapterhead\indexchap
+ \@xp\chapter\@xp*\@xp{\indexname}%
+%</amsbook>
+%<amsart|amsproc> \twocolumn[\@xp\section\@xp*\@xp{\indexname}]%
+}
+\def\theindex{\@restonecoltrue\if@twocolumn\@restonecolfalse\fi
+ \columnseprule\z@ \columnsep 35\p@
+ \@indextitlestyle
+ \thispagestyle{plain}%
+ \let\item\@idxitem
+ \parindent\z@ \parskip\z@\@plus.3\p@\relax
+ \raggedright
+ \hyphenpenalty\@M
+ \footnotesize}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\indexname{Index}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\@idxitem{\par\hangindent 2em}
+\def\subitem{\par\hangindent 2em\hspace*{1em}}
+\def\subsubitem{\par\hangindent 3em\hspace*{2em}}
+\def\endtheindex{\if@restonecol\onecolumn\else\clearpage\fi}
+\def\indexspace{\par\bigskip}
+% \end{macrocode}
+%
+% \subsection{Footnotes}
+% In books the footnote counter should reset to 0 at the beginning of
+% each chapter:
+% \begin{macrocode}
+%<amsbook>\@addtoreset{footnote}{chapter}
+% \end{macrocode}
+%
+% Rule above footnotes is 5 picas wide.
+% \begin{macrocode}
+\def\footnoterule{\kern-.4\p@
+ \hrule\@width 5pc\kern11\p@\kern-\footnotesep}
+% \end{macrocode}
+%
+% A simple superscript doesn't work here; it fails on a minipage,
+% where \cs{itshape} (which is invalid in math mode) is used for the
+% footnote numbers. Cf.~ the definition of \cn{textprime}.
+% \begin{macrocode}
+\def\@makefnmark{%
+ \leavevmode
+ \raise.9ex\hbox{\fontsize\sf@size\z@\normalfont\@thefnmark}%
+}
+%
+\def\@makefntext{\indent\@makefnmark}
+% \end{macrocode}
+% Add \cn{normalfont} before \cn{footnotesize} so that
+% fonts will come out properly using the new font selection scheme.
+% \begin{macrocode}
+\long\def\@footnotetext#1{%
+ \insert\footins{%
+ \normalfont\footnotesize
+ \interlinepenalty\interfootnotelinepenalty
+ \splittopskip\footnotesep \splitmaxdepth \dp\strutbox
+ \floatingpenalty\@MM \hsize\columnwidth
+% \end{macrocode}
+% Mostly \cs{@parboxrestore} does what we want; but not with
+% respect to \cs{parindent} and \cs{tolerance}.
+% \begin{macrocode}
+ \@parboxrestore \parindent\normalparindent \sloppy
+ \protected@edef\@currentlabel{%
+ \csname p@footnote\endcsname\@thefnmark}%
+ \@makefntext{%
+ \rule\z@\footnotesep\ignorespaces#1\unskip\strut\par}}}
+% \end{macrocode}
+% We change \cn{sloppy} to keep it from overriding our normal value of
+% 1pt for \cs{hfuzz} and \cs{vfuzz} with a LESS sloppy value (.5pt).
+% \begin{macrocode}
+\hfuzz=1pt \vfuzz=\hfuzz
+\def\sloppy{\tolerance9999 \emergencystretch 3em\relax}
+% \end{macrocode}
+%
+% \subsection{Float placement parameters}
+% These control the placing of floating objects like tables and
+% figures. We use much more tolerant values than the \latex/ defaults;
+% the \latex/ defaults are geared to fussier page breaks, at a price of
+% requiring more manual intervention to deal with difficult page
+% breaking problems.
+%
+% When using \latex/'s twocolumn option, `page' really means `column',
+% for the parameters that don't have a dbl prefix: that is, topnumber
+% is then the maximum number of top figures allowed in each column,
+% and so forth.
+% \begin{description}
+% \item[topnumber] maximum number of top figures allowed per page
+% \item[bottomnumber] maximum number of bottom figures allowed per page
+% \item[totalnumber] maximum number of figures (top and bottom) allowed
+% per page
+% \item[dbltopnumber] same as topnumber, but for two-column wide
+% figures, when double-column format is used
+% \end{description}
+% \begin{macrocode}
+\setcounter{topnumber}{4}
+\setcounter{bottomnumber}{4}
+\setcounter{totalnumber}{4}
+\setcounter{dbltopnumber}{4}
+% \end{macrocode}
+% Float fraction parameters.
+% \begin{description}
+% \item[\cs{topfraction}] maximum part of the page allowed for top
+% figures, expressed as a decimal fraction. The value of .97 means
+% roughly `accept pages that have only two lines of text, and the
+% rest figures'.
+% \item[\cs{bottomfraction}] same as \cs{topfraction}, but for bottom
+% figures
+% \item[\cs{textfraction}] \emph{minimum} part of the page that must be
+% occupied by text, if the page is to have any text at all. If this
+% value cannot be achieved, \latex/ will turn the current figure or
+% figures into a ``float page'', i.e., a page of figures without any
+% text.
+% \item[\cs{floatpagefraction}] minimum amount (that is, total combined
+% height) of figures needed before \latex/ will make a float page. This
+% is expressed as a fraction of the normal page height.
+% \item[\cs{dbltopfraction}] like \cs{topfraction}, but applies only to
+% figures that are two columns wide, when double-column format is
+% used.
+% \item[\cs{dblfloatpagefraction}] minimum amount of double-column
+% figure material needed before \latex/ will make a two-column wide
+% ``float page''
+% \end{description}
+% \begin{macrocode}
+\renewcommand{\topfraction}{.97}
+\renewcommand{\bottomfraction}{.97}
+\renewcommand{\textfraction}{.03}
+\renewcommand{\floatpagefraction}{.9}
+\renewcommand{\dbltopfraction}{.97}
+\renewcommand{\dblfloatpagefraction}{.9}
+% \end{macrocode}
+%
+% We also modify the default values for spacing around floating
+% figures: (A) so that figures on a float page will not be
+% vertically centered on the total page height but will
+% be flush at the top of the page, and (B) so that there will
+% be slightly more stretchability around figures, to help find better
+% page breaks in difficult situations.
+%
+% \begin{description}
+% \item[\cs{floatsep}] Space between consecutive figures
+% \item[\cs{textfloatsep}] Space between text and top or bottom figures
+% \item[\cs{intextsep}] Space above and below a figure in the middle of
+% the text (i.e., placed with the |[h]| option)
+% \item[\cs{dblfloatsep}] Space between consecutive figures that are
+% two columns wide (when two-column format is used)
+% \item[\cs{dbltextfloatsep}] Space between double-column figures and text
+% \item[\cs{@fptop}] Space above the first figure on a float page
+% \item[\cs{@fpsep}] Space between figures on a float page
+% \item[\cs{@fpbot}] Space below the last figure on a float page
+% \item[\cs{@dblfptop}] Space above the first double-column figure on a
+% two-column wide float page
+% \item[\cs{@dblfptop}] Space between double-column figures on a two-column
+% wide float page
+% \item[\cs{@dblfptop}] Space below the last double-column figure on a
+% two-column wide float page
+% \end{description}
+% \begin{macrocode}
+\setlength{\floatsep}{12pt plus 6pt minus 4pt}
+\setlength{\textfloatsep}{15pt plus 8pt minus 5pt}
+\setlength{\intextsep}{12pt plus 6pt minus 4pt}
+\setlength{\dblfloatsep}{12pt plus 6pt minus 4pt}
+\setlength{\dbltextfloatsep}{15pt plus 8pt minus 5pt}
+\setlength{\@fptop}{0pt}% removed "plus 1fil"
+\setlength{\@fpsep}{8pt}% removed "plus 2fil"
+\setlength{\@fpbot}{0pt plus 1fil}
+\setlength{\@dblfptop}{0pt}% removed "plus 1fil"
+\setlength{\@dblfpsep}{8pt}% removed "plus 2fil"
+\setlength{\@dblfpbot}{0pt plus 1fil}
+% \end{macrocode}
+%
+% \cs{fps@figure}, \cs{fps@table}: placement specifications for
+% \env{figure} and \env{table} environments. `|tbp|' means that a
+% figure will be placed at the top or bottom of a page, or on a
+% separate page with no text. This might be changed to `|tp|', for
+% example, if you never want figures to appear at the bottom of a
+% page.
+% \begin{macrocode}
+\newcommand{\fps@figure}{tbp}
+\newcommand{\fps@table}{tbp}
+% \end{macrocode}
+%
+% Some more setup for figures.
+% \begin{macrocode}
+%<amsart|amsproc>\newcounter{figure}
+%<amsbook>\newcounter{figure}[chapter]
+\def\@captionheadfont{\scshape}
+\def\@captionfont{\normalfont}
+\def\ftype@figure{1}
+\def\ext@figure{lof}
+\def\fnum@figure{\figurename\ \thefigure}
+\def\figurename{Figure}
+\newenvironment{figure}{%
+ \@float{figure}%
+}{%
+ \end@float
+}
+\newenvironment{figure*}{%
+ \@dblfloat{figure}%
+}{%
+ \end@dblfloat
+}
+% \end{macrocode}
+% And similar for tables.
+% \begin{macrocode}
+%<amsart|amsproc>\newcounter{table}
+%<amsbook>\newcounter{table}[chapter]
+\def\ftype@table{2}
+\def\ext@table{lot}
+\def\fnum@table{\tablename\ \thetable}
+\def\tablename{Table}
+\newenvironment{table}{%
+ \@float{table}%
+}{%
+ \end@float
+}
+\newenvironment{table*}{%
+ \@dblfloat{table}%
+}{%
+ \end@dblfloat
+}
+% \end{macrocode}
+%
+% Change \cs{@floatboxreset} to add \cn{centering}. Centering is
+% always applied to tables and figures in AMS publications. It should
+% not be necessary to throw in |\begin{center}| \ldots |\end{center}|
+% in every instance to achieve this.
+% \begin{macrocode}
+\def\@floatboxreset{\global\@minipagefalse \centering}
+% \end{macrocode}
+%
+% This is what we want \cs{@makecaption} to do: If the total width is
+% greater than normal columnwidth we want to break the caption into
+% lines using a line width of $W$ = (columnwidth $-$ 6pc), and center
+% the resulting block between the margins. Otherwise we want to set
+% the caption as a single line, centered between the margins.
+%
+% To do this we set the caption as a vbox with line width $W$,
+% except that we allow the last line (which may be the only line) to
+% have width up to full columnwidth by adding a kern of -6pc. If the
+% result is a single hbox (i.e., a single line) we need to unpack the
+% hbox, remove rightskip, parfillskip, and the -6pc kern, and center
+% the remaining material. If the caption is more than one line, then
+% box 1 contains the last line, which we need to unpack in the same
+% way, and run through the paragraphing process again (because this
+% last line may be up to 6 picas wider than the desired width).
+%
+% In practice this procedure tends to fail if there are any potential
+% breakpoints near the end of the first line (in the window between
+% short-width and full-width). Then \TeX{} tends to choose a break
+% (depending on spaceskip, tolerance, etc) at the last acceptable
+% breakpoint before short-width is exceeded, \emph{without
+% considering any later material}---in particular, the negative kern.
+% [This was pointed out by Donald Arseneau, May 2000.] Unfortunately,
+% setting parfillskip to a negative value does not work either. I
+% guess this is a special case of the existing limitation on
+% parshape: you cannot specify a parshape in terms of number of lines
+% from the bottom of the paragraph. (We would like to specify a
+% parshape where the last line is 6 picas longer than the others.)
+%
+% Finally, if the caption is for a figure, it will be set below the
+% figure, so the separating space goes above the caption; otherwise
+% the separating space goes below the caption.
+% \begin{macrocode}
+\long\def\@makecaption#1#2{%
+% \end{macrocode}
+% Measure the contents of the caption. If \arg{2} is not
+% empty, then we must add a period and an en-space before
+% typesetting it. The \cs{@caption} macro adds an extra
+% \cn{ignorespaces} at the beginning of \arg{2}, so in order
+% to find out if the user-typed portion is empty we use
+% \cs{@cdr} to pull off the \cn{ignorespaces}.
+% \begin{macrocode}
+% Use color-safe commands
+ \setbox\@tempboxa\vbox{\color@setgroup
+ \advance\hsize-2\captionindent\noindent
+ \@captionfont\@captionheadfont#1\@xp\@ifnotempty\@xp
+ {\@cdr#2\@nil}{.\@captionfont\upshape\enspace#2}%
+ \unskip\kern-2\captionindent\par
+ \global\setbox\@ne\lastbox\color@endgroup}%
+ \ifhbox\@ne % the normal case
+ \setbox\@ne\hbox{\unhbox\@ne\unskip\unskip\unpenalty\unkern}%
+ \fi
+% \end{macrocode}
+% If \cs{@tempboxa} is not empty at this point then the caption was
+% more than one line long or there was extra vertical mode material,
+% maybe a \cs{write} (from \cn{index} or something).
+% Interestingly, we can't use \cs{ifvoid} to see if
+% \cs{@tempboxa} is empty, because empty is not the same thing
+% as void (as far as the \cs{ifvoid} test is concerned). So
+% instead we measure the width of \cs{@tempboxa}
+% to see if it's zero; this should suffice for non-bizarre cases.
+% \begin{macrocode}
+ \ifdim\wd\@tempboxa=\z@ % this means caption will fit on one line
+ \setbox\@ne\hbox to\columnwidth{\hss\kern-2\captionindent\box\@ne\hss}%
+ \else % tempboxa contained more than one line
+ \setbox\@ne\vbox{\unvbox\@tempboxa\parskip\z@skip
+ \noindent\unhbox\@ne\advance\hsize-2\captionindent\par}%
+ \fi
+ \ifnum\@tempcnta<64 % if the float IS a figure...
+ \addvspace\abovecaptionskip
+ \hbox to\hsize{\kern\captionindent\box\@ne\hss}%
+ \else % if the float IS NOT a figure...
+ \hbox to\hsize{\kern\captionindent\box\@ne\hss}%
+ \nobreak
+ \vskip\belowcaptionskip
+ \fi
+\relax
+}
+% \end{macrocode}
+% Allocate the skip registers for above and below caption space.
+% \begin{macrocode}
+\newskip\abovecaptionskip \abovecaptionskip=12pt \relax
+\newskip\belowcaptionskip \belowcaptionskip=12pt \relax
+\newdimen\captionindent \captionindent=3pc
+% \end{macrocode}
+%
+% \subsection{Miscellaneous}
+%
+% \begin{macro}{\nonbreakingspace}
+% Change \qc{\~} to be more forgiving of accidental adjacent spaces.
+% Note that this means multiple |~~~...| cannot be used to get
+% multiple spaces in the output.
+% \begin{macrocode}
+\def\nonbreakingspace{\unskip\nobreak\ \ignorespaces}
+\def~{\protect\nonbreakingspace}
+% \end{macrocode}
+% \end{macro}
+%
+% Redefine \cs{@biblabel} to do nothing if the argument is empty. We
+% don't really care what the previous definition was so we don't
+% check it.
+% \begin{macrocode}
+\def\@biblabel#1{\@ifnotempty{#1}{[#1]}}
+% \end{macrocode}
+% Changed \cs{@cite} to always use roman/upright, nonbold font, even
+% in italic or bold text (following AMS style).
+% Turn off \cs{mathsurround} just in case there are subscripts in the
+% cite numbers.
+% \begin{macrocode}
+\def\@citestyle{\m@th\upshape\mdseries}
+%<amsart>\let\citeform\@firstofone
+%<amsbook|amsproc>\def\citeform#1{{\bfseries#1}}
+\def\@cite#1#2{{%
+ \@citestyle[\citeform{#1}\if@tempswa, #2\fi]}}
+% \end{macrocode}
+%
+% Make \cn{cite} robust if it isn't already. Too many unsuspecting
+% users get problems from this in a figure or table caption.
+% \begin{macrocode}
+\@ifundefined{cite }{%
+ \expandafter\let\csname cite \endcsname\cite
+ \edef\cite{\@nx\protect\@xp\@nx\csname cite \endcsname}%
+}{}
+% \end{macrocode}
+%
+% \begin{macro}{\fullwidthdisplay}
+% The function \cs{fullwidthdisplay} makes a displayed equation take
+% up the full column width even if the current context is an indented
+% list.
+% \begin{macrocode}
+\def\fullwidthdisplay{\displayindent\z@ \displaywidth\columnwidth}
+% \end{macrocode}
+% And we insert the \cs{fullwidthdisplay} function at the beginning of
+% \cs{everydisplay} just in case any later code in \cs{everydisplay}
+% needs to use the values of \cs{displayindent} or \cs{displaywidth}.
+% \begin{macrocode}
+\edef\@tempa{\noexpand\fullwidthdisplay\the\everydisplay}
+\everydisplay\expandafter{\@tempa}
+% \end{macrocode}
+% \end{macro}
+%
+% A few odds and ends for indexes, based on \pkg{makeindex}. The
+% definition of \cn{see} as ``see also'' is unfortunate, but of
+% long standing, and cannot be changed without destroying backward
+% compatibility, so an alternate command, \cn{seeonly}, is provided
+% to cover the basic situation.
+% \begin{macrocode}
+\newcommand*\seeonlyname{see}
+\newcommand*\seename{see also}
+\newcommand*\alsoname{see also}
+\newcommand*\seeonly[2]{\emph{\seeonlyname} #1}
+\newcommand*\see[2]{\emph{\seename} #1}
+\newcommand*\seealso[2]{\emph{\alsoname} #1}
+\newcommand\printindex{\@input{\jobname.ind}}
+% \end{macrocode}
+%
+% \begin{macro}{\textprime}
+% A text prime symbol, for applying primes to numbers such as list
+% numbers or equation numbers that are not really math. Furthermore
+% Cyrillic myagkii znak, or soft sign, is represented by a prime
+% symbol in Russian names when they are transliterated into English.
+%
+% \cn{textprime} uses the prime symbol from math, but because it's
+% intended specifically for nonmath use, we avoid going through math
+% mode with \verb'$...$'. We must therefore call \cs{check@mathfonts}
+% to ensure that \verb'scriptfont2' is actually defined. Otherwise,
+% if \cn{textprime} were used in a document before the first math
+% formula, there would be no adequate assignment yet for
+% \verb'\scriptfont2'.
+%
+% The raise value of \verb'.8ex' is just a reasonable guess at making
+% the bottom of the prime symbol fall near the top of a preceding
+% lowercase letter but still not fall too low on an uppercase letter.
+% We could look up the \cs{fontdimen} values used in math mode for
+% superscripts but I don't think it's worth the bother.
+%
+% Cf.~also the definition of \cs{@makefnmark}. The prime symbol here
+% is not raised quite so high because I think that is desirable for
+% the soft-sign usage.
+% \begin{macrocode}
+\DeclareRobustCommand\textprime{\leavevmode
+ \raise.8ex\hbox{\check@mathfonts\the\scriptfont2 \char48 }}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsection{Book style variations}
+% Here is the layout for a \cn{maketitle} in the \cls{amsbook} class.
+% \begin{macrocode}
+%<*amsbook>
+\def\maketitle{\par
+ \@topnum\z@ % this prevents figures from falling at the top of page 1
+ \begingroup
+ \@maketitle
+ \endgroup
+ \c@footnote\z@
+ \def\do##1{\let##1\relax}%
+ \do\maketitle \do\@maketitle \do\title \do\@xtitle \do\@title
+ \do\author \do\@xauthor \do\address \do\@xaddress
+ \do\email \do\@xemail \do\curraddr \do\@xcurraddr
+ \do\dedicatory \do\@dedicatory \do\thanks \do\thankses
+ \do\keywords \do\@keywords \do\subjclass \do\@subjclass
+}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\@maketitle{%
+ \cleardoublepage \thispagestyle{empty}%
+ \begingroup \topskip\z@skip
+ \null\vfil
+ \begingroup
+ \LARGE\bfseries \centering
+ \openup\medskipamount
+ \@title\par\vspace{24pt}%
+ \def\and{\par\medskip}\centering
+ \mdseries\authors\par\bigskip
+ \endgroup
+ \vfil
+ \ifx\@empty\addresses \else \@setaddresses \fi
+ \vfil
+ \ifx\@empty\@dedicatory
+ \else \begingroup
+ \centering{\footnotesize\itshape\@dedicatory\@@par}%
+ \endgroup
+ \fi
+ \vfill
+ \newpage\thispagestyle{empty}
+ \begin{center}
+ \ifx\@empty\@subjclass\else\@setsubjclass\fi
+ \ifx\@empty\@keywords\else\@setkeywords\fi
+ \ifx\@empty\@translators\else\vfil\@settranslators\fi
+ \ifx\@empty\thankses\else\vfil\@setthanks\fi
+ \end{center}
+ \vfil
+ \@setabstract
+ \endgroup}
+% \end{macrocode}
+%
+% Define the desired form for translator names.
+% \begin{macrocode}
+\def\@settranslators{\par
+ \begingroup
+ \translname: \andify\@translators \uppercasenonmath\@translators
+ \@translators \@@par
+ \endgroup}
+\def\@setdate{\par\smallskip\@date\par\smallskip}
+\def\@setsubjclass{\par\smallskip
+ {\itshape\subjclassname.}\enspace\@subjclass\par\smallskip}
+\def\@setkeywords{\par\smallskip
+ {\itshape \keywordsname.}\enspace \@keywords\par\smallskip}
+%</amsbook>
+%</classes>
+% \end{macrocode}
+%
+% \subsection{Setup for theorems, definitions, remarks, proofs}
+% \subsubsection{Intended usage}
+%
+% Here are some examples showing the kinds of theorem environment
+% declarations that are possible.
+%\begin{verbatim}
+% \newtheorem{prop}{Proposition}
+% \newtheorem{thm}{Theorem}[section]
+% \newtheorem{lem}[thm]{Lemma}
+% \newtheorem*{Zorn}{Zorn's Lemma}
+%
+% \theoremstyle{definition}
+% \newtheorem{dfn}{Definition}
+%
+% \theoremstyle{remark}
+% \newtheorem*{rmk}{Remark}
+%\end{verbatim}
+%
+% The first four statements all define environments using the default
+% theorem style (`plain'), since there is no prefatory
+% \cn{theoremstyle} declaration. The first statement defines an
+% automatically numbered \env{prop} environment whose headings will
+% look like this: Proposition 1, Proposition 2, and so forth. The
+% second statement defines an environment \env{thm} with numbers
+% subordinate to section numbers, so the headings will look like
+% this: Theorem 1.1, Theorem 1.2, Theorem 1.3, \dots, (in section 2:)
+% Theorem 2.1, Theorem 2.2, and so forth. The third statement defines
+% a \env{lem} environment whose numbers will interleave in sequence
+% with the theorem numbers: Theorem 1.3, Lemma 1.4, Lemma 1.5,
+% Theorem 1.6, and so forth. The fourth statement defines a special
+% unnumbered lemma named `Zorn's Lemma'. The remaining two
+% \cn{newtheorem} statements have no special features except for the
+% \cn{theoremstyle} declarations that cause the \env{dfn} and
+% \env{rmk} environments to have some differences in appearance.
+%
+% There are three basic styles provided: The `plain' style produces
+% bold headings and italic body text; the `definition' style produces
+% bold headings and normal body text; the `remark' style produces
+% italic headings and normal body text.
+%
+% A \cn{swapnumbers} command allows theorem numbers to be swapped to
+% the front of the theorem headings. Putting \cn{swapnumbers} in your
+% document preamble will cause \emph{all following} \cn{newtheorem}
+% statements to produce number-first headings. (To provide maximum
+% control, \cn{swapnumbers} is designed so that it can be used more
+% than once; each time it is used, theorem numbers will be swapped to
+% the opposite side for all following \cn{newtheorem} statements. But
+% rarely will it need to be invoked more than once per document.)
+%
+% \subsubsection{Custom theorem styles}
+% There is a \cn{newtheoremstyle} command provided to make the
+% creation of custom theoremstyles fairly easy.
+%
+% Usage:
+%\begin{verbatim}
+% #1
+% \newtheoremstyle{NAME}%
+% #2 #3 #4
+% {ABOVESPACE}{BELOWSPACE}{BODYFONT}%
+% #5 #6 #7 #8
+% {INDENT}{HEADFONT}{HEADPUNCT}{HEADSPACE}%
+% #9
+% {CUSTOM-HEAD-SPEC}
+%\end{verbatim}
+% Leaving the `indent' argument empty is equivalent to entering
+% |0pt|. The `headpunct' and `headspace' arguments are for the
+% punctuation and horizontal space between the theorem head and the
+% following text. There are two special values that may be used for
+% `headspace': a single space means that a normal interword space
+% should be used; ``\cn{newline}'' means that there should be a line
+% break after the head instead of horizontal space. The
+% `custom-head-spec' argument follows a special convention: it is
+% interpreted as the replacement text for an internal three-argument
+% function \cn{thmhead}, i.e., as if you were defining
+%\begin{verbatim}
+% \renewcommand{\thmhead}[3]{...#1...#2...#3...}
+%\end{verbatim}
+% but omitting the initial |\renewcommand{\thmhead}[3]|. The three
+% arguments that will be supplied to \cn{thmhead} are the name,
+% number, and optional note components. Within the replacement text
+% you can (and normally will want to) use other special functions
+% \cn{thmname}, \cn{thmnumber}, and \cn{thmnote}. These will print
+% their argument if and only if the corresponding argument of
+% \cn{thmhead} is nonempty. For example
+%\begin{verbatim}
+% {\thmname{#1}\thmnumber{ #2}\thmnote{ (#3)}}
+%\end{verbatim}
+% This would cause the theorem note \arg{3} to be printed with a
+% preceding space and enclosing parentheses, if it is present, and if
+% it is absent, the space and parentheses will be omitted because
+% they are inside the argument of \cn{thmnote}.
+%
+% Finally, if you have an extra bit of arbitrary code that you want
+% to slip in somewhere, the best place to do it is in the `body font'
+% argument.
+%
+% The \cn{newtheoremstyle} command is designed to provide, through a
+% relatively simple interface, control over the style aspects that
+% are most commonly changed. More complex requirements must be
+% addressed through a separate \latex/ package.
+%
+% When you set up custom theorem styles with \cn{newtheoremstyle} you
+% should not use \cn{swapnumbers}. You have full control of the
+% ordering of elements in the theorem head, just place them where you
+% want. Or, if you do use \cn{swapnumbers}, you must look at the
+% definition of \cs{swappedhead} and change it appropriately.
+
+% \subsubsection{Implementation}
+% The \cn{theoremstyle} command is very simple except for the need to
+% warn about an unknown theoremstyle.
+% \begin{macrocode}
+%<*amsthm|classes>
+\newcommand{\theoremstyle}[1]{%
+ \@ifundefined{th@#1}{%
+ \PackageWarning{amsthm}{Unknown theoremstyle `#1'}%
+ \thm@style{plain}%
+ }{%
+ \thm@style{#1}%
+ }%
+}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\newtoks\thm@style
+\thm@style{plain}
+% \end{macrocode}
+%
+% What's really needed is a full-fledged systematic approach for
+% specifying the desired order and formatting of the three identified
+% parts of a theorem head (name, number, note).
+% \begin{macrocode}
+\newtoks\thm@bodyfont \thm@bodyfont{\itshape}
+\newtoks\thm@headfont \thm@headfont{\bfseries}
+\newtoks\thm@notefont \thm@notefont{}
+\newtoks\thm@headpunct \thm@headpunct{.}
+% \end{macrocode}
+% Vertical spacing: initialize to current value of \cs{topsep}.
+% If a document class loads the \pkg{amsthm} package it
+% should take care to set these variables explicitly, if current
+% \cs{topsep} is not the desired value.
+% \begin{macrocode}
+\newskip\thm@preskip \newskip\thm@postskip
+%<*classes>
+\def\thm@space@setup{%
+ \thm@preskip=.5\baselineskip\@plus.2\baselineskip
+ \@minus.2\baselineskip
+ \thm@postskip=\thm@preskip
+}
+%</classes>
+%<*amsthm>
+\def\thm@space@setup{%
+ \thm@preskip=\topsep \thm@postskip=\thm@preskip
+}
+%</amsthm>
+% \end{macrocode}
+% Modify \cn{newtheorem} to add |*| option. If a |*| is found, pass
+% it on to \cs{@xnthm} as the first argument. (This information
+% enables us to handle two different possibilities in a single
+% function \cs{@xnthm} instead of needing two separate functions.)
+% \begin{macrocode}
+\renewcommand{\newtheorem}{\@ifstar{\@xnthm *}{\@xnthm \relax}}
+% \end{macrocode}
+%
+% Check to see if an optional arg is present after the first
+% mandatory arg (which is \arg{2} at the moment since the |*| or
+% non-|*| is \arg{1}).
+% \begin{macrocode}
+\def\@xnthm#1#2{%
+ \let\@tempa\relax
+ \@xp\@ifdefinable\csname #2\endcsname{%
+ \global\@xp\let\csname end#2\endcsname\@endtheorem
+ \ifx *#1% unnumbered, need to get one more mandatory arg
+ \edef\@tempa##1{%
+ \gdef\@xp\@nx\csname#2\endcsname{%
+ \@nx\@thm{\@xp\@nx\csname th@\the\thm@style\endcsname}%
+ {}{##1}}}%
+ \else % numbered theorem, need to check for optional arg
+ \def\@tempa{\@oparg{\@ynthm{#2}}[]}%
+ \fi
+ }%
+ \@tempa
+}
+% \end{macrocode}
+%
+% Environment numbered together with a previously defined
+% environment.
+%
+% Arg1: env name, e.g. `thm'\par
+% Arg2: optional sibling counter\par
+% Arg3: heading text e.g. `Theorem'
+% \begin{macrocode}
+\def\@ynthm#1[#2]#3{%
+% \end{macrocode}
+% If optional arg \arg{2} is empty, call \cs{@xthm} to look for a
+% possible optional arg in terminal position. Note that
+% the two optional args are mutually exclusive. As \arg{2} is a
+% counter name and must be processed by \cs{csname} anyway,
+% we can use a simpler test instead of \cs{@ifempty}.
+% \begin{macrocode}
+ \ifx\relax#2\relax
+ \def\@tempa{\@oparg{\@xthm{#1}{#3}}[]}%
+ \else
+ \@ifundefined{c@#2}{%
+ \def\@tempa{\@nocounterr{#2}}%
+ }{%
+ \@xp\xdef\csname the#1\endcsname{\@xp\@nx\csname the#2\endcsname}%
+ \toks@{#3}%
+ \@xp\xdef\csname#1\endcsname{%
+ \@nx\@thm{%
+ \let\@nx\thm@swap
+ \if S\thm@swap\@nx\@firstoftwo\else\@nx\@gobble\fi
+ \@xp\@nx\csname th@\the\thm@style\endcsname}%
+ {#2}{\the\toks@}}%
+ \let\@tempa\relax
+ }%
+ \fi
+ \@tempa
+}
+% \end{macrocode}
+%
+% Environment numbered relative to the counter given as \arg{3}. This
+% function should really be named \cs{@znthm} but we're trying to
+% save a bit of hash table and string pool by reusing one of the
+% command names rendered obsolete by the \pkg{amsthm} package.
+%
+% Arg1: env name e.g. `thm';
+% Arg2: heading text e.g. `Theorem';
+% Arg3: parent counter e.g. section.
+% \begin{macrocode}
+\def\@xthm#1#2[#3]{%
+% \end{macrocode}
+% Set up the counter \verb'c@#1' and optionally add it to the reset
+% list of counter \arg{3}. As \arg{3} is a
+% counter name and must be processed by \cs{csname} anyway,
+% we can use a simpler test instead of \cs{@ifempty}.
+% \begin{macrocode}
+ \ifx\relax#3\relax
+ \newcounter{#1}%
+ \else
+ \newcounter{#1}[#3]%
+% \end{macrocode}
+% Define \cn{thexxx} to be \verb'\theyyy.\arabic{xxx}' (assuming
+% default values of punctuation and numbering style). The use of
+% \cs{xdef} here is inherited from the old \latex/ code, I'm not
+% sure it's a good idea in general, but there should not be any
+% problems unless someone changes the value of \cs{@thmcountersep} or
+% \cs{@thmcounter}.
+% \begin{macrocode}
+ \@xp\xdef\csname the#1\endcsname{\@xp\@nx\csname the#3\endcsname
+ \@thmcountersep\@thmcounter{#1}}%
+ \fi
+ \toks@{#2}%
+ \@xp\xdef\csname#1\endcsname{%
+ \@nx\@thm{%
+ \let\@nx\thm@swap
+ \if S\thm@swap\@nx\@firstoftwo\else\@nx\@gobble\fi
+ \@xp\@nx\csname th@\the\thm@style\endcsname}%
+ {#1}{\the\toks@}}%
+}
+% \end{macrocode}
+%
+% [mjd,1999/10/13] The following code doesn't handle the case where
+% an equation is immediately followed by a theorem with no
+% intervening \cs{par}---then the spacefactor is 1000.
+% \begin{macrocode}
+% % \def\thm@check@break{%
+% % \ifhmode \unskip \unskip
+% % \edef\pre@thm@spacefactor{\the\spacefactor}\par
+% % \edef\thm@topbreak{%
+% % \ifnum\pre@thm@spacefactor<\sfcode`\!\relax
+% % % preceding text line did not end with end-of-sentence punctuation
+% % \ifnum\prevgraf=\@ne \penalty\widowpenalty
+% % \else \penalty9999\relax
+% % \fi
+% % \else
+% % \@nx\addpenalty{\@beginparpenalty}%
+% % \fi
+% % }%
+% % \else
+% % \def\thm@topbreak{\addpenalty\@beginparpenalty}%
+% % \fi
+% % }
+% \end{macrocode}
+%
+% If arg \arg{2} is empty, this is an unnumbered environment;
+% otherwise \arg{2} is the name of a counter. \arg{3} is descriptive
+% name such as ``Theorem'' or ``Lemma''. Arg \arg{1} is the style
+% function, for example \cs{th@plain}.
+% \begin{macrocode}
+\def\@thm#1#2#3{%
+ \ifhmode\unskip\unskip\par\fi
+ \normalfont
+ \trivlist
+% \end{macrocode}
+% Explicitly set plain style here, then override parts as necessary
+% in the function provided as \arg{1}.
+% \begin{macrocode}
+ \let\thmheadnl\relax
+ \let\thm@swap\@gobble
+%<amsart> \let\thm@indent\noindent % no indent
+%<amsart> \thm@headfont{\bfseries}% heading font bold
+%<amsbook|amsproc> \let\thm@indent\indent % indent
+%<amsbook|amsproc> \thm@headfont{\scshape}% heading font small caps
+ \thm@notefont{\fontseries\mddefault\upshape}%
+ \thm@headpunct{.}% add period after heading
+ \thm@headsep 5\p@ plus\p@ minus\p@\relax
+ \thm@space@setup
+ #1% style overrides
+ \@topsep \thm@preskip % used by thm head
+ \@topsepadd \thm@postskip % used by \@endparenv
+ \def\@tempa{#2}\ifx\@empty\@tempa
+ \def\@tempa{\@oparg{\@begintheorem{#3}{}}[]}%
+ \else
+ \refstepcounter{#2}%
+ \def\@tempa{\@oparg{\@begintheorem{#3}{\csname the#2\endcsname}}[]}%
+ \fi
+ \@tempa
+}
+% \end{macrocode}
+%
+% The internal function \cs{@restorelabelsep} starts out as a no-op.
+% I don't think this is needed any more [mjd,2000/10/26].
+% \begin{macrocode}
+\def\@restorelabelsep{\relax}
+% \end{macrocode}
+%
+% This variation of the \cs{@thm} command is no longer needed. The
+% variation \cs{@xthm} was commandeered for \cn{newtheorem} use.
+% \begin{macrocode}
+\let\@ythm\relax
+% \end{macrocode}
+%
+% Init \cn{thmname} etc.
+% \begin{macrocode}
+\let\thmname\@iden \let\thmnote\@iden \let\thmnumber\@iden
+% \end{macrocode}
+%
+% \begin{macro}{\@upn}
+% The function \cs{\@upn} is used to force theorem numbers and
+% similar elements to be upright even when the current font is
+% italic. If a suitable italic font with upright numbers and
+% punctuation is available, this function should be redefined to be a
+% no-op.
+% \begin{macrocode}
+\providecommand\@upn{\textup}
+% \end{macrocode}
+% \end{macro}
+%
+% Definitions for theorem heads.
+% \begin{macrocode}
+\def\thmhead@plain#1#2#3{%
+% \end{macrocode}
+% To allow for the case where the thmname part is empty and the
+% heading consists only of a number (don't laugh, we have
+% examples from real mathematical manuscripts), we don't add the
+% space at the beginning of thmnumber unless \arg{1} is nonempty.
+% \begin{macrocode}
+ \thmname{#1}\thmnumber{\@ifnotempty{#1}{ }\@upn{#2}}%
+% \end{macrocode}
+% In thmnote we always add a leading space, i.e., assuming that
+% at least one of the preceding parts will always be present.
+% \begin{macrocode}
+ \thmnote{ {\the\thm@notefont(#3)}}}
+\let\thmhead\thmhead@plain
+% \end{macrocode}
+% Swappedhead is for the case where the number precedes the
+% word "Theorem". When the numbers fall on the left, like section
+% numbers, AMS journal style calls for them to be lightface. We get
+% this by invoking \cs{@secnumfont}.
+%
+% In handling the punctuation after the number we have to step
+% delicately if we want to successfully handle cases where the
+% theorem name is empty (this is very rare, yet it sometimes arises
+% in practice).
+% \begin{macrocode}
+\def\swappedhead#1#2#3{%
+%<amsthm> \thmnumber{#2}%
+%<amsthm> \thmname{\@ifnotempty{#2}{~}#1}%
+%<classes> \thmnumber{\@upn{\@secnumfont#2\@ifnotempty{#1}{.~}}}%
+%<classes> \thmname{#1}%
+ \thmnote{ {\the\thm@notefont(#3)}}}
+% \end{macrocode}
+%
+% A customized definition of \cs{th@plain} written for version 1.x of
+% the \pkg{amsthm} package might refer to \cs{swappedhead@plain}; this
+% gives it a definition for backward compatibility.
+% \begin{macrocode}
+\let\swappedhead@plain=\swappedhead
+% \end{macrocode}
+%
+% In \cs{@begintheorem} \cn{thmheadnl} is called after the theorem
+% head: maybe a newline, otherwise a no-op.
+% \begin{macrocode}
+\let\thmheadnl\relax
+\let\thm@indent\noindent
+\let\thm@swap\@gobble
+% \end{macrocode}
+%
+% If argument \arg{2} is empty, then this is an unnumbered
+% environment. Otherwise \arg{2} is a numbering command such as
+% \cn{thexyz}. We use \cs{deferred@thm@head} instead of \cs{item} in
+% order to allow line breaking in the optional note argument.
+% \begin{macrocode}
+\def\@begintheorem#1#2[#3]{%
+ \deferred@thm@head{\the\thm@headfont \thm@indent
+% \end{macrocode}
+% Changes to \cs{thmnumber} and \cs{thmnote} are local to the
+% containing box.
+% \begin{macrocode}
+ \@ifempty{#1}{\let\thmname\@gobble}{\let\thmname\@iden}%
+ \@ifempty{#2}{\let\thmnumber\@gobble}{\let\thmnumber\@iden}%
+ \@ifempty{#3}{\let\thmnote\@gobble}{\let\thmnote\@iden}%
+% \end{macrocode}
+% The \cs{thm@swap} function selects either \cs{swappedhead} or
+% \cs{thmhead}.
+% \begin{macrocode}
+ \thm@swap\swappedhead\thmhead{#1}{#2}{#3}%
+% \end{macrocode}
+% I can't think of any example where the after-head punctuation
+% should be omitted so it seems correct not to use \cs{@addpunct}
+% here.
+% \begin{macrocode}
+ \the\thm@headpunct
+% \end{macrocode}
+% If this \emph{is} a newline (from a \cn{newtheoremstyle}), it
+% gets lost if there isn't any text following the heading, since
+% \cs{deferred@thm@head} packs the heading into an hbox with
+% \cs{sbox}\cs{@labels}. Attempting to move the \cs{thmheadnl}
+% outside the scope of \cs{deferred@thm@head} (just outside the
+% ending brace below) results in no improvement if no text follows
+% the heading, and where there is text, runs it in. Inserting a
+% space following such a heading results in an extra blank line.
+% [bnb, 2004/06/30]
+% \begin{macrocode}
+ \thmheadnl % possibly a newline.
+ \hskip\thm@headsep
+ }%
+ \ignorespaces}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\newskip\thm@headsep
+\thm@headsep=5pt plus1pt minus1pt\relax
+% \end{macrocode}
+%
+% \begin{macrocode}
+\let\adjust@parskip@nobreak=\@nbitem
+% \end{macrocode}
+%
+% \begin{macrocode}
+\newtoks\dth@everypar
+\dth@everypar={%
+ \@minipagefalse \global\@newlistfalse
+ \@noparitemfalse
+ \if@inlabel
+ \global\@inlabelfalse
+ \begingroup \setbox\z@\lastbox
+ \ifvoid\z@ \kern-\itemindent \fi
+ \endgroup
+ \unhbox\@labels
+ \fi
+ \if@nobreak \@nobreakfalse \clubpenalty\@M
+ \else \clubpenalty\@clubpenalty \everypar{}%
+ \fi
+}%
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\deferred@thm@head#1{%
+ \if@inlabel \indent \par \fi % eject a section head if one is pending
+ \if@nobreak
+% \end{macrocode}
+% This case normally arises when a theorem follows immediately after
+% a section head. Then we leave the below-section-head space instead
+% of adding above-theorem space; but some adjustment of parskip is
+% needed.
+% \begin{macrocode}
+ \adjust@parskip@nobreak
+ \else
+ \addpenalty\@beginparpenalty
+ \addvspace\@topsep
+ \addvspace{-\parskip}%
+ \fi
+ \global\@inlabeltrue
+ \everypar\dth@everypar
+ \sbox\@labels{\normalfont#1}%
+ \ignorespaces
+}
+% \end{macrocode}
+%
+% \begin{macro}{\nonslanted}
+% The \cn{nonslanted} command changes the current font to
+% \cn{upshape} if it is \cn{itshape} or \cn{slshape}. This is used
+% for document structure numbers that should be consistently upright
+% in all contexts.
+% \begin{macrocode}
+\def\nonslanted{\relax
+% \end{macrocode}
+% Can't do a direct \cs{ifx} between \cs{f@shape} and \cs{itdefault}
+% because the latter is \cs{long} (grumble grumble).
+% \begin{macrocode}
+ \@xp\let\@xp\@tempa\csname\f@shape shape\endcsname
+ \ifx\@tempa\itshape\upshape
+ \else\ifx\@tempa\slshape\upshape\fi\fi}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\swapnumbers}
+% The \cn{swapnumbers} command sets a switch \cs{thm@swap} that is
+% used by \cn{newtheorem}. To conserve hash table we load
+% \cs{thm@swap} with two uses; the first one is needed only in
+% \cn{newtheorem} declarations and the second one is needed only in
+% typesetting theorem environments.
+% \begin{macrocode}
+\def\swapnumbers{\edef\thm@swap{\if S\thm@swap N\else S\fi}}
+\def\thm@swap{N}%
+% \end{macrocode}
+% \end{macro}
+%
+% \cs{@opargbegintheorem} not needed, \cs{@oparg} utility serves
+% instead.
+% \begin{macrocode}
+\let\@opargbegintheorem\relax
+% \end{macrocode}
+%
+% Except for the body font, default values are built into \cs{@thm}.
+% \begin{macrocode}
+\def\th@plain{%
+%% \let\thm@indent\noindent % no indent
+%% \thm@headfont{\bfseries}% heading font is bold
+%% \thm@notefont{}% same as heading font
+%% \thm@headpunct{.}% add period after heading
+%% \let\thm@swap\@gobble
+%% \thm@preskip\topsep
+%% \thm@postskip\theorempreskipamount
+ \itshape % body font
+}
+% \end{macrocode}
+%
+% Theorem style `definition' is the same as `plain' except for the
+% body font.
+% \begin{macrocode}
+\def\th@definition{%
+ \normalfont % body font
+}
+% \end{macrocode}
+%
+% Theorem style `remark' differs from `plain' in head font and body
+% font. Also smaller spacing above and below for AMS classes only.
+% \begin{macrocode}
+\def\th@remark{%
+%<amsart|amsthm> \thm@headfont{\itshape}%
+ \normalfont % body font
+%<*amsthm>
+ \thm@preskip\topsep \divide\thm@preskip\tw@
+ \thm@postskip\thm@preskip
+%</amsthm>
+}
+% \end{macrocode}
+%
+% The standard definition of \cs{@endtheorem} is just
+% \cs{endtrivlist}, but that doesn't automatically start a new
+% paragraph, so we add \cs{@endpefalse} in order to ensure a new
+% paragraph. This differs from the basic \latex/ behavior.
+% \begin{macrocode}
+\def\@endtheorem{\endtrivlist\@endpefalse }
+% \end{macrocode}
+%
+% \begin{macro}{\newtheoremstyle}
+% An easy way to make a not too complicated variant theorem style.
+% Usage:
+%\begin{verbatim}
+% #1
+% \newtheoremstyle{NAME}%
+% #2 #3 #4
+% {ABOVESPACE}{BELOWSPACE}{BODYFONT}%
+% #5 #6 #7 #8
+% {INDENT}{HEADFONT}{HEADPUNCT}{HEADSPACE}%
+% #9
+% {CUSTOM-HEAD-SPEC}
+%\end{verbatim}
+% \begin{macrocode}
+\newcommand{\newtheoremstyle}[9]{%
+% \end{macrocode}
+% Empty or 0pt for \arg{5} is translated to \cs{noindent}.
+% \begin{macrocode}
+ \@ifempty{#5}{\dimen@\z@skip}{\dimen@#5\relax}%
+ \ifdim\dimen@=\z@
+% \end{macrocode}
+% \arg{4} is body font. Extra code could be included there if
+% necessary.
+% \begin{macrocode}
+ \toks@{#4\let\thm@indent\noindent}%
+ \else
+ \toks@{#4\def\thm@indent{\noindent\hbox to#5{}}}%
+ \fi
+% \end{macrocode}
+% Arg \arg{8} is a glue spec for the space after the head. As
+% a proper glue spec for `normal interword space' is rather hard to
+% write, we recognize an argument of |{ }| as a special case and
+% translate internally to the necessary fontdimen equivalent.
+% Furthermore, if \arg{8} consists entirely of \cn{newline}, then we
+% will perform a line break after the theorem head instead of adding
+% horizontal space. At the moment [1995/01/23] this is not perfectly
+% well implemented because of complications with the way \latex/'s
+% \cn{item} adds a heading to the vertical list; for best results
+% there should not be anything (not even a blank line) after the
+% |\begin{xxx}| command.
+% \begin{macrocode}
+ \def\@tempa{#8}\ifx\space\@tempa
+% \end{macrocode}
+% Notice that we disregard stretch and shrink for labelsep =
+% interwordspace.
+% \begin{macrocode}
+ \toks@\@xp{\the\toks@ \thm@headsep\fontdimen\tw@\font\relax}%
+ \else
+ \def\@tempb{\newline}%
+ \ifx\@tempb\@tempa
+ \toks@\@xp{\the\toks@ \thm@headsep\z@skip
+ \def\thmheadnl{\newline}}%
+ \else
+ \toks@\@xp{\the\toks@ \thm@headsep#8\relax}%
+ \fi
+ \fi
+ \begingroup
+ \thm@space@setup
+ \@defaultunits\@tempskipa#2\thm@preskip\relax\@nnil
+ \@defaultunits\@tempskipb#3\thm@postskip\relax\@nnil
+ \xdef\@gtempa{\thm@preskip\the\@tempskipa
+ \thm@postskip\the\@tempskipb\relax}%
+ \endgroup
+ \@temptokena\@xp{\@gtempa
+ \thm@headfont{#6}\thm@headpunct{#7}%
+ }%
+ \@ifempty{#9}{%
+ \let\thmhead\thmhead@plain
+ }{%
+ \@namedef{thmhead@#1}##1##2##3{#9}%
+ \@temptokena\@xp{\the\@temptokena
+ \@xp\let\@xp\thmhead\csname thmhead@#1\endcsname}%
+ }%
+ \@xp\xdef\csname th@#1\endcsname{\the\toks@ \the\@temptokena}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\qed}
+% Define \cn{qed} for end of proof. This command might
+% occur in math mode, in a displayed equation, but it should never
+% occur in inner math mode in ordinary paragraph text.
+% \begin{macrocode}
+\DeclareRobustCommand{\qed}{%
+ \ifmmode \mathqed
+ \else
+ \leavevmode\unskip\penalty9999 \hbox{}\nobreak\hfill
+% \end{macrocode}
+% The hbox is to prevent a line break within the \cn{qedsymbol} if it
+% is defined to be something composite--- e.g., things like
+% \verb"(Corollary 1.2) \openbox" as are occasionally done.
+% \begin{macrocode}
+ \quad\hbox{\qedsymbol}%
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% Setup for QED stack. We use a dedicated iterator macro \cs{qed@elt}
+% instead of the generic \cs{@elt} because the \latex/ output routine
+% is not safe against changes in \cs{@elt}. Therefore it is not safe
+% to use \cs{@elt} for any processing that might trigger the output
+% routine. Although this does not seem very likely when adding a QED
+% symbol to a horizontal list, we did in fact get a bug report for
+% this kind of failure.
+% \begin{macrocode}
+\let\QED@stack\@empty
+\let\qed@elt\relax
+% \end{macrocode}
+%
+% Puts a QED symbol on the stack:
+% \begin{macrocode}
+\newcommand{\pushQED}[1]{%
+ \toks@{\qed@elt{#1}}\@temptokena\expandafter{\QED@stack}%
+ \xdef\QED@stack{\the\toks@\the\@temptokena}%
+}
+% \end{macrocode}
+%
+% Pops the QED stack and prints the result.
+% \begin{macrocode}
+\newcommand{\popQED}{%
+ \begingroup\let\qed@elt\popQED@elt \QED@stack\relax\relax\endgroup
+}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\popQED@elt#1#2\relax{#1\gdef\QED@stack{#2}}
+% \end{macrocode}
+%
+% Prints the current QED symbol and replaces the top entry on the
+% stack with a null entry.
+% \begin{macrocode}
+\newcommand{\qedhere}{%
+ \begingroup \let\mathqed\math@qedhere
+ \let\qed@elt\setQED@elt \QED@stack\relax\relax \endgroup
+}
+% \end{macrocode}
+%
+% In case the \pkg{amsmath} or \pkg{amstext} packages are loaded, we
+% need the following two tests. (Redundantly declaring them is
+% harmless.)
+% \begin{macrocode}
+\newif\ifmeasuring@
+\newif\iffirstchoice@ \firstchoice@true
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\setQED@elt#1#2\relax{%
+ \ifmeasuring@
+ \else \iffirstchoice@ \gdef\QED@stack{\qed@elt{}#2}\fi
+ \fi
+ #1%
+}
+% \end{macrocode}
+%
+% \begin{macro}{\mathqed}
+% When a QED occurs inside a math formula, well, it is presumably a
+% displayed equation. In order to find out where to place the QED
+% symbol, we need to check what kind of equation structure we are in.
+%
+% \begin{macrocode}
+\def\qed@warning{%
+ \PackageWarning{amsthm}{The \@nx\qedhere command may not work
+ correctly here}%
+}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\newcommand{\mathqed}{\quad\hbox{\qedsymbol}}
+% \end{macrocode}
+%
+% The \cs{linebox@qed} function comes into play with the \opt{fleqn}
+% option.
+% \begin{macrocode}
+\def\linebox@qed{\hfil\hbox{\qedsymbol}\hfilneg}
+% \end{macrocode}
+% \end{macro}
+%
+% Two large sections of code follow. One for \fn{amsmath} 2.0 and one
+% for plain \latex/.
+% \begin{macrocode}
+\@ifpackageloaded{amsmath}{%
+% \end{macrocode}
+%
+% \begin{macrocode}
+ \def\math@qedhere{%
+ \@ifundefined{\@currenvir @qed}{%
+ \qed@warning\quad\hbox{\qedsymbol}%
+ }{%
+ \@xp\aftergroup\csname\@currenvir @qed\endcsname
+ }%
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+ \def\displaymath@qed{%
+ \relax
+ \ifmmode
+ \ifinner \aftergroup\linebox@qed
+ \else
+ \eqno
+ \let\eqno\relax \let\leqno\relax \let\veqno\relax
+ \hbox{\qedsymbol}%
+ \fi
+ \else
+ \aftergroup\linebox@qed
+ \fi
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+ \@xp\let\csname equation*@qed\endcsname\displaymath@qed
+% \end{macrocode}
+%
+% If the equation has both an equation number and a qed, we've got
+% trouble, but we can provide half-way decent for the simple cases.
+% \begin{macrocode}
+ \def\equation@qed{%
+ \iftagsleft@
+ \hbox{\phantom{\quad\qedsymbol}}%
+ \gdef\alt@tag{%
+ \rlap{\hbox to\displaywidth{\hfil\qedsymbol}}%
+ \global\let\alt@tag\@empty
+ }%
+ \else
+ \gdef\alt@tag{%
+ \global\let\alt@tag\@empty
+ \vtop{\ialign{\hfil####\cr
+ \tagform@\theequation\cr
+ \qedsymbol\cr}}%
+ \setbox\z@
+ }%
+ \fi
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+ \def\qed@tag{%
+ \global\tag@true \nonumber
+ &\omit\setboxz@h {\strut@ \qedsymbol}\tagsleft@false
+ \place@tag@gather
+ \kern-\tabskip
+ \ifst@rred \else \global\@eqnswtrue \fi \global\advance\row@\@ne \cr
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+ \def\split@qed{%
+ \def\endsplit{\crcr\egroup \egroup \ctagsplit@false \rendsplit@
+ \aftergroup\align@qed
+ }%
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+ \def\align@qed{%
+ \ifmeasuring@ \tag*{\qedsymbol}%
+ \else \let\math@cr@@@\qed@tag
+ \fi
+ }
+ \@xp\let\csname align*@qed\endcsname\align@qed
+ \@xp\let\csname gather*@qed\endcsname\align@qed
+% \end{macrocode}
+%
+% \begin{macrocode}
+%% Needs some patching up for amsmath 1.2
+% \end{macrocode}
+%
+% \begin{macrocode}
+}{% end of amsmath branch, start plain LaTeX branch
+% \end{macrocode}
+%
+% The \cn{qedhere} handling for generic \latex/ classes (\cls{article},
+% \cls{book}) with the \pkg{amsthm} package (without \pkg{amsmath}) is
+% fairly sketchy. When a qed symbol and an equation number are both
+% applied to a single display, the results may not be entirely
+% satisfactory, particularly when the \opt{fleqn} and/or \opt{leqno}
+% options are used. [mjd,2000/01/17]
+%
+% As for \cs{math@qedhere}, it is expected to occur only via
+% \cn{qedhere}, where the \cs{aftergroup} makes sense.
+% \begin{macrocode}
+ \def\math@qedhere{%
+ \@ifundefined{\@currenvir @qed}{%
+ \qed@warning \aftergroup\displaymath@qed
+ }{%
+ \@xp\aftergroup\csname\@currenvir @qed\endcsname
+ }%
+ }
+% \end{macrocode}
+%
+% The \cs{ifmmode} \cs{ifinner} case is expected to happen with the
+% \opt{fleqn} option, where we have something like:
+%\begin{verbatim}
+%\hbox to\linewidth{\hbox{$...$}\hfil}
+%\end{verbatim}
+% In order to counteract the \cs{hfil} we must jump out two grouping
+% levels.
+% \begin{macrocode}
+ \def\displaymath@qed{%
+ \relax
+ \ifmmode
+ \ifinner \aftergroup\aftergroup\aftergroup\linebox@qed
+ \else
+ \eqno \def\@badmath{$$}%
+ \let\eqno\relax \let\leqno\relax \let\veqno\relax
+ \hbox{\qedsymbol}%
+ \fi
+ \else
+ \aftergroup\linebox@qed
+ \fi
+ }
+% \end{macrocode}
+%
+% This definition is a fallback definition that places the qed and
+% then the equation number, on the right-hand side. For \opt{leqno},
+% not so good; but then
+% \begin{macrocode}
+ \@ifundefined{ver@leqno.clo}{%
+ \def\equation@qed{\displaymath@qed \quad}%
+ }{%
+ \def\equation@qed{\displaymath@qed}%
+ }
+% \end{macrocode}
+%
+% If \pkg{amsmath} is not loaded, then we need to do some surgery
+% on the \cn{[} macro. Normally it looks like this:
+%\begin{verbatim}
+% \[=macro:
+% ->\relax \ifmmode \@badmath \else
+% \ifvmode \nointerlineskip \makebox [.6\linewidth ]\fi $$\fi
+%\end{verbatim}
+%
+% If arg 2 is \cs{m@th} when we make this test it indicates that the
+% fleqn option is in effect. Perhaps try to do something there.
+% \begin{macrocode}
+ \def\@tempa#1$#2#3\@nil#4{%
+ \def#4{#1$#2\def\@currenvir{displaymath}#3}%
+ }%
+% \end{macrocode}
+% If \cn{[} has already been made robust (by \pkg{fixltx2e} or
+% a \LaTeX\ format from 2015 or later), patch the internal macro
+% \cs{[<space>} instead.
+% \begin{macrocode}
+ \expandafter\ifx\csname[ \endcsname\relax
+ \expandafter\@tempa\[\@nil\[%
+ \else
+ \expandafter\expandafter\expandafter\@tempa\csname[
+ \expandafter\endcsname\expandafter\@nil
+ \csname[ \endcsname
+ \fi
+}
+% \end{macrocode}
+%
+% If an older version of \pkg{amsmath} is in use, we need to fall
+% back to a simpler definition of \cs{math@qedhere}.
+% \begin{macrocode}
+\@ifpackageloaded{amstex}{%
+ \def\@tempa{TT}%
+}{%
+ \@ifpackageloaded{amsmath}{%
+ \def\@tempb#1 v#2.#3\@nil{#2}%
+ \ifnum\@xp\@xp\@xp\@tempb\csname ver@amsmath.sty\endcsname v0.0\@nil
+ <\tw@
+ \def\@tempa{TT}%
+ \else
+ \def\@tempa{TF}%
+ \fi
+ }{%
+ \def\@tempa{TF}
+ }%
+}
+\if\@tempa
+ \renewcommand{\math@qedhere}{\quad\hbox{\qedsymbol}}%
+\fi
+% \end{macrocode}
+%
+% The reason that we do not simply use the \cn{square} symbol from
+% \fn{msam} for the open-box qed symbol is that we want to avoid
+% requiring users to have the AMSFonts font package. And the \fn{lasy}
+% \cn{Box} is too large.
+% \begin{macrocode}
+\newcommand{\openbox}{\leavevmode
+% \end{macrocode}
+% I think I got these numbers from measuring \fn{msam}'s \cn{square}
+% but I forgot to make notes at the time. [mjd,1995/01/25]
+% \begin{macrocode}
+ \hbox to.77778em{%
+ \hfil\vrule
+ \vbox to.675em{\hrule width.6em\vfil\hrule}%
+ \vrule\hfil}}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\DeclareRobustCommand{\textsquare}{%
+ \begingroup \usefont{U}{msa}{m}{n}\thr@@\endgroup
+}
+% \end{macrocode}
+%
+% \begin{macrocode}
+%<*classes>
+\@ifclasswith{\@classname}{noamsfonts}{%
+ \providecommand{\qedsymbol}{\openbox}%
+}{}
+\providecommand{\qedsymbol}{\textsquare}
+%</classes>
+%<amsthm>\providecommand{\qedsymbol}{\openbox}
+% \end{macrocode}
+%
+% The proof environment is never numbered, and has a \cn{qed} at the
+% end, which makes it inconvenient to use \cn{newtheorem} for
+% defining it. Also authors frequently need to substitute an
+% alternative heading text (e.g.\ `Proof of Lemma 4.3')
+% instead of the default `Proof'. For all these reasons we define the
+% proof environment here instead of leaving it for authors to define.
+% Text after the end of a proof, like that after the end of a theorem,
+% begins a new paragraph. This differs from basic \latex/ behavior.
+% [bnb, 1999/09/27]
+% \begin{macrocode}
+\newenvironment{proof}[1][\proofname]{\par
+ \pushQED{\qed}%
+ \normalfont \topsep6\p@\@plus6\p@\relax
+ \trivlist
+%<amsbook|amsproc> \itemindent\normalparindent
+ \item[\hskip\labelsep
+%<amsbook|amsproc> \scshape
+%<amsart|amsthm> \itshape
+ #1\@addpunct{.}]\ignorespaces
+}{%
+ \popQED\endtrivlist\@endpefalse
+}
+% \end{macrocode}
+% Default for \cn{proofname}:
+% \begin{macrocode}
+\providecommand{\proofname}{Proof}
+% \end{macrocode}
+%
+% For reference:
+%\begin{verbatim}
+% From: tycchow@math.mit.edu (Timothy Y. Chow)
+% Subject: Suppressing theorem numbering in LaTeX
+% Message-ID: <1994Aug11.234754.22523@galois.mit.edu>
+% Date: Thu, 11 Aug 94 23:47:54 GMT
+% To: tex-news@SHSU.EDU
+%
+% A friend of mine wants numbering of theorems, conjectures, and so on
+% suppressed if there is only one of them in his article. In other words
+% he wants "Conjecture 1" to appear as simply "Conjecture" if there is no
+% Conjecture 2. What is the best way to go about doing this?
+% ...
+%\end{verbatim}
+% Maybe something clever can be done to make the desired behavior
+% happen automatically. Note that this would seem to be a general
+% numbering problem rather than a theorem-specific one, because
+% similar behavior would be desirable for appendixes: according to
+% standard publishing practice, if there's only one it is titled just
+% `Appendix', and if there are more than one they are titled
+% `Appendix A', `Appendix B', and so on.
+%
+% \begin{macrocode}
+%</amsthm|classes>
+%<*classes>
+% \end{macrocode}
+%
+% \subsection{Utility commands used with AMS author packages}
+%
+% \begin{macro}{\bb@skip}
+% Skip to result in base-to-base distance from previous to next box.
+% \begin{macrocode}
+\def\bb@skip#1{%
+ \skip@#1\relax \advance\skip@-\prevdepth \advance\skip@-\baselineskip
+ \vskip\skip@}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\markleft}
+% Basic \latex/ has \cn{markright} and \cn{markboth}, but sometimes
+% it's necessary to change just the left running head. This macro
+% completes the set. From the \pkg{altxext.sty} module of Klaus
+% Lagally's \pkg{arabtex}. [bnb, 2004/03/25]
+% \begin{macrocode}
+\def\markleft#1{{\let\protect\noexpand
+ \let\label\relax \let\index\relax \let\glossary\relax
+ \expandafter\@markleft\@themark{#1}%
+ \mark{\@themark}}%
+ \if@nobreak\ifvmode\nobreak\fi\fi}
+\def\@markleft#1#2#3{\gdef\@themark{{#3}{#2}}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\DH}
+% \begin{macro}{\dh}
+% \begin{macro}{\DJ}
+% \begin{macro}{\dj}
+% The Icelandic thorn and eth and the Croatian barred D are part of
+% the T1 font encoding, but aren't available in OT1. However, they
+% are needed (rarely) in the author names or bibliographies. Provide
+% emulations, using the thorn in \fn{msbm} or D's barred with a macron.
+% The lowercase eth requires an \cs{edef} to access \fn{msbm} properly.
+% Define it separately to permit checking for small caps. [bnb, 2004/04/05]
+% \begin{macrocode}
+\@ifundefined{symAMSb}{%
+ \def\@dh{dh}%
+ \ClassWarning{\@classname}{\string\dh\space unavailable without amsfonts;
+ replaced by 'dh'}%
+}{%
+ \edef\@dh{\noexpand\mathhexbox{\hexnumber@\symAMSb}67}%
+}
+\DeclareTextCommand{\dh}{OT1}{%
+ \edef\@tempb{\scdefault}%
+ \ifx\f@shape\@tempb
+ \leavevmode
+ \raisebox{-.8ex}{\makebox[\z@][l]{\hskip-.08em\accent"16\hss}}d%
+ \else
+ \@dh
+ \fi
+}
+\DeclareTextCommand{\DH}{OT1}{%
+ \leavevmode\raisebox{-.5ex}{\makebox[\z@][l]{\hskip-.07em\accent"16\hss}}D}
+\DeclareTextCommand{\DJ}{OT1}{%
+ \leavevmode\raisebox{-.5ex}{\makebox[\z@][l]{\hskip-.07em\accent"16\hss}}D}
+\DeclareTextCommand{\dj}{OT1}{%
+ \edef\@tempa{\f@shape}\edef\@tempb{\scdefault}%
+ \ifx\@tempa\@tempb
+ \leavevmode
+ \raisebox{-.75ex}{\makebox[\z@][l]{\hskip-.08em\accent"16\hss}}d%
+ \else
+ \leavevmode\raisebox{.02ex}{\makebox[\z@][l]{\hskip.1em\accent"16\hss}}d%
+ \fi}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \subsection{Hyphenation exceptions}
+% Some common hyphenation exceptions, based on the listing in
+% TUGboat vol 10, no 3, November 1989, pp.~336--341. Many words from
+% the TUGboat list that seemed less likely to occur in mathematical
+% text have been omitted because hyphenation exceptions use up memory
+% (most versions of \tex/ currently have a limit of 307 on hyphenation
+% exceptions; each added hyphenation exception uses up something like
+% 2 extra words of main memory as well). The list of hyphenations for
+% proper names could be expanded forever if room permitted; we
+% restrict ourselves to a rather short, extremely arbitrary list.
+% Note that the hyphenation rules of British English differ in some
+% particulars from the US rules, so some of the hyphenations
+% given below may need to be overridden for proper UK hyphenation.
+%
+% \begin{macrocode}
+\hyphenation{acad-e-my acad-e-mies af-ter-thought anom-aly anom-alies
+an-ti-deriv-a-tive an-tin-o-my an-tin-o-mies apoth-e-o-ses
+apoth-e-o-sis ap-pen-dix ar-che-typ-al as-sign-a-ble as-sist-ant-ship
+as-ymp-tot-ic asyn-chro-nous at-trib-uted at-trib-ut-able bank-rupt
+bank-rupt-cy bi-dif-fer-en-tial blue-print busier busiest
+cat-a-stroph-ic cat-a-stroph-i-cally con-gress cross-hatched data-base
+de-fin-i-tive de-riv-a-tive dis-trib-ute dri-ver dri-vers eco-nom-ics
+econ-o-mist elit-ist equi-vari-ant ex-quis-ite ex-tra-or-di-nary
+flow-chart for-mi-da-ble forth-right friv-o-lous ge-o-des-ic
+ge-o-det-ic geo-met-ric griev-ance griev-ous griev-ous-ly
+hexa-dec-i-mal ho-lo-no-my ho-mo-thetic ideals idio-syn-crasy
+in-fin-ite-ly in-fin-i-tes-i-mal ir-rev-o-ca-ble key-stroke
+lam-en-ta-ble light-weight mal-a-prop-ism man-u-script mar-gin-al
+meta-bol-ic me-tab-o-lism meta-lan-guage me-trop-o-lis
+met-ro-pol-i-tan mi-nut-est mol-e-cule mono-chrome mono-pole
+mo-nop-oly mono-spline mo-not-o-nous mul-ti-fac-eted mul-ti-plic-able
+non-euclid-ean non-iso-mor-phic non-smooth par-a-digm par-a-bol-ic
+pa-rab-o-loid pa-ram-e-trize para-mount pen-ta-gon phe-nom-e-non
+post-script pre-am-ble pro-ce-dur-al pro-hib-i-tive pro-hib-i-tive-ly
+pseu-do-dif-fer-en-tial pseu-do-fi-nite pseu-do-nym qua-drat-ic
+quad-ra-ture qua-si-smooth qua-si-sta-tion-ary qua-si-tri-an-gu-lar
+quin-tes-sence quin-tes-sen-tial re-arrange-ment rec-tan-gle
+ret-ri-bu-tion retro-fit retro-fit-ted right-eous right-eous-ness
+ro-bot ro-bot-ics sched-ul-ing se-mes-ter semi-def-i-nite
+semi-ho-mo-thet-ic set-up se-vere-ly side-step sov-er-eign spe-cious
+spher-oid spher-oid-al star-tling star-tling-ly sta-tis-tics
+sto-chas-tic straight-est strange-ness strat-a-gem strong-hold
+sum-ma-ble symp-to-matic syn-chro-nous topo-graph-i-cal tra-vers-a-ble
+tra-ver-sal tra-ver-sals treach-ery turn-around un-at-tached
+un-err-ing-ly white-space wide-spread wing-spread wretch-ed
+wretch-ed-ly Eng-lish Euler-ian Feb-ru-ary Gauss-ian
+Hamil-ton-ian Her-mit-ian Jan-u-ary Japan-ese Kor-te-weg
+Le-gendre Mar-kov-ian Noe-ther-ian No-vem-ber Rie-mann-ian Sep-tem-ber}
+% \end{macrocode}
+%
+% \subsection{Initialization}
+% We define a function to do the normal calculations that we want for
+% \cn{textheight} and \cn{textwidth}
+%
+% \begin{macro}{\calclayout}
+% Subtract the height of the running heads:
+% \begin{macrocode}
+\def\calclayout{\advance\textheight -\headheight
+ \advance\textheight -\headsep
+% \end{macrocode}
+% We set \cn{oddsidemargin} and \cn{evensidemargin} to
+% center the text on the page.
+% \begin{macrocode}
+ \oddsidemargin\paperwidth
+ \advance\oddsidemargin -\textwidth
+ \divide\oddsidemargin\tw@
+% \end{macrocode}
+% Now we subtract the default margin provided by standard DVI
+% drivers. But first we make sure that the final margin will
+% be at least .5 inch.
+% \begin{macrocode}
+ \ifdim\oddsidemargin<.5truein \oddsidemargin.5truein \fi
+ \advance\oddsidemargin -1truein
+ \evensidemargin\oddsidemargin
+% \end{macrocode}
+% And we set \cn{topmargin} to get vertical centering as well.
+% \begin{macrocode}
+ \topmargin\paperheight \advance\topmargin -\textheight
+ \advance\topmargin -\headheight \advance\topmargin -\headsep
+% \end{macrocode}
+% Height of running foot ignored: not present.
+% \begin{macrocode}
+ \divide\topmargin\tw@
+% \end{macrocode}
+% We provide a minimum of .5in (after compensating for the default
+% margin---see next step).
+% \begin{macrocode}
+ \ifdim\topmargin<.5truein \topmargin.5truein \fi
+% \end{macrocode}
+% Now subtract the default margin provided by standard DVI
+% drivers.
+% \begin{macrocode}
+ \advance\topmargin -1truein\relax
+}
+% \end{macrocode}
+% \end{macro}
+%
+% Initialize the dimensions, page numbering, etc. For inhouse use,
+% administrative stuff is isolated in separate files.
+% \begin{macrocode}
+%<amsart>\InputIfFileExists{amsart.cfg}{}{%
+%<amsproc>\InputIfFileExists{amsproc.cfg}{}{%
+%<amsbook>\InputIfFileExists{amsbook.cfg}{}{%
+ \calclayout % initialize
+ \pagenumbering{arabic}%
+ \pagestyle{headings}%
+ \thispagestyle{plain}%
+}
+% \end{macrocode}
+%
+% If we are in compatibility mode, add some backward compatibility
+% stuff below. Otherwise quit here.
+% \begin{macrocode}
+\if@compatibility \else\endinput\fi
+% \end{macrocode}
+%
+% Compensate for changed meaning of \cn{tiny}:
+% \begin{macrocode}
+\def\tiny{\Tiny}
+% \end{macrocode}
+%
+% The macro \cn{defaultfont} was provided in version 1.1 of amsart;
+% retained for compatibility as a synonym of \cn{normalfont}. Resets
+% everything except for size.
+% \begin{macrocode}
+\def\defaultfont{\normalfont}
+% \end{macrocode}
+%
+% Macro for making non-slanted numbers and punctuation in italic
+% or slanted text. This is to avoid visual inconsistencies
+% between numbers or parentheses in math and adjacent numbers or
+% parentheses in text.
+% \begin{macrocode}
+\def\rom{\textup}
+% \end{macrocode}
+%
+% For backward compatibility with version 1.1 of \cls{amsart}, we
+% define \env{pf}, \env{pf*} environments. And undefine \cn{proof}
+% just in case an existing document contains a \cn{newenvironment} or
+% \cn{newcommand} for it, as that would now cause an error.
+% \begin{macrocode}
+\let\@newpf\proof \let\proof\relax \let\endproof\relax
+\newenvironment{pf}{\@newpf[\proofname]}{\popQED\endtrivlist}
+\newenvironment{pf*}[1]{\@newpf[#1]}{\popQED\endtrivlist}
+% \end{macrocode}
+%
+% The usual \cn{endinput} to ensure that random garbage at the end of
+% the file doesn't get copied by \fn{docstrip}.
+% \begin{macrocode}
+\endinput
+%</classes>
+% \end{macrocode}
+%
+% \changes{v1.2a}{1995/02/01}{Added global init for @secnumber}
+% \changes{v1.2a}{1995/02/01}{Made psamsfonts option pass cmex10 to
+% amsmath}
+% \changes{v1.2a}{1995/02/01}{Added missing endpar after authors in
+% amsbook @maketitle}
+%
+% \changes{v1.2b}{1995/02/20}{Improve handling of abstract}
+% \changes{v1.2b}{1995/02/20}{Allow titlepage option for articles}
+% \changes{v1.2b}{1995/02/20}{Suppress logo and copyright info for
+% generic AMS classes}
+% \changes{v1.2b}{1995/02/20}{Use `Date' instead of `Received by...' in
+% the generic AMS classes}
+%
+% \changes{v2.13}{2002/12/06}{Added a warning for thanks inside author}
+%
+% \Finale
diff --git a/macros/latex/required/amscls/amsclass.ins b/macros/latex/required/amscls/amsclass.ins
new file mode 100644
index 0000000000..5f5aa98303
--- /dev/null
+++ b/macros/latex/required/amscls/amsclass.ins
@@ -0,0 +1,81 @@
+%% filename: amsclass.ins
+%% version: 3.03
+%% date: 2015/03/04
+%%
+%% American Mathematical Society
+%% Technical Support
+%% Publications Technical Group
+%% 201 Charles Street
+%% Providence, RI 02904
+%% USA
+%% tel: (401) 455-4080
+%% (800) 321-4267 (USA and Canada only)
+%% fax: (401) 331-3842
+%% email: tech-support@ams.org
+%%
+%% Copyright 1999, 2010, 2011, 2014-2017 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
+%% 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.
+%%
+%% This work has the LPPL maintenance status `maintained'.
+%%
+%% The Current Maintainer of this work is the American Mathematical
+%% Society.
+%%
+%% ====================================================================
+
+\input docstrip
+
+\askforoverwritefalse
+
+\keepsilent
+
+\preamble
+
+This is a generated file.
+
+Copyright 1995, 199, 2004, 2009, 2015, 2017 American Mathematical Society.
+
+American Mathematical Society
+Technical Support
+Publications Technical Group
+201 Charles Street
+Providence, RI 02904
+USA
+tel: (401) 455-4080
+ (800) 321-4267 (USA and Canada only)
+fax: (401) 331-3842
+email: tech-support@ams.org
+
+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
+ 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.
+
+This work has the LPPL maintenance status `maintained'.
+
+The Current Maintainer of this work is the American Mathematical
+Society.
+
+========================================================================
+
+\endpreamble
+
+\generate{
+ \file{amsthm.sty} {\from{amsclass.dtx}{amsthm}}
+ \file{amsart.cls} {\from{amsclass.dtx}{amsart,classes}}
+ \file{amsbook.cls}{\from{amsclass.dtx}{amsbook,classes}}
+ \file{amsproc.cls}{\from{amsclass.dtx}{amsproc,classes}}
+}
+
+\endbatchfile
+
diff --git a/macros/latex/required/amscls/amsdtx.dtx b/macros/latex/required/amscls/amsdtx.dtx
new file mode 100644
index 0000000000..7825a7028b
--- /dev/null
+++ b/macros/latex/required/amscls/amsdtx.dtx
@@ -0,0 +1,1223 @@
+% \def\filename{amsdtx.dtx}
+% \def\fileversion{2.07}
+% \def\filedate{2009/08/19}
+%
+% \iffalse meta-comment
+%
+% American Mathematical Society
+% Technical Support
+% Publications Technical Group
+% 201 Charles Street
+% Providence, RI 02904
+% USA
+% tel: (401) 455-4080
+% (800) 321-4267 (USA and Canada only)
+% fax: (401) 331-3842
+% email: tech-support@ams.org
+%
+% Copyright 1996, 1999, 2004, 2009 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
+% 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.
+%
+% This work has the LPPL maintenance status `maintained'.
+%
+% The Current Maintainer of this work is the American Mathematical
+% Society.
+%
+% \fi
+%
+% \iffalse
+% The following section of code makes this file self-printable.
+%<*driver>
+\NeedsTeXFormat{LaTeX2e}
+\documentclass{amsdtx}
+
+\newcommand{\rp}{\let\PBS\\\raggedright\let\\\PBS}
+
+\CodelineIndex
+
+\begin{document}
+
+\title{The \cls{amsldoc} and \cls{amsdtx} document classes}
+
+\author{American Mathematical Society\\Michael Downes\\
+ updated by David M. Jones}
+
+\date{Version \fileversion, \filedate}
+
+\DocInput{amsdtx.dtx}
+
+\PrintIndex
+
+\end{document}
+%</driver>
+% \fi
+%
+%^^A If this file is printed by itself the \fileversion and \filedate
+%^^A information will come from the file header rather than from the
+%^^A \ProvidesClass command. See \hDocInput.
+% \maketitle
+%
+% \tableofcontents
+%
+% \MakeShortVerb\|
+% \section{Introduction}
+% This file is the source for two documentclasses, \cls{amsldoc}
+% (used for the \amslatex/ user's guide) and \cls{amsdtx} (used for
+% printing AMS \fn{.dtx} files). The generic \cls{book} class is used
+% as a base, but the \cls{amsdtx} class is modified to serve as an
+% article-type class. This affects the form of documentation files
+% mainly in the use of \cn{maketitle} and \cn{chapter}.
+%
+% \begin{table}
+% \caption{Features of the \cls{amsldoc} and \cls{amsdtx} classes}
+% \centering
+% \begin{tabular}{lp{.65\columnwidth}}
+% Command Name& Purpose\\
+% \hline
+% \cn{cn}& \rp To print a user command name: \verb"\cn{title}"; leading
+% backslash can be optionally included for control symbols:
+% \verb"\cn{\%}". The \cn{cn} command works properly even in macro
+% arguments (compare to, e.g., \cn{verb}\verb"'\newif'"). But beware
+% of a fragile control symbol (are there any?) in a moving argument.\\
+% \cn{cs}& \rp `Control sequence': to print an internal command name,
+% not intended for the end user\\
+% \cn{env}& \rp To print an environment name: \verb"\env{table}"\\
+% \cn{pkg}& \rp To print a package name: \verb"\pkg{eufrak}"\\
+% \cn{cls}& \rp To print a class name: \verb"\cls{book}"\\
+% \cn{opt}& \rp To print the name of a class or package option:
+% \verb"\opt{twocolumn}"\\
+% \cn{bst}& \rp To print the name of a \bibtex/ style
+% \verb"\bst{amsalpha}"\\
+% \cn{fn}& \rp To print a file name or font name: \verb"\fn{T1enc.def}",
+% \verb"\fn{cmsy10}"\\
+% \cn{fnt}& \rp To print a font name: \verb"\fn{cmsy10}" \\
+% \cn{cnt}& \rp To print a counter name: \verb"\fn{topnumber}" \\
+% \cn{qc}& \rp To quote a single character: \verb"\qc{\%}";
+% this works properly for special characters, even in macro
+% arguments, unlike e.g., \verb"\verb'%'"\\
+% \cn{latex/} etc.& \rp Convenient forms of \cn{LaTeX}, \cn{TeX},
+% \cn{BibTeX}, etc. that are easier to type and have a trailing slash
+% to eliminate the following-space problem (without needing different
+% markup in different contexts)
+% \end{tabular}
+% \end{table}
+%
+% \StopEventually{}
+%
+% Standard starting pieces. (Note: the reason each \cn{ProvidesClass}
+% command is placed on a line by itself, with separate begin and end
+% guards for docstripping, is to make automatic update of file date
+% and version slightly easier and more robust.)
+% \begin{macrocode}
+\NeedsTeXFormat{LaTeX2e}% LaTeX 2.09 can't be used (nor non-LaTeX)
+[1995/06/01]% LaTeX date must be June 1995 or later
+%<*amsldoc>
+\ProvidesClass{amsldoc}[2009/08/19 v2.07]
+%</amsldoc>
+%<*amsdtx>
+\ProvidesClass{amsdtx}[2009/08/19 v2.07]
+%</amsdtx>
+% \end{macrocode}
+%
+% \section{Implementation}
+% Start with the generic book class as a base.
+% \begin{macrocode}
+\DeclareOption*{\PassOptionsToClass{\CurrentOption}{book}}
+\ProcessOptions
+\LoadClass{book}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\IfFileExists{url.sty}{%
+ \RequirePackage{url}\relax
+ \@gobble
+}{%
+ \@firstofone
+}
+{
+ \DeclareRobustCommand{\url}[1]{%
+ \def\@tempa{#1}%
+ \texttt{\urlsetup $\expandafter\strip@prefix\meaning\@tempa$}%
+ }%
+ \def\urlsetup{%
+ \check@mathfonts \textfont\@ne\the\font \textfont\z@\the\font
+ \urlfix +\urlfix\=\urlfix\:\urlfix\-\urlfix\.\urlfix\,\urlfix\;%
+ \urlbreak\&\urlbreak\/\urlbreak\?%
+ }%
+ \def\urlbreak#1{%
+ \mathcode`#1="8000
+ \begingroup \lccode`\~=`#1 \lowercase{\endgroup \edef~}%
+ {\mathchar\number`#1\penalty\hyphenpenalty}%
+ }%
+ \def\urlfix#1{%
+ \mathcode`#1=`#1\relax
+ }%
+}
+% \end{macrocode}
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% \begin{macrocode}
+\providecommand{\qq}[1]{\textquotedblleft#1\/\textquotedblright}
+\providecommand{\mdash}{\textemdash\penalty\exhyphenpenalty}
+\providecommand{\ndash}{\textendash\penalty\exhyphenpenalty}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\let\@xp\expandafter
+% \end{macrocode}
+% \section{Indexing primitives}
+%
+% Unlike \pkg{amsdtx}, \pkg{amsldoc} doesn't load the \pkg{doc}
+% package, so we need to provide the following logical names. The
+% values are consistent with \fn{makeindex}'s default conventions.
+% \begin{macrocode}
+%<*amsldoc>
+\def\actualchar{@}
+\def\quotechar{"}
+\def\levelchar{!}
+\def\encapchar{|}
+\def\verbatimchar{+}
+% \end{macrocode}
+% We also need the \cs{ifcodeline@index} switch.
+% \begin{macrocode}
+\newif\ifcodeline@index
+%</amsldoc>
+% \end{macrocode}
+%
+% \begin{macro}{\autoindex}
+% When generating a codeline index, this encapsulates the page
+% number in italics.
+% \begin{macrocode}
+\newcommand*{\autoindex}[1]{%
+ \index{#1\ifcodeline@index\encapchar usage\fi}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ntt}
+% To avoid font substitution warnings we make the tt font always
+% print in the normal weight and shape.
+% \begin{macrocode}
+\newcommand{\ntt}{\normalfont\ttfamily}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\indexcs}
+% Index a control sequence without printing it. Note
+% non-long. The \cs{@nobslash} strips off an optional leading
+% backslash before passing the control sequence name to
+% \cs{@indexcs}. This means that |\indexcs{\cs}| and
+% |\indexcs{cs}| produce the same index entry.
+% \begin{macrocode}
+\newcommand*{\indexcs}[1]{%
+ \@xp\@xp\@xp\@indexcs\@xp\@nobslash\string#1\@nil
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@indexcs}
+% Given |cs| as an argument, this writes something like
+% |cs@\verb"*+\cs+| to the \fn{.idx} file (or |cs=\verb!*+\cs+| if
+% using \fn{doc.sty}).
+% \begin{macrocode}
+\def\@indexcs#1\@nil{%
+ \autoindex{#1\actualchar
+ \string\verb\quotechar*\verbatimchar
+ \@xp\@bothoftwo\string\ #1\@empty
+ \verbatimchar
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@bothoftwo}
+% This has the effect of removing spaces before each of the
+% arguments. In particular, it removes the space generated by
+% \verb*+\string\ + above.
+% \begin{macrocode}
+\def\@bothoftwo#1#2{#1#2}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\category@index}
+% \begin{macrocode}
+\def\category@index#1#2{%
+ {\ntt#2}%
+ \@category@index{#1}{#2}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@category@index}
+% \begin{macrocode}
+\def\@category@index#1#2{%
+ \autoindex{%
+ #2\actualchar\string\texttt{#2}%
+ \ifx\@nil#1\@nil\else\space#1\fi
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% Some functions to support \cn{cn} etc. For most of these commands
+% we don't really want them to be \cs{long}! But in some early
+% releases of \LaTeXe\ the \verb'*' form of \cn{newcommand} was not
+% yet available.
+%
+% We use the name \cn{bslchar} instead of \cn{bslash} to avoid
+% potential conflict with the \pkg{doc} package \cn{bslash} command.
+% Unlike \cn{bslash}, \cn{bslchar} survives unlimited
+% writing/expansion because it is a chardef.
+% \begin{macrocode}
+\chardef\bslchar=`\\ % p. 424, TeXbook
+\newcommand{\addbslash}{\expandafter\@addbslash\string}
+\def\@addbslash#1{\bslchar\@nobslash#1}
+\newcommand{\nobslash}{\expandafter\@nobslash\string}
+\def\@nobslash#1{\ifnum`#1=\bslchar\else#1\fi}
+% \end{macrocode}
+%
+% \begin{macro}{\@boxorbreak}
+% Start up for a \cn{cs} or \cn{cn} command, adds an \cs{hbox} if in
+% math, or an allowbreak penalty if the preceding item is not a space.
+% (In case two such commands are used side-by-side.)
+% \begin{macrocode}
+\def\@boxorbreak{%
+ \leavevmode
+ \ifmmode\hbox\else\ifdim\lastskip=\z@\penalty9999 \fi\fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% Control sequence. The function \cn{addbslash} makes this command
+% also usable for some special control sequences like \cn{\%} \cn{\}}
+% \cn{\{}: instead of writing |\cs{%}| which doesn't work, you can
+% write |\cs{\%}|.
+% \begin{macrocode}
+\DeclareRobustCommand{\cs}[1]{%
+ \@boxorbreak{%
+ \ntt
+ \addbslash#1\@empty
+ \@xp\@xp\@xp\@indexcs\@xp\@nobslash\string#1\@nil
+ }%
+}
+% \end{macrocode}
+%
+% Allow distinguishing non-private `command names' that will be
+% visible to the user from internal (mostly private) `control
+% sequences'.
+% \begin{macrocode}
+\let\cn\cs
+% \end{macrocode}
+%
+% \begin{macro}{\embrace}
+% \begin{macrocode}
+\DeclareTextSymbol{\lbracechar}{OT1}{123}
+\DeclareTextSymbolDefault{\lbracechar}{OT1}
+\DeclareTextSymbol{\rbracechar}{OT1}{125}
+\DeclareTextSymbolDefault{\rbracechar}{OT1}
+
+\providecommand{\embrace}[1]{%
+ \begingroup \ntt\lbracechar#1\rbracechar\endgroup}
+% \end{macrocode}
+% \end{macro}
+%
+% One mandatory argument: cnm; two: cnmm; one optional and one
+% mandatory: cnom; throwing in a star: cnsom; and so on.
+% \begin{macrocode}
+\providecommand{\cnbreak}{\penalty999\hskip0pt\relax}
+\providecommand{\cnm}[2]{\cn{#1}\cnbreak\embrace{#2}}
+\providecommand{\cnmm}[3]{\cn{#1}\cnbreak\embrace{#2}\cnbreak\embrace{#3}}
+\providecommand{\cnom}[1]{\cn{#1}\cnbreak\ommitude}
+\providecommand{\ommitude}[2][]{{\ntt[#1]}\cnbreak\embrace{#2}}
+\providecommand{\cnmsm}[4]{%
+ \cn{#1}\cnbreak\embrace{#2}\cnbreak *\embrace{#4}}
+% \end{macrocode}
+% The following items should not normally appear in math mode so they
+% don't need to call \cs{@boxorbreak}.
+%
+% \latex/ documentclass name.
+% \begin{macrocode}
+\DeclareRobustCommand{\cls}{\category@index{class}}
+% \end{macrocode}
+%
+% \latex/ package name.
+% \begin{macrocode}
+\DeclareRobustCommand{\pkg}{\category@index{package}}
+% \end{macrocode}
+%
+% \latex/ option name.
+% \begin{macrocode}
+\DeclareRobustCommand{\opt}{\category@index{option}}
+% \end{macrocode}
+%
+% Environment name.
+% \begin{macrocode}
+%<amsdtx>\DeclareRobustCommand{\env}[1]{{\ntt#1}\SpecialEnvIndex{#1}}
+%<amsldoc>\DeclareRobustCommand{\env}{\category@index{environment}}
+% \end{macrocode}
+%
+% File name.
+% \begin{macrocode}
+\DeclareRobustCommand{\fn}{\category@index{}}
+% \end{macrocode}
+%
+% \bibtex/ style.
+% \begin{macrocode}
+\DeclareRobustCommand{\bst}{\category@index{\string\BibTeX{} style}}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\DeclareRobustCommand{\cnt}{\category@index{counter}}
+\DeclareRobustCommand{\fnt}{\category@index{font}}
+% \end{macrocode}
+%
+% With long command names or file names we sometimes prefer to allow
+% hyphenation in the tt font (in combination with suitable
+% \cn{hyphenation} statements for individual documents). To make this
+% work we must turn off the feature of \latex/ that disables the
+% hyphenchar of the tt fonts.
+%
+% The method shown here depends on the assumption that OT1 encoding
+% will be used for the tt fonts. An encoding-independent method would
+% be more awkward: You'd have to explicitly load the relevant
+% fonts, let's say by using \cn{AtBeginDocument}, and undo the
+% hyphenchar change individually for each font.
+%
+% Instead we force loading, or possibly reloading (depending on the
+% preload options used locally for creating the \latex/ format file),
+% of the \fn{OT1/cmtt} fd file, and then clear the macro
+% \cs{OT1+cmtt} which contains code to execute whenever a font of
+% this family is first loaded. The default value is to turn off the
+% hyphenchar, and that's what we don't want.
+%
+% This method is not especially palatable but other methods that
+% don't involve loading the fd file are significantly less reliable.
+% \begin{macrocode}
+\def\allowtthyphens{\begingroup
+ \fontencoding{OT1}\fontfamily{cmtt}%
+% \end{macrocode}
+% Undefine the csname that \cs{try@load@fontshape} tests to determine
+% whether the fd file needs loading. Then call
+% \cs{try@load@fontshape}. Then we can remove the `turn off
+% hyphenation' code, which as it happens resides in the same csname
+% that was tested.
+% \begin{macrocode}
+ \expandafter\let\csname OT1+cmtt\endcsname\relax
+ \try@load@fontshape
+ \endgroup
+ \expandafter\let\csname OT1+cmtt\endcsname\@empty
+}
+% \end{macrocode}
+%
+% We allow some slop at the right margin because we have some
+% long control sequence names and verbatim text to deal with. Also
+% ignore underfull hboxes and vboxes unless they are really bad.
+% \begin{macrocode}
+\hfuzz2pc
+\vbadness9999 \hbadness5000
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\AmS{{\protect\usefont{OMS}{cmsy}{m}{n}%
+ A\kern-.1667em\lower.5ex\hbox{M}\kern-.125emS}}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\latex/{{\protect\LaTeX}}
+\def\amslatex/{{\protect\AmS-\protect\LaTeX}}
+\def\tex/{{\protect\TeX}}
+\def\amstex/{{\protect\AmS-\protect\TeX}}
+\def\bibtex/{{Bib\protect\TeX}}
+% \end{macrocode}
+%
+% \cn{makeindex} command is already used for other purposes.
+% \begin{macrocode}
+\def\makeindx/{MakeIndex}
+% \end{macrocode}
+%
+% Don't allow a break after the hyphen:
+% \begin{macrocode}
+\def\xypic/{XY\mbox{-}pic}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\newcommand{\Textures}{\textit{Textures}}
+% \end{macrocode}
+%
+% `Meta' macro.
+% \begin{macrocode}
+\def\<#1>{\textit{$\langle$#1\/$\rangle$}}
+% \end{macrocode}
+%
+% Reduce itemsep in lists.
+% \begin{macrocode}
+\def\@listi{%
+ \leftmargin\leftmargini
+ \topsep 3\p@ \@plus2\p@ \@minus\p@
+ \parsep \p@ \@plus\p@ \itemsep\parsep
+}
+\let\@listI\@listi
+\@listi
+\def\@listii{%
+ \leftmargin\leftmarginii
+ \labelwidth\leftmarginii \advance\labelwidth-\labelsep
+ \topsep\p@\@plus\p@ \@minus\p@
+ \parsep\z@skip \itemsep\z@skip
+}
+\def\@listiii{%
+ \leftmargin\leftmarginiii
+ \labelwidth\leftmarginiii \advance\labelwidth-\labelsep
+ \topsep\z@skip \parsep\z@skip \itemsep\z@skip
+}
+% \end{macrocode}
+%
+% An environment to encapsulate remarks relevant to old versions but
+% not essential for the current version.
+% \begin{macrocode}
+\newenvironment{histnote}{%
+ \trivlist\item[\hspace{\labelsep}\bfseries Historical Note:]%
+}{%
+ \endtrivlist
+}
+% \end{macrocode}
+%
+% Turn off \cs{autoindex} during \cn{tableofcontents} or similar.
+% \begin{macrocode}
+\def\@starttoc#1{\begingroup
+ \let\autoindex\@gobble
+ \makeatletter
+ \@input{\jobname.#1}\if@filesw
+ \expandafter\newwrite\csname tf@#1\endcsname
+ \immediate\openout
+ \csname tf@#1\endcsname \jobname.#1\relax
+ \fi \global\@nobreakfalse \endgroup}
+% \end{macrocode}
+%
+% Make glossary commands a no-op for the moment. [mjd,1994/10/03]
+% Provide a \cn{secref} command for section references.
+% \begin{macrocode}
+%<*amsldoc>
+\newcommand{\gloss}[1]{}
+%</amsldoc>
+\newcommand*{\secref}[1]{\S\ref{#1}}
+% \end{macrocode}
+%
+% We can write |\qc{\%}| to quote a single
+% character in situations where |\verb"%"| would not work, mainly
+% when text is read as a macro argument (e.g., footnotes).
+% \begin{macrocode}
+\newcommand{\qc}[1]{}% check for prior definition
+\edef\qc#1{\noexpand\protect\expandafter\noexpand\csname qc \endcsname
+ \noexpand\protect#1}
+% \end{macrocode}
+% For this function the first argument is \cn{protect} and just needs
+% to be discarded. The method for removing a leading backslash is to
+% turn off \cs{escapechar}; this is more forgiving of variations like
+% |\qc{$}|. If the argument is `|\ |' we print a cmtt visible-space
+% character, \qc{\ }.
+% \begin{macrocode}
+\@namedef{qc }#1#2{\begingroup\ntt
+ \ifx\ #2\char`\ \else\escapechar\m@ne\string#2\fi\endgroup}
+% \end{macrocode}
+% Declare a few character names to avoid e.g., indexing difficulties.
+% \begin{macrocode}
+\DeclareRobustCommand{\qcat}{\qc\@}%
+\DeclareRobustCommand{\qcamp}{\qc\&}%
+\DeclareRobustCommand{\qcbang}{\qc\!}%
+% \end{macrocode}
+%
+% \begin{macro}{\arg}
+% Change \cn{arg} to print a macro argument number:
+% \begin{macrocode}
+\DeclareRobustCommand{\arg}[1]{{\ntt\##1}}
+% \end{macrocode}
+% \end{macro}
+%
+% We need to emulate the \pkg{amsthm} \cn{qedsymbol} for the
+% \amslatex/ user's guide.
+% \begin{macrocode}
+%<*amsldoc>
+\newcommand{\openbox}{\leavevmode
+ \hbox to.77778em{%
+ \hfil\vrule
+ \vbox to.675em{\hrule width.6em\vfil\hrule}%
+ \vrule\hfil}}
+\newcommand{\qedsymbol}{\openbox}
+%</amsldoc>
+% \end{macrocode}
+%
+% Logical markup for e-mail address:
+% \begin{macrocode}
+%<amsldoc>\def\mail{\texttt}
+% \end{macrocode}
+%
+% Shorthand for indexing:
+% \begin{macrocode}
+%<*amsldoc>
+\def\*#1{\def\@tempa{#1}\def\@tempb{*}%
+ \ifx\@tempa\@tempb \expandafter\index
+ \else #1\index{#1}\fi}
+%</amsldoc>
+% \end{macrocode}
+%
+% Non-indexed \cn{cn} (maybe call this |\cn*|?)
+% \begin{macrocode}
+\def\ncn#1{{\let\index\@gobble\cn{#1}}}
+% \end{macrocode}
+% Indexing difficulties with !, @.
+% \begin{macrocode}
+
+\DeclareRobustCommand{\cnbang}{%
+ \ncn{\!}\index{"!@{\ntt\bslchar\qcbang}}}
+\DeclareRobustCommand{\cnat}{%
+ \ncn{\!}\index{"@@{\ntt\bslchar\qcat}}}
+% \end{macrocode}
+%
+% Shorthand for a discouraged, but not forbidden, line break:
+% \begin{macrocode}
+\def\5{\penalty500 }
+% \end{macrocode}
+%
+% Environment for error message examples. Use \cs{meaning} to allow
+% reading the error message text as an ordinary brace-delimited arg
+% but still be able to print embedded braces; and first change the
+% backslash catcode to prevent extra spaces after control words.
+% \begin{macrocode}
+%<*amsldoc>
+\newenvironment{error}{%
+ \begingroup\catcode`\\=12 \expandafter\endgroup\errora
+}{%
+ \endtrivlist
+}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\newcommand{\errora}[1]{%
+ \trivlist
+ \item[\hskip\labelsep\errorbullet\enspace
+ \ntt\frenchspacing\def\@tempa{#1}%
+ \expandafter\strip@prefix\meaning\@tempa]\leavevmode\par
+}
+% \end{macrocode}
+% \cs{errorbullet} is just an attempt at a simple graphic device that
+% doesn't require any special fonts.
+% \begin{macrocode}
+\newcommand{\errorbullet}{\rule[-.5pt]{2.5pt}{7.5pt}%
+ \rule[-.5pt]{5pt}{2.5pt}\kern-2.5pt%
+ \rule[4.5pt]{2.5pt}{2.5pt}}
+%</amsldoc>
+% \end{macrocode}
+% A couple of subheading commands:
+% \begin{macrocode}
+\newcommand{\errexa}{\par\noindent\textit{Example}:\ }
+\newcommand{\errexpl}{\par\noindent\textit{Explanation}:\ }
+% \end{macrocode}
+%
+% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% \section{\cls{amsldoc} style modifications for sectioning commands}
+% The following section deals with book commands (part, chapter,
+% frontmatter, \dots).
+% \begin{macrocode}
+%<*amsldoc>
+% \end{macrocode}
+%
+% Modifications of sectioning commands from \fn{book.cls}, mostly
+% reducing font sizes and vertical spacing.
+% \begin{macrocode}
+\renewcommand\frontmatter{\clearpage
+ \@mainmatterfalse\pagenumbering{roman}}
+\renewcommand\mainmatter{\clearpage
+ \@mainmattertrue\pagenumbering{arabic}}
+\renewcommand\backmatter{\clearpage \@mainmatterfalse}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\renewcommand\part{\clearpage
+ \thispagestyle{plain}%
+ \if@twocolumn
+ \onecolumn
+ \@tempswatrue
+ \else
+ \@tempswafalse
+ \fi
+ \hbox{}\vfil
+ \secdef\@part\@spart}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\@part[#1]#2{%
+ \ifnum \c@secnumdepth >-2\relax
+ \refstepcounter{part}%
+ \addcontentsline{toc}{part}{\thepart\hspace{1em}#1}%
+ \else
+ \addcontentsline{toc}{part}{#1}%
+ \fi
+ \markboth{}{}%
+ {\centering
+ \interlinepenalty \@M
+ \reset@font
+ \ifnum \c@secnumdepth >-2\relax
+ \Large\bfseries \partname~\thepart
+ \par
+ \vskip 20\p@
+ \fi
+ \Large \bfseries #2\par}%
+ \@endpart}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\@spart#1{%
+ {\centering
+ \interlinepenalty \@M
+ \reset@font
+ \Large \bfseries #1\par}%
+ \@endpart}
+\def\@endpart{\vfil\newpage
+ \if@twoside
+ \hbox{}%
+ \thispagestyle{empty}%
+ \newpage
+ \fi
+ \if@tempswa
+ \twocolumn
+ \fi}
+%</amsldoc>
+% \end{macrocode}
+%
+% \begin{macrocode}
+\renewcommand\chapter{\par \@afterindentfalse
+ \secdef\@chapter\@schapter}
+\def\@chapter[#1]#2{\ifnum \c@secnumdepth >\m@ne
+ \if@mainmatter
+ \refstepcounter{chapter}%
+ \typeout{\@chapapp\space\thechapter.}%
+ \addcontentsline{toc}{chapter}%
+ {\protect\numberline{\thechapter}#1}%
+ \else
+ \addcontentsline{toc}{chapter}{#1}\fi
+ \else
+ \addcontentsline{toc}{chapter}{#1}
+ \fi
+ \chaptermark{#1}%
+ \addtocontents{lof}{\protect\addvspace{10\p@}}%
+ \addtocontents{lot}{\protect\addvspace{10\p@}}%
+ \if@twocolumn
+ \@topnewpage[\@makechapterhead{#2}]%
+ \else
+ \@makechapterhead{#2}%
+ \@afterheading
+ \fi}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\@makechapterhead#1{%
+ \vspace{1.5\baselineskip}%
+ {\parindent \z@ \raggedright \reset@font
+ \ifnum \c@secnumdepth >\m@ne
+ \large\bfseries \@chapapp\space\thechapter
+ \par\nobreak
+ \vskip.5\baselineskip\relax
+ \fi
+ #1\par\nobreak
+ \vskip\baselineskip
+ }}
+\def\@schapter#1{\if@twocolumn
+ \@topnewpage[\@makeschapterhead{#1}]%
+ \else
+ \@makeschapterhead{#1}%
+ \@afterheading
+ \fi}
+\def\@makeschapterhead#1{%
+ \vspace*{1.5\baselineskip}%
+ {\parindent \z@ \raggedright
+ \reset@font
+ \large \bfseries #1\par\nobreak
+ \vskip\baselineskip
+ }}
+% \end{macrocode}
+%
+% Add Donald Arseneau's \cs{@removefromreset}; used to decouple the
+% footnote counter from \cn{chapter}, since chapters here do not
+% automatically start on a new page. [bnb, 1999/09/27]
+% \begin{verbatim}
+% \@removefromreset{FOO}{BAR} : Removes counter FOO from the list of
+% counters \cl@BAR to be reset when counter BAR
+% is stepped. The opposite of \@addtoreset.
+% \end{verbatim}
+% \begin{macrocode}
+\def\@removefromreset#1#2{\let\@tempb\@elt
+ \expandafter\let\expandafter\@tempa\csname c@#1\endcsname
+ \def\@elt##1{\expandafter\ifx\csname c@##1\endcsname\@tempa\else
+ \noexpand\@elt{##1}\fi}%
+ \expandafter\edef\csname cl@#2\endcsname{\csname cl@#2\endcsname}%
+ \let\@elt\@tempb}
+\@removefromreset{footnote}{chapter}
+% \end{macrocode}
+%
+% Change running head font to \cn{footnotesize}, nonslanted.
+% \begin{macrocode}
+\def\ps@headings{%
+ \let\@oddfoot\@empty\let\@evenfoot\@empty
+ \def\@evenhead{\thepage\hfil{\footnotesize\leftmark{}{}}}%
+ \def\@oddhead{{\footnotesize\rightmark{}{}}\hfil\thepage}%
+ \let\@mkboth\markboth
+ \def\chaptermark##1{%
+ \markboth {\uppercase{\ifnum \c@secnumdepth >\m@ne
+ \if@mainmatter
+ \@chapapp\ \thechapter. \ \fi
+ \fi
+ ##1}}{}}%
+ \def\sectionmark##1{%
+ \markright {\uppercase{\ifnum \c@secnumdepth >\z@
+ \thesection. \ \fi
+ ##1}}}}
+% \end{macrocode}
+%
+%
+% \section{\cls{amsdtx} style modifications for sectioning commands}
+% These definitions for \cn{maketitle} are from \fn{article.cls}.
+% \begin{macrocode}
+%<*amsdtx>
+\renewcommand\maketitle{\par
+ \begingroup
+ \renewcommand\thefootnote{\fnsymbol{footnote}}%
+ \def\@makefnmark{\hbox to\z@{$\m@th^{\@thefnmark}$\hss}}%
+ \long\def\@makefntext##1{\parindent 1em\noindent
+ \hbox to1.8em{\hss$\m@th^{\@thefnmark}$}##1}%
+ \if@twocolumn
+ \ifnum \col@number=\@ne
+ \@maketitle
+ \else
+ \twocolumn[\@maketitle]%
+ \fi
+ \else
+ \newpage
+ \global\@topnum\z@ % Prevents figures from going at top of page.
+ \@maketitle
+ \fi
+ \thispagestyle{plain}\@thanks
+ \endgroup
+ \setcounter{footnote}{0}%
+ \let\thanks\relax
+ \let\maketitle\relax\let\@maketitle\relax
+ \gdef\@thanks{}\gdef\@author{}\gdef\@title{}}
+%
+\def\@maketitle{%
+ \newpage
+ \null
+ \vskip 2em%
+ \begin{center}%
+ {\LARGE \@title \par}%
+ \vskip 1.5em%
+ {\large
+ \lineskip .5em%
+ \begin{tabular}[t]{c}%
+ \@author
+ \end{tabular}\par}%
+ \vskip 1em%
+ {\large \@date}%
+ \end{center}%
+ \par
+% \end{macrocode}
+% Put the title into both running heads.
+% \begin{macrocode}
+ \uppercase\expandafter{\expandafter\toks@\expandafter{\@title}}%
+ \edef\@tempa{\noexpand\markboth{\the\toks@}{\the\toks@}}%
+ \@tempa
+ \vskip 1.5em}
+%</amsdtx>
+% \end{macrocode}
+%
+% Edit the table of contents.
+% \begin{macrocode}
+%<*amsdtx>
+\renewcommand\tableofcontents{%
+ \if@twocolumn
+ \@restonecoltrue\onecolumn
+ \else
+ \@restonecolfalse
+ \fi
+ \subsection*{\contentsname}%
+ \@starttoc{toc}%
+ \if@restonecol\twocolumn\fi
+ }
+%</amsdtx>
+% \end{macrocode}
+%
+% Edit the sectioning commands.
+% \begin{macrocode}
+\renewcommand\section{\@startsection {section}{1}{\z@}%
+ {-.6\baselineskip \@plus -3\p@}%
+ {.4\baselineskip}
+%<amsdtx> {\reset@font\Large\bfseries}}
+%<amsldoc> {\reset@font\normalsize\bfseries}}
+\renewcommand\subsection{\@startsection{subsection}{2}{\z@}%
+ {-.3\baselineskip\@plus -2\p@}%
+ {.2\baselineskip}%
+%<amsdtx> {\reset@font\large\bfseries}}
+%<amsldoc> {\reset@font\normalsize\bfseries}}
+\renewcommand\subsubsection{\@startsection{subsubsection}{3}{\z@}%
+ {-.2\baselineskip\@plus -2\p@}%
+ {.2\baselineskip}%
+ {\reset@font\normalsize\bfseries}}
+% \end{macrocode}
+% Change index environment to turn off \cn{autoindex}.
+% \begin{macrocode}
+\renewenvironment{theindex}{%
+ \if@twocolumn \@restonecolfalse \else \@restonecoltrue \fi
+ \columnseprule \z@ \columnsep 35\p@
+ \let\autoindex\@gobble
+%<amsdtx> \twocolumn[\section*{\indexname}]%
+%<amsldoc> \twocolumn[\@makeschapterhead{\indexname}]%
+ \addcontentsline{toc}{chapter}{\indexname}%
+ \@mkboth{\uppercase{\indexname}}{\uppercase{\indexname}}%
+ \thispagestyle{plain}\parindent\z@
+ \parskip\z@ \@plus .3\p@\relax
+ \let\item\@idxitem
+}{%
+ \if@restonecol\onecolumn\else\clearpage\fi
+}
+% \end{macrocode}
+%
+% Take out \cn{thechapter} from \cn{thesection}.
+% \begin{macrocode}
+%<amsdtx>\renewcommand{\thesection}{\arabic{section}}
+% \end{macrocode}
+%
+% Change the style of captions slightly. Also incorporate some
+% caption improvements from Donald Arseneau (\fn{comp.text.tex}, 11
+% Oct 1994).
+% \begin{macrocode}
+\long\def\@makecaption#1#2{%
+ \addvspace\abovecaptionskip
+ \begingroup
+ \countdef\@parcycles=8 % local count register
+ \@parcycles\z@
+ \@setpar{\advance\@parcycles\@ne \ifnum\@parcycles>999
+ \@@par\@parcycles\z@\fi
+ \ifhmode \unskip\hskip\parfillskip\penalty-\@M\fi}%
+ \@hangfrom{\textbf{#1.} }\vadjust{\penalty\m@ne}#2%
+ \endgroup
+ \ifhmode\unpenalty\fi\par
+ \ifnum\lastpenalty=\m@ne % only one line in the caption
+ \unpenalty \setbox\@tempboxa\lastbox
+ \nointerlineskip
+ \hbox to\hsize{\hfill\unhbox\@tempboxa\unskip\hfill}%
+ \fi
+ \nobreak\vskip\belowcaptionskip
+}
+% \end{macrocode}
+% For table captions, assume top captions and so put space below the
+% caption rather than above:
+% \begin{macrocode}
+\renewenvironment{table}{%
+ \belowcaptionskip\abovecaptionskip \abovecaptionskip\z@skip
+ \@float{table}%
+}{%
+ \end@float
+}
+\renewenvironment{table*}{%
+ \belowcaptionskip\abovecaptionskip \abovecaptionskip\z@skip
+ \@dblfloat{table}%
+}{%
+ \end@dblfloat
+}
+% \end{macrocode}
+%
+% \section{Float placement parameters}
+% These control the placing of floating objects like tables and
+% figures. The values here, which are much more tolerant than the
+% \latex/ defaults, are more or less copied from \fn{amsclass.dtx}.
+% \begin{macrocode}
+\setcounter{topnumber}{4}\setcounter{bottomnumber}{4}
+\setcounter{totalnumber}{4}\setcounter{dbltopnumber}{4}
+\renewcommand{\topfraction}{.97}\renewcommand{\bottomfraction}{.97}
+\renewcommand{\textfraction}{.03}\renewcommand{\floatpagefraction}{.9}
+\renewcommand{\dbltopfraction}{.97}
+\renewcommand{\dblfloatpagefraction}{.9}
+\setlength{\floatsep}{8pt plus6pt}
+\setlength{\textfloatsep}{10pt plus8pt}
+\setlength{\intextsep}{8pt plus6pt}
+\setlength{\dblfloatsep}{8pt plus6pt}
+\setlength{\dbltextfloatsep}{10pt plus8pt}
+\setlength{\@fptop}{0pt}\setlength{\@fpsep}{8pt}%
+\setlength{\@fpbot}{0pt plus 1fil}
+\setlength{\@dblfptop}{0pt}\setlength{\@dblfpsep}{8pt}%
+\setlength{\@dblfpbot}{0pt plus 1fil}
+% \end{macrocode}
+
+% \begin{macrocode}
+\pagestyle{headings}
+% \end{macrocode}
+%
+% Make \verb"|...|" shorthand for verbatim fragments. In the case of
+% the \cls{amsldoc} class, we avoid requiring an extra package
+% (\pkg{doc} or \pkg{shortvrb}), to reduce the possibility of package
+% files not being found at run time.
+% \begin{macrocode}
+%<*amsldoc>
+\AtBeginDocument{\catcode`\|=\active }
+\def\activevert{\verb|}
+\expandafter\gdef\expandafter\dospecials\expandafter
+ {\dospecials \do\|}%
+\expandafter\gdef\expandafter\@sanitize\expandafter
+ {\@sanitize \@makeother\|}
+\begingroup\catcode`\|=\active \gdef|{\protect\activevert{}}\endgroup
+%</amsldoc>
+% \end{macrocode}
+%
+% \begin{macro}{\arrayargpatch}
+% If the column-specs arg of array or tabular contains a vert bar
+% character, and we have made vert bars active, it will cause
+% trouble. The following command, used in the ctab environment,
+% prevents the trouble.
+% \begin{macrocode}
+\newcommand{\arrayargpatch}{%
+ \let\@oldarray\@array
+ \edef\@array[##1]##2{\catcode\number`\|=\number\catcode`\|
+ \catcode\number`\@=\number\catcode`\@ \relax
+ \let\noexpand\@array\noexpand\@oldarray
+ \noexpand\@array[##1]{##2}}%
+ \catcode`\|=12 \catcode`\@=12 \relax
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{environment}{ctab}
+% An environment for centered tables.
+% \begin{macrocode}
+\newenvironment{ctab}{%
+ \par\topsep\medskipamount
+ \trivlist\centering
+ \item[]%
+ \arrayargpatch
+ \begin{tabular}%
+}{%
+ \end{tabular}%
+ \endtrivlist
+}
+% \end{macrocode}
+% \end{environment}
+%
+% Load \pkg{doc} package, reset \cn{AltMacroFont} to be the same as
+% \cn{MacroFont} (when there are large sections of conditional
+% code I think it looks better not to have it all slanted).
+% \begin{macrocode}
+%<*amsdtx>
+\RequirePackage{doc}
+\def\AltMacroFont{\MacroFont}
+% \end{macrocode}
+%
+% \begin{macro}{\SpecialMainEnvIndex}
+% Override \fn{doc.sty}'s main environment indexing to get rid of
+% the parens around ``environment'', for compatibility with our
+% \cs{env} command.
+% \begin{macrocode}
+\def\SpecialMainEnvIndex#1{%
+ \@bsphack
+ \special@index{%
+ #1\actualchar\string\texttt{#1} environment\encapchar main%
+ }%
+ \special@index{%
+ environments:\levelchar#1%
+ \actualchar\string\texttt{#1}%
+ \encapchar main}%
+ \@esphack
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\SpecialEnvIndex}
+% \begin{macrocode}
+\def\SpecialEnvIndex#1{%
+ \@bsphack
+ \index{#1\actualchar\string\texttt{#1} environment\encapchar usage}%
+ \index{%
+ environments:\levelchar#1%
+ \actualchar\string\texttt{#1}%
+ \encapchar usage}%
+ \@esphack
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\DescribeOption}
+% \begin{macrocode}
+\def\DescribeOption{%
+ \leavevmode
+ \@bsphack
+ \begingroup
+ \MakePrivateLetters
+ \Describe@Option
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\Describe@Option}
+% \begin{macrocode}
+\def\Describe@Option#1{%
+ \endgroup
+ \marginpar{\raggedleft\PrintDescribeOption{#1}}%
+ \SpecialOptionIndex{#1}%
+ \@esphack
+ \ignorespaces
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\PrintDescribeOption}
+% \begin{macrocode}
+\def\PrintDescribeOption#1{\strut \MacroFont #1\ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\option}
+% \begin{macrocode}
+\def\option{%
+ \let\SpecialMainEnvIndex\SpecialMainOptionIndex
+\begingroup
+ \catcode`\\12
+ \MakePrivateLetters \m@cro@ \iffalse}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\SpecialMainOptionIndex}
+% \begin{macrocode}
+\def\SpecialMainOptionIndex#1{%
+ \@bsphack
+ \special@index{#1\actualchar\string\texttt{#1} option\encapchar main}%
+ \@esphack
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\SpecialOptionIndex}
+% \begin{macrocode}
+\def\SpecialOptionIndex{\@category@index{option}}
+% \end{macrocode}
+% \end{macro}
+%
+% Ordinary \cn{DocInput} doesn't handle standardized file headers
+% unless you enclose them in \cs{iffalse} \dots\ \cs{fi} which I
+% don't care to do. So instead here's an alternate version of
+% \cn{DocInput}, called \cn{hDocInput}.
+% \begin{macrocode}
+\def\hDocInput#1{\MakePercentIgnore
+ \begingroup
+% \end{macrocode}
+% Define active \qc{\@} which should be the first non-percent,
+% non-equal-sign character when a file header is present. (If a file
+% header is not present, \cn{hDocInput} should not be used.)
+% \begin{macrocode}
+ \begingroup \lccode`\~=`\@
+ \lowercase{\endgroup\long\def ~}##1##{%
+ \catcode`\==12 \skipfileheader{##1}}%
+ \catcode`\@=\active \catcode`\==14 % comment
+ \def\filename{#1}%
+ \@@input#1 \MakePercentComment}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\skipfileheader#1#2 {\endgroup
+ \hGetFileInfo#2 version = "??" date = "??"\@nil
+ \begingroup\catcode`\==9 \catcode`\ =9 \futurelet\0\endgroup
+}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\long\def\hGetFileInfo#1 version = "#2"#3 date = "#4"#5\@nil{%
+ \def\fileversion{#2}\def\filedate{#4}}
+%</amsdtx>
+% \end{macrocode}
+%
+%
+% \section{Hyphenation exceptions}
+%
+% \begin{macrocode}
+\hyphenation{base-line-skip}
+% \end{macrocode}
+%
+% \section{Index exceptions}
+%
+% A bunch of stuff we don't want in code indexes:
+% \begin{macrocode}
+%<*amsdtx>
+\DoNotIndex{\@xp,\@nx,\@empty,\newcommand,\renewcommand}
+\DoNotIndex{\newenvironment,\renewenvironment,\providecommand}
+\DoNotIndex{\if,\fi,\ifnum,\fi,\@let@token,\futurelet,\fsa@n}
+\DoNotIndex{\ignorespaces,\@tempcnta,\@tempcntb,\count@}
+\DoNotIndex{\toks@,\@ne,\advance}
+\DoNotIndex{\!,\/,\?,\@,\^,\_}
+\DoNotIndex{\@@par,\@M,\@auxout,\@bsphack,\@esphack,\@depth,\@ehc}
+\DoNotIndex{\@for,\@flushglue,\@gobble,\@gobbletwo,\@height,\@idxitem}
+\DoNotIndex{\@ifnextchar,\@ifstar,\@ifundefined,\@input,\@latexerr}
+\DoNotIndex{\@makeschapterhead,\@namedef,\@nameuse,\@nil}
+\DoNotIndex{\@nobreakfalse,\@restonecolfalse,\@restonecoltrue}
+\DoNotIndex{\@tempa,\@tempb,\@tempc,\@tempf}
+\DoNotIndex{\@temptokena,\@temptokenb}
+\DoNotIndex{\@themark,\@width}
+\DoNotIndex{\active,\aindex,\baselineskip,\begin,\begingroup,\box}
+\DoNotIndex{\c@page,\catcode,\chapter,\char,\chardef,\closeout}
+\DoNotIndex{\CodelineIndex,\sp,\sb,\label,\leavevmode,\mark}
+\DoNotIndex{\mark,\newinsert,\newwrite,\newtoks,\xdef}
+\DoNotIndex{\columnsep,\columnseprule,\columnwidth,\csname,\def}
+\DoNotIndex{\dimen,\do,\DocInput,\documentstyle,\edef,\em}
+\DoNotIndex{\EnableCrossrefs,\end,\endcsname,\endgroup,\endinput}
+\DoNotIndex{\everypar,\expandafter,\filedate,\fileversion}
+\DoNotIndex{\footnotesize,\gdef,\global,\glossary,\hangindent}
+\DoNotIndex{\if@filesw,\else,\fi}
+\DoNotIndex{\if@nobreak,\if@twocolumn,\if@twoside,\fi,\fi,\fi}
+\DoNotIndex{\hsize,\hskip}
+\DoNotIndex{\ifhmode,\ifmmode,\ifodd,\ifvmode,\ifx,\fi,\fi,\fi,\fi,\fi}
+\DoNotIndex{\ifcase,\ifdim,\ifeof,\iffalse,\iftrue,\fi,\fi,\fi,\fi,\fi}
+\DoNotIndex{\ifcat,\fi}
+\DoNotIndex{\immediate,\insert,\item,\jobname,\long}
+\DoNotIndex{\let,\lineskip,\marginparsep,\marginparwidth,\maxdimen}
+\DoNotIndex{\makeatletter,\noexpand,\openout,\protect,\rlap}
+\DoNotIndex{\min,\newpage,\nobreak,\normalbaselineskip}
+\DoNotIndex{\normallineskip,\p@,\par,\parfillskip,\parindent,\parskip}
+\DoNotIndex{\penalty,\relax,\section,\sin,\sloppy,\space,\string}
+\DoNotIndex{\tableofcontents,\the,\thepage,\thispagestyle,\toks,\tt}
+\DoNotIndex{\twocolumn,\uppercase,\vbox,\vrule,\vskip,\vss}
+\DoNotIndex{\write,\z@,\z@skip}
+%</amsdtx>
+% \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.2b}{1995/02/15}{Added {}{} after rightmark, leftmark to
+% handle no-maketitle case}
+% \changes{v1.2b}{1995/02/15}{Added frenchspacing in error env heading}
+%
+% \changes{v1.2c}{1996/10/28}{Update version number, date for new release}
+%
+% \changes{v1.2d}{1997/03/13}{Fixed up loading method for OT1cmtt fd file}
+%
+% \changes{v2.03}{2004/04/06}{Reworked indexing commands for
+% compatibility with doc.sty}
+%
+% \changes{v2.04}{2004/04/07}{Further work on indexing commands for
+% compatibility with macro and environment environments in \fn{doc.sty}.
+% Also added \env{option} environment, \cs{DescribeOption},
+% \cs{PrintDescribeOption}, \cs{SpecialOptionIndex}, and
+% \cs{SpecialMainOptionIndex}.}
+%
+% \changes{v2.05}{2004/04/27}{Fixed the amsdtx \cs{env} so that it
+% prints its argument in addition to putting it in the index. Added
+% |\penalty\exhyphenpenalty| to \cs{mdash} and \cs{ndash} as per
+% \pkg{textcmds}.}
+%
+% \CheckSum{1569}
+% \Finale
diff --git a/macros/latex/required/amscls/amsdtx.ins b/macros/latex/required/amscls/amsdtx.ins
new file mode 100644
index 0000000000..8ac5290de0
--- /dev/null
+++ b/macros/latex/required/amscls/amsdtx.ins
@@ -0,0 +1,77 @@
+%% filename: amsdtx.ins
+%% version: 1.00
+%% date: 2009/08/19
+%%
+%% American Mathematical Society
+%% Technical Support
+%% Publications Technical Group
+%% 201 Charles Street
+%% Providence, RI 02904
+%% USA
+%% tel: (401) 455-4080
+%% (800) 321-4267 (USA and Canada only)
+%% fax: (401) 331-3842
+%% email: tech-support@ams.org
+%%
+%% Copyright 1996, 1999, 2004, 2009 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
+%% 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.
+%%
+%% This work has the LPPL maintenance status `maintained'.
+%%
+%% The Current Maintainer of this work is the American Mathematical
+%% Society.
+%%
+%% ====================================================================
+
+\input docstrip
+
+\askforoverwritefalse
+
+\keepsilent
+
+\preamble
+This is a generated file.
+
+Copyright 1996, 1999, 2004, 2009 American Mathematical Society.
+
+American Mathematical Society
+Technical Support
+Publications Technical Group
+201 Charles Street
+Providence, RI 02904
+USA
+tel: (401) 455-4080
+ (800) 321-4267 (USA and Canada only)
+fax: (401) 331-3842
+email: tech-support@ams.org
+
+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
+ 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.
+
+This work has the LPPL maintenance status `maintained'.
+
+The Current Maintainer of this work is the American Mathematical
+Society.
+
+========================================================================
+
+\endpreamble
+
+\generate{
+ \file{amsdtx.cls} {\from{amsdtx.dtx}{amsdtx}}
+ \file{amsldoc.cls}{\from{amsdtx.dtx}{amsldoc}}
+}
+
+\endbatchfile
diff --git a/macros/latex/required/amscls/amsmidx.dtx b/macros/latex/required/amscls/amsmidx.dtx
new file mode 100644
index 0000000000..8a4174484e
--- /dev/null
+++ b/macros/latex/required/amscls/amsmidx.dtx
@@ -0,0 +1,232 @@
+% \def\filename{amsmidx.dtx}
+% \def\fileversion{2.02}
+% \def\filedate{2007/09/25}
+%
+% \iffalse meta-comment
+%
+% American Mathematical Society
+% Technical Support
+% Publications Technical Group
+% 201 Charles Street
+% Providence, RI 02904
+% USA
+% tel: (401) 455-4080
+% (800) 321-4267 (USA and Canada only)
+% fax: (401) 331-3842
+% email: tech-support@ams.org
+%
+% Copyright 1995, 2004, 2009, 2010 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
+% 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.
+%
+% This work has the LPPL maintenance status `maintained'.
+%
+% The Current Maintainer of this work is the American Mathematical
+% Society.
+%
+% \fi
+%
+% \iffalse
+%<*driver>
+\documentclass{amsdtx}
+\begin{document}
+\title{The \pkg{amsmidx} package}
+\author{American Mathematical Society\\Barbara Beeton}
+\date{Version \fileversion, \filedate}
+\DocInput{amsmidx.dtx}
+\end{document}
+%</driver>
+% \fi
+%
+% \maketitle
+%
+% \MakeShortVerb\|
+%
+% \section{Introduction}
+%
+% This package provides the facility to produce multiple indexes
+% with \amslatex/ document classes (particularly \fn{amsbook} and
+% the AMS author packages for books), superseding the built-in
+% index facility which can accommodate only one index. This may
+% in the future be incorporated as an option into the \amslatex/
+% document classes.
+%
+% This package is based on \pkg{multind.sty} by F.W. Long.
+%
+% \StopEventually{}
+%
+% Standard file identification.
+% \begin{macrocode}
+\NeedsTeXFormat{LaTeX2e}[1995/06/01]
+\ProvidesPackage{amsmidx}[2007/09/25 v2.02 multiple indexes for AMS classes]
+% \end{macrocode}
+%
+% \section{User instructions}
+%
+% In the preamble, invoke \cn{makeindex} with a file name to provide
+% as many indexes as desired:
+%\begin{verbatim}
+% \makeindex{filename-a}
+% \makeindex{filename-b}
+%\end{verbatim}
+% This will initiate the creation of \fn{filename-a.idx} etc.
+%
+% In the body of the text, use the \cn{index} command with two
+% arguments
+%\begin{verbatim}
+% \index{filename-a}{index term}
+%\end{verbatim}
+% as appropriate to populate the \fn{.idx} files.
+%
+% In the \cn{backmatter} segment of the driver file, insert the
+% \cn{Printendex} command to print the indexes; the second argument
+% gives the title to be printed at the top of the index:
+%\begin{verbatim}
+% \Printindex{filename-a}{First Index}
+% \Printindex{filename-b}{Second Index}
+%\end{verbatim}
+%
+% On the first pass, the \fn{.idx} files will be created. Process
+% each \fn{.idx} file with \textit{MakeIndex} to generate an \fn{.ind}
+% file, which will then be read in by \cn{Printindex}. Whenever any
+% page references change, be sure to run \textit{MakeIndex} again,
+% and process the entire job with \latex/ once more to get the correct
+% page references in the indexes.
+%
+% To include a paragraph of comments below the index title, insert
+% the text as an \cn{indexcomment} before the relevant \cn{Printindex}:
+%\begin{verbatim}
+% \indexcomment{Text of comments}
+% \Printindex{...}{...}
+%\end{verbatim}
+% The \cn{indexcomment} text will be cleared after use.
+%
+%
+% \section{Implementation}
+%
+% \begin{macro}{\makeindex}
+% Redefine \cn{makeindex} to create a new \fn{.idx} file with the
+% name provided by argument |#1|.
+% \begin{macrocode}
+\renewcommand{\makeindex}[1]{%
+ \begingroup
+ \makeatletter
+ \if@filesw \expandafter\newwrite\csname #1@idxfile\endcsname
+ \expandafter\immediate\openout \csname #1@idxfile\endcsname #1.idx\relax
+ \typeout{Writing index file #1.idx }\fi
+ \endgroup}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\index}
+% Redefine \cn{index} to specify into which file/index the term is
+% to be placed. Argument |#1| identifies the file, |#2| provides
+% the text of the term to be indexed.
+% \begin{macrocode}
+\renewcommand{\index}[1]{%
+ \@bsphack
+ \begingroup
+ \def\protect##1{\string##1\space}\@sanitize\@wrindex{#1}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@wrindex}
+% \cs{@wrindex} checks to make sure that the requested file is available,
+% and writes an entry into the file or emits an error message.
+% \begin{macrocode}
+\renewcommand{\@wrindex}[2]{%
+ \let\thepage\relax
+ \xdef\@gtempa{%
+ \@ifundefined{#1@idxfile}{%
+ \PackageError{\@packagename}{%
+ The requested file, #1@idxfile.idx, does not exist;\MessageBreak
+ index term #2 will not be be written out.%
+ }%
+ }{%
+ \expandafter\write\csname #1@idxfile\endcsname
+ {\string\indexentry{#2}{\thepage}}%
+ }%
+ }%
+ \endgroup\@gtempa
+ \if@nobreak \ifvmode\nobreak\fi\fi
+ \@esphack
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\printindex}
+% \begin{macro}{\Printindex}
+% Redefine \cs{printindex} to specify the file to be included; provide
+% an alternate command \cs{Printindex} that specifies both the file and
+% the index title to be printed. Argument |#1| identifies the file,
+% |#2| provides the title. Also modify some formatting commands to
+% improve the appearance of index entries, especially long ones in
+% the presence of three index levels.
+% \begin{macrocode}
+\renewcommand{\printindex}[1]{\@input{#1.ind}}
+\newcommand{\Printindex}[2]{%
+ \begingroup
+ \cleardoublepage
+ \def\indexname{#2}%
+ \raggedright
+ \hyphenpenalty=10000
+ \renewcommand{\seename}{see~also}
+ \renewcommand{\subitem}{\par\hangindent 3em\hspace*{1em}}
+ \@input{#1.ind}%
+ \endgroup
+ }
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\indexcomment}
+% \begin{macro}{\indexchap}
+% Format comments in a block somewhat narrower than the full page
+% width, and redefine \cn{indexchap} to insert the block below the
+% title, before starting the two-column index. Clear out
+% \cs{indexcomment} after use.
+% \begin{macrocode}
+\newdimen\@indexcommentwidth
+\@indexcommentwidth=\textwidth
+\ifdim\@indexcommentwidth > 26pc
+ \advance\@indexcommentwidth-6pc
+\else
+ \advance\@indexcommentwidth-4pc
+\fi
+\newcommand{\indexcomment}[1]{%
+ \def\theindexcomment{%
+ \vskip\baselineskip
+ \parbox[t]{\@indexcommentwidth}{\normalsize\mdseries#1}%
+ }%
+ }
+\let\theindexcomment\@empty
+\renewcommand{\indexchap}[1]{%
+ \global\topskip 7.5pc\relax
+ \twocolumn[\fontsize{\@xivpt}{18}%
+ \vskip\topskip\vskip-\baselineskip\hbox{}% adjust top space
+ \bfseries\centering #1\par
+ \ifx\theindexcomment\@empty
+ \else \theindexcomment
+ \global\let\theindexcomment\@empty
+ \fi
+ ]%
+ \global\topskip 34\p@
+}
+% \end{macrocode}
+% \end{macro}
+% \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{131}
+% \Finale
diff --git a/macros/latex/required/amscls/amsmidx.ins b/macros/latex/required/amscls/amsmidx.ins
new file mode 100644
index 0000000000..b69f121d23
--- /dev/null
+++ b/macros/latex/required/amscls/amsmidx.ins
@@ -0,0 +1,76 @@
+%% filename: amsmidx.ins
+%% version: 1.1
+%% date: 2014/07/24
+%%
+%% American Mathematical Society
+%% Technical Support
+%% Publications Technical Group
+%% 201 Charles Street
+%% Providence, RI 02904
+%% USA
+%% tel: (401) 455-4080
+%% (800) 321-4267 (USA and Canada only)
+%% fax: (401) 331-3842
+%% email: tech-support@ams.org
+%%
+%% Copyright 2010, 2014 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
+%% 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.
+%%
+%% This work has the LPPL maintenance status `maintained'.
+%%
+%% The Current Maintainer of this work is the American Mathematical
+%% Society.
+%%
+%% ====================================================================
+
+\input docstrip
+
+\askforoverwritefalse
+
+\keepsilent
+
+\preamble
+This is a generated file.
+
+Copyright 1995, 2004, 2009, 2010 American Mathematical Society.
+
+American Mathematical Society
+Technical Support
+Publications Technical Group
+201 Charles Street
+Providence, RI 02904
+USA
+tel: (401) 455-4080
+ (800) 321-4267 (USA and Canada only)
+fax: (401) 331-3842
+email: tech-support@ams.org
+
+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
+ 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.
+
+This work has the LPPL maintenance status `maintained'.
+
+The Current Maintainer of this work is the American Mathematical
+Society.
+
+========================================================================
+
+\endpreamble
+
+\generate{
+ \file{amsmidx.sty}{\from{amsmidx.dtx}{}}
+}
+
+\endbatchfile
diff --git a/macros/latex/required/amscls/amsplain.bst b/macros/latex/required/amscls/amsplain.bst
new file mode 100644
index 0000000000..2c83543057
--- /dev/null
+++ b/macros/latex/required/amscls/amsplain.bst
@@ -0,0 +1,1245 @@
+%% filename: amsplain.bst
+%% version: 2.0
+%% date: 2000/03/27
+%%
+%% American Mathematical Society
+%% Technical Support
+%% Publications Technical Group
+%% 201 Charles Street
+%% Providence, RI 02904
+%% USA
+%% tel: (401) 455-4080
+%% (800) 321-4267 (USA and Canada only)
+%% fax: (401) 331-3842
+%% email: tech-support@ams.org
+%%
+%% Copyright 1995, 2000, 2010 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
+%% 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.
+%%
+%% This work has the LPPL maintenance status `maintained'.
+%%
+%% The Current Maintainer of this work is the American Mathematical
+%% Society.
+%%
+%% ====================================================================
+
+% See the file btxbst.doc for extra documentation other than
+% what is included here. And see btxhak.tex for a description
+% of the BibTeX language and how to use it.
+
+% This defines the types of fields that can occur in a database entry
+% for this particular bibliography style. Except for `language',
+% this is the standard list from plain.bst.
+
+%% Types of entries currently allowed in a BibTeX file:
+%%
+%% ARTICLE -- An article from a journal or magazine.
+%%
+%% BOOK -- A book with an explicit publisher.
+%%
+%% BOOKLET -- A work that is printed and bound,
+%% but without a named publisher or sponsoring institution.
+%%
+%% CONFERENCE -- The same as INPROCEEDINGS,
+%% included for Scribe compatibility.
+%%
+%% INBOOK -- A part of a book,
+%% which may be a chapter (or section or whatever) and/or a range of pages.
+%%
+%% INCOLLECTION -- A part of a book having its own title.
+%%
+%% INPROCEEDINGS -- An article in a conference proceedings.
+%%
+%% MANUAL -- Technical documentation.
+%%
+%% MASTERSTHESIS -- A Master's thesis.
+%%
+%% MISC -- Use this type when nothing else fits.
+%%
+%% PHDTHESIS -- A PhD thesis.
+%%
+%% PROCEEDINGS -- The proceedings of a conference.
+%%
+%% TECHREPORT -- A report published by a school or other institution,
+%% usually numbered within a series.
+%%
+%% UNPUBLISHED -- A document having an author and title, but not formally
+%% published.
+
+ENTRY
+ { address
+ author
+ booktitle
+ chapter
+ edition
+ editor
+ howpublished
+ institution
+ journal
+ key
+ language
+ month
+ mrnumber
+ note
+ number
+ organization
+ pages
+ publisher
+ school
+ series
+ title
+ type
+ volume
+ year
+ }
+ {}
+ { label bysame }
+
+% Removed after.sentence, after.block---not needed.
+
+INTEGERS { output.state before.all mid.sentence }
+
+FUNCTION {init.state.consts}
+{ #0 'before.all :=
+ #1 'mid.sentence :=
+}
+
+% Scratch variables:
+
+STRINGS { s t }
+
+% Utility functions
+
+FUNCTION {shows}
+{ duplicate$ ":::: `" swap$ * "'" * top$
+}
+
+FUNCTION {showstack}
+{"STACK====================================================================="
+top$
+stack$
+"ENDSTACK=================================================================="
+top$
+}
+
+FUNCTION {not}
+{ { #0 }
+ { #1 }
+ if$
+}
+
+FUNCTION {and}
+{ 'skip$
+ { pop$ #0 }
+ if$
+}
+
+FUNCTION {or}
+{ { pop$ #1 }
+ 'skip$
+ if$
+}
+
+FUNCTION {field.or.null}
+{ duplicate$ empty$
+ { pop$ "" }
+ 'skip$
+ if$
+}
+
+FUNCTION {emphasize}
+{ duplicate$ empty$
+ { pop$ "" }
+ { "\emph{" swap$ * "}" * }
+ if$
+}
+
+% n.dashify is used to make sure page ranges get the TeX code
+% (two hyphens) for en-dashes.
+
+FUNCTION {n.dashify}
+{ 't :=
+ ""
+ { t empty$ not }
+ { t #1 #1 substring$ "-" =
+ { t #1 #2 substring$ "--" = not
+ { "--" *
+ t #2 global.max$ substring$ 't :=
+ }
+ { { t #1 #1 substring$ "-" = }
+ { "-" *
+ t #2 global.max$ substring$ 't :=
+ }
+ while$
+ }
+ if$
+ }
+ { t #1 #1 substring$ *
+ t #2 global.max$ substring$ 't :=
+ }
+ if$
+ }
+ while$
+}
+
+% tie.or.space.connect connects two items with a ~ if the
+% second item is less than 3 letters long, otherwise it just puts an
+% ordinary space.
+
+FUNCTION {tie.or.space.connect}
+{ duplicate$ text.length$ #3 <
+ { "~" }
+ { " " }
+ if$
+ swap$ * *
+}
+
+FUNCTION {add.space.if.necessary}
+{ duplicate$ "" =
+ 'skip$
+ { " " * }
+ if$
+}
+
+% either.or.check gives a warning if two mutually exclusive fields
+% were used in the database.
+
+FUNCTION {either.or.check}
+{ empty$
+ 'pop$
+ { "can't use both " swap$ * " fields in " * cite$ * warning$ }
+ if$
+}
+
+% output.nonnull is called by output.
+
+FUNCTION {output.nonnull}
+% remove the top item from the stack because it's in the way.
+{ 's :=
+ output.state mid.sentence =
+% If we're in mid-sentence, add a comma to the new top item and write it
+ { ", " * write$ }
+% Otherwise, if we're at the beginning of a bibitem,
+ { output.state before.all =
+% just write out the top item from the stack;
+ 'write$
+% and the last alternative is that we're at the end of the current
+% bibitem, so we add a period to the top stack item and write it out.
+ { add.period$ " " * write$ }
+ if$
+ mid.sentence 'output.state :=
+ }
+ if$
+% Put the top item back on the stack that we removed earlier.
+ s
+}
+
+% Output checks to see if the stack top is empty; if not, it
+% calls output.nonnull to write it out.
+
+FUNCTION {output}
+{ duplicate$ empty$
+ 'pop$
+ 'output.nonnull
+ if$
+}
+
+% Standard warning message for a missing or empty field. For the user
+% we call any such field `missing' without respect to the distinction
+% made by BibTeX between missing and empty.
+
+FUNCTION {missing.warning}
+{ "missing " swap$ * " in " * cite$ * warning$ }
+
+% Output.check is like output except that it gives a warning on-screen
+% if the given field in the database entry is empty. t is the field
+% name.
+
+FUNCTION {output.check}
+{ 't :=
+ duplicate$ empty$
+ { pop$ t missing.warning }
+ 'output.nonnull
+ if$
+}
+
+FUNCTION {output.bibitem}
+{ newline$
+ "\bibitem{" write$
+ cite$ write$
+ "}" write$
+ newline$
+% This empty string is the first thing that will be written
+% the next time write$ is called. Done this way because each
+% item is saved on the stack until we find out what punctuation
+% should be added after it. Therefore we need an empty first item.
+ ""
+ before.all 'output.state :=
+}
+
+FUNCTION {output.nonempty.mrnumber}
+{ duplicate$ missing$
+ { pop$ "" }
+ 'skip$
+ if$
+ duplicate$ empty$
+ 'pop$
+ { " \MR{" swap$ * "}" * write$ }
+ if$
+}
+
+FUNCTION {fin.entry}
+{ add.period$
+ write$
+ mrnumber output.nonempty.mrnumber
+ newline$
+}
+
+% Removed new.block, new.block.checka, new.block.checkb, new.sentence,
+% new.sentence.checka, and new.sentence.checkb functions here, since they
+% don't seem to be needed in the AMS style. Also moved some real
+% basic functions like `and' and 'or' earlier in the file.
+
+INTEGERS { nameptr namesleft numnames }
+
+% The extra section to write out a language field was added
+% for AMSPLAIN.BST. Not present in plain.bst.
+
+FUNCTION {format.language}
+{ language empty$
+ { "" }
+ { " (" language * ")" * }
+ if$
+}
+
+% This version of format.names puts names in the format
+%
+% First von Last, Jr.
+%
+% (i.e., first name first, no abbreviating to initials).
+
+FUNCTION {format.names}
+{ 's :=
+ #1 'nameptr :=
+ s num.names$ 'numnames :=
+ numnames 'namesleft :=
+ { namesleft #0 > }
+ { s nameptr "{ff~}{vv~}{ll}{, jj}" format.name$ 't :=
+ nameptr #1 >
+ { namesleft #1 >
+ { ", " * t * }
+ { numnames #2 >
+ { "," * }
+ 'skip$
+ if$
+ t "others" =
+ { " et~al." * }
+ { " and " * t * }
+ if$
+ }
+ if$
+ }
+ 't
+ if$
+ nameptr #1 + 'nameptr :=
+ namesleft #1 - 'namesleft :=
+ }
+ while$
+}
+
+FUNCTION {format.authors}
+{ author empty$
+ { "" }
+ { bysame "\bysame" =
+ {"\bysame"}
+ { author format.names }
+ if$
+ }
+ if$
+}
+
+FUNCTION {format.editors}
+{ editor empty$
+ { "" }
+ { editor format.names
+ editor num.names$ #1 >
+ { " (eds.)" * }
+ { " (ed.)" * }
+ if$
+ }
+ if$
+}
+
+FUNCTION {format.nonauthor.editors}
+{ editor empty$
+ { "" }
+ { editor format.names
+ editor num.names$ #1 >
+ { ", eds." * }
+ { ", ed." * }
+ if$
+ }
+ if$
+}
+
+FUNCTION {format.title}
+{ title empty$
+ { "" }
+ { title "t" change.case$ emphasize }
+ if$
+}
+
+FUNCTION {format.journal.vol.year}
+{ journal empty$
+ { "journal name" missing.warning ""}
+ { journal }
+ if$
+ volume empty$
+ 'skip$
+ { " \textbf{" * volume * "}" * }
+ if$
+ year empty$
+ { "year" missing.warning }
+ { " (" * year * ")" * }
+ if$
+}
+
+% For formatting the issue number for a journal article.
+
+FUNCTION {format.number}
+{ number empty$
+ { "" }
+ { "no.~" number * }
+ if$
+}
+
+% For formatting miscellaneous dates
+
+FUNCTION {format.date}
+{ year empty$
+ { month empty$
+ { "" }
+ { "there's a month but no year in " cite$ * warning$
+ month
+ }
+ if$
+ }
+ { month empty$
+ 'year
+ { month " " * year * }
+ if$
+ }
+ if$
+}
+
+%% The volume, series and number information is sort of tricky.
+%% This code handles it as follows:
+%% If the series is present, and the volume, but not the number,
+%% then we do "\emph{Book title}, Series Name, vol. 000"
+%% If the series is present, and the number, but not the volume,
+%% then we do "\emph{Book title}, Series Name, no. 000"
+%% If the series is present, and both number and volume,
+%% then we do "\emph{Book title}, vol. XX, Series Name, no. 000"
+%% Finally, if the series is absent,
+%% then we do "\emph{Book title}, vol. XX"
+%% or "\emph{Book title}, no. 000"
+%% and if both volume and number are present, give a warning message.
+
+FUNCTION {format.bookvolume.series.number}
+{ volume empty$
+ { "" % Push the empty string as a placeholder in case everything else
+ % is empty too.
+ series empty$
+ 'skip$
+ { pop$ series } % if series is not empty put in stack
+ if$
+ number empty$
+ 'skip$
+ { duplicate$ empty$ % if no preceding material,
+ 'skip$ % do nothing, otherwise
+ { ", " * } % add a comma and space to separate.
+ if$
+ "no." number tie.or.space.connect * % add the number information
+ }
+ if$
+ }
+%% If the volume is NOT EMPTY:
+ { "vol." volume tie.or.space.connect % vol. XX
+ number empty$
+ { series empty$
+ 'skip$
+ { series ", " * swap$ *} % Series Name, vol. XX
+ if$
+ }
+ { series empty$
+ { "can't use both volume and number if series info is missing"
+ warning$
+ "in BibTeX entry type `" type$ * "'" * top$
+ }
+ { ", " * series * ", no." * number tie.or.space.connect }
+ if$
+ }
+ if$
+ }
+ if$
+
+} % end of format.bookvolume.series.number
+
+%% format.inproc.title.where.editors is used by inproceedings entry types
+
+%% No case changing or emphasizing for the title. We want initial
+%% caps, roman.
+%% We add parentheses around the address (place where conference
+%% was held).
+%% Likewise we add parentheses around the editors' names.
+
+FUNCTION {format.inproc.title.address.editors}
+{ booktitle empty$
+ { "" }
+ { booktitle
+ address empty$
+ 'skip$
+ { add.space.if.necessary "(" * address * ")" * }
+ if$
+ editor empty$
+ 'skip$
+ { add.space.if.necessary "(" * format.nonauthor.editors * ")" * }
+ if$
+ }
+ if$
+}
+
+%% format.incoll.title.editors is similar to format.inproc... but
+%% omits the address. For collections that are not proceedings volumes.
+
+FUNCTION {format.incoll.title.editors}
+{ booktitle empty$
+ { "" }
+ { editor empty$
+ { booktitle }
+ { booktitle
+ add.space.if.necessary "(" * format.nonauthor.editors * ")" *
+ }
+ if$
+ }
+ if$
+}
+
+FUNCTION {format.edition}
+{ edition empty$
+ { "" }
+ { output.state mid.sentence =
+ { edition "l" change.case$ " ed." * }
+ { edition "t" change.case$ " ed." * }
+ if$
+ }
+ if$
+}
+
+INTEGERS { multiresult }
+
+FUNCTION {multi.page.check}
+{ 't :=
+ #0 'multiresult :=
+ { multiresult not
+ t empty$ not
+ and
+ }
+ { t #1 #1 substring$
+ duplicate$ "-" =
+ swap$ duplicate$ "," =
+ swap$ "+" =
+ or or
+ { #1 'multiresult := }
+ { t #2 global.max$ substring$ 't := }
+ if$
+ }
+ while$
+ multiresult
+}
+
+FUNCTION {format.pages}
+{ pages empty$
+ { "" }
+ { pages n.dashify }
+ if$
+}
+
+FUNCTION {format.book.pages}
+{ pages empty$
+ { "" }
+ { pages multi.page.check
+ { "pp.~" pages n.dashify * }
+ { "p.~" pages * }
+ if$
+ }
+ if$
+}
+
+FUNCTION {format.chapter.pages}
+{ chapter empty$
+ 'format.book.pages
+ { type empty$
+ { "ch.~" }
+ { type "l" change.case$ " " * }
+ if$
+ chapter *
+ pages empty$
+ 'skip$
+ { ", " * format.book.pages * }
+ if$
+ }
+ if$
+}
+
+FUNCTION {empty.misc.check}
+{ author empty$ title empty$ howpublished empty$
+ month empty$ year empty$ note empty$
+ and and and and and
+ key empty$ not and
+ { "all relevant fields are empty in " cite$ * warning$ }
+ 'skip$
+ if$
+}
+
+FUNCTION {format.thesis.type}
+{ type empty$
+ 'skip$
+ { pop$
+ type "t" change.case$
+ }
+ if$
+}
+
+FUNCTION {format.tr.number}
+{ type empty$
+ { "Tech. Report" }
+ 'type
+ if$
+ number empty$
+ { "t" change.case$ }
+ { number tie.or.space.connect }
+ if$
+}
+
+% The format.crossref functions haven't been paid much attention
+% at the present time (June 1990) and could probably use some
+% work. MJD
+
+FUNCTION {format.article.crossref}
+{ key empty$
+ { journal empty$
+ { "need key or journal for " cite$ * " to crossref " * crossref *
+ warning$
+ ""
+ }
+ { "in " journal * }
+ if$
+ }
+ { "in " key * }
+ if$
+ " \cite{" * crossref * "}" *
+}
+
+FUNCTION {format.crossref.editor}
+{ editor #1 "{vv~}{ll}" format.name$
+ editor num.names$ duplicate$
+ #2 >
+ { pop$ " et~al." * }
+ { #2 <
+ 'skip$
+ { editor #2 "{ff }{vv }{ll}{ jj}" format.name$ "others" =
+ { " et~al." * }
+ { " and " * editor #2 "{vv~}{ll}" format.name$ * }
+ if$
+ }
+ if$
+ }
+ if$
+}
+
+FUNCTION {format.book.crossref}
+{ volume empty$
+ { "empty volume in " cite$ * "'s crossref of " * crossref * warning$
+ "in "
+ }
+ { "vol." volume tie.or.space.connect
+ " of " *
+ }
+ if$
+ editor empty$
+ editor field.or.null author field.or.null =
+ or
+ { key empty$
+ { series empty$
+ { "need editor, key, or series for " cite$ * " to crossref " *
+ crossref * warning$
+ "" *
+ }
+ { series * }
+ if$
+ }
+ { key * }
+ if$
+ }
+ { format.crossref.editor * }
+ if$
+ " \cite{" * crossref * "}" *
+}
+
+FUNCTION {format.incoll.inproc.crossref}
+{ editor empty$
+ editor field.or.null author field.or.null =
+ or
+ { key empty$
+ { booktitle empty$
+ { "need editor, key, or booktitle for " cite$ * " to crossref " *
+ crossref * warning$
+ ""
+ }
+ { "in \emph{" booktitle * "}" * }
+ if$
+ }
+ { "in " key * }
+ if$
+ }
+ { "in " format.crossref.editor * }
+ if$
+ " \cite{" * crossref * "}" *
+}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+% The main functions for each entry type.
+
+% journal, vol and year are formatted together because they are
+% not separated by commas.
+
+FUNCTION {article}
+{ output.bibitem
+ format.authors "author" output.check
+ format.title "title" output.check
+ crossref missing$
+ { format.journal.vol.year output
+ format.number output
+ format.pages "pages" output.check
+ }
+ { format.article.crossref output.nonnull
+ format.pages "pages" output.check
+ }
+ if$
+ format.language *
+ note output
+ fin.entry
+}
+
+FUNCTION {book}
+{ output.bibitem
+ author empty$
+ { format.editors "author and editor" output.check }
+ { format.authors output.nonnull
+ crossref missing$
+ { "author and editor" editor either.or.check }
+ 'skip$
+ if$
+ }
+ if$
+ format.title "title" output.check
+ format.edition output
+ crossref missing$
+ { format.bookvolume.series.number output
+ publisher "publisher" output.check
+ address output
+ }
+ { format.book.crossref output.nonnull
+ }
+ if$
+ format.date "year" output.check
+ format.language *
+ note output
+ fin.entry
+}
+
+FUNCTION {booklet}
+{ output.bibitem
+ format.authors output
+ format.title "title" output.check
+ howpublished output
+ address output
+ format.date output
+ note output
+ fin.entry
+}
+
+FUNCTION {inbook}
+{ output.bibitem
+ author empty$
+ { format.editors "author and editor" output.check }
+ { format.authors output.nonnull
+ crossref missing$
+ { "author and editor" editor either.or.check }
+ 'skip$
+ if$
+ }
+ if$
+ format.title "title" output.check
+ format.edition output
+ crossref missing$
+ { format.bookvolume.series.number output
+ format.chapter.pages "chapter and pages" output.check
+ publisher "publisher" output.check
+ address output
+ }
+ { format.chapter.pages "chapter and pages" output.check
+ format.book.crossref output.nonnull
+ }
+ if$
+ format.date "year" output.check
+ format.language *
+ note output
+ fin.entry
+}
+
+FUNCTION {incollection}
+{ output.bibitem
+ format.authors "author" output.check
+ format.title "title" output.check
+ crossref missing$
+ { format.incoll.title.editors "booktitle" output.check
+ format.bookvolume.series.number output
+ publisher "publisher" output.check
+ address output
+ format.edition output
+ format.date "year" output.check
+ }
+ { format.incoll.inproc.crossref output.nonnull
+ }
+ if$
+ note output
+ format.book.pages output
+ format.language *
+ fin.entry
+}
+
+FUNCTION {inproceedings}
+{ output.bibitem
+ format.authors "author" output.check
+ format.title "title" output.check
+ crossref missing$
+ { format.inproc.title.address.editors "booktitle" output.check
+ format.bookvolume.series.number output
+ organization output
+ publisher output
+ format.date "year" output.check
+ }
+ { format.incoll.inproc.crossref output.nonnull
+ }
+ if$
+ note output
+ format.book.pages output
+ format.language *
+ fin.entry
+}
+
+FUNCTION {conference} { inproceedings }
+
+FUNCTION {manual}
+{ output.bibitem
+ author empty$
+ { organization empty$
+ 'skip$
+ { organization output.nonnull
+ address output
+ }
+ if$
+ }
+ { format.authors output.nonnull }
+ if$
+ format.title "title" output.check
+ author empty$
+ { organization empty$
+ { address output }
+ 'skip$
+ if$
+ }
+ { organization output
+ address output
+ }
+ if$
+ format.edition output
+ format.date output
+ note output
+ fin.entry
+}
+
+FUNCTION {mastersthesis}
+{ output.bibitem
+ format.authors "author" output.check
+ format.title "title" output.check
+ "Master's thesis" format.thesis.type output.nonnull
+ school "school" output.check
+ address output
+ format.date "year" output.check
+ note output
+ format.book.pages output
+ fin.entry
+}
+
+FUNCTION {misc}
+{ output.bibitem
+ format.authors output
+ format.title output
+ howpublished output
+ format.date output
+ note output
+ format.book.pages output
+ fin.entry
+ empty.misc.check
+}
+
+FUNCTION {phdthesis}
+{ output.bibitem
+ format.authors "author" output.check
+ format.title "title" output.check
+ "Ph.D. thesis" format.thesis.type output.nonnull
+ school "school" output.check
+ address output
+ format.date "year" output.check
+ note output
+ format.book.pages output
+ fin.entry
+}
+
+FUNCTION {proceedings}
+{ output.bibitem
+ editor empty$
+ { organization output }
+ { format.editors output.nonnull }
+ if$
+ format.title "title" output.check
+ format.bookvolume.series.number output
+ address empty$
+ { editor empty$
+ 'skip$
+ { organization output }
+ if$
+ publisher output
+ format.date "year" output.check
+ }
+ { address output.nonnull
+ editor empty$
+ 'skip$
+ { organization output }
+ if$
+ publisher output
+ format.date "year" output.check
+ }
+ if$
+ note output
+ fin.entry
+}
+
+FUNCTION {techreport}
+{ output.bibitem
+ format.authors "author" output.check
+ format.title "title" output.check
+ format.tr.number output.nonnull
+ institution "institution" output.check
+ address output
+ format.date "year" output.check
+ note output
+ fin.entry
+}
+
+FUNCTION {unpublished}
+{ output.bibitem
+ format.authors "author" output.check
+ format.title "title" output.check
+ note "note" output.check
+ format.date output
+ fin.entry
+}
+
+FUNCTION {default.type} { misc }
+
+MACRO {jan} {"January"}
+
+MACRO {feb} {"February"}
+
+MACRO {mar} {"March"}
+
+MACRO {apr} {"April"}
+
+MACRO {may} {"May"}
+
+MACRO {jun} {"June"}
+
+MACRO {jul} {"July"}
+
+MACRO {aug} {"August"}
+
+MACRO {sep} {"September"}
+
+MACRO {oct} {"October"}
+
+MACRO {nov} {"November"}
+
+MACRO {dec} {"December"}
+
+READ
+
+FUNCTION {sortify}
+{ purify$
+ "l" change.case$
+}
+
+INTEGERS { len }
+
+FUNCTION {chop.word}
+{ 's :=
+ 'len :=
+ s #1 len substring$ =
+ { s len #1 + global.max$ substring$ }
+ 's
+ if$
+}
+
+FUNCTION {sort.format.names}
+{ 's :=
+ #1 'nameptr :=
+ ""
+ s num.names$ 'numnames :=
+ numnames 'namesleft :=
+ { namesleft #0 > }
+ { nameptr #1 >
+ { " " * }
+ 'skip$
+ if$
+ s nameptr "{vv{ } }{ll{ }}{ ff{ }}{ jj{ }}" format.name$ 't :=
+ nameptr numnames = t "others" = and
+ { "et al" * }
+ { t sortify * }
+ if$
+ nameptr #1 + 'nameptr :=
+ namesleft #1 - 'namesleft :=
+ }
+ while$
+}
+
+FUNCTION {sort.format.title}
+{ 't :=
+ "A " #2
+ "An " #3
+ "The " #4 t chop.word
+ chop.word
+ chop.word
+ sortify
+ #1 global.max$ substring$
+}
+
+FUNCTION {author.sort}
+{ author empty$
+ { key empty$
+ { "to sort, need author or key in " cite$ * warning$
+ ""
+ }
+ { key sortify }
+ if$
+ }
+ { author sort.format.names }
+ if$
+}
+
+FUNCTION {author.editor.sort}
+{ author empty$
+ { editor empty$
+ { key empty$
+ { "to sort, need author, editor, or key in " cite$ * warning$
+ ""
+ }
+ { key sortify }
+ if$
+ }
+ { editor sort.format.names }
+ if$
+ }
+ { author sort.format.names }
+ if$
+}
+
+FUNCTION {author.organization.sort}
+{ author empty$
+ { organization empty$
+ { key empty$
+ { "to sort, need author, organization, or key in " cite$ * warning$
+ ""
+ }
+ { key sortify }
+ if$
+ }
+ { "The " #4 organization chop.word sortify }
+ if$
+ }
+ { author sort.format.names }
+ if$
+}
+
+FUNCTION {editor.organization.sort}
+{ editor empty$
+ { organization empty$
+ { key empty$
+ { "to sort, need editor, organization, or key in " cite$ * warning$
+ ""
+ }
+ { key sortify }
+ if$
+ }
+ { "The " #4 organization chop.word sortify }
+ if$
+ }
+ { editor sort.format.names }
+ if$
+}
+
+FUNCTION {presort}
+{ type$ "book" =
+ type$ "inbook" =
+ or
+ 'author.editor.sort
+ { type$ "proceedings" =
+ 'editor.organization.sort
+ { type$ "manual" =
+ 'author.organization.sort
+ 'author.sort
+ if$
+ }
+ if$
+ }
+ if$
+ " "
+ *
+ year field.or.null sortify
+ *
+ " "
+ *
+ title field.or.null
+ sort.format.title
+ *
+ #1 entry.max$ substring$
+ 'sort.key$ :=
+}
+
+ITERATE {presort}
+
+SORT
+
+STRINGS { longest.label prev.author this.author }
+
+INTEGERS { number.label longest.label.width }
+
+FUNCTION {initialize.longest.label}
+{ "" 'longest.label :=
+ #1 'number.label :=
+ #0 'longest.label.width :=
+ "abcxyz" 'prev.author :=
+ "" 'this.author :=
+}
+
+FUNCTION {longest.label.pass}
+{ number.label int.to.str$ 'label :=
+ number.label #1 + 'number.label :=
+ label width$ longest.label.width >
+ { label 'longest.label :=
+ label width$ 'longest.label.width :=
+ }
+ 'skip$
+ if$
+ author empty$
+ { editor empty$
+ { "" }
+ 'editor
+ if$
+ }
+ 'author
+ if$
+ 'this.author :=
+ this.author prev.author =
+ { "\bysame" 'bysame := }
+ { "" 'bysame :=
+ this.author "" =
+ { "abcxyz" }
+ 'this.author
+ if$
+ 'prev.author :=
+ }
+ if$
+}
+
+EXECUTE {initialize.longest.label}
+
+ITERATE {longest.label.pass}
+
+FUNCTION {write.lines}
+{ { duplicate$ "." = NOT }
+ { write$ newline$ }
+ while$
+ pop$
+}
+
+FUNCTION {begin.bib}
+{ preamble$ empty$
+ 'skip$
+ { preamble$ write$ newline$ }
+ if$
+ "\providecommand{\bysame}{\leavevmode\hbox to3em{\hrulefill}\thinspace}"
+ write$ newline$
+ "\providecommand{\MR}{\relax\ifhmode\unskip\space\fi MR }"
+ write$ newline$
+ "% \MRhref is called by the amsart/book/proc definition of \MR."
+ write$ newline$
+ "\providecommand{\MRhref}[2]{%"
+ write$ newline$
+ " \href{http://www.ams.org/mathscinet-getitem?mr=#1}{#2}"
+ write$ newline$
+ "}"
+ write$ newline$
+ "\providecommand{\href}[2]{#2}"
+ write$ newline$
+ "\begin{thebibliography}{" longest.label * "}" *
+ write$ newline$
+}
+
+EXECUTE {begin.bib}
+
+EXECUTE {init.state.consts}
+
+ITERATE {call.type$}
+
+FUNCTION {end.bib}
+{ newline$
+ "\end{thebibliography}" write$ newline$
+}
+
+EXECUTE {end.bib}
+%% \CharacterTable
+%% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
+%% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
+%% Digits \0\1\2\3\4\5\6\7\8\9
+%% Exclamation \! Double quote \" Hash (number) \#
+%% Dollar \$ Percent \% Ampersand \&
+%% Acute accent \' Left paren \( Right paren \)
+%% Asterisk \* Plus \+ Comma \,
+%% Minus \- Point \. Solidus \/
+%% Colon \: Semicolon \; Less than \<
+%% Equals \= Greater than \> Question mark \?
+%% Commercial at \@ Left bracket \[ Backslash \\
+%% Right bracket \] Circumflex \^ Underscore \_
+%% Grave accent \` Left brace \{ Vertical bar \|
+%% Right brace \} Tilde \~}
diff --git a/macros/latex/required/amscls/doc/00LICENSE.txt b/macros/latex/required/amscls/doc/00LICENSE.txt
new file mode 100644
index 0000000000..402f74e422
--- /dev/null
+++ b/macros/latex/required/amscls/doc/00LICENSE.txt
@@ -0,0 +1,198 @@
+00LICENSE.txt, 2010/05/04
+
+The AMS is in the process of restating and updating the licenses on
+all components of the AMS-LaTeX and AMSFonts distributions in order to
+bring their licenses into line with current standards of "free"
+software licenses. Since it will take some time to update all
+individual files, we're distributing this notice now to retroactively
+restate the license on currently-distributed files.
+
+In 2009 the font components -- e.g., AFM (.afm), MetaFont (.mf), TeX
+font metric (.tfm), and Type 1 (.pfb) files -- of version 3 of the
+AMSfonts package were released under the SIL Open Font License. Any
+file released under the SIL OFL continues to be covered by that
+license.
+
+As of May 1, 2010, the following license supersedes any license found
+inside any LaTeX macro files -- and associated documentation and
+source files -- currently being distributed by the AMS:
+
+ 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
+ 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.
+
+ This work has the LPPL maintenance status `maintained'.
+
+ The Current Maintainer of this work is the American Mathematical
+ Society.
+
+Files covered by this notice include -- but are not necessarily
+limited to -- the following, along with any associated documentation
+files (README files, templates, examples, etc.).
+
+amsclass, version 2:
+ ams-c1.ins v2.20 (2004/08/03)
+ amsalpha.bst v2.0 (2000/03/27)
+ amsart.cls v2.20.1 (2009/07/02)
+ amsbook.sty v2.20.1 (2009/07/02)
+ amsclass.dtx v2.20.1 (2009/07/02)
+ amsdtx.cls v2.06 (2004/08/06)
+ amsdtx.dtx v2.06 (2004/08/06)
+ amsldoc.cls v2.06 (2004/08/06)
+ amsldoc.tex v2.09 (2004/04/06)
+ amsmidx.dtx v2.01 (2004/08/03)
+ amsmidx.sty v2.01 (2004/08/03)
+ amsmidx.txt
+ amsplain.bst v2.0 (2000/03/27)
+ amsproc.sty v2.20.1 (2009/07/02)
+ amsthdoc.tex v2.20 (2004/08/03)
+ amsthm.sty v2.20 (2004/08/06)
+ instr-l.tex v2.20 (2004/08/06)
+ thmtest.tex v2.01 (2004/08/02)
+ upref.dtx v2.01 (2004/07/29)
+ upref.sty v2.01 (2004/07/29)
+
+amsfonts, version 3:
+ amsfndoc.cyr v2.2c (1997/12/15)
+ amsfndoc.def v2.2d (2002/01/18)
+ amsfndoc.fnt v2.2c (2001/11/16)
+ amsfndoc.ins v2.2f (2002/01/30)
+ amsfndoc.tex v2.2d (2002/01/19)
+ amsfonts.dtx v3.00 (2009/06/22)
+ amsfonts.ins v3.00 (2009/02/22)
+ amsfonts.sty v3.00 (2009/06/22)
+ amssym.def v2.2b (2001/07/03)
+ amssym.tex v2.2b (1997/02/26)
+ amssymb.dtx v3.00 (2009/06/22)
+ amssymb.sty v3.00 (2009/06/22)
+ cmmib57.dtx v3.00 (2009/06/22)
+ cmmib57.sty v3.00 (2009/06/22)
+ cyracc.def v2.2b (2001/10/01)
+ eucal.sty v3.00 (2009/06/22)
+ eufrak.dtx v3.00 (2009/06/22)
+ eufrak.sty v3.00 (2009/06/22)
+ euscript.dtx v3.00 (2009/06/22)
+ euscript.sty v3.00 (2009/06/22)
+ ueuex.fd v3.00 (2009/06/22)
+ ueuf.fd v3.00 (2009/06/22)
+ ueur.fd v3.00 (2009/06/22)
+ ueus.fd v3.00 (2009/06/22)
+ umsa.fd v3.00 (2009/06/22)
+ umsb.fd v3.00 (2009/06/22)
+
+amsmath, version 2:
+ ams-m1.ins v1.05 (2000/05/25)
+ amsbsy.dtx v1.2d (1999/11/29)
+ amsbsy.sty v1.2d (1999/11/29)
+ amscd.dtx v2.0 (1999/11/29)
+ amscd.sty v2.0 (1999/11/29)
+ amsgen.dtx v2.0 (1999/11/30)
+ amsgen.sty v2.0 (1999/11/30)
+ amsmath.dtx v2.13 (2000/07/18)
+ amsmath.sty v2.13 (2000/07/18)
+ amsopn.dtx v2.01 (1999/12/14)
+ amsopn.sty v2.01 (1999/12/14)
+ amstex.sty v1.2f (1999/11/15)
+ amstext.dtx v2.01 (2000/06/29)
+ amstext.sty v2.01 (2000/06/29)
+ amsxtra.dtx v1.2c (1999/11/15)
+ amsxtra.sty v1.2c (1999/11/15)
+ subeqn.tex v1.2c (1999/11/29)
+ technote.tex v2.0 (1999/11/15)
+ testmath.tex v2.0 (1999/11/15)
+
+amsrefs, version 2:
+ amsbst.sty v2.03 (2007/10/22)
+ amsj.bib v2.01 (2007/10/01)
+ amsra.bst v2.01 (2007/10/01)
+ amsrefs.dtx v2.03 (2007/10/22)
+ amsrefs.ins
+ amsrefs.sty v2.03 (2007/10/22)
+ amsrn.bst v2.01 (2007/10/01)
+ amsrs.bst v2.01 (2007/10/01)
+ amsru.bst v2.01 (2007/10/01)
+ amsry.bst v2.01 (2007/10/01)
+ amsxport.dtx v2.01 (2007/10/01)
+ amsxport.ins
+ ifoption.dtx v1.02 (2002/03/04)
+ ifoption.ins
+ ifoption.sty v1.02 (2002/03/04)
+ mathscinet.dtx v2.01 (2004/06/30)
+ mathscinet.ins
+ mathscinet.sty v2.01 (2004/06/30)
+ pcatcode.dtx v1.04b (2007/08/17)
+ pcatcode.ins
+ pcatcode.sty v1.04b (2007/08/17)
+ rkeyval.dtx v2.00 (2004/06/28)
+ rkeyval.ins
+ rkeyval.sty v2.00 (2004/06/28)
+ textcmds.dtx v1.06 (2007/10/19)
+ textcmds.ins
+ textcmds.sty v1.06 (2007/10/19)
+
+AMS author packages:
+ ams-rust.sty v1.02 (2003/11/26)
+ amsbkrev.cls v2.23 (2009/02/11)
+ amsip-m-l.cls v2.01 (2005/03/16)
+ amsip-p-l.cls v2.01 (2005/03/21)
+ amstext-l.cls v0.92 (2010/03/05)
+ bull-l.cls v2.05 (2009/05/07)
+ cbmath-l.cls v1.2b (1996/10/25)
+ cbms-l.cls v1.2b (1995/10/30)
+ ceb-l.cls v2.02 (2007/08/28)
+ cmim-l.cls v1.2b (2001/06/14)
+ cmip-l.cls v1.0b (2001/04/19)
+ cmsams-l.cls v1.2b (1996/10/25)
+ coll-l.cls v1.2b (1996/10/30)
+ conm-m-l.cls v1.2b (1996/10/30)
+ conm-p-l.cls v1.2b (1996/10/25)
+ crmm-l.cls v2.01 (2005/05/11)
+ crmp-l.cls v2.01 (2005/05/11)
+ dimacs-l.cls v1.2b (1996/10/24)
+ ecgd-l.cls v2.02 (2007/06/18)
+ editor.cls v0.97 (2008/12/04)
+ ert-l.cls v2.02 (2007/06/18)
+ fic-l.cls v1.2i (2010/01/26)
+ fim-l.cls v1.2i (2010/01/26)
+ gen-j-l.cls v1.2b (1996/10/25)
+ gen-m-l.cls v1.2b (1996/10/30)
+ gen-p-l.cls v1.2b (1996/01/25)
+ gsm-l.cls v2.05 (2008/09/26)
+ hmath-l.cls v1.2b (1996/10/30)
+ jag-l.cls v1.2u (2005/06/24)
+ jams-l.cls v2.01 (2007/06/18)
+ mawrld-l.cls v1.01 (2006/05/23)
+ mcom-l.cls v2.01 (2007/06/18)
+ memo-l.cls v2.01 (2007/05/09)
+ mmono-l.cls v1.2b (1996/10/30)
+ mmono-s.cls v1.1b (1998/04/13)
+ mosc-l.cls v2.07 (2006/03/06)
+ proc-l.cls v2.01 (2007/06/18)
+ psapm-l.cls v1.2c (1996/11/18)
+ pspum-l.cls v1.2c (1996/11/18)
+ qam-l.cls v2.07 (2005/09/09)
+ smf-l.cls v1.2b (1998/06/29)
+ spmj-l.cls v2.12 (2009/01/22)
+ stml-l.cls v1.17 (2008/06/25)
+ surv-l.cls v1.2b (1996/10/30)
+ tpms-l.cls v2.07 (2009/01/22)
+ tran-l.cls v2.01 (2007/06/18)
+ trans2-l.cls v1.2b (1997/11/17)
+ ulect-l.cls v1.2b (1996/10/30)
+
+Please address any questions to
+
+ American Mathematical Society
+ Technical Support
+ Publications Technical Group
+ 201 Charles Street
+ Providence, RI 02904
+ USA
+ tel: (401) 455-4080
+ (800) 321-4267 (USA and Canada only)
+ fax: (401) 331-3842
+ email: tech-support@ams.org
diff --git a/macros/latex/required/amscls/doc/amsart-template.tex b/macros/latex/required/amscls/doc/amsart-template.tex
new file mode 100644
index 0000000000..6c735fcb0b
--- /dev/null
+++ b/macros/latex/required/amscls/doc/amsart-template.tex
@@ -0,0 +1,89 @@
+%% filename: amsart-template.tex
+%% version: 1.1
+%% date: 2014/07/24
+%%
+%% American Mathematical Society
+%% Technical Support
+%% Publications Technical Group
+%% 201 Charles Street
+%% Providence, RI 02904
+%% USA
+%% tel: (401) 455-4080
+%% (800) 321-4267 (USA and Canada only)
+%% fax: (401) 331-3842
+%% email: tech-support@ams.org
+%%
+%% Copyright 2008-2010, 2014 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
+%% 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.
+%%
+%% This work has the LPPL maintenance status `maintained'.
+%%
+%% The Current Maintainer of this work is the American Mathematical
+%% Society.
+%%
+%% ====================================================================
+
+% AMS-LaTeX v.2 template for use with amsart
+%
+% Remove any commented or uncommented macros you do not use.
+
+\documentclass{amsart}
+
+\newtheorem{theorem}{Theorem}[section]
+\newtheorem{lemma}[theorem]{Lemma}
+
+\theoremstyle{definition}
+\newtheorem{definition}[theorem]{Definition}
+\newtheorem{example}[theorem]{Example}
+\newtheorem{xca}[theorem]{Exercise}
+
+\theoremstyle{remark}
+\newtheorem{remark}[theorem]{Remark}
+
+\numberwithin{equation}{section}
+
+\begin{document}
+
+\title{}
+
+% Remove any unused author tags.
+
+% author one information
+\author{}
+\address{}
+\curraddr{}
+\email{}
+\thanks{}
+
+% author two information
+\author{}
+\address{}
+\curraddr{}
+\email{}
+\thanks{}
+
+\subjclass[2010]{Primary }
+
+\keywords{}
+
+\date{}
+
+\dedicatory{}
+
+\begin{abstract}
+\end{abstract}
+
+\maketitle
+
+\end{document}
+
+%-----------------------------------------------------------------------
+% End of amsart-template.tex
+%-----------------------------------------------------------------------
diff --git a/macros/latex/required/amscls/doc/amsbook-template.tex b/macros/latex/required/amscls/doc/amsbook-template.tex
new file mode 100644
index 0000000000..36920ee634
--- /dev/null
+++ b/macros/latex/required/amscls/doc/amsbook-template.tex
@@ -0,0 +1,134 @@
+%% filename: amsbook-template.tex
+%% version: 1.1
+%% date: 2014/07/24
+%%
+%% American Mathematical Society
+%% Technical Support
+%% Publications Technical Group
+%% 201 Charles Street
+%% Providence, RI 02904
+%% USA
+%% tel: (401) 455-4080
+%% (800) 321-4267 (USA and Canada only)
+%% fax: (401) 331-3842
+%% email: tech-support@ams.org
+%%
+%% Copyright 2006, 2008-2010, 2014 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
+%% 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.
+%%
+%% This work has the LPPL maintenance status `maintained'.
+%%
+%% The Current Maintainer of this work is the American Mathematical
+%% Society.
+%%
+%% ====================================================================
+
+% AMS-LaTeX v.2 driver file template for use with amsbook
+%
+% Remove any commented or uncommented macros you do not use.
+
+\documentclass{amsbook}
+
+% For use when working on individual chapters
+%\includeonly{}
+
+% Include referenced packages here.
+\usepackage{}
+
+\newtheorem{theorem}{Theorem}[chapter]
+\newtheorem{lemma}[theorem]{Lemma}
+
+\theoremstyle{definition}
+\newtheorem{definition}[theorem]{Definition}
+\newtheorem{example}[theorem]{Example}
+\newtheorem{xca}[theorem]{Exercise}
+
+\theoremstyle{remark}
+\newtheorem{remark}[theorem]{Remark}
+
+\numberwithin{section}{chapter}
+\numberwithin{equation}{chapter}
+
+% For a single index; for multiple indexes, see the manual
+% "Instructions for preparation of papers and monographs:
+% AMS-LaTeX" (instr-l.pdf in the AMS-LaTeX distribution).
+\makeindex
+
+\begin{document}
+
+\frontmatter
+
+\title{}
+
+% Remove any unused author tags.
+
+% author one information
+\author{}
+\address{}
+\curraddr{}
+\email{}
+\thanks{}
+
+% author two information
+\author{}
+\address{}
+\curraddr{}
+\email{}
+\thanks{}
+
+\subjclass[2010]{Primary }
+
+\keywords{}
+
+\date{}
+
+\begin{abstract}
+\end{abstract}
+
+\maketitle
+
+% Dedication. If the dedication is longer than a line or two,
+% remove the centering instructions and the line break.
+%\cleardoublepage
+%\thispagestyle{empty}
+%\vspace*{13.5pc}
+%\begin{center}
+% Dedication text (use \\[2pt] for line break if necessary)
+%\end{center}
+%\cleardoublepage
+
+% Change page number to 6 if a dedication is present.
+\setcounter{page}{4}
+
+\tableofcontents
+
+% Include unnumbered chapters (preface, acknowledgments, etc.) here.
+\include{}
+
+\mainmatter
+% Include main chapters here.
+\include{}
+
+\appendix
+% Include appendix "chapters" here.
+\include{}
+
+\backmatter
+% Bibliography styles amsplain or harvard are also acceptable.
+\bibliographystyle{amsalpha}
+\bibliography{}
+% See note above about multiple indexes.
+\printindex
+
+\end{document}
+
+%-----------------------------------------------------------------------
+% End of amsbook-template.tex
+%-----------------------------------------------------------------------
diff --git a/macros/latex/required/amscls/doc/amsbooka.pdf b/macros/latex/required/amscls/doc/amsbooka.pdf
new file mode 100644
index 0000000000..e7d377b164
--- /dev/null
+++ b/macros/latex/required/amscls/doc/amsbooka.pdf
Binary files differ
diff --git a/macros/latex/required/amscls/doc/amsclass.pdf b/macros/latex/required/amscls/doc/amsclass.pdf
new file mode 100644
index 0000000000..2e484a954e
--- /dev/null
+++ b/macros/latex/required/amscls/doc/amsclass.pdf
Binary files differ
diff --git a/macros/latex/required/amscls/doc/amsdtx.pdf b/macros/latex/required/amscls/doc/amsdtx.pdf
new file mode 100644
index 0000000000..4bba820e74
--- /dev/null
+++ b/macros/latex/required/amscls/doc/amsdtx.pdf
Binary files differ
diff --git a/macros/latex/required/amscls/doc/amsmidx.pdf b/macros/latex/required/amscls/doc/amsmidx.pdf
new file mode 100644
index 0000000000..45b364c239
--- /dev/null
+++ b/macros/latex/required/amscls/doc/amsmidx.pdf
Binary files differ
diff --git a/macros/latex/required/amscls/doc/amsproc-template.tex b/macros/latex/required/amscls/doc/amsproc-template.tex
new file mode 100644
index 0000000000..5cc1370844
--- /dev/null
+++ b/macros/latex/required/amscls/doc/amsproc-template.tex
@@ -0,0 +1,89 @@
+%% filename: amsproc-template.tex
+%% version: 1.1
+%% date: 2014/07/24
+%%
+%% American Mathematical Society
+%% Technical Support
+%% Publications Technical Group
+%% 201 Charles Street
+%% Providence, RI 02904
+%% USA
+%% tel: (401) 455-4080
+%% (800) 321-4267 (USA and Canada only)
+%% fax: (401) 331-3842
+%% email: tech-support@ams.org
+%%
+%% Copyright 2008-2010, 2014 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
+%% 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.
+%%
+%% This work has the LPPL maintenance status `maintained'.
+%%
+%% The Current Maintainer of this work is the American Mathematical
+%% Society.
+%%
+%% ====================================================================
+
+% AMS-LaTeX v.2 template for use with amsproc
+%
+% Remove any commented or uncommented macros you do not use.
+
+\documentclass{amsproc}
+
+\newtheorem{theorem}{Theorem}[section]
+\newtheorem{lemma}[theorem]{Lemma}
+
+\theoremstyle{definition}
+\newtheorem{definition}[theorem]{Definition}
+\newtheorem{example}[theorem]{Example}
+\newtheorem{xca}[theorem]{Exercise}
+
+\theoremstyle{remark}
+\newtheorem{remark}[theorem]{Remark}
+
+\numberwithin{equation}{section}
+
+\begin{document}
+
+\title{}
+
+% Remove any unused author tags.
+
+% author one information
+\author{}
+\address{}
+\curraddr{}
+\email{}
+\thanks{}
+
+% author two information
+\author{}
+\address{}
+\curraddr{}
+\email{}
+\thanks{}
+
+\subjclass[2010]{Primary }
+
+\keywords{}
+
+\date{}
+
+\dedicatory{}
+
+\begin{abstract}
+\end{abstract}
+
+\maketitle
+
+\end{document}
+
+%-----------------------------------------------------------------------
+% End of amsproc-template.tex
+%-----------------------------------------------------------------------
diff --git a/macros/latex/required/amscls/doc/amsthdoc.pdf b/macros/latex/required/amscls/doc/amsthdoc.pdf
new file mode 100644
index 0000000000..c9209b03c0
--- /dev/null
+++ b/macros/latex/required/amscls/doc/amsthdoc.pdf
Binary files differ
diff --git a/macros/latex/required/amscls/doc/amsthdoc.tex b/macros/latex/required/amscls/doc/amsthdoc.tex
new file mode 100644
index 0000000000..918dfefa0f
--- /dev/null
+++ b/macros/latex/required/amscls/doc/amsthdoc.tex
@@ -0,0 +1,851 @@
+%% filename: amsthdoc.tex
+%% version: 2.20.3
+%% date: 2017/06/01
+%%
+%% Copyright 1999, 2004, 2010, 2015, 2017 American Mathematical Society.
+%%
+%% American Mathematical Society
+%% Technical Support
+%% Publications Technical Group
+%% 201 Charles Street
+%% Providence, RI 02904
+%% USA
+%% tel: (401) 455-4080
+%% (800) 321-4267 (USA and Canada only)
+%% fax: (401) 331-3842
+%% email: tech-support@ams.org
+%%
+%% 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
+%% 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.
+%%
+%% This work has the LPPL maintenance status `maintained'.
+%%
+%% The Current Maintainer of this work is the American Mathematical
+%% Society.
+%%
+%% ====================================================================
+%%
+\documentclass[11pt,twoside]{article}
+\pagestyle{myheadings}
+
+% Use the same version number as for the public amsthm release.
+\def\instrversion{2.20.3}
+\def\instrdate{September 2017}
+
+\title{Using the \pkg{amsthm} Package}
+\author{Version \instrversion, \instrdate\\[.5ex]
+ Publications Technical Group\\American Mathematical Society}
+\date{}
+
+\providecommand{\qq}[1]{\textquotedblleft#1\textquotedblright}
+\providecommand{\mdash}{\textemdash\penalty\hyphenpenalty}
+
+% Some item adjustments
+
+\setlength\leftmargini{2em}
+\setlength\leftmarginii{1.5em}
+\renewcommand\labelitemii{$\circ$}
+
+% Embedded \index commands are a legacy from the time when this
+% documentation was part of amsldoc. Since they don't hurt anything,
+% let's leave them in. Maybe they will become useful again in the
+% future. [mjd,2000/06/06]
+
+\chardef\bslchar=`\\ % p. 424, TeXbook
+\newcommand{\ntt}{%
+ \fontfamily\ttdefault \fontseries\mddefault \fontshape\updefault
+ \selectfont
+}
+\DeclareRobustCommand{\cn}[1]{{\ntt\bslchar#1}}
+\DeclareRobustCommand{\cls}[1]{{\ntt#1}}
+\DeclareRobustCommand{\pkg}[1]{{\ntt#1}}
+\DeclareRobustCommand{\opt}[1]{{\ntt#1}}
+\DeclareRobustCommand{\env}[1]{{\ntt#1}}
+\DeclareRobustCommand{\fn}[1]{{\ntt#1}}
+
+\providecommand{\qedsymbol}{\leavevmode
+ \hbox to.77778em{%
+ \hfil\vrule
+ \vbox to.675em{\hrule width.6em\vfil\hrule}%
+ \vrule\hfil}}
+
+%% Provide a meta-command facility; provide an alternate escape
+%% character so it can be used within the verbatim environment.
+
+\catcode`\|=0
+\begingroup \catcode`\>=13 % in LaTeX2e verbatim env makes > active
+\gdef\?#1>{{\normalfont$\langle$\textit{#1}$\rangle$}}
+\gdef\0{\relax}
+\endgroup
+\def\<#1>{{\normalfont$\langle$\textit{#1}$\rangle$}}
+\def\ntnote#1{{\normalfont$^{#1}$}\hangindent.5em}
+
+\hfuzz4pt \vbadness9999 \hbadness5000
+\def\latex/{{\protect\LaTeX}}
+
+\setlength{\textwidth}{210mm}\addtolength{\textwidth}{-2in}
+\setlength{\oddsidemargin}{39pt}
+\setlength{\evensidemargin}{39pt}
+\addtolength{\textwidth}{-2\oddsidemargin}
+
+\setcounter{tocdepth}{2}
+
+\usepackage{url}
+\usepackage[breaklinks]{hyperref}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\begin{document}
+\maketitle
+\markboth{Using the \pkg{amsthm} package}{Using the \pkg{amsthm} package}
+
+\begingroup
+\small
+\tableofcontents
+\endgroup
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\newpage %%%%%%%%%%%%%%%%%%%%
+
+\section{Introduction}
+
+\begin{sloppypar}
+The \pkg{amsthm} package provides an enhanced version of \latex/'s
+\cn{newtheorem} command for defining theorem-like environments. The
+enhanced \cn{newtheorem} recognizes a
+\cn{theoremstyle} specification (as in Mittelbach's \pkg{theorem}
+package) and has a \verb+*+ form for defining unnumbered environments. The
+\pkg{amsthm} package also defines a \env{proof} environment that
+automatically adds a QED symbol at the end. AMS document classes
+incorporate the \pkg{amsthm} package, so everything described here
+applies to them as well.
+\end{sloppypar}
+
+As part of the AMS \latex/ support environment, \pkg{amsthm} follows
+AMS style. This differs in some respects from the style provided by
+the base \latex/ classes and the package mentioned above; where a
+difference is known to be present, it will be noted in these instructions.
+One notable difference is that, after the end of a theorem or proof,
+the following line of text is assumed to start a new paragraph, and will
+always be indented, whether or not a blank line or \cn{par} is present.
+
+If the \pkg{amsthm} package is used with a non-AMS document class and
+with the \pkg{amsmath} package, \pkg{amsthm} must be loaded
+\emph{after} \pkg{amsmath}, not before.
+
+Since \pkg{amsthm} follows AMS publication style, formats that diverge
+significantly from that style may not be able to be accommodated.
+Other theorem packages \emph{do} exist, and users with incompatible
+requirements who are publishing elsewhere are advised to look for other
+possibilities on CTAN\@. However, authors preparing files for
+publication by the AMS are expected to follow AMS style.
+
+This manual describes the features provided by \pkg{amsthm}. Examples
+are given separately in the file \fn{thmtest.tex}. For best understanding,
+examine the output side-by-side with the input.
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+%\section{The \cn{newtheorem} command}
+\section{Setup and input of theorem elements}
+
+In mathematical research articles and books, theorems\index{theorems}
+and proofs\index{proofs} are among the most common elements, but authors
+also use many others that fall in the same general class: lemmas,
+propositions, axioms, corollaries, conjectures, definitions, remarks,
+cases, steps, and so forth (see page~\pageref{thmstyle:list}).
+It is natural to handle these elements as
+\latex/ environments, but document classes do not
+provide predefined environments for theorem-like elements because
+(a)~that would make it difficult for authors to exercise the necessary
+control over the automatic numbering, and (b)~the variety of such
+elements is so wide that it's not possible for a document class to
+provide every one that will ever be needed. Instead there is a command
+\cn{newtheorem}, similar in effect to \cn{newenvironment}, that makes it
+easy for authors to set up the elements required for a particular
+document.
+
+The \cn{newtheorem} command has two mandatory arguments: the first one
+is the environment name that the author would like to use for this
+element; the second one is the heading text. For example,
+\begin{verbatim}
+ \newtheorem{lem}{Lemma}
+\end{verbatim}
+means that instances in the document of
+\begin{verbatim}
+ \begin{lem} Text text ... \end{lem}
+\end{verbatim}
+will produce
+\[\makebox[.8\columnwidth]{%
+ \textbf{Lemma 1.} \textit{Text text \dots}\hfill}\]
+where the heading consists of the specified text \qq{Lemma} and an
+automatically generated number and punctuation. Note that there are
+no fixed text assignments as there are with, e.g., \cn{chaptername}
+(usually ``Chapter'' or ``Appendix'', depending on context); the heading
+text in the output will be exactly what you specify in the input.
+
+If \cn{newtheorem*} is used instead of \cn{newtheorem} in this
+example, numbers will not be generated automatically for
+any of the lemmas in the document. This form of the command can be
+useful even if you have only one lemma and don't want it to be
+numbered; more often, though, it is used to produce a special named
+variant of one of the common theorem types. For example, if you have a
+lemma that should get the heading \qq{Klein's Lemma}, then the statement
+\begin{verbatim}
+ \newtheorem*{KL}{Klein's Lemma}
+\end{verbatim}
+would allow you to write
+\begin{verbatim}
+ \begin{KL} Text text ... \end{KL}
+\end{verbatim}
+and get the desired output.
+
+Sometimes additional information is desired in the heading of a
+theorem or lemma, often because it is cited from another source.
+An optional argument is used to provide this information:
+\begin{verbatim}
+ \begin{lem}[Alinhac-Lerner \cite{a-l}]
+\end{verbatim}
+yielding the output
+\[\makebox[.8\columnwidth]{%
+ \textbf{Lemma 2.} (Alinhac-Lerner [4]). \textit{Text text \dots}\hfill}\]
+If the citation includes page numbers, the brackets in the reference
+must be ``hidden'' to prevent the closing bracket from being interpreted
+as the end of the optional argument to the heading:
+\begin{verbatim}
+ \begin{lem}[Alinhac-Lerner {\cite[p.~37]{a-l}}]
+\end{verbatim}
+with the output
+\[\makebox[.8\columnwidth]{%
+ \textbf{Lemma 2.} (Alinhac-Lerner [4, p.~37]). \textit{Text text \dots}\hfill}\]
+
+Often, theorems are referred to elsewhere in a document. The usual
+\latex/ \cn{label}-\cn{ref} mechanism works for this purpose. However,
+problems can arise when the \cn{label} is separated from the heading.
+For this reason, it is recommended to place the label immediately
+after the \verb+\begin{...}[...]+ command; placing it on a separate line
+should not cause any adverse effects.
+
+\subsection{Theorems beginning with lists}
+\label{ThmWithList}
+
+Sometimes it's desired to state a theorem in discrete steps, using
+a list. Preceding the list by text is recommended, to avoid problems
+both with linking (using \env{enumerate}) and with unattractive spacing.
+
+If no text is provided, the list will follow the heading on the same
+line. This has three unwanted effects: the horizontal space between
+the theorem head and the first item will be unacceptably large, a
+hyperlink to the theorem will not be ``live'' in the PDF file
+(although it will be marked), and the extra vertical space that should
+follow the end of the list will be absent.
+
+The best way to avoid these problems is to allow the list to start
+on a new line. One way to accomplish this is to follow the theorem
+head (and \cn{label}, if present) by the command \cn{leavevmode}.
+(For more information, see section~\ref{thmstyle:break}.)
+However, if the theorem comes near the bottom of a page, the list
+might move to the top of the next page, leaving an orphaned heading.
+If this happens, it must be addressed as an exception, to be taken
+care of after the text is final; at that point, the recommended
+fix is to call on the \pkg{needspace} \cite{NDS} package, or insert
+an explicit page break.
+
+An alternative method of starting a new line after the heading is to
+provide a \verb+\newtheoremstyle{break}+; the definition is given below
+on page~\pageref{thmstyle:break}. Like the \cn{leavevmode} approach,
+a \env{break} theorem environment is not perfect; known limitations
+accompany the definition.
+
+%The recommended remedy is to insert the command \cn{leavevmode}
+%after the heading (and label, if present). This will move the first
+%item to a new line, and restore linking and the usual spacing.
+%Adding \cn{samepage} immediately following \cn{leavevmode} will
+%prevent the page break, but this has the side effect of treating the
+%entire theorem as a unit, so such an adjustment should be delayed until
+%the ``last pass'' to minimize possible problems with long theorems.
+
+%% see also "break" below
+
+%% reconsider the following
+%% to be explored: use of enumerate package to reset item id styles
+
+If the list \emph{must} start on the same line as the heading, enter
+the first item identifier manually, with adjustments: enter an
+ordinary space between the heading and the identifier, reset the left
+margin if the item text will require more than one line, and reset
+the item counter (for \env{enumerate}) so that it will start
+with 2 (or whatever is appropriate).
+\begin{verbatim}
+ \begin{thm}[|?optional modifier>]
+ \hangindent\leftmargini % for a multi-line item
+ \label{thm:xxx}
+ \textup{(1)} First item ...
+ \begin{enumerate}
+ \setcounter{enumi}{1}
+ \item ...
+ \item ...
+ \end{enumerate}
+ \end{thm}
+\end{verbatim}
+The style shown here for the item identifier matches the default for
+AMS document classes. It may be different for other document classes;
+\pkg{amsthm} retains the class default. (\cn{textup} should be
+applied to hand-coded item identifiers when using an AMS class; AMS
+style conforms to traditional math typography in this respect, with item
+identifiers, cross-references, and similar elements consistently set
+upright, even in italic environments. However, an author should always
+try to match the style of the document class being used.) To match the
+default style of a first-level item counter when using an AMS document
+class, a reference may be entered with \cn{eqref}; however, beware if
+a package such as \pkg{cleveref} is being used, as it may associate the
+wrong element type.
+
+An initial item input in this manner cannot be linked using a \cn{label},
+since it is not associated with a counter; the \cn{label} in the above
+example refers to the theorem element, not to the item in the list.
+This is an important concept: a \cn{label} will always refer to the
+value of the most recent counter that is automatically incremented;
+this counter will also be the anchor for a hyperlink if the
+\pkg{hyperref} package is used.
+
+%%% theorems starting with lists; linking -- xref
+
+%%% footnote on header -- Q-586
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\enlargethispage{1\baselineskip} %%%%%%%%%%%%%%%%%%%%
+
+\section{Theorem numbering}
+
+In addition to the two mandatory arguments, \cn{newtheorem} has two
+mutually exclusive optional arguments. These govern the
+sequencing\index{theorems!numbering} and hierarchy of the numbering.
+The numbering mechanism can be thought of this way:
+%\null\hfil\verb+\newtheorem{+\<environment name>\verb+}[+\<shared counter>%
+\begin{verbatim}
+ \newtheorem{|?env name>}{|?text>}[|?parent counter>]
+ \newtheorem{|?env name>}[|?shared counter>]{|?text>}
+\end{verbatim}
+%(Only one of these optional arguments can be present at one time.)
+The \<parent counter> is comparable to \cn{numberwithin}; that is,
+numbering will restart whenever that sectional level is encountered.
+If a \<shared counter> is specified, numbering will progress
+sequentially for all theorem elements using this counter. See
+below for a more detailed explanation.
+
+%% ref tex.sx q/5244 for clear explanation
+
+By default each kind of theorem-like environment is numbered
+independently. Thus if you have three lemmas and two theorems
+interspersed, they will be numbered something like this: Lemma 1, Lemma
+2, Theorem 1, Lemma 3, Theorem 2. If you want lemmas and theorems to
+share the same numbering sequence\mdash Lemma 1, Lemma 2, Theorem 3, Lemma
+4, Theorem 5\mdash then you should use the \<shared counter> to indicate
+the desired relationship as follows:
+\begin{verbatim}
+ \newtheorem{thm}{Theorem}
+ \newtheorem{lem}[thm]{Lemma}
+\end{verbatim}
+The optional argument \verb+[thm]+ in the second statement means that
+the \env{lem} environment should share the \env{thm} numbering
+sequence instead of having its own independent sequence.
+
+To have a theorem environment numbered subordinately within a
+sectional unit\mdash e.g., to get propositions numbered Proposition 2.1,
+Proposition 2.2, and so on in Section~2\mdash put the name of the parent
+unit in square brackets in final position:
+\begin{verbatim}
+ \newtheorem{prop}{Proposition}[section]
+\end{verbatim}
+With the optional argument \verb+[section]+, the \verb+prop+ counter
+will be reset to 0 whenever the parent counter \verb+section+ is
+incremented, and the proposition heading will have the section number
+prepended.
+
+If any theorem elements are numbered by section, and (in a book) the
+first such element in a chapter comes before the first section,
+numbering will continue from the previous chapter. In such a case,
+reset the counter by invoking this command before the affected element:
+\begin{verbatim}
+ \setcounter{thm}{0}
+\end{verbatim}
+
+Note that theorem numbering is not accomplished by the same method
+as the \cn{numberwithin} facility of \pkg{amsmath}, so an attempt to
+use that to relate theorem numbers to equation numbers will not work
+in the expected way. A method for accomplishing that, as well as
+some other variations, is given in the AMS Author FAQ \cite{AF},
+in the section on
+\qq{\href{http://www.ams.org//faq?class_id=561}{Theorems in AMS-\LaTeX}}.
+
+\newpage %%%%%%%%%%%%%%%%%%%%
+
+\subsection{Related topics addressed in the AMS author FAQ}
+
+\begin{itemize}
+\item \href{http://www.ams.org/faq?faq_id=199}{``Number''
+ theorems with letters instead of numbers}
+
+\item \href{http://www.ams.org/faq?faq_id=200}{Restart numbering for each
+ chapter, but don't include chapter number as part of theorem number}
+
+\item \href{http://www.ams.org/faq?faq_id=202}{Number theorems by
+ section when chapters have sections, but by chapter only when a chapter
+ has no sections}
+
+\item \href{http://www.ams.org/faq?faq_id=289}{Number theorems and
+ equations with the same numbering sequence}
+\end{itemize}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\section{Changing styles for theorem-like environments}
+
+\subsection{The \texorpdfstring{\cn{theoremstyle}}{theoremstyle} command}
+
+The \pkg{amsthm} package supports the notion of a current theorem style,
+which determines what will be produced by a given \cn{newtheorem}
+command. The three theorem styles provided\mdash
+\env{plain},\index{plain theo@\env{plain} theorem style}\relax
+\index{definition theo@\env{definition} theorem style}\relax
+\index{remark theo@\env{remark} theorem style} \env{definition},
+and \env{remark}\mdash specify different degrees of
+visual emphasis corresponding to their relative importance. The
+details of this typographical treatment may vary depending on the
+document class, but typically the \env{plain} style produces italic
+body text, while the other two styles produce roman body text. These
+default settings are provided:
+\begin{itemize}
+\item \env{plain}\,: italic text, extra space above and below;
+\item \env{definition}\,: upright text, extra space above and below;
+\item \env{remark}\,: upright text, no extra space above or below.
+\end{itemize}
+
+If no \cn{theoremstyle} command is given, the style used will be
+\env{plain}. To specify different styles, divide your \cn{newtheorem}
+commands into groups and preface each group with the appropriate
+\cn{theoremstyle}. Some examples:\label{thmstyle:list}
+\begin{verbatim}
+ \theoremstyle{plain}% default
+ \newtheorem{thm}{Theorem}[section]
+ \newtheorem{lem}[thm]{Lemma}
+ \newtheorem{prop}[thm]{Proposition}
+ \newtheorem*{cor}{Corollary}
+ \newtheorem*{KL}{Klein's Lemma}
+
+ \theoremstyle{definition}
+ \newtheorem{defn}{Definition}[section]
+ \newtheorem{exmp}{Example}[section]
+ \newtheorem{xca}[exmp]{Exercise}
+
+ \theoremstyle{remark}
+ \newtheorem*{rem}{Remark}
+ \newtheorem*{note}{Note}
+ \newtheorem{case}{Case}
+\end{verbatim}
+
+The following list summarizes the types of structures which are
+normally associated with each theorem style.
+
+\smallskip
+\begin{tabular}{ll}
+ \relax\env{plain} & Theorem, Lemma, Corollary, Proposition, Conjecture, \\
+ & Criterion, Assertion \\
+ \relax\env{definition} \quad & Definition, Condition, Problem, Example,
+ Exercise, \\
+ & Algorithm, Question, Axiom, Property, Assumption, \\
+ & Hypothesis \\
+ \relax\env{remark} & Remark, Note, Notation, Claim, Summary, \\
+ & Acknowledgment, Case, Conclusion
+\end{tabular}
+
+\subsection{Number swapping}
+
+A common style variation is to have the theorem number at the beginning
+of the heading instead of at the end, for example \qq{1.4 Theorem}
+instead of \qq{Theorem 1.4}. As this variation is usually applied
+to all \cn{theoremstyle}s, it is done by
+placing a \cn{swapnumbers} command at the beginning of the list of
+\cn{newtheorem} statements that should be affected. For example:
+\begin{verbatim}
+ \swapnumbers
+ \theoremstyle{plain}
+ \newtheorem{thm}{Theorem}[section]
+ \theoremstyle{remark}
+ \newtheorem{rem}{Remark}
+\end{verbatim}
+
+When \pkg{amsthm} is used with a non-AMS document class, and numbers are
+swapped, no period is set following the number; this differs from the
+``basic'' \latex/ style. A workaround will be given in the AMS Author
+FAQ~\cite{AF}.
+
+In some AMS document classes, the style of the swapped numbers matches
+that of section headings; this may not be the same style as the rest
+of the theorem heading.
+
+% amsart: lightface numbers, bold heading
+% amsproc: all lightface; section headings bold
+% amsbook: all lightface; section headings bold
+
+\newpage %%%%%%%%%%%%%%%%%%%%
+
+\enlargethispage{1\baselineskip} % to fit code on same page
+\subsection{New theorem styles}
+
+The \pkg{amsthm} package provides a \cn{newtheoremstyle} command
+to aid in the creation of custom styles, should the three predefined
+styles prove insufficient. The following example illustrates the use
+of the \cn{newtheoremstyle} command.
+\begin{verbatim}
+ \newtheoremstyle{note}% |?name>
+ {3pt}% |?Space above>|ntnote1
+ {3pt}% |?Space below>|ntnote1
+ {}% |?Body font>
+ {}% |?Indent amount>|ntnote2
+ {\itshape}% |?Theorem head font>
+ {:}% |?Punctuation after theorem head>
+ {.5em}% |?Space after theorem head>|ntnote3
+ {}% |?Theorem head spec |textup(can be left empty, meaning `normal'|textup)>
+\end{verbatim}
+\noindent
+\ntnote1 Space above and below: these are equal, but the defaults differ
+ when using an AMS document class vs.\ \verb+\usepackage{amsthm}+. For
+ AMS classes, this is \verb+.5\baselineskip+$\pm$\verb+.2\baselineskip+;
+ for \pkg{amsthm} used as a separate package, it is the local value
+ of \cn{topsep}. If these arguments are left empty, the current
+ defaults are used.
+
+\noindent
+\ntnote2 Indent amount: empty = no indent, \cn{parindent} = normal
+ paragraph indent
+
+\noindent
+\ntnote3 Space after theorem head: \verb+{ }+ = normal interword space; \\
+%\null\phantom{\ntnote2}
+ \cn{newline} = line break
+
+\smallskip
+Apply the new theorem style in the same manner as the predefined ones.
+
+Here are some styles that have been requested by authors.
+
+\subsubsection{Theorem style \texttt{break}}
+\label{thmstyle:break}
+This style will break after the theorem heading and start a new line.
+\begin{verbatim}
+\newtheoremstyle{break}%
+ {}{}%
+ {\itshape}{}%
+ {\bfseries}{}% % Note that final punctuation is omitted.
+ {\newline}{}
+\end{verbatim}
+
+This style can be used for a theorem beginning with a list.
+When used with \env{enumerate} and an AMS document class, all items
+are properly labeled and will link. However, the vertical spacing
+needs help; a conflict between definitions prevents the first
+item from starting on a new line---it looks almost the same as
+a default theorem beginning with an enumerated list.
+To repair this problem, begin the theorem like this:
+\begin{verbatim}
+ \begin{breakthm}[...]
+ \leavevmode \vspace{-\baselineskip}
+ \begin{enumerate}
+\end{verbatim}
+\verb+\leavevmode+ alone will leave a full blank line after the theorem head.
+
+One more problem may arise: if the theorem starts close to the end
+of a page, the list could be split to a new page, leaving an
+orphaned heading. Make a note to address this when the text is
+final; then call on the \pkg{needspace} \cite{NDS} package, or insert
+an explicit page break.
+
+\subsubsection{Theorem with bold note field}
+
+If the note---with surrounding parentheses---is particularly important,
+setting the note field in bold may be desired. This variation numbers
+the theorem, an option not available when using \cn{newtheorem*}.
+\begin{verbatim}
+\newtheoremstyle{bfnote}%
+ {}{}%
+ {\itshape}{}%
+ {\bfseries}{.}%
+ { }%
+ {\thmname{#1}\thmnumber{ #2}\thmnote{ (#3)}}
+\end{verbatim}
+
+Parentheses may be omitted from around the note using this trivial
+adaptation of the formulation with a bold note.
+\begin{verbatim}
+\newtheoremstyle{noparens}%
+ {}{}%
+ {\itshape}{}%
+ {\bfseries}{.}%
+ { }%
+ {\thmname{#1}\thmnumber{ #2}\thmnote{ #3}}
+\end{verbatim}
+
+%\subsubsection*{other suggested examples (to be considered)}
+%
+%\begin{verbatim}
+% Q-353 [\newtheoremstyle, used with numbers omits parens on text]
+% Q-426 [\newtheoremstyle, number font doesn't change with \@thmheadfont]
+%\end{verbatim}
+
+\subsubsection{Other styles}
+For examples, see the file \fn{thmtest.tex}.
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\newpage %%%%%%%%%%%%%%%%%%%%
+
+\section{Proofs}
+
+A predefined \env{proof} environment provided by the \pkg{amsthm}
+package produces the heading \qq{Proof} with appropriate spacing and
+punctuation. The proof environment is primarily intended for short
+proofs, no more than a page or two in length; longer proofs are
+usually better done as a separate \cn{section} or \cn{subsection} in
+your document.
+
+\subsection{The beginning of a proof}
+
+An optional argument of the proof environment allows you to substitute
+a different name for the standard \qq{Proof\/}. If you want
+the proof heading to be, say, \qq{Proof of the Main Theorem}, then write
+\begin{verbatim}
+ \begin{proof}[Proof of the Main Theorem]
+\end{verbatim}
+
+Because of the way the \env{proof} environment is defined (as a
+\latex/ list), a substitute ``name'' that is longer than one output
+line will not break as it should; this is on the list for repair.
+In the meantime, this redefinition in your preamble will accomplish
+the desired result.
+\begin{verbatim}
+ \makeatletter
+ \renewenvironment{proof}[1][\proofname]{\par
+ \pushQED{\qed}%
+ \normalfont \topsep6\p@\@plus6\p@\relax
+ \trivlist
+ \item\relax
+ {\itshape
+ #1\@addpunct{.}}\hspace\labelsep\ignorespaces
+ }{%
+ \popQED\endtrivlist\@endpefalse
+ }
+ \makeatother
+\end{verbatim}
+
+A proof beginning with a list can be approached in the same manner
+as a theorem; see section~\ref{ThmWithList}.
+
+\subsection{The end of a proof}
+
+A QED symbol, \qedsymbol, is automatically appended at the end of
+a \env{proof} environment. To substitute a different end-of-proof
+symbol, use \cn{renewcommand} to redefine the command \cn{qedsymbol}.
+For a long proof done as a subsection or section instead of with the
+\env{proof} environment, you can obtain the symbol and the usual
+amount of preceding space by using \cn{qed}; this will work properly
+only if it follows ordinary text.
+
+A blank line preceding \verb+\end{proof}+ (or before an explicit \cn{qed})
+disables the mechanism that places the QED symbol, and may even allow
+that symbol to be set at the top of a new page.
+
+Placement of the QED symbol can be problematic if the last part of
+a \env{proof} environment is a displayed equation or list environment
+or something of that nature. In that case put a \cn{qedhere} command at
+the place where the QED symbol should appear, for example,
+\begin{verbatim}
+ \begin{proof}
+ ...
+ \begin{equation}
+ G(t)=L\gamma!\,t^{-\gamma}+t^{-\delta}\eta(t) \qedhere
+ \end{equation}
+ \end{proof}
+\end{verbatim}
+When used with the \pkg{amsmath} package, version 2 or later, \cn{qedhere}
+will position the QED symbol flush right; with earlier versions, the
+symbol will be spaced a quad away from the end of the text or display.
+
+If \cn{qedhere} produces an error message in an equation, try using \\
+\verb+\mbox{\qedhere}+ instead.
+
+\cn{qedhere} does not work with \env{eqnarray} or with equations input
+with \verb+$$+; the display environments defined by \pkg{amsmath} and
+the \verb+\[ ... \]+ form of unnumbered equations have been specially
+crafted for this purpose.
+
+When a proof ends with a list environment, place \cn{qedhere} as the
+last thing before \verb+\end{enumerate}+ or \verb+\end{itemize}+.
+
+If, for some reason, it is desired to omit the QED symbol from the
+end of a proof, it can be suppressed by including this definition just
+before \verb+\end{proof}+:
+\begin{verbatim}
+ \renewcommand{\qedsymbol}{}
+\end{verbatim}
+If the symbol is to be omitted from \emph{all} proofs in the document,
+place the redefinition in the preamble.
+
+If the QED symbol is needed outside of the \env{proof} environment,
+use \cn{qed} rather than \cn{qedhere}.
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\newpage %%%%%%%%%%%%%%%%%%%%
+
+\section{Known problems}
+
+The following problems are listed for attention with the next update
+of \pkg{amsthm}.
+
+\begin{itemize}
+\item Problems with \cn{qedhere}. % B-366
+ \begin{itemize}
+ \item When \cn{qedhere} is used with an unstarred multi-line display
+ structure, the final line is not numbered. (This is relevant only
+ when numbers are on the left; \cn{qedhere} is inappropriate for
+ use with displays numbered on the right.)
+ \item When \cn{qedhere} is within a \env{split} environment, that
+ part of the display is not numbered and \cn{label} is suppressed.
+ If \cn{qedhere} is moved outside of \env{split} the number appears
+ but the content of the \env{split} is shifted left, and the QED
+ symbol may be absent.
+ \item In an alignment, if no \verb+&+ is present, the box does not
+ go flush to the right margin.
+ \item For a one-line equation, both the number and the box appear,
+ but the equation is shifted left.
+ \end{itemize}
+\item Other problems inherent in \pkg{amsthm}.
+ \begin{itemize}
+ \item Hyperlinking the first item when a theorem begins with a list.
+ \end{itemize}
+\item Problems of interaction with AMS document classes. Corrections
+ will be made in the classes, not in \pkg{amsthm}.
+ \begin{itemize}
+ \item In \cls{amsbook}, when a theorem appears before a chapter's
+ first numbered section, theorem numbering continues from the
+ previous chapter.
+ \end{itemize}
+\end{itemize}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\section{Other packages}
+
+Some packages provide additional theorem functionality, with options
+that recognize the presence of \pkg{amsthm} and adjust for it.
+\begin{itemize}
+\itemsep=.5\itemsep
+\item \pkg{mdframed} \cite{MDF} provides the ability to set off theorems
+ (and other elements) with frames of various shapes and colors.
+ It should be loaded \emph{after} \pkg{amsthm} if both are used.
+\item \pkg{thmtools} \cite{THT} provides an alternate key-value syntax
+ for theorem specification, as well as variant presentation styles,
+ both predefined and user definable. A QED symbol can be applied to any
+ theorem element, not just to proofs. An adaptable \cn{listoftheorems}
+ is also available.
+\end{itemize}
+For details, refer to the package manuals. Both packages are included
+in \TeX~Live, so can be accessed with
+\texttt{texdoc}~\<package>.
+
+Some packages that offer potentially useful features have limitations
+that conflict with the implementation of theorems with AMS document
+classes or \pkg{amsthm}. Here are some we know about.
+\begin{itemize}
+\itemsep=.5\itemsep
+\item \pkg{paralist} overrides the settings in \pkg{amsthm} that apply
+ \cn{upshape} to item numbers in an \env{enumerate} environment within
+ a theorem; the numbers become italic, which is undesired.
+\item \pkg{wrapfig} documents that it does not coexist with lists.
+ Both theorems and proofs in \pkg{amsthm} are based on \cn{trivlist}.
+ An insertion using this method may cause succeeding paragraphs to be
+ indented by the width of the insert even if the depth of the
+ insertion does not warrant it.
+\item \pkg{floatflt} and \pkg{picinpar} suffer from the same limitation.
+\end{itemize}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\section{Potential modifications}
+
+Feedback from users and experience with AMS publications have pointed
+out several areas where added flexibility can benefit both users of
+\pkg{amsthm.sty} and developers of ``derivative'' document classes
+based on the AMS set.
+
+These suggestions are relatively easy to implement:
+
+\begin{itemize}
+\item Change hard-coded font specifications (e.g., \cn{itshape})
+ to commands (e.g., \cn{proofheadingfont}) to allow modification.
+\item Provide commands instead of hard-coded values for other elements,
+ such as punctuation.
+\end{itemize}
+
+The following suggestions, while having merit, require more work, including
+redesign of existing code:
+
+\begin{itemize}
+\item Extend applicability of \cn{qedhere} to theorem-class elements
+ as well as to proofs.
+\item Provide a means to ignore the definition of \env{proof} to
+ avoid name conflicts with some non-AMS document classes.
+\item Consider key-value mechanism for specifying \cn{newtheoremstyle}
+ options.
+\item Provide a new theorem style that begins with a list.
+\end{itemize}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\section{Providing feedback}
+
+Reports on bugs found in this package should be submitted to\\
+ \null\hfil \href{mailto:tech-support@ams.org}{\texttt{tech-support@ams.org}}
+
+\noindent
+For best results, a brief, compilable example should accompany the report.
+
+An alternate method is to use the
+ \href{http://latex-project.org/bugs-upload.html}{\LaTeX\ bugs}
+ reporting mechanism, specifying \texttt{AMS-LaTeX} as the bug category.
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\begin{thebibliography}{[MDF]}
+
+\raggedright
+
+\bibitem[AF]{AF} AMS Author FAQ,
+ \url{http://www.ams.org/authors/author-faq}
+
+\bibitem[MDF]{MDF} The \pkg{mdframed} package,
+ Marco Daniel and Elke~Schubert, 2013/07/01, v1.9b,
+% \url{http://mirror.ctan.org/macros/latex/contrib/mdframed/mdframed.pdf}
+ \url{http://mirror.ctan.org/macros/latex/contrib/mdframed}
+
+\bibitem[NDS]{NDS} The \pkg{needspace} package,
+ Peter Wilson, 2010/09/12, v1.3d,
+ \url{http://mirror.ctan.org/macros/latex/contrib/needspace}
+
+\bibitem[THT]{THT} \pkg{Thmtools} Users' Guide,
+ Ulrich M. Schwarz, 2014/04/21 v66,
+% \url{http://mirror.ctan.org/macros/latex/exptl/thmtools/thmtools.pdf}
+ \url{http://mirror.ctan.org/macros/latex/exptl/thmtools}
+
+\end{thebibliography}
+
+\end{document}
diff --git a/macros/latex/required/amscls/doc/diffs-c.txt b/macros/latex/required/amscls/doc/diffs-c.txt
new file mode 100644
index 0000000000..61c647df7f
--- /dev/null
+++ b/macros/latex/required/amscls/doc/diffs-c.txt
@@ -0,0 +1,383 @@
+diffs-c.txt [2017/10/31]
+
+Copyright 2004, 2010, 2017 American Mathematical Society.
+
+American Mathematical Society
+Technical Support
+Publications Technical Group
+201 Charles Street
+Providence, RI 02904
+USA
+tel: (401) 455-4080
+ (800) 321-4267 (USA and Canada only)
+fax: (401) 331-3842
+email: tech-support@ams.org
+
+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
+ 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.
+
+This work has the LPPL maintenance status `maintained'.
+
+The Current Maintainer of this work is the American Mathematical
+Society.
+
+========================================================================
+
+History of changes for AMS document classes, the amsthm package, and
+other packages distributed in this collection.
+
+========================================================================
+Differences in amsart/amsbook/amsproc 2.20.4 (October 2017)
+
+---Text for \emailaddrname changed from "E-mail" to "Email".
+
+---Don't assume amsfonts is available when providing a fallback
+ definition of \dh; instead, issue a warning and substitute "dh".
+
+---The files instr-l.tex and instr-l.pdf have been removed, replaced
+ by a set of Author Handbooks in the separate collection amscls-doc.
+
+========================================================================
+Differences in amsthdoc 2.20.3 (September 2017)
+
+---Corrected example (p.5), \begin{thm} ... \end{theorem} to \end{thm}.
+ Added problem warning about \qedhere used within a split environment.
+
+========================================================================
+Differences in amsart/amsbook/amsproc 2.20.2 (April 2015)
+
+---Patched definition of \[ for compatibility with the fixltx2e package
+ and post-2014 versions of the LaTeX kernel. Thanks to David Carlisle.
+
+========================================================================
+Differences in amsthdoc 2.20.2 (April 2015)
+
+---Completely rewritten, adding examples, workarounds, and notes on
+ interaction with other packages and document classes.
+
+========================================================================
+Differences in amsart/amsbook/amsproc 2.20.1 (July 2009)
+
+---Added 2010 as a valid version of the Mathematics Subject
+ Classification.
+
+========================================================================
+========================================================================
+Differences in amsthm 2.20 (August 2004)
+
+---Added a fallback definition for \swappedhead@plain (used in
+ amsthm.sty 1.x).
+
+---For \proofname, changed from \newcommand to \providecommand in case
+ it's already defined.
+
+---Improved the handling of \qed when the [fleqn] option is used.
+
+---Avoid using \@elt in qed stack because LaTeX output routine falls
+ over if triggered when something else is using \@elt.
+
+========================================================================
+Differences in amsart/amsbook/amsproc 2.20 (August 2004)
+
+---Removed dependency on amsgen package.
+
+---Added warning message about graphics when draft option is used.
+
+---Added a check for \ifhmode when adding punctuation, and provided
+ \nopunct for omitting punctuation when not wanted.
+
+---Made \small, \Small, etc., robust in case they are used in a
+ \caption.
+
+---Changed handling of author names to prevent line breaks within
+ names.
+
+---For author URLs, made ~ a printable character.
+
+---amsart, amsproc: Defined \@logofont and \@copyinsfont and moved font
+ instructions out of \set@logo and \@setcopyright, to simplify style
+ changes in derivative classes.
+
+---Added \copyins to \@reinserts so that it would be included in the
+ page length calculation when a float is input on the first page
+
+!! This change may affect line breaks and page breaks.
+
+---Added provision for an extra line following the copyright line with
+ \@extracrline (for use in derivative classes).
+
+---amsart, amsproc: Added \contrib (similar to \author) to handle names
+ of persons who provided, e.g., an introduction or appendix. Usage:
+ \contrib[with Appendix 1 by]{John Smith}
+ \contrib[and Appendix 2 by]{Henry Moore}
+ \contrib{Roger Williams}
+ This will be set as part of the author block:
+ ...[authors]..., with Appendix 1 by John Smith, and Appendix 2
+ by Henry Moore and Roger Williams
+ Contributors are ignored when generating running heads.
+
+---Added \thanks@warning in case \thanks is included in \author.
+
+---Added \markleft to permit easy changes to left running head only.
+
+---Defined \@cleartopmattertags and moved commands to do this out of
+ \maketitle.
+
+---Added OT1 defaults for \DH, \dh, \DJ, \dj (ordinarily in T1 only).
+
+---Added braces to limit scope of \uppercasenonmath.
+
+---Segregated definition of administrative footnotes (\@adminfootnotes)
+ to permit easier customization for derivative document styles.
+
+---amsart: When subsection has no title, made number bold.
+
+---Fixed the handling of theorem head punctuation when \swapnumbers is
+ used. Used \thm@headsep instead of \labelsep for theorem heads.
+
+---Provided \@citestyle and \citeform to simplify change of font used
+ in citation.
+
+---Provided \bibliofont to allow author to make change.
+
+---Provided \@bibtitlestyle, \@defaultbiblabelstyle and
+ \@indextitlestyle to simplify style changes.
+
+---Changed output format of \MR to recognize change in format of
+ MathSciNet reference numbers; output is now all lightface instead
+ of having a bold volume number.
+
+!! This change will result in a change of appearance.
+
+---Reset \chaptername with \backmatter to avoid spurious "Appendix" in
+ t-of-c.
+
+---Added \indexintro to allow a block of text at the top of an index.
+
+---Made index ragged right and suppressed hyphenation.
+
+---Added \seeonly = "see" to get around unfortunate use of \see for
+ "see also"; added \seealso (from makeindex) for compatibility with
+ material originally set with a LaTeX document class.
+
+========================================================================
+Differences in upref 2.0 (July 2004)
+
+---Package will now work with hyperref, regardless of package input
+ order.
+
+========================================================================
+========================================================================
+Differences in amsthm 2.0 (November 1999)
+
+---Allow line breaks in theorem headings (added \deferred@thm@head and
+ related code).
+
+---Make \end{proof} force end of paragraph so following text is
+ indented (oversight in version 1.2).
+
+!! This change may affect line breaks and page breaks.
+
+---Added \qedhere command for flush-right QED symbol in displayed
+ equations.
+
+---Added amsthdoc.tex documentation file (taken from amsldoc.tex).
+
+---Merged amsthm.dtx into amsclass.dtx.
+
+========================================================================
+Differences in amsart/amsbook/amsproc 2.0 (November 1999)
+
+---Corrected erroneous default style for labelenumi (should be parens
+ instead of period); increase list left margins slightly.
+
+!! To revert to former style: \renewcommand{\labelenumi}{\theenumi.}
+
+---amsart: For "swapped" theorem heads (numbers shifted to the left
+ margin) the number font was changed to lightface to match subsection
+ numbers. This is an AMS journal style requirement---old behavior was
+ incorrect.
+
+!! This change may affect line breaks and page breaks.
+
+---Overfull \vbox messages for every other page: increased headheight
+
+---Added openany option for amsbook
+
+---Moved erroneously placed \endgroup in \curraddr, \email and \urladdr
+
+---Added a year option to \subjclass (default to 1991 for backward
+ compatibility).
+
+---For \cleardoublepage, use \pagestyle{empty} for blank pages.
+
+---Empty argument of \thanks: do nothing instead of printing an empty
+ footnote.
+
+---Clear up contradictory font size commands for abstract; always
+ \Small,
+
+---Omit final punctuation for \section{} head containing only a number.
+
+---Added \contentsnamefont to make changes easier.
+
+---Read a .cfg file.
+
+---Changed \parindent\z@ to \@parboxrestore in \@serieslogo to avoid
+ side effects depending on context of pagebreaks.
+
+---Use \protect instead of \@nx in \@secmark.
+
+---Moved \thispagestyle{firstpage} closer to beginning of \maketitle to
+ assure that the logo will be set on the first page if long abstract
+ breaks to second page (for derivative classes that don't box the
+ abstract).
+
+---Added support for paragraph, subparagraph.
+
+---In \partrunhead, added \ignorespaces, \unskip.
+
+---In \@starttoc, set \parskip to zero.
+
+---In \indexchap, rearranged commands to fix vertical spacing for
+ title; wrong \baselineskip was being used, resulting in title 6pt
+ too low.
+
+---Footnote failure in minipage: Changed \@makefnmark so that it
+ doesn't use math mode.
+
+---Added figure* and table* environments
+
+---Revised \@cflci to do the right thing with drop folio at the end of
+ a two-column page.
+
+---Incorporate amsthm package by direct embedding instead of
+ \RequirePackage.
+
+---Added missing default definition for \MRhref.
+
+---Use \MakeTextUppercase if available to handle latin-1 characters in
+ author names.
+
+---amsbook: Print keywords and date info on title-page obverse if
+ given.
+
+---Added various features for AMS in-house use: \dateposted, e-only
+ option, \Mc, etc.
+
+========================================================================
+Differences in amsart/amsbook/amsproc 1.2 (January 1995)
+
+---Documentation
+
+The documentation for the AMS documentclasses, formerly contained in
+amslatex.tex, is now found in instr-l.tex in the amslatex/classes area.
+This is a copy of the file instr-l.tex that is found in the author-info
+area of e-math.ams.org. That area contains additional information
+pertaining specifically to the submission of LaTeX or AmS-TeX documents
+to AMS publications.
+
+---New documentclass "amsproc".
+
+A document class amsproc has been added for books that consist of a
+collection of articles, such as the proceedings of a conference.
+
+---Different placement of "abstract" environment.
+
+The abstract should now be entered *before* the \maketitle command.
+This provides maximum control over the position and vertical spacing
+when printing the abstract information at different places, as required
+by different AMS publications---for example, in some publications the
+abstract may be required to fall between certain other elements in the
+beginning section of a document, or it may be postponed to the end of
+the document, or it might even be omitted entirely. If an abstract is
+entered after \maketitle, it will still be printed, but with a warning
+(and possibly in the wrong place or with wrong spacing).
+
+---Treatment of the @ character.
+
+As the AMS document classes automatically load the amsmath package, all
+changes for amsmath 1.2 affect the AMS classes also. Note in particular
+that the @ character is no longer a special command prefix, so to
+produce a printed @ in an e-mail address you should now write simply
+@ instead of @@.
+
+---The nonbreaking dash commands @-, @--, @--- are no longer available
+because @ as a special command prefix has disappeared. An alternative
+\nobreakdash command is provided in the amsmath package.
+
+---Added "nomath" option.
+
+The AMS document classes now take an option nomath that suppresses
+the automatic loading of the amsmath package. This is sometimes helpful
+in converting a pre-existing document to AMS style if you only want to
+do a quick conversion without attempting to deal with any of the math.
+
+---Theorem handling.
+
+Theorem setup is now handled by the amsthm package instead of the
+"theorem" package. \theorembodyfont, \theoremheaderfont, etc are not
+used any more. See amsldoc.tex and thmtest.tex for details.
+
+---The old environments pf, pf* are superseded by a single proof
+environment. It takes an optional argument to specify an alternative
+heading text.
+
+If you are converting an older document to run with \documentclass
+instead of \documentstyle, here is how you could provide
+backward-compatible definitions for pf and pf*:
+
+ \newenvironment{pf}{\proof[\proofname]}{\endproof}
+ \newenvironment{pf*}[1]{\proof[#1]}{\endproof}
+
+---\small now produces 9pt text; \tiny now produces 6pt text
+
+Formerly \small produced the same typesize as \footnotesize (8pt). Now
+they produce different sizes, normally 9 and 8 respectively. Also the
+range of typesize-changing commands is filled out to include, below
+\normalsize, the following: \small, \Small, \SMALL, \tiny, \Tiny.
+\footnotesize and \scriptsize are retained as synonyms of \Small and
+\SMALL respectively. As it stands \tiny no longer produces the same
+typesize as it did before (now 6 instead of 5), except in compatibility
+mode. This might affect some existing documents if they are updated to
+use \documentclass instead of \documentstyle. Similarly, \large now
+produces 11pt if the base size is 10pt, where formerly it produced
+12pt.
+
+New commands \larger and \smaller are provided for changing the
+typesize relative to the current size. These commands take an optional
+integer argument to specify how many steps to go up or down: \larger[2]
+means go up two sizes, and \larger without an optional argument is the
+same as \larger[1]. The list of sizes is a standard progression of
+type sizes and associated linespacing values as defined by the
+documentclass. If you need finer control over type size or linespacing,
+consult the LaTeX documentation about the \fontsize command.
+
+---Extra documentclass options 8pt, 9pt, 11pt, 12pt
+
+---The \qed symbol is now an open square
+
+The \qed symbol is no longer a filled black square, but an open square,
+and it is positioned at the right margin, instead of at a fixed
+horizontal distance from the preceding text. If the \qed command is
+used inside a displayed equation, however, it will be placed at a fixed
+distance from the preceding material (correct placement in this case is
+limited by some technical difficulties).
+
+---The command \rom was renamed to \upn.
+
+The command \rom, for making numbers and punctuation roman/upright in
+italic text, has been renamed \upn ``upright punctuation or number''.
+It will in most cases suffice to leave this refinement undone until a
+document is sent to a publisher for final typesetting, and furthermore,
+certain publications at the AMS now use special in-house italic fonts
+that have upright numbers and punctuation built in, making the use of
+\upn unnecessary even then. For general preprint-type use, this
+refinement is one that most users probably won't care to bother with.
+
+========================================================================
diff --git a/macros/latex/required/amscls/doc/install.txt b/macros/latex/required/amscls/doc/install.txt
new file mode 100644
index 0000000000..27519dde83
--- /dev/null
+++ b/macros/latex/required/amscls/doc/install.txt
@@ -0,0 +1,126 @@
+install.txt for amscls 2.20.4 [2017/10/31]
+
+Copyright 2005, 2010, 2017 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
+ 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.
+
+This work has the LPPL maintenance status `maintained'.
+
+===========================================================================
+
+If you have a relatively up-do-date TeX system that complies with the
+TeX Directory Structure (TDS) standard, check first to see if there is
+an available procedure that will install the package automatically from
+a CTAN archive. Otherwise, installing according to the instructions in
+section I below is the easiest method. See
+
+ http://www.tug.org/tds/tds.pdf
+
+for details on the TDS standard. TeX Live distributions comply with
+the standard, as do MikTeX and MacTeX.
+
+If your TeX system does not comply with the TDS standard, please contact
+the provider of your TeX system for details on how to install third-party
+TeX packages.
+
+The first step is to identify the TEXMF folder that contains files used
+by LaTeX. To do this, look for the file article.cls. If you find, e.g.,
+
+ /usr/local/share/texmf/tex/latex/base/article.cls
+
+then we will define TEXMF to mean /usr/local/share/texmf (everything
+up to the /tex/latex/base part). On a Windows system the file location
+will probably be something like
+
+ c:\sw\texmf\tex\latex\base\article.cls
+
+Then we define TEXMF to mean c:\sw\texmf. In the following
+instructions, wherever you see "TEXMF" substitute the folder name
+determined in this way.
+
+If this terminology does not make sense to you, seek assistance from
+a friend or colleague, or from the source that you obtained your TeX
+system from, or contact us at
+
+ tech-support@ams.org
+ 800-321-4AMS (321-4267) (USA/Canada)
+ 401-455-4080
+
+========================================================================
+I. Installing the easy way.
+
+1. Download the following archive file:
+
+ http://mirror.ctan.org/install/macros/latexf/required/amscls.tds.zip
+
+2. View the following files to assess the effects of the upgrade on
+your system:
+
+ README
+ install.txt (this file)
+ diffs-c.txt
+
+3. Backup the old version of amscls, preferably by moving it out of
+the TEXMF tree.
+
+4. Extract files from the .zip archive using your favorite unzip tool,
+setting the extraction target directory to the texmf root directory.
+
+5. To check the end result, you should find that you now have amsart.cls
+in the following location
+
+ TEXMF/tex/latex/amscls/amsart.cls
+
+Some TeX systems also use a database to keep track of TeX input files.
+If this database is not updated, your TeX system might not find the
+newly installed files. Consult your system's documentation to determine
+how to update this database.
+
+6. There are no duplicate files in this archive. As distributed, the
+files in the source/latex/amscls area comprise a complete copy of the
+distribution from which all the other files needed for LaTeX processing
+can be regenerated if need be. If you need to conserve disk space, you
+could delete the files in the source area, since they are not needed
+for normal use.
+
+========================================================================
+II. Installing the not-so-easy way.
+
+Download http://mirror.ctan.org/macros/latex/required/amscls.zip
+
+Make the following directories, if not already present:
+
+ TEXMF/source/latex/amscls
+ TEXMF/tex/latex/amscls
+ TEXMF/doc/latex/amscls
+
+Backup your old amscls files if they are installed, preferably moving
+them out of the TEXMF tree.
+
+Create a temporary directory and generate documentation files (these
+assume a *nix TeX installation):
+
+ - make directory /tmp/amscls
+ - unzip -d /tmp/amscls amscls.zip
+ - cd /tmp/amscls
+ - Run latex on the file amsclass.ins and other *.ins files to produce
+ .cls and .sty files
+ - Run latex on *.tex
+ - [optional] Run pdflatex on *.dtx (technical documentation)
+ - move *.pdf and *.tex to TEXMF/doc/latex/amscls
+ - [optional] move *.dtx to TEXMF/doc/latex/amscls
+ - move *.sty and *.cls to TEXMF/tex/latex/amscls
+ - delete /tmp/amscls
+
+Some TeX systems also use a database to keep track of TeX input files.
+If this database is not updated, your TeX system might not find the
+newly installed files. Consult your system's documentation to determine
+how to update this database.
+
+========================================================================
diff --git a/macros/latex/required/amscls/doc/manifest.txt b/macros/latex/required/amscls/doc/manifest.txt
new file mode 100644
index 0000000000..7cdaad319b
--- /dev/null
+++ b/macros/latex/required/amscls/doc/manifest.txt
@@ -0,0 +1,29 @@
+00LICENSE.txt
+README
+amsalpha.bst
+amsart-template.tex
+amsbook-template.tex
+amsbooka.dtx
+amsbooka.ins
+amsbooka.pdf
+amsclass.dtx
+amsclass.ins
+amsclass.pdf
+amsdtx.dtx
+amsdtx.ins
+amsdtx.pdf
+amsmidx.dtx
+amsmidx.ins
+amsmidx.pdf
+amsplain.bst
+amsproc-template.tex
+amsthdoc.pdf
+amsthdoc.tex
+diffs-c.txt
+install.txt
+manifest.txt
+thmtest.pdf
+thmtest.tex
+upref.dtx
+upref.ins
+upref.pdf
diff --git a/macros/latex/required/amscls/doc/thmtest.pdf b/macros/latex/required/amscls/doc/thmtest.pdf
new file mode 100644
index 0000000000..c7456d740d
--- /dev/null
+++ b/macros/latex/required/amscls/doc/thmtest.pdf
Binary files differ
diff --git a/macros/latex/required/amscls/doc/thmtest.tex b/macros/latex/required/amscls/doc/thmtest.tex
new file mode 100644
index 0000000000..d097f1e00b
--- /dev/null
+++ b/macros/latex/required/amscls/doc/thmtest.tex
@@ -0,0 +1,247 @@
+%% filename: thmtest.tex
+%% version: 2.01
+%% date: 2004/08/02
+%%
+%% American Mathematical Society
+%% Technical Support
+%% Publications Technical Group
+%% 201 Charles Street
+%% Providence, RI 02904
+%% USA
+%% tel: (401) 455-4080
+%% (800) 321-4267 (USA and Canada only)
+%% fax: (401) 331-3842
+%% email: tech-support@ams.org
+%%
+%% Copyright 1996, 2004, 2010 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
+%% 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.
+%%
+%% This work has the LPPL maintenance status `maintained'.
+%%
+%% The Current Maintainer of this work is the American Mathematical
+%% Society.
+%%
+%% ====================================================================
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Option test file, will be created during the first LaTeX run;
+% this facility is not available when using an AMS document class.
+\begin{filecontents}{exercise.thm}
+\def\th@exercise{%
+ \normalfont % body font
+ \thm@headpunct{:}%
+}
+\end{filecontents}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\documentclass{article}
+\title{Newtheorem and theoremstyle test}
+\author{Michael Downes\\updated by Barbara Beeton}
+
+\usepackage[exercise]{amsthm}
+
+\newtheorem{thm}{Theorem}[section]
+\newtheorem{cor}[thm]{Corollary}
+\newtheorem{prop}{Proposition}
+\newtheorem{lem}[thm]{Lemma}
+
+\theoremstyle{remark}
+\newtheorem*{rmk}{Remark}
+
+\theoremstyle{plain}
+\newtheorem*{Ahlfors}{Ahlfors' Lemma}
+
+\newtheoremstyle{note}% name
+ {3pt}% Space above
+ {3pt}% Space below
+ {}% Body font
+ {}% Indent amount (empty = no indent, \parindent = para indent)
+ {\itshape}% Thm head font
+ {:}% Punctuation after thm head
+ {.5em}% Space after thm head: " " = normal interword space;
+ % \newline = linebreak
+ {}% Thm head spec (can be left empty, meaning `normal')
+
+\theoremstyle{note}
+\newtheorem{note}{Note}
+
+\newtheoremstyle{citing}% name
+ {3pt}% Space above, empty = `usual value'
+ {3pt}% Space below
+ {\itshape}% Body font
+ {}% Indent amount (empty = no indent, \parindent = para indent)
+ {\bfseries}% Thm head font
+ {.}% Punctuation after thm head
+ {.5em}% Space after thm head: " " = normal interword space;
+ % \newline = linebreak
+ {\thmnote{#3}}% Thm head spec
+
+\theoremstyle{citing}
+\newtheorem*{varthm}{}% all text supplied in the note
+
+\newtheoremstyle{break}% name
+ {9pt}% Space above, empty = `usual value'
+ {9pt}% Space below
+ {\itshape}% Body font
+ {}% Indent amount (empty = no indent, \parindent = para indent)
+ {\bfseries}% Thm head font
+ {.}% Punctuation after thm head
+ {\newline}% Space after thm head: \newline = linebreak
+ {}% Thm head spec
+
+\theoremstyle{break}
+\newtheorem{bthm}{B-Theorem}
+
+\theoremstyle{exercise}
+\newtheorem{exer}{Exercise}
+
+\swapnumbers
+\theoremstyle{plain}
+\newtheorem{thmsw}{Theorem}[section]
+\newtheorem{corsw}[thmsw]{Corollary}
+\newtheorem{propsw}{Proposition}
+\newtheorem{lemsw}[thmsw]{Lemma}
+
+% Because the amsmath pkg is not used, we need to define a couple of
+% commands in more primitive terms.
+\let\lvert=|\let\rvert=|
+\newcommand{\Ric}{\mathop{\mathrm{Ric}}\nolimits}
+
+% Dispel annoying problem of slightly overlong lines:
+\addtolength{\textwidth}{8pt}
+
+\begin{document}
+\maketitle
+
+\section{Test of standard theorem styles}
+
+Ahlfors' Lemma gives the principal criterion for obtaining lower bounds
+on the Kobayashi metric.
+
+\begin{Ahlfors}
+Let $ds^2 = h(z)\lvert dz\rvert^2$ be a Hermitian pseudo-metric on
+$\mathbf{D}_r$, $h\in C^2(\mathbf{D}_r)$, with $\omega$ the associated
+$(1,1)$-form. If $\Ric\omega\geq\omega$ on $\mathbf{D}_r$,
+then $\omega\leq\omega_r$ on all of $\mathbf{D}_r$ (or equivalently,
+$ds^2\leq ds_r^2$).
+\end{Ahlfors}
+
+\begin{lem}[negatively curved families]
+Let $\{ds_1^2,\dots,ds_k^2\}$ be a negatively curved family of metrics
+on $\mathbf{D}_r$, with associated forms $\omega^1$, \dots, $\omega^k$.
+Then $\omega^i \leq\omega_r$ for all $i$.
+\end{lem}
+
+Then our main theorem:
+\begin{thm}\label{pigspan}
+Let $d_{\max}$ and $d_{\min}$ be the maximum, resp.\ minimum distance
+between any two adjacent vertices of a quadrilateral $Q$. Let $\sigma$
+be the diagonal pigspan of a pig $P$ with four legs.
+Then $P$ is capable of standing on the corners of $Q$ iff
+\begin{equation}\label{sdq}
+\sigma\geq \sqrt{d_{\max}^2+d_{\min}^2}.
+\end{equation}
+\end{thm}
+
+\begin{cor}
+Admitting reflection and rotation, a three-legged pig $P$ is capable of
+standing on the corners of a triangle $T$ iff (\ref{sdq}) holds.
+\end{cor}
+
+\begin{rmk}
+As two-legged pigs generally fall over, the case of a polygon of order
+$2$ is uninteresting.
+\end{rmk}
+
+\section{Custom theorem styles}
+
+\begin{exer}
+Generalize Theorem~\ref{pigspan} to three and four dimensions.
+\end{exer}
+
+\begin{note}
+This is a test of the custom theorem style `note'. It is supposed to have
+variant fonts and other differences.
+\end{note}
+
+\begin{bthm}
+Test of the `linebreak' style of theorem heading.
+\end{bthm}
+
+This is a test of a citing theorem to cite a theorem from some other source.
+
+\begin{varthm}[Theorem 3.6 in \cite{thatone}]
+No hyperlinking available here yet \dots\ but that's not a
+bad idea for the future.
+\end{varthm}
+
+\section{The proof environment}
+
+\begin{proof}
+Here is a test of the proof environment.
+\end{proof}
+
+\begin{proof}[Proof of Theorem \ref{pigspan}]
+And another test.
+\end{proof}
+
+\begin{proof}[Proof \textup(necessity\textup)]
+And another.
+\end{proof}
+
+\begin{proof}[Proof \textup(sufficiency\textup)]
+And another, ending with a display:
+\[
+1+1=2\,. \qedhere
+\]
+\end{proof}
+
+\section{Test of number-swapping}
+
+This is a repeat of the first section but with numbers in theorem heads
+swapped to the left.
+
+Ahlfors' Lemma gives the principal criterion for obtaining lower bounds
+on the Kobayashi metric.
+\begin{Ahlfors}
+Let $ds^2 = h(z)\lvert dz\rvert^2$ be a Hermitian pseudo-metric on
+$\mathbf{D}_r$, $h\in C^2(\mathbf{D}_r)$, with $\omega$ the associated
+$(1,1)$-form. If $\Ric\omega\geq\omega$ on $\mathbf{D}_r$,
+then $\omega\leq\omega_r$ on all of $\mathbf{D}_r$ (or equivalently,
+$ds^2\leq ds_r^2$).
+\end{Ahlfors}
+
+\begin{lemsw}[negatively curved families]
+Let $\{ds_1^2,\dots,ds_k^2\}$ be a negatively curved family of metrics
+on $\mathbf{D}_r$, with associated forms $\omega^1$, \dots, $\omega^k$.
+Then $\omega^i \leq\omega_r$ for all $i$.
+\end{lemsw}
+
+Then our main theorem:
+\begin{thmsw}
+Let $d_{\max}$ and $d_{\min}$ be the maximum, resp.\ minimum distance
+between any two adjacent vertices of a quadrilateral $Q$. Let $\sigma$
+be the diagonal pigspan of a pig $P$ with four legs.
+Then $P$ is capable of standing on the corners of $Q$ iff
+\begin{equation}\label{sdqsw}
+\sigma\geq \sqrt{d_{\max}^2+d_{\min}^2}.
+\end{equation}
+\end{thmsw}
+
+\begin{corsw}
+Admitting reflection and rotation, a three-legged pig $P$ is capable of
+standing on the corners of a triangle $T$ iff (\ref{sdqsw}) holds.
+\end{corsw}
+
+\begin{thebibliography}{99}
+\bibitem{thatone} Dummy entry.
+\end{thebibliography}
+
+\end{document}
diff --git a/macros/latex/required/amscls/doc/upref.pdf b/macros/latex/required/amscls/doc/upref.pdf
new file mode 100644
index 0000000000..ae3a6e1a86
--- /dev/null
+++ b/macros/latex/required/amscls/doc/upref.pdf
Binary files differ
diff --git a/macros/latex/required/amscls/upref.dtx b/macros/latex/required/amscls/upref.dtx
new file mode 100644
index 0000000000..2f2fad5572
--- /dev/null
+++ b/macros/latex/required/amscls/upref.dtx
@@ -0,0 +1,165 @@
+% \def\filename{upref.dtx}
+% \def\fileversion{2.04}
+% \def\filedate{2007/03/14}
+%
+% \iffalse meta-comment
+%
+% American Mathematical Society
+% Technical Support
+% Publications Technical Group
+% 201 Charles Street
+% Providence, RI 02904
+% USA
+% tel: (401) 455-4080
+% (800) 321-4267 (USA and Canada only)
+% fax: (401) 331-3842
+% email: tech-support@ams.org
+%
+% Copyright 1996, 2010 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
+% 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.
+%
+% This work has the LPPL maintenance status `maintained'.
+%
+% The Current Maintainer of this work is the American Mathematical
+% Society.
+%
+% \fi
+%
+%\iffalse
+%<*driver>
+\documentclass{amsdtx}
+\begin{document}
+\title{The \pkg{upref} package}
+\author{American Mathematical Society\\ Michael Downes\\
+ updated by Barbara Beeton}
+\date{Version \fileversion, \filedate}
+\DocInput{upref.dtx}
+\end{document}
+%</driver>
+%\fi
+%
+% \maketitle
+%
+% \MakeShortVerb\|
+%
+% \section{Introduction}
+%
+% This package changes the \cn{ref} command so that it never applies
+% a slanted font shape to its argument, regardless of context. This
+% was the default behavior in \cls{amsart} version 1.1. Starting with
+% \cls{amsart} version 1.2, upright references must be obtained via
+% |\usepackage{upref}|.
+%
+% \StopEventually{}
+%
+% \section{Implementation}
+% Give package name, date, version.
+% \begin{macrocode}
+\NeedsTeXFormat{LaTeX2e}[1995/06/01]
+\ProvidesPackage{upref}[2007/03/14 v2.04]
+% \end{macrocode}
+%
+% \begin{macro}{\@noref}
+% Give a warning if a cited reference isn't defined.
+% \begin{macrocode}
+\newcommand{\@noref}[1]{%
+ \G@refundefinedtrue
+ \nfss@text{\reset@font\bfseries ??}%
+ \@latex@warning{Reference `#1' on page \thepage\space undefined}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@setref}
+% If the current fontshape is italic or slanted, we want to switch to
+% upright/roman for printing the number of a \cn{ref}. This requires
+% changing the \cs{@setref} command.
+%
+% Since \cs{@setref} is modified by the \pkg{hyperref} package, delay
+% the definition until \cs{AtBeginDocument}. Then check whether
+% \pkg{hyperref} is loaded. If it is, we have to redefine some
+% control sequences that \pkg{hyperref} defined in order to get
+% upright references even in a \pkg{hyperref} environment.
+% [tjk,bnb, 2004/07/29]
+%
+% Get around a restriction in an internal AMS package (shaderef) by
+% equating its command \cs{printref} to \cn{textup}; this applies
+% consistently regardless of other circumstances that have unwanted
+% effects. [dmj,bnb, 2005/05/17]
+% \begin{macrocode}
+\AtBeginDocument{%
+ \providecommand\printref{\textup}%
+ \@ifpackageloaded{hyperref}{%
+% \end{macrocode}
+% We overload \cs{Hy@setref@link} as this is where the upright
+% references get clobbered. Used in overloaded \cs{@setref}.
+% \cs{sw@slant} is usually applied by \cn{textup}, but the specials
+% inserted by the hyperlink get in the way of testing for whether
+% an italic correction is necessary; restore the test.
+% [dmj,bnb, 2005/09/22]
+%
+% If the link happens to be at the beginning of a paragraph,
+% \cs{sw@slant} will produce an error, since neither \unpenalty
+% nor a check for italic correction is valid in vertical mode.
+% For reasons not apparent, this may also occur in some other
+% situations, e.g., following a proof heading containing a cross
+% reference (jams561el). Add \cn{leavevmode} to compensate.
+% [dmj,bnb, 2007/02/14]
+% \begin{macrocode}
+ \def\Hy@setref@link#1#2#3#4#5#6\@nil#7{%
+ \begingroup
+ \leavevmode
+ \sw@slant
+ \toks0{\hyper@@link{#5}{#4}}%
+ \toks1\@xp{#7{\printref{#1}\hbox{}}{#2}{#3}{#4}{#5}}%
+ \edef\x{\endgroup\the\toks0{\the\toks1}}\x
+ }%
+% \end{macrocode}
+% We should not have to overload \cs{@setref}, but there is
+% a chance that an author is using an old version of hyperref
+% which does not use \cs{Hy@setref@link} in \cs{@setref}.
+% \begin{macrocode}
+ \def\@setref#1#2#3{%
+ \ifx#1\relax
+ \@xp\protect\@noref{#3}%
+ \else
+ \@xp\Hy@setref@link#1\@empty\@empty\@nil{#2}%
+ \fi
+ }%
+ }{%
+ \def\@setref#1#2#3{\ifx#1\relax
+ \protect\@noref{#3}%
+ \else
+ \protect\printref{\@xp#2#1\hbox{}}%
+ \fi
+ }%
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@upn}
+% The function \cs{\@upn} is used to force theorem numbers and
+% similar elements to be upright in sloped or italic contexts.
+% If a suitable italic font with upright numbers and punctuation is
+% available, this function should be redefined to be a no-op.
+% \begin{macrocode}
+\providecommand\@upn{\textup}
+% \end{macrocode}
+% \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{66}
+% \Finale
diff --git a/macros/latex/required/amscls/upref.ins b/macros/latex/required/amscls/upref.ins
new file mode 100644
index 0000000000..422e57b308
--- /dev/null
+++ b/macros/latex/required/amscls/upref.ins
@@ -0,0 +1,76 @@
+%% filename: upref.ins
+%% version: 1.1
+%% date: 2014/07/24
+%%
+%% American Mathematical Society
+%% Technical Support
+%% Publications Technical Group
+%% 201 Charles Street
+%% Providence, RI 02904
+%% USA
+%% tel: (401) 455-4080
+%% (800) 321-4267 (USA and Canada only)
+%% fax: (401) 331-3842
+%% email: tech-support@ams.org
+%%
+%% Copyright 2010, 2014 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
+%% 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.
+%%
+%% This work has the LPPL maintenance status `maintained'.
+%%
+%% The Current Maintainer of this work is the American Mathematical
+%% Society.
+%%
+%% ====================================================================
+
+\input docstrip
+
+\askforoverwritefalse
+
+\keepsilent
+
+\preamble
+This is a generated file.
+
+Copyright 1996, 2010 American Mathematical Society.
+
+American Mathematical Society
+Technical Support
+Publications Technical Group
+201 Charles Street
+Providence, RI 02904
+USA
+tel: (401) 455-4080
+ (800) 321-4267 (USA and Canada only)
+fax: (401) 331-3842
+email: tech-support@ams.org
+
+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
+ 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.
+
+This work has the LPPL maintenance status `maintained'.
+
+The Current Maintainer of this work is the American Mathematical
+Society.
+
+========================================================================
+
+\endpreamble
+
+\generate{
+ \file{upref.sty}{\from{upref.dtx}{}}
+}
+
+\endbatchfile
diff --git a/macros/latex/required/amsmath/README.md b/macros/latex/required/amsmath/README.md
new file mode 100644
index 0000000000..9b2de98578
--- /dev/null
+++ b/macros/latex/required/amsmath/README.md
@@ -0,0 +1,98 @@
+## README for latex-amsmath bundle
+
+
+### 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 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 LaTeX3 Project; as amsmath is considered a "required" package, this
+centralizes control over the core LaTeX components.
+
+
+### INSTALLATION AND GETTING STARTED
+
+In order to use amsmath you need to have TeX installed first.
+For information on getting TeX see one of the following:
+
+ - [LaTeX Project Website](https://www.latex-project.org/)
+ - [TeX User Group](https://www.tug.org/)
+ - [TeX resources (AMS infos for authors)](https://www.ams.org/tex/tex-resources)
+
+It is recommended to install a comprehensive distribution, such as
+TeX Live, MiKTeX for Windows, or MacTeX for Macintosh.
+As part of the "required" LaTeX package subset, amsmath
+will already be available if one of these distributions is chosen.
+
+If you are installing amsmath manually, the most recent version
+will be available from the CTAN archives
+https://www.ctan.org/pkg/amsmath
+
+
+The primary documentation for amsmath is in
+
+ - 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 LOG
+
+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 any of these packages
+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!
+
+
+### Copyright
+
+Copyright 2001-2004, 2007, 2008, 2010, 2011, 2013 American Mathematical Society.
+Copyright 2016-2018 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.
+
+This README file is copyright 2016-2018 The LaTeX3 Project.
diff --git a/macros/latex/required/amsmath/amsbsy.dtx b/macros/latex/required/amsmath/amsbsy.dtx
new file mode 100644
index 0000000000..21d61e8539
--- /dev/null
+++ b/macros/latex/required/amsmath/amsbsy.dtx
@@ -0,0 +1,238 @@
+%
+% \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
+%
+%\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/required/amsmath/amsbsy.ins b/macros/latex/required/amsmath/amsbsy.ins
new file mode 100644
index 0000000000..fe1cd5413d
--- /dev/null
+++ b/macros/latex/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/required/amsmath/amsbsy.pdf b/macros/latex/required/amsmath/amsbsy.pdf
new file mode 100644
index 0000000000..ae9cc56fcf
--- /dev/null
+++ b/macros/latex/required/amsmath/amsbsy.pdf
Binary files differ
diff --git a/macros/latex/required/amsmath/amscd.dtx b/macros/latex/required/amsmath/amscd.dtx
new file mode 100644
index 0000000000..176e7304be
--- /dev/null
+++ b/macros/latex/required/amsmath/amscd.dtx
@@ -0,0 +1,322 @@
+%
+% \iffalse meta-comment
+%
+% Copyright 1995, 1999 American Mathematical Society.
+% Copyright 2016-2017 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/required/amsmath/amscd.ins b/macros/latex/required/amsmath/amscd.ins
new file mode 100644
index 0000000000..148c4cb32e
--- /dev/null
+++ b/macros/latex/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/required/amsmath/amscd.pdf b/macros/latex/required/amsmath/amscd.pdf
new file mode 100644
index 0000000000..e66f4e75ab
--- /dev/null
+++ b/macros/latex/required/amsmath/amscd.pdf
Binary files differ
diff --git a/macros/latex/required/amsmath/amsgen.dtx b/macros/latex/required/amsmath/amsgen.dtx
new file mode 100644
index 0000000000..705168375e
--- /dev/null
+++ b/macros/latex/required/amsmath/amsgen.dtx
@@ -0,0 +1,386 @@
+%
+% \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
+%
+% \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/required/amsmath/amsgen.ins b/macros/latex/required/amsmath/amsgen.ins
new file mode 100644
index 0000000000..8c5683cb5a
--- /dev/null
+++ b/macros/latex/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/required/amsmath/amsgen.pdf b/macros/latex/required/amsmath/amsgen.pdf
new file mode 100644
index 0000000000..7a1a95c4d7
--- /dev/null
+++ b/macros/latex/required/amsmath/amsgen.pdf
Binary files differ
diff --git a/macros/latex/required/amsmath/amsldoc-1.pdf b/macros/latex/required/amsmath/amsldoc-1.pdf
new file mode 100644
index 0000000000..c3a8c86f0f
--- /dev/null
+++ b/macros/latex/required/amsmath/amsldoc-1.pdf
Binary files differ
diff --git a/macros/latex/required/amsmath/amsldoc-bb.pdf b/macros/latex/required/amsmath/amsldoc-bb.pdf
new file mode 100644
index 0000000000..71a18b3cba
--- /dev/null
+++ b/macros/latex/required/amsmath/amsldoc-bb.pdf
Binary files differ
diff --git a/macros/latex/required/amsmath/amsldoc.pdf b/macros/latex/required/amsmath/amsldoc.pdf
new file mode 100644
index 0000000000..5ea14d28a8
--- /dev/null
+++ b/macros/latex/required/amsmath/amsldoc.pdf
Binary files differ
diff --git a/macros/latex/required/amsmath/amsldoc.tex b/macros/latex/required/amsmath/amsldoc.tex
new file mode 100644
index 0000000000..1f46924b13
--- /dev/null
+++ b/macros/latex/required/amsmath/amsldoc.tex
@@ -0,0 +1,2770 @@
+%
+% Copyright 1995, 2000, 2013 American Mathematical Society.
+% Copyright 2016-2018 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/required/amsmath/amsmath.dtx b/macros/latex/required/amsmath/amsmath.dtx
new file mode 100644
index 0000000000..8e4943235f
--- /dev/null
+++ b/macros/latex/required/amsmath/amsmath.dtx
@@ -0,0 +1,6360 @@
+%
+% \iffalse meta-comment
+%
+% Copyright 1995, 2000, 2013 American Mathematical Society.
+% Copyright 2016-2018 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}
+%
+% Not yet used but for the future \ldots
+% \begin{macrocode}
+%\providecommand\DeclareRelease[3]{}
+%\providecommand\DeclareCurrentRelease[2]{}
+%
+%\DeclareRelease{}{2017-09-02}{amsmath-2017-09-02.sty}
+%\DeclareCurrentRelease{}{2018-12-01}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\ProvidesPackage{amsmath}[2018/12/01 v2.17b 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}
+\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}{\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/required/amsmath/amsmath.ins b/macros/latex/required/amsmath/amsmath.ins
new file mode 100644
index 0000000000..7a6a087359
--- /dev/null
+++ b/macros/latex/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/required/amsmath/amsmath.pdf b/macros/latex/required/amsmath/amsmath.pdf
new file mode 100644
index 0000000000..61d19095a9
--- /dev/null
+++ b/macros/latex/required/amsmath/amsmath.pdf
Binary files differ
diff --git a/macros/latex/required/amsmath/amsopn.dtx b/macros/latex/required/amsmath/amsopn.dtx
new file mode 100644
index 0000000000..a1127d3893
--- /dev/null
+++ b/macros/latex/required/amsmath/amsopn.dtx
@@ -0,0 +1,263 @@
+%
+% \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
+%
+%\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/required/amsmath/amsopn.ins b/macros/latex/required/amsmath/amsopn.ins
new file mode 100644
index 0000000000..8c977446cc
--- /dev/null
+++ b/macros/latex/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/required/amsmath/amsopn.pdf b/macros/latex/required/amsmath/amsopn.pdf
new file mode 100644
index 0000000000..a07f5a0378
--- /dev/null
+++ b/macros/latex/required/amsmath/amsopn.pdf
Binary files differ
diff --git a/macros/latex/required/amsmath/amstex.sty b/macros/latex/required/amsmath/amstex.sty
new file mode 100644
index 0000000000..edb57c1214
--- /dev/null
+++ b/macros/latex/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/required/amsmath/amstext.dtx b/macros/latex/required/amsmath/amstext.dtx
new file mode 100644
index 0000000000..fc9e127a11
--- /dev/null
+++ b/macros/latex/required/amsmath/amstext.dtx
@@ -0,0 +1,302 @@
+%
+% \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
+%
+% \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/required/amsmath/amstext.ins b/macros/latex/required/amsmath/amstext.ins
new file mode 100644
index 0000000000..84fcb0cb95
--- /dev/null
+++ b/macros/latex/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/required/amsmath/amstext.pdf b/macros/latex/required/amsmath/amstext.pdf
new file mode 100644
index 0000000000..b41ec69e29
--- /dev/null
+++ b/macros/latex/required/amsmath/amstext.pdf
Binary files differ
diff --git a/macros/latex/required/amsmath/amsxtra.dtx b/macros/latex/required/amsmath/amsxtra.dtx
new file mode 100644
index 0000000000..e7f1198d1e
--- /dev/null
+++ b/macros/latex/required/amsmath/amsxtra.dtx
@@ -0,0 +1,127 @@
+%
+% \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
+%
+%\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/required/amsmath/amsxtra.ins b/macros/latex/required/amsmath/amsxtra.ins
new file mode 100644
index 0000000000..9e739c3d4b
--- /dev/null
+++ b/macros/latex/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/required/amsmath/amsxtra.pdf b/macros/latex/required/amsmath/amsxtra.pdf
new file mode 100644
index 0000000000..882dce9197
--- /dev/null
+++ b/macros/latex/required/amsmath/amsxtra.pdf
Binary files differ
diff --git a/macros/latex/required/amsmath/changes.txt b/macros/latex/required/amsmath/changes.txt
new file mode 100644
index 0000000000..48a5e1992f
--- /dev/null
+++ b/macros/latex/required/amsmath/changes.txt
@@ -0,0 +1,119 @@
+
+#########################
+# 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/required/amsmath/diffs-m.txt b/macros/latex/required/amsmath/diffs-m.txt
new file mode 100644
index 0000000000..af3a273f52
--- /dev/null
+++ b/macros/latex/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/required/amsmath/manifest.txt b/macros/latex/required/amsmath/manifest.txt
new file mode 100644
index 0000000000..ee6b8e3238
--- /dev/null
+++ b/macros/latex/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/required/amsmath/subeqn.pdf b/macros/latex/required/amsmath/subeqn.pdf
new file mode 100644
index 0000000000..4d04db3b81
--- /dev/null
+++ b/macros/latex/required/amsmath/subeqn.pdf
Binary files differ
diff --git a/macros/latex/required/amsmath/subeqn.tex b/macros/latex/required/amsmath/subeqn.tex
new file mode 100644
index 0000000000..c34b3f6952
--- /dev/null
+++ b/macros/latex/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/required/amsmath/technote.pdf b/macros/latex/required/amsmath/technote.pdf
new file mode 100644
index 0000000000..e845ca15c8
--- /dev/null
+++ b/macros/latex/required/amsmath/technote.pdf
Binary files differ
diff --git a/macros/latex/required/amsmath/technote.tex b/macros/latex/required/amsmath/technote.tex
new file mode 100644
index 0000000000..aede450621
--- /dev/null
+++ b/macros/latex/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/required/amsmath/testmath.pdf b/macros/latex/required/amsmath/testmath.pdf
new file mode 100644
index 0000000000..6230a1dfdf
--- /dev/null
+++ b/macros/latex/required/amsmath/testmath.pdf
Binary files differ
diff --git a/macros/latex/required/amsmath/testmath.tex b/macros/latex/required/amsmath/testmath.tex
new file mode 100644
index 0000000000..069944ee9d
--- /dev/null
+++ b/macros/latex/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/required/babel/base/README.md b/macros/latex/required/babel/base/README.md
new file mode 100644
index 0000000000..40ce729ea6
--- /dev/null
+++ b/macros/latex/required/babel/base/README.md
@@ -0,0 +1,148 @@
+## Babel 3.33
+
+This package manages culturally-determined typographical (and other)
+rules, and hyphenation patterns for a wide range of languages. Many
+language styles work with pdflatex, as well as with xelatex and
+lualatex out of the box. A few even work with plain formats.
+
+The latest stable version is available on <https://ctan.org/pkg/babel>.
+
+Languages are not part of the Babel core any more; in particular, it
+shall be no longer necessary to synchronize Babel core releases with
+releases of Babel language files. See CONTRIB for further details
+about contributing a language. You may also create an ini file or
+improve the existing ones -- it's a trivial task (no programming
+skills required at all), but don't hesitate to ask for help.
+
+Included is a set of ini files for about 200 languages.
+
+The best way to install and/or update it is with the help of package
+managers.
+
+Changes are described in babel.pdf with the label "New <version>". The
+manual has been expanded to include some tips and tricks, but it will
+be improved in next releases.
+
+### Reporting Bugs
+
+If you wish to report a problem or bug in any of these packages please
+use the
+[Issue Tracker for LaTeX2e on GitHub](https://github.com/latex3/babel/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!
+
+You may also report them to the current maintainer more informally on:
+
+ http://www.texnia.com/contact.html
+
+Bugs related to specific languages are best reported to their
+respective authors.
+
+### Latest changes
+
+```
+3.33 2019-07-19
+ - \prehyphenchar set to 0 in languages requiring it: kannada,
+ marathi, tamil, etc. (lua).
+ - \AddBabelHook can be set for specific languages.
+ - Fix - !\grq in T1 behaved like the ligature !`.
+ - Minimal preliminary support for the experimental harftex.
+3.32 2019-06-03
+ - CJK line breaking is now disabled in verbatim (lua).
+ - New - \babelcharproperty, to change the direction, mirroring
+ glyph and line break properties (lua).
+ - Basic support for the picture environment (with pict2e) and pgf
+ (lua, somewhat experimental).
+ - Start support for harftex (just try - it may work).
+
+3.31 2019-05-04
+ - Basic support for line breaking with CJK scripts (lua)
+ - layout=tabular now works with the 'array' package (and some
+ others; lua).
+
+3.30 2019-04-22
+ - Fix - dir in boxes inside math (hopefully now it works; lua).
+ - Option mapdigits for \babelprovide, which converts European
+ digits to local ones (lua).
+
+3.29 2019-04-03
+ - The fix for boxes inside math is incompatible with ams.
+ Removed (a better fix is under study).
+ - Options bidi-l and bidi-r (for the bidi package; xe).
+
+3.28 2019-04-01
+ - Fixes - wrong dir after math, in math inside tabular, in weak L
+ inside R inside L, and in boxes inside math.
+ - \babelfont now takes into account \defaultfontfeatures. This
+ is a potential source of backwards incompatibilities, but
+ very likely the risks are very low, and it is, I think, the
+ expected behavior.
+
+3.27 2018-11-13
+ - Preliminary support for bidi (by Vafa Khalighi) with xetex.
+ - Fix for 3.23 - \ensureascii was redefined even when not
+ necessary.
+ - Minor improvements in babel-vi.ini.
+
+3.26 2018-10-16
+ - Fix for 3.25 - \babelprovide raised an error with xetex.
+
+3.25 2018-10-03
+ - Fixes for 3.23 - mapfont=direction could raise an error.
+ - Language and Script were not always defined correctly.
+ - Improved tentative support for Thai, Lao and Khmer in both
+ luatex and xetex.
+
+3.24 2018-09-26
+ - Prelimimary support for Thai interword spacing with luatex.
+
+3.23 2018-09-02
+ - After extensive tests and fixing some issues, bidi=basic is
+ not experimental any longer.
+ - import in \babelprovide does not require a language code if
+ the language name is a recognized one.
+ - New macro: \ifbabelshorthand.
+ - TS1, T3 and TS3 have been added to the non-ascii list, to
+ avoid problems in case no ASCII-savvy encoding is requested.
+ - Define Language and Script if fontspec does not known them (eg,
+ the Japanese script).
+ - Set the \thepage bidi bahavior in foots/heads.
+ - Fix - Undefined \bbl@stripslash in Plain.
+
+3.22 2018-06-05
+ - Fix - Error with \chapter if empty in ini
+ - Prelimimary support for Sanskrit
+ - Unknown languages in aux files do not raise an error
+ any more (only show a warning).
+
+3.21 2018-05-10
+ - Fix - equation numbers raised an error.
+ - Two minor changes: if no language is requested load nil
+ instead of raising an error, and the message 'babel <x.x>...'
+ is not printed to the log any more.
+
+3.20 2018-05-02
+ - ini files with the field digits.native define
+ \<language>digits and \<language>counters. \arabic can be
+ redefined to use native digits.
+ - Fix - mapfont in bidi=basic didn't take into account combining
+ marks (eg, Arabic vowels).
+ - Fix - A bug introduced in 3.19, which sometimes reversed text
+ in \hbox'es.
+ - Fix for luatex 1.07 - An internal change in luatex broke
+ bidi at 'automatic' hyphens.
+ - Fix for latest latex - babel.ins raised an error.
+
+```
+
+Javier Bezos
diff --git a/macros/latex/required/babel/base/babel.dtx b/macros/latex/required/babel/base/babel.dtx
new file mode 100644
index 0000000000..c26a20a748
--- /dev/null
+++ b/macros/latex/required/babel/base/babel.dtx
@@ -0,0 +1,20065 @@
+% \iffalse
+% This document requires lualatex
+%%
+%% Copyright (C) 2012-2019 Javier Bezos and Johannes L. Braams.
+%% Copyright (C) 1989-2012 Johannes L. Braams and
+%% any individual authors listed elsewhere in this file.
+%% All rights reserved.
+%%
+%% This file is part of the Babel system.
+%% --------------------------------------
+%%
+%% It may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either version 1.3
+%% 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.3 or later is part of all distributions of LaTeX
+%% version 2003/12/01 or later.
+%%
+%% This work has the LPPL maintenance status "maintained".
+%%
+%% The Current Maintainer of this work is Javier Bezos.
+%%
+%% The list of derived (unpacked) files belonging to the distribution
+%% and covered by LPPL is defined by the unpacking scripts (with
+%% extension |.ins|) which are part of the distribution.
+%%
+% \fi
+%
+% \CheckSum{5011}
+%
+% \iffalse
+%<*filedriver>
+\ProvidesFile{babel.dtx}[2019/07/19 v3.33 The Babel package]
+\documentclass{ltxdoc}
+\GetFileInfo{babel.dtx}
+\usepackage{fontspec}
+\setmainfont[
+ Scale=.88,
+ BoldFont = NotoSerif-Bold.ttf,
+ ItalicFont = NotoSerif-Italic.ttf,
+ BoldItalicFont = NotoSerif-BoldItalic.ttf]
+ {NotoSerif-Regular.ttf}
+\setsansfont[
+ Scale=.88,
+ BoldFont = NotoSans-Bold.ttf,
+ ItalicFont = NotoSans-Italic.ttf,
+ BoldItalicFont = NotoSans-BoldItalic.ttf]
+ {NotoSans-Regular.ttf}
+\setmonofont[Scale=.88,FakeStretch=.95]{NotoMono-Regular.ttf}
+\raggedright
+\addtolength{\textwidth}{25pt}
+\addtolength{\textheight}{3.5cm}
+\addtolength{\topmargin}{-2cm}
+\font\manual=logo10 % font used for the METAFONT logo, etc.
+\newcommand*\MF{{\manual META}\-{\manual FONT}}
+\newcommand*\babel{\textsf{babel}}
+\newcommand*\Babel{\textsf{Babel}}
+\newcommand*\xetex{\textsf{xetex}}
+\newcommand*\pdftex{\textsf{pdftex}}
+\newcommand*\luatex{\textsf{luatex}}
+\newcommand*\nb[1]{}
+\newcommand*\m[1]{\mbox{$\langle$\normalfont\itshape#1\/$\rangle$}}
+\newcommand*\langlist{%
+ \meta{language}\texttt{,}\meta{language}\texttt{,}...}
+\newcommand*\langvar{\m{lang}}
+\newcommand*\Lopt[1]{\textsf{#1}}
+\newcommand*\Lenv[1]{\texttt{#1}}
+\newcommand*\menv[1]{\char`\{#1\char`\}}
+\newcommand*\Eenv[1]{%
+ \quad\ldots\quad
+ \texttt{\color{thered}\string\end\menv{#1}}}
+\newcommand*\file[1]{\texttt{#1}}
+\newcommand*\cls[1]{\texttt{#1}}
+\newcommand*\pkg[1]{\texttt{#1}}
+\addtolength{\oddsidemargin}{1em}
+\setlength{\leftmargini}{1.5em}
+\usepackage{framed}
+\usepackage{multicol}
+\usepackage{color,colortbl}
+\usepackage[linkbordercolor={.9 .7 .5}]{hyperref}
+\newcommand\New[1]{%
+ \colorbox[rgb]{.92, .86, .73}{New #1}\enspace\ignorespaces}
+\definecolor{thered} {rgb}{0.65,0.04,0.07}
+\definecolor{thegrey} {gray}{0.8}
+\definecolor{shadecolor}{rgb}{1,1,0.97}
+\definecolor{messages}{rgb}{.66,.13,.27}
+\makeatletter
+\def\@begintheorem#1#2{%
+ \list{}{}%
+ \global\advance\@listdepth\m@ne
+ \item[{\sffamily\bfseries\color{messages}\hspace*{1.3em}%
+ \MakeUppercase{#1}}]}%
+\makeatother
+\newtheorem{warning}{Warning}
+\newtheorem{note}{Note}
+\newtheorem{example}{Example}
+\newtheorem{troubleshooting}{Troubleshooting}
+\let\bblxv\verbatim
+\let\bblexv\endverbatim
+\def\verbatim{\begin{shaded*}\bblxv\vskip-\baselineskip\vskip2.5\parsep}
+\def\endverbatim{\bblexv\vskip-2\baselineskip\end{shaded*}}
+\catcode`\_=\active
+\def_{\bgroup\let_\egroup\leavevmode\color{thered}}
+\def\MacroFont{\fontencoding \encodingdefault \fontfamily\ttdefault
+ \fontseries\mddefault \fontshape\updefault \small \catcode`\_=\active}
+\definecolor{shadecolor}{rgb}{0.96,0.96,0.93}
+\def\PrintDescribeMacro#1{%
+ \strut\MacroFont\color{thered}\normalsize\string#1}
+\def\Describe#1{%
+ \par\penalty-500\vskip3ex\noindent
+ \DescribeMacro{#1}\args}
+\def\DescribeOther{\vskip-4ex\Describe}
+\makeatletter
+\def\trouble#1{\addcontentsline{tsh}{trouble}{#1}}
+\def\listoftroubles{\section*{Troubleshoooting}\@starttoc{tsh}}
+\let\l@trouble\l@figure
+\let\saved@check@percent\check@percent
+\let\check@percent\relax
+\def\args#1{%
+ \def\bbl@tempa{#1}%
+ \ifx\bbl@tempa\@empty\else#1\vskip1ex\fi\ignorespaces}
+\begingroup % Changes to ltxdoc
+ \catcode`\<\active
+ \catcode`\>\active
+ \gdef\check@plus@etc{%
+ \let\bbl@next\pm@module
+ \ifx*\next
+ \let\bbl@next\star@module
+ \else\ifx/\next
+ \let\bbl@next\slash@module
+ \else\ifx<\next
+ \let\bbl@next\var@module
+ \fi\fi\fi
+ \bbl@next}
+ \gdef\var@module#1#2#3>>{%
+ $\langle$\pm@module#2#3>$\rangle$%
+ \ifx*#2\ $\equiv$\fi}
+\endgroup
+\renewcommand*\l@section[2]{%
+ \ifnum \c@tocdepth >\z@
+ \addpenalty\@secpenalty
+ \addvspace{1.0em \@plus\p@}%
+ \setlength\@tempdima{2em}%
+ \begingroup
+ \parindent \z@ \rightskip \@pnumwidth
+ \parfillskip -\@pnumwidth
+ \leavevmode \bfseries
+ \advance\leftskip\@tempdima
+ \hskip -\leftskip
+ #1\nobreak\hfil \nobreak\hb@xt@\@pnumwidth{\hss #2}\par
+ \endgroup
+ \fi}
+\renewcommand*\l@subsection{\@dottedtocline{2}{2em}{3em}}
+\renewcommand*\l@subsubsection{\@dottedtocline{3}{5em}{4em}}
+\renewcommand*\l@paragraph{\@dottedtocline{4}{9em}{4.5em}}
+\renewcommand\partname{Part}
+\def\@pnumwidth{3em}
+\makeatother
+\begin{document}
+\title{Babel, a multilingual package for use with \LaTeX's standard
+ document classes\thanks{During the development ideas from Nico
+ Poppelier, Piet van Oostrum and many others have been used.
+ Bernd Raichle has provided many helpful suggestions.}}
+\author{Johannes Braams\\
+ Kersengaarde 33\\
+ 2723 BP Zoetermeer\\
+ The Netherlands\\
+ \normalsize From version 3.9 on, Javier Bezos\\
+ \normalsize \texttt{www.texnia.com}}
+
+\date{Typeset \today}
+\begin{titlepage}
+\begin{minipage}[t][0pt]{30cm}
+\vspace{-3cm}\hspace{-7cm}
+\sffamily
+\begin{tabular}{p{8cm}p{15cm}}
+\cellcolor[rgb]{.86,.73,.67}
+&\cellcolor[rgb]{.95,.95,.95}
+\vspace{3.6cm}%
+\color[rgb]{.55,.4,.35}
+\leftskip5mm
+\sffamily\fontsize{72}{72}\selectfont Babel
+\vspace{1.8cm}
+\\
+\cellcolor[rgb]{.95,.95,.95}
+\vspace{2cm}\hspace{1.5cm}
+\begin{minipage}{5cm}
+\Large
+Version \csname @gobble\expandafter\endcsname\fileversion\newline
+\filedate
+
+\vspace{1cm}
+\textit{Original author}\newline
+Johannes L. Braams
+
+\vspace{.3cm}
+\textit{Current maintainer}\newline
+Javier Bezos
+\end{minipage}
+&\cellcolor[rgb]{.92, .86, .73}
+\vspace{2cm}
+\leftskip5mm
+\begin{minipage}{10cm}
+\large\setlength\parskip{3mm}\raggedright
+ The standard distribution of \LaTeX\ contains a number of document
+ classes that are meant to be used, but also serve as examples for
+ other users to create their own document classes. These document
+ classes have become very popular among \LaTeX\ users. But it should
+ be kept in mind that they were designed for American tastes and
+ typography. At one time they even contained a number of hard-wired
+ texts.
+
+ This manual describes \babel{}, a package that makes use of the
+ capabilities of \TeX, \xetex{} and \luatex{} to provide an
+ environment in which documents can be typeset in a language other
+ than US English, or in more than one language or script.
+
+ Current development is focused on Unicode engines (Xe\TeX{} and
+ Lua\TeX) and the so-called \textit{complex scripts}. New features
+ related to font selection, bidi writing, line breaking and so on are
+ being added incrementally.
+
+ \Babel{} provides support (total or partial) for about 200 languages,
+ either as a “classical†package option or as an |ini| file.
+ Furthermore, new languages can be created from scratch easily.
+
+ \vspace{20cm}
+\end{minipage}
+\end{tabular}
+\end{minipage}
+\end{titlepage}
+
+\tableofcontents
+\listoftroubles
+\clearpage
+
+\part{User guide}
+
+\begin{itemize}
+\item This user guide focuses on \LaTeX. There are also some notes on
+ its use with Plain \TeX.
+
+\item Changes and new features with relation to version 3.8 are
+ highlighted with \New{X.XX}\hspace{-.5em}. The most recent features
+ could be still unstable. Please, report any issues you find in
+ \texttt{https://github.com/latex3/babel/issues}, which is better
+ than just complaining on an e-mail list or a web forum.
+
+\item If you are interested in the \TeX{} multilingual support, please
+ join the \textsf{kadingira} list on
+ \texttt{http://tug.org/mailman/listinfo/kadingira}. You can follow
+ the development of \babel{} in
+ \texttt{https://github.com/latex3/babel} (which provides some sample
+ files, too).
+
+\item See section \ref{contribute} for contributing a language.
+
+\item The first sections describe the traditional way of loading a
+ language (with |ldf| files). The alternative way based on |ini|
+ files, which complements the previous one (it will \textit{not}
+ replace it), is described below.
+\end{itemize}
+
+\section{The user interface}\label{U-I}
+
+\subsection{Monolingual documents}
+
+In most cases, a single language is required, and then all you need in
+\LaTeX{} is to load the package using its standand mechanism for this
+purpose, namely, passing that language as an optional argument. In
+addition, you may want to set the font and input encodings.
+
+\begin{example}
+ Here is a simple full example for “traditional†\TeX{} engines
+ (see below for \xetex{} and \luatex{}). The packages |fontenc| and
+ |inputenc| do not belong to \babel, but they are included in the
+ example because typically you will need them (however, the package
+ \textsf{inputenc} may be omitted with \LaTeX{} $\ge$ 2018-04-01 if
+ the encoding is UTF-8):
+\begin{verbatim}
+\documentclass{article}
+
+\usepackage[T1]{fontenc}
+\usepackage[utf8]{inputenc}
+
+_\usepackage[french]{babel}_
+
+\begin{document}
+
+Plus ça change, plus c'est la même chose!
+
+\end{document}
+\end{verbatim}
+\end{example}
+\begin{troubleshooting}
+\trouble{Paragraph ended before \textbackslash UTFviii@three@octets
+was complete}
+A common source of trouble is a wrong setting of the input encoding.
+Very often you will get the following somewhat cryptic error:
+\begin{verbatim}
+! Paragraph ended before \UTFviii@three@octets was complete.
+\end{verbatim}
+Make sure you set the encoding actually used by your editor.
+\end{troubleshooting}
+
+Another approach is making the language (\Lopt{french} in the example)
+a global option in order to let other packages detect and use it:
+\begin{verbatim}
+_\documentclass[french]{article}_
+\usepackage{babel}
+\usepackage{varioref}
+\end{verbatim}
+
+In this last example, the package \texttt{varioref} will also see
+the option and will be able to use it.
+
+\begin{note}
+ Because of the way \babel{} has evolved, ``language'' can refer to
+ (1) a set of hyphenation patterns as preloaded into the format, (2)
+ a package option, (3) an |ldf| file, and (4) a name used in the
+ document to select a language or dialect. So, a package option
+ refers to a language in a generic way -- sometimes it is the actual
+ language name used to select it, sometimes it is a file name loading
+ a language with a different name, sometimes it is a file name
+ loading several languages. Please, read the documentation for
+ specific languages for further info.
+\end{note}
+
+\begin{troubleshooting}
+ The following warning is about hyphenation patterns, which are
+ not under the direct control of \babel:
+\trouble{No hyphenation patterns were preloaded for (babel) the
+ language `LANG' into the format}
+\begin{verbatim}
+Package babel Warning: No hyphenation patterns were preloaded for
+(babel) the language `LANG' into the format.
+(babel) Please, configure your TeX system to add them and
+(babel) rebuild the format. Now I will use the patterns
+(babel) preloaded for \language=0 instead on input line 57.
+\end{verbatim}
+ The document will be typeset, but very likely the text will not be
+ correctly hyphenated. Some languages may be raising this warning
+ wrongly (because they are not hyphenated); it is a bug to be fixed
+ -- just ignore it. See the manual of your distribution (Mac\TeX,
+ Mik\TeX, \TeX Live, etc.) for further info about how to configure
+ it.
+\end{troubleshooting}
+
+\subsection{Multilingual documents}
+
+In multilingual documents, just use several options. The last one is
+considered the main language, activated by default. Sometimes, the
+main language changes the document layout (eg, |spanish| and |french|).
+
+\begin{example}
+ In \LaTeX, the preamble of the document:
+\begin{verbatim}
+\documentclass{article}
+\usepackage[dutch,english]{babel}
+\end{verbatim}
+ would tell \LaTeX\ that the document would be written in two
+ languages, Dutch and English, and that English would be the first
+ language in use, and the main one.
+\end{example}
+
+You can also set the main language explicitly:
+\begin{verbatim}
+\documentclass{article}
+\usepackage[_main=english_,dutch]{babel}
+\end{verbatim}
+
+\begin{note}
+Some classes load \babel{} with a hardcoded language option. Sometimes,
+the main language could be overridden with something like that before
+|\documentclass|:
+\begin{verbatim}
+\PassOptionsToPackage{main=english}{babel}
+\end{verbatim}
+\end{note}
+
+\begin{warning}
+ Languages may be set as global and as package option at the same
+ time, but in such a case you should set explicitly the main language
+ with the package option |main|:
+\begin{verbatim}
+\documentclass[_italian_]{book}
+\usepackage[ngerman,_main=italian_]{babel}
+\end{verbatim}
+\end{warning}
+
+\begin{warning}
+ In the preamble the main language has \textit{not} been selected,
+ except hyphenation patterns and the name assigned to |\languagename|
+ (in particular, shorthands, captions and date are not activated). If
+ you need to define boxes and the like in the preamble, you might
+ want to use some of the language selectors described below.
+\end{warning}
+
+To switch the language there are two basic macros, described below in
+detail: |\selectlanguage| is used for blocks of text, while
+|\foreignlanguage| is for chunks of text inside paragraphs.
+
+\begin{example}
+A full bilingual document follows. The main language is |french|, which
+is activated when the document begins. The package \textsf{inputenc}
+may be omitted with \LaTeX{} $\ge$ 2018-04-01 if the encoding is UTF-8.
+\begin{verbatim}
+\documentclass{article}
+
+\usepackage[T1]{fontenc}
+\usepackage[utf8]{inputenc}
+
+_\usepackage[english,french]{babel}_
+
+\begin{document}
+
+Plus ça change, plus c'est la même chose!
+
+_\selectlanguage{english}_
+
+And an English paragraph, with a short text in
+_\foreignlanguage{french}{français}_.
+
+\end{document}
+\end{verbatim}
+\end{example}
+
+\subsection{Modifiers}
+
+\New{3.9c} The basic behavior of some languages can be modified when
+loading \babel{} by means of \textit{modifiers}. They are set after
+the language name, and are prefixed with a dot (only when the language
+is set as package option -- neither global options nor the |main| key
+accept them). An example is (spaces are not significant and they can
+be added or removed):\footnote{No predefined ``axis'' for modifiers
+are provided because languages and their scripts have quite different
+needs.}
+\begin{verbatim}
+\usepackage[latin_.medieval_, spanish_.notilde.lcroman_, danish]{babel}
+\end{verbatim}
+
+Attributes (described below) are considered modifiers, ie, you can
+set an attribute by including it in the list of modifiers. However,
+modifiers is a more general mechanism.
+
+\subsection{\textsf{xelatex} and \textsf{lualatex}}
+
+Many languages are compatible with \textsf{xetex} and \textsf{luatex}.
+With them you can use \babel{} to localize the documents.
+
+The Latin script is covered by default in current \LaTeX{} (provided
+the document encoding is UTF-8), because the font loader is preloaded
+and the font is switched to |lmroman|. Other scripts require loading
+\textsf{fontspec}. You may want to set the font attributes with
+\textsf{fontspec}, too.
+
+\begin{example}
+ The following bilingual, single script document in UTF-8 encoding
+ just prints a couple of ‘captions’ and |\today| in Danish and
+ Vietnamese. No additional packages are required.
+\begin{verbatim}
+\documentclass{article}
+
+_\usepackage[vietnamese,danish]{babel}_
+
+\begin{document}
+
+\prefacename{} -- \alsoname{} -- \today
+
+\selectlanguage{vietnamese}
+
+\prefacename{} -- \alsoname{} -- \today
+
+\end{document}
+\end{verbatim}
+\end{example}
+
+\begin{example}
+Here is a simple monolingual document in Russian (text from the
+Wikipedia). Note neither \textsf{fontenc} nor \textsf{inputenc} are
+necessary, but the document should be encoded in UTF-8 and a
+so-called Unicode font must be loaded (in this example |\babelfont| is
+used, described below).
+
+\begin{verbatim}
+\documentclass{article}
+
+_\usepackage[russian]{babel}_
+
+\babelfont{rm}{DejaVu Serif}
+
+\begin{document}
+
+РоÑÑиÑ, находÑщаÑÑÑ Ð½Ð° переÑечении множеÑтва культур, а также
+Ñ ÑƒÑ‡Ñ‘Ñ‚Ð¾Ð¼ многонационального характера её наÑелениÑ, — отличаетÑÑ
+выÑокой Ñтепенью Ñтнокультурного Ð¼Ð½Ð¾Ð³Ð¾Ð¾Ð±Ñ€Ð°Ð·Ð¸Ñ Ð¸ ÑпоÑобноÑтью к
+межкультурному диалогу.
+
+\end{document}
+\end{verbatim}
+\end{example}
+
+\subsection{Troubleshooting}
+
+\begin{itemize}
+\item Loading directly |sty| files in \LaTeX{} (ie,
+ |\usepackage|\marg{language}) is deprecated and you will get the
+ error:\footnote{In old versions the error read ``You have used an
+ old interface to call babel'', not very helpful.}
+\trouble{You are loading directly a language style}
+\begin{verbatim}
+! Package babel Error: You are loading directly a language style.
+(babel) This syntax is deprecated and you must use
+(babel) \usepackage[language]{babel}.
+\end{verbatim}
+
+\item Another typical error when using \babel{} is the
+ following:\footnote{In old versions the error read ``You haven't
+ loaded the language LANG yet''.}
+\trouble{Unknown language `LANG'}
+\begin{verbatim}
+! Package babel Error: Unknown language `#1'. Either you have
+(babel) misspelled its name, it has not been installed,
+(babel) or you requested it in a previous run. Fix its name,
+(babel) install it or just rerun the file, respectively. In
+(babel) some cases, you may need to remove the aux file
+\end{verbatim}
+ The most frequent reason is, by far, the latest (for example, you
+ included |spanish|, but you realized this language is not used after
+ all, and therefore you removed it from the option list). In most
+ cases, the error vanishes when the document is typeset again, but in
+ more severe ones you will need to remove the |aux| file.
+\end{itemize}
+\subsection{Plain}
+
+In Plain, load languages styles with |\input| and then use
+|\begindocument| (the latter is defined by \babel):
+\begin{verbatim}
+\input estonian.sty
+\begindocument
+\end{verbatim}
+
+\begin{warning}
+ Not all languages provide a |sty| file and some of them are not
+ compatible with Plain.\footnote{Even in the \babel{} kernel there
+ were some macros not compatible with plain. Hopefully these issues
+ have been fixed.}
+\end{warning}
+
+\subsection{Basic language selectors}
+
+This section describes the commands to be used in the document to
+switch the language in multilingual documents. In most cases, only the
+two basic macros |\selectlanguage| and |\foreignlanguage| are
+necessary. The environments |otherlanguage|, |otherlanguage*| and
+|hyphenrules| are auxiliary, and described in the next section.
+
+The main language is selected automatically when the |document|
+environment begins.
+
+\Describe{\selectlanguage}{\marg{language}}
+When a user wants to switch from one language to another he can
+do so using the macro |\selectlanguage|. This macro takes the
+language, defined previously by a language definition file, as
+its argument. It calls several macros that should be defined in
+the language definition files to activate the special definitions
+for the language chosen:
+\begin{verbatim}
+\selectlanguage{german}
+\end{verbatim}
+
+This command can be used as environment, too.
+
+\begin{note}
+ For ``historical reasons'', a macro name is converted to a language
+ name without the leading |\|; in other words,
+ |\selectlanguage{\german}| is equivalent to |\selectlanguage{german}|.
+ Using a macro instead of a ``real'' name is deprecated.
+\end{note}
+
+\begin{warning}
+ If used inside braces there might be some non-local changes, as this
+ would be roughly equivalent to:
+\begin{verbatim}
+{\selectlanguage{<inner-language>} ...}\selectlanguage{<outer-language>}
+\end{verbatim}
+ If you want a change which is really local, you must enclose this
+ code with an additional grouping level.
+\end{warning}
+
+\Describe{\foreignlanguage}{\marg{language}\marg{text}}
+The command |\foreignlanguage| takes two arguments; the second
+argument is a phrase to be typeset according to the rules of the
+language named in its first one. This command (1) only switches the
+extra definitions and the hyphenation rules for the language,
+\emph{not} the names and dates, (2) does not send information about
+the language to auxiliary files (i.e., the surrounding language is
+still in force), and (3) it works even if the language has not been
+set as package option (but in such a case it only sets the hyphenation
+patterns and a warning is shown). With the |bidi| option, it also
+enters in horizontal mode (this is not done always for backwards
+compatibility).
+
+\subsection{Auxiliary language selectors}
+
+\Describe{\begin\menv{otherlanguage}}{\marg{language}\Eenv{otherlanguage}}
+
+The environment \Lenv{otherlanguage} does basically the same as
+|\selectlanguage|, except the language change is (mostly) local to
+the environment.
+
+Actually, there might be some non-local changes, as this environment
+is roughly equivalent to:
+\begin{verbatim}
+\begingroup
+\selectlanguage{<inner-language>}
+...
+\endgroup
+\selectlanguage{<outer-language>}
+\end{verbatim}
+If you want a change which is really local, you must enclose this
+environment with an additional grouping, like braces |{}|.
+
+Spaces after the environment are ignored.
+
+\Describe{\begin\menv{otherlanguage*}}%
+{\marg{language}\Eenv{otherlanguage*}}
+
+Same as |\foreignlanguage| but as environment. Spaces after the
+environment are \textit{not} ignored.
+
+This environment was originally intended for intermixing left-to-right
+typesetting with right-to-left typesetting in engines not supporting a
+change in the writing direction inside a line. However, by default it
+never complied with the documented behavior and it is just a version as
+environment of |\foreignlanguage|, except when the option |bidi| is
+set -- in this case, |\foreignlanguage| emits a |\leavevmode|, while
+|otherlanguage*| does not.
+
+\Describe{\begin\menv{hyphenrules}}{\marg{language}\Eenv{hyphenrules}}
+
+The environment \Lenv{hyphenrules} can be used to select \emph{only} the
+hyphenation rules to be used (it can be used as command, too). This can
+for instance be used to select `nohyphenation', provided that in
+\file{language.dat} the `language' \textsf{nohyphenation} is defined by
+loading \file{zerohyph.tex}. It deactivates language shorthands, too
+(but not user shorthands).
+
+Except for these simple uses, |hyphenrules| is discouraged and
+|otherlanguage*| (the starred version) is preferred, as the former does
+not take into account possible changes in encodings of characters like,
+say, |'| done by some languages (eg, \textsf{italian}, \textsf{french},
+\textsf{ukraineb}). To set hyphenation exceptions, use
+|\babelhyphenation| (see below).
+
+\subsection{More on selection}
+
+\Describe{\babeltags}{\char`\{\m{tag1} \texttt{=} \m{language1}, \m{tag2}
+\texttt{=} \m{language2}, \dots\char`\}}
+
+\New{3.9i} In multilingual documents with many language switches the
+commands above can be cumbersome. With this tool shorter names can be
+defined. It adds nothing really new -- it is just syntactical sugar.
+
+It defines |\text|\m{tag1}\marg{text} to be
+|\foreignlanguage|\marg{language1}\marg{text}, and |\begin|\marg{tag1}
+to be |\begin{otherlanguage*}|\marg{language1}, and so on. Note
+|\|\m{tag1} is also allowed, but remember to set it locally inside a
+group.
+\begin{example}
+With
+\begin{verbatim}
+\babeltags{de = german}
+\end{verbatim}
+you can write
+\begin{verbatim}
+text \textde{German text} text
+\end{verbatim}
+and
+\begin{verbatim}
+text
+\begin{de}
+ German text
+\end{de}
+text
+\end{verbatim}
+\end{example}
+
+\begin{note}
+ Something like \verb|\babeltags{finnish = finnish}| is legitimate --
+ it defines |\textfinnish| and |\finnish| (and, of course,
+ |\begin{finnish}|).
+\end{note}
+
+\begin{note}
+ Actually, there may be another advantage in the ‘short’ syntax
+ |\text|\m{tag}, namely, it is not affected by |\MakeUppercase| (while
+ |\foreignlanguage| is).
+\end{note}
+
+\Describe{\babelensure}{|[include=|\m{commands}|,exclude=|\m{commands}%
+ |,fontenc=|\m{encoding}|]|\marg{language}}
+
+\New{3.9i} Except in a few languages, like \textsf{russian},
+captions and dates are just strings, and do not switch the
+language. That means you should set it explicitly if you want to use
+them, or hyphenation (and in some cases the text itself) will be
+wrong. For example:
+\begin{verbatim}
+\foreignlanguage{russian}{text \foreignlanguage{polish}{\seename} text}
+\end{verbatim}
+
+Of course, \TeX{} can do it for you. To avoid switching the language
+all the while, |\babelensure| redefines the captions for a given
+language to wrap them with a selector:
+\begin{verbatim}
+\babelensure{polish}
+\end{verbatim}
+By default only the basic captions and |\today| are redefined, but you
+can add further macros with the key |include| in the optional argument
+(without commas). Macros not to be modified are listed in
+|exclude|. You can also enforce a font encoding with
+|fontenc|.\footnote{With it encoded string may not work as expected.}
+A couple of examples:
+\begin{verbatim}
+\babelensure[include=\Today]{spanish}
+\babelensure[fontenc=T5]{vietnamese}
+\end{verbatim}
+
+They are activated when the language is selected (at the |afterextras|
+event), and it makes some assumptions which could not be fulfilled in
+some languages. Note also you should include only macros defined by
+the language, not global macros (eg, |\TeX| of |\dag|).
+
+With |ini| files (see below), captions are ensured by default.
+
+\subsection{Shorthands}
+
+A \textit{shorthand} is a sequence of one or two characters that
+expands to arbitrary \TeX{} code.
+
+Shorthands can be used for different kinds of things, as for example:
+(1) in some languages shorthands such as |"a| are defined to be able
+to hyphenate the word if the encoding is |OT1|; (2) in some languages
+shorthands such as |!| are used to insert the right amount of white
+space; (3) several kinds of discretionaries and breaks can be inserted
+easily with |"-|, |"=|, etc.
+
+The package \textsf{inputenc} as well as \xetex{} an \luatex{} have
+alleviated entering non-ASCII characters, but minority languages and
+some kinds of text can still require characters not directly available
+on the keyboards (and sometimes not even as separated or precomposed
+Unicode characters). As to the point 2, now \textsf{pdfTeX} provides
+|\knbccode|, and \luatex{} can manipulate the glyph list. Tools for
+point 3 can be still very useful in general.
+
+There are three levels of shorthands: \textit{user},
+\textit{language}, and \textit{system} (by order of
+precedence). Version 3.9 introduces the \textit{language user} level
+on top of the user level, as described below. In most cases, you will
+use only shorthands provided by languages.
+
+\begin{note} Note the following:
+\begin{enumerate}
+\item Activated chars used for two-char shorthands cannot be followed
+ by a closing brace |}| and the spaces following are gobbled. With
+ one-char shorthands (eg,~|:|), they are preserved.
+\item If on a certain level (system, language, user) there is a
+ one-char shorthand, two-char ones starting with that
+ char and on the same level are ignored.
+\item Since they are active, a shorthand cannot contain the same
+ character in its definition (except if it is deactivated with, eg,
+ |string|).
+\end{enumerate}
+\end{note}
+
+A typical error when using shorthands is the following:
+\trouble{Argument of \textbackslash language@active@arg"
+has an extra \textbraceright}
+\begin{verbatim}
+! Argument of \language@active@arg" has an extra }.
+\end{verbatim}
+It means there is a closing brace just after a shorthand, which is not
+allowed (eg,~|"}|). Just add |{}| after (eg,~|"{}}|).
+
+\Describe{\shorthandon}{\marg{shorthands-list}}
+\DescribeOther{\shorthandoff}{%
+\colorbox{thegrey}{\ttfamily\hskip-.2em*\hskip-.2em}%
+\marg{shorthands-list}}
+It is sometimes necessary to switch a shorthand
+character off temporarily, because it must be used in an
+entirely different way. For this purpose, the user commands
+|\shorthandoff| and |\shorthandon| are provided. They each take a
+list of characters as their arguments.
+
+The command |\shorthandoff| sets the |\catcode| for each of the
+characters in its argument to other (12); the command |\shorthandon|
+sets the |\catcode| to active (13). Both commands only work on `known'
+shorthand characters.
+
+% TODO - Is the following true ????
+% If a character is not known to be a shorthand character its category
+% code will be left unchanged.
+
+\New{3.9a} However, |\shorthandoff| does not behave as
+you would expect with characters like |~| or |^|, because they
+usually are not ``other''. For them |\shorthandoff*| is provided,
+so that with
+\begin{verbatim}
+\shorthandoff*{~^}
+\end{verbatim}
+|~| is still active, very likely with the meaning of a non-breaking
+space, and |^| is the superscript character. The catcodes used are
+those when the shorthands are defined, usually when language files are
+loaded.
+
+\Describe{\useshorthands}{%
+\colorbox{thegrey}{\ttfamily\hskip-.2em*\hskip-.2em}%
+\marg{char}}
+
+The command |\useshorthands| initiates the definition of user-defined
+shorthand sequences. It has one argument, the character that starts
+these personal shorthands.
+
+\New{3.9a} User shorthands are not always alive, as they may
+be deactivated by languages (for example, if you use |"| for your user
+shorthands and switch from \textsf{german} to \textsf{french}, they
+stop working). Therefore, a starred version
+|\useshorthands*|\marg{char} is provided, which makes sure shorthands
+are always activated.
+
+Currently, if the package option |shorthands| is used, you must include any
+character to be activated with |\useshorthands|. This restriction will
+be lifted in a future release. % <- TODO
+
+\Describe\defineshorthand{\texttt{[}\langlist\texttt{]}%
+ \marg{shorthand}\marg{code}}
+
+The command |\defineshorthand| takes two arguments: the first is
+a one- or two-character shorthand sequence, and the second is the
+code the shorthand should expand to.
+
+\New{3.9a} An optional argument allows to (re)define language and
+system shorthands (some languages do not activate shorthands, so you
+may want to add |\languageshorthands|\marg{lang} to the corresponding
+|\extras|\m{lang}, as explained below). By default, user shorthands
+are (re)defined.
+
+User shorthands override language ones, which in turn override
+system shorthands. Language-dependent user shorthands (new in
+3.9) take precedence over ``normal'' user shorthands.
+
+\begin{example}
+ Let's assume you want a unified set of shorthand for discretionaries
+ (languages do not define shorthands consistently, and |"-|, |\-|,
+ |"=| have different meanings). You could start with, say:
+\begin{verbatim}
+\useshorthands*{"}
+\defineshorthand{"*}{\babelhyphen{soft}}
+\defineshorthand{"-}{\babelhyphen{hard}}
+\end{verbatim}
+ However, behavior of hyphens is language dependent. For example, in
+ languages like Polish and Portuguese, a hard hyphen inside compound
+ words are repeated at the beginning of the next line. You could then
+ set:
+\begin{verbatim}
+\defineshorthand[*polish,*portugese]{"-}{\babelhyphen{repeat}}
+\end{verbatim}
+ Here, options with |*| set a language-dependent user shorthand,
+ which means the generic one above only applies for the rest of
+ languages; without |*| they would (re)define the language shorthands
+ instead, which are overriden by user ones.
+
+ Now, you have a single unified shorthand (|"-|), with a
+ content-based meaning (`compound word hyphen') whose visual behavior
+ is that expected in each context.
+\end{example}
+
+\Describe{\aliasshorthand}{\marg{original}\marg{alias}}
+
+The command |\aliasshorthand| can be used to let another
+character perform the same functions as the default shorthand
+character. If one prefers for example to use the character |/|
+over |"| in typing Polish texts, this can be achieved by entering
+|\aliasshorthand{"}{/}|.
+
+\begin{note}
+ The substitute character must \textit{not} have been declared before
+ as shorthand (in such a case, |\aliashorthands| is ignored).
+\end{note}
+
+\begin{example}
+ The following example shows how to replace a shorthand by another
+\begin{verbatim}
+\aliasshorthand{~}{^}
+\AtBeginDocument{\shorthandoff*{~}}
+\end{verbatim}
+\end{example}
+
+\begin{warning}
+ Shorthands remember somehow the original character, and the fallback
+ value is that of the latter. So, in this example, if no shorthand if
+ found, |^| expands to a non-breaking space, because this is the
+ value of |~| (internally, |^| still calls |\active@char~| or
+ |\normal@char~|). Furthermore, if you change the |system| value of
+ |^| with |\defineshorthand| nothing happens.
+\end{warning}
+
+\Describe{\languageshorthands}{\marg{language}} The command
+|\languageshorthands| can be used to switch the shorthands on the
+language level. It takes one argument, the name of a language or
+|none| (the latter does what its name suggests).\footnote{Actually,
+any name not corresponding to a language group does the same as
+\texttt{none}. However, follow this convention because it might be
+enforced in future releases of \babel{} to catch possible errors.}
+Note that for this to work the language should have been specified as
+an option when loading the \babel\ package. For example, you can use
+in \textsf{english} the shorthands defined by \textsf{ngerman} with
+\begin{verbatim}
+\addto\extrasenglish{\languageshorthands{ngerman}}
+\end{verbatim}
+(You may also need to activate them as user shorthands in the preamble
+with, for example, |\useshorthands| or |\useshorthands*|.)
+
+Very often, this is a more convenient way to deactivate shorthands
+than |\shorthandoff|, as for example if you want to define a macro
+to easy typing phonetic characters with \textsf{tipa}:
+\begin{verbatim}
+\newcommand{\myipa}[1]{{\languageshorthands{none}\tipaencoding#1}}
+\end{verbatim}
+
+\Describe{\babelshorthand}{\marg{shorthand}}
+With this command you can use a shorthand even if (1) not activated in
+\texttt{shorthands} (in this case only shorthands for the current
+language are taken into account, ie, not user shorthands), (2) turned
+off with |\shorthandoff| or (3) deactivated with the internal
+|\bbl@deactivate|; for example, \verb|\babelshorthand{"u}| or
+\verb|\babelshorthand{:}|. (You can conveniently define your own
+macros, or even you own user shorthands provided they do not ovelap.)
+
+For your records, here is a list of shorthands, but you must double
+check them, as they may change:\footnote{Thanks to Enrico Gregorio}
+
+\begin{description}
+\itemsep=-\parskip
+\item[Languages with no shorthands] Croatian, English (any variety),
+ Indonesian, Hebrew, Interlingua, Irish, Lower Sorbian, Malaysian,
+ North Sami, Romanian, Scottish, Welsh
+\item[Languages with only \texttt{"} as defined shorthand character]
+ Albanian, Bulgarian, Danish, Dutch, Finnish, German (old and new
+ orthography, also Austrian), Icelandic, Italian, Norwegian, Polish,
+ Portuguese (also Brazilian), Russian, Serbian (with Latin script),
+ Slovene, Swedish, Ukrainian, Upper Sorbian
+\item[Basque] |" ' ~|
+\item[Breton] |: ; ? !|
+\item[Catalan] |" ' `|
+\item[Czech] |" -|
+\item[Esperanto] |^|
+\item[Estonian] |" ~|
+\item[French] (all varieties) |: ; ? !|
+\item[Galician] |" . ' ~ < >|
+\item[Greek] |~|
+\item[Hungarian] |`|
+\item[Kurmanji] |^|
+\item[Latin] |" ^ =|
+\item[Slovak] |" ^ ' -|
+\item[Spanish] |" . < > '|
+\item[Turkish] |: ! =|
+\end{description}
+In addition, the \babel{} core declares |~| as a one-char shorthand
+which is let, like the standard |~|, to a non breaking
+space.\footnote{This declaration serves to nothing, but it is
+preserved for backward compatibility.}
+
+\Describe\ifbabelshorthand{\marg{character}\marg{true}\marg{false}}
+
+\New{3.23} Tests if a character has been made a shorthand.
+
+\subsection{Package options}
+
+\New{3.9a}
+These package options are processed before language options, so
+that they are taken into account irrespective of its order. The first
+three options have been available in previous versions.
+
+\Describe{KeepShorthandsActive}{}
+Tells babel not to deactivate shorthands after loading a language
+file, so that they are also available in the preamble.
+
+\Describe{activeacute}{} For some languages \babel\ supports this
+options to set |'| as a shorthand in case it is not done by default.
+
+\Describe{activegrave}{}
+Same for |`|.
+
+\Describe{shorthands=}{\meta{char}\meta{char}...
+$\string|$ \texttt{off}}
+The only language shorthands activated
+are those given, like, eg:
+\begin{verbatim}
+\usepackage[esperanto,french,shorthands=:;!?]{babel}
+\end{verbatim}
+If \verb|'| is included, \texttt{activeacute} is set; if \verb|`| is
+included, \texttt{activegrave} is set. Active characters (like
+\verb|~|) should be preceded by \verb|\string| (otherwise they will be
+expanded by \LaTeX{} before they are passed to the package and
+therefore they will not be recognized); however, |t| is provided for
+the common case of |~| (as well as |c| for not so common case of the
+comma).
+
+With |shorthands=off| no language shorthands are defined,
+As some languages use this mechanism for tools not available
+otherwise, a macro \verb|\babelshorthand| is defined, which allows
+using them; see above.
+
+\Describe{safe=}{\texttt{none} $\string|$ \texttt{ref} $\string|$
+\texttt{bib}} Some \LaTeX{} macros are redefined so that using
+shorthands is safe. With \texttt{safe=bib} only |\nocite|, |\bibcite|
+and |\bibitem| are redefined. With |safe=ref| only |\newlabel|, |\ref|
+and |\pageref| are redefined (as well as a few macros from
+\textsf{varioref} and \textsf{ifthen}). With |safe=none| no macro is
+redefined. This option is strongly recommended, because a good deal of
+incompatibilities and errors are related to these redefinitions -- of
+course, in such a case you cannot use shorthands in these macros, but
+this is not a real problem (just use ``allowed'' characters).
+
+\Describe{math=}{\texttt{active} $\string|$ \texttt{normal}}
+Shorthands are mainly intended for text, not for math. By setting this
+option with the value |normal| they are deactivated in math mode
+(default is |active|) and things like |${a'}$| (a closing brace after
+a shorthand) are not a source of trouble any more.
+
+\Describe{config=}{\meta{file}} Load \meta{file}\texttt{.cfg} instead
+of the default config file |bblopts.cfg| (the file is loaded even
+with |noconfigs|).
+
+\Describe{main=}{\meta{language}} Sets the main language, as explained
+above, ie, this language is always loaded last. If it is not given as
+package or global option, it is added to the list of requested
+languages.
+
+\Describe{headfoot=}{\meta{language}} By default, headlines and
+footlines are not touched (only marks), and if they contain language
+dependent macros (which is not usual) there may be unexpected
+results. With this option you may set the language in heads and foots.
+
+\Describe{noconfigs}{} Global and language default config files are
+not loaded, so you can make sure your document is not spoilt by an
+unexpected \texttt{.cfg} file. However, if the key |config| is set,
+this file is loaded.
+
+\Describe{showlanguages}{} Prints to the log the list of languages
+loaded when the format was created: number (remember dialects can
+share it), name, hyphenation file and exceptions file.
+
+\Describe{nocase}{} \New{3.9l} Language settings for uppercase and
+lowercase mapping (as set by |\SetCase|) are ignored. Use only if there
+are incompatibilities with other packages.
+
+\Describe{silent}{} \New{3.9l} No warnings and no \textit{infos} are
+written to the log file.\footnote{You can use alternatively the
+package \textsf{silence}.}
+
+\Describe{strings=}{\texttt{generic} $\string|$ \texttt{unicode}
+$\string|$ \texttt{encoded} $\string|$ \meta{label} $\string|$
+\meta{font encoding}} Selects the encoding of strings in languages
+supporting this feature. Predefined labels are |generic| (for
+traditional \TeX, LICR and ASCII strings), |unicode| (for engines like
+\xetex{} and \luatex) and |encoded| (for special cases requiring mixed
+encodings). Other allowed values are font encoding codes (|T1|, |T2A|,
+|LGR|, |L7X|...), but only in languages supporting them. Be aware with
+|encoded| captions are protected, but they work in |\MakeUppercase|
+and the like (this feature misuses some internal \LaTeX\ tools, so use
+it only as a last resort).
+
+\Describe{hyphenmap=}{\texttt{off} $\string|$ \texttt{main}
+$\string|$ \texttt{select} $\string|$ \texttt{other} $\string|$
+\texttt{other*}}
+
+\New{3.9g} Sets the behavior of case mapping for hyphenation,
+provided the language defines it.\footnote{Turned off in plain.} It
+can take the following values:
+\begin{description}
+\renewcommand\makelabel[1]{%
+ \hspace\labelsep\normalfont\ttfamily\color{thered}#1}
+\itemsep=-\parskip
+\item[off] deactivates this feature and no case mapping is applied;
+\item[first] sets it at the first switching commands in the
+ current or parent scope (typically, when the aux file is first read
+ and at |\begin{document}|, but also the first |\selectlanguage| in
+ the preamble), and it's the default if a single
+ language option has been stated;\footnote{Duplicated options count
+ as several ones.}
+\item[select] sets it only at |\selectlanguage|;
+\item[other] also sets it at |otherlanguage|;
+\item[other*] also sets it at |otherlanguage*| as well as in heads and
+ foots (if the option |headfoot| is used) and in auxiliary files (ie,
+ at |\select@language|), and it's the default if several language
+ options have been stated. The option |first| can be regarded as an
+ optimized version of \texttt{other*} for monolingual
+ documents.\footnote{Providing |foreign| is pointless, because the
+ case mapping applied is that at the end of paragraph, but if either
+ \xetex{} or \luatex{} change this behavior it might be added. On
+ the other hand, |other| is provided even if I [JBL] think it isn't
+ really useful, but who knows.}
+\end{description}
+
+\Describe{bidi=}{\texttt{default} $\string|$ \texttt{basic}
+ $\string|$ \texttt{basic-r} $\string|$ \texttt{bidi-l} $\string|$
+ \texttt{bidi-r}}
+
+\New{3.14} Selects the bidi algorithm to be used in \luatex{} and
+\xetex{}. See sec.~\ref{bidi}.
+
+\Describe{layout=}{}
+
+\New{3.16} Selects which layout elements are adapted in bidi
+documents. See sec.~\ref{bidi}.
+
+\subsection{The \texttt{base} option}
+
+With this package option \babel{} just loads some basic macros (those
+in |switch.def|), defines |\AfterBabelLanguage| and exits. It also
+selects the hyphenations patterns for the last language passed as
+option (by its name in |language.dat|). There are two main uses:
+classes and packages, and as a last resort in case there are, for some
+reason, incompatible languages. It can be used if you just want to
+select the hyphenations patterns of a single language, too.
+% TODO: example
+
+\Describe\AfterBabelLanguage{\marg{option-name}\marg{code}}
+
+This command is currently the only provided by |base|. Executes
+\meta{code} when the file loaded by the corresponding package option
+is finished (at |\ldf@finish|). The setting is global. So
+\begin{verbatim}
+\AfterBabelLanguage{french}{...}
+\end{verbatim}
+does ... at the end of |french.ldf|. It can be used in |ldf| files,
+too, but in such a case the code is executed only if
+\meta{option-name} is the same as |\CurrentOption| (which could not
+be the same as the option name as set in |\usepackage|!).
+
+\begin{example}
+ Consider two languages \textsf{foo} and \textsf{bar} defining the
+ same |\macro| with |\newcommand|. An error is raised if you attempt
+ to load both. Here is a way to overcome this problem:
+\begin{verbatim}
+\usepackage[base]{babel}
+\AfterBabelLanguage{foo}{%
+ \let\macroFoo\macro
+ \let\macro\relax}
+\usepackage[foo,bar]{babel}
+\end{verbatim}
+\end{example}
+
+\subsection{\texttt{ini} files}
+
+An alternative approach to define a language is by means of an
+\texttt{ini} file. Currently \babel{} provides about 200 of these
+files containing the basic data required for a language.
+
+Most of them set the date, and many also the captions (Unicode and
+LICR). They will be evolving with the time to add more features
+(something to keep in mind if backward compatibility is important). The
+following section shows how to make use of them currently (by means of
+|\babelprovide|), but a higher interface, based on package options, in
+under development (in other words, |\babelprovide| is mainly intended
+for auxiliary tasks).
+
+\begin{example}
+ Although Georgian has its own \texttt{ldf} file, here is how to
+ declare this language with an |ini| file in Unicode engines.
+\begingroup
+\setmonofont[Scale=.87,Script=Georgian]{DejaVu Sans Mono}
+\begin{verbatim}
+\documentclass{book}
+
+\usepackage{babel}
+\babelprovide[import, main]{georgian}
+
+\babelfont{rm}{DejaVu Sans}
+
+\begin{document}
+
+\tableofcontents
+
+\chapter{სáƒáƒ›áƒ–áƒáƒ áƒ”ულრდრსუფრის ტრáƒáƒ“იციები}
+
+ქáƒáƒ áƒ—ული ტრáƒáƒ“იციული სáƒáƒ›áƒ–áƒáƒ áƒ”ულრერთ-ერთი უმდიდრესირმთელ მსáƒáƒ¤áƒšáƒ˜áƒáƒ¨áƒ˜.
+
+\end{document}
+\end{verbatim}
+\endgroup
+\end{example}
+
+\begin{note}
+ The \texttt{ini} files just define and set some parameters, but the
+ corresponding behavior is not always implemented. Also, there are
+ some limitations in the engines. A few remarks follows:
+\begin{description}
+\itemsep=-\parskip
+\item[Arabic] Monolingual documents mostly work in \luatex, but it must
+ be fine tuned, and a recent version of
+ \textsf{fontspec}/\textsf{loaotfload} is required. In \xetex{}
+ \babel{} resorts to the \textsf{bidi} package, which seems to work.
+\item[Hebrew] Niqqud marks seem to work in both engines, but
+ cantillation marks are misplaced (\xetex{} seems better, but still
+ problematic).
+\item[Devanagari] In \luatex{} many fonts work, but some others do
+ not, the main issue being the ‘ra’. It is advisable to set explicitly
+ the script to either |deva| or |dev2|, eg:
+\begin{verbatim}
+\newfontscript{Devanagari}{deva}
+\end{verbatim}
+ Other Indic scripts are still under development in \luatex{}. On the
+ other hand, \xetex{} is better.
+\item[Southeast scripts] Thai works in both \luatex{} and \xetex{}, but
+ line breaking differs (rules can be modified in \luatex; they are
+ hardcoded in \xetex). Lao seems to work, too, but there are no
+ patterns for the latter in \luatex{}. Some quick patterns could help,
+ with something similar to:
+\begingroup
+\setmonofont[Script=Lao,Scale=MatchLowercase]{DejaVu Sans Mono}
+\begin{verbatim}
+\babelprovide[import,hyphenrules=+]{lao}
+\babelpatterns[lao]{1ດ 1ມ 1໠1ອ 1ງ 1ຠ1າ} % Random
+\end{verbatim}
+\endgroup
+ Khemer clusters are rendered wrongly.
+\item[East Asia scripts] Internal inconsistencies in script and
+ language names must be sorted out, so you may need to set them
+ explicitly in |\babelfont|, as well as |CJKShape|. \luatex{} does
+ basic line breaking, but currently \xetex{} does not (you may load
+ \textsf{zhspacing}). Although for a few words and shorts texts the
+ |ini| files should be fine, CJK texts are are best set with a
+ dedicated framework (\textsf{CJK}, \textsf{luatexja}, \textsf{kotex},
+ \textsf{CTeX}...), . Actually, this is what the |ldf| does in
+ |japanese| with \luatex, because the following piece of code loads
+ \textsf{luatexja}:
+\begin{verbatim}
+\documentclass{ltjbook}
+\usepackage[japanese]{babel}
+\end{verbatim}
+\end{description}
+\end{note}
+
+Here is the list (u means Unicode captions, and l means LICR
+captions):
+
+\begingroup
+\bigskip\hrule\nobreak
+
+\makeatletter
+\def\tag#1{\par\@hangfrom{\makebox[7em][l]{#1}}\ignorespaces}
+\def\hascapu{\textsuperscript{u}}
+\def\hascapl{\textsuperscript{l}}
+
+\begin{multicols}{2}
+
+\tag{af} Afrikaans\hascapu\hascapl
+\tag{agq} Aghem
+\tag{ak} Akan
+\tag{am} Amharic\hascapu\hascapl
+\tag{ar} Arabic\hascapu\hascapl
+\tag{ar-DZ} Arabic\hascapu\hascapl
+\tag{ar-MA} Arabic\hascapu\hascapl
+\tag{ar-SY} Arabic\hascapu\hascapl
+\tag{as} Assamese
+\tag{asa} Asu
+\tag{ast} Asturian\hascapu\hascapl
+\tag{az-Cyrl} Azerbaijani
+\tag{az-Latn} Azerbaijani
+\tag{az} Azerbaijani\hascapu\hascapl
+\tag{bas} Basaa
+\tag{be} Belarusian\hascapu\hascapl
+\tag{bem} Bemba
+\tag{bez} Bena
+\tag{bg} Bulgarian\hascapu\hascapl
+\tag{bm} Bambara
+\tag{bn} Bangla\hascapu\hascapl
+\tag{bo} Tibetan\hascapu
+\tag{brx} Bodo
+\tag{bs-Cyrl} Bosnian
+\tag{bs-Latn} Bosnian\hascapu\hascapl
+\tag{bs} Bosnian\hascapu\hascapl
+\tag{ca} Catalan\hascapu\hascapl
+\tag{ce} Chechen
+\tag{cgg} Chiga
+\tag{chr} Cherokee
+\tag{ckb} Central Kurdish
+\tag{cs} Czech\hascapu\hascapl
+\tag{cy} Welsh\hascapu\hascapl
+\tag{da} Danish\hascapu\hascapl
+\tag{dav} Taita
+\tag{de-AT} German\hascapu\hascapl
+\tag{de-CH} German\hascapu\hascapl
+\tag{de} German\hascapu\hascapl
+\tag{dje} Zarma
+\tag{dsb} Lower Sorbian\hascapu\hascapl
+\tag{dua} Duala
+\tag{dyo} Jola-Fonyi
+\tag{dz} Dzongkha
+\tag{ebu} Embu
+\tag{ee} Ewe
+\tag{el} Greek\hascapu\hascapl
+\tag{en-AU} English\hascapu\hascapl
+\tag{en-CA} English\hascapu\hascapl
+\tag{en-GB} English\hascapu\hascapl
+\tag{en-NZ} English\hascapu\hascapl
+\tag{en-US} English\hascapu\hascapl
+\tag{en} English\hascapu\hascapl
+\tag{eo} Esperanto\hascapu\hascapl
+\tag{es-MX} Spanish\hascapu\hascapl
+\tag{es} Spanish\hascapu\hascapl
+\tag{et} Estonian\hascapu\hascapl
+\tag{eu} Basque\hascapu\hascapl
+\tag{ewo} Ewondo
+\tag{fa} Persian\hascapu\hascapl
+\tag{ff} Fulah
+\tag{fi} Finnish\hascapu\hascapl
+\tag{fil} Filipino
+\tag{fo} Faroese
+\tag{fr} French\hascapu\hascapl
+\tag{fr-BE} French\hascapu\hascapl
+\tag{fr-CA} French\hascapu\hascapl
+\tag{fr-CH} French\hascapu\hascapl
+\tag{fr-LU} French\hascapu\hascapl
+\tag{fur} Friulian\hascapu\hascapl
+\tag{fy} Western Frisian
+\tag{ga} Irish\hascapu\hascapl
+\tag{gd} Scottish Gaelic\hascapu\hascapl
+\tag{gl} Galician\hascapu\hascapl
+\tag{gsw} Swiss German
+\tag{gu} Gujarati
+\tag{guz} Gusii
+\tag{gv} Manx
+\tag{ha-GH} Hausa
+\tag{ha-NE} Hausa\hascapl
+\tag{ha} Hausa
+\tag{haw} Hawaiian
+\tag{he} Hebrew\hascapu\hascapl
+\tag{hi} Hindi\hascapu
+\tag{hr} Croatian\hascapu\hascapl
+\tag{hsb} Upper Sorbian\hascapu\hascapl
+\tag{hu} Hungarian\hascapu\hascapl
+\tag{hy} Armenian
+\tag{ia} Interlingua\hascapu\hascapl
+\tag{id} Indonesian\hascapu\hascapl
+\tag{ig} Igbo
+\tag{ii} Sichuan Yi
+\tag{is} Icelandic\hascapu\hascapl
+\tag{it} Italian\hascapu\hascapl
+\tag{ja} Japanese
+\tag{jgo} Ngomba
+\tag{jmc} Machame
+\tag{ka} Georgian\hascapu\hascapl
+\tag{kab} Kabyle
+\tag{kam} Kamba
+\tag{kde} Makonde
+\tag{kea} Kabuverdianu
+\tag{khq} Koyra Chiini
+\tag{ki} Kikuyu
+\tag{kk} Kazakh
+\tag{kkj} Kako
+\tag{kl} Kalaallisut
+\tag{kln} Kalenjin
+\tag{km} Khmer
+\tag{kn} Kannada\hascapu\hascapl
+\tag{ko} Korean
+\tag{kok} Konkani
+\tag{ks} Kashmiri
+\tag{ksb} Shambala
+\tag{ksf} Bafia
+\tag{ksh} Colognian
+\tag{kw} Cornish
+\tag{ky} Kyrgyz
+\tag{lag} Langi
+\tag{lb} Luxembourgish
+\tag{lg} Ganda
+\tag{lkt} Lakota
+\tag{ln} Lingala
+\tag{lo} Lao\hascapu\hascapl
+\tag{lrc} Northern Luri
+\tag{lt} Lithuanian\hascapu\hascapl
+\tag{lu} Luba-Katanga
+\tag{luo} Luo
+\tag{luy} Luyia
+\tag{lv} Latvian\hascapu\hascapl
+\tag{mas} Masai
+\tag{mer} Meru
+\tag{mfe} Morisyen
+\tag{mg} Malagasy
+\tag{mgh} Makhuwa-Meetto
+\tag{mgo} Metaʼ
+\tag{mk} Macedonian\hascapu\hascapl
+\tag{ml} Malayalam\hascapu\hascapl
+\tag{mn} Mongolian
+\tag{mr} Marathi\hascapu\hascapl
+\tag{ms-BN} Malay\hascapl
+\tag{ms-SG} Malay\hascapl
+\tag{ms} Malay\hascapu\hascapl
+\tag{mt} Maltese
+\tag{mua} Mundang
+\tag{my} Burmese
+\tag{mzn} Mazanderani
+\tag{naq} Nama
+\tag{nb} Norwegian Bokmål\hascapu\hascapl
+\tag{nd} North Ndebele
+\tag{ne} Nepali
+\tag{nl} Dutch\hascapu\hascapl
+\tag{nmg} Kwasio
+\tag{nn} Norwegian Nynorsk\hascapu\hascapl
+\tag{nnh} Ngiemboon
+\tag{nus} Nuer
+\tag{nyn} Nyankole
+\tag{om} Oromo
+\tag{or} Odia
+\tag{os} Ossetic
+\tag{pa-Arab} Punjabi
+\tag{pa-Guru} Punjabi
+\tag{pa} Punjabi
+\tag{pl} Polish\hascapu\hascapl
+\tag{pms} Piedmontese\hascapu\hascapl
+\tag{ps} Pashto
+\tag{pt-BR} Portuguese\hascapu\hascapl
+\tag{pt-PT} Portuguese\hascapu\hascapl
+\tag{pt} Portuguese\hascapu\hascapl
+\tag{qu} Quechua
+\tag{rm} Romansh\hascapu\hascapl
+\tag{rn} Rundi
+\tag{ro} Romanian\hascapu\hascapl
+\tag{rof} Rombo
+\tag{ru} Russian\hascapu\hascapl
+\tag{rw} Kinyarwanda
+\tag{rwk} Rwa
+\tag{sa-Beng} Sanskrit
+\tag{sa-Deva} Sanskrit
+\tag{sa-Gujr} Sanskrit
+\tag{sa-Knda} Sanskrit
+\tag{sa-Mlym} Sanskrit
+\tag{sa-Telu} Sanskrit
+\tag{sa} Sanskrit
+\tag{sah} Sakha
+\tag{saq} Samburu
+\tag{sbp} Sangu
+\tag{se} Northern Sami\hascapu\hascapl
+\tag{seh} Sena
+\tag{ses} Koyraboro Senni
+\tag{sg} Sango
+\tag{shi-Latn} Tachelhit
+\tag{shi-Tfng} Tachelhit
+\tag{shi} Tachelhit
+\tag{si} Sinhala
+\tag{sk} Slovak\hascapu\hascapl
+\tag{sl} Slovenian\hascapu\hascapl
+\tag{smn} Inari Sami
+\tag{sn} Shona
+\tag{so} Somali
+\tag{sq} Albanian\hascapu\hascapl
+\tag{sr-Cyrl-BA} Serbian\hascapu\hascapl
+\tag{sr-Cyrl-ME} Serbian\hascapu\hascapl
+\tag{sr-Cyrl-XK} Serbian\hascapu\hascapl
+\tag{sr-Cyrl} Serbian\hascapu\hascapl
+\tag{sr-Latn-BA} Serbian\hascapu\hascapl
+\tag{sr-Latn-ME} Serbian\hascapu\hascapl
+\tag{sr-Latn-XK} Serbian\hascapu\hascapl
+\tag{sr-Latn} Serbian\hascapu\hascapl
+\tag{sr} Serbian\hascapu\hascapl
+\tag{sv} Swedish\hascapu\hascapl
+\tag{sw} Swahili
+\tag{ta} Tamil\hascapu
+\tag{te} Telugu\hascapu\hascapl
+\tag{teo} Teso
+\tag{th} Thai\hascapu\hascapl
+\tag{ti} Tigrinya
+\tag{tk} Turkmen\hascapu\hascapl
+\tag{to} Tongan
+\tag{tr} Turkish\hascapu\hascapl
+\tag{twq} Tasawaq
+\tag{tzm} Central Atlas Tamazight
+\tag{ug} Uyghur
+\tag{uk} Ukrainian\hascapu\hascapl
+\tag{ur} Urdu\hascapu\hascapl
+\tag{uz-Arab} Uzbek
+\tag{uz-Cyrl} Uzbek
+\tag{uz-Latn} Uzbek
+\tag{uz} Uzbek
+\tag{vai-Latn} Vai
+\tag{vai-Vaii} Vai
+\tag{vai} Vai
+\tag{vi} Vietnamese\hascapu\hascapl
+\tag{vun} Vunjo
+\tag{wae} Walser
+\tag{xog} Soga
+\tag{yav} Yangben
+\tag{yi} Yiddish
+\tag{yo} Yoruba
+\tag{yue} Cantonese
+\tag{zgh} Standard Moroccan Tamazight
+\tag{zh-Hans-HK} Chinese
+\tag{zh-Hans-MO} Chinese
+\tag{zh-Hans-SG} Chinese
+\tag{zh-Hans} Chinese
+\tag{zh-Hant-HK} Chinese
+\tag{zh-Hant-MO} Chinese
+\tag{zh-Hant} Chinese
+\tag{zh} Chinese
+\tag{zu} Zulu
+
+\end{multicols}
+\endgroup
+\hrule
+\bigskip
+
+In some contexts (currently |\babelfont|) an \texttt{ini} file may be
+loaded by its name. Here is the list of the names currently supported.
+With these languages, |\babelfont| loads (if not done before) the
+language and script names (even if the language is defined as a package
+option with an \textsf{ldf} file). These are also the names recognized
+by |\babelprovide| with a valueless |import|.
+
+\begingroup
+\bigskip\hrule\nobreak
+
+\let\\\par
+
+\begin{multicols}{2}
+
+aghem\\
+akan\\
+albanian\\
+american\\
+amharic\\
+arabic\\
+arabic-algeria\\
+arabic-DZ\\
+arabic-morocco\\
+arabic-MA\\
+arabic-syria\\
+arabic-SY\\
+armenian\\
+assamese\\
+asturian\\
+asu\\
+australian\\
+austrian\\
+azerbaijani-cyrillic\\
+azerbaijani-cyrl\\
+azerbaijani-latin\\
+azerbaijani-latn\\
+azerbaijani\\
+bafia\\
+bambara\\
+basaa\\
+basque\\
+belarusian\\
+bemba\\
+bena\\
+bengali\\
+bodo\\
+bosnian-cyrillic\\
+bosnian-cyrl\\
+bosnian-latin\\
+bosnian-latn\\
+bosnian\\
+brazilian\\
+breton\\
+british\\
+bulgarian\\
+burmese\\
+canadian\\
+cantonese\\
+catalan\\
+centralatlastamazight\\
+centralkurdish\\
+chechen\\
+cherokee\\
+chiga\\
+chinese-hans-hk\\
+chinese-hans-mo\\
+chinese-hans-sg\\
+chinese-hans\\
+chinese-hant-hk\\
+chinese-hant-mo\\
+chinese-hant\\
+chinese-simplified-hongkongsarchina\\
+chinese-simplified-macausarchina\\
+chinese-simplified-singapore\\
+chinese-simplified\\
+chinese-traditional-hongkongsarchina\\
+chinese-traditional-macausarchina\\
+chinese-traditional\\
+chinese\\
+colognian\\
+cornish\\
+croatian\\
+czech\\
+danish\\
+duala\\
+dutch\\
+dzongkha\\
+embu\\
+english-au\\
+english-australia\\
+english-ca\\
+english-canada\\
+english-gb\\
+english-newzealand\\
+english-nz\\
+english-unitedkingdom\\
+english-unitedstates\\
+english-us\\
+english\\
+esperanto\\
+estonian\\
+ewe\\
+ewondo\\
+faroese\\
+filipino\\
+finnish\\
+french-be\\
+french-belgium\\
+french-ca\\
+french-canada\\
+french-ch\\
+french-lu\\
+french-luxembourg\\
+french-switzerland\\
+french\\
+friulian\\
+fulah\\
+galician\\
+ganda\\
+georgian\\
+german-at\\
+german-austria\\
+german-ch\\
+german-switzerland\\
+german\\
+greek\\
+gujarati\\
+gusii\\
+hausa-gh\\
+hausa-ghana\\
+hausa-ne\\
+hausa-niger\\
+hausa\\
+hawaiian\\
+hebrew\\
+hindi\\
+hungarian\\
+icelandic\\
+igbo\\
+inarisami\\
+indonesian\\
+interlingua\\
+irish\\
+italian\\
+japanese\\
+jolafonyi\\
+kabuverdianu\\
+kabyle\\
+kako\\
+kalaallisut\\
+kalenjin\\
+kamba\\
+kannada\\
+kashmiri\\
+kazakh\\
+khmer\\
+kikuyu\\
+kinyarwanda\\
+konkani\\
+korean\\
+koyraborosenni\\
+koyrachiini\\
+kwasio\\
+kyrgyz\\
+lakota\\
+langi\\
+lao\\
+latvian\\
+lingala\\
+lithuanian\\
+lowersorbian\\
+lsorbian\\
+lubakatanga\\
+luo\\
+luxembourgish\\
+luyia\\
+macedonian\\
+machame\\
+makhuwameetto\\
+makonde\\
+malagasy\\
+malay-bn\\
+malay-brunei\\
+malay-sg\\
+malay-singapore\\
+malay\\
+malayalam\\
+maltese\\
+manx\\
+marathi\\
+masai\\
+mazanderani\\
+meru\\
+meta\\
+mexican\\
+mongolian\\
+morisyen\\
+mundang\\
+nama\\
+nepali\\
+newzealand\\
+ngiemboon\\
+ngomba\\
+norsk\\
+northernluri\\
+northernsami\\
+northndebele\\
+norwegianbokmal\\
+norwegiannynorsk\\
+nswissgerman\\
+nuer\\
+nyankole\\
+nynorsk\\
+occitan\\
+oriya\\
+oromo\\
+ossetic\\
+pashto\\
+persian\\
+piedmontese\\
+polish\\
+portuguese-br\\
+portuguese-brazil\\
+portuguese-portugal\\
+portuguese-pt\\
+portuguese\\
+punjabi-arab\\
+punjabi-arabic\\
+punjabi-gurmukhi\\
+punjabi-guru\\
+punjabi\\
+quechua\\
+romanian\\
+romansh\\
+rombo\\
+rundi\\
+russian\\
+rwa\\
+sakha\\
+samburu\\
+samin\\
+sango\\
+sangu\\
+sanskrit-beng\\
+sanskrit-bengali\\
+sanskrit-deva\\
+sanskrit-devanagari\\
+sanskrit-gujarati\\
+sanskrit-gujr\\
+sanskrit-kannada\\
+sanskrit-knda\\
+sanskrit-malayalam\\
+sanskrit-mlym\\
+sanskrit-telu\\
+sanskrit-telugu\\
+sanskrit\\
+scottishgaelic\\
+sena\\
+serbian-cyrillic-bosniaherzegovina\\
+serbian-cyrillic-kosovo\\
+serbian-cyrillic-montenegro\\
+serbian-cyrillic\\
+serbian-cyrl-ba\\
+serbian-cyrl-me\\
+serbian-cyrl-xk\\
+serbian-cyrl\\
+serbian-latin-bosniaherzegovina\\
+serbian-latin-kosovo\\
+serbian-latin-montenegro\\
+serbian-latin\\
+serbian-latn-ba\\
+serbian-latn-me\\
+serbian-latn-xk\\
+serbian-latn\\
+serbian\\
+shambala\\
+shona\\
+sichuanyi\\
+sinhala\\
+slovak\\
+slovene\\
+slovenian\\
+soga\\
+somali\\
+spanish-mexico\\
+spanish-mx\\
+spanish\\
+standardmoroccantamazight\\
+swahili\\
+swedish\\
+swissgerman\\
+tachelhit-latin\\
+tachelhit-latn\\
+tachelhit-tfng\\
+tachelhit-tifinagh\\
+tachelhit\\
+taita\\
+tamil\\
+tasawaq\\
+telugu\\
+teso\\
+thai\\
+tibetan\\
+tigrinya\\
+tongan\\
+turkish\\
+turkmen\\
+ukenglish\\
+ukrainian\\
+uppersorbian\\
+urdu\\
+usenglish\\
+usorbian\\
+uyghur\\
+uzbek-arab\\
+uzbek-arabic\\
+uzbek-cyrillic\\
+uzbek-cyrl\\
+uzbek-latin\\
+uzbek-latn\\
+uzbek\\
+vai-latin\\
+vai-latn\\
+vai-vai\\
+vai-vaii\\
+vai\\
+vietnam\\
+vietnamese\\
+vunjo\\
+walser\\
+welsh\\
+westernfrisian\\
+yangben\\
+yiddish\\
+yoruba\\
+zarma\\
+zulu
+afrikaans\\
+
+\end{multicols}
+\endgroup
+\hrule
+
+\subsection{Selecting fonts}
+
+\New{3.15} Babel provides a high level interface on top of |fontspec|
+to select fonts. There is no need to load \textsf{fontspec} explicitly
+-- \babel{} does it for you with the first |\babelfont|.\footnote{See
+also the package \textsf{combofont} for a complementary approach.}
+
+\Describe\babelfont{\oarg{language-list}\marg{font-family}%
+ \oarg{font-options}\marg{font-name}}
+
+Here \textit{font-family} is |rm|, |sf| or |tt| (or newly defined
+ones, as explained below), and \textit{font-name} is the same as in
+\textsf{fontspec} and the like.
+
+If no language is given, then it is considered the default font for
+the family, activated when a language is selected. On the other hand,
+if there is one or more languages in the optional argument, the font
+will be assigned to them, overriding the default. Alternatively, you
+may set a font for a script -- just precede its name (lowercase) with
+a star (eg, |*devanagari|).
+
+\Babel{} takes care of the font language and the font script when
+languages are selected (as well as the writing direction); see the
+recognized languages above. In most cases, you will not need
+\textit{font-options}, which is the same as in \textsf{fontspec}, but
+you may add further key/value pairs if necessary.
+
+\begin{example}
+ Usage in most cases is very simple. Let us assume you are setting up
+ a document in Swedish, with some words in Hebrew, with a font suited
+ for both languages.
+ \begingroup
+% If you are looking at the code to see how it has been written, you
+% will be disappointed :-). The following example is built ad hoc to
+% emulate the final result to avoid dependencies, and therefore it's
+% not "real" code.
+\setmonofont[Scale=.87,Script=Hebrew]{DejaVu Sans Mono} \catcode`@=13
+\def@#1{\ifcase#1\relax \egroup \or \bgroup\textdir TLT \else
+\bgroup\textdir TRT \fontspec[Scale=.87,Script=Hebrew]{Liberation
+Mono} \fi}
+\begin{verbatim}
+\documentclass{article}
+
+\usepackage[swedish, bidi=default]{babel}
+
+\babelprovide[import]{hebrew}
+
+_\babelfont{rm}{FreeSerif}_
+
+\begin{document}
+
+Svenska \foreignlanguage{hebrew}{@2עִבְרִית@0} svenska.
+
+\end{document}
+\end{verbatim}
+\endgroup
+
+If on the other hand you have to resort to different fonts, you could
+replace the red line above with, say:
+\begin{verbatim}
+\babelfont{rm}{Iwona}
+\babelfont[hebrew]{rm}{FreeSerif}
+\end{verbatim}
+\end{example}
+
+|\babelfont| can be used to implicitly define a new font family. Just
+write its name instead of |rm|, |sf| or |tt|. This is the preferred way
+to select fonts in addition to the three basic families.
+
+\begin{example}
+ Here is how to do it:
+\begin{verbatim}
+\babelfont{kai}{FandolKai}
+\end{verbatim}
+ Now, |\kaifamily| and |\kaidefault|, as well as |\textkai| are at
+ your disposal.
+\end{example}
+
+\begin{note}
+ You may load \textsf{fontspec} explicitly. For example:
+\begin{verbatim}
+\usepackage{fontspec}
+\newfontscript{Devanagari}{deva}
+\babelfont[hindi]{rm}{Shobhika}
+\end{verbatim}
+ This makes sure the OpenType script for Devanagari is |deva| and not
+ |dev2| (\luatex{} does not detect automatically the correct
+ script\footnote{And even with the correct code some fonts could be
+ rendered incorrectly by \textsf{fontspec}, so double check the
+ results. \xetex{} fares better, but some font are still
+ problematic.}). You may also pass some options to \textsf{fontspec}:
+ with |silent|, the warnings about unavailable scripts or languages
+ are not shown (they are only really useful when the document format
+ is being set up).
+\end{note}
+
+\begin{note}
+ Directionality is a property affecting margins, indentation, column
+ order, etc., not just text. Therefore, it is under the direct
+ control of the language, which applies both the script and the
+ direction to the text. As a consequence, there is no need to set
+ \texttt{Script} when declaring a font (nor \texttt{Language}). In
+ fact, it is even discouraged.
+\end{note}
+
+\begin{note}
+ |\fontspec| is not touched at all, only the preset font families
+ (|rm|, |sf|, |tt|, and the like). If a language is switched when an
+ \textit{ad hoc} font is active, or you select the font with this
+ command, neither the script nor the language are passed. You must
+ add them by hand. This is by design, for several reasons (for
+ example, each font has its own set of features and a generic setting
+ for several of them could be problematic, and also a “lower levelâ€
+ font selection is useful).
+\end{note}
+
+\begin{note}
+ The keys |Language| and |Script| just pass these values to the
+ \textit{font}, and do \textit{not} set the script for the
+ \textit{language} (and therefore the writing direction). In other
+ words, the |ini| file or |\babelprovide| provides default values for
+ |\babelfont| if omitted, but the opposite is not true. See the note
+ above for the reasons of this behavior.
+\end{note}
+
+\begin{warning}
+ Do not use |\set|\textit{xxxx}|font| and |\babelfont| at the same
+ time. |\babelfont| follows the standard \LaTeX{} conventions to set
+ the basic families -- define |\|\textit{xx}|default|, and activate
+ it with |\|\textit{xx}|family|. On the other hand,
+ |\set|\textit{xxxx}|font| in \textsf{fontspec} takes a different
+ approach, because |\|\textit{xx}|family| is redefined with the
+ family name hardcoded (so that |\|\textit{xx}|default| becomes
+ no-op). Of course, both methods are incompatible, and if you use
+ |\set|\textit{xxxx}|font|, font switching with |\babelfont| just
+ does \textit{not} work (nor the standard |\|\textit{xx}|default|,
+ for that matter).
+\end{warning}
+
+\begin{troubleshooting}
+\trouble{Package fontspec Warning: 'Language 'LANG' not available for
+font 'FONT' with script 'SCRIPT' 'Default' language used instead'}
+\textit{Package fontspec Warning: 'Language 'LANG' not available for
+font 'FONT' with script 'SCRIPT' 'Default' language used instead'}.
+This warning is shown by \textsf{fontspec}, not by \babel. It could be
+irrelevant for English, but not for many other languages, including
+Urdu and Turkish. This is a useful and harmless warning, and if
+everything is fine with your document the best thing you can do is just
+to ignore it altogether.
+\end{troubleshooting}
+
+\subsection{Modifying a language}
+
+Modifying the behavior of a language (say, the chapter “captionâ€), is
+sometimes necessary, but not always trivial.
+\begin{itemize}
+\item The old way, still valid for many languages, to redefine a
+ caption is the following:
+\begin{verbatim}
+\addto\captionsenglish{%
+ \renewcommand\contentsname{Foo}%
+}
+\end{verbatim}
+As of 3.15, there is no need to hide spaces with \texttt{\%%
+} (\babel{} removes them), but it is advisable to do it.
+\item The new way, which is found in |bulgarian|, |azerbaijani|,
+ |spanish|, |french|, |turkish|, |icelandic|, |vietnamese| and a few
+ more, as well as in languages created with |\babelprovide| and its
+ key |import|, is:
+\begin{verbatim}
+\renewcommand\spanishchaptername{Foo}
+\end{verbatim}
+\item Macros to be run when a language is selected can be add to
+ |\extras|\m{lang}:
+\begin{verbatim}
+\addto\extrasrussian{\mymacro}
+\end{verbatim}
+There is a counterpart for code to be run when a language is
+unselected: |\noextras|\m{lang}.
+\end{itemize}
+
+\begin{note}
+ These macros (|\captions|\m{lang}, |\extras|\m{lang}) may be
+ redefined, but \textit{must not} be used as such -- they just pass
+ information to \babel{}, which executes them in the proper context.
+\end{note}
+
+Another way to modify a language loaded as a package or class option
+is by means of |\babelprovide|, described below in depth. So,
+something like:
+\begin{verbatim}
+\usepackage[danish]{babel}
+\babelprovide[captions=da,hyphenrules=nohyphenation]{danish}
+\end{verbatim}
+first loads |danish.ldf|, and then redefines the captions for
+\texttt{danish} (as provided by the |ini| file) and prevents
+hyphenation. The rest of the language definitions are not touched.
+
+\subsection{Creating a language}
+
+\New{3.10} And what if there is no style for your language or none fits
+your needs? You may then define quickly a language with the help of the
+following macro in the preamble (which may be used to modify an
+existing language, too, as explained in the previous subsection).
+
+\Describe{\babelprovide}{\oarg{options}\marg{language-name}}
+
+Defines the internal structure of the language with some defaults: the
+hyphen rules, if not available, are set to the current ones, left and
+right hyphen mins are set to 2 and 3, but captions and date are not
+defined. Conveniently, \babel{} warns you about what to do. Very
+likely you will find alerts like that in the |log| file:
+\begin{verbatim}
+Package babel Warning: \mylangchaptername not set. Please, define
+(babel) it in the preamble with something like:
+(babel) \renewcommand\maylangchaptername{..}
+(babel) Reported on input line 18.
+\end{verbatim}
+
+In most cases, you will only need to define a few macros.
+
+\begin{example}
+ If you need a language named |arhinish|:
+\begin{verbatim}
+\usepackage[danish]{babel}
+\babelprovide{arhinish}
+\renewcommand\arhinishchaptername{Chapitula}
+\renewcommand\arhinishrefname{Refirenke}
+\renewcommand\arhinishhyphenmins{22}
+\end{verbatim}
+\end{example}
+
+The main language is not changed (\texttt{danish} in this example).
+So, you must add |\selectlanguage{arhinish}| or other selectors where
+necessary.
+
+If the language has been loaded as an argument in |\documentclass| or
+|\usepackage|, then |\babelprovide| redefines the requested data.
+
+\Describe{import=}{\meta{language-tag}}
+\New{3.13} Imports data from an |ini| file, including captions, date,
+and hyphenmins. For example:
+\begin{verbatim}
+\babelprovide[import=hu]{hungarian}
+\end{verbatim}
+Unicode engines load the UTF-8 variants, while 8-bit engines load the
+LICR (ie, with macros like |\'| or |\ss|) ones.
+
+\New{3.23} It may be used without a value. In such a case, the |ini|
+file set in the corresponding |babel-<language>.tex| (where
+|<language>| is the last argument in |\babelprovide|) is imported. See
+the list of recognized languages above. So, the previous example could
+be written:
+\begin{verbatim}
+\babelprovide[import]{hungarian}
+\end{verbatim}
+
+There are about 200 |ini| files, with data taken from the |ldf| files
+and the CLDR provided by Unicode. Not all languages in the latter are
+complete, and therefore neither are the |ini| files. A few languages
+will show a warning about the current lack of suitability of the date
+format (\textsf{hindi}, \textsf{french}, \textsf{breton}, and
+\textsf{occitan}).
+
+Besides |\today|, this option defines an additional command for dates:
+|\<language>date|, which takes three arguments, namely, year, month and
+day numbers. In fact, |\today| calls |\<language>today|, which in turn
+calls |\<language>date{\the\year}{\the\month}{\the\day}|.
+
+\Describe{captions=}{\meta{language-tag}}
+Loads only the strings. For example:
+\begin{verbatim}
+\babelprovide[captions=hu]{hungarian}
+\end{verbatim}
+
+\Describe{hyphenrules=}{\meta{language-list}} With this option, with a
+space-separated list of hyphenation rules, \babel{} assigns to the
+language the first valid hyphenation rules in the list. For example:
+\begin{verbatim}
+\babelprovide[hyphenrules=chavacano spanish italian]{chavacano}
+\end{verbatim}
+If none of the listed hyphenrules exist, the default behavior
+applies. Note in this example we set |chavacano| as first option --
+without it, it would select |spanish| even if |chavacano| exists.
+
+A special value is |+|, which allocates a new language (in the \TeX{}
+sense). It only makes sense as the last value (or the only one; the
+subsequent ones are silently ignored). It is mostly useful with
+\luatex, because you can add some patterns with |\babelpatterns|, as
+for example:
+\begin{verbatim}
+\babelprovide[hyphenrules=+]{neo}
+\babelpatterns[neo]{a1 e1 i1 o1 u1}
+\end{verbatim}
+In other engines it just suppresses hyphenation (because the pattern
+list is empty).
+
+\Describe{main}{} This valueless option makes the language the main
+one. Only in newly defined languages.
+
+\Describe{script=}{\meta{script-name}}
+\New{3.15} Sets the script name to be used by \textsf{fontspec} (eg,
+|Devanagari|). Overrides the value in the |ini| file. If
+\textsf{fontspec} does not define it, then \babel{} sets its tag to
+that provided by the |ini| file. This value is particularly important
+because it sets the writing direction, so you must use it if for some
+reason the default value is wrong.
+
+\Describe{language=}{\meta{language-name}} \New{3.15}
+Sets the language name to be used by \textsf{fontspec} (eg, |Hindi|).
+Overrides the value in the |ini| file. If \textsf{fontspec} does not
+define it, then \babel{} sets its tag to that provided by the |ini|
+file. Not so important, but sometimes still relevant.
+
+\bigskip
+
+A few options (only \luatex) set some properties of the writing system
+used by the language. These properties are \textit{always} applied to
+the script, no matter which language is active. Although somewhat
+inconsistent, this makes setting a language up easier in most typical
+cases.
+
+\Describe{mapfont=}{\texttt{direction}}
+Assigns the font for the writing direction of this language (only with
+|bidi=basic|).\footnote{There will be another value, \texttt{language},
+not yet implemented.} More precisely, what |mapfont=direction| means
+is, ‘when a character has the same direction as the script for the
+“provided†language, then change its font to that set for this
+language’. There are 3 directions, following the bidi Unicode
+algorithm, namely, Arabic-like, Hebrew-like and left to
+right.\footnote{In future releases an new value (\texttt{script}) will
+be added.} So, there should be at most 3 directives of this kind.
+
+\Describe{intraspace=}{\meta{base} \meta{shrink} \meta{stretch}}
+Sets the interword space for the writing system of the language, in em
+units (so, |0 .1 0| is |0em plus .1em|). Like |\spaceskip|, the em unit
+applied is that of the current text (more precisely, the previous
+glyph). Currently used only in Southeast Asian scrips, like Thai.
+Requires |import|.
+
+\Describe{intrapenalty=}{\meta{penalty}}
+Sets the interword penalty for the writing system of this language.
+Currently used only in Southeast Asian scrips, like Thai. Ignored if 0
+(which is the default value). Requires |import|.
+
+\begin{note}
+ (1) If you need shorthands, you can define them with |\useshorthands|
+ and |\defineshorthand| as described above. (2) Captions and |\today|
+ are ``ensured'' with |\babelensure| (this is the default in
+ |ini|-based languages).
+\end{note}
+
+\subsection{Digits}
+
+\New{3.20} About thirty |ini| files define a field named
+|digits.native|. When it is present, two macros are created:
+|\<language>digits| and |\<language>counter| (only \xetex{} and
+\luatex{}). With the first, a string of ‘Latin’ digits are converted to
+the native digits of that language; the second takes a counter name as
+argument. With the option |maparabic| in |\babelprovide|, |\arabic| is
+redefined to produce the native digits (this is done \textit{globally},
+to avoid inconsistencies in, for example, page numbering, and note as
+well dates do not rely on |\arabic|.)
+
+For example:
+\begin{verbatim}
+\babelprovide[import]{telugu} % Telugu better with XeTeX
+ % Or also, if you want:
+ % \babelprovide[import, maparabic]{telugu}
+\babelfont{rm}{Gautami}
+\begin{document}
+\telugudigits{1234}
+\telugucounter{section}
+\end{document}
+\end{verbatim}
+
+Languages providing native digits in all or some variants are
+\textit{ar, as, bn, bo, brx, ckb, dz, fa, gu, hi, km, kn, kok, ks, lo,
+lrc, ml, mr, my, mzn, ne, or, pa, ps, ta, te, th, ug, ur, uz, vai, yue,
+zh.}
+
+\New{3.30} With \luatex{} there is an alternative approach for mapping
+digits, namely, |mapdigits|. Conversion is based on the language and it
+is applied to the typeset text (not math, PDF bookmarks, etc.) before
+bidi and fonts are processed (ie, to the node list as generated by the
+\TeX{} code). This means the local digits have the correct
+bidirectional behavior (unlike |Numbers=Arabic| in \textsf{fontspec},
+which is not recommended).
+
+\subsection{Getting the current language name}
+
+\Describe{\languagename}{}
+The control sequence |\languagename| contains the name of the
+current language.
+
+\begin{warning}
+ Due to some internal inconsistencies in catcodes, it should
+ \textit{not} be used to test its value. Use \textsf{iflang}, by
+ Heiko Oberdiek.
+\end{warning}
+
+\Describe{\iflanguage}{\marg{language}\marg{true}\marg{false}}
+
+If more than one language is used, it might be necessary to know which
+language is active at a specific time. This can be checked by a call
+to |\iflanguage|, but note here ``language'' is used in the \TeX\
+sense, as a set of hyphenation patterns, and \textit{not} as its
+\textsf{babel} name. This macro takes three arguments. The first
+argument is the name of a language; the second and third arguments are
+the actions to take if the result of the test is true or false
+respectively.
+
+\begin{warning}
+ The advice about |\languagename| also applies here -- use
+ \textsf{iflang} instead of |\iflanguage| if possible.
+\end{warning}
+
+\subsection{Hyphenation and line breaking}
+
+\Describe{\babelhyphen}{%
+ \colorbox{thegrey}{\ttfamily\hskip-.2em*\hskip-.2em}\marg{type}}
+\DescribeOther\babelhyphen{%
+ \colorbox{thegrey}{\ttfamily\hskip-.2em*\hskip-.2em}\marg{text}}
+
+\New{3.9a} It is customary to classify hyphens in two types: (1)
+\textit{explicit} or \textit{hard hyphens}, which in \TeX\ are
+entered as \verb|-|, and (2) \textit{optional} or \textit{soft
+hyphens}, which are entered as \verb|\-|. Strictly, a \textit{soft
+hyphen} is not a hyphen, but just a breaking opportunity or, in
+\TeX\ terms, a ``discretionary''; a \textit{hard hyphen} is a hyphen
+with a breaking opportunity after it. A further type is a
+\textit{non-breaking hyphen}, a hyphen without a breaking
+opportunity.
+
+In \TeX, \verb|-| and \verb|\-| forbid further breaking opportunities
+in the word. This is the desired behavior very often, but not always,
+and therefore many languages provide shorthands for these
+cases. Unfortunately, this has not been done consistently: for
+example, \verb|"-| in Dutch, Portugese, Catalan or Danish is a hard
+hyphen, while in German, Spanish, Norwegian, Slovak or Russian is a
+soft hyphen. Furthermore, some of them even redefine |\-|, so that you
+cannot insert a soft hyphen without breaking opportunities in the rest
+of the word.
+
+Therefore, some macros are provide with a set of basic ``hyphens''
+which can be used by themselves, to define a user shorthand, or even
+in language files.
+\begin{itemize}
+\item |\babelhyphen{soft}| and |\babelhyphen{hard}| are self
+ explanatory.
+\item |\babelhyphen{repeat}| inserts a hard hyphen which is repeated
+ at the beginning of the next line, as done in languages like
+ Polish, Portugese and Spanish.
+\item |\babelhyphen{nobreak}| inserts a hard hyphen without a break
+ after it (even if a space follows).
+\item |\babelhyphen{empty}| inserts a break oportunity without
+ a hyphen at all.
+\item |\babelhyphen|\marg{text} is a hard ``hyphen'' using \m{text}
+ instead. A typical case is |\babelhyphen{/}|.
+\end{itemize}
+With all of them hyphenation in the rest of the word is enabled. If
+you don't want enabling it, there is a starred counterpart:
+|\babelhyphen*{soft}| (which in most cases is equivalent to the
+original |\-|), |\babelhyphen*{hard}|, etc.
+
+Note |hard| is also good for isolated prefixes (eg, \textit{anti-})
+and |nobreak| for isolated suffixes (eg, \textit{-ism}), but in both
+cases |\babelhyphen*{nobreak}| is usually better.
+
+There are also some differences with \LaTeX: (1) the character used is
+that set for the current font, while in \LaTeX{} it is hardwired to
+|-| (a typical value); (2) the hyphen to be used in fonts with a
+negative |\hyphenchar| is |-|, like in \LaTeX, but it can be changed to
+another value by redefining |\babelnullhyphen|; (3) a break after the
+hyphen is forbidden if preceded by a glue ${>}0$~pt (at the beginning
+of a word, provided it is not immediately preceded by, say, a
+parenthesis).
+
+\Describe\babelhyphenation{\texttt{[}\langlist\texttt{]}%
+ \marg{exceptions}}
+
+\New{3.9a} Sets hyphenation exceptions for the languages given
+or, without the optional argument, for \textit{all} languages (eg,
+proper nouns or common loan words, and of course monolingual
+documents). Language exceptions take precedence over global ones.
+
+It can be used only in the preamble, and exceptions are set when the
+language is first selected, thus taking into account changes of
+|\lccodes|'s done in |\extras|\m{lang} as well as the language specific
+encoding (not set in the preamble by default). Multiple
+|\babelhyphenation|'s are allowed. For example:
+\begin{verbatim}
+\babelhyphenation{Wal-hal-la Dar-bhan-ga}
+\end{verbatim}
+
+Listed words are saved expanded and therefore it relies on the
+LICR. Of course, it also works without the LICR if the input and the
+font encodings are the same, like in Unicode based engines.
+
+\begin{note}
+ Using |\babelhyphenation| with Southeast Asian scripts is mostly
+ pointless. But with |\babelpatterns| (below) you may fine-tune line
+ breaking (only \luatex). Even if there are no pattern for the
+ language, you can add at least some typical cases.
+\end{note}
+
+\Describe{\babelpatterns}{\texttt{[}\langlist\texttt{]}%
+ \marg{patterns}}
+
+\New{3.9m} \textit{In \textsf{luatex} only},\footnote{With
+\textsf{luatex} exceptions and patterns can be modified almost
+freely. However, this is very likely a task for a separate package
+and \texttt{babel} only provides the most basic tools.} adds or
+replaces patterns for the languages given or, without the optional
+argument, for \textit{all} languages. If a pattern for a certain
+combination already exists, it gets replaced by the new one.
+
+It can be used only in the preamble, and patterns are added when the
+language is first selected, thus taking into account changes of
+|\lccodes|'s done in |\extras|\m{lang} as well as the language specific
+encoding (not set in the preamble by default). Multiple
+|\babelpatterns|'s are allowed.
+
+Listed patterns are saved expanded and therefore it relies on the
+LICR. Of course, it also works without the LICR if the input and the
+font encodings are the same, like in Unicode based engines.
+
+\New{3.31} (Only \luatex.) With |\babelprovide| and |import|ed CJK
+languages, a simple generic line breaking algorithm (push-out-first) is
+applied, based on a selection of the Unicode rules (\New{3.32} it is
+disabled in verbatim mode, or more precisely when the hyphenrules
+are set to |nohyphenation|). It can be activated alternatively by
+setting explicitly the |intraspace|.
+
+\New{3.27} Interword spacing for Thai, Lao and Khemer is activated
+automatically if a language with one of those scripts are loaded with
+|\babelprovide|. See the sample on the \babel{} repository. With both
+Unicode engines, spacing is based on the ``current'' em unit (the size
+of the previous char in \luatex, and the font size set by the last
+|\selectfont| in \xetex).
+
+\subsection{Selecting scripts}
+
+Currently \babel{} provides no standard interface to select
+scripts, because they are best selected with either |\fontencoding|
+(low level) or a language name (high level). Even the Latin script may
+require different encodings (ie, sets of glyphs) depending on the
+language, and therefore such a switch would be in a sense
+incomplete.\footnote{The so-called Unicode fonts do not improve the
+situation either. So, a font suited for Vietnamese is not necessarily
+suited for, say, the romanization of Indic languages, and the fact it
+contains glyphs for Modern Greek does not mean it includes them for
+Classic Greek.}
+
+Some languages sharing the same script define macros to switch it (eg,
+|\textcyrillic|), but be aware they may also set the language to a
+certain default. Even the \babel{} core defined |\textlatin|, but is
+was somewhat buggy because in some cases it messed up encodings and
+fonts (for example, if the main Latin encoding was |LY1|), and
+therefore it has been deprecated.\footnote{But still defined for
+backwards compatibility.}
+
+\Describe{\ensureascii}{\marg{text}}
+
+\New{3.9i} This macro makes sure \m{text} is typeset with a
+LICR-savvy encoding in the ASCII range. It is used to redefine |\TeX|
+and |\LaTeX| so that they are correctly typeset even with |LGR| or
+|X2| (the complete list is stored in |\BabelNonASCII|, which by default
+is |LGR|, |X2|, |OT2|, |OT3|, |OT6|, |LHE|, |LWN|, |LMA|, |LMC|,
+|LMS|, |LMU|, but you can modify it). So, in some sense it fixes the
+bug described in the previous paragraph.
+
+If non-ASCII encodings are not loaded (or no encoding at all), it is
+no-op (also |\TeX| and |\LaTeX| are not redefined); otherwise,
+|\ensureascii| switches to the encoding at the beginning of the
+document if ASCII-savvy, or else the last ASCII-savvy encoding
+loaded. For example, if you load |LY1,LGR|, then it is set to |LY1|,
+but if you load |LY1,T2A| it is set to |T2A|. The symbol encodings
+|TS1|, |T3|, and |TS3| are not taken into account, since they are not
+used for ``ordinary'' text (they are stored in |\BabelNonText|, used
+in some special cases when no Latin encoding is explicitly set).
+
+The foregoing rules (which are applied ``at begin document'') cover
+most of cases. No assumption is made on characters above
+127, which may not follow the LICR conventions -- the goal is just
+to ensure most of the ASCII letters and symbols are the right ones.
+
+\subsection{Selecting directions}
+\label{bidi}
+
+No macros to select the writing direction are provided, either --
+writing direction is intrinsic to each script and therefore it is best
+set by the language (which could be a dummy one). Furthermore, there
+are in fact two right-to-left modes, depending on the language, which
+differ in the way `weak' numeric characters are ordered (eg, Arabic
+\%123 \textit{vs} Hebrew 123\%).
+
+\begin{warning}
+ The current code for \textbf{text} in \luatex{} should be considered
+ essentially stable, but, of course, it is not bug free and there
+ could be improvements in the future, because setting bidi text has
+ many subtleties (see for example <https://www.w3.org/TR/html-bidi/>).
+ A basic stable version for other engines must wait. This applies to
+ text; there is a basic support for \textbf{graphical} elements,
+ including the |picture| environment (with \textsf{pict2e}) and
+ \textsf{pfg/tikz}. Also, indexes and the like are under study, as
+ well as math (there are progresses in the latter, too, but for
+ example |cases| may fail).
+
+ An effort is being made to avoid incompatibilities in the future
+ (this one of the reason currently bidi must be explicitly requested
+ as a package option, with a certain bidi model, and also the |layout|
+ options described below).
+\end{warning}
+
+There are some package options controlling bidi writing.
+
+\Describe{bidi=}{\texttt{default} $\string|$ \texttt{basic}
+ $\string|$ \texttt{basic-r} $\string|$ \texttt{bidi-l} $\string|$
+ \texttt{bidi-r}}
+
+\New{3.14} Selects the bidi algorithm to be used. With |default| the
+bidi mechanism is just activated (by default it is not), but every
+change must by marked up. In \xetex{} and \pdftex{} this is the only
+option.
+
+In \luatex, |basic-r| provides a simple and fast method for R text,
+which handles numbers and unmarked L text within an R context many in
+typical cases. \New{3.19} Finally, |basic| supports both L and R text,
+and it is the preferred method (support for |basic-r| is currently
+limited). (They are named \texttt{basic} mainly because they only
+consider the intrinsic direction of scripts and weak directionality.)
+
+\New{3.29} In \xetex, |bidi-r| and |bidi-l| resort to the package
+\textsf{bidi} (by Vafa Khalighi). Integration is still somewhat
+tentative, but it mostly works. For RL documents use the former, and
+for LR ones use the latter.
+
+\New{3.32} There is some experimental support for \textsf{harftex}.
+Since it is based on \luatex, the option |basic| mostly works. You may
+need to deactivate the |rtlm| or the |rtla| font features (besides
+loading \textsf{harfload} before \babel and activating |mode=harf|;
+there is a sample in the GitHub repository).
+
+There are samples on GitHub, under \texttt{/required/babel/samples}.
+See particularly |lua-bidibasic.tex| and |lua-secenum.tex|.
+
+\begin{example}
+ The following text comes from the Arabic Wikipedia (article about
+ Arabia). Copy-pasting some text from the Wikipedia is a good way to
+ test this feature. Remember |basic-r| is available in \luatex{}
+ only.
+ \begingroup
+% If you are looking at the code to see how it has been written, you
+% will be disappointed :-). The following example is built ad hoc to
+% emulate the final result to avoid dependencies, and therefore it's
+% not "real" code.
+\setmonofont[Scale=.87,Script=Arabic]{DejaVu Sans Mono} \catcode`@=13
+\def@#1{\ifcase#1\relax \egroup \or \bgroup\textdir TLT \else
+\bgroup\textdir TRT \pardir TRT \fi}
+\begin{verbatim}
+\documentclass{article}
+
+\usepackage[_bidi=basic-r_]{babel}
+
+_\babelprovide[import, main]{arabic}_
+
+\babelfont{rm}{FreeSerif}
+
+\begin{document}
+
+@9وقد عرÙت شبه جزيرة العرب طيلة العصر الهيليني )الاغريقي( بـ
+@1Arabia@0 أو @1Aravia@0 )بالاغريقية @1ΑÏαβία@0(ØŒ استخدم الرومان ثلاث
+بادئات بـ@1“Arabiaâ€@0 على ثلاث مناطق من شبه الجزيرة العربية، إلا أنها
+حقيقةً كانت أكبر مما تعر٠عليه اليوم.
+
+@0\end{document}
+\end{verbatim}
+\endgroup
+\end{example}
+
+\begin{example}
+ With |bidi=basic| \textit{both} L and R text can be
+ mixed without explicit markup (the latter will be only necessary in
+ some special cases where the Unicode algorithm fails). It is used much
+ like |bidi=basic-r|, but with R text inside L text you may want to map
+ the font so that the correct features are in force. This is accomplished
+ with an option in |\babelprovide|, as illustrated:
+ \begingroup
+ % If you are looking at the code to see how it has been written, you
+ % will be disappointed :-). The following example is built ad hoc to
+ % emulate the final result to avoid dependencies, and therefore it's
+ % not "real" code.
+ \setmonofont[Scale=.87,Script=Arabic]{DejaVu Sans Mono} \catcode`@=13
+ \def@#1{\ifcase#1\relax \egroup \or \bgroup\textdir TRT \else
+ \bgroup\textdir TLT \pardir TLT \fi}
+\begin{verbatim}
+\documentclass{book}
+
+\usepackage[english, _bidi=basic_]{babel}
+
+\babelprovide[_mapfont=direction_]{arabic}
+
+\babelfont{rm}{Crimson}
+\babelfont[*arabic]{rm}{FreeSerif}
+
+\begin{document}
+
+Most Arabic speakers consider the two varieties to be two registers
+of one language, although the two registers can be referred to in
+Arabic as @1Ùصحى العصر@0 \textit{fuá¹£á¸¥Ä l-Ê»aá¹£r} (MSA) and
+@1Ùصحى التراث@0 \textit{fuá¹£á¸¥Ä t-turÄth} (CA).
+
+\end{document}
+\end{verbatim}
+ \endgroup
+ In this example, and thanks to |mapfont=direction|, any Arabic letter
+ (because the language is |arabic|) changes its font to that set for
+ this language (here defined via |*arabic|, because Crimson does not
+ provide Arabic letters).
+\end{example}
+
+\begin{note}
+ Boxes are “black boxesâ€. Numbers inside an |\hbox| (as for example
+ in a |\ref|) do not know anything about the surrounding chars. So,
+ |\ref{A}-\ref{B}| are not rendered in the visual order A-B, but in the
+ wrong one B-A (because the hyphen does not “see†the digits inside the
+ |\hbox|’es). If you need |\ref| ranges, the best option is to define
+ a dedicated macro like this (to avoid explicit direction changes in the
+ body; here |\texthe| must be defined to select the main language):
+\begin{verbatim}
+\newcommand\refrange[2]{\babelsublr{\texthe{\ref{#1}}-\texthe{\ref{#2}}}}
+\end{verbatim}
+
+ In a future a more complete method, reading recursively boxed text, may
+ be added.
+\end{note}
+
+\Describe{layout=}{\texttt{sectioning} $\string|$
+ \texttt{counters} $\string|$
+ \texttt{lists} $\string|$
+ \texttt{contents} $\string|$
+ \texttt{footnotes} $\string|$
+ \texttt{captions} $\string|$
+ \texttt{columns} $\string|$
+ \texttt{graphics} $\string|$
+ \texttt{extras}}
+
+\New{3.16} \textit{To be expanded}. Selects which layout elements are
+adapted in bidi documents, including some text elements (except with
+options loading the |bidi| package, which provides its own mechanism to
+control these elements). You may use several options with a
+dot-separated list (eg, |layout=counters.contents.sectioning|). This
+list will be expanded in future releases. Note not all options are
+required by all engines.
+
+\begin{description}
+\renewcommand\makelabel[1]{%
+ \hspace\labelsep\normalfont\ttfamily\color{thered}#1}
+\itemsep=-\parskip
+
+\item[sectioning] makes sure the sectioning macros are typeset in the
+ main language, but with the title text in the current language (see
+ below |\BabelPatchSection| for further details).
+
+\item[counters] required in all engines (except \luatex{} with
+ |bidi=basic|) to reorder section numbers and the like (eg,
+ \m{subsection}.\m{section}); required in \xetex{} and \pdftex{} for
+ counters in general, as well as in \luatex{} with |bidi=default|;
+ required in \luatex{} for numeric footnote marks $>$9 with
+ |bidi=basic-r| (but \textit{not} with |bidi=basic|); note, however,
+ it could depend on the counter format.
+
+ With |counters|, |\arabic| is not only considered L text always (with
+ |\babelsublr|, see below), but also an ``isolated'' block which does
+ not interact with the surrounding chars. So, while |1.2| in R text is
+ rendered in that order with |bidi=basic| (as a decimal number), in
+ |\arabic{c1}.\arabic{c2}| the visual order is \textit{c2.c1}. Of
+ course, you may always adjust the order by changing the language, if
+ necessary.\footnote{Next on the roadmap are counters and numeral
+ systems in general. Expect some minor readjustments.}
+
+\item[lists] required in \xetex{} and \pdftex{}, but only in
+bidirectional (with both R and L paragraphs) documents in \luatex{}.
+
+\begin{warning}
+ As of April 2019 there is a bug with |\parshape| in \luatex{} (a
+ \TeX{} primitive) which makes lists to be horizontally misplaced if
+ they are inside a |\vbox| (like |minipage|) and the current direction
+ is different from the main one. A workaround is to restore the main
+ language before the box and then set the local one inside.
+\end{warning}
+
+\item[contents] required in \xetex{} and \pdftex{}; in \luatex{}
+ toc entries are R by default if the main language is R.
+
+\item[columns] required in \xetex{} and \pdftex{} to reverse the
+ column order (currently only the standard two column mode); in
+ \luatex{} they are R by default if the main language is R (including
+ \textsf{multicol}).
+
+\item[footnotes] not required in monolingual documents, but it may be
+ useful in bidirectional documents (with both R and L paragraphs) in all
+ engines; you may use alternatively |\BabelFootnote| described below
+ (what this options does exactly is also explained there).
+
+\item[captions] is similar to |sectioning|, but for |\caption|; not
+ required in monolingual documents with \luatex{}, but may be
+ required in \xetex{} and \pdftex{} in some styles (support for the
+ latter two engines is still experimental) \New{3.18}.
+
+\item[tabular] required in \luatex{} for R |tabular| (it has been
+ tested only with simple tables, so expect some readjustments in the
+ future); ignored in \pdftex{} or \xetex{} (which will not support a
+ similar option in the short term). It patches an internal command, so
+ it might be ignored by some packages and classes (or even raise an
+ error). \New{3.18}.
+
+\item[graphics] modifies the |picture| environment so that the whole
+ figure is L but the text is R. It \textit{does not} work with the
+ standard |picture|, and \textit{pict2e} is required if you want
+ sloped lines. It attempts to do the same for \textsf{pgf/tikz}.
+ Somewhat experimental. \New{3.32}.
+
+\item[extras] is used for miscellaneous readjustments which do not fit into
+ the previous groups. Currently redefines in \luatex{} |\underline| and
+ |\LaTeX2e| \New{3.19}.
+\end{description}
+
+\begin{example}
+ Typically, in an Arabic document you would need:
+\begin{verbatim}
+\usepackage[bidi=basic,
+ layout=counters.tabular]{babel}
+\end{verbatim}
+\end{example}
+
+\Describe{\babelsublr}{\marg{lr-text}}
+
+Digits in \pdftex{} must be marked up explicitly (unlike \luatex{} with
+|bidi=basic| or |bidi=basic-r| and, usually, \xetex{}). This command is
+provided to set \marg{lr-text} in L mode if necessary. It's intended
+for what Unicode calls weak characters, because words are best set with
+the corresponding language. For this reason, there is no |rl|
+counterpart.
+
+Any |\babelsublr| in \textit{explicit} L mode is ignored. However, with
+|bidi=basic| and \textit{implicit} L, it first returns to R and then
+switches to explicit L. To clarify this point, consider, in an R
+context:
+\begin{verbatim}
+RTL A ltr text \thechapter{} and still ltr RTL B
+\end{verbatim}
+There are \textit{three} R blocks and \textit{two} L blocks, and the
+order is \textit{RTL B and still ltr 1 ltr text RTL A}. This is by
+design to provide the proper behavior in the most usual cases — but if
+you need to use |\ref| in an L text inside R, the L text must be marked
+up explictly; for example:
+\begin{verbatim}
+RTL A \foreignlanguage{english}{ltr text \thechapter{} and still ltr} RTL B
+\end{verbatim}
+
+\Describe{\BabelPatchSection}{\marg{section-name}}
+
+Mainly for bidi text, but it could be useful in other cases.
+|\BabelPatchSection| and the corresponding option |layout=sectioning|
+takes a more logical approach (at least in many cases) because it
+applies the global language to the section format (including the
+|\chaptername| in |\chapter|), while the section text is still the
+current language. The latter is passed to tocs and marks, too,
+and with |sectioning| in |layout| they both reset the “global†language
+to the main one, while the text uses the “local†language.
+
+With |layout=sectioning| all the standard sectioning commands are
+redefined (it also “isolates†the page number in heads, for a proper
+bidi behavior), but with this command you can set them individually if
+necessary (but note then tocs and marks are not touched).
+
+\Describe{\BabelFootnote}{\marg{cmd}\marg{local-language}%
+ \marg{before}\marg{after}}
+
+\New{3.17} Something like:
+\begin{verbatim}
+\BabelFootnote{\parsfootnote}{\languagename}{(}{)}
+\end{verbatim}
+defines |\parsfootnote| so that |\parsfootnote{note}| is equivalent to:
+\begin{verbatim}
+\footnote{(\foreignlanguage{\languagename}{note})}
+\end{verbatim}
+but the footnote itself is typeset in the main language (to unify its
+direction). In addition, |\parsfootnotetext| is defined. The option
+|footnotes| just does the following:
+\begin{verbatim}
+\BabelFootnote{\footnote}{\languagename}{}{}%
+\BabelFootnote{\localfootnote}{\languagename}{}{}%
+\BabelFootnote{\mainfootnote}{}{}{}
+\end{verbatim}
+(which also redefine |\footnotetext| and define |\localfootnotetext|
+and |\mainfootnotetext|). If the language argument is empty, then no
+language is selected inside the argument of the footnote. Note this
+command is available always in bidi documents, even without
+|layout=footnotes|.
+
+\begin{example}
+ If you want to preserve directionality in footnotes and there are
+ many footnotes entirely in English, you can define:
+\begin{verbatim}
+\BabelFootnote{\enfootnote}{english}{}{.}
+\end{verbatim}
+ It adds a period outside the English part, so that it is placed
+ at the left in the last line. This means the dot the end of the
+ footnote text should be omitted.
+\end{example}
+
+\subsection{Language attributes}
+
+\DescribeMacro{\languageattribute}
+This is a user-level command, to be used in the preamble of a
+document (after |\usepackage[...]{babel}|), that declares which
+attributes are to be used for a given language. It takes two
+arguments: the first is the name of the language; the second,
+a (list of) attribute(s) to be used. Attributes must be set in the
+preamble and only once -- they cannot be turned on and off.
+The command checks whether the language is known in this document
+and whether the attribute(s) are known for this language.
+
+Very often, using a \textit{modifier} in a package option is better.
+
+Several language definition files use their own methods to set
+options. For example, \textsf{french} uses |\frenchsetup|,
+\textsf{magyar} (1.5) uses |\magyarOptions|; modifiers provided by
+|spanish| have no attribute counterparts. Macros setting
+options are also used (eg, |\ProsodicMarksOn| in \textsf{latin}).
+
+\subsection{Hooks}
+
+\New{3.9a} A hook is a piece of code to be executed at certain
+events. Some hooks are predefined when \luatex{} and \xetex{} are
+used.
+
+\Describe{\AddBabelHook}{\oarg{lang}\marg{name}\marg{event}\marg{code}}
+
+The same name can be applied to several events. Hooks may be enabled
+and disabled for all defined events with |\EnableBabelHook|\marg{name},
+|\DisableBabelHook|\marg{name}. Names containing the string |babel| are
+reserved (they are used, for example, by |\useshortands*| to add a hook
+for the event |afterextras|). \New{3.33} They may be also applied to an
+specific language with the optional argument; language specific
+settings are executed after global ones.
+
+Current events are the following; in some of them you can use one to
+three \TeX{} parameters (|#1|, |#2|, |#3|), with the meaning given:
+\begin{description}
+\renewcommand\makelabel[1]{%
+ \hspace\labelsep\normalfont\ttfamily\color{thered}#1}
+\itemsep=-\parskip
+\item[adddialect] (language name, dialect name) Used by
+ \file{luababel.def} to load the patterns if not preloaded.
+\item[patterns] (language name, language with encoding) Executed just
+ after the |\language| has been set. The second argument has the
+ patterns name actually selected (in the form of either |lang:ENC| or
+ |lang|).
+\item[hyphenation] (language name, language with encoding) Executed
+ locally just before exceptions given in |\babelhyphenation| are
+ actually set.
+\item[defaultcommands] Used (locally) in |\StartBabelCommands|.
+\item[encodedcommands] (input, font encodings) Used (locally) in
+ |\StartBabelCommands|. Both \xetex{} and \luatex{} make sure the
+ encoded text is read correctly.
+\item[stopcommands] Used to reset the the above, if necessary.
+\item[write] This event comes just after the switching commands are
+ written to the |aux| file.
+\item[beforeextras] Just before executing |\extras|\m{language}. This
+ event and the next one should not contain language-dependent code
+ (for that, add it to |\extras|\m{language}).
+\item[afterextras] Just after executing |\extras|\m{language}. For
+ example, the following deactivates shorthands in all languages:
+\begin{verbatim}
+\AddBabelHook{noshort}{afterextras}{\languageshorthands{none}}
+\end{verbatim}
+\item[stringprocess] Instead of a parameter, you can manipulate the
+ macro |\BabelString| containing the string to be defined with
+ |\SetString|. For example, to use an expanded version of the string
+ in the definition, write:
+\begin{verbatim}
+\AddBabelHook{myhook}{stringprocess}{%
+ \protected@edef\BabelString{\BabelString}}
+\end{verbatim}
+\item[initiateactive] (char as active, char as other, original char)
+ \New{3.9i} Executed just after a shorthand has been `initiated'. The three
+ parameters are the same character with different catcodes: active,
+ other (|\string|'ed) and the original one.
+\item[afterreset] \New{3.9i} Executed when selecting a language just after
+ |\originalTeX| is run and reset to its base value, before executing
+ |\captions|\m{language} and |\date|\m{language}.
+\end{description}
+
+Four events are used in \file{hyphen.cfg}, which are handled in a
+quite different way for efficiency reasons -- unlike the precedent
+ones, they only have a single hook and replace a default definition.
+\begin{description}
+\renewcommand\makelabel[1]{%
+ \hspace\labelsep\normalfont\ttfamily\color{thered}#1}
+\itemsep=-\parskip
+\item[everylanguage] (language) Executed before every language patterns
+ are loaded.
+\item[loadkernel] (file) By default loads |switch.def|. It can be used
+ to load a different version of this files or to load nothing.
+\item[loadpatterns] (patterns file) Loads the patterns file. Used by
+ \file{luababel.def}.
+\item[loadexceptions] (exceptions file) Loads the exceptions
+ file. Used by \file{luababel.def}.
+\end{description}
+
+\Describe{\BabelContentsFiles}{}
+\New{3.9a} This macro contains a list of ``toc'' types
+requiring a command to switch the language. Its default value is
+|toc,lof,lot|, but you may redefine it with |\renewcommand| (it's up
+to you to make sure no toc type is duplicated).
+
+\subsection{Languages supported by \babel{} with \textsf{ldf} files}
+
+In the following table most of the languages supported by \babel{} with
+and |.ldf| file are listed, together with the names of the option which
+you can load \babel\ with for each language. Note this list is open and
+the current options may be different. It does not include |ini| files.
+
+\begin{description}
+\itemsep=-\parskip
+\sffamily
+\item[Afrikaans] afrikaans
+\item[Azerbaijani] azerbaijani
+\item[Basque] basque
+\item[Breton] breton
+\item[Bulgarian] bulgarian
+\item[Catalan] catalan
+\item[Croatian] croatian
+\item[Czech] czech
+\item[Danish] danish
+\item[Dutch] dutch
+\item[English] english, USenglish, american, UKenglish,
+ british, canadian, australian, newzealand
+\item[Esperanto] esperanto
+\item[Estonian] estonian
+\item[Finnish] finnish
+\item[French] french, francais, canadien, acadian
+\item[Galician] galician
+\item[German] austrian, german, germanb, ngerman, naustrian
+\item[Greek] greek, polutonikogreek
+\item[Hebrew] hebrew
+\item[Icelandic] icelandic
+\item[Indonesian] bahasa, indonesian, indon, bahasai
+\item[Interlingua] interlingua
+\item[Irish Gaelic] irish
+\item[Italian] italian
+\item[Latin] latin
+\item[Lower Sorbian] lowersorbian
+\item[Malay] bahasam, malay, melayu
+\item[North Sami] samin
+\item[Norwegian] norsk, nynorsk
+\item[Polish] polish
+\item[Portuguese] portuges, portuguese, brazilian, brazil
+\item[Romanian] romanian
+\item[Russian] russian
+\item[Scottish Gaelic] scottish
+\item[Spanish] spanish
+\item[Slovakian] slovak
+\item[Slovenian] slovene
+\item[Swedish] swedish
+\item[Serbian] serbian
+\item[Turkish] turkish
+\item[Ukrainian] ukrainian
+\item[Upper Sorbian] uppersorbian
+\item[Welsh] welsh
+\end{description}
+
+There are more languages not listed above, including \textsf{hindi,
+thai, thaicjk, latvian, turkmen, magyar, mongolian, romansh,
+lithuanian, spanglish, vietnamese, japanese, pinyin, arabic, farsi,
+ibygreek, bgreek, serbianc, frenchle, ethiop} and \textsf{friulan}.
+
+Most of them work out of the box, but some may require extra fonts,
+encoding files, a preprocessor or even a complete framework (like
+\textsf{CJK} or \textsf{luatexja}). For example, if you have got the
+\textsf{velthuis/devnag} package, you can create a file with extension
+|.dn|:
+\begin{verbatim}
+\documentclass{article}
+\usepackage[hindi]{babel}
+\begin{document}
+{\dn devaanaa.m priya.h}
+\end{document}
+\end{verbatim}
+Then you preprocess it with |devnag| \m{file}, which creates
+\m{file}|.tex|; you can then typeset the latter with \LaTeX.
+
+\subsection{Unicode character properties in \luatex}
+
+\New{3.32} Part of the \babel{} job is to apply Unicode rules to some
+script-specific features based on some properties. Currently, they are
+3, namely, direction (ie, bidi class), mirroring glyphs, and line
+breaking for CJK scripts. These properties are stored in \textsf{lua}
+tables, which you can modify with the following macro.
+
+\Describe{\babelcharproperty}{\marg{char-code}\oarg{to-char-code}%
+ \marg{propertry}\marg{value}}
+
+\New{3.32} Here, \marg{char-code} is a number (with \TeX{} syntax).
+With the optional argument, you can set a range of values. There are
+three properties (with a short name, taken from Unicode): |direction|
+(|bc|), |mirror| (|bmg|), |linebreak| (|lb|). The settings are global.
+
+For example:
+\begin{verbatim}
+\babelcharproperty{`¿}{mirror}{`?}
+\babelcharproperty{`-}{direction}{l} % or al, r, en, an, on, et, cs
+\babelcharproperty{`)}{linebreak}{cl} % or id, op, cl, ns, ex, in, hy
+\end{verbatim}
+
+This command is allowed only in vertical mode (the preamble or between
+paragraphs).
+
+\subsection{Tips, workarounds, know issues and notes}
+
+\begin{itemize}
+\item If you use the document class \cls{book} \emph{and} you use
+ |\ref| inside the argument of |\chapter| (or just use |\ref| inside
+ |\MakeUppercase|), \LaTeX\ will keep complaining about an undefined
+ label. To prevent such problems, you could revert to using
+ uppercase labels, you can use |\lowercase{\ref{foo}}| inside the
+ argument of |\chapter|, or, if you will not use shorthands in
+ labels, set the |safe| option to |none| or |bib|.
+
+\item\catcode`\|=12\relax Both \textsf{ltxdoc} and \textsf{babel} use
+ \verb|\AtBeginDocument| to change some catcodes, and babel reloads
+ \textsf{hhline} to make sure \verb|:| has the right one, so if you
+ want to change the catcode of \verb/|/ it has to be done using the
+ same method at the proper place, with
+\begin{verbatim}
+\AtBeginDocument{\DeleteShortVerb{\|}}
+\end{verbatim}
+ \textit{before} loading babel. This way, when the document begins
+ the sequence is (1) make \verb/|/ active (\textsf{ltxdoc}); (2) make
+ it unactive (your settings); (3) make babel shorthands active
+ (\textsf{babel)}; (4) reload \textsf{hhline} (\textsf{babel}, now
+ with the correct catcodes for \verb/|/ and
+ \verb|:|).\catcode`\|=\active
+
+\item Documents with several input encodings are not frequent, but
+ sometimes are useful. You can set different encodings for different
+ languages as the following example shows:
+\begin{verbatim}
+\addto\extrasfrench{\inputencoding{latin1}}
+\addto\extrasrussian{\inputencoding{koi8-r}}
+\end{verbatim}
+ (A recent version of \textsf{inputenc} is required.)
+ \item For the hyphenation to work correctly, lccodes cannot change,
+ because \TeX{} only takes into account the values when the
+ paragraph is hyphenated, i.e., when it has been
+ finished.\footnote{This explains why \LaTeX{} assumes the lowercase
+ mapping of T1 and does not provide a tool for multiple
+ mappings. Unfortunately, \cs{savinghyphcodes} is not a solution
+ either, because lccodes for hyphenation are frozen in the format
+ and cannot be changed.} So, if you write a chunk of French text
+ with |\foreinglanguage|, the apostrophes might not be taken into
+ account. This is a limitation of \TeX, not of
+ \babel. Alternatively, you may use |\useshorthands| to activate |'|
+ and |\defineshorthand|, or redefine |\textquoteright| (the latter
+ is called by the non-ASCII right quote).
+\item \verb|\bibitem| is out of sync with \verb|\selectlanguage| in
+ the \file{.aux} file. The reason is \verb|\bibitem| uses
+ \verb|\immediate| (and others, in fact), while
+ \verb|\selectlanguage| doesn't. There is no known workaround.
+\item Babel does not take into account |\normalsfcodes| and
+ (non-)French spacing is not always properly (un)set by
+ languages. However, problems are unlikely to happen and therefore
+ this part remains untouched in version 3.9 (but it is in the `to
+ do' list).
+\item Using a character mathematically active (ie, with math code
+ |"8000|) as a shorthand can make \TeX{} enter in an infinite loop in
+ some rare cases. (Another issue in the `to do' list, although there
+ is a partial solution.)
+\end{itemize}
+
+The following packages can be useful, too (the list is still
+far from complete):
+\begin{description}
+\itemsep=-\parskip
+\item[csquotes] Logical markup for quotes.
+\item[iflang] Tests correctly the current language.
+\item[hyphsubst] Selects a different set of patterns for a language.
+\item[translator] An open platform for packages that need to be
+ localized.
+\item[siunitx] Typesetting of numbers and physical quantities.
+\item[biblatex] Programmable bibliographies and citations.
+\item[bicaption] Bilingual captions.
+\item[babelbib] Multilingual bibliographies.
+\item[microtype] Adjusts the typesetting according to
+some languages (kerning and spacing). Ligatures can be disabled.
+\item[substitutefont] Combines fonts in several encodings.
+\item[mkpattern] Generates hyphenation patterns.
+\item[tracklang] Tracks which languages have been requested.
+\item[ucharclasses] (\xetex) Switches fonts when you switch from one
+ Unicode block to another.
+\item[zhspacing] Spacing for CJK documents in \xetex.
+\end{description}
+
+\subsection{Current and future work}
+
+Current work is focused on the so-called complex scripts in \luatex{}.
+In 8-bit engines, \babel{} provided a basic support for bidi text as
+part of the style for Hebrew, but it is somewhat unsatisfactory and
+internally replaces some hardwired commands by other hardwired commands
+(generic changes would be much better).
+
+Useful additions would be, for example, time, currency, addresses and
+personal names.\footnote{See for example POSIX, ISO 14652 and the
+Unicode Common Locale Data Repository (CLDR). Those system, however,
+have limited application to \TeX\ because their aim is just to display
+information and not fine typesetting.}. But that is the easy
+part, because they don't require modifying the \LaTeX{} internals.
+Calendars (Arabic, Persian, Indic, etc.) are under study.
+
+Also interesting are differences in the sentence structure or related
+to it. For example, in Basque the number precedes the name (including
+chapters), in Hungarian ``from (1)'' is ``(1)-b\H{o}l'', but ``from
+(3)'' is ``(3)-b\'{o}l'', in Spanish an item labelled
+``3.$^{\textrm{\scriptsize o}}$'' may be referred to as either
+``\'{\i}tem 3.$^{\textrm{\scriptsize o}}$'' or
+``3.$^{\textrm{\scriptsize er}}$ \'{\i}tem'', and so on.
+
+An option to manage bidirectional document layout in \luatex{} (lists,
+footnotes, etc.) is almost finished, but \xetex{} required more work.
+Unfortunately, proper support for \xetex{} requires patching somehow
+lots of macros and packages (and some issues related to |\special|s
+remain, like color and hyperlinks), so \babel{} resorts to the
+\textsf{bidi} package (by Vafa Khalighi). See the \babel{} repository
+for a small example (|xe-bidi|).
+
+\subsection{Tentative and experimental code}
+
+See the code section for |\foreignlanguage*| (a new starred
+version of |\foreignlanguage|).
+
+\medskip
+\textbf{Old stuff}
+
+A couple of tentative macros were provided by \babel{} ($\ge$3.9g) with
+a partial solution for ``Unicode'' fonts. These macros are now
+deprecated --- use |\babelfont|. A short description follows, for
+reference:
+\begin{itemize}
+\item |\babelFSstore|\marg{babel-language} sets the current three
+ basic families (rm, sf, tt) as the default for the language
+ given.
+\item |\babelFSdefault|\marg{babel-language}\marg{fontspec-features}
+ patches |\fontspec| so that the given features are always passed as
+ the optional argument or added to it (not an ideal solution).
+\end{itemize}
+So, for example:
+\begin{verbatim}
+\setmainfont[Language=Turkish]{Minion Pro}
+\babelFSstore{turkish}
+\setmainfont{Minion Pro}
+\babelFSfeatures{turkish}{Language=Turkish}
+\end{verbatim}
+
+\section{Loading languages with \file{language.dat}}
+
+\TeX{} and most engines based on it (pdf\TeX, \xetex, $\epsilon$-\TeX,
+the main exception being \luatex) require hyphenation patterns to be
+preloaded when a format is created (eg, \LaTeX, Xe\LaTeX,
+pdf\LaTeX). \babel{} provides a tool which has become standard in many
+distributions and based on a ``configuration file'' named
+\file{language.dat}. The exact way this file is used depends on the
+distribution, so please, read the documentation for the latter (note
+also some distributions generate the file with some tool).
+
+\New{3.9q} With \luatex, however, patterns are loaded on the fly when
+requested by the language (except the ``0th'' language, typically
+\textsf{english}, which is preloaded always).\footnote{This feature
+was added to 3.9o, but it was buggy. Both 3.9o and 3.9p are
+deprecated.} Until 3.9n, this task was delegated to the package
+\textsf{luatex-hyphen}, by Khaled Hosny, \'Elie Roux, and Manuel
+P\'egouri\'e-Gonnard, and required an extra file named
+|language.dat.lua|, but now a new mechanism has been devised based
+solely on |language.dat|. \textbf{You must rebuild the formats} if
+upgrading from a previous version. You may want to have a local
+|language.dat| for a particular project (for example, a book on
+Chemistry).\footnote{The loader for lua(e)tex is slightly different as
+it's not based on \babel{} but on \texttt{etex.src}. Until 3.9p it
+just didn't work, but thanks to the new code it works by reloading the
+data in the \babel{} way, i.e., with \texttt{language.dat}.}
+
+\subsection{Format}
+
+In that file the person who maintains a \TeX\ environment has to record
+for which languages he has hyphenation patterns \emph{and} in which
+files these are stored\footnote{This is because different operating
+systems sometimes use \emph{very} different file-naming
+conventions.}. When hyphenation exceptions are stored in a separate
+file this can be indicated by naming that file \emph{after} the file
+with the hyphenation patterns.
+
+The file can contain empty lines and comments, as well as lines which
+start with an equals (\texttt{=}) sign. Such a line will instruct
+\LaTeX\ that the hyphenation patterns just processed have to be known
+under an alternative name. Here is an example:
+\begin{verbatim}
+% File : language.dat
+% Purpose : tell iniTeX what files with patterns to load.
+english english.hyphenations
+=british
+
+dutch hyphen.dutch exceptions.dutch % Nederlands
+german hyphen.ger
+\end{verbatim}
+
+You may also set the font encoding the patterns are intended for by
+following the language name by a colon and the encoding
+code.\footnote{This in not a new feature, but in former versions it
+didn't work correctly.} For example:
+\begin{verbatim}
+german:T1 hyphenT1.ger
+german hyphen.ger
+\end{verbatim}
+With the previous settings, if the encoding when the language is
+selected is |T1| then the patterns in \file{hyphenT1.ger} are
+used, but otherwise use those in \file{hyphen.ger} (note the encoding
+could be set in |\extras|\m{lang}).
+
+A typical error when using \babel{} is the following:
+\begin{verbatim}
+No hyphenation patterns were preloaded for
+the language `<lang>' into the format.
+Please, configure your TeX system to add them and
+rebuild the format. Now I will use the patterns
+preloaded for english instead}}
+\end{verbatim}
+It simply means you must reconfigure \file{language.dat}, either by
+hand or with the tools provided by your distribution.
+
+\section{The interface between the core of \babel{} and the language
+definition files}
+
+The \textit{language definition files} (ldf) must conform to a
+number of conventions, because these files have to fill in the gaps
+left by the common code in \file{babel.def}, i.\,e., the
+definitions of the macros that produce texts. Also the
+language-switching possibility which has been built into the
+\babel{} system has its implications.
+
+The following assumptions are made:
+\begin{itemize}
+\item Some of the language-specific definitions might be used by plain
+ \TeX\ users, so the files have to be coded so that they can be read
+ by both \LaTeX\ and plain \TeX. The current format can be checked by
+ looking at the value of the macro |\fmtname|.
+\item The common part of the \babel{} system redefines a number of
+ macros and environments (defined previously in the document style)
+ to put in the names of macros that replace the previously hard-wired
+ texts. These macros have to be defined in the language definition
+ files.
+\item The language definition files must define five macros, used to
+ activate and deactivate the language-specific definitions. These
+ macros are |\|\langvar|hyphenmins|, |\captions|\langvar,
+ |\date|\langvar, |\extras|\langvar\ and |\noextras|\langvar (the
+ last two may be left empty); where \langvar\ is either the name of
+ the language definition file or the name of the \LaTeX\ option that
+ is to be used. These macros and their functions are discussed
+ below. You must define all or none for a language (or a dialect);
+ defining, say, |\date|\langvar\ but not |\captions|\langvar\ does
+ not raise an error but can lead to unexpected results.
+\item When a language definition file is loaded, it can define
+ |\l@|\langvar\ to be a dialect of |\language0| when |\l@|\langvar\
+ is undefined.
+\item Language names must be all lowercase. If an unknown language is
+ selected, \babel{} will attempt setting it after lowercasing its
+ name.
+\item The semantics of modifiers is not defined (on purpose). In
+ most cases, they will just be simple separated options (eg,
+ \texttt{spanish}), but a language might require, say, a set of
+ options organized as a tree with suboptions (in such a case, the
+ recommended separator is \verb|/|).
+\end{itemize}
+
+Some recommendations:
+\begin{itemize}
+\item The preferred shorthand is |"|, which is not used in \LaTeX{}
+ (quotes are entered as |``| and |''|). Other good choices are
+ characters which are not used in a certain context (eg, |=| in an
+ ancient language). Note however |=|, |<|, |>|, |:| and the like
+ can be dangerous, because they may be used as part of the syntax
+ of some elements (numeric expressions, key/value pairs, etc.).
+\item Captions should not contain shorthands or encoding dependent
+ commands (the latter is not always possible, but should be clearly
+ documented). They should be defined using the LICR. You may
+ also use the new tools for encoded strings, described below.
+\item Avoid adding things to |\noextras|\m{lang} except for umlauthigh
+ and friends, |\bbl@deactivate|, |\bbl@(non)frenchspacing|, and
+ language specific macros. Use always, if possible, |\bbl@save| and
+ |\bbl@savevariable| (except if you still want to have access to the
+ previous value). Do not reset a macro or a setting to a hardcoded
+ value. Never. Instead save its value in |\extras|\m{lang}.
+\item Do not switch scripts. If you want to make sure a set of glyphs
+ is used, switch either the font encoding (low level) or the language
+ (high level, which in turn may switch the font encoding). Usage of things
+ like |\latintext| is deprecated.\footnote{But not removed, for backward
+ compatibility.}
+\item Please, for ``private'' internal macros do not use the |\bbl@|
+ prefix. It is used by \babel{} and it can lead to incompatibilities.
+\end{itemize}
+
+There are no special requirements for documenting your language
+files. Now they are not included in the base \babel{} manual, so
+provide a standalone document suited for your needs, as well as other
+files you think can be useful. A PDF and a ``readme'' are strongly
+recommended.
+
+\subsection{Guidelines for contributed languages}
+\label{contribute}
+
+Now language files are “outsourced†and are located in a separate
+directory (\texttt{/macros/latex/contrib/babel-contrib}), so that they
+are contributed directly to CTAN (please, do not send to me language
+styles just to upload them to CTAN).
+
+Of course, placing your style files in this directory is not mandatory,
+but if you want to do it, here are a few guidelines.
+
+\begin{itemize}
+\item Do not hesitate stating on the file heads you are the author and the
+ maintainer, if you actually are. There is no need to state the babel
+ maintainer(s) as authors if they have not contributed significantly
+ to your language files.
+\item Fonts are not strictly part of a language, so they are best placed
+ in the corresponding TeX tree. This includes not only \texttt{tfm},
+ \texttt{vf}, \texttt{ps1}, \texttt{otf}, \texttt{mf} files and the
+ like, but also \texttt{fd} ones.
+\item Font and input encodings are usually best placed in the
+ corresponding tree, too, but sometimes they belong more naturally to
+ the babel style. Note you may also need to define a LICR.
+\item \Babel{} ldf files may just interface a framework, as it happens often
+ with Oriental languages/scripts. This framework is best placed in its
+ own directory.
+\end{itemize}
+
+The following page provides a starting point:
+\texttt{http://www.texnia.com/incubator.html}.
+
+If your need further assistance and technical advice in the
+development of language styles, I am willing to help you. And of
+course, you can make any suggestion you like.
+
+\subsection{Basic macros}
+
+In the core of the \babel{} system, several macros are defined for use
+in language definition files. Their purpose is to make a new language
+known. The first two are related to hyphenation patterns.
+
+\DescribeMacro{\addlanguage}
+The macro |\addlanguage| is a non-outer version of the macro
+|\newlanguage|, defined in \file{plain.tex} version~3.x. For older
+versions of \file{plain.tex} and \file{lplain.tex} a substitute
+definition is used. Here ``language'' is used in the \TeX{} sense of
+set of hyphenation patterns.
+
+\DescribeMacro{\adddialect}
+The macro |\adddialect| can be used when two languages can (or
+must) use the same hyphenation patterns. This can also be useful
+for languages for which no patterns are preloaded in the
+format. In such cases the default behavior of the \babel{}
+system is to define this language as a `dialect' of the language
+for which the patterns were loaded as |\language0|. Here
+``language'' is used in the \TeX{} sense of set of hyphenation
+patterns.
+
+\DescribeMacro{\<lang>hyphenmins}
+The macro |\|\langvar|hyphenmins| is used to store the values of
+the |\lefthyphenmin| and |\righthyphenmin|. Redefine this macro
+to set your own values, with two numbers corresponding to these
+two parameters. For example:
+\begin{verbatim}
+\renewcommand\spanishhyphenmins{34}
+\end{verbatim}
+(Assigning |\lefthyphenmin| and |\righthyphenmin| directly in
+|\extras<lang>| has no effect.)
+
+\DescribeMacro{\providehyphenmins}
+The macro |\providehyphenmins| should be used in the language
+definition files to set |\lefthyphenmin| and
+|\righthyphenmin|. This macro will check whether these parameters
+were provided by the hyphenation file before it takes any action.
+If these values have been already set, this command is ignored
+(currently, default pattern files do \textit{not} set them).
+
+\DescribeMacro{\captions\langvar}
+The macro |\captions|\langvar\ defines the macros that
+hold the texts to replace the original hard-wired texts.
+
+\DescribeMacro{\date\langvar}
+The macro |\date|\langvar\ defines |\today|.
+
+\DescribeMacro{\extras\langvar}
+The macro |\extras|\langvar\ contains all the extra definitions needed
+for a specific language. This macro, like the following, is a hook --
+you can add things to it, but it must not be used directly.
+
+\DescribeMacro{\noextras\langvar}
+Because we want to let the user switch
+between languages, but we do not know what state \TeX\ might be in
+after the execution of |\extras|\langvar, a macro that brings
+\TeX\ into a predefined state is needed. It will be no surprise
+that the name of this macro is |\noextras|\langvar.
+
+\DescribeMacro{\bbl@declare@ttribute}
+This is a command to be used in the language definition files for
+declaring a language attribute. It takes three arguments: the
+name of the language, the attribute to be defined, and the code
+to be executed when the attribute is to be used.
+
+\DescribeMacro{\main@language}
+To postpone the activation of the definitions needed for a
+language until the beginning of a document, all language
+definition files should use |\main@language| instead of
+|\selectlanguage|. This will just store the name of the language,
+and the proper language will be activated at the start of the
+document.
+
+\DescribeMacro{\ProvidesLanguage}
+The macro |\ProvidesLanguage| should be used to identify the
+language definition files. Its syntax is similar to the syntax
+of the \LaTeX\ command |\ProvidesPackage|.
+
+\DescribeMacro{\LdfInit}
+The macro |\LdfInit| performs a couple of standard checks that
+must be made at the beginning of a language definition file,
+such as checking the category code of the @-sign, preventing
+the \file{.ldf} file from being processed twice, etc.
+
+\DescribeMacro{\ldf@quit}
+The macro |\ldf@quit| does work needed if a \file{.ldf} file was
+processed earlier. This includes resetting the category code of the
+@-sign, preparing the language to be activated at |\begin{document}|
+time, and ending the input stream.
+
+\DescribeMacro{\ldf@finish}
+The macro |\ldf@finish| does work needed at the end of each \file{.ldf}
+file. This includes resetting the category code of the @-sign, loading
+a local configuration file, and preparing the language to be activated
+at |\begin{document}| time.
+
+\DescribeMacro{\loadlocalcfg}
+After processing a language definition file,
+\LaTeX\ can be instructed to load a local configuration
+file. This file can, for instance, be used to add strings to
+|\captions|\langvar\ to support local document
+classes. The user will be informed that this
+configuration file has been loaded. This macro is called by
+|\ldf@finish|.
+
+\DescribeMacro{\substitutefontfamily}
+(Deprecated.) This command takes three arguments, a font encoding and
+two font family names. It creates a font description file for the
+first font in the given encoding. This \file{.fd} file will instruct
+\LaTeX\ to use a font from the second family when a font from the
+first family in the given encoding seems to be needed.
+
+\subsection{Skeleton}
+
+Here is the basic structure of an |ldf| file, with a language, a
+dialect and an attribute. Strings are best defined using the method
+explained in in sec. \ref{s:strings} (\babel{} 3.9 and later).
+
+\begin{verbatim}
+\ProvidesLanguage{<language>}
+ [2016/04/23 v0.0 <Language> support from the babel system]
+\LdfInit{<language>}{captions<language>}
+
+\ifx\undefined\l@<language>
+ \@nopatterns{<Language>}
+ \adddialect\l@<language>0
+\fi
+
+\adddialect\l@<dialect>\l@<language>
+
+\bbl@declare@ttribute{<language>}{<attrib>}{%
+ \expandafter\addto\expandafter\extras<language>
+ \expandafter{\extras<attrib><language>}%
+ \let\captions<language>\captions<attrib><language>}
+
+\providehyphenmins{<language>}{\tw@\thr@@}
+
+\StartBabelCommands*{<language>}{captions}
+\SetString\chaptername{<chapter name>}
+% More strings
+
+\StartBabelCommands*{<language>}{date}
+\SetString\monthiname{<name of first month>}
+% More strings
+
+\StartBabelCommands*{<dialect>}{captions}
+\SetString\chaptername{<chapter name>}
+% More strings
+
+\StartBabelCommands*{<dialect>}{date}
+\SetString\monthiname{<name of first month>}
+% More strings
+
+\EndBabelCommands
+
+\addto\extras<language>{}
+\addto\noextras<language>{}
+\let\extras<dialect>\extras<language>
+\let\noextras<dialect>\noextras<language>
+
+\ldf@finish{<language>}
+\end{verbatim}
+
+\begin{note}
+ If for some reason you want to load a package in your style, you
+ should be aware it cannot be done directly in the \texttt{ldf} file,
+ but it can be delayed with |\AtEndOfPackage|. Macros from external
+ packages can be used \textit{inside} definitions in the \textsf{ldf}
+ itself (for example, |\extras<language>|), but if executed directly,
+ the code must be placed inside |\AtEndOfPackage|. A trivial example
+ illustrating these points is:
+\begin{verbatim}
+\AtEndOfPackage{%
+ \RequirePackage{dingbat}% Delay package
+ \savebox{\myeye}{\eye}}% And direct usage
+\newsavebox{\myeye}
+\newcommand\myanchor{\anchor}% But OK inside command
+\end{verbatim}
+\end{note}
+
+\subsection{Support for active characters}
+
+In quite a number of language definition files, active characters are
+introduced. To facilitate this, some support macros are provided.
+
+\DescribeMacro{\initiate@active@char}
+The internal macro |\initiate@active@char| is used in language
+definition files to instruct \LaTeX\ to give a character the category
+code `active'. When a character has been made active it will remain
+that way until the end of the document. Its definition may vary.
+
+\DescribeMacro{\bbl@activate}
+\DescribeMacro{\bbl@deactivate}
+The command |\bbl@activate| is used to change the way an active
+character expands. |\bbl@activate| `switches on' the active behavior
+of the character. |\bbl@deactivate| lets the active character expand
+to its former (mostly) non-active self.
+
+\DescribeMacro{\declare@shorthand}
+The macro |\declare@shorthand| is used to define the various
+shorthands. It takes three arguments: the name for the collection of
+shorthands this definition belongs to; the character (sequence) that
+makes up the shorthand, i.e.\ |~| or |"a|; and the code to be executed
+when the shorthand is encountered. (It does \textit{not} raise an
+error if the shorthand character has not been ``initiated''.)
+
+\DescribeMacro{\bbl@add@special}
+\DescribeMacro{\bbl@remove@special}
+The \TeX book states: ``Plain \TeX\ includes a macro called
+|\dospecials| that is essentially a set macro, representing the set of
+all characters that have a special category code.'' \cite[p.~380]{DEK}
+It is used to set text `verbatim'. To make this work if more
+characters get a special category code, you have to add this character
+to the macro |\dospecial|. \LaTeX\ adds another macro called
+|\@sanitize| representing the same character set, but without the
+curly braces. The macros |\bbl@add@special|\meta{char} and
+|\bbl@remove@special|\meta{char} add and remove the character
+\meta{char} to these two sets.
+
+\subsection{Support for saving macro definitions}
+
+Language definition files may want to \emph{re}define macros that
+already exist. Therefore a mechanism for saving (and restoring) the
+original definition of those macros is provided. We provide two macros
+for this\footnote{This mechanism was introduced by Bernd Raichle.}.
+
+\DescribeMacro{\babel@save}
+To save the current meaning of any control sequence, the macro
+|\babel@save| is provided. It takes one argument, \meta{csname}, the
+control sequence for which the meaning has to be saved.
+
+\DescribeMacro{\babel@savevariable}
+A second macro is provided to save the current value of a variable.
+In this context, anything that is allowed after the |\the| primitive
+is considered to be a variable. The macro takes one argument, the
+\meta{variable}.
+
+The effect of the preceding macros is to append a piece of code to
+the current definition of |\originalTeX|. When |\originalTeX| is
+expanded, this code restores the previous definition of the control
+sequence or the previous value of the variable.
+
+\subsection{Support for extending macros}
+
+\DescribeMacro{\addto}
+The macro |\addto{|\meta{control sequence}|}{|\meta{\TeX\ code}|}| can
+be used to extend the definition of a macro. The macro need not be
+defined (ie, it can be undefined or |\relax|). This macro can, for
+instance, be used in adding instructions to a macro like
+|\extrasenglish|.
+
+Be careful when using this macro, because depending on the case the
+assignment could be either global (usually) or local (sometimes). That
+does not seem very consistent, but this behavior is preserved for
+backward compatibility. If you are using \pkg{etoolbox}, by Philipp
+Lehman, consider using the tools provided by this package instead of
+|\addto|.
+
+\subsection{Macros common to a number of languages}
+
+\DescribeMacro{\bbl@allowhyphens}
+In several languages compound words are used. This means that when
+\TeX\ has to hyphenate such a compound word, it only does so at the
+`\texttt{-}' that is used in such words. To allow hyphenation in the
+rest of such a compound word, the macro |\bbl@allowhyphens| can be
+used.
+
+\DescribeMacro{\allowhyphens}
+Same as |\bbl@allowhyphens|, but does nothing if the encoding is
+|T1|. It is intended mainly for characters provided as real glyphs by
+this encoding but constructed with |\accent| in |OT1|.
+
+Note the previous command (|\bbl@allowhyphens|) has different
+applications (hyphens and discretionaries) than this one (composite
+chars). Note also prior to version 3.7, |\allowhyphens| had the
+behavior of |\bbl@allowhyphens|.
+
+\DescribeMacro{\set@low@box}
+For some languages, quotes need to be lowered to the baseline. For
+this purpose the macro |\set@low@box| is available. It takes one
+argument and puts that argument in an |\hbox|, at the baseline. The
+result is available in |\box0| for further processing.
+
+\DescribeMacro{\save@sf@q}
+Sometimes it is necessary to preserve the |\spacefactor|. For this
+purpose the macro |\save@sf@q| is available. It takes one argument,
+saves the current spacefactor, executes the argument, and restores the
+spacefactor.
+
+\DescribeMacro{\bbl@frenchspacing}
+\DescribeMacro{\bbl@nonfrenchspacing}
+The commands |\bbl@frenchspacing| and |\bbl@nonfrenchspacing| can be
+used to properly switch French spacing on and off.
+
+\subsection{Encoding-dependent strings}
+\label{s:strings}
+
+\New{3.9a} Babel 3.9 provides a way of defining strings in several
+encodings, intended mainly for \luatex{} and \xetex. This is the only new
+feature requiring changes in language files if you want to make use of
+it.
+
+Furthermore, it must be activated explicitly, with the package option
+|strings|. If there is no |strings|, these blocks are ignored, except
+|\SetCase|s (and except if forced as described below). In other words,
+the old way of defining/switching strings still works and it's used by
+default.
+
+It consist is a series of blocks started with
+|\StartBabelCommands|. The last block is closed with
+|\EndBabelCommands|. Each block is a single group (ie, local
+declarations apply until the next |\StartBabelCommands| or
+|\EndBabelCommands|). An |ldf| may contain several series of this
+kind.
+
+Thanks to this new feature, string values and string language
+switching are not mixed any more. No need of |\addto|. If the language
+is |french|, just redefine |\frenchchaptername|.
+
+\Describe\StartBabelCommands
+ {\marg{language-list}\marg{category}\oarg{selector}}
+
+The \m{language-list} specifies which languages the block is
+intended for. A block is taken into account only if the
+|\CurrentOption| is listed here. Alternatively, you can define
+|\BabelLanguages| to a comma-separated list of languages to be
+defined (if undefined, |\StartBabelCommands| sets it to
+|\CurrentOption|). You may write |\CurrentOption| as the language,
+but this is discouraged -- a explicit name (or names) is much better
+and clearer.
+
+A ``selector'' is a name to be used as value in package option
+|strings|, optionally followed by extra info about the encodings to be
+used. The name |unicode| must be used for \xetex{} and \luatex{} (the
+key |strings| has also other two special values: |generic| and
+|encoded|).
+
+If a string is set several times (because several blocks are read),
+the first one take precedence (ie, it works much like
+|\providecommand|).
+
+Encoding info is |charset=| followed by a charset, which if given sets
+how the strings should be translated to the internal representation
+used by the engine, typically |utf8|, which is the only value
+supported currently (default is no translations). Note |charset| is
+applied by \luatex{} and \xetex{} when reading the file, not when the
+macro or string is used in the document.
+
+A list of font encodings which the strings are expected to work with
+can be given after |fontenc=| (separated with spaces, if two or more) --
+recommended, but not mandatory, although blocks without this key are
+not taken into account if you have requested |strings=encoded|.
+
+Blocks without a selector are read always if the key |strings| has
+been used. They provide fallback values, and therefore must be the
+last blocks; they should be provided always if possible and all
+strings should be defined somehow inside it; they can be the only
+blocks (mainly LGC scripts using the LICR). Blocks without a selector
+can be activated explicitly with |strings=generic| (no block is taken
+into account except those). With |strings=encoded|, strings in those
+blocks are set as default (internally, |?|). With |strings=encoded|
+strings are protected, but they are correctly expanded in
+|\MakeUppercase| and the like. If there is no key |strings|, string
+definitions are ignored, but |\SetCase|s are still honored (in a
+|encoded| way).
+
+The \m{category} is either |captions|, |date| or |extras|. You must
+stick to these three categories, even if no error is raised when using
+other name.\footnote{In future releases further categories may be
+added.\nb{like `monetary', `time', `address', `name', `case' or
+`numeric'}} It may be empty, too, but in such a case using
+|\SetString| is an error (but not |\SetCase|).
+
+\begin{verbatim}
+\StartBabelCommands{language}{captions}
+ [unicode, fontenc=TU EU1 EU2, charset=utf8]
+\SetString{\chaptername}{utf8-string}
+
+\StartBabelCommands{language}{captions}
+\SetString{\chaptername}{ascii-maybe-LICR-string}
+
+\EndBabelCommands
+\end{verbatim}
+
+A real example is:
+\begin{verbatim}
+\StartBabelCommands{austrian}{date}
+ [unicode, fontenc=TU EU1 EU2, charset=utf8]
+ \SetString\monthiname{Jänner}
+
+\StartBabelCommands{german,austrian}{date}
+ [unicode, fontenc=TU EU1 EU2, charset=utf8]
+ \SetString\monthiiiname{März}
+
+\StartBabelCommands{austrian}{date}
+ \SetString\monthiname{J\"{a}nner}
+
+\StartBabelCommands{german}{date}
+ \SetString\monthiname{Januar}
+
+\StartBabelCommands{german,austrian}{date}
+ \SetString\monthiiname{Februar}
+ \SetString\monthiiiname{M\"{a}rz}
+ \SetString\monthivname{April}
+ \SetString\monthvname{Mai}
+ \SetString\monthviname{Juni}
+ \SetString\monthviiname{Juli}
+ \SetString\monthviiiname{August}
+ \SetString\monthixname{September}
+ \SetString\monthxname{Oktober}
+ \SetString\monthxiname{November}
+ \SetString\monthxiiname{Dezenber}
+ \SetString\today{\number\day.~%
+ \csname month\romannumeral\month name\endcsname\space
+ \number\year}
+
+\StartBabelCommands{german,austrian}{captions}
+ \SetString\prefacename{Vorwort}
+ [etc.]
+
+\EndBabelCommands
+\end{verbatim}
+
+When used in |ldf| files, previous values of |\|\m{category}\m{language}
+are overridden, which means the old way to define strings still works
+and used by default (to be precise, is first set to undefined and then
+strings are added). However, when used in the preamble or in a
+package, new settings are added to the previous ones, if the language
+exists (in the \babel{} sense, ie, if |\date|\m{language} exists).
+
+\Describe\StartBabelCommands{%
+ \colorbox{thegrey}{\ttfamily\hskip-.2em*\hskip-.2em}%
+ \marg{language-list}\marg{category}\oarg{selector}}
+The starred version just forces |strings| to take a value -- if not set
+as package option, then the default for the engine is used. This is
+not done by default to prevent backward incompatibilities, but if you
+are creating a new language this version is better. It's up to
+the maintainers of the current languages to decide if using it is
+appropriate.\footnote{This replaces in 3.9g a short-lived
+\texttt{\string\UseStrings} which has been removed because it did
+not work.}
+
+\Describe{\EndBabelCommands}{}
+Marks the end of the series of blocks.
+
+\Describe{\AfterBabelCommands}{\marg{code}}
+The code is delayed and executed at the global scope just after
+|\EndBabelCommands|.
+
+\Describe{\SetString}{\marg{macro-name}\marg{string}}
+Adds \meta{macro-name} to the current category, and defines globally
+\meta{lang-macro-name} to \meta{code} (after applying the
+transformation corresponding to the current charset or defined with
+the hook |stringprocess|).
+
+Use this command to define strings, without including any ``logic'' if
+possible, which should be a separated macro. See the example above for
+the date.
+
+\Describe{\SetStringLoop}{\marg{macro-name}\marg{string-list}}
+A convenient way to define several ordered names at once. For example,
+to define |\abmoniname|, |\abmoniiname|, etc. (and similarly with
+|abday|):
+\begin{verbatim}
+\SetStringLoop{abmon#1name}{en,fb,mr,ab,my,jn,jl,ag,sp,oc,nv,dc}
+\SetStringLoop{abday#1name}{lu,ma,mi,ju,vi,sa,do}
+\end{verbatim}
+|#1| is replaced by the roman numeral.
+
+\Describe\SetCase{\oarg{map-list}\marg{toupper-code}\marg{tolower-code}}
+Sets globally code to be executed at |\MakeUppercase| and
+|\MakeLowercase|. The code would be typically things like |\let\BB\bb|
+and |\uccode| or |\lccode| (although for the reasons explained above,
+changes in lc/uc codes may not work). A \meta{map-list} is a series of
+macros using the internal format of |\@uclclist| (eg,
+|\bb\BB\cc\CC|). The mandatory arguments take precedence over the
+optional one. This command, unlike |\SetString|, is executed always
+(even without |strings|), and it is intended for minor readjustments
+only.
+
+For example, as |T1| is the default case mapping in \LaTeX, we could
+set for Turkish:
+\begin{verbatim}
+\StartBabelCommands{turkish}{}[ot1enc, fontenc=OT1]
+\SetCase
+ {\uccode"10=`I\relax}
+ {\lccode`I="10\relax}
+
+\StartBabelCommands{turkish}{}[unicode, fontenc=TU EU1 EU2, charset=utf8]
+\SetCase
+ {\uccode`i=`Ä°\relax
+ \uccode`ı=`I\relax}
+ {\lccode`Ä°=`i\relax
+ \lccode`I=`ı\relax}
+
+\StartBabelCommands{turkish}{}
+\SetCase
+ {\uccode`i="9D\relax
+ \uccode"19=`I\relax}
+ {\lccode"9D=`i\relax
+ \lccode`I="19\relax}
+
+\EndBabelCommands
+\end{verbatim}
+(Note the mapping for |OT1| is not complete.)
+
+\Describe{\SetHyphenMap}{\marg{to-lower-macros}}
+\New{3.9g} Case mapping serves in \TeX{} for two unrelated purposes: case
+transforms (upper/lower) and hyphenation. |\SetCase| handles the
+former, while hyphenation is handled by |\SetHyphenMap| and controlled
+with the package option |hyphenmap|. So, even if internally they are based
+on the same \TeX{} primitive (|\lccode|), \babel{} sets them separately.
+
+There are three helper macros to
+be used inside |\SetHyphenMap|:
+\begin{itemize}
+\item |\BabelLower|\marg{uccode}\marg{lccode} is
+ similar to |\lccode| but it's ignored if the char has been set and
+ saves the original lccode to restore it when switching the language
+ (except with |hyphenmap=first|).
+\item |\BabelLowerMM|\marg{uccode-from}\marg{uccode-to}%
+ \marg{step}\marg{lccode-from} loops though the given uppercase
+ codes, using the step, and assigns them the lccode, which is also
+ increased (|MM| stands for \textit{many-to-many}).
+\item |\BabelLowerMO|\marg{uccode-from}\marg{uccode-to}%
+ \marg{step}\marg{lccode} loops though the given uppercase
+ codes, using the step, and assigns them the lccode, which is fixed
+ (|MO| stands for \textit{many-to-one}).
+\end{itemize}
+An example is (which is redundant, because these assignments are done
+by both \luatex{} and \xetex{}):
+\begin{verbatim}
+\SetHyphenMap{\BabelLowerMM{"100}{"11F}{2}{"101}}
+\end{verbatim}
+
+This macro is not intended to fix wrong mappings done by Unicode
+(which are the default in both \xetex{} and \luatex{}) -- if an
+assignment is wrong, fix it directly.
+
+\section{Changes}
+
+\subsection{Changes in \babel\ version 3.9}
+
+Most of changes in version 3.9 were related to bugs, either to fix them
+(there were lots), or to provide some alternatives. Even new features
+like |\babelhyphen| are intended to solve a certain problem (in this
+case, the lacking of a uniform syntax and behavior for shorthands
+across languages). These changes are described in this manual in the
+corresponding place. A selective list follows:
+\begin{itemize}
+\item |\select@language| did not set |\languagename|. This meant the
+ language in force when auxiliary files were loaded was the one used
+ in, for example, shorthands -- if the language was |german|, a
+ |\select@language{spanish}| had no effect.
+
+\item |\foreignlanguage| and |otherlanguage*| messed up
+ |\extras<language>|. Scripts, encodings and many other things were
+ not switched correctly.
+
+\item The |:ENC| mechanism for hyphenation patterns used the encoding
+ of the \textit{previous} language, not that of the language being
+ selected.
+
+\item |'| (with |activeacute|) had the original value when writing to an
+ auxiliary file, and things like an infinite loop could happen. It
+ worked incorrectly with |^| (if activated) and also if deactivated.
+
+\item Active chars where not reset at the end of language options, and
+ that lead to incompatibilities between languages.
+
+\item |\textormath| raised and error with a conditional.
+
+\item |\aliasshorthand| didn't work (or only in a few and very specific
+ cases).
+
+\item |\l@english| was defined incorrectly (using |\let| instead of
+ |\chardef|).
+
+\item |ldf| files not bundled with babel were not recognized when
+ called as global options.
+\end{itemize}
+
+\DocInput{babel.dtx}
+
+\section{Acknowledgements}
+
+I would like to thank all who volunteered as $\beta$-testers for their
+time. Michel Goossens supplied contributions for most of the other
+languages. Nico Poppelier helped polish the text of the documentation
+and supplied parts of the macros for the Dutch language. Paul Wackers
+and Werenfried Spit helped find and repair bugs.
+
+During the further development of the babel system I received much
+help from Bernd Raichle, for which I am grateful.
+
+\begin{thebibliography}{9}
+ \bibitem{AT} Huda Smitshuijzen Abifares, \textit{Arabic Typography},
+ Saqi, 2001.
+ \bibitem{DEK} Donald E. Knuth,
+ \emph{The \TeX book}, Addison-Wesley, 1986.
+ \bibitem{LLbook} Leslie Lamport,
+ \emph{\LaTeX, A document preparation System}, Addison-Wesley,
+ 1986.
+ \bibitem{treebus} K.F. Treebus.
+ \emph{Tekstwijzer, een gids voor het grafisch verwerken van
+ tekst},
+ SDU Uitgeverij ('s-Gravenhage, 1988).
+ \bibitem{HP} Hubert Partl,
+ \emph{German \TeX},
+ \emph{TUGboat} 9 (1988) \#1, p.~70--72.
+ \bibitem{LLth} Leslie Lamport,
+ in: \TeX hax Digest, Volume 89, \#13, 17 February 1989.
+ \bibitem{BEP} Johannes Braams, Victor Eijkhout and Nico Poppelier,
+ \emph{The development of national \LaTeX\ styles},
+ \emph{TUGboat} 10 (1989) \#3, p.~401--406.
+ \bibitem{FE} Yannis Haralambous,
+ \emph{Fonts \& Encodings}, O'Reilly, 2007.
+ \bibitem{UE} Jukka K. Korpela,
+ \textit{Unicode Explained}, O'Reilly, 2006.
+ \bibitem{CJKV} Ken Lunde,
+ \textit{CJKV Information Processing}, O'Reilly, 2nd ed., 2009.
+ \bibitem{ilatex} Joachim Schrod,
+ \emph{International \LaTeX\ is ready to use},
+ \emph{TUGboat} 11 (1990) \#1, p.~87--90.
+ \bibitem{STS} Apostolos Syropoulos, Antonis Tsolomitis and Nick
+ Sofroniu,
+ \emph{Digital typography using \LaTeX},
+ Springer, 2002, p.~301--373.
+\end{thebibliography}
+\end{document}
+%</filedriver>
+%
+% \fi
+%
+% \changes{babel~3.9c}{2013/04/04}{Added the ``modifiers'' mechanism}
+% \changes{babel~3.9g}{2013/06/01}{bbplain merged}
+% \changes{babel~3.9k}{2014/03/23}{Code and doc reorganized, and some
+% minor enhancements}
+%
+%\begingroup
+% \catcode`<=\active%
+% \catcode`>=\active
+% \makeatletter
+% \gdef\MakePrivateLetters{%
+% \catcode`@=11\relax
+% \gdef<##1{\ifx##1@$\langle\langle$\bgroup\itshape\rmfamily
+% \expandafter\bblref
+% \else\string<##1\fi}%
+% \gdef\bblref##1@>{##1\/\egroup$\rangle\rangle$}}%
+% \global\let\check@percent\saved@check@percent
+%\endgroup
+%
+% \part{Source code}
+%
+% \babel{} is being developed incrementally, which means parts of the
+% code are under development and therefore incomplete. Only documented
+% features are considered complete. In other words, use \babel{} only
+% as documented (except, of course, if you want to explore and test
+% them -- you can post suggestions about multilingual issues to
+% |kadingira@tug.org| on |http://tug.org/mailman/listinfo/kadingira|).
+%
+% \section{Identification and loading of required files}
+%
+% \textit{Code documentation is still under revision.}
+%
+% The \babel{} package after unpacking consists of the following files:
+% \begin{description}
+% \itemsep=-\parskip
+% \item[switch.def] defines macros to set and switch languages.
+% \item[babel.def] defines the rest of macros. It has tow parts: a
+% generic one and a second one only for LaTeX{}.
+% \item[babel.sty] is the \LaTeX{} package, which set options and
+% load language styles.
+% \item[plain.def] defines some \LaTeX{} macros required by
+% \file{babel.def} and provides a few tools for Plain.
+% \item[hyphen.cfg] is the file to be used when generating the
+% formats to load hyphenation patterns. By default it also loads
+% \file{switch.def}.
+% \end{description}
+%
+% The \babel{} installer extends \textsf{docstrip} with a few
+% ``pseudo-guards'' to set ``variables'' used at installation time.
+% They are used with |<||@name@>| at the appropiated places in the
+% source code and shown below with
+% $\langle\langle$\textit{name}$\rangle\rangle$. That brings a little
+% bit of literate programming.
+%
+% \section{\texttt{locale} directory}
+%
+% A required component of \babel{} is a set of |ini| files
+% with basic definitions for about 200 languages. They are distributed
+% as a separate |zip| file, not packed as |dtx|. With them, babel
+% will fully support Unicode engines.
+
+% Most of them are essentially finished (except bugs and mistakes, of
+% course). Some of them are still incomplete (but they will be usable),
+% and there are some omissions (eg, Latin and polytonic Greek, and
+% there are no geographic areas in Spanish). Hindi, French, Occitan and
+% Breton will show a warning related to dates. Not all include LICR
+% variants.
+%
+% This is a preliminary documentation.
+%
+% |ini| files contain the actual data; |tex| files are currently just
+% proxies to the corresponding ini files.
+%
+% Most keys are self-explanatory.
+% \begin{description}
+% \itemsep=-\parskip
+% \item[charset] the encoding used in the ini file.
+% \item[version] of the ini file
+% \item[level] ``version'' of the ini specification . which keys are
+% available (they may grow in a compatible way) and how they should be
+% read.
+% \item[encodings] a descriptive list of font encondings.
+% \item[{[captions]}] section of captions in the file charset
+% \item[{[captions.licr]}] same, but in pure ASCII using the LICR
+% \item[date.long] fields are as in the CLDR, but the syntax is
+% different. Anything inside brackets is a date field (eg, |MMMM| for
+% the month name) and anything outside is text. In addition, |[ ]| is a
+% non breakable space and |[.]| is an abbreviation dot.
+% \end{description}
+%
+% Keys may be further qualified in a particular language with a suffix
+% starting with a uppercase letter. It can be just a letter (eg,
+% babel.name.A, babel.name.B) or a name (eg, date.long.Nominative,
+% date.long.Formal, but no language is currently using the latter).
+% Multi-letter qualifiers are forward compatible in the sense they
+% won’t conflict with new ``global'' keys (all lowercase).
+%
+% \section{Tools}
+%
+% \begin{macrocode}
+%<<version=3.33>>
+%<<date=2019/07/19>>
+% \end{macrocode}
+%
+% \textbf{Do not use the following macros in \texttt{ldf} files. They
+% may change in the future}. This applies mainly to those recently
+% added for replacing, trimming and looping. The older ones, like
+% |\bbl@afterfi|, will not change.
+%
+% \changes{babel~3.9t}{2017/04/22}{Added new helper macros. Not all are
+% currently used, but will be in 3.10 -- \cs{bbl@trim},
+% \cs{bbl@ifunset}, \cs{bbl@exp}, \cs{bbl@stripslash}}
+%
+% We define some basic macros which just make the code cleaner.
+% |\bbl@add| is now used internally instead of |\addto| because of
+% the unpredictable behavior of the latter. Used in
+% \file{babel.def} and in \file{babel.sty}, which means in \LaTeX{}
+% is executed twice, but we need them when defining options and
+% \file{babel.def} cannot be load until options have been defined.
+% This does not hurt, but should be fixed somehow.
+%
+% \changes{babel~3.9i}{2014/02/16}{\cs{@for} didn't work with
+% Plain. Added \cs{bbl@loop}}
+% \changes{babel~3.15}{2017/10/30}{New convenience macros
+% \cs{bbl@xin@} and \cs{bbl@cs}}
+%
+% \begin{macrocode}
+%<<*Basic macros>>
+\bbl@trace{Basic macros}
+\def\bbl@stripslash{\expandafter\@gobble\string}
+\def\bbl@add#1#2{%
+ \bbl@ifunset{\bbl@stripslash#1}%
+ {\def#1{#2}}%
+ {\expandafter\def\expandafter#1\expandafter{#1#2}}}
+\def\bbl@xin@{\@expandtwoargs\in@}
+\def\bbl@csarg#1#2{\expandafter#1\csname bbl@#2\endcsname}%
+\def\bbl@cs#1{\csname bbl@#1\endcsname}
+\def\bbl@loop#1#2#3{\bbl@@loop#1{#3}#2,\@nnil,}
+\def\bbl@loopx#1#2{\expandafter\bbl@loop\expandafter#1\expandafter{#2}}
+\def\bbl@@loop#1#2#3,{%
+ \ifx\@nnil#3\relax\else
+ \def#1{#3}#2\bbl@afterfi\bbl@@loop#1{#2}%
+ \fi}
+\def\bbl@for#1#2#3{\bbl@loopx#1{#2}{\ifx#1\@empty\else#3\fi}}
+% \end{macrocode}
+%
+% \changes{babel~3.9t}{2017/04/22}{Use \cs{bbl@ifunset} instead of
+% \cs{@ifundefined}.}
+%
+% \begin{macro}{\bbl@add@list}
+% This internal macro adds its second argument to a comma
+% separated list in its first argument. When the list is not
+% defined yet (or empty), it will be initiated. It presumes
+% expandable character strings.
+%
+% \changes{babel~3.9t}{2017/04/22}{Redefined to avoid infinite loops
+% if the macro is \cs{relax}.}
+%
+% \begin{macrocode}
+\def\bbl@add@list#1#2{%
+ \edef#1{%
+ \bbl@ifunset{\bbl@stripslash#1}%
+ {}%
+ {\ifx#1\@empty\else#1,\fi}%
+ #2}}
+% \end{macrocode}
+%
+% \end{macro}
+%
+% \begin{macro}{\bbl@afterelse}
+% \begin{macro}{\bbl@afterfi}
+% Because the code that is used in the handling of active
+% characters may need to look ahead, we take extra care to `throw'
+% it over the |\else| and |\fi| parts of an
+% |\if|-statement\footnote{This code is based on code presented in
+% TUGboat vol. 12, no2, June 1991 in ``An expansion Power Lemma''
+% by Sonja Maus.}. These macros will break if another |\if...\fi|
+% statement appears in one of the arguments and it is not enclosed
+% in braces.
+%
+% \begin{macrocode}
+\long\def\bbl@afterelse#1\else#2\fi{\fi#1}
+\long\def\bbl@afterfi#1\fi{\fi#1}
+% \end{macrocode}
+%
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\bbl@trim}
+% The following piece of code is stolen (with some changes) from
+% \textsf{keyval}, by David Carlisle. It defines two macros:
+% |\bbl@trim| and |\bbl@trim@def|. The first one strips the leading
+% and trailing spaces from the second argument and then applies the
+% first argument (a macro, |\toks@| and the like). The second one,
+% as its name suggests, defines the first argument as the stripped
+% second argument.
+%
+% \begin{macrocode}
+\def\bbl@tempa#1{%
+ \long\def\bbl@trim##1##2{%
+ \futurelet\bbl@trim@a\bbl@trim@c##2\@nil\@nil#1\@nil\relax{##1}}%
+ \def\bbl@trim@c{%
+ \ifx\bbl@trim@a\@sptoken
+ \expandafter\bbl@trim@b
+ \else
+ \expandafter\bbl@trim@b\expandafter#1%
+ \fi}%
+ \long\def\bbl@trim@b#1##1 \@nil{\bbl@trim@i##1}}
+\bbl@tempa{ }
+\long\def\bbl@trim@i#1\@nil#2\relax#3{#3{#1}}
+\long\def\bbl@trim@def#1{\bbl@trim{\def#1}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\bbl@ifunset}
+% To check if a macro is defined, we create a new macro, which does
+% the same as |\@ifundefined|. However, in an $\epsilon$-tex engine,
+% it is based on |\ifcsname|, which is more efficient, and do not
+% waste memory.
+%
+% \begin{macrocode}
+\def\bbl@ifunset#1{%
+ \expandafter\ifx\csname#1\endcsname\relax
+ \expandafter\@firstoftwo
+ \else
+ \expandafter\@secondoftwo
+ \fi}
+\bbl@ifunset{ifcsname}%
+ {}%
+ {\def\bbl@ifunset#1{%
+ \ifcsname#1\endcsname
+ \expandafter\ifx\csname#1\endcsname\relax
+ \bbl@afterelse\expandafter\@firstoftwo
+ \else
+ \bbl@afterfi\expandafter\@secondoftwo
+ \fi
+ \else
+ \expandafter\@firstoftwo
+ \fi}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\bbl@ifblank}
+% A tool from \textsf{url}, by Donald Arseneau, which tests if a
+% string is empty or space.
+%
+% \begin{macrocode}
+\def\bbl@ifblank#1{%
+ \bbl@ifblank@i#1\@nil\@nil\@secondoftwo\@firstoftwo\@nil}
+\long\def\bbl@ifblank@i#1#2\@nil#3#4#5\@nil{#4}
+% \end{macrocode}
+% \end{macro}
+%
+% For each element in the comma separated <key>|=|<value> list,
+% execute <code> with |#1| and |#2| as the key and the value of
+% current item (trimmed). In addition, the item is passed verbatim as
+% |#3|. With the <key> alone, it passes |\@empty| (ie, the macro thus
+% named, not an empty argument, which is what you get with <key>|=|
+% and no value).
+%
+% \begin{macrocode}
+\def\bbl@forkv#1#2{%
+ \def\bbl@kvcmd##1##2##3{#2}%
+ \bbl@kvnext#1,\@nil,}
+\def\bbl@kvnext#1,{%
+ \ifx\@nil#1\relax\else
+ \bbl@ifblank{#1}{}{\bbl@forkv@eq#1=\@empty=\@nil{#1}}%
+ \expandafter\bbl@kvnext
+ \fi}
+\def\bbl@forkv@eq#1=#2=#3\@nil#4{%
+ \bbl@trim@def\bbl@forkv@a{#1}%
+ \bbl@trim{\expandafter\bbl@kvcmd\expandafter{\bbl@forkv@a}}{#2}{#4}}
+% \end{macrocode}
+%
+% A \textit{for} loop. Each item (trimmed), is |#1|. It cannot be
+% nested (it's doable, but we don't need it).
+%
+% \begin{macrocode}
+\def\bbl@vforeach#1#2{%
+ \def\bbl@forcmd##1{#2}%
+ \bbl@fornext#1,\@nil,}
+\def\bbl@fornext#1,{%
+ \ifx\@nil#1\relax\else
+ \bbl@ifblank{#1}{}{\bbl@trim\bbl@forcmd{#1}}%
+ \expandafter\bbl@fornext
+ \fi}
+\def\bbl@foreach#1{\expandafter\bbl@vforeach\expandafter{#1}}
+% \end{macrocode}
+%
+% \begin{macro}{\bbl@replace}
+%
+% \begin{macrocode}
+\def\bbl@replace#1#2#3{% in #1 -> repl #2 by #3
+ \toks@{}%
+ \def\bbl@replace@aux##1#2##2#2{%
+ \ifx\bbl@nil##2%
+ \toks@\expandafter{\the\toks@##1}%
+ \else
+ \toks@\expandafter{\the\toks@##1#3}%
+ \bbl@afterfi
+ \bbl@replace@aux##2#2%
+ \fi}%
+ \expandafter\bbl@replace@aux#1#2\bbl@nil#2%
+ \edef#1{\the\toks@}}
+% \end{macrocode}
+%
+% An extensison to the previous macro. It takes into account the
+% parameters, and it is string based (ie, if you replace |elax| by
+% |ho|, then |\relax| becomes |\rho|). No checking is done at all,
+% because it is not a general purpose macro, and it is used by \babel{}
+% only when it works (an example where it does \textit{not} work is in
+% |\bbl@TG@@date|). It may change! (to add new features).
+%
+% \begin{macrocode}
+\expandafter\def\expandafter\bbl@parsedef\detokenize{macro:}#1->#2\relax{%
+ \def\bbl@tempa{#1}%
+ \def\bbl@tempb{#2}}
+\def\bbl@sreplace#1#2#3{%
+ \begingroup
+ \expandafter\bbl@parsedef\meaning#1\relax
+ \def\bbl@tempc{#2}%
+ \edef\bbl@tempc{\expandafter\strip@prefix\meaning\bbl@tempc}%
+ \def\bbl@tempd{#3}%
+ \edef\bbl@tempd{\expandafter\strip@prefix\meaning\bbl@tempd}%
+ \bbl@exp{\\\bbl@replace\\\bbl@tempb{\bbl@tempc}{\bbl@tempd}}%
+ \bbl@exp{%
+ \endgroup
+ \\\makeatletter % "internal" macros with @ are assumed
+ \\\scantokens{\def\\#1\bbl@tempa{\bbl@tempb}}%
+ \catcode64=\the\catcode64\relax}} % Restore @
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\bbl@exp}
+%
+% Now, just syntactical sugar, but it makes partial expansion of
+% some code a lot more simple and readable. Here |\\| stands for
+% |\noexpand| and |\<..>| for |\noexpand| applied to a built macro
+% name (the latter does not define the macro if undefined to
+% |\relax|, because it is created locally). The result may be
+% followed by extra arguments, if necessary.
+%
+% \begin{macrocode}
+\def\bbl@exp#1{%
+ \begingroup
+ \let\\\noexpand
+ \def\<##1>{\expandafter\noexpand\csname##1\endcsname}%
+ \edef\bbl@exp@aux{\endgroup#1}%
+ \bbl@exp@aux}
+% \end{macrocode}
+% \end{macro}
+%
+% Two further tools. |\bbl@samestring| first expand its arguments and
+% then compare their expansion (sanitized, so that the catcodes do not
+% matter). |\bbl@engine| takes the following values: 0 is pdf\TeX, 1
+% is \luatex, and 2 is \xetex. You may use the latter it in your
+% language style if you want.
+%
+% \begin{macrocode}
+\def\bbl@ifsamestring#1#2{%
+ \begingroup
+ \protected@edef\bbl@tempb{#1}%
+ \edef\bbl@tempb{\expandafter\strip@prefix\meaning\bbl@tempb}%
+ \protected@edef\bbl@tempc{#2}%
+ \edef\bbl@tempc{\expandafter\strip@prefix\meaning\bbl@tempc}%
+ \ifx\bbl@tempb\bbl@tempc
+ \aftergroup\@firstoftwo
+ \else
+ \aftergroup\@secondoftwo
+ \fi
+ \endgroup}
+\chardef\bbl@engine=%
+ \ifx\directlua\@undefined
+ \ifx\XeTeXinputencoding\@undefined
+ \z@
+ \else
+ \tw@
+ \fi
+ \else
+ \@ne
+ \fi
+%<</Basic macros>>
+% \end{macrocode}
+%
+% Some files identify themselves with a \LaTeX{} macro. The following
+% code is placed before them to define (and then undefine) if not in
+% \LaTeX.
+%
+% \begin{macrocode}
+%<<*Make sure ProvidesFile is defined>>
+\ifx\ProvidesFile\@undefined
+ \def\ProvidesFile#1[#2 #3 #4]{%
+ \wlog{File: #1 #4 #3 <#2>}%
+ \let\ProvidesFile\@undefined}
+\fi
+%<</Make sure ProvidesFile is defined>>
+% \end{macrocode}
+%
+% The following code is used in \file{babel.sty} and
+% \file{babel.def}, and loads (only once) the data in |language.dat|.
+%
+% \begin{macrocode}
+%<<*Load patterns in luatex>>
+\ifx\directlua\@undefined\else
+ \ifx\bbl@luapatterns\@undefined
+ \input luababel.def
+ \fi
+\fi
+%<</Load patterns in luatex>>
+% \end{macrocode}
+%
+% The following code is used in \file{babel.def} and
+% \file{switch.def}.
+%
+% \begin{macrocode}
+%<<*Load macros for plain if not LaTeX>>
+\ifx\AtBeginDocument\@undefined
+ \input plain.def\relax
+\fi
+%<</Load macros for plain if not LaTeX>>
+% \end{macrocode}
+%
+% \subsection{Multiple languages}
+%
+% \begin{macro}{\language}
+% Plain \TeX\ version~3.0 provides the primitive |\language| that
+% is used to store the current language. When used with a pre-3.0
+% version this function has to be implemented by allocating a
+% counter. The following block is used in \file{switch.def} and
+% \file{hyphen.cfg}; the latter may seem redundant, but remember
+% \babel{} doesn't requires loading \file{switch.def} in the format.
+%
+% \begin{macrocode}
+%<<*Define core switching macros>>
+\ifx\language\@undefined
+ \csname newcount\endcsname\language
+\fi
+%<</Define core switching macros>>
+% \end{macrocode}
+%
+% \end{macro}
+%
+% \begin{macro}{\last@language}
+% Another counter is used to store the last language defined. For
+% pre-3.0 formats an extra counter has to be allocated.
+%
+% \begin{macro}{\addlanguage}
+%
+% To add languages to \TeX's memory plain \TeX\ version~3.0
+% supplies |\newlanguage|, in a pre-3.0 environment a similar macro
+% has to be provided. For both cases a new macro is defined here,
+% because the original |\newlanguage| was defined to be |\outer|.
+%
+% For a format based on plain version~2.x, the definition of
+% |\newlanguage| can not be copied because |\count 19| is used for
+% other purposes in these formats. Therefore |\addlanguage| is
+% defined using a definition based on the macros used to define
+% |\newlanguage| in plain \TeX\ version~3.0.
+%
+% For formats based on plain version~3.0 the definition of
+% |\newlanguage| can be simply copied, removing |\outer|.
+% Plain \TeX\ version 3.0 uses |\count 19| for this purpose.
+%
+% \begin{macrocode}
+%<<*Define core switching macros>>
+\ifx\newlanguage\@undefined
+ \csname newcount\endcsname\last@language
+ \def\addlanguage#1{%
+ \global\advance\last@language\@ne
+ \ifnum\last@language<\@cclvi
+ \else
+ \errmessage{No room for a new \string\language!}%
+ \fi
+ \global\chardef#1\last@language
+ \wlog{\string#1 = \string\language\the\last@language}}
+\else
+ \countdef\last@language=19
+ \def\addlanguage{\alloc@9\language\chardef\@cclvi}
+\fi
+%<</Define core switching macros>>
+% \end{macrocode}
+%
+% \end{macro}
+% \end{macro}
+%
+% Now we make sure all required files are loaded. When the command
+% |\AtBeginDocument| doesn't exist we assume that we are dealing
+% with a plain-based format or \LaTeX2.09. In that case the file
+% \file{plain.def} is needed (which also defines
+% |\AtBeginDocument|, and therefore it is not loaded twice). We
+% need the first part when the format is created, and |\orig@dump|
+% is used as a flag. Otherwise, we need to use the second part, so
+% |\orig@dump| is not defined (\file{plain.def} undefines it).
+%
+% \changes{babel~3.9a}{2012/12/21}{Use \cs{orig@dump} as flag instead
+% of \cs{adddialect}}
+%
+% Check if the current version of \file{switch.def} has been
+% previously loaded (mainly, \file{hyphen.cfg}). If not, load it
+% now. We cannot load |babel.def| here because we first need to
+% declare and process the package options.
+%
+% \changes{babel~3.9a}{2012/08/11}{Now switch.def is loaded always, so
+% that there is no need to rebuild formats just to update babel}
+% \changes{babel~3.9a}{2012/12/13}{But switch.def is loaded only if
+% loaded in a different version (or not loaded)}
+% \changes{babel~3.9a}{2013/01/14}{Added the debug option}
+% \changes{babel~3.9a}{2013/02/05}{Added \cs{bbl@add}}
+%
+% \section{The Package File (\LaTeX, \texttt{babel.sty})}
+%
+% In order to make use of the features of \LaTeXe, the \babel\
+% system contains a package file, \file{babel.sty}. This file is
+% loaded by the |\usepackage| command and defines all the language
+% options whose name is different from that of the |.ldf| file
+% (like variant spellings). It also takes care of a number of
+% compatibility issues with other packages an defines a few
+% aditional package options.
+%
+% Apart from all the language options below we also have a few options
+% that influence the behavior of language definition files.
+%
+% Many of the following options don't do anything themselves, they
+% are just defined in order to make it possible for babel and
+% language definition files to check if one of them was specified
+% by the user.
+%
+% \subsection{\texttt{base}}
+%
+% The first option to be processed is |base|, which set the
+% hyphenation patterns then resets |ver@babel.sty| so that
+% \LaTeX forgets about the first loading. After |switch.def| has
+% been loaded (above) and |\AfterBabelLanguage| defined, exits.
+%
+% \changes{babel~3.9a}{2012/10/05}{preset option started,
+% party stolen from fontenc}
+% \changes{babel~3.9a}{2012/10/17}{Hooks started}
+% \changes{babel~3.9a}{2013/02/07}{Rejected preset, and replaced by
+% base}
+% \changes{babel~3.9q}{2016/02/11}{Load patterns with option base.
+% To be improved. Moved showlanguages before base}
+% \changes{babel~3.18}{2018/02/14}{Fix - prevent doble input of
+% switch.def}
+% \changes{babel~3.19}{2018/04/23}{Split callback - vertical and
+% horizontal}
+% \changes{babel~3.19}{2018/04/23}{Added bidi=basic, here and passim}
+%
+% \begin{macrocode}
+%<*package>
+\NeedsTeXFormat{LaTeX2e}[2005/12/01]
+\ProvidesPackage{babel}[<@date@> <@version@> The Babel package]
+\@ifpackagewith{babel}{debug}
+ {\providecommand\bbl@trace[1]{\message{^^J[ #1 ]}}%
+ \let\bbl@debug\@firstofone}
+ {\providecommand\bbl@trace[1]{}%
+ \let\bbl@debug\@gobble}
+\ifx\bbl@switchflag\@undefined % Prevent double input
+ \let\bbl@switchflag\relax
+ \input switch.def\relax
+\fi
+<@Load patterns in luatex@>
+<@Basic macros@>
+\def\AfterBabelLanguage#1{%
+ \global\expandafter\bbl@add\csname#1.ldf-h@@k\endcsname}%
+% \end{macrocode}
+%
+% If the format created a list of loaded languages (in
+% |\bbl@languages|), get the name of the 0-th to show the actual
+% language used.
+%
+% \changes{babel~3.30}{2019/04/22}{Callbacks aren't specific to
+% bidi any more, so they are moved.}
+% \changes{babel~3.32}{2019/05/30}{Consider Harf.}
+%
+% \begin{macrocode}
+\ifx\bbl@languages\@undefined\else
+ \begingroup
+ \catcode`\^^I=12
+ \@ifpackagewith{babel}{showlanguages}{%
+ \begingroup
+ \def\bbl@elt#1#2#3#4{\wlog{#2^^I#1^^I#3^^I#4}}%
+ \wlog{<*languages>}%
+ \bbl@languages
+ \wlog{</languages>}%
+ \endgroup}{}
+ \endgroup
+ \def\bbl@elt#1#2#3#4{%
+ \ifnum#2=\z@
+ \gdef\bbl@nulllanguage{#1}%
+ \def\bbl@elt##1##2##3##4{}%
+ \fi}%
+ \bbl@languages
+\fi
+\ifodd\bbl@engine
+ % Harftex is evolving, so the callback is not harcoded, just in case
+ \def\bbl@harfpreline{Harf pre_linebreak_filter callback}%
+ \def\bbl@activate@preotf{%
+ \let\bbl@activate@preotf\relax % only once
+ \directlua{
+ Babel = Babel or {}
+ %
+ function Babel.pre_otfload_v(head)
+ if Babel.numbers and Babel.digits_mapped then
+ head = Babel.numbers(head)
+ end
+ if Babel.bidi_enabled then
+ head = Babel.bidi(head, false, dir)
+ end
+ return head
+ end
+ %
+ function Babel.pre_otfload_h(head, gc, sz, pt, dir)
+ if Babel.numbers and Babel.digits_mapped then
+ head = Babel.numbers(head)
+ end
+ if Babel.fixboxdirs then % Temporary!
+ head = Babel.fixboxdirs(head)
+ end
+ if Babel.bidi_enabled then
+ head = Babel.bidi(head, false, dir)
+ end
+ return head
+ end
+ %
+ luatexbase.add_to_callback('pre_linebreak_filter',
+ Babel.pre_otfload_v,
+ 'Babel.pre_otfload_v',
+ luatexbase.priority_in_callback('pre_linebreak_filter',
+ '\bbl@harfpreline')
+ or luatexbase.priority_in_callback('pre_linebreak_filter',
+ 'luaotfload.node_processor')
+ or nil)
+ %
+ luatexbase.add_to_callback('hpack_filter',
+ Babel.pre_otfload_h,
+ 'Babel.pre_otfload_h',
+ luatexbase.priority_in_callback('hpack_filter',
+ '\bbl@harfpreline')
+ or luatexbase.priority_in_callback('hpack_filter',
+ 'luaotfload.node_processor')
+ or nil)
+ }%
+ \@ifpackageloaded{harfload}%
+ {\directlua{ Babel.mirroring_enabled = false }}%
+ {}}
+ \let\bbl@tempa\relax
+ \@ifpackagewith{babel}{bidi=basic}%
+ {\def\bbl@tempa{basic}}%
+ {\@ifpackagewith{babel}{bidi=basic-r}%
+ {\def\bbl@tempa{basic-r}}%
+ {}}
+ \ifx\bbl@tempa\relax\else
+ \let\bbl@beforeforeign\leavevmode
+ \AtEndOfPackage{\EnableBabelHook{babel-bidi}}%
+ \RequirePackage{luatexbase}%
+ \directlua{
+ require('babel-data-bidi.lua')
+ require('babel-bidi-\bbl@tempa.lua')
+ }
+ \bbl@activate@preotf
+ \fi
+\fi
+% \end{macrocode}
+%
+% Now the \texttt{base} option. With it we can define (and load, with
+% \luatex) hyphenation patterns, even if we are not interesed in the
+% rest of babel. Useful for old versions of \textsf{polyglossia}, too.
+%
+% \begin{macrocode}
+\bbl@trace{Defining option 'base'}
+\@ifpackagewith{babel}{base}{%
+ \ifx\directlua\@undefined
+ \DeclareOption*{\bbl@patterns{\CurrentOption}}%
+ \else
+ \DeclareOption*{\bbl@patterns@lua{\CurrentOption}}%
+ \fi
+ \DeclareOption{base}{}%
+ \DeclareOption{showlanguages}{}%
+ \ProcessOptions
+ \global\expandafter\let\csname opt@babel.sty\endcsname\relax
+ \global\expandafter\let\csname ver@babel.sty\endcsname\relax
+ \global\let\@ifl@ter@@\@ifl@ter
+ \def\@ifl@ter#1#2#3#4#5{\global\let\@ifl@ter\@ifl@ter@@}%
+ \endinput}{}%
+% \end{macrocode}
+%
+% \subsection{\texttt{key=value} options and other general option}
+%
+% The following macros extract language modifiers, and only real
+% package options are kept in the option list. Modifiers are saved
+% and assigned to |\BabelModifiers| at |\bbl@load@language|; when
+% no modifiers have been given, the former is |\relax|. How
+% modifiers are handled are left to language styles; they can use
+% |\in@|, loop them with |\@for| or load |keyval|, for example.
+%
+% \changes{babel~3.9e}{2013/04/15}{Bug fixed - a dot was added in
+% key=value pairs}
+%
+% \begin{macrocode}
+\bbl@trace{key=value and another general options}
+\bbl@csarg\let{tempa\expandafter}\csname opt@babel.sty\endcsname
+\def\bbl@tempb#1.#2{%
+ #1\ifx\@empty#2\else,\bbl@afterfi\bbl@tempb#2\fi}%
+\def\bbl@tempd#1.#2\@nnil{%
+ \ifx\@empty#2%
+ \edef\bbl@tempc{\ifx\bbl@tempc\@empty\else\bbl@tempc,\fi#1}%
+ \else
+ \in@{=}{#1}\ifin@
+ \edef\bbl@tempc{\ifx\bbl@tempc\@empty\else\bbl@tempc,\fi#1.#2}%
+ \else
+ \edef\bbl@tempc{\ifx\bbl@tempc\@empty\else\bbl@tempc,\fi#1}%
+ \bbl@csarg\edef{mod@#1}{\bbl@tempb#2}%
+ \fi
+ \fi}
+\let\bbl@tempc\@empty
+\bbl@foreach\bbl@tempa{\bbl@tempd#1.\@empty\@nnil}
+\expandafter\let\csname opt@babel.sty\endcsname\bbl@tempc
+% \end{macrocode}
+%
+% The next option tells \babel\ to leave shorthand characters active
+% at the end of processing the package. This is \emph{not} the default
+% as it can cause problems with other packages, but for those who want
+% to use the shorthand characters in the preamble of their documents
+% this can help.
+%
+% \changes{babel~3.9a}{2012/08/14}{Implemented the \texttt{noconfigs}
+% option}
+% \changes{babel~3.9a}{2012/09/26}{Implemented the
+% \texttt{showlanguages} option}
+% \changes{babel~3.9g}{2013/08/07}{Options for hyphenmap}
+% \changes{babel~3.9l}{2014/07/29}{Option \texttt{silent}}
+%
+% \begin{macrocode}
+\DeclareOption{KeepShorthandsActive}{}
+\DeclareOption{activeacute}{}
+\DeclareOption{activegrave}{}
+\DeclareOption{debug}{}
+\DeclareOption{noconfigs}{}
+\DeclareOption{showlanguages}{}
+\DeclareOption{silent}{}
+\DeclareOption{mono}{}
+\DeclareOption{shorthands=off}{\bbl@tempa shorthands=\bbl@tempa}
+<@More package options@>
+% \end{macrocode}
+%
+% Handling of package options is done in three passes. (I [JBL] am not
+% very happy with the idea, anyway.) The first one processes options
+% which has been declared above or follow the syntax |<key>=<value>|,
+% the second one loads the requested languages, except the main one if
+% set with the key |main|, and the third one loads the latter. First,
+% we ``flag'' valid keys with a nil value.
+%
+% \changes{babel~3.9a}{2012/08/10}{Added the `safe' key, including code
+% below for selecting the redefined macros}
+%
+% \begin{macrocode}
+\let\bbl@opt@shorthands\@nnil
+\let\bbl@opt@config\@nnil
+\let\bbl@opt@main\@nnil
+\let\bbl@opt@headfoot\@nnil
+\let\bbl@opt@layout\@nnil
+% \end{macrocode}
+%
+% The following tool is defined temporarily to store the values of
+% options.
+%
+% \begin{macrocode}
+\def\bbl@tempa#1=#2\bbl@tempa{%
+ \bbl@csarg\ifx{opt@#1}\@nnil
+ \bbl@csarg\edef{opt@#1}{#2}%
+ \else
+ \bbl@error{%
+ Bad option `#1=#2'. Either you have misspelled the\\%
+ key or there is a previous setting of `#1'}{%
+ Valid keys are `shorthands', `config', `strings', `main',\\%
+ `headfoot', `safe', `math', among others.}
+ \fi}
+% \end{macrocode}
+%
+% Now the option list is processed, taking into account only currently
+% declared options (including those declared with a |=|), and
+% |<key>=<value>| options (the former take precedence). Unrecognized
+% options are saved in |\bbl@language@opts|, because they are language
+% options.
+%
+% \begin{macrocode}
+\let\bbl@language@opts\@empty
+\DeclareOption*{%
+ \bbl@xin@{\string=}{\CurrentOption}%
+ \ifin@
+ \expandafter\bbl@tempa\CurrentOption\bbl@tempa
+ \else
+ \bbl@add@list\bbl@language@opts{\CurrentOption}%
+ \fi}
+% \end{macrocode}
+%
+% Now we finish the first pass (and start over).
+%
+% \begin{macrocode}
+\ProcessOptions*
+% \end{macrocode}
+%
+% \subsection{Conditional loading of shorthands}
+%
+% If there is no |shorthands=<chars>|, the original \textsf{babel}
+% macros are left untouched, but if there is, these macros are
+% wrapped (in |babel.def|) to define only those given.
+%
+% A bit of optimization: if there is no |shorthands=|, then
+% |\bbl@ifshorthand| is always true, and it is always false if
+% |shorthands| is empty. Also, some code makes sense only with
+% |shorthands=...|.
+%
+% \changes{babel~3.9c}{2013/04/07}{Added t and c for tilde and comma}
+%
+% \begin{macrocode}
+\bbl@trace{Conditional loading of shorthands}
+\def\bbl@sh@string#1{%
+ \ifx#1\@empty\else
+ \ifx#1t\string~%
+ \else\ifx#1c\string,%
+ \else\string#1%
+ \fi\fi
+ \expandafter\bbl@sh@string
+ \fi}
+\ifx\bbl@opt@shorthands\@nnil
+ \def\bbl@ifshorthand#1#2#3{#2}%
+\else\ifx\bbl@opt@shorthands\@empty
+ \def\bbl@ifshorthand#1#2#3{#3}%
+\else
+% \end{macrocode}
+%
+% The following macro tests if a shorthand is one of the allowed
+% ones.
+%
+% \begin{macrocode}
+ \def\bbl@ifshorthand#1{%
+ \bbl@xin@{\string#1}{\bbl@opt@shorthands}%
+ \ifin@
+ \expandafter\@firstoftwo
+ \else
+ \expandafter\@secondoftwo
+ \fi}
+% \end{macrocode}
+%
+% We make sure all chars in the string are `other', with the help
+% of an auxiliary macro defined above (which also zaps spaces).
+%
+% \begin{macrocode}
+ \edef\bbl@opt@shorthands{%
+ \expandafter\bbl@sh@string\bbl@opt@shorthands\@empty}%
+% \end{macrocode}
+%
+% The following is ignored with |shorthands=off|, since it is
+% intended to take some aditional actions for certain chars.
+%
+% \begin{macrocode}
+ \bbl@ifshorthand{'}%
+ {\PassOptionsToPackage{activeacute}{babel}}{}
+ \bbl@ifshorthand{`}%
+ {\PassOptionsToPackage{activegrave}{babel}}{}
+\fi\fi
+% \end{macrocode}
+%
+% \changes{babel~3.9a}{2012/07/30}{Code setting language in
+% head/foots. Related to babel/3796}
+%
+% With |headfoot=lang| we can set the language used in heads/foots.
+% For example, in babel/3796 just adds |headfoot=english|. It
+% misuses \cs{@resetactivechars} but seems to work.
+%
+% \begin{macrocode}
+\ifx\bbl@opt@headfoot\@nnil\else
+ \g@addto@macro\@resetactivechars{%
+ \set@typeset@protect
+ \expandafter\select@language@x\expandafter{\bbl@opt@headfoot}%
+ \let\protect\noexpand}
+\fi
+% \end{macrocode}
+%
+% For the option safe we use a different approach -- |\bbl@opt@safe|
+% says which macros are redefined (B for bibs and R for refs). By
+% default, both are set.
+%
+% \begin{macrocode}
+\ifx\bbl@opt@safe\@undefined
+ \def\bbl@opt@safe{BR}
+\fi
+\ifx\bbl@opt@main\@nnil\else
+ \edef\bbl@language@opts{%
+ \ifx\bbl@language@opts\@empty\else\bbl@language@opts,\fi
+ \bbl@opt@main}
+\fi
+% \end{macrocode}
+%
+% For |layout| an auxiliary macro is provided, available for packages
+% and language styles.
+%
+% \changes{babel~3.16}{2018/01/02}{Added the basic layout stuff and the
+% macro \cs{IfBabelLayout}}
+%
+% \begin{macrocode}
+\bbl@trace{Defining IfBabelLayout}
+\ifx\bbl@opt@layout\@nnil
+ \newcommand\IfBabelLayout[3]{#3}%
+\else
+ \newcommand\IfBabelLayout[1]{%
+ \@expandtwoargs\in@{.#1.}{.\bbl@opt@layout.}%
+ \ifin@
+ \expandafter\@firstoftwo
+ \else
+ \expandafter\@secondoftwo
+ \fi}
+\fi
+% \end{macrocode}
+%
+% \subsection{Language options}
+%
+% \changes{babel~3.9a}{2012/06/15}{Rewritten the loading mechanism, so
+% that languages not declared are also correctly recognized, even
+% if given as global options}
+% \changes{babel~3.9a}{2012/08/12}{Revised the loading mechanism}
+% \changes{babel~3.9i}{2014/03/01}{Removed German options, because
+% they are now loaded directly}
+%
+% Languages are loaded when processing the corresponding option
+% \textit{except} if a |main| language has been set. In such a
+% case, it is not loaded until all options has been processed.
+% The following macro inputs the ldf file and does some additional
+% checks (|\input| works, too, but possible errors are not catched).
+%
+% \begin{macrocode}
+\bbl@trace{Language options}
+\let\bbl@afterlang\relax
+\let\BabelModifiers\relax
+\let\bbl@loaded\@empty
+\def\bbl@load@language#1{%
+ \InputIfFileExists{#1.ldf}%
+ {\edef\bbl@loaded{\CurrentOption
+ \ifx\bbl@loaded\@empty\else,\bbl@loaded\fi}%
+ \expandafter\let\expandafter\bbl@afterlang
+ \csname\CurrentOption.ldf-h@@k\endcsname
+ \expandafter\let\expandafter\BabelModifiers
+ \csname bbl@mod@\CurrentOption\endcsname}%
+ {\bbl@error{%
+ Unknown option `\CurrentOption'. Either you misspelled it\\%
+ or the language definition file \CurrentOption.ldf was not found}{%
+ Valid options are: shorthands=, KeepShorthandsActive,\\%
+ activeacute, activegrave, noconfigs, safe=, main=, math=\\%
+ headfoot=, strings=, config=, hyphenmap=, or a language name.}}}
+% \end{macrocode}
+%
+% Now, we set language options whose names are different from |ldf| files.
+%
+% \changes{babel~3.9t}{2017/04/23}{Removed options for English, Indonesian and
+% Malay, now handled with proxy files}
+% \changes{babel~3.13}{2017/08/24}{Removed options for French,
+% too. ldf files now takes priority if exist, except Hebrew (to do)}
+%
+% \begin{macrocode}
+\def\bbl@try@load@lang#1#2#3{%
+ \IfFileExists{\CurrentOption.ldf}%
+ {\bbl@load@language{\CurrentOption}}%
+ {#1\bbl@load@language{#2}#3}}
+\DeclareOption{afrikaans}{\bbl@try@load@lang{}{dutch}{}}
+\DeclareOption{brazil}{\bbl@try@load@lang{}{portuges}{}}
+\DeclareOption{brazilian}{\bbl@try@load@lang{}{portuges}{}}
+\DeclareOption{hebrew}{%
+ \input{rlbabel.def}%
+ \bbl@load@language{hebrew}}
+\DeclareOption{hungarian}{\bbl@try@load@lang{}{magyar}{}}
+\DeclareOption{lowersorbian}{\bbl@try@load@lang{}{lsorbian}{}}
+\DeclareOption{nynorsk}{\bbl@try@load@lang{}{norsk}{}}
+\DeclareOption{polutonikogreek}{%
+ \bbl@try@load@lang{}{greek}{\languageattribute{greek}{polutoniko}}}
+\DeclareOption{portuguese}{\bbl@try@load@lang{}{portuges}{}}
+\DeclareOption{russian}{\bbl@try@load@lang{}{russianb}{}}
+\DeclareOption{ukrainian}{\bbl@try@load@lang{}{ukraineb}{}}
+\DeclareOption{uppersorbian}{\bbl@try@load@lang{}{usorbian}{}}
+% \end{macrocode}
+%
+% Another way to extend the list of `known' options for \babel\ was
+% to create the file \file{bblopts.cfg} in which one can add option
+% declarations. However, this mechanism is deprecated -- if you
+% want an alternative name for a language, just create a new |.ldf|
+% file loading the actual one. You can also set the name
+% of the file with the package option |config=<name>|, which will
+% load |<name>.cfg| instead.
+%
+% \changes{babel~3.9a}{2012/06/28}{Added the \cs{AfterBabelLanguage}
+% mechanism, to be used mainly with the local cfg file.}
+% \changes{babel~3.9a}{2012/06/31}{Now you can set the name of the
+% local cfg file.}
+%
+% \begin{macrocode}
+\ifx\bbl@opt@config\@nnil
+ \@ifpackagewith{babel}{noconfigs}{}%
+ {\InputIfFileExists{bblopts.cfg}%
+ {\typeout{*************************************^^J%
+ * Local config file bblopts.cfg used^^J%
+ *}}%
+ {}}%
+\else
+ \InputIfFileExists{\bbl@opt@config.cfg}%
+ {\typeout{*************************************^^J%
+ * Local config file \bbl@opt@config.cfg used^^J%
+ *}}%
+ {\bbl@error{%
+ Local config file `\bbl@opt@config.cfg' not found}{%
+ Perhaps you misspelled it.}}%
+\fi
+% \end{macrocode}
+%
+% Recognizing global options in packages not having a closed set of
+% them is not trivial, as for them to be processed they must be
+% defined explicitly. So, package options not yet taken into
+% account and stored in |bbl@language@opts| are assumed to be
+% languages (note this list also contains the language given with
+% |main|). If not declared above, the name of the option and the
+% file are the same.
+%
+% \begin{macrocode}
+\bbl@for\bbl@tempa\bbl@language@opts{%
+ \bbl@ifunset{ds@\bbl@tempa}%
+ {\edef\bbl@tempb{%
+ \noexpand\DeclareOption
+ {\bbl@tempa}%
+ {\noexpand\bbl@load@language{\bbl@tempa}}}%
+ \bbl@tempb}%
+ \@empty}
+% \end{macrocode}
+%
+% Now, we make sure an option is explicitly declared for any
+% language set as global option, by checking if an |ldf|
+% exists. The previous step was, in fact, somewhat redundant, but
+% that way we minimize accesing the file system just to see if the
+% option could be a language.
+%
+% \begin{macrocode}
+\bbl@foreach\@classoptionslist{%
+ \bbl@ifunset{ds@#1}%
+ {\IfFileExists{#1.ldf}%
+ {\DeclareOption{#1}{\bbl@load@language{#1}}}%
+ {}}%
+ {}}
+% \end{macrocode}
+%
+% If a main language has been set, store it for the third pass.
+%
+% \begin{macrocode}
+\ifx\bbl@opt@main\@nnil\else
+ \expandafter
+ \let\expandafter\bbl@loadmain\csname ds@\bbl@opt@main\endcsname
+ \DeclareOption{\bbl@opt@main}{}
+\fi
+% \end{macrocode}
+%
+% And we are done, because all options for this pass has been
+% declared. Those already processed in the first pass are just
+% ignored.
+%
+% \changes{babel~3.9a}{2012/12/22}{Default option does nothing}
+%
+% The options have to be processed in the order in which the user
+% specified them (except, of course, global options, which \LaTeX{}
+% processes before):
+%
+% \begin{macrocode}
+\def\AfterBabelLanguage#1{%
+ \bbl@ifsamestring\CurrentOption{#1}{\global\bbl@add\bbl@afterlang}{}}
+\DeclareOption*{}
+\ProcessOptions*
+% \end{macrocode}
+%
+% This finished the second pass. Now the third one begins, which
+% loads the main language set with the key |main|. A warning is
+% raised if the main language is not the same as the last named
+% one, or if the value of the key |main| is not a language. Then
+% execute directly the option (because it could be used only in
+% |main|). After loading all languages, we deactivate
+% |\AfterBabelLanguage|.
+%
+% \begin{macrocode}
+\ifx\bbl@opt@main\@nnil
+ \edef\bbl@tempa{\@classoptionslist,\bbl@language@opts}
+ \let\bbl@tempc\@empty
+ \bbl@for\bbl@tempb\bbl@tempa{%
+ \bbl@xin@{,\bbl@tempb,}{,\bbl@loaded,}%
+ \ifin@\edef\bbl@tempc{\bbl@tempb}\fi}
+ \def\bbl@tempa#1,#2\@nnil{\def\bbl@tempb{#1}}
+ \expandafter\bbl@tempa\bbl@loaded,\@nnil
+ \ifx\bbl@tempb\bbl@tempc\else
+ \bbl@warning{%
+ Last declared language option is `\bbl@tempc',\\%
+ but the last processed one was `\bbl@tempb'.\\%
+ The main language cannot be set as both a global\\%
+ and a package option. Use `main=\bbl@tempc' as\\%
+ option. Reported}%
+ \fi
+\else
+ \DeclareOption{\bbl@opt@main}{\bbl@loadmain}
+ \ExecuteOptions{\bbl@opt@main}
+ \DeclareOption*{}
+ \ProcessOptions*
+\fi
+\def\AfterBabelLanguage{%
+ \bbl@error
+ {Too late for \string\AfterBabelLanguage}%
+ {Languages have been loaded, so I can do nothing}}
+% \end{macrocode}
+%
+% In order to catch the case where the user forgot to specify a
+% language we check whether |\bbl@main@language|, has become
+% defined. If not, no language has been loaded and an error
+% message is displayed.
+%
+% \changes{babel~3.9a}{2012/06/24}{Now babel is not loaded to prevent
+% the document from raising errors after fixing it}
+% \changes{babel~3.21}{2018/05/09}{Requesting a language is no required
+% any more, in case you only need \cs{babelprovide}.}
+%
+% \begin{macrocode}
+\ifx\bbl@main@language\@undefined
+ \bbl@info{%
+ You haven't specified a language. I'll use 'nil'\\%
+ as the main language. Reported}
+ \bbl@load@language{nil}
+\fi
+%</package>
+%<*core>
+% \end{macrocode}
+%
+% \section{The kernel of Babel (\texttt{babel.def}, common)}
+%
+% The kernel of the \babel\ system is stored in either
+% \file{hyphen.cfg} or \file{switch.def} and \file{babel.def}. The
+% file \file{babel.def} contains most of the code, while
+% \file{switch.def} defines the language switching commands; both can
+% be read at run time. The file \file{hyphen.cfg} is a file that can
+% be loaded into the format, which is necessary when you want to be
+% able to switch hyphenation patterns (by default, it also inputs
+% \file{switch.def}, for ``historical reasons'', but it is not
+% necessary). When \file{babel.def} is loaded it checks if the current
+% version of \file{switch.def} is in the format; if not, it is
+% loaded. A further file, \file{babel.sty}, contains \LaTeX-specific
+% stuff.
+%
+% Because plain \TeX\ users might want to use some of the features of
+% the \babel{} system too, care has to be taken that plain \TeX\ can
+% process the files. For this reason the current format will have to
+% be checked in a number of places. Some of the code below is common
+% to plain \TeX\ and \LaTeX, some of it is for the \LaTeX\ case only.
+%
+% Plain formats based on etex (etex, xetex, luatex) don't load
+% |hyphen.cfg| but |etex.src|, which follows a different naming
+% convention, so we need to define the babel names. It presumes
+% |language.def| exists and it is the same file used when formats were
+% created.
+%
+% \changes{babel~3.9a}{2013/01/11}{Added \cs{bbl@for} for loops
+% ignoring empties}
+% \changes{babel~3.9c}{2013/04/06}{Normalize \cs{bbl@afterlang} to
+% relax}
+% \changes{babel~3.9i}{2014/03/10}{Make sure \cs{bbl@language@opts}
+% is defined.}
+% \changes{babel~3.9i}{2014/03/11}{Define \cs{l@} values from
+% \cs{lang@} values set in Plain etex/xetex/luatex}
+%
+% \subsection{Tools}
+%
+% \changes{babel~3.9k}{2014/03/24}{Added definition for
+% \cs{uselanguage}}
+% \changes{babel~3.9n}{2015/12/21}{Define a few macros for 2.09}
+% \changes{babel~3.9p}{2016/02/05}{Added a test for lua(e)tex.}
+% \changes{babel~3.9q}{2016/02/12}{Load lua patterns if not lualatex.}
+%
+% \begin{macrocode}
+\ifx\ldf@quit\@undefined
+\else
+ \expandafter\endinput
+\fi
+<@Make sure ProvidesFile is defined@>
+\ProvidesFile{babel.def}[<@date@> <@version@> Babel common definitions]
+<@Load macros for plain if not LaTeX@>
+% \end{macrocode}
+%
+% The file |babel.def| expects some definitions made in the \LaTeXe{}
+% style file. So, In \LaTeX2.09 and Plain{} we must provide at least
+% some predefined values as well some tools to set them (even if not
+% all options are available). There in no package options, and
+% therefore and alternative mechanism is provided. For the moment,
+% only |\babeloptionstrings| and |\babeloptionmath| are provided,
+% which can be defined before loading \babel. |\BabelModifiers| can be
+% set too (but not sure it works).
+%
+% \begin{macrocode}
+\ifx\bbl@ifshorthand\@undefined
+ \let\bbl@opt@shorthands\@nnil
+ \def\bbl@ifshorthand#1#2#3{#2}%
+ \let\bbl@language@opts\@empty
+ \ifx\babeloptionstrings\@undefined
+ \let\bbl@opt@strings\@nnil
+ \else
+ \let\bbl@opt@strings\babeloptionstrings
+ \fi
+ \def\BabelStringsDefault{generic}
+ \def\bbl@tempa{normal}
+ \ifx\babeloptionmath\bbl@tempa
+ \def\bbl@mathnormal{\noexpand\textormath}
+ \fi
+ \def\AfterBabelLanguage#1#2{}
+ \ifx\BabelModifiers\@undefined\let\BabelModifiers\relax\fi
+ \let\bbl@afterlang\relax
+ \def\bbl@opt@safe{BR}
+ \ifx\@uclclist\@undefined\let\@uclclist\@empty\fi
+ \ifx\bbl@trace\@undefined\def\bbl@trace#1{}\fi
+\fi
+% \end{macrocode}
+%
+% And continue.
+%
+% \begin{macrocode}
+\ifx\bbl@switchflag\@undefined % Prevent double input
+ \let\bbl@switchflag\relax
+ \input switch.def\relax
+\fi
+\bbl@trace{Compatibility with language.def}
+\ifx\bbl@languages\@undefined
+ \ifx\directlua\@undefined
+ \openin1 = language.def
+ \ifeof1
+ \closein1
+ \message{I couldn't find the file language.def}
+ \else
+ \closein1
+ \begingroup
+ \def\addlanguage#1#2#3#4#5{%
+ \expandafter\ifx\csname lang@#1\endcsname\relax\else
+ \global\expandafter\let\csname l@#1\expandafter\endcsname
+ \csname lang@#1\endcsname
+ \fi}%
+ \def\uselanguage#1{}%
+ \input language.def
+ \endgroup
+ \fi
+ \fi
+ \chardef\l@english\z@
+\fi
+<@Load patterns in luatex@>
+<@Basic macros@>
+% \end{macrocode}
+%
+% \begin{macro}{\addto}
+% For each language four control sequences have to be defined that
+% control the language-specific definitions. To be able to add
+% something to these macro once they have been defined the macro
+% |\addto| is introduced. It takes two arguments, a \meta{control
+% sequence} and \TeX-code to be added to the \meta{control
+% sequence}.
+%
+% If the \meta{control sequence} has not been defined before it is
+% defined now. The control sequence could also expand to |\relax|,
+% in which case a circular definition results. The net result is a
+% stack overflow. Otherwise the replacement text for the
+% \meta{control sequence} is expanded and stored in a token
+% register, together with the \TeX-code to be added. Finally the
+% \meta{control sequence} is \emph{re}defined, using the contents
+% of the token register.
+%
+% \begin{macrocode}
+\def\addto#1#2{%
+ \ifx#1\@undefined
+ \def#1{#2}%
+ \else
+ \ifx#1\relax
+ \def#1{#2}%
+ \else
+ {\toks@\expandafter{#1#2}%
+ \xdef#1{\the\toks@}}%
+ \fi
+ \fi}
+% \end{macrocode}
+%
+% \end{macro}
+%
+% \changes{babel~3.9a}{2012/08/10}{Removed the \cs{peek@token} and
+% \textsc{test@token} stuff}
+%
+% The macro |\initiate@active@char| takes all the necessary actions
+% to make its argument a shorthand character. The real work is
+% performed once for each character.
+%
+% \changes{babel~3.9a}{1999/04/30}{Added \cs{bbl@withactive}}
+%
+% \begin{macrocode}
+\def\bbl@withactive#1#2{%
+ \begingroup
+ \lccode`~=`#2\relax
+ \lowercase{\endgroup#1~}}
+% \end{macrocode}
+%
+% \begin{macro}{\bbl@redefine}
+% To redefine a command, we save the old meaning of the macro.
+% Then we redefine it to call the original macro with the
+% `sanitized' argument. The reason why we do it this way is that
+% we don't want to redefine the \LaTeX\ macros completely in case
+% their definitions change (they have changed in the past).
+%
+% Because we need to redefine a number of commands we define the
+% command |\bbl@redefine| which takes care of this. It creates a
+% new control sequence, |\org@...|
+%
+% \begin{macrocode}
+\def\bbl@redefine#1{%
+ \edef\bbl@tempa{\bbl@stripslash#1}%
+ \expandafter\let\csname org@\bbl@tempa\endcsname#1%
+ \expandafter\def\csname\bbl@tempa\endcsname}
+% \end{macrocode}
+%
+% This command should only be used in the preamble of the document.
+%
+% \begin{macrocode}
+\@onlypreamble\bbl@redefine
+% \end{macrocode}
+%
+% \end{macro}
+%
+% \begin{macro}{\bbl@redefine@long}
+% This version of |\babel@redefine| can be used to redefine |\long|
+% commands such as |\ifthenelse|.
+%
+% \begin{macrocode}
+\def\bbl@redefine@long#1{%
+ \edef\bbl@tempa{\bbl@stripslash#1}%
+ \expandafter\let\csname org@\bbl@tempa\endcsname#1%
+ \expandafter\long\expandafter\def\csname\bbl@tempa\endcsname}
+\@onlypreamble\bbl@redefine@long
+% \end{macrocode}
+%
+% \end{macro}
+%
+% \begin{macro}{\bbl@redefinerobust}
+% For commands that are redefined, but which \textit{might} be
+% robust we need a slightly more intelligent macro. A robust
+% command |foo| is defined to expand to |\protect|\verb*|\foo |. So
+% it is necessary to check whether \verb*|\foo | exists. The result
+% is that the command that is being redefined is always robust
+% afterwards. Therefore all we need to do now is define \verb*|\foo |.
+%
+% \begin{macrocode}
+\def\bbl@redefinerobust#1{%
+ \edef\bbl@tempa{\bbl@stripslash#1}%
+ \bbl@ifunset{\bbl@tempa\space}%
+ {\expandafter\let\csname org@\bbl@tempa\endcsname#1%
+ \bbl@exp{\def\\#1{\\\protect\<\bbl@tempa\space>}}}%
+ {\bbl@exp{\let\<org@\bbl@tempa>\<\bbl@tempa\space>}}%
+ \@namedef{\bbl@tempa\space}}
+% \end{macrocode}
+%
+% This command should only be used in the preamble of the document.
+%
+% \begin{macrocode}
+\@onlypreamble\bbl@redefinerobust
+% \end{macrocode}
+%
+% \end{macro}
+%
+% \subsection{Hooks}
+%
+% Note they are loaded in babel.def. switch.def only provides a
+% ``hook'' for hooks (with a default value which is a no-op,
+% below). Admittedly, the current implementation is a somewhat
+% simplistic and does vety little to catch errors, but it is intended
+% for developpers, after all. |\bbl@usehooks| is the commands used by
+% babel to execute hooks defined for an event.
+%
+% \changes{babel~3.33}{2019/07/16}{Optional argument for languages.}
+%
+% \begin{macrocode}
+\bbl@trace{Hooks}
+\newcommand\AddBabelHook[3][]{%
+ \bbl@ifunset{bbl@hk@#2}{\EnableBabelHook{#2}}{}%
+ \def\bbl@tempa##1,#3=##2,##3\@empty{\def\bbl@tempb{##2}}%
+ \expandafter\bbl@tempa\bbl@evargs,#3=,\@empty
+ \bbl@ifunset{bbl@ev@#2@#3@#1}%
+ {\bbl@csarg\bbl@add{ev@#3@#1}{\bbl@elt{#2}}}%
+ {\bbl@csarg\let{ev@#2@#3@#1}\relax}%
+ \bbl@csarg\newcommand{ev@#2@#3@#1}[\bbl@tempb]}
+\newcommand\EnableBabelHook[1]{\bbl@csarg\let{hk@#1}\@firstofone}
+\newcommand\DisableBabelHook[1]{\bbl@csarg\let{hk@#1}\@gobble}
+\def\bbl@usehooks#1#2{%
+ \def\bbl@elt##1{%
+ \@nameuse{bbl@hk@##1}{\@nameuse{bbl@ev@##1@#1@}#2}}%
+ \@nameuse{bbl@ev@#1@}%
+ \ifx\languagename\@undefined\else % Test required for Plain (?)
+ \def\bbl@elt##1{%
+ \@nameuse{bbl@hk@##1}{\@nameuse{bbl@ev@##1@#1@\languagename}#2}}%
+ \@nameuse{bbl@ev@#1@\languagename}%
+ \fi}
+% \end{macrocode}
+%
+% To ensure forward compatibility, arguments in hooks are set
+% implicitly. So, if a further argument is added in the future,
+% there is no need to change the existing code. Note events
+% intended for \textsf{hyphen.cfg} are also loaded (just in
+% case you need them for some reason).
+%
+% \begin{macrocode}
+\def\bbl@evargs{,% <- don't delete this comma
+ everylanguage=1,loadkernel=1,loadpatterns=1,loadexceptions=1,%
+ adddialect=2,patterns=2,defaultcommands=0,encodedcommands=2,write=0,%
+ beforeextras=0,afterextras=0,stopcommands=0,stringprocess=0,%
+ hyphenation=2,initiateactive=3,afterreset=0,foreign=0,foreign*=0}
+% \end{macrocode}
+%
+% \begin{macro}{\babelensure}
+%
+% The user command just parses the optional argument and creates a
+% new macro named |\bbl@e@|\m{language}. We register a hook at the
+% |afterextras| event which just executes this macro in a
+% ``complete'' selection (which, if undefined, is |\relax| and does
+% nothing). This part is somewhat involved because we have to make
+% sure things are expanded the correct number of times.
+%
+% The macro |\bbl@e@|\m{language} contains
+% |\bbl@ensure|\marg{include}\marg{exclude}\marg{fontenc}, which in in
+% turn loops over the macros names in |\bbl@captionslist|, excluding
+% (with the help of |\in@|) those in the |exclude| list. If the
+% |fontenc| is given (and not |\relax|), the |\fontencoding| is also
+% added. Then we loop over the |include| list, but if the macro
+% already contains |\foreignlanguage|, nothing is done. Note this
+% macro (1) is not restricted to the preamble, and (2) changes are
+% local.
+%
+% \changes{babel~3.9i}{2014/02/14}{Macro \cs{babelensure} added}
+% \changes{babel~3.9k}{2014/03/23}{Encapsulate \cs{foreignlanguage} in
+% \cs{bbl@ensure@}language, to "protect" strings}
+% \changes{babel~3.9s}{2017/04/10}{Bug fix - extra spaces because a
+% missing percent}
+% \changes{babel~3.9s}{2017/04/10}{\cs{bbl@ensure@lang} defined only
+% once}
+% \changes{babel~3.10}{2017/05/06}{\cs{bbl@ensured} renamed to
+% \cs{bbl@captionslist} (for \cs{babelprovide}), which means
+% \cs{today} must be given explicitly in \cs{babelensure}}
+%
+% \begin{macrocode}
+\bbl@trace{Defining babelensure}
+\newcommand\babelensure[2][]{% TODO - revise test files
+ \AddBabelHook{babel-ensure}{afterextras}{%
+ \ifcase\bbl@select@type
+ \@nameuse{bbl@e@\languagename}%
+ \fi}%
+ \begingroup
+ \let\bbl@ens@include\@empty
+ \let\bbl@ens@exclude\@empty
+ \def\bbl@ens@fontenc{\relax}%
+ \def\bbl@tempb##1{%
+ \ifx\@empty##1\else\noexpand##1\expandafter\bbl@tempb\fi}%
+ \edef\bbl@tempa{\bbl@tempb#1\@empty}%
+ \def\bbl@tempb##1=##2\@@{\@namedef{bbl@ens@##1}{##2}}%
+ \bbl@foreach\bbl@tempa{\bbl@tempb##1\@@}%
+ \def\bbl@tempc{\bbl@ensure}%
+ \expandafter\bbl@add\expandafter\bbl@tempc\expandafter{%
+ \expandafter{\bbl@ens@include}}%
+ \expandafter\bbl@add\expandafter\bbl@tempc\expandafter{%
+ \expandafter{\bbl@ens@exclude}}%
+ \toks@\expandafter{\bbl@tempc}%
+ \bbl@exp{%
+ \endgroup
+ \def\<bbl@e@#2>{\the\toks@{\bbl@ens@fontenc}}}}
+\def\bbl@ensure#1#2#3{% 1: include 2: exclude 3: fontenc
+ \def\bbl@tempb##1{% elt for (excluding) \bbl@captionslist list
+ \ifx##1\@undefined % 3.32 - Don't assume the macros exists
+ \edef##1{\noexpand\bbl@nocaption
+ {\bbl@stripslash##1}{\languagename\bbl@stripslash##1}}%
+ \fi
+ \ifx##1\@empty\else
+ \in@{##1}{#2}%
+ \ifin@\else
+ \bbl@ifunset{bbl@ensure@\languagename}%
+ {\bbl@exp{%
+ \\\DeclareRobustCommand\<bbl@ensure@\languagename>[1]{%
+ \\\foreignlanguage{\languagename}%
+ {\ifx\relax#3\else
+ \\\fontencoding{#3}\\\selectfont
+ \fi
+ ########1}}}}%
+ {}%
+ \toks@\expandafter{##1}%
+ \edef##1{%
+ \bbl@csarg\noexpand{ensure@\languagename}%
+ {\the\toks@}}%
+ \fi
+ \expandafter\bbl@tempb
+ \fi}%
+ \expandafter\bbl@tempb\bbl@captionslist\today\@empty
+ \def\bbl@tempa##1{% elt for include list
+ \ifx##1\@empty\else
+ \bbl@csarg\in@{ensure@\languagename\expandafter}\expandafter{##1}%
+ \ifin@\else
+ \bbl@tempb##1\@empty
+ \fi
+ \expandafter\bbl@tempa
+ \fi}%
+ \bbl@tempa#1\@empty}
+\def\bbl@captionslist{%
+ \prefacename\refname\abstractname\bibname\chaptername\appendixname
+ \contentsname\listfigurename\listtablename\indexname\figurename
+ \tablename\partname\enclname\ccname\headtoname\pagename\seename
+ \alsoname\proofname\glossaryname}
+% \end{macrocode}
+%
+% \end{macro}
+%
+% \subsection{Setting up language files}
+%
+% \begin{macro}{\LdfInit}
+% The second version of |\LdfInit| macro takes two arguments. The first
+% argument is the name of the language that will be defined in the
+% language definition file; the second argument is either a control
+% sequence or a string from which a control sequence should be
+% constructed. The existence of the control sequence indicates that
+% the file has been processed before.
+%
+% At the start of processing a language definition file we always
+% check the category code of the at-sign. We make sure that it is
+% a `letter' during the processing of the file. We also save its
+% name as the last called option, even if not loaded.
+%
+% Another character that needs to have the correct category code
+% during processing of language definition files is the equals sign,
+% `=', because it is sometimes used in constructions with the
+% |\let| primitive. Therefore we store its current catcode and
+% restore it later on.
+%
+% Now we check whether we should perhaps stop the processing of
+% this file. To do this we first need to check whether the second
+% argument that is passed to |\LdfInit| is a control sequence. We
+% do that by looking at the first token after passing |#2| through
+% |string|. When it is equal to |\@backslashchar| we are dealing
+% with a control sequence which we can compare with |\@undefined|.
+%
+% \changes{babel~3.9a}{2012/08/11}{\cs{ldf@quit} is not delayed any
+% more after \cs{fi} , since \cs{endinput} is not executed
+% immediately}
+% \changes{babel~3.9g}{2012/08/11}{Preset the ``family'' of macros
+% \cs{Babel}...}
+%
+% If so, we call |\ldf@quit| to set the main language, restore the
+% category code of the @-sign and call |\endinput|
+%
+% When |#2| was \emph{not} a control sequence we construct one and
+% compare it with |\relax|.
+%
+% Finally we check |\originalTeX|.
+%
+% \begin{macrocode}
+\bbl@trace{Macros for setting language files up}
+\def\bbl@ldfinit{%
+ \let\bbl@screset\@empty
+ \let\BabelStrings\bbl@opt@string
+ \let\BabelOptions\@empty
+ \let\BabelLanguages\relax
+ \ifx\originalTeX\@undefined
+ \let\originalTeX\@empty
+ \else
+ \originalTeX
+ \fi}
+\def\LdfInit#1#2{%
+ \chardef\atcatcode=\catcode`\@
+ \catcode`\@=11\relax
+ \chardef\eqcatcode=\catcode`\=
+ \catcode`\==12\relax
+ \expandafter\if\expandafter\@backslashchar
+ \expandafter\@car\string#2\@nil
+ \ifx#2\@undefined\else
+ \ldf@quit{#1}%
+ \fi
+ \else
+ \expandafter\ifx\csname#2\endcsname\relax\else
+ \ldf@quit{#1}%
+ \fi
+ \fi
+ \bbl@ldfinit}
+% \end{macrocode}
+%
+% \end{macro}
+%
+% \begin{macro}{\ldf@quit}
+% This macro interrupts the processing of a language definition file.
+%
+% \begin{macrocode}
+\def\ldf@quit#1{%
+ \expandafter\main@language\expandafter{#1}%
+ \catcode`\@=\atcatcode \let\atcatcode\relax
+ \catcode`\==\eqcatcode \let\eqcatcode\relax
+ \endinput}
+% \end{macrocode}
+%
+% \end{macro}
+%
+% \begin{macro}{\ldf@finish}
+% This macro takes one argument. It is the name of the language
+% that was defined in the language definition file.
+%
+% We load the local configuration file if one is present, we set
+% the main language (taking into account that the argument might be
+% a control sequence that needs to be expanded) and reset the
+% category code of the @-sign.
+%
+% \changes{babel~3.9a}{2012/10/01}{Added \cs{bbl@afterlang} which
+% executes the code delayed with \cs{AfterBabelLanguage}}
+%
+% \begin{macrocode}
+\def\bbl@afterldf#1{%
+ \bbl@afterlang
+ \let\bbl@afterlang\relax
+ \let\BabelModifiers\relax
+ \let\bbl@screset\relax}%
+\def\ldf@finish#1{%
+ \loadlocalcfg{#1}%
+ \bbl@afterldf{#1}%
+ \expandafter\main@language\expandafter{#1}%
+ \catcode`\@=\atcatcode \let\atcatcode\relax
+ \catcode`\==\eqcatcode \let\eqcatcode\relax}
+% \end{macrocode}
+%
+% \end{macro}
+%
+% After the preamble of the document the commands |\LdfInit|,
+% |\ldf@quit| and |\ldf@finish| are no longer needed. Therefore
+% they are turned into warning messages in \LaTeX.
+%
+% \begin{macrocode}
+\@onlypreamble\LdfInit
+\@onlypreamble\ldf@quit
+\@onlypreamble\ldf@finish
+% \end{macrocode}
+%
+% \begin{macro}{\main@language}
+% \begin{macro}{\bbl@main@language}
+% This command should be used in the various language definition
+% files. It stores its argument in |\bbl@main@language|; to be used
+% to switch to the correct language at the beginning of the
+% document.
+%
+% \begin{macrocode}
+\def\main@language#1{%
+ \def\bbl@main@language{#1}%
+ \let\languagename\bbl@main@language
+ \bbl@id@assign
+ \chardef\localeid\@nameuse{bbl@id@@\languagename}%
+ \bbl@patterns{\languagename}}
+% \end{macrocode}
+%
+% We also have to make sure that some code gets executed at the
+% beginning of the document. Languages does not set |\pagedir|, so
+% we set here for the whole document to the main |\bodydir|.
+%
+% \begin{macrocode}
+\AtBeginDocument{%
+ \expandafter\selectlanguage\expandafter{\bbl@main@language}%
+ \ifcase\bbl@engine\or\pagedir\bodydir\fi} % TODO - a better place
+% \end{macrocode}
+%
+% \end{macro}
+% \end{macro}
+%
+% A bit of optimization. Select in heads/foots the language only if
+% necessary.
+%
+% \begin{macrocode}
+\def\select@language@x#1{%
+ \ifcase\bbl@select@type
+ \bbl@ifsamestring\languagename{#1}{}{\select@language{#1}}%
+ \else
+ \select@language{#1}%
+ \fi}
+% \end{macrocode}
+%
+% \subsection{Shorthands}
+%
+% \begin{macro}{\bbl@add@special}
+% The macro |\bbl@add@special| is used to add a new character (or
+% single character control sequence) to the macro |\dospecials|
+% (and |\@sanitize| if \LaTeX\ is used). It is used only at one
+% place, namely when |\initiate@active@char| is called (which is
+% ignored if the char has been made active before). Because
+% |\@sanitize| can be undefined, we put the definition inside a
+% conditional.
+%
+% Items are added to the lists without checking its existence or
+% the original catcode. It does not hurt, but should be fixed. It's
+% already done with |\nfss@catcodes|, added in 3.10.
+%
+% \changes{3.10}{2017/05/14}{Refactored. Add to \cs{nfss@catcodes} too.}
+%
+% \begin{macrocode}
+\bbl@trace{Shorhands}
+\def\bbl@add@special#1{% 1:a macro like \", \?, etc.
+ \bbl@add\dospecials{\do#1}% test @sanitize = \relax, for back. compat.
+ \bbl@ifunset{@sanitize}{}{\bbl@add\@sanitize{\@makeother#1}}%
+ \ifx\nfss@catcodes\@undefined\else % TODO - same for above
+ \begingroup
+ \catcode`#1\active
+ \nfss@catcodes
+ \ifnum\catcode`#1=\active
+ \endgroup
+ \bbl@add\nfss@catcodes{\@makeother#1}%
+ \else
+ \endgroup
+ \fi
+ \fi}
+% \end{macrocode}
+%
+% \end{macro}
+%
+% \begin{macro}{\bbl@remove@special}
+%
+% The companion of the former macro is |\bbl@remove@special|. It
+% removes a character from the set macros |\dospecials| and
+% |\@sanitize|, but it is not used at all in the \babel{} core.
+%
+% \begin{macrocode}
+\def\bbl@remove@special#1{%
+ \begingroup
+ \def\x##1##2{\ifnum`#1=`##2\noexpand\@empty
+ \else\noexpand##1\noexpand##2\fi}%
+ \def\do{\x\do}%
+ \def\@makeother{\x\@makeother}%
+ \edef\x{\endgroup
+ \def\noexpand\dospecials{\dospecials}%
+ \expandafter\ifx\csname @sanitize\endcsname\relax\else
+ \def\noexpand\@sanitize{\@sanitize}%
+ \fi}%
+ \x}
+% \end{macrocode}
+%
+% \end{macro}
+%
+% \begin{macro}{\initiate@active@char}
+% A language definition file can call this macro to make a
+% character active. This macro takes one argument, the character
+% that is to be made active. When the character was already active
+% this macro does nothing. Otherwise, this macro defines the
+% control sequence |\normal@char|\m{char} to expand to the
+% character in its `normal state' and it defines the active
+% character to expand to |\normal@char|\m{char} by default
+% (\m{char} being the character to be made active). Later its
+% definition can be changed to expand to |\active@char|\m{char}
+% by calling |\bbl@activate{|\m{char}|}|.
+%
+% For example, to make the double quote character active one could
+% have |\initiate@active@char{"}| in a language definition file.
+% This defines |"| as |\active@prefix "\active@char"| (where the
+% first |"| is the character with its original catcode, when the
+% shorthand is created, and |\active@char"| is a single token). In
+% protected contexts, it expands to |\protect "| or |\noexpand "|
+% (ie, with the original |"|); otherwise |\active@char"| is
+% executed. This macro in turn expands to |\normal@char"| in
+% ``safe'' contexts (eg, |\label|), but |\user@active"| in normal
+% ``unsafe'' ones. The latter search a definition in the user,
+% language and system levels, in this order, but if none is found,
+% |\normal@char"| is used. However, a deactivated shorthand (with
+% |\bbl@deactivate| is defined as |\active@prefix "\normal@char"|.
+%
+% The following macro is used to define shorthands in the three
+% levels. It takes 4 arguments: the (string'ed) character,
+% |\<level>@group|, |<level>@active| and |<next-level>@active|
+% (except in |system|).
+%
+% \changes{babel~3.9a}{2012/08/18}{New macro, with code from
+% \cs{@initiate@active@char}}
+%
+% \begin{macrocode}
+\def\bbl@active@def#1#2#3#4{%
+ \@namedef{#3#1}{%
+ \expandafter\ifx\csname#2@sh@#1@\endcsname\relax
+ \bbl@afterelse\bbl@sh@select#2#1{#3@arg#1}{#4#1}%
+ \else
+ \bbl@afterfi\csname#2@sh@#1@\endcsname
+ \fi}%
+% \end{macrocode}
+%
+% When there is also no current-level shorthand with an argument we
+% will check whether there is a next-level defined shorthand for
+% this active character.
+%
+% \begin{macrocode}
+ \long\@namedef{#3@arg#1}##1{%
+ \expandafter\ifx\csname#2@sh@#1@\string##1@\endcsname\relax
+ \bbl@afterelse\csname#4#1\endcsname##1%
+ \else
+ \bbl@afterfi\csname#2@sh@#1@\string##1@\endcsname
+ \fi}}%
+% \end{macrocode}
+%
+% \changes{babel~3.9a}{2012/08/18}{Removed an extra hash. Now calls
+% \cs{@initiate@active@char} with 3 arguments.}
+%
+% |\initiate@active@char| calls |\@initiate@active@char| with 3
+% arguments. All of them are the same character with different
+% catcodes: active, other (|\string|'ed) and the original one.
+% This trick simplifies the code a lot.
+%
+% \begin{macrocode}
+\def\initiate@active@char#1{%
+ \bbl@ifunset{active@char\string#1}%
+ {\bbl@withactive
+ {\expandafter\@initiate@active@char\expandafter}#1\string#1#1}%
+ {}}
+% \end{macrocode}
+%
+% \changes{babel~3.9e}{2012/08/18}{Introduced the 3-argument
+% \cs{@initiate@active@char}, with different catcodes: active,
+% string'ed, and original. Reorganized}
+% \changes{babel~3.9a}{2012/08/19}{The catcode is saved}
+% \changes{babel~3.9a}{2012/09/09}{The original definition is saved,
+% too}
+% \changes{babel~3.9a}{2012/12/27}{Take into account mathematically
+% active chars, to avoid infinite loops}
+%
+% The very first thing to do is saving the original catcode and the
+% original definition, even if not active, which is possible
+% (undefined characters require a special treatement to avoid
+% making them |\relax|).
+%
+% \begin{macrocode}
+\def\@initiate@active@char#1#2#3{%
+ \bbl@csarg\edef{oricat@#2}{\catcode`#2=\the\catcode`#2\relax}%
+ \ifx#1\@undefined
+ \bbl@csarg\edef{oridef@#2}{\let\noexpand#1\noexpand\@undefined}%
+ \else
+ \bbl@csarg\let{oridef@@#2}#1%
+ \bbl@csarg\edef{oridef@#2}{%
+ \let\noexpand#1%
+ \expandafter\noexpand\csname bbl@oridef@@#2\endcsname}%
+ \fi
+% \end{macrocode}
+%
+% If the character is already active we provide the default
+% expansion under this shorthand mechanism. Otherwise we write a
+% message in the transcript file, and define |\normal@char|\m{char}
+% to expand to the character in its default state. If the character
+% is mathematically active when \babel{} is loaded (for example
+% |'|) the normal expansion is somewhat different to avoid an
+% infinite loop (but it does not prevent the loop if the mathcode
+% is set to |"8000| \textit{a posteriori}).
+%
+% \begin{macrocode}
+ \ifx#1#3\relax
+ \expandafter\let\csname normal@char#2\endcsname#3%
+ \else
+ \bbl@info{Making #2 an active character}%
+ \ifnum\mathcode`#2="8000
+ \@namedef{normal@char#2}{%
+ \textormath{#3}{\csname bbl@oridef@@#2\endcsname}}%
+ \else
+ \@namedef{normal@char#2}{#3}%
+ \fi
+% \end{macrocode}
+%
+% To prevent problems with the loading of other packages after
+% \babel\ we reset the catcode of the character to the original one
+% at the end of the package and of each language file (except with
+% \textsf{KeepShorthandsActive}). It is re-activate again at
+% |\begin{document}|. We also need to make sure that the
+% shorthands are active during the processing of the \file{.aux}
+% file. Otherwise some citations may give unexpected results in
+% the printout when a shorthand was used in the optional argument
+% of |\bibitem| for example. Then we make it active (not strictly
+% necessary, but done for backward compatibility).
+%
+% \begin{macrocode}
+ \bbl@restoreactive{#2}%
+ \AtBeginDocument{%
+ \catcode`#2\active
+ \if@filesw
+ \immediate\write\@mainaux{\catcode`\string#2\active}%
+ \fi}%
+ \expandafter\bbl@add@special\csname#2\endcsname
+ \catcode`#2\active
+ \fi
+% \end{macrocode}
+%
+% Now we have set |\normal@char|\m{char}, we must define
+% |\active@char|\m{char}, to be executed when the character is
+% activated. We define the first level expansion of
+% |\active@char|\m{char} to check the status of the |@safe@actives|
+% flag. If it is set to true we expand to the `normal' version of
+% this character, otherwise we call |\user@active|\m{char} to start
+% the search of a definition in the user, language and system
+% levels (or eventually |normal@char|\m{char}).
+%
+% \changes{babel~3.9a}{2012/12/27}{Added code for option math=normal}
+% \changes{babel~3.9i}{2014/02/03}{Don't call directly
+% \cs{user@active}, but with an intermediate step}
+%
+% \begin{macrocode}
+ \let\bbl@tempa\@firstoftwo
+ \if\string^#2%
+ \def\bbl@tempa{\noexpand\textormath}%
+ \else
+ \ifx\bbl@mathnormal\@undefined\else
+ \let\bbl@tempa\bbl@mathnormal
+ \fi
+ \fi
+ \expandafter\edef\csname active@char#2\endcsname{%
+ \bbl@tempa
+ {\noexpand\if@safe@actives
+ \noexpand\expandafter
+ \expandafter\noexpand\csname normal@char#2\endcsname
+ \noexpand\else
+ \noexpand\expandafter
+ \expandafter\noexpand\csname bbl@doactive#2\endcsname
+ \noexpand\fi}%
+ {\expandafter\noexpand\csname normal@char#2\endcsname}}%
+ \bbl@csarg\edef{doactive#2}{%
+ \expandafter\noexpand\csname user@active#2\endcsname}%
+% \end{macrocode}
+%
+% \changes{babel~3.9a}{2012/12/27}{Shorthands are not defined
+% directly, but with a couple of intermediate macros}
+%
+% We now define the default values which the shorthand is set to
+% when activated or deactivated. It is set to the deactivated form
+% (globally), so that the character expands to
+% \begin{center}
+% |\active@prefix| \m{char} |\normal@char|\m{char}
+% \end{center}
+% (where |\active@char|\m{char} is \emph{one} control sequence!).
+%
+% \begin{macrocode}
+ \bbl@csarg\edef{active@#2}{%
+ \noexpand\active@prefix\noexpand#1%
+ \expandafter\noexpand\csname active@char#2\endcsname}%
+ \bbl@csarg\edef{normal@#2}{%
+ \noexpand\active@prefix\noexpand#1%
+ \expandafter\noexpand\csname normal@char#2\endcsname}%
+ \expandafter\let\expandafter#1\csname bbl@normal@#2\endcsname
+% \end{macrocode}
+%
+% The next level of the code checks whether a user has defined a
+% shorthand for himself with this character. First we check for a
+% single character shorthand. If that doesn't exist we check for a
+% shorthand with an argument.
+%
+% \changes{babel~3.9a}{2012/08/18}{Instead of the ``copy-paste pattern''
+% a new macro is used}
+%
+% \begin{macrocode}
+ \bbl@active@def#2\user@group{user@active}{language@active}%
+ \bbl@active@def#2\language@group{language@active}{system@active}%
+ \bbl@active@def#2\system@group{system@active}{normal@char}%
+% \end{macrocode}
+%
+% In order to do the right thing when a shorthand with an argument
+% is used by itself at the end of the line we provide a definition
+% for the case of an empty argument. For that case we let the
+% shorthand character expand to its non-active self. Also, When a
+% shorthand combination such as |''| ends up in a heading \TeX\
+% would see |\protect'\protect'|. To prevent this from happening a
+% couple of shorthand needs to be defined at user level.
+%
+% \changes{babel~3.9a}{2012/8/18}{Use \cs{user@group}, as above,
+% instead of the hardwired \texttt{user}}
+%
+% \begin{macrocode}
+ \expandafter\edef\csname\user@group @sh@#2@@\endcsname
+ {\expandafter\noexpand\csname normal@char#2\endcsname}%
+ \expandafter\edef\csname\user@group @sh@#2@\string\protect@\endcsname
+ {\expandafter\noexpand\csname user@active#2\endcsname}%
+% \end{macrocode}
+%
+% Finally, a couple of special cases are taken care of. (1) If we
+% are making the right quote (|'|) active we need to change |\pr@m@s| as
+% well. Also, make sure that a single |'| in math mode `does the
+% right thing'. (2) If we are using the caret (|^|) as a shorthand
+% character special care should be taken to make sure math still
+% works. Therefore an extra level of expansion is introduced with a
+% check for math mode on the upper level.
+%
+% \changes{babel~3.9a}{2012/09/11}{The output routine resets the quote
+% to \cs{active@math@prime}, so we redefine the latter with the new
+% ``normal'' value}
+% \changes{babel~3.9a}{2012/06/20}{Added a couple of missing
+% comment characters (PR 4146)}
+% \changes{babel~3.9a}{2012/07/29}{Use \cs{textormath} instead of
+% \cs{ifmath}}
+% \changes{babel~3.9a}{2012/11/26}{Compare the char, irrespective of
+% its catcode.}
+% \changes{babel~3.9a}{2012/12/27}{Removed the redeclaration of
+% \cs{normal@char'} because it is handled in a generic way above}
+% \changes{babel~3.9a}{2012/12/29}{Removed the intermediate step of
+% \cs{bbl@act@caret} and moved above}
+% \changes{babel~3.9i}{2012/12/29}{Added the event \cs{initiateactive}}
+%
+% \begin{macrocode}
+ \if\string'#2%
+ \let\prim@s\bbl@prim@s
+ \let\active@math@prime#1%
+ \fi
+ \bbl@usehooks{initiateactive}{{#1}{#2}{#3}}}
+% \end{macrocode}
+%
+% The following package options control the behavior of shorthands
+% in math mode.
+%
+% \begin{macrocode}
+%<<*More package options>>
+\DeclareOption{math=active}{}
+\DeclareOption{math=normal}{\def\bbl@mathnormal{\noexpand\textormath}}
+%<</More package options>>
+% \end{macrocode}
+%
+% Initiating a shorthand makes active the char. That is not
+% strictly necessary but it is still done for backward
+% compatibility. So we need to restore the original catcode at the
+% end of package \textit{and} and the end of the |ldf|.
+%
+% \changes{babel~3.9a}{2012/07/04}{Catcodes are also restored after
+% each language, to prevent incompatibilities. Use \cs{string} instead
+% of \cs{noexpand} and add \cs{relax}}
+% \changes{babel~3.9a}{2012/10/18}{Catcodes are deactivated in a separate
+% macro, which is made no-op when babel exits}
+%
+% \begin{macrocode}
+\@ifpackagewith{babel}{KeepShorthandsActive}%
+ {\let\bbl@restoreactive\@gobble}%
+ {\def\bbl@restoreactive#1{%
+ \bbl@exp{%
+ \\\AfterBabelLanguage\\\CurrentOption
+ {\catcode`#1=\the\catcode`#1\relax}%
+ \\\AtEndOfPackage
+ {\catcode`#1=\the\catcode`#1\relax}}}%
+ \AtEndOfPackage{\let\bbl@restoreactive\@gobble}}
+% \end{macrocode}
+%
+% \end{macro}
+%
+% \begin{macro}{\bbl@sh@select}
+% This command helps the shorthand supporting macros to select how
+% to proceed. Note that this macro needs to be expandable as do all
+% the shorthand macros in order for them to work in expansion-only
+% environments such as the argument of |\hyphenation|.
+%
+% This macro expects the name of a group of shorthands in its first
+% argument and a shorthand character in its second argument. It
+% will expand to either |\bbl@firstcs| or |\bbl@scndcs|. Hence two
+% more arguments need to follow it.
+%
+% \changes{babel~3.9a}{2012/08/18}{Removed \cs{string}s, because the
+% char are already string'ed}
+%
+% \begin{macrocode}
+\def\bbl@sh@select#1#2{%
+ \expandafter\ifx\csname#1@sh@#2@sel\endcsname\relax
+ \bbl@afterelse\bbl@scndcs
+ \else
+ \bbl@afterfi\csname#1@sh@#2@sel\endcsname
+ \fi}
+% \end{macrocode}
+%
+% \end{macro}
+%
+% \begin{macro}{\active@prefix}
+% The command |\active@prefix| which is used in the expansion of
+% active characters has a function similar to |\OT1-cmd| in that it
+% |\protect|s the active character whenever |\protect| is
+% \emph{not} |\@typeset@protect|.
+%
+% \begin{macrocode}
+\def\active@prefix#1{%
+ \ifx\protect\@typeset@protect
+ \else
+% \end{macrocode}
+%
+% When |\protect| is set to |\@unexpandable@protect| we make sure
+% that the active character is als \emph{not} expanded by inserting
+% |\noexpand| in front of it. The |\@gobble| is needed to remove
+% a token such as |\activechar:| (when the double colon was the
+% active character to be dealt with).
+%
+% \begin{macrocode}
+ \ifx\protect\@unexpandable@protect
+ \noexpand#1%
+ \else
+ \protect#1%
+ \fi
+ \expandafter\@gobble
+ \fi}
+% \end{macrocode}
+%
+% \end{macro}
+%
+% \begin{macro}{\if@safe@actives}
+% In some circumstances it is necessary to be able to change the
+% expansion of an active character on the fly. For this purpose the
+% switch |@safe@actives| is available. The setting of this switch
+% should be checked in the first level expansion of
+% |\active@char|\m{char}.
+%
+% \begin{macrocode}
+\newif\if@safe@actives
+\@safe@activesfalse
+% \end{macrocode}
+%
+% \end{macro}
+%
+% \begin{macro}{\bbl@restore@actives}
+% When the output routine kicks in while the
+% active characters were made ``safe'' this must be undone in
+% the headers to prevent unexpected typeset results. For this
+% situation we define a command to make them ``unsafe'' again.
+%
+% \begin{macrocode}
+\def\bbl@restore@actives{\if@safe@actives\@safe@activesfalse\fi}
+% \end{macrocode}
+%
+% \end{macro}
+%
+% \begin{macro}{\bbl@activate}
+% \begin{macro}{\bbl@deactivate}
+%
+% \changes{babel~3.9a}{2013/01/11}{\cs{bbl@withactive} makes sure the
+% catcode is active}
+%
+% Both macros take one argument, like |\initiate@active@char|. The
+% macro is used to change the definition of an active character to
+% expand to |\active@char|\m{char} in the case of |\bbl@activate|,
+% or |\normal@char|\m{char} in the case of
+% |\bbl@deactivate|.
+%
+% \begin{macrocode}
+\def\bbl@activate#1{%
+ \bbl@withactive{\expandafter\let\expandafter}#1%
+ \csname bbl@active@\string#1\endcsname}
+\def\bbl@deactivate#1{%
+ \bbl@withactive{\expandafter\let\expandafter}#1%
+ \csname bbl@normal@\string#1\endcsname}
+% \end{macrocode}
+%
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\bbl@firstcs}
+% \begin{macro}{\bbl@scndcs}
+% These macros have two arguments. They use one of their arguments
+% to build a control sequence from.
+%
+% \begin{macrocode}
+\def\bbl@firstcs#1#2{\csname#1\endcsname}
+\def\bbl@scndcs#1#2{\csname#2\endcsname}
+% \end{macrocode}
+%
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\declare@shorthand}
+% The command |\declare@shorthand| is used to declare a shorthand
+% on a certain level. It takes three arguments:
+% \begin{enumerate}
+% \item a name for the collection of shorthands, i.e. `system', or
+% `dutch';
+% \item the character (sequence) that makes up the shorthand,
+% i.e. |~| or |"a|;
+% \item the code to be executed when the shorthand is encountered.
+% \end{enumerate}
+%
+% \changes{babel~3.9a}{2012/07/03}{Check if shorthands are redefined}
+%
+% \begin{macrocode}
+\def\declare@shorthand#1#2{\@decl@short{#1}#2\@nil}
+\def\@decl@short#1#2#3\@nil#4{%
+ \def\bbl@tempa{#3}%
+ \ifx\bbl@tempa\@empty
+ \expandafter\let\csname #1@sh@\string#2@sel\endcsname\bbl@scndcs
+ \bbl@ifunset{#1@sh@\string#2@}{}%
+ {\def\bbl@tempa{#4}%
+ \expandafter\ifx\csname#1@sh@\string#2@\endcsname\bbl@tempa
+ \else
+ \bbl@info
+ {Redefining #1 shorthand \string#2\\%
+ in language \CurrentOption}%
+ \fi}%
+ \@namedef{#1@sh@\string#2@}{#4}%
+ \else
+ \expandafter\let\csname #1@sh@\string#2@sel\endcsname\bbl@firstcs
+ \bbl@ifunset{#1@sh@\string#2@\string#3@}{}%
+ {\def\bbl@tempa{#4}%
+ \expandafter\ifx\csname#1@sh@\string#2@\string#3@\endcsname\bbl@tempa
+ \else
+ \bbl@info
+ {Redefining #1 shorthand \string#2\string#3\\%
+ in language \CurrentOption}%
+ \fi}%
+ \@namedef{#1@sh@\string#2@\string#3@}{#4}%
+ \fi}
+% \end{macrocode}
+%
+% \end{macro}
+%
+% \begin{macro}{\textormath}
+% Some of the shorthands that will be declared by the language
+% definition files have to be usable in both text and mathmode. To
+% achieve this the helper macro |\textormath| is provided.
+%
+% \changes{babel~3.9a}{2012/12/29}{Failed if an argument had a
+% condicional. Use the more robust mechanism of \cs{XXXoftwo}}
+%
+% \begin{macrocode}
+\def\textormath{%
+ \ifmmode
+ \expandafter\@secondoftwo
+ \else
+ \expandafter\@firstoftwo
+ \fi}
+% \end{macrocode}
+%
+% \end{macro}
+%
+% \begin{macro}{\user@group}
+% \begin{macro}{\language@group}
+% \begin{macro}{\system@group}
+% The current concept of `shorthands' supports three levels or
+% groups of shorthands. For each level the name of the level or
+% group is stored in a macro. The default is to have a user group;
+% use language group `english' and have a system group called
+% `system'.
+%
+% \begin{macrocode}
+\def\user@group{user}
+\def\language@group{english}
+\def\system@group{system}
+% \end{macrocode}
+%
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\useshorthands}
+% This is the user level command to tell \LaTeX\ that user level
+% shorthands will be used in the document. It takes one argument,
+% the character that starts a shorthand. First note that this is
+% user level, and then initialize and activate the character for
+% use as a shorthand character (ie, it's active in the
+% preamble). Languages can deactivate shorthands, so a starred
+% version is also provided which activates them always after the
+% language has been switched.
+%
+% \changes{babel~3.9a}{2012/08/05}{Now \cs{bbl@activate} makes sure
+% the catcode is active, so this part is simplified}
+% \changes{babel~3.9a}{2012/08/12}{User shorhands can be
+% defined even with shorthands=off}
+%
+% \begin{macrocode}
+\def\useshorthands{%
+ \@ifstar\bbl@usesh@s{\bbl@usesh@x{}}}
+\def\bbl@usesh@s#1{%
+ \bbl@usesh@x
+ {\AddBabelHook{babel-sh-\string#1}{afterextras}{\bbl@activate{#1}}}%
+ {#1}}
+\def\bbl@usesh@x#1#2{%
+ \bbl@ifshorthand{#2}%
+ {\def\user@group{user}%
+ \initiate@active@char{#2}%
+ #1%
+ \bbl@activate{#2}}%
+ {\bbl@error
+ {Cannot declare a shorthand turned off (\string#2)}
+ {Sorry, but you cannot use shorthands which have been\\%
+ turned off in the package options}}}
+% \end{macrocode}
+%
+% \end{macro}
+%
+% \begin{macro}{\defineshorthand}
+%
+% \changes{babel~3.9a}{2012/08/05}{Added optional argument, to provide
+% a way to (re)define language shorthands}
+% \changes{babel~3.9a}{2012/08/25}{Extended for language-dependent
+% user macros, with two new auxiliary macros}
+%
+% Currently we only support two groups of user level shorthands,
+% named internally |user| and |user@<lang>| (language-dependent
+% user shorthands). By default, only the first one is taken into
+% account, but if the former is also used (in the optional argument
+% of |\defineshorthand|) a new level is inserted for it
+% (|user@generic|, done by |\bbl@set@user@generic|); we make also
+% sure |{}| and |\protect| are taken into account in this new top
+% level.
+%
+% \begin{macrocode}
+\def\user@language@group{user@\language@group}
+\def\bbl@set@user@generic#1#2{%
+ \bbl@ifunset{user@generic@active#1}%
+ {\bbl@active@def#1\user@language@group{user@active}{user@generic@active}%
+ \bbl@active@def#1\user@group{user@generic@active}{language@active}%
+ \expandafter\edef\csname#2@sh@#1@@\endcsname{%
+ \expandafter\noexpand\csname normal@char#1\endcsname}%
+ \expandafter\edef\csname#2@sh@#1@\string\protect@\endcsname{%
+ \expandafter\noexpand\csname user@active#1\endcsname}}%
+ \@empty}
+\newcommand\defineshorthand[3][user]{%
+ \edef\bbl@tempa{\zap@space#1 \@empty}%
+ \bbl@for\bbl@tempb\bbl@tempa{%
+ \if*\expandafter\@car\bbl@tempb\@nil
+ \edef\bbl@tempb{user@\expandafter\@gobble\bbl@tempb}%
+ \@expandtwoargs
+ \bbl@set@user@generic{\expandafter\string\@car#2\@nil}\bbl@tempb
+ \fi
+ \declare@shorthand{\bbl@tempb}{#2}{#3}}}
+% \end{macrocode}
+%
+% \end{macro}
+%
+% \begin{macro}{\languageshorthands}
+% A user level command to change the language from which shorthands
+% are used. Unfortunately, \babel{} currently does not keep track
+% of defined groups, and therefore there is no way to catch a
+% possible change in casing.
+%
+% \begin{macrocode}
+\def\languageshorthands#1{\def\language@group{#1}}
+% \end{macrocode}
+%
+% \end{macro}
+%
+% \begin{macro}{\aliasshorthand}
+% First the new shorthand needs to be initialized,
+%
+% \begin{macrocode}
+\def\aliasshorthand#1#2{%
+ \bbl@ifshorthand{#2}%
+ {\expandafter\ifx\csname active@char\string#2\endcsname\relax
+ \ifx\document\@notprerr
+ \@notshorthand{#2}%
+ \else
+ \initiate@active@char{#2}%
+% \end{macrocode}
+%
+% \changes{babel~3.9a}{2012/08/06}{Instead of letting the new shorthand to
+% the original char, which very often didn't work, we define it
+% directly}
+% \changes{babel~3.9a}{2012/08/20}{Make sure both characters (old an
+% new) are active}
+%
+% Then, we define the new shorthand in terms of the original
+% one, but note with |\aliasshorthands{"}{/}| is
+% |\active@prefix /\active@char/|, so we still need to let the
+% lattest to |\active@char"|.
+%
+% \begin{macrocode}
+ \expandafter\let\csname active@char\string#2\expandafter\endcsname
+ \csname active@char\string#1\endcsname
+ \expandafter\let\csname normal@char\string#2\expandafter\endcsname
+ \csname normal@char\string#1\endcsname
+ \bbl@activate{#2}%
+ \fi
+ \fi}%
+ {\bbl@error
+ {Cannot declare a shorthand turned off (\string#2)}
+ {Sorry, but you cannot use shorthands which have been\\%
+ turned off in the package options}}}
+% \end{macrocode}
+%
+% \end{macro}
+%
+% \begin{macro}{\@notshorthand}
+%
+% \begin{macrocode}
+\def\@notshorthand#1{%
+ \bbl@error{%
+ The character `\string #1' should be made a shorthand character;\\%
+ add the command \string\useshorthands\string{#1\string} to
+ the preamble.\\%
+ I will ignore your instruction}%
+ {You may proceed, but expect unexpected results}}
+% \end{macrocode}
+%
+% \end{macro}
+%
+% \begin{macro}{\shorthandon}
+% \begin{macro}{\shorthandoff}
+% The first level definition of these macros just passes the
+% argument on to |\bbl@switch@sh|, adding |\@nil| at the end to
+% denote the end of the list of characters.
+%
+% \begin{macrocode}
+\newcommand*\shorthandon[1]{\bbl@switch@sh\@ne#1\@nnil}
+\DeclareRobustCommand*\shorthandoff{%
+ \@ifstar{\bbl@shorthandoff\tw@}{\bbl@shorthandoff\z@}}
+\def\bbl@shorthandoff#1#2{\bbl@switch@sh#1#2\@nnil}
+% \end{macrocode}
+%
+% \begin{macro}{\bbl@switch@sh}
+%
+% \changes{babel~3.9a}{2013/02/21}{Code revised}
+%
+% The macro |\bbl@switch@sh| takes the list of characters apart one
+% by one and subsequently switches the category code of the
+% shorthand character according to the first argument of
+% |\bbl@switch@sh|.
+%
+% But before any of this switching takes place we make sure that
+% the character we are dealing with is known as a shorthand
+% character. If it is, a macro such as |\active@char"| should
+% exist.
+%
+% Switching off and on is easy -- we just set the category
+% code to `other' (12) and |\active|. With the starred version, the
+% original catcode and the original definition, saved
+% in |@initiate@active@char|, are restored.
+%
+% \begin{macrocode}
+\def\bbl@switch@sh#1#2{%
+ \ifx#2\@nnil\else
+ \bbl@ifunset{bbl@active@\string#2}%
+ {\bbl@error
+ {I cannot switch `\string#2' on or off--not a shorthand}%
+ {This character is not a shorthand. Maybe you made\\%
+ a typing mistake? I will ignore your instruction}}%
+ {\ifcase#1%
+ \catcode`#212\relax
+ \or
+ \catcode`#2\active
+ \or
+ \csname bbl@oricat@\string#2\endcsname
+ \csname bbl@oridef@\string#2\endcsname
+ \fi}%
+ \bbl@afterfi\bbl@switch@sh#1%
+ \fi}
+% \end{macrocode}
+%
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \changes{babel~3.9a}{2012/06/16}{Added code}
+%
+% Note the value is that at the expansion time, eg, in the preample
+% shorhands are usually deactivated.
+%
+% \begin{macrocode}
+\def\babelshorthand{\active@prefix\babelshorthand\bbl@putsh}
+\def\bbl@putsh#1{%
+ \bbl@ifunset{bbl@active@\string#1}%
+ {\bbl@putsh@i#1\@empty\@nnil}%
+ {\csname bbl@active@\string#1\endcsname}}
+\def\bbl@putsh@i#1#2\@nnil{%
+ \csname\languagename @sh@\string#1@%
+ \ifx\@empty#2\else\string#2@\fi\endcsname}
+\ifx\bbl@opt@shorthands\@nnil\else
+ \let\bbl@s@initiate@active@char\initiate@active@char
+ \def\initiate@active@char#1{%
+ \bbl@ifshorthand{#1}{\bbl@s@initiate@active@char{#1}}{}}
+ \let\bbl@s@switch@sh\bbl@switch@sh
+ \def\bbl@switch@sh#1#2{%
+ \ifx#2\@nnil\else
+ \bbl@afterfi
+ \bbl@ifshorthand{#2}{\bbl@s@switch@sh#1{#2}}{\bbl@switch@sh#1}%
+ \fi}
+ \let\bbl@s@activate\bbl@activate
+ \def\bbl@activate#1{%
+ \bbl@ifshorthand{#1}{\bbl@s@activate{#1}}{}}
+ \let\bbl@s@deactivate\bbl@deactivate
+ \def\bbl@deactivate#1{%
+ \bbl@ifshorthand{#1}{\bbl@s@deactivate{#1}}{}}
+\fi
+% \end{macrocode}
+%
+% \changes{babel~3.23}{2018/08/26}{Added \cs{ifbabelshorthand}}
+%
+% You may want to test if a character is a shorthand. Note it does not
+% test whether the shorthand is on or off.
+%
+% \begin{macrocode}
+\newcommand\ifbabelshorthand[3]{\bbl@ifunset{bbl@active@\string#1}{#3}{#2}}
+% \end{macrocode}
+%
+% \changes{babel~3.9a}{2012/12/27}{Removed redundant system declarations}
+%
+% \begin{macro}{\bbl@prim@s}
+% \begin{macro}{\bbl@pr@m@s}
+%
+% \changes{babel~3.9a}{2012/07/29}{\cs{bbl@pr@m@s} rewritten to
+% take into account catcodes for both the quote and the hat}
+%
+% One of the internal macros that are involved in substituting |\prime|
+% for each right quote in mathmode is |\prim@s|. This checks if the
+% next character is a right quote. When the right quote is active, the
+% definition of this macro needs to be adapted to look also for an
+% active right quote; the hat could be active, too.
+%
+% \begin{macrocode}
+\def\bbl@prim@s{%
+ \prime\futurelet\@let@token\bbl@pr@m@s}
+\def\bbl@if@primes#1#2{%
+ \ifx#1\@let@token
+ \expandafter\@firstoftwo
+ \else\ifx#2\@let@token
+ \bbl@afterelse\expandafter\@firstoftwo
+ \else
+ \bbl@afterfi\expandafter\@secondoftwo
+ \fi\fi}
+\begingroup
+ \catcode`\^=7 \catcode`\*=\active \lccode`\*=`\^
+ \catcode`\'=12 \catcode`\"=\active \lccode`\"=`\'
+ \lowercase{%
+ \gdef\bbl@pr@m@s{%
+ \bbl@if@primes"'%
+ \pr@@@s
+ {\bbl@if@primes*^\pr@@@t\egroup}}}
+\endgroup
+% \end{macrocode}
+%
+% \end{macro}
+% \end{macro}
+%
+% Usually the |~| is active and expands to \verb*=\penalty\@M\ =.
+% When it is written to the \file{.aux} file it is written
+% expanded. To prevent that and to be able to use the character |~|
+% as a start character for a shorthand, it is redefined here as a
+% one character shorthand on system level. The system declaration
+% is in most cases redundant (when |~| is still a non-break space),
+% and in some cases is inconvenient (if |~| has been redefined);
+% however, for backward compatibility it is maintained (some
+% existing documents may rely on the \babel{} value).
+%
+% \changes{babel~3.9i}{2014/02/06}{Moved from above, after
+% \cs{bbl@usehook} has been defined}
+% \changes{babel~3.9k}{2014/02/06}{Moved again at the original place}
+%
+% \begin{macrocode}
+\initiate@active@char{~}
+\declare@shorthand{system}{~}{\leavevmode\nobreak\ }
+\bbl@activate{~}
+% \end{macrocode}
+%
+% \begin{macro}{\OT1dqpos}
+% \begin{macro}{\T1dqpos}
+% The position of the double quote character is different for the
+% OT1 and T1 encodings. It will later be selected using the
+% |\f@encoding| macro. Therefore we define two macros here to store
+% the position of the character in these encodings.
+%
+% \begin{macrocode}
+\expandafter\def\csname OT1dqpos\endcsname{127}
+\expandafter\def\csname T1dqpos\endcsname{4}
+% \end{macrocode}
+%
+% When the macro |\f@encoding| is undefined (as it is in plain
+% \TeX) we define it here to expand to \texttt{OT1}
+%
+% \begin{macrocode}
+\ifx\f@encoding\@undefined
+ \def\f@encoding{OT1}
+\fi
+% \end{macrocode}
+%
+% \end{macro}
+% \end{macro}
+%
+% \subsection{Language attributes}
+%
+% Language attributes provide a means to give the user control over
+% which features of the language definition files he wants to
+% enable.
+% \begin{macro}{\languageattribute}
+%
+% \changes{babel~3.9a}{2012/09/07}{Use \cs{@expandtwoargs} with
+% \cs{in@}}
+%
+% The macro |\languageattribute| checks whether its arguments are
+% valid and then activates the selected language attribute.
+% First check whether the language is known, and then process each
+% attribute in the list.
+%
+% \begin{macrocode}
+\bbl@trace{Language attributes}
+\newcommand\languageattribute[2]{%
+ \def\bbl@tempc{#1}%
+ \bbl@fixname\bbl@tempc
+ \bbl@iflanguage\bbl@tempc{%
+ \bbl@vforeach{#2}{%
+% \end{macrocode}
+%
+% We want to make sure that each attribute is selected only once;
+% therefore we store the already selected attributes in
+% |\bbl@known@attribs|. When that control sequence is not yet
+% defined this attribute is certainly not selected before.
+%
+% \begin{macrocode}
+ \ifx\bbl@known@attribs\@undefined
+ \in@false
+ \else
+% \end{macrocode}
+%
+% Now we need to see if the attribute occurs in the list of
+% already selected attributes.
+%
+% \begin{macrocode}
+ \bbl@xin@{,\bbl@tempc-##1,}{,\bbl@known@attribs,}%
+ \fi
+% \end{macrocode}
+%
+% When the attribute was in the list we issue a warning; this might
+% not be the users intention.
+%
+% \begin{macrocode}
+ \ifin@
+ \bbl@warning{%
+ You have more than once selected the attribute '##1'\\%
+ for language #1. Reported}%
+ \else
+% \end{macrocode}
+%
+% When we end up here the attribute is not selected before. So, we
+% add it to the list of selected attributes and execute the
+% associated \TeX-code.
+%
+% \begin{macrocode}
+ \bbl@exp{%
+ \\\bbl@add@list\\\bbl@known@attribs{\bbl@tempc-##1}}%
+ \edef\bbl@tempa{\bbl@tempc-##1}%
+ \expandafter\bbl@ifknown@ttrib\expandafter{\bbl@tempa}\bbl@attributes%
+ {\csname\bbl@tempc @attr@##1\endcsname}%
+ {\@attrerr{\bbl@tempc}{##1}}%
+ \fi}}}
+% \end{macrocode}
+%
+% This command should only be used in the preamble of a document.
+%
+% \begin{macrocode}
+\@onlypreamble\languageattribute
+% \end{macrocode}
+%
+% The error text to be issued when an unknown attribute is
+% selected.
+%
+% \begin{macrocode}
+\newcommand*{\@attrerr}[2]{%
+ \bbl@error
+ {The attribute #2 is unknown for language #1.}%
+ {Your command will be ignored, type <return> to proceed}}
+% \end{macrocode}
+%
+% \end{macro}
+%
+% \begin{macro}{\bbl@declare@ttribute}
+% This command adds the new language/attribute combination to the
+% list of known attributes.
+%
+% Then it defines a control sequence to be executed when the
+% attribute is used in a document. The result of this should be
+% that the macro |\extras...| for the current language is extended,
+% otherwise the attribute will not work as its code is removed from
+% memory at |\begin{document}|.
+%
+% \begin{macrocode}
+\def\bbl@declare@ttribute#1#2#3{%
+ \bbl@xin@{,#2,}{,\BabelModifiers,}%
+ \ifin@
+ \AfterBabelLanguage{#1}{\languageattribute{#1}{#2}}%
+ \fi
+ \bbl@add@list\bbl@attributes{#1-#2}%
+ \expandafter\def\csname#1@attr@#2\endcsname{#3}}
+% \end{macrocode}
+%
+% \end{macro}
+%
+% \begin{macro}{\bbl@ifattributeset}
+% This internal macro has 4 arguments. It can be used to interpret
+% \TeX\ code based on whether a certain attribute was set. This
+% command should appear inside the argument to |\AtBeginDocument|
+% because the attributes are set in the document preamble,
+% \emph{after} \babel\ is loaded.
+%
+% The first argument is the language, the second argument the
+% attribute being checked, and the third and fourth arguments are
+% the true and false clauses.
+%
+% \begin{macrocode}
+\def\bbl@ifattributeset#1#2#3#4{%
+% \end{macrocode}
+%
+% First we need to find out if any attributes were set; if not
+% we're done.
+%
+% \begin{macrocode}
+ \ifx\bbl@known@attribs\@undefined
+ \in@false
+ \else
+% \end{macrocode}
+%
+% The we need to check the list of known attributes.
+%
+% \begin{macrocode}
+ \bbl@xin@{,#1-#2,}{,\bbl@known@attribs,}%
+ \fi
+% \end{macrocode}
+%
+% When we're this far |\ifin@| has a value indicating if the
+% attribute in question was set or not. Just to be safe the code to
+% be executed is `thrown over the |\fi|'.
+%
+% \begin{macrocode}
+ \ifin@
+ \bbl@afterelse#3%
+ \else
+ \bbl@afterfi#4%
+ \fi
+ }
+% \end{macrocode}
+%
+% \end{macro}
+%
+% \begin{macro}{\bbl@ifknown@ttrib}
+% An internal macro to check whether a given language/attribute is
+% known. The macro takes 4 arguments, the language/attribute, the
+% attribute list, the \TeX-code to be executed when the attribute
+% is known and the \TeX-code to be executed otherwise.
+%
+% \begin{macrocode}
+\def\bbl@ifknown@ttrib#1#2{%
+% \end{macrocode}
+%
+% We first assume the attribute is unknown.
+%
+% \begin{macrocode}
+ \let\bbl@tempa\@secondoftwo
+% \end{macrocode}
+%
+% Then we loop over the list of known attributes, trying to find a
+% match.
+%
+% \begin{macrocode}
+ \bbl@loopx\bbl@tempb{#2}{%
+ \expandafter\in@\expandafter{\expandafter,\bbl@tempb,}{,#1,}%
+ \ifin@
+% \end{macrocode}
+%
+% When a match is found the definition of |\bbl@tempa| is changed.
+%
+% \begin{macrocode}
+ \let\bbl@tempa\@firstoftwo
+ \else
+ \fi}%
+% \end{macrocode}
+%
+% Finally we execute |\bbl@tempa|.
+%
+% \begin{macrocode}
+ \bbl@tempa
+}
+% \end{macrocode}
+%
+% \end{macro}
+%
+% \begin{macro}{\bbl@clear@ttribs}
+% This macro removes all the attribute code from \LaTeX's memory at
+% |\begin{document}| time (if any is present).
+%
+% \begin{macrocode}
+\def\bbl@clear@ttribs{%
+ \ifx\bbl@attributes\@undefined\else
+ \bbl@loopx\bbl@tempa{\bbl@attributes}{%
+ \expandafter\bbl@clear@ttrib\bbl@tempa.
+ }%
+ \let\bbl@attributes\@undefined
+ \fi}
+\def\bbl@clear@ttrib#1-#2.{%
+ \expandafter\let\csname#1@attr@#2\endcsname\@undefined}
+\AtBeginDocument{\bbl@clear@ttribs}
+% \end{macrocode}
+%
+% \end{macro}
+%
+% \subsection{Support for saving macro definitions}
+%
+% To save the meaning of control sequences using |\babel@save|, we
+% use temporary control sequences. To save hash table entries for
+% these control sequences, we don't use the name of the control
+% sequence to be saved to construct the temporary name. Instead we
+% simply use the value of a counter, which is reset to zero each time
+% we begin to save new values. This works well because we release
+% the saved meanings before we begin to save a new set of control
+% sequence meanings (see |\selectlanguage| and |\originalTeX|). Note
+% undefined macros are not undefined any more when saved -- they are
+% |\relax|'ed.
+%
+% \begin{macro}{\babel@savecnt}
+% \begin{macro}{\babel@beginsave}
+% The initialization of a new save cycle: reset the counter to
+% zero.
+%
+% \begin{macrocode}
+\bbl@trace{Macros for saving definitions}
+\def\babel@beginsave{\babel@savecnt\z@}
+% \end{macrocode}
+%
+% Before it's forgotten, allocate the counter and initialize all.
+%
+% \begin{macrocode}
+\newcount\babel@savecnt
+\babel@beginsave
+% \end{macrocode}
+%
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\babel@save}
+% The macro |\babel@save|\meta{csname} saves the current meaning of
+% the control sequence \meta{csname} to
+% |\originalTeX|\footnote{\cs{originalTeX} has to be
+% expandable, i.\,e.\ you shouldn't let it to \cs{relax}.}.
+% To do this, we let the current meaning to a temporary control
+% sequence, the restore commands are appended to |\originalTeX| and
+% the counter is incremented.
+%
+% \begin{macrocode}
+\def\babel@save#1{%
+ \expandafter\let\csname babel@\number\babel@savecnt\endcsname#1\relax
+ \toks@\expandafter{\originalTeX\let#1=}%
+ \bbl@exp{%
+ \def\\\originalTeX{\the\toks@\<babel@\number\babel@savecnt>\relax}}%
+ \advance\babel@savecnt\@ne}
+% \end{macrocode}
+%
+% \end{macro}
+%
+% \begin{macro}{\babel@savevariable}
+%
+% The macro |\babel@savevariable|\meta{variable} saves the value of
+% the variable. \meta{variable} can be anything allowed after the
+% |\the| primitive.
+%
+% \begin{macrocode}
+\def\babel@savevariable#1{%
+ \toks@\expandafter{\originalTeX #1=}%
+ \bbl@exp{\def\\\originalTeX{\the\toks@\the#1\relax}}}
+% \end{macrocode}
+%
+% \end{macro}
+%
+% \begin{macro}{\bbl@frenchspacing}
+% \begin{macro}{\bbl@nonfrenchspacing}
+% Some languages need to have |\frenchspacing| in effect. Others
+% don't want that. The command |\bbl@frenchspacing| switches it on
+% when it isn't already in effect and |\bbl@nonfrenchspacing|
+% switches it off if necessary.
+%
+% \begin{macrocode}
+\def\bbl@frenchspacing{%
+ \ifnum\the\sfcode`\.=\@m
+ \let\bbl@nonfrenchspacing\relax
+ \else
+ \frenchspacing
+ \let\bbl@nonfrenchspacing\nonfrenchspacing
+ \fi}
+\let\bbl@nonfrenchspacing\nonfrenchspacing
+% \end{macrocode}
+%
+% \end{macro}
+% \end{macro}
+%
+% \subsection{Short tags}
+%
+% \begin{macro}{\babeltags}
+% This macro is straightforward. After zapping spaces, we
+% loop over the list and define the macros |\text|\m{tag} and
+% |\|\m{tag}. Definitions are first expanded so that they don't
+% contain |\csname| but the actual macro.
+%
+% \changes{babel~3.9i}{2014/02/21}{Macro \cs{babeltags} added}
+%
+% \begin{macrocode}
+\bbl@trace{Short tags}
+\def\babeltags#1{%
+ \edef\bbl@tempa{\zap@space#1 \@empty}%
+ \def\bbl@tempb##1=##2\@@{%
+ \edef\bbl@tempc{%
+ \noexpand\newcommand
+ \expandafter\noexpand\csname ##1\endcsname{%
+ \noexpand\protect
+ \expandafter\noexpand\csname otherlanguage*\endcsname{##2}}
+ \noexpand\newcommand
+ \expandafter\noexpand\csname text##1\endcsname{%
+ \noexpand\foreignlanguage{##2}}}
+ \bbl@tempc}%
+ \bbl@for\bbl@tempa\bbl@tempa{%
+ \expandafter\bbl@tempb\bbl@tempa\@@}}
+% \end{macrocode}
+%
+% \end{macro}
+%
+% \subsection{Hyphens}
+%
+% \begin{macro}{\babelhyphenation}
+%
+% This macro saves hyphenation exceptions. Two macros are used to
+% store them: |\bbl@hyphenation@| for the global ones and
+% |\bbl@hyphenation<lang>| for language ones. See |\bbl@patterns|
+% above for further details. We make sure there is a space between
+% words when multiple commands are used.
+%
+% \changes{babel~3.9a}{2012/08/28}{Macro added}
+%
+% \begin{macrocode}
+\bbl@trace{Hyphens}
+\@onlypreamble\babelhyphenation
+\AtEndOfPackage{%
+ \newcommand\babelhyphenation[2][\@empty]{%
+ \ifx\bbl@hyphenation@\relax
+ \let\bbl@hyphenation@\@empty
+ \fi
+ \ifx\bbl@hyphlist\@empty\else
+ \bbl@warning{%
+ You must not intermingle \string\selectlanguage\space and\\%
+ \string\babelhyphenation\space or some exceptions will not\\%
+ be taken into account. Reported}%
+ \fi
+ \ifx\@empty#1%
+ \protected@edef\bbl@hyphenation@{\bbl@hyphenation@\space#2}%
+ \else
+ \bbl@vforeach{#1}{%
+ \def\bbl@tempa{##1}%
+ \bbl@fixname\bbl@tempa
+ \bbl@iflanguage\bbl@tempa{%
+ \bbl@csarg\protected@edef{hyphenation@\bbl@tempa}{%
+ \bbl@ifunset{bbl@hyphenation@\bbl@tempa}%
+ \@empty
+ {\csname bbl@hyphenation@\bbl@tempa\endcsname\space}%
+ #2}}}%
+ \fi}}
+% \end{macrocode}
+%
+% \end{macro}
+%
+% \begin{macro}{\bbl@allowhyphens}
+%
+% \changes{babel-3.9a}{2012/07/28}{Replaced many \cs{allowhyphens} by
+% \cs{bbl@allowhyphen}. They were either no-op or executed always.}
+% \changes{babel-3.9i}{2014/01/29}{\cs{bbl@allowhyphens} must be
+% ignored at the beginning of a paragraph or table cell.}
+% \changes{babel-3.9t}{2017/04/26}{Fixed misplaced \cs{nobreak} -
+% sx366454 - soft hyphens could vanish.}
+%
+% This macro makes hyphenation possible. Basically its definition
+% is nothing more than |\nobreak| |\hskip| \texttt{0pt plus
+% 0pt}\footnote{\TeX\ begins and ends a word for hyphenation at a
+% glue node. The penalty prevents a linebreak at this glue node.}.
+%
+% \begin{macrocode}
+\def\bbl@allowhyphens{\ifvmode\else\nobreak\hskip\z@skip\fi}
+\def\bbl@t@one{T1}
+\def\allowhyphens{\ifx\cf@encoding\bbl@t@one\else\bbl@allowhyphens\fi}
+% \end{macrocode}
+%
+% \end{macro}
+%
+% \changes{babel-3.9a}{2012/08/27}{Added \cs{babelhyphen} and related
+% macros}
+%
+% \begin{macro}{\babelhyphen}
+%
+% Macros to insert common hyphens. Note the space before |@| in
+% |\babelhyphen|. Instead of protecting it with
+% |\DeclareRobustCommand|, which could insert a |\relax|, we use
+% the same procedure as shorthands, with |\active@prefix|.
+%
+% \begin{macrocode}
+\newcommand\babelnullhyphen{\char\hyphenchar\font}
+\def\babelhyphen{\active@prefix\babelhyphen\bbl@hyphen}
+\def\bbl@hyphen{%
+ \@ifstar{\bbl@hyphen@i @}{\bbl@hyphen@i\@empty}}
+\def\bbl@hyphen@i#1#2{%
+ \bbl@ifunset{bbl@hy@#1#2\@empty}%
+ {\csname bbl@#1usehyphen\endcsname{\discretionary{#2}{}{#2}}}%
+ {\csname bbl@hy@#1#2\@empty\endcsname}}
+% \end{macrocode}
+%
+% The following two commands are used to wrap the ``hyphen'' and
+% set the behavior of the rest of the word -- the version with a
+% single |@| is used when further hyphenation is allowed, while
+% that with |@@| if no more hyphen are allowed. In both cases, if
+% the hyphen is preceded by a positive space, breaking after the
+% hyphen is disallowed.
+%
+% There should not be a discretionaty after a hyphen at the
+% beginning of a word, so it is prevented if preceded by a
+% skip. Unfortunately, this does handle cases like ``(-suffix)''.
+% |\nobreak| is always preceded by |\leavevmode|, in case the
+% shorthand starts a paragraph.
+%
+% \begin{macrocode}
+\def\bbl@usehyphen#1{%
+ \leavevmode
+ \ifdim\lastskip>\z@\mbox{#1}\else\nobreak#1\fi
+ \nobreak\hskip\z@skip}
+\def\bbl@@usehyphen#1{%
+ \leavevmode\ifdim\lastskip>\z@\mbox{#1}\else#1\fi}
+% \end{macrocode}
+%
+% The following macro inserts the hyphen char.
+%
+% \begin{macrocode}
+\def\bbl@hyphenchar{%
+ \ifnum\hyphenchar\font=\m@ne
+ \babelnullhyphen
+ \else
+ \char\hyphenchar\font
+ \fi}
+% \end{macrocode}
+%
+% Finally, we define the hyphen ``types''. Their names will not
+% change, so you may use them in |ldf|'s. After a space, the
+% |\mbox| in |\bbl@hy@nobreak| is redundant.
+%
+% \begin{macrocode}
+\def\bbl@hy@soft{\bbl@usehyphen{\discretionary{\bbl@hyphenchar}{}{}}}
+\def\bbl@hy@@soft{\bbl@@usehyphen{\discretionary{\bbl@hyphenchar}{}{}}}
+\def\bbl@hy@hard{\bbl@usehyphen\bbl@hyphenchar}
+\def\bbl@hy@@hard{\bbl@@usehyphen\bbl@hyphenchar}
+\def\bbl@hy@nobreak{\bbl@usehyphen{\mbox{\bbl@hyphenchar}}}
+\def\bbl@hy@@nobreak{\mbox{\bbl@hyphenchar}}
+\def\bbl@hy@repeat{%
+ \bbl@usehyphen{%
+ \discretionary{\bbl@hyphenchar}{\bbl@hyphenchar}{\bbl@hyphenchar}}}
+\def\bbl@hy@@repeat{%
+ \bbl@@usehyphen{%
+ \discretionary{\bbl@hyphenchar}{\bbl@hyphenchar}{\bbl@hyphenchar}}}
+\def\bbl@hy@empty{\hskip\z@skip}
+\def\bbl@hy@@empty{\discretionary{}{}{}}
+% \end{macrocode}
+%
+% \end{macro}
+%
+% \begin{macro}{\bbl@disc}
+% For some languages the macro |\bbl@disc| is used to ease the
+% insertion of discretionaries for letters that behave `abnormally'
+% at a breakpoint.
+%
+% \begin{macrocode}
+\def\bbl@disc#1#2{\nobreak\discretionary{#2-}{}{#1}\bbl@allowhyphens}
+% \end{macrocode}
+%
+% \end{macro}
+%
+% \subsection{Multiencoding strings}
+%
+% \changes{babel~3.9a}{2012/09/05}{Added tentative code for string
+% declarations}
+% \changes{babel~3.9a}{2012/12/24}{Added hooks}
+%
+% The aim following commands is to provide a commom interface for
+% strings in several encodings. They also contains several hooks which
+% can be ued by \luatex{} and \xetex. The code is organized here with
+% pseudo-guards, so we start with the basic commands.
+%
+% \paragraph{Tools}
+%
+% But first, a couple of tools. The first one makes global a local
+% variable. This is not the best solution, but it works.
+%
+% \begin{macrocode}
+\bbl@trace{Multiencoding strings}
+\def\bbl@toglobal#1{\global\let#1#1}
+\def\bbl@recatcode#1{%
+ \@tempcnta="7F
+ \def\bbl@tempa{%
+ \ifnum\@tempcnta>"FF\else
+ \catcode\@tempcnta=#1\relax
+ \advance\@tempcnta\@ne
+ \expandafter\bbl@tempa
+ \fi}%
+ \bbl@tempa}
+% \end{macrocode}
+%
+% The second one. We need to patch |\@uclclist|, but it is done once
+% and only if |\SetCase| is used or if strings are encoded. The code
+% is far from satisfactory for several reasons, including the fact
+% |\@uclclist| is not a list any more. Therefore a package option is
+% added to ignore it. Instead of gobbling the macro
+% getting the next two elements (usually |\reserved@a|), we pass it as
+% argument to |\bbl@uclc|. The parser is restarted inside
+% |\|\m{lang}|@bbl@uclc| because we do not know how many expansions
+% are necessary (depends on whether strings are encoded). The last
+% part is tricky -- when uppercasing, we have:
+%\begin{verbatim}
+% \let\bbl@tolower\@empty\bbl@toupper\@empty
+%\end{verbatim}
+% and starts over (and similarly when lowercasing).
+%
+% \changes{babel~3.9l}{2014/07/29}{Now tries to catch the parsing
+% macro. Removed some redundant code. Option |nocase|.}
+%
+% \begin{macrocode}
+\@ifpackagewith{babel}{nocase}%
+ {\let\bbl@patchuclc\relax}%
+ {\def\bbl@patchuclc{%
+ \global\let\bbl@patchuclc\relax
+ \g@addto@macro\@uclclist{\reserved@b{\reserved@b\bbl@uclc}}%
+ \gdef\bbl@uclc##1{%
+ \let\bbl@encoded\bbl@encoded@uclc
+ \bbl@ifunset{\languagename @bbl@uclc}% and resumes it
+ {##1}%
+ {\let\bbl@tempa##1\relax % Used by LANG@bbl@uclc
+ \csname\languagename @bbl@uclc\endcsname}%
+ {\bbl@tolower\@empty}{\bbl@toupper\@empty}}%
+ \gdef\bbl@tolower{\csname\languagename @bbl@lc\endcsname}%
+ \gdef\bbl@toupper{\csname\languagename @bbl@uc\endcsname}}}
+% \end{macrocode}
+%
+% \begin{macrocode}
+%<<*More package options>>
+\DeclareOption{nocase}{}
+%<</More package options>>
+% \end{macrocode}
+%
+% The following package options control the behavior of |\SetString|.
+%
+% \begin{macrocode}
+%<<*More package options>>
+\let\bbl@opt@strings\@nnil % accept strings=value
+\DeclareOption{strings}{\def\bbl@opt@strings{\BabelStringsDefault}}
+\DeclareOption{strings=encoded}{\let\bbl@opt@strings\relax}
+\def\BabelStringsDefault{generic}
+%<</More package options>>
+% \end{macrocode}
+%
+% \paragraph{Main command} This is the main command. With the
+% first use it is redefined to omit the basic setup in subsequent
+% blocks. We make sure strings contain actual letters in the range
+% 128-255, not active characters.
+%
+% \changes{babel~3.9g}{2013/07/29}{Added starred variant. A bit of
+% clean up. Removed \cs{UseString}, which didn't work.}
+% \changes{babel~3.9g}{2013/08/01}{Now several languages can be
+% processed with \cs{BabelLanguages}, if set in the ldf.}
+%
+% \begin{macrocode}
+\@onlypreamble\StartBabelCommands
+\def\StartBabelCommands{%
+ \begingroup
+ \bbl@recatcode{11}%
+ <@Macros local to BabelCommands@>
+ \def\bbl@provstring##1##2{%
+ \providecommand##1{##2}%
+ \bbl@toglobal##1}%
+ \global\let\bbl@scafter\@empty
+ \let\StartBabelCommands\bbl@startcmds
+ \ifx\BabelLanguages\relax
+ \let\BabelLanguages\CurrentOption
+ \fi
+ \begingroup
+ \let\bbl@screset\@nnil % local flag - disable 1st stopcommands
+ \StartBabelCommands}
+\def\bbl@startcmds{%
+ \ifx\bbl@screset\@nnil\else
+ \bbl@usehooks{stopcommands}{}%
+ \fi
+ \endgroup
+ \begingroup
+ \@ifstar
+ {\ifx\bbl@opt@strings\@nnil
+ \let\bbl@opt@strings\BabelStringsDefault
+ \fi
+ \bbl@startcmds@i}%
+ \bbl@startcmds@i}
+\def\bbl@startcmds@i#1#2{%
+ \edef\bbl@L{\zap@space#1 \@empty}%
+ \edef\bbl@G{\zap@space#2 \@empty}%
+ \bbl@startcmds@ii}
+% \end{macrocode}
+%
+% Parse the encoding info to get the label, input, and font parts.
+%
+% Select the behavior of |\SetString|. Thre are two main cases,
+% depending of if there is an optional argument: without it and
+% |strings=encoded|, strings are defined
+% always; otherwise, they are set only if they are still undefined
+% (ie, fallback values). With labelled blocks and
+% |strings=encoded|, define the strings, but with another value,
+% define strings only if the current label or font encoding is the
+% value of |strings|; otherwise (ie, no |strings| or a block whose
+% label is not in |strings=|) do nothing.
+%
+% We presume the current block is not loaded, and therefore set
+% (above) a couple of default values to gobble the arguments. Then,
+% these macros are redefined if necessary according to several
+% parameters.
+%
+% \changes{babel~3.9g}{2013/08/04}{Use \cs{ProvideTextCommand}, which
+% does with encoded strings what the manual says.}
+% \changes{babel~3.9h}{2013/11/08}{Tidied up code related to
+% \cs{bbl@scswitch}}
+%
+% \begin{macrocode}
+\newcommand\bbl@startcmds@ii[1][\@empty]{%
+ \let\SetString\@gobbletwo
+ \let\bbl@stringdef\@gobbletwo
+ \let\AfterBabelCommands\@gobble
+ \ifx\@empty#1%
+ \def\bbl@sc@label{generic}%
+ \def\bbl@encstring##1##2{%
+ \ProvideTextCommandDefault##1{##2}%
+ \bbl@toglobal##1%
+ \expandafter\bbl@toglobal\csname\string?\string##1\endcsname}%
+ \let\bbl@sctest\in@true
+ \else
+ \let\bbl@sc@charset\space % <- zapped below
+ \let\bbl@sc@fontenc\space % <- " "
+ \def\bbl@tempa##1=##2\@nil{%
+ \bbl@csarg\edef{sc@\zap@space##1 \@empty}{##2 }}%
+ \bbl@vforeach{label=#1}{\bbl@tempa##1\@nil}%
+ \def\bbl@tempa##1 ##2{% space -> comma
+ ##1%
+ \ifx\@empty##2\else\ifx,##1,\else,\fi\bbl@afterfi\bbl@tempa##2\fi}%
+ \edef\bbl@sc@fontenc{\expandafter\bbl@tempa\bbl@sc@fontenc\@empty}%
+ \edef\bbl@sc@label{\expandafter\zap@space\bbl@sc@label\@empty}%
+ \edef\bbl@sc@charset{\expandafter\zap@space\bbl@sc@charset\@empty}%
+ \def\bbl@encstring##1##2{%
+ \bbl@foreach\bbl@sc@fontenc{%
+ \bbl@ifunset{T@####1}%
+ {}%
+ {\ProvideTextCommand##1{####1}{##2}%
+ \bbl@toglobal##1%
+ \expandafter
+ \bbl@toglobal\csname####1\string##1\endcsname}}}%
+ \def\bbl@sctest{%
+ \bbl@xin@{,\bbl@opt@strings,}{,\bbl@sc@label,\bbl@sc@fontenc,}}%
+ \fi
+ \ifx\bbl@opt@strings\@nnil % ie, no strings key -> defaults
+ \else\ifx\bbl@opt@strings\relax % ie, strings=encoded
+ \let\AfterBabelCommands\bbl@aftercmds
+ \let\SetString\bbl@setstring
+ \let\bbl@stringdef\bbl@encstring
+ \else % ie, strings=value
+ \bbl@sctest
+ \ifin@
+ \let\AfterBabelCommands\bbl@aftercmds
+ \let\SetString\bbl@setstring
+ \let\bbl@stringdef\bbl@provstring
+ \fi\fi\fi
+ \bbl@scswitch
+ \ifx\bbl@G\@empty
+ \def\SetString##1##2{%
+ \bbl@error{Missing group for string \string##1}%
+ {You must assign strings to some category, typically\\%
+ captions or extras, but you set none}}%
+ \fi
+ \ifx\@empty#1%
+ \bbl@usehooks{defaultcommands}{}%
+ \else
+ \@expandtwoargs
+ \bbl@usehooks{encodedcommands}{{\bbl@sc@charset}{\bbl@sc@fontenc}}%
+ \fi}
+% \end{macrocode}
+%
+% There are two versions of |\bbl@scswitch|. The first version is
+% used when |ldf|s are read, and it makes sure
+% |\|\m{group}\m{language} is reset, but only once (|\bbl@screset|
+% is used to keep track of this). The second version is used in the
+% preamble and packages loaded after \babel{} and does nothing. The
+% macro |\bbl@forlang| loops |\bbl@L| but its body is executed only
+% if the value is in |\BabelLanguages| (inside \babel) or
+% |\date|\m{language} is defined (after \babel{} has been loaded).
+% There are also two version of |\bbl@forlang|. The first one skips
+% the current iteration if the language is not in |\BabelLanguages|
+% (used in |ldf|s), and the second one skips undefined languages
+% (after \babel{} has been loaded) .
+%
+% \begin{macrocode}
+\def\bbl@forlang#1#2{%
+ \bbl@for#1\bbl@L{%
+ \bbl@xin@{,#1,}{,\BabelLanguages,}%
+ \ifin@#2\relax\fi}}
+\def\bbl@scswitch{%
+ \bbl@forlang\bbl@tempa{%
+ \ifx\bbl@G\@empty\else
+ \ifx\SetString\@gobbletwo\else
+ \edef\bbl@GL{\bbl@G\bbl@tempa}%
+ \bbl@xin@{,\bbl@GL,}{,\bbl@screset,}%
+ \ifin@\else
+ \global\expandafter\let\csname\bbl@GL\endcsname\@undefined
+ \xdef\bbl@screset{\bbl@screset,\bbl@GL}%
+ \fi
+ \fi
+ \fi}}
+\AtEndOfPackage{%
+ \def\bbl@forlang#1#2{\bbl@for#1\bbl@L{\bbl@ifunset{date#1}{}{#2}}}%
+ \let\bbl@scswitch\relax}
+\@onlypreamble\EndBabelCommands
+\def\EndBabelCommands{%
+ \bbl@usehooks{stopcommands}{}%
+ \endgroup
+ \endgroup
+ \bbl@scafter}
+% \end{macrocode}
+%
+% Now we define commands to be used inside |\StartBabelCommands|.
+%
+% \paragraph{Strings} The following macro is the actual definition
+% of |\SetString| when it is ``active''
+%
+% First save the ``switcher''. Create it if undefined. Strings are
+% defined only if undefined (ie, like |\providescommmand|). With
+% the event |stringprocess| you can preprocess the string by
+% manipulating the value of |\BabelString|. If there are several
+% hooks assigned to this event, preprocessing is done in the same
+% order as defined. Finally, the string is set.
+%
+% \changes{babel~3.9g}{2013/07/29}{Added \cs{bbl@forlang} to ignore in
+% the preamble unknown languages, as described in the doc.}
+%
+% \begin{macrocode}
+\def\bbl@setstring#1#2{%
+ \bbl@forlang\bbl@tempa{%
+ \edef\bbl@LC{\bbl@tempa\bbl@stripslash#1}%
+ \bbl@ifunset{\bbl@LC}% eg, \germanchaptername
+ {\global\expandafter % TODO - con \bbl@exp ?
+ \bbl@add\csname\bbl@G\bbl@tempa\expandafter\endcsname\expandafter
+ {\expandafter\bbl@scset\expandafter#1\csname\bbl@LC\endcsname}}%
+ {}%
+ \def\BabelString{#2}%
+ \bbl@usehooks{stringprocess}{}%
+ \expandafter\bbl@stringdef
+ \csname\bbl@LC\expandafter\endcsname\expandafter{\BabelString}}}
+% \end{macrocode}
+%
+% Now, some addtional stuff to be used when encoded strings are
+% used. Captions then include |\bbl@encoded| for string to be
+% expanded in case transformations. It is |\relax| by default, but
+% in |\MakeUppercase| and |\MakeLowercase| its value is a modified
+% expandable |\@changed@cmd|.
+%
+% \changes{babel~3.9i}{2014/03/13}{Added code to expand captions in
+% case transformations.}
+%
+% \begin{macrocode}
+\ifx\bbl@opt@strings\relax
+ \def\bbl@scset#1#2{\def#1{\bbl@encoded#2}}
+ \bbl@patchuclc
+ \let\bbl@encoded\relax
+ \def\bbl@encoded@uclc#1{%
+ \@inmathwarn#1%
+ \expandafter\ifx\csname\cf@encoding\string#1\endcsname\relax
+ \expandafter\ifx\csname ?\string#1\endcsname\relax
+ \TextSymbolUnavailable#1%
+ \else
+ \csname ?\string#1\endcsname
+ \fi
+ \else
+ \csname\cf@encoding\string#1\endcsname
+ \fi}
+\else
+ \def\bbl@scset#1#2{\def#1{#2}}
+\fi
+% \end{macrocode}
+%
+% Define |\SetStringLoop|, which is actually set inside
+% |\StartBabelCommands|. The current definition is
+% somewhat complicated because we need a count, but |\count@| is
+% not under our control (remember |\SetString| may call hooks).
+% Instead of defining a dedicated count, we just ``pre-expand''
+% its value.
+%
+% \changes{babel~3.9h}{2013/10/16}{Tidied up and bug fixed - first
+% element expanded prematurely.}
+%
+% \begin{macrocode}
+%<<*Macros local to BabelCommands>>
+\def\SetStringLoop##1##2{%
+ \def\bbl@templ####1{\expandafter\noexpand\csname##1\endcsname}%
+ \count@\z@
+ \bbl@loop\bbl@tempa{##2}{% empty items and spaces are ok
+ \advance\count@\@ne
+ \toks@\expandafter{\bbl@tempa}%
+ \bbl@exp{%
+ \\\SetString\bbl@templ{\romannumeral\count@}{\the\toks@}%
+ \count@=\the\count@\relax}}}%
+%<</Macros local to BabelCommands>>
+% \end{macrocode}
+%
+% \paragraph{Delaying code} Now the definition of
+% |\AfterBabelCommands| when it is activated.
+%
+% \begin{macrocode}
+\def\bbl@aftercmds#1{%
+ \toks@\expandafter{\bbl@scafter#1}%
+ \xdef\bbl@scafter{\the\toks@}}
+% \end{macrocode}
+%
+% \paragraph{Case mapping}
+%
+% The command |\SetCase| provides a way to change the behavior of
+% |\MakeUppercase| and |\MakeLowercase|. |\bbl@tempa| is set by the
+% patched |\@uclclist| to the parsing command.
+%
+% \changes{babel~3.9h}{2013/11/08}{Use \cs{bbl@encstrings} - they
+% should be defined always, even if no `strings'}
+%
+% \begin{macrocode}
+%<<*Macros local to BabelCommands>>
+ \newcommand\SetCase[3][]{%
+ \bbl@patchuclc
+ \bbl@forlang\bbl@tempa{%
+ \expandafter\bbl@encstring
+ \csname\bbl@tempa @bbl@uclc\endcsname{\bbl@tempa##1}%
+ \expandafter\bbl@encstring
+ \csname\bbl@tempa @bbl@uc\endcsname{##2}%
+ \expandafter\bbl@encstring
+ \csname\bbl@tempa @bbl@lc\endcsname{##3}}}%
+%<</Macros local to BabelCommands>>
+% \end{macrocode}
+%
+% Macros to deal with case mapping for hyphenation. To decide if the
+% document is monolingual or multilingual, we make a rough guess --
+% just see if there is a comma in the languages list, built in the
+% first pass of the package options.
+%
+% \begin{macrocode}
+%<<*Macros local to BabelCommands>>
+ \newcommand\SetHyphenMap[1]{%
+ \bbl@forlang\bbl@tempa{%
+ \expandafter\bbl@stringdef
+ \csname\bbl@tempa @bbl@hyphenmap\endcsname{##1}}}
+%<</Macros local to BabelCommands>>
+% \end{macrocode}
+%
+% There are 3 helper macros which do most of the work for you.
+%
+% \begin{macrocode}
+\newcommand\BabelLower[2]{% one to one.
+ \ifnum\lccode#1=#2\else
+ \babel@savevariable{\lccode#1}%
+ \lccode#1=#2\relax
+ \fi}
+\newcommand\BabelLowerMM[4]{% many-to-many
+ \@tempcnta=#1\relax
+ \@tempcntb=#4\relax
+ \def\bbl@tempa{%
+ \ifnum\@tempcnta>#2\else
+ \@expandtwoargs\BabelLower{\the\@tempcnta}{\the\@tempcntb}%
+ \advance\@tempcnta#3\relax
+ \advance\@tempcntb#3\relax
+ \expandafter\bbl@tempa
+ \fi}%
+ \bbl@tempa}
+\newcommand\BabelLowerMO[4]{% many-to-one
+ \@tempcnta=#1\relax
+ \def\bbl@tempa{%
+ \ifnum\@tempcnta>#2\else
+ \@expandtwoargs\BabelLower{\the\@tempcnta}{#4}%
+ \advance\@tempcnta#3
+ \expandafter\bbl@tempa
+ \fi}%
+ \bbl@tempa}
+% \end{macrocode}
+%
+% The following package options control the behavior of
+% hyphenation mapping.
+%
+% \changes{babel~3.9t}{2017/04/28}{Renamed \cs{bbl@hymapopt} to
+% \cs{bbl@opt@hyphenmap} for consistency}
+%
+% \begin{macrocode}
+%<<*More package options>>
+\DeclareOption{hyphenmap=off}{\chardef\bbl@opt@hyphenmap\z@}
+\DeclareOption{hyphenmap=first}{\chardef\bbl@opt@hyphenmap\@ne}
+\DeclareOption{hyphenmap=select}{\chardef\bbl@opt@hyphenmap\tw@}
+\DeclareOption{hyphenmap=other}{\chardef\bbl@opt@hyphenmap\thr@@}
+\DeclareOption{hyphenmap=other*}{\chardef\bbl@opt@hyphenmap4\relax}
+%<</More package options>>
+% \end{macrocode}
+%
+% Initial setup to provide a default behavior if |hypenmap|
+% is not set.
+%
+% \begin{macrocode}
+\AtEndOfPackage{%
+ \ifx\bbl@opt@hyphenmap\@undefined
+ \bbl@xin@{,}{\bbl@language@opts}%
+ \chardef\bbl@opt@hyphenmap\ifin@4\else\@ne\fi
+ \fi}
+% \end{macrocode}
+%
+% \subsection{Macros common to a number of languages}
+%
+% \begin{macro}{\set@low@box}
+% The following macro is used to lower quotes to the same level as
+% the comma. It prepares its argument in box register~0.
+%
+% \begin{macrocode}
+\bbl@trace{Macros related to glyphs}
+\def\set@low@box#1{\setbox\tw@\hbox{,}\setbox\z@\hbox{#1}%
+ \dimen\z@\ht\z@ \advance\dimen\z@ -\ht\tw@%
+ \setbox\z@\hbox{\lower\dimen\z@ \box\z@}\ht\z@\ht\tw@ \dp\z@\dp\tw@}
+% \end{macrocode}
+%
+% \end{macro}
+%
+% \begin{macro}{\save@sf@q}
+% The macro |\save@sf@q| is used to save and reset the current
+% space factor.
+%
+% \begin{macrocode}
+\def\save@sf@q#1{\leavevmode
+ \begingroup
+ \edef\@SF{\spacefactor\the\spacefactor}#1\@SF
+ \endgroup}
+% \end{macrocode}
+%
+% \end{macro}
+%
+% \subsection{Making glyphs available}
+%
+% This section makes a number of glyphs available that either do not
+% exist in the \texttt{OT1} encoding and have to be `faked', or
+% that are not accessible through \file{T1enc.def}.
+%
+% \subsubsection{Quotation marks}
+%
+% \begin{macro}{\quotedblbase}
+% In the \texttt{T1} encoding the opening double quote at the
+% baseline is available as a separate character, accessible via
+% |\quotedblbase|. In the \texttt{OT1} encoding it is not
+% available, therefore we make it available by lowering the normal
+% open quote character to the baseline.
+%
+% \begin{macrocode}
+\ProvideTextCommand{\quotedblbase}{OT1}{%
+ \save@sf@q{\set@low@box{\textquotedblright\/}%
+ \box\z@\kern-.04em\bbl@allowhyphens}}
+% \end{macrocode}
+%
+% Make sure that when an encoding other than \texttt{OT1} or
+% \texttt{T1} is used this glyph can still be typeset.
+%
+% \begin{macrocode}
+\ProvideTextCommandDefault{\quotedblbase}{%
+ \UseTextSymbol{OT1}{\quotedblbase}}
+% \end{macrocode}
+%
+% \end{macro}
+%
+% \begin{macro}{\quotesinglbase}
+% We also need the single quote character at the baseline.
+%
+% \begin{macrocode}
+\ProvideTextCommand{\quotesinglbase}{OT1}{%
+ \save@sf@q{\set@low@box{\textquoteright\/}%
+ \box\z@\kern-.04em\bbl@allowhyphens}}
+% \end{macrocode}
+%
+% Make sure that when an encoding other than \texttt{OT1} or
+% \texttt{T1} is used this glyph can still be typeset.
+%
+% \begin{macrocode}
+\ProvideTextCommandDefault{\quotesinglbase}{%
+ \UseTextSymbol{OT1}{\quotesinglbase}}
+% \end{macrocode}
+%
+% \end{macro}
+%
+% \begin{macro}{\guillemotleft}
+% \begin{macro}{\guillemotright}
+% The guillemet characters are not available in \texttt{OT1}
+% encoding. They are faked.
+%
+% \begin{macrocode}
+\ProvideTextCommand{\guillemotleft}{OT1}{%
+ \ifmmode
+ \ll
+ \else
+ \save@sf@q{\nobreak
+ \raise.2ex\hbox{$\scriptscriptstyle\ll$}\bbl@allowhyphens}%
+ \fi}
+\ProvideTextCommand{\guillemotright}{OT1}{%
+ \ifmmode
+ \gg
+ \else
+ \save@sf@q{\nobreak
+ \raise.2ex\hbox{$\scriptscriptstyle\gg$}\bbl@allowhyphens}%
+ \fi}
+% \end{macrocode}
+%
+% Make sure that when an encoding other than \texttt{OT1} or
+% \texttt{T1} is used these glyphs can still be typeset.
+%
+% \begin{macrocode}
+\ProvideTextCommandDefault{\guillemotleft}{%
+ \UseTextSymbol{OT1}{\guillemotleft}}
+\ProvideTextCommandDefault{\guillemotright}{%
+ \UseTextSymbol{OT1}{\guillemotright}}
+% \end{macrocode}
+%
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\guilsinglleft}
+% \begin{macro}{\guilsinglright}
+% The single guillemets are not available in \texttt{OT1}
+% encoding. They are faked.
+%
+% \begin{macrocode}
+\ProvideTextCommand{\guilsinglleft}{OT1}{%
+ \ifmmode
+ <%
+ \else
+ \save@sf@q{\nobreak
+ \raise.2ex\hbox{$\scriptscriptstyle<$}\bbl@allowhyphens}%
+ \fi}
+\ProvideTextCommand{\guilsinglright}{OT1}{%
+ \ifmmode
+ >%
+ \else
+ \save@sf@q{\nobreak
+ \raise.2ex\hbox{$\scriptscriptstyle>$}\bbl@allowhyphens}%
+ \fi}
+% \end{macrocode}
+%
+% Make sure that when an encoding other than \texttt{OT1} or
+% \texttt{T1} is used these glyphs can still be typeset.
+%
+% \begin{macrocode}
+\ProvideTextCommandDefault{\guilsinglleft}{%
+ \UseTextSymbol{OT1}{\guilsinglleft}}
+\ProvideTextCommandDefault{\guilsinglright}{%
+ \UseTextSymbol{OT1}{\guilsinglright}}
+% \end{macrocode}
+%
+% \end{macro}
+% \end{macro}
+%
+% \subsubsection{Letters}
+%
+% \begin{macro}{\ij}
+% \begin{macro}{\IJ}
+% The dutch language uses the letter `ij'. It is available in
+% \texttt{T1} encoded fonts, but not in the \texttt{OT1} encoded
+% fonts. Therefore we fake it for the \texttt{OT1} encoding.
+%
+% \changes{babel~3.9a}{2012/07/28}{Removed the first \cs{allowhyphens}.
+% Moved the second one just after the kern.}
+%
+% \begin{macrocode}
+\DeclareTextCommand{\ij}{OT1}{%
+ i\kern-0.02em\bbl@allowhyphens j}
+\DeclareTextCommand{\IJ}{OT1}{%
+ I\kern-0.02em\bbl@allowhyphens J}
+\DeclareTextCommand{\ij}{T1}{\char188}
+\DeclareTextCommand{\IJ}{T1}{\char156}
+% \end{macrocode}
+%
+% Make sure that when an encoding other than \texttt{OT1} or
+% \texttt{T1} is used these glyphs can still be typeset.
+%
+% \begin{macrocode}
+\ProvideTextCommandDefault{\ij}{%
+ \UseTextSymbol{OT1}{\ij}}
+\ProvideTextCommandDefault{\IJ}{%
+ \UseTextSymbol{OT1}{\IJ}}
+% \end{macrocode}
+%
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\dj}
+% \begin{macro}{\DJ}
+% The croatian language needs the letters |\dj| and |\DJ|; they are
+% available in the \texttt{T1} encoding, but not in the
+% \texttt{OT1} encoding by default.
+%
+% Some code to construct these glyphs for the \texttt{OT1} encoding
+% was made available to me by Stipcevic Mario,
+% (\texttt{stipcevic@olimp.irb.hr}).
+%
+% \begin{macrocode}
+\def\crrtic@{\hrule height0.1ex width0.3em}
+\def\crttic@{\hrule height0.1ex width0.33em}
+\def\ddj@{%
+ \setbox0\hbox{d}\dimen@=\ht0
+ \advance\dimen@1ex
+ \dimen@.45\dimen@
+ \dimen@ii\expandafter\rem@pt\the\fontdimen\@ne\font\dimen@
+ \advance\dimen@ii.5ex
+ \leavevmode\rlap{\raise\dimen@\hbox{\kern\dimen@ii\vbox{\crrtic@}}}}
+\def\DDJ@{%
+ \setbox0\hbox{D}\dimen@=.55\ht0
+ \dimen@ii\expandafter\rem@pt\the\fontdimen\@ne\font\dimen@
+ \advance\dimen@ii.15ex % correction for the dash position
+ \advance\dimen@ii-.15\fontdimen7\font % correction for cmtt font
+ \dimen\thr@@\expandafter\rem@pt\the\fontdimen7\font\dimen@
+ \leavevmode\rlap{\raise\dimen@\hbox{\kern\dimen@ii\vbox{\crttic@}}}}
+%
+\DeclareTextCommand{\dj}{OT1}{\ddj@ d}
+\DeclareTextCommand{\DJ}{OT1}{\DDJ@ D}
+% \end{macrocode}
+%
+% Make sure that when an encoding other than \texttt{OT1} or
+% \texttt{T1} is used these glyphs can still be typeset.
+%
+% \begin{macrocode}
+\ProvideTextCommandDefault{\dj}{%
+ \UseTextSymbol{OT1}{\dj}}
+\ProvideTextCommandDefault{\DJ}{%
+ \UseTextSymbol{OT1}{\DJ}}
+% \end{macrocode}
+%
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\SS}
+% For the \texttt{T1} encoding |\SS| is defined and selects a
+% specific glyph from the font, but for other encodings it is not
+% available. Therefore we make it available here.
+%
+% \begin{macrocode}
+\DeclareTextCommand{\SS}{OT1}{SS}
+\ProvideTextCommandDefault{\SS}{\UseTextSymbol{OT1}{\SS}}
+% \end{macrocode}
+%
+% \end{macro}
+%
+% \subsubsection{Shorthands for quotation marks}
+%
+% Shorthands are provided for a number of different quotation
+% marks, which make them usable both outside and inside mathmode.
+% They are defined with |\ProvideTextCommandDefault|, but this is
+% very likely not required because their definitions are based on
+% encoding dependent macros.
+%
+% \changes{babel~3.16}{2018/01/02}{Adapted to TU and refactored -
+% redundant code.}
+%
+% \begin{macro}{\glq}
+% \begin{macro}{\grq}
+%
+% The `german' single quotes.
+%
+% \begin{macrocode}
+\ProvideTextCommandDefault{\glq}{%
+ \textormath{\quotesinglbase}{\mbox{\quotesinglbase}}}
+% \end{macrocode}
+%
+% The definition of |\grq| depends on the fontencoding. With
+% \texttt{T1} encoding no extra kerning is needed.
+%
+% \begin{macrocode}
+\ProvideTextCommand{\grq}{T1}{%
+ \textormath{\kern\z@\textquoteleft}{\mbox{\textquoteleft}}}
+\ProvideTextCommand{\grq}{TU}{%
+ \textormath{\textquoteleft}{\mbox{\textquoteleft}}}
+\ProvideTextCommand{\grq}{OT1}{%
+ \save@sf@q{\kern-.0125em
+ \textormath{\textquoteleft}{\mbox{\textquoteleft}}%
+ \kern.07em\relax}}
+\ProvideTextCommandDefault{\grq}{\UseTextSymbol{OT1}\grq}
+% \end{macrocode}
+%
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\glqq}
+% \begin{macro}{\grqq}
+%
+% The `german' double quotes.
+%
+% \begin{macrocode}
+\ProvideTextCommandDefault{\glqq}{%
+ \textormath{\quotedblbase}{\mbox{\quotedblbase}}}
+% \end{macrocode}
+%
+% The definition of |\grqq| depends on the fontencoding. With
+% \texttt{T1} encoding no extra kerning is needed.
+%
+% \begin{macrocode}
+\ProvideTextCommand{\grqq}{T1}{%
+ \textormath{\textquotedblleft}{\mbox{\textquotedblleft}}}
+\ProvideTextCommand{\grqq}{TU}{%
+ \textormath{\textquotedblleft}{\mbox{\textquotedblleft}}}
+\ProvideTextCommand{\grqq}{OT1}{%
+ \save@sf@q{\kern-.07em
+ \textormath{\textquotedblleft}{\mbox{\textquotedblleft}}%
+ \kern.07em\relax}}
+\ProvideTextCommandDefault{\grqq}{\UseTextSymbol{OT1}\grqq}
+% \end{macrocode}
+%
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\flq}
+% \begin{macro}{\frq}
+%
+% The `french' single guillemets.
+%
+% \begin{macrocode}
+\ProvideTextCommandDefault{\flq}{%
+ \textormath{\guilsinglleft}{\mbox{\guilsinglleft}}}
+\ProvideTextCommandDefault{\frq}{%
+ \textormath{\guilsinglright}{\mbox{\guilsinglright}}}
+% \end{macrocode}
+%
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\flqq}
+% \begin{macro}{\frqq}
+%
+% The `french' double guillemets.
+%
+% \begin{macrocode}
+\ProvideTextCommandDefault{\flqq}{%
+ \textormath{\guillemotleft}{\mbox{\guillemotleft}}}
+\ProvideTextCommandDefault{\frqq}{%
+ \textormath{\guillemotright}{\mbox{\guillemotright}}}
+% \end{macrocode}
+%
+% \end{macro}
+% \end{macro}
+%
+% \subsubsection{Umlauts and tremas}
+%
+% The command |\"| needs to have a different effect for different
+% languages. For German for instance, the `umlaut' should be
+% positioned lower than the default position for placing it over
+% the letters a, o, u, A, O and U. When placed over an e, i, E or I
+% it can retain its normal position. For Dutch the same glyph is
+% always placed in the lower position.
+%
+% \begin{macro}{\umlauthigh}
+%
+% \begin{macro}{\umlautlow}
+% To be able to provide both positions of |\"| we provide two
+% commands to switch the positioning, the default will be
+% |\umlauthigh| (the normal positioning).
+%
+% \begin{macrocode}
+\def\umlauthigh{%
+ \def\bbl@umlauta##1{\leavevmode\bgroup%
+ \expandafter\accent\csname\f@encoding dqpos\endcsname
+ ##1\bbl@allowhyphens\egroup}%
+ \let\bbl@umlaute\bbl@umlauta}
+\def\umlautlow{%
+ \def\bbl@umlauta{\protect\lower@umlaut}}
+\def\umlautelow{%
+ \def\bbl@umlaute{\protect\lower@umlaut}}
+\umlauthigh
+% \end{macrocode}
+%
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\lower@umlaut}
+% The command |\lower@umlaut| is used to position the |\"| closer
+% to the letter.
+%
+% We want the umlaut character lowered, nearer to the letter. To do
+% this we need an extra \meta{dimen} register.
+%
+% \begin{macrocode}
+\expandafter\ifx\csname U@D\endcsname\relax
+ \csname newdimen\endcsname\U@D
+\fi
+% \end{macrocode}
+%
+% The following code fools \TeX's \texttt{make\_accent} procedure
+% about the current x-height of the font to force another placement
+% of the umlaut character.
+% First we have to save the current x-height of the font, because
+% we'll change this font dimension and this is always done
+% globally.
+%
+% Then we compute the new x-height in such a way that the umlaut
+% character is lowered to the base character. The value of
+% \texttt{.45ex} depends on the \MF\ parameters with which the
+% fonts were built. (Just try out, which value will look best.)
+% If the new x-height is too low, it is not changed.
+% Finally we call the |\accent| primitive, reset the old x-height
+% and insert the base character in the argument.
+%
+% \begin{macrocode}
+\def\lower@umlaut#1{%
+ \leavevmode\bgroup
+ \U@D 1ex%
+ {\setbox\z@\hbox{%
+ \expandafter\char\csname\f@encoding dqpos\endcsname}%
+ \dimen@ -.45ex\advance\dimen@\ht\z@
+ \ifdim 1ex<\dimen@ \fontdimen5\font\dimen@ \fi}%
+ \expandafter\accent\csname\f@encoding dqpos\endcsname
+ \fontdimen5\font\U@D #1%
+ \egroup}
+% \end{macrocode}
+%
+% \end{macro}
+%
+% For all vowels we declare |\"| to be a composite command which
+% uses |\bbl@umlauta| or |\bbl@umlaute| to position the umlaut
+% character. We need to be sure that these definitions override the
+% ones that are provided when the package \pkg{fontenc} with
+% option \Lopt{OT1} is used. Therefore these declarations are
+% postponed until the beginning of the document. Note these
+% definitions only apply to some languages, but
+% babel sets them for \textit{all} languages -- you may want to
+% redefine |\bbl@umlauta| and/or |\bbl@umlaute| for a language
+% in the corresponding |ldf| (using the babel switching mechanism,
+% of course).
+%
+% \begin{macrocode}
+\AtBeginDocument{%
+ \DeclareTextCompositeCommand{\"}{OT1}{a}{\bbl@umlauta{a}}%
+ \DeclareTextCompositeCommand{\"}{OT1}{e}{\bbl@umlaute{e}}%
+ \DeclareTextCompositeCommand{\"}{OT1}{i}{\bbl@umlaute{\i}}%
+ \DeclareTextCompositeCommand{\"}{OT1}{\i}{\bbl@umlaute{\i}}%
+ \DeclareTextCompositeCommand{\"}{OT1}{o}{\bbl@umlauta{o}}%
+ \DeclareTextCompositeCommand{\"}{OT1}{u}{\bbl@umlauta{u}}%
+ \DeclareTextCompositeCommand{\"}{OT1}{A}{\bbl@umlauta{A}}%
+ \DeclareTextCompositeCommand{\"}{OT1}{E}{\bbl@umlaute{E}}%
+ \DeclareTextCompositeCommand{\"}{OT1}{I}{\bbl@umlaute{I}}%
+ \DeclareTextCompositeCommand{\"}{OT1}{O}{\bbl@umlauta{O}}%
+ \DeclareTextCompositeCommand{\"}{OT1}{U}{\bbl@umlauta{U}}%
+}
+% \end{macrocode}
+%
+% Finally, the default is to use English as the main language.
+%
+% \changes{babel~3.9a}{2012-05-17}{Languages are best assigned with
+% \cs{chardef}, not \cs{let}}
+%
+% \begin{macrocode}
+\ifx\l@english\@undefined
+ \chardef\l@english\z@
+\fi
+\main@language{english}
+% \end{macrocode}
+%
+% \subsection{Layout}
+%
+% \textbf{Work in progress}.
+%
+% Layout is mainly intended to set bidi documents, but there is at
+% least a tool useful in general.
+%
+% \begin{macrocode}
+\bbl@trace{Bidi layout}
+\providecommand\IfBabelLayout[3]{#3}%
+\newcommand\BabelPatchSection[1]{%
+ \@ifundefined{#1}{}{%
+ \bbl@exp{\let\<bbl@ss@#1>\<#1>}%
+ \@namedef{#1}{%
+ \@ifstar{\bbl@presec@s{#1}}%
+ {\@dblarg{\bbl@presec@x{#1}}}}}}
+\def\bbl@presec@x#1[#2]#3{%
+ \bbl@exp{%
+ \\\select@language@x{\bbl@main@language}%
+ \\\@nameuse{bbl@sspre@#1}%
+ \\\@nameuse{bbl@ss@#1}%
+ [\\\foreignlanguage{\languagename}{\unexpanded{#2}}]%
+ {\\\foreignlanguage{\languagename}{\unexpanded{#3}}}%
+ \\\select@language@x{\languagename}}}
+\def\bbl@presec@s#1#2{%
+ \bbl@exp{%
+ \\\select@language@x{\bbl@main@language}%
+ \\\@nameuse{bbl@sspre@#1}%
+ \\\@nameuse{bbl@ss@#1}*%
+ {\\\foreignlanguage{\languagename}{\unexpanded{#2}}}%
+ \\\select@language@x{\languagename}}}
+\IfBabelLayout{sectioning}%
+ {\BabelPatchSection{part}%
+ \BabelPatchSection{chapter}%
+ \BabelPatchSection{section}%
+ \BabelPatchSection{subsection}%
+ \BabelPatchSection{subsubsection}%
+ \BabelPatchSection{paragraph}%
+ \BabelPatchSection{subparagraph}%
+ \def\babel@toc#1{%
+ \select@language@x{\bbl@main@language}}}{}
+\IfBabelLayout{captions}%
+ {\BabelPatchSection{caption}}{}
+% \end{macrocode}
+%
+% \subsection{Load engine specific macros}
+%
+% \begin{macrocode}
+\bbl@trace{Input engine specific macros}
+\ifcase\bbl@engine
+ \input txtbabel.def
+\or
+ \input luababel.def
+\or
+ \input xebabel.def
+\fi
+% \end{macrocode}
+%
+% \changes{babel~3.18}{2018/02/14}{Moved \cs{babelprovide}, also for
+% plain}
+%
+% \subsection{Creating languages}
+%
+% |\babelprovide| is a general purpose tool for creating and modifying
+% languages. It creates the language infrastructure, and loads, if
+% requested, an |ini| file. It may be used in conjunction to previouly
+% loaded |ldf| files.
+%
+% \changes{3.10}{2017/05/19}{Added \cs{babelprovide}}
+% \changes{3.13}{2017/08/30}{Added \cs{import}, which also reads
+% dates. Some refactoring in the ini reader.}
+% \changes{3.15}{2017/10/30}{New keys script, language}
+% \changes{3.16}{2018/01/02}{Make sure ensuring works even before
+% the language is selected}
+% \changes{babel~3.19}{2018/04/23}{New option - mapfont. Currently
+% only with direction}
+% \changes{babel~3.20}{2018/05/01}{Handle native digits (TeX level).
+% New option - maparabic.}
+% \changes{babel~3.23}{2018/09/01}{Valueless import}
+% \changes{babel~3.26}{2018/10/16}{Quick fix for xetex - test the
+% script for intraspace}
+% \changes{3.30}{2019/04/22}{Read some basic parameters from ini
+% even without import.}
+% \changes{3.30}{2019/04/22}{Native digits (lua level).}
+% \changes{3.30}{2019/04/22}{New attribute in luatex for `locale'. Also
+% \cs{localeid}}
+% \changes{3.32}{2019/05/30}{Activate CJK line breaking with an explicit
+% intraspace.}
+%
+% \begin{macrocode}
+\bbl@trace{Creating languages and reading ini files}
+\newcommand\babelprovide[2][]{%
+ \let\bbl@savelangname\languagename
+ \edef\bbl@savelocaleid{\the\localeid}%
+ % Set name and locale id
+ \def\languagename{#2}%
+ \bbl@id@assign
+ \chardef\localeid\@nameuse{bbl@id@@\languagename}%
+ \let\bbl@KVP@captions\@nil
+ \let\bbl@KVP@import\@nil
+ \let\bbl@KVP@main\@nil
+ \let\bbl@KVP@script\@nil
+ \let\bbl@KVP@language\@nil
+ \let\bbl@KVP@dir\@nil
+ \let\bbl@KVP@hyphenrules\@nil
+ \let\bbl@KVP@mapfont\@nil
+ \let\bbl@KVP@maparabic\@nil
+ \let\bbl@KVP@mapdigits\@nil
+ \let\bbl@KVP@intraspace\@nil
+ \let\bbl@KVP@intrapenalty\@nil
+ \bbl@forkv{#1}{\bbl@csarg\def{KVP@##1}{##2}}% TODO - error handling
+ \ifx\bbl@KVP@import\@nil\else
+ \bbl@exp{\\\bbl@ifblank{\bbl@KVP@import}}%
+ {\begingroup
+ \def\BabelBeforeIni##1##2{\gdef\bbl@KVP@import{##1}\endinput}%
+ \InputIfFileExists{babel-#2.tex}{}{}%
+ \endgroup}%
+ {}%
+ \fi
+ \ifx\bbl@KVP@captions\@nil
+ \let\bbl@KVP@captions\bbl@KVP@import
+ \fi
+ % Load ini
+ \bbl@ifunset{date#2}%
+ {\bbl@provide@new{#2}}%
+ {\bbl@ifblank{#1}%
+ {\bbl@error
+ {If you want to modify `#2' you must tell how in\\%
+ the optional argument. See the manual for the\\%
+ available options.}%
+ {Use this macro as documented}}%
+ {\bbl@provide@renew{#2}}}%
+ % Post tasks
+ \bbl@exp{\\\babelensure[exclude=\\\today]{#2}}%
+ \bbl@ifunset{bbl@ensure@\languagename}%
+ {\bbl@exp{%
+ \\\DeclareRobustCommand\<bbl@ensure@\languagename>[1]{%
+ \\\foreignlanguage{\languagename}%
+ {####1}}}}%
+ {}%
+ % At this point all parameters are defined if 'import'. Now we
+ % execute some code depending on them. But what about if nothing was
+ % imported? We just load the very basic parameters: ids and a few
+ % more.
+ \bbl@ifunset{bbl@lname@#2}%
+ {\def\BabelBeforeIni##1##2{%
+ \begingroup
+ \catcode`\[=12 \catcode`\]=12 \catcode`\==12 %
+ \let\bbl@ini@captions@aux\@gobbletwo
+ \def\bbl@inidate ####1.####2.####3.####4\relax ####5####6{}%
+ \bbl@read@ini{##1}%
+ \bbl@exportkey{chrng}{characters.ranges}{}%
+ \bbl@exportkey{dgnat}{numbers.digits.native}{}%
+ \endgroup}% boxed, to avoid extra spaces:
+ {\setbox\z@\hbox{\InputIfFileExists{babel-#2.tex}{}{}}}}%
+ {}%
+ % -
+ % Override script and language names with script= and language=
+ \ifx\bbl@KVP@script\@nil\else
+ \bbl@csarg\edef{sname@#2}{\bbl@KVP@script}%
+ \fi
+ \ifx\bbl@KVP@language\@nil\else
+ \bbl@csarg\edef{lname@#2}{\bbl@KVP@language}%
+ \fi
+ % For bidi texts, to switch the language based on direction
+ \ifx\bbl@KVP@mapfont\@nil\else
+ \bbl@ifsamestring{\bbl@KVP@mapfont}{direction}{}%
+ {\bbl@error{Option `\bbl@KVP@mapfont' unknown for\\%
+ mapfont. Use `direction'.%
+ {See the manual for details.}}}%
+ \bbl@ifunset{bbl@lsys@\languagename}{\bbl@provide@lsys{\languagename}}{}%
+ \bbl@ifunset{bbl@wdir@\languagename}{\bbl@provide@dirs{\languagename}}{}%
+ \ifx\bbl@mapselect\@undefined
+ \AtBeginDocument{%
+ \expandafter\bbl@add\csname selectfont \endcsname{{\bbl@mapselect}}%
+ {\selectfont}}%
+ \def\bbl@mapselect{%
+ \let\bbl@mapselect\relax
+ \edef\bbl@prefontid{\fontid\font}}%
+ \def\bbl@mapdir##1{%
+ {\def\languagename{##1}%
+ \let\bbl@ifrestoring\@firstoftwo % avoid font warning
+ \bbl@switchfont
+ \directlua{Babel.fontmap
+ [\the\csname bbl@wdir@##1\endcsname]%
+ [\bbl@prefontid]=\fontid\font}}}%
+ \fi
+ \bbl@exp{\\\bbl@add\\\bbl@mapselect{\\\bbl@mapdir{\languagename}}}%
+ \fi
+ % For East Asian, Southeast Asian, if interspace in ini - TODO: as hook?
+ \ifx\bbl@KVP@intraspace\@nil\else % We may override the ini
+ \bbl@csarg\edef{intsp@#2}{\bbl@KVP@intraspace}%
+ \fi
+ \ifcase\bbl@engine\or
+ \bbl@ifunset{bbl@intsp@\languagename}{}%
+ {\expandafter\ifx\csname bbl@intsp@\languagename\endcsname\@empty\else
+ \bbl@xin@{\bbl@cs{sbcp@\languagename}}{Hant,Hans,Jpan,Kore,Kana}%
+ \ifin@
+ \bbl@cjkintraspace
+ \directlua{
+ Babel = Babel or {}
+ Babel.locale_props = Babel.locale_props or {}
+ Babel.locale_props[\the\localeid].linebreak = 'c'
+ }%
+ \bbl@exp{\\\bbl@intraspace\bbl@cs{intsp@\languagename}\\\@@}%
+ \ifx\bbl@KVP@intrapenalty\@nil
+ \bbl@intrapenalty0\@@
+ \fi
+ \else
+ \bbl@seaintraspace
+ \bbl@exp{\\\bbl@intraspace\bbl@cs{intsp@\languagename}\\\@@}%
+ \directlua{
+ Babel = Babel or {}
+ Babel.sea_ranges = Babel.sea_ranges or {}
+ Babel.set_chranges('\bbl@cs{sbcp@\languagename}',
+ '\bbl@cs{chrng@\languagename}')
+ }%
+ \ifx\bbl@KVP@intrapenalty\@nil
+ \bbl@intrapenalty0\@@
+ \fi
+ \fi
+ \fi
+ \ifx\bbl@KVP@intrapenalty\@nil\else
+ \expandafter\bbl@intrapenalty\bbl@KVP@intrapenalty\@@
+ \fi}%
+ \or
+ \bbl@xin@{\bbl@cs{sbcp@\languagename}}{Thai,Laoo,Khmr}%
+ \ifin@
+ \bbl@ifunset{bbl@intsp@\languagename}{}%
+ {\expandafter\ifx\csname bbl@intsp@\languagename\endcsname\@empty\else
+ \ifx\bbl@KVP@intraspace\@nil
+ \bbl@exp{%
+ \\\bbl@intraspace\bbl@cs{intsp@\languagename}\\\@@}%
+ \fi
+ \ifx\bbl@KVP@intrapenalty\@nil
+ \bbl@intrapenalty0\@@
+ \fi
+ \fi
+ \ifx\bbl@KVP@intraspace\@nil\else % We may override the ini
+ \expandafter\bbl@intraspace\bbl@KVP@intraspace\@@
+ \fi
+ \ifx\bbl@KVP@intrapenalty\@nil\else
+ \expandafter\bbl@intrapenalty\bbl@KVP@intrapenalty\@@
+ \fi
+ \ifx\bbl@ispacesize\@undefined
+ \AtBeginDocument{%
+ \expandafter\bbl@add
+ \csname selectfont \endcsname{\bbl@ispacesize}}%
+ \def\bbl@ispacesize{\bbl@cs{xeisp@\bbl@cs{sbcp@\languagename}}}%
+ \fi}%
+ \fi
+ \fi
+ % Native digits, if provided in ini (TeX level, xe and lua)
+ \ifcase\bbl@engine\else
+ \bbl@ifunset{bbl@dgnat@\languagename}{}%
+ {\expandafter\ifx\csname bbl@dgnat@\languagename\endcsname\@empty\else
+ \expandafter\expandafter\expandafter
+ \bbl@setdigits\csname bbl@dgnat@\languagename\endcsname
+ \ifx\bbl@KVP@maparabic\@nil\else
+ \ifx\bbl@latinarabic\@undefined
+ \expandafter\let\expandafter\@arabic
+ \csname bbl@counter@\languagename\endcsname
+ \else % ie, if layout=counters, which redefines \@arabic
+ \expandafter\let\expandafter\bbl@latinarabic
+ \csname bbl@counter@\languagename\endcsname
+ \fi
+ \fi
+ \fi}%
+ \fi
+ % Native digits (lua level).
+ \ifodd\bbl@engine
+ \ifx\bbl@KVP@mapdigits\@nil\else
+ \bbl@ifunset{bbl@dgnat@\languagename}{}%
+ {\RequirePackage{luatexbase}%
+ \bbl@activate@preotf
+ \directlua{
+ Babel = Babel or {} %%% -> presets in luababel
+ Babel.digits_mapped = true
+ Babel.digits = Babel.digits or {}
+ Babel.digits[\the\localeid] =
+ table.pack(string.utfvalue('\bbl@cs{dgnat@\languagename}'))
+ if not Babel.numbers then
+ function Babel.numbers(head)
+ local LOCALE = luatexbase.registernumber'bbl@attr@locale'
+ local GLYPH = node.id'glyph'
+ local inmath = false
+ for item in node.traverse(head) do
+ if not inmath and item.id == GLYPH then
+ local temp = node.get_attribute(item, LOCALE)
+ if Babel.digits[temp] then
+ local chr = item.char
+ if chr > 47 and chr < 58 then
+ item.char = Babel.digits[temp][chr-47]
+ end
+ end
+ elseif item.id == node.id'math' then
+ inmath = (item.subtype == 0)
+ end
+ end
+ return head
+ end
+ end
+ }}
+ \fi
+ \fi
+ % To load or reaload the babel-*.tex, if require.babel in ini
+ \bbl@ifunset{bbl@rqtex@\languagename}{}%
+ {\expandafter\ifx\csname bbl@rqtex@\languagename\endcsname\@empty\else
+ \let\BabelBeforeIni\@gobbletwo
+ \chardef\atcatcode=\catcode`\@
+ \catcode`\@=11\relax
+ \InputIfFileExists{babel-\bbl@cs{rqtex@\languagename}.tex}{}{}%
+ \catcode`\@=\atcatcode
+ \let\atcatcode\relax
+ \fi}%
+ \let\languagename\bbl@savelangname
+ \chardef\localeid\bbl@savelocaleid\relax}
+% \end{macrocode}
+%
+% A tool to define the macros for native digits from the list provided
+% in the |ini| file. Somewhat convoluted because there are 10 digits,
+% but only 9 arguments in \TeX.
+%
+% \begin{macrocode}
+\def\bbl@setdigits#1#2#3#4#5{%
+ \bbl@exp{%
+ \def\<\languagename digits>####1{% ie, \langdigits
+ \<bbl@digits@\languagename>####1\\\@nil}%
+ \def\<\languagename counter>####1{% ie, \langcounter
+ \\\expandafter\<bbl@counter@\languagename>%
+ \\\csname c@####1\endcsname}%
+ \def\<bbl@counter@\languagename>####1{% ie, \bbl@counter@lang
+ \\\expandafter\<bbl@digits@\languagename>%
+ \\\number####1\\\@nil}}%
+ \def\bbl@tempa##1##2##3##4##5{%
+ \bbl@exp{% Wow, quite a lot of hashes! :-(
+ \def\<bbl@digits@\languagename>########1{%
+ \\\ifx########1\\\@nil % ie, \bbl@digits@lang
+ \\\else
+ \\\ifx0########1#1%
+ \\\else\\\ifx1########1#2%
+ \\\else\\\ifx2########1#3%
+ \\\else\\\ifx3########1#4%
+ \\\else\\\ifx4########1#5%
+ \\\else\\\ifx5########1##1%
+ \\\else\\\ifx6########1##2%
+ \\\else\\\ifx7########1##3%
+ \\\else\\\ifx8########1##4%
+ \\\else\\\ifx9########1##5%
+ \\\else########1%
+ \\\fi\\\fi\\\fi\\\fi\\\fi\\\fi\\\fi\\\fi\\\fi\\\fi
+ \\\expandafter\<bbl@digits@\languagename>%
+ \\\fi}}}%
+ \bbl@tempa}
+% \end{macrocode}
+%
+% Depending on whether or not the language exists, we define two macros.
+%
+% \changes{3.22}{2018/06/05}{Fix - Error with \cs{chapter} if empty in ini.}-
+%
+% \begin{macrocode}
+\def\bbl@provide@new#1{%
+ \@namedef{date#1}{}% marks lang exists - required by \StartBabelCommands
+ \@namedef{extras#1}{}%
+ \@namedef{noextras#1}{}%
+ \StartBabelCommands*{#1}{captions}%
+ \ifx\bbl@KVP@captions\@nil % and also if import, implicit
+ \def\bbl@tempb##1{% elt for \bbl@captionslist
+ \ifx##1\@empty\else
+ \bbl@exp{%
+ \\\SetString\\##1{%
+ \\\bbl@nocaption{\bbl@stripslash##1}{#1\bbl@stripslash##1}}}%
+ \expandafter\bbl@tempb
+ \fi}%
+ \expandafter\bbl@tempb\bbl@captionslist\@empty
+ \else
+ \bbl@read@ini{\bbl@KVP@captions}% Here all letters cat = 11
+ \bbl@after@ini
+ \bbl@savestrings
+ \fi
+ \StartBabelCommands*{#1}{date}%
+ \ifx\bbl@KVP@import\@nil
+ \bbl@exp{%
+ \\\SetString\\\today{\\\bbl@nocaption{today}{#1today}}}%
+ \else
+ \bbl@savetoday
+ \bbl@savedate
+ \fi
+ \EndBabelCommands
+ \bbl@exp{%
+ \def\<#1hyphenmins>{%
+ {\bbl@ifunset{bbl@lfthm@#1}{2}{\@nameuse{bbl@lfthm@#1}}}%
+ {\bbl@ifunset{bbl@rgthm@#1}{3}{\@nameuse{bbl@rgthm@#1}}}}}%
+ \bbl@provide@hyphens{#1}%
+ \ifx\bbl@KVP@main\@nil\else
+ \expandafter\main@language\expandafter{#1}%
+ \fi}
+\def\bbl@provide@renew#1{%
+ \ifx\bbl@KVP@captions\@nil\else
+ \StartBabelCommands*{#1}{captions}%
+ \bbl@read@ini{\bbl@KVP@captions}% Here all letters cat = 11
+ \bbl@after@ini
+ \bbl@savestrings
+ \EndBabelCommands
+ \fi
+ \ifx\bbl@KVP@import\@nil\else
+ \StartBabelCommands*{#1}{date}%
+ \bbl@savetoday
+ \bbl@savedate
+ \EndBabelCommands
+ \fi
+ \bbl@provide@hyphens{#1}}
+% \end{macrocode}
+%
+% The |hyphenrules| option is handled with an auxiliary macro.
+%
+% \changes{3.14}{2017/10/03}{Take into account ini settings for
+% hyphenrules if `import'.}
+%
+% \begin{macrocode}
+\def\bbl@provide@hyphens#1{%
+ \let\bbl@tempa\relax
+ \ifx\bbl@KVP@hyphenrules\@nil\else
+ \bbl@replace\bbl@KVP@hyphenrules{ }{,}%
+ \bbl@foreach\bbl@KVP@hyphenrules{%
+ \ifx\bbl@tempa\relax % if not yet found
+ \bbl@ifsamestring{##1}{+}%
+ {{\bbl@exp{\\\addlanguage\<l@##1>}}}%
+ {}%
+ \bbl@ifunset{l@##1}%
+ {}%
+ {\bbl@exp{\let\bbl@tempa\<l@##1>}}%
+ \fi}%
+ \fi
+ \ifx\bbl@tempa\relax % if no opt or no language in opt found
+ \ifx\bbl@KVP@import\@nil\else % if importing
+ \bbl@exp{% and hyphenrules is not empty
+ \\\bbl@ifblank{\@nameuse{bbl@hyphr@#1}}%
+ {}%
+ {\let\\\bbl@tempa\<l@\@nameuse{bbl@hyphr@\languagename}>}}%
+ \fi
+ \fi
+ \bbl@ifunset{bbl@tempa}% ie, relax or undefined
+ {\bbl@ifunset{l@#1}% no hyphenrules found - fallback
+ {\bbl@exp{\\\adddialect\<l@#1>\language}}%
+ {}}% so, l@<lang> is ok - nothing to do
+ {\bbl@exp{\\\adddialect\<l@#1>\bbl@tempa}}% found in opt list or ini
+ \bbl@ifunset{bbl@prehc@\languagename}%
+ {}% TODO - XeTeX, based on \babelfont and HyphenChar?
+ {\ifodd\bbl@engine\bbl@exp{%
+ \\\bbl@ifblank{\@nameuse{bbl@prehc@#1}}%
+ {}%
+ {\\\AddBabelHook[\languagename]{babel-prehc-\languagename}{patterns}%
+ {\prehyphenchar=\@nameuse{bbl@prehc@\languagename}\relax}}}%
+ \fi}}
+% \end{macrocode}
+%
+% The reader of |ini| files. There are 3 possible cases: a section name
+% (in the form |[...]|), a comment (starting with |;|) and a
+% key/value pair. \textit{TODO - Work in progress.}
+%
+% \begin{macrocode}
+\def\bbl@read@ini#1{%
+ \openin1=babel-#1.ini % FIXME - number must not be hardcoded
+ \ifeof1
+ \bbl@error
+ {There is no ini file for the requested language\\%
+ (#1). Perhaps you misspelled it or your installation\\%
+ is not complete.}%
+ {Fix the name or reinstall babel.}%
+ \else
+ \let\bbl@section\@empty
+ \let\bbl@savestrings\@empty
+ \let\bbl@savetoday\@empty
+ \let\bbl@savedate\@empty
+ \let\bbl@inireader\bbl@iniskip
+ \bbl@info{Importing data from babel-#1.ini for \languagename}%
+ \loop
+ \if T\ifeof1F\fi T\relax % Trick, because inside \loop
+ \endlinechar\m@ne
+ \read1 to \bbl@line
+ \endlinechar`\^^M
+ \ifx\bbl@line\@empty\else
+ \expandafter\bbl@iniline\bbl@line\bbl@iniline
+ \fi
+ \repeat
+ \fi}
+\def\bbl@iniline#1\bbl@iniline{%
+ \@ifnextchar[\bbl@inisec{\@ifnextchar;\bbl@iniskip\bbl@inireader}#1\@@}% ]
+% \end{macrocode}
+%
+% The special cases for comment lines and sections are handled by the
+% two following commands. In sections, we provide the posibility to
+% take extra actions at the end or at the start (TODO - but note the last
+% section is not ended). By default, key=val pairs are ignored.
+%
+% \begin{macrocode}
+\def\bbl@iniskip#1\@@{}% if starts with ;
+\def\bbl@inisec[#1]#2\@@{% if starts with opening bracket
+ \@nameuse{bbl@secpost@\bbl@section}% ends previous section
+ \def\bbl@section{#1}%
+ \@nameuse{bbl@secpre@\bbl@section}% starts current section
+ \bbl@ifunset{bbl@inikv@#1}%
+ {\let\bbl@inireader\bbl@iniskip}%
+ {\bbl@exp{\let\\\bbl@inireader\<bbl@inikv@#1>}}}
+% \end{macrocode}
+%
+% Reads a key=val line and stores the trimmed val in
+% |\bbl@@kv@<section>.<key>|.
+%
+% \begin{macrocode}
+\def\bbl@inikv#1=#2\@@{% key=value
+ \bbl@trim@def\bbl@tempa{#1}%
+ \bbl@trim\toks@{#2}%
+ \bbl@csarg\edef{@kv@\bbl@section.\bbl@tempa}{\the\toks@}}
+% \end{macrocode}
+%
+% The previous assignments are local, so we need to export them. If
+% the value is empty, we can provide a default value.
+%
+% \begin{macrocode}
+\def\bbl@exportkey#1#2#3{%
+ \bbl@ifunset{bbl@@kv@#2}%
+ {\bbl@csarg\gdef{#1@\languagename}{#3}}%
+ {\expandafter\ifx\csname bbl@@kv@#2\endcsname\@empty
+ \bbl@csarg\gdef{#1@\languagename}{#3}%
+ \else
+ \bbl@exp{\global\let\<bbl@#1@\languagename>\<bbl@@kv@#2>}%
+ \fi}}
+% \end{macrocode}
+%
+% Key-value pairs are treated differently depending on the section in
+% the |ini| file. The following macros are the readers for
+% |identification| and |typography|.
+%
+% \begin{macrocode}
+\let\bbl@inikv@identification\bbl@inikv
+\def\bbl@secpost@identification{%
+ \bbl@exportkey{lname}{identification.name.english}{}%
+ \bbl@exportkey{lbcp}{identification.tag.bcp47}{}%
+ \bbl@exportkey{lotf}{identification.tag.opentype}{dflt}%
+ \bbl@exportkey{sname}{identification.script.name}{}%
+ \bbl@exportkey{sbcp}{identification.script.tag.bcp47}{}%
+ \bbl@exportkey{sotf}{identification.script.tag.opentype}{DFLT}}
+\let\bbl@inikv@typography\bbl@inikv
+\let\bbl@inikv@characters\bbl@inikv
+\let\bbl@inikv@numbers\bbl@inikv
+\def\bbl@after@ini{%
+ \bbl@exportkey{lfthm}{typography.lefthyphenmin}{2}%
+ \bbl@exportkey{rgthm}{typography.righthyphenmin}{3}%
+ \bbl@exportkey{prehc}{typography.prehyphenchar}{}%
+ \bbl@exportkey{hyphr}{typography.hyphenrules}{}%
+ \bbl@exportkey{intsp}{typography.intraspace}{}%
+ \bbl@exportkey{jstfy}{typography.justify}{w}%
+ \bbl@exportkey{chrng}{characters.ranges}{}%
+ \bbl@exportkey{dgnat}{numbers.digits.native}{}%
+ \bbl@exportkey{rqtex}{identification.require.babel}{}%
+ \bbl@xin@{0.5}{\@nameuse{bbl@@kv@identification.version}}%
+ \ifin@
+ \bbl@warning{%
+ There are neither captions nor date in `\languagename'.\\%
+ It may not be suitable for proper typesetting, and it\\%
+ could change. Reported}%
+ \fi
+ \bbl@xin@{0.9}{\@nameuse{bbl@@kv@identification.version}}%
+ \ifin@
+ \bbl@warning{%
+ The `\languagename' date format may not be suitable\\%
+ for proper typesetting, and therefore it very likely will\\%
+ change in a future release. Reported}%
+ \fi
+ \bbl@toglobal\bbl@savetoday
+ \bbl@toglobal\bbl@savedate}
+% \end{macrocode}
+%
+% Now |captions| and |captions.licr|, depending on the engine. And
+% below also for dates. They rely on a few auxiliary macros. It is
+% expected the ini file provides the complete set in Unicode and LICR,
+% in that order.
+%
+% \begin{macrocode}
+\ifcase\bbl@engine
+ \bbl@csarg\def{inikv@captions.licr}#1=#2\@@{%
+ \bbl@ini@captions@aux{#1}{#2}}
+\else
+ \def\bbl@inikv@captions#1=#2\@@{%
+ \bbl@ini@captions@aux{#1}{#2}}
+\fi
+% \end{macrocode}
+%
+% The auxiliary macro for captions define |\<caption>name|.
+%
+% \begin{macrocode}
+\def\bbl@ini@captions@aux#1#2{%
+ \bbl@trim@def\bbl@tempa{#1}%
+ \bbl@ifblank{#2}%
+ {\bbl@exp{%
+ \toks@{\\\bbl@nocaption{\bbl@tempa}{\languagename\bbl@tempa name}}}}%
+ {\bbl@trim\toks@{#2}}%
+ \bbl@exp{%
+ \\\bbl@add\\\bbl@savestrings{%
+ \\\SetString\<\bbl@tempa name>{\the\toks@}}}}
+% \end{macrocode}
+%
+% But dates are more complex. The full date format is stores in
+% |date.gregorian|, so we must read it in non-Unicode engines, too
+% (saved months are just discarded when the LICR section is reached).
+%
+% TODO. Remove copypaste pattern.
+%
+% \changes{3.16}{2018/01/02}{Fix - dates were severely broken.}
+% \changes{3.28}{2019/04/01}{Start work on calendars.}
+%
+% \begin{macrocode}
+\bbl@csarg\def{inikv@date.gregorian}#1=#2\@@{% for defaults
+ \bbl@inidate#1...\relax{#2}{}}
+\bbl@csarg\def{inikv@date.islamic}#1=#2\@@{%
+ \bbl@inidate#1...\relax{#2}{islamic}}
+\bbl@csarg\def{inikv@date.hebrew}#1=#2\@@{%
+ \bbl@inidate#1...\relax{#2}{hebrew}}
+\bbl@csarg\def{inikv@date.persian}#1=#2\@@{%
+ \bbl@inidate#1...\relax{#2}{persian}}
+\bbl@csarg\def{inikv@date.indian}#1=#2\@@{%
+ \bbl@inidate#1...\relax{#2}{indian}}
+\ifcase\bbl@engine
+ \bbl@csarg\def{inikv@date.gregorian.licr}#1=#2\@@{% override
+ \bbl@inidate#1...\relax{#2}{}}
+ \bbl@csarg\def{secpre@date.gregorian.licr}{% discard uni
+ \ifcase\bbl@engine\let\bbl@savedate\@empty\fi}
+\fi
+% eg: 1=months, 2=wide, 3=1, 4=dummy
+\def\bbl@inidate#1.#2.#3.#4\relax#5#6{% TODO - ignore with 'captions'
+ \bbl@trim@def\bbl@tempa{#1.#2}%
+ \bbl@ifsamestring{\bbl@tempa}{months.wide}% to savedate
+ {\bbl@trim@def\bbl@tempa{#3}%
+ \bbl@trim\toks@{#5}%
+ \bbl@exp{%
+ \\\bbl@add\\\bbl@savedate{%
+ \\\SetString\<month\romannumeral\bbl@tempa#6name>{\the\toks@}}}}%
+ {\bbl@ifsamestring{\bbl@tempa}{date.long}% defined now
+ {\bbl@trim@def\bbl@toreplace{#5}%
+ \bbl@TG@@date
+ \global\bbl@csarg\let{date@\languagename}\bbl@toreplace
+ \bbl@exp{%
+ \gdef\<\languagename date>{\\\protect\<\languagename date >}%
+ \gdef\<\languagename date >####1####2####3{%
+ \\\bbl@usedategrouptrue
+ \<bbl@ensure@\languagename>{%
+ \<bbl@date@\languagename>{####1}{####2}{####3}}}%
+ \\\bbl@add\\\bbl@savetoday{%
+ \\\SetString\\\today{%
+ \<\languagename date>{\\\the\year}{\\\the\month}{\\\the\day}}}}}}%
+ {}}
+% \end{macrocode}
+%
+% Dates will require some macros for the basic formatting. They may be
+% redefined by language, so ``semi-public'' names (camel case) are
+% used. Oddly enough, the CLDR places particles like “deâ€
+% inconsistently in either in the date or in the month name.
+%
+% \begin{macrocode}
+\let\bbl@calendar\@empty
+\newcommand\BabelDateSpace{\nobreakspace}
+\newcommand\BabelDateDot{.\@}
+\newcommand\BabelDated[1]{{\number#1}}
+\newcommand\BabelDatedd[1]{{\ifnum#1<10 0\fi\number#1}}
+\newcommand\BabelDateM[1]{{\number#1}}
+\newcommand\BabelDateMM[1]{{\ifnum#1<10 0\fi\number#1}}
+\newcommand\BabelDateMMMM[1]{{%
+ \csname month\romannumeral#1\bbl@calendar name\endcsname}}%
+\newcommand\BabelDatey[1]{{\number#1}}%
+\newcommand\BabelDateyy[1]{{%
+ \ifnum#1<10 0\number#1 %
+ \else\ifnum#1<100 \number#1 %
+ \else\ifnum#1<1000 \expandafter\@gobble\number#1 %
+ \else\ifnum#1<10000 \expandafter\@gobbletwo\number#1 %
+ \else
+ \bbl@error
+ {Currently two-digit years are restricted to the\\
+ range 0-9999.}%
+ {There is little you can do. Sorry.}%
+ \fi\fi\fi\fi}}
+\newcommand\BabelDateyyyy[1]{{\number#1}} % FIXME - add leading 0
+\def\bbl@replace@finish@iii#1{%
+ \bbl@exp{\def\\#1####1####2####3{\the\toks@}}}
+\def\bbl@TG@@date{%
+ \bbl@replace\bbl@toreplace{[ ]}{\BabelDateSpace{}}%
+ \bbl@replace\bbl@toreplace{[.]}{\BabelDateDot{}}%
+ \bbl@replace\bbl@toreplace{[d]}{\BabelDated{####3}}%
+ \bbl@replace\bbl@toreplace{[dd]}{\BabelDatedd{####3}}%
+ \bbl@replace\bbl@toreplace{[M]}{\BabelDateM{####2}}%
+ \bbl@replace\bbl@toreplace{[MM]}{\BabelDateMM{####2}}%
+ \bbl@replace\bbl@toreplace{[MMMM]}{\BabelDateMMMM{####2}}%
+ \bbl@replace\bbl@toreplace{[y]}{\BabelDatey{####1}}%
+ \bbl@replace\bbl@toreplace{[yy]}{\BabelDateyy{####1}}%
+ \bbl@replace\bbl@toreplace{[yyyy]}{\BabelDateyyyy{####1}}%
+% Note after \bbl@replace \toks@ contains the resulting string.
+% TODO - Using this implicit behavior doesn't seem a good idea.
+ \bbl@replace@finish@iii\bbl@toreplace}
+% \end{macrocode}
+%
+% Language and Script values to be used when defining a font or
+% setting the direction are set with the following macros.
+%
+% \begin{macrocode}
+\def\bbl@provide@lsys#1{%
+ \bbl@ifunset{bbl@lname@#1}%
+ {\bbl@ini@ids{#1}}%
+ {}%
+ \bbl@csarg\let{lsys@#1}\@empty
+ \bbl@ifunset{bbl@sname@#1}{\bbl@csarg\gdef{sname@#1}{Default}}{}%
+ \bbl@ifunset{bbl@sotf@#1}{\bbl@csarg\gdef{sotf@#1}{DFLT}}{}%
+ \bbl@csarg\bbl@add@list{lsys@#1}{Script=\bbl@cs{sname@#1}}%
+ \bbl@ifunset{bbl@lname@#1}{}%
+ {\bbl@csarg\bbl@add@list{lsys@#1}{Language=\bbl@cs{lname@#1}}}%
+ \bbl@csarg\bbl@toglobal{lsys@#1}}
+% \end{macrocode}
+%
+% The following |ini| reader ignores everything but the
+% |identification| section. It is called when a font is defined (ie,
+% when the language is first selected) to know which script/language
+% must be enabled. This means we must make sure a few characters are
+% not active. The |ini| is not read directly, but with a proxy |tex|
+% file named as the language.
+%
+% \changes{3.16}{2018/01/02}{Load ids inside a box, to prevent extra
+% spaces.}
+%
+% \begin{macrocode}
+\def\bbl@ini@ids#1{%
+ \def\BabelBeforeIni##1##2{%
+ \begingroup
+ \bbl@add\bbl@secpost@identification{\closein1 }%
+ \catcode`\[=12 \catcode`\]=12 \catcode`\==12 %
+ \bbl@read@ini{##1}%
+ \endgroup}% boxed, to avoid extra spaces:
+ {\setbox\z@\hbox{\InputIfFileExists{babel-#1.tex}{}{}}}}
+% \end{macrocode}
+%
+% \section{The kernel of Babel (\texttt{babel.def}, only \LaTeX)}
+%
+% \subsection{The redefinition of the style commands}
+%
+% The rest of the code in this file can only be processed by
+% \LaTeX, so we check the current format. If it is plain \TeX,
+% processing should stop here. But, because of the need to limit
+% the scope of the definition of |\format|, a macro that is used
+% locally in the following |\if|~statement, this comparison is done
+% inside a group. To prevent \TeX\ from complaining about an
+% unclosed group, the processing of the command |\endinput| is
+% deferred until after the group is closed. This is accomplished by
+% the command |\aftergroup|.
+%
+% \begin{macrocode}
+{\def\format{lplain}
+\ifx\fmtname\format
+\else
+ \def\format{LaTeX2e}
+ \ifx\fmtname\format
+ \else
+ \aftergroup\endinput
+ \fi
+\fi}
+% \end{macrocode}
+%
+% \subsection{Cross referencing macros}
+%
+% The \LaTeX\ book states:
+% \begin{quote}
+% The \emph{key} argument is any sequence of letters, digits, and
+% punctuation symbols; upper- and lowercase letters are regarded as
+% different.
+% \end{quote}
+% When the above quote should still be true when a document is
+% typeset in a language that has active characters, special care
+% has to be taken of the category codes of these characters when
+% they appear in an argument of the cross referencing macros.
+%
+% When a cross referencing command processes its argument, all
+% tokens in this argument should be character tokens with category
+% `letter' or `other'.
+%
+% The only way to accomplish this in most cases is to use the trick
+% described in the \TeX book~\cite{DEK} (Appendix~D, page~382).
+% The primitive |\meaning| applied to a token expands to the
+% current meaning of this token. For example, `|\meaning\A|' with
+% |\A| defined as `|\def\A#1{\B}|' expands to the characters
+% `|macro:#1->\B|' with all category codes set to `other' or
+% `space'.
+% \begin{macro}{\newlabel}
+% The macro |\label| writes a line with a |\newlabel| command
+% into the |.aux| file to define labels.
+%
+% \begin{macrocode}
+%\bbl@redefine\newlabel#1#2{%
+% \@safe@activestrue\org@newlabel{#1}{#2}\@safe@activesfalse}
+% \end{macrocode}
+%
+% \end{macro}
+%
+% \begin{macro}{\@newl@bel}
+% We need to change the definition of the \LaTeX-internal macro
+% |\@newl@bel|. This is needed because we need to make sure that
+% shorthand characters expand to their non-active version.
+%
+% The following package options control which macros are to be
+% redefined.
+%
+% \begin{macrocode}
+%<<*More package options>>
+\DeclareOption{safe=none}{\let\bbl@opt@safe\@empty}
+\DeclareOption{safe=bib}{\def\bbl@opt@safe{B}}
+\DeclareOption{safe=ref}{\def\bbl@opt@safe{R}}
+%<</More package options>>
+% \end{macrocode}
+%
+% First we open a new group to keep the changed setting of
+% |\protect| local and then we set the |@safe@actives| switch to
+% true to make sure that any shorthand that appears in any of the
+% arguments immediately expands to its non-active self.
+%
+% \begin{macrocode}
+\bbl@trace{Cross referencing macros}
+\ifx\bbl@opt@safe\@empty\else
+ \def\@newl@bel#1#2#3{%
+ {\@safe@activestrue
+ \bbl@ifunset{#1@#2}%
+ \relax
+ {\gdef\@multiplelabels{%
+ \@latex@warning@no@line{There were multiply-defined labels}}%
+ \@latex@warning@no@line{Label `#2' multiply defined}}%
+ \global\@namedef{#1@#2}{#3}}}
+% \end{macrocode}
+%
+% \end{macro}
+%
+% \begin{macro}{\@testdef}
+% An internal \LaTeX\ macro used to test if the labels that have
+% been written on the |.aux| file have changed. It is called by
+% the |\enddocument| macro. This macro needs to be completely
+% rewritten, using |\meaning|. The reason for this is that in some
+% cases the expansion of |\#1@#2| contains the same characters as
+% the |#3|; but the character codes differ. Therefore \LaTeX\ keeps
+% reporting that the labels may have changed.
+%
+% \begin{macrocode}
+ \CheckCommand*\@testdef[3]{%
+ \def\reserved@a{#3}%
+ \expandafter\ifx\csname#1@#2\endcsname\reserved@a
+ \else
+ \@tempswatrue
+ \fi}
+% \end{macrocode}
+%
+% Now that we made sure that |\@testdef| still has the same
+% definition we can rewrite it. First we make the shorthands
+% `safe'.
+%
+% \begin{macrocode}
+ \def\@testdef#1#2#3{%
+ \@safe@activestrue
+% \end{macrocode}
+%
+% Then we use |\bbl@tempa| as an `alias' for the macro that
+% contains the label which is being checked.
+%
+% \begin{macrocode}
+ \expandafter\let\expandafter\bbl@tempa\csname #1@#2\endcsname
+% \end{macrocode}
+%
+% Then we define |\bbl@tempb| just as |\@newl@bel| does it.
+%
+% \begin{macrocode}
+ \def\bbl@tempb{#3}%
+ \@safe@activesfalse
+% \end{macrocode}
+%
+% When the label is defined we replace the definition of
+% |\bbl@tempa| by its meaning.
+%
+% \begin{macrocode}
+ \ifx\bbl@tempa\relax
+ \else
+ \edef\bbl@tempa{\expandafter\strip@prefix\meaning\bbl@tempa}%
+ \fi
+% \end{macrocode}
+%
+% We do the same for |\bbl@tempb|.
+%
+% \begin{macrocode}
+ \edef\bbl@tempb{\expandafter\strip@prefix\meaning\bbl@tempb}%
+% \end{macrocode}
+%
+% If the label didn't change, |\bbl@tempa| and |\bbl@tempb| should
+% be identical macros.
+%
+% \begin{macrocode}
+ \ifx\bbl@tempa\bbl@tempb
+ \else
+ \@tempswatrue
+ \fi}
+\fi
+% \end{macrocode}
+%
+% \end{macro}
+%
+% \begin{macro}{\ref}
+% \begin{macro}{\pageref}
+% The same holds for the macro |\ref| that references a label
+% and |\pageref| to reference a page. So we redefine |\ref| and
+% |\pageref|. While we change these macros, we make them robust as
+% well (if they weren't already) to prevent problems if they should
+% become expanded at the wrong moment.
+%
+% \begin{macrocode}
+\bbl@xin@{R}\bbl@opt@safe
+\ifin@
+ \bbl@redefinerobust\ref#1{%
+ \@safe@activestrue\org@ref{#1}\@safe@activesfalse}
+ \bbl@redefinerobust\pageref#1{%
+ \@safe@activestrue\org@pageref{#1}\@safe@activesfalse}
+\else
+ \let\org@ref\ref
+ \let\org@pageref\pageref
+\fi
+% \end{macrocode}
+%
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\@citex}
+% The macro used to cite from a bibliography, |\cite|, uses an
+% internal macro, |\@citex|.
+% It is this internal macro that picks up the argument(s),
+% so we redefine this internal macro and leave |\cite| alone. The
+% first argument is used for typesetting, so the shorthands need
+% only be deactivated in the second argument.
+%
+% \begin{macrocode}
+\bbl@xin@{B}\bbl@opt@safe
+\ifin@
+ \bbl@redefine\@citex[#1]#2{%
+ \@safe@activestrue\edef\@tempa{#2}\@safe@activesfalse
+ \org@@citex[#1]{\@tempa}}
+% \end{macrocode}
+%
+% Unfortunately, the packages \pkg{natbib} and \pkg{cite} need a
+% different definition of |\@citex|...
+% To begin with, \pkg{natbib} has a definition for |\@citex| with
+% \emph{three} arguments... We only know that a package is loaded
+% when |\begin{document}| is executed, so we need to postpone the
+% different redefinition.
+%
+% \begin{macrocode}
+ \AtBeginDocument{%
+ \@ifpackageloaded{natbib}{%
+% \end{macrocode}
+%
+% Notice that we use |\def| here instead of |\bbl@redefine| because
+% |\org@@citex| is already defined and we don't want to overwrite
+% that definition (it would result in parameter stack overflow
+% because of a circular definition).
+%
+% (Recent versions of natbib change dynamically |\@citex|, so PR4087
+% doesn't seem fixable in a simple way. Just load natbib before.)
+%
+% \begin{macrocode}
+ \def\@citex[#1][#2]#3{%
+ \@safe@activestrue\edef\@tempa{#3}\@safe@activesfalse
+ \org@@citex[#1][#2]{\@tempa}}%
+ }{}}
+% \end{macrocode}
+%
+% The package \pkg{cite} has a definition of |\@citex| where the
+% shorthands need to be turned off in both arguments.
+%
+% \begin{macrocode}
+ \AtBeginDocument{%
+ \@ifpackageloaded{cite}{%
+ \def\@citex[#1]#2{%
+ \@safe@activestrue\org@@citex[#1]{#2}\@safe@activesfalse}%
+ }{}}
+% \end{macrocode}
+%
+% \end{macro}
+%
+% \begin{macro}{\nocite}
+% The macro |\nocite| which is used to instruct BiB\TeX\ to
+% extract uncited references from the database.
+%
+% \begin{macrocode}
+ \bbl@redefine\nocite#1{%
+ \@safe@activestrue\org@nocite{#1}\@safe@activesfalse}
+% \end{macrocode}
+%
+% \end{macro}
+%
+% \begin{macro}{\bibcite}
+% The macro that is used in the |.aux| file to
+% define citation labels. When packages such as \pkg{natbib} or
+% \pkg{cite} are not loaded its second argument is used to typeset the
+% citation label. In that case, this second argument can contain
+% active characters but is used in an environment where
+% |\@safe@activestrue| is in effect. This switch needs to be reset
+% inside the |\hbox| which contains the citation label. In order to
+% determine during \file{.aux} file processing which definition of
+% |\bibcite| is needed we define |\bibcite| in such a way that it
+% redefines itself with the proper definition. We call
+% |\bbl@cite@choice| to select the proper definition for |\bibcite|.
+% This new definition is then activated.
+%
+% \begin{macrocode}
+ \bbl@redefine\bibcite{%
+ \bbl@cite@choice
+ \bibcite}
+% \end{macrocode}
+%
+% \end{macro}
+%
+% \begin{macro}{\bbl@bibcite}
+% The macro |\bbl@bibcite| holds the definition of |\bibcite|
+% needed when neither \pkg{natbib} nor \pkg{cite} is loaded.
+%
+% \begin{macrocode}
+ \def\bbl@bibcite#1#2{%
+ \org@bibcite{#1}{\@safe@activesfalse#2}}
+% \end{macrocode}
+%
+% \end{macro}
+%
+% \begin{macro}{\bbl@cite@choice}
+% The macro |\bbl@cite@choice| determines which definition of
+% |\bibcite| is needed. First we give |\bibcite| its default
+% definition.
+%
+% \begin{macrocode}
+ \def\bbl@cite@choice{%
+ \global\let\bibcite\bbl@bibcite
+% \end{macrocode}
+%
+% Then, when \pkg{natbib} is loaded we restore the original
+% definition of |\bibcite|. For \pkg{cite} we do the same.
+%
+% \begin{macrocode}
+ \@ifpackageloaded{natbib}{\global\let\bibcite\org@bibcite}{}%
+ \@ifpackageloaded{cite}{\global\let\bibcite\org@bibcite}{}%
+% \end{macrocode}
+%
+% Make sure this only happens once.
+%
+% \begin{macrocode}
+ \global\let\bbl@cite@choice\relax}
+% \end{macrocode}
+%
+% When a document is run for the first time, no \file{.aux} file is
+% available, and |\bibcite| will not yet be properly defined. In
+% this case, this has to happen before the document starts.
+%
+% \begin{macrocode}
+ \AtBeginDocument{\bbl@cite@choice}
+% \end{macrocode}
+%
+% \end{macro}
+%
+% \begin{macro}{\@bibitem}
+% One of the two internal \LaTeX\ macros called by |\bibitem|
+% that write the citation label on the |.aux| file.
+%
+% \begin{macrocode}
+ \bbl@redefine\@bibitem#1{%
+ \@safe@activestrue\org@@bibitem{#1}\@safe@activesfalse}
+\else
+ \let\org@nocite\nocite
+ \let\org@@citex\@citex
+ \let\org@bibcite\bibcite
+ \let\org@@bibitem\@bibitem
+\fi
+% \end{macrocode}
+%
+% \end{macro}
+%
+% \subsection{Marks}
+%
+% \begin{macro}{\markright}
+% Because the output routine is asynchronous, we must
+% pass the current language attribute to the head lines, together
+% with the text that is put into them. To achieve this we need to
+% adapt the definition of |\markright| and |\markboth| somewhat.
+%
+% \changes{babel~3.9t}{2017/04/23}{Refactored \cs{markright} and
+% \cs{markboth}}
+% \changes{babel~3.23}{2018/09/01}{Trick to isolate the bidi in page
+% numbers}
+%
+% We check whether the argument is empty; if it is, we just make
+% sure the scratch token register is empty. Next, we store the
+% argument to |\markright| in the scratch token register. This way
+% these commands will not be expanded later, and we make sure that
+% the text is typeset using the correct language settings. While
+% doing so, we make sure that active characters that may end up in
+% the mark are not disabled by the output routine kicking in while
+% \cs{@safe@activestrue} is in effect.
+%
+% \begin{macrocode}
+\bbl@trace{Marks}
+\IfBabelLayout{sectioning}
+ {\ifx\bbl@opt@headfoot\@nnil
+ \g@addto@macro\@resetactivechars{%
+ \set@typeset@protect
+ \expandafter\select@language@x\expandafter{\bbl@main@language}%
+ \let\protect\noexpand
+ \edef\thepage{%
+ \noexpand\babelsublr{\unexpanded\expandafter{\thepage}}}}%
+ \fi}
+ {\bbl@redefine\markright#1{%
+ \bbl@ifblank{#1}%
+ {\org@markright{}}%
+ {\toks@{#1}%
+ \bbl@exp{%
+ \\\org@markright{\\\protect\\\foreignlanguage{\languagename}%
+ {\\\protect\\\bbl@restore@actives\the\toks@}}}}}%
+% \end{macrocode}
+%
+% \end{macro}
+%
+% \begin{macro}{\markboth}
+% \begin{macro}{\@mkboth}
+% The definition of |\markboth| is equivalent to that of
+% |\markright|, except that we need two token registers. The
+% documentclasses \cls{report} and \cls{book} define and set the
+% headings for the page. While doing so they also store a copy of
+% |\markboth| in |\@mkboth|. Therefore we need to check whether
+% |\@mkboth| has already been set. If so we neeed to do that again
+% with the new definition of |\markboth|.
+%
+% \begin{macrocode}
+ \ifx\@mkboth\markboth
+ \def\bbl@tempc{\let\@mkboth\markboth}
+ \else
+ \def\bbl@tempc{}
+ \fi
+% \end{macrocode}
+%
+% Now we can start the new definition of |\markboth|
+%
+% \begin{macrocode}
+ \bbl@redefine\markboth#1#2{%
+ \protected@edef\bbl@tempb##1{%
+ \protect\foreignlanguage
+ {\languagename}{\protect\bbl@restore@actives##1}}%
+ \bbl@ifblank{#1}%
+ {\toks@{}}%
+ {\toks@\expandafter{\bbl@tempb{#1}}}%
+ \bbl@ifblank{#2}%
+ {\@temptokena{}}%
+ {\@temptokena\expandafter{\bbl@tempb{#2}}}%
+ \bbl@exp{\\\org@markboth{\the\toks@}{\the\@temptokena}}}
+% \end{macrocode}
+%
+% and copy it to |\@mkboth| if necessary.
+%
+% \begin{macrocode}
+ \bbl@tempc} % end \IfBabelLayout
+% \end{macrocode}
+%
+% \end{macro}
+% \end{macro}
+%
+% \subsection{Preventing clashes with other packages}
+%
+% \subsubsection{\pkg{ifthen}}
+%
+% \begin{macro}{\ifthenelse}
+%
+% \changes{babel~3.9a}{2012/09/07}{Redefine only if `ref' is `safe'}
+% \changes{babel~3.9a}{2013/01/03}{Moved to babel.def}
+%
+% Sometimes a document writer wants to create a special effect
+% depending on the page a certain fragment of text appears on. This
+% can be achieved by the following piece of code:
+%\begin{verbatim}
+% \ifthenelse{\isodd{\pageref{some:label}}}
+% {code for odd pages}
+% {code for even pages}
+%\end{verbatim}
+% In order for this to work the argument of |\isodd| needs to be
+% fully expandable. With the above redefinition of |\pageref| it is
+% not in the case of this example. To overcome that, we add some
+% code to the definition of |\ifthenelse| to make things work.
+%
+% The first thing we need to do is check if the package
+% \pkg{ifthen} is loaded. This should be done at |\begin{document}|
+% time.
+%
+% \begin{macrocode}
+\bbl@trace{Preventing clashes with other packages}
+\bbl@xin@{R}\bbl@opt@safe
+\ifin@
+ \AtBeginDocument{%
+ \@ifpackageloaded{ifthen}{%
+% \end{macrocode}
+%
+% Then we can redefine |\ifthenelse|:
+%
+% \changes{babel~3.9a}{2012/06/22}{\cs{ref} is also taken into account}
+% \changes{babel~3.9n}{2015/12/14}{Don't use generic temp
+% macros. babel/4441}
+%
+% \begin{macrocode}
+ \bbl@redefine@long\ifthenelse#1#2#3{%
+% \end{macrocode}
+%
+% We want to revert the definition of |\pageref| and |\ref| to
+% their original definition for the first argument of |\ifthenelse|,
+% so we first need to store their current meanings.
+%
+% \begin{macrocode}
+ \let\bbl@temp@pref\pageref
+ \let\pageref\org@pageref
+ \let\bbl@temp@ref\ref
+ \let\ref\org@ref
+% \end{macrocode}
+%
+% Then we can set the |\@safe@actives| switch and call the original
+% |\ifthenelse|. In order to be able to use shorthands in the
+% second and third arguments of |\ifthenelse| the resetting of the
+% switch \emph{and} the definition of |\pageref| happens inside
+% those arguments. When the package wasn't loaded we do nothing.
+%
+% \begin{macrocode}
+ \@safe@activestrue
+ \org@ifthenelse{#1}%
+ {\let\pageref\bbl@temp@pref
+ \let\ref\bbl@temp@ref
+ \@safe@activesfalse
+ #2}%
+ {\let\pageref\bbl@temp@pref
+ \let\ref\bbl@temp@ref
+ \@safe@activesfalse
+ #3}%
+ }%
+ }{}%
+ }
+% \end{macrocode}
+%
+% \end{macro}
+%
+% \subsubsection{\pkg{varioref}}
+%
+% \begin{macro}{\@@vpageref}
+% \begin{macro}{\vrefpagenum}
+% \begin{macro}{\Ref}
+%
+% When the package varioref is in use we need to modify its
+% internal command |\@@vpageref| in order to prevent problems when
+% an active character ends up in the argument of |\vref|. The same
+% needs to happen for |\vrefpagenum|.
+%
+% \begin{macrocode}
+ \AtBeginDocument{%
+ \@ifpackageloaded{varioref}{%
+ \bbl@redefine\@@vpageref#1[#2]#3{%
+ \@safe@activestrue
+ \org@@@vpageref{#1}[#2]{#3}%
+ \@safe@activesfalse}%
+ \bbl@redefine\vrefpagenum#1#2{%
+ \@safe@activestrue
+ \org@vrefpagenum{#1}{#2}%
+ \@safe@activesfalse}%
+% \end{macrocode}
+%
+% The package \pkg{varioref} defines |\Ref| to be a robust command
+% wich uppercases the first character of the reference text. In
+% order to be able to do that it needs to access the exandable form
+% of |\ref|. So we employ a little trick here. We redefine the
+% (internal) command \verb*|\Ref | to call |\org@ref| instead of
+% |\ref|. The disadvantgage of this solution is that whenever the
+% derfinition of |\Ref| changes, this definition needs to be updated
+% as well.
+%
+% \begin{macrocode}
+ \expandafter\def\csname Ref \endcsname#1{%
+ \protected@edef\@tempa{\org@ref{#1}}\expandafter\MakeUppercase\@tempa}
+ }{}%
+ }
+\fi
+% \end{macrocode}
+%
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \subsubsection{\pkg{hhline}}
+%
+% \begin{macro}{\hhline}
+% Delaying the activation of the shorthand characters has introduced
+% a problem with the \pkg{hhline} package. The reason is that it
+% uses the `:' character which is made active by the french support
+% in \babel. Therefore we need to \emph{reload} the package when
+% the `:' is an active character.
+%
+% So at |\begin{document}| we check whether \pkg{hhline} is loaded.
+%
+% \begin{macrocode}
+\AtEndOfPackage{%
+ \AtBeginDocument{%
+ \@ifpackageloaded{hhline}%
+% \end{macrocode}
+%
+% Then we check whether the expansion of |\normal@char:| is not
+% equal to |\relax|.
+%
+% \begin{macrocode}
+ {\expandafter\ifx\csname normal@char\string:\endcsname\relax
+ \else
+% \end{macrocode}
+%
+% In that case we simply reload the package. Note that this happens
+% \emph{after} the category code of the @-sign has been changed to
+% other, so we need to temporarily change it to letter again.
+%
+% \begin{macrocode}
+ \makeatletter
+ \def\@currname{hhline}\input{hhline.sty}\makeatother
+ \fi}%
+ {}}}
+% \end{macrocode}
+%
+% \end{macro}
+%
+% \subsubsection{\pkg{hyperref}}
+%
+% \begin{macro}{\pdfstringdefDisableCommands}
+%
+% A number of interworking problems between \pkg{babel} and
+% \pkg{hyperref} are tackled by \pkg{hyperref} itself. The
+% following code was introduced to prevent some annoying warnings
+% but it broke bookmarks. This was quickly fixed in \pkg{hyperref},
+% which essentially made it no-op. However, it will not removed for
+% the moment because \pkg{hyperref} is expecting it.
+%
+% \begin{macrocode}
+\AtBeginDocument{%
+ \ifx\pdfstringdefDisableCommands\@undefined\else
+ \pdfstringdefDisableCommands{\languageshorthands{system}}%
+ \fi}
+% \end{macrocode}
+%
+% \end{macro}
+%
+% \subsubsection{\pkg{fancyhdr}}
+%
+% \begin{macro}{\FOREIGNLANGUAGE}
+% The package \pkg{fancyhdr} treats the running head and fout lines
+% somewhat differently as the standard classes. A symptom of this is
+% that the command |\foreignlanguage| which \babel\ adds to the
+% marks can end up inside the argument of |\MakeUppercase|. To
+% prevent unexpected results we need to define |\FOREIGNLANGUAGE|
+% here.
+%
+% \begin{macrocode}
+\DeclareRobustCommand{\FOREIGNLANGUAGE}[1]{%
+ \lowercase{\foreignlanguage{#1}}}
+% \end{macrocode}
+%
+% \end{macro}
+%
+% \begin{macro}{\substitutefontfamily}
+% The command |\substitutefontfamily| creates an
+% \file{.fd} file on the fly. The first argument is an encoding
+% mnemonic, the second and third arguments are font family names.
+%
+% \begin{macrocode}
+\def\substitutefontfamily#1#2#3{%
+ \lowercase{\immediate\openout15=#1#2.fd\relax}%
+ \immediate\write15{%
+ \string\ProvidesFile{#1#2.fd}%
+ [\the\year/\two@digits{\the\month}/\two@digits{\the\day}
+ \space generated font description file]^^J
+ \string\DeclareFontFamily{#1}{#2}{}^^J
+ \string\DeclareFontShape{#1}{#2}{m}{n}{<->ssub * #3/m/n}{}^^J
+ \string\DeclareFontShape{#1}{#2}{m}{it}{<->ssub * #3/m/it}{}^^J
+ \string\DeclareFontShape{#1}{#2}{m}{sl}{<->ssub * #3/m/sl}{}^^J
+ \string\DeclareFontShape{#1}{#2}{m}{sc}{<->ssub * #3/m/sc}{}^^J
+ \string\DeclareFontShape{#1}{#2}{b}{n}{<->ssub * #3/bx/n}{}^^J
+ \string\DeclareFontShape{#1}{#2}{b}{it}{<->ssub * #3/bx/it}{}^^J
+ \string\DeclareFontShape{#1}{#2}{b}{sl}{<->ssub * #3/bx/sl}{}^^J
+ \string\DeclareFontShape{#1}{#2}{b}{sc}{<->ssub * #3/bx/sc}{}^^J
+ }%
+ \closeout15
+ }
+% \end{macrocode}
+%
+% This command should only be used in the preamble of a document.
+%
+% \begin{macrocode}
+\@onlypreamble\substitutefontfamily
+% \end{macrocode}
+%
+% \end{macro}
+%
+% \subsection{Encoding and fonts}
+%
+% Because documents may use non-ASCII font encodings, we make sure
+% that the logos of \TeX\ and \LaTeX\ always come out in the right
+% encoding. There is a list of non-ASCII encodings. Unfortunately,
+% \textsf{fontenc} deletes its package options, so we must guess which
+% encodings has been loaded by traversing |\@filelist| to search for
+% \m{enc}|enc.def|. If a non-ASCII has been loaded, we define versions
+% of |\TeX| and |\LaTeX| for them using |\ensureascii|. The default
+% ASCII encoding is set, too (in reverse order): the ``main'' encoding
+% (when the document begins), the last loaded, or |OT1|.
+%
+% \begin{macro}{\ensureascii}
+%
+% \changes{babel~3.9i}{2014/02/14}{Macro added, to replace
+% \cs{textlatin} and friends}
+% \changes{babel~3.9j}{2014/03/17}{Moved misplaced code - it should be
+% executed only with LaTeX}
+% \changes{babel~3.23}{2018/08/28}{Added TS1, T3, TS3}
+%
+% \begin{macrocode}
+\bbl@trace{Encoding and fonts}
+\newcommand\BabelNonASCII{LGR,X2,OT2,OT3,OT6,LHE,LWN,LMA,LMC,LMS,LMU}
+\newcommand\BabelNonText{TS1,T3,TS3}
+\let\org@TeX\TeX
+\let\org@LaTeX\LaTeX
+\let\ensureascii\@firstofone
+\AtBeginDocument{%
+ \in@false
+ \bbl@foreach\BabelNonASCII{% is there a text non-ascii enc?
+ \ifin@\else
+ \lowercase{\bbl@xin@{,#1enc.def,}{,\@filelist,}}%
+ \fi}%
+ \ifin@ % if a text non-ascii has been loaded
+ \def\ensureascii#1{{\fontencoding{OT1}\selectfont#1}}%
+ \DeclareTextCommandDefault{\TeX}{\org@TeX}%
+ \DeclareTextCommandDefault{\LaTeX}{\org@LaTeX}%
+ \def\bbl@tempb#1\@@{\uppercase{\bbl@tempc#1}ENC.DEF\@empty\@@}%
+ \def\bbl@tempc#1ENC.DEF#2\@@{%
+ \ifx\@empty#2\else
+ \bbl@ifunset{T@#1}%
+ {}%
+ {\bbl@xin@{,#1,}{,\BabelNonASCII,\BabelNonText,}%
+ \ifin@
+ \DeclareTextCommand{\TeX}{#1}{\ensureascii{\org@TeX}}%
+ \DeclareTextCommand{\LaTeX}{#1}{\ensureascii{\org@LaTeX}}%
+ \else
+ \def\ensureascii##1{{\fontencoding{#1}\selectfont##1}}%
+ \fi}%
+ \fi}%
+ \bbl@foreach\@filelist{\bbl@tempb#1\@@}% TODO - \@@ de mas??
+ \bbl@xin@{,\cf@encoding,}{,\BabelNonASCII,\BabelNonText,}%
+ \ifin@\else
+ \edef\ensureascii#1{{%
+ \noexpand\fontencoding{\cf@encoding}\noexpand\selectfont#1}}%
+ \fi
+ \fi}
+% \end{macrocode}
+%
+% \end{macro}
+%
+% Now comes the old deprecated stuff (with a little change in 3.9l,
+% for \textsf{fontspec}). The first thing we need to do is to
+% determine, at |\begin{document}|, which latin fontencoding to use.
+%
+% \begin{macro}{\latinencoding}
+% When text is being typeset in an encoding other than `latin'
+% (\texttt{OT1} or \texttt{T1}), it would be nice to still have
+% Roman numerals come out in the Latin encoding.
+% So we first assume that the current encoding at the end
+% of processing the package is the Latin encoding.
+%
+% \begin{macrocode}
+\AtEndOfPackage{\edef\latinencoding{\cf@encoding}}
+% \end{macrocode}
+%
+% But this might be overruled with a later loading of the package
+% \pkg{fontenc}. Therefore we check at the execution of
+% |\begin{document}| whether it was loaded with the \Lopt{T1}
+% option. The normal way to do this (using |\@ifpackageloaded|) is
+% disabled for this package. Now we have to revert to parsing the
+% internal macro |\@filelist| which contains all the filenames
+% loaded.
+%
+% \changes{babel~3.9l}{2014/08/02}{fontspec used to set
+% \cs{latinencoding} to EUx, but now it doesn't. So, it's done
+% here.}
+% \changes{babel~3.9o}{2016/01/27}{With fontspec, first check if
+% \cs{UTFencname} exists.}
+%
+% \begin{macrocode}
+\AtBeginDocument{%
+ \@ifpackageloaded{fontspec}%
+ {\xdef\latinencoding{%
+ \ifx\UTFencname\@undefined
+ EU\ifcase\bbl@engine\or2\or1\fi
+ \else
+ \UTFencname
+ \fi}}%
+ {\gdef\latinencoding{OT1}%
+ \ifx\cf@encoding\bbl@t@one
+ \xdef\latinencoding{\bbl@t@one}%
+ \else
+ \@ifl@aded{def}{t1enc}{\xdef\latinencoding{\bbl@t@one}}{}%
+ \fi}}
+% \end{macrocode}
+%
+% \end{macro}
+%
+% \begin{macro}{\latintext}
+% Then we can define the command |\latintext| which is a
+% declarative switch to a latin font-encoding. Usage of this macro
+% is deprecated.
+%
+% \begin{macrocode}
+\DeclareRobustCommand{\latintext}{%
+ \fontencoding{\latinencoding}\selectfont
+ \def\encodingdefault{\latinencoding}}
+% \end{macrocode}
+%
+% \end{macro}
+%
+% \begin{macro}{\textlatin}
+% This command takes an argument which is then typeset using the
+% requested font encoding. In order to avoid many encoding switches
+% it operates in a local scope.
+%
+% \begin{macrocode}
+\ifx\@undefined\DeclareTextFontCommand
+ \DeclareRobustCommand{\textlatin}[1]{\leavevmode{\latintext #1}}
+\else
+ \DeclareTextFontCommand{\textlatin}{\latintext}
+\fi
+% \end{macrocode}
+%
+% \end{macro}
+%
+% \subsection{Basic bidi support}
+%
+% \textbf{Work in progress.} This code is currently placed here for
+% practical reasons.
+%
+% It is loosely based on |rlbabel.def|, but most of it has been
+% developed from scratch. This \babel{} module (by Johannes Braams and
+% Boris Lavva) has served the purpose of typesetting R documents for
+% two decades, and despite its flaws I think it is still a good starting
+% point (some parts have been copied here almost verbatim), partly
+% thanks to its simplicity. I've also looked at \textsc{arabi} (by
+% Youssef Jabri), which is compatible with \babel{}.
+%
+% There are two ways of modifying macros to make them “bidiâ€, namely,
+% by patching the internal low level macros (which is what I have done
+% with lists, columns, counters, tocs, much like |rlbabel| did), and
+% by introducing a “middle layer†just below the user interface
+% (sectioning, footnotes).
+%
+% \begin{itemize}
+% \item pdftex provides a minimal support for bidi text, and it
+% must be done by hand. Vertical typesetting is not possible.
+% \item \xetex{} is somewhat better, thanks to its font engine
+% (even if not always reliable) and a few additional tools. However,
+% very little is done at the paragraph level. Another challenging
+% problem is text direction does not honour \TeX{} grouping.
+% \item \luatex{} can provide the most complete solution, as we can
+% manipulate almost freely the node list, the generated lines,
+% and so on, but bidi text does not work out of the box and some
+% development is necessary. It also provides tools to properly
+% set left-to-right and right-to-left page layouts. As Lua\TeX-ja
+% shows, vertical typesetting is posible, too. Its main drawback
+% is font handling is often considered to be less mature than
+% \xetex{}, mainly in Indic scripts (but there are steps to make
+% HarfBuzz, the \xetex{} font engine, available in \luatex{}; see
+% <https://github.com/tatzetwerk/luatex-harfbuzz>).
+% \end{itemize}
+%
+% \changes{3.15}{2017/10/30}{Use an attribute instead of tex language
+% (reserved for hyphenation).}
+% \changes{3.15}{2017/10/30}{Store direction in @wdir@<lang>.}
+% \changes{3.28}{2019/04/01}{Dir in boxes within math and other
+% contexts (passim).}
+%
+% \begin{macrocode}
+\bbl@trace{Basic (internal) bidi support}
+\def\bbl@alscripts{,Arabic,Syriac,Thaana,}
+\def\bbl@rscripts{%
+ ,Imperial Aramaic,Avestan,Cypriot,Hatran,Hebrew,%
+ Old Hungarian,Old Hungarian,Lydian,Mandaean,Manichaean,%
+ Manichaean,Meroitic Cursive,Meroitic,Old North Arabian,%
+ Nabataean,N'Ko,Orkhon,Palmyrene,Inscriptional Pahlavi,%
+ Psalter Pahlavi,Phoenician,Inscriptional Parthian,Samaritan,%
+ Old South Arabian,}%
+\def\bbl@provide@dirs#1{%
+ \bbl@xin@{\csname bbl@sname@#1\endcsname}{\bbl@alscripts\bbl@rscripts}%
+ \ifin@
+ \global\bbl@csarg\chardef{wdir@#1}\@ne
+ \bbl@xin@{\csname bbl@sname@#1\endcsname}{\bbl@alscripts}%
+ \ifin@
+ \global\bbl@csarg\chardef{wdir@#1}\tw@ % useless in xetex
+ \fi
+ \else
+ \global\bbl@csarg\chardef{wdir@#1}\z@
+ \fi
+ \ifodd\bbl@engine
+ \bbl@csarg\ifcase{wdir@#1}%
+ \directlua{ Babel.locale_props[\the\localeid].textdir = 'l' }%
+ \or
+ \directlua{ Babel.locale_props[\the\localeid].textdir = 'r' }%
+ \or
+ \directlua{ Babel.locale_props[\the\localeid].textdir = 'al' }%
+ \fi
+ \fi}
+\def\bbl@switchdir{%
+ \bbl@ifunset{bbl@lsys@\languagename}{\bbl@provide@lsys{\languagename}}{}%
+ \bbl@ifunset{bbl@wdir@\languagename}{\bbl@provide@dirs{\languagename}}{}%
+ \bbl@exp{\\\bbl@setdirs\bbl@cs{wdir@\languagename}}}
+\def\bbl@setdirs#1{% TODO - math
+ \ifcase\bbl@select@type % TODO - strictly, not the right test
+ \bbl@bodydir{#1}%
+ \bbl@pardir{#1}%
+ \fi
+ \bbl@textdir{#1}}
+\ifodd\bbl@engine % luatex=1
+ \AddBabelHook{babel-bidi}{afterextras}{\bbl@switchdir}
+ \DisableBabelHook{babel-bidi}
+ \chardef\bbl@thetextdir\z@
+ \chardef\bbl@thepardir\z@
+ \def\bbl@getluadir#1{%
+ \directlua{
+ if tex.#1dir == 'TLT' then
+ tex.sprint('0')
+ elseif tex.#1dir == 'TRT' then
+ tex.sprint('1')
+ end}}
+ \def\bbl@setluadir#1#2#3{% 1=text/par.. 2=\textdir.. 3=0 lr/1 rl
+ \ifcase#3\relax
+ \ifcase\bbl@getluadir{#1}\relax\else
+ #2 TLT\relax
+ \fi
+ \else
+ \ifcase\bbl@getluadir{#1}\relax
+ #2 TRT\relax
+ \fi
+ \fi}
+ \def\bbl@textdir#1{%
+ \bbl@setluadir{text}\textdir{#1}%
+ \chardef\bbl@thetextdir#1\relax
+ \setattribute\bbl@attr@dir{\numexpr\bbl@thepardir*3+#1}}
+ \def\bbl@pardir#1{%
+ \bbl@setluadir{par}\pardir{#1}%
+ \chardef\bbl@thepardir#1\relax}
+ \def\bbl@bodydir{\bbl@setluadir{body}\bodydir}
+ \def\bbl@pagedir{\bbl@setluadir{page}\pagedir}
+ \def\bbl@dirparastext{\pardir\the\textdir\relax}% %%%%
+ % Sadly, we have to deal with boxes in math with basic.
+ % Activated every math with the package option bidi=:
+ \def\bbl@mathboxdir{%
+ \ifcase\bbl@thetextdir\relax
+ \everyhbox{\textdir TLT\relax}%
+ \else
+ \everyhbox{\textdir TRT\relax}%
+ \fi}
+\else % pdftex=0, xetex=2
+ \AddBabelHook{babel-bidi}{afterextras}{\bbl@switchdir}
+ \DisableBabelHook{babel-bidi}
+ \newcount\bbl@dirlevel
+ \chardef\bbl@thetextdir\z@
+ \chardef\bbl@thepardir\z@
+ \def\bbl@textdir#1{%
+ \ifcase#1\relax
+ \chardef\bbl@thetextdir\z@
+ \bbl@textdir@i\beginL\endL
+ \else
+ \chardef\bbl@thetextdir\@ne
+ \bbl@textdir@i\beginR\endR
+ \fi}
+ \def\bbl@textdir@i#1#2{%
+ \ifhmode
+ \ifnum\currentgrouplevel>\z@
+ \ifnum\currentgrouplevel=\bbl@dirlevel
+ \bbl@error{Multiple bidi settings inside a group}%
+ {I'll insert a new group, but expect wrong results.}%
+ \bgroup\aftergroup#2\aftergroup\egroup
+ \else
+ \ifcase\currentgrouptype\or % 0 bottom
+ \aftergroup#2% 1 simple {}
+ \or
+ \bgroup\aftergroup#2\aftergroup\egroup % 2 hbox
+ \or
+ \bgroup\aftergroup#2\aftergroup\egroup % 3 adj hbox
+ \or\or\or % vbox vtop align
+ \or
+ \bgroup\aftergroup#2\aftergroup\egroup % 7 noalign
+ \or\or\or\or\or\or % output math disc insert vcent mathchoice
+ \or
+ \aftergroup#2% 14 \begingroup
+ \else
+ \bgroup\aftergroup#2\aftergroup\egroup % 15 adj
+ \fi
+ \fi
+ \bbl@dirlevel\currentgrouplevel
+ \fi
+ #1%
+ \fi}
+ \def\bbl@pardir#1{\chardef\bbl@thepardir#1\relax}
+ \let\bbl@bodydir\@gobble
+ \let\bbl@pagedir\@gobble
+ \def\bbl@dirparastext{\chardef\bbl@thepardir\bbl@thetextdir}
+% \end{macrocode}
+%
+% The following command is executed only if there is a right-to-left
+% script (once). It activates the |\everypar| hack for \xetex, to
+% properly handle the par direction. Note text and par dirs are
+% decoupled to some extent (although not completely).
+%
+% \changes{3.16}{2018/01/02}{Fix - the direction prevented the removal
+% of the indent to be re-placed}
+%
+% \begin{macrocode}
+ \def\bbl@xebidipar{%
+ \let\bbl@xebidipar\relax
+ \TeXXeTstate\@ne
+ \def\bbl@xeeverypar{%
+ \ifcase\bbl@thepardir
+ \ifcase\bbl@thetextdir\else\beginR\fi
+ \else
+ {\setbox\z@\lastbox\beginR\box\z@}%
+ \fi}%
+ \let\bbl@severypar\everypar
+ \newtoks\everypar
+ \everypar=\bbl@severypar
+ \bbl@severypar{\bbl@xeeverypar\the\everypar}}
+ \@ifpackagewith{babel}{bidi=bidi}%
+ {\let\bbl@textdir@i\@gobbletwo
+ \let\bbl@xebidipar\@empty
+ \AddBabelHook{bidi}{foreign}{%
+ \def\bbl@tempa{\def\BabelText####1}%
+ \ifcase\bbl@thetextdir
+ \expandafter\bbl@tempa\expandafter{\BabelText{\LR{##1}}}%
+ \else
+ \expandafter\bbl@tempa\expandafter{\BabelText{\RL{##1}}}%
+ \fi}
+ \def\bbl@pardir#1{\ifcase#1\relax\setLR\else\setRL\fi}}
+ {}%
+\fi
+% \end{macrocode}
+%
+% A tool for weak L (mainly digits). We also disable warnings with
+% \textsf{hyperref}.
+%
+% \changes{3.16}{2018/01/02}{New macro \cs{babelsublr}}
+%
+% \begin{macrocode}
+\DeclareRobustCommand\babelsublr[1]{\leavevmode{\bbl@textdir\z@#1}}
+\AtBeginDocument{%
+ \ifx\pdfstringdefDisableCommands\@undefined\else
+ \ifx\pdfstringdefDisableCommands\relax\else
+ \pdfstringdefDisableCommands{\let\babelsublr\@firstofone}%
+ \fi
+ \fi}
+% \end{macrocode}
+%
+% \subsection{Local Language Configuration}
+%
+% \begin{macro}{\loadlocalcfg}
+% At some sites it may be necessary to add site-specific actions to
+% a language definition file. This can be done by creating a file
+% with the same name as the language definition file, but with the
+% extension \file{.cfg}. For instance the file \file{norsk.cfg}
+% will be loaded when the language definition file \file{norsk.ldf}
+% is loaded.
+%
+% For plain-based formats we don't want to override the definition
+% of |\loadlocalcfg| from \file{plain.def}.
+%
+% \begin{macrocode}
+\bbl@trace{Local Language Configuration}
+\ifx\loadlocalcfg\@undefined
+ \@ifpackagewith{babel}{noconfigs}%
+ {\let\loadlocalcfg\@gobble}%
+ {\def\loadlocalcfg#1{%
+ \InputIfFileExists{#1.cfg}%
+ {\typeout{*************************************^^J%
+ * Local config file #1.cfg used^^J%
+ *}}%
+ \@empty}}
+\fi
+% \end{macrocode}
+%
+% Just to be compatible with \LaTeX$\:$2.09 we add a few more lines
+% of code:
+%
+% \begin{macrocode}
+\ifx\@unexpandable@protect\@undefined
+ \def\@unexpandable@protect{\noexpand\protect\noexpand}
+ \long\def\protected@write#1#2#3{%
+ \begingroup
+ \let\thepage\relax
+ #2%
+ \let\protect\@unexpandable@protect
+ \edef\reserved@a{\write#1{#3}}%
+ \reserved@a
+ \endgroup
+ \if@nobreak\ifvmode\nobreak\fi\fi}
+\fi
+%</core>
+%<*kernel>
+% \end{macrocode}%
+% \end{macro}
+%
+% \section{Multiple languages (\texttt{switch.def)}}
+%
+% Plain \TeX\ version~3.0 provides the primitive |\language| that
+% is used to store the current language. When used with a pre-3.0
+% version this function has to be implemented by allocating a
+% counter.
+%
+% \begin{macrocode}
+<@Make sure ProvidesFile is defined@>
+\ProvidesFile{switch.def}[<@date@> <@version@> Babel switching mechanism]
+<@Load macros for plain if not LaTeX@>
+<@Define core switching macros@>
+% \end{macrocode}
+%
+% \begin{macro}{\adddialect}
+% The macro |\adddialect| can be used to add the name of a dialect
+% or variant language, for which an already defined hyphenation
+% table can be used.
+%
+% \begin{macrocode}
+\def\bbl@version{<@version@>}
+\def\bbl@date{<@date@>}
+\def\adddialect#1#2{%
+ \global\chardef#1#2\relax
+ \bbl@usehooks{adddialect}{{#1}{#2}}%
+ \wlog{\string#1 = a dialect from \string\language#2}}
+% \end{macrocode}
+%
+% \end{macro}
+%
+% \changes{babel~3.9a}{2012/09/07}{Added macro}
+% \changes{babel~3.9a}{2013/01/23}{New macro to normalize
+% a macro (eg, \cs{languagename}) to lowercase if necessary}
+%
+% |\bbl@iflanguage| executes code only if the language |l@|
+% exists. Otherwise raises and error.
+%
+% The argument of |\bbl@fixname| has to be a macro name, as it may get
+% ``fixed'' if casing (lc/uc) is wrong. It's intented to fix a
+% long-standing bug when |\foreignlanguage| and the like appear in
+% a |\MakeXXXcase|. However, a lowercase form is not imposed to
+% improve backward compatibility (perhaps you defined a language
+% named |MYLANG|, but unfortunately mixed case names cannot be
+% trapped). Note |l@| is encapsulated, so that its case does not
+% change.
+%
+% \begin{macrocode}
+\def\bbl@fixname#1{%
+ \begingroup
+ \def\bbl@tempe{l@}%
+ \edef\bbl@tempd{\noexpand\@ifundefined{\noexpand\bbl@tempe#1}}%
+ \bbl@tempd
+ {\lowercase\expandafter{\bbl@tempd}%
+ {\uppercase\expandafter{\bbl@tempd}%
+ \@empty
+ {\edef\bbl@tempd{\def\noexpand#1{#1}}%
+ \uppercase\expandafter{\bbl@tempd}}}%
+ {\edef\bbl@tempd{\def\noexpand#1{#1}}%
+ \lowercase\expandafter{\bbl@tempd}}}%
+ \@empty
+ \edef\bbl@tempd{\endgroup\def\noexpand#1{#1}}%
+ \bbl@tempd}
+\def\bbl@iflanguage#1{%
+ \@ifundefined{l@#1}{\@nolanerr{#1}\@gobble}\@firstofone}
+% \end{macrocode}
+%
+% \begin{macro}{\iflanguage}
+% Users might want to test (in a private package for instance)
+% which language is currently active. For this we provide a test
+% macro, |\iflanguage|, that has three arguments. It checks
+% whether the first argument is a known language. If so, it
+% compares the first argument with the value of |\language|. Then,
+% depending on the result of the comparison, it executes either the
+% second or the third argument.
+%
+% \begin{macrocode}
+\def\iflanguage#1{%
+ \bbl@iflanguage{#1}{%
+ \ifnum\csname l@#1\endcsname=\language
+ \expandafter\@firstoftwo
+ \else
+ \expandafter\@secondoftwo
+ \fi}}
+% \end{macrocode}
+%
+% \end{macro}
+%
+% \subsection{Selecting the language}
+%
+% \begin{macro}{\selectlanguage}
+% The macro |\selectlanguage| checks whether the language is
+% already defined before it performs its actual task, which is to
+% update |\language| and activate language-specific definitions.
+%
+% To allow the call of |\selectlanguage| either with a control
+% sequence name or with a simple string as argument, we have to use
+% a trick to delete the optional escape character.
+%
+% To convert a control sequence to a string, we use the |\string|
+% primitive. Next we have to look at the first character of this
+% string and compare it with the escape character. Because this
+% escape character can be changed by setting the internal integer
+% |\escapechar| to a character number, we have to compare this
+% number with the character of the string. To do this we have to
+% use \TeX's backquote notation to specify the character as a
+% number.
+%
+% If the first character of the |\string|'ed argument is the
+% current escape character, the comparison has stripped this
+% character and the rest in the `then' part consists of the rest of
+% the control sequence name. Otherwise we know that either the
+% argument is not a control sequence or |\escapechar| is set to a
+% value outside of the character range~$0$--$255$.
+%
+% If the user gives an empty argument, we provide a default
+% argument for |\string|. This argument should expand to nothing.
+%
+% \changes{babel~3.9a}{2012/11/16}{\cs{bbl@select@type} keep tracks of
+% the selection method: 0 is select, 1 is foreign}
+%
+% \begin{macrocode}
+\let\bbl@select@type\z@
+\edef\selectlanguage{%
+ \noexpand\protect
+ \expandafter\noexpand\csname selectlanguage \endcsname}
+% \end{macrocode}
+%
+% Because the command |\selectlanguage| could be used in a moving
+% argument it expands to \verb*=\protect\selectlanguage =.
+% Therefore, we have to make sure that a macro |\protect| exists.
+% If it doesn't it is |\let| to |\relax|.
+%
+% \begin{macrocode}
+\ifx\@undefined\protect\let\protect\relax\fi
+% \end{macrocode}
+%
+% As \LaTeX$\:$2.09 writes to files \textit{expanded} whereas
+% \LaTeXe\ takes care \textit{not} to expand the arguments of
+% |\write| statements we need to be a bit clever about the way we
+% add information to \file{.aux} files. Therefore we introduce the
+% macro |\xstring| which should expand to the right amount of
+% |\string|'s.
+%
+% \begin{macrocode}
+\ifx\documentclass\@undefined
+ \def\xstring{\string\string\string}
+\else
+ \let\xstring\string
+\fi
+% \end{macrocode}
+%
+% \end{macro}
+%
+% Since version 3.5 \babel\ writes entries to the auxiliary files in
+% order to typeset table of contents etc. in the correct language
+% environment.
+% \begin{macro}{\bbl@pop@language}
+% \emph{But} when the language change happens \emph{inside} a group
+% the end of the group doesn't write anything to the auxiliary
+% files. Therefore we need \TeX's |aftergroup| mechanism to help
+% us. The command |\aftergroup| stores the token immediately
+% following it to be executed when the current group is closed. So
+% we define a temporary control sequence |\bbl@pop@language| to be
+% executed at the end of the group. It calls |\bbl@set@language|
+% with the name of the current language as its argument.
+%
+% \begin{macro}{\bbl@language@stack}
+% The previous solution works for one level of nesting groups, but
+% as soon as more levels are used it is no longer adequate. For
+% that case we need to keep track of the nested languages using a
+% stack mechanism. This stack is called |\bbl@language@stack| and
+% initially empty.
+%
+% \begin{macrocode}
+\def\bbl@language@stack{}
+% \end{macrocode}
+%
+% When using a stack we need a mechanism to push an element on the
+% stack and to retrieve the information afterwards.
+% \begin{macro}{\bbl@push@language}
+% \begin{macro}{\bbl@pop@language}
+% The stack is simply a list of languagenames, separated with a `+'
+% sign; the push function can be simple:
+%
+% \begin{macrocode}
+\def\bbl@push@language{%
+ \xdef\bbl@language@stack{\languagename+\bbl@language@stack}}
+% \end{macrocode}
+%
+% Retrieving information from the stack is a little bit less simple, as
+% we need to remove the element from the stack while storing it in the
+% macro |\languagename|. For this we first define a helper function.
+% \begin{macro}{\bbl@pop@lang}
+% This macro stores its first element (which is delimited by the
+% `+'-sign) in |\languagename| and stores the rest of the string
+% (delimited by `-') in its third argument.
+%
+% \begin{macrocode}
+\def\bbl@pop@lang#1+#2-#3{%
+ \edef\languagename{#1}\xdef#3{#2}}
+% \end{macrocode}
+%
+% \end{macro}
+% The reason for the somewhat weird arrangement of arguments to the
+% helper function is the fact it is called in the following way.
+% This means that before |\bbl@pop@lang| is executed \TeX\ first
+% \emph{expands} the stack, stored in |\bbl@language@stack|. The
+% result of that is that the argument string of |\bbl@pop@lang|
+% contains one or more language names, each followed by a `+'-sign
+% (zero language names won't occur as this macro will only be
+% called after something has been pushed on the stack) followed by
+% the `-'-sign and finally the reference to the stack.
+%
+% \begin{macrocode}
+\let\bbl@ifrestoring\@secondoftwo
+\def\bbl@pop@language{%
+ \expandafter\bbl@pop@lang\bbl@language@stack-\bbl@language@stack
+ \let\bbl@ifrestoring\@firstoftwo
+ \expandafter\bbl@set@language\expandafter{\languagename}%
+ \let\bbl@ifrestoring\@secondoftwo}
+% \end{macrocode}
+%
+% Once the name of the previous language is retrieved from the stack,
+% it is fed to |\bbl@set@language| to do the actual work of
+% switching everything that needs switching.
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% An alternative way to identify languages (in the \babel{} sense)
+% with a numerical value is introduced in 3.30. This is one of the
+% first steps for a new interface based on the concept of locale,
+% which explains the name of |\localeid|. This means |\l@...| will be
+% reserved for hyphenation patterns.
+%
+% \begin{macrocode}
+\chardef\localeid\z@
+\def\bbl@id@last{0} % No real need for a new counter
+\def\bbl@id@assign{%
+ \bbl@ifunset{bbl@id@@\languagename}%
+ {\count@\bbl@id@last\relax
+ \advance\count@\@ne
+ \bbl@csarg\chardef{id@@\languagename}\count@
+ \edef\bbl@id@last{\the\count@}%
+ \ifcase\bbl@engine\or
+ \directlua{
+ Babel = Babel or {}
+ Babel.locale_props = Babel.locale_props or {}
+ Babel.locale_props[\bbl@id@last] = {}
+ }%
+ \fi}%
+ {}}
+% \end{macrocode}
+%
+% The unprotected part of |\selectlanguage|.
+%
+% \begin{macrocode}
+\expandafter\def\csname selectlanguage \endcsname#1{%
+ \ifnum\bbl@hymapsel=\@cclv\let\bbl@hymapsel\tw@\fi
+ \bbl@push@language
+ \aftergroup\bbl@pop@language
+ \bbl@set@language{#1}}
+% \end{macrocode}
+%
+% \end{macro}
+%
+% \begin{macro}{\bbl@set@language}
+%
+% The macro |\bbl@set@language| takes care of switching the language
+% environment \emph{and} of writing entries on the auxiliary files.
+% For historial reasons, language names can be either |language| of
+% |\language|. To catch either form a trick is used, but
+% unfortunately as a side effect the catcodes of letters in
+% |\languagename| are messed up. This is a bug, but preserved for
+% backwards compatibility. The list of auxiliary files can be
+% extended by redefining |\BabelContentsFiles|, but make sure they
+% are loaded inside a group (as |aux|, |toc|, |lof|, and |lot| do)
+% or the last language of the document will remain active
+% afterwards.
+%
+% We also write a command to change the current language in the
+% auxiliary files.
+%
+% \changes{babel~3.9a}{2012/09/09}{Added hook}
+% \changes{babel~3.9a}{2012/11/07}{Use a loop for contents files, with
+% the help of \cs{BabelContentsFiles}}
+% \changes{babel~3.9a}{2013/03/08}{Don't write to aux if language is
+% unknown}
+% \changes{babel~3.9h}{2013/11/20}{Error with a more helpful text }
+% \changes{babel~3.16}{2018/01/02}{New mechanism to pass the language
+% to aux, toc, etc.}
+% \changes{babel~3.22}{2018/06/05}{Unknown languages in aux files do
+% not raise an error any more (only a warning).}
+%
+% \begin{macrocode}
+\def\BabelContentsFiles{toc,lof,lot}
+\def\bbl@set@language#1{% from selectlanguage, pop@
+ \edef\languagename{%
+ \ifnum\escapechar=\expandafter`\string#1\@empty
+ \else\string#1\@empty\fi}%
+ \select@language{\languagename}%
+ % write to auxs
+ \expandafter\ifx\csname date\languagename\endcsname\relax\else
+ \if@filesw
+ \protected@write\@auxout{}{\string\babel@aux{\languagename}{}}%
+ \bbl@usehooks{write}{}%
+ \fi
+ \fi}
+\def\select@language#1{% from set@, babel@aux
+ % set hymap
+ \ifnum\bbl@hymapsel=\@cclv\chardef\bbl@hymapsel4\relax\fi
+ % set name
+ \edef\languagename{#1}%
+ \bbl@fixname\languagename
+ \bbl@iflanguage\languagename{%
+ \expandafter\ifx\csname date\languagename\endcsname\relax
+ \bbl@error
+ {Unknown language `#1'. Either you have\\%
+ misspelled its name, it has not been installed,\\%
+ or you requested it in a previous run. Fix its name,\\%
+ install it or just rerun the file, respectively. In\\%
+ some cases, you may need to remove the aux file}%
+ {You may proceed, but expect wrong results}%
+ \else
+ % set type
+ \let\bbl@select@type\z@
+ \expandafter\bbl@switch\expandafter{\languagename}%
+ \fi}}
+\def\babel@aux#1#2{%
+ \expandafter\ifx\csname date#1\endcsname\relax
+ \expandafter\ifx\csname bbl@auxwarn@#1\endcsname\relax
+ \@namedef{bbl@auxwarn@#1}{}%
+ \bbl@warning
+ {Unknown language `#1'. Very likely you\\%
+ requested it in a previous run. Expect some\\%
+ wrong results in this run, which should vanish\\%
+ in the next one. Reported}%
+ \fi
+ \else
+ \select@language{#1}%
+ \bbl@foreach\BabelContentsFiles{%
+ \@writefile{##1}{\babel@toc{#1}{#2}}}% %% TODO - ok in plain?
+ \fi}
+\def\babel@toc#1#2{%
+ \select@language{#1}}
+% \end{macrocode}
+%
+% A bit of optimization. Select in heads/foots the language only if
+% necessary. The real thing is in \texttt{babel.def}.
+%
+% \begin{macrocode}
+\let\select@language@x\select@language
+% \end{macrocode}
+%
+% \end{macro}
+%
+% First, check if the user asks for a known language. If so,
+% update the value of |\language| and call |\originalTeX|
+% to bring \TeX\ in a certain pre-defined state.
+%
+% \changes{babel~3.9a}{2012/07/27}{Moved \cs{bbl@patterns} to the
+% correct place, after setting the extras for the current
+% language}
+% \changes{babel~3.9a}{2012/08/01}{Created \cs{bbl@switch} with code
+% shared by \cs{select@language} and \cs{foreing@language}}
+%
+% The name of the language is stored in the control sequence
+% |\languagename|.
+%
+% Then we have to \emph{re}define |\originalTeX| to compensate for
+% the things that have been activated. To save memory space for
+% the macro definition of |\originalTeX|, we construct the control
+% sequence name for the |\noextras|\langvar\ command at definition
+% time by expanding the |\csname| primitive.
+%
+% Now activate the language-specific definitions. This is done by
+% constructing the names of three macros by concatenating three
+% words with the argument of |\selectlanguage|, and calling these
+% macros. \nb{What if \cs{hyphenation} was used in |extras|? Patch
+% temporarily |\set@hyphenmins| and hyphenation. It can be done in
+% hooks if necessary.}
+%
+% The switching of the values of |\lefthyphenmin| and
+% |\righthyphenmin| is somewhat different. First we save their
+% current values, then we check if |\|\langvar|hyphenmins| is
+% defined. If it is not, we set default values (2 and 3), otherwise
+% the values in |\|\langvar|hyphenmins| will be used.
+%
+% \changes{babel~3.9a}{2012/08/01}{Adddd \cs{bbl@iflanguagename} and
+% \cs{select@language@x}, which is no-op if the language is the same}
+% \changes{babel~3.9a}{2013/01/23}{\cs{select@language} sets
+% \textsc{languagename} so that it has the correct value in the aux
+% file (eg, shorthand expansion was wrong)}
+% \changes{babel~3.9a}{2012/08/14}{Make sure the save counter is reset
+% even if \cs{originalTeX} is used in other contexts}
+% \changes{babel~3.9c}{2013/04/08}{Removed an extra empty line}
+% \changes{babel~3.9h}{2013/11/29}{Use \cs{def} instead of
+% \cs{renewcommand} for \cs{BabelLower}}
+% \changes{babel~3.9i}{2014/03/04}{Added `afterreset' hook}
+% \changes{3.15}{2017/10/30}{Remove spaces inside captions and date.}
+%
+% \begin{macrocode}
+\newif\ifbbl@usedategroup
+\def\bbl@switch#1{% from select@, foreign@
+ % restore
+ \originalTeX
+ \expandafter\def\expandafter\originalTeX\expandafter{%
+ \csname noextras#1\endcsname
+ \let\originalTeX\@empty
+ \babel@beginsave}%
+ \bbl@usehooks{afterreset}{}%
+ \languageshorthands{none}%
+ % set the locale id
+ \bbl@id@assign
+ \chardef\localeid\@nameuse{bbl@id@@\languagename}%
+ % switch captions, date
+ \ifcase\bbl@select@type
+ \ifhmode
+ \hskip\z@skip % trick to ignore spaces
+ \csname captions#1\endcsname\relax
+ \csname date#1\endcsname\relax
+ \loop\ifdim\lastskip>\z@\unskip\repeat\unskip
+ \else
+ \csname captions#1\endcsname\relax
+ \csname date#1\endcsname\relax
+ \fi
+ \else
+ \ifbbl@usedategroup % if \foreign... within \<lang>date
+ \bbl@usedategroupfalse
+ \ifhmode
+ \hskip\z@skip % trick to ignore spaces
+ \csname date#1\endcsname\relax
+ \loop\ifdim\lastskip>\z@\unskip\repeat\unskip
+ \else
+ \csname date#1\endcsname\relax
+ \fi
+ \fi
+ \fi
+ % switch extras
+ \bbl@usehooks{beforeextras}{}%
+ \csname extras#1\endcsname\relax
+ \bbl@usehooks{afterextras}{}%
+ % > babel-ensure
+ % > babel-sh-<short>
+ % > babel-bidi
+ % > babel-fontspec
+ % hyphenation - case mapping
+ \ifcase\bbl@opt@hyphenmap\or
+ \def\BabelLower##1##2{\lccode##1=##2\relax}%
+ \ifnum\bbl@hymapsel>4\else
+ \csname\languagename @bbl@hyphenmap\endcsname
+ \fi
+ \chardef\bbl@opt@hyphenmap\z@
+ \else
+ \ifnum\bbl@hymapsel>\bbl@opt@hyphenmap\else
+ \csname\languagename @bbl@hyphenmap\endcsname
+ \fi
+ \fi
+ \global\let\bbl@hymapsel\@cclv
+ % hyphenation - patterns
+ \bbl@patterns{#1}%
+ % hyphenation - mins
+ \babel@savevariable\lefthyphenmin
+ \babel@savevariable\righthyphenmin
+ \expandafter\ifx\csname #1hyphenmins\endcsname\relax
+ \set@hyphenmins\tw@\thr@@\relax
+ \else
+ \expandafter\expandafter\expandafter\set@hyphenmins
+ \csname #1hyphenmins\endcsname\relax
+ \fi}
+% \end{macrocode}
+%
+% \begin{environment}{otherlanguage}
+% The \Lenv{otherlanguage} environment can be used as an
+% alternative to using the |\selectlanguage| declarative
+% command. When you are typesetting a document which mixes
+% left-to-right and right-to-left typesetting you have to use this
+% environment in order to let things work as you expect them to.
+%
+% The |\ignorespaces| command is necessary to hide the environment
+% when it is entered in horizontal mode.
+%
+% \changes{babel~3.9a}{2012/07/31}{Removed \cs{originalTeX}}
+%
+% \begin{macrocode}
+\long\def\otherlanguage#1{%
+ \ifnum\bbl@hymapsel=\@cclv\let\bbl@hymapsel\thr@@\fi
+ \csname selectlanguage \endcsname{#1}%
+ \ignorespaces}
+% \end{macrocode}
+%
+% The |\endotherlanguage| part of the environment tries to hide
+% itself when it is called in horizontal mode.
+%
+% \begin{macrocode}
+\long\def\endotherlanguage{%
+ \global\@ignoretrue\ignorespaces}
+% \end{macrocode}
+%
+% \end{environment}
+%
+% \begin{environment}{otherlanguage*}
+% The \Lenv{otherlanguage} environment is meant to be used when a
+% large part of text from a different language needs to be typeset,
+% but without changing the translation of words such as `figure'.
+% This environment makes use of |\foreign@language|.
+%
+% \begin{macrocode}
+\expandafter\def\csname otherlanguage*\endcsname#1{%
+ \ifnum\bbl@hymapsel=\@cclv\chardef\bbl@hymapsel4\relax\fi
+ \foreign@language{#1}}
+% \end{macrocode}
+%
+% At the end of the environment we need to switch off the extra
+% definitions. The grouping mechanism of the environment will take
+% care of resetting the correct hyphenation rules and ``extras''.
+%
+% \begin{macrocode}
+\expandafter\let\csname endotherlanguage*\endcsname\relax
+% \end{macrocode}
+%
+% \end{environment}
+%
+% \begin{macro}{\foreignlanguage}
+% The |\foreignlanguage| command is another substitute for the
+% |\selectlanguage| command. This command takes two arguments, the
+% first argument is the name of the language to use for typesetting
+% the text specified in the second argument.
+%
+% Unlike |\selectlanguage| this command doesn't switch
+% \emph{everything}, it only switches the hyphenation rules and the
+% extra definitions for the language specified. It does this within
+% a group and assumes the |\extras|\langvar\ command doesn't make
+% any |\global| changes. The coding is very similar to part of
+% |\selectlanguage|.
+%
+% |\bbl@beforeforeign| is a trick to fix a bug in bidi
+% texts. |\foreignlanguage| is supposed to be a `text' command, and
+% therefore it must emit a |\leavevmode|, but it does not, and
+% therefore the indent is placed on the opposite margin. For
+% backward compatibility, however, it is done only if a
+% right-to-left script is requested; otherwise, it is no-op.
+%
+% (3.11) |\foreignlanguage*| is a temporary, experimental macro for
+% a few lines with a different script direction, while preserving
+% the paragraph format (thank the braces around |\par|, things like
+% |\hangindent| are not reset). Do not use it in production,
+% because its semantics and its syntax may change (and very likely
+% will, or even it could be removed altogether). Currently it
+% enters in vmode and then selects the language (which in turn sets the
+% paragraph direction).
+%
+% (3.11) Also experimental are the hook |foreign| and
+% |foreign*|. With them you can redefine |\BabelText| which by
+% default does nothing. Its
+% behavior is not well defined yet. So, use it in
+% horizontal mode only if you do not want surprises.
+%
+% In other words, at the beginning of a paragraph |\foreignlanguage|
+% enters into hmode with the surrounding lang, and with
+% |\foreignlanguage*| with the new lang.
+%
+% \changes{babel~3.9a}{2012/07/30}{Removed unnecesary \cs{noextras}
+% just before closing the group}
+% \changes{babel~3.9a}{2012/07/31}{Moved \cs{originalTeX} to
+% \cs{foreing@language} so that it's also used in
+% \texttt{otherlanguage*}}
+% \changes{babel~3.9a}{2012/12/24}{\cs{foreignlanguage} defined
+% similarly to \cs{selectlanguage}, protecting the whole macro}
+% \changes{babel~3.11}{2017/03/04}{\cs{foreignlanguage*},
+% \cs{bbl@beforeforeign} and hooks}
+%
+% \begin{macrocode}
+\providecommand\bbl@beforeforeign{}
+\edef\foreignlanguage{%
+ \noexpand\protect
+ \expandafter\noexpand\csname foreignlanguage \endcsname}
+\expandafter\def\csname foreignlanguage \endcsname{%
+ \@ifstar\bbl@foreign@s\bbl@foreign@x}
+\def\bbl@foreign@x#1#2{%
+ \begingroup
+ \let\BabelText\@firstofone
+ \bbl@beforeforeign
+ \foreign@language{#1}%
+ \bbl@usehooks{foreign}{}%
+ \BabelText{#2}% Now in horizontal mode!
+ \endgroup}
+\def\bbl@foreign@s#1#2{% TODO - \shapemode, \@setpar, ?\@@par
+ \begingroup
+ {\par}%
+ \let\BabelText\@firstofone
+ \foreign@language{#1}%
+ \bbl@usehooks{foreign*}{}%
+ \bbl@dirparastext
+ \BabelText{#2}% Still in vertical mode!
+ {\par}%
+ \endgroup}
+% \end{macrocode}
+%
+% \end{macro}
+%
+% \begin{macro}{\foreign@language}
+% This macro does the
+% work for |\foreignlanguage| and the \Lenv{otherlanguage*}
+% environment. First we need to store the name of the language and
+% check that it is a known language. Then it just calls
+% |bbl@switch|.
+%
+% \changes{babel~3.9h}{2013/11/29}{The warning shows the language
+% actually selected (with fixed case)}
+%
+% \begin{macrocode}
+\def\foreign@language#1{%
+ % set name
+ \edef\languagename{#1}%
+ \bbl@fixname\languagename
+ \bbl@iflanguage\languagename{%
+ \expandafter\ifx\csname date\languagename\endcsname\relax
+ \bbl@warning % TODO - why a warning, not an error?
+ {Unknown language `#1'. Either you have\\%
+ misspelled its name, it has not been installed,\\%
+ or you requested it in a previous run. Fix its name,\\%
+ install it or just rerun the file, respectively. In\\%
+ some cases, you may need to remove the aux file.\\%
+ I'll proceed, but expect wrong results.\\%
+ Reported}%
+ \fi
+ % set type
+ \let\bbl@select@type\@ne
+ \expandafter\bbl@switch\expandafter{\languagename}}}
+% \end{macrocode}
+%
+% \end{macro}
+%
+% \begin{macro}{\bbl@patterns}
+%
+% \changes{babel~3.9a}{2012/08/28}{Extended to set hyphenation
+% exceptions as defined with \cs{babelhyphenation}}
+% \changes{babel~3.9m}{2015/07/25}{Preset \cs{bbl@pttnlist} and
+% \cs{bbl@patterns@} to relax, for luatex.}
+%
+% This macro selects the hyphenation patterns by changing the
+% \cs{language} register. If special hyphenation patterns
+% are available specifically for the current font encoding,
+% use them instead of the default.
+%
+% It also sets hyphenation exceptions, but only once, because they
+% are global (here language |\lccode|'s has been set,
+% too). |\bbl@hyphenation@| is set to relax until the very first
+% |\babelhyphenation|, so do nothing with this value. If the
+% exceptions for a language (by its number, not its name, so that
+% |:ENC| is taken into account) has been set, then use
+% |\hyphenation| with both global and language exceptions and empty
+% the latter to mark they must not be set again.
+%
+% \begin{macrocode}
+\let\bbl@hyphlist\@empty
+\let\bbl@hyphenation@\relax
+\let\bbl@pttnlist\@empty
+\let\bbl@patterns@\relax
+\let\bbl@hymapsel=\@cclv
+\def\bbl@patterns#1{%
+ \language=\expandafter\ifx\csname l@#1:\f@encoding\endcsname\relax
+ \csname l@#1\endcsname
+ \edef\bbl@tempa{#1}%
+ \else
+ \csname l@#1:\f@encoding\endcsname
+ \edef\bbl@tempa{#1:\f@encoding}%
+ \fi
+ \@expandtwoargs\bbl@usehooks{patterns}{{#1}{\bbl@tempa}}%
+ % > luatex
+ \@ifundefined{bbl@hyphenation@}{}{% Can be \relax!
+ \begingroup
+ \bbl@xin@{,\number\language,}{,\bbl@hyphlist}%
+ \ifin@\else
+ \@expandtwoargs\bbl@usehooks{hyphenation}{{#1}{\bbl@tempa}}%
+ \hyphenation{%
+ \bbl@hyphenation@
+ \@ifundefined{bbl@hyphenation@#1}%
+ \@empty
+ {\space\csname bbl@hyphenation@#1\endcsname}}%
+ \xdef\bbl@hyphlist{\bbl@hyphlist\number\language,}%
+ \fi
+ \endgroup}}
+% \end{macrocode}
+%
+% \end{macro}
+%
+% \begin{environment}{hyphenrules}
+% The environment \Lenv{hyphenrules} can be used to select
+% \emph{just} the hyphenation rules. This environment does
+% \emph{not} change |\languagename| and when the hyphenation rules
+% specified were not loaded it has no effect. Note however,
+% |\lccode|'s and font encodings are not set at all, so in most
+% cases you should use |otherlanguage*|.
+%
+% \changes{3.15}{2017/10/30}{Don't set language name. Use temp macro.}
+% \changes{3.15}{2018/02/14}{Fix - didn't work with polyglossia}
+%
+% \begin{macrocode}
+\def\hyphenrules#1{%
+ \edef\bbl@tempf{#1}%
+ \bbl@fixname\bbl@tempf
+ \bbl@iflanguage\bbl@tempf{%
+ \expandafter\bbl@patterns\expandafter{\bbl@tempf}%
+ \languageshorthands{none}%
+ \expandafter\ifx\csname\bbl@tempf hyphenmins\endcsname\relax
+ \set@hyphenmins\tw@\thr@@\relax
+ \else
+ \expandafter\expandafter\expandafter\set@hyphenmins
+ \csname\bbl@tempf hyphenmins\endcsname\relax
+ \fi}}
+\let\endhyphenrules\@empty
+% \end{macrocode}
+%
+% \end{environment}
+%
+% \begin{macro}{\providehyphenmins}
+% The macro |\providehyphenmins| should be used in the language
+% definition files to provide a \emph{default} setting for the
+% hyphenation parameters |\lefthyphenmin| and |\righthyphenmin|. If
+% the macro |\|\langvar|hyphenmins| is already defined this command
+% has no effect.
+%
+% \begin{macrocode}
+\def\providehyphenmins#1#2{%
+ \expandafter\ifx\csname #1hyphenmins\endcsname\relax
+ \@namedef{#1hyphenmins}{#2}%
+ \fi}
+% \end{macrocode}
+%
+% \end{macro}
+%
+% \begin{macro}{\set@hyphenmins}
+% This macro sets the values of |\lefthyphenmin| and
+% |\righthyphenmin|. It expects two values as its argument.
+%
+% \begin{macrocode}
+\def\set@hyphenmins#1#2{%
+ \lefthyphenmin#1\relax
+ \righthyphenmin#2\relax}
+% \end{macrocode}
+%
+% \end{macro}
+%
+% \begin{macro}{\ProvidesLanguage}
+% The identification code for each file is something that was
+% introduced in \LaTeXe. When the command |\ProvidesFile| does not
+% exist, a dummy definition is provided temporarily. For use in the
+% language definition file the command |\ProvidesLanguage| is
+% defined by \babel.
+%
+% Depending on the format, ie, on if the former is defined, we use
+% a similar definition or not.
+%
+% \changes{babel~3.9a}{2012/12/09}{Save info about the babel
+% version in the format (switch.def) so that it can be checked
+% later if necessary}
+%
+% \begin{macrocode}
+\ifx\ProvidesFile\@undefined
+ \def\ProvidesLanguage#1[#2 #3 #4]{%
+ \wlog{Language: #1 #4 #3 <#2>}%
+ }
+\else
+ \def\ProvidesLanguage#1{%
+ \begingroup
+ \catcode`\ 10 %
+ \@makeother\/%
+ \@ifnextchar[%]
+ {\@provideslanguage{#1}}{\@provideslanguage{#1}[]}}
+ \def\@provideslanguage#1[#2]{%
+ \wlog{Language: #1 #2}%
+ \expandafter\xdef\csname ver@#1.ldf\endcsname{#2}%
+ \endgroup}
+\fi
+% \end{macrocode}
+%
+% \end{macro}
+%
+% \begin{macro}{\LdfInit}
+% This macro is defined in two versions. The first version is to be
+% part of the `kernel' of \babel, ie. the part that is loaded in
+% the format; the second version is defined in \file{babel.def}.
+% The version in the format just checks the category code of the
+% ampersand and then loads \file{babel.def}.
+%
+% The category code of the ampersand is restored and the macro
+% calls itself again with the new definition from
+% \file{babel.def}
+%
+% \begin{macrocode}
+\def\LdfInit{%
+ \chardef\atcatcode=\catcode`\@
+ \catcode`\@=11\relax
+ \input babel.def\relax
+ \catcode`\@=\atcatcode \let\atcatcode\relax
+ \LdfInit}
+% \end{macrocode}
+%
+% \end{macro}
+%
+% \begin{macro}{\originalTeX}
+% The macro|\originalTeX| should be known to \TeX\ at this moment.
+% As it has to be expandable we |\let| it to |\@empty| instead of
+% |\relax|.
+%
+% \begin{macrocode}
+\ifx\originalTeX\@undefined\let\originalTeX\@empty\fi
+% \end{macrocode}
+%
+% Because this part of the code can be included in a format, we
+% make sure that the macro which initialises the save mechanism,
+% |\babel@beginsave|, is not considered to be undefined.
+%
+% \begin{macrocode}
+\ifx\babel@beginsave\@undefined\let\babel@beginsave\relax\fi
+% \end{macrocode}
+%
+% \end{macro}
+%
+% A few macro names are reserved for future releases of \babel, which
+% will use the concept of `locale':
+%
+% \changes{babel~3.9s}{2017/04/13}{Reserved macro names for `locale'}
+%
+% \begin{macrocode}
+\providecommand\setlocale{%
+ \bbl@error
+ {Not yet available}%
+ {Find an armchair, sit down and wait}}
+\let\uselocale\setlocale
+\let\locale\setlocale
+\let\selectlocale\setlocale
+\let\textlocale\setlocale
+\let\textlanguage\setlocale
+\let\languagetext\setlocale
+% \end{macrocode}
+%
+% \subsection{Errors}
+%
+% \begin{macro}{\@nolanerr}
+% \begin{macro}{\@nopatterns}
+% The \babel\ package will signal an error when a documents tries
+% to select a language that hasn't been defined earlier. When a
+% user selects a language for which no hyphenation patterns were
+% loaded into the format he will be given a warning about that
+% fact. We revert to the patterns for |\language|=0 in that case.
+% In most formats that will be (US)english, but it might also be
+% empty.
+% \begin{macro}{\@noopterr}
+% When the package was loaded without options not everything will
+% work as expected. An error message is issued in that case.
+%
+% When the format knows about |\PackageError| it must be \LaTeXe,
+% so we can safely use its error handling interface. Otherwise
+% we'll have to `keep it simple'.
+%
+% \changes{babel~3.9a}{2012/07/30}{\cs{newcommand}s replaced by
+% \cs{def}'s, so that the file can be loaded twice}
+% \changes{babel~3.9a}{2013/01/26}{Define generic variants instead of
+% duplicating each predefined message}
+%
+% \begin{macrocode}
+\edef\bbl@nulllanguage{\string\language=0}
+\ifx\PackageError\@undefined
+ \def\bbl@error#1#2{%
+ \begingroup
+ \newlinechar=`\^^J
+ \def\\{^^J(babel) }%
+ \errhelp{#2}\errmessage{\\#1}%
+ \endgroup}
+ \def\bbl@warning#1{%
+ \begingroup
+ \newlinechar=`\^^J
+ \def\\{^^J(babel) }%
+ \message{\\#1}%
+ \endgroup}
+ \def\bbl@info#1{%
+ \begingroup
+ \newlinechar=`\^^J
+ \def\\{^^J}%
+ \wlog{#1}%
+ \endgroup}
+\else
+ \def\bbl@error#1#2{%
+ \begingroup
+ \def\\{\MessageBreak}%
+ \PackageError{babel}{#1}{#2}%
+ \endgroup}
+ \def\bbl@warning#1{%
+ \begingroup
+ \def\\{\MessageBreak}%
+ \PackageWarning{babel}{#1}%
+ \endgroup}
+ \def\bbl@info#1{%
+ \begingroup
+ \def\\{\MessageBreak}%
+ \PackageInfo{babel}{#1}%
+ \endgroup}
+\fi
+\@ifpackagewith{babel}{silent}
+ {\let\bbl@info\@gobble
+ \let\bbl@warning\@gobble}
+ {}
+\def\bbl@nocaption{\protect\bbl@nocaption@i}
+\def\bbl@nocaption@i#1#2{% 1: text to be printed 2: caption macro \langXname
+ \global\@namedef{#2}{\textbf{?#1?}}%
+ \@nameuse{#2}%
+ \bbl@warning{%
+ \@backslashchar#2 not set. Please, define\\%
+ it in the preamble with something like:\\%
+ \string\renewcommand\@backslashchar#2{..}\\%
+ Reported}}
+\def\bbl@tentative{\protect\bbl@tentative@i}
+\def\bbl@tentative@i#1{%
+ \bbl@warning{%
+ Some functions for '#1' are tentative.\\%
+ They might not work as expected and their behavior\\%
+ could change in the future.\\%
+ Reported}}
+\def\@nolanerr#1{%
+ \bbl@error
+ {You haven't defined the language #1\space yet}%
+ {Your command will be ignored, type <return> to proceed}}
+\def\@nopatterns#1{%
+ \bbl@warning
+ {No hyphenation patterns were preloaded for\\%
+ the language `#1' into the format.\\%
+ Please, configure your TeX system to add them and\\%
+ rebuild the format. Now I will use the patterns\\%
+ preloaded for \bbl@nulllanguage\space instead}}
+\let\bbl@usehooks\@gobbletwo
+%</kernel>
+%<*patterns>
+% \end{macrocode}
+%
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \section{Loading hyphenation patterns}
+%
+% The following code is meant to be read by ini\TeX\ because it
+% should instruct \TeX\ to read hyphenation patterns. To this end the
+% \texttt{docstrip} option \texttt{patterns} can be used to include
+% this code in the file \file{hyphen.cfg}. Code is written with lower
+% level macros.
+%
+% \changes{babel~3.9g}{2013/05/30}{Code moved from plain.def}
+%
+% We want to add a message to the message \LaTeX$\:$2.09 puts in
+% the |\everyjob| register. This could be done by the following
+% code:
+%\begin{verbatim}
+% \let\orgeveryjob\everyjob
+% \def\everyjob#1{%
+% \orgeveryjob{#1}%
+% \orgeveryjob\expandafter{\the\orgeveryjob\immediate\write16{%
+% hyphenation patterns for \the\loaded@patterns loaded.}}%
+% \let\everyjob\orgeveryjob\let\orgeveryjob\@undefined}
+%\end{verbatim}
+% The code above redefines the control sequence \cs{everyjob}
+% in order to be able to add something to the current contents of
+% the register. This is necessary because the processing of
+% hyphenation patterns happens long before \LaTeX\ fills the
+% register.
+%
+% There are some problems with this approach though.
+% \begin{itemize}
+% \item When someone wants to use several hyphenation patterns with
+% \SliTeX\ the above scheme won't work. The reason is that \SliTeX\
+% overwrites the contents of the |\everyjob| register with its own
+% message.
+% \item Plain \TeX\ does not use the |\everyjob| register so the
+% message would not be displayed.
+% \end{itemize}
+% To circumvent this a `dirty trick' can be used. As this code is
+% only processed when creating a new format file there is one
+% command that is sure to be used, |\dump|. Therefore the original
+% |\dump| is saved in |\org@dump| and a new definition is supplied.
+%
+% To make sure that \LaTeX$\:$2.09 executes the
+% |\@begindocumenthook| we would want to alter |\begin{document}|,
+% but as this done too often already, we add the new code at the
+% front of |\@preamblecmds|. But we can only do that after it has
+% been defined, so we add this piece of code to |\dump|.
+%
+% This new definition starts by adding an instruction to write a
+% message on the terminal and in the transcript file to inform the
+% user of the preloaded hyphenation patterns.
+%
+% Then everything is restored to the old situation and the format
+% is dumped.
+%
+% \begin{macrocode}
+<@Make sure ProvidesFile is defined@>
+\ProvidesFile{hyphen.cfg}[<@date@> <@version@> Babel hyphens]
+\xdef\bbl@format{\jobname}
+\ifx\AtBeginDocument\@undefined
+ \def\@empty{}
+ \let\orig@dump\dump
+ \def\dump{%
+ \ifx\@ztryfc\@undefined
+ \else
+ \toks0=\expandafter{\@preamblecmds}%
+ \edef\@preamblecmds{\noexpand\@begindocumenthook\the\toks0}%
+ \def\@begindocumenthook{}%
+ \fi
+ \let\dump\orig@dump\let\orig@dump\@undefined\dump}
+\fi
+<@Define core switching macros@>
+% \end{macrocode}
+%
+% \begin{macro}{\process@line}
+% Each line in the file \file{language.dat} is processed by
+% |\process@line| after it is read. The first thing this macro does
+% is to check whether the line starts with \texttt{=}.
+% When the first token of a line is an \texttt{=}, the macro
+% |\process@synonym| is called; otherwise the macro
+% |\process@language| will continue.
+%
+% \changes{babel~3.9a}{2012/12/12}{Use spaces as delimiters, to avoid
+% extra spaces. Once parsed, pass them in the traditional way}
+%
+% \begin{macrocode}
+\def\process@line#1#2 #3 #4 {%
+ \ifx=#1%
+ \process@synonym{#2}%
+ \else
+ \process@language{#1#2}{#3}{#4}%
+ \fi
+ \ignorespaces}
+% \end{macrocode}
+%
+% \end{macro}
+%
+% \begin{macro}{\process@synonym}
+%
+% This macro takes care of the lines which start with an
+% \texttt{=}. It needs an empty token register to begin with.
+% |\bbl@languages| is also set to empty.
+%
+% \begin{macrocode}
+\toks@{}
+\def\bbl@languages{}
+% \end{macrocode}
+%
+% When no languages have been loaded yet, the name following the
+% \texttt{=} will be a synonym for hyphenation register 0. So, it is
+% stored in a token register and executed when the first pattern file
+% has been processed. (The |\relax| just helps to the |\if| below
+% catching synonyms without a language.)
+%
+% Otherwise the name will be a synonym for the language loaded last.
+%
+% We also need to copy the hyphenmin parameters for the synonym.
+%
+% \changes{babel~3.9a}{2012/06/25}{Added \cs{bbl@languages}}
+%
+% \begin{macrocode}
+\def\process@synonym#1{%
+ \ifnum\last@language=\m@ne
+ \toks@\expandafter{\the\toks@\relax\process@synonym{#1}}%
+ \else
+ \expandafter\chardef\csname l@#1\endcsname\last@language
+ \wlog{\string\l@#1=\string\language\the\last@language}%
+ \expandafter\let\csname #1hyphenmins\expandafter\endcsname
+ \csname\languagename hyphenmins\endcsname
+ \let\bbl@elt\relax
+ \edef\bbl@languages{\bbl@languages\bbl@elt{#1}{\the\last@language}{}{}}%
+ \fi}
+% \end{macrocode}
+%
+% \end{macro}
+%
+% \begin{macro}{\process@language}
+% The macro |\process@language| is used to process a non-empty line
+% from the `configuration file'. It has three arguments, each
+% delimited by white space. The first argument is the `name' of a
+% language; the second is the name of the file that contains the
+% patterns. The optional third argument is the name of a file
+% containing hyphenation exceptions.
+%
+% The first thing to do is call |\addlanguage| to allocate a pattern
+% register and to make that register `active'. Then the pattern file
+% is read.
+%
+% \changes{babel~3.9a}{2012/12/10}{Removed \cs{selectfont} (I presume
+% it was intended to catch wrong encoding codes, but I don't think
+% this is necessary and as a side effect it might preload fonts)}
+%
+% For some hyphenation patterns it is needed to load them with a
+% specific font encoding selected. This can be specified in the
+% file \file{language.dat} by adding for instance `\texttt{:T1}' to
+% the name of the language. The macro |\bbl@get@enc| extracts the
+% font encoding from the language name and stores it in
+% |\bbl@hyph@enc|. The latter can be used in hyphenation files if
+% you need to set a behavior depending on the given encoding (it
+% is set to empty if no encoding is given).
+%
+% Pattern files may contain assignments to |\lefthyphenmin| and
+% |\righthyphenmin|. \TeX\ does not keep track of these
+% assignments. Therefore we try to detect such assignments and
+% store them in the |\|\langvar|hyphenmins| macro. When no
+% assignments were made we provide a default setting.
+%
+% Some pattern files contain changes to the |\lccode| en |\uccode|
+% arrays. Such changes should remain local to the language;
+% therefore we process the pattern file in a group; the |\patterns|
+% command acts globally so its effect will be remembered.
+%
+% Then we globally store the settings of |\lefthyphenmin| and
+% |\righthyphenmin| and close the group.
+%
+% When the hyphenation patterns have been processed we need to see
+% if a file with hyphenation exceptions needs to be read. This is
+% the case when the third argument is not empty and when it does
+% not contain a space token. (Note however there is no need to save
+% hyphenation exceptions into the format.)
+%
+% \changes{babel~3.9a}{2012/06/25}{Added \cs{bbl@languages}}
+% \changes{babel~3.9f}{2013/05/16}{Restored code to set default
+% hyphenmins, which was deleted mistakenly}
+%
+% \cs{bbl@languages} saves a snapshot of the loaded languagues in the
+% form \cs{bbl@elt}\marg{language-name}\marg{number}%
+% \marg{patterns-file}\marg{exceptions-file}. Note the last 2
+% arguments are empty in `dialects' defined in |language.dat| with
+% |=|. Note also the language name can have encoding info.
+%
+% Finally, if the counter |\language| is equal to zero we execute the
+% synonyms stored.
+%
+% \begin{macrocode}
+\def\process@language#1#2#3{%
+ \expandafter\addlanguage\csname l@#1\endcsname
+ \expandafter\language\csname l@#1\endcsname
+ \edef\languagename{#1}%
+ \bbl@hook@everylanguage{#1}%
+ % > luatex
+ \bbl@get@enc#1::\@@@
+ \begingroup
+ \lefthyphenmin\m@ne
+ \bbl@hook@loadpatterns{#2}%
+ % > luatex
+ \ifnum\lefthyphenmin=\m@ne
+ \else
+ \expandafter\xdef\csname #1hyphenmins\endcsname{%
+ \the\lefthyphenmin\the\righthyphenmin}%
+ \fi
+ \endgroup
+ \def\bbl@tempa{#3}%
+ \ifx\bbl@tempa\@empty\else
+ \bbl@hook@loadexceptions{#3}%
+ % > luatex
+ \fi
+ \let\bbl@elt\relax
+ \edef\bbl@languages{%
+ \bbl@languages\bbl@elt{#1}{\the\language}{#2}{\bbl@tempa}}%
+ \ifnum\the\language=\z@
+ \expandafter\ifx\csname #1hyphenmins\endcsname\relax
+ \set@hyphenmins\tw@\thr@@\relax
+ \else
+ \expandafter\expandafter\expandafter\set@hyphenmins
+ \csname #1hyphenmins\endcsname
+ \fi
+ \the\toks@
+ \toks@{}%
+ \fi}
+% \end{macrocode}
+%
+% \begin{macro}{\bbl@get@enc}
+%
+% \changes{babel~3.9a}{2012/12/11}{Code much simplified}
+%
+% \begin{macro}{\bbl@hyph@enc}
+% The macro |\bbl@get@enc| extracts the font encoding from the
+% language name and stores it in |\bbl@hyph@enc|. It uses delimited
+% arguments to achieve this.
+%
+% \begin{macrocode}
+\def\bbl@get@enc#1:#2:#3\@@@{\def\bbl@hyph@enc{#2}}
+% \end{macrocode}
+%
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% Now, hooks are defined. For efficiency reasons, they are dealt
+% here in a special way. Besides \luatex, format specific
+% configuration files are taken into account.
+%
+% \changes{babel~3.9b}{2013/03/25}{Fixed an idiot slip: \cs{def}
+% intead of \cs{let}}
+%
+% \begin{macrocode}
+\def\bbl@hook@everylanguage#1{}
+\def\bbl@hook@loadpatterns#1{\input #1\relax}
+\let\bbl@hook@loadexceptions\bbl@hook@loadpatterns
+\let\bbl@hook@loadkernel\bbl@hook@loadpatterns
+\begingroup
+ \def\AddBabelHook#1#2{%
+ \expandafter\ifx\csname bbl@hook@#2\endcsname\relax
+ \def\next{\toks1}%
+ \else
+ \def\next{\expandafter\gdef\csname bbl@hook@#2\endcsname####1}%
+ \fi
+ \next}
+ \ifx\directlua\@undefined
+ \ifx\XeTeXinputencoding\@undefined\else
+ \input xebabel.def
+ \fi
+ \else
+ \input luababel.def
+ \fi
+ \openin1 = babel-\bbl@format.cfg
+ \ifeof1
+ \else
+ \input babel-\bbl@format.cfg\relax
+ \fi
+ \closein1
+\endgroup
+\bbl@hook@loadkernel{switch.def}
+% \end{macrocode}
+%
+% \begin{macro}{\readconfigfile}
+% The configuration file can now be opened for reading.
+%
+% \begin{macrocode}
+\openin1 = language.dat
+% \end{macrocode}
+%
+% See if the file exists, if not, use the default hyphenation file
+% \file{hyphen.tex}. The user will be informed about this.
+%
+% \begin{macrocode}
+\def\languagename{english}%
+\ifeof1
+ \message{I couldn't find the file language.dat,\space
+ I will try the file hyphen.tex}
+ \input hyphen.tex\relax
+ \chardef\l@english\z@
+\else
+% \end{macrocode}
+%
+% Pattern registers are allocated using count register
+% |\last@language|. Its initial value is~0. The definition of the
+% macro |\newlanguage| is such that it first increments the count
+% register and then defines the language. In order to have the
+% first patterns loaded in pattern register number~0 we initialize
+% |\last@language| with the value~$-1$.
+%
+% \begin{macrocode}
+ \last@language\m@ne
+% \end{macrocode}
+%
+% We now read lines from the file until the end is found
+%
+% \begin{macrocode}
+ \loop
+% \end{macrocode}
+%
+% While reading from the input, it is useful to switch off
+% recognition of the end-of-line character. This saves us stripping
+% off spaces from the contents of the control sequence.
+%
+% \begin{macrocode}
+ \endlinechar\m@ne
+ \read1 to \bbl@line
+ \endlinechar`\^^M
+% \end{macrocode}
+%
+% \changes{babel~3.9a}{2012/12/14}{Test simplified and moved}
+% \changes{babel~3.9a}{2012/12/12}{Use only spaces as delimiters and
+% not /, as previouly done}
+%
+% If the file has reached its end, exit from the loop here. If not,
+% empty lines are skipped. Add 3 space characters to the end of
+% |\bbl@line|. This is needed to be able to recognize the arguments
+% of |\process@line| later on. The default language should be the
+% very first one.
+%
+% \begin{macrocode}
+ \if T\ifeof1F\fi T\relax
+ \ifx\bbl@line\@empty\else
+ \edef\bbl@line{\bbl@line\space\space\space}%
+ \expandafter\process@line\bbl@line\relax
+ \fi
+ \repeat
+% \end{macrocode}
+%
+% Check for the end of the file. We must reverse the test for
+% |\ifeof| without |\else|. Then reactivate the default patterns.
+%
+% \begin{macrocode}
+ \begingroup
+ \def\bbl@elt#1#2#3#4{%
+ \global\language=#2\relax
+ \gdef\languagename{#1}%
+ \def\bbl@elt##1##2##3##4{}}%
+ \bbl@languages
+ \endgroup
+\fi
+% \end{macrocode}
+%
+% and close the configuration file.
+%
+% \begin{macrocode}
+\closein1
+% \end{macrocode}
+%
+% We add a message about the fact that babel is loaded in the
+% format and with which language patterns to the \cs{everyjob}
+% register.
+%
+% \changes{babel~3.9a}{2012/09/25}{The list of languages is not
+% printed every job any more (it is saved in \cs{bbl@languages}).}
+% \changes{babel~3.9g}{2013/07/28}{In non-LaTeX formats the number of
+% languages were not printed. Moved from \cs{dump} and cleaned up:
+% now \cs{toks}8 is expanded here.}
+% \changes{babel~3.9o}{2016/01/25}{The number of languages loaded was
+% off by 1.}
+% \changes{babel~3.21}{2018/05/09}{The message is not printed any more.}
+%
+% \begin{macrocode}
+\if/\the\toks@/\else
+ \errhelp{language.dat loads no language, only synonyms}
+ \errmessage{Orphan language synonym}
+\fi
+% \end{macrocode}
+%
+% Also remove some macros from memory and raise an error
+% if |\toks@| is not empty. Finally load \file{switch.def}, but the
+% latter is not required and the line inputting it may be commented
+% out.
+%
+% \changes{babel~3.9a}{2012/12/11}{Raise error if there are synonyms
+% without languages}
+%
+% \begin{macrocode}
+\let\bbl@line\@undefined
+\let\process@line\@undefined
+\let\process@synonym\@undefined
+\let\process@language\@undefined
+\let\bbl@get@enc\@undefined
+\let\bbl@hyph@enc\@undefined
+\let\bbl@tempa\@undefined
+\let\bbl@hook@loadkernel\@undefined
+\let\bbl@hook@everylanguage\@undefined
+\let\bbl@hook@loadpatterns\@undefined
+\let\bbl@hook@loadexceptions\@undefined
+%</patterns>
+% \end{macrocode}
+%
+% Here the code for ini\TeX\ ends.
+% \end{macro}
+%
+% \section{Font handling with fontspec}
+%
+% \changes{3.15}{2017/10/30}{New way to select fonts, with \cs{babelfont}}
+%
+% Add the bidi handler just before luaoftload, which is loaded by default
+% by LaTeX. Just in case, consider the possibility it has not been
+% loaded. First, a couple of definitions related to bidi [misplaced].
+%
+% \changes{babel~3.30}{2019/04/22}{Ensure the current textdir inside
+% boxes within math.}
+%
+% \begin{macrocode}
+%<<*More package options>>
+\ifodd\bbl@engine
+ \DeclareOption{bidi=basic-r}%
+ {\ExecuteOptions{bidi=basic}}
+ \DeclareOption{bidi=basic}%
+ {\let\bbl@beforeforeign\leavevmode
+ % TODO - to locale_props, not as separate attribute
+ \newattribute\bbl@attr@dir
+ % I don't like it, hackish:
+ \frozen@everymath\expandafter{%
+ \expandafter\bbl@mathboxdir\the\frozen@everymath}%
+ \frozen@everydisplay\expandafter{%
+ \expandafter\bbl@mathboxdir\the\frozen@everydisplay}%
+ \bbl@exp{\output{\bodydir\pagedir\the\output}}%
+ \AtEndOfPackage{\EnableBabelHook{babel-bidi}}}
+\else
+ \DeclareOption{bidi=basic-r}%
+ {\ExecuteOptions{bidi=basic}}
+ \DeclareOption{bidi=basic}%
+ {\bbl@error
+ {The bidi method `basic' is available only in\\%
+ luatex. I'll continue with `bidi=default', so\\%
+ expect wrong results}%
+ {See the manual for further details.}%
+ \let\bbl@beforeforeign\leavevmode
+ \AtEndOfPackage{%
+ \EnableBabelHook{babel-bidi}%
+ \bbl@xebidipar}}
+ \def\bbl@loadxebidi#1{%
+ \ifx\RTLfootnotetext\@undefined
+ \AtEndOfPackage{%
+ \EnableBabelHook{babel-bidi}%
+ \ifx\fontspec\@undefined
+ \usepackage{fontspec}% bidi needs fontspec
+ \fi
+ \usepackage#1{bidi}}%
+ \fi}
+ \DeclareOption{bidi=bidi}%
+ {\bbl@tentative{bidi=bidi}%
+ \bbl@loadxebidi{}}
+ \DeclareOption{bidi=bidi-r}%
+ {\bbl@tentative{bidi=bidi-r}%
+ \bbl@loadxebidi{[rldocument]}}
+ \DeclareOption{bidi=bidi-l}%
+ {\bbl@tentative{bidi=bidi-l}%
+ \bbl@loadxebidi{}}
+\fi
+\DeclareOption{bidi=default}%
+ {\let\bbl@beforeforeign\leavevmode
+ \ifodd\bbl@engine
+ \newattribute\bbl@attr@dir
+ \bbl@exp{\output{\bodydir\pagedir\the\output}}%
+ \fi
+ \AtEndOfPackage{%
+ \EnableBabelHook{babel-bidi}%
+ \ifodd\bbl@engine\else
+ \bbl@xebidipar
+ \fi}}
+%<</More package options>>
+% \end{macrocode}
+%
+% With explicit languages, we could define the font at once, but we
+% don't. Just wait and see if the language is actually activated.
+%
+% \begin{macrocode}
+%<<*Font selection>>
+\bbl@trace{Font handling with fontspec}
+\@onlypreamble\babelfont
+\newcommand\babelfont[2][]{% 1=langs/scripts 2=fam
+ \edef\bbl@tempa{#1}%
+ \def\bbl@tempb{#2}%
+ \ifx\fontspec\@undefined
+ \usepackage{fontspec}%
+ \fi
+ \EnableBabelHook{babel-fontspec}% Just calls \bbl@switchfont
+ \bbl@bblfont}
+\newcommand\bbl@bblfont[2][]{% 1=features 2=fontname
+ \bbl@ifunset{\bbl@tempb family}{\bbl@providefam{\bbl@tempb}}{}%
+ % For the default font, just in case:
+ \bbl@ifunset{bbl@lsys@\languagename}{\bbl@provide@lsys{\languagename}}{}%
+ \expandafter\bbl@ifblank\expandafter{\bbl@tempa}%
+ {\bbl@csarg\edef{\bbl@tempb dflt@}{<>{#1}{#2}}% save bbl@rmdflt@
+ \bbl@exp{%
+ \let\<bbl@\bbl@tempb dflt@\languagename>\<bbl@\bbl@tempb dflt@>%
+ \\\bbl@font@set\<bbl@\bbl@tempb dflt@\languagename>%
+ \<\bbl@tempb default>\<\bbl@tempb family>}}%
+ {\bbl@foreach\bbl@tempa{% ie bbl@rmdflt@lang / *scrt
+ \bbl@csarg\def{\bbl@tempb dflt@##1}{<>{#1}{#2}}}}}%
+% \end{macrocode}
+%
+% If the family in the previous command does not exist, it must be
+% defined. Here is how:
+%
+% \begin{macrocode}
+\def\bbl@providefam#1{%
+ \bbl@exp{%
+ \\\newcommand\<#1default>{}% Just define it
+ \\\bbl@add@list\\\bbl@font@fams{#1}%
+ \\\DeclareRobustCommand\<#1family>{%
+ \\\not@math@alphabet\<#1family>\relax
+ \\\fontfamily\<#1default>\\\selectfont}%
+ \\\DeclareTextFontCommand{\<text#1>}{\<#1family>}}}
+% \end{macrocode}
+%
+% The following macro is activated when the hook |babel-fontspec| is
+% enabled.
+%
+% \begin{macrocode}
+\def\bbl@switchfont{%
+ \bbl@ifunset{bbl@lsys@\languagename}{\bbl@provide@lsys{\languagename}}{}%
+ \bbl@exp{% eg Arabic -> arabic
+ \lowercase{\edef\\\bbl@tempa{\bbl@cs{sname@\languagename}}}}%
+ \bbl@foreach\bbl@font@fams{%
+ \bbl@ifunset{bbl@##1dflt@\languagename}% (1) language?
+ {\bbl@ifunset{bbl@##1dflt@*\bbl@tempa}% (2) from script?
+ {\bbl@ifunset{bbl@##1dflt@}% 2=F - (3) from generic?
+ {}% 123=F - nothing!
+ {\bbl@exp{% 3=T - from generic
+ \global\let\<bbl@##1dflt@\languagename>%
+ \<bbl@##1dflt@>}}}%
+ {\bbl@exp{% 2=T - from script
+ \global\let\<bbl@##1dflt@\languagename>%
+ \<bbl@##1dflt@*\bbl@tempa>}}}%
+ {}}% 1=T - language, already defined
+ \def\bbl@tempa{%
+ \bbl@warning{The current font is not a standard family:\\%
+ \fontname\font\\%
+ Script and Language are not applied. Consider\\%
+ defining a new family with \string\babelfont.\\%
+ Reported}}%
+ \bbl@foreach\bbl@font@fams{% don't gather with prev for
+ \bbl@ifunset{bbl@##1dflt@\languagename}%
+ {\bbl@cs{famrst@##1}%
+ \global\bbl@csarg\let{famrst@##1}\relax}%
+ {\bbl@exp{% order is relevant
+ \\\bbl@add\\\originalTeX{%
+ \\\bbl@font@rst{\bbl@cs{##1dflt@\languagename}}%
+ \<##1default>\<##1family>{##1}}%
+ \\\bbl@font@set\<bbl@##1dflt@\languagename>% the main part!
+ \<##1default>\<##1family>}}}%
+ \bbl@ifrestoring{}{\bbl@tempa}}%
+% \end{macrocode}
+%
+% Now the macros defining the font with \textsf{fontspec}.
+%
+% When there are repeated keys in \textsf{fontspec}, the last value
+% wins. So, we just place the ini settings at the beginning, and user
+% settings will take precedence. We must deactivate temporarily
+% |\bbl@mapselect| because |\selectfont| is called internally when a
+% font is defined.
+%
+% \changes{3.28}{2019/04/01}{\cs{babelfont} now based on
+% \cs{newfontfamily}.}
+%
+% \begin{macrocode}
+\def\bbl@font@set#1#2#3{% eg \bbl@rmdflt@lang \rmdefault \rmfamily
+ \bbl@xin@{<>}{#1}%
+ \ifin@
+ \bbl@exp{\\\bbl@fontspec@set\\#1\expandafter\@gobbletwo#1\\#3}%
+ \fi
+ \bbl@exp{%
+ \def\\#2{#1}% eg, \rmdefault{\bbl@rmdflt@lang}
+ \\\bbl@ifsamestring{#2}{\f@family}{\\#3\let\\\bbl@tempa\relax}{}}}
+% TODO - next should be global?, but even local does its job. I'm
+% still not sure -- must investigate:
+\def\bbl@fontspec@set#1#2#3#4{% eg \bbl@rmdflt@lang fnt-opt fnt-nme \xxfamily
+ \let\bbl@tempe\bbl@mapselect
+ \let\bbl@mapselect\relax
+ \let\bbl@temp@fam#4% eg, '\rmfamily', to be restored below
+ \let#4\relax % So that can be used with \newfontfamily
+ \bbl@exp{%
+ \let\\\bbl@temp@pfam\<\bbl@stripslash#4\space>% eg, '\rmfamily '
+ \<keys_if_exist:nnF>{fontspec-opentype}%
+ {Script/\bbl@cs{sname@\languagename}}%
+ {\\\newfontscript{\bbl@cs{sname@\languagename}}%
+ {\bbl@cs{sotf@\languagename}}}%
+ \<keys_if_exist:nnF>{fontspec-opentype}%
+ {Language/\bbl@cs{lname@\languagename}}%
+ {\\\newfontlanguage{\bbl@cs{lname@\languagename}}%
+ {\bbl@cs{lotf@\languagename}}}%
+ \\\newfontfamily\\#4%
+ [\bbl@cs{lsys@\languagename},#2]}{#3}% ie \bbl@exp{..}{#3}
+ \begingroup
+ #4%
+ \xdef#1{\f@family}% eg, \bbl@rmdflt@lang{FreeSerif(0)}
+ \endgroup
+ \let#4\bbl@temp@fam
+ \bbl@exp{\let\<\bbl@stripslash#4\space>}\bbl@temp@pfam
+ \let\bbl@mapselect\bbl@tempe}%
+% \end{macrocode}
+%
+% font@rst and famrst are only used when there is no global settings,
+% to save and restore de previous families. Not really necessary, but
+% done for optimization.
+%
+% \begin{macrocode}
+\def\bbl@font@rst#1#2#3#4{%
+ \bbl@csarg\def{famrst@#4}{\bbl@font@set{#1}#2#3}}
+% \end{macrocode}
+%
+% The default font families. They are eurocentric, but the list can be
+% expanded easily with |\babelfont|.
+%
+% \begin{macrocode}
+\def\bbl@font@fams{rm,sf,tt}
+% \end{macrocode}
+%
+% The old tentative way. Short and preverved for compatibility, but
+% deprecated. Note there is no direct alternative for
+% |\babelFSfeatures|. The reason in explained in the user guide, but
+% essentially -- that was not the way to go :-).
+%
+% \begin{macrocode}
+\newcommand\babelFSstore[2][]{%
+ \bbl@ifblank{#1}%
+ {\bbl@csarg\def{sname@#2}{Latin}}%
+ {\bbl@csarg\def{sname@#2}{#1}}%
+ \bbl@provide@dirs{#2}%
+ \bbl@csarg\ifnum{wdir@#2}>\z@
+ \let\bbl@beforeforeign\leavevmode
+ \EnableBabelHook{babel-bidi}%
+ \fi
+ \bbl@foreach{#2}{%
+ \bbl@FSstore{##1}{rm}\rmdefault\bbl@save@rmdefault
+ \bbl@FSstore{##1}{sf}\sfdefault\bbl@save@sfdefault
+ \bbl@FSstore{##1}{tt}\ttdefault\bbl@save@ttdefault}}
+\def\bbl@FSstore#1#2#3#4{%
+ \bbl@csarg\edef{#2default#1}{#3}%
+ \expandafter\addto\csname extras#1\endcsname{%
+ \let#4#3%
+ \ifx#3\f@family
+ \edef#3{\csname bbl@#2default#1\endcsname}%
+ \fontfamily{#3}\selectfont
+ \else
+ \edef#3{\csname bbl@#2default#1\endcsname}%
+ \fi}%
+ \expandafter\addto\csname noextras#1\endcsname{%
+ \ifx#3\f@family
+ \fontfamily{#4}\selectfont
+ \fi
+ \let#3#4}}
+\let\bbl@langfeatures\@empty
+\def\babelFSfeatures{% make sure \fontspec is redefined once
+ \let\bbl@ori@fontspec\fontspec
+ \renewcommand\fontspec[1][]{%
+ \bbl@ori@fontspec[\bbl@langfeatures##1]}
+ \let\babelFSfeatures\bbl@FSfeatures
+ \babelFSfeatures}
+\def\bbl@FSfeatures#1#2{%
+ \expandafter\addto\csname extras#1\endcsname{%
+ \babel@save\bbl@langfeatures
+ \edef\bbl@langfeatures{#2,}}}
+%<</Font selection>>
+% \end{macrocode}
+%
+% \section{Hooks for XeTeX and LuaTeX}
+%
+% \subsection{XeTeX}
+%
+% Unfortunately, the current encoding cannot be retrieved and
+% therefore it is reset always to |utf8|, which seems a sensible
+% default.
+%
+% \LaTeX{} sets many ``codes'' just before loading
+% \verb|hyphen.cfg|. That is not a problem in luatex, but in xetex
+% they must be reset to the proper value. Most of the work is done in
+% \textsf{xe(la)tex.ini}, so here we just ``undo'' some of the
+% changes done by \LaTeX. Anyway, for consistency Lua\TeX{} also
+% resets the catcodes.
+%
+% \changes{bbunicode~1.0c}{2014/03/10}{Reset ``codes'' set by \cs{LaTeX}
+% to what xetex expects. Used also in luatex.}
+% \changes{bbunicode~1.0f}{2015/12/06}{This block was assigned to
+% xetex, even in luatex. Fixed here and below.}
+%
+% \begin{macrocode}
+%<<*Restore Unicode catcodes before loading patterns>>
+ \begingroup
+ % Reset chars "80-"C0 to category "other", no case mapping:
+ \catcode`\@=11 \count@=128
+ \loop\ifnum\count@<192
+ \global\uccode\count@=0 \global\lccode\count@=0
+ \global\catcode\count@=12 \global\sfcode\count@=1000
+ \advance\count@ by 1 \repeat
+ % Other:
+ \def\O ##1 {%
+ \global\uccode"##1=0 \global\lccode"##1=0
+ \global\catcode"##1=12 \global\sfcode"##1=1000 }%
+ % Letter:
+ \def\L ##1 ##2 ##3 {\global\catcode"##1=11
+ \global\uccode"##1="##2
+ \global\lccode"##1="##3
+ % Uppercase letters have sfcode=999:
+ \ifnum"##1="##3 \else \global\sfcode"##1=999 \fi }%
+ % Letter without case mappings:
+ \def\l ##1 {\L ##1 ##1 ##1 }%
+ \l 00AA
+ \L 00B5 039C 00B5
+ \l 00BA
+ \O 00D7
+ \l 00DF
+ \O 00F7
+ \L 00FF 0178 00FF
+ \endgroup
+ \input #1\relax
+%<</Restore Unicode catcodes before loading patterns>>
+% \end{macrocode}
+%
+% Some more common code.
+%
+% \changes{babel 3.17}{2018/01/24}{Tools for bidi footnote}
+%
+% \begin{macrocode}
+%<<*Footnote changes>>
+\bbl@trace{Bidi footnotes}
+\ifx\bbl@beforeforeign\leavevmode
+ \def\bbl@footnote#1#2#3{%
+ \@ifnextchar[%
+ {\bbl@footnote@o{#1}{#2}{#3}}%
+ {\bbl@footnote@x{#1}{#2}{#3}}}
+ \def\bbl@footnote@x#1#2#3#4{%
+ \bgroup
+ \select@language@x{\bbl@main@language}%
+ \bbl@fn@footnote{#2#1{\ignorespaces#4}#3}%
+ \egroup}
+ \def\bbl@footnote@o#1#2#3[#4]#5{%
+ \bgroup
+ \select@language@x{\bbl@main@language}%
+ \bbl@fn@footnote[#4]{#2#1{\ignorespaces#5}#3}%
+ \egroup}
+ \def\bbl@footnotetext#1#2#3{%
+ \@ifnextchar[%
+ {\bbl@footnotetext@o{#1}{#2}{#3}}%
+ {\bbl@footnotetext@x{#1}{#2}{#3}}}
+ \def\bbl@footnotetext@x#1#2#3#4{%
+ \bgroup
+ \select@language@x{\bbl@main@language}%
+ \bbl@fn@footnotetext{#2#1{\ignorespaces#4}#3}%
+ \egroup}
+ \def\bbl@footnotetext@o#1#2#3[#4]#5{%
+ \bgroup
+ \select@language@x{\bbl@main@language}%
+ \bbl@fn@footnotetext[#4]{#2#1{\ignorespaces#5}#3}%
+ \egroup}
+ \def\BabelFootnote#1#2#3#4{%
+ \ifx\bbl@fn@footnote\@undefined
+ \let\bbl@fn@footnote\footnote
+ \fi
+ \ifx\bbl@fn@footnotetext\@undefined
+ \let\bbl@fn@footnotetext\footnotetext
+ \fi
+ \bbl@ifblank{#2}%
+ {\def#1{\bbl@footnote{\@firstofone}{#3}{#4}}
+ \@namedef{\bbl@stripslash#1text}%
+ {\bbl@footnotetext{\@firstofone}{#3}{#4}}}%
+ {\def#1{\bbl@exp{\\\bbl@footnote{\\\foreignlanguage{#2}}}{#3}{#4}}%
+ \@namedef{\bbl@stripslash#1text}%
+ {\bbl@exp{\\\bbl@footnotetext{\\\foreignlanguage{#2}}}{#3}{#4}}}}
+\fi
+%<</Footnote changes>>
+% \end{macrocode}
+%
+% Now, the code.
+%
+% \begin{macrocode}
+%<*xetex>
+\def\BabelStringsDefault{unicode}
+\let\xebbl@stop\relax
+\AddBabelHook{xetex}{encodedcommands}{%
+ \def\bbl@tempa{#1}%
+ \ifx\bbl@tempa\@empty
+ \XeTeXinputencoding"bytes"%
+ \else
+ \XeTeXinputencoding"#1"%
+ \fi
+ \def\xebbl@stop{\XeTeXinputencoding"utf8"}}
+\AddBabelHook{xetex}{stopcommands}{%
+ \xebbl@stop
+ \let\xebbl@stop\relax}
+\def\bbl@intraspace#1 #2 #3\@@{%
+ \bbl@csarg\gdef{xeisp@\bbl@cs{sbcp@\languagename}}%
+ {\XeTeXlinebreakskip #1em plus #2em minus #3em\relax}}
+\def\bbl@intrapenalty#1\@@{%
+ \bbl@csarg\gdef{xeipn@\bbl@cs{sbcp@\languagename}}%
+ {\XeTeXlinebreakpenalty #1\relax}}
+\AddBabelHook{xetex}{loadkernel}{%
+<@Restore Unicode catcodes before loading patterns@>}
+\ifx\DisableBabelHook\@undefined\endinput\fi
+\AddBabelHook{babel-fontspec}{afterextras}{\bbl@switchfont}
+\DisableBabelHook{babel-fontspec}
+<@Font selection@>
+\input txtbabel.def
+%</xetex>
+% \end{macrocode}
+%
+% \subsection{Layout}
+%
+% \changes{babel~3.16}{2018/01/02}{Option layout - first available options:
+% sectioning, counters, lists, columns, contents}
+%
+% \textit{In progress.}
+%
+% Note elements like headlines and margins can be modified easily with
+% packages like \textsf{fancyhdr}, \textsf{typearea} or
+% \textsf{titleps}, and \textsf{geometry}.
+%
+% |\bbl@startskip| and |\bbl@endskip| are available to package
+% authors. Thanks to the \TeX{} expansion mechanism the following
+% constructs are valid: |\adim\bbl@startskip|,
+% |\advance\bbl@startskip\adim|, |\bbl@startskip\adim|.
+%
+% Consider |txtbabel| as a shorthand for \textit{tex--xet babel},
+% which is the bidi model in both \pdftex{} and \xetex{}.
+%
+% \changes{3.33}{2019/05/04}{\cs{@tabular}, \cs{list}, etc., are
+% patched, instead of redefined.}
+%
+% \begin{macrocode}
+%<*texxet>
+\bbl@trace{Redefinitions for bidi layout}
+\def\bbl@sspre@caption{%
+ \bbl@exp{\everyhbox{\\\bbl@textdir\bbl@cs{wdir@\bbl@main@language}}}}
+\ifx\bbl@opt@layout\@nnil\endinput\fi % No layout
+\def\bbl@startskip{\ifcase\bbl@thepardir\leftskip\else\rightskip\fi}
+\def\bbl@endskip{\ifcase\bbl@thepardir\rightskip\else\leftskip\fi}
+\ifx\bbl@beforeforeign\leavevmode % A poor test for bidi=
+ \def\@hangfrom#1{%
+ \setbox\@tempboxa\hbox{{#1}}%
+ \hangindent\ifcase\bbl@thepardir\wd\@tempboxa\else-\wd\@tempboxa\fi
+ \noindent\box\@tempboxa}
+ \def\raggedright{%
+ \let\\\@centercr
+ \bbl@startskip\z@skip
+ \@rightskip\@flushglue
+ \bbl@endskip\@rightskip
+ \parindent\z@
+ \parfillskip\bbl@startskip}
+ \def\raggedleft{%
+ \let\\\@centercr
+ \bbl@startskip\@flushglue
+ \bbl@endskip\z@skip
+ \parindent\z@
+ \parfillskip\bbl@endskip}
+\fi
+\IfBabelLayout{lists}
+ {\bbl@sreplace\list
+ {\@totalleftmargin\leftmargin}{\@totalleftmargin\bbl@listleftmargin}%
+ \def\bbl@listleftmargin{%
+ \ifcase\bbl@thepardir\leftmargin\else\rightmargin\fi}%
+ \ifcase\bbl@engine
+ \def\labelenumii{)\theenumii(}% pdftex doesn't reverse ()
+ \def\p@enumiii{\p@enumii)\theenumii(}%
+ \fi
+ \bbl@sreplace\@verbatim
+ {\leftskip\@totalleftmargin}%
+ {\bbl@startskip\textwidth
+ \advance\bbl@startskip-\linewidth}%
+ \bbl@sreplace\@verbatim
+ {\rightskip\z@skip}%
+ {\bbl@endskip\z@skip}}%
+ {}
+\IfBabelLayout{contents}
+ {\bbl@sreplace\@dottedtocline{\leftskip}{\bbl@startskip}%
+ \bbl@sreplace\@dottedtocline{\rightskip}{\bbl@endskip}}
+ {}
+\IfBabelLayout{columns}
+ {\bbl@sreplace\@outputdblcol{\hb@xt@\textwidth}{\bbl@outputhbox}%
+ \def\bbl@outputhbox#1{%
+ \hb@xt@\textwidth{%
+ \hskip\columnwidth
+ \hfil
+ {\normalcolor\vrule \@width\columnseprule}%
+ \hfil
+ \hb@xt@\columnwidth{\box\@leftcolumn \hss}%
+ \hskip-\textwidth
+ \hb@xt@\columnwidth{\box\@outputbox \hss}%
+ \hskip\columnsep
+ \hskip\columnwidth}}}%
+ {}
+<@Footnote changes@>
+\IfBabelLayout{footnotes}%
+ {\BabelFootnote\footnote\languagename{}{}%
+ \BabelFootnote\localfootnote\languagename{}{}%
+ \BabelFootnote\mainfootnote{}{}{}}
+ {}
+% \end{macrocode}
+%
+% Implicitly reverses sectioning labels in |bidi=basic|, because
+% the full stop is not in contact with L numbers any more. I
+% think there must be a better way.
+%
+% \begin{macrocode}
+\IfBabelLayout{counters}%
+ {\let\bbl@latinarabic=\@arabic
+ \def\@arabic#1{\babelsublr{\bbl@latinarabic#1}}%
+ \let\bbl@asciiroman=\@roman
+ \def\@roman#1{\babelsublr{\ensureascii{\bbl@asciiroman#1}}}%
+ \let\bbl@asciiRoman=\@Roman
+ \def\@Roman#1{\babelsublr{\ensureascii{\bbl@asciiRoman#1}}}}{}
+%</texxet>
+% \end{macrocode}
+%
+% \subsection{LuaTeX}
+%
+% The new loader for luatex is based solely on |language.dat|, which
+% is read on the fly. The code shouldn't be executed when the format
+% is build, so we check if |\AddBabelHook| is defined. Then comes a
+% modified version of the loader in |hyphen.cfg| (without the
+% hyphenmins stuff, which is under the direct control of \babel).
+%
+% The names |\l@<language>| are defined and take some value from the
+% beginning because all \texttt{ldf} files assume this for the
+% corresponding language to be considered valid, but patterns are not
+% loaded (except the first one). This is done later, when the language
+% is first selected (which usually means when the \texttt{ldf}
+% finishes). If a language has been loaded, |\bbl@hyphendata@<num>|
+% exists (with the names of the files read).
+%
+% The default setup preloads the first language into the format. This
+% is intended mainly for `english', so that it's available without
+% further intervention from the user. To avoid duplicating it, the
+% following rule applies: if the ``0th'' language and the first
+% language in |language.dat| have the same name then just ignore the
+% latter. If there are new synonymous, the are added, but note if the
+% language patterns have not been preloaded they won't at run time.
+%
+% Other preloaded languages could be read twice, if they has been
+% preloaded into the format. This is not optimal, but it shouldn't
+% happen very often -- with \luatex{} patterns are best loaded when
+% the document is typeset, and the ``0th'' language is preloaded just
+% for backwards compatibility.
+%
+% As of 1.1b, lua(e)tex is taken into account. Formerly, loading of
+% patterns on the fly didn't work in this format, but with the new
+% loader it does. Unfortunately, the format is not based on \babel,
+% and data could be duplicated, because languages are reassigned above
+% those in the format (nothing serious, anyway). Note even with this
+% format |language.dat| is used (under the principle of a single
+% source), instead of |language.def|.
+%
+% Of course, there is room for improvements, like tools to read and
+% reassign languages, which would require modifying the language list,
+% and better error handling.
+%
+% We need catcode tables, but no format (targeted by \babel) provide a
+% command to allocate them (although there are packages like
+% \textsf{ctablestack}). For the moment, a dangerous approach is used
+% -- just allocate a high random number and cross the fingers. To
+% complicate things, \textsf{etex.sty} changes the way languages are
+% allocated.
+%
+% \changes{bbunicode~1.0b}{2013/04/22}{luatex-hyphen is loaded with
+% require. Changes supplied by \'{E}lie Roux.}
+% \changes{bbunicode~1.0c}{2014/03/10}{Defined hook for
+% `initiateactive', to fetch the next token and continue only if
+% letter or other.}
+% \changes{bbunicode~1.0d}{2014/03/21}{Removed the `misfeature' for
+% `initiateactive'.}
+% \changes{bbunicode~1.0e}{2015/05/10}{Use brackets instead of
+% \cs{luaescapestring}.}
+% \changes{bbunicode~1.0e}{2015/07/26}{Added function addpattern
+% and modified the patterns hook.}
+% \changes{bbunicode~1.1a}{2016/01/26}{New hyphenation loader for
+% luatex.}
+% \changes{bbunicode~1.1b}{2016/02/05}{Also lua(e)tex.}
+% \changes{bbunicode~1.1c}{2016/02/08}{Base reading of patterns on
+% number, not in name.}
+% \changes{bbunicode~1.1c}{2016/02/08}{Some hacks for polyglossia. To
+% be improved.}
+% \changes{bbunicode~1.1c}{2016/02/23}{Thoroughly revised.}
+% \changes{bbunicode~1.1d}{2016/4/22}{Lua: Fixed a line break at
+% \cs{foreignlanguage} with unloaded patterns. Added
+% \cs{babelcatcodetablenum}, just in case.}
+%
+% \begin{macrocode}
+%<*luatex>
+\ifx\AddBabelHook\@undefined
+\bbl@trace{Read language.dat}
+\begingroup
+ \toks@{}
+ \count@\z@ % 0=start, 1=0th, 2=normal
+ \def\bbl@process@line#1#2 #3 #4 {%
+ \ifx=#1%
+ \bbl@process@synonym{#2}%
+ \else
+ \bbl@process@language{#1#2}{#3}{#4}%
+ \fi
+ \ignorespaces}
+ \def\bbl@manylang{%
+ \ifnum\bbl@last>\@ne
+ \bbl@info{Non-standard hyphenation setup}%
+ \fi
+ \let\bbl@manylang\relax}
+ \def\bbl@process@language#1#2#3{%
+ \ifcase\count@
+ \@ifundefined{zth@#1}{\count@\tw@}{\count@\@ne}%
+ \or
+ \count@\tw@
+ \fi
+ \ifnum\count@=\tw@
+ \expandafter\addlanguage\csname l@#1\endcsname
+ \language\allocationnumber
+ \chardef\bbl@last\allocationnumber
+ \bbl@manylang
+ \let\bbl@elt\relax
+ \xdef\bbl@languages{%
+ \bbl@languages\bbl@elt{#1}{\the\language}{#2}{#3}}%
+ \fi
+ \the\toks@
+ \toks@{}}
+ \def\bbl@process@synonym@aux#1#2{%
+ \global\expandafter\chardef\csname l@#1\endcsname#2\relax
+ \let\bbl@elt\relax
+ \xdef\bbl@languages{%
+ \bbl@languages\bbl@elt{#1}{#2}{}{}}}%
+ \def\bbl@process@synonym#1{%
+ \ifcase\count@
+ \toks@\expandafter{\the\toks@\relax\bbl@process@synonym{#1}}%
+ \or
+ \@ifundefined{zth@#1}{\bbl@process@synonym@aux{#1}{0}}{}%
+ \else
+ \bbl@process@synonym@aux{#1}{\the\bbl@last}%
+ \fi}
+ \ifx\bbl@languages\@undefined % Just a (sensible?) guess
+ \chardef\l@english\z@
+ \chardef\l@USenglish\z@
+ \chardef\bbl@last\z@
+ \global\@namedef{bbl@hyphendata@0}{{hyphen.tex}{}}
+ \gdef\bbl@languages{%
+ \bbl@elt{english}{0}{hyphen.tex}{}%
+ \bbl@elt{USenglish}{0}{}{}}
+ \else
+ \global\let\bbl@languages@format\bbl@languages
+ \def\bbl@elt#1#2#3#4{% Remove all except language 0
+ \ifnum#2>\z@\else
+ \noexpand\bbl@elt{#1}{#2}{#3}{#4}%
+ \fi}%
+ \xdef\bbl@languages{\bbl@languages}%
+ \fi
+ \def\bbl@elt#1#2#3#4{\@namedef{zth@#1}{}} % Define flags
+ \bbl@languages
+ \openin1=language.dat
+ \ifeof1
+ \bbl@warning{I couldn't find language.dat. No additional\\%
+ patterns loaded. Reported}%
+ \else
+ \loop
+ \endlinechar\m@ne
+ \read1 to \bbl@line
+ \endlinechar`\^^M
+ \if T\ifeof1F\fi T\relax
+ \ifx\bbl@line\@empty\else
+ \edef\bbl@line{\bbl@line\space\space\space}%
+ \expandafter\bbl@process@line\bbl@line\relax
+ \fi
+ \repeat
+ \fi
+\endgroup
+\bbl@trace{Macros for reading patterns files}
+\def\bbl@get@enc#1:#2:#3\@@@{\def\bbl@hyph@enc{#2}}
+\ifx\babelcatcodetablenum\@undefined
+ \def\babelcatcodetablenum{5211}
+\fi
+\def\bbl@luapatterns#1#2{%
+ \bbl@get@enc#1::\@@@
+ \setbox\z@\hbox\bgroup
+ \begingroup
+ \ifx\catcodetable\@undefined
+ \let\savecatcodetable\luatexsavecatcodetable
+ \let\initcatcodetable\luatexinitcatcodetable
+ \let\catcodetable\luatexcatcodetable
+ \fi
+ \savecatcodetable\babelcatcodetablenum\relax
+ \initcatcodetable\numexpr\babelcatcodetablenum+1\relax
+ \catcodetable\numexpr\babelcatcodetablenum+1\relax
+ \catcode`\#=6 \catcode`\$=3 \catcode`\&=4 \catcode`\^=7
+ \catcode`\_=8 \catcode`\{=1 \catcode`\}=2 \catcode`\~=13
+ \catcode`\@=11 \catcode`\^^I=10 \catcode`\^^J=12
+ \catcode`\<=12 \catcode`\>=12 \catcode`\*=12 \catcode`\.=12
+ \catcode`\-=12 \catcode`\/=12 \catcode`\[=12 \catcode`\]=12
+ \catcode`\`=12 \catcode`\'=12 \catcode`\"=12
+ \input #1\relax
+ \catcodetable\babelcatcodetablenum\relax
+ \endgroup
+ \def\bbl@tempa{#2}%
+ \ifx\bbl@tempa\@empty\else
+ \input #2\relax
+ \fi
+ \egroup}%
+\def\bbl@patterns@lua#1{%
+ \language=\expandafter\ifx\csname l@#1:\f@encoding\endcsname\relax
+ \csname l@#1\endcsname
+ \edef\bbl@tempa{#1}%
+ \else
+ \csname l@#1:\f@encoding\endcsname
+ \edef\bbl@tempa{#1:\f@encoding}%
+ \fi\relax
+ \@namedef{lu@texhyphen@loaded@\the\language}{}% Temp
+ \@ifundefined{bbl@hyphendata@\the\language}%
+ {\def\bbl@elt##1##2##3##4{%
+ \ifnum##2=\csname l@\bbl@tempa\endcsname % #2=spanish, dutch:OT1...
+ \def\bbl@tempb{##3}%
+ \ifx\bbl@tempb\@empty\else % if not a synonymous
+ \def\bbl@tempc{{##3}{##4}}%
+ \fi
+ \bbl@csarg\xdef{hyphendata@##2}{\bbl@tempc}%
+ \fi}%
+ \bbl@languages
+ \@ifundefined{bbl@hyphendata@\the\language}%
+ {\bbl@info{No hyphenation patterns were set for\\%
+ language '\bbl@tempa'. Reported}}%
+ {\expandafter\expandafter\expandafter\bbl@luapatterns
+ \csname bbl@hyphendata@\the\language\endcsname}}{}}
+\endinput\fi
+\begingroup
+\catcode`\%=12
+\catcode`\'=12
+\catcode`\"=12
+\catcode`\:=12
+\directlua{
+ Babel = Babel or {}
+ function Babel.bytes(line)
+ return line:gsub("(.)",
+ function (chr) return unicode.utf8.char(string.byte(chr)) end)
+ end
+ function Babel.begin_process_input()
+ if luatexbase and luatexbase.add_to_callback then
+ luatexbase.add_to_callback('process_input_buffer',
+ Babel.bytes,'Babel.bytes')
+ else
+ Babel.callback = callback.find('process_input_buffer')
+ callback.register('process_input_buffer',Babel.bytes)
+ end
+ end
+ function Babel.end_process_input ()
+ if luatexbase and luatexbase.remove_from_callback then
+ luatexbase.remove_from_callback('process_input_buffer','Babel.bytes')
+ else
+ callback.register('process_input_buffer',Babel.callback)
+ end
+ end
+ function Babel.addpatterns(pp, lg)
+ local lg = lang.new(lg)
+ local pats = lang.patterns(lg) or ''
+ lang.clear_patterns(lg)
+ for p in pp:gmatch('[^%s]+') do
+ ss = ''
+ for i in string.utfcharacters(p:gsub('%d', '')) do
+ ss = ss .. '%d?' .. i
+ end
+ ss = ss:gsub('^%%d%?%.', '%%.') .. '%d?'
+ ss = ss:gsub('%.%%d%?$', '%%.')
+ pats, n = pats:gsub('%s' .. ss .. '%s', ' ' .. p .. ' ')
+ if n == 0 then
+ tex.sprint(
+ [[\string\csname\space bbl@info\endcsname{New pattern: ]]
+ .. p .. [[}]])
+ pats = pats .. ' ' .. p
+ else
+ tex.sprint(
+ [[\string\csname\space bbl@info\endcsname{Renew pattern: ]]
+ .. p .. [[}]])
+ end
+ end
+ lang.patterns(lg, pats)
+ end
+}
+\endgroup
+\ifx\newattribute\@undefined\else
+ \newattribute\bbl@attr@locale
+ \AddBabelHook{luatex}{beforeextras}{%
+ \setattribute\bbl@attr@locale\localeid}
+\fi
+\def\BabelStringsDefault{unicode}
+\let\luabbl@stop\relax
+\AddBabelHook{luatex}{encodedcommands}{%
+ \def\bbl@tempa{utf8}\def\bbl@tempb{#1}%
+ \ifx\bbl@tempa\bbl@tempb\else
+ \directlua{Babel.begin_process_input()}%
+ \def\luabbl@stop{%
+ \directlua{Babel.end_process_input()}}%
+ \fi}%
+\AddBabelHook{luatex}{stopcommands}{%
+ \luabbl@stop
+ \let\luabbl@stop\relax}
+\AddBabelHook{luatex}{patterns}{%
+ \@ifundefined{bbl@hyphendata@\the\language}%
+ {\def\bbl@elt##1##2##3##4{%
+ \ifnum##2=\csname l@#2\endcsname % #2=spanish, dutch:OT1...
+ \def\bbl@tempb{##3}%
+ \ifx\bbl@tempb\@empty\else % if not a synonymous
+ \def\bbl@tempc{{##3}{##4}}%
+ \fi
+ \bbl@csarg\xdef{hyphendata@##2}{\bbl@tempc}%
+ \fi}%
+ \bbl@languages
+ \@ifundefined{bbl@hyphendata@\the\language}%
+ {\bbl@info{No hyphenation patterns were set for\\%
+ language '#2'. Reported}}%
+ {\expandafter\expandafter\expandafter\bbl@luapatterns
+ \csname bbl@hyphendata@\the\language\endcsname}}{}%
+ \@ifundefined{bbl@patterns@}{}{%
+ \begingroup
+ \bbl@xin@{,\number\language,}{,\bbl@pttnlist}%
+ \ifin@\else
+ \ifx\bbl@patterns@\@empty\else
+ \directlua{ Babel.addpatterns(
+ [[\bbl@patterns@]], \number\language) }%
+ \fi
+ \@ifundefined{bbl@patterns@#1}%
+ \@empty
+ {\directlua{ Babel.addpatterns(
+ [[\space\csname bbl@patterns@#1\endcsname]],
+ \number\language) }}%
+ \xdef\bbl@pttnlist{\bbl@pttnlist\number\language,}%
+ \fi
+ \endgroup}}
+\AddBabelHook{luatex}{everylanguage}{%
+ \def\process@language##1##2##3{%
+ \def\process@line####1####2 ####3 ####4 {}}}
+\AddBabelHook{luatex}{loadpatterns}{%
+ \input #1\relax
+ \expandafter\gdef\csname bbl@hyphendata@\the\language\endcsname
+ {{#1}{}}}
+\AddBabelHook{luatex}{loadexceptions}{%
+ \input #1\relax
+ \def\bbl@tempb##1##2{{##1}{#1}}%
+ \expandafter\xdef\csname bbl@hyphendata@\the\language\endcsname
+ {\expandafter\expandafter\expandafter\bbl@tempb
+ \csname bbl@hyphendata@\the\language\endcsname}}
+% \end{macrocode}
+%
+% \begin{macro}{\babelpatterns}
+%
+% This macro adds patterns. Two macros are used to store them:
+% |\bbl@patterns@| for the global ones and |\bbl@patterns@<lang>|
+% for language ones. We make sure there is a space between words
+% when multiple commands are used.
+% \changes{bbunicode~1.0e}{2015/07/26}{Macro \cs{babelpatterns} added}
+%
+% \begin{macrocode}
+\@onlypreamble\babelpatterns
+\AtEndOfPackage{%
+ \newcommand\babelpatterns[2][\@empty]{%
+ \ifx\bbl@patterns@\relax
+ \let\bbl@patterns@\@empty
+ \fi
+ \ifx\bbl@pttnlist\@empty\else
+ \bbl@warning{%
+ You must not intermingle \string\selectlanguage\space and\\%
+ \string\babelpatterns\space or some patterns will not\\%
+ be taken into account. Reported}%
+ \fi
+ \ifx\@empty#1%
+ \protected@edef\bbl@patterns@{\bbl@patterns@\space#2}%
+ \else
+ \edef\bbl@tempb{\zap@space#1 \@empty}%
+ \bbl@for\bbl@tempa\bbl@tempb{%
+ \bbl@fixname\bbl@tempa
+ \bbl@iflanguage\bbl@tempa{%
+ \bbl@csarg\protected@edef{patterns@\bbl@tempa}{%
+ \@ifundefined{bbl@patterns@\bbl@tempa}%
+ \@empty
+ {\csname bbl@patterns@\bbl@tempa\endcsname\space}%
+ #2}}}%
+ \fi}}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsection{Southeast Asian scripts}
+%
+% \changes{babel~3.24}{2018/09/24}{Lua code for interword spacing
+% in Southeast Asian scripts.}
+% \changes{babel~3.32}{2019/05/25}{Don't break with CJK if nohyphenation.}
+%
+% \textit{In progress.} Replace regular (ie, implicit) discretionaries
+% by spaceskips, based on the previous glyph (which I think makes
+% sense, because the hyphen and the previous char go always together).
+% Other discretionaries are not touched.
+%
+% For the moment, only 3 SA languages are activated by default (see
+% Unicode UAX 14).
+%
+% \begin{macrocode}
+\def\bbl@intraspace#1 #2 #3\@@{%
+ \directlua{
+ Babel = Babel or {}
+ Babel.intraspaces = Babel.intraspaces or {}
+ Babel.intraspaces['\csname bbl@sbcp@\languagename\endcsname'] = %
+ {b = #1, p = #2, m = #3}
+ Babel.locale_props[\the\localeid].intraspace = %
+ {b = #1, p = #2, m = #3}
+ }}
+\def\bbl@intrapenalty#1\@@{%
+ \directlua{
+ Babel = Babel or {}
+ Babel.intrapenalties = Babel.intrapenalties or {}
+ Babel.intrapenalties['\csname bbl@sbcp@\languagename\endcsname'] = #1
+ Babel.locale_props[\the\localeid].intrapenalty = #1
+ }}
+\begingroup
+\catcode`\%=12
+\catcode`\^=14
+\catcode`\'=12
+\catcode`\~=12
+\gdef\bbl@seaintraspace{^
+ \let\bbl@seaintraspace\relax
+ \directlua{
+ Babel = Babel or {}
+ Babel.sea_enabled = true
+ Babel.sea_ranges = Babel.sea_ranges or {}
+ function Babel.set_chranges (script, chrng)
+ local c = 0
+ for s, e in string.gmatch(chrng..' ', '(.-)%.%.(.-)%s') do
+ Babel.sea_ranges[script..c]={tonumber(s,16), tonumber(e,16)}
+ c = c + 1
+ end
+ end
+ function Babel.sea_disc_to_space (head)
+ local sea_ranges = Babel.sea_ranges
+ local last_char = nil
+ local quad = 655360 ^^ 10 pt = 655360 = 10 * 65536
+ for item in node.traverse(head) do
+ local i = item.id
+ if i == node.id'glyph' then
+ last_char = item
+ elseif i == 7 and item.subtype == 3 and last_char
+ and last_char.char > 0x0C99 then
+ quad = font.getfont(last_char.font).size
+ for lg, rg in pairs(sea_ranges) do
+ if last_char.char > rg[1] and last_char.char < rg[2] then
+ lg = lg:sub(1, 4)
+ local intraspace = Babel.intraspaces[lg]
+ local intrapenalty = Babel.intrapenalties[lg]
+ local n
+ if intrapenalty ~= 0 then
+ n = node.new(14, 0) ^^ penalty
+ n.penalty = intrapenalty
+ node.insert_before(head, item, n)
+ end
+ n = node.new(12, 13) ^^ (glue, spaceskip)
+ node.setglue(n, intraspace.b * quad,
+ intraspace.p * quad,
+ intraspace.m * quad)
+ node.insert_before(head, item, n)
+ node.remove(head, item)
+ end
+ end
+ end
+ end
+ end
+ }^^
+ \bbl@luahyphenate}
+\catcode`\%=14
+\gdef\bbl@cjkintraspace{%
+ \let\bbl@cjkintraspace\relax
+ \directlua{
+ Babel = Babel or {}
+ require'babel-data-cjk.lua'
+ Babel.cjk_enabled = true
+ function Babel.cjk_linebreak(head)
+ local GLYPH = node.id'glyph'
+ local last_char = nil
+ local quad = 655360 % 10 pt = 655360 = 10 * 65536
+ local last_class = nil
+ local last_lang = nil
+
+ for item in node.traverse(head) do
+ if item.id == GLYPH then
+
+ local lang = item.lang
+
+ local LOCALE = node.get_attribute(item,
+ luatexbase.registernumber'bbl@attr@locale')
+ local props = Babel.locale_props[LOCALE]
+
+ class = Babel.cjk_class[item.char].c
+
+ if class == 'cp' then class = 'cl' end % )] as CL
+ if class == 'id' then class = 'I' end
+
+ if class and last_class and Babel.cjk_breaks[last_class][class] then
+ br = Babel.cjk_breaks[last_class][class]
+ else
+ br = 0
+ end
+
+ if br == 1 and props.linebreak == 'c' and
+ lang ~= \the\l@nohyphenation\space and
+ last_lang ~= \the\l@nohyphenation then
+ local intrapenalty = props.intrapenalty
+ if intrapenalty ~= 0 then
+ local n = node.new(14, 0) % penalty
+ n.penalty = intrapenalty
+ node.insert_before(head, item, n)
+ end
+ local intraspace = props.intraspace
+ local n = node.new(12, 13) % (glue, spaceskip)
+ node.setglue(n, intraspace.b * quad,
+ intraspace.p * quad,
+ intraspace.m * quad)
+ node.insert_before(head, item, n)
+ end
+
+ quad = font.getfont(item.font).size
+ last_class = class
+ last_lang = lang
+ else % if penalty, glue or anything else
+ last_class = nil
+ end
+ end
+ lang.hyphenate(head)
+ end
+ }%
+ \bbl@luahyphenate}
+\gdef\bbl@luahyphenate{%
+ \let\bbl@luahyphenate\relax
+ \directlua{
+ luatexbase.add_to_callback('hyphenate',
+ function (head, tail)
+ if Babel.cjk_enabled then
+ Babel.cjk_linebreak(head)
+ end
+ lang.hyphenate(head)
+ if Babel.sea_enabled then
+ Babel.sea_disc_to_space(head)
+ end
+ end,
+ 'Babel.hyphenate')
+ }
+}
+\endgroup
+% \end{macrocode}
+%
+% \subsection{CJK line breaking}
+%
+% Minimal line breaking for CJK scripts, mainly intended for simple
+% documents and short texts as a secundary language. Only line
+% breaking, with a little stretching for justification, without any
+% attempt to adjust the spacing. It is based on (but does not strictly
+% follow) the Unicode algorithm.
+%
+% We first need a little table with the corresponding line breaking
+% properties. A few characters have an additional key for the width
+% (fullwidth \textit{vs.} halfwidth), not yet used. There is a separate
+% file, defined below.
+%
+% \changes{3.31}{2019/05/04}{Simple CJK line breaking.}
+%
+% \textit{Work in progress.}
+%
+% Common stuff.
+%
+% \begin{macrocode}
+\AddBabelHook{luatex}{loadkernel}{%
+<@Restore Unicode catcodes before loading patterns@>}
+\ifx\DisableBabelHook\@undefined\endinput\fi
+\AddBabelHook{babel-fontspec}{afterextras}{\bbl@switchfont}
+\DisableBabelHook{babel-fontspec}
+<@Font selection@>
+% \end{macrocode}
+%
+% \textbf{Temporary} fix for luatex $<$1.10, which sometimes inserted a
+% spurious closing dir node with a |\textdir| within |\hbox|es. This
+% will be eventually removed.
+%
+% \begin{macrocode}
+\def\bbl@luafixboxdir{%
+ \setbox\z@\hbox{\textdir TLT}%
+ \directlua{
+ function Babel.first_dir(head)
+ for item in node.traverse_id(node.id'dir', head) do
+ return item
+ end
+ return nil
+ end
+ if Babel.first_dir(tex.box[0].head) then
+ function Babel.fixboxdirs(head)
+ local fd = Babel.first_dir(head)
+ if fd and fd.dir:sub(1,1) == '-' then
+ head = node.remove(head, fd)
+ end
+ return head
+ end
+ end
+ }}
+\AtBeginDocument{\bbl@luafixboxdir}
+% \end{macrocode}
+%
+% \changes{3.32}{2019/05/23}{New - \cs{babelcharproperty}.}
+%
+% The code for |\babelcharproperty| is straightforward. Just note the
+% modified lua table can be different.
+%
+% \begin{macrocode}
+\newcommand\babelcharproperty[1]{%
+ \count@=#1\relax
+ \ifvmode
+ \expandafter\bbl@chprop
+ \else
+ \bbl@error{\string\babelcharproperty\space can be used only in\\%
+ vertical mode (preamble or between paragraphs)}%
+ {See the manual for futher info}%
+ \fi}
+\newcommand\bbl@chprop[3][\the\count@]{%
+ \@tempcnta=#1\relax
+ \bbl@ifunset{bbl@chprop@#2}%
+ {\bbl@error{No property named '#2'. Allowed values are\\%
+ direction (bc), mirror (bmg), and linebreak (lb)}%
+ {See the manual for futher info}}%
+ {}%
+ \loop
+ \@nameuse{bbl@chprop@#2}{#3}%
+ \ifnum\count@<\@tempcnta
+ \advance\count@\@ne
+ \repeat}
+\def\bbl@chprop@direction#1{%
+ \directlua{
+ Babel.characters[\the\count@] = Babel.characters[\the\count@] or {}
+ Babel.characters[\the\count@]['d'] = '#1'
+ }}
+\let\bbl@chprop@bc\bbl@chprop@direction
+\def\bbl@chprop@mirror#1{%
+ \directlua{
+ Babel.characters[\the\count@] = Babel.characters[\the\count@] or {}
+ Babel.characters[\the\count@]['m'] = '\number#1'
+ }}
+\let\bbl@chprop@bmg\bbl@chprop@mirror
+\def\bbl@chprop@linebreak#1{%
+ \directlua{
+ Babel.Babel.cjk_characters[\the\count@] = Babel.Babel.cjk_characters[\the\count@] or {}
+ Babel.Babel.cjk_characters[\the\count@]['c'] = '#1'
+ }}
+\let\bbl@chprop@lb\bbl@chprop@linebreak
+% \end{macrocode}
+%
+% \subsection{Layout}
+%
+% \textbf{Work in progress}.
+%
+% Unlike \xetex{}, \luatex{} requires only minimal changes for
+% right-to-left layouts, particularly in monolingual documents (the
+% engine itself reverses boxes -- including column order or headings
+% --, margins, etc.) with |bidi=basic|, without having to patch
+% almost any macro where text direction is relevant.
+%
+% |\@hangfrom| is useful in many contexts and it is redefined always
+% with the |layout| option.
+%
+% There are, however, a number of issues when the text direction is not
+% the same as the box direction (as set by |\bodydir|), and when
+% |\parbox| and |\hangindent| are involved. Fortunately, latest
+% releases of \luatex{} simplify a lot the solution with |\shapemode|.
+%
+% With the issue \#15 I realized commands are best patched, instead of
+% redefined. With a few lines, a modification could be applied to
+% several classes and packages. Now, |tabular| seems to work (at least
+% in simple cases) with \textsf{array}, \textsf{tabularx},
+% \textsf{hhline}, \textsf{colortbl}, \textsf{longtable},
+% \textsf{booktabs}, etc. However, \textsf{dcolumn} still fails.
+%
+% \changes{3.18}{2018/02/14}{\cs{bbl@nextfake}, similar to the old
+% \cs{nextfakemath} in Omega}
+% \changes{3.19}{2018/04/23}{Patch \cs{@eqnnum}, somewhat ad hoc. To be
+% improved.}
+% \changes{3.21}{2018/05/09}{The ad hoc \cs{@eqnnum} was buggy. Fixed.}
+% \changes{3.31}{2019/05/04}{\cs{@tabular} and \cs{list} are patched,
+% instead of redefined.}
+%
+% \begin{macrocode}
+\bbl@trace{Redefinitions for bidi layout}
+\ifx\@eqnnum\@undefined\else
+ \ifx\bbl@attr@dir\@undefined\else
+ \edef\@eqnnum{{%
+ \unexpanded{\ifcase\bbl@attr@dir\else\bbl@textdir\@ne\fi}%
+ \unexpanded\expandafter{\@eqnnum}}}
+ \fi
+\fi
+\ifx\bbl@opt@layout\@nnil\endinput\fi % if no layout
+\ifx\bbl@beforeforeign\leavevmode % A poor test for bidi=
+ \def\bbl@nextfake#1{% non-local changes, use always inside a group!
+ \bbl@exp{%
+ \mathdir\the\bodydir
+ #1% Once entered in math, set boxes to restore values
+ \<ifmmode>%
+ \everyvbox{%
+ \the\everyvbox
+ \bodydir\the\bodydir
+ \mathdir\the\mathdir
+ \everyhbox{\the\everyhbox}%
+ \everyvbox{\the\everyvbox}}%
+ \everyhbox{%
+ \the\everyhbox
+ \bodydir\the\bodydir
+ \mathdir\the\mathdir
+ \everyhbox{\the\everyhbox}%
+ \everyvbox{\the\everyvbox}}%
+ \<fi>}}%
+ \def\@hangfrom#1{%
+ \setbox\@tempboxa\hbox{{#1}}%
+ \hangindent\wd\@tempboxa
+ \ifnum\bbl@getluadir{page}=\bbl@getluadir{par}\else
+ \shapemode\@ne
+ \fi
+ \noindent\box\@tempboxa}
+\fi
+\IfBabelLayout{tabular}
+ {\bbl@replace\@tabular{$}{\bbl@nextfake$}%
+ \let\bbl@tabular\@tabular
+ \AtBeginDocument{%
+ \ifx\bbl@tabular\@tabular\else
+ \bbl@replace\@tabular{$}{\bbl@nextfake$}%
+ \fi}}
+ {}
+\IfBabelLayout{lists}
+ {\bbl@sreplace\list{\parshape}{\bbl@listparshape}%
+ \def\bbl@listparshape#1#2#3{%
+ \parshape #1 #2 #3 %
+ \ifnum\bbl@getluadir{page}=\bbl@getluadir{par}\else
+ \shapemode\tw@
+ \fi}}
+ {}
+\IfBabelLayout{graphics}
+ {\let\bbl@pictresetdir\relax
+ \def\bbl@pictsetdir{%
+ \ifcase\bbl@thetextdir
+ \let\bbl@pictresetdir\relax
+ \else
+ \textdir TLT\relax
+ \def\bbl@pictresetdir{\textdir TRT\relax}%
+ \fi}%
+ \bbl@sreplace\@picture{\hskip-}{\bbl@pictsetdir\hskip-}%
+ \def\put(#1,#2)#3{% Not easy to patch. Better redefine.
+ \@killglue
+ \raise#2\unitlength
+ \hb@xt@\z@{\kern#1\unitlength{\bbl@pictresetdir#3}\hss}}%
+ \AtBeginDocument
+ {\ifx\tikz@atbegin@node\@undefined\else
+ \bbl@sreplace\pgfpicture{\pgfpicturetrue}{\bbl@pictsetdir\pgfpicturetrue}%
+ \bbl@add\pgfsys@beginpicture{\bbl@pictsetdir}%
+ \bbl@add\tikz@atbegin@node{\bbl@pictresetdir}%
+ \fi}}
+ {}
+% \end{macrocode}
+%
+% Implicitly reverses sectioning labels in bidi=basic-r, because
+% the full stop is not in contact with L numbers any more. I
+% think there must be a better way. Assumes |bidi=basic|, but
+% there are some additional readjustments for |bidi=default|.
+%
+% \begin{macrocode}
+\IfBabelLayout{counters}%
+ {\bbl@sreplace\@textsuperscript{\m@th}{\m@th\mathdir\pagedir}%
+ \let\bbl@latinarabic=\@arabic
+ \def\@arabic#1{\babelsublr{\bbl@latinarabic#1}}%
+ \@ifpackagewith{babel}{bidi=default}%
+ {\let\bbl@asciiroman=\@roman
+ \def\@roman#1{\babelsublr{\ensureascii{\bbl@asciiroman#1}}}%
+ \let\bbl@asciiRoman=\@Roman
+ \def\@Roman#1{\babelsublr{\ensureascii{\bbl@asciiRoman#1}}}%
+ \def\labelenumii{)\theenumii(}%
+ \def\p@enumiii{\p@enumii)\theenumii(}}{}}{}
+<@Footnote changes@>
+\IfBabelLayout{footnotes}%
+ {\BabelFootnote\footnote\languagename{}{}%
+ \BabelFootnote\localfootnote\languagename{}{}%
+ \BabelFootnote\mainfootnote{}{}{}}
+ {}
+% \end{macrocode}
+%
+% Some \LaTeX{} macros use internally the math mode for text
+% formatting. They have very little in common and are grouped here, as
+% a single option.
+%
+% \changes{3.19}{2018/04/23}{New option extras for layout}
+%
+% \begin{macrocode}
+\IfBabelLayout{extras}%
+ {\bbl@sreplace\underline{$\@@underline}{\bbl@nextfake$\@@underline}%
+ \DeclareRobustCommand{\LaTeXe}{\mbox{\m@th
+ \if b\expandafter\@car\f@series\@nil\boldmath\fi
+ \babelsublr{%
+ \LaTeX\kern.15em2\bbl@nextfake$_{\textstyle\varepsilon}$}}}}
+ {}
+%</luatex>
+% \end{macrocode}
+%
+% \subsection{Auto bidi with \texttt{basic} and \texttt{basic-r}}
+%
+% \changes{3.14}{2017/09/30}{LuaTeX - support for R/AL texts - basic-r}
+%
+% The file \textsf{babel-data-bidi.lua} currently only contains data. It is
+% a large and boring file and it's not shown here. See the generated
+% file.
+%\iffalse
+% \begin{macrocode}
+%<*bididata>
+-- Data from Unicode and ConTeXt
+
+Babel = Babel or {}
+
+Babel.ranges={
+ {0x0590, 0x05FF, 'r'},
+ {0x0600, 0x07BF, 'al'},
+ {0x07C0, 0x085F, 'r'},
+ {0x0860, 0x086F, 'al'},
+ {0x08A0, 0x08FF, 'al'},
+ {0xFB1D, 0xFB4F, 'r'},
+ {0xFB50, 0xFDFF, 'al'},
+ {0xFE70, 0xFEFF, 'al'},
+ {0x10800, 0x10C4F, 'r'},
+ {0x1E800, 0x1E8DF, 'r'},
+ {0x1E900, 0x1E95F, 'r'},
+ {0x1F300, 0x1F9FF, 'on'}
+}
+
+Babel.characters={
+ [0x0]={d='bn'},
+ [0x1]={d='bn'},
+ [0x2]={d='bn'},
+ [0x3]={d='bn'},
+ [0x4]={d='bn'},
+ [0x5]={d='bn'},
+ [0x6]={d='bn'},
+ [0x7]={d='bn'},
+ [0x8]={d='bn'},
+ [0x9]={d='s'},
+ [0xA]={d='b'},
+ [0xB]={d='s'},
+ [0xC]={d='ws'},
+ [0xD]={d='b'},
+ [0xE]={d='bn'},
+ [0xF]={d='bn'},
+ [0x10]={d='bn'},
+ [0x11]={d='bn'},
+ [0x12]={d='bn'},
+ [0x13]={d='bn'},
+ [0x14]={d='bn'},
+ [0x15]={d='bn'},
+ [0x16]={d='bn'},
+ [0x17]={d='bn'},
+ [0x18]={d='bn'},
+ [0x19]={d='bn'},
+ [0x1A]={d='bn'},
+ [0x1B]={d='bn'},
+ [0x1C]={d='b'},
+ [0x1D]={d='b'},
+ [0x1E]={d='b'},
+ [0x1F]={d='s'},
+ [0x20]={d='ws'},
+ [0x21]={d='on'},
+ [0x22]={d='on'},
+ [0x23]={d='et'},
+ [0x24]={d='et'},
+ [0x25]={d='et'},
+ [0x26]={d='on'},
+ [0x27]={d='on'},
+ [0x28]={d='on', m=0x29},
+ [0x29]={d='on', m=0x28},
+ [0x2A]={d='on'},
+ [0x2B]={d='es'},
+ [0x2C]={d='cs'},
+ [0x2D]={d='es'},
+ [0x2E]={d='cs'},
+ [0x2F]={d='cs'},
+ [0x30]={d='en'},
+ [0x31]={d='en'},
+ [0x32]={d='en'},
+ [0x33]={d='en'},
+ [0x34]={d='en'},
+ [0x35]={d='en'},
+ [0x36]={d='en'},
+ [0x37]={d='en'},
+ [0x38]={d='en'},
+ [0x39]={d='en'},
+ [0x3A]={d='cs'},
+ [0x3B]={d='on'},
+ [0x3C]={d='on', m=0x3E},
+ [0x3D]={d='on'},
+ [0x3E]={d='on', m=0x3C},
+ [0x3F]={d='on'},
+ [0x40]={d='on'},
+ [0x5B]={d='on', m=0x5D},
+ [0x5C]={d='on'},
+ [0x5D]={d='on', m=0x5B},
+ [0x5E]={d='on'},
+ [0x5F]={d='on'},
+ [0x60]={d='on'},
+ [0x7B]={d='on', m=0x7D},
+ [0x7C]={d='on'},
+ [0x7D]={d='on', m=0x7B},
+ [0x7E]={d='on'},
+ [0x7F]={d='bn'},
+ [0x80]={d='bn'},
+ [0x81]={d='bn'},
+ [0x82]={d='bn'},
+ [0x83]={d='bn'},
+ [0x84]={d='bn'},
+ [0x85]={d='b'},
+ [0x86]={d='bn'},
+ [0x87]={d='bn'},
+ [0x88]={d='bn'},
+ [0x89]={d='bn'},
+ [0x8A]={d='bn'},
+ [0x8B]={d='bn'},
+ [0x8C]={d='bn'},
+ [0x8D]={d='bn'},
+ [0x8E]={d='bn'},
+ [0x8F]={d='bn'},
+ [0x90]={d='bn'},
+ [0x91]={d='bn'},
+ [0x92]={d='bn'},
+ [0x93]={d='bn'},
+ [0x94]={d='bn'},
+ [0x95]={d='bn'},
+ [0x96]={d='bn'},
+ [0x97]={d='bn'},
+ [0x98]={d='bn'},
+ [0x99]={d='bn'},
+ [0x9A]={d='bn'},
+ [0x9B]={d='bn'},
+ [0x9C]={d='bn'},
+ [0x9D]={d='bn'},
+ [0x9E]={d='bn'},
+ [0x9F]={d='bn'},
+ [0xA0]={d='cs'},
+ [0xA1]={d='on'},
+ [0xA2]={d='et'},
+ [0xA3]={d='et'},
+ [0xA4]={d='et'},
+ [0xA5]={d='et'},
+ [0xA6]={d='on'},
+ [0xA7]={d='on'},
+ [0xA8]={d='on'},
+ [0xA9]={d='on'},
+ [0xAB]={d='on', m=0xBB},
+ [0xAC]={d='on'},
+ [0xAD]={d='bn'},
+ [0xAE]={d='on'},
+ [0xAF]={d='on'},
+ [0xB0]={d='et'},
+ [0xB1]={d='et'},
+ [0xB2]={d='en'},
+ [0xB3]={d='en'},
+ [0xB4]={d='on'},
+ [0xB6]={d='on'},
+ [0xB7]={d='on'},
+ [0xB8]={d='on'},
+ [0xB9]={d='en'},
+ [0xBB]={d='on', m=0xAB},
+ [0xBC]={d='on'},
+ [0xBD]={d='on'},
+ [0xBE]={d='on'},
+ [0xBF]={d='on'},
+ [0xD7]={d='on'},
+ [0xF7]={d='on'},
+ [0x2B9]={d='on'},
+ [0x2BA]={d='on'},
+ [0x2C2]={d='on'},
+ [0x2C3]={d='on'},
+ [0x2C4]={d='on'},
+ [0x2C5]={d='on'},
+ [0x2C6]={d='on'},
+ [0x2C7]={d='on'},
+ [0x2C8]={d='on'},
+ [0x2C9]={d='on'},
+ [0x2CA]={d='on'},
+ [0x2CB]={d='on'},
+ [0x2CC]={d='on'},
+ [0x2CD]={d='on'},
+ [0x2CE]={d='on'},
+ [0x2CF]={d='on'},
+ [0x2D2]={d='on'},
+ [0x2D3]={d='on'},
+ [0x2D4]={d='on'},
+ [0x2D5]={d='on'},
+ [0x2D6]={d='on'},
+ [0x2D7]={d='on'},
+ [0x2D8]={d='on'},
+ [0x2D9]={d='on'},
+ [0x2DA]={d='on'},
+ [0x2DB]={d='on'},
+ [0x2DC]={d='on'},
+ [0x2DD]={d='on'},
+ [0x2DE]={d='on'},
+ [0x2DF]={d='on'},
+ [0x2E5]={d='on'},
+ [0x2E6]={d='on'},
+ [0x2E7]={d='on'},
+ [0x2E8]={d='on'},
+ [0x2E9]={d='on'},
+ [0x2EA]={d='on'},
+ [0x2EB]={d='on'},
+ [0x2EC]={d='on'},
+ [0x2ED]={d='on'},
+ [0x2EF]={d='on'},
+ [0x2F0]={d='on'},
+ [0x2F1]={d='on'},
+ [0x2F2]={d='on'},
+ [0x2F3]={d='on'},
+ [0x2F4]={d='on'},
+ [0x2F5]={d='on'},
+ [0x2F6]={d='on'},
+ [0x2F7]={d='on'},
+ [0x2F8]={d='on'},
+ [0x2F9]={d='on'},
+ [0x2FA]={d='on'},
+ [0x2FB]={d='on'},
+ [0x2FC]={d='on'},
+ [0x2FD]={d='on'},
+ [0x2FE]={d='on'},
+ [0x2FF]={d='on'},
+ [0x300]={d='nsm'},
+ [0x301]={d='nsm'},
+ [0x302]={d='nsm'},
+ [0x303]={d='nsm'},
+ [0x304]={d='nsm'},
+ [0x305]={d='nsm'},
+ [0x306]={d='nsm'},
+ [0x307]={d='nsm'},
+ [0x308]={d='nsm'},
+ [0x309]={d='nsm'},
+ [0x30A]={d='nsm'},
+ [0x30B]={d='nsm'},
+ [0x30C]={d='nsm'},
+ [0x30D]={d='nsm'},
+ [0x30E]={d='nsm'},
+ [0x30F]={d='nsm'},
+ [0x310]={d='nsm'},
+ [0x311]={d='nsm'},
+ [0x312]={d='nsm'},
+ [0x313]={d='nsm'},
+ [0x314]={d='nsm'},
+ [0x315]={d='nsm'},
+ [0x316]={d='nsm'},
+ [0x317]={d='nsm'},
+ [0x318]={d='nsm'},
+ [0x319]={d='nsm'},
+ [0x31A]={d='nsm'},
+ [0x31B]={d='nsm'},
+ [0x31C]={d='nsm'},
+ [0x31D]={d='nsm'},
+ [0x31E]={d='nsm'},
+ [0x31F]={d='nsm'},
+ [0x320]={d='nsm'},
+ [0x321]={d='nsm'},
+ [0x322]={d='nsm'},
+ [0x323]={d='nsm'},
+ [0x324]={d='nsm'},
+ [0x325]={d='nsm'},
+ [0x326]={d='nsm'},
+ [0x327]={d='nsm'},
+ [0x328]={d='nsm'},
+ [0x329]={d='nsm'},
+ [0x32A]={d='nsm'},
+ [0x32B]={d='nsm'},
+ [0x32C]={d='nsm'},
+ [0x32D]={d='nsm'},
+ [0x32E]={d='nsm'},
+ [0x32F]={d='nsm'},
+ [0x330]={d='nsm'},
+ [0x331]={d='nsm'},
+ [0x332]={d='nsm'},
+ [0x333]={d='nsm'},
+ [0x334]={d='nsm'},
+ [0x335]={d='nsm'},
+ [0x336]={d='nsm'},
+ [0x337]={d='nsm'},
+ [0x338]={d='nsm'},
+ [0x339]={d='nsm'},
+ [0x33A]={d='nsm'},
+ [0x33B]={d='nsm'},
+ [0x33C]={d='nsm'},
+ [0x33D]={d='nsm'},
+ [0x33E]={d='nsm'},
+ [0x33F]={d='nsm'},
+ [0x340]={d='nsm'},
+ [0x341]={d='nsm'},
+ [0x342]={d='nsm'},
+ [0x343]={d='nsm'},
+ [0x344]={d='nsm'},
+ [0x345]={d='nsm'},
+ [0x346]={d='nsm'},
+ [0x347]={d='nsm'},
+ [0x348]={d='nsm'},
+ [0x349]={d='nsm'},
+ [0x34A]={d='nsm'},
+ [0x34B]={d='nsm'},
+ [0x34C]={d='nsm'},
+ [0x34D]={d='nsm'},
+ [0x34E]={d='nsm'},
+ [0x34F]={d='nsm'},
+ [0x350]={d='nsm'},
+ [0x351]={d='nsm'},
+ [0x352]={d='nsm'},
+ [0x353]={d='nsm'},
+ [0x354]={d='nsm'},
+ [0x355]={d='nsm'},
+ [0x356]={d='nsm'},
+ [0x357]={d='nsm'},
+ [0x358]={d='nsm'},
+ [0x359]={d='nsm'},
+ [0x35A]={d='nsm'},
+ [0x35B]={d='nsm'},
+ [0x35C]={d='nsm'},
+ [0x35D]={d='nsm'},
+ [0x35E]={d='nsm'},
+ [0x35F]={d='nsm'},
+ [0x360]={d='nsm'},
+ [0x361]={d='nsm'},
+ [0x362]={d='nsm'},
+ [0x363]={d='nsm'},
+ [0x364]={d='nsm'},
+ [0x365]={d='nsm'},
+ [0x366]={d='nsm'},
+ [0x367]={d='nsm'},
+ [0x368]={d='nsm'},
+ [0x369]={d='nsm'},
+ [0x36A]={d='nsm'},
+ [0x36B]={d='nsm'},
+ [0x36C]={d='nsm'},
+ [0x36D]={d='nsm'},
+ [0x36E]={d='nsm'},
+ [0x36F]={d='nsm'},
+ [0x374]={d='on'},
+ [0x375]={d='on'},
+ [0x37E]={d='on'},
+ [0x384]={d='on'},
+ [0x385]={d='on'},
+ [0x387]={d='on'},
+ [0x3F6]={d='on'},
+ [0x483]={d='nsm'},
+ [0x484]={d='nsm'},
+ [0x485]={d='nsm'},
+ [0x486]={d='nsm'},
+ [0x487]={d='nsm'},
+ [0x488]={d='nsm'},
+ [0x489]={d='nsm'},
+ [0x58A]={d='on'},
+ [0x58D]={d='on'},
+ [0x58E]={d='on'},
+ [0x58F]={d='et'},
+ [0x591]={d='nsm'},
+ [0x592]={d='nsm'},
+ [0x593]={d='nsm'},
+ [0x594]={d='nsm'},
+ [0x595]={d='nsm'},
+ [0x596]={d='nsm'},
+ [0x597]={d='nsm'},
+ [0x598]={d='nsm'},
+ [0x599]={d='nsm'},
+ [0x59A]={d='nsm'},
+ [0x59B]={d='nsm'},
+ [0x59C]={d='nsm'},
+ [0x59D]={d='nsm'},
+ [0x59E]={d='nsm'},
+ [0x59F]={d='nsm'},
+ [0x5A0]={d='nsm'},
+ [0x5A1]={d='nsm'},
+ [0x5A2]={d='nsm'},
+ [0x5A3]={d='nsm'},
+ [0x5A4]={d='nsm'},
+ [0x5A5]={d='nsm'},
+ [0x5A6]={d='nsm'},
+ [0x5A7]={d='nsm'},
+ [0x5A8]={d='nsm'},
+ [0x5A9]={d='nsm'},
+ [0x5AA]={d='nsm'},
+ [0x5AB]={d='nsm'},
+ [0x5AC]={d='nsm'},
+ [0x5AD]={d='nsm'},
+ [0x5AE]={d='nsm'},
+ [0x5AF]={d='nsm'},
+ [0x5B0]={d='nsm'},
+ [0x5B1]={d='nsm'},
+ [0x5B2]={d='nsm'},
+ [0x5B3]={d='nsm'},
+ [0x5B4]={d='nsm'},
+ [0x5B5]={d='nsm'},
+ [0x5B6]={d='nsm'},
+ [0x5B7]={d='nsm'},
+ [0x5B8]={d='nsm'},
+ [0x5B9]={d='nsm'},
+ [0x5BA]={d='nsm'},
+ [0x5BB]={d='nsm'},
+ [0x5BC]={d='nsm'},
+ [0x5BD]={d='nsm'},
+ [0x5BF]={d='nsm'},
+ [0x5C1]={d='nsm'},
+ [0x5C2]={d='nsm'},
+ [0x5C4]={d='nsm'},
+ [0x5C5]={d='nsm'},
+ [0x5C7]={d='nsm'},
+ [0x600]={d='an'},
+ [0x601]={d='an'},
+ [0x602]={d='an'},
+ [0x603]={d='an'},
+ [0x604]={d='an'},
+ [0x605]={d='an'},
+ [0x606]={d='on'},
+ [0x607]={d='on'},
+ [0x608]={d='al'},
+ [0x609]={d='et'},
+ [0x60A]={d='et'},
+ [0x60B]={d='al'},
+ [0x60C]={d='cs'},
+ [0x60D]={d='al'},
+ [0x60E]={d='on'},
+ [0x60F]={d='on'},
+ [0x610]={d='nsm'},
+ [0x611]={d='nsm'},
+ [0x612]={d='nsm'},
+ [0x613]={d='nsm'},
+ [0x614]={d='nsm'},
+ [0x615]={d='nsm'},
+ [0x616]={d='nsm'},
+ [0x617]={d='nsm'},
+ [0x618]={d='nsm'},
+ [0x619]={d='nsm'},
+ [0x61A]={d='nsm'},
+ [0x64B]={d='nsm'},
+ [0x64C]={d='nsm'},
+ [0x64D]={d='nsm'},
+ [0x64E]={d='nsm'},
+ [0x64F]={d='nsm'},
+ [0x650]={d='nsm'},
+ [0x651]={d='nsm'},
+ [0x652]={d='nsm'},
+ [0x653]={d='nsm'},
+ [0x654]={d='nsm'},
+ [0x655]={d='nsm'},
+ [0x656]={d='nsm'},
+ [0x657]={d='nsm'},
+ [0x658]={d='nsm'},
+ [0x659]={d='nsm'},
+ [0x65A]={d='nsm'},
+ [0x65B]={d='nsm'},
+ [0x65C]={d='nsm'},
+ [0x65D]={d='nsm'},
+ [0x65E]={d='nsm'},
+ [0x65F]={d='nsm'},
+ [0x660]={d='an'},
+ [0x661]={d='an'},
+ [0x662]={d='an'},
+ [0x663]={d='an'},
+ [0x664]={d='an'},
+ [0x665]={d='an'},
+ [0x666]={d='an'},
+ [0x667]={d='an'},
+ [0x668]={d='an'},
+ [0x669]={d='an'},
+ [0x66A]={d='et'},
+ [0x66B]={d='an'},
+ [0x66C]={d='an'},
+ [0x670]={d='nsm'},
+ [0x6D6]={d='nsm'},
+ [0x6D7]={d='nsm'},
+ [0x6D8]={d='nsm'},
+ [0x6D9]={d='nsm'},
+ [0x6DA]={d='nsm'},
+ [0x6DB]={d='nsm'},
+ [0x6DC]={d='nsm'},
+ [0x6DD]={d='an'},
+ [0x6DE]={d='on'},
+ [0x6DF]={d='nsm'},
+ [0x6E0]={d='nsm'},
+ [0x6E1]={d='nsm'},
+ [0x6E2]={d='nsm'},
+ [0x6E3]={d='nsm'},
+ [0x6E4]={d='nsm'},
+ [0x6E7]={d='nsm'},
+ [0x6E8]={d='nsm'},
+ [0x6E9]={d='on'},
+ [0x6EA]={d='nsm'},
+ [0x6EB]={d='nsm'},
+ [0x6EC]={d='nsm'},
+ [0x6ED]={d='nsm'},
+ [0x6F0]={d='en'},
+ [0x6F1]={d='en'},
+ [0x6F2]={d='en'},
+ [0x6F3]={d='en'},
+ [0x6F4]={d='en'},
+ [0x6F5]={d='en'},
+ [0x6F6]={d='en'},
+ [0x6F7]={d='en'},
+ [0x6F8]={d='en'},
+ [0x6F9]={d='en'},
+ [0x711]={d='nsm'},
+ [0x730]={d='nsm'},
+ [0x731]={d='nsm'},
+ [0x732]={d='nsm'},
+ [0x733]={d='nsm'},
+ [0x734]={d='nsm'},
+ [0x735]={d='nsm'},
+ [0x736]={d='nsm'},
+ [0x737]={d='nsm'},
+ [0x738]={d='nsm'},
+ [0x739]={d='nsm'},
+ [0x73A]={d='nsm'},
+ [0x73B]={d='nsm'},
+ [0x73C]={d='nsm'},
+ [0x73D]={d='nsm'},
+ [0x73E]={d='nsm'},
+ [0x73F]={d='nsm'},
+ [0x740]={d='nsm'},
+ [0x741]={d='nsm'},
+ [0x742]={d='nsm'},
+ [0x743]={d='nsm'},
+ [0x744]={d='nsm'},
+ [0x745]={d='nsm'},
+ [0x746]={d='nsm'},
+ [0x747]={d='nsm'},
+ [0x748]={d='nsm'},
+ [0x749]={d='nsm'},
+ [0x74A]={d='nsm'},
+ [0x7A6]={d='nsm'},
+ [0x7A7]={d='nsm'},
+ [0x7A8]={d='nsm'},
+ [0x7A9]={d='nsm'},
+ [0x7AA]={d='nsm'},
+ [0x7AB]={d='nsm'},
+ [0x7AC]={d='nsm'},
+ [0x7AD]={d='nsm'},
+ [0x7AE]={d='nsm'},
+ [0x7AF]={d='nsm'},
+ [0x7B0]={d='nsm'},
+ [0x7EB]={d='nsm'},
+ [0x7EC]={d='nsm'},
+ [0x7ED]={d='nsm'},
+ [0x7EE]={d='nsm'},
+ [0x7EF]={d='nsm'},
+ [0x7F0]={d='nsm'},
+ [0x7F1]={d='nsm'},
+ [0x7F2]={d='nsm'},
+ [0x7F3]={d='nsm'},
+ [0x7F6]={d='on'},
+ [0x7F7]={d='on'},
+ [0x7F8]={d='on'},
+ [0x7F9]={d='on'},
+ [0x816]={d='nsm'},
+ [0x817]={d='nsm'},
+ [0x818]={d='nsm'},
+ [0x819]={d='nsm'},
+ [0x81B]={d='nsm'},
+ [0x81C]={d='nsm'},
+ [0x81D]={d='nsm'},
+ [0x81E]={d='nsm'},
+ [0x81F]={d='nsm'},
+ [0x820]={d='nsm'},
+ [0x821]={d='nsm'},
+ [0x822]={d='nsm'},
+ [0x823]={d='nsm'},
+ [0x825]={d='nsm'},
+ [0x826]={d='nsm'},
+ [0x827]={d='nsm'},
+ [0x829]={d='nsm'},
+ [0x82A]={d='nsm'},
+ [0x82B]={d='nsm'},
+ [0x82C]={d='nsm'},
+ [0x82D]={d='nsm'},
+ [0x859]={d='nsm'},
+ [0x85A]={d='nsm'},
+ [0x85B]={d='nsm'},
+ [0x8D4]={d='nsm'},
+ [0x8D5]={d='nsm'},
+ [0x8D6]={d='nsm'},
+ [0x8D7]={d='nsm'},
+ [0x8D8]={d='nsm'},
+ [0x8D9]={d='nsm'},
+ [0x8DA]={d='nsm'},
+ [0x8DB]={d='nsm'},
+ [0x8DC]={d='nsm'},
+ [0x8DD]={d='nsm'},
+ [0x8DE]={d='nsm'},
+ [0x8DF]={d='nsm'},
+ [0x8E0]={d='nsm'},
+ [0x8E1]={d='nsm'},
+ [0x8E2]={d='an'},
+ [0x8E3]={d='nsm'},
+ [0x8E4]={d='nsm'},
+ [0x8E5]={d='nsm'},
+ [0x8E6]={d='nsm'},
+ [0x8E7]={d='nsm'},
+ [0x8E8]={d='nsm'},
+ [0x8E9]={d='nsm'},
+ [0x8EA]={d='nsm'},
+ [0x8EB]={d='nsm'},
+ [0x8EC]={d='nsm'},
+ [0x8ED]={d='nsm'},
+ [0x8EE]={d='nsm'},
+ [0x8EF]={d='nsm'},
+ [0x8F0]={d='nsm'},
+ [0x8F1]={d='nsm'},
+ [0x8F2]={d='nsm'},
+ [0x8F3]={d='nsm'},
+ [0x8F4]={d='nsm'},
+ [0x8F5]={d='nsm'},
+ [0x8F6]={d='nsm'},
+ [0x8F7]={d='nsm'},
+ [0x8F8]={d='nsm'},
+ [0x8F9]={d='nsm'},
+ [0x8FA]={d='nsm'},
+ [0x8FB]={d='nsm'},
+ [0x8FC]={d='nsm'},
+ [0x8FD]={d='nsm'},
+ [0x8FE]={d='nsm'},
+ [0x8FF]={d='nsm'},
+ [0x900]={d='nsm'},
+ [0x901]={d='nsm'},
+ [0x902]={d='nsm'},
+ [0x93A]={d='nsm'},
+ [0x93C]={d='nsm'},
+ [0x941]={d='nsm'},
+ [0x942]={d='nsm'},
+ [0x943]={d='nsm'},
+ [0x944]={d='nsm'},
+ [0x945]={d='nsm'},
+ [0x946]={d='nsm'},
+ [0x947]={d='nsm'},
+ [0x948]={d='nsm'},
+ [0x94D]={d='nsm'},
+ [0x951]={d='nsm'},
+ [0x952]={d='nsm'},
+ [0x953]={d='nsm'},
+ [0x954]={d='nsm'},
+ [0x955]={d='nsm'},
+ [0x956]={d='nsm'},
+ [0x957]={d='nsm'},
+ [0x962]={d='nsm'},
+ [0x963]={d='nsm'},
+ [0x981]={d='nsm'},
+ [0x9BC]={d='nsm'},
+ [0x9C1]={d='nsm'},
+ [0x9C2]={d='nsm'},
+ [0x9C3]={d='nsm'},
+ [0x9C4]={d='nsm'},
+ [0x9CD]={d='nsm'},
+ [0x9E2]={d='nsm'},
+ [0x9E3]={d='nsm'},
+ [0x9F2]={d='et'},
+ [0x9F3]={d='et'},
+ [0x9FB]={d='et'},
+ [0xA01]={d='nsm'},
+ [0xA02]={d='nsm'},
+ [0xA3C]={d='nsm'},
+ [0xA41]={d='nsm'},
+ [0xA42]={d='nsm'},
+ [0xA47]={d='nsm'},
+ [0xA48]={d='nsm'},
+ [0xA4B]={d='nsm'},
+ [0xA4C]={d='nsm'},
+ [0xA4D]={d='nsm'},
+ [0xA51]={d='nsm'},
+ [0xA70]={d='nsm'},
+ [0xA71]={d='nsm'},
+ [0xA75]={d='nsm'},
+ [0xA81]={d='nsm'},
+ [0xA82]={d='nsm'},
+ [0xABC]={d='nsm'},
+ [0xAC1]={d='nsm'},
+ [0xAC2]={d='nsm'},
+ [0xAC3]={d='nsm'},
+ [0xAC4]={d='nsm'},
+ [0xAC5]={d='nsm'},
+ [0xAC7]={d='nsm'},
+ [0xAC8]={d='nsm'},
+ [0xACD]={d='nsm'},
+ [0xAE2]={d='nsm'},
+ [0xAE3]={d='nsm'},
+ [0xAF1]={d='et'},
+ [0xB01]={d='nsm'},
+ [0xB3C]={d='nsm'},
+ [0xB3F]={d='nsm'},
+ [0xB41]={d='nsm'},
+ [0xB42]={d='nsm'},
+ [0xB43]={d='nsm'},
+ [0xB44]={d='nsm'},
+ [0xB4D]={d='nsm'},
+ [0xB56]={d='nsm'},
+ [0xB62]={d='nsm'},
+ [0xB63]={d='nsm'},
+ [0xB82]={d='nsm'},
+ [0xBC0]={d='nsm'},
+ [0xBCD]={d='nsm'},
+ [0xBF3]={d='on'},
+ [0xBF4]={d='on'},
+ [0xBF5]={d='on'},
+ [0xBF6]={d='on'},
+ [0xBF7]={d='on'},
+ [0xBF8]={d='on'},
+ [0xBF9]={d='et'},
+ [0xBFA]={d='on'},
+ [0xC00]={d='nsm'},
+ [0xC3E]={d='nsm'},
+ [0xC3F]={d='nsm'},
+ [0xC40]={d='nsm'},
+ [0xC46]={d='nsm'},
+ [0xC47]={d='nsm'},
+ [0xC48]={d='nsm'},
+ [0xC4A]={d='nsm'},
+ [0xC4B]={d='nsm'},
+ [0xC4C]={d='nsm'},
+ [0xC4D]={d='nsm'},
+ [0xC55]={d='nsm'},
+ [0xC56]={d='nsm'},
+ [0xC62]={d='nsm'},
+ [0xC63]={d='nsm'},
+ [0xC78]={d='on'},
+ [0xC79]={d='on'},
+ [0xC7A]={d='on'},
+ [0xC7B]={d='on'},
+ [0xC7C]={d='on'},
+ [0xC7D]={d='on'},
+ [0xC7E]={d='on'},
+ [0xC81]={d='nsm'},
+ [0xCBC]={d='nsm'},
+ [0xCCC]={d='nsm'},
+ [0xCCD]={d='nsm'},
+ [0xCE2]={d='nsm'},
+ [0xCE3]={d='nsm'},
+ [0xD01]={d='nsm'},
+ [0xD41]={d='nsm'},
+ [0xD42]={d='nsm'},
+ [0xD43]={d='nsm'},
+ [0xD44]={d='nsm'},
+ [0xD4D]={d='nsm'},
+ [0xD62]={d='nsm'},
+ [0xD63]={d='nsm'},
+ [0xDCA]={d='nsm'},
+ [0xDD2]={d='nsm'},
+ [0xDD3]={d='nsm'},
+ [0xDD4]={d='nsm'},
+ [0xDD6]={d='nsm'},
+ [0xE31]={d='nsm'},
+ [0xE34]={d='nsm'},
+ [0xE35]={d='nsm'},
+ [0xE36]={d='nsm'},
+ [0xE37]={d='nsm'},
+ [0xE38]={d='nsm'},
+ [0xE39]={d='nsm'},
+ [0xE3A]={d='nsm'},
+ [0xE3F]={d='et'},
+ [0xE47]={d='nsm'},
+ [0xE48]={d='nsm'},
+ [0xE49]={d='nsm'},
+ [0xE4A]={d='nsm'},
+ [0xE4B]={d='nsm'},
+ [0xE4C]={d='nsm'},
+ [0xE4D]={d='nsm'},
+ [0xE4E]={d='nsm'},
+ [0xEB1]={d='nsm'},
+ [0xEB4]={d='nsm'},
+ [0xEB5]={d='nsm'},
+ [0xEB6]={d='nsm'},
+ [0xEB7]={d='nsm'},
+ [0xEB8]={d='nsm'},
+ [0xEB9]={d='nsm'},
+ [0xEBB]={d='nsm'},
+ [0xEBC]={d='nsm'},
+ [0xEC8]={d='nsm'},
+ [0xEC9]={d='nsm'},
+ [0xECA]={d='nsm'},
+ [0xECB]={d='nsm'},
+ [0xECC]={d='nsm'},
+ [0xECD]={d='nsm'},
+ [0xF18]={d='nsm'},
+ [0xF19]={d='nsm'},
+ [0xF35]={d='nsm'},
+ [0xF37]={d='nsm'},
+ [0xF39]={d='nsm'},
+ [0xF3A]={d='on', m=0xF3B},
+ [0xF3B]={d='on', m=0xF3A},
+ [0xF3C]={d='on', m=0xF3D},
+ [0xF3D]={d='on', m=0xF3C},
+ [0xF71]={d='nsm'},
+ [0xF72]={d='nsm'},
+ [0xF73]={d='nsm'},
+ [0xF74]={d='nsm'},
+ [0xF75]={d='nsm'},
+ [0xF76]={d='nsm'},
+ [0xF77]={d='nsm'},
+ [0xF78]={d='nsm'},
+ [0xF79]={d='nsm'},
+ [0xF7A]={d='nsm'},
+ [0xF7B]={d='nsm'},
+ [0xF7C]={d='nsm'},
+ [0xF7D]={d='nsm'},
+ [0xF7E]={d='nsm'},
+ [0xF80]={d='nsm'},
+ [0xF81]={d='nsm'},
+ [0xF82]={d='nsm'},
+ [0xF83]={d='nsm'},
+ [0xF84]={d='nsm'},
+ [0xF86]={d='nsm'},
+ [0xF87]={d='nsm'},
+ [0xF8D]={d='nsm'},
+ [0xF8E]={d='nsm'},
+ [0xF8F]={d='nsm'},
+ [0xF90]={d='nsm'},
+ [0xF91]={d='nsm'},
+ [0xF92]={d='nsm'},
+ [0xF93]={d='nsm'},
+ [0xF94]={d='nsm'},
+ [0xF95]={d='nsm'},
+ [0xF96]={d='nsm'},
+ [0xF97]={d='nsm'},
+ [0xF99]={d='nsm'},
+ [0xF9A]={d='nsm'},
+ [0xF9B]={d='nsm'},
+ [0xF9C]={d='nsm'},
+ [0xF9D]={d='nsm'},
+ [0xF9E]={d='nsm'},
+ [0xF9F]={d='nsm'},
+ [0xFA0]={d='nsm'},
+ [0xFA1]={d='nsm'},
+ [0xFA2]={d='nsm'},
+ [0xFA3]={d='nsm'},
+ [0xFA4]={d='nsm'},
+ [0xFA5]={d='nsm'},
+ [0xFA6]={d='nsm'},
+ [0xFA7]={d='nsm'},
+ [0xFA8]={d='nsm'},
+ [0xFA9]={d='nsm'},
+ [0xFAA]={d='nsm'},
+ [0xFAB]={d='nsm'},
+ [0xFAC]={d='nsm'},
+ [0xFAD]={d='nsm'},
+ [0xFAE]={d='nsm'},
+ [0xFAF]={d='nsm'},
+ [0xFB0]={d='nsm'},
+ [0xFB1]={d='nsm'},
+ [0xFB2]={d='nsm'},
+ [0xFB3]={d='nsm'},
+ [0xFB4]={d='nsm'},
+ [0xFB5]={d='nsm'},
+ [0xFB6]={d='nsm'},
+ [0xFB7]={d='nsm'},
+ [0xFB8]={d='nsm'},
+ [0xFB9]={d='nsm'},
+ [0xFBA]={d='nsm'},
+ [0xFBB]={d='nsm'},
+ [0xFBC]={d='nsm'},
+ [0xFC6]={d='nsm'},
+ [0x102D]={d='nsm'},
+ [0x102E]={d='nsm'},
+ [0x102F]={d='nsm'},
+ [0x1030]={d='nsm'},
+ [0x1032]={d='nsm'},
+ [0x1033]={d='nsm'},
+ [0x1034]={d='nsm'},
+ [0x1035]={d='nsm'},
+ [0x1036]={d='nsm'},
+ [0x1037]={d='nsm'},
+ [0x1039]={d='nsm'},
+ [0x103A]={d='nsm'},
+ [0x103D]={d='nsm'},
+ [0x103E]={d='nsm'},
+ [0x1058]={d='nsm'},
+ [0x1059]={d='nsm'},
+ [0x105E]={d='nsm'},
+ [0x105F]={d='nsm'},
+ [0x1060]={d='nsm'},
+ [0x1071]={d='nsm'},
+ [0x1072]={d='nsm'},
+ [0x1073]={d='nsm'},
+ [0x1074]={d='nsm'},
+ [0x1082]={d='nsm'},
+ [0x1085]={d='nsm'},
+ [0x1086]={d='nsm'},
+ [0x108D]={d='nsm'},
+ [0x109D]={d='nsm'},
+ [0x135D]={d='nsm'},
+ [0x135E]={d='nsm'},
+ [0x135F]={d='nsm'},
+ [0x1390]={d='on'},
+ [0x1391]={d='on'},
+ [0x1392]={d='on'},
+ [0x1393]={d='on'},
+ [0x1394]={d='on'},
+ [0x1395]={d='on'},
+ [0x1396]={d='on'},
+ [0x1397]={d='on'},
+ [0x1398]={d='on'},
+ [0x1399]={d='on'},
+ [0x1400]={d='on'},
+ [0x1680]={d='ws'},
+ [0x169B]={d='on', m=0x169C},
+ [0x169C]={d='on', m=0x169B},
+ [0x1712]={d='nsm'},
+ [0x1713]={d='nsm'},
+ [0x1714]={d='nsm'},
+ [0x1732]={d='nsm'},
+ [0x1733]={d='nsm'},
+ [0x1734]={d='nsm'},
+ [0x1752]={d='nsm'},
+ [0x1753]={d='nsm'},
+ [0x1772]={d='nsm'},
+ [0x1773]={d='nsm'},
+ [0x17B4]={d='nsm'},
+ [0x17B5]={d='nsm'},
+ [0x17B7]={d='nsm'},
+ [0x17B8]={d='nsm'},
+ [0x17B9]={d='nsm'},
+ [0x17BA]={d='nsm'},
+ [0x17BB]={d='nsm'},
+ [0x17BC]={d='nsm'},
+ [0x17BD]={d='nsm'},
+ [0x17C6]={d='nsm'},
+ [0x17C9]={d='nsm'},
+ [0x17CA]={d='nsm'},
+ [0x17CB]={d='nsm'},
+ [0x17CC]={d='nsm'},
+ [0x17CD]={d='nsm'},
+ [0x17CE]={d='nsm'},
+ [0x17CF]={d='nsm'},
+ [0x17D0]={d='nsm'},
+ [0x17D1]={d='nsm'},
+ [0x17D2]={d='nsm'},
+ [0x17D3]={d='nsm'},
+ [0x17DB]={d='et'},
+ [0x17DD]={d='nsm'},
+ [0x17F0]={d='on'},
+ [0x17F1]={d='on'},
+ [0x17F2]={d='on'},
+ [0x17F3]={d='on'},
+ [0x17F4]={d='on'},
+ [0x17F5]={d='on'},
+ [0x17F6]={d='on'},
+ [0x17F7]={d='on'},
+ [0x17F8]={d='on'},
+ [0x17F9]={d='on'},
+ [0x1800]={d='on'},
+ [0x1801]={d='on'},
+ [0x1802]={d='on'},
+ [0x1803]={d='on'},
+ [0x1804]={d='on'},
+ [0x1805]={d='on'},
+ [0x1806]={d='on'},
+ [0x1807]={d='on'},
+ [0x1808]={d='on'},
+ [0x1809]={d='on'},
+ [0x180A]={d='on'},
+ [0x180B]={d='nsm'},
+ [0x180C]={d='nsm'},
+ [0x180D]={d='nsm'},
+ [0x180E]={d='bn'},
+ [0x1885]={d='nsm'},
+ [0x1886]={d='nsm'},
+ [0x18A9]={d='nsm'},
+ [0x1920]={d='nsm'},
+ [0x1921]={d='nsm'},
+ [0x1922]={d='nsm'},
+ [0x1927]={d='nsm'},
+ [0x1928]={d='nsm'},
+ [0x1932]={d='nsm'},
+ [0x1939]={d='nsm'},
+ [0x193A]={d='nsm'},
+ [0x193B]={d='nsm'},
+ [0x1940]={d='on'},
+ [0x1944]={d='on'},
+ [0x1945]={d='on'},
+ [0x19DE]={d='on'},
+ [0x19DF]={d='on'},
+ [0x19E0]={d='on'},
+ [0x19E1]={d='on'},
+ [0x19E2]={d='on'},
+ [0x19E3]={d='on'},
+ [0x19E4]={d='on'},
+ [0x19E5]={d='on'},
+ [0x19E6]={d='on'},
+ [0x19E7]={d='on'},
+ [0x19E8]={d='on'},
+ [0x19E9]={d='on'},
+ [0x19EA]={d='on'},
+ [0x19EB]={d='on'},
+ [0x19EC]={d='on'},
+ [0x19ED]={d='on'},
+ [0x19EE]={d='on'},
+ [0x19EF]={d='on'},
+ [0x19F0]={d='on'},
+ [0x19F1]={d='on'},
+ [0x19F2]={d='on'},
+ [0x19F3]={d='on'},
+ [0x19F4]={d='on'},
+ [0x19F5]={d='on'},
+ [0x19F6]={d='on'},
+ [0x19F7]={d='on'},
+ [0x19F8]={d='on'},
+ [0x19F9]={d='on'},
+ [0x19FA]={d='on'},
+ [0x19FB]={d='on'},
+ [0x19FC]={d='on'},
+ [0x19FD]={d='on'},
+ [0x19FE]={d='on'},
+ [0x19FF]={d='on'},
+ [0x1A17]={d='nsm'},
+ [0x1A18]={d='nsm'},
+ [0x1A1B]={d='nsm'},
+ [0x1A56]={d='nsm'},
+ [0x1A58]={d='nsm'},
+ [0x1A59]={d='nsm'},
+ [0x1A5A]={d='nsm'},
+ [0x1A5B]={d='nsm'},
+ [0x1A5C]={d='nsm'},
+ [0x1A5D]={d='nsm'},
+ [0x1A5E]={d='nsm'},
+ [0x1A60]={d='nsm'},
+ [0x1A62]={d='nsm'},
+ [0x1A65]={d='nsm'},
+ [0x1A66]={d='nsm'},
+ [0x1A67]={d='nsm'},
+ [0x1A68]={d='nsm'},
+ [0x1A69]={d='nsm'},
+ [0x1A6A]={d='nsm'},
+ [0x1A6B]={d='nsm'},
+ [0x1A6C]={d='nsm'},
+ [0x1A73]={d='nsm'},
+ [0x1A74]={d='nsm'},
+ [0x1A75]={d='nsm'},
+ [0x1A76]={d='nsm'},
+ [0x1A77]={d='nsm'},
+ [0x1A78]={d='nsm'},
+ [0x1A79]={d='nsm'},
+ [0x1A7A]={d='nsm'},
+ [0x1A7B]={d='nsm'},
+ [0x1A7C]={d='nsm'},
+ [0x1A7F]={d='nsm'},
+ [0x1AB0]={d='nsm'},
+ [0x1AB1]={d='nsm'},
+ [0x1AB2]={d='nsm'},
+ [0x1AB3]={d='nsm'},
+ [0x1AB4]={d='nsm'},
+ [0x1AB5]={d='nsm'},
+ [0x1AB6]={d='nsm'},
+ [0x1AB7]={d='nsm'},
+ [0x1AB8]={d='nsm'},
+ [0x1AB9]={d='nsm'},
+ [0x1ABA]={d='nsm'},
+ [0x1ABB]={d='nsm'},
+ [0x1ABC]={d='nsm'},
+ [0x1ABD]={d='nsm'},
+ [0x1ABE]={d='nsm'},
+ [0x1B00]={d='nsm'},
+ [0x1B01]={d='nsm'},
+ [0x1B02]={d='nsm'},
+ [0x1B03]={d='nsm'},
+ [0x1B34]={d='nsm'},
+ [0x1B36]={d='nsm'},
+ [0x1B37]={d='nsm'},
+ [0x1B38]={d='nsm'},
+ [0x1B39]={d='nsm'},
+ [0x1B3A]={d='nsm'},
+ [0x1B3C]={d='nsm'},
+ [0x1B42]={d='nsm'},
+ [0x1B6B]={d='nsm'},
+ [0x1B6C]={d='nsm'},
+ [0x1B6D]={d='nsm'},
+ [0x1B6E]={d='nsm'},
+ [0x1B6F]={d='nsm'},
+ [0x1B70]={d='nsm'},
+ [0x1B71]={d='nsm'},
+ [0x1B72]={d='nsm'},
+ [0x1B73]={d='nsm'},
+ [0x1B80]={d='nsm'},
+ [0x1B81]={d='nsm'},
+ [0x1BA2]={d='nsm'},
+ [0x1BA3]={d='nsm'},
+ [0x1BA4]={d='nsm'},
+ [0x1BA5]={d='nsm'},
+ [0x1BA8]={d='nsm'},
+ [0x1BA9]={d='nsm'},
+ [0x1BAB]={d='nsm'},
+ [0x1BAC]={d='nsm'},
+ [0x1BAD]={d='nsm'},
+ [0x1BE6]={d='nsm'},
+ [0x1BE8]={d='nsm'},
+ [0x1BE9]={d='nsm'},
+ [0x1BED]={d='nsm'},
+ [0x1BEF]={d='nsm'},
+ [0x1BF0]={d='nsm'},
+ [0x1BF1]={d='nsm'},
+ [0x1C2C]={d='nsm'},
+ [0x1C2D]={d='nsm'},
+ [0x1C2E]={d='nsm'},
+ [0x1C2F]={d='nsm'},
+ [0x1C30]={d='nsm'},
+ [0x1C31]={d='nsm'},
+ [0x1C32]={d='nsm'},
+ [0x1C33]={d='nsm'},
+ [0x1C36]={d='nsm'},
+ [0x1C37]={d='nsm'},
+ [0x1CD0]={d='nsm'},
+ [0x1CD1]={d='nsm'},
+ [0x1CD2]={d='nsm'},
+ [0x1CD4]={d='nsm'},
+ [0x1CD5]={d='nsm'},
+ [0x1CD6]={d='nsm'},
+ [0x1CD7]={d='nsm'},
+ [0x1CD8]={d='nsm'},
+ [0x1CD9]={d='nsm'},
+ [0x1CDA]={d='nsm'},
+ [0x1CDB]={d='nsm'},
+ [0x1CDC]={d='nsm'},
+ [0x1CDD]={d='nsm'},
+ [0x1CDE]={d='nsm'},
+ [0x1CDF]={d='nsm'},
+ [0x1CE0]={d='nsm'},
+ [0x1CE2]={d='nsm'},
+ [0x1CE3]={d='nsm'},
+ [0x1CE4]={d='nsm'},
+ [0x1CE5]={d='nsm'},
+ [0x1CE6]={d='nsm'},
+ [0x1CE7]={d='nsm'},
+ [0x1CE8]={d='nsm'},
+ [0x1CED]={d='nsm'},
+ [0x1CF4]={d='nsm'},
+ [0x1CF8]={d='nsm'},
+ [0x1CF9]={d='nsm'},
+ [0x1DC0]={d='nsm'},
+ [0x1DC1]={d='nsm'},
+ [0x1DC2]={d='nsm'},
+ [0x1DC3]={d='nsm'},
+ [0x1DC4]={d='nsm'},
+ [0x1DC5]={d='nsm'},
+ [0x1DC6]={d='nsm'},
+ [0x1DC7]={d='nsm'},
+ [0x1DC8]={d='nsm'},
+ [0x1DC9]={d='nsm'},
+ [0x1DCA]={d='nsm'},
+ [0x1DCB]={d='nsm'},
+ [0x1DCC]={d='nsm'},
+ [0x1DCD]={d='nsm'},
+ [0x1DCE]={d='nsm'},
+ [0x1DCF]={d='nsm'},
+ [0x1DD0]={d='nsm'},
+ [0x1DD1]={d='nsm'},
+ [0x1DD2]={d='nsm'},
+ [0x1DD3]={d='nsm'},
+ [0x1DD4]={d='nsm'},
+ [0x1DD5]={d='nsm'},
+ [0x1DD6]={d='nsm'},
+ [0x1DD7]={d='nsm'},
+ [0x1DD8]={d='nsm'},
+ [0x1DD9]={d='nsm'},
+ [0x1DDA]={d='nsm'},
+ [0x1DDB]={d='nsm'},
+ [0x1DDC]={d='nsm'},
+ [0x1DDD]={d='nsm'},
+ [0x1DDE]={d='nsm'},
+ [0x1DDF]={d='nsm'},
+ [0x1DE0]={d='nsm'},
+ [0x1DE1]={d='nsm'},
+ [0x1DE2]={d='nsm'},
+ [0x1DE3]={d='nsm'},
+ [0x1DE4]={d='nsm'},
+ [0x1DE5]={d='nsm'},
+ [0x1DE6]={d='nsm'},
+ [0x1DE7]={d='nsm'},
+ [0x1DE8]={d='nsm'},
+ [0x1DE9]={d='nsm'},
+ [0x1DEA]={d='nsm'},
+ [0x1DEB]={d='nsm'},
+ [0x1DEC]={d='nsm'},
+ [0x1DED]={d='nsm'},
+ [0x1DEE]={d='nsm'},
+ [0x1DEF]={d='nsm'},
+ [0x1DF0]={d='nsm'},
+ [0x1DF1]={d='nsm'},
+ [0x1DF2]={d='nsm'},
+ [0x1DF3]={d='nsm'},
+ [0x1DF4]={d='nsm'},
+ [0x1DF5]={d='nsm'},
+ [0x1DFB]={d='nsm'},
+ [0x1DFC]={d='nsm'},
+ [0x1DFD]={d='nsm'},
+ [0x1DFE]={d='nsm'},
+ [0x1DFF]={d='nsm'},
+ [0x1FBD]={d='on'},
+ [0x1FBF]={d='on'},
+ [0x1FC0]={d='on'},
+ [0x1FC1]={d='on'},
+ [0x1FCD]={d='on'},
+ [0x1FCE]={d='on'},
+ [0x1FCF]={d='on'},
+ [0x1FDD]={d='on'},
+ [0x1FDE]={d='on'},
+ [0x1FDF]={d='on'},
+ [0x1FED]={d='on'},
+ [0x1FEE]={d='on'},
+ [0x1FEF]={d='on'},
+ [0x1FFD]={d='on'},
+ [0x1FFE]={d='on'},
+ [0x2000]={d='ws'},
+ [0x2001]={d='ws'},
+ [0x2002]={d='ws'},
+ [0x2003]={d='ws'},
+ [0x2004]={d='ws'},
+ [0x2005]={d='ws'},
+ [0x2006]={d='ws'},
+ [0x2007]={d='ws'},
+ [0x2008]={d='ws'},
+ [0x2009]={d='ws'},
+ [0x200A]={d='ws'},
+ [0x200B]={d='bn'},
+ [0x200C]={d='bn'},
+ [0x200D]={d='bn'},
+ [0x200F]={d='r'},
+ [0x2010]={d='on'},
+ [0x2011]={d='on'},
+ [0x2012]={d='on'},
+ [0x2013]={d='on'},
+ [0x2014]={d='on'},
+ [0x2015]={d='on'},
+ [0x2016]={d='on'},
+ [0x2017]={d='on'},
+ [0x2018]={d='on'},
+ [0x2019]={d='on'},
+ [0x201A]={d='on'},
+ [0x201B]={d='on'},
+ [0x201C]={d='on'},
+ [0x201D]={d='on'},
+ [0x201E]={d='on'},
+ [0x201F]={d='on'},
+ [0x2020]={d='on'},
+ [0x2021]={d='on'},
+ [0x2022]={d='on'},
+ [0x2023]={d='on'},
+ [0x2024]={d='on'},
+ [0x2025]={d='on'},
+ [0x2026]={d='on'},
+ [0x2027]={d='on'},
+ [0x2028]={d='ws'},
+ [0x2029]={d='b'},
+ [0x202A]={d='lre'},
+ [0x202B]={d='rle'},
+ [0x202C]={d='pdf'},
+ [0x202D]={d='lro'},
+ [0x202E]={d='rlo'},
+ [0x202F]={d='cs'},
+ [0x2030]={d='et'},
+ [0x2031]={d='et'},
+ [0x2032]={d='et'},
+ [0x2033]={d='et'},
+ [0x2034]={d='et'},
+ [0x2035]={d='on'},
+ [0x2036]={d='on'},
+ [0x2037]={d='on'},
+ [0x2038]={d='on'},
+ [0x2039]={d='on', m=0x203A},
+ [0x203A]={d='on', m=0x2039},
+ [0x203B]={d='on'},
+ [0x203C]={d='on'},
+ [0x203D]={d='on'},
+ [0x203E]={d='on'},
+ [0x203F]={d='on'},
+ [0x2040]={d='on'},
+ [0x2041]={d='on'},
+ [0x2042]={d='on'},
+ [0x2043]={d='on'},
+ [0x2044]={d='cs'},
+ [0x2045]={d='on', m=0x2046},
+ [0x2046]={d='on', m=0x2045},
+ [0x2047]={d='on'},
+ [0x2048]={d='on'},
+ [0x2049]={d='on'},
+ [0x204A]={d='on'},
+ [0x204B]={d='on'},
+ [0x204C]={d='on'},
+ [0x204D]={d='on'},
+ [0x204E]={d='on'},
+ [0x204F]={d='on'},
+ [0x2050]={d='on'},
+ [0x2051]={d='on'},
+ [0x2052]={d='on'},
+ [0x2053]={d='on'},
+ [0x2054]={d='on'},
+ [0x2055]={d='on'},
+ [0x2056]={d='on'},
+ [0x2057]={d='on'},
+ [0x2058]={d='on'},
+ [0x2059]={d='on'},
+ [0x205A]={d='on'},
+ [0x205B]={d='on'},
+ [0x205C]={d='on'},
+ [0x205D]={d='on'},
+ [0x205E]={d='on'},
+ [0x205F]={d='ws'},
+ [0x2060]={d='bn'},
+ [0x2061]={d='bn'},
+ [0x2062]={d='bn'},
+ [0x2063]={d='bn'},
+ [0x2064]={d='bn'},
+ [0x2066]={d='lri'},
+ [0x2067]={d='rli'},
+ [0x2068]={d='fsi'},
+ [0x2069]={d='pdi'},
+ [0x206A]={d='bn'},
+ [0x206B]={d='bn'},
+ [0x206C]={d='bn'},
+ [0x206D]={d='bn'},
+ [0x206E]={d='bn'},
+ [0x206F]={d='bn'},
+ [0x2070]={d='en'},
+ [0x2074]={d='en'},
+ [0x2075]={d='en'},
+ [0x2076]={d='en'},
+ [0x2077]={d='en'},
+ [0x2078]={d='en'},
+ [0x2079]={d='en'},
+ [0x207A]={d='es'},
+ [0x207B]={d='es'},
+ [0x207C]={d='on'},
+ [0x207D]={d='on', m=0x207E},
+ [0x207E]={d='on', m=0x207D},
+ [0x2080]={d='en'},
+ [0x2081]={d='en'},
+ [0x2082]={d='en'},
+ [0x2083]={d='en'},
+ [0x2084]={d='en'},
+ [0x2085]={d='en'},
+ [0x2086]={d='en'},
+ [0x2087]={d='en'},
+ [0x2088]={d='en'},
+ [0x2089]={d='en'},
+ [0x208A]={d='es'},
+ [0x208B]={d='es'},
+ [0x208C]={d='on'},
+ [0x208D]={d='on', m=0x208E},
+ [0x208E]={d='on', m=0x208D},
+ [0x20A0]={d='et'},
+ [0x20A1]={d='et'},
+ [0x20A2]={d='et'},
+ [0x20A3]={d='et'},
+ [0x20A4]={d='et'},
+ [0x20A5]={d='et'},
+ [0x20A6]={d='et'},
+ [0x20A7]={d='et'},
+ [0x20A8]={d='et'},
+ [0x20A9]={d='et'},
+ [0x20AA]={d='et'},
+ [0x20AB]={d='et'},
+ [0x20AC]={d='et'},
+ [0x20AD]={d='et'},
+ [0x20AE]={d='et'},
+ [0x20AF]={d='et'},
+ [0x20B0]={d='et'},
+ [0x20B1]={d='et'},
+ [0x20B2]={d='et'},
+ [0x20B3]={d='et'},
+ [0x20B4]={d='et'},
+ [0x20B5]={d='et'},
+ [0x20B6]={d='et'},
+ [0x20B7]={d='et'},
+ [0x20B8]={d='et'},
+ [0x20B9]={d='et'},
+ [0x20BA]={d='et'},
+ [0x20BB]={d='et'},
+ [0x20BC]={d='et'},
+ [0x20BD]={d='et'},
+ [0x20BE]={d='et'},
+ [0x20D0]={d='nsm'},
+ [0x20D1]={d='nsm'},
+ [0x20D2]={d='nsm'},
+ [0x20D3]={d='nsm'},
+ [0x20D4]={d='nsm'},
+ [0x20D5]={d='nsm'},
+ [0x20D6]={d='nsm'},
+ [0x20D7]={d='nsm'},
+ [0x20D8]={d='nsm'},
+ [0x20D9]={d='nsm'},
+ [0x20DA]={d='nsm'},
+ [0x20DB]={d='nsm'},
+ [0x20DC]={d='nsm'},
+ [0x20DD]={d='nsm'},
+ [0x20DE]={d='nsm'},
+ [0x20DF]={d='nsm'},
+ [0x20E0]={d='nsm'},
+ [0x20E1]={d='nsm'},
+ [0x20E2]={d='nsm'},
+ [0x20E3]={d='nsm'},
+ [0x20E4]={d='nsm'},
+ [0x20E5]={d='nsm'},
+ [0x20E6]={d='nsm'},
+ [0x20E7]={d='nsm'},
+ [0x20E8]={d='nsm'},
+ [0x20E9]={d='nsm'},
+ [0x20EA]={d='nsm'},
+ [0x20EB]={d='nsm'},
+ [0x20EC]={d='nsm'},
+ [0x20ED]={d='nsm'},
+ [0x20EE]={d='nsm'},
+ [0x20EF]={d='nsm'},
+ [0x20F0]={d='nsm'},
+ [0x2100]={d='on'},
+ [0x2101]={d='on'},
+ [0x2103]={d='on'},
+ [0x2104]={d='on'},
+ [0x2105]={d='on'},
+ [0x2106]={d='on'},
+ [0x2108]={d='on'},
+ [0x2109]={d='on'},
+ [0x2114]={d='on'},
+ [0x2116]={d='on'},
+ [0x2117]={d='on'},
+ [0x2118]={d='on'},
+ [0x211E]={d='on'},
+ [0x211F]={d='on'},
+ [0x2120]={d='on'},
+ [0x2121]={d='on'},
+ [0x2122]={d='on'},
+ [0x2123]={d='on'},
+ [0x2125]={d='on'},
+ [0x2127]={d='on'},
+ [0x2129]={d='on'},
+ [0x212E]={d='et'},
+ [0x213A]={d='on'},
+ [0x213B]={d='on'},
+ [0x2140]={d='on'},
+ [0x2141]={d='on'},
+ [0x2142]={d='on'},
+ [0x2143]={d='on'},
+ [0x2144]={d='on'},
+ [0x214A]={d='on'},
+ [0x214B]={d='on'},
+ [0x214C]={d='on'},
+ [0x214D]={d='on'},
+ [0x2150]={d='on'},
+ [0x2151]={d='on'},
+ [0x2152]={d='on'},
+ [0x2153]={d='on'},
+ [0x2154]={d='on'},
+ [0x2155]={d='on'},
+ [0x2156]={d='on'},
+ [0x2157]={d='on'},
+ [0x2158]={d='on'},
+ [0x2159]={d='on'},
+ [0x215A]={d='on'},
+ [0x215B]={d='on'},
+ [0x215C]={d='on'},
+ [0x215D]={d='on'},
+ [0x215E]={d='on'},
+ [0x215F]={d='on'},
+ [0x2189]={d='on'},
+ [0x218A]={d='on'},
+ [0x218B]={d='on'},
+ [0x2190]={d='on'},
+ [0x2191]={d='on'},
+ [0x2192]={d='on'},
+ [0x2193]={d='on'},
+ [0x2194]={d='on'},
+ [0x2195]={d='on'},
+ [0x2196]={d='on'},
+ [0x2197]={d='on'},
+ [0x2198]={d='on'},
+ [0x2199]={d='on'},
+ [0x219A]={d='on'},
+ [0x219B]={d='on'},
+ [0x219C]={d='on'},
+ [0x219D]={d='on'},
+ [0x219E]={d='on'},
+ [0x219F]={d='on'},
+ [0x21A0]={d='on'},
+ [0x21A1]={d='on'},
+ [0x21A2]={d='on'},
+ [0x21A3]={d='on'},
+ [0x21A4]={d='on'},
+ [0x21A5]={d='on'},
+ [0x21A6]={d='on'},
+ [0x21A7]={d='on'},
+ [0x21A8]={d='on'},
+ [0x21A9]={d='on'},
+ [0x21AA]={d='on'},
+ [0x21AB]={d='on'},
+ [0x21AC]={d='on'},
+ [0x21AD]={d='on'},
+ [0x21AE]={d='on'},
+ [0x21AF]={d='on'},
+ [0x21B0]={d='on'},
+ [0x21B1]={d='on'},
+ [0x21B2]={d='on'},
+ [0x21B3]={d='on'},
+ [0x21B4]={d='on'},
+ [0x21B5]={d='on'},
+ [0x21B6]={d='on'},
+ [0x21B7]={d='on'},
+ [0x21B8]={d='on'},
+ [0x21B9]={d='on'},
+ [0x21BA]={d='on'},
+ [0x21BB]={d='on'},
+ [0x21BC]={d='on'},
+ [0x21BD]={d='on'},
+ [0x21BE]={d='on'},
+ [0x21BF]={d='on'},
+ [0x21C0]={d='on'},
+ [0x21C1]={d='on'},
+ [0x21C2]={d='on'},
+ [0x21C3]={d='on'},
+ [0x21C4]={d='on'},
+ [0x21C5]={d='on'},
+ [0x21C6]={d='on'},
+ [0x21C7]={d='on'},
+ [0x21C8]={d='on'},
+ [0x21C9]={d='on'},
+ [0x21CA]={d='on'},
+ [0x21CB]={d='on'},
+ [0x21CC]={d='on'},
+ [0x21CD]={d='on'},
+ [0x21CE]={d='on'},
+ [0x21CF]={d='on'},
+ [0x21D0]={d='on'},
+ [0x21D1]={d='on'},
+ [0x21D2]={d='on'},
+ [0x21D3]={d='on'},
+ [0x21D4]={d='on'},
+ [0x21D5]={d='on'},
+ [0x21D6]={d='on'},
+ [0x21D7]={d='on'},
+ [0x21D8]={d='on'},
+ [0x21D9]={d='on'},
+ [0x21DA]={d='on'},
+ [0x21DB]={d='on'},
+ [0x21DC]={d='on'},
+ [0x21DD]={d='on'},
+ [0x21DE]={d='on'},
+ [0x21DF]={d='on'},
+ [0x21E0]={d='on'},
+ [0x21E1]={d='on'},
+ [0x21E2]={d='on'},
+ [0x21E3]={d='on'},
+ [0x21E4]={d='on'},
+ [0x21E5]={d='on'},
+ [0x21E6]={d='on'},
+ [0x21E7]={d='on'},
+ [0x21E8]={d='on'},
+ [0x21E9]={d='on'},
+ [0x21EA]={d='on'},
+ [0x21EB]={d='on'},
+ [0x21EC]={d='on'},
+ [0x21ED]={d='on'},
+ [0x21EE]={d='on'},
+ [0x21EF]={d='on'},
+ [0x21F0]={d='on'},
+ [0x21F1]={d='on'},
+ [0x21F2]={d='on'},
+ [0x21F3]={d='on'},
+ [0x21F4]={d='on'},
+ [0x21F5]={d='on'},
+ [0x21F6]={d='on'},
+ [0x21F7]={d='on'},
+ [0x21F8]={d='on'},
+ [0x21F9]={d='on'},
+ [0x21FA]={d='on'},
+ [0x21FB]={d='on'},
+ [0x21FC]={d='on'},
+ [0x21FD]={d='on'},
+ [0x21FE]={d='on'},
+ [0x21FF]={d='on'},
+ [0x2200]={d='on'},
+ [0x2201]={d='on'},
+ [0x2202]={d='on'},
+ [0x2203]={d='on'},
+ [0x2204]={d='on'},
+ [0x2205]={d='on'},
+ [0x2206]={d='on'},
+ [0x2207]={d='on'},
+ [0x2208]={d='on', m=0x220B},
+ [0x2209]={d='on', m=0x220C},
+ [0x220A]={d='on', m=0x220D},
+ [0x220B]={d='on', m=0x2208},
+ [0x220C]={d='on', m=0x2209},
+ [0x220D]={d='on', m=0x220A},
+ [0x220E]={d='on'},
+ [0x220F]={d='on'},
+ [0x2210]={d='on'},
+ [0x2211]={d='on'},
+ [0x2212]={d='es'},
+ [0x2213]={d='et'},
+ [0x2214]={d='on'},
+ [0x2215]={d='on', m=0x29F5},
+ [0x2216]={d='on'},
+ [0x2217]={d='on'},
+ [0x2218]={d='on'},
+ [0x2219]={d='on'},
+ [0x221A]={d='on'},
+ [0x221B]={d='on'},
+ [0x221C]={d='on'},
+ [0x221D]={d='on'},
+ [0x221E]={d='on'},
+ [0x221F]={d='on'},
+ [0x2220]={d='on'},
+ [0x2221]={d='on'},
+ [0x2222]={d='on'},
+ [0x2223]={d='on'},
+ [0x2224]={d='on'},
+ [0x2225]={d='on'},
+ [0x2226]={d='on'},
+ [0x2227]={d='on'},
+ [0x2228]={d='on'},
+ [0x2229]={d='on'},
+ [0x222A]={d='on'},
+ [0x222B]={d='on'},
+ [0x222C]={d='on'},
+ [0x222D]={d='on'},
+ [0x222E]={d='on'},
+ [0x222F]={d='on'},
+ [0x2230]={d='on'},
+ [0x2231]={d='on'},
+ [0x2232]={d='on'},
+ [0x2233]={d='on'},
+ [0x2234]={d='on'},
+ [0x2235]={d='on'},
+ [0x2236]={d='on'},
+ [0x2237]={d='on'},
+ [0x2238]={d='on'},
+ [0x2239]={d='on'},
+ [0x223A]={d='on'},
+ [0x223B]={d='on'},
+ [0x223C]={d='on', m=0x223D},
+ [0x223D]={d='on', m=0x223C},
+ [0x223E]={d='on'},
+ [0x223F]={d='on'},
+ [0x2240]={d='on'},
+ [0x2241]={d='on'},
+ [0x2242]={d='on'},
+ [0x2243]={d='on', m=0x22CD},
+ [0x2244]={d='on'},
+ [0x2245]={d='on'},
+ [0x2246]={d='on'},
+ [0x2247]={d='on'},
+ [0x2248]={d='on'},
+ [0x2249]={d='on'},
+ [0x224A]={d='on'},
+ [0x224B]={d='on'},
+ [0x224C]={d='on'},
+ [0x224D]={d='on'},
+ [0x224E]={d='on'},
+ [0x224F]={d='on'},
+ [0x2250]={d='on'},
+ [0x2251]={d='on'},
+ [0x2252]={d='on', m=0x2253},
+ [0x2253]={d='on', m=0x2252},
+ [0x2254]={d='on', m=0x2255},
+ [0x2255]={d='on', m=0x2254},
+ [0x2256]={d='on'},
+ [0x2257]={d='on'},
+ [0x2258]={d='on'},
+ [0x2259]={d='on'},
+ [0x225A]={d='on'},
+ [0x225B]={d='on'},
+ [0x225C]={d='on'},
+ [0x225D]={d='on'},
+ [0x225E]={d='on'},
+ [0x225F]={d='on'},
+ [0x2260]={d='on'},
+ [0x2261]={d='on'},
+ [0x2262]={d='on'},
+ [0x2263]={d='on'},
+ [0x2264]={d='on', m=0x2265},
+ [0x2265]={d='on', m=0x2264},
+ [0x2266]={d='on', m=0x2267},
+ [0x2267]={d='on', m=0x2266},
+ [0x2268]={d='on', m=0x2269},
+ [0x2269]={d='on', m=0x2268},
+ [0x226A]={d='on', m=0x226B},
+ [0x226B]={d='on', m=0x226A},
+ [0x226C]={d='on'},
+ [0x226D]={d='on'},
+ [0x226E]={d='on', m=0x226F},
+ [0x226F]={d='on', m=0x226E},
+ [0x2270]={d='on', m=0x2271},
+ [0x2271]={d='on', m=0x2270},
+ [0x2272]={d='on', m=0x2273},
+ [0x2273]={d='on', m=0x2272},
+ [0x2274]={d='on', m=0x2275},
+ [0x2275]={d='on', m=0x2274},
+ [0x2276]={d='on', m=0x2277},
+ [0x2277]={d='on', m=0x2276},
+ [0x2278]={d='on', m=0x2279},
+ [0x2279]={d='on', m=0x2278},
+ [0x227A]={d='on', m=0x227B},
+ [0x227B]={d='on', m=0x227A},
+ [0x227C]={d='on', m=0x227D},
+ [0x227D]={d='on', m=0x227C},
+ [0x227E]={d='on', m=0x227F},
+ [0x227F]={d='on', m=0x227E},
+ [0x2280]={d='on', m=0x2281},
+ [0x2281]={d='on', m=0x2280},
+ [0x2282]={d='on', m=0x2283},
+ [0x2283]={d='on', m=0x2282},
+ [0x2284]={d='on', m=0x2285},
+ [0x2285]={d='on', m=0x2284},
+ [0x2286]={d='on', m=0x2287},
+ [0x2287]={d='on', m=0x2286},
+ [0x2288]={d='on', m=0x2289},
+ [0x2289]={d='on', m=0x2288},
+ [0x228A]={d='on', m=0x228B},
+ [0x228B]={d='on', m=0x228A},
+ [0x228C]={d='on'},
+ [0x228D]={d='on'},
+ [0x228E]={d='on'},
+ [0x228F]={d='on', m=0x2290},
+ [0x2290]={d='on', m=0x228F},
+ [0x2291]={d='on', m=0x2292},
+ [0x2292]={d='on', m=0x2291},
+ [0x2293]={d='on'},
+ [0x2294]={d='on'},
+ [0x2295]={d='on'},
+ [0x2296]={d='on'},
+ [0x2297]={d='on'},
+ [0x2298]={d='on', m=0x29B8},
+ [0x2299]={d='on'},
+ [0x229A]={d='on'},
+ [0x229B]={d='on'},
+ [0x229C]={d='on'},
+ [0x229D]={d='on'},
+ [0x229E]={d='on'},
+ [0x229F]={d='on'},
+ [0x22A0]={d='on'},
+ [0x22A1]={d='on'},
+ [0x22A2]={d='on', m=0x22A3},
+ [0x22A3]={d='on', m=0x22A2},
+ [0x22A4]={d='on'},
+ [0x22A5]={d='on'},
+ [0x22A6]={d='on', m=0x2ADE},
+ [0x22A7]={d='on'},
+ [0x22A8]={d='on', m=0x2AE4},
+ [0x22A9]={d='on', m=0x2AE3},
+ [0x22AA]={d='on'},
+ [0x22AB]={d='on', m=0x2AE5},
+ [0x22AC]={d='on'},
+ [0x22AD]={d='on'},
+ [0x22AE]={d='on'},
+ [0x22AF]={d='on'},
+ [0x22B0]={d='on', m=0x22B1},
+ [0x22B1]={d='on', m=0x22B0},
+ [0x22B2]={d='on', m=0x22B3},
+ [0x22B3]={d='on', m=0x22B2},
+ [0x22B4]={d='on', m=0x22B5},
+ [0x22B5]={d='on', m=0x22B4},
+ [0x22B6]={d='on', m=0x22B7},
+ [0x22B7]={d='on', m=0x22B6},
+ [0x22B8]={d='on'},
+ [0x22B9]={d='on'},
+ [0x22BA]={d='on'},
+ [0x22BB]={d='on'},
+ [0x22BC]={d='on'},
+ [0x22BD]={d='on'},
+ [0x22BE]={d='on'},
+ [0x22BF]={d='on'},
+ [0x22C0]={d='on'},
+ [0x22C1]={d='on'},
+ [0x22C2]={d='on'},
+ [0x22C3]={d='on'},
+ [0x22C4]={d='on'},
+ [0x22C5]={d='on'},
+ [0x22C6]={d='on'},
+ [0x22C7]={d='on'},
+ [0x22C8]={d='on'},
+ [0x22C9]={d='on', m=0x22CA},
+ [0x22CA]={d='on', m=0x22C9},
+ [0x22CB]={d='on', m=0x22CC},
+ [0x22CC]={d='on', m=0x22CB},
+ [0x22CD]={d='on', m=0x2243},
+ [0x22CE]={d='on'},
+ [0x22CF]={d='on'},
+ [0x22D0]={d='on', m=0x22D1},
+ [0x22D1]={d='on', m=0x22D0},
+ [0x22D2]={d='on'},
+ [0x22D3]={d='on'},
+ [0x22D4]={d='on'},
+ [0x22D5]={d='on'},
+ [0x22D6]={d='on', m=0x22D7},
+ [0x22D7]={d='on', m=0x22D6},
+ [0x22D8]={d='on', m=0x22D9},
+ [0x22D9]={d='on', m=0x22D8},
+ [0x22DA]={d='on', m=0x22DB},
+ [0x22DB]={d='on', m=0x22DA},
+ [0x22DC]={d='on', m=0x22DD},
+ [0x22DD]={d='on', m=0x22DC},
+ [0x22DE]={d='on', m=0x22DF},
+ [0x22DF]={d='on', m=0x22DE},
+ [0x22E0]={d='on', m=0x22E1},
+ [0x22E1]={d='on', m=0x22E0},
+ [0x22E2]={d='on', m=0x22E3},
+ [0x22E3]={d='on', m=0x22E2},
+ [0x22E4]={d='on', m=0x22E5},
+ [0x22E5]={d='on', m=0x22E4},
+ [0x22E6]={d='on', m=0x22E7},
+ [0x22E7]={d='on', m=0x22E6},
+ [0x22E8]={d='on', m=0x22E9},
+ [0x22E9]={d='on', m=0x22E8},
+ [0x22EA]={d='on', m=0x22EB},
+ [0x22EB]={d='on', m=0x22EA},
+ [0x22EC]={d='on', m=0x22ED},
+ [0x22ED]={d='on', m=0x22EC},
+ [0x22EE]={d='on'},
+ [0x22EF]={d='on'},
+ [0x22F0]={d='on', m=0x22F1},
+ [0x22F1]={d='on', m=0x22F0},
+ [0x22F2]={d='on', m=0x22FA},
+ [0x22F3]={d='on', m=0x22FB},
+ [0x22F4]={d='on', m=0x22FC},
+ [0x22F5]={d='on'},
+ [0x22F6]={d='on', m=0x22FD},
+ [0x22F7]={d='on', m=0x22FE},
+ [0x22F8]={d='on'},
+ [0x22F9]={d='on'},
+ [0x22FA]={d='on', m=0x22F2},
+ [0x22FB]={d='on', m=0x22F3},
+ [0x22FC]={d='on', m=0x22F4},
+ [0x22FD]={d='on', m=0x22F6},
+ [0x22FE]={d='on', m=0x22F7},
+ [0x22FF]={d='on'},
+ [0x2300]={d='on'},
+ [0x2301]={d='on'},
+ [0x2302]={d='on'},
+ [0x2303]={d='on'},
+ [0x2304]={d='on'},
+ [0x2305]={d='on'},
+ [0x2306]={d='on'},
+ [0x2307]={d='on'},
+ [0x2308]={d='on', m=0x2309},
+ [0x2309]={d='on', m=0x2308},
+ [0x230A]={d='on', m=0x230B},
+ [0x230B]={d='on', m=0x230A},
+ [0x230C]={d='on'},
+ [0x230D]={d='on'},
+ [0x230E]={d='on'},
+ [0x230F]={d='on'},
+ [0x2310]={d='on'},
+ [0x2311]={d='on'},
+ [0x2312]={d='on'},
+ [0x2313]={d='on'},
+ [0x2314]={d='on'},
+ [0x2315]={d='on'},
+ [0x2316]={d='on'},
+ [0x2317]={d='on'},
+ [0x2318]={d='on'},
+ [0x2319]={d='on'},
+ [0x231A]={d='on'},
+ [0x231B]={d='on'},
+ [0x231C]={d='on'},
+ [0x231D]={d='on'},
+ [0x231E]={d='on'},
+ [0x231F]={d='on'},
+ [0x2320]={d='on'},
+ [0x2321]={d='on'},
+ [0x2322]={d='on'},
+ [0x2323]={d='on'},
+ [0x2324]={d='on'},
+ [0x2325]={d='on'},
+ [0x2326]={d='on'},
+ [0x2327]={d='on'},
+ [0x2328]={d='on'},
+ [0x2329]={d='on', m=0x232A},
+ [0x232A]={d='on', m=0x2329},
+ [0x232B]={d='on'},
+ [0x232C]={d='on'},
+ [0x232D]={d='on'},
+ [0x232E]={d='on'},
+ [0x232F]={d='on'},
+ [0x2330]={d='on'},
+ [0x2331]={d='on'},
+ [0x2332]={d='on'},
+ [0x2333]={d='on'},
+ [0x2334]={d='on'},
+ [0x2335]={d='on'},
+ [0x237B]={d='on'},
+ [0x237C]={d='on'},
+ [0x237D]={d='on'},
+ [0x237E]={d='on'},
+ [0x237F]={d='on'},
+ [0x2380]={d='on'},
+ [0x2381]={d='on'},
+ [0x2382]={d='on'},
+ [0x2383]={d='on'},
+ [0x2384]={d='on'},
+ [0x2385]={d='on'},
+ [0x2386]={d='on'},
+ [0x2387]={d='on'},
+ [0x2388]={d='on'},
+ [0x2389]={d='on'},
+ [0x238A]={d='on'},
+ [0x238B]={d='on'},
+ [0x238C]={d='on'},
+ [0x238D]={d='on'},
+ [0x238E]={d='on'},
+ [0x238F]={d='on'},
+ [0x2390]={d='on'},
+ [0x2391]={d='on'},
+ [0x2392]={d='on'},
+ [0x2393]={d='on'},
+ [0x2394]={d='on'},
+ [0x2396]={d='on'},
+ [0x2397]={d='on'},
+ [0x2398]={d='on'},
+ [0x2399]={d='on'},
+ [0x239A]={d='on'},
+ [0x239B]={d='on'},
+ [0x239C]={d='on'},
+ [0x239D]={d='on'},
+ [0x239E]={d='on'},
+ [0x239F]={d='on'},
+ [0x23A0]={d='on'},
+ [0x23A1]={d='on'},
+ [0x23A2]={d='on'},
+ [0x23A3]={d='on'},
+ [0x23A4]={d='on'},
+ [0x23A5]={d='on'},
+ [0x23A6]={d='on'},
+ [0x23A7]={d='on'},
+ [0x23A8]={d='on'},
+ [0x23A9]={d='on'},
+ [0x23AA]={d='on'},
+ [0x23AB]={d='on'},
+ [0x23AC]={d='on'},
+ [0x23AD]={d='on'},
+ [0x23AE]={d='on'},
+ [0x23AF]={d='on'},
+ [0x23B0]={d='on'},
+ [0x23B1]={d='on'},
+ [0x23B2]={d='on'},
+ [0x23B3]={d='on'},
+ [0x23B4]={d='on'},
+ [0x23B5]={d='on'},
+ [0x23B6]={d='on'},
+ [0x23B7]={d='on'},
+ [0x23B8]={d='on'},
+ [0x23B9]={d='on'},
+ [0x23BA]={d='on'},
+ [0x23BB]={d='on'},
+ [0x23BC]={d='on'},
+ [0x23BD]={d='on'},
+ [0x23BE]={d='on'},
+ [0x23BF]={d='on'},
+ [0x23C0]={d='on'},
+ [0x23C1]={d='on'},
+ [0x23C2]={d='on'},
+ [0x23C3]={d='on'},
+ [0x23C4]={d='on'},
+ [0x23C5]={d='on'},
+ [0x23C6]={d='on'},
+ [0x23C7]={d='on'},
+ [0x23C8]={d='on'},
+ [0x23C9]={d='on'},
+ [0x23CA]={d='on'},
+ [0x23CB]={d='on'},
+ [0x23CC]={d='on'},
+ [0x23CD]={d='on'},
+ [0x23CE]={d='on'},
+ [0x23CF]={d='on'},
+ [0x23D0]={d='on'},
+ [0x23D1]={d='on'},
+ [0x23D2]={d='on'},
+ [0x23D3]={d='on'},
+ [0x23D4]={d='on'},
+ [0x23D5]={d='on'},
+ [0x23D6]={d='on'},
+ [0x23D7]={d='on'},
+ [0x23D8]={d='on'},
+ [0x23D9]={d='on'},
+ [0x23DA]={d='on'},
+ [0x23DB]={d='on'},
+ [0x23DC]={d='on'},
+ [0x23DD]={d='on'},
+ [0x23DE]={d='on'},
+ [0x23DF]={d='on'},
+ [0x23E0]={d='on'},
+ [0x23E1]={d='on'},
+ [0x23E2]={d='on'},
+ [0x23E3]={d='on'},
+ [0x23E4]={d='on'},
+ [0x23E5]={d='on'},
+ [0x23E6]={d='on'},
+ [0x23E7]={d='on'},
+ [0x23E8]={d='on'},
+ [0x23E9]={d='on'},
+ [0x23EA]={d='on'},
+ [0x23EB]={d='on'},
+ [0x23EC]={d='on'},
+ [0x23ED]={d='on'},
+ [0x23EE]={d='on'},
+ [0x23EF]={d='on'},
+ [0x23F0]={d='on'},
+ [0x23F1]={d='on'},
+ [0x23F2]={d='on'},
+ [0x23F3]={d='on'},
+ [0x23F4]={d='on'},
+ [0x23F5]={d='on'},
+ [0x23F6]={d='on'},
+ [0x23F7]={d='on'},
+ [0x23F8]={d='on'},
+ [0x23F9]={d='on'},
+ [0x23FA]={d='on'},
+ [0x23FB]={d='on'},
+ [0x23FC]={d='on'},
+ [0x23FD]={d='on'},
+ [0x23FE]={d='on'},
+ [0x2400]={d='on'},
+ [0x2401]={d='on'},
+ [0x2402]={d='on'},
+ [0x2403]={d='on'},
+ [0x2404]={d='on'},
+ [0x2405]={d='on'},
+ [0x2406]={d='on'},
+ [0x2407]={d='on'},
+ [0x2408]={d='on'},
+ [0x2409]={d='on'},
+ [0x240A]={d='on'},
+ [0x240B]={d='on'},
+ [0x240C]={d='on'},
+ [0x240D]={d='on'},
+ [0x240E]={d='on'},
+ [0x240F]={d='on'},
+ [0x2410]={d='on'},
+ [0x2411]={d='on'},
+ [0x2412]={d='on'},
+ [0x2413]={d='on'},
+ [0x2414]={d='on'},
+ [0x2415]={d='on'},
+ [0x2416]={d='on'},
+ [0x2417]={d='on'},
+ [0x2418]={d='on'},
+ [0x2419]={d='on'},
+ [0x241A]={d='on'},
+ [0x241B]={d='on'},
+ [0x241C]={d='on'},
+ [0x241D]={d='on'},
+ [0x241E]={d='on'},
+ [0x241F]={d='on'},
+ [0x2420]={d='on'},
+ [0x2421]={d='on'},
+ [0x2422]={d='on'},
+ [0x2423]={d='on'},
+ [0x2424]={d='on'},
+ [0x2425]={d='on'},
+ [0x2426]={d='on'},
+ [0x2440]={d='on'},
+ [0x2441]={d='on'},
+ [0x2442]={d='on'},
+ [0x2443]={d='on'},
+ [0x2444]={d='on'},
+ [0x2445]={d='on'},
+ [0x2446]={d='on'},
+ [0x2447]={d='on'},
+ [0x2448]={d='on'},
+ [0x2449]={d='on'},
+ [0x244A]={d='on'},
+ [0x2460]={d='on'},
+ [0x2461]={d='on'},
+ [0x2462]={d='on'},
+ [0x2463]={d='on'},
+ [0x2464]={d='on'},
+ [0x2465]={d='on'},
+ [0x2466]={d='on'},
+ [0x2467]={d='on'},
+ [0x2468]={d='on'},
+ [0x2469]={d='on'},
+ [0x246A]={d='on'},
+ [0x246B]={d='on'},
+ [0x246C]={d='on'},
+ [0x246D]={d='on'},
+ [0x246E]={d='on'},
+ [0x246F]={d='on'},
+ [0x2470]={d='on'},
+ [0x2471]={d='on'},
+ [0x2472]={d='on'},
+ [0x2473]={d='on'},
+ [0x2474]={d='on'},
+ [0x2475]={d='on'},
+ [0x2476]={d='on'},
+ [0x2477]={d='on'},
+ [0x2478]={d='on'},
+ [0x2479]={d='on'},
+ [0x247A]={d='on'},
+ [0x247B]={d='on'},
+ [0x247C]={d='on'},
+ [0x247D]={d='on'},
+ [0x247E]={d='on'},
+ [0x247F]={d='on'},
+ [0x2480]={d='on'},
+ [0x2481]={d='on'},
+ [0x2482]={d='on'},
+ [0x2483]={d='on'},
+ [0x2484]={d='on'},
+ [0x2485]={d='on'},
+ [0x2486]={d='on'},
+ [0x2487]={d='on'},
+ [0x2488]={d='en'},
+ [0x2489]={d='en'},
+ [0x248A]={d='en'},
+ [0x248B]={d='en'},
+ [0x248C]={d='en'},
+ [0x248D]={d='en'},
+ [0x248E]={d='en'},
+ [0x248F]={d='en'},
+ [0x2490]={d='en'},
+ [0x2491]={d='en'},
+ [0x2492]={d='en'},
+ [0x2493]={d='en'},
+ [0x2494]={d='en'},
+ [0x2495]={d='en'},
+ [0x2496]={d='en'},
+ [0x2497]={d='en'},
+ [0x2498]={d='en'},
+ [0x2499]={d='en'},
+ [0x249A]={d='en'},
+ [0x249B]={d='en'},
+ [0x24EA]={d='on'},
+ [0x24EB]={d='on'},
+ [0x24EC]={d='on'},
+ [0x24ED]={d='on'},
+ [0x24EE]={d='on'},
+ [0x24EF]={d='on'},
+ [0x24F0]={d='on'},
+ [0x24F1]={d='on'},
+ [0x24F2]={d='on'},
+ [0x24F3]={d='on'},
+ [0x24F4]={d='on'},
+ [0x24F5]={d='on'},
+ [0x24F6]={d='on'},
+ [0x24F7]={d='on'},
+ [0x24F8]={d='on'},
+ [0x24F9]={d='on'},
+ [0x24FA]={d='on'},
+ [0x24FB]={d='on'},
+ [0x24FC]={d='on'},
+ [0x24FD]={d='on'},
+ [0x24FE]={d='on'},
+ [0x24FF]={d='on'},
+ [0x2500]={d='on'},
+ [0x2501]={d='on'},
+ [0x2502]={d='on'},
+ [0x2503]={d='on'},
+ [0x2504]={d='on'},
+ [0x2505]={d='on'},
+ [0x2506]={d='on'},
+ [0x2507]={d='on'},
+ [0x2508]={d='on'},
+ [0x2509]={d='on'},
+ [0x250A]={d='on'},
+ [0x250B]={d='on'},
+ [0x250C]={d='on'},
+ [0x250D]={d='on'},
+ [0x250E]={d='on'},
+ [0x250F]={d='on'},
+ [0x2510]={d='on'},
+ [0x2511]={d='on'},
+ [0x2512]={d='on'},
+ [0x2513]={d='on'},
+ [0x2514]={d='on'},
+ [0x2515]={d='on'},
+ [0x2516]={d='on'},
+ [0x2517]={d='on'},
+ [0x2518]={d='on'},
+ [0x2519]={d='on'},
+ [0x251A]={d='on'},
+ [0x251B]={d='on'},
+ [0x251C]={d='on'},
+ [0x251D]={d='on'},
+ [0x251E]={d='on'},
+ [0x251F]={d='on'},
+ [0x2520]={d='on'},
+ [0x2521]={d='on'},
+ [0x2522]={d='on'},
+ [0x2523]={d='on'},
+ [0x2524]={d='on'},
+ [0x2525]={d='on'},
+ [0x2526]={d='on'},
+ [0x2527]={d='on'},
+ [0x2528]={d='on'},
+ [0x2529]={d='on'},
+ [0x252A]={d='on'},
+ [0x252B]={d='on'},
+ [0x252C]={d='on'},
+ [0x252D]={d='on'},
+ [0x252E]={d='on'},
+ [0x252F]={d='on'},
+ [0x2530]={d='on'},
+ [0x2531]={d='on'},
+ [0x2532]={d='on'},
+ [0x2533]={d='on'},
+ [0x2534]={d='on'},
+ [0x2535]={d='on'},
+ [0x2536]={d='on'},
+ [0x2537]={d='on'},
+ [0x2538]={d='on'},
+ [0x2539]={d='on'},
+ [0x253A]={d='on'},
+ [0x253B]={d='on'},
+ [0x253C]={d='on'},
+ [0x253D]={d='on'},
+ [0x253E]={d='on'},
+ [0x253F]={d='on'},
+ [0x2540]={d='on'},
+ [0x2541]={d='on'},
+ [0x2542]={d='on'},
+ [0x2543]={d='on'},
+ [0x2544]={d='on'},
+ [0x2545]={d='on'},
+ [0x2546]={d='on'},
+ [0x2547]={d='on'},
+ [0x2548]={d='on'},
+ [0x2549]={d='on'},
+ [0x254A]={d='on'},
+ [0x254B]={d='on'},
+ [0x254C]={d='on'},
+ [0x254D]={d='on'},
+ [0x254E]={d='on'},
+ [0x254F]={d='on'},
+ [0x2550]={d='on'},
+ [0x2551]={d='on'},
+ [0x2552]={d='on'},
+ [0x2553]={d='on'},
+ [0x2554]={d='on'},
+ [0x2555]={d='on'},
+ [0x2556]={d='on'},
+ [0x2557]={d='on'},
+ [0x2558]={d='on'},
+ [0x2559]={d='on'},
+ [0x255A]={d='on'},
+ [0x255B]={d='on'},
+ [0x255C]={d='on'},
+ [0x255D]={d='on'},
+ [0x255E]={d='on'},
+ [0x255F]={d='on'},
+ [0x2560]={d='on'},
+ [0x2561]={d='on'},
+ [0x2562]={d='on'},
+ [0x2563]={d='on'},
+ [0x2564]={d='on'},
+ [0x2565]={d='on'},
+ [0x2566]={d='on'},
+ [0x2567]={d='on'},
+ [0x2568]={d='on'},
+ [0x2569]={d='on'},
+ [0x256A]={d='on'},
+ [0x256B]={d='on'},
+ [0x256C]={d='on'},
+ [0x256D]={d='on'},
+ [0x256E]={d='on'},
+ [0x256F]={d='on'},
+ [0x2570]={d='on'},
+ [0x2571]={d='on'},
+ [0x2572]={d='on'},
+ [0x2573]={d='on'},
+ [0x2574]={d='on'},
+ [0x2575]={d='on'},
+ [0x2576]={d='on'},
+ [0x2577]={d='on'},
+ [0x2578]={d='on'},
+ [0x2579]={d='on'},
+ [0x257A]={d='on'},
+ [0x257B]={d='on'},
+ [0x257C]={d='on'},
+ [0x257D]={d='on'},
+ [0x257E]={d='on'},
+ [0x257F]={d='on'},
+ [0x2580]={d='on'},
+ [0x2581]={d='on'},
+ [0x2582]={d='on'},
+ [0x2583]={d='on'},
+ [0x2584]={d='on'},
+ [0x2585]={d='on'},
+ [0x2586]={d='on'},
+ [0x2587]={d='on'},
+ [0x2588]={d='on'},
+ [0x2589]={d='on'},
+ [0x258A]={d='on'},
+ [0x258B]={d='on'},
+ [0x258C]={d='on'},
+ [0x258D]={d='on'},
+ [0x258E]={d='on'},
+ [0x258F]={d='on'},
+ [0x2590]={d='on'},
+ [0x2591]={d='on'},
+ [0x2592]={d='on'},
+ [0x2593]={d='on'},
+ [0x2594]={d='on'},
+ [0x2595]={d='on'},
+ [0x2596]={d='on'},
+ [0x2597]={d='on'},
+ [0x2598]={d='on'},
+ [0x2599]={d='on'},
+ [0x259A]={d='on'},
+ [0x259B]={d='on'},
+ [0x259C]={d='on'},
+ [0x259D]={d='on'},
+ [0x259E]={d='on'},
+ [0x259F]={d='on'},
+ [0x25A0]={d='on'},
+ [0x25A1]={d='on'},
+ [0x25A2]={d='on'},
+ [0x25A3]={d='on'},
+ [0x25A4]={d='on'},
+ [0x25A5]={d='on'},
+ [0x25A6]={d='on'},
+ [0x25A7]={d='on'},
+ [0x25A8]={d='on'},
+ [0x25A9]={d='on'},
+ [0x25AA]={d='on'},
+ [0x25AB]={d='on'},
+ [0x25AC]={d='on'},
+ [0x25AD]={d='on'},
+ [0x25AE]={d='on'},
+ [0x25AF]={d='on'},
+ [0x25B0]={d='on'},
+ [0x25B1]={d='on'},
+ [0x25B2]={d='on'},
+ [0x25B3]={d='on'},
+ [0x25B4]={d='on'},
+ [0x25B5]={d='on'},
+ [0x25B6]={d='on'},
+ [0x25B7]={d='on'},
+ [0x25B8]={d='on'},
+ [0x25B9]={d='on'},
+ [0x25BA]={d='on'},
+ [0x25BB]={d='on'},
+ [0x25BC]={d='on'},
+ [0x25BD]={d='on'},
+ [0x25BE]={d='on'},
+ [0x25BF]={d='on'},
+ [0x25C0]={d='on'},
+ [0x25C1]={d='on'},
+ [0x25C2]={d='on'},
+ [0x25C3]={d='on'},
+ [0x25C4]={d='on'},
+ [0x25C5]={d='on'},
+ [0x25C6]={d='on'},
+ [0x25C7]={d='on'},
+ [0x25C8]={d='on'},
+ [0x25C9]={d='on'},
+ [0x25CA]={d='on'},
+ [0x25CB]={d='on'},
+ [0x25CC]={d='on'},
+ [0x25CD]={d='on'},
+ [0x25CE]={d='on'},
+ [0x25CF]={d='on'},
+ [0x25D0]={d='on'},
+ [0x25D1]={d='on'},
+ [0x25D2]={d='on'},
+ [0x25D3]={d='on'},
+ [0x25D4]={d='on'},
+ [0x25D5]={d='on'},
+ [0x25D6]={d='on'},
+ [0x25D7]={d='on'},
+ [0x25D8]={d='on'},
+ [0x25D9]={d='on'},
+ [0x25DA]={d='on'},
+ [0x25DB]={d='on'},
+ [0x25DC]={d='on'},
+ [0x25DD]={d='on'},
+ [0x25DE]={d='on'},
+ [0x25DF]={d='on'},
+ [0x25E0]={d='on'},
+ [0x25E1]={d='on'},
+ [0x25E2]={d='on'},
+ [0x25E3]={d='on'},
+ [0x25E4]={d='on'},
+ [0x25E5]={d='on'},
+ [0x25E6]={d='on'},
+ [0x25E7]={d='on'},
+ [0x25E8]={d='on'},
+ [0x25E9]={d='on'},
+ [0x25EA]={d='on'},
+ [0x25EB]={d='on'},
+ [0x25EC]={d='on'},
+ [0x25ED]={d='on'},
+ [0x25EE]={d='on'},
+ [0x25EF]={d='on'},
+ [0x25F0]={d='on'},
+ [0x25F1]={d='on'},
+ [0x25F2]={d='on'},
+ [0x25F3]={d='on'},
+ [0x25F4]={d='on'},
+ [0x25F5]={d='on'},
+ [0x25F6]={d='on'},
+ [0x25F7]={d='on'},
+ [0x25F8]={d='on'},
+ [0x25F9]={d='on'},
+ [0x25FA]={d='on'},
+ [0x25FB]={d='on'},
+ [0x25FC]={d='on'},
+ [0x25FD]={d='on'},
+ [0x25FE]={d='on'},
+ [0x25FF]={d='on'},
+ [0x2600]={d='on'},
+ [0x2601]={d='on'},
+ [0x2602]={d='on'},
+ [0x2603]={d='on'},
+ [0x2604]={d='on'},
+ [0x2605]={d='on'},
+ [0x2606]={d='on'},
+ [0x2607]={d='on'},
+ [0x2608]={d='on'},
+ [0x2609]={d='on'},
+ [0x260A]={d='on'},
+ [0x260B]={d='on'},
+ [0x260C]={d='on'},
+ [0x260D]={d='on'},
+ [0x260E]={d='on'},
+ [0x260F]={d='on'},
+ [0x2610]={d='on'},
+ [0x2611]={d='on'},
+ [0x2612]={d='on'},
+ [0x2613]={d='on'},
+ [0x2614]={d='on'},
+ [0x2615]={d='on'},
+ [0x2616]={d='on'},
+ [0x2617]={d='on'},
+ [0x2618]={d='on'},
+ [0x2619]={d='on'},
+ [0x261A]={d='on'},
+ [0x261B]={d='on'},
+ [0x261C]={d='on'},
+ [0x261D]={d='on'},
+ [0x261E]={d='on'},
+ [0x261F]={d='on'},
+ [0x2620]={d='on'},
+ [0x2621]={d='on'},
+ [0x2622]={d='on'},
+ [0x2623]={d='on'},
+ [0x2624]={d='on'},
+ [0x2625]={d='on'},
+ [0x2626]={d='on'},
+ [0x2627]={d='on'},
+ [0x2628]={d='on'},
+ [0x2629]={d='on'},
+ [0x262A]={d='on'},
+ [0x262B]={d='on'},
+ [0x262C]={d='on'},
+ [0x262D]={d='on'},
+ [0x262E]={d='on'},
+ [0x262F]={d='on'},
+ [0x2630]={d='on'},
+ [0x2631]={d='on'},
+ [0x2632]={d='on'},
+ [0x2633]={d='on'},
+ [0x2634]={d='on'},
+ [0x2635]={d='on'},
+ [0x2636]={d='on'},
+ [0x2637]={d='on'},
+ [0x2638]={d='on'},
+ [0x2639]={d='on'},
+ [0x263A]={d='on'},
+ [0x263B]={d='on'},
+ [0x263C]={d='on'},
+ [0x263D]={d='on'},
+ [0x263E]={d='on'},
+ [0x263F]={d='on'},
+ [0x2640]={d='on'},
+ [0x2641]={d='on'},
+ [0x2642]={d='on'},
+ [0x2643]={d='on'},
+ [0x2644]={d='on'},
+ [0x2645]={d='on'},
+ [0x2646]={d='on'},
+ [0x2647]={d='on'},
+ [0x2648]={d='on'},
+ [0x2649]={d='on'},
+ [0x264A]={d='on'},
+ [0x264B]={d='on'},
+ [0x264C]={d='on'},
+ [0x264D]={d='on'},
+ [0x264E]={d='on'},
+ [0x264F]={d='on'},
+ [0x2650]={d='on'},
+ [0x2651]={d='on'},
+ [0x2652]={d='on'},
+ [0x2653]={d='on'},
+ [0x2654]={d='on'},
+ [0x2655]={d='on'},
+ [0x2656]={d='on'},
+ [0x2657]={d='on'},
+ [0x2658]={d='on'},
+ [0x2659]={d='on'},
+ [0x265A]={d='on'},
+ [0x265B]={d='on'},
+ [0x265C]={d='on'},
+ [0x265D]={d='on'},
+ [0x265E]={d='on'},
+ [0x265F]={d='on'},
+ [0x2660]={d='on'},
+ [0x2661]={d='on'},
+ [0x2662]={d='on'},
+ [0x2663]={d='on'},
+ [0x2664]={d='on'},
+ [0x2665]={d='on'},
+ [0x2666]={d='on'},
+ [0x2667]={d='on'},
+ [0x2668]={d='on'},
+ [0x2669]={d='on'},
+ [0x266A]={d='on'},
+ [0x266B]={d='on'},
+ [0x266C]={d='on'},
+ [0x266D]={d='on'},
+ [0x266E]={d='on'},
+ [0x266F]={d='on'},
+ [0x2670]={d='on'},
+ [0x2671]={d='on'},
+ [0x2672]={d='on'},
+ [0x2673]={d='on'},
+ [0x2674]={d='on'},
+ [0x2675]={d='on'},
+ [0x2676]={d='on'},
+ [0x2677]={d='on'},
+ [0x2678]={d='on'},
+ [0x2679]={d='on'},
+ [0x267A]={d='on'},
+ [0x267B]={d='on'},
+ [0x267C]={d='on'},
+ [0x267D]={d='on'},
+ [0x267E]={d='on'},
+ [0x267F]={d='on'},
+ [0x2680]={d='on'},
+ [0x2681]={d='on'},
+ [0x2682]={d='on'},
+ [0x2683]={d='on'},
+ [0x2684]={d='on'},
+ [0x2685]={d='on'},
+ [0x2686]={d='on'},
+ [0x2687]={d='on'},
+ [0x2688]={d='on'},
+ [0x2689]={d='on'},
+ [0x268A]={d='on'},
+ [0x268B]={d='on'},
+ [0x268C]={d='on'},
+ [0x268D]={d='on'},
+ [0x268E]={d='on'},
+ [0x268F]={d='on'},
+ [0x2690]={d='on'},
+ [0x2691]={d='on'},
+ [0x2692]={d='on'},
+ [0x2693]={d='on'},
+ [0x2694]={d='on'},
+ [0x2695]={d='on'},
+ [0x2696]={d='on'},
+ [0x2697]={d='on'},
+ [0x2698]={d='on'},
+ [0x2699]={d='on'},
+ [0x269A]={d='on'},
+ [0x269B]={d='on'},
+ [0x269C]={d='on'},
+ [0x269D]={d='on'},
+ [0x269E]={d='on'},
+ [0x269F]={d='on'},
+ [0x26A0]={d='on'},
+ [0x26A1]={d='on'},
+ [0x26A2]={d='on'},
+ [0x26A3]={d='on'},
+ [0x26A4]={d='on'},
+ [0x26A5]={d='on'},
+ [0x26A6]={d='on'},
+ [0x26A7]={d='on'},
+ [0x26A8]={d='on'},
+ [0x26A9]={d='on'},
+ [0x26AA]={d='on'},
+ [0x26AB]={d='on'},
+ [0x26AD]={d='on'},
+ [0x26AE]={d='on'},
+ [0x26AF]={d='on'},
+ [0x26B0]={d='on'},
+ [0x26B1]={d='on'},
+ [0x26B2]={d='on'},
+ [0x26B3]={d='on'},
+ [0x26B4]={d='on'},
+ [0x26B5]={d='on'},
+ [0x26B6]={d='on'},
+ [0x26B7]={d='on'},
+ [0x26B8]={d='on'},
+ [0x26B9]={d='on'},
+ [0x26BA]={d='on'},
+ [0x26BB]={d='on'},
+ [0x26BC]={d='on'},
+ [0x26BD]={d='on'},
+ [0x26BE]={d='on'},
+ [0x26BF]={d='on'},
+ [0x26C0]={d='on'},
+ [0x26C1]={d='on'},
+ [0x26C2]={d='on'},
+ [0x26C3]={d='on'},
+ [0x26C4]={d='on'},
+ [0x26C5]={d='on'},
+ [0x26C6]={d='on'},
+ [0x26C7]={d='on'},
+ [0x26C8]={d='on'},
+ [0x26C9]={d='on'},
+ [0x26CA]={d='on'},
+ [0x26CB]={d='on'},
+ [0x26CC]={d='on'},
+ [0x26CD]={d='on'},
+ [0x26CE]={d='on'},
+ [0x26CF]={d='on'},
+ [0x26D0]={d='on'},
+ [0x26D1]={d='on'},
+ [0x26D2]={d='on'},
+ [0x26D3]={d='on'},
+ [0x26D4]={d='on'},
+ [0x26D5]={d='on'},
+ [0x26D6]={d='on'},
+ [0x26D7]={d='on'},
+ [0x26D8]={d='on'},
+ [0x26D9]={d='on'},
+ [0x26DA]={d='on'},
+ [0x26DB]={d='on'},
+ [0x26DC]={d='on'},
+ [0x26DD]={d='on'},
+ [0x26DE]={d='on'},
+ [0x26DF]={d='on'},
+ [0x26E0]={d='on'},
+ [0x26E1]={d='on'},
+ [0x26E2]={d='on'},
+ [0x26E3]={d='on'},
+ [0x26E4]={d='on'},
+ [0x26E5]={d='on'},
+ [0x26E6]={d='on'},
+ [0x26E7]={d='on'},
+ [0x26E8]={d='on'},
+ [0x26E9]={d='on'},
+ [0x26EA]={d='on'},
+ [0x26EB]={d='on'},
+ [0x26EC]={d='on'},
+ [0x26ED]={d='on'},
+ [0x26EE]={d='on'},
+ [0x26EF]={d='on'},
+ [0x26F0]={d='on'},
+ [0x26F1]={d='on'},
+ [0x26F2]={d='on'},
+ [0x26F3]={d='on'},
+ [0x26F4]={d='on'},
+ [0x26F5]={d='on'},
+ [0x26F6]={d='on'},
+ [0x26F7]={d='on'},
+ [0x26F8]={d='on'},
+ [0x26F9]={d='on'},
+ [0x26FA]={d='on'},
+ [0x26FB]={d='on'},
+ [0x26FC]={d='on'},
+ [0x26FD]={d='on'},
+ [0x26FE]={d='on'},
+ [0x26FF]={d='on'},
+ [0x2700]={d='on'},
+ [0x2701]={d='on'},
+ [0x2702]={d='on'},
+ [0x2703]={d='on'},
+ [0x2704]={d='on'},
+ [0x2705]={d='on'},
+ [0x2706]={d='on'},
+ [0x2707]={d='on'},
+ [0x2708]={d='on'},
+ [0x2709]={d='on'},
+ [0x270A]={d='on'},
+ [0x270B]={d='on'},
+ [0x270C]={d='on'},
+ [0x270D]={d='on'},
+ [0x270E]={d='on'},
+ [0x270F]={d='on'},
+ [0x2710]={d='on'},
+ [0x2711]={d='on'},
+ [0x2712]={d='on'},
+ [0x2713]={d='on'},
+ [0x2714]={d='on'},
+ [0x2715]={d='on'},
+ [0x2716]={d='on'},
+ [0x2717]={d='on'},
+ [0x2718]={d='on'},
+ [0x2719]={d='on'},
+ [0x271A]={d='on'},
+ [0x271B]={d='on'},
+ [0x271C]={d='on'},
+ [0x271D]={d='on'},
+ [0x271E]={d='on'},
+ [0x271F]={d='on'},
+ [0x2720]={d='on'},
+ [0x2721]={d='on'},
+ [0x2722]={d='on'},
+ [0x2723]={d='on'},
+ [0x2724]={d='on'},
+ [0x2725]={d='on'},
+ [0x2726]={d='on'},
+ [0x2727]={d='on'},
+ [0x2728]={d='on'},
+ [0x2729]={d='on'},
+ [0x272A]={d='on'},
+ [0x272B]={d='on'},
+ [0x272C]={d='on'},
+ [0x272D]={d='on'},
+ [0x272E]={d='on'},
+ [0x272F]={d='on'},
+ [0x2730]={d='on'},
+ [0x2731]={d='on'},
+ [0x2732]={d='on'},
+ [0x2733]={d='on'},
+ [0x2734]={d='on'},
+ [0x2735]={d='on'},
+ [0x2736]={d='on'},
+ [0x2737]={d='on'},
+ [0x2738]={d='on'},
+ [0x2739]={d='on'},
+ [0x273A]={d='on'},
+ [0x273B]={d='on'},
+ [0x273C]={d='on'},
+ [0x273D]={d='on'},
+ [0x273E]={d='on'},
+ [0x273F]={d='on'},
+ [0x2740]={d='on'},
+ [0x2741]={d='on'},
+ [0x2742]={d='on'},
+ [0x2743]={d='on'},
+ [0x2744]={d='on'},
+ [0x2745]={d='on'},
+ [0x2746]={d='on'},
+ [0x2747]={d='on'},
+ [0x2748]={d='on'},
+ [0x2749]={d='on'},
+ [0x274A]={d='on'},
+ [0x274B]={d='on'},
+ [0x274C]={d='on'},
+ [0x274D]={d='on'},
+ [0x274E]={d='on'},
+ [0x274F]={d='on'},
+ [0x2750]={d='on'},
+ [0x2751]={d='on'},
+ [0x2752]={d='on'},
+ [0x2753]={d='on'},
+ [0x2754]={d='on'},
+ [0x2755]={d='on'},
+ [0x2756]={d='on'},
+ [0x2757]={d='on'},
+ [0x2758]={d='on'},
+ [0x2759]={d='on'},
+ [0x275A]={d='on'},
+ [0x275B]={d='on'},
+ [0x275C]={d='on'},
+ [0x275D]={d='on'},
+ [0x275E]={d='on'},
+ [0x275F]={d='on'},
+ [0x2760]={d='on'},
+ [0x2761]={d='on'},
+ [0x2762]={d='on'},
+ [0x2763]={d='on'},
+ [0x2764]={d='on'},
+ [0x2765]={d='on'},
+ [0x2766]={d='on'},
+ [0x2767]={d='on'},
+ [0x2768]={d='on', m=0x2769},
+ [0x2769]={d='on', m=0x2768},
+ [0x276A]={d='on', m=0x276B},
+ [0x276B]={d='on', m=0x276A},
+ [0x276C]={d='on', m=0x276D},
+ [0x276D]={d='on', m=0x276C},
+ [0x276E]={d='on', m=0x276F},
+ [0x276F]={d='on', m=0x276E},
+ [0x2770]={d='on', m=0x2771},
+ [0x2771]={d='on', m=0x2770},
+ [0x2772]={d='on', m=0x2773},
+ [0x2773]={d='on', m=0x2772},
+ [0x2774]={d='on', m=0x2775},
+ [0x2775]={d='on', m=0x2774},
+ [0x2776]={d='on'},
+ [0x2777]={d='on'},
+ [0x2778]={d='on'},
+ [0x2779]={d='on'},
+ [0x277A]={d='on'},
+ [0x277B]={d='on'},
+ [0x277C]={d='on'},
+ [0x277D]={d='on'},
+ [0x277E]={d='on'},
+ [0x277F]={d='on'},
+ [0x2780]={d='on'},
+ [0x2781]={d='on'},
+ [0x2782]={d='on'},
+ [0x2783]={d='on'},
+ [0x2784]={d='on'},
+ [0x2785]={d='on'},
+ [0x2786]={d='on'},
+ [0x2787]={d='on'},
+ [0x2788]={d='on'},
+ [0x2789]={d='on'},
+ [0x278A]={d='on'},
+ [0x278B]={d='on'},
+ [0x278C]={d='on'},
+ [0x278D]={d='on'},
+ [0x278E]={d='on'},
+ [0x278F]={d='on'},
+ [0x2790]={d='on'},
+ [0x2791]={d='on'},
+ [0x2792]={d='on'},
+ [0x2793]={d='on'},
+ [0x2794]={d='on'},
+ [0x2795]={d='on'},
+ [0x2796]={d='on'},
+ [0x2797]={d='on'},
+ [0x2798]={d='on'},
+ [0x2799]={d='on'},
+ [0x279A]={d='on'},
+ [0x279B]={d='on'},
+ [0x279C]={d='on'},
+ [0x279D]={d='on'},
+ [0x279E]={d='on'},
+ [0x279F]={d='on'},
+ [0x27A0]={d='on'},
+ [0x27A1]={d='on'},
+ [0x27A2]={d='on'},
+ [0x27A3]={d='on'},
+ [0x27A4]={d='on'},
+ [0x27A5]={d='on'},
+ [0x27A6]={d='on'},
+ [0x27A7]={d='on'},
+ [0x27A8]={d='on'},
+ [0x27A9]={d='on'},
+ [0x27AA]={d='on'},
+ [0x27AB]={d='on'},
+ [0x27AC]={d='on'},
+ [0x27AD]={d='on'},
+ [0x27AE]={d='on'},
+ [0x27AF]={d='on'},
+ [0x27B0]={d='on'},
+ [0x27B1]={d='on'},
+ [0x27B2]={d='on'},
+ [0x27B3]={d='on'},
+ [0x27B4]={d='on'},
+ [0x27B5]={d='on'},
+ [0x27B6]={d='on'},
+ [0x27B7]={d='on'},
+ [0x27B8]={d='on'},
+ [0x27B9]={d='on'},
+ [0x27BA]={d='on'},
+ [0x27BB]={d='on'},
+ [0x27BC]={d='on'},
+ [0x27BD]={d='on'},
+ [0x27BE]={d='on'},
+ [0x27BF]={d='on'},
+ [0x27C0]={d='on'},
+ [0x27C1]={d='on'},
+ [0x27C2]={d='on'},
+ [0x27C3]={d='on', m=0x27C4},
+ [0x27C4]={d='on', m=0x27C3},
+ [0x27C5]={d='on', m=0x27C6},
+ [0x27C6]={d='on', m=0x27C5},
+ [0x27C7]={d='on'},
+ [0x27C8]={d='on', m=0x27C9},
+ [0x27C9]={d='on', m=0x27C8},
+ [0x27CA]={d='on'},
+ [0x27CB]={d='on', m=0x27CD},
+ [0x27CC]={d='on'},
+ [0x27CD]={d='on', m=0x27CB},
+ [0x27CE]={d='on'},
+ [0x27CF]={d='on'},
+ [0x27D0]={d='on'},
+ [0x27D1]={d='on'},
+ [0x27D2]={d='on'},
+ [0x27D3]={d='on'},
+ [0x27D4]={d='on'},
+ [0x27D5]={d='on', m=0x27D6},
+ [0x27D6]={d='on', m=0x27D5},
+ [0x27D7]={d='on'},
+ [0x27D8]={d='on'},
+ [0x27D9]={d='on'},
+ [0x27DA]={d='on'},
+ [0x27DB]={d='on'},
+ [0x27DC]={d='on'},
+ [0x27DD]={d='on', m=0x27DE},
+ [0x27DE]={d='on', m=0x27DD},
+ [0x27DF]={d='on'},
+ [0x27E0]={d='on'},
+ [0x27E1]={d='on'},
+ [0x27E2]={d='on', m=0x27E3},
+ [0x27E3]={d='on', m=0x27E2},
+ [0x27E4]={d='on', m=0x27E5},
+ [0x27E5]={d='on', m=0x27E4},
+ [0x27E6]={d='on', m=0x27E7},
+ [0x27E7]={d='on', m=0x27E6},
+ [0x27E8]={d='on', m=0x27E9},
+ [0x27E9]={d='on', m=0x27E8},
+ [0x27EA]={d='on', m=0x27EB},
+ [0x27EB]={d='on', m=0x27EA},
+ [0x27EC]={d='on', m=0x27ED},
+ [0x27ED]={d='on', m=0x27EC},
+ [0x27EE]={d='on', m=0x27EF},
+ [0x27EF]={d='on', m=0x27EE},
+ [0x27F0]={d='on'},
+ [0x27F1]={d='on'},
+ [0x27F2]={d='on'},
+ [0x27F3]={d='on'},
+ [0x27F4]={d='on'},
+ [0x27F5]={d='on'},
+ [0x27F6]={d='on'},
+ [0x27F7]={d='on'},
+ [0x27F8]={d='on'},
+ [0x27F9]={d='on'},
+ [0x27FA]={d='on'},
+ [0x27FB]={d='on'},
+ [0x27FC]={d='on'},
+ [0x27FD]={d='on'},
+ [0x27FE]={d='on'},
+ [0x27FF]={d='on'},
+ [0x2900]={d='on'},
+ [0x2901]={d='on'},
+ [0x2902]={d='on'},
+ [0x2903]={d='on'},
+ [0x2904]={d='on'},
+ [0x2905]={d='on'},
+ [0x2906]={d='on'},
+ [0x2907]={d='on'},
+ [0x2908]={d='on'},
+ [0x2909]={d='on'},
+ [0x290A]={d='on'},
+ [0x290B]={d='on'},
+ [0x290C]={d='on'},
+ [0x290D]={d='on'},
+ [0x290E]={d='on'},
+ [0x290F]={d='on'},
+ [0x2910]={d='on'},
+ [0x2911]={d='on'},
+ [0x2912]={d='on'},
+ [0x2913]={d='on'},
+ [0x2914]={d='on'},
+ [0x2915]={d='on'},
+ [0x2916]={d='on'},
+ [0x2917]={d='on'},
+ [0x2918]={d='on'},
+ [0x2919]={d='on'},
+ [0x291A]={d='on'},
+ [0x291B]={d='on'},
+ [0x291C]={d='on'},
+ [0x291D]={d='on'},
+ [0x291E]={d='on'},
+ [0x291F]={d='on'},
+ [0x2920]={d='on'},
+ [0x2921]={d='on'},
+ [0x2922]={d='on'},
+ [0x2923]={d='on'},
+ [0x2924]={d='on'},
+ [0x2925]={d='on'},
+ [0x2926]={d='on'},
+ [0x2927]={d='on'},
+ [0x2928]={d='on'},
+ [0x2929]={d='on'},
+ [0x292A]={d='on'},
+ [0x292B]={d='on'},
+ [0x292C]={d='on'},
+ [0x292D]={d='on'},
+ [0x292E]={d='on'},
+ [0x292F]={d='on'},
+ [0x2930]={d='on'},
+ [0x2931]={d='on'},
+ [0x2932]={d='on'},
+ [0x2933]={d='on'},
+ [0x2934]={d='on'},
+ [0x2935]={d='on'},
+ [0x2936]={d='on'},
+ [0x2937]={d='on'},
+ [0x2938]={d='on'},
+ [0x2939]={d='on'},
+ [0x293A]={d='on'},
+ [0x293B]={d='on'},
+ [0x293C]={d='on'},
+ [0x293D]={d='on'},
+ [0x293E]={d='on'},
+ [0x293F]={d='on'},
+ [0x2940]={d='on'},
+ [0x2941]={d='on'},
+ [0x2942]={d='on'},
+ [0x2943]={d='on'},
+ [0x2944]={d='on'},
+ [0x2945]={d='on'},
+ [0x2946]={d='on'},
+ [0x2947]={d='on'},
+ [0x2948]={d='on'},
+ [0x2949]={d='on'},
+ [0x294A]={d='on'},
+ [0x294B]={d='on'},
+ [0x294C]={d='on'},
+ [0x294D]={d='on'},
+ [0x294E]={d='on'},
+ [0x294F]={d='on'},
+ [0x2950]={d='on'},
+ [0x2951]={d='on'},
+ [0x2952]={d='on'},
+ [0x2953]={d='on'},
+ [0x2954]={d='on'},
+ [0x2955]={d='on'},
+ [0x2956]={d='on'},
+ [0x2957]={d='on'},
+ [0x2958]={d='on'},
+ [0x2959]={d='on'},
+ [0x295A]={d='on'},
+ [0x295B]={d='on'},
+ [0x295C]={d='on'},
+ [0x295D]={d='on'},
+ [0x295E]={d='on'},
+ [0x295F]={d='on'},
+ [0x2960]={d='on'},
+ [0x2961]={d='on'},
+ [0x2962]={d='on'},
+ [0x2963]={d='on'},
+ [0x2964]={d='on'},
+ [0x2965]={d='on'},
+ [0x2966]={d='on'},
+ [0x2967]={d='on'},
+ [0x2968]={d='on'},
+ [0x2969]={d='on'},
+ [0x296A]={d='on'},
+ [0x296B]={d='on'},
+ [0x296C]={d='on'},
+ [0x296D]={d='on'},
+ [0x296E]={d='on'},
+ [0x296F]={d='on'},
+ [0x2970]={d='on'},
+ [0x2971]={d='on'},
+ [0x2972]={d='on'},
+ [0x2973]={d='on'},
+ [0x2974]={d='on'},
+ [0x2975]={d='on'},
+ [0x2976]={d='on'},
+ [0x2977]={d='on'},
+ [0x2978]={d='on'},
+ [0x2979]={d='on'},
+ [0x297A]={d='on'},
+ [0x297B]={d='on'},
+ [0x297C]={d='on'},
+ [0x297D]={d='on'},
+ [0x297E]={d='on'},
+ [0x297F]={d='on'},
+ [0x2980]={d='on'},
+ [0x2981]={d='on'},
+ [0x2982]={d='on'},
+ [0x2983]={d='on', m=0x2984},
+ [0x2984]={d='on', m=0x2983},
+ [0x2985]={d='on', m=0x2986},
+ [0x2986]={d='on', m=0x2985},
+ [0x2987]={d='on', m=0x2988},
+ [0x2988]={d='on', m=0x2987},
+ [0x2989]={d='on', m=0x298A},
+ [0x298A]={d='on', m=0x2989},
+ [0x298B]={d='on', m=0x298C},
+ [0x298C]={d='on', m=0x298B},
+ [0x298D]={d='on', m=0x2990},
+ [0x298E]={d='on', m=0x298F},
+ [0x298F]={d='on', m=0x298E},
+ [0x2990]={d='on', m=0x298D},
+ [0x2991]={d='on', m=0x2992},
+ [0x2992]={d='on', m=0x2991},
+ [0x2993]={d='on', m=0x2994},
+ [0x2994]={d='on', m=0x2993},
+ [0x2995]={d='on', m=0x2996},
+ [0x2996]={d='on', m=0x2995},
+ [0x2997]={d='on', m=0x2998},
+ [0x2998]={d='on', m=0x2997},
+ [0x2999]={d='on'},
+ [0x299A]={d='on'},
+ [0x299B]={d='on'},
+ [0x299C]={d='on'},
+ [0x299D]={d='on'},
+ [0x299E]={d='on'},
+ [0x299F]={d='on'},
+ [0x29A0]={d='on'},
+ [0x29A1]={d='on'},
+ [0x29A2]={d='on'},
+ [0x29A3]={d='on'},
+ [0x29A4]={d='on'},
+ [0x29A5]={d='on'},
+ [0x29A6]={d='on'},
+ [0x29A7]={d='on'},
+ [0x29A8]={d='on'},
+ [0x29A9]={d='on'},
+ [0x29AA]={d='on'},
+ [0x29AB]={d='on'},
+ [0x29AC]={d='on'},
+ [0x29AD]={d='on'},
+ [0x29AE]={d='on'},
+ [0x29AF]={d='on'},
+ [0x29B0]={d='on'},
+ [0x29B1]={d='on'},
+ [0x29B2]={d='on'},
+ [0x29B3]={d='on'},
+ [0x29B4]={d='on'},
+ [0x29B5]={d='on'},
+ [0x29B6]={d='on'},
+ [0x29B7]={d='on'},
+ [0x29B8]={d='on', m=0x2298},
+ [0x29B9]={d='on'},
+ [0x29BA]={d='on'},
+ [0x29BB]={d='on'},
+ [0x29BC]={d='on'},
+ [0x29BD]={d='on'},
+ [0x29BE]={d='on'},
+ [0x29BF]={d='on'},
+ [0x29C0]={d='on', m=0x29C1},
+ [0x29C1]={d='on', m=0x29C0},
+ [0x29C2]={d='on'},
+ [0x29C3]={d='on'},
+ [0x29C4]={d='on', m=0x29C5},
+ [0x29C5]={d='on', m=0x29C4},
+ [0x29C6]={d='on'},
+ [0x29C7]={d='on'},
+ [0x29C8]={d='on'},
+ [0x29C9]={d='on'},
+ [0x29CA]={d='on'},
+ [0x29CB]={d='on'},
+ [0x29CC]={d='on'},
+ [0x29CD]={d='on'},
+ [0x29CE]={d='on'},
+ [0x29CF]={d='on', m=0x29D0},
+ [0x29D0]={d='on', m=0x29CF},
+ [0x29D1]={d='on', m=0x29D2},
+ [0x29D2]={d='on', m=0x29D1},
+ [0x29D3]={d='on'},
+ [0x29D4]={d='on', m=0x29D5},
+ [0x29D5]={d='on', m=0x29D4},
+ [0x29D6]={d='on'},
+ [0x29D7]={d='on'},
+ [0x29D8]={d='on', m=0x29D9},
+ [0x29D9]={d='on', m=0x29D8},
+ [0x29DA]={d='on', m=0x29DB},
+ [0x29DB]={d='on', m=0x29DA},
+ [0x29DC]={d='on'},
+ [0x29DD]={d='on'},
+ [0x29DE]={d='on'},
+ [0x29DF]={d='on'},
+ [0x29E0]={d='on'},
+ [0x29E1]={d='on'},
+ [0x29E2]={d='on'},
+ [0x29E3]={d='on'},
+ [0x29E4]={d='on'},
+ [0x29E5]={d='on'},
+ [0x29E6]={d='on'},
+ [0x29E7]={d='on'},
+ [0x29E8]={d='on'},
+ [0x29E9]={d='on'},
+ [0x29EA]={d='on'},
+ [0x29EB]={d='on'},
+ [0x29EC]={d='on'},
+ [0x29ED]={d='on'},
+ [0x29EE]={d='on'},
+ [0x29EF]={d='on'},
+ [0x29F0]={d='on'},
+ [0x29F1]={d='on'},
+ [0x29F2]={d='on'},
+ [0x29F3]={d='on'},
+ [0x29F4]={d='on'},
+ [0x29F5]={d='on', m=0x2215},
+ [0x29F6]={d='on'},
+ [0x29F7]={d='on'},
+ [0x29F8]={d='on', m=0x29F9},
+ [0x29F9]={d='on', m=0x29F8},
+ [0x29FA]={d='on'},
+ [0x29FB]={d='on'},
+ [0x29FC]={d='on', m=0x29FD},
+ [0x29FD]={d='on', m=0x29FC},
+ [0x29FE]={d='on'},
+ [0x29FF]={d='on'},
+ [0x2A00]={d='on'},
+ [0x2A01]={d='on'},
+ [0x2A02]={d='on'},
+ [0x2A03]={d='on'},
+ [0x2A04]={d='on'},
+ [0x2A05]={d='on'},
+ [0x2A06]={d='on'},
+ [0x2A07]={d='on'},
+ [0x2A08]={d='on'},
+ [0x2A09]={d='on'},
+ [0x2A0A]={d='on'},
+ [0x2A0B]={d='on'},
+ [0x2A0C]={d='on'},
+ [0x2A0D]={d='on'},
+ [0x2A0E]={d='on'},
+ [0x2A0F]={d='on'},
+ [0x2A10]={d='on'},
+ [0x2A11]={d='on'},
+ [0x2A12]={d='on'},
+ [0x2A13]={d='on'},
+ [0x2A14]={d='on'},
+ [0x2A15]={d='on'},
+ [0x2A16]={d='on'},
+ [0x2A17]={d='on'},
+ [0x2A18]={d='on'},
+ [0x2A19]={d='on'},
+ [0x2A1A]={d='on'},
+ [0x2A1B]={d='on'},
+ [0x2A1C]={d='on'},
+ [0x2A1D]={d='on'},
+ [0x2A1E]={d='on'},
+ [0x2A1F]={d='on'},
+ [0x2A20]={d='on'},
+ [0x2A21]={d='on'},
+ [0x2A22]={d='on'},
+ [0x2A23]={d='on'},
+ [0x2A24]={d='on'},
+ [0x2A25]={d='on'},
+ [0x2A26]={d='on'},
+ [0x2A27]={d='on'},
+ [0x2A28]={d='on'},
+ [0x2A29]={d='on'},
+ [0x2A2A]={d='on'},
+ [0x2A2B]={d='on', m=0x2A2C},
+ [0x2A2C]={d='on', m=0x2A2B},
+ [0x2A2D]={d='on', m=0x2A2E},
+ [0x2A2E]={d='on', m=0x2A2D},
+ [0x2A2F]={d='on'},
+ [0x2A30]={d='on'},
+ [0x2A31]={d='on'},
+ [0x2A32]={d='on'},
+ [0x2A33]={d='on'},
+ [0x2A34]={d='on', m=0x2A35},
+ [0x2A35]={d='on', m=0x2A34},
+ [0x2A36]={d='on'},
+ [0x2A37]={d='on'},
+ [0x2A38]={d='on'},
+ [0x2A39]={d='on'},
+ [0x2A3A]={d='on'},
+ [0x2A3B]={d='on'},
+ [0x2A3C]={d='on', m=0x2A3D},
+ [0x2A3D]={d='on', m=0x2A3C},
+ [0x2A3E]={d='on'},
+ [0x2A3F]={d='on'},
+ [0x2A40]={d='on'},
+ [0x2A41]={d='on'},
+ [0x2A42]={d='on'},
+ [0x2A43]={d='on'},
+ [0x2A44]={d='on'},
+ [0x2A45]={d='on'},
+ [0x2A46]={d='on'},
+ [0x2A47]={d='on'},
+ [0x2A48]={d='on'},
+ [0x2A49]={d='on'},
+ [0x2A4A]={d='on'},
+ [0x2A4B]={d='on'},
+ [0x2A4C]={d='on'},
+ [0x2A4D]={d='on'},
+ [0x2A4E]={d='on'},
+ [0x2A4F]={d='on'},
+ [0x2A50]={d='on'},
+ [0x2A51]={d='on'},
+ [0x2A52]={d='on'},
+ [0x2A53]={d='on'},
+ [0x2A54]={d='on'},
+ [0x2A55]={d='on'},
+ [0x2A56]={d='on'},
+ [0x2A57]={d='on'},
+ [0x2A58]={d='on'},
+ [0x2A59]={d='on'},
+ [0x2A5A]={d='on'},
+ [0x2A5B]={d='on'},
+ [0x2A5C]={d='on'},
+ [0x2A5D]={d='on'},
+ [0x2A5E]={d='on'},
+ [0x2A5F]={d='on'},
+ [0x2A60]={d='on'},
+ [0x2A61]={d='on'},
+ [0x2A62]={d='on'},
+ [0x2A63]={d='on'},
+ [0x2A64]={d='on', m=0x2A65},
+ [0x2A65]={d='on', m=0x2A64},
+ [0x2A66]={d='on'},
+ [0x2A67]={d='on'},
+ [0x2A68]={d='on'},
+ [0x2A69]={d='on'},
+ [0x2A6A]={d='on'},
+ [0x2A6B]={d='on'},
+ [0x2A6C]={d='on'},
+ [0x2A6D]={d='on'},
+ [0x2A6E]={d='on'},
+ [0x2A6F]={d='on'},
+ [0x2A70]={d='on'},
+ [0x2A71]={d='on'},
+ [0x2A72]={d='on'},
+ [0x2A73]={d='on'},
+ [0x2A74]={d='on'},
+ [0x2A75]={d='on'},
+ [0x2A76]={d='on'},
+ [0x2A77]={d='on'},
+ [0x2A78]={d='on'},
+ [0x2A79]={d='on', m=0x2A7A},
+ [0x2A7A]={d='on', m=0x2A79},
+ [0x2A7B]={d='on'},
+ [0x2A7C]={d='on'},
+ [0x2A7D]={d='on', m=0x2A7E},
+ [0x2A7E]={d='on', m=0x2A7D},
+ [0x2A7F]={d='on', m=0x2A80},
+ [0x2A80]={d='on', m=0x2A7F},
+ [0x2A81]={d='on', m=0x2A82},
+ [0x2A82]={d='on', m=0x2A81},
+ [0x2A83]={d='on', m=0x2A84},
+ [0x2A84]={d='on', m=0x2A83},
+ [0x2A85]={d='on'},
+ [0x2A86]={d='on'},
+ [0x2A87]={d='on'},
+ [0x2A88]={d='on'},
+ [0x2A89]={d='on'},
+ [0x2A8A]={d='on'},
+ [0x2A8B]={d='on', m=0x2A8C},
+ [0x2A8C]={d='on', m=0x2A8B},
+ [0x2A8D]={d='on'},
+ [0x2A8E]={d='on'},
+ [0x2A8F]={d='on'},
+ [0x2A90]={d='on'},
+ [0x2A91]={d='on', m=0x2A92},
+ [0x2A92]={d='on', m=0x2A91},
+ [0x2A93]={d='on', m=0x2A94},
+ [0x2A94]={d='on', m=0x2A93},
+ [0x2A95]={d='on', m=0x2A96},
+ [0x2A96]={d='on', m=0x2A95},
+ [0x2A97]={d='on', m=0x2A98},
+ [0x2A98]={d='on', m=0x2A97},
+ [0x2A99]={d='on', m=0x2A9A},
+ [0x2A9A]={d='on', m=0x2A99},
+ [0x2A9B]={d='on', m=0x2A9C},
+ [0x2A9C]={d='on', m=0x2A9B},
+ [0x2A9D]={d='on'},
+ [0x2A9E]={d='on'},
+ [0x2A9F]={d='on'},
+ [0x2AA0]={d='on'},
+ [0x2AA1]={d='on', m=0x2AA2},
+ [0x2AA2]={d='on', m=0x2AA1},
+ [0x2AA3]={d='on'},
+ [0x2AA4]={d='on'},
+ [0x2AA5]={d='on'},
+ [0x2AA6]={d='on', m=0x2AA7},
+ [0x2AA7]={d='on', m=0x2AA6},
+ [0x2AA8]={d='on', m=0x2AA9},
+ [0x2AA9]={d='on', m=0x2AA8},
+ [0x2AAA]={d='on', m=0x2AAB},
+ [0x2AAB]={d='on', m=0x2AAA},
+ [0x2AAC]={d='on', m=0x2AAD},
+ [0x2AAD]={d='on', m=0x2AAC},
+ [0x2AAE]={d='on'},
+ [0x2AAF]={d='on', m=0x2AB0},
+ [0x2AB0]={d='on', m=0x2AAF},
+ [0x2AB1]={d='on'},
+ [0x2AB2]={d='on'},
+ [0x2AB3]={d='on', m=0x2AB4},
+ [0x2AB4]={d='on', m=0x2AB3},
+ [0x2AB5]={d='on'},
+ [0x2AB6]={d='on'},
+ [0x2AB7]={d='on'},
+ [0x2AB8]={d='on'},
+ [0x2AB9]={d='on'},
+ [0x2ABA]={d='on'},
+ [0x2ABB]={d='on', m=0x2ABC},
+ [0x2ABC]={d='on', m=0x2ABB},
+ [0x2ABD]={d='on', m=0x2ABE},
+ [0x2ABE]={d='on', m=0x2ABD},
+ [0x2ABF]={d='on', m=0x2AC0},
+ [0x2AC0]={d='on', m=0x2ABF},
+ [0x2AC1]={d='on', m=0x2AC2},
+ [0x2AC2]={d='on', m=0x2AC1},
+ [0x2AC3]={d='on', m=0x2AC4},
+ [0x2AC4]={d='on', m=0x2AC3},
+ [0x2AC5]={d='on', m=0x2AC6},
+ [0x2AC6]={d='on', m=0x2AC5},
+ [0x2AC7]={d='on'},
+ [0x2AC8]={d='on'},
+ [0x2AC9]={d='on'},
+ [0x2ACA]={d='on'},
+ [0x2ACB]={d='on'},
+ [0x2ACC]={d='on'},
+ [0x2ACD]={d='on', m=0x2ACE},
+ [0x2ACE]={d='on', m=0x2ACD},
+ [0x2ACF]={d='on', m=0x2AD0},
+ [0x2AD0]={d='on', m=0x2ACF},
+ [0x2AD1]={d='on', m=0x2AD2},
+ [0x2AD2]={d='on', m=0x2AD1},
+ [0x2AD3]={d='on', m=0x2AD4},
+ [0x2AD4]={d='on', m=0x2AD3},
+ [0x2AD5]={d='on', m=0x2AD6},
+ [0x2AD6]={d='on', m=0x2AD5},
+ [0x2AD7]={d='on'},
+ [0x2AD8]={d='on'},
+ [0x2AD9]={d='on'},
+ [0x2ADA]={d='on'},
+ [0x2ADB]={d='on'},
+ [0x2ADC]={d='on'},
+ [0x2ADD]={d='on'},
+ [0x2ADE]={d='on', m=0x22A6},
+ [0x2ADF]={d='on'},
+ [0x2AE0]={d='on'},
+ [0x2AE1]={d='on'},
+ [0x2AE2]={d='on'},
+ [0x2AE3]={d='on', m=0x22A9},
+ [0x2AE4]={d='on', m=0x22A8},
+ [0x2AE5]={d='on', m=0x22AB},
+ [0x2AE6]={d='on'},
+ [0x2AE7]={d='on'},
+ [0x2AE8]={d='on'},
+ [0x2AE9]={d='on'},
+ [0x2AEA]={d='on'},
+ [0x2AEB]={d='on'},
+ [0x2AEC]={d='on', m=0x2AED},
+ [0x2AED]={d='on', m=0x2AEC},
+ [0x2AEE]={d='on'},
+ [0x2AEF]={d='on'},
+ [0x2AF0]={d='on'},
+ [0x2AF1]={d='on'},
+ [0x2AF2]={d='on'},
+ [0x2AF3]={d='on'},
+ [0x2AF4]={d='on'},
+ [0x2AF5]={d='on'},
+ [0x2AF6]={d='on'},
+ [0x2AF7]={d='on', m=0x2AF8},
+ [0x2AF8]={d='on', m=0x2AF7},
+ [0x2AF9]={d='on', m=0x2AFA},
+ [0x2AFA]={d='on', m=0x2AF9},
+ [0x2AFB]={d='on'},
+ [0x2AFC]={d='on'},
+ [0x2AFD]={d='on'},
+ [0x2AFE]={d='on'},
+ [0x2AFF]={d='on'},
+ [0x2B00]={d='on'},
+ [0x2B01]={d='on'},
+ [0x2B02]={d='on'},
+ [0x2B03]={d='on'},
+ [0x2B04]={d='on'},
+ [0x2B05]={d='on'},
+ [0x2B06]={d='on'},
+ [0x2B07]={d='on'},
+ [0x2B08]={d='on'},
+ [0x2B09]={d='on'},
+ [0x2B0A]={d='on'},
+ [0x2B0B]={d='on'},
+ [0x2B0C]={d='on'},
+ [0x2B0D]={d='on'},
+ [0x2B0E]={d='on'},
+ [0x2B0F]={d='on'},
+ [0x2B10]={d='on'},
+ [0x2B11]={d='on'},
+ [0x2B12]={d='on'},
+ [0x2B13]={d='on'},
+ [0x2B14]={d='on'},
+ [0x2B15]={d='on'},
+ [0x2B16]={d='on'},
+ [0x2B17]={d='on'},
+ [0x2B18]={d='on'},
+ [0x2B19]={d='on'},
+ [0x2B1A]={d='on'},
+ [0x2B1B]={d='on'},
+ [0x2B1C]={d='on'},
+ [0x2B1D]={d='on'},
+ [0x2B1E]={d='on'},
+ [0x2B1F]={d='on'},
+ [0x2B20]={d='on'},
+ [0x2B21]={d='on'},
+ [0x2B22]={d='on'},
+ [0x2B23]={d='on'},
+ [0x2B24]={d='on'},
+ [0x2B25]={d='on'},
+ [0x2B26]={d='on'},
+ [0x2B27]={d='on'},
+ [0x2B28]={d='on'},
+ [0x2B29]={d='on'},
+ [0x2B2A]={d='on'},
+ [0x2B2B]={d='on'},
+ [0x2B2C]={d='on'},
+ [0x2B2D]={d='on'},
+ [0x2B2E]={d='on'},
+ [0x2B2F]={d='on'},
+ [0x2B30]={d='on'},
+ [0x2B31]={d='on'},
+ [0x2B32]={d='on'},
+ [0x2B33]={d='on'},
+ [0x2B34]={d='on'},
+ [0x2B35]={d='on'},
+ [0x2B36]={d='on'},
+ [0x2B37]={d='on'},
+ [0x2B38]={d='on'},
+ [0x2B39]={d='on'},
+ [0x2B3A]={d='on'},
+ [0x2B3B]={d='on'},
+ [0x2B3C]={d='on'},
+ [0x2B3D]={d='on'},
+ [0x2B3E]={d='on'},
+ [0x2B3F]={d='on'},
+ [0x2B40]={d='on'},
+ [0x2B41]={d='on'},
+ [0x2B42]={d='on'},
+ [0x2B43]={d='on'},
+ [0x2B44]={d='on'},
+ [0x2B45]={d='on'},
+ [0x2B46]={d='on'},
+ [0x2B47]={d='on'},
+ [0x2B48]={d='on'},
+ [0x2B49]={d='on'},
+ [0x2B4A]={d='on'},
+ [0x2B4B]={d='on'},
+ [0x2B4C]={d='on'},
+ [0x2B4D]={d='on'},
+ [0x2B4E]={d='on'},
+ [0x2B4F]={d='on'},
+ [0x2B50]={d='on'},
+ [0x2B51]={d='on'},
+ [0x2B52]={d='on'},
+ [0x2B53]={d='on'},
+ [0x2B54]={d='on'},
+ [0x2B55]={d='on'},
+ [0x2B56]={d='on'},
+ [0x2B57]={d='on'},
+ [0x2B58]={d='on'},
+ [0x2B59]={d='on'},
+ [0x2B5A]={d='on'},
+ [0x2B5B]={d='on'},
+ [0x2B5C]={d='on'},
+ [0x2B5D]={d='on'},
+ [0x2B5E]={d='on'},
+ [0x2B5F]={d='on'},
+ [0x2B60]={d='on'},
+ [0x2B61]={d='on'},
+ [0x2B62]={d='on'},
+ [0x2B63]={d='on'},
+ [0x2B64]={d='on'},
+ [0x2B65]={d='on'},
+ [0x2B66]={d='on'},
+ [0x2B67]={d='on'},
+ [0x2B68]={d='on'},
+ [0x2B69]={d='on'},
+ [0x2B6A]={d='on'},
+ [0x2B6B]={d='on'},
+ [0x2B6C]={d='on'},
+ [0x2B6D]={d='on'},
+ [0x2B6E]={d='on'},
+ [0x2B6F]={d='on'},
+ [0x2B70]={d='on'},
+ [0x2B71]={d='on'},
+ [0x2B72]={d='on'},
+ [0x2B73]={d='on'},
+ [0x2B76]={d='on'},
+ [0x2B77]={d='on'},
+ [0x2B78]={d='on'},
+ [0x2B79]={d='on'},
+ [0x2B7A]={d='on'},
+ [0x2B7B]={d='on'},
+ [0x2B7C]={d='on'},
+ [0x2B7D]={d='on'},
+ [0x2B7E]={d='on'},
+ [0x2B7F]={d='on'},
+ [0x2B80]={d='on'},
+ [0x2B81]={d='on'},
+ [0x2B82]={d='on'},
+ [0x2B83]={d='on'},
+ [0x2B84]={d='on'},
+ [0x2B85]={d='on'},
+ [0x2B86]={d='on'},
+ [0x2B87]={d='on'},
+ [0x2B88]={d='on'},
+ [0x2B89]={d='on'},
+ [0x2B8A]={d='on'},
+ [0x2B8B]={d='on'},
+ [0x2B8C]={d='on'},
+ [0x2B8D]={d='on'},
+ [0x2B8E]={d='on'},
+ [0x2B8F]={d='on'},
+ [0x2B90]={d='on'},
+ [0x2B91]={d='on'},
+ [0x2B92]={d='on'},
+ [0x2B93]={d='on'},
+ [0x2B94]={d='on'},
+ [0x2B95]={d='on'},
+ [0x2B98]={d='on'},
+ [0x2B99]={d='on'},
+ [0x2B9A]={d='on'},
+ [0x2B9B]={d='on'},
+ [0x2B9C]={d='on'},
+ [0x2B9D]={d='on'},
+ [0x2B9E]={d='on'},
+ [0x2B9F]={d='on'},
+ [0x2BA0]={d='on'},
+ [0x2BA1]={d='on'},
+ [0x2BA2]={d='on'},
+ [0x2BA3]={d='on'},
+ [0x2BA4]={d='on'},
+ [0x2BA5]={d='on'},
+ [0x2BA6]={d='on'},
+ [0x2BA7]={d='on'},
+ [0x2BA8]={d='on'},
+ [0x2BA9]={d='on'},
+ [0x2BAA]={d='on'},
+ [0x2BAB]={d='on'},
+ [0x2BAC]={d='on'},
+ [0x2BAD]={d='on'},
+ [0x2BAE]={d='on'},
+ [0x2BAF]={d='on'},
+ [0x2BB0]={d='on'},
+ [0x2BB1]={d='on'},
+ [0x2BB2]={d='on'},
+ [0x2BB3]={d='on'},
+ [0x2BB4]={d='on'},
+ [0x2BB5]={d='on'},
+ [0x2BB6]={d='on'},
+ [0x2BB7]={d='on'},
+ [0x2BB8]={d='on'},
+ [0x2BB9]={d='on'},
+ [0x2BBD]={d='on'},
+ [0x2BBE]={d='on'},
+ [0x2BBF]={d='on'},
+ [0x2BC0]={d='on'},
+ [0x2BC1]={d='on'},
+ [0x2BC2]={d='on'},
+ [0x2BC3]={d='on'},
+ [0x2BC4]={d='on'},
+ [0x2BC5]={d='on'},
+ [0x2BC6]={d='on'},
+ [0x2BC7]={d='on'},
+ [0x2BC8]={d='on'},
+ [0x2BCA]={d='on'},
+ [0x2BCB]={d='on'},
+ [0x2BCC]={d='on'},
+ [0x2BCD]={d='on'},
+ [0x2BCE]={d='on'},
+ [0x2BCF]={d='on'},
+ [0x2BD0]={d='on'},
+ [0x2BD1]={d='on'},
+ [0x2BEC]={d='on'},
+ [0x2BED]={d='on'},
+ [0x2BEE]={d='on'},
+ [0x2BEF]={d='on'},
+ [0x2CE5]={d='on'},
+ [0x2CE6]={d='on'},
+ [0x2CE7]={d='on'},
+ [0x2CE8]={d='on'},
+ [0x2CE9]={d='on'},
+ [0x2CEA]={d='on'},
+ [0x2CEF]={d='nsm'},
+ [0x2CF0]={d='nsm'},
+ [0x2CF1]={d='nsm'},
+ [0x2CF9]={d='on'},
+ [0x2CFA]={d='on'},
+ [0x2CFB]={d='on'},
+ [0x2CFC]={d='on'},
+ [0x2CFD]={d='on'},
+ [0x2CFE]={d='on'},
+ [0x2CFF]={d='on'},
+ [0x2D7F]={d='nsm'},
+ [0x2DE0]={d='nsm'},
+ [0x2DE1]={d='nsm'},
+ [0x2DE2]={d='nsm'},
+ [0x2DE3]={d='nsm'},
+ [0x2DE4]={d='nsm'},
+ [0x2DE5]={d='nsm'},
+ [0x2DE6]={d='nsm'},
+ [0x2DE7]={d='nsm'},
+ [0x2DE8]={d='nsm'},
+ [0x2DE9]={d='nsm'},
+ [0x2DEA]={d='nsm'},
+ [0x2DEB]={d='nsm'},
+ [0x2DEC]={d='nsm'},
+ [0x2DED]={d='nsm'},
+ [0x2DEE]={d='nsm'},
+ [0x2DEF]={d='nsm'},
+ [0x2DF0]={d='nsm'},
+ [0x2DF1]={d='nsm'},
+ [0x2DF2]={d='nsm'},
+ [0x2DF3]={d='nsm'},
+ [0x2DF4]={d='nsm'},
+ [0x2DF5]={d='nsm'},
+ [0x2DF6]={d='nsm'},
+ [0x2DF7]={d='nsm'},
+ [0x2DF8]={d='nsm'},
+ [0x2DF9]={d='nsm'},
+ [0x2DFA]={d='nsm'},
+ [0x2DFB]={d='nsm'},
+ [0x2DFC]={d='nsm'},
+ [0x2DFD]={d='nsm'},
+ [0x2DFE]={d='nsm'},
+ [0x2DFF]={d='nsm'},
+ [0x2E00]={d='on'},
+ [0x2E01]={d='on'},
+ [0x2E02]={d='on', m=0x2E03},
+ [0x2E03]={d='on', m=0x2E02},
+ [0x2E04]={d='on', m=0x2E05},
+ [0x2E05]={d='on', m=0x2E04},
+ [0x2E06]={d='on'},
+ [0x2E07]={d='on'},
+ [0x2E08]={d='on'},
+ [0x2E09]={d='on', m=0x2E0A},
+ [0x2E0A]={d='on', m=0x2E09},
+ [0x2E0B]={d='on'},
+ [0x2E0C]={d='on', m=0x2E0D},
+ [0x2E0D]={d='on', m=0x2E0C},
+ [0x2E0E]={d='on'},
+ [0x2E0F]={d='on'},
+ [0x2E10]={d='on'},
+ [0x2E11]={d='on'},
+ [0x2E12]={d='on'},
+ [0x2E13]={d='on'},
+ [0x2E14]={d='on'},
+ [0x2E15]={d='on'},
+ [0x2E16]={d='on'},
+ [0x2E17]={d='on'},
+ [0x2E18]={d='on'},
+ [0x2E19]={d='on'},
+ [0x2E1A]={d='on'},
+ [0x2E1B]={d='on'},
+ [0x2E1C]={d='on', m=0x2E1D},
+ [0x2E1D]={d='on', m=0x2E1C},
+ [0x2E1E]={d='on'},
+ [0x2E1F]={d='on'},
+ [0x2E20]={d='on', m=0x2E21},
+ [0x2E21]={d='on', m=0x2E20},
+ [0x2E22]={d='on', m=0x2E23},
+ [0x2E23]={d='on', m=0x2E22},
+ [0x2E24]={d='on', m=0x2E25},
+ [0x2E25]={d='on', m=0x2E24},
+ [0x2E26]={d='on', m=0x2E27},
+ [0x2E27]={d='on', m=0x2E26},
+ [0x2E28]={d='on', m=0x2E29},
+ [0x2E29]={d='on', m=0x2E28},
+ [0x2E2A]={d='on'},
+ [0x2E2B]={d='on'},
+ [0x2E2C]={d='on'},
+ [0x2E2D]={d='on'},
+ [0x2E2E]={d='on'},
+ [0x2E2F]={d='on'},
+ [0x2E30]={d='on'},
+ [0x2E31]={d='on'},
+ [0x2E32]={d='on'},
+ [0x2E33]={d='on'},
+ [0x2E34]={d='on'},
+ [0x2E35]={d='on'},
+ [0x2E36]={d='on'},
+ [0x2E37]={d='on'},
+ [0x2E38]={d='on'},
+ [0x2E39]={d='on'},
+ [0x2E3A]={d='on'},
+ [0x2E3B]={d='on'},
+ [0x2E3C]={d='on'},
+ [0x2E3D]={d='on'},
+ [0x2E3E]={d='on'},
+ [0x2E3F]={d='on'},
+ [0x2E40]={d='on'},
+ [0x2E41]={d='on'},
+ [0x2E42]={d='on'},
+ [0x2E43]={d='on'},
+ [0x2E44]={d='on'},
+ [0x2E80]={d='on'},
+ [0x2E81]={d='on'},
+ [0x2E82]={d='on'},
+ [0x2E83]={d='on'},
+ [0x2E84]={d='on'},
+ [0x2E85]={d='on'},
+ [0x2E86]={d='on'},
+ [0x2E87]={d='on'},
+ [0x2E88]={d='on'},
+ [0x2E89]={d='on'},
+ [0x2E8A]={d='on'},
+ [0x2E8B]={d='on'},
+ [0x2E8C]={d='on'},
+ [0x2E8D]={d='on'},
+ [0x2E8E]={d='on'},
+ [0x2E8F]={d='on'},
+ [0x2E90]={d='on'},
+ [0x2E91]={d='on'},
+ [0x2E92]={d='on'},
+ [0x2E93]={d='on'},
+ [0x2E94]={d='on'},
+ [0x2E95]={d='on'},
+ [0x2E96]={d='on'},
+ [0x2E97]={d='on'},
+ [0x2E98]={d='on'},
+ [0x2E99]={d='on'},
+ [0x2E9B]={d='on'},
+ [0x2E9C]={d='on'},
+ [0x2E9D]={d='on'},
+ [0x2E9E]={d='on'},
+ [0x2E9F]={d='on'},
+ [0x2EA0]={d='on'},
+ [0x2EA1]={d='on'},
+ [0x2EA2]={d='on'},
+ [0x2EA3]={d='on'},
+ [0x2EA4]={d='on'},
+ [0x2EA5]={d='on'},
+ [0x2EA6]={d='on'},
+ [0x2EA7]={d='on'},
+ [0x2EA8]={d='on'},
+ [0x2EA9]={d='on'},
+ [0x2EAA]={d='on'},
+ [0x2EAB]={d='on'},
+ [0x2EAC]={d='on'},
+ [0x2EAD]={d='on'},
+ [0x2EAE]={d='on'},
+ [0x2EAF]={d='on'},
+ [0x2EB0]={d='on'},
+ [0x2EB1]={d='on'},
+ [0x2EB2]={d='on'},
+ [0x2EB3]={d='on'},
+ [0x2EB4]={d='on'},
+ [0x2EB5]={d='on'},
+ [0x2EB6]={d='on'},
+ [0x2EB7]={d='on'},
+ [0x2EB8]={d='on'},
+ [0x2EB9]={d='on'},
+ [0x2EBA]={d='on'},
+ [0x2EBB]={d='on'},
+ [0x2EBC]={d='on'},
+ [0x2EBD]={d='on'},
+ [0x2EBE]={d='on'},
+ [0x2EBF]={d='on'},
+ [0x2EC0]={d='on'},
+ [0x2EC1]={d='on'},
+ [0x2EC2]={d='on'},
+ [0x2EC3]={d='on'},
+ [0x2EC4]={d='on'},
+ [0x2EC5]={d='on'},
+ [0x2EC6]={d='on'},
+ [0x2EC7]={d='on'},
+ [0x2EC8]={d='on'},
+ [0x2EC9]={d='on'},
+ [0x2ECA]={d='on'},
+ [0x2ECB]={d='on'},
+ [0x2ECC]={d='on'},
+ [0x2ECD]={d='on'},
+ [0x2ECE]={d='on'},
+ [0x2ECF]={d='on'},
+ [0x2ED0]={d='on'},
+ [0x2ED1]={d='on'},
+ [0x2ED2]={d='on'},
+ [0x2ED3]={d='on'},
+ [0x2ED4]={d='on'},
+ [0x2ED5]={d='on'},
+ [0x2ED6]={d='on'},
+ [0x2ED7]={d='on'},
+ [0x2ED8]={d='on'},
+ [0x2ED9]={d='on'},
+ [0x2EDA]={d='on'},
+ [0x2EDB]={d='on'},
+ [0x2EDC]={d='on'},
+ [0x2EDD]={d='on'},
+ [0x2EDE]={d='on'},
+ [0x2EDF]={d='on'},
+ [0x2EE0]={d='on'},
+ [0x2EE1]={d='on'},
+ [0x2EE2]={d='on'},
+ [0x2EE3]={d='on'},
+ [0x2EE4]={d='on'},
+ [0x2EE5]={d='on'},
+ [0x2EE6]={d='on'},
+ [0x2EE7]={d='on'},
+ [0x2EE8]={d='on'},
+ [0x2EE9]={d='on'},
+ [0x2EEA]={d='on'},
+ [0x2EEB]={d='on'},
+ [0x2EEC]={d='on'},
+ [0x2EED]={d='on'},
+ [0x2EEE]={d='on'},
+ [0x2EEF]={d='on'},
+ [0x2EF0]={d='on'},
+ [0x2EF1]={d='on'},
+ [0x2EF2]={d='on'},
+ [0x2EF3]={d='on'},
+ [0x2F00]={d='on'},
+ [0x2F01]={d='on'},
+ [0x2F02]={d='on'},
+ [0x2F03]={d='on'},
+ [0x2F04]={d='on'},
+ [0x2F05]={d='on'},
+ [0x2F06]={d='on'},
+ [0x2F07]={d='on'},
+ [0x2F08]={d='on'},
+ [0x2F09]={d='on'},
+ [0x2F0A]={d='on'},
+ [0x2F0B]={d='on'},
+ [0x2F0C]={d='on'},
+ [0x2F0D]={d='on'},
+ [0x2F0E]={d='on'},
+ [0x2F0F]={d='on'},
+ [0x2F10]={d='on'},
+ [0x2F11]={d='on'},
+ [0x2F12]={d='on'},
+ [0x2F13]={d='on'},
+ [0x2F14]={d='on'},
+ [0x2F15]={d='on'},
+ [0x2F16]={d='on'},
+ [0x2F17]={d='on'},
+ [0x2F18]={d='on'},
+ [0x2F19]={d='on'},
+ [0x2F1A]={d='on'},
+ [0x2F1B]={d='on'},
+ [0x2F1C]={d='on'},
+ [0x2F1D]={d='on'},
+ [0x2F1E]={d='on'},
+ [0x2F1F]={d='on'},
+ [0x2F20]={d='on'},
+ [0x2F21]={d='on'},
+ [0x2F22]={d='on'},
+ [0x2F23]={d='on'},
+ [0x2F24]={d='on'},
+ [0x2F25]={d='on'},
+ [0x2F26]={d='on'},
+ [0x2F27]={d='on'},
+ [0x2F28]={d='on'},
+ [0x2F29]={d='on'},
+ [0x2F2A]={d='on'},
+ [0x2F2B]={d='on'},
+ [0x2F2C]={d='on'},
+ [0x2F2D]={d='on'},
+ [0x2F2E]={d='on'},
+ [0x2F2F]={d='on'},
+ [0x2F30]={d='on'},
+ [0x2F31]={d='on'},
+ [0x2F32]={d='on'},
+ [0x2F33]={d='on'},
+ [0x2F34]={d='on'},
+ [0x2F35]={d='on'},
+ [0x2F36]={d='on'},
+ [0x2F37]={d='on'},
+ [0x2F38]={d='on'},
+ [0x2F39]={d='on'},
+ [0x2F3A]={d='on'},
+ [0x2F3B]={d='on'},
+ [0x2F3C]={d='on'},
+ [0x2F3D]={d='on'},
+ [0x2F3E]={d='on'},
+ [0x2F3F]={d='on'},
+ [0x2F40]={d='on'},
+ [0x2F41]={d='on'},
+ [0x2F42]={d='on'},
+ [0x2F43]={d='on'},
+ [0x2F44]={d='on'},
+ [0x2F45]={d='on'},
+ [0x2F46]={d='on'},
+ [0x2F47]={d='on'},
+ [0x2F48]={d='on'},
+ [0x2F49]={d='on'},
+ [0x2F4A]={d='on'},
+ [0x2F4B]={d='on'},
+ [0x2F4C]={d='on'},
+ [0x2F4D]={d='on'},
+ [0x2F4E]={d='on'},
+ [0x2F4F]={d='on'},
+ [0x2F50]={d='on'},
+ [0x2F51]={d='on'},
+ [0x2F52]={d='on'},
+ [0x2F53]={d='on'},
+ [0x2F54]={d='on'},
+ [0x2F55]={d='on'},
+ [0x2F56]={d='on'},
+ [0x2F57]={d='on'},
+ [0x2F58]={d='on'},
+ [0x2F59]={d='on'},
+ [0x2F5A]={d='on'},
+ [0x2F5B]={d='on'},
+ [0x2F5C]={d='on'},
+ [0x2F5D]={d='on'},
+ [0x2F5E]={d='on'},
+ [0x2F5F]={d='on'},
+ [0x2F60]={d='on'},
+ [0x2F61]={d='on'},
+ [0x2F62]={d='on'},
+ [0x2F63]={d='on'},
+ [0x2F64]={d='on'},
+ [0x2F65]={d='on'},
+ [0x2F66]={d='on'},
+ [0x2F67]={d='on'},
+ [0x2F68]={d='on'},
+ [0x2F69]={d='on'},
+ [0x2F6A]={d='on'},
+ [0x2F6B]={d='on'},
+ [0x2F6C]={d='on'},
+ [0x2F6D]={d='on'},
+ [0x2F6E]={d='on'},
+ [0x2F6F]={d='on'},
+ [0x2F70]={d='on'},
+ [0x2F71]={d='on'},
+ [0x2F72]={d='on'},
+ [0x2F73]={d='on'},
+ [0x2F74]={d='on'},
+ [0x2F75]={d='on'},
+ [0x2F76]={d='on'},
+ [0x2F77]={d='on'},
+ [0x2F78]={d='on'},
+ [0x2F79]={d='on'},
+ [0x2F7A]={d='on'},
+ [0x2F7B]={d='on'},
+ [0x2F7C]={d='on'},
+ [0x2F7D]={d='on'},
+ [0x2F7E]={d='on'},
+ [0x2F7F]={d='on'},
+ [0x2F80]={d='on'},
+ [0x2F81]={d='on'},
+ [0x2F82]={d='on'},
+ [0x2F83]={d='on'},
+ [0x2F84]={d='on'},
+ [0x2F85]={d='on'},
+ [0x2F86]={d='on'},
+ [0x2F87]={d='on'},
+ [0x2F88]={d='on'},
+ [0x2F89]={d='on'},
+ [0x2F8A]={d='on'},
+ [0x2F8B]={d='on'},
+ [0x2F8C]={d='on'},
+ [0x2F8D]={d='on'},
+ [0x2F8E]={d='on'},
+ [0x2F8F]={d='on'},
+ [0x2F90]={d='on'},
+ [0x2F91]={d='on'},
+ [0x2F92]={d='on'},
+ [0x2F93]={d='on'},
+ [0x2F94]={d='on'},
+ [0x2F95]={d='on'},
+ [0x2F96]={d='on'},
+ [0x2F97]={d='on'},
+ [0x2F98]={d='on'},
+ [0x2F99]={d='on'},
+ [0x2F9A]={d='on'},
+ [0x2F9B]={d='on'},
+ [0x2F9C]={d='on'},
+ [0x2F9D]={d='on'},
+ [0x2F9E]={d='on'},
+ [0x2F9F]={d='on'},
+ [0x2FA0]={d='on'},
+ [0x2FA1]={d='on'},
+ [0x2FA2]={d='on'},
+ [0x2FA3]={d='on'},
+ [0x2FA4]={d='on'},
+ [0x2FA5]={d='on'},
+ [0x2FA6]={d='on'},
+ [0x2FA7]={d='on'},
+ [0x2FA8]={d='on'},
+ [0x2FA9]={d='on'},
+ [0x2FAA]={d='on'},
+ [0x2FAB]={d='on'},
+ [0x2FAC]={d='on'},
+ [0x2FAD]={d='on'},
+ [0x2FAE]={d='on'},
+ [0x2FAF]={d='on'},
+ [0x2FB0]={d='on'},
+ [0x2FB1]={d='on'},
+ [0x2FB2]={d='on'},
+ [0x2FB3]={d='on'},
+ [0x2FB4]={d='on'},
+ [0x2FB5]={d='on'},
+ [0x2FB6]={d='on'},
+ [0x2FB7]={d='on'},
+ [0x2FB8]={d='on'},
+ [0x2FB9]={d='on'},
+ [0x2FBA]={d='on'},
+ [0x2FBB]={d='on'},
+ [0x2FBC]={d='on'},
+ [0x2FBD]={d='on'},
+ [0x2FBE]={d='on'},
+ [0x2FBF]={d='on'},
+ [0x2FC0]={d='on'},
+ [0x2FC1]={d='on'},
+ [0x2FC2]={d='on'},
+ [0x2FC3]={d='on'},
+ [0x2FC4]={d='on'},
+ [0x2FC5]={d='on'},
+ [0x2FC6]={d='on'},
+ [0x2FC7]={d='on'},
+ [0x2FC8]={d='on'},
+ [0x2FC9]={d='on'},
+ [0x2FCA]={d='on'},
+ [0x2FCB]={d='on'},
+ [0x2FCC]={d='on'},
+ [0x2FCD]={d='on'},
+ [0x2FCE]={d='on'},
+ [0x2FCF]={d='on'},
+ [0x2FD0]={d='on'},
+ [0x2FD1]={d='on'},
+ [0x2FD2]={d='on'},
+ [0x2FD3]={d='on'},
+ [0x2FD4]={d='on'},
+ [0x2FD5]={d='on'},
+ [0x2FF0]={d='on'},
+ [0x2FF1]={d='on'},
+ [0x2FF2]={d='on'},
+ [0x2FF3]={d='on'},
+ [0x2FF4]={d='on'},
+ [0x2FF5]={d='on'},
+ [0x2FF6]={d='on'},
+ [0x2FF7]={d='on'},
+ [0x2FF8]={d='on'},
+ [0x2FF9]={d='on'},
+ [0x2FFA]={d='on'},
+ [0x2FFB]={d='on'},
+ [0x3000]={d='ws'},
+ [0x3001]={d='on'},
+ [0x3002]={d='on'},
+ [0x3003]={d='on'},
+ [0x3004]={d='on'},
+ [0x3008]={d='on', m=0x3009},
+ [0x3009]={d='on', m=0x3008},
+ [0x300A]={d='on', m=0x300B},
+ [0x300B]={d='on', m=0x300A},
+ [0x300C]={d='on', m=0x300D},
+ [0x300D]={d='on', m=0x300C},
+ [0x300E]={d='on', m=0x300F},
+ [0x300F]={d='on', m=0x300E},
+ [0x3010]={d='on', m=0x3011},
+ [0x3011]={d='on', m=0x3010},
+ [0x3012]={d='on'},
+ [0x3013]={d='on'},
+ [0x3014]={d='on', m=0x3015},
+ [0x3015]={d='on', m=0x3014},
+ [0x3016]={d='on', m=0x3017},
+ [0x3017]={d='on', m=0x3016},
+ [0x3018]={d='on', m=0x3019},
+ [0x3019]={d='on', m=0x3018},
+ [0x301A]={d='on', m=0x301B},
+ [0x301B]={d='on', m=0x301A},
+ [0x301C]={d='on'},
+ [0x301D]={d='on'},
+ [0x301E]={d='on'},
+ [0x301F]={d='on'},
+ [0x3020]={d='on'},
+ [0x302A]={d='nsm'},
+ [0x302B]={d='nsm'},
+ [0x302C]={d='nsm'},
+ [0x302D]={d='nsm'},
+ [0x3030]={d='on'},
+ [0x3036]={d='on'},
+ [0x3037]={d='on'},
+ [0x303D]={d='on'},
+ [0x303E]={d='on'},
+ [0x303F]={d='on'},
+ [0x3099]={d='nsm'},
+ [0x309A]={d='nsm'},
+ [0x309B]={d='on'},
+ [0x309C]={d='on'},
+ [0x30A0]={d='on'},
+ [0x30FB]={d='on'},
+ [0x31C0]={d='on'},
+ [0x31C1]={d='on'},
+ [0x31C2]={d='on'},
+ [0x31C3]={d='on'},
+ [0x31C4]={d='on'},
+ [0x31C5]={d='on'},
+ [0x31C6]={d='on'},
+ [0x31C7]={d='on'},
+ [0x31C8]={d='on'},
+ [0x31C9]={d='on'},
+ [0x31CA]={d='on'},
+ [0x31CB]={d='on'},
+ [0x31CC]={d='on'},
+ [0x31CD]={d='on'},
+ [0x31CE]={d='on'},
+ [0x31CF]={d='on'},
+ [0x31D0]={d='on'},
+ [0x31D1]={d='on'},
+ [0x31D2]={d='on'},
+ [0x31D3]={d='on'},
+ [0x31D4]={d='on'},
+ [0x31D5]={d='on'},
+ [0x31D6]={d='on'},
+ [0x31D7]={d='on'},
+ [0x31D8]={d='on'},
+ [0x31D9]={d='on'},
+ [0x31DA]={d='on'},
+ [0x31DB]={d='on'},
+ [0x31DC]={d='on'},
+ [0x31DD]={d='on'},
+ [0x31DE]={d='on'},
+ [0x31DF]={d='on'},
+ [0x31E0]={d='on'},
+ [0x31E1]={d='on'},
+ [0x31E2]={d='on'},
+ [0x31E3]={d='on'},
+ [0x321D]={d='on'},
+ [0x321E]={d='on'},
+ [0x3250]={d='on'},
+ [0x3251]={d='on'},
+ [0x3252]={d='on'},
+ [0x3253]={d='on'},
+ [0x3254]={d='on'},
+ [0x3255]={d='on'},
+ [0x3256]={d='on'},
+ [0x3257]={d='on'},
+ [0x3258]={d='on'},
+ [0x3259]={d='on'},
+ [0x325A]={d='on'},
+ [0x325B]={d='on'},
+ [0x325C]={d='on'},
+ [0x325D]={d='on'},
+ [0x325E]={d='on'},
+ [0x325F]={d='on'},
+ [0x327C]={d='on'},
+ [0x327D]={d='on'},
+ [0x327E]={d='on'},
+ [0x32B1]={d='on'},
+ [0x32B2]={d='on'},
+ [0x32B3]={d='on'},
+ [0x32B4]={d='on'},
+ [0x32B5]={d='on'},
+ [0x32B6]={d='on'},
+ [0x32B7]={d='on'},
+ [0x32B8]={d='on'},
+ [0x32B9]={d='on'},
+ [0x32BA]={d='on'},
+ [0x32BB]={d='on'},
+ [0x32BC]={d='on'},
+ [0x32BD]={d='on'},
+ [0x32BE]={d='on'},
+ [0x32BF]={d='on'},
+ [0x32CC]={d='on'},
+ [0x32CD]={d='on'},
+ [0x32CE]={d='on'},
+ [0x32CF]={d='on'},
+ [0x3377]={d='on'},
+ [0x3378]={d='on'},
+ [0x3379]={d='on'},
+ [0x337A]={d='on'},
+ [0x33DE]={d='on'},
+ [0x33DF]={d='on'},
+ [0x33FF]={d='on'},
+ [0x4DC0]={d='on'},
+ [0x4DC1]={d='on'},
+ [0x4DC2]={d='on'},
+ [0x4DC3]={d='on'},
+ [0x4DC4]={d='on'},
+ [0x4DC5]={d='on'},
+ [0x4DC6]={d='on'},
+ [0x4DC7]={d='on'},
+ [0x4DC8]={d='on'},
+ [0x4DC9]={d='on'},
+ [0x4DCA]={d='on'},
+ [0x4DCB]={d='on'},
+ [0x4DCC]={d='on'},
+ [0x4DCD]={d='on'},
+ [0x4DCE]={d='on'},
+ [0x4DCF]={d='on'},
+ [0x4DD0]={d='on'},
+ [0x4DD1]={d='on'},
+ [0x4DD2]={d='on'},
+ [0x4DD3]={d='on'},
+ [0x4DD4]={d='on'},
+ [0x4DD5]={d='on'},
+ [0x4DD6]={d='on'},
+ [0x4DD7]={d='on'},
+ [0x4DD8]={d='on'},
+ [0x4DD9]={d='on'},
+ [0x4DDA]={d='on'},
+ [0x4DDB]={d='on'},
+ [0x4DDC]={d='on'},
+ [0x4DDD]={d='on'},
+ [0x4DDE]={d='on'},
+ [0x4DDF]={d='on'},
+ [0x4DE0]={d='on'},
+ [0x4DE1]={d='on'},
+ [0x4DE2]={d='on'},
+ [0x4DE3]={d='on'},
+ [0x4DE4]={d='on'},
+ [0x4DE5]={d='on'},
+ [0x4DE6]={d='on'},
+ [0x4DE7]={d='on'},
+ [0x4DE8]={d='on'},
+ [0x4DE9]={d='on'},
+ [0x4DEA]={d='on'},
+ [0x4DEB]={d='on'},
+ [0x4DEC]={d='on'},
+ [0x4DED]={d='on'},
+ [0x4DEE]={d='on'},
+ [0x4DEF]={d='on'},
+ [0x4DF0]={d='on'},
+ [0x4DF1]={d='on'},
+ [0x4DF2]={d='on'},
+ [0x4DF3]={d='on'},
+ [0x4DF4]={d='on'},
+ [0x4DF5]={d='on'},
+ [0x4DF6]={d='on'},
+ [0x4DF7]={d='on'},
+ [0x4DF8]={d='on'},
+ [0x4DF9]={d='on'},
+ [0x4DFA]={d='on'},
+ [0x4DFB]={d='on'},
+ [0x4DFC]={d='on'},
+ [0x4DFD]={d='on'},
+ [0x4DFE]={d='on'},
+ [0x4DFF]={d='on'},
+ [0xA490]={d='on'},
+ [0xA491]={d='on'},
+ [0xA492]={d='on'},
+ [0xA493]={d='on'},
+ [0xA494]={d='on'},
+ [0xA495]={d='on'},
+ [0xA496]={d='on'},
+ [0xA497]={d='on'},
+ [0xA498]={d='on'},
+ [0xA499]={d='on'},
+ [0xA49A]={d='on'},
+ [0xA49B]={d='on'},
+ [0xA49C]={d='on'},
+ [0xA49D]={d='on'},
+ [0xA49E]={d='on'},
+ [0xA49F]={d='on'},
+ [0xA4A0]={d='on'},
+ [0xA4A1]={d='on'},
+ [0xA4A2]={d='on'},
+ [0xA4A3]={d='on'},
+ [0xA4A4]={d='on'},
+ [0xA4A5]={d='on'},
+ [0xA4A6]={d='on'},
+ [0xA4A7]={d='on'},
+ [0xA4A8]={d='on'},
+ [0xA4A9]={d='on'},
+ [0xA4AA]={d='on'},
+ [0xA4AB]={d='on'},
+ [0xA4AC]={d='on'},
+ [0xA4AD]={d='on'},
+ [0xA4AE]={d='on'},
+ [0xA4AF]={d='on'},
+ [0xA4B0]={d='on'},
+ [0xA4B1]={d='on'},
+ [0xA4B2]={d='on'},
+ [0xA4B3]={d='on'},
+ [0xA4B4]={d='on'},
+ [0xA4B5]={d='on'},
+ [0xA4B6]={d='on'},
+ [0xA4B7]={d='on'},
+ [0xA4B8]={d='on'},
+ [0xA4B9]={d='on'},
+ [0xA4BA]={d='on'},
+ [0xA4BB]={d='on'},
+ [0xA4BC]={d='on'},
+ [0xA4BD]={d='on'},
+ [0xA4BE]={d='on'},
+ [0xA4BF]={d='on'},
+ [0xA4C0]={d='on'},
+ [0xA4C1]={d='on'},
+ [0xA4C2]={d='on'},
+ [0xA4C3]={d='on'},
+ [0xA4C4]={d='on'},
+ [0xA4C5]={d='on'},
+ [0xA4C6]={d='on'},
+ [0xA60D]={d='on'},
+ [0xA60E]={d='on'},
+ [0xA60F]={d='on'},
+ [0xA66F]={d='nsm'},
+ [0xA670]={d='nsm'},
+ [0xA671]={d='nsm'},
+ [0xA672]={d='nsm'},
+ [0xA673]={d='on'},
+ [0xA674]={d='nsm'},
+ [0xA675]={d='nsm'},
+ [0xA676]={d='nsm'},
+ [0xA677]={d='nsm'},
+ [0xA678]={d='nsm'},
+ [0xA679]={d='nsm'},
+ [0xA67A]={d='nsm'},
+ [0xA67B]={d='nsm'},
+ [0xA67C]={d='nsm'},
+ [0xA67D]={d='nsm'},
+ [0xA67E]={d='on'},
+ [0xA67F]={d='on'},
+ [0xA69E]={d='nsm'},
+ [0xA69F]={d='nsm'},
+ [0xA6F0]={d='nsm'},
+ [0xA6F1]={d='nsm'},
+ [0xA700]={d='on'},
+ [0xA701]={d='on'},
+ [0xA702]={d='on'},
+ [0xA703]={d='on'},
+ [0xA704]={d='on'},
+ [0xA705]={d='on'},
+ [0xA706]={d='on'},
+ [0xA707]={d='on'},
+ [0xA708]={d='on'},
+ [0xA709]={d='on'},
+ [0xA70A]={d='on'},
+ [0xA70B]={d='on'},
+ [0xA70C]={d='on'},
+ [0xA70D]={d='on'},
+ [0xA70E]={d='on'},
+ [0xA70F]={d='on'},
+ [0xA710]={d='on'},
+ [0xA711]={d='on'},
+ [0xA712]={d='on'},
+ [0xA713]={d='on'},
+ [0xA714]={d='on'},
+ [0xA715]={d='on'},
+ [0xA716]={d='on'},
+ [0xA717]={d='on'},
+ [0xA718]={d='on'},
+ [0xA719]={d='on'},
+ [0xA71A]={d='on'},
+ [0xA71B]={d='on'},
+ [0xA71C]={d='on'},
+ [0xA71D]={d='on'},
+ [0xA71E]={d='on'},
+ [0xA71F]={d='on'},
+ [0xA720]={d='on'},
+ [0xA721]={d='on'},
+ [0xA788]={d='on'},
+ [0xA802]={d='nsm'},
+ [0xA806]={d='nsm'},
+ [0xA80B]={d='nsm'},
+ [0xA825]={d='nsm'},
+ [0xA826]={d='nsm'},
+ [0xA828]={d='on'},
+ [0xA829]={d='on'},
+ [0xA82A]={d='on'},
+ [0xA82B]={d='on'},
+ [0xA838]={d='et'},
+ [0xA839]={d='et'},
+ [0xA874]={d='on'},
+ [0xA875]={d='on'},
+ [0xA876]={d='on'},
+ [0xA877]={d='on'},
+ [0xA8C4]={d='nsm'},
+ [0xA8C5]={d='nsm'},
+ [0xA8E0]={d='nsm'},
+ [0xA8E1]={d='nsm'},
+ [0xA8E2]={d='nsm'},
+ [0xA8E3]={d='nsm'},
+ [0xA8E4]={d='nsm'},
+ [0xA8E5]={d='nsm'},
+ [0xA8E6]={d='nsm'},
+ [0xA8E7]={d='nsm'},
+ [0xA8E8]={d='nsm'},
+ [0xA8E9]={d='nsm'},
+ [0xA8EA]={d='nsm'},
+ [0xA8EB]={d='nsm'},
+ [0xA8EC]={d='nsm'},
+ [0xA8ED]={d='nsm'},
+ [0xA8EE]={d='nsm'},
+ [0xA8EF]={d='nsm'},
+ [0xA8F0]={d='nsm'},
+ [0xA8F1]={d='nsm'},
+ [0xA926]={d='nsm'},
+ [0xA927]={d='nsm'},
+ [0xA928]={d='nsm'},
+ [0xA929]={d='nsm'},
+ [0xA92A]={d='nsm'},
+ [0xA92B]={d='nsm'},
+ [0xA92C]={d='nsm'},
+ [0xA92D]={d='nsm'},
+ [0xA947]={d='nsm'},
+ [0xA948]={d='nsm'},
+ [0xA949]={d='nsm'},
+ [0xA94A]={d='nsm'},
+ [0xA94B]={d='nsm'},
+ [0xA94C]={d='nsm'},
+ [0xA94D]={d='nsm'},
+ [0xA94E]={d='nsm'},
+ [0xA94F]={d='nsm'},
+ [0xA950]={d='nsm'},
+ [0xA951]={d='nsm'},
+ [0xA980]={d='nsm'},
+ [0xA981]={d='nsm'},
+ [0xA982]={d='nsm'},
+ [0xA9B3]={d='nsm'},
+ [0xA9B6]={d='nsm'},
+ [0xA9B7]={d='nsm'},
+ [0xA9B8]={d='nsm'},
+ [0xA9B9]={d='nsm'},
+ [0xA9BC]={d='nsm'},
+ [0xA9E5]={d='nsm'},
+ [0xAA29]={d='nsm'},
+ [0xAA2A]={d='nsm'},
+ [0xAA2B]={d='nsm'},
+ [0xAA2C]={d='nsm'},
+ [0xAA2D]={d='nsm'},
+ [0xAA2E]={d='nsm'},
+ [0xAA31]={d='nsm'},
+ [0xAA32]={d='nsm'},
+ [0xAA35]={d='nsm'},
+ [0xAA36]={d='nsm'},
+ [0xAA43]={d='nsm'},
+ [0xAA4C]={d='nsm'},
+ [0xAA7C]={d='nsm'},
+ [0xAAB0]={d='nsm'},
+ [0xAAB2]={d='nsm'},
+ [0xAAB3]={d='nsm'},
+ [0xAAB4]={d='nsm'},
+ [0xAAB7]={d='nsm'},
+ [0xAAB8]={d='nsm'},
+ [0xAABE]={d='nsm'},
+ [0xAABF]={d='nsm'},
+ [0xAAC1]={d='nsm'},
+ [0xAAEC]={d='nsm'},
+ [0xAAED]={d='nsm'},
+ [0xAAF6]={d='nsm'},
+ [0xABE5]={d='nsm'},
+ [0xABE8]={d='nsm'},
+ [0xABED]={d='nsm'},
+ [0xFB1E]={d='nsm'},
+ [0xFB29]={d='es'},
+ [0xFD3E]={d='on'},
+ [0xFD3F]={d='on'},
+ [0xFDFD]={d='on'},
+ [0xFE10]={d='on'},
+ [0xFE11]={d='on'},
+ [0xFE12]={d='on'},
+ [0xFE13]={d='on'},
+ [0xFE14]={d='on'},
+ [0xFE15]={d='on'},
+ [0xFE16]={d='on'},
+ [0xFE17]={d='on'},
+ [0xFE18]={d='on'},
+ [0xFE19]={d='on'},
+ [0xFE20]={d='nsm'},
+ [0xFE21]={d='nsm'},
+ [0xFE22]={d='nsm'},
+ [0xFE23]={d='nsm'},
+ [0xFE24]={d='nsm'},
+ [0xFE25]={d='nsm'},
+ [0xFE26]={d='nsm'},
+ [0xFE27]={d='nsm'},
+ [0xFE28]={d='nsm'},
+ [0xFE29]={d='nsm'},
+ [0xFE2A]={d='nsm'},
+ [0xFE2B]={d='nsm'},
+ [0xFE2C]={d='nsm'},
+ [0xFE2D]={d='nsm'},
+ [0xFE2E]={d='nsm'},
+ [0xFE2F]={d='nsm'},
+ [0xFE30]={d='on'},
+ [0xFE31]={d='on'},
+ [0xFE32]={d='on'},
+ [0xFE33]={d='on'},
+ [0xFE34]={d='on'},
+ [0xFE35]={d='on'},
+ [0xFE36]={d='on'},
+ [0xFE37]={d='on'},
+ [0xFE38]={d='on'},
+ [0xFE39]={d='on'},
+ [0xFE3A]={d='on'},
+ [0xFE3B]={d='on'},
+ [0xFE3C]={d='on'},
+ [0xFE3D]={d='on'},
+ [0xFE3E]={d='on'},
+ [0xFE3F]={d='on'},
+ [0xFE40]={d='on'},
+ [0xFE41]={d='on'},
+ [0xFE42]={d='on'},
+ [0xFE43]={d='on'},
+ [0xFE44]={d='on'},
+ [0xFE45]={d='on'},
+ [0xFE46]={d='on'},
+ [0xFE47]={d='on'},
+ [0xFE48]={d='on'},
+ [0xFE49]={d='on'},
+ [0xFE4A]={d='on'},
+ [0xFE4B]={d='on'},
+ [0xFE4C]={d='on'},
+ [0xFE4D]={d='on'},
+ [0xFE4E]={d='on'},
+ [0xFE4F]={d='on'},
+ [0xFE50]={d='cs'},
+ [0xFE51]={d='on'},
+ [0xFE52]={d='cs'},
+ [0xFE54]={d='on'},
+ [0xFE55]={d='cs'},
+ [0xFE56]={d='on'},
+ [0xFE57]={d='on'},
+ [0xFE58]={d='on'},
+ [0xFE59]={d='on', m=0xFE5A},
+ [0xFE5A]={d='on', m=0xFE59},
+ [0xFE5B]={d='on', m=0xFE5C},
+ [0xFE5C]={d='on', m=0xFE5B},
+ [0xFE5D]={d='on', m=0xFE5E},
+ [0xFE5E]={d='on', m=0xFE5D},
+ [0xFE5F]={d='et'},
+ [0xFE60]={d='on'},
+ [0xFE61]={d='on'},
+ [0xFE62]={d='es'},
+ [0xFE63]={d='es'},
+ [0xFE64]={d='on', m=0xFE65},
+ [0xFE65]={d='on', m=0xFE64},
+ [0xFE66]={d='on'},
+ [0xFE68]={d='on'},
+ [0xFE69]={d='et'},
+ [0xFE6A]={d='et'},
+ [0xFE6B]={d='on'},
+ [0xFEFF]={d='bn'},
+ [0xFF01]={d='on'},
+ [0xFF02]={d='on'},
+ [0xFF03]={d='et'},
+ [0xFF04]={d='et'},
+ [0xFF05]={d='et'},
+ [0xFF06]={d='on'},
+ [0xFF07]={d='on'},
+ [0xFF08]={d='on', m=0xFF09},
+ [0xFF09]={d='on', m=0xFF08},
+ [0xFF0A]={d='on'},
+ [0xFF0B]={d='es'},
+ [0xFF0C]={d='cs'},
+ [0xFF0D]={d='es'},
+ [0xFF0E]={d='cs'},
+ [0xFF0F]={d='cs'},
+ [0xFF10]={d='en'},
+ [0xFF11]={d='en'},
+ [0xFF12]={d='en'},
+ [0xFF13]={d='en'},
+ [0xFF14]={d='en'},
+ [0xFF15]={d='en'},
+ [0xFF16]={d='en'},
+ [0xFF17]={d='en'},
+ [0xFF18]={d='en'},
+ [0xFF19]={d='en'},
+ [0xFF1A]={d='cs'},
+ [0xFF1B]={d='on'},
+ [0xFF1C]={d='on', m=0xFF1E},
+ [0xFF1D]={d='on'},
+ [0xFF1E]={d='on', m=0xFF1C},
+ [0xFF1F]={d='on'},
+ [0xFF20]={d='on'},
+ [0xFF3B]={d='on', m=0xFF3D},
+ [0xFF3C]={d='on'},
+ [0xFF3D]={d='on', m=0xFF3B},
+ [0xFF3E]={d='on'},
+ [0xFF3F]={d='on'},
+ [0xFF40]={d='on'},
+ [0xFF5B]={d='on', m=0xFF5D},
+ [0xFF5C]={d='on'},
+ [0xFF5D]={d='on', m=0xFF5B},
+ [0xFF5E]={d='on'},
+ [0xFF5F]={d='on', m=0xFF60},
+ [0xFF60]={d='on', m=0xFF5F},
+ [0xFF61]={d='on'},
+ [0xFF62]={d='on', m=0xFF63},
+ [0xFF63]={d='on', m=0xFF62},
+ [0xFF64]={d='on'},
+ [0xFF65]={d='on'},
+ [0xFFE0]={d='et'},
+ [0xFFE1]={d='et'},
+ [0xFFE2]={d='on'},
+ [0xFFE3]={d='on'},
+ [0xFFE4]={d='on'},
+ [0xFFE5]={d='et'},
+ [0xFFE6]={d='et'},
+ [0xFFE8]={d='on'},
+ [0xFFE9]={d='on'},
+ [0xFFEA]={d='on'},
+ [0xFFEB]={d='on'},
+ [0xFFEC]={d='on'},
+ [0xFFED]={d='on'},
+ [0xFFEE]={d='on'},
+ [0xFFF9]={d='on'},
+ [0xFFFA]={d='on'},
+ [0xFFFB]={d='on'},
+ [0xFFFC]={d='on'},
+ [0xFFFD]={d='on'},
+ [0x10101]={d='on'},
+ [0x10140]={d='on'},
+ [0x10141]={d='on'},
+ [0x10142]={d='on'},
+ [0x10143]={d='on'},
+ [0x10144]={d='on'},
+ [0x10145]={d='on'},
+ [0x10146]={d='on'},
+ [0x10147]={d='on'},
+ [0x10148]={d='on'},
+ [0x10149]={d='on'},
+ [0x1014A]={d='on'},
+ [0x1014B]={d='on'},
+ [0x1014C]={d='on'},
+ [0x1014D]={d='on'},
+ [0x1014E]={d='on'},
+ [0x1014F]={d='on'},
+ [0x10150]={d='on'},
+ [0x10151]={d='on'},
+ [0x10152]={d='on'},
+ [0x10153]={d='on'},
+ [0x10154]={d='on'},
+ [0x10155]={d='on'},
+ [0x10156]={d='on'},
+ [0x10157]={d='on'},
+ [0x10158]={d='on'},
+ [0x10159]={d='on'},
+ [0x1015A]={d='on'},
+ [0x1015B]={d='on'},
+ [0x1015C]={d='on'},
+ [0x1015D]={d='on'},
+ [0x1015E]={d='on'},
+ [0x1015F]={d='on'},
+ [0x10160]={d='on'},
+ [0x10161]={d='on'},
+ [0x10162]={d='on'},
+ [0x10163]={d='on'},
+ [0x10164]={d='on'},
+ [0x10165]={d='on'},
+ [0x10166]={d='on'},
+ [0x10167]={d='on'},
+ [0x10168]={d='on'},
+ [0x10169]={d='on'},
+ [0x1016A]={d='on'},
+ [0x1016B]={d='on'},
+ [0x1016C]={d='on'},
+ [0x1016D]={d='on'},
+ [0x1016E]={d='on'},
+ [0x1016F]={d='on'},
+ [0x10170]={d='on'},
+ [0x10171]={d='on'},
+ [0x10172]={d='on'},
+ [0x10173]={d='on'},
+ [0x10174]={d='on'},
+ [0x10175]={d='on'},
+ [0x10176]={d='on'},
+ [0x10177]={d='on'},
+ [0x10178]={d='on'},
+ [0x10179]={d='on'},
+ [0x1017A]={d='on'},
+ [0x1017B]={d='on'},
+ [0x1017C]={d='on'},
+ [0x1017D]={d='on'},
+ [0x1017E]={d='on'},
+ [0x1017F]={d='on'},
+ [0x10180]={d='on'},
+ [0x10181]={d='on'},
+ [0x10182]={d='on'},
+ [0x10183]={d='on'},
+ [0x10184]={d='on'},
+ [0x10185]={d='on'},
+ [0x10186]={d='on'},
+ [0x10187]={d='on'},
+ [0x10188]={d='on'},
+ [0x10189]={d='on'},
+ [0x1018A]={d='on'},
+ [0x1018B]={d='on'},
+ [0x1018C]={d='on'},
+ [0x10190]={d='on'},
+ [0x10191]={d='on'},
+ [0x10192]={d='on'},
+ [0x10193]={d='on'},
+ [0x10194]={d='on'},
+ [0x10195]={d='on'},
+ [0x10196]={d='on'},
+ [0x10197]={d='on'},
+ [0x10198]={d='on'},
+ [0x10199]={d='on'},
+ [0x1019A]={d='on'},
+ [0x1019B]={d='on'},
+ [0x101A0]={d='on'},
+ [0x101FD]={d='nsm'},
+ [0x102E0]={d='nsm'},
+ [0x102E1]={d='en'},
+ [0x102E2]={d='en'},
+ [0x102E3]={d='en'},
+ [0x102E4]={d='en'},
+ [0x102E5]={d='en'},
+ [0x102E6]={d='en'},
+ [0x102E7]={d='en'},
+ [0x102E8]={d='en'},
+ [0x102E9]={d='en'},
+ [0x102EA]={d='en'},
+ [0x102EB]={d='en'},
+ [0x102EC]={d='en'},
+ [0x102ED]={d='en'},
+ [0x102EE]={d='en'},
+ [0x102EF]={d='en'},
+ [0x102F0]={d='en'},
+ [0x102F1]={d='en'},
+ [0x102F2]={d='en'},
+ [0x102F3]={d='en'},
+ [0x102F4]={d='en'},
+ [0x102F5]={d='en'},
+ [0x102F6]={d='en'},
+ [0x102F7]={d='en'},
+ [0x102F8]={d='en'},
+ [0x102F9]={d='en'},
+ [0x102FA]={d='en'},
+ [0x102FB]={d='en'},
+ [0x10376]={d='nsm'},
+ [0x10377]={d='nsm'},
+ [0x10378]={d='nsm'},
+ [0x10379]={d='nsm'},
+ [0x1037A]={d='nsm'},
+ [0x1091F]={d='on'},
+ [0x10A01]={d='nsm'},
+ [0x10A02]={d='nsm'},
+ [0x10A03]={d='nsm'},
+ [0x10A05]={d='nsm'},
+ [0x10A06]={d='nsm'},
+ [0x10A0C]={d='nsm'},
+ [0x10A0D]={d='nsm'},
+ [0x10A0E]={d='nsm'},
+ [0x10A0F]={d='nsm'},
+ [0x10A38]={d='nsm'},
+ [0x10A39]={d='nsm'},
+ [0x10A3A]={d='nsm'},
+ [0x10A3F]={d='nsm'},
+ [0x10AE5]={d='nsm'},
+ [0x10AE6]={d='nsm'},
+ [0x10B39]={d='on'},
+ [0x10B3A]={d='on'},
+ [0x10B3B]={d='on'},
+ [0x10B3C]={d='on'},
+ [0x10B3D]={d='on'},
+ [0x10B3E]={d='on'},
+ [0x10B3F]={d='on'},
+ [0x10C80]={d='r'},
+ [0x10C81]={d='r'},
+ [0x10C82]={d='r'},
+ [0x10C83]={d='r'},
+ [0x10C84]={d='r'},
+ [0x10C85]={d='r'},
+ [0x10C86]={d='r'},
+ [0x10C87]={d='r'},
+ [0x10C88]={d='r'},
+ [0x10C89]={d='r'},
+ [0x10C8A]={d='r'},
+ [0x10C8B]={d='r'},
+ [0x10C8C]={d='r'},
+ [0x10C8D]={d='r'},
+ [0x10C8E]={d='r'},
+ [0x10C8F]={d='r'},
+ [0x10C90]={d='r'},
+ [0x10C91]={d='r'},
+ [0x10C92]={d='r'},
+ [0x10C93]={d='r'},
+ [0x10C94]={d='r'},
+ [0x10C95]={d='r'},
+ [0x10C96]={d='r'},
+ [0x10C97]={d='r'},
+ [0x10C98]={d='r'},
+ [0x10C99]={d='r'},
+ [0x10C9A]={d='r'},
+ [0x10C9B]={d='r'},
+ [0x10C9C]={d='r'},
+ [0x10C9D]={d='r'},
+ [0x10C9E]={d='r'},
+ [0x10C9F]={d='r'},
+ [0x10CA0]={d='r'},
+ [0x10CA1]={d='r'},
+ [0x10CA2]={d='r'},
+ [0x10CA3]={d='r'},
+ [0x10CA4]={d='r'},
+ [0x10CA5]={d='r'},
+ [0x10CA6]={d='r'},
+ [0x10CA7]={d='r'},
+ [0x10CA8]={d='r'},
+ [0x10CA9]={d='r'},
+ [0x10CAA]={d='r'},
+ [0x10CAB]={d='r'},
+ [0x10CAC]={d='r'},
+ [0x10CAD]={d='r'},
+ [0x10CAE]={d='r'},
+ [0x10CAF]={d='r'},
+ [0x10CB0]={d='r'},
+ [0x10CB1]={d='r'},
+ [0x10CB2]={d='r'},
+ [0x10CC0]={d='r'},
+ [0x10CC1]={d='r'},
+ [0x10CC2]={d='r'},
+ [0x10CC3]={d='r'},
+ [0x10CC4]={d='r'},
+ [0x10CC5]={d='r'},
+ [0x10CC6]={d='r'},
+ [0x10CC7]={d='r'},
+ [0x10CC8]={d='r'},
+ [0x10CC9]={d='r'},
+ [0x10CCA]={d='r'},
+ [0x10CCB]={d='r'},
+ [0x10CCC]={d='r'},
+ [0x10CCD]={d='r'},
+ [0x10CCE]={d='r'},
+ [0x10CCF]={d='r'},
+ [0x10CD0]={d='r'},
+ [0x10CD1]={d='r'},
+ [0x10CD2]={d='r'},
+ [0x10CD3]={d='r'},
+ [0x10CD4]={d='r'},
+ [0x10CD5]={d='r'},
+ [0x10CD6]={d='r'},
+ [0x10CD7]={d='r'},
+ [0x10CD8]={d='r'},
+ [0x10CD9]={d='r'},
+ [0x10CDA]={d='r'},
+ [0x10CDB]={d='r'},
+ [0x10CDC]={d='r'},
+ [0x10CDD]={d='r'},
+ [0x10CDE]={d='r'},
+ [0x10CDF]={d='r'},
+ [0x10CE0]={d='r'},
+ [0x10CE1]={d='r'},
+ [0x10CE2]={d='r'},
+ [0x10CE3]={d='r'},
+ [0x10CE4]={d='r'},
+ [0x10CE5]={d='r'},
+ [0x10CE6]={d='r'},
+ [0x10CE7]={d='r'},
+ [0x10CE8]={d='r'},
+ [0x10CE9]={d='r'},
+ [0x10CEA]={d='r'},
+ [0x10CEB]={d='r'},
+ [0x10CEC]={d='r'},
+ [0x10CED]={d='r'},
+ [0x10CEE]={d='r'},
+ [0x10CEF]={d='r'},
+ [0x10CF0]={d='r'},
+ [0x10CF1]={d='r'},
+ [0x10CF2]={d='r'},
+ [0x10CFA]={d='r'},
+ [0x10CFB]={d='r'},
+ [0x10CFC]={d='r'},
+ [0x10CFD]={d='r'},
+ [0x10CFE]={d='r'},
+ [0x10CFF]={d='r'},
+ [0x10E60]={d='an'},
+ [0x10E61]={d='an'},
+ [0x10E62]={d='an'},
+ [0x10E63]={d='an'},
+ [0x10E64]={d='an'},
+ [0x10E65]={d='an'},
+ [0x10E66]={d='an'},
+ [0x10E67]={d='an'},
+ [0x10E68]={d='an'},
+ [0x10E69]={d='an'},
+ [0x10E6A]={d='an'},
+ [0x10E6B]={d='an'},
+ [0x10E6C]={d='an'},
+ [0x10E6D]={d='an'},
+ [0x10E6E]={d='an'},
+ [0x10E6F]={d='an'},
+ [0x10E70]={d='an'},
+ [0x10E71]={d='an'},
+ [0x10E72]={d='an'},
+ [0x10E73]={d='an'},
+ [0x10E74]={d='an'},
+ [0x10E75]={d='an'},
+ [0x10E76]={d='an'},
+ [0x10E77]={d='an'},
+ [0x10E78]={d='an'},
+ [0x10E79]={d='an'},
+ [0x10E7A]={d='an'},
+ [0x10E7B]={d='an'},
+ [0x10E7C]={d='an'},
+ [0x10E7D]={d='an'},
+ [0x10E7E]={d='an'},
+ [0x11001]={d='nsm'},
+ [0x11038]={d='nsm'},
+ [0x11039]={d='nsm'},
+ [0x1103A]={d='nsm'},
+ [0x1103B]={d='nsm'},
+ [0x1103C]={d='nsm'},
+ [0x1103D]={d='nsm'},
+ [0x1103E]={d='nsm'},
+ [0x1103F]={d='nsm'},
+ [0x11040]={d='nsm'},
+ [0x11041]={d='nsm'},
+ [0x11042]={d='nsm'},
+ [0x11043]={d='nsm'},
+ [0x11044]={d='nsm'},
+ [0x11045]={d='nsm'},
+ [0x11046]={d='nsm'},
+ [0x11052]={d='on'},
+ [0x11053]={d='on'},
+ [0x11054]={d='on'},
+ [0x11055]={d='on'},
+ [0x11056]={d='on'},
+ [0x11057]={d='on'},
+ [0x11058]={d='on'},
+ [0x11059]={d='on'},
+ [0x1105A]={d='on'},
+ [0x1105B]={d='on'},
+ [0x1105C]={d='on'},
+ [0x1105D]={d='on'},
+ [0x1105E]={d='on'},
+ [0x1105F]={d='on'},
+ [0x11060]={d='on'},
+ [0x11061]={d='on'},
+ [0x11062]={d='on'},
+ [0x11063]={d='on'},
+ [0x11064]={d='on'},
+ [0x11065]={d='on'},
+ [0x1107F]={d='nsm'},
+ [0x11080]={d='nsm'},
+ [0x11081]={d='nsm'},
+ [0x110B3]={d='nsm'},
+ [0x110B4]={d='nsm'},
+ [0x110B5]={d='nsm'},
+ [0x110B6]={d='nsm'},
+ [0x110B9]={d='nsm'},
+ [0x110BA]={d='nsm'},
+ [0x11100]={d='nsm'},
+ [0x11101]={d='nsm'},
+ [0x11102]={d='nsm'},
+ [0x11127]={d='nsm'},
+ [0x11128]={d='nsm'},
+ [0x11129]={d='nsm'},
+ [0x1112A]={d='nsm'},
+ [0x1112B]={d='nsm'},
+ [0x1112D]={d='nsm'},
+ [0x1112E]={d='nsm'},
+ [0x1112F]={d='nsm'},
+ [0x11130]={d='nsm'},
+ [0x11131]={d='nsm'},
+ [0x11132]={d='nsm'},
+ [0x11133]={d='nsm'},
+ [0x11134]={d='nsm'},
+ [0x11173]={d='nsm'},
+ [0x11180]={d='nsm'},
+ [0x11181]={d='nsm'},
+ [0x111B6]={d='nsm'},
+ [0x111B7]={d='nsm'},
+ [0x111B8]={d='nsm'},
+ [0x111B9]={d='nsm'},
+ [0x111BA]={d='nsm'},
+ [0x111BB]={d='nsm'},
+ [0x111BC]={d='nsm'},
+ [0x111BD]={d='nsm'},
+ [0x111BE]={d='nsm'},
+ [0x111CA]={d='nsm'},
+ [0x111CB]={d='nsm'},
+ [0x111CC]={d='nsm'},
+ [0x1122F]={d='nsm'},
+ [0x11230]={d='nsm'},
+ [0x11231]={d='nsm'},
+ [0x11234]={d='nsm'},
+ [0x11236]={d='nsm'},
+ [0x11237]={d='nsm'},
+ [0x1123E]={d='nsm'},
+ [0x112DF]={d='nsm'},
+ [0x112E3]={d='nsm'},
+ [0x112E4]={d='nsm'},
+ [0x112E5]={d='nsm'},
+ [0x112E6]={d='nsm'},
+ [0x112E7]={d='nsm'},
+ [0x112E8]={d='nsm'},
+ [0x112E9]={d='nsm'},
+ [0x112EA]={d='nsm'},
+ [0x11300]={d='nsm'},
+ [0x11301]={d='nsm'},
+ [0x1133C]={d='nsm'},
+ [0x11340]={d='nsm'},
+ [0x11366]={d='nsm'},
+ [0x11367]={d='nsm'},
+ [0x11368]={d='nsm'},
+ [0x11369]={d='nsm'},
+ [0x1136A]={d='nsm'},
+ [0x1136B]={d='nsm'},
+ [0x1136C]={d='nsm'},
+ [0x11370]={d='nsm'},
+ [0x11371]={d='nsm'},
+ [0x11372]={d='nsm'},
+ [0x11373]={d='nsm'},
+ [0x11374]={d='nsm'},
+ [0x11438]={d='nsm'},
+ [0x11439]={d='nsm'},
+ [0x1143A]={d='nsm'},
+ [0x1143B]={d='nsm'},
+ [0x1143C]={d='nsm'},
+ [0x1143D]={d='nsm'},
+ [0x1143E]={d='nsm'},
+ [0x1143F]={d='nsm'},
+ [0x11442]={d='nsm'},
+ [0x11443]={d='nsm'},
+ [0x11444]={d='nsm'},
+ [0x11446]={d='nsm'},
+ [0x114B3]={d='nsm'},
+ [0x114B4]={d='nsm'},
+ [0x114B5]={d='nsm'},
+ [0x114B6]={d='nsm'},
+ [0x114B7]={d='nsm'},
+ [0x114B8]={d='nsm'},
+ [0x114BA]={d='nsm'},
+ [0x114BF]={d='nsm'},
+ [0x114C0]={d='nsm'},
+ [0x114C2]={d='nsm'},
+ [0x114C3]={d='nsm'},
+ [0x115B2]={d='nsm'},
+ [0x115B3]={d='nsm'},
+ [0x115B4]={d='nsm'},
+ [0x115B5]={d='nsm'},
+ [0x115BC]={d='nsm'},
+ [0x115BD]={d='nsm'},
+ [0x115BF]={d='nsm'},
+ [0x115C0]={d='nsm'},
+ [0x115DC]={d='nsm'},
+ [0x115DD]={d='nsm'},
+ [0x11633]={d='nsm'},
+ [0x11634]={d='nsm'},
+ [0x11635]={d='nsm'},
+ [0x11636]={d='nsm'},
+ [0x11637]={d='nsm'},
+ [0x11638]={d='nsm'},
+ [0x11639]={d='nsm'},
+ [0x1163A]={d='nsm'},
+ [0x1163D]={d='nsm'},
+ [0x1163F]={d='nsm'},
+ [0x11640]={d='nsm'},
+ [0x11660]={d='on'},
+ [0x11661]={d='on'},
+ [0x11662]={d='on'},
+ [0x11663]={d='on'},
+ [0x11664]={d='on'},
+ [0x11665]={d='on'},
+ [0x11666]={d='on'},
+ [0x11667]={d='on'},
+ [0x11668]={d='on'},
+ [0x11669]={d='on'},
+ [0x1166A]={d='on'},
+ [0x1166B]={d='on'},
+ [0x1166C]={d='on'},
+ [0x116AB]={d='nsm'},
+ [0x116AD]={d='nsm'},
+ [0x116B0]={d='nsm'},
+ [0x116B1]={d='nsm'},
+ [0x116B2]={d='nsm'},
+ [0x116B3]={d='nsm'},
+ [0x116B4]={d='nsm'},
+ [0x116B5]={d='nsm'},
+ [0x116B7]={d='nsm'},
+ [0x1171D]={d='nsm'},
+ [0x1171E]={d='nsm'},
+ [0x1171F]={d='nsm'},
+ [0x11722]={d='nsm'},
+ [0x11723]={d='nsm'},
+ [0x11724]={d='nsm'},
+ [0x11725]={d='nsm'},
+ [0x11727]={d='nsm'},
+ [0x11728]={d='nsm'},
+ [0x11729]={d='nsm'},
+ [0x1172A]={d='nsm'},
+ [0x1172B]={d='nsm'},
+ [0x11C30]={d='nsm'},
+ [0x11C31]={d='nsm'},
+ [0x11C32]={d='nsm'},
+ [0x11C33]={d='nsm'},
+ [0x11C34]={d='nsm'},
+ [0x11C35]={d='nsm'},
+ [0x11C36]={d='nsm'},
+ [0x11C38]={d='nsm'},
+ [0x11C39]={d='nsm'},
+ [0x11C3A]={d='nsm'},
+ [0x11C3B]={d='nsm'},
+ [0x11C3C]={d='nsm'},
+ [0x11C3D]={d='nsm'},
+ [0x11C92]={d='nsm'},
+ [0x11C93]={d='nsm'},
+ [0x11C94]={d='nsm'},
+ [0x11C95]={d='nsm'},
+ [0x11C96]={d='nsm'},
+ [0x11C97]={d='nsm'},
+ [0x11C98]={d='nsm'},
+ [0x11C99]={d='nsm'},
+ [0x11C9A]={d='nsm'},
+ [0x11C9B]={d='nsm'},
+ [0x11C9C]={d='nsm'},
+ [0x11C9D]={d='nsm'},
+ [0x11C9E]={d='nsm'},
+ [0x11C9F]={d='nsm'},
+ [0x11CA0]={d='nsm'},
+ [0x11CA1]={d='nsm'},
+ [0x11CA2]={d='nsm'},
+ [0x11CA3]={d='nsm'},
+ [0x11CA4]={d='nsm'},
+ [0x11CA5]={d='nsm'},
+ [0x11CA6]={d='nsm'},
+ [0x11CA7]={d='nsm'},
+ [0x11CAA]={d='nsm'},
+ [0x11CAB]={d='nsm'},
+ [0x11CAC]={d='nsm'},
+ [0x11CAD]={d='nsm'},
+ [0x11CAE]={d='nsm'},
+ [0x11CAF]={d='nsm'},
+ [0x11CB0]={d='nsm'},
+ [0x11CB2]={d='nsm'},
+ [0x11CB3]={d='nsm'},
+ [0x11CB5]={d='nsm'},
+ [0x11CB6]={d='nsm'},
+ [0x16AF0]={d='nsm'},
+ [0x16AF1]={d='nsm'},
+ [0x16AF2]={d='nsm'},
+ [0x16AF3]={d='nsm'},
+ [0x16AF4]={d='nsm'},
+ [0x16B30]={d='nsm'},
+ [0x16B31]={d='nsm'},
+ [0x16B32]={d='nsm'},
+ [0x16B33]={d='nsm'},
+ [0x16B34]={d='nsm'},
+ [0x16B35]={d='nsm'},
+ [0x16B36]={d='nsm'},
+ [0x16F8F]={d='nsm'},
+ [0x16F90]={d='nsm'},
+ [0x16F91]={d='nsm'},
+ [0x16F92]={d='nsm'},
+ [0x1BC9D]={d='nsm'},
+ [0x1BC9E]={d='nsm'},
+ [0x1BCA0]={d='bn'},
+ [0x1BCA1]={d='bn'},
+ [0x1BCA2]={d='bn'},
+ [0x1BCA3]={d='bn'},
+ [0x1D167]={d='nsm'},
+ [0x1D168]={d='nsm'},
+ [0x1D169]={d='nsm'},
+ [0x1D173]={d='bn'},
+ [0x1D174]={d='bn'},
+ [0x1D175]={d='bn'},
+ [0x1D176]={d='bn'},
+ [0x1D177]={d='bn'},
+ [0x1D178]={d='bn'},
+ [0x1D179]={d='bn'},
+ [0x1D17A]={d='bn'},
+ [0x1D17B]={d='nsm'},
+ [0x1D17C]={d='nsm'},
+ [0x1D17D]={d='nsm'},
+ [0x1D17E]={d='nsm'},
+ [0x1D17F]={d='nsm'},
+ [0x1D180]={d='nsm'},
+ [0x1D181]={d='nsm'},
+ [0x1D182]={d='nsm'},
+ [0x1D185]={d='nsm'},
+ [0x1D186]={d='nsm'},
+ [0x1D187]={d='nsm'},
+ [0x1D188]={d='nsm'},
+ [0x1D189]={d='nsm'},
+ [0x1D18A]={d='nsm'},
+ [0x1D18B]={d='nsm'},
+ [0x1D1AA]={d='nsm'},
+ [0x1D1AB]={d='nsm'},
+ [0x1D1AC]={d='nsm'},
+ [0x1D1AD]={d='nsm'},
+ [0x1D200]={d='on'},
+ [0x1D201]={d='on'},
+ [0x1D202]={d='on'},
+ [0x1D203]={d='on'},
+ [0x1D204]={d='on'},
+ [0x1D205]={d='on'},
+ [0x1D206]={d='on'},
+ [0x1D207]={d='on'},
+ [0x1D208]={d='on'},
+ [0x1D209]={d='on'},
+ [0x1D20A]={d='on'},
+ [0x1D20B]={d='on'},
+ [0x1D20C]={d='on'},
+ [0x1D20D]={d='on'},
+ [0x1D20E]={d='on'},
+ [0x1D20F]={d='on'},
+ [0x1D210]={d='on'},
+ [0x1D211]={d='on'},
+ [0x1D212]={d='on'},
+ [0x1D213]={d='on'},
+ [0x1D214]={d='on'},
+ [0x1D215]={d='on'},
+ [0x1D216]={d='on'},
+ [0x1D217]={d='on'},
+ [0x1D218]={d='on'},
+ [0x1D219]={d='on'},
+ [0x1D21A]={d='on'},
+ [0x1D21B]={d='on'},
+ [0x1D21C]={d='on'},
+ [0x1D21D]={d='on'},
+ [0x1D21E]={d='on'},
+ [0x1D21F]={d='on'},
+ [0x1D220]={d='on'},
+ [0x1D221]={d='on'},
+ [0x1D222]={d='on'},
+ [0x1D223]={d='on'},
+ [0x1D224]={d='on'},
+ [0x1D225]={d='on'},
+ [0x1D226]={d='on'},
+ [0x1D227]={d='on'},
+ [0x1D228]={d='on'},
+ [0x1D229]={d='on'},
+ [0x1D22A]={d='on'},
+ [0x1D22B]={d='on'},
+ [0x1D22C]={d='on'},
+ [0x1D22D]={d='on'},
+ [0x1D22E]={d='on'},
+ [0x1D22F]={d='on'},
+ [0x1D230]={d='on'},
+ [0x1D231]={d='on'},
+ [0x1D232]={d='on'},
+ [0x1D233]={d='on'},
+ [0x1D234]={d='on'},
+ [0x1D235]={d='on'},
+ [0x1D236]={d='on'},
+ [0x1D237]={d='on'},
+ [0x1D238]={d='on'},
+ [0x1D239]={d='on'},
+ [0x1D23A]={d='on'},
+ [0x1D23B]={d='on'},
+ [0x1D23C]={d='on'},
+ [0x1D23D]={d='on'},
+ [0x1D23E]={d='on'},
+ [0x1D23F]={d='on'},
+ [0x1D240]={d='on'},
+ [0x1D241]={d='on'},
+ [0x1D242]={d='nsm'},
+ [0x1D243]={d='nsm'},
+ [0x1D244]={d='nsm'},
+ [0x1D245]={d='on'},
+ [0x1D300]={d='on'},
+ [0x1D301]={d='on'},
+ [0x1D302]={d='on'},
+ [0x1D303]={d='on'},
+ [0x1D304]={d='on'},
+ [0x1D305]={d='on'},
+ [0x1D306]={d='on'},
+ [0x1D307]={d='on'},
+ [0x1D308]={d='on'},
+ [0x1D309]={d='on'},
+ [0x1D30A]={d='on'},
+ [0x1D30B]={d='on'},
+ [0x1D30C]={d='on'},
+ [0x1D30D]={d='on'},
+ [0x1D30E]={d='on'},
+ [0x1D30F]={d='on'},
+ [0x1D310]={d='on'},
+ [0x1D311]={d='on'},
+ [0x1D312]={d='on'},
+ [0x1D313]={d='on'},
+ [0x1D314]={d='on'},
+ [0x1D315]={d='on'},
+ [0x1D316]={d='on'},
+ [0x1D317]={d='on'},
+ [0x1D318]={d='on'},
+ [0x1D319]={d='on'},
+ [0x1D31A]={d='on'},
+ [0x1D31B]={d='on'},
+ [0x1D31C]={d='on'},
+ [0x1D31D]={d='on'},
+ [0x1D31E]={d='on'},
+ [0x1D31F]={d='on'},
+ [0x1D320]={d='on'},
+ [0x1D321]={d='on'},
+ [0x1D322]={d='on'},
+ [0x1D323]={d='on'},
+ [0x1D324]={d='on'},
+ [0x1D325]={d='on'},
+ [0x1D326]={d='on'},
+ [0x1D327]={d='on'},
+ [0x1D328]={d='on'},
+ [0x1D329]={d='on'},
+ [0x1D32A]={d='on'},
+ [0x1D32B]={d='on'},
+ [0x1D32C]={d='on'},
+ [0x1D32D]={d='on'},
+ [0x1D32E]={d='on'},
+ [0x1D32F]={d='on'},
+ [0x1D330]={d='on'},
+ [0x1D331]={d='on'},
+ [0x1D332]={d='on'},
+ [0x1D333]={d='on'},
+ [0x1D334]={d='on'},
+ [0x1D335]={d='on'},
+ [0x1D336]={d='on'},
+ [0x1D337]={d='on'},
+ [0x1D338]={d='on'},
+ [0x1D339]={d='on'},
+ [0x1D33A]={d='on'},
+ [0x1D33B]={d='on'},
+ [0x1D33C]={d='on'},
+ [0x1D33D]={d='on'},
+ [0x1D33E]={d='on'},
+ [0x1D33F]={d='on'},
+ [0x1D340]={d='on'},
+ [0x1D341]={d='on'},
+ [0x1D342]={d='on'},
+ [0x1D343]={d='on'},
+ [0x1D344]={d='on'},
+ [0x1D345]={d='on'},
+ [0x1D346]={d='on'},
+ [0x1D347]={d='on'},
+ [0x1D348]={d='on'},
+ [0x1D349]={d='on'},
+ [0x1D34A]={d='on'},
+ [0x1D34B]={d='on'},
+ [0x1D34C]={d='on'},
+ [0x1D34D]={d='on'},
+ [0x1D34E]={d='on'},
+ [0x1D34F]={d='on'},
+ [0x1D350]={d='on'},
+ [0x1D351]={d='on'},
+ [0x1D352]={d='on'},
+ [0x1D353]={d='on'},
+ [0x1D354]={d='on'},
+ [0x1D355]={d='on'},
+ [0x1D356]={d='on'},
+ [0x1D6DB]={d='on'},
+ [0x1D715]={d='on'},
+ [0x1D74F]={d='on'},
+ [0x1D789]={d='on'},
+ [0x1D7C3]={d='on'},
+ [0x1D7CE]={d='en'},
+ [0x1D7CF]={d='en'},
+ [0x1D7D0]={d='en'},
+ [0x1D7D1]={d='en'},
+ [0x1D7D2]={d='en'},
+ [0x1D7D3]={d='en'},
+ [0x1D7D4]={d='en'},
+ [0x1D7D5]={d='en'},
+ [0x1D7D6]={d='en'},
+ [0x1D7D7]={d='en'},
+ [0x1D7D8]={d='en'},
+ [0x1D7D9]={d='en'},
+ [0x1D7DA]={d='en'},
+ [0x1D7DB]={d='en'},
+ [0x1D7DC]={d='en'},
+ [0x1D7DD]={d='en'},
+ [0x1D7DE]={d='en'},
+ [0x1D7DF]={d='en'},
+ [0x1D7E0]={d='en'},
+ [0x1D7E1]={d='en'},
+ [0x1D7E2]={d='en'},
+ [0x1D7E3]={d='en'},
+ [0x1D7E4]={d='en'},
+ [0x1D7E5]={d='en'},
+ [0x1D7E6]={d='en'},
+ [0x1D7E7]={d='en'},
+ [0x1D7E8]={d='en'},
+ [0x1D7E9]={d='en'},
+ [0x1D7EA]={d='en'},
+ [0x1D7EB]={d='en'},
+ [0x1D7EC]={d='en'},
+ [0x1D7ED]={d='en'},
+ [0x1D7EE]={d='en'},
+ [0x1D7EF]={d='en'},
+ [0x1D7F0]={d='en'},
+ [0x1D7F1]={d='en'},
+ [0x1D7F2]={d='en'},
+ [0x1D7F3]={d='en'},
+ [0x1D7F4]={d='en'},
+ [0x1D7F5]={d='en'},
+ [0x1D7F6]={d='en'},
+ [0x1D7F7]={d='en'},
+ [0x1D7F8]={d='en'},
+ [0x1D7F9]={d='en'},
+ [0x1D7FA]={d='en'},
+ [0x1D7FB]={d='en'},
+ [0x1D7FC]={d='en'},
+ [0x1D7FD]={d='en'},
+ [0x1D7FE]={d='en'},
+ [0x1D7FF]={d='en'},
+ [0x1DA00]={d='nsm'},
+ [0x1DA01]={d='nsm'},
+ [0x1DA02]={d='nsm'},
+ [0x1DA03]={d='nsm'},
+ [0x1DA04]={d='nsm'},
+ [0x1DA05]={d='nsm'},
+ [0x1DA06]={d='nsm'},
+ [0x1DA07]={d='nsm'},
+ [0x1DA08]={d='nsm'},
+ [0x1DA09]={d='nsm'},
+ [0x1DA0A]={d='nsm'},
+ [0x1DA0B]={d='nsm'},
+ [0x1DA0C]={d='nsm'},
+ [0x1DA0D]={d='nsm'},
+ [0x1DA0E]={d='nsm'},
+ [0x1DA0F]={d='nsm'},
+ [0x1DA10]={d='nsm'},
+ [0x1DA11]={d='nsm'},
+ [0x1DA12]={d='nsm'},
+ [0x1DA13]={d='nsm'},
+ [0x1DA14]={d='nsm'},
+ [0x1DA15]={d='nsm'},
+ [0x1DA16]={d='nsm'},
+ [0x1DA17]={d='nsm'},
+ [0x1DA18]={d='nsm'},
+ [0x1DA19]={d='nsm'},
+ [0x1DA1A]={d='nsm'},
+ [0x1DA1B]={d='nsm'},
+ [0x1DA1C]={d='nsm'},
+ [0x1DA1D]={d='nsm'},
+ [0x1DA1E]={d='nsm'},
+ [0x1DA1F]={d='nsm'},
+ [0x1DA20]={d='nsm'},
+ [0x1DA21]={d='nsm'},
+ [0x1DA22]={d='nsm'},
+ [0x1DA23]={d='nsm'},
+ [0x1DA24]={d='nsm'},
+ [0x1DA25]={d='nsm'},
+ [0x1DA26]={d='nsm'},
+ [0x1DA27]={d='nsm'},
+ [0x1DA28]={d='nsm'},
+ [0x1DA29]={d='nsm'},
+ [0x1DA2A]={d='nsm'},
+ [0x1DA2B]={d='nsm'},
+ [0x1DA2C]={d='nsm'},
+ [0x1DA2D]={d='nsm'},
+ [0x1DA2E]={d='nsm'},
+ [0x1DA2F]={d='nsm'},
+ [0x1DA30]={d='nsm'},
+ [0x1DA31]={d='nsm'},
+ [0x1DA32]={d='nsm'},
+ [0x1DA33]={d='nsm'},
+ [0x1DA34]={d='nsm'},
+ [0x1DA35]={d='nsm'},
+ [0x1DA36]={d='nsm'},
+ [0x1DA3B]={d='nsm'},
+ [0x1DA3C]={d='nsm'},
+ [0x1DA3D]={d='nsm'},
+ [0x1DA3E]={d='nsm'},
+ [0x1DA3F]={d='nsm'},
+ [0x1DA40]={d='nsm'},
+ [0x1DA41]={d='nsm'},
+ [0x1DA42]={d='nsm'},
+ [0x1DA43]={d='nsm'},
+ [0x1DA44]={d='nsm'},
+ [0x1DA45]={d='nsm'},
+ [0x1DA46]={d='nsm'},
+ [0x1DA47]={d='nsm'},
+ [0x1DA48]={d='nsm'},
+ [0x1DA49]={d='nsm'},
+ [0x1DA4A]={d='nsm'},
+ [0x1DA4B]={d='nsm'},
+ [0x1DA4C]={d='nsm'},
+ [0x1DA4D]={d='nsm'},
+ [0x1DA4E]={d='nsm'},
+ [0x1DA4F]={d='nsm'},
+ [0x1DA50]={d='nsm'},
+ [0x1DA51]={d='nsm'},
+ [0x1DA52]={d='nsm'},
+ [0x1DA53]={d='nsm'},
+ [0x1DA54]={d='nsm'},
+ [0x1DA55]={d='nsm'},
+ [0x1DA56]={d='nsm'},
+ [0x1DA57]={d='nsm'},
+ [0x1DA58]={d='nsm'},
+ [0x1DA59]={d='nsm'},
+ [0x1DA5A]={d='nsm'},
+ [0x1DA5B]={d='nsm'},
+ [0x1DA5C]={d='nsm'},
+ [0x1DA5D]={d='nsm'},
+ [0x1DA5E]={d='nsm'},
+ [0x1DA5F]={d='nsm'},
+ [0x1DA60]={d='nsm'},
+ [0x1DA61]={d='nsm'},
+ [0x1DA62]={d='nsm'},
+ [0x1DA63]={d='nsm'},
+ [0x1DA64]={d='nsm'},
+ [0x1DA65]={d='nsm'},
+ [0x1DA66]={d='nsm'},
+ [0x1DA67]={d='nsm'},
+ [0x1DA68]={d='nsm'},
+ [0x1DA69]={d='nsm'},
+ [0x1DA6A]={d='nsm'},
+ [0x1DA6B]={d='nsm'},
+ [0x1DA6C]={d='nsm'},
+ [0x1DA75]={d='nsm'},
+ [0x1DA84]={d='nsm'},
+ [0x1DA9B]={d='nsm'},
+ [0x1DA9C]={d='nsm'},
+ [0x1DA9D]={d='nsm'},
+ [0x1DA9E]={d='nsm'},
+ [0x1DA9F]={d='nsm'},
+ [0x1DAA1]={d='nsm'},
+ [0x1DAA2]={d='nsm'},
+ [0x1DAA3]={d='nsm'},
+ [0x1DAA4]={d='nsm'},
+ [0x1DAA5]={d='nsm'},
+ [0x1DAA6]={d='nsm'},
+ [0x1DAA7]={d='nsm'},
+ [0x1DAA8]={d='nsm'},
+ [0x1DAA9]={d='nsm'},
+ [0x1DAAA]={d='nsm'},
+ [0x1DAAB]={d='nsm'},
+ [0x1DAAC]={d='nsm'},
+ [0x1DAAD]={d='nsm'},
+ [0x1DAAE]={d='nsm'},
+ [0x1DAAF]={d='nsm'},
+ [0x1E000]={d='nsm'},
+ [0x1E001]={d='nsm'},
+ [0x1E002]={d='nsm'},
+ [0x1E003]={d='nsm'},
+ [0x1E004]={d='nsm'},
+ [0x1E005]={d='nsm'},
+ [0x1E006]={d='nsm'},
+ [0x1E008]={d='nsm'},
+ [0x1E009]={d='nsm'},
+ [0x1E00A]={d='nsm'},
+ [0x1E00B]={d='nsm'},
+ [0x1E00C]={d='nsm'},
+ [0x1E00D]={d='nsm'},
+ [0x1E00E]={d='nsm'},
+ [0x1E00F]={d='nsm'},
+ [0x1E010]={d='nsm'},
+ [0x1E011]={d='nsm'},
+ [0x1E012]={d='nsm'},
+ [0x1E013]={d='nsm'},
+ [0x1E014]={d='nsm'},
+ [0x1E015]={d='nsm'},
+ [0x1E016]={d='nsm'},
+ [0x1E017]={d='nsm'},
+ [0x1E018]={d='nsm'},
+ [0x1E01B]={d='nsm'},
+ [0x1E01C]={d='nsm'},
+ [0x1E01D]={d='nsm'},
+ [0x1E01E]={d='nsm'},
+ [0x1E01F]={d='nsm'},
+ [0x1E020]={d='nsm'},
+ [0x1E021]={d='nsm'},
+ [0x1E023]={d='nsm'},
+ [0x1E024]={d='nsm'},
+ [0x1E026]={d='nsm'},
+ [0x1E027]={d='nsm'},
+ [0x1E028]={d='nsm'},
+ [0x1E029]={d='nsm'},
+ [0x1E02A]={d='nsm'},
+ [0x1E8D0]={d='nsm'},
+ [0x1E8D1]={d='nsm'},
+ [0x1E8D2]={d='nsm'},
+ [0x1E8D3]={d='nsm'},
+ [0x1E8D4]={d='nsm'},
+ [0x1E8D5]={d='nsm'},
+ [0x1E8D6]={d='nsm'},
+ [0x1E944]={d='nsm'},
+ [0x1E945]={d='nsm'},
+ [0x1E946]={d='nsm'},
+ [0x1E947]={d='nsm'},
+ [0x1E948]={d='nsm'},
+ [0x1E949]={d='nsm'},
+ [0x1E94A]={d='nsm'},
+ [0x1EE00]={d='al'},
+ [0x1EE01]={d='al'},
+ [0x1EE02]={d='al'},
+ [0x1EE03]={d='al'},
+ [0x1EE05]={d='al'},
+ [0x1EE06]={d='al'},
+ [0x1EE07]={d='al'},
+ [0x1EE08]={d='al'},
+ [0x1EE09]={d='al'},
+ [0x1EE0A]={d='al'},
+ [0x1EE0B]={d='al'},
+ [0x1EE0C]={d='al'},
+ [0x1EE0D]={d='al'},
+ [0x1EE0E]={d='al'},
+ [0x1EE0F]={d='al'},
+ [0x1EE10]={d='al'},
+ [0x1EE11]={d='al'},
+ [0x1EE12]={d='al'},
+ [0x1EE13]={d='al'},
+ [0x1EE14]={d='al'},
+ [0x1EE15]={d='al'},
+ [0x1EE16]={d='al'},
+ [0x1EE17]={d='al'},
+ [0x1EE18]={d='al'},
+ [0x1EE19]={d='al'},
+ [0x1EE1A]={d='al'},
+ [0x1EE1B]={d='al'},
+ [0x1EE1C]={d='al'},
+ [0x1EE1D]={d='al'},
+ [0x1EE1E]={d='al'},
+ [0x1EE1F]={d='al'},
+ [0x1EE21]={d='al'},
+ [0x1EE22]={d='al'},
+ [0x1EE24]={d='al'},
+ [0x1EE27]={d='al'},
+ [0x1EE29]={d='al'},
+ [0x1EE2A]={d='al'},
+ [0x1EE2B]={d='al'},
+ [0x1EE2C]={d='al'},
+ [0x1EE2D]={d='al'},
+ [0x1EE2E]={d='al'},
+ [0x1EE2F]={d='al'},
+ [0x1EE30]={d='al'},
+ [0x1EE31]={d='al'},
+ [0x1EE32]={d='al'},
+ [0x1EE34]={d='al'},
+ [0x1EE35]={d='al'},
+ [0x1EE36]={d='al'},
+ [0x1EE37]={d='al'},
+ [0x1EE39]={d='al'},
+ [0x1EE3B]={d='al'},
+ [0x1EE42]={d='al'},
+ [0x1EE47]={d='al'},
+ [0x1EE49]={d='al'},
+ [0x1EE4B]={d='al'},
+ [0x1EE4D]={d='al'},
+ [0x1EE4E]={d='al'},
+ [0x1EE4F]={d='al'},
+ [0x1EE51]={d='al'},
+ [0x1EE52]={d='al'},
+ [0x1EE54]={d='al'},
+ [0x1EE57]={d='al'},
+ [0x1EE59]={d='al'},
+ [0x1EE5B]={d='al'},
+ [0x1EE5D]={d='al'},
+ [0x1EE5F]={d='al'},
+ [0x1EE61]={d='al'},
+ [0x1EE62]={d='al'},
+ [0x1EE64]={d='al'},
+ [0x1EE67]={d='al'},
+ [0x1EE68]={d='al'},
+ [0x1EE69]={d='al'},
+ [0x1EE6A]={d='al'},
+ [0x1EE6C]={d='al'},
+ [0x1EE6D]={d='al'},
+ [0x1EE6E]={d='al'},
+ [0x1EE6F]={d='al'},
+ [0x1EE70]={d='al'},
+ [0x1EE71]={d='al'},
+ [0x1EE72]={d='al'},
+ [0x1EE74]={d='al'},
+ [0x1EE75]={d='al'},
+ [0x1EE76]={d='al'},
+ [0x1EE77]={d='al'},
+ [0x1EE79]={d='al'},
+ [0x1EE7A]={d='al'},
+ [0x1EE7B]={d='al'},
+ [0x1EE7C]={d='al'},
+ [0x1EE7E]={d='al'},
+ [0x1EE80]={d='al'},
+ [0x1EE81]={d='al'},
+ [0x1EE82]={d='al'},
+ [0x1EE83]={d='al'},
+ [0x1EE84]={d='al'},
+ [0x1EE85]={d='al'},
+ [0x1EE86]={d='al'},
+ [0x1EE87]={d='al'},
+ [0x1EE88]={d='al'},
+ [0x1EE89]={d='al'},
+ [0x1EE8B]={d='al'},
+ [0x1EE8C]={d='al'},
+ [0x1EE8D]={d='al'},
+ [0x1EE8E]={d='al'},
+ [0x1EE8F]={d='al'},
+ [0x1EE90]={d='al'},
+ [0x1EE91]={d='al'},
+ [0x1EE92]={d='al'},
+ [0x1EE93]={d='al'},
+ [0x1EE94]={d='al'},
+ [0x1EE95]={d='al'},
+ [0x1EE96]={d='al'},
+ [0x1EE97]={d='al'},
+ [0x1EE98]={d='al'},
+ [0x1EE99]={d='al'},
+ [0x1EE9A]={d='al'},
+ [0x1EE9B]={d='al'},
+ [0x1EEA1]={d='al'},
+ [0x1EEA2]={d='al'},
+ [0x1EEA3]={d='al'},
+ [0x1EEA5]={d='al'},
+ [0x1EEA6]={d='al'},
+ [0x1EEA7]={d='al'},
+ [0x1EEA8]={d='al'},
+ [0x1EEA9]={d='al'},
+ [0x1EEAB]={d='al'},
+ [0x1EEAC]={d='al'},
+ [0x1EEAD]={d='al'},
+ [0x1EEAE]={d='al'},
+ [0x1EEAF]={d='al'},
+ [0x1EEB0]={d='al'},
+ [0x1EEB1]={d='al'},
+ [0x1EEB2]={d='al'},
+ [0x1EEB3]={d='al'},
+ [0x1EEB4]={d='al'},
+ [0x1EEB5]={d='al'},
+ [0x1EEB6]={d='al'},
+ [0x1EEB7]={d='al'},
+ [0x1EEB8]={d='al'},
+ [0x1EEB9]={d='al'},
+ [0x1EEBA]={d='al'},
+ [0x1EEBB]={d='al'},
+ [0x1EEF0]={d='on'},
+ [0x1EEF1]={d='on'},
+ [0x1F000]={d='on'},
+ [0x1F001]={d='on'},
+ [0x1F002]={d='on'},
+ [0x1F003]={d='on'},
+ [0x1F004]={d='on'},
+ [0x1F005]={d='on'},
+ [0x1F006]={d='on'},
+ [0x1F007]={d='on'},
+ [0x1F008]={d='on'},
+ [0x1F009]={d='on'},
+ [0x1F00A]={d='on'},
+ [0x1F00B]={d='on'},
+ [0x1F00C]={d='on'},
+ [0x1F00D]={d='on'},
+ [0x1F00E]={d='on'},
+ [0x1F00F]={d='on'},
+ [0x1F010]={d='on'},
+ [0x1F011]={d='on'},
+ [0x1F012]={d='on'},
+ [0x1F013]={d='on'},
+ [0x1F014]={d='on'},
+ [0x1F015]={d='on'},
+ [0x1F016]={d='on'},
+ [0x1F017]={d='on'},
+ [0x1F018]={d='on'},
+ [0x1F019]={d='on'},
+ [0x1F01A]={d='on'},
+ [0x1F01B]={d='on'},
+ [0x1F01C]={d='on'},
+ [0x1F01D]={d='on'},
+ [0x1F01E]={d='on'},
+ [0x1F01F]={d='on'},
+ [0x1F020]={d='on'},
+ [0x1F021]={d='on'},
+ [0x1F022]={d='on'},
+ [0x1F023]={d='on'},
+ [0x1F024]={d='on'},
+ [0x1F025]={d='on'},
+ [0x1F026]={d='on'},
+ [0x1F027]={d='on'},
+ [0x1F028]={d='on'},
+ [0x1F029]={d='on'},
+ [0x1F02A]={d='on'},
+ [0x1F02B]={d='on'},
+ [0x1F030]={d='on'},
+ [0x1F031]={d='on'},
+ [0x1F032]={d='on'},
+ [0x1F033]={d='on'},
+ [0x1F034]={d='on'},
+ [0x1F035]={d='on'},
+ [0x1F036]={d='on'},
+ [0x1F037]={d='on'},
+ [0x1F038]={d='on'},
+ [0x1F039]={d='on'},
+ [0x1F03A]={d='on'},
+ [0x1F03B]={d='on'},
+ [0x1F03C]={d='on'},
+ [0x1F03D]={d='on'},
+ [0x1F03E]={d='on'},
+ [0x1F03F]={d='on'},
+ [0x1F040]={d='on'},
+ [0x1F041]={d='on'},
+ [0x1F042]={d='on'},
+ [0x1F043]={d='on'},
+ [0x1F044]={d='on'},
+ [0x1F045]={d='on'},
+ [0x1F046]={d='on'},
+ [0x1F047]={d='on'},
+ [0x1F048]={d='on'},
+ [0x1F049]={d='on'},
+ [0x1F04A]={d='on'},
+ [0x1F04B]={d='on'},
+ [0x1F04C]={d='on'},
+ [0x1F04D]={d='on'},
+ [0x1F04E]={d='on'},
+ [0x1F04F]={d='on'},
+ [0x1F050]={d='on'},
+ [0x1F051]={d='on'},
+ [0x1F052]={d='on'},
+ [0x1F053]={d='on'},
+ [0x1F054]={d='on'},
+ [0x1F055]={d='on'},
+ [0x1F056]={d='on'},
+ [0x1F057]={d='on'},
+ [0x1F058]={d='on'},
+ [0x1F059]={d='on'},
+ [0x1F05A]={d='on'},
+ [0x1F05B]={d='on'},
+ [0x1F05C]={d='on'},
+ [0x1F05D]={d='on'},
+ [0x1F05E]={d='on'},
+ [0x1F05F]={d='on'},
+ [0x1F060]={d='on'},
+ [0x1F061]={d='on'},
+ [0x1F062]={d='on'},
+ [0x1F063]={d='on'},
+ [0x1F064]={d='on'},
+ [0x1F065]={d='on'},
+ [0x1F066]={d='on'},
+ [0x1F067]={d='on'},
+ [0x1F068]={d='on'},
+ [0x1F069]={d='on'},
+ [0x1F06A]={d='on'},
+ [0x1F06B]={d='on'},
+ [0x1F06C]={d='on'},
+ [0x1F06D]={d='on'},
+ [0x1F06E]={d='on'},
+ [0x1F06F]={d='on'},
+ [0x1F070]={d='on'},
+ [0x1F071]={d='on'},
+ [0x1F072]={d='on'},
+ [0x1F073]={d='on'},
+ [0x1F074]={d='on'},
+ [0x1F075]={d='on'},
+ [0x1F076]={d='on'},
+ [0x1F077]={d='on'},
+ [0x1F078]={d='on'},
+ [0x1F079]={d='on'},
+ [0x1F07A]={d='on'},
+ [0x1F07B]={d='on'},
+ [0x1F07C]={d='on'},
+ [0x1F07D]={d='on'},
+ [0x1F07E]={d='on'},
+ [0x1F07F]={d='on'},
+ [0x1F080]={d='on'},
+ [0x1F081]={d='on'},
+ [0x1F082]={d='on'},
+ [0x1F083]={d='on'},
+ [0x1F084]={d='on'},
+ [0x1F085]={d='on'},
+ [0x1F086]={d='on'},
+ [0x1F087]={d='on'},
+ [0x1F088]={d='on'},
+ [0x1F089]={d='on'},
+ [0x1F08A]={d='on'},
+ [0x1F08B]={d='on'},
+ [0x1F08C]={d='on'},
+ [0x1F08D]={d='on'},
+ [0x1F08E]={d='on'},
+ [0x1F08F]={d='on'},
+ [0x1F090]={d='on'},
+ [0x1F091]={d='on'},
+ [0x1F092]={d='on'},
+ [0x1F093]={d='on'},
+ [0x1F0A0]={d='on'},
+ [0x1F0A1]={d='on'},
+ [0x1F0A2]={d='on'},
+ [0x1F0A3]={d='on'},
+ [0x1F0A4]={d='on'},
+ [0x1F0A5]={d='on'},
+ [0x1F0A6]={d='on'},
+ [0x1F0A7]={d='on'},
+ [0x1F0A8]={d='on'},
+ [0x1F0A9]={d='on'},
+ [0x1F0AA]={d='on'},
+ [0x1F0AB]={d='on'},
+ [0x1F0AC]={d='on'},
+ [0x1F0AD]={d='on'},
+ [0x1F0AE]={d='on'},
+ [0x1F0B1]={d='on'},
+ [0x1F0B2]={d='on'},
+ [0x1F0B3]={d='on'},
+ [0x1F0B4]={d='on'},
+ [0x1F0B5]={d='on'},
+ [0x1F0B6]={d='on'},
+ [0x1F0B7]={d='on'},
+ [0x1F0B8]={d='on'},
+ [0x1F0B9]={d='on'},
+ [0x1F0BA]={d='on'},
+ [0x1F0BB]={d='on'},
+ [0x1F0BC]={d='on'},
+ [0x1F0BD]={d='on'},
+ [0x1F0BE]={d='on'},
+ [0x1F0BF]={d='on'},
+ [0x1F0C1]={d='on'},
+ [0x1F0C2]={d='on'},
+ [0x1F0C3]={d='on'},
+ [0x1F0C4]={d='on'},
+ [0x1F0C5]={d='on'},
+ [0x1F0C6]={d='on'},
+ [0x1F0C7]={d='on'},
+ [0x1F0C8]={d='on'},
+ [0x1F0C9]={d='on'},
+ [0x1F0CA]={d='on'},
+ [0x1F0CB]={d='on'},
+ [0x1F0CC]={d='on'},
+ [0x1F0CD]={d='on'},
+ [0x1F0CE]={d='on'},
+ [0x1F0CF]={d='on'},
+ [0x1F0D1]={d='on'},
+ [0x1F0D2]={d='on'},
+ [0x1F0D3]={d='on'},
+ [0x1F0D4]={d='on'},
+ [0x1F0D5]={d='on'},
+ [0x1F0D6]={d='on'},
+ [0x1F0D7]={d='on'},
+ [0x1F0D8]={d='on'},
+ [0x1F0D9]={d='on'},
+ [0x1F0DA]={d='on'},
+ [0x1F0DB]={d='on'},
+ [0x1F0DC]={d='on'},
+ [0x1F0DD]={d='on'},
+ [0x1F0DE]={d='on'},
+ [0x1F0DF]={d='on'},
+ [0x1F0E0]={d='on'},
+ [0x1F0E1]={d='on'},
+ [0x1F0E2]={d='on'},
+ [0x1F0E3]={d='on'},
+ [0x1F0E4]={d='on'},
+ [0x1F0E5]={d='on'},
+ [0x1F0E6]={d='on'},
+ [0x1F0E7]={d='on'},
+ [0x1F0E8]={d='on'},
+ [0x1F0E9]={d='on'},
+ [0x1F0EA]={d='on'},
+ [0x1F0EB]={d='on'},
+ [0x1F0EC]={d='on'},
+ [0x1F0ED]={d='on'},
+ [0x1F0EE]={d='on'},
+ [0x1F0EF]={d='on'},
+ [0x1F0F0]={d='on'},
+ [0x1F0F1]={d='on'},
+ [0x1F0F2]={d='on'},
+ [0x1F0F3]={d='on'},
+ [0x1F0F4]={d='on'},
+ [0x1F0F5]={d='on'},
+ [0x1F100]={d='en'},
+ [0x1F101]={d='en'},
+ [0x1F102]={d='en'},
+ [0x1F103]={d='en'},
+ [0x1F104]={d='en'},
+ [0x1F105]={d='en'},
+ [0x1F106]={d='en'},
+ [0x1F107]={d='en'},
+ [0x1F108]={d='en'},
+ [0x1F109]={d='en'},
+ [0x1F10A]={d='en'},
+ [0x1F10B]={d='on'},
+ [0x1F10C]={d='on'},
+ [0x1F16A]={d='on'},
+ [0x1F16B]={d='on'},
+ [0xE0001]={d='bn'},
+ [0xE0020]={d='bn'},
+ [0xE0021]={d='bn'},
+ [0xE0022]={d='bn'},
+ [0xE0023]={d='bn'},
+ [0xE0024]={d='bn'},
+ [0xE0025]={d='bn'},
+ [0xE0026]={d='bn'},
+ [0xE0027]={d='bn'},
+ [0xE0028]={d='bn'},
+ [0xE0029]={d='bn'},
+ [0xE002A]={d='bn'},
+ [0xE002B]={d='bn'},
+ [0xE002C]={d='bn'},
+ [0xE002D]={d='bn'},
+ [0xE002E]={d='bn'},
+ [0xE002F]={d='bn'},
+ [0xE0030]={d='bn'},
+ [0xE0031]={d='bn'},
+ [0xE0032]={d='bn'},
+ [0xE0033]={d='bn'},
+ [0xE0034]={d='bn'},
+ [0xE0035]={d='bn'},
+ [0xE0036]={d='bn'},
+ [0xE0037]={d='bn'},
+ [0xE0038]={d='bn'},
+ [0xE0039]={d='bn'},
+ [0xE003A]={d='bn'},
+ [0xE003B]={d='bn'},
+ [0xE003C]={d='bn'},
+ [0xE003D]={d='bn'},
+ [0xE003E]={d='bn'},
+ [0xE003F]={d='bn'},
+ [0xE0040]={d='bn'},
+ [0xE0041]={d='bn'},
+ [0xE0042]={d='bn'},
+ [0xE0043]={d='bn'},
+ [0xE0044]={d='bn'},
+ [0xE0045]={d='bn'},
+ [0xE0046]={d='bn'},
+ [0xE0047]={d='bn'},
+ [0xE0048]={d='bn'},
+ [0xE0049]={d='bn'},
+ [0xE004A]={d='bn'},
+ [0xE004B]={d='bn'},
+ [0xE004C]={d='bn'},
+ [0xE004D]={d='bn'},
+ [0xE004E]={d='bn'},
+ [0xE004F]={d='bn'},
+ [0xE0050]={d='bn'},
+ [0xE0051]={d='bn'},
+ [0xE0052]={d='bn'},
+ [0xE0053]={d='bn'},
+ [0xE0054]={d='bn'},
+ [0xE0055]={d='bn'},
+ [0xE0056]={d='bn'},
+ [0xE0057]={d='bn'},
+ [0xE0058]={d='bn'},
+ [0xE0059]={d='bn'},
+ [0xE005A]={d='bn'},
+ [0xE005B]={d='bn'},
+ [0xE005C]={d='bn'},
+ [0xE005D]={d='bn'},
+ [0xE005E]={d='bn'},
+ [0xE005F]={d='bn'},
+ [0xE0060]={d='bn'},
+ [0xE0061]={d='bn'},
+ [0xE0062]={d='bn'},
+ [0xE0063]={d='bn'},
+ [0xE0064]={d='bn'},
+ [0xE0065]={d='bn'},
+ [0xE0066]={d='bn'},
+ [0xE0067]={d='bn'},
+ [0xE0068]={d='bn'},
+ [0xE0069]={d='bn'},
+ [0xE006A]={d='bn'},
+ [0xE006B]={d='bn'},
+ [0xE006C]={d='bn'},
+ [0xE006D]={d='bn'},
+ [0xE006E]={d='bn'},
+ [0xE006F]={d='bn'},
+ [0xE0070]={d='bn'},
+ [0xE0071]={d='bn'},
+ [0xE0072]={d='bn'},
+ [0xE0073]={d='bn'},
+ [0xE0074]={d='bn'},
+ [0xE0075]={d='bn'},
+ [0xE0076]={d='bn'},
+ [0xE0077]={d='bn'},
+ [0xE0078]={d='bn'},
+ [0xE0079]={d='bn'},
+ [0xE007A]={d='bn'},
+ [0xE007B]={d='bn'},
+ [0xE007C]={d='bn'},
+ [0xE007D]={d='bn'},
+ [0xE007E]={d='bn'},
+ [0xE007F]={d='bn'}
+}
+%</bididata>
+% \end{macrocode}
+%\fi
+%
+% Now the |basic-r| bidi mode. One of the aims is to implement a fast
+% and simple bidi algorithm, with a single loop. I managed to do it
+% for R texts, with a second smaller loop for a special case. The code
+% is still somewhat chaotic, but its behavior is essentially
+% correct. I cannot resist copying the following text from
+% \textsf{Emacs} |bidi.c| (which also attempts to implement the bidi
+% algorithm with a single loop):
+%
+% \begin{quote}
+% Arrrgh!! The UAX\#9 algorithm is too deeply entrenched in the
+% assumption of batch-style processing [...]. May the fleas of a
+% thousand camels infest the armpits of those who design supposedly
+% general-purpose algorithms by looking at their own
+% implementations, and fail to consider other possible
+% implementations!
+% \end{quote}
+%
+% Well, it took me some time to guess what the batch rules in UAX\#9
+% actually mean (in other word, \textit{what} they do and\textit{why},
+% and not only \textit{how}), but I think (or I hope) I've managed to
+% understand them.
+%
+% In some sense, there are two bidi modes, one for numbers, and the
+% other for text. Furthermore, setting just the direction in R text
+% is not enough, because there are actually \textit{two} R modes (set
+% explicitly in Unicode with RLM and ALM). In \babel{} the dir is set
+% by a higher protocol based on the language/script, which in turn
+% sets the correct dir (<l>, <r> or <al>).
+%
+% From UAX\#9: “Where available, markup should be used instead of the
+% explicit formatting charactersâ€. So, this simple version just
+% ignores formatting characters. Actually, most of that annex is
+% devoted to how to handle them.
+%
+% BD14-BD16 are not implemented. Unicode (and the W3C) are making a
+% great effort to deal with some special problematic cases in
+% “streamed†plain text. I don't think this is the way to go --
+% particular issues should be fixed by a high level interface taking
+% into account the needs of the document. And here is where \luatex{}
+% excels, because everything related to bidi writing is under our
+% control.
+%
+% \changes{babel~3.20}{2018/05/01}{Adapted to exhyphens in luatex >=
+% 1.07. Fix - now attr@dir is mod 3.}
+% \changes{babel~3.30}{2019/04/22}{Switch to enable/disable bidi.}
+%
+% \begin{macrocode}
+%<*basic-r>
+Babel = Babel or {}
+
+Babel.bidi_enabled = true
+
+require('babel-data-bidi.lua')
+
+local characters = Babel.characters
+local ranges = Babel.ranges
+
+local DIR = node.id("dir")
+
+local function dir_mark(head, from, to, outer)
+ dir = (outer == 'r') and 'TLT' or 'TRT' -- ie, reverse
+ local d = node.new(DIR)
+ d.dir = '+' .. dir
+ node.insert_before(head, from, d)
+ d = node.new(DIR)
+ d.dir = '-' .. dir
+ node.insert_after(head, to, d)
+end
+
+function Babel.bidi(head, ispar)
+ local first_n, last_n -- first and last char with nums
+ local last_es -- an auxiliary 'last' used with nums
+ local first_d, last_d -- first and last char in L/R block
+ local dir, dir_real
+% \end{macrocode}
+%
+% Next also depends on script/lang (<al>/<r>). To be set by
+% babel. |tex.pardir| is dangerous, could be (re)set but it
+% should be changed only in vmode. There are two strong's --
+% |strong| = l/al/r and |strong_lr| = l/r (there must be a better
+% way):
+%
+% \begin{macrocode}
+ local strong = ('TRT' == tex.pardir) and 'r' or 'l'
+ local strong_lr = (strong == 'l') and 'l' or 'r'
+ local outer = strong
+
+ local new_dir = false
+ local first_dir = false
+ local inmath = false
+
+ local last_lr
+
+ local type_n = ''
+
+ for item in node.traverse(head) do
+
+ -- three cases: glyph, dir, otherwise
+ if item.id == node.id'glyph'
+ or (item.id == 7 and item.subtype == 2) then
+
+ local itemchar
+ if item.id == 7 and item.subtype == 2 then
+ itemchar = item.replace.char
+ else
+ itemchar = item.char
+ end
+ local chardata = characters[itemchar]
+ dir = chardata and chardata.d or nil
+ if not dir then
+ for nn, et in ipairs(ranges) do
+ if itemchar < et[1] then
+ break
+ elseif itemchar <= et[2] then
+ dir = et[3]
+ break
+ end
+ end
+ end
+ dir = dir or 'l'
+ if inmath then dir = ('TRT' == tex.mathdir) and 'r' or 'l' end
+% \end{macrocode}
+%
+% Next is based on the assumption babel sets the language AND
+% switches the script with its dir. We treat a language block as
+% a separate Unicode sequence. The following piece of code is
+% executed at the first glyph after a `dir' node. We don't know
+% the current language until then. This is not exactly true, as
+% the math mode may insert explicit dirs in the node list, so, for
+% the moment there is a hack by brute force (just above).
+%
+% \begin{macrocode}
+ if new_dir then
+ attr_dir = 0
+ for at in node.traverse(item.attr) do
+ if at.number == luatexbase.registernumber'bbl@attr@dir' then
+ attr_dir = at.value % 3
+ end
+ end
+ if attr_dir == 1 then
+ strong = 'r'
+ elseif attr_dir == 2 then
+ strong = 'al'
+ else
+ strong = 'l'
+ end
+ strong_lr = (strong == 'l') and 'l' or 'r'
+ outer = strong_lr
+ new_dir = false
+ end
+
+ if dir == 'nsm' then dir = strong end -- W1
+% \end{macrocode}
+%
+% \textbf{Numbers.} The dual <al>/<r> system for R is somewhat
+% cumbersome.
+%
+% \begin{macrocode}
+ dir_real = dir -- We need dir_real to set strong below
+ if dir == 'al' then dir = 'r' end -- W3
+% \end{macrocode}
+%
+% By W2, there are no <en> <et> <es> if |strong == <al>|, only
+% <an>. Therefore, there are not <et en> nor <en et>, W5 can be
+% ignored, and W6 applied:
+%
+% \begin{macrocode}
+ if strong == 'al' then
+ if dir == 'en' then dir = 'an' end -- W2
+ if dir == 'et' or dir == 'es' then dir = 'on' end -- W6
+ strong_lr = 'r' -- W3
+ end
+% \end{macrocode}
+%
+% Once finished the basic setup for glyphs, consider the two other
+% cases: dir node and the rest.
+%
+% \begin{macrocode}
+ elseif item.id == node.id'dir' and not inmath then
+ new_dir = true
+ dir = nil
+ elseif item.id == node.id'math' then
+ inmath = (item.subtype == 0)
+ else
+ dir = nil -- Not a char
+ end
+% \end{macrocode}
+%
+% Numbers in R mode. A sequence of <en>, <et>, <an>, <es> and <cs> is
+% typeset (with some rules) in L mode. We store the starting and
+% ending points, and only when anything different is found (including
+% nil, ie, a non-char), the textdir is set. This means you cannot
+% insert, say, a whatsit, but this is what I would expect (with
+% \textsf{luacolor} you may colorize some digits). Anyway, this
+% behavior could be changed with a switch in the future. Note in the
+% first branch only <an> is relevant if <al>.
+%
+% \begin{macrocode}
+ if dir == 'en' or dir == 'an' or dir == 'et' then
+ if dir ~= 'et' then
+ type_n = dir
+ end
+ first_n = first_n or item
+ last_n = last_es or item
+ last_es = nil
+ elseif dir == 'es' and last_n then -- W3+W6
+ last_es = item
+ elseif dir == 'cs' then -- it's right - do nothing
+ elseif first_n then -- & if dir = any but en, et, an, es, cs, inc nil
+ if strong_lr == 'r' and type_n ~= '' then
+ dir_mark(head, first_n, last_n, 'r')
+ elseif strong_lr == 'l' and first_d and type_n == 'an' then
+ dir_mark(head, first_n, last_n, 'r')
+ dir_mark(head, first_d, last_d, outer)
+ first_d, last_d = nil, nil
+ elseif strong_lr == 'l' and type_n ~= '' then
+ last_d = last_n
+ end
+ type_n = ''
+ first_n, last_n = nil, nil
+ end
+% \end{macrocode}
+%
+% R text in L, or L text in R. Order of |dir_ mark|'s are relevant: d
+% goes outside n, and therefore it's emitted after. See |dir_mark| to
+% understand why (but is the nesting actually necessary or is a flat
+% dir structure enough?). Only L, R (and AL) chars are taken into
+% account -- everything else, including spaces, whatsits, etc., are
+% ignored:
+%
+% \begin{macrocode}
+ if dir == 'l' or dir == 'r' then
+ if dir ~= outer then
+ first_d = first_d or item
+ last_d = item
+ elseif first_d and dir ~= strong_lr then
+ dir_mark(head, first_d, last_d, outer)
+ first_d, last_d = nil, nil
+ end
+ end
+% \end{macrocode}
+%
+% \textbf{Mirroring.} Each chunk of text in a certain language is
+% considered a ``closed'' sequence. If <r on r> and <l on l>, it's
+% clearly <r> and <l>, resptly, but with other combinations depends on
+% outer. From all these, we select only those resolving <on> $\to$
+% <r>. At the beginning (when |last_lr| is nil) of an R text, they are
+% mirrored directly.
+%
+% TODO - numbers in R mode are processed. It doesn't hurt, but should
+% not be done.
+%
+% \begin{macrocode}
+ if dir and not last_lr and dir ~= 'l' and outer == 'r' then
+ item.char = characters[item.char] and
+ characters[item.char].m or item.char
+ elseif (dir or new_dir) and last_lr ~= item then
+ local mir = outer .. strong_lr .. (dir or outer)
+ if mir == 'rrr' or mir == 'lrr' or mir == 'rrl' or mir == 'rlr' then
+ for ch in node.traverse(node.next(last_lr)) do
+ if ch == item then break end
+ if ch.id == node.id'glyph' then
+ ch.char = characters[ch.char].m or ch.char
+ end
+ end
+ end
+ end
+% \end{macrocode}
+%
+% Save some values for the next iteration. If the current node is
+% `dir', open a new sequence. Since dir could be changed, strong is
+% set with its real value (|dir_real|).
+%
+% \begin{macrocode}
+ if dir == 'l' or dir == 'r' then
+ last_lr = item
+ strong = dir_real -- Don't search back - best save now
+ strong_lr = (strong == 'l') and 'l' or 'r'
+ elseif new_dir then
+ last_lr = nil
+ end
+ end
+% \end{macrocode}
+%
+% Mirror the last chars if they are no directed. And make sure any
+% open block is closed, too.
+%
+% \begin{macrocode}
+ if last_lr and outer == 'r' then
+ for ch in node.traverse_id(node.id'glyph', node.next(last_lr)) do
+ ch.char = characters[ch.char].m or ch.char
+ end
+ end
+ if first_n then
+ dir_mark(head, first_n, last_n, outer)
+ end
+ if first_d then
+ dir_mark(head, first_d, last_d, outer)
+ end
+% \end{macrocode}
+%
+% In boxes, the dir node could be added before the original head, so
+% the actual head is the previous node.
+%
+% \begin{macrocode}
+ return node.prev(head) or head
+end
+%</basic-r>
+% \end{macrocode}
+%
+% And here the Lua code for |bidi=basic|:
+% \changes{babel~3.20}{2018/05/01}{Adapted to exhyphens in luatex >=
+% 1.07. Fix - nsm in mapfont (eg, Arabic vowels)}
+%
+% \begin{macrocode}
+%<*basic>
+Babel = Babel or {}
+
+-- eg, Babel.fontmap[1][<prefontid>]=<dirfontid>
+
+Babel.fontmap = Babel.fontmap or {}
+Babel.fontmap[0] = {} -- l
+Babel.fontmap[1] = {} -- r
+Babel.fontmap[2] = {} -- al/an
+
+Babel.bidi_enabled = true
+Babel.mirroring_enabled = true
+
+-- Temporary:
+
+if harf then
+ Babel.mirroring_enabled = false
+end
+
+require('babel-data-bidi.lua')
+
+local characters = Babel.characters
+local ranges = Babel.ranges
+
+local DIR = node.id('dir')
+local GLYPH = node.id('glyph')
+
+local function insert_implicit(head, state, outer)
+ local new_state = state
+ if state.sim and state.eim and state.sim ~= state.eim then
+ dir = ((outer == 'r') and 'TLT' or 'TRT') -- ie, reverse
+ local d = node.new(DIR)
+ d.dir = '+' .. dir
+ node.insert_before(head, state.sim, d)
+ local d = node.new(DIR)
+ d.dir = '-' .. dir
+ node.insert_after(head, state.eim, d)
+ end
+ new_state.sim, new_state.eim = nil, nil
+ return head, new_state
+end
+
+local function insert_numeric(head, state)
+ local new
+ local new_state = state
+ if state.san and state.ean and state.san ~= state.ean then
+ local d = node.new(DIR)
+ d.dir = '+TLT'
+ _, new = node.insert_before(head, state.san, d)
+ if state.san == state.sim then state.sim = new end
+ local d = node.new(DIR)
+ d.dir = '-TLT'
+ _, new = node.insert_after(head, state.ean, d)
+ if state.ean == state.eim then state.eim = new end
+ end
+ new_state.san, new_state.ean = nil, nil
+ return head, new_state
+end
+
+-- TODO - \hbox with an explicit dir can lead to wrong results
+-- <R \hbox dir TLT{<R>}> and <L \hbox dir TRT{<L>}>. A small attempt
+-- was s made to improve the situation, but the problem is the 3-dir
+-- model in babel/Unicode and the 2-dir model in LuaTeX don't fit
+-- well.
+
+function Babel.bidi(head, ispar, hdir)
+ local d -- d is used mainly for computations in a loop
+ local prev_d = ''
+ local new_d = false
+
+ local nodes = {}
+ local outer_first = nil
+ local inmath = false
+
+ local glue_d = nil
+ local glue_i = nil
+
+ local has_en = false
+ local first_et = nil
+
+ local ATDIR = luatexbase.registernumber'bbl@attr@dir'
+
+ local save_outer
+ local temp = node.get_attribute(head, ATDIR)
+ if temp then
+ temp = temp % 3
+ save_outer = (temp == 0 and 'l') or
+ (temp == 1 and 'r') or
+ (temp == 2 and 'al')
+ elseif ispar then -- Or error? Shouldn't happen
+ save_outer = ('TRT' == tex.pardir) and 'r' or 'l'
+ else -- Or error? Shouldn't happen
+ save_outer = ('TRT' == hdir) and 'r' or 'l'
+ end
+ -- when the callback is called, we are just _after_ the box,
+ -- and the textdir is that of the surrounding text
+ -- if not ispar and hdir ~= tex.textdir then
+ -- save_outer = ('TRT' == hdir) and 'r' or 'l'
+ -- end
+ local outer = save_outer
+ local last = outer
+ -- 'al' is only taken into account in the first, current loop
+ if save_outer == 'al' then save_outer = 'r' end
+
+ local fontmap = Babel.fontmap
+
+ for item in node.traverse(head) do
+
+ -- In what follows, #node is the last (previous) node, because the
+ -- current one is not added until we start processing the neutrals.
+
+ -- three cases: glyph, dir, otherwise
+ if item.id == GLYPH
+ or (item.id == 7 and item.subtype == 2) then
+
+ local d_font = nil
+ local item_r
+ if item.id == 7 and item.subtype == 2 then
+ item_r = item.replace -- automatic discs have just 1 glyph
+ else
+ item_r = item
+ end
+ local chardata = characters[item_r.char]
+ d = chardata and chardata.d or nil
+ if not d or d == 'nsm' then
+ for nn, et in ipairs(ranges) do
+ if item_r.char < et[1] then
+ break
+ elseif item_r.char <= et[2] then
+ if not d then d = et[3]
+ elseif d == 'nsm' then d_font = et[3]
+ end
+ break
+ end
+ end
+ end
+ d = d or 'l'
+
+ -- A short 'pause' in bidi for mapfont
+ d_font = d_font or d
+ d_font = (d_font == 'l' and 0) or
+ (d_font == 'nsm' and 0) or
+ (d_font == 'r' and 1) or
+ (d_font == 'al' and 2) or
+ (d_font == 'an' and 2) or nil
+ if d_font and fontmap and fontmap[d_font][item_r.font] then
+ item_r.font = fontmap[d_font][item_r.font]
+ end
+
+ if new_d then
+ table.insert(nodes, {nil, (outer == 'l') and 'l' or 'r', nil})
+ if inmath then
+ attr_d = 0
+ else
+ attr_d = node.get_attribute(item, ATDIR)
+ attr_d = attr_d % 3
+ end
+ if attr_d == 1 then
+ outer_first = 'r'
+ last = 'r'
+ elseif attr_d == 2 then
+ outer_first = 'r'
+ last = 'al'
+ else
+ outer_first = 'l'
+ last = 'l'
+ end
+ outer = last
+ has_en = false
+ first_et = nil
+ new_d = false
+ end
+
+ if glue_d then
+ if (d == 'l' and 'l' or 'r') ~= glue_d then
+ table.insert(nodes, {glue_i, 'on', nil})
+ end
+ glue_d = nil
+ glue_i = nil
+ end
+
+ elseif item.id == DIR then
+ d = nil
+ new_d = true
+
+ elseif item.id == node.id'glue' and item.subtype == 13 then
+ glue_d = d
+ glue_i = item
+ d = nil
+
+ elseif item.id == node.id'math' then
+ inmath = (item.subtype == 0)
+
+ else
+ d = nil
+ end
+
+ -- AL <= EN/ET/ES -- W2 + W3 + W6
+ if last == 'al' and d == 'en' then
+ d = 'an' -- W3
+ elseif last == 'al' and (d == 'et' or d == 'es') then
+ d = 'on' -- W6
+ end
+
+ -- EN + CS/ES + EN -- W4
+ if d == 'en' and #nodes >= 2 then
+ if (nodes[#nodes][2] == 'es' or nodes[#nodes][2] == 'cs')
+ and nodes[#nodes-1][2] == 'en' then
+ nodes[#nodes][2] = 'en'
+ end
+ end
+
+ -- AN + CS + AN -- W4 too, because uax9 mixes both cases
+ if d == 'an' and #nodes >= 2 then
+ if (nodes[#nodes][2] == 'cs')
+ and nodes[#nodes-1][2] == 'an' then
+ nodes[#nodes][2] = 'an'
+ end
+ end
+
+ -- ET/EN -- W5 + W7->l / W6->on
+ if d == 'et' then
+ first_et = first_et or (#nodes + 1)
+ elseif d == 'en' then
+ has_en = true
+ first_et = first_et or (#nodes + 1)
+ elseif first_et then -- d may be nil here !
+ if has_en then
+ if last == 'l' then
+ temp = 'l' -- W7
+ else
+ temp = 'en' -- W5
+ end
+ else
+ temp = 'on' -- W6
+ end
+ for e = first_et, #nodes do
+ if nodes[e][1].id == GLYPH then nodes[e][2] = temp end
+ end
+ first_et = nil
+ has_en = false
+ end
+
+ if d then
+ if d == 'al' then
+ d = 'r'
+ last = 'al'
+ elseif d == 'l' or d == 'r' then
+ last = d
+ end
+ prev_d = d
+ table.insert(nodes, {item, d, outer_first})
+ end
+
+ outer_first = nil
+
+ end
+
+ -- TODO -- repeated here in case EN/ET is the last node. Find a
+ -- better way of doing things:
+ if first_et then -- dir may be nil here !
+ if has_en then
+ if last == 'l' then
+ temp = 'l' -- W7
+ else
+ temp = 'en' -- W5
+ end
+ else
+ temp = 'on' -- W6
+ end
+ for e = first_et, #nodes do
+ if nodes[e][1].id == GLYPH then nodes[e][2] = temp end
+ end
+ end
+
+ -- dummy node, to close things
+ table.insert(nodes, {nil, (outer == 'l') and 'l' or 'r', nil})
+
+ --------------- NEUTRAL -----------------
+
+ outer = save_outer
+ last = outer
+
+ local first_on = nil
+
+ for q = 1, #nodes do
+ local item
+
+ local outer_first = nodes[q][3]
+ outer = outer_first or outer
+ last = outer_first or last
+
+ local d = nodes[q][2]
+ if d == 'an' or d == 'en' then d = 'r' end
+ if d == 'cs' or d == 'et' or d == 'es' then d = 'on' end --- W6
+
+ if d == 'on' then
+ first_on = first_on or q
+ elseif first_on then
+ if last == d then
+ temp = d
+ else
+ temp = outer
+ end
+ for r = first_on, q - 1 do
+ nodes[r][2] = temp
+ item = nodes[r][1] -- MIRRORING
+ if Babel.mirroring_enabled and item.id == GLYPH and temp == 'r' then
+ item.char = characters[item.char].m or item.char
+ end
+ end
+ first_on = nil
+ end
+
+ if d == 'r' or d == 'l' then last = d end
+ end
+
+ -------------- IMPLICIT, REORDER ----------------
+
+ outer = save_outer
+ last = outer
+
+ local state = {}
+ state.has_r = false
+
+ for q = 1, #nodes do
+
+ local item = nodes[q][1]
+
+ outer = nodes[q][3] or outer
+
+ local d = nodes[q][2]
+
+ if d == 'nsm' then d = last end -- W1
+ if d == 'en' then d = 'an' end
+ local isdir = (d == 'r' or d == 'l')
+
+ if outer == 'l' and d == 'an' then
+ state.san = state.san or item
+ state.ean = item
+ elseif state.san then
+ head, state = insert_numeric(head, state)
+ end
+
+ if outer == 'l' then
+ if d == 'an' or d == 'r' then -- im -> implicit
+ if d == 'r' then state.has_r = true end
+ state.sim = state.sim or item
+ state.eim = item
+ elseif d == 'l' and state.sim and state.has_r then
+ head, state = insert_implicit(head, state, outer)
+ elseif d == 'l' then
+ state.sim, state.eim, state.has_r = nil, nil, false
+ end
+ else
+ if d == 'an' or d == 'l' then
+ if nodes[q][3] then -- nil except after an explicit dir
+ state.sim = item -- so we move sim 'inside' the group
+ else
+ state.sim = state.sim or item
+ end
+ state.eim = item
+ elseif d == 'r' and state.sim then
+ head, state = insert_implicit(head, state, outer)
+ elseif d == 'r' then
+ state.sim, state.eim = nil, nil
+ end
+ end
+
+ if isdir then
+ last = d -- Don't search back - best save now
+ elseif d == 'on' and state.san then
+ state.san = state.san or item
+ state.ean = item
+ end
+
+ end
+
+ return node.prev(head) or head
+end
+%</basic>
+% \end{macrocode}
+%
+% \section{Data for CJK}
+%
+% It is a boring file and it's not shown here. See the generated file.
+%\iffalse
+% \begin{macrocode}
+%<*cjkdata>
+Babel = Babel or {}
+
+Babel.cjk_characters = {
+ [0x0021]={c='ex'},
+ [0x0024]={c='pr'},
+ [0x0025]={c='po'},
+ [0x0028]={c='op'},
+ [0x0029]={c='cp'},
+ [0x002B]={c='pr'},
+ [0x002C]={c='is'},
+ [0x002D]={c='hy'},
+ [0x002E]={c='is'},
+ [0x002F]={c='sy'},
+ [0x003A]={c='is'},
+ [0x003B]={c='is'},
+ [0x003F]={c='ex'},
+ [0x005B]={c='op'},
+ [0x005C]={c='pr'},
+ [0x005D]={c='cp'},
+ [0x007B]={c='op'},
+ [0x007D]={c='cl'},
+ [0x00A1]={c='op'},
+ [0x00A2]={c='po'},
+ [0x00A3]={c='pr'},
+ [0x00A4]={c='pr'},
+ [0x00A5]={c='pr'},
+ [0x00B0]={c='po'},
+ [0x00B1]={c='pr'},
+ [0x201A]={c='op'},
+ [0x201E]={c='op'},
+ [0x2024]={c='in'},
+ [0x2025]={c='in'},
+ [0x2026]={c='in'},
+ [0x2030]={c='po'},
+ [0x2031]={c='po'},
+ [0x2032]={c='po'},
+ [0x2033]={c='po'},
+ [0x2034]={c='po'},
+ [0x2035]={c='po'},
+ [0x2036]={c='po'},
+ [0x2037]={c='po'},
+ [0x203C]={c='ns'},
+ [0x203D]={c='ns'},
+ [0x2044]={c='is'},
+ [0x2045]={c='op'},
+ [0x2046]={c='cl'},
+ [0x2047]={c='ns'},
+ [0x2048]={c='ns'},
+ [0x2049]={c='ns'},
+ [0x207D]={c='op'},
+ [0x207E]={c='cl'},
+ [0x208D]={c='op'},
+ [0x208E]={c='cl'},
+ [0x20A7]={c='po'},
+ [0x20B6]={c='po'},
+ [0x20BB]={c='po'},
+ [0x20BE]={c='po'},
+ [0x2103]={c='po'},
+ [0x2109]={c='po'},
+ [0x2116]={c='pr'},
+ [0x2212]={c='pr'},
+ [0x2213]={c='pr'},
+ [0x22EF]={c='in'},
+ [0x2308]={c='op'},
+ [0x2309]={c='cl'},
+ [0x230A]={c='op'},
+ [0x230B]={c='cl'},
+ [0x2329]={c='op'},
+ [0x232A]={c='cl'},
+ [0x2983]={c='op'},
+ [0x2984]={c='cl'},
+ [0x2985]={c='op'},
+ [0x2986]={c='cl'},
+ [0x2987]={c='op'},
+ [0x2988]={c='cl'},
+ [0x2989]={c='op'},
+ [0x298A]={c='cl'},
+ [0x298B]={c='op'},
+ [0x298C]={c='cl'},
+ [0x298D]={c='op'},
+ [0x298E]={c='cl'},
+ [0x298F]={c='op'},
+ [0x2990]={c='cl'},
+ [0x2991]={c='op'},
+ [0x2992]={c='cl'},
+ [0x2993]={c='op'},
+ [0x2994]={c='cl'},
+ [0x2995]={c='op'},
+ [0x2996]={c='cl'},
+ [0x2997]={c='op'},
+ [0x2998]={c='cl'},
+ [0x29D8]={c='op'},
+ [0x29D9]={c='cl'},
+ [0x29DA]={c='op'},
+ [0x29DB]={c='cl'},
+ [0x29FC]={c='op'},
+ [0x29FD]={c='cl'},
+ [0x2CF9]={c='ex'},
+ [0x2CFE]={c='ex'},
+ [0x2E18]={c='op'},
+ [0x2E22]={c='op'},
+ [0x2E23]={c='cl'},
+ [0x2E24]={c='op'},
+ [0x2E25]={c='cl'},
+ [0x2E26]={c='op'},
+ [0x2E27]={c='cl'},
+ [0x2E28]={c='op'},
+ [0x2E29]={c='cl'},
+ [0x2E2E]={c='ex'},
+ [0x2E42]={c='op'},
+ [0x3001]={c='cl'},
+ [0x3002]={c='cl'},
+ [0x3005]={c='ns'},
+ [0x3008]={c='op'},
+ [0x3009]={c='cl'},
+ [0x300A]={c='op'},
+ [0x300B]={c='cl'},
+ [0x300C]={c='op'},
+ [0x300D]={c='cl'},
+ [0x300E]={c='op'},
+ [0x300F]={c='cl'},
+ [0x3010]={c='op'},
+ [0x3011]={c='cl'},
+ [0x3014]={c='op'},
+ [0x3015]={c='cl'},
+ [0x3016]={c='op'},
+ [0x3017]={c='cl'},
+ [0x3018]={c='op'},
+ [0x3019]={c='cl'},
+ [0x301A]={c='op'},
+ [0x301B]={c='cl'},
+ [0x301C]={c='ns'},
+ [0x301D]={c='op'},
+ [0x301E]={c='cl'},
+ [0x301F]={c='cl'},
+ [0x303B]={c='ns'},
+ [0x303C]={c='ns'},
+ [0x309B]={c='ns'},
+ [0x309C]={c='ns'},
+ [0x309D]={c='ns'},
+ [0x309E]={c='ns'},
+ [0x30A0]={c='ns'},
+ [0x30FB]={c='ns'},
+ [0x30FD]={c='ns'},
+ [0x30FE]={c='ns'},
+ [0xA015]={c='ns'},
+ [0xA60E]={c='ex'},
+ [0xA838]={c='po'},
+ [0xFD3E]={c='cl'},
+ [0xFD3F]={c='op'},
+ [0xFDFC]={c='po'},
+ [0xFE10]={c='is'},
+ [0xFE11]={c='cl'},
+ [0xFE12]={c='cl'},
+ [0xFE13]={c='is'},
+ [0xFE14]={c='is'},
+ [0xFE15]={c='ex'},
+ [0xFE16]={c='ex'},
+ [0xFE17]={c='op'},
+ [0xFE18]={c='cl'},
+ [0xFE19]={c='in'},
+ [0xFE35]={c='op'},
+ [0xFE36]={c='cl'},
+ [0xFE37]={c='op'},
+ [0xFE38]={c='cl'},
+ [0xFE39]={c='op'},
+ [0xFE3A]={c='cl'},
+ [0xFE3B]={c='op'},
+ [0xFE3C]={c='cl'},
+ [0xFE3D]={c='op'},
+ [0xFE3E]={c='cl'},
+ [0xFE3F]={c='op'},
+ [0xFE40]={c='cl'},
+ [0xFE41]={c='op'},
+ [0xFE42]={c='cl'},
+ [0xFE43]={c='op'},
+ [0xFE44]={c='cl'},
+ [0xFE47]={c='op'},
+ [0xFE48]={c='cl'},
+ [0xFE50]={c='cl'},
+ [0xFE52]={c='cl'},
+ [0xFE54]={c='ns'},
+ [0xFE55]={c='ns'},
+ [0xFE56]={c='ex'},
+ [0xFE57]={c='ex'},
+ [0xFE59]={c='op'},
+ [0xFE5A]={c='cl'},
+ [0xFE5B]={c='op'},
+ [0xFE5C]={c='cl'},
+ [0xFE5D]={c='op'},
+ [0xFE5E]={c='cl'},
+ [0xFE69]={c='pr'},
+ [0xFE6A]={c='po'},
+ [0xFF01]={c='ex', w='f'},
+ [0xFF04]={c='pr', w='f'},
+ [0xFF05]={c='po', w='f'},
+ [0xFF08]={c='op', w='f'},
+ [0xFF09]={c='cl', w='f'},
+ [0xFF0C]={c='cl', w='f'},
+ [0xFF0E]={c='cl', w='f'},
+ [0xFF1A]={c='ns', w='f'},
+ [0xFF1B]={c='ns', w='f'},
+ [0xFF1F]={c='ex', w='f'},
+ [0xFF3B]={c='op', w='f'},
+ [0xFF3D]={c='cl', w='f'},
+ [0xFF5B]={c='op', w='f'},
+ [0xFF5D]={c='cl', w='f'},
+ [0xFF5F]={c='op', w='f'},
+ [0xFF60]={c='cl', w='f'},
+ [0xFF61]={c='cl', w='h'},
+ [0xFF62]={c='op', w='h'},
+ [0xFF63]={c='cl', w='h'},
+ [0xFF64]={c='cl', w='h'}
+}
+
+Babel.cjk_class = setmetatable ( Babel.cjk_characters, {
+ __index = function(_, k)
+ if (k >= 0xAC00 and k <= 0xD7A3) -- H2/H3
+ or (k >= 0x2E80 and k <= 0x9FFF)
+ or (k >= 0xF900 and k <= 0xFAFF)
+ or (k >= 0xFE10 and k <= 0xFE1F)
+ or (k >= 0xFE30 and k <= 0xFE6F)
+ or (k >= 0xFF00 and k <= 0xFFEF)
+ or (k >= 0x1F000 and k <= 0x1FFFD)
+ or (k >= 0x20000 and k <= 0x2FFFD)
+ or (k >= 0x30000 and k <= 0x3FFFD) then
+ return {c='I'}
+ elseif (k >= 0x20A0 and k <= 0x20CF) then
+ return {c='pr'}
+ else
+ return {c='O'}
+ end
+ end })
+
+-- Note ns = ex = sy = is = po = hy. Here, 'I' and 'O' are
+-- pseudo-classes for ideographic-like (id, h2, h3), and 'other',
+-- respectively. Jamo is not considered yet, but very likely at least
+-- jl must be.
+
+Babel.cjk_breaks = {
+ ['op'] = { },
+ ['cl'] = { ['op']=1, ['pr']=1, ['in']=1, ['I']=1 },
+ ['ns'] = { ['op']=1, ['pr']=1, ['po']=1, ['in']=1, ['I']=1 },
+ ['ex'] = { ['op']=1, ['pr']=1, ['po']=1, ['in']=1, ['I']=1 },
+ ['sy'] = { ['op']=1, ['pr']=1, ['po']=1, ['in']=1, ['I']=1 },
+ ['is'] = { ['op']=1, ['pr']=1, ['po']=1, ['in']=1, ['I']=1 },
+ ['pr'] = { ['pr']=1, ['po']=1, ['in']=1 },
+ ['po'] = { ['op']=1, ['pr']=1, ['po']=1, ['in']=1, ['I']=1 },
+ ['in'] = { ['op']=1, ['pr']=1, ['po']=1, ['I']=1 },
+ ['hy'] = { ['op']=1, ['pr']=1, ['po']=1, ['in']=1, ['I']=1 },
+ --
+ ['I'] = { ['op']=1, ['pr']=1, ['I']=1, ['O']=1 },
+ ['O'] = { ['I']=1 }
+}
+%</cjkdata>
+% \end{macrocode}
+%\fi
+%
+% \section{The `nil' language}
+%
+% This `language' does nothing, except setting the hyphenation patterns to
+% nohyphenation.
+%
+% For this language currently no special definitions are needed or
+% available.
+%
+% The macro |\LdfInit| takes care of preventing that this file is
+% loaded more than once, checking the category code of the
+% \texttt{@} sign, etc.
+%
+% \begin{macrocode}
+%<*nil>
+\ProvidesLanguage{nil}[<@date@> <@version@> Nil language]
+\LdfInit{nil}{datenil}
+% \end{macrocode}
+%
+% When this file is read as an option, i.e. by the |\usepackage|
+% command, \texttt{nil} could be an `unknown' language in which
+% case we have to make it known.
+%
+% \changes{babel-3.32}{2019/05/21}{Don't set it to
+% \cs{l@nohyphenation}, best reserved fo special uses.}
+%
+% \begin{macrocode}
+\ifx\l@nil\@undefined
+ \newlanguage\l@nil
+ \@namedef{bbl@hyphendata@\the\l@nil}{{}{}}% Remove warning
+\fi
+% \end{macrocode}
+%
+% This macro is used to store the values of the hyphenation
+% parameters |\lefthyphenmin| and |\righthyphenmin|.
+%
+% \begin{macrocode}
+\providehyphenmins{\CurrentOption}{\m@ne\m@ne}
+% \end{macrocode}
+%
+% The next step consists of defining commands to switch to (and
+% from) the `nil' language.
+% \begin{macro}{\captionnil}
+% \begin{macro}{\datenil}
+%
+% \begin{macrocode}
+\let\captionsnil\@empty
+\let\datenil\@empty
+% \end{macrocode}
+%
+% \end{macro}
+% \end{macro}
+%
+% The macro |\ldf@finish| takes care of looking for a
+% configuration file, setting the main language to be switched on
+% at |\begin{document}| and resetting the category code of
+% \texttt{@} to its original value.
+%
+% \begin{macrocode}
+\ldf@finish{nil}
+%</nil>
+% \end{macrocode}
+%
+% \section{Support for Plain \TeX\ (\texttt{plain.def})}
+%
+% \subsection{Not renaming \file{hyphen.tex}}
+% As Don Knuth has declared that the filename \file{hyphen.tex} may
+% only be used to designate \emph{his} version of the american
+% English hyphenation patterns, a new solution has to be found in
+% order to be able to load hyphenation patterns for other languages
+% in a plain-based \TeX-format.
+% When asked he responded:
+% \begin{quote}
+% That file name is ``sacred'', and if anybody changes it they will
+% cause severe upward/downward compatibility headaches.
+%
+% People can have a file localhyphen.tex or whatever they like,
+% but they mustn't diddle with hyphen.tex (or plain.tex except to
+% preload additional fonts).
+% \end{quote}
+%
+% The files \file{bplain.tex} and \file{blplain.tex} can be used as
+% replacement wrappers around \file{plain.tex} and
+% \file{lplain.tex} to acheive the desired effect, based on the
+% \pkg{babel} package. If you load each of them with ini\TeX, you
+% will get a file called either \file{bplain.fmt} or
+% \file{blplain.fmt}, which you can use as replacements for
+% \file{plain.fmt} and \file{lplain.fmt}.
+%
+% As these files are going to be read as the first thing ini\TeX\
+% sees, we need to set some category codes just to be able to
+% change the definition of |\input|
+%
+% \begin{macrocode}
+%<*bplain|blplain>
+\catcode`\{=1 % left brace is begin-group character
+\catcode`\}=2 % right brace is end-group character
+\catcode`\#=6 % hash mark is macro parameter character
+% \end{macrocode}
+%
+% Now let's see if a file called \file{hyphen.cfg} can be found
+% somewhere on \TeX's input path by trying to open it for
+% reading...
+%
+% \begin{macrocode}
+\openin 0 hyphen.cfg
+% \end{macrocode}
+%
+% If the file wasn't found the following test turns out true.
+%
+% \begin{macrocode}
+\ifeof0
+\else
+% \end{macrocode}
+%
+% When \file{hyphen.cfg} could be opened we make sure that
+% \emph{it} will be read instead of the file \file{hyphen.tex}
+% which should (according to Don Knuth's ruling) contain the
+% american English hyphenation patterns and nothing else.
+%
+% We do this by first saving the original meaning of |\input| (and
+% I use a one letter control sequence for that so as not to waste
+% multi-letter control sequence on this in the format).
+%
+% \begin{macrocode}
+ \let\a\input
+% \end{macrocode}
+%
+% Then |\input| is defined to forget about its argument and load
+% \file{hyphen.cfg} instead.
+%
+% \begin{macrocode}
+ \def\input #1 {%
+ \let\input\a
+ \a hyphen.cfg
+% \end{macrocode}
+%
+% Once that's done the original meaning of |\input| can be restored
+% and the definition of |\a| can be forgotten.
+%
+% \begin{macrocode}
+ \let\a\undefined
+ }
+\fi
+%</bplain|blplain>
+% \end{macrocode}
+%
+% Now that we have made sure that \file{hyphen.cfg} will be loaded
+% at the right moment it is time to load \file{plain.tex}.
+%
+% \begin{macrocode}
+%<bplain>\a plain.tex
+%<blplain>\a lplain.tex
+% \end{macrocode}
+%
+% Finally we change the contents of |\fmtname| to indicate that
+% this is \emph{not} the plain format, but a format based on plain
+% with the \pkg{babel} package preloaded.
+%
+% \begin{macrocode}
+%<bplain>\def\fmtname{babel-plain}
+%<blplain>\def\fmtname{babel-lplain}
+% \end{macrocode}
+%
+% When you are using a different format, based on plain.tex you can
+% make a copy of blplain.tex, rename it and replace \file{plain.tex}
+% with the name of your format file.
+%
+% \subsection{Emulating some \LaTeX{} features}
+%
+% The following code duplicates or emulates parts of \LaTeXe\ that
+% are needed for \babel.
+%
+% \changes{bbplain-1.0s}{2012/12/21}{\cs{loadlocalcfg} not loaded in
+% the format}
+%
+% \begin{macrocode}
+%<*plain>
+\def\@empty{}
+\def\loadlocalcfg#1{%
+ \openin0#1.cfg
+ \ifeof0
+ \closein0
+ \else
+ \closein0
+ {\immediate\write16{*************************************}%
+ \immediate\write16{* Local config file #1.cfg used}%
+ \immediate\write16{*}%
+ }
+ \input #1.cfg\relax
+ \fi
+ \@endofldf}
+% \end{macrocode}
+%
+% \subsection{General tools}
+%
+% A number of \LaTeX\ macro's that are needed later on.
+%
+% \changes{bbplain-1.0t}{2013/04/10}{Added \cs{@expandtwoargs}}
+% \changes{babel~3.9h}{2013/12/02}{Added \cs{zap@space}}
+% \changes{babel~3.9k}{2014/03/22}{Added \cs{@nnil}}
+% \changes{babel~3.9k}{2014/03/22}{Added \cs{@gobbletwo}}
+% \changes{babel~3.9k}{2014/03/22}{Added \cs{protected@edef}}
+%
+% \begin{macrocode}
+\long\def\@firstofone#1{#1}
+\long\def\@firstoftwo#1#2{#1}
+\long\def\@secondoftwo#1#2{#2}
+\def\@nnil{\@nil}
+\def\@gobbletwo#1#2{}
+\def\@ifstar#1{\@ifnextchar *{\@firstoftwo{#1}}}
+\def\@star@or@long#1{%
+ \@ifstar
+ {\let\l@ngrel@x\relax#1}%
+ {\let\l@ngrel@x\long#1}}
+\let\l@ngrel@x\relax
+\def\@car#1#2\@nil{#1}
+\def\@cdr#1#2\@nil{#2}
+\let\@typeset@protect\relax
+\let\protected@edef\edef
+\long\def\@gobble#1{}
+\edef\@backslashchar{\expandafter\@gobble\string\\}
+\def\strip@prefix#1>{}
+\def\g@addto@macro#1#2{{%
+ \toks@\expandafter{#1#2}%
+ \xdef#1{\the\toks@}}}
+\def\@namedef#1{\expandafter\def\csname #1\endcsname}
+\def\@nameuse#1{\csname #1\endcsname}
+\def\@ifundefined#1{%
+ \expandafter\ifx\csname#1\endcsname\relax
+ \expandafter\@firstoftwo
+ \else
+ \expandafter\@secondoftwo
+ \fi}
+\def\@expandtwoargs#1#2#3{%
+ \edef\reserved@a{\noexpand#1{#2}{#3}}\reserved@a}
+\def\zap@space#1 #2{%
+ #1%
+ \ifx#2\@empty\else\expandafter\zap@space\fi
+ #2}
+% \end{macrocode}
+%
+% \LaTeXe\ has the command |\@onlypreamble| which adds commands to
+% a list of commands that are no longer needed after
+% |\begin{document}|.
+%
+% \begin{macrocode}
+\ifx\@preamblecmds\@undefined
+ \def\@preamblecmds{}
+\fi
+\def\@onlypreamble#1{%
+ \expandafter\gdef\expandafter\@preamblecmds\expandafter{%
+ \@preamblecmds\do#1}}
+\@onlypreamble\@onlypreamble
+% \end{macrocode}
+%
+% Mimick \LaTeX's |\AtBeginDocument|; for this to work the user
+% needs to add |\begindocument| to his file.
+%
+% \begin{macrocode}
+\def\begindocument{%
+ \@begindocumenthook
+ \global\let\@begindocumenthook\@undefined
+ \def\do##1{\global\let##1\@undefined}%
+ \@preamblecmds
+ \global\let\do\noexpand}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\ifx\@begindocumenthook\@undefined
+ \def\@begindocumenthook{}
+\fi
+\@onlypreamble\@begindocumenthook
+\def\AtBeginDocument{\g@addto@macro\@begindocumenthook}
+% \end{macrocode}
+%
+% We also have to mimick \LaTeX's |\AtEndOfPackage|. Our
+% replacement macro is much simpler; it stores its argument in
+% |\@endofldf|.
+%
+% \changes{babel~3.9h}{2013/11/28}{Set \cs{bbl@opt@hyphenmap} to 0 - we
+% presume hyphenmap=off in plain}
+%
+% \begin{macrocode}
+\def\AtEndOfPackage#1{\g@addto@macro\@endofldf{#1}}
+\@onlypreamble\AtEndOfPackage
+\def\@endofldf{}
+\@onlypreamble\@endofldf
+\let\bbl@afterlang\@empty
+\chardef\bbl@opt@hyphenmap\z@
+% \end{macrocode}
+%
+% \LaTeX\ needs to be able to switch off writing to its auxiliary
+% files; plain doesn't have them by default.
+%
+% \begin{macrocode}
+\ifx\if@filesw\@undefined
+ \expandafter\let\csname if@filesw\expandafter\endcsname
+ \csname iffalse\endcsname
+\fi
+% \end{macrocode}
+%
+% Mimick \LaTeX's commands to define control sequences.
+%
+% \begin{macrocode}
+\def\newcommand{\@star@or@long\new@command}
+\def\new@command#1{%
+ \@testopt{\@newcommand#1}0}
+\def\@newcommand#1[#2]{%
+ \@ifnextchar [{\@xargdef#1[#2]}%
+ {\@argdef#1[#2]}}
+\long\def\@argdef#1[#2]#3{%
+ \@yargdef#1\@ne{#2}{#3}}
+\long\def\@xargdef#1[#2][#3]#4{%
+ \expandafter\def\expandafter#1\expandafter{%
+ \expandafter\@protected@testopt\expandafter #1%
+ \csname\string#1\expandafter\endcsname{#3}}%
+ \expandafter\@yargdef \csname\string#1\endcsname
+ \tw@{#2}{#4}}
+\long\def\@yargdef#1#2#3{%
+ \@tempcnta#3\relax
+ \advance \@tempcnta \@ne
+ \let\@hash@\relax
+ \edef\reserved@a{\ifx#2\tw@ [\@hash@1]\fi}%
+ \@tempcntb #2%
+ \@whilenum\@tempcntb <\@tempcnta
+ \do{%
+ \edef\reserved@a{\reserved@a\@hash@\the\@tempcntb}%
+ \advance\@tempcntb \@ne}%
+ \let\@hash@##%
+ \l@ngrel@x\expandafter\def\expandafter#1\reserved@a}
+\def\providecommand{\@star@or@long\provide@command}
+\def\provide@command#1{%
+ \begingroup
+ \escapechar\m@ne\xdef\@gtempa{{\string#1}}%
+ \endgroup
+ \expandafter\@ifundefined\@gtempa
+ {\def\reserved@a{\new@command#1}}%
+ {\let\reserved@a\relax
+ \def\reserved@a{\new@command\reserved@a}}%
+ \reserved@a}%
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\DeclareRobustCommand{\@star@or@long\declare@robustcommand}
+\def\declare@robustcommand#1{%
+ \edef\reserved@a{\string#1}%
+ \def\reserved@b{#1}%
+ \edef\reserved@b{\expandafter\strip@prefix\meaning\reserved@b}%
+ \edef#1{%
+ \ifx\reserved@a\reserved@b
+ \noexpand\x@protect
+ \noexpand#1%
+ \fi
+ \noexpand\protect
+ \expandafter\noexpand\csname
+ \expandafter\@gobble\string#1 \endcsname
+ }%
+ \expandafter\new@command\csname
+ \expandafter\@gobble\string#1 \endcsname
+}
+\def\x@protect#1{%
+ \ifx\protect\@typeset@protect\else
+ \@x@protect#1%
+ \fi
+}
+\def\@x@protect#1\fi#2#3{%
+ \fi\protect#1%
+}
+% \end{macrocode}
+%
+% The following little macro |\in@| is taken from \file{latex.ltx};
+% it checks whether its first argument is part of its second
+% argument. It uses the boolean |\in@|; allocating a new boolean
+% inside conditionally executed code is not possible, hence the
+% construct with the temporary definition of |\bbl@tempa|.
+%
+% \changes{bbplain-1.0s}{2013/01/15}{Use \cs{bbl@tempa} as
+% documented}
+%
+% \begin{macrocode}
+\def\bbl@tempa{\csname newif\endcsname\ifin@}
+\ifx\in@\@undefined
+ \def\in@#1#2{%
+ \def\in@@##1#1##2##3\in@@{%
+ \ifx\in@##2\in@false\else\in@true\fi}%
+ \in@@#2#1\in@\in@@}
+\else
+ \let\bbl@tempa\@empty
+\fi
+\bbl@tempa
+% \end{macrocode}
+%
+% \LaTeX\ has a macro to check whether a certain package was loaded
+% with specific options. The command has two extra arguments which
+% are code to be executed in either the true or false case.
+% This is used to detect whether the document needs one of the
+% accents to be activated (\Lopt{activegrave} and
+% \Lopt{activeacute}). For plain \TeX\ we assume that the user
+% wants them to be active by default. Therefore the only thing we
+% do is execute the third argument (the code for the true case).
+%
+% \begin{macrocode}
+\def\@ifpackagewith#1#2#3#4{#3}
+% \end{macrocode}
+%
+% The \LaTeX\ macro |\@ifl@aded| checks whether a file was
+% loaded. This functionality is not needed for plain \TeX\ but we
+% need the macro to be defined as a no-op.
+%
+% \begin{macrocode}
+\def\@ifl@aded#1#2#3#4{}
+% \end{macrocode}
+%
+% For the following code we need to make sure that the commands
+% |\newcommand| and |\providecommand| exist with some sensible
+% definition. They are not fully equivalent to their \LaTeXe\
+% versions; just enough to make things work in plain~\TeX
+% environments.
+%
+% \begin{macrocode}
+\ifx\@tempcnta\@undefined
+ \csname newcount\endcsname\@tempcnta\relax
+\fi
+\ifx\@tempcntb\@undefined
+ \csname newcount\endcsname\@tempcntb\relax
+\fi
+% \end{macrocode}
+%
+% To prevent wasting two counters in \LaTeX$\:$2.09 (because
+% counters with the same name are allocated later by it) we reset
+% the counter that holds the next free counter (|\count10|).
+%
+% \begin{macrocode}
+\ifx\bye\@undefined
+ \advance\count10 by -2\relax
+\fi
+\ifx\@ifnextchar\@undefined
+ \def\@ifnextchar#1#2#3{%
+ \let\reserved@d=#1%
+ \def\reserved@a{#2}\def\reserved@b{#3}%
+ \futurelet\@let@token\@ifnch}
+ \def\@ifnch{%
+ \ifx\@let@token\@sptoken
+ \let\reserved@c\@xifnch
+ \else
+ \ifx\@let@token\reserved@d
+ \let\reserved@c\reserved@a
+ \else
+ \let\reserved@c\reserved@b
+ \fi
+ \fi
+ \reserved@c}
+ \def\:{\let\@sptoken= } \: % this makes \@sptoken a space token
+ \def\:{\@xifnch} \expandafter\def\: {\futurelet\@let@token\@ifnch}
+\fi
+\def\@testopt#1#2{%
+ \@ifnextchar[{#1}{#1[#2]}}
+\def\@protected@testopt#1{%
+ \ifx\protect\@typeset@protect
+ \expandafter\@testopt
+ \else
+ \@x@protect#1%
+ \fi}
+\long\def\@whilenum#1\do #2{\ifnum #1\relax #2\relax\@iwhilenum{#1\relax
+ #2\relax}\fi}
+\long\def\@iwhilenum#1{\ifnum #1\expandafter\@iwhilenum
+ \else\expandafter\@gobble\fi{#1}}
+% \end{macrocode}
+%
+% \subsection{Encoding related macros}
+%
+% Code from \file{ltoutenc.dtx}, adapted for use in the plain \TeX\
+% environment.
+%
+% \begin{macrocode}
+\def\DeclareTextCommand{%
+ \@dec@text@cmd\providecommand
+}
+\def\ProvideTextCommand{%
+ \@dec@text@cmd\providecommand
+}
+\def\DeclareTextSymbol#1#2#3{%
+ \@dec@text@cmd\chardef#1{#2}#3\relax
+}
+\def\@dec@text@cmd#1#2#3{%
+ \expandafter\def\expandafter#2%
+ \expandafter{%
+ \csname#3-cmd\expandafter\endcsname
+ \expandafter#2%
+ \csname#3\string#2\endcsname
+ }%
+% \let\@ifdefinable\@rc@ifdefinable
+ \expandafter#1\csname#3\string#2\endcsname
+}
+\def\@current@cmd#1{%
+ \ifx\protect\@typeset@protect\else
+ \noexpand#1\expandafter\@gobble
+ \fi
+}
+\def\@changed@cmd#1#2{%
+ \ifx\protect\@typeset@protect
+ \expandafter\ifx\csname\cf@encoding\string#1\endcsname\relax
+ \expandafter\ifx\csname ?\string#1\endcsname\relax
+ \expandafter\def\csname ?\string#1\endcsname{%
+ \@changed@x@err{#1}%
+ }%
+ \fi
+ \global\expandafter\let
+ \csname\cf@encoding \string#1\expandafter\endcsname
+ \csname ?\string#1\endcsname
+ \fi
+ \csname\cf@encoding\string#1%
+ \expandafter\endcsname
+ \else
+ \noexpand#1%
+ \fi
+}
+\def\@changed@x@err#1{%
+ \errhelp{Your command will be ignored, type <return> to proceed}%
+ \errmessage{Command \protect#1 undefined in encoding \cf@encoding}}
+\def\DeclareTextCommandDefault#1{%
+ \DeclareTextCommand#1?%
+}
+\def\ProvideTextCommandDefault#1{%
+ \ProvideTextCommand#1?%
+}
+\expandafter\let\csname OT1-cmd\endcsname\@current@cmd
+\expandafter\let\csname?-cmd\endcsname\@changed@cmd
+\def\DeclareTextAccent#1#2#3{%
+ \DeclareTextCommand#1{#2}[1]{\accent#3 ##1}
+}
+\def\DeclareTextCompositeCommand#1#2#3#4{%
+ \expandafter\let\expandafter\reserved@a\csname#2\string#1\endcsname
+ \edef\reserved@b{\string##1}%
+ \edef\reserved@c{%
+ \expandafter\@strip@args\meaning\reserved@a:-\@strip@args}%
+ \ifx\reserved@b\reserved@c
+ \expandafter\expandafter\expandafter\ifx
+ \expandafter\@car\reserved@a\relax\relax\@nil
+ \@text@composite
+ \else
+ \edef\reserved@b##1{%
+ \def\expandafter\noexpand
+ \csname#2\string#1\endcsname####1{%
+ \noexpand\@text@composite
+ \expandafter\noexpand\csname#2\string#1\endcsname
+ ####1\noexpand\@empty\noexpand\@text@composite
+ {##1}%
+ }%
+ }%
+ \expandafter\reserved@b\expandafter{\reserved@a{##1}}%
+ \fi
+ \expandafter\def\csname\expandafter\string\csname
+ #2\endcsname\string#1-\string#3\endcsname{#4}
+ \else
+ \errhelp{Your command will be ignored, type <return> to proceed}%
+ \errmessage{\string\DeclareTextCompositeCommand\space used on
+ inappropriate command \protect#1}
+ \fi
+}
+\def\@text@composite#1#2#3\@text@composite{%
+ \expandafter\@text@composite@x
+ \csname\string#1-\string#2\endcsname
+}
+\def\@text@composite@x#1#2{%
+ \ifx#1\relax
+ #2%
+ \else
+ #1%
+ \fi
+}
+%
+\def\@strip@args#1:#2-#3\@strip@args{#2}
+\def\DeclareTextComposite#1#2#3#4{%
+ \def\reserved@a{\DeclareTextCompositeCommand#1{#2}{#3}}%
+ \bgroup
+ \lccode`\@=#4%
+ \lowercase{%
+ \egroup
+ \reserved@a @%
+ }%
+}
+%
+\def\UseTextSymbol#1#2{%
+% \let\@curr@enc\cf@encoding
+% \@use@text@encoding{#1}%
+ #2%
+% \@use@text@encoding\@curr@enc
+}
+\def\UseTextAccent#1#2#3{%
+% \let\@curr@enc\cf@encoding
+% \@use@text@encoding{#1}%
+% #2{\@use@text@encoding\@curr@enc\selectfont#3}%
+% \@use@text@encoding\@curr@enc
+}
+\def\@use@text@encoding#1{%
+% \edef\f@encoding{#1}%
+% \xdef\font@name{%
+% \csname\curr@fontshape/\f@size\endcsname
+% }%
+% \pickup@font
+% \font@name
+% \@@enc@update
+}
+\def\DeclareTextSymbolDefault#1#2{%
+ \DeclareTextCommandDefault#1{\UseTextSymbol{#2}#1}%
+}
+\def\DeclareTextAccentDefault#1#2{%
+ \DeclareTextCommandDefault#1{\UseTextAccent{#2}#1}%
+}
+\def\cf@encoding{OT1}
+% \end{macrocode}
+%
+% Currently we only use the \LaTeXe\ method for accents for those
+% that are known to be made active in \emph{some} language
+% definition file.
+%
+% \begin{macrocode}
+\DeclareTextAccent{\"}{OT1}{127}
+\DeclareTextAccent{\'}{OT1}{19}
+\DeclareTextAccent{\^}{OT1}{94}
+\DeclareTextAccent{\`}{OT1}{18}
+\DeclareTextAccent{\~}{OT1}{126}
+% \end{macrocode}
+%
+% The following control sequences are used in \file{babel.def}
+% but are not defined for \textsc{plain} \TeX.
+%
+% \begin{macrocode}
+\DeclareTextSymbol{\textquotedblleft}{OT1}{92}
+\DeclareTextSymbol{\textquotedblright}{OT1}{`\"}
+\DeclareTextSymbol{\textquoteleft}{OT1}{`\`}
+\DeclareTextSymbol{\textquoteright}{OT1}{`\'}
+\DeclareTextSymbol{\i}{OT1}{16}
+\DeclareTextSymbol{\ss}{OT1}{25}
+% \end{macrocode}
+%
+% For a couple of languages we need the \LaTeX-control sequence
+% |\scriptsize| to be available. Because plain \TeX\ doesn't have
+% such a sofisticated font mechanism as \LaTeX\ has, we just |\let|
+% it to |\sevenrm|.
+%
+% \begin{macrocode}
+\ifx\scriptsize\@undefined
+ \let\scriptsize\sevenrm
+\fi
+%</plain>
+% \end{macrocode}
+%
+% \Finale
+%
+\endinput
+%
+% Local Variables:
+% mode: doctex
+% coding: utf-8
+% TeX-engine: luatex
+% End:
diff --git a/macros/latex/required/babel/base/babel.ins b/macros/latex/required/babel/base/babel.ins
new file mode 100644
index 0000000000..ea54bbbf07
--- /dev/null
+++ b/macros/latex/required/babel/base/babel.ins
@@ -0,0 +1,249 @@
+%%
+%% 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 2012-2019 Javier Bezos and Johannes L. Braams.
+%% Copyright 1989-2008 Johannes L. Braams and any individual authors
+%% listed elsewhere in this file. All rights reserved.
+%%
+%% This file is part of the Babel system.
+%% --------------------------------------
+%%
+%% It may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either version 1.3
+%% 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.3 or later is part of all distributions of LaTeX
+%% version 2003/12/01 or later.
+%%
+%% This work has the LPPL maintenance status "maintained".
+%%
+%% The Current Maintainer of this work is Javier Bezos.
+%%
+%% The list of derived (unpacked) files belonging to the distribution
+%% and covered by LPPL is defined by the unpacking scripts (with
+%% extension .ins) which are part of the distribution.
+%%
+\def\filedate{2019/07/19}
+\def\batchfile{babel.ins}
+\input docstrip.tex
+
+{\ifx\generate\undefined
+\Msg{**********************************************}
+\Msg{*}
+\Msg{* This installation requires docstrip}
+\Msg{* version 2.3c or later.}
+\Msg{*}
+\Msg{* An older version of docstrip has been input}
+\Msg{*}
+\Msg{**********************************************}
+\errhelp{Move or rename old docstrip.tex.}
+\errmessage{Old docstrip in input path}
+\batchmode
+\csname @@end\endcsname
+\fi}
+
+% Modify docstrip. A pseudo-guard is defined to set variables:
+% <<name=value>>. These variables are used with <@name@> Two further
+% pseudo-guards define "block" variables: <<*name>> and <</name>>
+% delimite the lines to be retrived with <@name@>. Note the verbatim
+% guard is overridden, but it's not used here. This is done in two
+% passes: 1) with saving true, there is a dummy pass, generating
+% nothing, but blocks are read and saved; 2) with saving false, blocks
+% are always ignored, but replacing <@name@>. While <@name@> can be
+% used freely outside <<>>, it's only allowed inside <<>> if
+% previously defined. Deeper nesting is not allowed.
+
+\def\replaceVar#1<@#2{%
+ #1%
+ \ifx\endLine#2\else
+ \expandafter\replaceVarX\expandafter#2%
+ \fi}
+
+\def\replaceVarX#1@>{\csname #1Var\endcsname\replaceVar}
+
+\def\normalLine#1\endLine{%
+ \advance\codeLinesPassed\@ne
+ \maybeMsg{.}%
+ \edef\inLine{\replaceVar#1<@\endLine}%
+ \let\do\putline@do
+ \ifcollect
+ \xdef\varCollect{\varCollect^^J\inLine}%
+ \else
+ \activefiles
+ \fi}
+
+\newif\ifcollect
+\newif\ifsaving
+
+\def\verbOption<#1#2>>#3{%
+ \ifx#1*%
+ \maybeMsg{<<*#2>>}%
+ \global\collecttrue
+ \gdef\varCollect##1{}%
+ \else\ifx#1/%
+ \global\collectfalse
+ \ifsaving
+ \expandafter\ifx\csname #2Var\endcsname\relax
+ \global\expandafter\let\csname #2Var\endcsname\varCollect
+ \else
+ \toks@\expandafter\expandafter\expandafter{%
+ \csname #2Var\expandafter\endcsname\expandafter^^J%
+ \varCollect}%
+ \expandafter\xdef\csname #2Var\endcsname{\the\toks@}%
+ \fi
+ \fi
+ \else
+ \varOptionI#1#2>%
+ \fi\fi}
+
+\def\varOptionI#1=#2>{%
+ \maybeMsg{<<#1=#2>>}%
+ \ifsaving
+ \expandafter\gdef\csname #1Var\endcsname{#2}%
+ \fi}
+
+% Preambles
+
+\declarepreamble\mainpreamble
+\endpreamble
+
+\def\MetaPrefix{--}
+\declarepreamble\luapreamble
+\endpreamble
+\let\MetaPrefix\DoubleperCent
+
+\keepsilent
+\askonceonly
+
+\usedir{tex/generic/babel}
+
+\usepreamble\mainpreamble
+
+% Dummy, it just read "modules" to be used when generating
+% the actual file. There must be a better way.
+\savingtrue
+\generate{\usepreamble\empty
+ \usepostamble\empty
+ \file{babel.log}{\from{babel.dtx}{dummy}}}
+\savingfalse
+
+\generate{\file{babel.sty}{\from{babel.dtx}{package}}
+ \file{babel.def}{\from{babel.dtx}{core}}
+ \file{switch.def}{\from{babel.dtx}{kernel}}
+ \file{hyphen.cfg}{\from{babel.dtx}{patterns}}
+ \file{nil.ldf}{\from{babel.dtx}{nil}}
+ \file{xebabel.def}{\from{babel.dtx}{xetex}}
+ \file{luababel.def}{\from{babel.dtx}{luatex}}
+ \file{txtbabel.def}{\from{babel.dtx}{texxet}}
+ }
+
+% Support for plain users
+\generate{\file{plain.def}{\from{babel.dtx}{plain}}
+ \file{bplain.tex}{\from{babel.dtx}{bplain}}
+ \file{blplain.tex}{\from{babel.dtx}{blplain}}
+ }
+
+% compatibility files
+\def\compatfile#1{\file{#1.sty}{\from{bbcompat.dtx}{styfile,#1}}}
+
+\generate{%
+ \compatfile{esperanto}
+ \compatfile{afrikaans}
+ \compatfile{dutch}
+ \compatfile{american}
+ \compatfile{british}
+ \compatfile{english}
+ \compatfile{UKenglish}
+ \compatfile{USenglish}
+ \compatfile{germanb}
+ \compatfile{austrian}
+ \compatfile{ngermanb}
+ \compatfile{naustrian}
+ \compatfile{irish}
+ \compatfile{scottish}
+ \compatfile{welsh}
+ \compatfile{breton}
+ }
+\generate{%
+ \compatfile{francais}
+ \compatfile{italian}
+ \compatfile{portuges}
+ \compatfile{spanish}
+ \compatfile{catalan}
+ \compatfile{galician}
+ \compatfile{danish}
+ \compatfile{norsk}
+ \compatfile{swedish}
+ \compatfile{finnish}
+ \compatfile{magyar}
+ \compatfile{greek}
+ \compatfile{croatian}
+ \compatfile{czech}
+ \compatfile{slovak}
+ \compatfile{polish}
+ }
+\generate{%
+ \compatfile{estonian}
+ \compatfile{romanian}
+ \compatfile{slovene}
+ \compatfile{russianb}
+ \compatfile{ukraineb}
+ \compatfile{turkish}
+ \compatfile{lsorbian}
+ \compatfile{usorbian}
+ \compatfile{bahasa}
+ \compatfile{hebrew}
+ \compatfile{basque}
+ \compatfile{latin}
+ \compatfile{icelandic}
+ \compatfile{serbian}
+ \compatfile{bulgarian}
+ }
+\generate{%
+ \compatfile{samin}
+ \compatfile{interlingua}
+ \compatfile{albanian}
+ \compatfile{bahasam}
+ }
+
+% MakeIndex style files
+
+\usedir{makeindex/babel}
+
+\generate{\file{bbind.ist}{\from{bbidxglo.dtx}{idx}}
+ \file{bbglo.ist}{\from{bbidxglo.dtx}{glo}}}
+
+% lua code
+
+\def\MetaPrefix{--}
+\usepreamble\luapreamble
+\nopostamble
+\generate{\file{babel-data-bidi.lua}{\from{babel.dtx}{bididata}}}
+\generate{\file{babel-data-cjk.lua}{\from{babel.dtx}{cjkdata}}}
+\generate{\file{babel-bidi-basic-r.lua}{\from{babel.dtx}{basic-r}}}
+\generate{\file{babel-bidi-basic.lua}{\from{babel.dtx}{basic}}}
+
+\Msg{***********************************************************}
+\Msg{*}
+\Msg{* To finish the installation you have to move all the files}
+\Msg{* with names ending in .ldf, .sty, .def or .lua into a}
+\Msg{* directory searched by TeX}
+\Msg{*}
+\Msg{* For making a format the following files have to be in a}
+\Msg{* directory which is searched by IniTeX:}
+\Msg{* \space\space hyphen.cfg}
+\Msg{* \space\space language.dat}
+\Msg{* \space\space and files with hyphenation patterns}
+\Msg{*}
+\Msg{* To produce source listings you can run babel.dtx}
+\Msg{* through LuaLaTeX. Deja Vu fonts are required.}
+\Msg{*}
+\Msg{*}
+\Msg{* Happy TeXing}
+\Msg{*}
+\Msg{***********************************************************}
+
+
diff --git a/macros/latex/required/babel/base/babel.pdf b/macros/latex/required/babel/base/babel.pdf
new file mode 100644
index 0000000000..1fc17020fd
--- /dev/null
+++ b/macros/latex/required/babel/base/babel.pdf
Binary files differ
diff --git a/macros/latex/required/babel/base/bbcompat.dtx b/macros/latex/required/babel/base/bbcompat.dtx
new file mode 100644
index 0000000000..063767ea93
--- /dev/null
+++ b/macros/latex/required/babel/base/bbcompat.dtx
@@ -0,0 +1,591 @@
+% \iffalse meta-comment
+%
+% Copyright 1989-2008 Johannes L. Braams and any individual authors
+% listed elsewhere in this file. All rights reserved.
+%
+% This file is part of the Babel system.
+% --------------------------------------
+%
+% It may be distributed and/or modified under the
+% conditions of the LaTeX Project Public License, either version 1.3
+% 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.3 or later is part of all distributions of LaTeX
+% version 2003/12/01 or later.
+%
+% This work has the LPPL maintenance status "maintained".
+%
+% The Current Maintainer of this work is Javier Bezos.
+%
+% The list of all files belonging to the Babel system is
+% given in the file `manifest.bbl. See also `legal.bbl' for additional
+% information.
+%
+% The list of derived (unpacked) files belonging to the distribution
+% and covered by LPPL is defined by the unpacking scripts (with
+% extension .ins) which are part of the distribution.
+% \fi
+% \CheckSum{263}
+%
+% \iffalse
+%<*dtx>
+\ProvidesFile{bbcompat.dtx}[2019/07/19 v3.33]
+%</dtx>
+%
+%% File 'bbcompat.dtx'
+%% Copyright (C) 1989 -- 2008 by Johannes Braams,
+%% TeXniek
+%% all rights reserved.
+%<*filedriver>
+\documentclass{ltxdoc}
+\newcommand*\TeXhax{\TeX hax}
+\newcommand*\babel{\textsf{babel}}
+\newcommand*\Lopt[1]{\textsf{#1}}
+\newcommand*\file[1]{\texttt{#1}}
+\newcommand*\pkg[1]{\texttt{#1}}
+\begin{document}
+ \DocInput{bbcompat.dtx}
+\end{document}
+%</filedriver>
+% \fi
+%
+% \GetFileInfo{bbcompat.dtx}
+% \changes{bbcompat-1.2j}{2006/06/05}{Small documentation fix}
+%
+% \StopEventually{}
+%
+% \changes{bbcompat-1.2}{1996/11/02}{Added the check for \cs{LdfInit}}
+% \changes{bbcompat-1.2d}{1999/04/12}{When these files are read by a
+% non-babel plain format the @ has still category code `other' so
+% can't use \cs{@undefined}}
+% \begin{macrocode}
+\ifx\LdfInit\undefined
+ \def\LdfInit{%
+ \chardef\atcatcode=\catcode`\@
+ \catcode`\@=11\relax
+ \input babel.def\relax
+ \catcode`\@=\atcatcode \let\atcatcode\relax
+ \LdfInit}
+\fi
+% \end{macrocode}
+% It seems that these files, although meant for compatibility with
+% \file{plain.tex} are also used as packages in \LaTeXe. The
+% disadvantage of that is that a number of compatibility measures
+% with other packages that are part of \file{babel.sty} are not
+% present. Therefore we issue an error and then load
+% \file{babel.def} to let the user continue processing his
+% document (at his own risk).
+%
+% First we determine whether we are loaded from \LaTeX\ by checking
+% whether |\PackageError| is defined.
+% \begin{macrocode}
+\ifx\PackageError\undefined
+% \end{macrocode}
+% In this case we are not being loaded by \LaTeXe, so just define
+% |\ProvidesLanguage| to prevent an error when the \file{.ldf} file
+% is loaded.
+% \begin{macrocode}
+ \def\ProvidesLanguage#1[#2 #3 #4]{%
+ \wlog{Language: #1 #4 #3 <#2>}}%
+\else
+% \end{macrocode}
+% Now we define an error message which `deletes' itself from
+% memory.
+% \changes{bbcompat-1.2l}{2013/07/28}{Raise a more useful error.}
+%
+% \begin{macrocode}
+ \def\bblstyerror{%
+ \PackageError{babel}%
+ {You are loading directly a language style.\MessageBreak
+ This syntax is deprecated and you must use\MessageBreak
+ \string\usepackage[language]\string{babel\string}}%
+ {You could proceed but don't complain if you run into errors}%
+ \let\bblstyerror\@undefined
+ }
+% \end{macrocode}
+% Now we can issue the error, it should appear when these files are
+% loaded from \LaTeXe, with \emph{or} without \file{hyphen.cfg}
+% preloaded in the format.
+% \changes{bbcompat-1.2e}{1999/04/20}{Added a check for
+% \cs{ProvidesLanguage}}
+% \begin{macrocode}
+ \ifx\ProvidesLanguage\undefined
+% \end{macrocode}
+% In this case \file{hyphen.cfg} wasn't loaded in the \LaTeXe\
+% format so we also need to provide a suitable definition for
+% |\ProvidesLanguage|.
+% \begin{macrocode}
+ \bblstyerror
+ \def\ProvidesLanguage{%
+ \chardef\atcatcode=\catcode`\@
+ \catcode`\@=11\relax
+ \input babel.def\relax
+ \catcode`\@=\atcatcode \let\atcatcode\relax
+ \ProvidesLanguage}
+% \end{macrocode}
+% When we end up here, \file{hyphen.cfg} was loaded into the
+% format; we only need to issue the error from \LaTeXe.
+% \begin{macrocode}
+ \else
+ \bblstyerror
+ \fi
+\fi
+% \end{macrocode}
+% \changes{bbcompat-1.2}{1996/07/13}{Added \file{.sty} files and
+% definition of \cs{CurrentOption} for language definition files
+% that are loaded by more than one option.}
+% \changes{bbcompat-1.2}{1996/12/14}{Added \file{welsh.sty}}
+% \changes{bbcompat-1.2b}{1997/02/07}{Added \file{sanskrit.sty}}
+% \changes{bbcompat-1.2c}{1998/03/24}{Added \file{hebrew.sty}}
+% \changes{bbcompat-1.2d}{1999/03/09}{Added \file{ukraineb.sty}}
+% \changes{bbcompat-1.2d}{1999/04/10}{Added \file{ngerman.sty} and
+% \file{naustrian.sty}}
+% \changes{bbcompat-1.2f}{2000/09/26}{Added \file{icelandic.sty},
+% \file{bulgarian.sty} and \file{samin.sty}}
+% \changes{bbcompat-1.2f}{2000/09/27}{Define \cs{CurrentOption} in
+% each file}
+% \changes{bbcompat-1.2g}{2001/01/19}{Added code for usenglish and
+% ukenglish.sty}
+% \changes{bbcompat-1.2h}{2003/11/13}{Added \file{interlingua.sty}}
+% \changes{bbcompat-1.2i}{2005/11/23}{Added \file{albanian.sty} and
+% \file{bahasam.sty}}
+% \changes{bbcompat-1.2k}{2008/07/06}{Added \file{latin.sty}}
+% \begin{macrocode}
+%<+albanian>\def\CurrentOption{albanian}
+%<+albanian>\input albanian.ldf\relax
+%<+american>\def\CurrentOption{american}
+%<+USenglish>\def\CurrentOption{USenglish}
+%<+british>\def\CurrentOption{british}
+%<+english>\def\CurrentOption{english}
+%<+UKenglish>\def\CurrentOption{UKenglish}
+%<american|british|english|UKenglish|USenglish>\input english.ldf\relax
+%<+bahasa>\def\CurrentOption{bahasai}
+%<+bahasa>\input bahasai.ldf\relax
+%<+bahasam>\def\CurrentOption{bahasam}
+%<+bahasam>\input bahasam.ldf\relax
+%<+breton>\def\CurrentOption{breton}
+%<+breton>\input breton.ldf\relax
+%<+bulgarian>\def\CurrentOption{bulgarian}
+%<+bulgarian>\input bulgarian.ldf\relax
+%<+catalan>\def\CurrentOption{catalan}
+%<+catalan>\input catalan.ldf\relax
+%<+croatian>\def\CurrentOption{croatian}
+%<+croatian>\input croatian.ldf\relax
+%<+czech>\def\CurrentOption{czech}
+%<+czech>\input czech.ldf\relax
+%<+danish>\def\CurrentOption{danish}
+%<+danish>\input danish.ldf\relax
+%<+afrikaans>\def\CurrentOption{afrikaans}
+%<+dutch>\def\CurrentOption{dutch}
+%<+afrikaans|dutch>\input dutch.ldf\relax
+%<+esperanto>\def\CurrentOption{esperanto}
+%<+esperanto>\input esperanto.ldf\relax
+%<+estonian>\def\CurrentOption{estonian}
+%<+estonian>\input estonian.ldf\relax
+%<+finnish>\def\CurrentOption{finnish}
+%<+finnish>\input finnish.ldf\relax
+%<+francais>\def\CurrentOption{french}
+%<+francais>\input french.ldf\relax
+%<+galician>\def\CurrentOption{galician}
+%<+galician>\input galician.ldf\relax
+%<+austrian>\def\CurrentOption{austrian}
+%<+german>\def\CurrentOption{german}
+%<+germanb>\def\CurrentOption{german}
+%<+austrian|german|germanb>\input germanb.ldf\relax
+%<+naustrian>\def\CurrentOption{naustrian}
+%<+ngerman>\def\CurrentOption{ngerman}
+%<+naustrian|ngerman>\input ngermanb.ldf\relax
+%<+greek>\def\CurrentOption{greek}
+%<+greek>\input greek.ldf\relax
+%<+icelandic>\def\CurrentOption{icelandic}
+%<+icelandic>\input icelandic.ldf\relax
+%<+interlingua>\def\CurrentOption{interlingua}
+%<+interlingua>\input interlingua.ldf\relax
+%<+irish>\def\CurrentOption{irish}
+%<+irish>\input irish.ldf\relax
+%<+italian>\def\CurrentOption{italian}
+%<+italian>\input italian.ldf\relax
+%<+latin>\def\CurrentOption{latin}
+%<+latin>\input latin.ldf\relax
+%<+lsorbian>\def\CurrentOption{lsorbian}
+%<+lsorbian>\input lsorbian.ldf\relax
+%<+magyar>\def\CurrentOption{magyar}
+%<+hungarian>\def\CurrentOption{hungarian}
+%<+magyar|hungarian>\input magyar.ldf\relax
+%<+norsk>\def\CurrentOption{norsk}
+%<+nynorsk>\def\CurrentOption{nynorsk}
+%<+norsk|nynorsk>\input norsk.ldf\relax
+%<+polish>\def\CurrentOption{polish}
+%<+polish>\input polish.ldf\relax
+%<+portuges>\def\CurrentOption{portuges}
+%<+portuguese>\def\CurrentOption{portuguese}
+%<+brazil>\def\CurrentOption{brazil}
+%<+brazilian>\def\CurrentOption{brazilian}
+%<+portuges|portuguese|brazil|brazilian>\input portuges.ldf\relax
+%<+romanian>\def\CurrentOption{romanian}
+%<+romanian>\input romanian.ldf\relax
+%<+russianb>\def\CurrentOption{russianb}
+%<+russianb>\input russianb.ldf\relax
+%<+ukraineb>\def\CurrentOption{ukraineb}
+%<+ukraineb>\input ukraineb.ldf\relax
+%<+samin>\def\CurrentOption{samin}
+%<+samin>\input samin.ldf\relax
+%<+sanskrit>\def\CurrentOption{sanskrit}
+%<+sanskrit>\input sanskrit.ldf\relax
+%<+scottish>\def\CurrentOption{scottish}
+%<+scottish>\input scottish.ldf\relax
+%<+slovak>\def\CurrentOption{slovak}
+%<+slovak>\input slovak.ldf\relax
+%<+slovene>\def\CurrentOption{slovene}
+%<+slovene>\input slovene.ldf\relax
+%<+spanish>\def\CurrentOption{spanish}
+%<+spanish>\input spanish.ldf\relax
+%<+swedish>\def\CurrentOption{swedish}
+%<+swedish>\input swedish.ldf\relax
+%<+turkish>\def\CurrentOption{turkish}
+%<+turkish>\input turkish.ldf\relax
+%<+usorbian>\def\CurrentOption{usorbian}
+%<+usorbian>\input usorbian.ldf\relax
+%<+welsh>\def\CurrentOption{welsh}
+%<+welsh>\input welsh.ldf\relax
+%<+hebrew>\def\CurrentOption{hebrew}
+%<+hebrew>\input rlbabel.def\input hebrew.ldf\relax
+% \end{macrocode}
+%
+% \section{Internationalizing \LaTeX{} 2.09}
+%
+% Now that we're sure that the code is seen by \LaTeX\ only, we
+% have to find out what the main (primary) document style is
+% because we want to redefine some macros. This is only necessary
+% for releases of \LaTeX\ dated before December~1991. Therefore
+% this part of the code can optionally be included in
+% \file{babel.def} by specifying the \texttt{docstrip} option
+% \texttt{names}.
+%
+% The standard styles can be distinguished by checking whether some
+% macros are defined. In table~\ref{styles} an overview is given of
+% the macros that can be used for this purpose.
+% \begin{table}[htb]
+% \begin{center}
+% \DeleteShortVerb{\|}
+% \begin{tabular}{|lcp{8cm}|}
+% \hline
+% article & : & both the \verb+\chapter+ and \verb+\opening+
+% macros are undefined\\
+% report and book & : & the \verb+\chapter+ macro is defined and
+% the \verb+\opening+ is undefined\\
+% letter & : & the \verb+\chapter+ macro is undefined and
+% the \verb+\opening+ is defined\\
+% \hline
+% \end{tabular}
+% \caption{How to determine the main document style}\label{styles}
+% \MakeShortVerb{\|}
+% \end{center}
+% \end{table}
+%
+% \noindent The macros that have to be redefined for the
+% \texttt{report} and \texttt{book} document styles happen to be
+% the same, so there is no need to distinguish between those two
+% styles.
+%
+% \begin{macro}{\doc@style}
+% First a parameter |\doc@style| is defined to identify the current
+% document style. This parameter might have been defined by a
+% document style that already uses macros instead of hard-wired
+% texts, such as \file{artikel1.sty}~\cite{BEP}, so the existence of
+% |\doc@style| is checked. If this macro is undefined, i.\,e., if
+% the document style is unknown and could therefore contain
+% hard-wired texts, |\doc@style| is defined to the default
+% value~`0'.
+% \changes{babel~3.0d}{1991/10/29}{Removed use of \cs{@ifundefined}}
+% \begin{macrocode}
+%<*names>
+\ifx\@undefined\doc@style
+ \def\doc@style{0}%
+% \end{macrocode}
+% This parameter is defined in the following \texttt{if}
+% construction (see table~\ref{styles}):
+%
+% \begin{macrocode}
+ \ifx\@undefined\opening
+ \ifx\@undefined\chapter
+ \def\doc@style{1}%
+ \else
+ \def\doc@style{2}%
+ \fi
+ \else
+ \def\doc@style{3}%
+ \fi%
+\fi%
+% \end{macrocode}
+% \end{macro}
+%
+% \changes{babel~3.1}{1991/11/05}{Removed definition of
+% \cs{if@restonecol}}
+%
+% Now here comes the real work: we start to redefine things and
+% replace hard-wired texts by macros. These redefinitions should be
+% carried out conditionally, in case it has already been done.
+%
+% For the \texttt{figure} and \texttt{table} environments we have
+% in all styles:
+% \begin{macrocode}
+\@ifundefined{figurename}{\def\fnum@figure{\figurename{} \thefigure}}{}
+\@ifundefined{tablename}{\def\fnum@table{\tablename{} \thetable}}{}
+% \end{macrocode}
+%
+% The rest of the macros have to be treated differently for each
+% style. When |\doc@style| still has its default value nothing
+% needs to be done.
+% \begin{macrocode}
+\ifcase\doc@style\relax
+\or
+% \end{macrocode}
+%
+% This means that \file{babel.def} is read after the
+% \texttt{article} style, where no |\chapter| and |\opening|
+% commands are defined\footnote{A fact that was pointed out to me
+% by Nico Poppelier and was already used in Piet van Oostrum's
+% document style option~\texttt{nl}.}.
+%
+% First we have the |\tableofcontents|,
+% |\listoffigures| and |\listoftables|:
+% \begin{macrocode}
+\@ifundefined{contentsname}%
+ {\def\tableofcontents{\section*{\contentsname\@mkboth
+ {\uppercase{\contentsname}}{\uppercase{\contentsname}}}%
+ \@starttoc{toc}}}{}
+\@ifundefined{listfigurename}%
+ {\def\listoffigures{\section*{\listfigurename\@mkboth
+ {\uppercase{\listfigurename}}{\uppercase{\listfigurename}}}%
+ \@starttoc{lof}}}{}
+\@ifundefined{listtablename}%
+ {\def\listoftables{\section*{\listtablename\@mkboth
+ {\uppercase{\listtablename}}{\uppercase{\listtablename}}}%
+ \@starttoc{lot}}}{}
+% \end{macrocode}
+%
+% Then the |\thebibliography| and |\theindex| environments.
+%
+% \begin{macrocode}
+\@ifundefined{refname}%
+ {\def\thebibliography#1{\section*{\refname
+ \@mkboth{\uppercase{\refname}}{\uppercase{\refname}}}%
+ \list{[\arabic{enumi}]}{\settowidth\labelwidth{[#1]}%
+ \leftmargin\labelwidth
+ \advance\leftmargin\labelsep
+ \usecounter{enumi}}%
+ \def\newblock{\hskip.11em plus.33em minus.07em}%
+ \sloppy\clubpenalty4000\widowpenalty\clubpenalty
+ \sfcode`\.=1000\relax}}{}
+\@ifundefined{indexname}%
+ {\def\theindex{\@restonecoltrue\if@twocolumn\@restonecolfalse\fi
+ \columnseprule \z@
+ \columnsep 35pt\twocolumn[\section*{\indexname}]%
+ \@mkboth{\uppercase{\indexname}}{\uppercase{\indexname}}%
+ \thispagestyle{plain}%
+ \parskip\z@ plus.3pt\parindent\z@\let\item\@idxitem}}{}
+% \end{macrocode}
+%
+% The |abstract| environment:
+%
+% \begin{macrocode}
+\@ifundefined{abstractname}%
+ {\def\abstract{\if@twocolumn
+ \section*{\abstractname}%
+ \else \small
+ \begin{center}%
+ {\bf \abstractname\vspace{-.5em}\vspace{\z@}}%
+ \end{center}%
+ \quotation
+ \fi}}{}
+% \end{macrocode}
+%
+% And last but not least, the macro |\part|:
+%
+% \begin{macrocode}
+\@ifundefined{partname}%
+{\def\@part[#1]#2{\ifnum \c@secnumdepth >\m@ne
+ \refstepcounter{part}%
+ \addcontentsline{toc}{part}{\thepart
+ \hspace{1em}#1}\else
+ \addcontentsline{toc}{part}{#1}\fi
+ {\parindent\z@ \raggedright
+ \ifnum \c@secnumdepth >\m@ne
+ \Large \bf \partname{} \thepart
+ \par \nobreak
+ \fi
+ \huge \bf
+ #2\markboth{}{}\par}%
+ \nobreak
+ \vskip 3ex\@afterheading}%
+}{}
+% \end{macrocode}
+%
+% This is all that needs to be done for the \texttt{article} style.
+%
+% \begin{macrocode}
+\or
+% \end{macrocode}
+%
+% The next case is formed by the two styles \texttt{book} and
+% \texttt{report}. Basically we have to do the same as for the
+% \texttt{article} style, except now we must also change the
+% |\chapter| command.
+%
+% The tables of contents, figures and tables:
+% \begin{macrocode}
+\@ifundefined{contentsname}%
+ {\def\tableofcontents{\@restonecolfalse
+ \if@twocolumn\@restonecoltrue\onecolumn
+ \fi\chapter*{\contentsname\@mkboth
+ {\uppercase{\contentsname}}{\uppercase{\contentsname}}}%
+ \@starttoc{toc}%
+ \csname if@restonecol\endcsname\twocolumn
+ \csname fi\endcsname}}{}
+\@ifundefined{listfigurename}%
+ {\def\listoffigures{\@restonecolfalse
+ \if@twocolumn\@restonecoltrue\onecolumn
+ \fi\chapter*{\listfigurename\@mkboth
+ {\uppercase{\listfigurename}}{\uppercase{\listfigurename}}}%
+ \@starttoc{lof}%
+ \csname if@restonecol\endcsname\twocolumn
+ \csname fi\endcsname}}{}
+\@ifundefined{listtablename}%
+ {\def\listoftables{\@restonecolfalse
+ \if@twocolumn\@restonecoltrue\onecolumn
+ \fi\chapter*{\listtablename\@mkboth
+ {\uppercase{\listtablename}}{\uppercase{\listtablename}}}%
+ \@starttoc{lot}%
+ \csname if@restonecol\endcsname\twocolumn
+ \csname fi\endcsname}}{}
+% \end{macrocode}
+%
+% Again, the |bibliography| and |index| environments; notice that
+% in this case we use |\bibname| instead of |\refname| as in the
+% definitions for the \texttt{article} style. The reason for this
+% is that in the \texttt{article} document style the term
+% `References' is used in the definition of |\thebibliography|. In
+% the \texttt{report} and \texttt{book} document styles the term
+% `Bibliography' is used.
+% \begin{macrocode}
+\@ifundefined{bibname}%
+ {\def\thebibliography#1{\chapter*{\bibname
+ \@mkboth{\uppercase{\bibname}}{\uppercase{\bibname}}}%
+ \list{[\arabic{enumi}]}{\settowidth\labelwidth{[#1]}%
+ \leftmargin\labelwidth \advance\leftmargin\labelsep
+ \usecounter{enumi}}%
+ \def\newblock{\hskip.11em plus.33em minus.07em}%
+ \sloppy\clubpenalty4000\widowpenalty\clubpenalty
+ \sfcode`\.=1000\relax}}{}
+\@ifundefined{indexname}%
+ {\def\theindex{\@restonecoltrue\if@twocolumn\@restonecolfalse\fi
+ \columnseprule \z@
+ \columnsep 35pt\twocolumn[\@makeschapterhead{\indexname}]%
+ \@mkboth{\uppercase{\indexname}}{\uppercase{\indexname}}%
+ \thispagestyle{plain}%
+ \parskip\z@ plus.3pt\parindent\z@ \let\item\@idxitem}}{}
+% \end{macrocode}
+%
+% Here is the |abstract| environment:
+% \begin{macrocode}
+\@ifundefined{abstractname}%
+ {\def\abstract{\titlepage
+ \null\vfil
+ \begin{center}%
+ {\bf \abstractname}%
+ \end{center}}}{}
+% \end{macrocode}
+%
+% And last but not least the |\chapter|, |\appendix| and
+% |\part| macros.
+% \begin{macrocode}
+\@ifundefined{chaptername}{\def\@chapapp{\chaptername}}{}
+%
+\@ifundefined{appendixname}%
+ {\def\appendix{\par
+ \setcounter{chapter}{0}%
+ \setcounter{section}{0}%
+ \def\@chapapp{\appendixname}%
+ \def\thechapter{\Alph{chapter}}}}{}
+%
+\@ifundefined{partname}%
+ {\def\@part[#1]#2{\ifnum \c@secnumdepth >-2\relax
+ \refstepcounter{part}%
+ \addcontentsline{toc}{part}{\thepart
+ \hspace{1em}#1}\else
+ \addcontentsline{toc}{part}{#1}\fi
+ \markboth{}{}%
+ {\centering
+ \ifnum \c@secnumdepth >-2\relax
+ \huge\bf \partname{} \thepart
+ \par
+ \vskip 20pt \fi
+ \Huge \bf
+ #1\par}\@endpart}}{}%
+\or
+% \end{macrocode}
+%
+% Now we address the case where \file{babel.def} is read after the
+% \texttt{letter} style. The \texttt{letter} document style
+% defines the macro |\opening| and some other macros that are
+% specific to \texttt{letter}. This means that we have to redefine
+% other macros, compared to the previous two cases.
+%
+% First two macros for the material at the end of a letter, the
+% |\cc| and |\encl| macros.
+% \begin{macrocode}
+\@ifundefined{ccname}%
+ {\def\cc#1{\par\noindent
+ \parbox[t]{\textwidth}%
+ {\@hangfrom{\rm \ccname : }\ignorespaces #1\strut}\par}}{}
+\@ifundefined{enclname}%
+ {\def\encl#1{\par\noindent
+ \parbox[t]{\textwidth}%
+ {\@hangfrom{\rm \enclname : }\ignorespaces #1\strut}\par}}{}
+% \end{macrocode}
+%
+% The last thing we have to do here is to redefine the
+% \texttt{headings} pagestyle:
+% \changes{babel~3.3}{1993/07/11}{\cs{headpagename} should be
+% \cs{pagename}}
+% \begin{macrocode}
+\@ifundefined{headtoname}%
+ {\def\ps@headings{%
+ \def\@oddhead{\sl \headtoname{} \ignorespaces\toname \hfil
+ \@date \hfil \pagename{} \thepage}%
+ \def\@oddfoot{}}}{}
+\fi
+%</names>
+% \end{macrocode}
+%
+% This was the last of the four standard document styles, so if
+% |\doc@style| has another value we do nothing and just close the
+% \texttt{if} construction. Here ends the code that can be optionally
+% included when a version of \LaTeX\ is in use that is dated
+% \emph{before} December~1991.
+%
+% We also need to redefine a number of commands to ensure that the
+% right font encoding is used, but this can't be done before
+% \file{babel.def} is loaded.
+% \changes{babel~3.6o}{1999/04/07}{Moved the rest of the font encoding
+% related definitions to their original place}
+%
+%%
+%% \CharacterTable
+%% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
+%% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
+%% Digits \0\1\2\3\4\5\6\7\8\9
+%% Exclamation \! Double quote \" Hash (number) \#
+%% Dollar \$ Percent \% Ampersand \&
+%% Acute accent \' Left paren \( Right paren \)
+%% Asterisk \* Plus \+ Comma \,
+%% Minus \- Point \. Solidus \/
+%% Colon \: Semicolon \; Less than \<
+%% Equals \= Greater than \> Question mark \?
+%% Commercial at \@ Left bracket \[ Backslash \\
+%% Right bracket \] Circumflex \^ Underscore \_
+%% Grave accent \` Left brace \{ Vertical bar \|
+%% Right brace \} Tilde \~}
+\endinput
diff --git a/macros/latex/required/babel/base/bbidxglo.dtx b/macros/latex/required/babel/base/bbidxglo.dtx
new file mode 100644
index 0000000000..58a43d9adb
--- /dev/null
+++ b/macros/latex/required/babel/base/bbidxglo.dtx
@@ -0,0 +1,124 @@
+% \iffalse meta-comment
+%
+% Copyright 1989-2008 Johannes L. Braams and any individual authors
+% listed elsewhere in this file. All rights reserved.
+%
+% This file is part of the Babel system.
+% --------------------------------------
+%
+% It may be distributed and/or modified under the
+% conditions of the LaTeX Project Public License, either version 1.3
+% 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.3 or later is part of all distributions of LaTeX
+% version 2003/12/01 or later.
+%
+% This work has the LPPL maintenance status "maintained".
+%
+% The Current Maintainer of this work is Javier Bezos.
+%
+% The list of all files belonging to the Babel system is
+% given in the file `manifest.bbl. See also `legal.bbl' for additional
+% information.
+%
+% The list of derived (unpacked) files belonging to the distribution
+% and covered by LPPL is defined by the unpacking scripts (with
+% extension .ins) which are part of the distribution.
+% \fi
+% \CheckSum{66}
+%
+% \iffalse
+%
+% \begin{macrocode}
+%<*driver>
+\ProvidesFile{bbidxglo.drv}[2008/03/21 v1.0b]
+\documentclass{ltxdoc}
+\GetFileInfo{bbidxglo.drv}
+\newcommand{\babel}{\textsf{babel}}
+\newcommand{\mkidx}{\texttt{MakeIndex}}
+\newcommand{\file}[1]{\texttt{#1}}
+\newcommand{\Lopt}[1]{\textsf{#1}}
+\begin{document}
+\DocInput{bbidxglo.dtx}
+\end{document}
+%</driver>
+% \end{macrocode}
+%
+% \fi
+% \title{Generating the index and chage log for the Babel system}
+% \author{Johannes Braams}
+% \date{\filedate}
+% \maketitle
+%
+% \section{Description}
+%
+% This file contains the source for the style files for the \mkidx\
+% program. These are needed to produce the index for the complete
+% source listing and to produce the listing of the changes.
+%
+% \StopEventually{}
+%
+% \section{The index and the list of changes } Most of the entries are
+% the same as in the files \file{gind.ist} and \file{gglo.ist} from
+% the \Lopt{doc} package.
+%
+% \begin{macrocode}
+%<*idx|glo>
+actual '='
+quote '!'
+level '>'
+%</idx|glo>
+% \end{macrocode}
+%
+% Because the \babel\ system consists of so many files the default
+% codeline numbering scheme of the \Lopt{doc} package has been
+% adapted. The line numbers consist of two parts seperated with a
+% dot. This has to made known to the \mkidx\ program when it
+% produces the index.
+%
+% \begin{macrocode}
+%<+idx>page_compositor "."
+% \end{macrocode}
+%
+% Any further entries are again copied from \file{gind.ist} and
+% \file{gglo.ist}.
+%
+% \begin{macrocode}
+%<*idx>
+preamble
+"\n \\begin{theindex} \n \\makeatletter\\scan@allowedfalse\n"
+postamble
+"\n\n \\end{theindex}\n"
+%</idx>
+%<*glo>
+preamble
+"\n \\begin{theglossary} \n
+ \\makeatletter\\scan@allowedfalse\n"
+postamble
+"\n\n \\end{theglossary}\n"
+keyword "\\glossaryentry"
+%</glo>
+%<+idx|glo>item_x1 "\\efill \n \\subitem "
+%<+idx>item_x2 "\\efill \n \\subsubitem "
+%<+glo>item_x2 "\\ "
+%<*idx|glo>
+delim_0 "\\pfill "
+delim_1 "\\pfill "
+delim_2 "\\pfill "
+% The next lines will produce some warnings when
+% running Makeindex as they try to cover two different
+% versions of the program:
+lethead_prefix "{\\bfseries\\hfil "
+lethead_suffix "\\hfil}\\nopagebreak\n"
+%</idx|glo>
+%<+idx>lethead_flag 1
+%<+glo>lethead_flag 0
+%<*idx|glo>
+heading_prefix "{\\bfseries\\hfil "
+heading_suffix "\\hfil}\\nopagebreak\n"
+%</idx|glo>
+%<+idx>headings_flag 1
+%<+glo>headings_flag 0
+% \end{macrocode}
+%
diff --git a/macros/latex/required/babel/contrib b/macros/latex/required/babel/contrib
new file mode 120000
index 0000000000..28c7571cf7
--- /dev/null
+++ b/macros/latex/required/babel/contrib
@@ -0,0 +1 @@
+../../contrib/babel-contrib \ No newline at end of file
diff --git a/macros/latex/required/cyrillic/README.md b/macros/latex/required/cyrillic/README.md
new file mode 100644
index 0000000000..9d42a35675
--- /dev/null
+++ b/macros/latex/required/cyrillic/README.md
@@ -0,0 +1,67 @@
+## README for the `cyrillic` bundle (June 2001)
+
+This `bundle` consists of LaTeX2e packages for Cyrillic languages
+supported by the LaTeX3 Project Team.
+
+Running LaTeX on the file cyrlatex.ins will produce all the package
+files, and some associated files.
+
+So you should first process cyrlatex.ins:
+
+ latex cyrlatex.ins
+
+The files with extensions `.def`, `.fd`, `.sty` and `.tex` should
+then be moved to a directory on LaTeX's standard input path.
+
+The documented source code of each component may then be obtained by
+running LaTeX on a files with extensions `.dtx` and `.fdd`.
+
+For example:
+
+ latex cyoutenc.dtx
+
+will produce the file `cyoutenc.pdf`, documenting the output encodings
+source code.
+
+The file `manifest.txt` contains a list of the main files in the
+distribution together with a one-or-two line summary of each file.
+
+
+### Distribution Conditions
+
+All the files in this bundle may be distributed 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 use of these files is otherwise unrestricted.
+
+
+### Reporting Bugs
+
+If you wish to report a problem or bug in any of these packages
+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!
+
+
+
+### Copyright
+
+This README file is copyright 2005-2017 The LaTeX3 Project.
+
+
+
diff --git a/macros/latex/required/cyrillic/changes.txt b/macros/latex/required/cyrillic/changes.txt
new file mode 100644
index 0000000000..cfc514226f
--- /dev/null
+++ b/macros/latex/required/cyrillic/changes.txt
@@ -0,0 +1,192 @@
+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.
+=======================================================================
+
+2015-04-02 Joseph Wright <joseph.wright@morningstar2.co.uk>
+ * TDS-style zip improvements
+
+2015-04-02 Joseph Wright <latex-team@latex-project.org>
+ * Tweak README
+
+2015-03-31 Joseph Wright <joseph.wright@morningstar2.co.uk>
+ * Update packing of files for CTAN
+
+2014-10-28 <Frank.Mittelbach@latex-project.org>
+
+ * cyinpenc.dtx: typo corrected
+
+2005-09-27 Frank Mittelbach <latex-bugs@latex-project.org>
+
+ * cyoutenc.dtx: Replace \sh@ft by \ltx@sh@ft (pr/3469)
+
+2004-05-28 Vladimir Volovich <latex-bugs@latex-project.org>
+
+ * cyoutenc.dtx, lcy.dtx: disable by default the special code
+ (hack) for \r{A} composite for all cyrillic encodings. See
+ discussions on the CyrTeX-ru mailing list. To restore, one may add
+ the AAhack docstrip option.
+
+2004-01-26 Vladimir Volovich <latex-bugs@latex-project.org>
+
+ * cyoutenc.dtx, lcy.dtx: coding change for \r{A} to follow bug fix
+ by DEK in plain.tex and in base LaTeX (pr/3469).
+
+2001-08-11 Vladimir Volovich <latex-bugs@latex-project.org>
+
+ * ot2.dtx: added \d accent and \.\i composite to OT2 encoding.
+
+ * cyoutenc.dtx, lcy.dtx, ot2.dtx: use \hmode@bgroup where
+ applicable.
+
+ * cyrlatex.ins, t2lhfnt.fdd, lcycmlh.fdd, ot2cmlh.fdd:
+ added font definition files for Cyrillic CM Concrete (ccr)
+ font family.
+
+ * cyrlatex.ins, t2lhfnt.fdd, lcycmlh.fdd, ot2cmlh.fdd:
+ added font definition files for Cyrillic CM Bright (cmbr)
+ and CM Typewriter Light (cmtl) font families.
+
+ * t2lhfnt.fdd: added cmss/sbc/n font shape to all encodings.
+
+2000-12-27 Vladimir Volovich <latex-bugs@latex-project.org>
+
+ * lcy.dtx (lcyenc.def): added a fake accent for the
+ Cyrillic breve.
+
+2000-06-06 Vladimir Volovich <latex-bugs@latex-project.org>
+
+ * cyoutenc.dtx: added \r{A} composite for T2*
+ encodings (as they do not contain a pre-built glyph).
+
+2000-05-03 Vladimir Volovich <latex-bugs@latex-project.org>
+
+ * cyoutenc.dtx, lcy.dtx, ot2.dtx: added declarations
+ for composites for use with dblaccnt package.
+
+1999-12-17 Vladimir Volovich <latex-bugs@latex-project.org>
+
+ * ot2cmams.fdd: added families OT2/wlcyr and OT2/wlcyss
+ for virtual WLCY fonts without ligatures.
+
+ * cyrlatex.ins: added entries for ot2wlcyr.fd and ot2wlcyss.fd.
+
+1999-12-07 Vladimir Volovich <latex-bugs@latex-project.org>
+
+ * cyoutenc.dtx: renamed \CYRRHOOK -> \CYRRHK,
+ \cyrrhook -> \cyrrhk for consistency with other
+ glyph names.
+
+1999-11-29 Vladimir Volovich <latex-bugs@latex-project.org>
+
+ * cyinpenc.dtx: removed \CYRFITA and \cyrfita as
+ a shared glyph for CYROTLD from x2enc.def.
+
+1999-11-16 Vladimir Volovich <latex-bugs@latex-project.org>
+
+ * cyinpenc.dtx: added ParaType Cyrillic Asian codepages
+ pt154 and pt254.
+
+ * cyrlatex.ins: added entries for pt154.def and pt254.def.
+
+1999-10-28 Vladimir Volovich <latex-bugs@latex-project.org>
+
+ * cyoutenc.dtx: added |\cyrdash| as an alias to
+ |\textemdash| for all T2*, X2 encodings.
+
+ * ot2.dtx: ditto for OT2 encoding.
+
+1999-09-03 Frank Mittelbach <latex-bugs@latex-project.org>
+
+ * DEFAULT.pre: updated for LPPL 1.2
+
+ * DEFAULT.hea: updated for LPPL 1.2
+
+ * copyfd.pre: updated for LPPL 1.2
+
+ * copyins.hea: updated for LPPL 1.2
+
+1999-07-09 Frank Mittelbach <latex-bugs@latex-project.org>
+
+ * updated header to reflect LPPL 1.1
+
+1999-06-24 Vladimir Volovich <latex-bugs@latex-project.org>
+
+ * lcy.dtx (lcydefs.tex): added zeroing of uc/lccodes for
+ non-letter signs to avoid breaking hyphenation.
+
+ * cyinpenc.dtx: corrected MIK codepage.
+
+1999-06-07 Vladimir Volovich <latex-bugs@latex-project.org>
+
+ * lcy.dtx: now contains lcydefs.tex
+
+ * lcy.dtx: added a wrapper package lcy.sty
+
+ * lcy.dtx: removed \include{lcydefs} from lcyenc.def
+
+ * manifest.txt: updated
+
+ * readme.txt: updated
+
+1999-06-07 Werner Lemberg <latex-bugs@latex-project.org>
+
+ * lcy.dtx: fixes for documentation.
+
+1999-06-07 Frank Mittelbach <latex-bugs@latex-project.org>
+
+ * Makefile (FILES): remove lcydefs.tex as it is now generated
+
+1999-06-05 Vladimir Volovich <latex-bugs@latex-project.org>
+
+ * manifest.txt: updated
+
+ * cyrlatex.ins: merged oldcyr.ins into cyrlatex.ins
+
+ * cyoutenc.dtx: removed \DeclareErrorFont from cyoutenc.dtx
+
+ * cyinpenc.dtx: added bulgarian input encoding MIK (BDS)
+
+1999-06-05 Frank Mittelbach <latex-bugs@latex-project.org>
+
+ * cyoutenc.dtx: updated version number
+
+ * cyinpenc.dtx: updated version number
+
+ * Makefile (FILES): removed oldcyr.ins from distribution
+ added ChangeLog.vvv
+
+1999-06-02 Rainer Schoepf <latex-bugs@latex-project.org>
+
+ * ot2cmlh.fdd: added.
+
+ * lcycmlh.fdd: added.
+
+ * ot2cmams.fdd: added.
+
+ * ot2.dtx: added.
+
+ * oldcyr.ins: added.
+
+ * lcydefs.tex: added.
+
+ * lcy.dtx: added.
+
+1999-05-09 Frank Mittelbach <latex-bugs@latex-project.org>
+
+ * ot2cmlh.fdd: docstrip `nowarn' guard was the wrong way around
+ for font OT2/cmr/bx/ui (pr/3036)
+ lcycmlh.fdd: ditto for LCY/cmr/bx/ui
+
+1999-02-04 Frank Mittelbach <latex-bugs@latex-project.org>
+
+ * cyrlatex.ins: do not generate too many files in parallel
+
+1999-01-26 Frank Mittelbach <latex-bugs@latex-project.org>
+
+ * readme.txt: small changes to "reporting bugs" section
+
+1999-01-25 Frank Mittelbach <latex-bugs@latex-project.org>
+
+ * cyrlatex.ins: added copyrights etc
diff --git a/macros/latex/required/cyrillic/cyinpenc.dtx b/macros/latex/required/cyrillic/cyinpenc.dtx
new file mode 100644
index 0000000000..e560ca8691
--- /dev/null
+++ b/macros/latex/required/cyrillic/cyinpenc.dtx
@@ -0,0 +1,1838 @@
+% \iffalse meta-comment
+%
+% Copyright 1993-2014
+%
+% The LaTeX3 Project and any individual authors listed elsewhere
+% in this file.
+%
+% This file is part of the Standard LaTeX `Cyrillic Bundle'.
+% ----------------------------------------------------------
+%
+% It may be distributed and/or modified under the
+% conditions of the LaTeX Project Public License, either version 1.3b
+% 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.3b or later is part of all distributions of LaTeX
+% version 2005/12/01 or later.
+%
+% The list of all files belonging to the `Cyrillic Bundle' is
+% given in the file `manifest.txt'.
+%
+% \fi
+% \iffalse
+% This is the file |cyinpenc.dtx| of the cyrillic bundle for LaTeX2e.
+%
+% The input encoding files for mongolian are
+% (C) Copyright 1999 by Oliver Corff.
+%
+%<*driver>
+\documentclass{ltxdoc}
+\begin{document}
+\DocInput{cyinpenc.dtx}
+\end{document}
+%</driver>
+% \fi
+%
+% \section{The Cyrillic codepages}
+%
+% There are several widely used Cyrillic codepages.
+% Currently, we define here the following codepages:
+%
+% \begin{itemize}
+% \item cp~866 is the standard MS-DOS Russian codepage. There are
+% also several codepages in use, which are very similar to
+% cp~866. These are: so-called ``Cyrillic Alternative codepage''
+% (or Alternative Variant of cp~866), Modified Alternative Variant,
+% New Alternative Variant, and experimental Tatarian codepage. The
+% differences take place in the range |0xf2|--|0xfe|. All these
+% `Alternative' codepages are also supported.
+% \item cp~855 is the standard MS-DOS Cyrillic codepage.
+% \item cp~1251 is the standard MS Windows Cyrillic codepage.
+% \item pt~154 is a Windows Cyrillic Asian codepage developed in
+% ParaType. It is a variant of Windows Cyrillic codepage.
+% \item koi8-r is a standard codepage widely used in UNIX-like
+% systems for Russian language support. It is specified in
+% RFC~1489. The situation with koi8-r is somewhat similar to the
+% one with cp~866: there are also several similar codepages in
+% use, which coincide with koi8-r for all Russian letters, but add
+% some other Cyrillic letters. These codepages include: koi8-u
+% (it is a variant of the koi8-r codepage with some Ukrainian
+% letters added), koi8-ru (it is described in a draft RFC document
+% specifying the widely used character set for mail and news
+% exchange in the Ukrainian internet community as well as for
+% presenting WWW information resources in the Ukrainian language),
+% and ISO-IR-111 ECMA Cyrillic Code Page. All these codepages are
+% supported also.
+% \item ISO~8859-5 Cyrillic codepage (also called ISO-IR-144).
+% \item Apple Macintosh Cyrillic (Microsoft cp~10007) codepage.
+% \item Apple Macintosh Ukrainian codepage (very similar to the
+% previous codepage).
+% \item pt~254 is a Macintosh Cyrillic Asian codepage developed in
+% ParaType. It is a variant of Macintosh Cyrillic codepage.
+% \item Bulgarian MIK (BDS) codepage.
+% \item Mongolian codepages: CTT, DBK, MNK, MOS, NCC, MLS.
+% \end{itemize}
+%
+% For all codepages, one of T2* (or X2) encoding is needed. To access some
+% characters (e.g.\ |\textregistered|, |\textbrokenbar|) present in some
+% codepages, T1 and TS1 are necessary also. However, if the characters
+% used from these codepages will be limited only to Russian letters, it
+% is sufficient to have old LH fonts with LCY or OT2 encoding. In this
+% case, characters which are absent in the font will cause error
+% messages.
+%
+% Note that the following composite glyphs (using accents) are not
+% `named' here: |\CYRGJE| (|\'\CYRG|), |\cyrgje| (|\'\cyrg|), |\CYRKJE|
+% (|\'\CYRK|), |\cyrkje| (|\'\cyrk|). Also, |\@tabacckludge'| is used
+% instead of |\'| because of the tabbing environment.
+%
+% \subsection{Additional Copyright notice(s)}
+%
+% \begin{macrocode}
+%<CTT|DBK|MNK|MOS|NCC|MLS>% (C) Copyright 1999 by Oliver Corff.
+%<MIK>% (C) Copyright 1999 by Georgi Boshnakov, Guentcho Skordev.
+% \end{macrocode}
+%
+% \subsection{Headers}
+%
+% \begin{macrocode}
+%\NeedsTeXFormat{LaTeX2e}[1995/12/01]
+%<cp866&std>\ProvidesFile{cp866.def}
+%<cp866&AV>\ProvidesFile{cp866av.def}
+%<cp866&MAV>\ProvidesFile{cp866mav.def}
+%<cp866&NAV>\ProvidesFile{cp866nav.def}
+%<cp866&Tatar>\ProvidesFile{cp866tat.def}
+%<cp1251>\ProvidesFile{cp1251.def}
+%<pt154>\ProvidesFile{pt154.def}
+%<cp855>\ProvidesFile{cp855.def}
+%<koi8&koi8r>\ProvidesFile{koi8-r.def}
+%<koi8&koi8ru>\ProvidesFile{koi8-ru.def}
+%<koi8&isoir111>\ProvidesFile{isoir111.def}
+%<koi8&koi8u>\ProvidesFile{koi8-u.def}
+%<ISO88595>\ProvidesFile{iso88595.def}
+%<maccyrillic>\ProvidesFile{maccyr.def}
+%<macukrainian>\ProvidesFile{macukr.def}
+%<pt254>\ProvidesFile{pt254.def}
+%<MIK>\ProvidesFile{mik.def}
+%<CTT>\ProvidesFile{ctt.def}
+%<DBK>\ProvidesFile{dbk.def}
+%<MNK>\ProvidesFile{mnk.def}
+%<MOS>\ProvidesFile{mos.def}
+%<NCC>\ProvidesFile{ncc.def}
+%<MLS>\ProvidesFile{mls.def}
+ [2014/10/28 v1.0d Input encoding file]
+% \end{macrocode}
+% Insert a |\makeatletter| at the beginning of all .def files.
+% \begin{macrocode}
+\makeatletter
+%<*cp866&!NAV|cp855|koi8r|koi8ru|MIK>
+\ProvideTextCommandDefault{\textblacksquare}
+ {\vrule \@width .3em \@height .4em \@depth -.1em\relax}
+%</cp866&!NAV|cp855|koi8r|koi8ru|MIK>
+%<*cp866&std|cp866&MAV|cp1251|koi8r|maccyrillic|macukrainian|MIK|pt154|pt254>
+\ProvideTextCommandDefault{\textdegree}{\ensuremath{{^\circ}}}
+%</cp866&std|cp866&MAV|cp1251|koi8r|maccyrillic|macukrainian|MIK|pt154|pt254>
+%<*cp1251>
+\ProvideTextCommandDefault{\textbrokenbar}
+ {\TextSymbolUnavailable\textbrokenbar}
+\ProvideTextCommandDefault{\texteuro}
+ {\TextSymbolUnavailable\texteuro}
+%</cp1251>
+%<cp866&MAV|koi8r|MIK>\providecommand{\mathtwosuperior}{{^2}}
+%<cp866&MAV|MIK>\providecommand{\mathnsuperior}{{^n}}
+% \end{macrocode}
+%
+% \subsection{Microsoft cp~866}
+%
+% \begin{macrocode}
+%<*cp866>
+\DeclareInputText{128}{\CYRA}
+\DeclareInputText{129}{\CYRB}
+\DeclareInputText{130}{\CYRV}
+\DeclareInputText{131}{\CYRG}
+\DeclareInputText{132}{\CYRD}
+\DeclareInputText{133}{\CYRE}
+\DeclareInputText{134}{\CYRZH}
+\DeclareInputText{135}{\CYRZ}
+\DeclareInputText{136}{\CYRI}
+\DeclareInputText{137}{\CYRISHRT}
+\DeclareInputText{138}{\CYRK}
+\DeclareInputText{139}{\CYRL}
+\DeclareInputText{140}{\CYRM}
+\DeclareInputText{141}{\CYRN}
+\DeclareInputText{142}{\CYRO}
+\DeclareInputText{143}{\CYRP}
+\DeclareInputText{144}{\CYRR}
+\DeclareInputText{145}{\CYRS}
+\DeclareInputText{146}{\CYRT}
+\DeclareInputText{147}{\CYRU}
+\DeclareInputText{148}{\CYRF}
+\DeclareInputText{149}{\CYRH}
+\DeclareInputText{150}{\CYRC}
+\DeclareInputText{151}{\CYRCH}
+\DeclareInputText{152}{\CYRSH}
+\DeclareInputText{153}{\CYRSHCH}
+\DeclareInputText{154}{\CYRHRDSN}
+\DeclareInputText{155}{\CYRERY}
+\DeclareInputText{156}{\CYRSFTSN}
+\DeclareInputText{157}{\CYREREV}
+\DeclareInputText{158}{\CYRYU}
+\DeclareInputText{159}{\CYRYA}
+%
+\DeclareInputText{160}{\cyra}
+\DeclareInputText{161}{\cyrb}
+\DeclareInputText{162}{\cyrv}
+\DeclareInputText{163}{\cyrg}
+\DeclareInputText{164}{\cyrd}
+\DeclareInputText{165}{\cyre}
+\DeclareInputText{166}{\cyrzh}
+\DeclareInputText{167}{\cyrz}
+\DeclareInputText{168}{\cyri}
+\DeclareInputText{169}{\cyrishrt}
+\DeclareInputText{170}{\cyrk}
+\DeclareInputText{171}{\cyrl}
+\DeclareInputText{172}{\cyrm}
+\DeclareInputText{173}{\cyrn}
+\DeclareInputText{174}{\cyro}
+\DeclareInputText{175}{\cyrp}
+\DeclareInputText{224}{\cyrr}
+\DeclareInputText{225}{\cyrs}
+\DeclareInputText{226}{\cyrt}
+\DeclareInputText{227}{\cyru}
+\DeclareInputText{228}{\cyrf}
+\DeclareInputText{229}{\cyrh}
+\DeclareInputText{230}{\cyrc}
+\DeclareInputText{231}{\cyrch}
+\DeclareInputText{232}{\cyrsh}
+\DeclareInputText{233}{\cyrshch}
+\DeclareInputText{234}{\cyrhrdsn}
+\DeclareInputText{235}{\cyrery}
+\DeclareInputText{236}{\cyrsftsn}
+\DeclareInputText{237}{\cyrerev}
+\DeclareInputText{238}{\cyryu}
+\DeclareInputText{239}{\cyrya}
+%
+\DeclareInputText{240}{\CYRYO}
+\DeclareInputText{241}{\cyryo}
+% \end{macrocode}
+%
+% The following block corresponds to the \emph{standard} cp~866
+% codepage:
+%
+% \begin{macrocode}
+%<*std>
+\DeclareInputText{242}{\CYRIE}
+\DeclareInputText{243}{\cyrie}
+\DeclareInputText{244}{\CYRYI}
+\DeclareInputText{245}{\cyryi}
+\DeclareInputText{246}{\CYRUSHRT}
+\DeclareInputText{247}{\cyrushrt}
+\DeclareInputText{248}{\textdegree}
+\DeclareInputText{249}{\textbullet}
+\DeclareInputText{250}{\textperiodcentered}
+\DeclareInputMath{251}{\surd}
+\DeclareInputText{252}{\textnumero}
+\DeclareInputText{253}{\textcurrency}
+\DeclareInputText{254}{\textblacksquare}
+%</std>
+% \end{macrocode}
+%
+% The following block corresponds to the so called \emph{Alternative
+% Variant} (AV) of cp~866:
+%
+% \begin{macrocode}
+%<*AV>
+% 0xf2 LOW ACUTE ACCENT
+% 0xf3 LOW GRAVE ACCENT
+% 0xf4 HIGH ACUTE ACCENT
+% 0xf5 HIGH GRAVE ACCENT
+\DeclareInputMath{246}{\rightarrow}
+\DeclareInputMath{247}{\leftarrow}
+\DeclareInputMath{248}{\downarrow}
+\DeclareInputMath{249}{\uparrow}
+\DeclareInputMath{250}{\div}
+\DeclareInputMath{251}{\pm}
+\DeclareInputText{252}{\textnumero}
+\DeclareInputText{253}{\textcurrency}
+\DeclareInputText{254}{\textblacksquare}
+%</AV>
+% \end{macrocode}
+%
+% The following block corresponds to the so called \emph{Modified
+% Alternative Variant} (MAV) of cp~866. Symbols |0xf2| through |0xfd|
+% match standard IBM coding (MS code page~437):
+%
+% \begin{macrocode}
+%<*MAV>
+\DeclareInputMath{242}{\geq}
+\DeclareInputMath{243}{\leq}
+% 0xf4 TOP HALF INTEGRAL
+% 0xf5 BOTTOM HALF INTEGRAL
+\DeclareInputMath{246}{\div}
+\DeclareInputMath{247}{\sim}
+\DeclareInputText{248}{\textdegree}
+\DeclareInputText{249}{\textbullet}
+\DeclareInputText{250}{\textperiodcentered}
+\DeclareInputMath{251}{\surd}
+\DeclareInputMath{252}{\mathnsuperior}
+\DeclareInputMath{253}{\mathtwosuperior}
+\DeclareInputText{254}{\textblacksquare}
+%</MAV>
+% \end{macrocode}
+%
+% The following block corresponds to the yet another modern
+% modification of cp~866:
+%
+% \begin{macrocode}
+%<*NAV>
+\DeclareInputText{242}{\CYRGUP}
+\DeclareInputText{243}{\cyrgup}
+\DeclareInputText{244}{\CYRIE}
+\DeclareInputText{245}{\cyrie}
+\DeclareInputText{246}{\CYRII}
+\DeclareInputText{247}{\cyrii}
+\DeclareInputText{248}{\CYRYI}
+\DeclareInputText{249}{\cyryi}
+\DeclareInputText{250}{\CYRUSHRT}
+\DeclareInputText{251}{\cyrushrt}
+\DeclareInputText{252}{\textnumero}
+% ? left European quotes:
+\DeclareInputText{253}{\guillemotleft}
+% ? right European quotes:
+\DeclareInputText{254}{\guillemotright}
+%</NAV>
+% \end{macrocode}
+%
+% The following block corresponds to the experimental Tatarian
+% modification of cp~866. Information was taken from the LH fonts.
+%
+% \begin{macrocode}
+%<*Tatar>
+\DeclareInputText{242}{\CYRSCHWA}
+\DeclareInputText{243}{\cyrschwa}
+\DeclareInputText{244}{\CYROTLD}
+\DeclareInputText{245}{\cyrotld}
+\DeclareInputText{246}{\CYRY}
+\DeclareInputText{247}{\cyry}
+\DeclareInputText{248}{\CYRZHDSC}
+\DeclareInputText{249}{\cyrzhdsc}
+\DeclareInputText{250}{\CYRNDSC}
+\DeclareInputText{251}{\cyrndsc}
+\DeclareInputText{252}{\CYRSHHA}
+\DeclareInputText{253}{\cyrshha}
+% ? was not explicitly declared:
+\DeclareInputText{254}{\textblacksquare}
+%</Tatar>
+% \end{macrocode}
+%
+% \begin{macrocode}
+\DeclareInputText{255}{\nobreakspace}
+%</cp866>
+% \end{macrocode}
+%
+% \subsection{Microsoft cp~855}
+%
+% \begin{macrocode}
+%<*cp855>
+\DeclareInputText{128}{\cyrdje}
+\DeclareInputText{129}{\CYRDJE}
+\DeclareInputText{130}{\@tabacckludge'\cyrg}
+\DeclareInputText{131}{\@tabacckludge'\CYRG}
+\DeclareInputText{132}{\cyryo}
+\DeclareInputText{133}{\CYRYO}
+\DeclareInputText{134}{\cyrie}
+\DeclareInputText{135}{\CYRIE}
+\DeclareInputText{136}{\cyrdze}
+\DeclareInputText{137}{\CYRDZE}
+\DeclareInputText{138}{\cyrii}
+\DeclareInputText{139}{\CYRII}
+\DeclareInputText{140}{\cyryi}
+\DeclareInputText{141}{\CYRYI}
+\DeclareInputText{142}{\cyrje}
+\DeclareInputText{143}{\CYRJE}
+\DeclareInputText{144}{\cyrlje}
+\DeclareInputText{145}{\CYRLJE}
+\DeclareInputText{146}{\cyrnje}
+\DeclareInputText{147}{\CYRNJE}
+\DeclareInputText{148}{\cyrtshe}
+\DeclareInputText{149}{\CYRTSHE}
+\DeclareInputText{150}{\@tabacckludge'\cyrk}
+\DeclareInputText{151}{\@tabacckludge'\CYRK}
+\DeclareInputText{152}{\cyrushrt}
+\DeclareInputText{153}{\CYRUSHRT}
+\DeclareInputText{154}{\cyrdzhe}
+\DeclareInputText{155}{\CYRDZHE}
+\DeclareInputText{156}{\cyryu}
+\DeclareInputText{157}{\CYRYU}
+\DeclareInputText{158}{\cyrhrdsn}
+\DeclareInputText{159}{\CYRHRDSN}
+\DeclareInputText{160}{\cyra}
+\DeclareInputText{161}{\CYRA}
+\DeclareInputText{162}{\cyrb}
+\DeclareInputText{163}{\CYRB}
+\DeclareInputText{164}{\cyrc}
+\DeclareInputText{165}{\CYRC}
+\DeclareInputText{166}{\cyrd}
+\DeclareInputText{167}{\CYRD}
+\DeclareInputText{168}{\cyre}
+\DeclareInputText{169}{\CYRE}
+\DeclareInputText{170}{\cyrf}
+\DeclareInputText{171}{\CYRF}
+\DeclareInputText{172}{\cyrg}
+\DeclareInputText{173}{\CYRG}
+\DeclareInputText{174}{\guillemotleft}
+\DeclareInputText{175}{\guillemotright}
+% 0xb0 LIGHT SHADE
+% 0xb1 MEDIUM SHADE
+% 0xb2 DARK SHADE
+% 0xb3 BOX DRAWINGS LIGHT VERTICAL
+% 0xb4 BOX DRAWINGS LIGHT VERTICAL AND LEFT
+\DeclareInputText{181}{\cyrh}
+\DeclareInputText{182}{\CYRH}
+\DeclareInputText{183}{\cyri}
+\DeclareInputText{184}{\CYRI}
+% 0xb9 BOX DRAWINGS DOUBLE VERTICAL AND LEFT
+% 0xba BOX DRAWINGS DOUBLE VERTICAL
+% 0xbb BOX DRAWINGS DOUBLE DOWN AND LEFT
+% 0xbc BOX DRAWINGS DOUBLE UP AND LEFT
+\DeclareInputText{189}{\cyrishrt}
+\DeclareInputText{190}{\CYRISHRT}
+% 0xbf BOX DRAWINGS LIGHT DOWN AND LEFT
+% 0xc0 BOX DRAWINGS LIGHT UP AND RIGHT
+% 0xc1 BOX DRAWINGS LIGHT UP AND HORIZONTAL
+% 0xc2 BOX DRAWINGS LIGHT DOWN AND HORIZONTAL
+% 0xc3 BOX DRAWINGS LIGHT VERTICAL AND RIGHT
+% 0xc4 BOX DRAWINGS LIGHT HORIZONTAL
+% 0xc5 BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL
+\DeclareInputText{198}{\cyrk}
+\DeclareInputText{199}{\CYRK}
+% 0xc8 BOX DRAWINGS DOUBLE UP AND RIGHT
+% 0xc9 BOX DRAWINGS DOUBLE DOWN AND RIGHT
+% 0xca BOX DRAWINGS DOUBLE UP AND HORIZONTAL
+% 0xcb BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL
+% 0xcc BOX DRAWINGS DOUBLE VERTICAL AND RIGHT
+% 0xcd BOX DRAWINGS DOUBLE HORIZONTAL
+% 0xce BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL
+\DeclareInputText{207}{\textcurrency}
+\DeclareInputText{208}{\cyrl}
+\DeclareInputText{209}{\CYRL}
+\DeclareInputText{210}{\cyrm}
+\DeclareInputText{211}{\CYRM}
+\DeclareInputText{212}{\cyrn}
+\DeclareInputText{213}{\CYRN}
+\DeclareInputText{214}{\cyro}
+\DeclareInputText{215}{\CYRO}
+\DeclareInputText{216}{\cyrp}
+% 0xd9 BOX DRAWINGS LIGHT UP AND LEFT
+% 0xda BOX DRAWINGS LIGHT DOWN AND RIGHT
+% 0xdb FULL BLOCK
+% 0xdc LOWER HALF BLOCK
+\DeclareInputText{221}{\CYRP}
+\DeclareInputText{222}{\cyrya}
+% 0xdf UPPER HALF BLOCK
+\DeclareInputText{224}{\CYRYA}
+\DeclareInputText{225}{\cyrr}
+\DeclareInputText{226}{\CYRR}
+\DeclareInputText{227}{\cyrs}
+\DeclareInputText{228}{\CYRS}
+\DeclareInputText{229}{\cyrt}
+\DeclareInputText{230}{\CYRT}
+\DeclareInputText{231}{\cyru}
+\DeclareInputText{232}{\CYRU}
+\DeclareInputText{233}{\cyrzh}
+\DeclareInputText{234}{\CYRZH}
+\DeclareInputText{235}{\cyrv}
+\DeclareInputText{236}{\CYRV}
+\DeclareInputText{237}{\cyrsftsn}
+\DeclareInputText{238}{\CYRSFTSN}
+\DeclareInputText{239}{\textnumero}
+\DeclareInputText{240}{\-}
+\DeclareInputText{241}{\cyrery}
+\DeclareInputText{242}{\CYRERY}
+\DeclareInputText{243}{\cyrz}
+\DeclareInputText{244}{\CYRZ}
+\DeclareInputText{245}{\cyrsh}
+\DeclareInputText{246}{\CYRSH}
+\DeclareInputText{247}{\cyrerev}
+\DeclareInputText{248}{\CYREREV}
+\DeclareInputText{249}{\cyrshch}
+\DeclareInputText{250}{\CYRSHCH}
+\DeclareInputText{251}{\cyrch}
+\DeclareInputText{252}{\CYRCH}
+\DeclareInputText{253}{\S}
+\DeclareInputText{254}{\textblacksquare}
+\DeclareInputText{255}{\nobreakspace}
+%</cp855>
+% \end{macrocode}
+%
+% \subsection{Microsoft cp~1251 and ParaType pt~154}
+%
+% \begin{macrocode}
+%<*cp1251|pt154>
+\DeclareInputText{192}{\CYRA}
+\DeclareInputText{193}{\CYRB}
+\DeclareInputText{194}{\CYRV}
+\DeclareInputText{195}{\CYRG}
+\DeclareInputText{196}{\CYRD}
+\DeclareInputText{197}{\CYRE}
+\DeclareInputText{198}{\CYRZH}
+\DeclareInputText{199}{\CYRZ}
+\DeclareInputText{200}{\CYRI}
+\DeclareInputText{201}{\CYRISHRT}
+\DeclareInputText{202}{\CYRK}
+\DeclareInputText{203}{\CYRL}
+\DeclareInputText{204}{\CYRM}
+\DeclareInputText{205}{\CYRN}
+\DeclareInputText{206}{\CYRO}
+\DeclareInputText{207}{\CYRP}
+\DeclareInputText{208}{\CYRR}
+\DeclareInputText{209}{\CYRS}
+\DeclareInputText{210}{\CYRT}
+\DeclareInputText{211}{\CYRU}
+\DeclareInputText{212}{\CYRF}
+\DeclareInputText{213}{\CYRH}
+\DeclareInputText{214}{\CYRC}
+\DeclareInputText{215}{\CYRCH}
+\DeclareInputText{216}{\CYRSH}
+\DeclareInputText{217}{\CYRSHCH}
+\DeclareInputText{218}{\CYRHRDSN}
+\DeclareInputText{219}{\CYRERY}
+\DeclareInputText{220}{\CYRSFTSN}
+\DeclareInputText{221}{\CYREREV}
+\DeclareInputText{222}{\CYRYU}
+\DeclareInputText{223}{\CYRYA}
+%
+\DeclareInputText{224}{\cyra}
+\DeclareInputText{225}{\cyrb}
+\DeclareInputText{226}{\cyrv}
+\DeclareInputText{227}{\cyrg}
+\DeclareInputText{228}{\cyrd}
+\DeclareInputText{229}{\cyre}
+\DeclareInputText{230}{\cyrzh}
+\DeclareInputText{231}{\cyrz}
+\DeclareInputText{232}{\cyri}
+\DeclareInputText{233}{\cyrishrt}
+\DeclareInputText{234}{\cyrk}
+\DeclareInputText{235}{\cyrl}
+\DeclareInputText{236}{\cyrm}
+\DeclareInputText{237}{\cyrn}
+\DeclareInputText{238}{\cyro}
+\DeclareInputText{239}{\cyrp}
+\DeclareInputText{240}{\cyrr}
+\DeclareInputText{241}{\cyrs}
+\DeclareInputText{242}{\cyrt}
+\DeclareInputText{243}{\cyru}
+\DeclareInputText{244}{\cyrf}
+\DeclareInputText{245}{\cyrh}
+\DeclareInputText{246}{\cyrc}
+\DeclareInputText{247}{\cyrch}
+\DeclareInputText{248}{\cyrsh}
+\DeclareInputText{249}{\cyrshch}
+\DeclareInputText{250}{\cyrhrdsn}
+\DeclareInputText{251}{\cyrery}
+\DeclareInputText{252}{\cyrsftsn}
+\DeclareInputText{253}{\cyrerev}
+\DeclareInputText{254}{\cyryu}
+\DeclareInputText{255}{\cyrya}
+%
+%<cp1251>\DeclareInputText{128}{\CYRDJE}
+%<cp1251>\DeclareInputText{129}{\@tabacckludge'\CYRG}
+%<pt154>\DeclareInputText{128}{\CYRZHDSC}
+%<pt154>\DeclareInputText{129}{\CYRGHCRS}
+\DeclareInputText{130}{\quotesinglbase}
+%<cp1251>\DeclareInputText{131}{\@tabacckludge'\cyrg}
+%<pt154>\DeclareInputText{131}{\cyrghcrs}
+\DeclareInputText{132}{\quotedblbase}
+\DeclareInputText{133}{\dots}
+\DeclareInputText{134}{\dag}
+%<*cp1251>
+\DeclareInputText{135}{\ddag}
+\DeclareInputText{136}{\texteuro}
+\DeclareInputText{137}{\textperthousand}
+\DeclareInputText{138}{\CYRLJE}
+%</cp1251>
+%<*pt154>
+\DeclareInputText{135}{\CYRY}
+\DeclareInputText{136}{\CYRHDSC}
+\DeclareInputText{137}{\cyry}
+\DeclareInputText{138}{\CYRKBEAK}
+%</pt154>
+\DeclareInputText{139}{\guilsinglleft}
+%<*cp1251>
+\DeclareInputText{140}{\CYRNJE}
+\DeclareInputText{141}{\@tabacckludge'\CYRK}
+\DeclareInputText{142}{\CYRTSHE}
+\DeclareInputText{143}{\CYRDZHE}
+\DeclareInputText{144}{\cyrdje}
+%</cp1251>
+%<*pt154>
+\DeclareInputText{140}{\CYRNDSC}
+\DeclareInputText{141}{\CYRKDSC}
+\DeclareInputText{142}{\CYRSHHA}
+\DeclareInputText{143}{\CYRCHVCRS}
+\DeclareInputText{144}{\cyrzhdsc}
+%</pt154>
+\DeclareInputText{145}{\textquoteleft}
+\DeclareInputText{146}{\textquoteright}
+\DeclareInputText{147}{\textquotedblleft}
+\DeclareInputText{148}{\textquotedblright}
+\DeclareInputText{149}{\textbullet}
+\DeclareInputText{150}{\textendash}
+\DeclareInputText{151}{\textemdash}
+% 0x98 undefined in cp1251
+%<pt154>\DeclareInputText{152}{\cyrhdsc}
+\DeclareInputText{153}{\texttrademark}
+%<cp1251>\DeclareInputText{154}{\cyrlje}
+%<pt154>\DeclareInputText{154}{\cyrkbeak}
+\DeclareInputText{155}{\guilsinglright}
+%<*cp1251>
+\DeclareInputText{156}{\cyrnje}
+\DeclareInputText{157}{\@tabacckludge'\cyrk}
+\DeclareInputText{158}{\cyrtshe}
+\DeclareInputText{159}{\cyrdzhe}
+%</cp1251>
+%<*pt154>
+\DeclareInputText{156}{\cyrndsc}
+\DeclareInputText{157}{\cyrkdsc}
+\DeclareInputText{158}{\cyrshha}
+\DeclareInputText{159}{\cyrchvcrs}
+%</pt154>
+\DeclareInputText{160}{\nobreakspace}
+\DeclareInputText{161}{\CYRUSHRT}
+\DeclareInputText{162}{\cyrushrt}
+\DeclareInputText{163}{\CYRJE}
+%<*cp1251>
+\DeclareInputText{164}{\textcurrency}
+\DeclareInputText{165}{\CYRGUP}
+\DeclareInputText{166}{\textbrokenbar}
+%</cp1251>
+%<*pt154>
+\DeclareInputText{164}{\CYROTLD}
+\DeclareInputText{165}{\CYRZDSC}
+\DeclareInputText{166}{\CYRYHCRS}
+%</pt154>
+\DeclareInputText{167}{\S}
+\DeclareInputText{168}{\CYRYO}
+\DeclareInputText{169}{\copyright}
+%<cp1251>\DeclareInputText{170}{\CYRIE}
+%<pt154>\DeclareInputText{170}{\CYRSCHWA}
+\DeclareInputText{171}{\guillemotleft}
+\DeclareInputMath{172}{\lnot}
+\DeclareInputText{173}{\-}
+\DeclareInputText{174}{\textregistered}
+%<cp1251>\DeclareInputText{175}{\CYRYI}
+%<pt154>\DeclareInputText{175}{\CYRKVCRS}
+\DeclareInputText{176}{\textdegree}
+%<cp1251>\DeclareInputMath{177}{\pm}
+%<pt154>\DeclareInputText{177}{\cyryhcrs}
+\DeclareInputText{178}{\CYRII}
+\DeclareInputText{179}{\cyrii}
+%<cp1251>\DeclareInputText{180}{\cyrgup}
+%<cp1251>\DeclareInputMath{181}{\mu}
+%<pt154>\DeclareInputText{180}{\cyrzdsc}
+%<pt154>\DeclareInputText{181}{\cyrotld}
+\DeclareInputText{182}{\P}
+\DeclareInputText{183}{\textperiodcentered}
+\DeclareInputText{184}{\cyryo}
+\DeclareInputText{185}{\textnumero}
+%<cp1251>\DeclareInputText{186}{\cyrie}
+%<pt154>\DeclareInputText{186}{\cyrschwa}
+\DeclareInputText{187}{\guillemotright}
+\DeclareInputText{188}{\cyrje}
+%<*cp1251>
+\DeclareInputText{189}{\CYRDZE}
+\DeclareInputText{190}{\cyrdze}
+\DeclareInputText{191}{\cyryi}
+%</cp1251>
+%<*pt154>
+\DeclareInputText{189}{\CYRSDSC}
+\DeclareInputText{190}{\cyrsdsc}
+\DeclareInputText{191}{\cyrkvcrs}
+%</pt154>
+%</cp1251|pt154>
+% \end{macrocode}
+%
+% \subsection{The koi8 codepage}
+%
+% \begin{macrocode}
+%<*koi8>
+\DeclareInputText{225}{\CYRA}
+\DeclareInputText{226}{\CYRB}
+\DeclareInputText{247}{\CYRV}
+\DeclareInputText{231}{\CYRG}
+\DeclareInputText{228}{\CYRD}
+\DeclareInputText{229}{\CYRE}
+\DeclareInputText{179}{\CYRYO}
+\DeclareInputText{246}{\CYRZH}
+\DeclareInputText{250}{\CYRZ}
+\DeclareInputText{233}{\CYRI}
+\DeclareInputText{234}{\CYRISHRT}
+\DeclareInputText{235}{\CYRK}
+\DeclareInputText{236}{\CYRL}
+\DeclareInputText{237}{\CYRM}
+\DeclareInputText{238}{\CYRN}
+\DeclareInputText{239}{\CYRO}
+\DeclareInputText{240}{\CYRP}
+\DeclareInputText{242}{\CYRR}
+\DeclareInputText{243}{\CYRS}
+\DeclareInputText{244}{\CYRT}
+\DeclareInputText{245}{\CYRU}
+\DeclareInputText{230}{\CYRF}
+\DeclareInputText{232}{\CYRH}
+\DeclareInputText{227}{\CYRC}
+\DeclareInputText{254}{\CYRCH}
+\DeclareInputText{251}{\CYRSH}
+\DeclareInputText{253}{\CYRSHCH}
+\DeclareInputText{255}{\CYRHRDSN}
+\DeclareInputText{249}{\CYRERY}
+\DeclareInputText{248}{\CYRSFTSN}
+\DeclareInputText{252}{\CYREREV}
+\DeclareInputText{224}{\CYRYU}
+\DeclareInputText{241}{\CYRYA}
+%
+\DeclareInputText{193}{\cyra}
+\DeclareInputText{194}{\cyrb}
+\DeclareInputText{215}{\cyrv}
+\DeclareInputText{199}{\cyrg}
+\DeclareInputText{196}{\cyrd}
+\DeclareInputText{197}{\cyre}
+\DeclareInputText{163}{\cyryo}
+\DeclareInputText{214}{\cyrzh}
+\DeclareInputText{218}{\cyrz}
+\DeclareInputText{201}{\cyri}
+\DeclareInputText{202}{\cyrishrt}
+\DeclareInputText{203}{\cyrk}
+\DeclareInputText{204}{\cyrl}
+\DeclareInputText{205}{\cyrm}
+\DeclareInputText{206}{\cyrn}
+\DeclareInputText{207}{\cyro}
+\DeclareInputText{208}{\cyrp}
+\DeclareInputText{210}{\cyrr}
+\DeclareInputText{211}{\cyrs}
+\DeclareInputText{212}{\cyrt}
+\DeclareInputText{213}{\cyru}
+\DeclareInputText{198}{\cyrf}
+\DeclareInputText{200}{\cyrh}
+\DeclareInputText{195}{\cyrc}
+\DeclareInputText{222}{\cyrch}
+\DeclareInputText{219}{\cyrsh}
+\DeclareInputText{221}{\cyrshch}
+\DeclareInputText{223}{\cyrhrdsn}
+\DeclareInputText{217}{\cyrery}
+\DeclareInputText{216}{\cyrsftsn}
+\DeclareInputText{220}{\cyrerev}
+\DeclareInputText{192}{\cyryu}
+\DeclareInputText{209}{\cyrya}
+% \end{macrocode}
+%
+% \subsubsection{koi8-r and relatives (koi8-ru, koi8-u, ISO-IR-111)}
+%
+% |0x80|--|0x9f| are unused in the ISO~IR-111 Cyrillic Code Page
+%
+% \begin{macrocode}
+%<*koi8r|koi8ru>
+% 0x80 FORMS LIGHT HORIZONTAL
+% 0x81 FORMS LIGHT VERTICAL
+% 0x82 FORMS LIGHT DOWN AND RIGHT
+% 0x83 FORMS LIGHT DOWN AND LEFT
+% 0x84 FORMS LIGHT UP AND RIGHT
+% 0x85 FORMS LIGHT UP AND LEFT
+% 0x86 FORMS LIGHT VERTICAL AND RIGHT
+% 0x87 FORMS LIGHT VERTICAL AND LEFT
+% 0x88 FORMS LIGHT DOWN AND HORIZONTAL
+% 0x89 FORMS LIGHT UP AND HORIZONTAL
+% 0x8A FORMS LIGHT VERTICAL AND HORIZONTAL
+% 0x8B UPPER HALF BLOCK
+% 0x8C LOWER HALF BLOCK
+% 0x8D FULL BLOCK
+% 0x8E LEFT HALF BLOCK
+% 0x8F RIGHT HALF BLOCK
+% 0x90 LIGHT SHADE
+% 0x91 MEDIUM SHADE
+% 0x92 DARK SHADE
+%</koi8r|koi8ru>
+%<*koi8r>
+% 0x93 TOP HALF INTEGRAL
+%</koi8r>
+%<koi8ru>\DeclareInputText{147}{\textquotedblleft}
+%<*koi8r|koi8ru>
+\DeclareInputText{148}{\textblacksquare}
+\DeclareInputText{149}{\textbullet}
+%</koi8r|koi8ru>
+%<*koi8r>
+\DeclareInputMath{150}{\surd}
+\DeclareInputMath{151}{\sim}
+\DeclareInputMath{152}{\leq}
+\DeclareInputMath{153}{\geq}
+%</koi8r>
+%<*koi8ru>
+\DeclareInputText{150}{\textquotedblright}
+\DeclareInputText{151}{\textemdash}
+\DeclareInputText{152}{\textnumero}
+\DeclareInputText{153}{\texttrademark}
+%</koi8ru>
+%<koi8r|koi8ru>\DeclareInputText{154}{\nobreakspace}
+%<*koi8r>
+% 0x9B BOTTOM HALF INTEGRAL
+\DeclareInputText{156}{\textdegree}
+\DeclareInputMath{157}{\mathtwosuperior}
+%</koi8r>
+%<*koi8ru>
+\DeclareInputText{155}{\guillemotright}
+\DeclareInputText{156}{\textregistered}
+\DeclareInputText{157}{\guillemotleft}
+%</koi8ru>
+%<koi8r|koi8ru>\DeclareInputText{158}{\textperiodcentered}
+%<koi8r>\DeclareInputMath{159}{\div}
+%<koi8ru>\DeclareInputText{159}{\textcurrency}
+%<*koi8r|koi8ru>
+% 0xA0 FORMS DOUBLE HORIZONTAL
+% 0xA1 FORMS DOUBLE VERTICAL
+% 0xA2 FORMS DOWN SINGLE AND RIGHT DOUBLE
+%</koi8r|koi8ru>
+%<*isoir111>
+\DeclareInputText{160}{\nobreakspace}
+\DeclareInputText{161}{\cyrdje}
+\DeclareInputText{162}{\@tabacckludge'\cyrg}
+%</isoir111>
+%<*koi8r>
+% 0xA4 FORMS DOWN DOUBLE AND RIGHT SINGLE
+%</koi8r>
+%<koi8ru|isoir111|koi8u>\DeclareInputText{164}{\cyrie}
+%<*koi8r|koi8ru>
+% 0xA5 FORMS DOUBLE DOWN AND RIGHT
+%</koi8r|koi8ru>
+%<isoir111>\DeclareInputText{165}{\cyrdze}
+%<*koi8r>
+% 0xA6 FORMS DOWN SINGLE AND LEFT DOUBLE
+% 0xA7 FORMS DOWN DOUBLE AND LEFT SINGLE
+%</koi8r>
+%<*koi8ru|isoir111|koi8u>
+\DeclareInputText{166}{\cyrii}
+\DeclareInputText{167}{\cyryi}
+%</koi8ru|isoir111|koi8u>
+%<*koi8r|koi8ru>
+% 0xA8 FORMS DOUBLE DOWN AND LEFT
+% 0xA9 FORMS UP SINGLE AND RIGHT DOUBLE
+% 0xAA FORMS UP DOUBLE AND RIGHT SINGLE
+% 0xAB FORMS DOUBLE UP AND RIGHT
+% 0xAC FORMS UP SINGLE AND LEFT DOUBLE
+%</koi8r|koi8ru>
+%<*isoir111>
+\DeclareInputText{168}{\cyrje}
+\DeclareInputText{169}{\cyrlje}
+\DeclareInputText{170}{\cyrnje}
+\DeclareInputText{171}{\cyrtshe}
+\DeclareInputText{172}{\@tabacckludge'\cyrk}
+%</isoir111>
+%<*koi8r>
+% 0xAD FORMS UP DOUBLE AND LEFT SINGLE
+% 0xAE FORMS DOUBLE UP AND LEFT
+%</koi8r>
+%<koi8ru|koi8u>\DeclareInputText{173}{\cyrgup}
+%<isoir111>\DeclareInputText{173}{\-}
+%<koi8ru|isoir111>\DeclareInputText{174}{\cyrushrt}
+%<*koi8r|koi8ru>
+% 0xAF FORMS VERTICAL SINGLE AND RIGHT DOUBLE
+% 0xB0 FORMS VERTICAL DOUBLE AND RIGHT SINGLE
+% 0xB1 FORMS DOUBLE VERTICAL AND RIGHT
+% 0xB2 FORMS VERTICAL SINGLE AND LEFT DOUBLE
+%</koi8r|koi8ru>
+%<*isoir111>
+\DeclareInputText{175}{\cyrdzhe}
+\DeclareInputText{176}{\textnumero}
+\DeclareInputText{177}{\CYRDJE}
+\DeclareInputText{178}{\@tabacckludge'\CYRG}
+%</isoir111>
+%<*koi8r>
+% 0xB4 FORMS VERTICAL DOUBLE AND LEFT SINGLE
+%</koi8r>
+%<koi8ru|isoir111|koi8u>\DeclareInputText{180}{\CYRIE}
+%<*koi8r|koi8ru>
+% 0xB5 FORMS DOUBLE VERTICAL AND LEFT
+%</koi8r|koi8ru>
+%<isoir111>\DeclareInputText{181}{\CYRDZE}
+%<*koi8r>
+% 0xB6 FORMS DOWN SINGLE AND HORIZONTAL DOUBLE
+% 0xB7 FORMS DOWN DOUBLE AND HORIZONTAL SINGLE
+%</koi8r>
+%<*koi8ru|isoir111|koi8u>
+\DeclareInputText{182}{\CYRII}
+\DeclareInputText{183}{\CYRYI}
+%</koi8ru|isoir111|koi8u>
+%<*koi8r|koi8ru>
+% 0xB8 FORMS DOUBLE DOWN AND HORIZONTAL
+% 0xB9 FORMS UP SINGLE AND HORIZONTAL DOUBLE
+% 0xBA FORMS UP DOUBLE AND HORIZONTAL SINGLE
+% 0xBB FORMS DOUBLE UP AND HORIZONTAL
+% 0xBC FORMS VERTICAL SINGLE AND HORIZONTAL DOUBLE
+%</koi8r|koi8ru>
+%<*isoir111>
+\DeclareInputText{184}{\CYRJE}
+\DeclareInputText{185}{\CYRLJE}
+\DeclareInputText{186}{\CYRNJE}
+\DeclareInputText{187}{\CYRTSHE}
+\DeclareInputText{188}{\@tabacckludge'\CYRK}
+%</isoir111>
+%<*koi8r>
+% 0xBD FORMS VERTICAL DOUBLE AND HORIZONTAL SINGLE
+% 0xBE FORMS DOUBLE VERTICAL AND HORIZONTAL
+%</koi8r>
+%<koi8ru|koi8u>\DeclareInputText{189}{\CYRGUP}
+%<isoir111>\DeclareInputText{189}{\textcurrency}
+%<koi8ru|isoir111>\DeclareInputText{190}{\CYRUSHRT}
+%<koi8r|koi8ru>\DeclareInputText{191}{\copyright}
+%<isoir111>\DeclareInputText{191}{\CYRDZHE}
+%</koi8>
+% \end{macrocode}
+%
+% \subsection{ISO~8859-5}
+%
+% \begin{macrocode}
+%<*ISO88595>
+\DeclareInputText{160}{\nobreakspace}
+\DeclareInputText{161}{\CYRYO}
+\DeclareInputText{162}{\CYRDJE}
+\DeclareInputText{163}{\@tabacckludge'\CYRG}
+\DeclareInputText{164}{\CYRIE}
+\DeclareInputText{165}{\CYRDZE}
+\DeclareInputText{166}{\CYRII}
+\DeclareInputText{167}{\CYRYI}
+\DeclareInputText{168}{\CYRJE}
+\DeclareInputText{169}{\CYRLJE}
+\DeclareInputText{170}{\CYRNJE}
+\DeclareInputText{171}{\CYRTSHE}
+\DeclareInputText{172}{\@tabacckludge'\CYRK}
+\DeclareInputText{173}{\-}
+\DeclareInputText{174}{\CYRUSHRT}
+\DeclareInputText{175}{\CYRDZHE}
+%
+\DeclareInputText{176}{\CYRA}
+\DeclareInputText{177}{\CYRB}
+\DeclareInputText{178}{\CYRV}
+\DeclareInputText{179}{\CYRG}
+\DeclareInputText{180}{\CYRD}
+\DeclareInputText{181}{\CYRE}
+\DeclareInputText{182}{\CYRZH}
+\DeclareInputText{183}{\CYRZ}
+\DeclareInputText{184}{\CYRI}
+\DeclareInputText{185}{\CYRISHRT}
+\DeclareInputText{186}{\CYRK}
+\DeclareInputText{187}{\CYRL}
+\DeclareInputText{188}{\CYRM}
+\DeclareInputText{189}{\CYRN}
+\DeclareInputText{190}{\CYRO}
+\DeclareInputText{191}{\CYRP}
+\DeclareInputText{192}{\CYRR}
+\DeclareInputText{193}{\CYRS}
+\DeclareInputText{194}{\CYRT}
+\DeclareInputText{195}{\CYRU}
+\DeclareInputText{196}{\CYRF}
+\DeclareInputText{197}{\CYRH}
+\DeclareInputText{198}{\CYRC}
+\DeclareInputText{199}{\CYRCH}
+\DeclareInputText{200}{\CYRSH}
+\DeclareInputText{201}{\CYRSHCH}
+\DeclareInputText{202}{\CYRHRDSN}
+\DeclareInputText{203}{\CYRERY}
+\DeclareInputText{204}{\CYRSFTSN}
+\DeclareInputText{205}{\CYREREV}
+\DeclareInputText{206}{\CYRYU}
+\DeclareInputText{207}{\CYRYA}
+%
+\DeclareInputText{208}{\cyra}
+\DeclareInputText{209}{\cyrb}
+\DeclareInputText{210}{\cyrv}
+\DeclareInputText{211}{\cyrg}
+\DeclareInputText{212}{\cyrd}
+\DeclareInputText{213}{\cyre}
+\DeclareInputText{214}{\cyrzh}
+\DeclareInputText{215}{\cyrz}
+\DeclareInputText{216}{\cyri}
+\DeclareInputText{217}{\cyrishrt}
+\DeclareInputText{218}{\cyrk}
+\DeclareInputText{219}{\cyrl}
+\DeclareInputText{220}{\cyrm}
+\DeclareInputText{221}{\cyrn}
+\DeclareInputText{222}{\cyro}
+\DeclareInputText{223}{\cyrp}
+\DeclareInputText{224}{\cyrr}
+\DeclareInputText{225}{\cyrs}
+\DeclareInputText{226}{\cyrt}
+\DeclareInputText{227}{\cyru}
+\DeclareInputText{228}{\cyrf}
+\DeclareInputText{229}{\cyrh}
+\DeclareInputText{230}{\cyrc}
+\DeclareInputText{231}{\cyrch}
+\DeclareInputText{232}{\cyrsh}
+\DeclareInputText{233}{\cyrshch}
+\DeclareInputText{234}{\cyrhrdsn}
+\DeclareInputText{235}{\cyrery}
+\DeclareInputText{236}{\cyrsftsn}
+\DeclareInputText{237}{\cyrerev}
+\DeclareInputText{238}{\cyryu}
+\DeclareInputText{239}{\cyrya}
+%
+\DeclareInputText{240}{\textnumero}
+\DeclareInputText{241}{\cyryo}
+\DeclareInputText{242}{\cyrdje}
+\DeclareInputText{243}{\@tabacckludge'\cyrg}
+\DeclareInputText{244}{\cyrie}
+\DeclareInputText{245}{\cyrdze}
+\DeclareInputText{246}{\cyrii}
+\DeclareInputText{247}{\cyryi}
+\DeclareInputText{248}{\cyrje}
+\DeclareInputText{249}{\cyrlje}
+\DeclareInputText{250}{\cyrnje}
+\DeclareInputText{251}{\cyrtshe}
+\DeclareInputText{252}{\@tabacckludge'\cyrk}
+\DeclareInputText{253}{\S}
+\DeclareInputText{254}{\cyrushrt}
+\DeclareInputText{255}{\cyrdzhe}
+%</ISO88595>
+% \end{macrocode}
+%
+% \subsection{Apple Macintosh Cyrillic encodings and ParaType pt~254}
+%
+% The MacOS Cyrillic encoding (Microsoft cp~10007) includes the full
+% Cyrillic letter repertory of ISO~8859-5 (although not at the same
+% code points). This covers most of the Slavic languages written with
+% the Cyrillic script.
+%
+% The MacOS Cyrillic encoding also includes a number of characters
+% needed for the MacOS user interface (e.g.\ ellipsis, bullet for
+% echoing passwords, copyright sign, etc). All of the characters in
+% MacOS Cyrillic that are also in the MacOS Roman encoding are at the
+% same code points as specified in MacOS Roman. This improves
+% application compatibility (since some naughty applications hard-code
+% the MacOS Roman code points of certain characters).
+%
+% A variant of MacOS Cyrillic is used for Ukrainian. This character
+% encoding adds upper and lower GHE WITH UPTURN, for a grand total of
+% 2~code point differences from standard MacOS Cyrillic.
+%
+% \begin{macrocode}
+%<*maccyrillic|macukrainian|pt254>
+\DeclareInputText{128}{\CYRA}
+\DeclareInputText{129}{\CYRB}
+\DeclareInputText{130}{\CYRV}
+\DeclareInputText{131}{\CYRG}
+\DeclareInputText{132}{\CYRD}
+\DeclareInputText{133}{\CYRE}
+\DeclareInputText{134}{\CYRZH}
+\DeclareInputText{135}{\CYRZ}
+\DeclareInputText{136}{\CYRI}
+\DeclareInputText{137}{\CYRISHRT}
+\DeclareInputText{138}{\CYRK}
+\DeclareInputText{139}{\CYRL}
+\DeclareInputText{140}{\CYRM}
+\DeclareInputText{141}{\CYRN}
+\DeclareInputText{142}{\CYRO}
+\DeclareInputText{143}{\CYRP}
+\DeclareInputText{144}{\CYRR}
+\DeclareInputText{145}{\CYRS}
+\DeclareInputText{146}{\CYRT}
+\DeclareInputText{147}{\CYRU}
+\DeclareInputText{148}{\CYRF}
+\DeclareInputText{149}{\CYRH}
+\DeclareInputText{150}{\CYRC}
+\DeclareInputText{151}{\CYRCH}
+\DeclareInputText{152}{\CYRSH}
+\DeclareInputText{153}{\CYRSHCH}
+\DeclareInputText{154}{\CYRHRDSN}
+\DeclareInputText{155}{\CYRERY}
+\DeclareInputText{156}{\CYRSFTSN}
+\DeclareInputText{157}{\CYREREV}
+\DeclareInputText{158}{\CYRYU}
+\DeclareInputText{159}{\CYRYA}
+%
+\DeclareInputText{160}{\dag}
+\DeclareInputText{161}{\textdegree}
+%<maccyrillic|pt254>\DeclareInputText{162}{\textcent}
+%<macukrainian>\DeclareInputText{162}{\CYRGUP}
+\DeclareInputText{163}{\pounds}
+\DeclareInputText{164}{\S}
+\DeclareInputText{165}{\textbullet}
+\DeclareInputText{166}{\P}
+\DeclareInputText{167}{\CYRII}
+\DeclareInputText{168}{\textregistered}
+\DeclareInputText{169}{\copyright}
+\DeclareInputText{170}{\texttrademark}
+%<*maccyrillic|macukrainian>
+\DeclareInputText{171}{\CYRDJE}
+\DeclareInputText{172}{\cyrdje}
+\DeclareInputMath{173}{\neq}
+\DeclareInputText{174}{\@tabacckludge'\CYRG}
+\DeclareInputText{175}{\@tabacckludge'\cyrg}
+\DeclareInputMath{176}{\infty}
+\DeclareInputMath{177}{\pm}
+%</maccyrillic|macukrainian>
+%<*pt254>
+\DeclareInputText{171}{\CYRZHDSC}
+\DeclareInputText{172}{\cyrzhdsc}
+\DeclareInputText{173}{\cyrii}
+\DeclareInputText{174}{\CYRGHCRS}
+\DeclareInputText{175}{\cyrghcrs}
+\DeclareInputText{176}{\CYRZDSC}
+\DeclareInputText{177}{\cyrzdsc}
+%</pt254>
+\DeclareInputMath{178}{\leq}
+\DeclareInputMath{179}{\geq}
+%<maccyrillic|macukrainian>\DeclareInputText{180}{\cyrii}
+%<maccyrillic|macukrainian>\DeclareInputMath{181}{\mu}
+%<pt254>\DeclareInputText{180}{\CYRYHCRS}
+%<pt254>\DeclareInputText{181}{\cyrotld}
+%<maccyrillic>\DeclareInputMath{182}{\partial}
+%<macukrainian>\DeclareInputText{182}{\cyrgup}
+%<pt254>\DeclareInputText{182}{\CYRY}
+%
+\DeclareInputText{183}{\CYRJE}
+%<*maccyrillic|macukrainian>
+\DeclareInputText{184}{\CYRIE}
+\DeclareInputText{185}{\cyrie}
+\DeclareInputText{186}{\CYRYI}
+\DeclareInputText{187}{\cyryi}
+\DeclareInputText{188}{\CYRLJE}
+\DeclareInputText{189}{\cyrlje}
+\DeclareInputText{190}{\CYRNJE}
+\DeclareInputText{191}{\cyrnje}
+%</maccyrillic|macukrainian>
+%<*pt254>
+\DeclareInputText{184}{\CYRSCHWA}
+\DeclareInputText{185}{\cyrschwa}
+\DeclareInputText{186}{\CYRKVCRS}
+\DeclareInputText{187}{\cyrkvcrs}
+\DeclareInputText{188}{\CYRKBEAK}
+\DeclareInputText{189}{\cyrkbeak}
+\DeclareInputText{190}{\CYRNDSC}
+\DeclareInputText{191}{\cyrndsc}
+%</pt254>
+\DeclareInputText{192}{\cyrje}
+%<maccyrillic|macukrainian>\DeclareInputText{193}{\CYRDZE}
+%<pt254>\DeclareInputText{193}{\CYRSDSC}
+%
+\DeclareInputMath{194}{\lnot}
+%<*maccyrillic|macukrainian>
+\DeclareInputMath{195}{\surd}
+\DeclareInputText{196}{\textflorin}
+\DeclareInputMath{197}{\approx}
+% INCREMENT:
+\DeclareInputMath{198}{\Delta}
+%</maccyrillic|macukrainian>
+%<*pt254>
+\DeclareInputText{195}{\CYRHDSC}
+\DeclareInputText{196}{\cyryhcrs}
+\DeclareInputText{197}{\cyrhdsc}
+\DeclareInputText{198}{\cyry}
+%</pt254>
+\DeclareInputText{199}{\guillemotleft}
+\DeclareInputText{200}{\guillemotright}
+% HORIZONTAL ELLIPSIS:
+\DeclareInputText{201}{\dots}
+\DeclareInputText{202}{\nobreakspace}
+%
+%<*maccyrillic|macukrainian>
+\DeclareInputText{203}{\CYRTSHE}
+\DeclareInputText{204}{\cyrtshe}
+\DeclareInputText{205}{\@tabacckludge'\CYRK}
+\DeclareInputText{206}{\@tabacckludge'\cyrk}
+\DeclareInputText{207}{\cyrdze}
+%</maccyrillic|macukrainian>
+%<*pt254>
+\DeclareInputText{203}{\CYRSHHA}
+\DeclareInputText{204}{\cyrshha}
+\DeclareInputText{205}{\CYRKDSC}
+\DeclareInputText{206}{\cyrkdsc}
+\DeclareInputText{207}{\cyrsdsc}
+%</pt254>
+%
+\DeclareInputText{208}{\textendash}
+\DeclareInputText{209}{\textemdash}
+\DeclareInputText{210}{\textquotedblleft}
+\DeclareInputText{211}{\textquotedblright}
+\DeclareInputText{212}{\textquoteleft}
+\DeclareInputText{213}{\textquoteright}
+\DeclareInputMath{214}{\div}
+\DeclareInputText{215}{\quotedblbase}
+%
+\DeclareInputText{216}{\CYRUSHRT}
+\DeclareInputText{217}{\cyrushrt}
+%<maccyrillic|macukrainian>\DeclareInputText{218}{\CYRDZHE}
+%<maccyrillic|macukrainian>\DeclareInputText{219}{\cyrdzhe}
+%<pt254>\DeclareInputText{218}{\CYRCHVCRS}
+%<pt254>\DeclareInputText{219}{\cyrchvcrs}
+\DeclareInputText{220}{\textnumero}
+%
+\DeclareInputText{221}{\CYRYO}
+\DeclareInputText{222}{\cyryo}
+\DeclareInputText{223}{\cyrya}
+\DeclareInputText{224}{\cyra}
+\DeclareInputText{225}{\cyrb}
+\DeclareInputText{226}{\cyrv}
+\DeclareInputText{227}{\cyrg}
+\DeclareInputText{228}{\cyrd}
+\DeclareInputText{229}{\cyre}
+\DeclareInputText{230}{\cyrzh}
+\DeclareInputText{231}{\cyrz}
+\DeclareInputText{232}{\cyri}
+\DeclareInputText{233}{\cyrishrt}
+\DeclareInputText{234}{\cyrk}
+\DeclareInputText{235}{\cyrl}
+\DeclareInputText{236}{\cyrm}
+\DeclareInputText{237}{\cyrn}
+\DeclareInputText{238}{\cyro}
+\DeclareInputText{239}{\cyrp}
+\DeclareInputText{240}{\cyrr}
+\DeclareInputText{241}{\cyrs}
+\DeclareInputText{242}{\cyrt}
+\DeclareInputText{243}{\cyru}
+\DeclareInputText{244}{\cyrf}
+\DeclareInputText{245}{\cyrh}
+\DeclareInputText{246}{\cyrc}
+\DeclareInputText{247}{\cyrch}
+\DeclareInputText{248}{\cyrsh}
+\DeclareInputText{249}{\cyrshch}
+\DeclareInputText{250}{\cyrhrdsn}
+\DeclareInputText{251}{\cyrery}
+\DeclareInputText{252}{\cyrsftsn}
+\DeclareInputText{253}{\cyrerev}
+\DeclareInputText{254}{\cyryu}
+%<maccyrillic|macukrainian>\DeclareInputText{255}{\textcurrency}
+%<pt254>\DeclareInputText{255}{\CYROTLD}
+%</maccyrillic|macukrainian|pt254>
+% \end{macrocode}
+%
+% \subsection{Bulgarian MIK (BDS) codepage}
+%
+% It is an MS-DOS codepage used in Bulgaria. This codepage was
+% provided by Georgi Boshnakov and Guentcho Skordev.
+%
+% \begin{macrocode}
+%<*MIK>
+\DeclareInputText{128}{\CYRA}
+\DeclareInputText{129}{\CYRB}
+\DeclareInputText{130}{\CYRV}
+\DeclareInputText{131}{\CYRG}
+\DeclareInputText{132}{\CYRD}
+\DeclareInputText{133}{\CYRE}
+\DeclareInputText{134}{\CYRZH}
+\DeclareInputText{135}{\CYRZ}
+\DeclareInputText{136}{\CYRI}
+\DeclareInputText{137}{\CYRISHRT}
+\DeclareInputText{138}{\CYRK}
+\DeclareInputText{139}{\CYRL}
+\DeclareInputText{140}{\CYRM}
+\DeclareInputText{141}{\CYRN}
+\DeclareInputText{142}{\CYRO}
+\DeclareInputText{143}{\CYRP}
+\DeclareInputText{144}{\CYRR}
+\DeclareInputText{145}{\CYRS}
+\DeclareInputText{146}{\CYRT}
+\DeclareInputText{147}{\CYRU}
+\DeclareInputText{148}{\CYRF}
+\DeclareInputText{149}{\CYRH}
+\DeclareInputText{150}{\CYRC}
+\DeclareInputText{151}{\CYRCH}
+\DeclareInputText{152}{\CYRSH}
+\DeclareInputText{153}{\CYRSHCH}
+\DeclareInputText{154}{\CYRHRDSN}
+\DeclareInputText{155}{\CYRERY}
+\DeclareInputText{156}{\CYRSFTSN}
+\DeclareInputText{157}{\CYREREV}
+\DeclareInputText{158}{\CYRYU}
+\DeclareInputText{159}{\CYRYA}
+\DeclareInputText{160}{\cyra}
+\DeclareInputText{161}{\cyrb}
+\DeclareInputText{162}{\cyrv}
+\DeclareInputText{163}{\cyrg}
+\DeclareInputText{164}{\cyrd}
+\DeclareInputText{165}{\cyre}
+\DeclareInputText{166}{\cyrzh}
+\DeclareInputText{167}{\cyrz}
+\DeclareInputText{168}{\cyri}
+\DeclareInputText{169}{\cyrishrt}
+\DeclareInputText{170}{\cyrk}
+\DeclareInputText{171}{\cyrl}
+\DeclareInputText{172}{\cyrm}
+\DeclareInputText{173}{\cyrn}
+\DeclareInputText{174}{\cyro}
+\DeclareInputText{175}{\cyrp}
+\DeclareInputText{176}{\cyrr}
+\DeclareInputText{177}{\cyrs}
+\DeclareInputText{178}{\cyrt}
+\DeclareInputText{179}{\cyru}
+\DeclareInputText{180}{\cyrf}
+\DeclareInputText{181}{\cyrh}
+\DeclareInputText{182}{\cyrc}
+\DeclareInputText{183}{\cyrch}
+\DeclareInputText{184}{\cyrsh}
+\DeclareInputText{185}{\cyrshch}
+\DeclareInputText{186}{\cyrhrdsn}
+\DeclareInputText{187}{\cyrery}
+\DeclareInputText{188}{\cyrsftsn}
+\DeclareInputText{189}{\cyrerev}
+\DeclareInputText{190}{\cyryu}
+\DeclareInputText{191}{\cyrya}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\DeclareInputText{213}{\textnumero}
+\DeclareInputText{214}{\S}
+\DeclareInputMath{224}{\alpha}
+\DeclareInputMath{225}{\beta}
+\DeclareInputMath{226}{\Gamma}
+\DeclareInputMath{227}{\pi}
+\DeclareInputMath{228}{\Sigma}
+\DeclareInputMath{229}{\sigma}
+\DeclareInputMath{230}{\mu}
+\DeclareInputMath{231}{\tau}
+\DeclareInputMath{232}{\Phi}
+\DeclareInputMath{233}{\Theta}
+\DeclareInputMath{234}{\Omega}
+\DeclareInputMath{235}{\delta}
+\DeclareInputMath{236}{\infty}
+\DeclareInputMath{237}{\emptyset}
+\DeclareInputMath{238}{\in}
+\DeclareInputMath{239}{\cap}
+\DeclareInputMath{240}{\equiv}
+\DeclareInputMath{241}{\pm}
+\DeclareInputMath{242}{\geq}
+\DeclareInputMath{243}{\leq}
+\DeclareInputMath{246}{\div}
+\DeclareInputMath{247}{\sim}
+\DeclareInputText{248}{\textdegree}
+\DeclareInputText{249}{\textbullet}
+\DeclareInputText{250}{\textperiodcentered}
+\DeclareInputMath{251}{\surd}
+\DeclareInputMath{252}{\mathnsuperior}
+\DeclareInputMath{253}{\mathtwosuperior}
+\DeclareInputText{254}{\textblacksquare}
+\DeclareInputText{255}{\nobreakspace}
+%</MIK>
+% \end{macrocode}
+%
+% \subsection{Mongolian codepages}
+%
+% These codepages were taken from Oliver Corff's `Mon\TeX' package
+% (available at CTAN:language/mongolian/montex). Since T2 encodings
+% support the Mongolian Cyrillic script, it is convenient to have support
+% for Mongolian input encodings as well. Pointers to documentation
+% for these codepages are highly appreciated.
+%
+% \subsubsection{CTT Mongolian codepage}
+%
+% \begin{macrocode}
+%<*CTT>
+\DeclareInputText{171}{\guillemotleft}
+\DeclareInputText{187}{\guillemotright}
+\DeclareInputText{192}{\CYRA}
+\DeclareInputText{193}{\CYRB}
+\DeclareInputText{194}{\CYRV}
+\DeclareInputText{195}{\CYRG}
+\DeclareInputText{196}{\CYRD}
+\DeclareInputText{197}{\CYRE}
+\DeclareInputText{168}{\CYRYO}
+\DeclareInputText{198}{\CYRZH}
+\DeclareInputText{199}{\CYRZ}
+\DeclareInputText{200}{\CYRI}
+\DeclareInputText{201}{\CYRISHRT}
+\DeclareInputText{202}{\CYRK}
+\DeclareInputText{203}{\CYRL}
+\DeclareInputText{204}{\CYRM}
+\DeclareInputText{205}{\CYRN}
+\DeclareInputText{206}{\CYRO}
+\DeclareInputText{170}{\CYROTLD}
+\DeclareInputText{207}{\CYRP}
+\DeclareInputText{208}{\CYRR}
+\DeclareInputText{209}{\CYRS}
+\DeclareInputText{210}{\CYRT}
+\DeclareInputText{211}{\CYRU}
+\DeclareInputText{175}{\CYRY}
+\DeclareInputText{212}{\CYRF}
+\DeclareInputText{213}{\CYRH}
+\DeclareInputText{214}{\CYRC}
+\DeclareInputText{215}{\CYRCH}
+\DeclareInputText{216}{\CYRSH}
+\DeclareInputText{217}{\CYRSHCH}
+\DeclareInputText{218}{\CYRHRDSN}
+\DeclareInputText{219}{\CYRERY}
+\DeclareInputText{220}{\CYRSFTSN}
+\DeclareInputText{221}{\CYREREV}
+\DeclareInputText{222}{\CYRYU}
+\DeclareInputText{223}{\CYRYA}
+\DeclareInputText{224}{\cyra}
+\DeclareInputText{225}{\cyrb}
+\DeclareInputText{226}{\cyrv}
+\DeclareInputText{227}{\cyrg}
+\DeclareInputText{228}{\cyrd}
+\DeclareInputText{229}{\cyre}
+\DeclareInputText{184}{\cyryo}
+\DeclareInputText{230}{\cyrzh}
+\DeclareInputText{231}{\cyrz}
+\DeclareInputText{232}{\cyri}
+\DeclareInputText{233}{\cyrishrt}
+\DeclareInputText{234}{\cyrk}
+\DeclareInputText{235}{\cyrl}
+\DeclareInputText{236}{\cyrm}
+\DeclareInputText{237}{\cyrn}
+\DeclareInputText{238}{\cyro}
+\DeclareInputText{186}{\cyrotld}
+\DeclareInputText{239}{\cyrp}
+\DeclareInputText{240}{\cyrr}
+\DeclareInputText{241}{\cyrs}
+\DeclareInputText{242}{\cyrt}
+\DeclareInputText{243}{\cyru}
+\DeclareInputText{191}{\cyry}
+\DeclareInputText{244}{\cyrf}
+\DeclareInputText{245}{\cyrh}
+\DeclareInputText{246}{\cyrc}
+\DeclareInputText{247}{\cyrch}
+\DeclareInputText{248}{\cyrsh}
+\DeclareInputText{249}{\cyrshch}
+\DeclareInputText{250}{\cyrhrdsn}
+\DeclareInputText{251}{\cyrery}
+\DeclareInputText{252}{\cyrsftsn}
+\DeclareInputText{253}{\cyrerev}
+\DeclareInputText{254}{\cyryu}
+\DeclareInputText{255}{\cyrya}
+%</CTT>
+% \end{macrocode}
+%
+% \subsubsection{DBK Mongolian codepage}
+%
+% \begin{macrocode}
+%<*DBK>
+\DeclareInputText{128}{\CYRA}
+\DeclareInputText{129}{\CYRB}
+\DeclareInputText{130}{\CYRV}
+\DeclareInputText{131}{\CYRG}
+\DeclareInputText{132}{\CYRD}
+\DeclareInputText{133}{\CYRE}
+\DeclareInputText{134}{\CYRYO}
+\DeclareInputText{135}{\CYRZH}
+\DeclareInputText{136}{\CYRZ}
+\DeclareInputText{137}{\CYRI}
+\DeclareInputText{139}{\CYRISHRT}
+\DeclareInputText{140}{\CYRK}
+\DeclareInputText{142}{\CYRL}
+\DeclareInputText{143}{\CYRM}
+\DeclareInputText{144}{\CYRN}
+\DeclareInputText{145}{\CYRO}
+\DeclareInputText{146}{\CYROTLD}
+\DeclareInputText{147}{\CYRP}
+\DeclareInputText{148}{\CYRR}
+\DeclareInputText{149}{\CYRS}
+\DeclareInputText{150}{\CYRT}
+\DeclareInputText{151}{\CYRU}
+\DeclareInputText{152}{\CYRY}
+\DeclareInputText{153}{\CYRF}
+\DeclareInputText{154}{\CYRH}
+\DeclareInputText{155}{\CYRC}
+\DeclareInputText{156}{\CYRCH}
+\DeclareInputText{157}{\CYRSH}
+\DeclareInputText{158}{\CYRSHCH}
+\DeclareInputText{159}{\CYRHRDSN}
+\DeclareInputText{160}{\CYRERY}
+\DeclareInputText{161}{\CYRSFTSN}
+\DeclareInputText{162}{\CYREREV}
+\DeclareInputText{163}{\CYRYU}
+\DeclareInputText{164}{\CYRYA}
+\DeclareInputText{165}{\cyra}
+\DeclareInputText{166}{\cyrb}
+\DeclareInputText{167}{\cyrv}
+\DeclareInputText{168}{\cyrg}
+\DeclareInputText{169}{\cyrd}
+\DeclareInputText{170}{\cyre}
+\DeclareInputText{171}{\cyryo}
+\DeclareInputText{172}{\cyrzh}
+\DeclareInputText{173}{\cyrz}
+\DeclareInputText{174}{\cyri}
+\DeclareInputText{175}{\cyrishrt}
+\DeclareInputText{225}{\cyrk}
+\DeclareInputText{226}{\cyrl}
+\DeclareInputText{227}{\cyrm}
+\DeclareInputText{228}{\cyrn}
+\DeclareInputText{229}{\cyro}
+\DeclareInputText{230}{\cyrotld}
+\DeclareInputText{231}{\cyrp}
+\DeclareInputText{232}{\cyrr}
+\DeclareInputText{233}{\cyrs}
+\DeclareInputText{234}{\cyrt}
+\DeclareInputText{235}{\cyru}
+\DeclareInputText{236}{\cyry}
+\DeclareInputText{237}{\cyrf}
+\DeclareInputText{238}{\cyrh}
+\DeclareInputText{239}{\cyrc}
+\DeclareInputText{241}{\cyrch}
+\DeclareInputText{242}{\cyrsh}
+\DeclareInputText{243}{\cyrshch}
+\DeclareInputText{244}{\cyrhrdsn}
+\DeclareInputText{245}{\cyrery}
+\DeclareInputText{246}{\cyrsftsn}
+\DeclareInputText{247}{\cyrerev}
+\DeclareInputText{248}{\cyryu}
+\DeclareInputText{249}{\cyrya}
+%</DBK>
+% \end{macrocode}
+%
+% \subsubsection{MNK Mongolian codepage}
+%
+% \begin{macrocode}
+%<*MNK>
+\DeclareInputText{128}{\CYRA}
+\DeclareInputText{129}{\CYRB}
+\DeclareInputText{130}{\CYRV}
+\DeclareInputText{131}{\CYRG}
+\DeclareInputText{132}{\CYRD}
+\DeclareInputText{133}{\CYRE}
+\DeclareInputText{134}{\CYRYO}
+\DeclareInputText{135}{\CYRZH}
+\DeclareInputText{136}{\CYRZ}
+\DeclareInputText{137}{\CYRI}
+\DeclareInputText{138}{\CYRISHRT}
+\DeclareInputText{139}{\CYRK}
+\DeclareInputText{140}{\CYRL}
+\DeclareInputText{141}{\CYRM}
+\DeclareInputText{142}{\CYRN}
+\DeclareInputText{143}{\CYRO}
+\DeclareInputText{144}{\CYROTLD}
+\DeclareInputText{145}{\CYRP}
+\DeclareInputText{146}{\CYRR}
+\DeclareInputText{147}{\CYRS}
+\DeclareInputText{148}{\CYRT}
+\DeclareInputText{149}{\CYRU}
+\DeclareInputText{150}{\CYRY}
+\DeclareInputText{151}{\CYRF}
+\DeclareInputText{152}{\CYRH}
+\DeclareInputText{153}{\CYRC}
+\DeclareInputText{154}{\CYRCH}
+\DeclareInputText{155}{\CYRSH}
+\DeclareInputText{156}{\CYRSHCH}
+\DeclareInputText{157}{\CYRHRDSN}
+\DeclareInputText{158}{\CYRERY}
+\DeclareInputText{159}{\CYRSFTSN}
+\DeclareInputText{160}{\CYREREV}
+\DeclareInputText{161}{\CYRYU}
+\DeclareInputText{162}{\CYRYA}
+\DeclareInputText{163}{\cyra}
+\DeclareInputText{164}{\cyrb}
+\DeclareInputText{165}{\cyrv}
+\DeclareInputText{166}{\cyrg}
+\DeclareInputText{167}{\cyrd}
+\DeclareInputText{168}{\cyre}
+\DeclareInputText{169}{\cyryo}
+\DeclareInputText{170}{\cyrzh}
+\DeclareInputText{173}{\cyrz}
+\DeclareInputText{224}{\cyri}
+\DeclareInputText{225}{\cyrishrt}
+\DeclareInputText{226}{\cyrk}
+\DeclareInputText{227}{\cyrl}
+\DeclareInputText{228}{\cyrm}
+\DeclareInputText{229}{\cyrn}
+\DeclareInputText{230}{\cyro}
+\DeclareInputText{231}{\cyrotld}
+\DeclareInputText{232}{\cyrp}
+\DeclareInputText{233}{\cyrr}
+\DeclareInputText{234}{\cyrs}
+\DeclareInputText{235}{\cyrt}
+\DeclareInputText{236}{\cyru}
+\DeclareInputText{237}{\cyry}
+\DeclareInputText{238}{\cyrf}
+\DeclareInputText{239}{\cyrh}
+\DeclareInputText{240}{\cyrc}
+\DeclareInputText{241}{\cyrch}
+\DeclareInputText{242}{\cyrsh}
+\DeclareInputText{243}{\cyrshch}
+\DeclareInputText{244}{\cyrhrdsn}
+\DeclareInputText{245}{\cyrery}
+\DeclareInputText{248}{\cyrsftsn}
+\DeclareInputText{252}{\cyrerev}
+\DeclareInputText{253}{\cyryu}
+\DeclareInputText{254}{\cyrya}
+%</MNK>
+% \end{macrocode}
+%
+% \subsubsection{MOS Mongolian codepage}
+%
+% \begin{macrocode}
+%<*MOS>
+\DeclareInputText{128}{\CYRA}
+\DeclareInputText{129}{\CYRB}
+\DeclareInputText{130}{\CYRV}
+\DeclareInputText{131}{\CYRG}
+\DeclareInputText{132}{\CYRD}
+\DeclareInputText{133}{\CYRE}
+\DeclareInputText{160}{\CYRYO}
+\DeclareInputText{134}{\CYRZH}
+\DeclareInputText{135}{\CYRZ}
+\DeclareInputText{136}{\CYRI}
+\DeclareInputText{137}{\CYRISHRT}
+\DeclareInputText{138}{\CYRK}
+\DeclareInputText{139}{\CYRL}
+\DeclareInputText{140}{\CYRM}
+\DeclareInputText{141}{\CYRN}
+\DeclareInputText{142}{\CYRO}
+\DeclareInputText{153}{\CYROTLD}
+\DeclareInputText{143}{\CYRP}
+\DeclareInputText{144}{\CYRR}
+\DeclareInputText{145}{\CYRS}
+\DeclareInputText{146}{\CYRT}
+\DeclareInputText{147}{\CYRU}
+\DeclareInputText{154}{\CYRY}
+\DeclareInputText{148}{\CYRF}
+\DeclareInputText{149}{\CYRH}
+\DeclareInputText{150}{\CYRC}
+\DeclareInputText{151}{\CYRCH}
+\DeclareInputText{152}{\CYRSH}
+\DeclareInputText{164}{\CYRSHCH}
+\DeclareInputText{162}{\CYRHRDSN}
+\DeclareInputText{155}{\CYRERY}
+\DeclareInputText{156}{\CYRSFTSN}
+\DeclareInputText{157}{\CYREREV}
+\DeclareInputText{158}{\CYRYU}
+\DeclareInputText{159}{\CYRYA}
+\DeclareInputText{224}{\cyra}
+\DeclareInputText{225}{\cyrb}
+\DeclareInputText{226}{\cyrv}
+\DeclareInputText{227}{\cyrg}
+\DeclareInputText{228}{\cyrd}
+\DeclareInputText{229}{\cyre}
+\DeclareInputText{161}{\cyryo}
+\DeclareInputText{230}{\cyrzh}
+\DeclareInputText{231}{\cyrz}
+\DeclareInputText{232}{\cyri}
+\DeclareInputText{233}{\cyrishrt}
+\DeclareInputText{234}{\cyrk}
+\DeclareInputText{235}{\cyrl}
+\DeclareInputText{236}{\cyrm}
+\DeclareInputText{237}{\cyrn}
+\DeclareInputText{238}{\cyro}
+\DeclareInputText{249}{\cyrotld}
+\DeclareInputText{239}{\cyrp}
+\DeclareInputText{240}{\cyrr}
+\DeclareInputText{241}{\cyrs}
+\DeclareInputText{242}{\cyrt}
+\DeclareInputText{243}{\cyru}
+\DeclareInputText{250}{\cyry}
+\DeclareInputText{244}{\cyrf}
+\DeclareInputText{245}{\cyrh}
+\DeclareInputText{246}{\cyrc}
+\DeclareInputText{247}{\cyrch}
+\DeclareInputText{248}{\cyrsh}
+\DeclareInputText{165}{\cyrshch}
+\DeclareInputText{163}{\cyrhrdsn}
+\DeclareInputText{251}{\cyrery}
+\DeclareInputText{252}{\cyrsftsn}
+\DeclareInputText{253}{\cyrerev}
+\DeclareInputText{254}{\cyryu}
+\DeclareInputText{168}{\cyrya}
+%</MOS>
+% \end{macrocode}
+%
+% \subsubsection{NCC Mongolian codepage}
+%
+% \begin{macrocode}
+%<*NCC>
+\DeclareInputText{128}{\CYRA}
+\DeclareInputText{129}{\CYRB}
+\DeclareInputText{130}{\CYRV}
+\DeclareInputText{131}{\CYRG}
+\DeclareInputText{132}{\CYRD}
+\DeclareInputText{133}{\CYRE}
+\DeclareInputText{134}{\CYRYO}
+\DeclareInputText{135}{\CYRZH}
+\DeclareInputText{136}{\CYRZ}
+\DeclareInputText{137}{\CYRI}
+\DeclareInputText{139}{\CYRISHRT}
+\DeclareInputText{140}{\CYRK}
+\DeclareInputText{142}{\CYRL}
+\DeclareInputText{143}{\CYRM}
+\DeclareInputText{144}{\CYRN}
+\DeclareInputText{145}{\CYRO}
+\DeclareInputText{146}{\CYROTLD}
+\DeclareInputText{147}{\CYRP}
+\DeclareInputText{148}{\CYRR}
+\DeclareInputText{149}{\CYRS}
+\DeclareInputText{150}{\CYRT}
+\DeclareInputText{151}{\CYRU}
+\DeclareInputText{152}{\CYRY}
+\DeclareInputText{153}{\CYRF}
+\DeclareInputText{154}{\CYRH}
+\DeclareInputText{155}{\CYRC}
+\DeclareInputText{156}{\CYRCH}
+\DeclareInputText{157}{\CYRSH}
+\DeclareInputText{158}{\CYRSHCH}
+\DeclareInputText{159}{\CYRHRDSN}
+\DeclareInputText{160}{\CYRERY}
+\DeclareInputText{161}{\CYRSFTSN}
+\DeclareInputText{162}{\CYREREV}
+\DeclareInputText{163}{\CYRYU}
+\DeclareInputText{164}{\CYRYA}
+\DeclareInputText{165}{\cyra}
+\DeclareInputText{166}{\cyrb}
+\DeclareInputText{167}{\cyrv}
+\DeclareInputText{168}{\cyrg}
+\DeclareInputText{169}{\cyrd}
+\DeclareInputText{170}{\cyre}
+\DeclareInputText{171}{\cyryo}
+\DeclareInputText{172}{\cyrzh}
+\DeclareInputText{173}{\cyrz}
+\DeclareInputText{225}{\cyri}
+\DeclareInputText{226}{\cyrishrt}
+\DeclareInputText{227}{\cyrk}
+\DeclareInputText{228}{\cyrl}
+\DeclareInputText{229}{\cyrm}
+\DeclareInputText{230}{\cyrn}
+\DeclareInputText{231}{\cyro}
+\DeclareInputText{232}{\cyrotld}
+\DeclareInputText{233}{\cyrp}
+\DeclareInputText{234}{\cyrr}
+\DeclareInputText{235}{\cyrs}
+\DeclareInputText{236}{\cyrt}
+\DeclareInputText{237}{\cyru}
+\DeclareInputText{238}{\cyry}
+\DeclareInputText{239}{\cyrf}
+\DeclareInputText{240}{\cyrh}
+\DeclareInputText{241}{\cyrc}
+\DeclareInputText{242}{\cyrch}
+\DeclareInputText{243}{\cyrsh}
+\DeclareInputText{244}{\cyrshch}
+\DeclareInputText{245}{\cyrhrdsn}
+\DeclareInputText{246}{\cyrery}
+\DeclareInputText{247}{\cyrsftsn}
+\DeclareInputText{248}{\cyrerev}
+\DeclareInputText{249}{\cyryu}
+\DeclareInputText{251}{\cyrya}
+%</NCC>
+% \end{macrocode}
+%
+% \subsubsection{MLS Mongolian codepage}
+%
+% \begin{macrocode}
+%<*MLS>
+\DeclareInputText{128}{\CYRB}
+\DeclareInputText{129}{\cyry}
+\DeclareInputText{130}{\CYRD}
+\DeclareInputText{131}{\CYRYO}
+\DeclareInputText{132}{\cyrerev}
+\DeclareInputText{133}{\CYRZH}
+\DeclareInputText{134}{\CYRZ}
+\DeclareInputText{135}{\CYRI}
+\DeclareInputText{136}{\CYRISHRT}
+\DeclareInputText{137}{\cyryo}
+\DeclareInputText{138}{\CYRL}
+\DeclareInputText{139}{\cyrishrt}
+\DeclareInputText{140}{\CYROTLD}
+\DeclareInputText{141}{\CYRP}
+\DeclareInputText{142}{\CYREREV}
+\DeclareInputText{143}{\CYRU}
+\DeclareInputText{144}{\CYRF}
+\DeclareInputText{145}{\CYRC}
+\DeclareInputText{146}{\CYRCH}
+\DeclareInputText{147}{\CYRSH}
+\DeclareInputText{148}{\cyrotld}
+\DeclareInputText{149}{\CYRSHCH}
+\DeclareInputText{150}{\CYRHRDSN}
+\DeclareInputText{151}{\CYRERY}
+\DeclareInputText{152}{\CYRSFTSN}
+\DeclareInputText{153}{\CYROTLD}
+\DeclareInputText{154}{\CYRY}
+\DeclareInputText{155}{\CYREREV}
+\DeclareInputText{156}{\CYRYU}
+\DeclareInputText{157}{\CYRYA}
+\DeclareInputText{158}{\cyrb}
+\DeclareInputText{159}{\cyrv}
+\DeclareInputText{160}{\cyrg}
+\DeclareInputText{161}{\cyrd}
+\DeclareInputText{162}{\cyrzh}
+\DeclareInputText{163}{\cyrz}
+\DeclareInputText{164}{\cyri}
+\DeclareInputText{165}{\cyrishrt}
+\DeclareInputText{166}{\cyrk}
+\DeclareInputText{167}{\cyrl}
+\DeclareInputText{168}{\cyrm}
+\DeclareInputText{169}{\cyrn}
+\DeclareInputText{170}{\cyrotld}
+\DeclareInputText{171}{\cyrp}
+\DeclareInputText{172}{\cyrt}
+\DeclareInputText{173}{\cyry}
+\DeclareInputText{174}{\guillemotleft}
+\DeclareInputText{175}{\guillemotright}
+\DeclareInputText{176}{\cyrf}
+\DeclareInputText{177}{\cyrc}
+\DeclareInputText{178}{\cyrch}
+\DeclareInputText{180}{\cyrsh}
+\DeclareInputText{181}{\cyrshch}
+\DeclareInputText{182}{\cyrhrdsn}
+\DeclareInputText{183}{\cyrery}
+\DeclareInputText{184}{\cyrsftsn}
+\DeclareInputText{189}{\cyrerev}
+\DeclareInputText{190}{\cyryu}
+\DeclareInputText{193}{\cyrya}
+\DeclareInputText{226}{\CYRG}
+\DeclareInputText{225}{\ss}
+\DeclareInputText{231}{\ensuremath{\gamma}}
+\DeclareInputText{255}{\nobreakspace}
+% \end{macrocode}
+% Bicig Letters. These are traditional (non-Cyrillic) Mongolian letters,
+% which are not supported by Cyrillic |T2|~encodings. To use these
+% letters you should install the |LMS|~font encoding definition file and
+% Mongolian fonts contained in the Mon\TeX{} package. These letters
+% coexist with Cyrillic in one input encoding.
+% \begin{macrocode}
+\DeclareInputText{194}{\titem}
+\DeclareInputText{195}{\shud}
+\DeclareInputText{197}{\secondaryshud}
+\DeclareInputText{198}{\shilbe}
+\DeclareInputText{199}{\gedes}
+\DeclareInputText{207}{\secondarygedes}
+\DeclareInputText{208}{\cegteishud}
+\DeclareInputText{209}{\lewer}
+\DeclareInputText{210}{\suuliinlewer}
+\DeclareInputText{211}{\tertiarylewer}
+\DeclareInputText{212}{\mewer}
+\DeclareInputText{213}{\suuliinmewer}
+\DeclareInputText{214}{\xewteeqix}
+\DeclareInputText{215}{\dawxarcegtxewteeqix}
+\DeclareInputText{216}{\halfnum}
+\DeclareInputText{219}{\num}
+\DeclareInputText{220}{\halfnumtgedes}
+\DeclareInputText{221}{\numtaigedes}
+\DeclareInputText{222}{\buruuxarsangedes}
+\DeclareInputText{223}{\gedesteishilbe}
+\DeclareInputText{224}{\erweeljinshilbe}
+\DeclareInputText{227}{\secerweeljin}
+\DeclareInputText{228}{\bosooshilbe}
+\DeclareInputText{229}{\etgershilbe}
+\DeclareInputText{230}{\zawj}
+\DeclareInputText{232}{\suuliinzawj}
+\DeclareInputText{233}{\dawxarcegtzawj}
+\DeclareInputText{234}{\sereeewer}
+\DeclareInputText{235}{\matgarshilbe}
+\DeclareInputText{236}{\bituushilbe}
+\DeclareInputText{237}{\secondaryqagt}
+\DeclareInputText{238}{\qagt}
+\DeclareInputText{239}{\secnumtdelbenqix}
+\DeclareInputText{240}{\numtdelbenqix}
+\DeclareInputText{241}{\secsertenqixtnum}
+\DeclareInputText{242}{\sertenqixtnum}
+\DeclareInputText{243}{\zadgaizardigt}
+\DeclareInputText{244}{\bituuzardigt}
+\DeclareInputText{245}{\malgaitaititem}
+\DeclareInputText{246}{\suul}
+\DeclareInputText{247}{\orxic}
+\DeclareInputText{248}{\biodoisuul}
+\DeclareInputText{249}{\bagodoisuul}
+\DeclareInputText{250}{\nceg}
+\DeclareInputText{251}{\gceg}
+\DeclareInputText{252}{\ceg}
+\DeclareInputText{253}{\dorwoljin}
+%</MLS>
+% \end{macrocode}
+% Finally, we reset the category code of the at sign at the end of all
+% .def files.
+% \begin{macrocode}
+\makeatother
+% \end{macrocode}
+\endinput
diff --git a/macros/latex/required/cyrillic/cyinpenc.pdf b/macros/latex/required/cyrillic/cyinpenc.pdf
new file mode 100644
index 0000000000..98b349a917
--- /dev/null
+++ b/macros/latex/required/cyrillic/cyinpenc.pdf
Binary files differ
diff --git a/macros/latex/required/cyrillic/cyoutenc.dtx b/macros/latex/required/cyrillic/cyoutenc.dtx
new file mode 100644
index 0000000000..4b510de97f
--- /dev/null
+++ b/macros/latex/required/cyrillic/cyoutenc.dtx
@@ -0,0 +1,611 @@
+% \iffalse meta-comment
+%
+% Copyright 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2008 2009
+% The LaTeX3 Project and any individual authors listed elsewhere
+% in this file.
+%
+% This file is part of the Standard LaTeX `Cyrillic Bundle'.
+% ----------------------------------------------------------
+%
+% It may be distributed and/or modified under the
+% conditions of the LaTeX Project Public License, either version 1.3b
+% 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.3b or later is part of all distributions of LaTeX
+% version 2005/12/01 or later.
+%
+% The list of all files belonging to the `Cyrillic Bundle' is
+% given in the file `manifest.txt'.
+%
+% \fi
+% \iffalse
+% This is the file |cyoutenc.dtx| of the cyrillic bundle for LaTeX2e.
+%
+%<*driver>
+\documentclass{ltxdoc}
+\begin{document}
+\DocInput{cyoutenc.dtx}
+\end{document}
+%</driver>
+% \fi
+%
+% \section{The Cyrillic font encodings: T2A, T2B, T2C, and X2}
+%
+% Since the number of Cyrillic glyphs exceeds the limit for a `T'
+% encoding, it is necessary to create multiple glyph containers. The
+% output encodings `T2A', `T2B', and `T2C' are the result of long
+% discussions in various Internet mailing lists; they emerged from the
+% `X2' glyph container which was previously called `T2'. Please
+% consult section~6.4 (`Naming conventions') in the file
+% |fntguide.tex| of the base \LaTeXe\ distribution for details on the
+% differences between \LaTeX\ font encodings.
+%
+% When typesetting Cyrillic texts, there is a tradition to use Cyrillic
+% letters (in some situations) inside math formul\ae\ just like Latin
+% letters. By default, this does not work, because symbols declared
+% with |\DeclareTextSymbol| may not be used inside math. If you need to
+% `transparently' typeset symbols in math formul\ae\ which are declared
+% in encoding definition files, you could use the |mathtext| package
+% available at |CTAN:macros/latex/contrib/supported/t2|. Note that this
+% package uses at least one additional math alphabet per font encoding.
+%
+% To make code more compact, we use the |\LastDeclaredEncoding| macro to
+% share the same lines in the DTX file for different encodings. This macro
+% appeared in the December 1998 \LaTeXe\ release (together with the
+% integration of Cyrillic stuff), thus we use |\NeedsTeXFormat|
+% below. We will probably change this `sharing mechanism' to use
+% a yet-to-be-written |docstrip| extension (namely, substring substitution)
+% in the future.
+%
+% \begin{macrocode}
+%<*X2|T2A|T2B|T2C>
+\NeedsTeXFormat{LaTeX2e}[1998/12/01]
+%<X2>\ProvidesFile{x2enc.def}
+%<T2A>\ProvidesFile{t2aenc.def}
+%<T2B>\ProvidesFile{t2benc.def}
+%<T2C>\ProvidesFile{t2cenc.def}
+ [2005/09/27 v1.0i Cyrillic encoding definition file]
+% \end{macrocode}
+%
+% To assure that |\MakeUppercase| and |\MakeLowercase| will work
+% correctly, |\@uclclist| (defined in the \LaTeX\ kernel) contains all
+% Cyrillic uppercase-lowercase letter pairs. This also needs at least
+% December 1998 \LaTeXe\ release.
+%
+% \begin{macrocode}
+%<X2>\DeclareFontEncoding{X2}{}{}
+%<T2A>\DeclareFontEncoding{T2A}{}{}
+%<T2B>\DeclareFontEncoding{T2B}{}{}
+%<T2C>\DeclareFontEncoding{T2C}{}{}
+\DeclareFontSubstitution{\LastDeclaredEncoding}{cmr}{m}{n}
+% \end{macrocode}
+%
+% Common accents.
+%
+% \begin{macrocode}
+\DeclareTextAccent{\`}{\LastDeclaredEncoding}{0}
+\DeclareTextAccent{\'}{\LastDeclaredEncoding}{1}
+\DeclareTextAccent{\^}{\LastDeclaredEncoding}{2}
+\DeclareTextAccent{\~}{\LastDeclaredEncoding}{3}
+\DeclareTextAccent{\"}{\LastDeclaredEncoding}{4}
+\DeclareTextAccent{\H}{\LastDeclaredEncoding}{5}
+\DeclareTextAccent{\r}{\LastDeclaredEncoding}{6}
+\DeclareTextAccent{\v}{\LastDeclaredEncoding}{7}
+\DeclareTextAccent{\u}{\LastDeclaredEncoding}{8}
+\DeclareTextAccent{\=}{\LastDeclaredEncoding}{9}
+\DeclareTextAccent{\.}{\LastDeclaredEncoding}{10}
+% 11 cedilla
+% 12 ogonek
+% Cyrillic flex (inverted breve) accent:
+\DeclareTextAccent{\f}{\LastDeclaredEncoding}{18}
+% double grave (`Cyrillic umlaut') accent:
+\DeclareTextAccent{\C}{\LastDeclaredEncoding}{19}
+% Cyrillic breve accent:
+\DeclareTextAccent{\U}{\LastDeclaredEncoding}{20}
+% \end{macrocode}
+% In these definitions we no longer use the helper function |\sh@ft|
+% from plain.tex since that now has two incompatible definitions.
+% \changes{v1.0i}{2005/09/27}{Replace \cs{sh@ft} by \cs{ltx@sh@ft}}
+% \begin{macrocode}
+\DeclareTextCommand{\b}{\LastDeclaredEncoding}[1]
+ {\hmode@bgroup\o@lign{\relax#1\crcr\hidewidth\ltx@sh@ft{-3ex}%
+ \vbox to.2ex{\hbox{\char9}\vss}\hidewidth}\egroup}
+\DeclareTextCommand{\c}{\LastDeclaredEncoding}[1]
+ {\leavevmode\setbox\z@\hbox{#1}\ifdim\ht\z@=1ex\accent11 #1%
+ \else{\ooalign{\hidewidth\char11\hidewidth
+ \crcr\unhbox\z@}}\fi}
+\DeclareTextCommand{\d}{\LastDeclaredEncoding}[1]
+ {\hmode@bgroup
+ \o@lign{\relax#1\crcr\hidewidth\ltx@sh@ft{-1ex}.\hidewidth}\egroup}
+\DeclareTextCommand{\k}{\LastDeclaredEncoding}[1]
+ {\oalign{\null#1\crcr\hidewidth\char12}}
+\DeclareTextCommand{\textperthousand}{\LastDeclaredEncoding}
+ {\%\char 24 }
+\DeclareTextCommand{\textpertenthousand}{\LastDeclaredEncoding}
+ {\%\char 24\char 24 }
+%<*!X2&AAhack>
+\DeclareTextCompositeCommand{\r}{\LastDeclaredEncoding}{A}
+ {\leavevmode\setbox\z@\hbox{!}\dimen@\ht\z@\advance\dimen@-1ex%
+ \rlap{\raise.67\dimen@\hbox{\char6}}A}
+%</!X2&AAhack>
+% \end{macrocode}
+%
+% Common symbolic glyphs.
+%
+% \begin{macrocode}
+\DeclareTextSymbol{\textendash}{\LastDeclaredEncoding}{21}
+% \end{macrocode}
+% Slot 22 is a `cyrillic emdash' --- |\cyrdash| which is longer
+% than endash, but shorter than english emdash (but we define an
+% alias too).
+% \begin{macrocode}
+\DeclareTextSymbol{\cyrdash}{\LastDeclaredEncoding}{22}
+\DeclareTextSymbol{\textemdash}{\LastDeclaredEncoding}{22}
+\DeclareTextSymbol{\textcompwordmark}{\LastDeclaredEncoding}{23}
+% 24 perthousandzero
+\DeclareTextSymbol{\textvisiblespace}{\LastDeclaredEncoding}{32}
+\DeclareTextSymbol{\textdollar}{\LastDeclaredEncoding}{36}
+\DeclareTextSymbol{\textless}{\LastDeclaredEncoding}{60}
+\DeclareTextSymbol{\textgreater}{\LastDeclaredEncoding}{62}
+%\DeclareTextSymbol{\texthyphenchar}{\LastDeclaredEncoding}{127}
+%\DeclareTextSymbol{\texthyphen}{\LastDeclaredEncoding}{45}
+\DeclareTextSymbol{\textbackslash}{\LastDeclaredEncoding}{92}
+\DeclareTextSymbol{\textasciicircum}{\LastDeclaredEncoding}{94}
+\DeclareTextSymbol{\textunderscore}{\LastDeclaredEncoding}{95}
+\DeclareTextSymbol{\textbraceleft}{\LastDeclaredEncoding}{123}
+\DeclareTextSymbol{\textbar}{\LastDeclaredEncoding}{124}
+\DeclareTextSymbol{\textbraceright}{\LastDeclaredEncoding}{125}
+\DeclareTextSymbol{\textasciitilde}{\LastDeclaredEncoding}{126}
+\DeclareTextSymbol{\textnumero}{\LastDeclaredEncoding}{157}
+\DeclareTextSymbol{\textcurrency}{\LastDeclaredEncoding}{158}
+\DeclareTextSymbol{\textsection}{\LastDeclaredEncoding}{159}
+%
+\DeclareTextSymbol{\textquotedbl}{\LastDeclaredEncoding}{34}
+\DeclareTextSymbol{\textquoteleft}{\LastDeclaredEncoding}{96}
+\DeclareTextSymbol{\textquoteright}{\LastDeclaredEncoding}{39}
+\DeclareTextSymbol{\textquotedblleft}{\LastDeclaredEncoding}{16}
+\DeclareTextSymbol{\textquotedblright}{\LastDeclaredEncoding}{17}
+\DeclareTextSymbol{\quotedblbase}{\LastDeclaredEncoding}{189}
+\DeclareTextSymbol{\CYRpalochka}{\LastDeclaredEncoding}{13}
+\DeclareTextSymbol{\cyrlangle}{\LastDeclaredEncoding}{14}
+\DeclareTextSymbol{\cyrrangle}{\LastDeclaredEncoding}{15}
+\DeclareTextSymbol{\guillemotleft}{\LastDeclaredEncoding}{190}
+\DeclareTextSymbol{\guillemotright}{\LastDeclaredEncoding}{191}
+% \end{macrocode}
+%
+% |\i| and |\j| are unused in Cyrillic languages, so are absent
+% in X2. Slots 25, 26, 27 in the X2 encoding are `cross grave',
+% `cross acute', and `hcross' modifiers, respectively.
+%
+% \begin{macrocode}
+%<!X2>\DeclareTextSymbol{\i}{\LastDeclaredEncoding}{25}
+%<!X2>\DeclareTextSymbol{\j}{\LastDeclaredEncoding}{26}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\DeclareTextComposite{\.}{\LastDeclaredEncoding}{i}{`\i}
+% \end{macrocode}
+%
+% Here are the letters common to all font encodings.
+%
+% \begin{macrocode}
+\DeclareTextSymbol{\CYRA}{\LastDeclaredEncoding}{192}
+\DeclareTextSymbol{\cyra}{\LastDeclaredEncoding}{224}
+\DeclareTextSymbol{\CYRB}{\LastDeclaredEncoding}{193}
+\DeclareTextSymbol{\cyrb}{\LastDeclaredEncoding}{225}
+\DeclareTextSymbol{\CYRV}{\LastDeclaredEncoding}{194}
+\DeclareTextSymbol{\cyrv}{\LastDeclaredEncoding}{226}
+\DeclareTextSymbol{\CYRG}{\LastDeclaredEncoding}{195}
+\DeclareTextSymbol{\cyrg}{\LastDeclaredEncoding}{227}
+\DeclareTextSymbol{\CYRD}{\LastDeclaredEncoding}{196}
+\DeclareTextSymbol{\cyrd}{\LastDeclaredEncoding}{228}
+\DeclareTextSymbol{\CYRE}{\LastDeclaredEncoding}{197}
+\DeclareTextSymbol{\cyre}{\LastDeclaredEncoding}{229}
+\DeclareTextSymbol{\CYRZH}{\LastDeclaredEncoding}{198}
+\DeclareTextSymbol{\cyrzh}{\LastDeclaredEncoding}{230}
+\DeclareTextSymbol{\CYRZ}{\LastDeclaredEncoding}{199}
+\DeclareTextSymbol{\cyrz}{\LastDeclaredEncoding}{231}
+\DeclareTextSymbol{\CYRI}{\LastDeclaredEncoding}{200}
+\DeclareTextSymbol{\cyri}{\LastDeclaredEncoding}{232}
+\DeclareTextSymbol{\CYRISHRT}{\LastDeclaredEncoding}{201}
+\DeclareTextSymbol{\cyrishrt}{\LastDeclaredEncoding}{233}
+\DeclareTextSymbol{\CYRK}{\LastDeclaredEncoding}{202}
+\DeclareTextSymbol{\cyrk}{\LastDeclaredEncoding}{234}
+\DeclareTextSymbol{\CYRL}{\LastDeclaredEncoding}{203}
+\DeclareTextSymbol{\cyrl}{\LastDeclaredEncoding}{235}
+\DeclareTextSymbol{\CYRM}{\LastDeclaredEncoding}{204}
+\DeclareTextSymbol{\cyrm}{\LastDeclaredEncoding}{236}
+\DeclareTextSymbol{\CYRN}{\LastDeclaredEncoding}{205}
+\DeclareTextSymbol{\cyrn}{\LastDeclaredEncoding}{237}
+\DeclareTextSymbol{\CYRO}{\LastDeclaredEncoding}{206}
+\DeclareTextSymbol{\cyro}{\LastDeclaredEncoding}{238}
+\DeclareTextSymbol{\CYRP}{\LastDeclaredEncoding}{207}
+\DeclareTextSymbol{\cyrp}{\LastDeclaredEncoding}{239}
+\DeclareTextSymbol{\CYRR}{\LastDeclaredEncoding}{208}
+\DeclareTextSymbol{\cyrr}{\LastDeclaredEncoding}{240}
+\DeclareTextSymbol{\CYRS}{\LastDeclaredEncoding}{209}
+\DeclareTextSymbol{\cyrs}{\LastDeclaredEncoding}{241}
+\DeclareTextSymbol{\CYRT}{\LastDeclaredEncoding}{210}
+\DeclareTextSymbol{\cyrt}{\LastDeclaredEncoding}{242}
+\DeclareTextSymbol{\CYRU}{\LastDeclaredEncoding}{211}
+\DeclareTextSymbol{\cyru}{\LastDeclaredEncoding}{243}
+\DeclareTextSymbol{\CYRF}{\LastDeclaredEncoding}{212}
+\DeclareTextSymbol{\cyrf}{\LastDeclaredEncoding}{244}
+\DeclareTextSymbol{\CYRH}{\LastDeclaredEncoding}{213}
+\DeclareTextSymbol{\cyrh}{\LastDeclaredEncoding}{245}
+\DeclareTextSymbol{\CYRC}{\LastDeclaredEncoding}{214}
+\DeclareTextSymbol{\cyrc}{\LastDeclaredEncoding}{246}
+\DeclareTextSymbol{\CYRCH}{\LastDeclaredEncoding}{215}
+\DeclareTextSymbol{\cyrch}{\LastDeclaredEncoding}{247}
+\DeclareTextSymbol{\CYRSH}{\LastDeclaredEncoding}{216}
+\DeclareTextSymbol{\cyrsh}{\LastDeclaredEncoding}{248}
+\DeclareTextSymbol{\CYRSHCH}{\LastDeclaredEncoding}{217}
+\DeclareTextSymbol{\cyrshch}{\LastDeclaredEncoding}{249}
+\DeclareTextSymbol{\CYRHRDSN}{\LastDeclaredEncoding}{218}
+\DeclareTextSymbol{\cyrhrdsn}{\LastDeclaredEncoding}{250}
+\DeclareTextSymbol{\CYRERY}{\LastDeclaredEncoding}{219}
+\DeclareTextSymbol{\cyrery}{\LastDeclaredEncoding}{251}
+\DeclareTextSymbol{\CYRSFTSN}{\LastDeclaredEncoding}{220}
+\DeclareTextSymbol{\cyrsftsn}{\LastDeclaredEncoding}{252}
+\DeclareTextSymbol{\CYREREV}{\LastDeclaredEncoding}{221}
+\DeclareTextSymbol{\cyrerev}{\LastDeclaredEncoding}{253}
+\DeclareTextSymbol{\CYRYU}{\LastDeclaredEncoding}{222}
+\DeclareTextSymbol{\cyryu}{\LastDeclaredEncoding}{254}
+\DeclareTextSymbol{\CYRYA}{\LastDeclaredEncoding}{223}
+\DeclareTextSymbol{\cyrya}{\LastDeclaredEncoding}{255}
+% \end{macrocode}
+%
+% And now the remaining letters.
+%
+% \begin{macrocode}
+%<*X2>
+\DeclareTextSymbol{\CYRGUP}{X2}{128}
+\DeclareTextSymbol{\cyrgup}{X2}{160}
+\DeclareTextSymbol{\CYRGHCRS}{X2}{129}
+\DeclareTextSymbol{\cyrghcrs}{X2}{161}
+\DeclareTextSymbol{\CYRGDSC}{X2}{130}
+\DeclareTextSymbol{\cyrgdsc}{X2}{162}
+\DeclareTextSymbol{\CYRGHK}{X2}{131}
+\DeclareTextSymbol{\cyrghk}{X2}{163}
+\DeclareTextSymbol{\CYRSHHA}{X2}{132}
+\DeclareTextSymbol{\cyrshha}{X2}{164}
+\DeclareTextSymbol{\CYRZHDSC}{X2}{133}
+\DeclareTextSymbol{\cyrzhdsc}{X2}{165}
+\DeclareTextSymbol{\CYRZDSC}{X2}{134}
+\DeclareTextSymbol{\cyrzdsc}{X2}{166}
+\DeclareTextSymbol{\CYRABHDZE}{X2}{135}
+\DeclareTextSymbol{\cyrabhdze}{X2}{167}
+\DeclareTextSymbol{\CYRYI}{X2}{136}
+\DeclareTextSymbol{\cyryi}{X2}{168}
+\DeclareTextSymbol{\CYRKDSC}{X2}{137}
+\DeclareTextSymbol{\cyrkdsc}{X2}{169}
+\DeclareTextSymbol{\CYRKBEAK}{X2}{138}
+\DeclareTextSymbol{\cyrkbeak}{X2}{170}
+\DeclareTextSymbol{\CYRKHK}{X2}{139}
+\DeclareTextSymbol{\cyrkhk}{X2}{171}
+\DeclareTextSymbol{\CYRLHK}{X2}{140}
+\DeclareTextSymbol{\cyrlhk}{X2}{172}
+\DeclareTextSymbol{\CYRNDSC}{X2}{141}
+\DeclareTextSymbol{\cyrndsc}{X2}{173}
+\DeclareTextSymbol{\CYRNG}{X2}{142}
+\DeclareTextSymbol{\cyrng}{X2}{174}
+\DeclareTextSymbol{\CYRNHK}{X2}{143}
+\DeclareTextSymbol{\cyrnhk}{X2}{175}
+\DeclareTextSymbol{\CYROTLD}{X2}{144}
+\DeclareTextSymbol{\cyrotld}{X2}{176}
+\DeclareTextSymbol{\CYRSDSC}{X2}{145}
+\DeclareTextSymbol{\cyrsdsc}{X2}{177}
+\DeclareTextSymbol{\CYRUSHRT}{X2}{146}
+\DeclareTextSymbol{\cyrushrt}{X2}{178}
+\DeclareTextSymbol{\CYRY}{X2}{147}
+\DeclareTextSymbol{\cyry}{X2}{179}
+\DeclareTextSymbol{\CYRYHCRS}{X2}{148}
+\DeclareTextSymbol{\cyryhcrs}{X2}{180}
+\DeclareTextSymbol{\CYRHDSC}{X2}{149}
+\DeclareTextSymbol{\cyrhdsc}{X2}{181}
+\DeclareTextSymbol{\CYRHHK}{X2}{150}
+\DeclareTextSymbol{\cyrhhk}{X2}{182}
+\DeclareTextSymbol{\CYRCHLDSC}{X2}{151}
+\DeclareTextSymbol{\cyrchldsc}{X2}{183}
+\DeclareTextSymbol{\CYRCHRDSC}{X2}{152}
+\DeclareTextSymbol{\cyrchrdsc}{X2}{184}
+\DeclareTextSymbol{\CYRIE}{X2}{153}
+\DeclareTextSymbol{\cyrie}{X2}{185}
+\DeclareTextSymbol{\CYRSCHWA}{X2}{154}
+\DeclareTextSymbol{\cyrschwa}{X2}{186}
+\DeclareTextSymbol{\CYREPS}{X2}{155}
+\DeclareTextSymbol{\cyreps}{X2}{187}
+%</X2>
+%
+%<*T2A>
+\DeclareTextSymbol{\CYRGUP}{T2A}{128}
+\DeclareTextSymbol{\cyrgup}{T2A}{160}
+\DeclareTextSymbol{\CYRGHCRS}{T2A}{129}
+\DeclareTextSymbol{\cyrghcrs}{T2A}{161}
+\DeclareTextSymbol{\CYRDJE}{T2A}{130}
+\DeclareTextSymbol{\cyrdje}{T2A}{162}
+\DeclareTextSymbol{\CYRTSHE}{T2A}{131}
+\DeclareTextSymbol{\cyrtshe}{T2A}{163}
+\DeclareTextSymbol{\CYRSHHA}{T2A}{132}
+\DeclareTextSymbol{\cyrshha}{T2A}{164}
+\DeclareTextSymbol{\CYRZHDSC}{T2A}{133}
+\DeclareTextSymbol{\cyrzhdsc}{T2A}{165}
+\DeclareTextSymbol{\CYRZDSC}{T2A}{134}
+\DeclareTextSymbol{\cyrzdsc}{T2A}{166}
+\DeclareTextSymbol{\CYRLJE}{T2A}{135}
+\DeclareTextSymbol{\cyrlje}{T2A}{167}
+\DeclareTextSymbol{\CYRYI}{T2A}{136}
+\DeclareTextSymbol{\cyryi}{T2A}{168}
+\DeclareTextSymbol{\CYRKDSC}{T2A}{137}
+\DeclareTextSymbol{\cyrkdsc}{T2A}{169}
+\DeclareTextSymbol{\CYRKBEAK}{T2A}{138}
+\DeclareTextSymbol{\cyrkbeak}{T2A}{170}
+\DeclareTextSymbol{\CYRKVCRS}{T2A}{139}
+\DeclareTextSymbol{\cyrkvcrs}{T2A}{171}
+\DeclareTextSymbol{\CYRAE}{T2A}{140}
+\DeclareTextSymbol{\cyrae}{T2A}{172}
+\DeclareTextSymbol{\CYRNDSC}{T2A}{141}
+\DeclareTextSymbol{\cyrndsc}{T2A}{173}
+\DeclareTextSymbol{\CYRNG}{T2A}{142}
+\DeclareTextSymbol{\cyrng}{T2A}{174}
+\DeclareTextSymbol{\CYRDZE}{T2A}{143}
+\DeclareTextSymbol{\cyrdze}{T2A}{175}
+\DeclareTextSymbol{\CYROTLD}{T2A}{144}
+\DeclareTextSymbol{\cyrotld}{T2A}{176}
+\DeclareTextSymbol{\CYRSDSC}{T2A}{145}
+\DeclareTextSymbol{\cyrsdsc}{T2A}{177}
+\DeclareTextSymbol{\CYRUSHRT}{T2A}{146}
+\DeclareTextSymbol{\cyrushrt}{T2A}{178}
+\DeclareTextSymbol{\CYRY}{T2A}{147}
+\DeclareTextSymbol{\cyry}{T2A}{179}
+\DeclareTextSymbol{\CYRYHCRS}{T2A}{148}
+\DeclareTextSymbol{\cyryhcrs}{T2A}{180}
+\DeclareTextSymbol{\CYRHDSC}{T2A}{149}
+\DeclareTextSymbol{\cyrhdsc}{T2A}{181}
+\DeclareTextSymbol{\CYRDZHE}{T2A}{150}
+\DeclareTextSymbol{\cyrdzhe}{T2A}{182}
+\DeclareTextSymbol{\CYRCHVCRS}{T2A}{151}
+\DeclareTextSymbol{\cyrchvcrs}{T2A}{183}
+\DeclareTextSymbol{\CYRCHRDSC}{T2A}{152}
+\DeclareTextSymbol{\cyrchrdsc}{T2A}{184}
+\DeclareTextSymbol{\CYRIE}{T2A}{153}
+\DeclareTextSymbol{\cyrie}{T2A}{185}
+\DeclareTextSymbol{\CYRSCHWA}{T2A}{154}
+\DeclareTextSymbol{\cyrschwa}{T2A}{186}
+\DeclareTextSymbol{\CYRNJE}{T2A}{155}
+\DeclareTextSymbol{\cyrnje}{T2A}{187}
+%</T2A>
+%
+%<*T2B>
+\DeclareTextSymbol{\CYRGDSCHCRS}{T2B}{128}
+\DeclareTextSymbol{\cyrgdschcrs}{T2B}{160}
+\DeclareTextSymbol{\CYRGHCRS}{T2B}{129}
+\DeclareTextSymbol{\cyrghcrs}{T2B}{161}
+\DeclareTextSymbol{\CYRGDSC}{T2B}{130}
+\DeclareTextSymbol{\cyrgdsc}{T2B}{162}
+\DeclareTextSymbol{\CYRGHK}{T2B}{131}
+\DeclareTextSymbol{\cyrghk}{T2B}{163}
+\DeclareTextSymbol{\CYRSHHA}{T2B}{132}
+\DeclareTextSymbol{\cyrshha}{T2B}{164}
+\DeclareTextSymbol{\CYRZHDSC}{T2B}{133}
+\DeclareTextSymbol{\cyrzhdsc}{T2B}{165}
+\DeclareTextSymbol{\CYRDELTA}{T2B}{134}
+\DeclareTextSymbol{\cyrdelta}{T2B}{166}
+\DeclareTextSymbol{\CYRABHDZE}{T2B}{135}
+\DeclareTextSymbol{\cyrabhdze}{T2B}{167}
+\DeclareTextSymbol{\CYRLJE}{T2B}{136}
+\DeclareTextSymbol{\cyrlje}{T2B}{168}
+\DeclareTextSymbol{\CYRKDSC}{T2B}{137}
+\DeclareTextSymbol{\cyrkdsc}{T2B}{169}
+\DeclareTextSymbol{\CYRLDSC}{T2B}{138}
+\DeclareTextSymbol{\cyrldsc}{T2B}{170}
+\DeclareTextSymbol{\CYRKHK}{T2B}{139}
+\DeclareTextSymbol{\cyrkhk}{T2B}{171}
+\DeclareTextSymbol{\CYRLHK}{T2B}{140}
+\DeclareTextSymbol{\cyrlhk}{T2B}{172}
+\DeclareTextSymbol{\CYRNDSC}{T2B}{141}
+\DeclareTextSymbol{\cyrndsc}{T2B}{173}
+\DeclareTextSymbol{\CYRNG}{T2B}{142}
+\DeclareTextSymbol{\cyrng}{T2B}{174}
+\DeclareTextSymbol{\CYRNHK}{T2B}{143}
+\DeclareTextSymbol{\cyrnhk}{T2B}{175}
+\DeclareTextSymbol{\CYROTLD}{T2B}{144}
+\DeclareTextSymbol{\cyrotld}{T2B}{176}
+\DeclareTextSymbol{\CYRSACRS}{T2B}{145}
+\DeclareTextSymbol{\cyrsacrs}{T2B}{177}
+\DeclareTextSymbol{\CYRUSHRT}{T2B}{146}
+\DeclareTextSymbol{\cyrushrt}{T2B}{178}
+\DeclareTextSymbol{\CYRY}{T2B}{147}
+\DeclareTextSymbol{\cyry}{T2B}{179}
+\DeclareTextSymbol{\CYRHHCRS}{T2B}{148}
+\DeclareTextSymbol{\cyrhhcrs}{T2B}{180}
+\DeclareTextSymbol{\CYRHDSC}{T2B}{149}
+\DeclareTextSymbol{\cyrhdsc}{T2B}{181}
+\DeclareTextSymbol{\CYRHHK}{T2B}{150}
+\DeclareTextSymbol{\cyrhhk}{T2B}{182}
+\DeclareTextSymbol{\CYRCHLDSC}{T2B}{151}
+\DeclareTextSymbol{\cyrchldsc}{T2B}{183}
+\DeclareTextSymbol{\CYRCHRDSC}{T2B}{152}
+\DeclareTextSymbol{\cyrchrdsc}{T2B}{184}
+\DeclareTextSymbol{\CYRNJE}{T2B}{153}
+\DeclareTextSymbol{\cyrnje}{T2B}{185}
+\DeclareTextSymbol{\CYRSCHWA}{T2B}{154}
+\DeclareTextSymbol{\cyrschwa}{T2B}{186}
+\DeclareTextSymbol{\CYREPS}{T2B}{155}
+\DeclareTextSymbol{\cyreps}{T2B}{187}
+%</T2B>
+%
+%<*T2C>
+\DeclareTextSymbol{\CYRPHK}{T2C}{128}
+\DeclareTextSymbol{\cyrphk}{T2C}{160}
+\DeclareTextSymbol{\CYRTETSE}{T2C}{129}
+\DeclareTextSymbol{\cyrtetse}{T2C}{161}
+\DeclareTextSymbol{\CYRTDSC}{T2C}{130}
+\DeclareTextSymbol{\cyrtdsc}{T2C}{162}
+\DeclareTextSymbol{\CYRGHK}{T2C}{131}
+\DeclareTextSymbol{\cyrghk}{T2C}{163}
+\DeclareTextSymbol{\CYRSHHA}{T2C}{132}
+\DeclareTextSymbol{\cyrshha}{T2C}{164}
+\DeclareTextSymbol{\CYRRDSC}{T2C}{133}
+\DeclareTextSymbol{\cyrrdsc}{T2C}{165}
+\DeclareTextSymbol{\CYRRTICK}{T2C}{134}
+\DeclareTextSymbol{\cyrrtick}{T2C}{166}
+\DeclareTextSymbol{\CYRABHDZE}{T2C}{135}
+\DeclareTextSymbol{\cyrabhdze}{T2C}{167}
+\DeclareTextSymbol{\CYRMDSC}{T2C}{136}
+\DeclareTextSymbol{\cyrmdsc}{T2C}{168}
+\DeclareTextSymbol{\CYRKDSC}{T2C}{137}
+\DeclareTextSymbol{\cyrkdsc}{T2C}{169}
+\DeclareTextSymbol{\CYRLDSC}{T2C}{138}
+\DeclareTextSymbol{\cyrldsc}{T2C}{170}
+\DeclareTextSymbol{\CYRKHCRS}{T2C}{139}
+\DeclareTextSymbol{\cyrkhcrs}{T2C}{171}
+\DeclareTextSymbol{\CYRLHK}{T2C}{140}
+\DeclareTextSymbol{\cyrlhk}{T2C}{172}
+\DeclareTextSymbol{\CYRNDSC}{T2C}{141}
+\DeclareTextSymbol{\cyrndsc}{T2C}{173}
+\DeclareTextSymbol{\CYRMHK}{T2C}{142}
+\DeclareTextSymbol{\cyrmhk}{T2C}{174}
+\DeclareTextSymbol{\CYRNHK}{T2C}{143}
+\DeclareTextSymbol{\cyrnhk}{T2C}{175}
+\DeclareTextSymbol{\CYROTLD}{T2C}{144}
+\DeclareTextSymbol{\cyrotld}{T2C}{176}
+\DeclareTextSymbol{\CYRABHCH}{T2C}{145}
+\DeclareTextSymbol{\cyrabhch}{T2C}{177}
+\DeclareTextSymbol{\CYRABHCHDSC}{T2C}{146}
+\DeclareTextSymbol{\cyrabhchdsc}{T2C}{178}
+\DeclareTextSymbol{\CYRSEMISFTSN}{T2C}{147}
+\DeclareTextSymbol{\cyrsemisftsn}{T2C}{179}
+\DeclareTextSymbol{\CYRISHRTDSC}{T2C}{148}
+\DeclareTextSymbol{\cyrishrtdsc}{T2C}{180}
+\DeclareTextSymbol{\CYRHDSC}{T2C}{149}
+\DeclareTextSymbol{\cyrhdsc}{T2C}{181}
+\DeclareTextSymbol{\CYRDZHE}{T2C}{150}
+\DeclareTextSymbol{\cyrdzhe}{T2C}{182}
+\DeclareTextSymbol{\CYRABHHA}{T2C}{151}
+\DeclareTextSymbol{\cyrabhha}{T2C}{183}
+\DeclareTextSymbol{\CYRCHRDSC}{T2C}{152}
+\DeclareTextSymbol{\cyrchrdsc}{T2C}{184}
+\DeclareTextSymbol{\CYRNLHK}{T2C}{153}
+\DeclareTextSymbol{\cyrnlhk}{T2C}{185}
+\DeclareTextSymbol{\CYRSCHWA}{T2C}{154}
+\DeclareTextSymbol{\cyrschwa}{T2C}{186}
+\DeclareTextSymbol{\CYRRHK}{T2C}{155}
+\DeclareTextSymbol{\cyrrhk}{T2C}{187}
+%</T2C>
+%
+\DeclareTextSymbol{\CYRYO}{\LastDeclaredEncoding}{156}
+\DeclareTextSymbol{\cyryo}{\LastDeclaredEncoding}{188}
+% \end{macrocode}
+%
+% The final block of Cyrillic letters occupies the space covered with
+% Latin letters in ASCII. These letters are only present
+% in X2 encoding (which does not contain Latin letters at all). However,
+% some Cyrillic glyphs here look exactly like some Latin analogues, and we
+% declare them also for T2* encodings, so that they are accessible
+% from inputenc files. In T2* encodings, these letters share the same
+% slots with the corresponding Latin letters. The affected letters are:
+% |\CYRII|, |\CYRJE|, |\CYRQ|, |\CYRDZE|, |\CYRW| (and lowercase
+% forms).
+%
+% \begin{macrocode}
+%<*X2>
+\DeclareTextSymbol{\CYRAE}{X2}{65}
+\DeclareTextSymbol{\cyrae}{X2}{97}
+\DeclareTextSymbol{\CYRDJE}{X2}{66}
+\DeclareTextSymbol{\cyrdje}{X2}{98}
+\DeclareTextSymbol{\CYRTSHE}{X2}{67}
+\DeclareTextSymbol{\cyrtshe}{X2}{99}
+\DeclareTextSymbol{\CYRABHCH}{X2}{68}
+\DeclareTextSymbol{\cyrabhch}{X2}{100}
+\DeclareTextSymbol{\CYRABHCHDSC}{X2}{69}
+\DeclareTextSymbol{\cyrabhchdsc}{X2}{101}
+\DeclareTextSymbol{\CYRKVCRS}{X2}{70}
+\DeclareTextSymbol{\cyrkvcrs}{X2}{102}
+\DeclareTextSymbol{\CYRKHCRS}{X2}{71}
+\DeclareTextSymbol{\cyrkhcrs}{X2}{103}
+\DeclareTextSymbol{\CYRLDSC}{X2}{72}
+\DeclareTextSymbol{\cyrldsc}{X2}{104}
+%</X2>
+\DeclareTextSymbol{\CYRII}{\LastDeclaredEncoding}{73}
+\DeclareTextSymbol{\cyrii}{\LastDeclaredEncoding}{105}
+\DeclareTextSymbol{\CYRJE}{\LastDeclaredEncoding}{74}
+\DeclareTextSymbol{\cyrje}{\LastDeclaredEncoding}{106}
+%<*X2>
+\DeclareTextSymbol{\CYRLJE}{X2}{75}
+\DeclareTextSymbol{\cyrlje}{X2}{107}
+\DeclareTextSymbol{\CYRMDSC}{X2}{76}
+\DeclareTextSymbol{\cyrmdsc}{X2}{108}
+\DeclareTextSymbol{\CYRNJE}{X2}{77}
+\DeclareTextSymbol{\cyrnje}{X2}{109}
+\DeclareTextSymbol{\CYRABHHA}{X2}{78}
+\DeclareTextSymbol{\cyrabhha}{X2}{110}
+\DeclareTextSymbol{\CYRPHK}{X2}{79}
+\DeclareTextSymbol{\cyrphk}{X2}{111}
+\DeclareTextSymbol{\CYRRDSC}{X2}{80}
+\DeclareTextSymbol{\cyrrdsc}{X2}{112}
+%</X2>
+\DeclareTextSymbol{\CYRQ}{\LastDeclaredEncoding}{81}
+\DeclareTextSymbol{\cyrq}{\LastDeclaredEncoding}{113}
+%<*X2>
+\DeclareTextSymbol{\CYRTDSC}{X2}{82}
+\DeclareTextSymbol{\cyrtdsc}{X2}{114}
+%</X2>
+%<!T2A>\DeclareTextSymbol{\CYRDZE}{\LastDeclaredEncoding}{83}
+%<!T2A>\DeclareTextSymbol{\cyrdze}{\LastDeclaredEncoding}{115}
+%<*X2>
+\DeclareTextSymbol{\CYRTETSE}{X2}{84}
+\DeclareTextSymbol{\cyrtetse}{X2}{116}
+\DeclareTextSymbol{\CYRDZHE}{X2}{85}
+\DeclareTextSymbol{\cyrdzhe}{X2}{117}
+\DeclareTextSymbol{\CYRCHVCRS}{X2}{86}
+\DeclareTextSymbol{\cyrchvcrs}{X2}{118}
+%</X2>
+\DeclareTextSymbol{\CYRW}{\LastDeclaredEncoding}{87}
+\DeclareTextSymbol{\cyrw}{\LastDeclaredEncoding}{119}
+%<*X2>
+\DeclareTextSymbol{\CYRYAT}{X2}{88}
+\DeclareTextSymbol{\cyryat}{X2}{120}
+\DeclareTextSymbol{\CYRBYUS}{X2}{89}
+\DeclareTextSymbol{\cyrbyus}{X2}{121}
+\DeclareTextSymbol{\CYRIZH}{X2}{90}
+\DeclareTextSymbol{\cyrizh}{X2}{122}
+%</X2>
+%<*X2>
+\DeclareTextSymbol{\CYRDELTA}{X2}{28}
+\DeclareTextSymbol{\cyrdelta}{X2}{29}
+\DeclareTextSymbol{\CYRNLHK}{X2}{30}
+\DeclareTextSymbol{\cyrnlhk}{X2}{31}
+%</X2>
+%</X2|T2A|T2B|T2C>
+% \end{macrocode}
+% Text composites. The following declarations will not work for 8-bit
+% chars generated via |inputenc| unless a |dblaccnt| package is used.
+% \begin{macrocode}
+\DeclareTextComposite{\"}{\LastDeclaredEncoding}{\CYRE}{156}
+\DeclareTextComposite{\"}{\LastDeclaredEncoding}{\cyre}{188}
+\DeclareTextComposite{\U}{\LastDeclaredEncoding}{\CYRI}{201}
+\DeclareTextComposite{\U}{\LastDeclaredEncoding}{\cyri}{233}
+%<*X2|T2A>
+\DeclareTextComposite{\"}{\LastDeclaredEncoding}{\CYRII}{136}
+\DeclareTextComposite{\"}{\LastDeclaredEncoding}{\cyrii}{168}
+\DeclareTextComposite{\c}{\LastDeclaredEncoding}{\CYRZ}{134}
+\DeclareTextComposite{\c}{\LastDeclaredEncoding}{\cyrz}{166}
+\DeclareTextComposite{\k}{\LastDeclaredEncoding}{\CYRS}{145}
+\DeclareTextComposite{\k}{\LastDeclaredEncoding}{\cyrs}{177}
+%</X2|T2A>
+%<*X2|T2A|T2B>
+\DeclareTextComposite{\U}{\LastDeclaredEncoding}{\CYRU}{146}
+\DeclareTextComposite{\U}{\LastDeclaredEncoding}{\cyru}{178}
+%</X2|T2A|T2B>
+%<*X2>
+\DeclareTextComposite{\k}{X2}{\CYRABHCH}{69}
+\DeclareTextComposite{\k}{X2}{\cyrabhch}{101}
+%</X2>
+%<*T2C>
+\DeclareTextComposite{\k}{T2C}{\CYRABHCH}{146}
+\DeclareTextComposite{\k}{T2C}{\cyrabhch}{178}
+%</T2C>
+% \end{macrocode}
+\endinput
diff --git a/macros/latex/required/cyrillic/cyoutenc.pdf b/macros/latex/required/cyrillic/cyoutenc.pdf
new file mode 100644
index 0000000000..e82387a659
--- /dev/null
+++ b/macros/latex/required/cyrillic/cyoutenc.pdf
Binary files differ
diff --git a/macros/latex/required/cyrillic/cyrlatex.ins b/macros/latex/required/cyrillic/cyrlatex.ins
new file mode 100644
index 0000000000..701479f03a
--- /dev/null
+++ b/macros/latex/required/cyrillic/cyrlatex.ins
@@ -0,0 +1,277 @@
+%%
+%% 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 1993-2017
+%% The LaTeX3 Project and any individual authors listed elsewhere
+%% in this file.
+%%
+%% This file is part of the Standard LaTeX `Cyrillic 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 `Cyrillic Bundle' is
+%% given in the file `manifest.txt'.
+%%
+%%
+%% --------------- start of docstrip commands ------------------
+%%
+%% Copyright 1993-2017
+%%
+%% This file is part of the `cyrillic' bundle in the LaTeX2e distribution.
+%%
+%% You are allowed to distribute this file together with all files
+%% mentioned in manifest.txt.
+%%
+%% You are not allowed to modify its contents.
+%%
+
+\input docstrip
+\keepsilent
+\usedir{tex/latex/cyrillic}
+
+\preamble
+This file is a generated file from the sources of the `cyrillic' bundle
+in the LaTeX2e distribution.
+
+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 `Cyrillic 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
+`Cyrillic Bundle'. You may however distribute the LaTeX `Cyrillic
+Bundle' without such generated files.
+
+The list of all files belonging to the `Cyrillic Bundle' is
+given in the file `manifest.txt'.
+
+\endpreamble
+
+% Encoding definition files:
+\generate{
+ \file{x2enc.def}{\from{cyoutenc.dtx}{X2}}
+ \file{t2aenc.def}{\from{cyoutenc.dtx}{T2A}}
+ \file{t2benc.def}{\from{cyoutenc.dtx}{T2B}}
+ \file{t2cenc.def}{\from{cyoutenc.dtx}{T2C}}
+% old font encodings:
+ \file{ot2enc.def}{\from{ot2.dtx}{OT2}}
+ \file{lcyenc.def}{\from{lcy.dtx}{LCY}}
+% support files for LCY encoding:
+ \file{lcydefs.tex}{\from{lcy.dtx}{LCYdefs}}
+ \file{lcy.sty}{\from{lcy.dtx}{wrapper}}
+}
+
+% Cyrillic codepages (to be used with inputenc):
+\generate{
+ \file{cp866.def}{\from{cyinpenc.dtx}{cp866,std}}
+ \file{cp866av.def}{\from{cyinpenc.dtx}{cp866,AV}}
+ \file{cp866mav.def}{\from{cyinpenc.dtx}{cp866,MAV}}
+ \file{cp866nav.def}{\from{cyinpenc.dtx}{cp866,NAV}}
+ \file{cp866tat.def}{\from{cyinpenc.dtx}{cp866,Tatar}}
+ \file{cp1251.def}{\from{cyinpenc.dtx}{cp1251}}
+ \file{cp855.def}{\from{cyinpenc.dtx}{cp855}}
+}
+\generate{
+ \file{koi8-r.def}{\from{cyinpenc.dtx}{koi8,koi8r}}
+ \file{koi8-ru.def}{\from{cyinpenc.dtx}{koi8,koi8ru}}
+ \file{koi8-u.def}{\from{cyinpenc.dtx}{koi8,koi8u}}
+ \file{isoir111.def}{\from{cyinpenc.dtx}{koi8,isoir111}}
+ \file{iso88595.def}{\from{cyinpenc.dtx}{ISO88595}}
+ \file{maccyr.def}{\from{cyinpenc.dtx}{maccyrillic}}
+ \file{macukr.def}{\from{cyinpenc.dtx}{macukrainian}}
+ \file{mik.def}{\from{cyinpenc.dtx}{MIK}}
+}
+% Mongolian Cyrillic codepages:
+\generate{
+ \file{ctt.def}{\from{cyinpenc.dtx}{CTT}}
+ \file{dbk.def}{\from{cyinpenc.dtx}{DBK}}
+ \file{mnk.def}{\from{cyinpenc.dtx}{MNK}}
+ \file{mos.def}{\from{cyinpenc.dtx}{MOS}}
+ \file{ncc.def}{\from{cyinpenc.dtx}{NCC}}
+ \file{mls.def}{\from{cyinpenc.dtx}{MLS}}
+% ParaType Cyrillic Asian codepages:
+ \file{pt154.def}{\from{cyinpenc.dtx}{pt154}}
+ \file{pt254.def}{\from{cyinpenc.dtx}{pt254}}
+}
+
+\preamble
+This file is a generated file from the sources of the `cyrillic' bundle
+in the LaTeX2e distribution.
+
+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-2016
+The LaTeX3 Project and any individual authors listed elsewhere
+in this file.
+
+This file was generated from file(s) of the Standard LaTeX `Cyrillic 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
+`Cyrillic Bundle'. You may however distribute the LaTeX `Cyrillic
+Bundle' without such generated files.
+
+The list of all files belonging to the `Cyrillic Bundle' is
+given in the file `manifest.txt'.
+
+In particular, permission is granted to customize the declarations in
+this file to serve the needs of your installation.
+
+However, a modified version of this file under its original name
+should not be distributed as part of a standard LaTeX distribution, as
+the modification will be nontransparent for the user of that
+distribution (and thus violating clause 6a of the LPPL license),
+making successful document exchange impossible.
+
+\endpreamble
+
+% X2 Cyrillic Computer Modern font definition files:
+\generate{
+ \file{x2cmdh.fd}{\from{t2lhfnt.fdd}{X2cmdh}}
+ \file{x2cmfib.fd}{\from{t2lhfnt.fdd}{X2cmfib}}
+ \file{x2cmfr.fd}{\from{t2lhfnt.fdd}{X2cmfr}}
+ \file{x2cmr.fd}{\from{t2lhfnt.fdd}{X2cmr}}
+ \file{x2cmss.fd}{\from{t2lhfnt.fdd}{X2cmss}}
+ \file{x2cmtt.fd}{\from{t2lhfnt.fdd}{X2cmtt,tt,nowarn}}
+ \file{x2cmvtt.fd}{\from{t2lhfnt.fdd}{X2cmvtt,tt}}
+ \file{x2lcmss.fd}{\from{t2lhfnt.fdd}{lcmss,X2}}
+ \file{x2lcmtt.fd}{\from{t2lhfnt.fdd}{lcmtt,X2}}
+ \file{x2cmbr.fd}{\from{t2lhfnt.fdd}{X2cmbr}}
+ \file{x2cmtl.fd}{\from{t2lhfnt.fdd}{X2cmtl}}
+ \file{x2ccr.fd}{\from{t2lhfnt.fdd}{X2ccr}}
+}
+
+% T2A Cyrillic Computer Modern font definition files:
+\generate{
+ \file{t2acmdh.fd}{\from{t2lhfnt.fdd}{T2Acmdh}}
+ \file{t2acmfib.fd}{\from{t2lhfnt.fdd}{T2Acmfib}}
+ \file{t2acmfr.fd}{\from{t2lhfnt.fdd}{T2Acmfr}}
+ \file{t2acmr.fd}{\from{t2lhfnt.fdd}{T2Acmr}}
+ \file{t2acmss.fd}{\from{t2lhfnt.fdd}{T2Acmss}}
+ \file{t2acmtt.fd}{\from{t2lhfnt.fdd}{T2Acmtt,tt,nowarn}}
+ \file{t2acmvtt.fd}{\from{t2lhfnt.fdd}{T2Acmvtt,tt}}
+ \file{t2alcmss.fd}{\from{t2lhfnt.fdd}{lcmss,T2A}}
+ \file{t2alcmtt.fd}{\from{t2lhfnt.fdd}{lcmtt,T2A}}
+ \file{t2acmbr.fd}{\from{t2lhfnt.fdd}{T2Acmbr}}
+ \file{t2acmtl.fd}{\from{t2lhfnt.fdd}{T2Acmtl}}
+ \file{t2accr.fd}{\from{t2lhfnt.fdd}{T2Accr}}
+}
+
+% T2B Cyrillic Computer Modern font definition files:
+\generate{
+ \file{t2bcmdh.fd}{\from{t2lhfnt.fdd}{T2Bcmdh}}
+ \file{t2bcmfib.fd}{\from{t2lhfnt.fdd}{T2Bcmfib}}
+ \file{t2bcmfr.fd}{\from{t2lhfnt.fdd}{T2Bcmfr}}
+ \file{t2bcmr.fd}{\from{t2lhfnt.fdd}{T2Bcmr}}
+ \file{t2bcmss.fd}{\from{t2lhfnt.fdd}{T2Bcmss}}
+ \file{t2bcmtt.fd}{\from{t2lhfnt.fdd}{T2Bcmtt,tt,nowarn}}
+ \file{t2bcmvtt.fd}{\from{t2lhfnt.fdd}{T2Bcmvtt,tt}}
+ \file{t2blcmss.fd}{\from{t2lhfnt.fdd}{lcmss,T2B}}
+ \file{t2blcmtt.fd}{\from{t2lhfnt.fdd}{lcmtt,T2B}}
+ \file{t2bcmbr.fd}{\from{t2lhfnt.fdd}{T2Bcmbr}}
+ \file{t2bcmtl.fd}{\from{t2lhfnt.fdd}{T2Bcmtl}}
+ \file{t2bccr.fd}{\from{t2lhfnt.fdd}{T2Bccr}}
+}
+
+% T2C Cyrillic Computer Modern font definition files:
+\generate{
+ \file{t2ccmdh.fd}{\from{t2lhfnt.fdd}{T2Ccmdh}}
+ \file{t2ccmfib.fd}{\from{t2lhfnt.fdd}{T2Ccmfib}}
+ \file{t2ccmfr.fd}{\from{t2lhfnt.fdd}{T2Ccmfr}}
+ \file{t2ccmr.fd}{\from{t2lhfnt.fdd}{T2Ccmr}}
+ \file{t2ccmss.fd}{\from{t2lhfnt.fdd}{T2Ccmss}}
+ \file{t2ccmtt.fd}{\from{t2lhfnt.fdd}{T2Ccmtt,tt,nowarn}}
+ \file{t2ccmvtt.fd}{\from{t2lhfnt.fdd}{T2Ccmvtt,tt}}
+ \file{t2clcmss.fd}{\from{t2lhfnt.fdd}{lcmss,T2C}}
+ \file{t2clcmtt.fd}{\from{t2lhfnt.fdd}{lcmtt,T2C}}
+ \file{t2ccmbr.fd}{\from{t2lhfnt.fdd}{T2Ccmbr}}
+ \file{t2ccmtl.fd}{\from{t2lhfnt.fdd}{T2Ccmtl}}
+ \file{t2cccr.fd}{\from{t2lhfnt.fdd}{T2Cccr}}
+}
+
+% font definition files for OT2 encoding / LH fonts
+\generate{
+ \file{ot2cmss.fd}{\from{ot2cmlh.fdd}{OT2cmss}}
+ \file{ot2cmr.fd}{\from{ot2cmlh.fdd}{OT2cmr}}
+ \file{ot2cmtt.fd}{\from{ot2cmlh.fdd}{OT2cmtt,nowarn}}
+ \file{ot2cmvtt.fd}{\from{ot2cmlh.fdd}{OT2cmvtt}}
+ \file{ot2cmfib.fd}{\from{ot2cmlh.fdd}{OT2cmfib}}
+ \file{ot2cmfr.fd}{\from{ot2cmlh.fdd}{OT2cmfr}}
+ \file{ot2cmdh.fd}{\from{ot2cmlh.fdd}{OT2cmdh}}
+ \file{ot2lcmss.fd}{\from{ot2cmlh.fdd}{OT2lcmss}}
+ \file{ot2lcmtt.fd}{\from{ot2cmlh.fdd}{OT2lcmtt}}
+ \file{ot2cmbr.fd}{\from{ot2cmlh.fdd}{OT2cmbr}}
+ \file{ot2cmtl.fd}{\from{ot2cmlh.fdd}{OT2cmtl}}
+ \file{ot2ccr.fd}{\from{ot2cmlh.fdd}{OT2ccr}}
+}
+
+% font definition files for OT2 encoding / WNCY fonts
+\generate{
+ \file{ot2wncyr.fd}{\from{ot2cmams.fdd}{OT2wncyr,pdftex}}
+ \file{ot2wncyss.fd}{\from{ot2cmams.fdd}{OT2wncyss,pdftex}}
+% virtual fonts without ligatures
+ \file{ot2wlcyr.fd}{\from{ot2cmams.fdd}{OT2wlcyr,pdftex}}
+ \file{ot2wlcyss.fd}{\from{ot2cmams.fdd}{OT2wlcyss,pdftex}}
+}
+
+% font definition files for LCY encoding / LH fonts
+\generate{
+ \file{lcycmss.fd}{\from{lcycmlh.fdd}{LCYcmss}}
+ \file{lcycmr.fd}{\from{lcycmlh.fdd}{LCYcmr}}
+ \file{lcycmtt.fd}{\from{lcycmlh.fdd}{LCYcmtt,nowarn}}
+ \file{lcycmvtt.fd}{\from{lcycmlh.fdd}{LCYcmvtt}}
+ \file{lcycmfib.fd}{\from{lcycmlh.fdd}{LCYcmfib}}
+ \file{lcycmfr.fd}{\from{lcycmlh.fdd}{LCYcmfr}}
+ \file{lcycmdh.fd}{\from{lcycmlh.fdd}{LCYcmdh}}
+ \file{lcylcmss.fd}{\from{lcycmlh.fdd}{LCYlcmss}}
+ \file{lcylcmtt.fd}{\from{lcycmlh.fdd}{LCYlcmtt}}
+ \file{lcycmbr.fd}{\from{lcycmlh.fdd}{LCYcmbr}}
+ \file{lcycmtl.fd}{\from{lcycmlh.fdd}{LCYcmtl}}
+ \file{lcyccr.fd}{\from{lcycmlh.fdd}{LCYccr}}
+}
+
+\endbatchfile
diff --git a/macros/latex/required/cyrillic/lcy.dtx b/macros/latex/required/cyrillic/lcy.dtx
new file mode 100644
index 0000000000..6605733fe6
--- /dev/null
+++ b/macros/latex/required/cyrillic/lcy.dtx
@@ -0,0 +1,382 @@
+% \iffalse meta-comment
+%
+% Copyright 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2008 2009
+% The LaTeX3 Project and any individual authors listed elsewhere
+% in this file.
+%
+% This file is part of the Standard LaTeX `Cyrillic Bundle'.
+% ----------------------------------------------------------
+%
+% It may be distributed and/or modified under the
+% conditions of the LaTeX Project Public License, either version 1.3b
+% 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.3b or later is part of all distributions of LaTeX
+% version 2005/12/01 or later.
+%
+% The list of all files belonging to the `Cyrillic Bundle' is
+% given in the file `manifest.txt'.
+%
+% \fi
+% \iffalse
+% This is the file |lcy.dtx| of the cyrillic bundle for LaTeX2e.
+%
+% Copyright (C) 1995-1997 Olga Lapko, Johannes L. Braams
+% Copyright (C) 1998-2001 Werner Lemberg, Vladimir Volovich
+%
+%<*driver>
+\documentclass{ltxdoc}
+\begin{document}
+\DocInput{lcy.dtx}
+\end{document}
+%</driver>
+% \fi
+%
+% \begin{macrocode}
+%<*LCY>
+\NeedsTeXFormat{LaTeX2e}[1998/12/01]
+\ProvidesFile{lcyenc.def}
+ [2004/05/28 v3.4d Cyrillic encoding definition file]
+% \end{macrocode}
+%
+% \section{Definitions for the \texttt{LCY} encoding}
+%
+% The definitions for the `\TeX{} text Cyrillic' (|LCY|) encoding.
+%
+% The |LCY| encoding is an extension of the |OT1| encoding; all lower
+% 128 positions are the same (and this part of the file was taken from
+% ot1enc.def), but most of the upper 128 positions are used for Cyrillic
+% glyphs.
+%
+% Important note: The |LCY| font encoding is \emph{incompatible} with the
+% \LaTeXe\ standard conventions regarding uccode and lccode settings!
+% Therefore, the |LCY| font encoding should not be used in a multilingual
+% environment (for example, Russian, German, and English), because the
+% hyphenation will be broken! Instead, use the new standard Cyrillic
+% encodings |T2A|, |T2B|, |T2C| and |X2| defined in the \textsf{cyrillic}
+% bundle for \LaTeXe. One can only use |LCY| to typeset at most bilingual
+% Russian-English documents.
+%
+% Because of this incompatibility we have to set the lccode values,
+% which are important for \TeX's hyphenation process, to match the |LCY|
+% encoding. We do not need to set the uccode and catcode values because
+% they are unused in hyphenation process, and uppercase
+% $\leftrightarrow$ lowercase translation is defined via another
+% mechanism in |\MakeUppercase| and |\MakeLowercase| commands. Again,
+% this change of lccodes will break hyphenation for other languages with
+% standard 8-bit font encodings! It is useless to make these changes in
+% |\extrasrussian| (i.e., `locally') for the same reason, so we make
+% global changes, which are stored in the file |lcydefs.tex| defined
+% below.
+%
+% Note that \emph{it is not sufficient to use the |LCY| encoding via the
+% \textsf{fontenc} package, but one also should load a file |lcydefs.tex|
+% which sets lccode and other \TeX\ registers for |LCY| encoding
+% globally (breaking standard 8-bit font encodings)}. For this reason we
+% created also a wrapper package `lcy' which is a preferred mechanism
+% for using the |LCY| font encoding, --- it loads |LCY| encoding
+% definition file and |lcydefs.tex|.
+%
+% We rely on \LaTeX\ to set the |\@uclclist|, and thus the
+% |\NeedsTeXFormat| line above.
+%
+% Declare the Local Cyrillic encoding. Specify a default for the font
+% substitution process for the |LCY| encoding.
+% \begin{macrocode}
+\DeclareFontEncoding{LCY}{}{}
+\DeclareFontSubstitution{LCY}{cmr}{m}{n}
+% \end{macrocode}
+% Declare the accents.
+% \begin{macrocode}
+\DeclareTextAccent{\"}{LCY}{127}
+\DeclareTextAccent{\'}{LCY}{19}
+\DeclareTextAccent{\.}{LCY}{95}
+\DeclareTextAccent{\=}{LCY}{22}
+\DeclareTextAccent{\^}{LCY}{94}
+\DeclareTextAccent{\`}{LCY}{18}
+\DeclareTextAccent{\~}{LCY}{126}
+\DeclareTextAccent{\H}{LCY}{125}
+\DeclareTextAccent{\u}{LCY}{21}
+\DeclareTextAccent{\v}{LCY}{20}
+\DeclareTextAccent{\r}{LCY}{23}
+% \end{macrocode}
+% A fake accent for the Cyrillic breve.
+% \begin{macrocode}
+\DeclareTextCommand{\U}{LCY}[1]{\TextSymbolUnavailable{\U{#1}}#1}
+% \end{macrocode}
+% Some accents have to be built by hand:
+% \begin{macrocode}
+\DeclareTextCommand{\b}{LCY}[1]
+ {\hmode@bgroup\o@lign{\relax#1\crcr\hidewidth\sh@ft{29}%
+ \vbox to.2ex{\hbox{\char22}\vss}\hidewidth}\egroup}
+\DeclareTextCommand{\c}{LCY}[1]
+ {\leavevmode\setbox\z@\hbox{#1}\ifdim\ht\z@=1ex\accent24 #1%
+ \else{\ooalign{\unhbox\z@\crcr\hidewidth\char24\hidewidth}}\fi}
+\DeclareTextCommand{\d}{LCY}[1]
+ {\hmode@bgroup
+ \o@lign{\relax#1\crcr\hidewidth\sh@ft{10}.\hidewidth}\egroup}
+% \end{macrocode}
+% Declare the text symbols.
+% \begin{macrocode}
+\DeclareTextSymbol{\AE}{LCY}{29}
+\DeclareTextSymbol{\OE}{LCY}{30}
+\DeclareTextSymbol{\O}{LCY}{31}
+\DeclareTextSymbol{\ae}{LCY}{26}
+\DeclareTextSymbol{\i}{LCY}{16}
+\DeclareTextSymbol{\j}{LCY}{17}
+\DeclareTextSymbol{\oe}{LCY}{27}
+\DeclareTextSymbol{\o}{LCY}{28}
+\DeclareTextSymbol{\ss}{LCY}{25}
+\DeclareTextSymbol{\textemdash}{LCY}{124}
+\DeclareTextSymbol{\textendash}{LCY}{123}
+\DeclareTextSymbol{\textexclamdown}{LCY}{60}
+%\DeclareTextSymbol{\texthyphenchar}{LCY}{`\-}
+%\DeclareTextSymbol{\texthyphen}{LCY}{`\-}
+\DeclareTextSymbol{\textquestiondown}{LCY}{62}
+\DeclareTextSymbol{\textquotedblleft}{LCY}{92}
+\DeclareTextSymbol{\textquotedblright}{LCY}{`\"}
+\DeclareTextSymbol{\textquoteleft}{LCY}{`\`}
+\DeclareTextSymbol{\textquoteright}{LCY}{`\'}
+% \end{macrocode}
+% Some symbols which are faked from others:
+% \begin{macrocode}
+\DeclareTextCommand{\L}{LCY}
+ {\leavevmode\setbox\z@\hbox{L}\hb@xt@\wd\z@{\hss\@xxxii L}}
+\DeclareTextCommand{\l}{LCY}
+ {\hmode@bgroup\@xxxii l\egroup}
+%<*AAhack>
+%\DeclareTextCommand{\AA}{LCY}
+% {\leavevmode\setbox\z@\hbox{!}\dimen@\ht\z@\advance\dimen@-1ex%
+% \rlap{\raise.67\dimen@\hbox{\char23}}A}
+%\DeclareTextCommand{\aa}{LCY}{{\accent23a}}
+%</AAhack>
+% \end{macrocode}
+%<*AAhack>
+% In the |LCY| encoding `\r A' has a hand-crafted definition:
+% \begin{macrocode}
+\DeclareTextCompositeCommand{\r}{LCY}{A}
+ {\leavevmode\setbox\z@\hbox{!}\dimen@\ht\z@\advance\dimen@-1ex%
+ \rlap{\raise.67\dimen@\hbox{\char23}}A}
+% \end{macrocode}
+%</AAhack>
+% In the |LCY| encoding, `\pounds' and `\$' share a slot.
+% \begin{macrocode}
+\DeclareTextCommand{\textdollar}{LCY}{\hmode@bgroup
+ \ifdim \fontdimen\@ne\font >\z@
+ \slshape
+ \else
+ \upshape
+ \fi
+ \char`\$\egroup}
+\DeclareTextCommand{\textsterling}{LCY}{\hmode@bgroup
+ \ifdim \fontdimen\@ne\font >\z@
+ \itshape
+ \else
+ \fontshape{ui}\selectfont
+ \fi
+ \char`\$\egroup}
+% \end{macrocode}
+% And now, the Cyrillic part of the |LCY| encoding:
+% \begin{macrocode}
+\DeclareTextSymbol{\CYRA}{LCY}{128}
+\DeclareTextSymbol{\CYRB}{LCY}{129}
+\DeclareTextSymbol{\CYRV}{LCY}{130}
+\DeclareTextSymbol{\CYRG}{LCY}{131}
+\DeclareTextSymbol{\CYRD}{LCY}{132}
+\DeclareTextSymbol{\CYRE}{LCY}{133}
+\DeclareTextSymbol{\CYRZH}{LCY}{134}
+\DeclareTextSymbol{\CYRZ}{LCY}{135}
+\DeclareTextSymbol{\CYRI}{LCY}{136}
+\DeclareTextSymbol{\CYRISHRT}{LCY}{137}
+\DeclareTextSymbol{\CYRK}{LCY}{138}
+\DeclareTextSymbol{\CYRL}{LCY}{139}
+\DeclareTextSymbol{\CYRM}{LCY}{140}
+\DeclareTextSymbol{\CYRN}{LCY}{141}
+\DeclareTextSymbol{\CYRO}{LCY}{142}
+\DeclareTextSymbol{\CYRP}{LCY}{143}
+\DeclareTextSymbol{\CYRR}{LCY}{144}
+\DeclareTextSymbol{\CYRS}{LCY}{145}
+\DeclareTextSymbol{\CYRT}{LCY}{146}
+\DeclareTextSymbol{\CYRU}{LCY}{147}
+\DeclareTextSymbol{\CYRF}{LCY}{148}
+\DeclareTextSymbol{\CYRH}{LCY}{149}
+\DeclareTextSymbol{\CYRC}{LCY}{150}
+\DeclareTextSymbol{\CYRCH}{LCY}{151}
+\DeclareTextSymbol{\CYRSH}{LCY}{152}
+\DeclareTextSymbol{\CYRSHCH}{LCY}{153}
+\DeclareTextSymbol{\CYRHRDSN}{LCY}{154}
+\DeclareTextSymbol{\CYRERY}{LCY}{155}
+\DeclareTextSymbol{\CYRSFTSN}{LCY}{156}
+\DeclareTextSymbol{\CYREREV}{LCY}{157}
+\DeclareTextSymbol{\CYRYU}{LCY}{158}
+\DeclareTextSymbol{\CYRYA}{LCY}{159}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\DeclareTextSymbol{\cyra}{LCY}{160}
+\DeclareTextSymbol{\cyrb}{LCY}{161}
+\DeclareTextSymbol{\cyrv}{LCY}{162}
+\DeclareTextSymbol{\cyrg}{LCY}{163}
+\DeclareTextSymbol{\cyrd}{LCY}{164}
+\DeclareTextSymbol{\cyre}{LCY}{165}
+\DeclareTextSymbol{\cyrzh}{LCY}{166}
+\DeclareTextSymbol{\cyrz}{LCY}{167}
+\DeclareTextSymbol{\cyri}{LCY}{168}
+\DeclareTextSymbol{\cyrishrt}{LCY}{169}
+\DeclareTextSymbol{\cyrk}{LCY}{170}
+\DeclareTextSymbol{\cyrl}{LCY}{171}
+\DeclareTextSymbol{\cyrm}{LCY}{172}
+\DeclareTextSymbol{\cyrn}{LCY}{173}
+\DeclareTextSymbol{\cyro}{LCY}{174}
+\DeclareTextSymbol{\cyrp}{LCY}{175}
+\DeclareTextSymbol{\cyrr}{LCY}{224}
+\DeclareTextSymbol{\cyrs}{LCY}{225}
+\DeclareTextSymbol{\cyrt}{LCY}{226}
+\DeclareTextSymbol{\cyru}{LCY}{227}
+\DeclareTextSymbol{\cyrf}{LCY}{228}
+\DeclareTextSymbol{\cyrh}{LCY}{229}
+\DeclareTextSymbol{\cyrc}{LCY}{230}
+\DeclareTextSymbol{\cyrch}{LCY}{231}
+\DeclareTextSymbol{\cyrsh}{LCY}{232}
+\DeclareTextSymbol{\cyrshch}{LCY}{233}
+\DeclareTextSymbol{\cyrhrdsn}{LCY}{234}
+\DeclareTextSymbol{\cyrery}{LCY}{235}
+\DeclareTextSymbol{\cyrsftsn}{LCY}{236}
+\DeclareTextSymbol{\cyrerev}{LCY}{237}
+\DeclareTextSymbol{\cyryu}{LCY}{238}
+\DeclareTextSymbol{\cyrya}{LCY}{239}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\DeclareTextSymbol{\CYRYO}{LCY}{240}
+\DeclareTextSymbol{\cyryo}{LCY}{241}
+\DeclareTextSymbol{\CYRGUP}{LCY}{242}
+\DeclareTextSymbol{\cyrgup}{LCY}{243}
+\DeclareTextSymbol{\CYRIE}{LCY}{244}
+\DeclareTextSymbol{\cyrie}{LCY}{245}
+\DeclareTextSymbol{\CYRII}{LCY}{246}
+\DeclareTextSymbol{\cyrii}{LCY}{247}
+\DeclareTextSymbol{\CYRYI}{LCY}{248}
+\DeclareTextSymbol{\cyryi}{LCY}{249}
+\DeclareTextSymbol{\CYRUSHRT}{LCY}{250}
+\DeclareTextSymbol{\cyrushrt}{LCY}{251}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\DeclareTextSymbol{\cyrdash}{LCY}{196}
+\DeclareTextSymbol{\textcurrency}{LCY}{197}
+\DeclareTextSymbol{\textnumero}{LCY}{252}
+\DeclareTextSymbol{\guillemotleft}{LCY}{253}
+\DeclareTextSymbol{\guillemotright}{LCY}{254}
+\DeclareTextSymbol{\quotedblbase}{LCY}{255}
+% \end{macrocode}
+% Text composites. The following declarations will not work for 8-bit
+% chars generated via |inputenc| unless a |dblaccnt| package is used.
+% \begin{macrocode}
+\DeclareTextComposite{\"}{LCY}{\CYRE}{240}
+\DeclareTextComposite{\"}{LCY}{\cyre}{241}
+\DeclareTextComposite{\U}{LCY}{\CYRI}{137}
+\DeclareTextComposite{\U}{LCY}{\cyri}{169}
+\DeclareTextComposite{\"}{LCY}{\CYRII}{248}
+\DeclareTextComposite{\"}{LCY}{\cyrii}{249}
+\DeclareTextComposite{\U}{LCY}{\CYRU}{250}
+\DeclareTextComposite{\U}{LCY}{\cyru}{251}
+%</LCY>
+% \end{macrocode}
+%
+% \section{Setup \{cat,uc,lc,sf,math\}code values for LCY font encoding}
+%
+% We store this setup in a separate file, |lcydefs.tex|, which is
+% used also in a `cyrplain' bundle for Plain \TeX.
+%
+% \begin{macrocode}
+%<*LCYdefs>
+\def\letter#1 #2 {%
+% \end{macrocode}
+% Do not break inputenc:
+% \begin{macrocode}
+ \ifnum\catcode#1=13\else\catcode#1=11 \catcode#2=11 \fi
+ \uccode#1=#1 \uccode#2=#1
+ \lccode#1=#2 \lccode#2=#2
+ \sfcode#1=999 \sfcode#2=1000
+ \count255=#1 \advance\count255 "7000 \mathcode#1=\count255
+ \count255=#2 \advance\count255 "7000 \mathcode#2=\count255
+}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\letter 128 160
+\letter 129 161
+\letter 130 162
+\letter 131 163
+\letter 132 164
+\letter 133 165
+\letter 134 166
+\letter 135 167
+\letter 136 168
+\letter 137 169
+\letter 138 170
+\letter 139 171
+\letter 140 172
+\letter 141 173
+\letter 142 174
+\letter 143 175
+\letter 144 224
+\letter 145 225
+\letter 146 226
+\letter 147 227
+\letter 148 228
+\letter 149 229
+\letter 150 230
+\letter 151 231
+\letter 152 232
+\letter 153 233
+\letter 154 234
+\letter 155 235
+\letter 156 236
+\letter 157 237
+\letter 158 238
+\letter 159 239
+\letter 240 241
+\letter 242 243
+\letter 244 245
+\letter 246 247
+\letter 248 249
+\letter 250 251
+\let\letter\undefined
+% \end{macrocode}
+% To avoid bad hyphenation of words delimited with non-letter signs
+% (like quotes), we have to zero uc/lccode parameters for these
+% non-letter signs.
+% \begin{macrocode}
+\lccode 196=0 \uccode 196=0 \lccode 197=0 \uccode 197=0
+\lccode 252=0 \uccode 252=0 \lccode 253=0 \uccode 253=0
+\lccode 254=0 \uccode 254=0 \lccode 255=0 \uccode 255=0
+%</LCYdefs>
+% \end{macrocode}
+%
+% \section{A wrapper package for the \texttt{LCY} encoding}
+%
+% \begin{macrocode}
+%<*wrapper>
+\ProvidesPackage{lcy}[1999/06/06 v1.0 Wrapper for LCY encoding]
+% \end{macrocode}
+% You can use the `\textsf{nowarn}' option to suppress boring warning.
+% \begin{macrocode}
+\DeclareOption{nowarn}{\let\iflcy@warn\iffalse}
+\let\iflcy@warn\iftrue
+\ProcessOptions
+\iflcy@warn
+\typeout{%
+****************************************************^^J%
+* The LCY encoding will break multilingual documents^^J%
+* because it needs non-standard uc/lccode settings.^^J%
+* Please use T2* encodings instead.^^J%
+****************************************************}
+\fi
+\RequirePackage[LCY]{fontenc}
+\input{lcydefs}
+%</wrapper>
+% \end{macrocode}
+\endinput
diff --git a/macros/latex/required/cyrillic/lcy.pdf b/macros/latex/required/cyrillic/lcy.pdf
new file mode 100644
index 0000000000..b1a2810dcd
--- /dev/null
+++ b/macros/latex/required/cyrillic/lcy.pdf
Binary files differ
diff --git a/macros/latex/required/cyrillic/lcycmlh.fdd b/macros/latex/required/cyrillic/lcycmlh.fdd
new file mode 100644
index 0000000000..6610d74de3
--- /dev/null
+++ b/macros/latex/required/cyrillic/lcycmlh.fdd
@@ -0,0 +1,338 @@
+% \iffalse meta-comment
+%
+% Copyright 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2008 2009
+% The LaTeX3 Project and any individual authors listed elsewhere
+% in this file.
+%
+% This file is part of the Standard LaTeX `Cyrillic Bundle'.
+% ----------------------------------------------------------
+%
+% It may be distributed and/or modified under the
+% conditions of the LaTeX Project Public License, either version 1.3b
+% 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.3b or later is part of all distributions of LaTeX
+% version 2005/12/01 or later.
+%
+% The list of all files belonging to the `Cyrillic Bundle' is
+% given in the file `manifest.txt'.
+%
+% \fi
+% \iffalse
+% This is the file |lcycmlh.fdd| of the cyrillic bundle for LaTeX2e.
+%
+% Copyright (C) 1995-1997 Olga Lapko, Johannes L. Braams
+% Copyright (C) 1998-2001 Werner Lemberg, Vladimir Volovich
+%
+%<*driver>
+\documentclass{ltxdoc}
+\begin{document}
+\DocInput{lcycmlh.fdd}
+\end{document}
+%</driver>
+% \fi
+%
+% \begin{macrocode}
+%<LCYcmdh>\ProvidesFile{lcycmdh.fd}
+%<LCYcmfib>\ProvidesFile{lcycmfib.fd}
+%<LCYcmfr>\ProvidesFile{lcycmfr.fd}
+%<LCYcmr>\ProvidesFile{lcycmr.fd}
+%<LCYcmss>\ProvidesFile{lcycmss.fd}
+%<LCYcmtt>\ProvidesFile{lcycmtt.fd}
+%<LCYcmvtt>\ProvidesFile{lcycmvtt.fd}
+%<LCYlcmss>\ProvidesFile{lcylcmss.fd}
+%<LCYlcmtt>\ProvidesFile{lcylcmtt.fd}
+%<LCYcmbr>\ProvidesFile{lcycmbr.fd}
+%<LCYcmtl>\ProvidesFile{lcycmtl.fd}
+%<LCYccr>\ProvidesFile{lcyccr.fd}
+ [2001/08/11 v3.2c Computer Modern Cyrillic font definitions]
+% \end{macrocode}
+%
+% \section{Fonts in old \TeX{} text Cyrillic encoding (\texttt{LCY})}
+%
+% These are the font definitions for Computer Modern Cyrillic fonts in old
+% |LCY| encoding, based on the \textsf{LH} fonts. All font shapes and sizes
+% provided by \textsf{CM} fonts are also supported by \textsf{LH} fonts, so
+% this file is based on |cmfonts.fdd| and |slifonts.fdd|. See comments
+% there.
+%
+% \subsection{Computer Modern Roman}
+%
+% \begin{macrocode}
+%<*LCYcmr>
+\DeclareFontFamily{LCY}{cmr}{\hyphenchar\font45 }
+\DeclareFontShape{LCY}{cmr}{m}{n}{%
+ <5><6><7><8><9><10><12>gen*lhr%
+ <10.95>lhr10%
+ <14.4>lhr12%
+ <17.28><20.74><24.88>lhr17}{}
+\DeclareFontShape{LCY}{cmr}{m}{sl}{%
+ <5><6><7>lhsl8%
+ <8><9>gen*lhsl%
+ <10><10.95>lhsl10%
+ <12><14.4><17.28><20.74><24.88>lhsl12}{}
+\DeclareFontShape{LCY}{cmr}{m}{it}{%
+ <5><6><7>lhti7%
+ <8>lhti8%
+ <9>lhti9%
+ <10><10.95>lhti10%
+ <12><14.4><17.28><20.74><24.88>lhti12}{}
+\DeclareFontShape{LCY}{cmr}{m}{sc}{%
+ <5><6><7><8><9><10><10.95><12>%
+ <14.4><17.28><20.74><24.88>lhcsc10}{}
+\DeclareFontShape{LCY}{cmr}{m}{ui}{%
+ <5><6><7><8><9><10><10.95><12>%
+ <14.4><17.28><20.74><24.88>lhu10}{}
+\DeclareFontShape{LCY}{cmr}{b}{n}{%
+ <5><6><7><8><9><10><10.95><12>%
+ <14.4><17.28><20.74><24.88>lhb10}{}
+\DeclareFontShape{LCY}{cmr}{bx}{n}{%
+ <5><6><7><8><9>gen*lhbx%
+ <10><10.95>lhbx10%
+ <12><14.4><17.28><20.74><24.88>lhbx12}{}
+\DeclareFontShape{LCY}{cmr}{bx}{sl}{%
+ <5><6><7><8><9>%
+ <10><10.95><12><14.4><17.28><20.74><24.88>lhbxsl10}{}
+\DeclareFontShape{LCY}{cmr}{bx}{it}{%
+ <5><6><7><8><9>%
+ <10><10.95><12><14.4><17.28><20.74><24.88>lhbxti10}{}
+\DeclareFontShape{LCY}{cmr}{bx}{ui}{%
+%<-nowarn> <->sub*cmr/m/ui}{}
+%<+nowarn> <->ssub*cmr/m/ui}{}
+%</LCYcmr>
+% \end{macrocode}
+%
+% \subsection{Computer Modern Sans}
+%
+% \begin{macrocode}
+%<*LCYcmss>
+\DeclareFontFamily{LCY}{cmss}{\hyphenchar\font45 }
+\DeclareFontShape{LCY}{cmss}{m}{n}{%
+ <5><6><7><8>lhss8%
+ <9>lhss9%
+ <10><10.95>lhss10%
+ <12><14.4>lhss12%
+ <17.28><20.74><24.88>lhss17}{}
+\DeclareFontShape{LCY}{cmss}{m}{it}{%
+%<-nowarn> <->sub*cmss/m/sl}{}
+%<+nowarn> <->ssub*cmss/m/sl}{}
+\DeclareFontShape{LCY}{cmss}{m}{sl}{%
+ <5><6><7><8>lhssi8<9>lhssi9%
+ <10><10.95>lhssi10%
+ <12><14.4>lhssi12%
+ <17.28><20.74><24.88>lhssi17}{}
+\DeclareFontShape{LCY}{cmss}{m}{sc}{%
+ <->sub*cmr/m/sc}{}
+\DeclareFontShape{LCY}{cmss}{m}{ui}{%
+ <->sub*cmr/m/ui}{}
+\DeclareFontShape{LCY}{cmss}{sbc}{n}{%
+ <5><6><7><8><9><10><10.95><12><14.4><17.28><20.74><24.88>lhssdc10}{}
+\DeclareFontShape{LCY}{cmss}{bx}{n}{%
+ <5><6><7><8><9><10><10.95><12><14.4><17.28><20.74><24.88>lhssbx10}{}
+\DeclareFontShape{LCY}{cmss}{bx}{ui}{%
+ <->sub*cmr/bx/ui}{}
+%</LCYcmss>
+% \end{macrocode}
+%
+% \subsection{Computer Modern Typewriter}
+%
+% \begin{macrocode}
+%<*LCYcmtt>
+\DeclareFontFamily{LCY}{cmtt}{\hyphenchar\font\m@ne}
+\DeclareFontShape{LCY}{cmtt}{m}{n}{%
+ <5><6><7><8>lhtt8<9>lhtt9%
+ <10><10.95>lhtt10%
+ <12><14.4><17.28><20.74><24.88>lhtt12}{}
+\DeclareFontShape{LCY}{cmtt}{m}{it}{%
+ <5><6><7><8><9>%
+ <10><10.95><12><14.4><17.28><20.74><24.88>lhitt10}{}
+\DeclareFontShape{LCY}{cmtt}{m}{sl}{%
+ <5><6><7><8><9>%
+ <10><10.95><12><14.4><17.28><20.74><24.88>lhsltt10}{}
+\DeclareFontShape{LCY}{cmtt}{m}{sc}{%
+ <5><6><7><8><9>%
+ <10><10.95><12><14.4><17.28><20.74><24.88>lhtcsc10}{}
+\DeclareFontShape{LCY}{cmtt}{m}{ui}{%
+%<-nowarn> <->sub*cmtt/m/it}{}
+%<+nowarn> <->ssub*cmtt/m/it}{}
+\DeclareFontShape{LCY}{cmtt}{bx}{n}{%
+%<-nowarn> <->sub*cmtt/m/n}{}
+%<+nowarn> <->ssub*cmtt/m/n}{}
+\DeclareFontShape{LCY}{cmtt}{bx}{it}{%
+%<-nowarn> <->sub*cmtt/m/it}{}
+%<+nowarn> <->ssub*cmtt/m/it}{}
+\DeclareFontShape{LCY}{cmtt}{bx}{ui}{%
+%<-nowarn> <->sub*cmtt/m/it}{}
+%<+nowarn> <->ssub*cmtt/m/it}{}
+%</LCYcmtt>
+% \end{macrocode}
+%
+% \subsection{Computer Modern Variable Typewriter}
+%
+% \begin{macrocode}
+%<*LCYcmvtt>
+\DeclareFontFamily{LCY}{cmvtt}{\hyphenchar\font45 }
+\DeclareFontShape{LCY}{cmvtt}{m}{n}{%
+ <5><6><7><8><9><10><10.95>%
+ <12><14.4><17.28><20.74><24.88>lhvtt10}{}
+\DeclareFontShape{LCY}{cmvtt}{m}{it}{%
+ <5><6><7><8><9><10><10.95>%
+ <12><14.4><17.28><20.74><24.88>lhvtti10}{}
+%</LCYcmvtt>
+% \end{macrocode}
+%
+% \subsection{Computer Modern Funny}
+%
+% \begin{macrocode}
+%<*LCYcmfr>
+\DeclareFontFamily{LCY}{cmfr}{\hyphenchar\font45 }
+\DeclareFontShape{LCY}{cmfr}{m}{n}{%
+ <10>lhff10}{}
+\DeclareFontShape{LCY}{cmfr}{m}{it}{%
+ <10>lhfi10}{}
+%</LCYcmfr>
+% \end{macrocode}
+%
+% \subsection{Computer Modern Dunhill}
+%
+% \begin{macrocode}
+%<*LCYcmdh>
+\DeclareFontFamily{LCY}{cmdh}{\hyphenchar\font45 }
+\DeclareFontShape{LCY}{cmdh}{m}{n}{%
+ <10>lhdunh10}{}
+%</LCYcmdh>
+% \end{macrocode}
+%
+% \subsection{Computer Modern Fibonacci}
+%
+% \begin{macrocode}
+%<*LCYcmfib>
+\DeclareFontFamily{LCY}{cmfib}{\hyphenchar\font45 }
+\DeclareFontShape{LCY}{cmfib}{m}{n}{%
+ <8>lhfib8}{}
+%</LCYcmfib>
+% \end{macrocode}
+%
+% \subsection{Computer Modern Sans for \SliTeX}
+%
+% \begin{macrocode}
+%<*LCYlcmss>
+\DeclareFontFamily{LCY}{lcmss}{\hyphenchar\font45 }
+\DeclareFontShape{LCY}{lcmss}{m}{n}{%
+ <7><8><10><12>%
+ <13.82><16.59><19.907><23.89><28.66><34.4><41.28>llhss8}{}
+\DeclareFontShape{LCY}{lcmss}{m}{In}{%
+ <7><8><10><12>%
+ <13.82><16.59><19.907><23.89><28.66><34.4><41.28>illhss8}{}
+\DeclareFontShape{LCY}{lcmss}{m}{sl}{%
+ <13.82><16.59><19.907><23.89><28.66><34.4><41.28>llhssi8}{}
+\DeclareFontShape{LCY}{lcmss}{m}{Isl}{%
+ <13.82><16.59><19.907><23.89><28.66><34.4><41.28>illhssi8}{}
+\DeclareFontShape{LCY}{lcmss}{m}{it}{%
+ <->sub*lcmss/m/sl}{}
+\DeclareFontShape{LCY}{lcmss}{m}{Iit}{%
+ <->sub*lcmss/m/Isl}{}
+\DeclareFontShape{LCY}{lcmss}{bx}{n}{%
+ <13.82><16.59><19.907><23.89><28.66><34.4><41.28>llhssb8}{}
+\DeclareFontShape{LCY}{lcmss}{bx}{In}{%
+ <13.82><16.59><19.907><23.89><28.66><34.4><41.28>illhssb8}{}
+\DeclareFontShape{LCY}{lcmss}{m}{ui}{%
+ <->sub*cmr/m/ui}{}
+\DeclareFontShape{LCY}{lcmss}{bx}{ui}{%
+ <->sub*cmr/m/ui}{}
+%</LCYlcmss>
+% \end{macrocode}
+%
+% \subsection{Computer Modern Typewriter for \SliTeX}
+%
+% \begin{macrocode}
+%<*LCYlcmtt>
+\DeclareFontFamily{LCY}{lcmtt}{\hyphenchar\font\m@ne}
+\DeclareFontShape{LCY}{lcmtt}{m}{n}{%
+ <13.82><16.59><19.907><23.89><28.66><34.4><41.28>lhtt8}{}
+\DeclareFontShape{LCY}{lcmtt}{m}{In}{%
+ <13.82><16.59><19.907><23.89><28.66><34.4><41.28>ilhtt8}{}
+\DeclareFontShape{LCY}{lcmtt}{m}{it}{%
+ <13.82><16.59><19.907><23.89><28.66><34.4><41.28>lhitt10}{}
+\DeclareFontShape{LCY}{lcmtt}{m}{ui}{%
+ <->sub*cmtt/m/it}{}
+\DeclareFontShape{LCY}{lcmtt}{bx}{ui}{%
+ <->sub*cmtt/m/it}{}
+%</LCYlcmtt>
+% \end{macrocode}
+%
+% \subsection{Computer Modern Bright}
+%
+% \begin{macrocode}
+%<*LCYcmbr>
+\DeclareFontFamily{LCY}{cmbr}{\hyphenchar\font45 }
+\DeclareFontShape{LCY}{cmbr}{m}{n}{%
+ <5><6><7><8>lhbr8%
+ <9>lhbr9%
+ <10><10.95><12><14.4>lhbr10%
+ <17.28><20.74><24.88><29.86><35.83>lhbr17%
+}{}
+\DeclareFontShape{LCY}{cmbr}{m}{sl}{%
+ <5><6><7><8>lhbrsl8%
+ <9>lhbrsl9%
+ <10><10.95><12><14.4>lhbrsl10%
+ <17.28><20.74><24.88><29.86><35.83>lhbrsl17%
+}{}
+\DeclareFontShape{LCY}{cmbr}{m}{it}{<->ssub*cmbr/m/sl}{}
+\DeclareFontShape{LCY}{cmbr}{b}{n}{<->ssub*cmbr/bx/n}{}
+\DeclareFontShape{LCY}{cmbr}{bx}{n}{%
+ <-9>sub*cmbr/m/n%
+ <9><10><10.95><12><14.4><17.28><20.74><24.88><29.86><35.83>lhbrbx10%
+}{}
+%</LCYcmbr>
+% \end{macrocode}
+%
+% \subsection{Computer Modern Typewriter Light}
+%
+% \begin{macrocode}
+%<*LCYcmtl>
+\DeclareFontFamily{LCY}{cmtl}{\hyphenchar\font\m@ne}
+\DeclareFontShape{LCY}{cmtl}{m}{n}{%
+ <5><6><7><8><9><10><10.95><12><14.4><17.28>%
+ <20.74><24.88><29.86><35.83>lhtl10%
+}{}
+\DeclareFontShape{LCY}{cmtl}{m}{sl}{%
+ <5><6><7><8><9><10><10.95><12><14.4><17.28>%
+ <20.74><24.88><29.86><35.83>lhsltl10%
+}{}
+\DeclareFontShape{LCY}{cmtl}{m}{it}{<->ssub*cmtl/m/sl}{}
+%</LCYcmtl>
+% \end{macrocode}
+%
+% \subsection{Computer Modern Concrete}
+%
+% \begin{macrocode}
+%<*LCYccr>
+\DeclareFontFamily{LCY}{ccr}{\hyphenchar\font45 }
+\DeclareFontShape{LCY}{ccr}{m}{n}{%
+ <5><6><7><8><9>gen*lhcr%
+ <10><10.95><12><14.4><17.28><20.74><24.88>lhcr10%
+}{}
+\DeclareFontShape{LCY}{ccr}{m}{sl}{%
+ <5><6><7><8><9>lhcsl9%
+ <10><10.95><12><14.4><17.28><20.74><24.88>lhcsl10%
+}{}
+\DeclareFontShape{LCY}{ccr}{m}{it}{%
+ <5><6><7><8><9><10><10.95><12><14.4><17.28><20.74><24.88>lhcti10%
+}{}
+\DeclareFontShape{LCY}{ccr}{m}{sc}{%
+ <5><6><7><8><9><10><10.95><12><14.4><17.28><20.74><24.88>lhccsc10%
+}{}
+\DeclareFontShape{LCY}{ccr}{bx}{n}{<->ssub*cmr/bx/n}{}
+\DeclareFontShape{LCY}{ccr}{bx}{sl}{<->ssub*cmr/bx/sl}{}
+\DeclareFontShape{LCY}{ccr}{bx}{it}{<->ssub*cmr/bx/it}{}
+\DeclareFontShape{LCY}{ccr}{sbc}{n}{<->ssub*cmss/sbc/n}{}
+\DeclareFontShape{LCY}{ccr}{sbc}{sl}{<->ssub*cmss/sbc/n}{}
+\DeclareFontShape{LCY}{ccr}{sbc}{it}{<->ssub*cmss/sbc/n}{}
+\DeclareFontShape{LCY}{ccr}{c}{sl}{%
+ <9>lhcslc9%
+}{}
+%</LCYccr>
+% \end{macrocode}
+\endinput
diff --git a/macros/latex/required/cyrillic/lcycmlh.pdf b/macros/latex/required/cyrillic/lcycmlh.pdf
new file mode 100644
index 0000000000..a54eae2a33
--- /dev/null
+++ b/macros/latex/required/cyrillic/lcycmlh.pdf
Binary files differ
diff --git a/macros/latex/required/cyrillic/manifest.txt b/macros/latex/required/cyrillic/manifest.txt
new file mode 100644
index 0000000000..6ea004491b
--- /dev/null
+++ b/macros/latex/required/cyrillic/manifest.txt
@@ -0,0 +1,31 @@
+%
+% The following files form the LaTeX2e distribution of 2005-12-01
+%
+%
+% CONTENTS OF THE CYRILLIC BUNDLE
+% ===============================
+
+cyoutenc.dtx
+ Encoding definition files for new standard Cyrillic TeX font
+ encodings: T2A, T2B, T2C, X2.
+cyinpenc.dtx
+ Cyrillic input encoding definition files.
+t2lhfnt.fdd
+ Font definition files for the Computer Modern families (LH fonts).
+ot2.dtx
+ Encoding definition file for old (7-bit Washington) Cyrillic
+ TeX font encoding: OT2.
+lcy.dtx
+ Encoding definition file for old (non-standard, but supported)
+ Cyrillic TeX font encoding: LCY; also contains lcydefs.tex which
+ sets up {cat,uc,lc,sf,math}code values for LCY font encoding,
+ and a wrapper package lcy.sty.
+ot2cmams.fdd
+ font definition files for OT2 encoding / WNCY fonts.
+ot2cmlh.fdd
+ font definition files for OT2 encoding / LH fonts.
+lcycmlh.fdd
+ font definition files for LCY encoding / LH fonts.
+cyrlatex.ins
+ docstrip batch file.
+\endinput
diff --git a/macros/latex/required/cyrillic/ot2.dtx b/macros/latex/required/cyrillic/ot2.dtx
new file mode 100644
index 0000000000..05e747a136
--- /dev/null
+++ b/macros/latex/required/cyrillic/ot2.dtx
@@ -0,0 +1,218 @@
+% \iffalse meta-comment
+%
+% Copyright 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2008 2009
+% The LaTeX3 Project and any individual authors listed elsewhere
+% in this file.
+%
+% This file is part of the Standard LaTeX `Cyrillic Bundle'.
+% ----------------------------------------------------------
+%
+% It may be distributed and/or modified under the
+% conditions of the LaTeX Project Public License, either version 1.3b
+% 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.3b or later is part of all distributions of LaTeX
+% version 2005/12/01 or later.
+%
+% The list of all files belonging to the `Cyrillic Bundle' is
+% given in the file `manifest.txt'.
+%
+% \fi
+% \iffalse
+% This is the file |ot2.dtx| of the cyrillic bundle for LaTeX2e.
+%
+% Copyright (C) 1996 Sebastian Rahtz, M. Ellert, F. Widmann
+% Copyright (C) 1995-1997 Olga Lapko, Johannes L. Braams
+% Copyright (C) 1998-2001 Werner Lemberg, Vladimir Volovich
+%
+%<*driver>
+\documentclass{ltxdoc}
+\begin{document}
+\DocInput{ot2.dtx}
+\end{document}
+%</driver>
+% \fi
+%
+% \begin{macrocode}
+%<*OT2>
+\NeedsTeXFormat{LaTeX2e}[1998/12/01]
+\ProvidesFile{ot2enc.def}
+ [2001/08/11 v3.3a Cyrillic encoding definition file]
+% \end{macrocode}
+%
+% \section{Definitions for the \texttt{OT2} encoding}
+%
+% \begin{macrocode}
+\DeclareFontEncoding{OT2}{}{}
+\DeclareFontSubstitution{OT2}{cmr}{m}{n}
+% \end{macrocode}
+% Accents:
+% \begin{macrocode}
+\DeclareTextAccent{\"}{OT2}{32}
+\DeclareTextAccent{\'}{OT2}{38}
+% \end{macrocode}
+% There is a |\U| accent for the wide Cyrillic breve in addition to the
+% |\u| accent used for the smaller breve. It is recommended to use |\U|
+% accent for |\U{i}| and |\U{u}|. |\U{i}| has a composite declared below.
+% \begin{macrocode}
+\DeclareTextAccent{\u}{OT2}{64}
+\DeclareTextAccent{\U}{OT2}{36}
+\DeclareTextCommand{\d}{OT2}[1]
+ {\hmode@bgroup
+ \o@lign{\relax#1\crcr\hidewidth\sh@ft{10}.\hidewidth}\egroup}
+\DeclareTextCommand{\.}{OT2}[1]{\TextSymbolUnavailable{\.{#1}}#1}
+% \end{macrocode}
+% Letters. We declare all letters here, including the ones which are
+% accessible either directly or via ligatures from Latin letters, because we
+% can use an encoding-independent notation in \textsf{Babel} support files,
+% shareable for all font encodings. It is even possible to use 7-bit |OT2|
+% font encoding with 8-bit input encodings; all letters become accessible
+% for accents (there is a problem when putting an accent on letters treated
+% as ligatures: E.g., in ordinary text `yu' and `ya' are rendered as soft `u'
+% and soft `a', but |\'{yu}| does not produce a soft `u' with an accent, but
+% a `y' with an accent followed by an `u'). We use an approach based on
+% standard \LaTeX\ encoding-dependent symbols (but not definitions like
+% |\def\CYRA{A}|) which allows one to use several Cyrillic font encodings in
+% one document.
+% \begin{macrocode}
+\DeclareTextSymbol{\CYRNJE}{OT2}{0}
+\DeclareTextSymbol{\CYRLJE}{OT2}{1}
+\DeclareTextSymbol{\CYRDZHE}{OT2}{2}
+\DeclareTextSymbol{\CYREREV}{OT2}{3}
+\DeclareTextSymbol{\CYRII}{OT2}{4}
+\DeclareTextSymbol{\CYRIE}{OT2}{5}
+\DeclareTextSymbol{\CYRDJE}{OT2}{6}
+\DeclareTextSymbol{\CYRTSHE}{OT2}{7}
+\DeclareTextSymbol{\cyrnje}{OT2}{8}
+\DeclareTextSymbol{\cyrlje}{OT2}{9}
+\DeclareTextSymbol{\cyrdzhe}{OT2}{10}
+\DeclareTextSymbol{\cyrerev}{OT2}{11}
+\DeclareTextSymbol{\cyrii}{OT2}{12}
+\DeclareTextSymbol{\cyrie}{OT2}{13}
+\DeclareTextSymbol{\cyrdje}{OT2}{14}
+\DeclareTextSymbol{\cyrtshe}{OT2}{15}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\DeclareTextSymbol{\CYRYU}{OT2}{16}
+\DeclareTextSymbol{\CYRZH}{OT2}{17}
+\DeclareTextSymbol{\CYRISHRT}{OT2}{18}
+\DeclareTextSymbol{\CYRYO}{OT2}{19}
+\DeclareTextSymbol{\CYRIZH}{OT2}{20}
+\DeclareTextSymbol{\CYRFITA}{OT2}{21}
+\DeclareTextSymbol{\CYRDZE}{OT2}{22}
+\DeclareTextSymbol{\CYRYA}{OT2}{23}
+\DeclareTextSymbol{\cyryu}{OT2}{24}
+\DeclareTextSymbol{\cyrzh}{OT2}{25}
+\DeclareTextSymbol{\cyrishrt}{OT2}{26}
+\DeclareTextSymbol{\cyryo}{OT2}{27}
+\DeclareTextSymbol{\cyrizh}{OT2}{28}
+\DeclareTextSymbol{\cyrfita}{OT2}{29}
+\DeclareTextSymbol{\cyrdze}{OT2}{30}
+\DeclareTextSymbol{\cyrya}{OT2}{31}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\DeclareTextSymbol{\CYRYAT}{OT2}{35}
+\DeclareTextSymbol{\cyryat}{OT2}{43}
+% \end{macrocode}
+% We use the same command for the dotless `i' letter as in other encodings.
+% \begin{macrocode}
+\DeclareTextSymbol{\i}{OT2}{61}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\DeclareTextSymbol{\CYRA}{OT2}{65}
+\DeclareTextSymbol{\CYRB}{OT2}{66}
+\DeclareTextSymbol{\CYRC}{OT2}{67}
+\DeclareTextSymbol{\CYRD}{OT2}{68}
+\DeclareTextSymbol{\CYRE}{OT2}{69}
+\DeclareTextSymbol{\CYRF}{OT2}{70}
+\DeclareTextSymbol{\CYRG}{OT2}{71}
+\DeclareTextSymbol{\CYRH}{OT2}{72}
+\DeclareTextSymbol{\CYRI}{OT2}{73}
+\DeclareTextSymbol{\CYRJE}{OT2}{74}
+\DeclareTextSymbol{\CYRK}{OT2}{75}
+\DeclareTextSymbol{\CYRL}{OT2}{76}
+\DeclareTextSymbol{\CYRM}{OT2}{77}
+\DeclareTextSymbol{\CYRN}{OT2}{78}
+\DeclareTextSymbol{\CYRO}{OT2}{79}
+\DeclareTextSymbol{\CYRP}{OT2}{80}
+\DeclareTextSymbol{\CYRCH}{OT2}{81}
+\DeclareTextSymbol{\CYRR}{OT2}{82}
+\DeclareTextSymbol{\CYRS}{OT2}{83}
+\DeclareTextSymbol{\CYRT}{OT2}{84}
+\DeclareTextSymbol{\CYRU}{OT2}{85}
+\DeclareTextSymbol{\CYRV}{OT2}{86}
+\DeclareTextSymbol{\CYRSHCH}{OT2}{87}
+\DeclareTextSymbol{\CYRSH}{OT2}{88}
+\DeclareTextSymbol{\CYRERY}{OT2}{89}
+\DeclareTextSymbol{\CYRZ}{OT2}{90}
+\DeclareTextSymbol{\CYRSFTSN}{OT2}{94}
+\DeclareTextSymbol{\CYRHRDSN}{OT2}{95}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\DeclareTextSymbol{\cyra}{OT2}{97}
+\DeclareTextSymbol{\cyrb}{OT2}{98}
+\DeclareTextSymbol{\cyrc}{OT2}{99}
+\DeclareTextSymbol{\cyrd}{OT2}{100}
+\DeclareTextSymbol{\cyre}{OT2}{101}
+\DeclareTextSymbol{\cyrf}{OT2}{102}
+\DeclareTextSymbol{\cyrg}{OT2}{103}
+\DeclareTextSymbol{\cyrh}{OT2}{104}
+\DeclareTextSymbol{\cyri}{OT2}{105}
+\DeclareTextSymbol{\cyrje}{OT2}{106}
+\DeclareTextSymbol{\cyrk}{OT2}{107}
+\DeclareTextSymbol{\cyrl}{OT2}{108}
+\DeclareTextSymbol{\cyrm}{OT2}{109}
+\DeclareTextSymbol{\cyrn}{OT2}{110}
+\DeclareTextSymbol{\cyro}{OT2}{111}
+\DeclareTextSymbol{\cyrp}{OT2}{112}
+\DeclareTextSymbol{\cyrch}{OT2}{113}
+\DeclareTextSymbol{\cyrr}{OT2}{114}
+\DeclareTextSymbol{\cyrs}{OT2}{115}
+\DeclareTextSymbol{\cyrt}{OT2}{116}
+\DeclareTextSymbol{\cyru}{OT2}{117}
+\DeclareTextSymbol{\cyrv}{OT2}{118}
+\DeclareTextSymbol{\cyrshch}{OT2}{119}
+\DeclareTextSymbol{\cyrsh}{OT2}{120}
+\DeclareTextSymbol{\cyrery}{OT2}{121}
+\DeclareTextSymbol{\cyrz}{OT2}{122}
+\DeclareTextSymbol{\cyrsftsn}{OT2}{126}
+\DeclareTextSymbol{\cyrhrdsn}{OT2}{127}
+% \end{macrocode}
+% Other symbols:
+% \begin{macrocode}
+%\DeclareTextSymbol{\texthyphenchar}{OT2}{45}
+%\DeclareTextSymbol{\texthyphen}{OT2}{45}
+\DeclareTextSymbol{\textquoteleft}{OT2}{96}
+\DeclareTextSymbol{\textquoteright}{OT2}{39}
+\DeclareTextSymbol{\textquotedblleft}{OT2}{92}
+\DeclareTextSymbol{\textquotedblright}{OT2}{34}
+\DeclareTextSymbol{\guillemotleft}{OT2}{60}
+\DeclareTextSymbol{\guillemotright}{OT2}{62}
+\DeclareTextSymbol{\textendash}{OT2}{123}
+\DeclareTextSymbol{\cyrdash}{OT2}{124}
+\DeclareTextSymbol{\textemdash}{OT2}{124}
+\DeclareTextSymbol{\textnumero}{OT2}{125}
+% \end{macrocode}
+% Some `obvious' composites:
+% \begin{macrocode}
+\DeclareTextComposite{\U}{OT2}{I}{18}
+\DeclareTextComposite{\U}{OT2}{i}{26}
+\DeclareTextComposite{\"}{OT2}{E}{19}
+\DeclareTextComposite{\"}{OT2}{e}{27}
+\DeclareTextComposite{\.}{OT2}{\i}{12}
+% \end{macrocode}
+% The following declarations will not work for 8-bit chars generated via
+% |inputenc| unless a |dblaccnt| package is used.
+% \begin{macrocode}
+\DeclareTextComposite{\U}{OT2}{\CYRI}{18}
+\DeclareTextComposite{\U}{OT2}{\cyri}{26}
+\DeclareTextComposite{\"}{OT2}{\CYRE}{19}
+\DeclareTextComposite{\"}{OT2}{\cyre}{27}
+%</OT2>
+% \end{macrocode}
+\endinput
diff --git a/macros/latex/required/cyrillic/ot2.pdf b/macros/latex/required/cyrillic/ot2.pdf
new file mode 100644
index 0000000000..ab2c9b8f79
--- /dev/null
+++ b/macros/latex/required/cyrillic/ot2.pdf
Binary files differ
diff --git a/macros/latex/required/cyrillic/ot2cmams.fdd b/macros/latex/required/cyrillic/ot2cmams.fdd
new file mode 100644
index 0000000000..be87506268
--- /dev/null
+++ b/macros/latex/required/cyrillic/ot2cmams.fdd
@@ -0,0 +1,135 @@
+% \iffalse meta-comment
+%
+% Copyright 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2008 2009
+% The LaTeX3 Project and any individual authors listed elsewhere
+% in this file.
+%
+% This file is part of the Standard LaTeX `Cyrillic Bundle'.
+% ----------------------------------------------------------
+%
+% It may be distributed and/or modified under the
+% conditions of the LaTeX Project Public License, either version 1.3b
+% 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.3b or later is part of all distributions of LaTeX
+% version 2005/12/01 or later.
+%
+% The list of all files belonging to the `Cyrillic Bundle' is
+% given in the file `manifest.txt'.
+%
+% \fi
+% \iffalse
+% This is the file |ot2cmams.fdd| of the cyrillic bundle for LaTeX2e.
+%
+% Copyright (C) 1989-1998 Frank Mittelbach, Rainer Sch\"opf
+% Copyright (C) 1995-1999 Sebastian Rahtz, Thierry Bouche
+% Copyright (C) 1998-1999 Werner Lemberg, Vladimir Volovich
+%
+%<*driver>
+\documentclass{ltxdoc}
+\begin{document}
+\DocInput{ot2cmams.fdd}
+\end{document}
+%</driver>
+% \fi
+%
+% \begin{macrocode}
+%<OT2wncyr>\ProvidesFile{ot2wncyr.fd}
+%<OT2wncyss>\ProvidesFile{ot2wncyss.fd}
+%<OT2wlcyr>\ProvidesFile{ot2wlcyr.fd}
+%<OT2wlcyss>\ProvidesFile{ot2wlcyss.fd}
+ [1999/12/17 v3.2a Computer Modern Cyrillic font definitions]
+% \end{macrocode}
+%
+% \section{Computer Modern Roman in \texttt{OT2} encoding}
+%
+% These fonts are from the University of Washington.
+% \begin{macrocode}
+%<*OT2wncyr>
+\DeclareFontFamily{OT2}{wncyr}{\hyphenchar\font45 }
+%<*pdftex>
+\@ifundefined{pdfoutput}\iffalse{\ifnum\pdfoutput=1}
+\DeclareFontShape{OT2}{wncyr}{m}{n}{<->wncyr10}{}
+\DeclareFontShape{OT2}{wncyr}{m}{it}{<->wncyi10}{}
+\DeclareFontShape{OT2}{wncyr}{m}{sc}{<->wncysc10}{}
+\DeclareFontShape{OT2}{wncyr}{b}{n}{<->wncyb10}{}
+\else
+%</pdftex>
+\DeclareFontShape{OT2}{wncyr}{m}{n}{%
+ <5><6><7><8><9>gen*wncyr%
+ <10><10.95><12><14.4><17.28><20.74><24.88>wncyr10}{}
+\DeclareFontShape{OT2}{wncyr}{m}{it}{%
+ <5><6><7><8><9>gen*wncyi%
+ <10><10.95><12><14.4><17.28><20.74><24.88>wncyi10}{}
+\DeclareFontShape{OT2}{wncyr}{m}{sc}{%
+ <5><6><7><8><9><10><10.95><12><14.4><17.28><20.74><24.88>wncysc10}{}
+\DeclareFontShape{OT2}{wncyr}{b}{n}{%
+ <5><6><7><8><9>gen*wncyb%
+ <10><10.95><12><14.4><17.28><20.74><24.88>wncyb10}{}
+%<pdftex>\fi
+\DeclareFontShape{OT2}{wncyr}{bx}{n}{<->ssub*wncyr/b/n}{}
+%</OT2wncyr>
+% \end{macrocode}
+%
+% \section{Computer Modern Sans in \texttt{OT2} encoding}
+%
+% \begin{macrocode}
+%<*OT2wncyss>
+\DeclareFontFamily{OT2}{wncyss}{\hyphenchar\font45 }
+%<*pdftex>
+\@ifundefined{pdfoutput}\iffalse{\ifnum\pdfoutput=1}
+\DeclareFontShape{OT2}{wncyss}{m}{n}{<->wncyss10}{}
+\else
+%</pdftex>
+\DeclareFontShape{OT2}{wncyss}{m}{n}{%
+ <5><6><7><8>wncyss8<9>wncyss9%
+ <10><10.95><12><14.4><17.28><20.74><24.88>wncyss10}{}
+%<pdftex>\fi
+%</OT2wncyss>
+% \end{macrocode}
+%
+% \section{Virtual WLCY fonts without ligatures}
+%
+% \begin{macrocode}
+%<*OT2wlcyr>
+\DeclareFontFamily{OT2}{wlcyr}{\hyphenchar\font45 }
+%<*pdftex>
+\@ifundefined{pdfoutput}\iffalse{\ifnum\pdfoutput=1}
+\DeclareFontShape{OT2}{wlcyr}{m}{n}{<->wlcyr10}{}
+\DeclareFontShape{OT2}{wlcyr}{m}{it}{<->wlcyi10}{}
+\DeclareFontShape{OT2}{wlcyr}{m}{sc}{<->wlcysc10}{}
+\DeclareFontShape{OT2}{wlcyr}{b}{n}{<->wlcyb10}{}
+\else
+%</pdftex>
+\DeclareFontShape{OT2}{wlcyr}{m}{n}{%
+ <5><6><7><8><9>gen*wlcyr%
+ <10><10.95><12><14.4><17.28><20.74><24.88>wlcyr10}{}
+\DeclareFontShape{OT2}{wlcyr}{m}{it}{%
+ <5><6><7><8><9>gen*wlcyi%
+ <10><10.95><12><14.4><17.28><20.74><24.88>wlcyi10}{}
+\DeclareFontShape{OT2}{wlcyr}{m}{sc}{%
+ <5><6><7><8><9><10><10.95><12><14.4><17.28><20.74><24.88>wlcysc10}{}
+\DeclareFontShape{OT2}{wlcyr}{b}{n}{%
+ <5><6><7><8><9>gen*wlcyb%
+ <10><10.95><12><14.4><17.28><20.74><24.88>wlcyb10}{}
+%<pdftex>\fi
+\DeclareFontShape{OT2}{wlcyr}{bx}{n}{<->ssub*wlcyr/b/n}{}
+%</OT2wlcyr>
+% \end{macrocode}
+%
+% \begin{macrocode}
+%<*OT2wlcyss>
+\DeclareFontFamily{OT2}{wlcyss}{\hyphenchar\font45 }
+%<*pdftex>
+\@ifundefined{pdfoutput}\iffalse{\ifnum\pdfoutput=1}
+\DeclareFontShape{OT2}{wlcyss}{m}{n}{<->wlcyss10}{}
+\else
+%</pdftex>
+\DeclareFontShape{OT2}{wlcyss}{m}{n}{%
+ <5><6><7><8>wlcyss8<9>wlcyss9%
+ <10><10.95><12><14.4><17.28><20.74><24.88>wlcyss10}{}
+%<pdftex>\fi
+%</OT2wlcyss>
+% \end{macrocode}
+\endinput
diff --git a/macros/latex/required/cyrillic/ot2cmams.pdf b/macros/latex/required/cyrillic/ot2cmams.pdf
new file mode 100644
index 0000000000..738b5a2406
--- /dev/null
+++ b/macros/latex/required/cyrillic/ot2cmams.pdf
Binary files differ
diff --git a/macros/latex/required/cyrillic/ot2cmlh.fdd b/macros/latex/required/cyrillic/ot2cmlh.fdd
new file mode 100644
index 0000000000..5790955f59
--- /dev/null
+++ b/macros/latex/required/cyrillic/ot2cmlh.fdd
@@ -0,0 +1,342 @@
+% \iffalse meta-comment
+%
+% Copyright 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2008 2009
+% The LaTeX3 Project and any individual authors listed elsewhere
+% in this file.
+%
+% This file is part of the Standard LaTeX `Cyrillic Bundle'.
+% ----------------------------------------------------------
+%
+% It may be distributed and/or modified under the
+% conditions of the LaTeX Project Public License, either version 1.3b
+% 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.3b or later is part of all distributions of LaTeX
+% version 2005/12/01 or later.
+%
+% The list of all files belonging to the `Cyrillic Bundle' is
+% given in the file `manifest.txt'.
+%
+% \fi
+% \iffalse
+% This is the file |ot2cmlh.fdd| of the cyrillic bundle for LaTeX2e.
+%
+% Copyright (C) 1995-1997 Olga Lapko, Johannes L. Braams
+% Copyright (C) 1998-2001 Werner Lemberg, Vladimir Volovich
+%
+%<*driver>
+\documentclass{ltxdoc}
+\begin{document}
+\DocInput{ot2cmlh.fdd}
+\end{document}
+%</driver>
+% \fi
+%
+% \begin{macrocode}
+%<OT2cmdh>\ProvidesFile{ot2cmdh.fd}
+%<OT2cmfib>\ProvidesFile{ot2cmfib.fd}
+%<OT2cmfr>\ProvidesFile{ot2cmfr.fd}
+%<OT2cmr>\ProvidesFile{ot2cmr.fd}
+%<OT2cmss>\ProvidesFile{ot2cmss.fd}
+%<OT2cmtt>\ProvidesFile{ot2cmtt.fd}
+%<OT2cmvtt>\ProvidesFile{ot2cmvtt.fd}
+%<OT2lcmss>\ProvidesFile{ot2lcmss.fd}
+%<OT2lcmtt>\ProvidesFile{ot2lcmtt.fd}
+%<OT2cmbr>\ProvidesFile{ot2cmbr.fd}
+%<OT2cmtl>\ProvidesFile{ot2cmtl.fd}
+%<OT2ccr>\ProvidesFile{ot2ccr.fd}
+ [2001/08/11 v3.2c Computer Modern Cyrillic font definitions]
+% \end{macrocode}
+%
+% \section{Fonts in old \TeX{} text Cyrillic encoding (\texttt{OT2})}
+%
+% These are the font definitions for Computer Modern Cyrillic fonts for old
+% |OT2| encoding, based on \textsf{LH} fonts. All font shapes and sizes
+% provided by \textsf{CM} fonts are also supported by \textsf{LH} fonts, so
+% this file is based on |cmfonts.fdd| and |slifonts.fdd|. See comments
+% there.
+%
+% The encoding name for the \textsf{LH} |wn*| fonts was `|LWN|' in old
+% versions of \textsf{Babel}. However, one should use the name `|OT2|' for
+% this encoding.
+%
+% \subsection{Computer Modern Roman}
+%
+% \begin{macrocode}
+%<*OT2cmr>
+\DeclareFontFamily{OT2}{cmr}{\hyphenchar\font45 }
+\DeclareFontShape{OT2}{cmr}{m}{n}{%
+ <5><6><7><8><9><10><12>gen*wnr%
+ <10.95>wnr10%
+ <14.4>wnr12%
+ <17.28><20.74><24.88>wnr17}{}
+\DeclareFontShape{OT2}{cmr}{m}{sl}{%
+ <5><6><7>wnsl8%
+ <8><9>gen*wnsl%
+ <10><10.95>wnsl10%
+ <12><14.4><17.28><20.74><24.88>wnsl12}{}
+\DeclareFontShape{OT2}{cmr}{m}{it}{%
+ <5><6><7>wnti7%
+ <8>wnti8%
+ <9>wnti9%
+ <10><10.95>wnti10%
+ <12><14.4><17.28><20.74><24.88>wnti12}{}
+\DeclareFontShape{OT2}{cmr}{m}{sc}{%
+ <5><6><7><8><9><10><10.95><12>%
+ <14.4><17.28><20.74><24.88>wncsc10}{}
+\DeclareFontShape{OT2}{cmr}{m}{ui}{%
+ <5><6><7><8><9><10><10.95><12>%
+ <14.4><17.28><20.74><24.88>wnu10}{}
+\DeclareFontShape{OT2}{cmr}{b}{n}{%
+ <5><6><7><8><9><10><10.95><12>%
+ <14.4><17.28><20.74><24.88>wnb10}{}
+\DeclareFontShape{OT2}{cmr}{bx}{n}{%
+ <5><6><7><8><9>gen*wnbx%
+ <10><10.95>wnbx10%
+ <12><14.4><17.28><20.74><24.88>wnbx12}{}
+\DeclareFontShape{OT2}{cmr}{bx}{sl}{%
+ <5><6><7><8><9>%
+ <10><10.95><12><14.4><17.28><20.74><24.88>wnbxsl10}{}
+\DeclareFontShape{OT2}{cmr}{bx}{it}{%
+ <5><6><7><8><9>%
+ <10><10.95><12><14.4><17.28><20.74><24.88>wnbxti10}{}
+\DeclareFontShape{OT2}{cmr}{bx}{ui}{%
+%<-nowarn> <->sub*cmr/m/ui}{}
+%<+nowarn> <->ssub*cmr/m/ui}{}
+%</OT2cmr>
+% \end{macrocode}
+%
+% \subsection{Computer Modern Sans}
+%
+% \begin{macrocode}
+%<*OT2cmss>
+\DeclareFontFamily{OT2}{cmss}{\hyphenchar\font45 }
+\DeclareFontShape{OT2}{cmss}{m}{n}{%
+ <5><6><7><8>wnss8%
+ <9>wnss9%
+ <10><10.95>wnss10%
+ <12><14.4>wnss12%
+ <17.28><20.74><24.88>wnss17}{}
+\DeclareFontShape{OT2}{cmss}{m}{it}{%
+%<-nowarn> <->sub*cmss/m/sl}{}
+%<+nowarn> <->ssub*cmss/m/sl}{}
+\DeclareFontShape{OT2}{cmss}{m}{sl}{%
+ <5><6><7><8>wnssi8<9>wnssi9%
+ <10><10.95>wnssi10%
+ <12><14.4>wnssi12%
+ <17.28><20.74><24.88>wnssi17}{}
+\DeclareFontShape{OT2}{cmss}{m}{sc}{%
+ <->sub*cmr/m/sc}{}
+\DeclareFontShape{OT2}{cmss}{m}{ui}{%
+ <->sub*cmr/m/ui}{}
+\DeclareFontShape{OT2}{cmss}{sbc}{n}{%
+ <5><6><7><8><9><10><10.95><12><14.4><17.28><20.74><24.88>wnssdc10}{}
+\DeclareFontShape{OT2}{cmss}{bx}{n}{%
+ <5><6><7><8><9><10><10.95><12><14.4><17.28><20.74><24.88>wnssbx10}{}
+\DeclareFontShape{OT2}{cmss}{bx}{ui}{%
+ <->sub*cmr/bx/ui}{}
+%</OT2cmss>
+% \end{macrocode}
+%
+% \subsection{Computer Modern Typewriter}
+%
+% \begin{macrocode}
+%<*OT2cmtt>
+\DeclareFontFamily{OT2}{cmtt}{\hyphenchar\font\m@ne}
+\DeclareFontShape{OT2}{cmtt}{m}{n}{%
+ <5><6><7><8>wntt8<9>wntt9%
+ <10><10.95>wntt10%
+ <12><14.4><17.28><20.74><24.88>wntt12}{}
+\DeclareFontShape{OT2}{cmtt}{m}{it}{%
+ <5><6><7><8><9>%
+ <10><10.95><12><14.4><17.28><20.74><24.88>wnitt10}{}
+\DeclareFontShape{OT2}{cmtt}{m}{sl}{%
+ <5><6><7><8><9>%
+ <10><10.95><12><14.4><17.28><20.74><24.88>wnsltt10}{}
+\DeclareFontShape{OT2}{cmtt}{m}{sc}{%
+ <5><6><7><8><9>%
+ <10><10.95><12><14.4><17.28><20.74><24.88>wntcsc10}{}
+\DeclareFontShape{OT2}{cmtt}{m}{ui}{%
+%<-nowarn> <->sub*cmtt/m/it}{}
+%<+nowarn> <->ssub*cmtt/m/it}{}
+\DeclareFontShape{OT2}{cmtt}{bx}{n}{%
+%<-nowarn> <->sub*cmtt/m/n}{}
+%<+nowarn> <->ssub*cmtt/m/n}{}
+\DeclareFontShape{OT2}{cmtt}{bx}{it}{%
+%<-nowarn> <->sub*cmtt/m/it}{}
+%<+nowarn> <->ssub*cmtt/m/it}{}
+\DeclareFontShape{OT2}{cmtt}{bx}{ui}{%
+%<-nowarn> <->sub*cmtt/m/it}{}
+%<+nowarn> <->ssub*cmtt/m/it}{}
+%</OT2cmtt>
+% \end{macrocode}
+%
+% \subsection{Computer Modern Variable Typewriter}
+%
+% \begin{macrocode}
+%<*OT2cmvtt>
+\DeclareFontFamily{OT2}{cmvtt}{\hyphenchar\font45 }
+\DeclareFontShape{OT2}{cmvtt}{m}{n}{%
+ <5><6><7><8><9><10><10.95>%
+ <12><14.4><17.28><20.74><24.88>wnvtt10}{}
+\DeclareFontShape{OT2}{cmvtt}{m}{it}{%
+ <5><6><7><8><9><10><10.95>%
+ <12><14.4><17.28><20.74><24.88>wnvtti10}{}
+%</OT2cmvtt>
+% \end{macrocode}
+%
+% \subsection{Computer Modern Funny}
+%
+% \begin{macrocode}
+%<*OT2cmfr>
+\DeclareFontFamily{OT2}{cmfr}{\hyphenchar\font45 }
+\DeclareFontShape{OT2}{cmfr}{m}{n}{%
+ <10>wnff10}{}
+\DeclareFontShape{OT2}{cmfr}{m}{it}{%
+ <10>wnfi10}{}
+%</OT2cmfr>
+% \end{macrocode}
+%
+% \subsection{Computer Modern Dunhill}
+%
+% \begin{macrocode}
+%<*OT2cmdh>
+\DeclareFontFamily{OT2}{cmdh}{\hyphenchar\font45 }
+\DeclareFontShape{OT2}{cmdh}{m}{n}{%
+ <10>wndunh10}{}
+%</OT2cmdh>
+% \end{macrocode}
+%
+% \subsection{Computer Modern Fibonacci}
+%
+% \begin{macrocode}
+%<*OT2cmfib>
+\DeclareFontFamily{OT2}{cmfib}{\hyphenchar\font45 }
+\DeclareFontShape{OT2}{cmfib}{m}{n}{%
+ <8>wnfib8}{}
+%</OT2cmfib>
+% \end{macrocode}
+%
+% \subsection{Computer Modern Sans for \SliTeX}
+%
+% \begin{macrocode}
+%<*OT2lcmss>
+\DeclareFontFamily{OT2}{lcmss}{\hyphenchar\font45 }
+\DeclareFontShape{OT2}{lcmss}{m}{n}{%
+ <7><8><10><12>%
+ <13.82><16.59><19.907><23.89><28.66><34.4><41.28>lwnss8}{}
+\DeclareFontShape{OT2}{lcmss}{m}{In}{%
+ <7><8><10><12>%
+ <13.82><16.59><19.907><23.89><28.66><34.4><41.28>ilwnss8}{}
+\DeclareFontShape{OT2}{lcmss}{m}{sl}{%
+ <13.82><16.59><19.907><23.89><28.66><34.4><41.28>lwnssi8}{}
+\DeclareFontShape{OT2}{lcmss}{m}{Isl}{%
+ <13.82><16.59><19.907><23.89><28.66><34.4><41.28>ilwnssi8}{}
+\DeclareFontShape{OT2}{lcmss}{m}{it}{%
+ <->sub*lcmss/m/sl}{}
+\DeclareFontShape{OT2}{lcmss}{m}{Iit}{%
+ <->sub*lcmss/m/Isl}{}
+\DeclareFontShape{OT2}{lcmss}{bx}{n}{%
+ <13.82><16.59><19.907><23.89><28.66><34.4><41.28>lwnssb8}{}
+\DeclareFontShape{OT2}{lcmss}{bx}{In}{%
+ <13.82><16.59><19.907><23.89><28.66><34.4><41.28>ilwnssb8}{}
+\DeclareFontShape{OT2}{lcmss}{m}{ui}{%
+ <->sub*cmr/m/ui}{}
+\DeclareFontShape{OT2}{lcmss}{bx}{ui}{%
+ <->sub*cmr/m/ui}{}
+%</OT2lcmss>
+% \end{macrocode}
+%
+% \subsection{Computer Modern Typewriter for \SliTeX}
+%
+% \begin{macrocode}
+%<*OT2lcmtt>
+\DeclareFontFamily{OT2}{lcmtt}{\hyphenchar\font\m@ne}
+\DeclareFontShape{OT2}{lcmtt}{m}{n}{%
+ <13.82><16.59><19.907><23.89><28.66><34.4><41.28>wntt8}{}
+\DeclareFontShape{OT2}{lcmtt}{m}{In}{%
+ <13.82><16.59><19.907><23.89><28.66><34.4><41.28>iwntt8}{}
+\DeclareFontShape{OT2}{lcmtt}{m}{it}{%
+ <13.82><16.59><19.907><23.89><28.66><34.4><41.28>wnitt10}{}
+\DeclareFontShape{OT2}{lcmtt}{m}{ui}{%
+ <->sub*cmtt/m/it}{}
+\DeclareFontShape{OT2}{lcmtt}{bx}{ui}{%
+ <->sub*cmtt/m/it}{}
+%</OT2lcmtt>
+% \end{macrocode}
+%
+% \subsection{Computer Modern Bright}
+%
+% \begin{macrocode}
+%<*OT2cmbr>
+\DeclareFontFamily{OT2}{cmbr}{\hyphenchar\font45 }
+\DeclareFontShape{OT2}{cmbr}{m}{n}{%
+ <5><6><7><8>wnbr8%
+ <9>wnbr9%
+ <10><10.95><12><14.4>wnbr10%
+ <17.28><20.74><24.88><29.86><35.83>wnbr17%
+}{}
+\DeclareFontShape{OT2}{cmbr}{m}{sl}{%
+ <5><6><7><8>wnbrsl8%
+ <9>wnbrsl9%
+ <10><10.95><12><14.4>wnbrsl10%
+ <17.28><20.74><24.88><29.86><35.83>wnbrsl17%
+}{}
+\DeclareFontShape{OT2}{cmbr}{m}{it}{<->ssub*cmbr/m/sl}{}
+\DeclareFontShape{OT2}{cmbr}{b}{n}{<->ssub*cmbr/bx/n}{}
+\DeclareFontShape{OT2}{cmbr}{bx}{n}{%
+ <-9>sub*cmbr/m/n%
+ <9><10><10.95><12><14.4><17.28><20.74><24.88><29.86><35.83>wnbrbx10%
+}{}
+%</OT2cmbr>
+% \end{macrocode}
+%
+% \subsection{Computer Modern Typewriter Light}
+%
+% \begin{macrocode}
+%<*OT2cmtl>
+\DeclareFontFamily{OT2}{cmtl}{\hyphenchar\font\m@ne}
+\DeclareFontShape{OT2}{cmtl}{m}{n}{%
+ <5><6><7><8><9><10><10.95><12><14.4><17.28>%
+ <20.74><24.88><29.86><35.83>wntl10%
+}{}
+\DeclareFontShape{OT2}{cmtl}{m}{sl}{%
+ <5><6><7><8><9><10><10.95><12><14.4><17.28>%
+ <20.74><24.88><29.86><35.83>wnsltl10%
+}{}
+\DeclareFontShape{OT2}{cmtl}{m}{it}{<->ssub*cmtl/m/sl}{}
+%</OT2cmtl>
+% \end{macrocode}
+%
+% \subsection{Computer Modern Concrete}
+%
+% \begin{macrocode}
+%<*OT2ccr>
+\DeclareFontFamily{OT2}{ccr}{\hyphenchar\font45 }
+\DeclareFontShape{OT2}{ccr}{m}{n}{%
+ <5><6><7><8><9>gen*wncr%
+ <10><10.95><12><14.4><17.28><20.74><24.88>wncr10%
+}{}
+\DeclareFontShape{OT2}{ccr}{m}{sl}{%
+ <5><6><7><8><9>wncsl9%
+ <10><10.95><12><14.4><17.28><20.74><24.88>wncsl10%
+}{}
+\DeclareFontShape{OT2}{ccr}{m}{it}{%
+ <5><6><7><8><9><10><10.95><12><14.4><17.28><20.74><24.88>wncti10%
+}{}
+\DeclareFontShape{OT2}{ccr}{m}{sc}{%
+ <5><6><7><8><9><10><10.95><12><14.4><17.28><20.74><24.88>wnccsc10%
+}{}
+\DeclareFontShape{OT2}{ccr}{bx}{n}{<->ssub*cmr/bx/n}{}
+\DeclareFontShape{OT2}{ccr}{bx}{sl}{<->ssub*cmr/bx/sl}{}
+\DeclareFontShape{OT2}{ccr}{bx}{it}{<->ssub*cmr/bx/it}{}
+\DeclareFontShape{OT2}{ccr}{sbc}{n}{<->ssub*cmss/sbc/n}{}
+\DeclareFontShape{OT2}{ccr}{sbc}{sl}{<->ssub*cmss/sbc/n}{}
+\DeclareFontShape{OT2}{ccr}{sbc}{it}{<->ssub*cmss/sbc/n}{}
+\DeclareFontShape{OT2}{ccr}{c}{sl}{%
+ <9>wncslc9%
+}{}
+%</OT2ccr>
+% \end{macrocode}
+\endinput
diff --git a/macros/latex/required/cyrillic/ot2cmlh.pdf b/macros/latex/required/cyrillic/ot2cmlh.pdf
new file mode 100644
index 0000000000..90a8c20835
--- /dev/null
+++ b/macros/latex/required/cyrillic/ot2cmlh.pdf
Binary files differ
diff --git a/macros/latex/required/cyrillic/t2lhfnt.fdd b/macros/latex/required/cyrillic/t2lhfnt.fdd
new file mode 100644
index 0000000000..8f0dac0df6
--- /dev/null
+++ b/macros/latex/required/cyrillic/t2lhfnt.fdd
@@ -0,0 +1,997 @@
+% \iffalse meta-comment
+%
+% Copyright 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2008 2009
+% The LaTeX3 Project and any individual authors listed elsewhere
+% in this file.
+%
+% This file is part of the Standard LaTeX `Cyrillic Bundle'.
+% ----------------------------------------------------------
+%
+% It may be distributed and/or modified under the
+% conditions of the LaTeX Project Public License, either version 1.3b
+% 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.3b or later is part of all distributions of LaTeX
+% version 2005/12/01 or later.
+%
+% The list of all files belonging to the `Cyrillic Bundle' is
+% given in the file `manifest.txt'.
+%
+% \fi
+% \iffalse
+% This is the file |t2lhfnt.fdd| of the cyrillic bundle for LaTeX2e.
+%
+%<*driver>
+\documentclass{ltxdoc}
+\begin{document}
+\DocInput{t2lhfnt.fdd}
+\end{document}
+%</driver>
+% \fi
+%
+% \section{Font definition files for the LH family of Cyrillic fonts}
+%
+% A lot of mostly duplicated code (for different encodings) will
+% probably be removed when an extension to docstrip will be available.
+%
+% \begin{macrocode}
+%<X2cmdh>\ProvidesFile{x2cmdh.fd}
+%<X2cmfib>\ProvidesFile{x2cmfib.fd}
+%<X2cmfr>\ProvidesFile{x2cmfr.fd}
+%<X2cmr>\ProvidesFile{x2cmr.fd}
+%<X2cmss>\ProvidesFile{x2cmss.fd}
+%<X2cmtt>\ProvidesFile{x2cmtt.fd}
+%<X2cmvtt>\ProvidesFile{x2cmvtt.fd}
+%<lcmss&X2>\ProvidesFile{x2lcmss.fd}
+%<lcmtt&X2>\ProvidesFile{x2lcmtt.fd}
+%<X2cmbr>\ProvidesFile{x2cmbr.fd}
+%<X2cmtl>\ProvidesFile{x2cmtl.fd}
+%<X2ccr>\ProvidesFile{x2ccr.fd}
+%<T2Acmdh>\ProvidesFile{t2acmdh.fd}
+%<T2Acmfib>\ProvidesFile{t2acmfib.fd}
+%<T2Acmfr>\ProvidesFile{t2acmfr.fd}
+%<T2Acmr>\ProvidesFile{t2acmr.fd}
+%<T2Acmss>\ProvidesFile{t2acmss.fd}
+%<T2Acmtt>\ProvidesFile{t2acmtt.fd}
+%<T2Acmvtt>\ProvidesFile{t2acmvtt.fd}
+%<lcmss&T2A>\ProvidesFile{t2alcmss.fd}
+%<lcmtt&T2A>\ProvidesFile{t2alcmtt.fd}
+%<T2Acmbr>\ProvidesFile{t2acmbr.fd}
+%<T2Acmtl>\ProvidesFile{t2acmtl.fd}
+%<T2Accr>\ProvidesFile{t2accr.fd}
+%<T2Bcmdh>\ProvidesFile{t2bcmdh.fd}
+%<T2Bcmfib>\ProvidesFile{t2bcmfib.fd}
+%<T2Bcmfr>\ProvidesFile{t2bcmfr.fd}
+%<T2Bcmr>\ProvidesFile{t2bcmr.fd}
+%<T2Bcmss>\ProvidesFile{t2bcmss.fd}
+%<T2Bcmtt>\ProvidesFile{t2bcmtt.fd}
+%<T2Bcmvtt>\ProvidesFile{t2bcmvtt.fd}
+%<lcmss&T2B>\ProvidesFile{t2blcmss.fd}
+%<lcmtt&T2B>\ProvidesFile{t2blcmtt.fd}
+%<T2Bcmbr>\ProvidesFile{t2bcmbr.fd}
+%<T2Bcmtl>\ProvidesFile{t2bcmtl.fd}
+%<T2Bccr>\ProvidesFile{t2bccr.fd}
+%<T2Ccmdh>\ProvidesFile{t2ccmdh.fd}
+%<T2Ccmfib>\ProvidesFile{t2ccmfib.fd}
+%<T2Ccmfr>\ProvidesFile{t2ccmfr.fd}
+%<T2Ccmr>\ProvidesFile{t2ccmr.fd}
+%<T2Ccmss>\ProvidesFile{t2ccmss.fd}
+%<T2Ccmtt>\ProvidesFile{t2ccmtt.fd}
+%<T2Ccmvtt>\ProvidesFile{t2ccmvtt.fd}
+%<lcmss&T2C>\ProvidesFile{t2clcmss.fd}
+%<lcmtt&T2C>\ProvidesFile{t2clcmtt.fd}
+%<T2Ccmbr>\ProvidesFile{t2ccmbr.fd}
+%<T2Ccmtl>\ProvidesFile{t2ccmtl.fd}
+%<T2Cccr>\ProvidesFile{t2cccr.fd}
+ [2001/08/11 v1.0a Computer Modern Cyrillic font definitions]
+% \end{macrocode}
+%
+% The following definitions will be removed when this file will be
+% merged with |cmfonts.fdd|.
+%
+% \begin{macrocode}
+%<*!lcmss&!lcmtt>
+%<*!tt>
+\providecommand{\EC@family}[5]{%
+ \DeclareFontShape{#1}{#2}{#3}{#4}%
+ {<5><6><7><8><9><10><10.95><12><14.4>%
+ <17.28><20.74><24.88><29.86><35.83>genb*#5}{}}
+%</!tt>
+%<*tt>
+\providecommand{\EC@ttfamily}[5]{%
+ \DeclareFontShape{#1}{#2}{#3}{#4}%
+ {<5><6><7><8>#50800%
+ <9><10><10.95><12><14.4><17.28><20.74><24.88><29.86>%
+ <35.83>genb*#5}{}}
+%</tt>
+%</!lcmss&!lcmtt>
+% \end{macrocode}
+%
+% LH fonts for X2 encoding.
+%
+% \begin{macrocode}
+%<*X2cmdh>
+% Cyrillic Dunhill
+\DeclareFontFamily{X2}{cmdh}{}
+\EC@family{X2}{cmdh}{m}{n}{rxdh}
+%</X2cmdh>
+%
+%<*X2cmfib>
+\DeclareFontFamily{X2}{cmfib}{}
+\EC@family{X2}{cmfib}{m}{n}{rxfb}
+\EC@family{X2}{cmfib}{m}{sl}{rxfs}
+%</X2cmfib>
+%
+%<*X2cmfr>
+\DeclareFontFamily{X2}{cmfr}{}
+\EC@family{X2}{cmfr}{m}{n}{rxff}
+\EC@family{X2}{cmfr}{m}{it}{rxfi}
+%</X2cmfr>
+%
+%<*X2cmr>
+% Cyrillic Roman
+\DeclareFontFamily{X2}{cmr}{}
+%
+\EC@family{X2}{cmr}{m}{n}{rxrm}
+\EC@family{X2}{cmr}{m}{sl}{rxsl}
+\EC@family{X2}{cmr}{m}{it}{rxti}
+\EC@family{X2}{cmr}{m}{sc}{rxcc}
+\EC@family{X2}{cmr}{bx}{n}{rxbx}
+\EC@family{X2}{cmr}{b}{n}{rxrb}
+\EC@family{X2}{cmr}{bx}{it}{rxbi}
+\EC@family{X2}{cmr}{bx}{sl}{rxbl}
+\EC@family{X2}{cmr}{bx}{sc}{rxxc}
+\EC@family{X2}{cmr}{m}{ui}{rxui}
+%</X2cmr>
+%
+%<*X2cmss>
+% Cyrillic Sans Serif
+\DeclareFontFamily{X2}{cmss}{}
+%
+\EC@family{X2}{cmss}{m}{n}{rxss}
+\EC@family{X2}{cmss}{m}{sl}{rxsi}
+\EC@family{X2}{cmss}{m}{it}{rxsi}
+\EC@family{X2}{cmss}{bx}{n}{rxsx}
+\EC@family{X2}{cmss}{bx}{it}{rxso}
+\EC@family{X2}{cmss}{bx}{sl}{rxso}
+%
+\DeclareFontShape{X2}{cmss}{m}{sc}{<->sub*cmr/m/sc}{}
+% semibold condensed series:
+\DeclareFontShape{X2}{cmss}{sbc}{n}{%
+ <5><6><7><8><9><10><10.95><12><14.4><17.28><20.74><24.88>rxssdc10%
+}{}
+%</X2cmss>
+%
+%<*X2cmtt>
+% Cyrillic Typewriter
+\DeclareFontFamily{X2}{cmtt}{\hyphenchar\font\m@ne}
+%
+\EC@ttfamily{X2}{cmtt}{m}{n}{rxtt}
+\EC@ttfamily{X2}{cmtt}{m}{sl}{rxst}
+\EC@ttfamily{X2}{cmtt}{m}{it}{rxit}
+\EC@ttfamily{X2}{cmtt}{m}{sc}{rxtc}
+%
+\DeclareFontShape{X2}{cmtt}{bx}{n}%
+%<!nowarn> {<->sub*cmtt/m/n}{}
+%<nowarn> {<->ssub*cmtt/m/n}{}
+\DeclareFontShape{X2}{cmtt}{bx}{it}%
+%<!nowarn> {<->sub*cmtt/m/it}{}
+%<nowarn> {<->ssub*cmtt/m/it}{}
+%</X2cmtt>
+%
+%<*X2cmvtt>
+% Cyrillic Variable Typewriter
+\DeclareFontFamily{X2}{cmvtt}{}
+%
+\EC@ttfamily{X2}{cmvtt}{m}{n}{rxvt}
+\EC@ttfamily{X2}{cmvtt}{m}{it}{rxvi}
+%</X2cmvtt>
+% \end{macrocode}
+%
+% LH fonts for T2A encoding.
+%
+% \begin{macrocode}
+%<*T2Acmdh>
+% Cyrillic Dunhill
+\DeclareFontFamily{T2A}{cmdh}{}
+\EC@family{T2A}{cmdh}{m}{n}{ladh}
+%</T2Acmdh>
+%
+%<*T2Acmfib>
+\DeclareFontFamily{T2A}{cmfib}{}
+\EC@family{T2A}{cmfib}{m}{n}{lafb}
+\EC@family{T2A}{cmfib}{m}{sl}{lafs}
+%</T2Acmfib>
+%
+%<*T2Acmfr>
+\DeclareFontFamily{T2A}{cmfr}{}
+\EC@family{T2A}{cmfr}{m}{n}{laff}
+\EC@family{T2A}{cmfr}{m}{it}{lafi}
+%</T2Acmfr>
+%
+%<*T2Acmr>
+% Cyrillic Roman
+\DeclareFontFamily{T2A}{cmr}{}
+%
+\EC@family{T2A}{cmr}{m}{n}{larm}
+\EC@family{T2A}{cmr}{m}{sl}{lasl}
+\EC@family{T2A}{cmr}{m}{it}{lati}
+\EC@family{T2A}{cmr}{m}{sc}{lacc}
+\EC@family{T2A}{cmr}{bx}{n}{labx}
+\EC@family{T2A}{cmr}{b}{n}{larb}
+\EC@family{T2A}{cmr}{bx}{it}{labi}
+\EC@family{T2A}{cmr}{bx}{sl}{labl}
+\EC@family{T2A}{cmr}{bx}{sc}{laxc}
+\EC@family{T2A}{cmr}{m}{ui}{laui}
+%</T2Acmr>
+%
+%<*T2Acmss>
+% Cyrillic Sans Serif
+\DeclareFontFamily{T2A}{cmss}{}
+%
+\EC@family{T2A}{cmss}{m}{n}{lass}
+\EC@family{T2A}{cmss}{m}{sl}{lasi}
+\EC@family{T2A}{cmss}{m}{it}{lasi}
+\EC@family{T2A}{cmss}{bx}{n}{lasx}
+\EC@family{T2A}{cmss}{bx}{it}{laso}
+\EC@family{T2A}{cmss}{bx}{sl}{laso}
+%
+\DeclareFontShape{T2A}{cmss}{m}{sc}{<->sub*cmr/m/sc}{}
+% semibold condensed series:
+\DeclareFontShape{T2A}{cmss}{sbc}{n}{%
+ <5><6><7><8><9><10><10.95><12><14.4><17.28><20.74><24.88>lassdc10%
+}{}
+%</T2Acmss>
+%
+%<*T2Acmtt>
+% Cyrillic Typewriter
+\DeclareFontFamily{T2A}{cmtt}{\hyphenchar\font\m@ne}
+%
+\EC@ttfamily{T2A}{cmtt}{m}{n}{latt}
+\EC@ttfamily{T2A}{cmtt}{m}{sl}{last}
+\EC@ttfamily{T2A}{cmtt}{m}{it}{lait}
+\EC@ttfamily{T2A}{cmtt}{m}{sc}{latc}
+%
+\DeclareFontShape{T2A}{cmtt}{bx}{n}%
+%<!nowarn> {<->sub*cmtt/m/n}{}
+%<nowarn> {<->ssub*cmtt/m/n}{}
+\DeclareFontShape{T2A}{cmtt}{bx}{it}%
+%<!nowarn> {<->sub*cmtt/m/it}{}
+%<nowarn> {<->ssub*cmtt/m/it}{}
+%</T2Acmtt>
+%
+%<*T2Acmvtt>
+% Cyrillic Variable Typewriter
+\DeclareFontFamily{T2A}{cmvtt}{}
+%
+\EC@ttfamily{T2A}{cmvtt}{m}{n}{lavt}
+\EC@ttfamily{T2A}{cmvtt}{m}{it}{lavi}
+%</T2Acmvtt>
+% \end{macrocode}
+%
+% LH fonts for T2B encoding.
+%
+% \begin{macrocode}
+%<*T2Bcmdh>
+% Cyrillic Dunhill
+\DeclareFontFamily{T2B}{cmdh}{}
+\EC@family{T2B}{cmdh}{m}{n}{lbdh}
+%</T2Bcmdh>
+%
+%<*T2Bcmfib>
+\DeclareFontFamily{T2B}{cmfib}{}
+\EC@family{T2B}{cmfib}{m}{n}{lbfb}
+\EC@family{T2B}{cmfib}{m}{sl}{lbfs}
+%</T2Bcmfib>
+%
+%<*T2Bcmfr>
+\DeclareFontFamily{T2B}{cmfr}{}
+\EC@family{T2B}{cmfr}{m}{n}{lbff}
+\EC@family{T2B}{cmfr}{m}{it}{lbfi}
+%</T2Bcmfr>
+%
+%<*T2Bcmr>
+% Cyrillic Roman
+\DeclareFontFamily{T2B}{cmr}{}
+%
+\EC@family{T2B}{cmr}{m}{n}{lbrm}
+\EC@family{T2B}{cmr}{m}{sl}{lbsl}
+\EC@family{T2B}{cmr}{m}{it}{lbti}
+\EC@family{T2B}{cmr}{m}{sc}{lbcc}
+\EC@family{T2B}{cmr}{bx}{n}{lbbx}
+\EC@family{T2B}{cmr}{b}{n}{lbrb}
+\EC@family{T2B}{cmr}{bx}{it}{lbbi}
+\EC@family{T2B}{cmr}{bx}{sl}{lbbl}
+\EC@family{T2B}{cmr}{bx}{sc}{lbxc}
+\EC@family{T2B}{cmr}{m}{ui}{lbui}
+%</T2Bcmr>
+%
+%<*T2Bcmss>
+% Cyrillic Sans Serif
+\DeclareFontFamily{T2B}{cmss}{}
+%
+\EC@family{T2B}{cmss}{m}{n}{lbss}
+\EC@family{T2B}{cmss}{m}{sl}{lbsi}
+\EC@family{T2B}{cmss}{m}{it}{lbsi}
+\EC@family{T2B}{cmss}{bx}{n}{lbsx}
+\EC@family{T2B}{cmss}{bx}{it}{lbso}
+\EC@family{T2B}{cmss}{bx}{sl}{lbso}
+%
+\DeclareFontShape{T2B}{cmss}{m}{sc}{<->sub*cmr/m/sc}{}
+% semibold condensed series:
+\DeclareFontShape{T2B}{cmss}{sbc}{n}{%
+ <5><6><7><8><9><10><10.95><12><14.4><17.28><20.74><24.88>lbssdc10%
+}{}
+%</T2Bcmss>
+%
+%<*T2Bcmtt>
+% Cyrillic Typewriter
+\DeclareFontFamily{T2B}{cmtt}{\hyphenchar\font\m@ne}
+%
+\EC@ttfamily{T2B}{cmtt}{m}{n}{lbtt}
+\EC@ttfamily{T2B}{cmtt}{m}{sl}{lbst}
+\EC@ttfamily{T2B}{cmtt}{m}{it}{lbit}
+\EC@ttfamily{T2B}{cmtt}{m}{sc}{lbtc}
+%
+\DeclareFontShape{T2B}{cmtt}{bx}{n}%
+%<!nowarn> {<->sub*cmtt/m/n}{}
+%<nowarn> {<->ssub*cmtt/m/n}{}
+\DeclareFontShape{T2B}{cmtt}{bx}{it}%
+%<!nowarn> {<->sub*cmtt/m/it}{}
+%<nowarn> {<->ssub*cmtt/m/it}{}
+%</T2Bcmtt>
+%
+%<*T2Bcmvtt>
+% Cyrillic Variable Typewriter
+\DeclareFontFamily{T2B}{cmvtt}{}
+%
+\EC@ttfamily{T2B}{cmvtt}{m}{n}{lbvt}
+\EC@ttfamily{T2B}{cmvtt}{m}{it}{lbvi}
+%</T2Bcmvtt>
+% \end{macrocode}
+%
+% LH fonts for T2C encoding.
+%
+% \begin{macrocode}
+%<*T2Ccmdh>
+% Cyrillic Dunhill
+\DeclareFontFamily{T2C}{cmdh}{}
+\EC@family{T2C}{cmdh}{m}{n}{lcdh}
+%</T2Ccmdh>
+%
+%<*T2Ccmfib>
+\DeclareFontFamily{T2C}{cmfib}{}
+\EC@family{T2C}{cmfib}{m}{n}{lcfb}
+\EC@family{T2C}{cmfib}{m}{sl}{lcfs}
+%</T2Ccmfib>
+%
+%<*T2Ccmfr>
+\DeclareFontFamily{T2C}{cmfr}{}
+\EC@family{T2C}{cmfr}{m}{n}{lcff}
+\EC@family{T2C}{cmfr}{m}{it}{lcfi}
+%</T2Ccmfr>
+%
+%<*T2Ccmr>
+% Cyrillic Roman
+\DeclareFontFamily{T2C}{cmr}{}
+%
+\EC@family{T2C}{cmr}{m}{n}{lcrm}
+\EC@family{T2C}{cmr}{m}{sl}{lcsl}
+\EC@family{T2C}{cmr}{m}{it}{lcti}
+\EC@family{T2C}{cmr}{m}{sc}{lccc}
+\EC@family{T2C}{cmr}{bx}{n}{lcbx}
+\EC@family{T2C}{cmr}{b}{n}{lcrb}
+\EC@family{T2C}{cmr}{bx}{it}{lcbi}
+\EC@family{T2C}{cmr}{bx}{sl}{lcbl}
+\EC@family{T2C}{cmr}{bx}{sc}{lcxc}
+\EC@family{T2C}{cmr}{m}{ui}{lcui}
+%</T2Ccmr>
+%
+%<*T2Ccmss>
+% Cyrillic Sans Serif
+\DeclareFontFamily{T2C}{cmss}{}
+%
+\EC@family{T2C}{cmss}{m}{n}{lcss}
+\EC@family{T2C}{cmss}{m}{sl}{lcsi}
+\EC@family{T2C}{cmss}{m}{it}{lcsi}
+\EC@family{T2C}{cmss}{bx}{n}{lcsx}
+\EC@family{T2C}{cmss}{bx}{it}{lcso}
+\EC@family{T2C}{cmss}{bx}{sl}{lcso}
+%
+\DeclareFontShape{T2C}{cmss}{m}{sc}{<->sub*cmr/m/sc}{}
+% semibold condensed series:
+\DeclareFontShape{T2C}{cmss}{sbc}{n}{%
+ <5><6><7><8><9><10><10.95><12><14.4><17.28><20.74><24.88>lcssdc10%
+}{}
+%</T2Ccmss>
+%
+%<*T2Ccmtt>
+% Cyrillic Typewriter
+\DeclareFontFamily{T2C}{cmtt}{\hyphenchar\font\m@ne}
+%
+\EC@ttfamily{T2C}{cmtt}{m}{n}{lctt}
+\EC@ttfamily{T2C}{cmtt}{m}{sl}{lcst}
+\EC@ttfamily{T2C}{cmtt}{m}{it}{lcit}
+\EC@ttfamily{T2C}{cmtt}{m}{sc}{lctc}
+%
+\DeclareFontShape{T2C}{cmtt}{bx}{n}%
+%<!nowarn> {<->sub*cmtt/m/n}{}
+%<nowarn> {<->ssub*cmtt/m/n}{}
+\DeclareFontShape{T2C}{cmtt}{bx}{it}%
+%<!nowarn> {<->sub*cmtt/m/it}{}
+%<nowarn> {<->ssub*cmtt/m/it}{}
+%</T2Ccmtt>
+%
+%<*T2Ccmvtt>
+% Cyrillic Variable Typewriter
+\DeclareFontFamily{T2C}{cmvtt}{}
+%
+\EC@ttfamily{T2C}{cmvtt}{m}{n}{lcvt}
+\EC@ttfamily{T2C}{cmvtt}{m}{it}{lcvi}
+%</T2Ccmvtt>
+% \end{macrocode}
+%
+% \subsection{Computer Modern Sans}
+%
+% \begin{macrocode}
+%<*lcmss>
+%<X2>\DeclareFontFamily{X2}{lcmss}{}
+%<T2A>\DeclareFontFamily{T2A}{lcmss}{}
+%<T2B>\DeclareFontFamily{T2B}{lcmss}{}
+%<T2C>\DeclareFontFamily{T2C}{lcmss}{}
+% \end{macrocode}
+%
+% \begin{macrocode}
+%<X2>\DeclareFontShape{X2}{lcmss}{m}{n}{%
+%<T2A>\DeclareFontShape{T2A}{lcmss}{m}{n}{%
+%<T2B>\DeclareFontShape{T2B}{lcmss}{m}{n}{%
+%<T2C>\DeclareFontShape{T2C}{lcmss}{m}{n}{%
+ <7><8><10><12><13.82><16.59><19.907><23.89><28.66><34.4><41.28>%
+%<X2> rxlq8%
+%<T2A> lalq8%
+%<T2B> lblq8%
+%<T2C> lclq8%
+}{}
+% \end{macrocode}
+%
+% \begin{macrocode}
+%<X2>\DeclareFontShape{X2}{lcmss}{m}{In}{%
+%<T2A>\DeclareFontShape{T2A}{lcmss}{m}{In}{%
+%<T2B>\DeclareFontShape{T2B}{lcmss}{m}{In}{%
+%<T2C>\DeclareFontShape{T2C}{lcmss}{m}{In}{%
+ <7><8><10><12><13.82><16.59><19.907><23.89><28.66><34.4><41.28>%
+%<X2> irxlq8%
+%<T2A> ilalq8%
+%<T2B> ilblq8%
+%<T2C> ilclq8%
+}{}
+% \end{macrocode}
+%
+% \begin{macrocode}
+%<X2>\DeclareFontShape{X2}{lcmss}{m}{sl}{%
+%<T2A>\DeclareFontShape{T2A}{lcmss}{m}{sl}{%
+%<T2B>\DeclareFontShape{T2B}{lcmss}{m}{sl}{%
+%<T2C>\DeclareFontShape{T2C}{lcmss}{m}{sl}{%
+ <13.82><16.59><19.907><23.89><28.66><34.4><41.28>%
+%<X2> rxli8%
+%<T2A> lali8%
+%<T2B> lbli8%
+%<T2C> lcli8%
+}{}
+% \end{macrocode}
+%
+% \begin{macrocode}
+%<X2>\DeclareFontShape{X2}{lcmss}{m}{Isl}{%
+%<T2A>\DeclareFontShape{T2A}{lcmss}{m}{Isl}{%
+%<T2B>\DeclareFontShape{T2B}{lcmss}{m}{Isl}{%
+%<T2C>\DeclareFontShape{T2C}{lcmss}{m}{Isl}{%
+ <13.82><16.59><19.907><23.89><28.66><34.4><41.28>%
+%<X2> irxli8%
+%<T2A> ilali8%
+%<T2B> ilbli8%
+%<T2C> ilcli8%
+}{}
+% \end{macrocode}
+%
+% \begin{macrocode}
+%<X2>\DeclareFontShape{X2}{lcmss}{m}{it}{%
+%<T2A>\DeclareFontShape{T2A}{lcmss}{m}{it}{%
+%<T2B>\DeclareFontShape{T2B}{lcmss}{m}{it}{%
+%<T2C>\DeclareFontShape{T2C}{lcmss}{m}{it}{%
+ <->sub*lcmss/m/sl}{}
+% \end{macrocode}
+%
+% \begin{macrocode}
+%<X2>\DeclareFontShape{X2}{lcmss}{m}{Iit}{%
+%<T2A>\DeclareFontShape{T2A}{lcmss}{m}{Iit}{%
+%<T2B>\DeclareFontShape{T2B}{lcmss}{m}{Iit}{%
+%<T2C>\DeclareFontShape{T2C}{lcmss}{m}{Iit}{%
+ <->sub*lcmss/m/Isl}{}
+% \end{macrocode}
+%
+% \begin{macrocode}
+%<X2>\DeclareFontShape{X2}{lcmss}{bx}{n}{%
+%<T2A>\DeclareFontShape{T2A}{lcmss}{bx}{n}{%
+%<T2B>\DeclareFontShape{T2B}{lcmss}{bx}{n}{%
+%<T2C>\DeclareFontShape{T2C}{lcmss}{bx}{n}{%
+ <13.82><16.59><19.907><23.89><28.66><34.4><41.28>%
+%<X2> rxlb8%
+%<T2A> lalb8%
+%<T2B> lblb8%
+%<T2C> lclb8%
+}{}
+% \end{macrocode}
+%
+% \begin{macrocode}
+%<X2>\DeclareFontShape{X2}{lcmss}{bx}{In}{%
+%<T2A>\DeclareFontShape{T2A}{lcmss}{bx}{In}{%
+%<T2B>\DeclareFontShape{T2B}{lcmss}{bx}{In}{%
+%<T2C>\DeclareFontShape{T2C}{lcmss}{bx}{In}{%
+ <13.82><16.59><19.907><23.89><28.66><34.4><41.28>%
+%<X2> irxlb8%
+%<T2A> ilalb8%
+%<T2B> ilblb8%
+%<T2C> ilclb8%
+}{}
+% \end{macrocode}
+%
+% \begin{macrocode}
+%<X2>\DeclareFontShape{X2}{lcmss}{bx}{sl}{%
+%<T2A>\DeclareFontShape{T2A}{lcmss}{bx}{sl}{%
+%<T2B>\DeclareFontShape{T2B}{lcmss}{bx}{sl}{%
+%<T2C>\DeclareFontShape{T2C}{lcmss}{bx}{sl}{%
+ <13.82><16.59><19.907><23.89><28.66><34.4><41.28>%
+%<X2> rxlo8%
+%<T2A> lalo8%
+%<T2B> lblo8%
+%<T2C> lclo8%
+}{}
+% \end{macrocode}
+%
+% \begin{macrocode}
+%<X2>\DeclareFontShape{X2}{lcmss}{bx}{Isl}{%
+%<T2A>\DeclareFontShape{T2A}{lcmss}{bx}{Isl}{%
+%<T2B>\DeclareFontShape{T2B}{lcmss}{bx}{Isl}{%
+%<T2C>\DeclareFontShape{T2C}{lcmss}{bx}{Isl}{%
+ <13.82><16.59><19.907><23.89><28.66><34.4><41.28>%
+%<X2> irxlo8%
+%<T2A> ilalo8%
+%<T2B> ilblo8%
+%<T2C> ilclo8%
+}{}
+% \end{macrocode}
+%
+% \begin{macrocode}
+%<X2>\DeclareFontShape{X2}{lcmss}{bx}{it}{%
+%<T2A>\DeclareFontShape{T2A}{lcmss}{bx}{it}{%
+%<T2B>\DeclareFontShape{T2B}{lcmss}{bx}{it}{%
+%<T2C>\DeclareFontShape{T2C}{lcmss}{bx}{it}{%
+ <->sub*lcmss/bx/sl}{}
+% \end{macrocode}
+%
+% \begin{macrocode}
+%<X2>\DeclareFontShape{X2}{lcmss}{bx}{Iit}{%
+%<T2A>\DeclareFontShape{T2A}{lcmss}{bx}{Iit}{%
+%<T2B>\DeclareFontShape{T2B}{lcmss}{bx}{Iit}{%
+%<T2C>\DeclareFontShape{T2C}{lcmss}{bx}{Iit}{%
+ <->sub*lcmss/bx/Isl}{}
+%</lcmss>
+% \end{macrocode}
+%
+% \subsection{Computer Modern Typewriter}
+%
+% \begin{macrocode}
+%<*lcmtt>
+%<X2>\DeclareFontFamily{X2}{lcmtt}{\hyphenchar\font\m@ne}
+%<T2A>\DeclareFontFamily{T2A}{lcmtt}{\hyphenchar\font\m@ne}
+%<T2B>\DeclareFontFamily{T2B}{lcmtt}{\hyphenchar\font\m@ne}
+%<T2C>\DeclareFontFamily{T2C}{lcmtt}{\hyphenchar\font\m@ne}
+% \end{macrocode}
+%
+% \begin{macrocode}
+%<X2>\DeclareFontShape{X2}{lcmtt}{m}{n}{%
+%<T2A>\DeclareFontShape{T2A}{lcmtt}{m}{n}{%
+%<T2B>\DeclareFontShape{T2B}{lcmtt}{m}{n}{%
+%<T2C>\DeclareFontShape{T2C}{lcmtt}{m}{n}{%
+ <13.82><16.59><19.907><23.89><28.66><34.4><41.28>%
+%<X2> rxltt8%
+%<T2A> laltt8%
+%<T2B> lbltt8%
+%<T2C> lcltt8%
+}{}
+% \end{macrocode}
+%
+% \begin{macrocode}
+%<X2>\DeclareFontShape{X2}{lcmtt}{m}{In}{%
+%<T2A>\DeclareFontShape{T2A}{lcmtt}{m}{In}{%
+%<T2B>\DeclareFontShape{T2B}{lcmtt}{m}{In}{%
+%<T2C>\DeclareFontShape{T2C}{lcmtt}{m}{In}{%
+ <13.82><16.59><19.907><23.89><28.66><34.4><41.28>%
+%<X2> irxltt8%
+%<T2A> ilaltt8%
+%<T2B> ilbltt8%
+%<T2C> ilcltt8%
+}{}
+% \end{macrocode}
+%
+% \begin{macrocode}
+%<X2>\DeclareFontShape{X2}{lcmtt}{m}{it}{%
+%<T2A>\DeclareFontShape{T2A}{lcmtt}{m}{it}{%
+%<T2B>\DeclareFontShape{T2B}{lcmtt}{m}{it}{%
+%<T2C>\DeclareFontShape{T2C}{lcmtt}{m}{it}{%
+ <13.82><16.59><19.907><23.89><28.66><34.4><41.28>%
+%<X2> rxit1000%
+%<T2A> lait1000%
+%<T2B> lbit1000%
+%<T2C> lcit1000%
+}{}
+%</lcmtt>
+% \end{macrocode}
+%
+% \section{Computer Modern Bright family}
+%
+% \subsection{Computer Modern Bright, T2A encoding}
+%
+% \begin{macrocode}
+%<*T2Acmbr>
+\DeclareFontFamily{T2A}{cmbr}{}
+\DeclareFontShape{T2A}{cmbr}{m}{n}{%
+ <5><6><7><8>labmr8%
+ <9>labmr9%
+ <10><10.95><12><14.4>labmr10%
+ <17.28><20.74><24.88><29.86><35.83>labmr17%
+}{}
+\DeclareFontShape{T2A}{cmbr}{m}{sl}{%
+ <5><6><7><8>labmo8%
+ <9>labmo9%
+ <10><10.95><12><14.4>labmo10%
+ <17.28><20.74><24.88><29.86><35.83>labmo17%
+}{}
+\DeclareFontShape{T2A}{cmbr}{m}{it}{<->ssub*cmbr/m/sl}{}
+\DeclareFontShape{T2A}{cmbr}{sb}{n}{%
+ <5><6><7><8>labsr8%
+ <9>labsr9%
+ <10><10.95><12><14.4>labsr10%
+ <17.28><20.74><24.88><29.86><35.83>labsr17%
+}{}
+\DeclareFontShape{T2A}{cmbr}{sb}{sl}{%
+ <5><6><7><8>labso8%
+ <9>labso9%
+ <10><10.95><12><14.4>labso10%
+ <17.28><20.74><24.88><29.86><35.83>labso17%
+}{}
+\DeclareFontShape{T2A}{cmbr}{sb}{it}{<->ssub*cmbr/sb/sl}{}
+\DeclareFontShape{T2A}{cmbr}{b}{n}{<->ssub*cmbr/bx/n}{}
+\DeclareFontShape{T2A}{cmbr}{bx}{n}{%
+ <-9>sub*cmbr/sb/n%
+ <9><10><10.95><12><14.4><17.28><20.74><24.88><29.86><35.83>labbx10%
+}{}
+%</T2Acmbr>
+% \end{macrocode}
+%
+% \subsection{Computer Modern Bright, T2B encoding}
+%
+% \begin{macrocode}
+%<*T2Bcmbr>
+\DeclareFontFamily{T2B}{cmbr}{}
+\DeclareFontShape{T2B}{cmbr}{m}{n}{%
+ <5><6><7><8>lbbmr8%
+ <9>lbbmr9%
+ <10><10.95><12><14.4>lbbmr10%
+ <17.28><20.74><24.88><29.86><35.83>lbbmr17%
+}{}
+\DeclareFontShape{T2B}{cmbr}{m}{sl}{%
+ <5><6><7><8>lbbmo8%
+ <9>lbbmo9%
+ <10><10.95><12><14.4>lbbmo10%
+ <17.28><20.74><24.88><29.86><35.83>lbbmo17%
+}{}
+\DeclareFontShape{T2B}{cmbr}{m}{it}{<->ssub*cmbr/m/sl}{}
+\DeclareFontShape{T2B}{cmbr}{sb}{n}{%
+ <5><6><7><8>lbbsr8%
+ <9>lbbsr9%
+ <10><10.95><12><14.4>lbbsr10%
+ <17.28><20.74><24.88><29.86><35.83>lbbsr17%
+}{}
+\DeclareFontShape{T2B}{cmbr}{sb}{sl}{%
+ <5><6><7><8>lbbso8%
+ <9>lbbso9%
+ <10><10.95><12><14.4>lbbso10%
+ <17.28><20.74><24.88><29.86><35.83>lbbso17%
+}{}
+\DeclareFontShape{T2B}{cmbr}{sb}{it}{<->ssub*cmbr/sb/sl}{}
+\DeclareFontShape{T2B}{cmbr}{b}{n}{<->ssub*cmbr/bx/n}{}
+\DeclareFontShape{T2B}{cmbr}{bx}{n}{%
+ <-9>sub*cmbr/sb/n%
+ <9><10><10.95><12><14.4><17.28><20.74><24.88><29.86><35.83>lbbbx10%
+}{}
+%</T2Bcmbr>
+% \end{macrocode}
+%
+% \subsection{Computer Modern Bright, T2C encoding}
+%
+% \begin{macrocode}
+%<*T2Ccmbr>
+\DeclareFontFamily{T2C}{cmbr}{}
+\DeclareFontShape{T2C}{cmbr}{m}{n}{%
+ <5><6><7><8>lcbmr8%
+ <9>lcbmr9%
+ <10><10.95><12><14.4>lcbmr10%
+ <17.28><20.74><24.88><29.86><35.83>lcbmr17%
+}{}
+\DeclareFontShape{T2C}{cmbr}{m}{sl}{%
+ <5><6><7><8>lcbmo8%
+ <9>lcbmo9%
+ <10><10.95><12><14.4>lcbmo10%
+ <17.28><20.74><24.88><29.86><35.83>lcbmo17%
+}{}
+\DeclareFontShape{T2C}{cmbr}{m}{it}{<->ssub*cmbr/m/sl}{}
+\DeclareFontShape{T2C}{cmbr}{sb}{n}{%
+ <5><6><7><8>lcbsr8%
+ <9>lcbsr9%
+ <10><10.95><12><14.4>lcbsr10%
+ <17.28><20.74><24.88><29.86><35.83>lcbsr17%
+}{}
+\DeclareFontShape{T2C}{cmbr}{sb}{sl}{%
+ <5><6><7><8>lcbso8%
+ <9>lcbso9%
+ <10><10.95><12><14.4>lcbso10%
+ <17.28><20.74><24.88><29.86><35.83>lcbso17%
+}{}
+\DeclareFontShape{T2C}{cmbr}{sb}{it}{<->ssub*cmbr/sb/sl}{}
+\DeclareFontShape{T2C}{cmbr}{b}{n}{<->ssub*cmbr/bx/n}{}
+\DeclareFontShape{T2C}{cmbr}{bx}{n}{%
+ <-9>sub*cmbr/sb/n%
+ <9><10><10.95><12><14.4><17.28><20.74><24.88><29.86><35.83>lcbbx10%
+}{}
+%</T2Ccmbr>
+% \end{macrocode}
+%
+% \subsection{Computer Modern Bright, X2 encoding}
+%
+% \begin{macrocode}
+%<*X2cmbr>
+\DeclareFontFamily{X2}{cmbr}{}
+\DeclareFontShape{X2}{cmbr}{m}{n}{%
+ <5><6><7><8>rxbmr8%
+ <9>rxbmr9%
+ <10><10.95><12><14.4>rxbmr10%
+ <17.28><20.74><24.88><29.86><35.83>rxbmr17%
+}{}
+\DeclareFontShape{X2}{cmbr}{m}{sl}{%
+ <5><6><7><8>rxbmo8%
+ <9>rxbmo9%
+ <10><10.95><12><14.4>rxbmo10%
+ <17.28><20.74><24.88><29.86><35.83>rxbmo17%
+}{}
+\DeclareFontShape{X2}{cmbr}{m}{it}{<->ssub*cmbr/m/sl}{}
+\DeclareFontShape{X2}{cmbr}{sb}{n}{%
+ <5><6><7><8>rxbsr8%
+ <9>rxbsr9%
+ <10><10.95><12><14.4>rxbsr10%
+ <17.28><20.74><24.88><29.86><35.83>rxbsr17%
+}{}
+\DeclareFontShape{X2}{cmbr}{sb}{sl}{%
+ <5><6><7><8>rxbso8%
+ <9>rxbso9%
+ <10><10.95><12><14.4>rxbso10%
+ <17.28><20.74><24.88><29.86><35.83>rxbso17%
+}{}
+\DeclareFontShape{X2}{cmbr}{sb}{it}{<->ssub*cmbr/sb/sl}{}
+\DeclareFontShape{X2}{cmbr}{b}{n}{<->ssub*cmbr/bx/n}{}
+\DeclareFontShape{X2}{cmbr}{bx}{n}{%
+ <-9>sub*cmbr/sb/n%
+ <9><10><10.95><12><14.4><17.28><20.74><24.88><29.86><35.83>rxbbx10%
+}{}
+%</X2cmbr>
+% \end{macrocode}
+%
+% \section{Computer Modern Typewriter Light family}
+%
+% \subsection{Computer Modern Typewriter Light, T2A encoding}
+%
+% \begin{macrocode}
+%<*T2Acmtl>
+\DeclareFontFamily{T2A}{cmtl}{\hyphenchar\font\m@ne}
+\DeclareFontShape{T2A}{cmtl}{m}{n}{%
+ <5><6><7><8><9><10><10.95><12><14.4><17.28>%
+ <20.74><24.88><29.86><35.83>labtl10%
+}{}
+\DeclareFontShape{T2A}{cmtl}{m}{sl}{%
+ <5><6><7><8><9><10><10.95><12><14.4><17.28>%
+ <20.74><24.88><29.86><35.83>labto10%
+}{}
+\DeclareFontShape{T2A}{cmtl}{m}{it}{<->ssub*cmtl/m/sl}{}
+%</T2Acmtl>
+% \end{macrocode}
+%
+% \subsection{Computer Modern Typewriter Light, T2B encoding}
+%
+% \begin{macrocode}
+%<*T2Bcmtl>
+\DeclareFontFamily{T2B}{cmtl}{\hyphenchar\font\m@ne}
+\DeclareFontShape{T2B}{cmtl}{m}{n}{%
+ <5><6><7><8><9><10><10.95><12><14.4><17.28>%
+ <20.74><24.88><29.86><35.83>lbbtl10%
+}{}
+\DeclareFontShape{T2B}{cmtl}{m}{sl}{%
+ <5><6><7><8><9><10><10.95><12><14.4><17.28>%
+ <20.74><24.88><29.86><35.83>lbbto10%
+}{}
+\DeclareFontShape{T2B}{cmtl}{m}{it}{<->ssub*cmtl/m/sl}{}
+%</T2Bcmtl>
+% \end{macrocode}
+%
+% \subsection{Computer Modern Typewriter Light, T2C encoding}
+%
+% \begin{macrocode}
+%<*T2Ccmtl>
+\DeclareFontFamily{T2C}{cmtl}{\hyphenchar\font\m@ne}
+\DeclareFontShape{T2C}{cmtl}{m}{n}{%
+ <5><6><7><8><9><10><10.95><12><14.4><17.28>%
+ <20.74><24.88><29.86><35.83>lcbtl10%
+}{}
+\DeclareFontShape{T2C}{cmtl}{m}{sl}{%
+ <5><6><7><8><9><10><10.95><12><14.4><17.28>%
+ <20.74><24.88><29.86><35.83>lcbto10%
+}{}
+\DeclareFontShape{T2C}{cmtl}{m}{it}{<->ssub*cmtl/m/sl}{}
+%</T2Ccmtl>
+% \end{macrocode}
+%
+% \subsection{Computer Modern Typewriter Light, X2 encoding}
+%
+% \begin{macrocode}
+%<*X2cmtl>
+\DeclareFontFamily{X2}{cmtl}{\hyphenchar\font\m@ne}
+\DeclareFontShape{X2}{cmtl}{m}{n}{%
+ <5><6><7><8><9><10><10.95><12><14.4><17.28>%
+ <20.74><24.88><29.86><35.83>rxbtl10%
+}{}
+\DeclareFontShape{X2}{cmtl}{m}{sl}{%
+ <5><6><7><8><9><10><10.95><12><14.4><17.28>%
+ <20.74><24.88><29.86><35.83>rxbto10%
+}{}
+\DeclareFontShape{X2}{cmtl}{m}{it}{<->ssub*cmtl/m/sl}{}
+%</X2cmtl>
+% \end{macrocode}
+%
+% \section{Computer Modern Concrete family}
+%
+% \subsection{Computer Modern Concrete, T2A encoding}
+%
+% \begin{macrocode}
+%<*T2Accr>
+\DeclareFontFamily{T2A}{ccr}{}
+\DeclareFontShape{T2A}{ccr}{m}{n}{%
+ <5><6><7><8><9><10>gen*laorm%
+ <10.95><12><14.4><17.28><20.74><24.88>laorm10%
+}{}
+\DeclareFontShape{T2A}{ccr}{m}{sl}{%
+ <5><6><7><8><9><10>gen*laosl%
+ <10.95><12><14.4><17.28><20.74><24.88>laosl10%
+}{}
+\DeclareFontShape{T2A}{ccr}{m}{it}{%
+ <5><6><7><8><9><10><10.95><12><14.4><17.28><20.74><24.88>laoti10%
+}{}
+\DeclareFontShape{T2A}{ccr}{m}{sc}{%
+ <5><6><7><8><9><10><10.95><12><14.4><17.28><20.74><24.88>laocc10%
+}{}
+\DeclareFontShape{T2A}{ccr}{bx}{n}{%
+ <5><6><7><8><9><10><10.95><12><14.4><17.28><20.74><24.88>ssub*cmr/bx/n%
+}{}
+\DeclareFontShape{T2A}{ccr}{bx}{sl}{%
+ <5><6><7><8><9><10><10.95><12><14.4><17.28><20.74><24.88>ssub*cmr/bx/sl%
+}{}
+\DeclareFontShape{T2A}{ccr}{bx}{it}{%
+ <5><6><7><8><9><10><10.95><12><14.4><17.28><20.74><24.88>ssub*cmr/bx/it%
+}{}
+\DeclareFontShape{T2A}{ccr}{sbc}{n}{%
+ <5><6><7><8><9><10><10.95><12><14.4><17.28><20.74><24.88>ssubf*lassdc10%
+}{}
+%</T2Accr>
+% \end{macrocode}
+%
+% \subsection{Computer Modern Concrete, T2B encoding}
+%
+% \begin{macrocode}
+%<*T2Bccr>
+\DeclareFontFamily{T2B}{ccr}{}
+\DeclareFontShape{T2B}{ccr}{m}{n}{%
+ <5><6><7><8><9><10>gen*lborm%
+ <10.95><12><14.4><17.28><20.74><24.88>lborm10%
+}{}
+\DeclareFontShape{T2B}{ccr}{m}{sl}{%
+ <5><6><7><8><9><10>gen*lbosl%
+ <10.95><12><14.4><17.28><20.74><24.88>lbosl10%
+}{}
+\DeclareFontShape{T2B}{ccr}{m}{it}{%
+ <5><6><7><8><9><10><10.95><12><14.4><17.28><20.74><24.88>lboti10%
+}{}
+\DeclareFontShape{T2B}{ccr}{m}{sc}{%
+ <5><6><7><8><9><10><10.95><12><14.4><17.28><20.74><24.88>lbocc10%
+}{}
+\DeclareFontShape{T2B}{ccr}{bx}{n}{%
+ <5><6><7><8><9><10><10.95><12><14.4><17.28><20.74><24.88>ssub*cmr/bx/n%
+}{}
+\DeclareFontShape{T2B}{ccr}{bx}{sl}{%
+ <5><6><7><8><9><10><10.95><12><14.4><17.28><20.74><24.88>ssub*cmr/bx/sl%
+}{}
+\DeclareFontShape{T2B}{ccr}{bx}{it}{%
+ <5><6><7><8><9><10><10.95><12><14.4><17.28><20.74><24.88>ssub*cmr/bx/it%
+}{}
+\DeclareFontShape{T2B}{ccr}{sbc}{n}{%
+ <5><6><7><8><9><10><10.95><12><14.4><17.28><20.74><24.88>ssubf*lbssdc10%
+}{}
+%</T2Bccr>
+% \end{macrocode}
+%
+% \subsection{Computer Modern Concrete, T2C encoding}
+%
+% \begin{macrocode}
+%<*T2Cccr>
+\DeclareFontFamily{T2C}{ccr}{}
+\DeclareFontShape{T2C}{ccr}{m}{n}{%
+ <5><6><7><8><9><10>gen*lcorm%
+ <10.95><12><14.4><17.28><20.74><24.88>lcorm10%
+}{}
+\DeclareFontShape{T2C}{ccr}{m}{sl}{%
+ <5><6><7><8><9><10>gen*lcosl%
+ <10.95><12><14.4><17.28><20.74><24.88>lcosl10%
+}{}
+\DeclareFontShape{T2C}{ccr}{m}{it}{%
+ <5><6><7><8><9><10><10.95><12><14.4><17.28><20.74><24.88>lcoti10%
+}{}
+\DeclareFontShape{T2C}{ccr}{m}{sc}{%
+ <5><6><7><8><9><10><10.95><12><14.4><17.28><20.74><24.88>lcocc10%
+}{}
+\DeclareFontShape{T2C}{ccr}{bx}{n}{%
+ <5><6><7><8><9><10><10.95><12><14.4><17.28><20.74><24.88>ssub*cmr/bx/n%
+}{}
+\DeclareFontShape{T2C}{ccr}{bx}{sl}{%
+ <5><6><7><8><9><10><10.95><12><14.4><17.28><20.74><24.88>ssub*cmr/bx/sl%
+}{}
+\DeclareFontShape{T2C}{ccr}{bx}{it}{%
+ <5><6><7><8><9><10><10.95><12><14.4><17.28><20.74><24.88>ssub*cmr/bx/it%
+}{}
+\DeclareFontShape{T2C}{ccr}{sbc}{n}{%
+ <5><6><7><8><9><10><10.95><12><14.4><17.28><20.74><24.88>ssubf*lcssdc10%
+}{}
+%</T2Cccr>
+% \end{macrocode}
+%
+% \subsection{Computer Modern Concrete, X2 encoding}
+%
+% \begin{macrocode}
+%<*X2ccr>
+\DeclareFontFamily{X2}{ccr}{}
+\DeclareFontShape{X2}{ccr}{m}{n}{%
+ <5><6><7><8><9><10>gen*rxorm%
+ <10.95><12><14.4><17.28><20.74><24.88>rxorm10%
+}{}
+\DeclareFontShape{X2}{ccr}{m}{sl}{%
+ <5><6><7><8><9><10>gen*rxosl%
+ <10.95><12><14.4><17.28><20.74><24.88>rxosl10%
+}{}
+\DeclareFontShape{X2}{ccr}{m}{it}{%
+ <5><6><7><8><9><10><10.95><12><14.4><17.28><20.74><24.88>rxoti10%
+}{}
+\DeclareFontShape{X2}{ccr}{m}{sc}{%
+ <5><6><7><8><9><10><10.95><12><14.4><17.28><20.74><24.88>rxocc10%
+}{}
+\DeclareFontShape{X2}{ccr}{bx}{n}{%
+ <5><6><7><8><9><10><10.95><12><14.4><17.28><20.74><24.88>ssub*cmr/bx/n%
+}{}
+\DeclareFontShape{X2}{ccr}{bx}{sl}{%
+ <5><6><7><8><9><10><10.95><12><14.4><17.28><20.74><24.88>ssub*cmr/bx/sl%
+}{}
+\DeclareFontShape{X2}{ccr}{bx}{it}{%
+ <5><6><7><8><9><10><10.95><12><14.4><17.28><20.74><24.88>ssub*cmr/bx/it%
+}{}
+\DeclareFontShape{X2}{ccr}{sbc}{n}{%
+ <5><6><7><8><9><10><10.95><12><14.4><17.28><20.74><24.88>ssubf*rxssdc10%
+}{}
+%</X2ccr>
+% \end{macrocode}
+\endinput
diff --git a/macros/latex/required/cyrillic/t2lhfnt.pdf b/macros/latex/required/cyrillic/t2lhfnt.pdf
new file mode 100644
index 0000000000..88f3eb17e0
--- /dev/null
+++ b/macros/latex/required/cyrillic/t2lhfnt.pdf
Binary files differ
diff --git a/macros/latex/required/graphics/README.md b/macros/latex/required/graphics/README.md
new file mode 100644
index 0000000000..54dbc10875
--- /dev/null
+++ b/macros/latex/required/graphics/README.md
@@ -0,0 +1,132 @@
+## README for the Standard LaTeX `Graphics` bundle
+
+This bundle consists of LaTeX2e packages written and supported by
+members of the LaTeX3 Project Team.
+
+It is a collection of LaTeX packages for:
+- producing colour
+- including graphics (eg PostScript) files
+- rotation and scaling of text
+in LaTeX documents.
+
+
+
+### THIS DIRECTORY CONTAINS
+
+#### Support files
+
+| File | Notes |
+| --- | --- |
+| README.md | This file |
+| changes.txt | Log of changes to the packages |
+| graphics.ins | Install file for docstrip |
+
+#### Basic packages
+
+| File           | Notes |
+| --- | --- |
+| color.dtx | Source for color package |
+| graphics.dtx | Source for graphics package |
+| trig.dtx | Source for trig package (required by graphics) |
+
+#### Extension Packages
+
+| File | Notes |
+| --- | --- |
+| graphicx.dtx | Source for graphicx package (extension of graphics) |
+| epsfig.dtx     | Source for epsfig package (extension of graphicx). |
+| rotating.dtx   | Source for rotating package (extension of graphicx). |
+| keyval.dtx | Source for keyval pacakge (required by both the above) |
+| lscape.sty | Produce landscape pages in a (mainly) portrait document |
+
+#### Driver Files
+
+| File | Notes |
+| --- | --- |
+| drivers.dtx | Source for driver files for supported drivers |
+
+#### User Documentation
+
+| File | Notes |
+| --- | --- |
+| grfguide.tex | User Guide to all the packages in this bundle |
+| | **WARNING:** *This file calls color and graphics packages without a driver option. You **must** therefore set up two files `color.cfg` and `graphics.cfg` containing (for example) `\ExecuteOptions{dvips}` before running this file.* |
+| rotex.tex | Examples of use of rotating package |
+
+
+
+### TO UNPACK THE PACKAGES
+
+ latex graphics.ins
+
+This will produce the `.sty` package files.
+
+Similarly you can run
+
+ latex graphics-drivers.ins
+
+to produce the `.def` driver files.
+
+Not all supported drivers are included in this file as they are
+maintained elsewhere.
+
+
+### USING THE PACKAGES
+
+Move files ending in `.sty` or `.def` to a standard TeX input directory.
+
+Make a default option for your site by creating two files `color.cfg` and `graphics.cfg`
+containing (if dvips is your default driver)
+ \ExecuteOptions{dvips}
+
+You may then LaTeX the user guide by running:
+
+ latex grfguide.tex
+
+
+
+### Copyright
+
+Copyright is maintained on each of these packages by the author(s)
+of the package.
+
+
+### Distribution Conditions
+
+All the files in this bundle may be distributed 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 this bundle is listed above.
+
+The use of these files is otherwise unrestricted.
+
+
+### Reporting Bugs
+
+If you wish to report a problem or bug in any of these packages
+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!
+
+
+
+### Copyright
+
+This README file is copyright 1993-2017 The LaTeX3 Project.
+
diff --git a/macros/latex/required/graphics/cat.eps b/macros/latex/required/graphics/cat.eps
new file mode 100644
index 0000000000..0042ea088f
--- /dev/null
+++ b/macros/latex/required/graphics/cat.eps
@@ -0,0 +1,305 @@
+%!PS-Adobe-2.0 EPSF-2.0
+%%BoundingBox: 44 527 80 559
+%%Creator: COREL DRAW
+%%Title: CAT.TMP
+%%CreationDate: Sat Jan 18 17:29:05 1992
+
+%%DocumentFonts:
+%%EndComments
+%%BeginProlog
+% -------------- POSTSCRIPT PROLOG FOR CORELDRAW 2.X ------
+% Copyright Corel Systems Corporation 1990
+/AutoFlatness 0 def/wCorelDict 300 dict def
+wCorelDict begin/bd{bind def}bind def/ld{load def}bd
+/xd{exch def}bd/_ null def/$c 0 def/$m 0 def
+/$y 0 def/$k 0 def/$t 1 def/$n _ def/$o 0 def
+/$fil 0 def/$C 0 def/$M 0 def/$Y 0 def/$K 0 def
+/$T 1 def/$N _ def/$O 0 def/$PF false def
+/$pan 0 def/$h false def/$al 0 def/$tr 0 def
+/$le 0 def/$lx 0 def/$ly 0 def/$ctm matrix currentmatrix def
+/$ptm matrix def/$ttm matrix def/$stm matrix def
+/$skm matrix def/$fst 128 def/$pad 0 def/$rox 0 def
+/$roy 0 def currentscreen/@dsp xd/$dsp/@dsp def
+/$dsa xd/$dsf xd/$sdf false def/$SDF false def
+/$Scra 0.0 def statusdict/pageparams known{statusdict begin
+pageparams end 1 ne{/$Scra -90.0 def}if pop pop pop}if
+/$sv 0 def/@cp/closepath ld/@gs/gsave ld/@gr/grestore ld
+/@np/newpath ld/@sv{/$sv save def}bd/@rs{$sv restore}bd
+/@ss{load setscreen}bd AutoFlatness 1 eq{/$cpx ([Error: PathTooComplex; OffendingCommand: AnyPaintingOperator;\n) def
+/@err1{$cpx print flush newpath}bd/@ifl{currentflat dup 10 gt{pop @err1 exit}if 2 add setflat}bd
+/@fill/fill ld/fill{currentflat{{@fill}stopped{@ifl}{exit}ifelse}bind loop setflat}bd
+/@eofill/eofill ld/eofill{currentflat{{@eofill}stopped{@ifl}{exit}ifelse}bind loop setflat}bd
+/@clip/clip ld/clip{currentflat{{@clip}stopped{initclip @ifl}{exit}ifelse}bind loop setflat}bd
+/@eoclip/eoclip ld/eoclip{currentflat{{@eoclip}stopped{initclip @ifl}{exit}ifelse}bind loop setflat}bd
+/@stroke/stroke ld/stroke{currentflat{{@stroke}stopped{@ifl}{exit}ifelse}bind loop setflat}bd
+}if/InRange{3 -1 roll 2 copy le{pop}{exch pop}ifelse
+2 copy ge{pop}{exch pop}ifelse}bd/wDstChck{2 1 roll dup 3 -1 roll
+eq{1 add}if}bd/@dot{dup mul exch dup mul add 1 exch sub 2 div}bd
+/@lin{exch pop abs 1 exch sub}bd/@MN{2 copy le{pop}{exch pop}ifelse}bd
+/setcmykcolor where{pop}{/setcmykcolor{4 1 roll
+3{3 index add 1 @MN 1 exch sub 3 1 roll}repeat
+setrgbcolor pop}bd}ifelse/colorimage where{pop}{/colorimage{/$ncl xd
+pop pop pop pop{currentfile $dat readhexstring pop}repeat
+pop}bd}ifelse/@tc{dup 1 ge{pop}{4{dup 6 -1 roll
+mul exch}repeat pop}ifelse}bd/@spc{7 2 roll
+ColorSeparationMode 1 eq{6 index @tc 0 4 $ink sub index
+exch pop}{5 index dup _ eq{pop 0 4 $ink sub index
+exch pop}{CurrentInkName eq{6 index}{0}ifelse}ifelse}ifelse
+5 1 roll 8 -2 roll 6{pop}repeat 1 exch sub dup setgray
+1 eq exch 1 eq and not}bd/@scc{$ink -1 eq
+{$c $m $y $k $t @tc setcmykcolor true}{$o $c $m $y $k $t $n @spc
+}ifelse}bd/@SCC{$ink -1 eq{$C $M $Y $K $T @tc setcmykcolor true}{
+$O $C $M $Y $K $T $N @spc}ifelse}bd/@sft{
+/$tx $tllx $pxf add dup $tllx gt{$pwid sub}if def
+/$ty $tury $pyf sub dup $tury lt{$phei add}if def}bd
+/@stb{pathbbox/$ury xd/$urx xd/$lly xd/$llx xd}bd
+/@ep{{cvx exec}forall}bd/@tp{@sv/$in true def
+2 copy dup $lly le{/$in false def}if $phei sub $ury ge{/$in false def}if
+dup $urx ge{/$in false def}if $pwid add $llx le{/$in false def}if
+$in{@np 2 copy moveto $pwid 0 rlineto 0 $phei neg rlineto
+$pwid neg 0 rlineto 0 $phei rlineto clip @np
+$pn cvlit load aload pop 7 -1 roll 5 index sub
+7 -1 roll 3 index sub translate/$ctm matrix currentmatrix def
+@ep pop pop pop pop}{pop pop}ifelse @rs}bd/@th{@sft
+0 1 $tly 1 sub{dup $psx mul $tx add{dup $llx gt{$pwid sub}{exit}ifelse
+}loop exch $phei mul $ty exch sub 0 1 $tlx 1 sub{$pwid mul
+3 copy 3 -1 roll add exch @tp pop}for pop pop}for}bd
+/@tv{@sft 0 1 $tlx 1 sub{dup $pwid mul $tx add
+exch $psy mul $ty exch sub{dup $ury lt{$phei add}{exit}ifelse}loop
+0 1 $tly 1 sub{$phei mul 3 copy sub @tp pop}for
+pop pop}for}bd/@pf{@gs $ctm setmatrix $pm concat
+@stb @gs ColorSeparationMode 0 eq{1 setgray eofill}{
+$o 0 0 0 0 0 (Black) @spc{eofill}if}ifelse
+@gr eoclip Bburx Bbury $pm itransform/$tury xd/$turx xd
+Bbllx Bblly $pm itransform/$tlly xd/$tllx xd
+/$wid $turx $tllx sub def/$hei $tury $tlly sub def
+$wid 0 gt $hei 0 gt and{$pn cvlit load aload pop
+/$pd xd 3 -1 roll sub/$phei xd exch sub/$pwid xd
+/$tlx $wid $pwid div ceiling 1 add def/$tly $hei $phei div ceiling 1 add def
+$psx 0 eq{@tv}{@th}ifelse}if @gr @np}bd/@dlt{ColorSeparationMode 0 eq{
+/$dc $toc $tot mul $frc $frt mul dup/$c xd sub $fst 1 sub div def
+/$dm $tom $tot mul $frm $frt mul dup/$m xd sub $fst 1 sub div def
+/$dy $toy $tot mul $fry $frt mul dup/$y xd sub $fst 1 sub div def
+/$dk $tok $tot mul $frk $frt mul dup/$k xd sub $fst 1 sub div def
+true}{$o $frc $frm $fry $frk $frt $frn @spc
+dup{/$frk 1 currentgray sub def}{/$frk 0 def}ifelse
+$o $toc $tom $toy $tok $tot $ton @spc dup{/$tok 1 currentgray sub def}
+{/$tok 0 def}ifelse or dup{/$c 0 def/$m 0 def/$y 0 def/$k $frk def
+/$dc 0 def/$dm 0 def/$dy 0 def/$dk $tok $frk sub $fst 1 sub div def}if
+}ifelse}bd/@ftl{1 index 4 index sub dup $pad mul dup/$pdw xd
+2 mul sub $fst div/$wid xd 2 index sub/$hei xd
+pop translate $c $m $y $k 4 copy ColorSeparationMode 0 ne
+{1 exch sub setgray pop pop pop}{setcmykcolor}ifelse
+0 0 moveto 0 $hei lineto $pdw $hei lineto $pdw 0 lineto 0 0 lineto fill
+$pdw 0 translate $fst{4 copy ColorSeparationMode 0 ne
+{1 exch sub setgray pop pop pop}{setcmykcolor}ifelse
+0 0 moveto 0 $hei lineto $wid $hei lineto $wid 0 lineto 0 0 lineto fill
+$wid 0 translate $dk add 4 1 roll $dy add 4 1 roll
+$dm add 4 1 roll $dc add 4 1 roll}repeat $dk sub 4 1 roll
+$dy sub 4 1 roll $dm sub 4 1 roll $dc sub 4 1 roll
+ColorSeparationMode 0 ne{1 exch sub setgray pop pop pop}
+{setcmykcolor}ifelse 0 0 moveto 0 $hei lineto $pdw $hei lineto $pdw 0 lineto 0 0 lineto fill
+}bd/@ftr{1 index 4 index sub dup $rox mul/$row xd
+2 div 1 index 4 index sub dup $roy mul/$roh xd
+2 div 2 copy dup mul exch dup mul add sqrt
+$row dup mul $roh dup mul add sqrt add dup/$hei xd $fst div/$wid xd
+4 index add $roh add exch 5 index add $row add
+exch translate pop pop pop pop currentflat 5 mul setflat
+$c $m $y $k 4 copy ColorSeparationMode 0 ne
+{1 exch sub setgray pop pop pop}{setcmykcolor}ifelse
+$wid 0 moveto 0 0 $hei 0 360 arc fill 1.0 $pad 2 mul sub dup scale
+$fst{4 copy ColorSeparationMode 0 ne{1 exch sub setgray pop pop pop}
+{setcmykcolor}ifelse $wid 0 moveto 0 0 $hei 0 360 arc fill
+/$hei $hei $wid sub def $dk add 4 1 roll $dy add 4 1 roll
+$dm add 4 1 roll $dc add 4 1 roll}repeat pop pop pop pop}bd
+/@ff{@gs @dlt{$ctm setmatrix eoclip newpath Bbllx Bblly moveto
+Bbllx Bbury lineto Bburx Bbury lineto Bburx Bblly lineto
+$fan rotate pathbbox newpath $fty 1 eq{@ftr}{@ftl}ifelse}if
+@gr @np}bd/@Pf{@sv ColorSeparationMode 0 eq $ink 3 eq or{$ctm setmatrix
+72 1000 div dup matrix scale dup concat dup Bburx exch Bbury exch itransform
+ceiling cvi/Bbury xd ceiling cvi/Bburx xd Bbllx exch Bblly exch itransform
+floor cvi/Bblly xd floor cvi/Bbllx xd $Prm aload pop
+$Psn load exec}{1 setgray eofill}ifelse @rs
+@np}bd/@ftx{{(0) dup 3 -1 roll 0 exch put
+@gs true charpath currentpoint $ctm setmatrix
+@@txt @gr @np moveto $tr 0 rmoveto}forall pop}bd
+/@sm{/$ctm $ctm currentmatrix def}bd/@lorg{$lx $ly moveto
+/$ly $ly $le sub def}bd/@ft{matrix currentmatrix 3 1 roll
+$sdf{$scf $sca $scp @ss}if $fil 1 eq{/@@txt/@pf ld @ftx}{$fil 2 eq
+{/@@txt/@ff ld @ftx}{$fil 3 eq{/@@txt/@Pf ld @ftx}{@scc
+{dup $tr exch 0 exch ashow}if pop pop}ifelse}ifelse}ifelse
+$sdf{$dsf $dsa $dsp @ss}if setmatrix}bd/@st{
+matrix currentmatrix 3 1 roll $SDF{$SCF $SCA $SCP @ss}if
+@SCC{{(0) dup 3 -1 roll 0 exch put @gs true charpath currentpoint
+$ctm setmatrix $ptm concat stroke @gr moveto $tr 0 rmoveto}forall
+pop}{pop pop}ifelse $SDF{$dsf $dsa $dsp @ss}if
+setmatrix}bd/@pt{dup length exch}bd/@te{@pt
+@lorg @ft cleartomark [}bd/@tr{@pt @lorg @st cleartomark [}bd
+/@ta{@pt @lorg 2 copy @gs @ft @gr @st cleartomark [}bd
+/@t@a{@pt @lorg 2 copy @gs @st @gr @ft cleartomark [}bd
+/g{1 exch sub/$k xd/$c 0 def/$m 0 def/$y 0 def/$t 1 def/$n _ def/$fil 0 def
+}bd/G{1 exch sub/$K xd/$C 0 def/$M 0 def/$Y 0 def/$T 1 def/$N _ def}bd
+/k{/$k xd/$y xd/$m xd/$c xd/$t 1 def/$n _ def/$fil 0 def}bd
+/K{/$K xd/$Y xd/$M xd/$C xd/$T 1 def/$N _ def}bd
+/x{1 exch sub/$t xd/$n xd/$k xd/$y xd/$m xd/$c xd/$fil 0 def}bd
+/X{1 exch sub/$T xd/$N xd/$K xd/$Y xd/$M xd/$C xd}bd
+/d/setdash ld/i{dup 0 ne{setflat}{pop}ifelse}bd
+/j/setlinejoin ld/J/setlinecap ld/M/setmiterlimit ld
+/w/setlinewidth ld/O{/$o xd}bd/R{/$O xd}bd
+/c/curveto ld/C/c ld/v{4 -2 roll 2 copy 6 -2 roll curveto}bd
+/V/v ld/y{2 copy curveto}bd/Y/y ld/l/lineto ld
+/L/l ld/m/moveto ld/n/newpath ld/N/newpath ld
+/F{matrix currentmatrix $sdf{$scf $sca $scp @ss}if
+$fil 1 eq{@pf}{$fil 2 eq{@ff}{$fil 3 eq{@Pf}{@scc{eofill}{@np}ifelse
+}ifelse}ifelse}ifelse $sdf{$dsf $dsa $dsp @ss}if
+setmatrix}bd/f{@cp F}bd/S{matrix currentmatrix
+$ctm setmatrix $SDF{$SCF $SCA $SCP @ss}if @SCC{$skm currentmatrix
+$ptm concat stroke setmatrix}{@np}ifelse $SDF{$dsf $dsa $dsp @ss}if
+setmatrix}bd/s{@cp S}bd/B{@gs F @gr S}bd/b{@cp B}bd
+/W{eoclip}bd/p{/$pm xd 7{pop}repeat/$pyf xd/$pxf xd
+/$pn xd/$fil 1 def}bd/P{11{pop}repeat}bd/z{/$al xd
+/$tr xd/$le xd exch findfont exch scalefont setfont}bd
+/Z{dup type 0 type eq{/$bDir xd}if findfont
+dup maxlength 1 add dict exch dup{1 index/FID ne{3 index
+3 1 roll put}{pop pop}ifelse}forall pop dup dup/Encoding get
+256 array copy dup/$fe xd/Encoding exch put
+dup/Fontname 3 index put 3 -1 roll dup length 0 ne{0 exch{
+dup type 0 type eq{exch pop}{$fe exch 2 index exch put
+1 add}ifelse}forall pop}if definefont pop}bd
+/e{@sm concat [/t{@te}def}bd/r{@sm concat [/t{@tr}def}bd
+/o{@sm concat [/t{pop}def}bd/a{@sm concat [/t{@ta}def}bd
+/t{@te}def/T{cleartomark @np/$lx 0 def/$ly 0 def
+$ctm setmatrix/$ttm matrix def}bd/u{}bd/U{}bd
+/A{pop}bd/H{/$h true def}bd/h{@cp H}bd/q/@gs ld
+/Q/@gr ld/E{5 array astore exch cvlit exch def}bd
+/`{}bd/~{}bd/@{}bd/&{}bd/CorelDrawRencodeVect [
+16#80/grave/circumflex/tilde/dotlessi/florin/quotedblleft/quotedblright/guilsinglleft
+16#88/guilsinglright/fi/fl/dagger/daggerdbl/endash/periodcentered/breve
+16#90/quotedblbase/ellipsis/perthousand/trademark/Pt/fractionbar
+16#98/divide 16#a1/exclamdown/cent/sterling/currency/yen/bar/section
+16#a8/dieresis/copyright/ordfeminine/guillemotleft/logicalnot/emdash/registered/overbar
+16#b0/ring/plusminus/twosuperior/threesuperior/acute/mu/paragraph/bullet
+16#b8/cedilla/onesuperior/ordmasculine/guillemotright/onequarter/onehalf/threequarters/questiondown
+16#c0/Agrave/Aacute/Acircumflex/Atilde/Adieresis/Aring/AE/Ccedilla
+16#c8/Egrave/Eacute/Ecircumflex/Edieresis/Igrave/Iacute/Icircumflex/Idieresis
+16#d0/Eth/Ntilde/Ograve/Oacute/Ocircumflex/Otilde/Odieresis/OE
+16#d8/Oslash/Ugrave/Uacute/Ucircumflex/Udieresis/Yacute/Thorn/germandbls
+16#e0/agrave/aacute/acircumflex/atilde/adieresis/aring/ae/ccedilla
+16#e8/egrave/eacute/ecircumflex/edieresis/igrave/iacute/icircumflex/idieresis
+16#f0/eth/ntilde/ograve/oacute/ocircumflex/otilde/odieresis/oe
+16#f8/oslash/ugrave/uacute/ucircumflex/udieresis/yacute/thorn/ydieresis
+] def/@cc{currentfile $dat readhexstring pop}bd
+/@ii{concat 3 index 3 index m 3 index 1 index l
+2 copy l 1 index 3 index l 3 index 3 index l
+clip pop pop pop pop}bd/@E{/Bbury xd/Bburx xd
+/Bblly xd/Bbllx xd}bd/@c{@cp}bd/@p{/$fil 1 def
+/$pm xd/$psy xd/$psx xd/$pyf xd/$pxf xd/$pn xd}bd
+/@P{/$fil 3 def/$Psn xd array astore/$Prm xd}bd
+/@k{/$fil 2 def/$roy xd/$rox xd/$pad xd/$fty xd/$fan xd
+$fty 1 eq{/$fan 0 def}if/$tok xd/$toy xd/$tom xd/$toc xd
+/$frk xd/$fry xd/$frm xd/$frc xd/$frn _ def/$frt 1 def/$ton _ def/$tot 1 def
+}bd/@x{/$fil 2 def/$roy xd/$rox xd/$pad xd
+/$fty xd/$fan xd 1 exch sub/$tot xd/$ton xd/$tok xd/$toy xd/$tom xd/$toc xd
+1 exch sub/$frt xd/$frn xd/$frk xd/$fry xd/$frm xd/$frc xd}bd
+/@i{@sm @gs @ii 5 index 1 ne{@gs 1 g F @gr}if
+1 eq 5 index 1 eq and{@gs $ctm setmatrix F @gr}if
+@np/$ury xd/$urx xd/$lly xd/$llx xd/$bts xd
+/$hei xd/$wid xd/$dat $wid $bts mul 8 div ceiling cvi string def
+$bts 1 eq{@SCC/$frg xd}{1 G @SCC/$frg xd}ifelse
+$frg{$SDF{$SCF $SCA $SCP @ss}if $llx $lly translate
+$urx $llx sub $ury $lly sub scale $wid $hei abs
+$bts 1 eq{false}{$bts}ifelse [ $wid 0 0 $hei neg 0
+$hei 0 gt{$hei}{0}ifelse]/@cc load $bts 1 eq{imagemask}{image}ifelse
+$SDF{$dsf $dsa $dsp @ss}if}{$hei{@cc pop}repeat}ifelse
+@gr $ctm setmatrix}def/@M {@sv}bd/@N{/@cc{}def
+12 -1 roll neg 12 1 roll @i @rs}bd/@I{@sm @gs
+@ii @np/$ury xd/$urx xd/$lly xd/$llx xd/$ncl xd
+/$bts xd/$hei xd/$wid xd/$dat $wid $bts mul $ncl mul 8 div ceiling cvi string def
+$llx $lly translate $urx $llx sub $ury $lly sub scale
+$wid $hei $bts [ $wid 0 0 $hei neg 0 $hei]/@cc load
+false $ncl colorimage @gr $ctm setmatrix}bd
+/@t{/$lx 0 def/$ly 0 def/$stm $stm currentmatrix def
+3 1 roll translate $ttm concat 1 exch t $stm setmatrix}def
+/@n{/$ttm exch matrix rotate def}bd/@z{ exch findfont exch scalefont setfont
+}bd/@s{}bd/@l{}bd/@B{@gs S @gr F}bd/@b{@cp @B}bd
+/@a{@sm concat [/t{@t@a}def}bd/@w{5 2 roll dup/$pan xd
+matrix rotate/$ptm xd matrix scale $ptm dup concatmatrix/$ptm xd
+1 eq{$ptm exch dup concatmatrix/$ptm xd}{pop}ifelse
+1 w}bd/@g{1 eq dup/$sdf xd{/$scp xd/$sca xd
+/$scf xd}if}bd/@G{1 eq dup/$SDF xd{/$SCP xd
+/$SCA xd/$SCF xd}if}bd/@D{3 copy @ss/$dsp xd
+/$dsa xd/$dsf xd}bd/@j{@sv @np}bind def/@J{@rs}bind def
+/@sep{/ColorSeparationMode where{pop}{/ColorSeparationMode 0 def
+/CurrentInkName (Composite) def}ifelse ColorSeparationMode 0 eq
+{/CurrentInkName (Composite) def}if/CurrentInkName where{pop}{
+/CurrentInkName (Composite) def}ifelse CurrentInkName (Composite) eq{/$ink -1 def}
+{CurrentInkName (Cyan) eq{/$ink 0 def} {CurrentInkName (Magenta) eq{/$ink 1 def}
+{CurrentInkName (Yellow) eq{/$ink 2 def} {CurrentInkName (Black) eq{/$ink 3 def}
+{/$ink 4 def}ifelse}ifelse}ifelse}ifelse}ifelse}bd
+@sep/@whi{@gs -72000 dup moveto -72000 72000 lineto
+72000 dup lineto 72000 -72000 lineto closepath 1 setgray fill
+@gr}bd/@neg{ [{1 exch sub}/exec cvx currenttransfer/exec cvx] cvx settransfer
+@whi}bd/@reg{[] 0 d 0 setgray .3 setlinewidth
+2 copy 5.4 0 360 arc closepath 2 copy moveto 9 0 rlineto
+2 copy moveto -9 0 rlineto 2 copy moveto 0 9 rlineto
+moveto 0 -9 rlineto stroke}bd/leftbracket{(\050)}def
+/rightbracket{(\051)}def
+
+%%EndProlog
+%%BeginSetup
+11.4737 setmiterlimit
+1.00 setflat
+/$fst 128 def
+
+%%EndSetup
+@sv
+/$ctm matrix currentmatrix def
+u
+%%Note: Object
+45.22 528.19 78.98 558.14 @E
+0 J 0 j [] 0 d 0 R 0 @G
+0.00 0.00 0.00 1.00 K
+1.01 1.01 0.00 [1.00000 0.00000 0.00000 1.00000 0.00000 0.00000] 0 @w
+%%CURV 106
+73.30 539.78 m
+73.08 538.42 72.22 537.26 71.78 536.33 C
+72.79 534.67 73.73 531.43 74.81 530.64 C
+74.59 530.64 77.04 528.84 73.87 529.06 C
+73.08 529.34 73.08 530.93 70.20 533.81 C
+69.70 533.74 70.56 530.57 71.50 529.63 c
+73.15 528.19 70.27 528.55 70.13 528.62 C
+68.98 529.34 68.62 534.60 67.03 536.26 c
+66.24 537.19 65.16 536.98 64.30 536.90 C
+63.22 536.62 60.62 537.19 60.55 534.02 C
+60.62 532.66 62.14 530.21 62.86 529.78 c
+65.30 528.41 62.06 528.34 61.70 528.77 C
+61.13 529.34 60.19 530.64 59.26 531.65 C
+57.74 532.44 56.38 533.66 56.02 534.96 C
+54.94 534.74 53.86 534.17 53.64 533.23 C
+53.42 532.22 53.86 531.58 54.86 530.14 C
+56.02 529.85 56.38 529.27 56.02 528.98 c
+55.87 528.84 53.71 528.62 53.57 528.91 C
+52.70 529.49 51.70 531.86 51.19 533.16 c
+50.90 533.88 49.97 535.82 51.55 537.77 C
+51.98 538.49 51.91 539.86 51.77 540.65 c
+51.55 541.94 51.55 542.74 52.42 544.46 C
+49.75 546.77 45.22 551.23 49.61 557.14 C
+50.11 557.64 51.55 558.14 50.76 556.27 C
+49.82 553.68 46.66 551.45 53.42 546.19 C
+54.50 546.91 58.97 546.48 60.48 546.19 c
+64.66 545.33 65.52 545.33 68.40 546.05 C
+68.76 546.19 68.83 547.99 70.34 549.22 C
+70.06 550.15 72.00 551.45 72.22 552.53 C
+72.65 553.39 73.66 550.73 73.66 550.66 C
+73.58 551.23 74.66 552.31 74.81 552.96 C
+75.74 553.25 75.10 550.94 75.89 549.50 c
+76.32 548.93 76.68 549.07 77.11 547.70 C
+77.47 546.34 78.98 545.18 76.54 543.89 c
+75.17 543.17 74.59 543.31 73.58 542.88 C
+73.58 542.23 73.51 540.79 73.30 539.78 c
+@c
+S
+U
+@rs
+%%Trailer
+ end
diff --git a/macros/latex/required/graphics/changes.txt b/macros/latex/required/graphics/changes.txt
new file mode 100644
index 0000000000..9b3edac553
--- /dev/null
+++ b/macros/latex/required/graphics/changes.txt
@@ -0,0 +1,945 @@
+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.
+=======================================================================
+2017-06-25 Joseph Wright <latex-bugs@latex-project.org>
+
+ * New decodearray key, adopted from older pdftex.def
+
+2017-05-31 David Carlisle, Joseph Wright <latex-bugs@latex-project.org>
+
+ * graphics.dtx: Generalize bounding box reader for use in other formats than EPS
+ * graphicsx.dtx: Additional options, moved from pdftex.def
+
+
+2017-04-14 David Carlisle <latex-bugs@latex-project.org>
+
+ * graphics.dtx: modify \Gscale@box for math mode usage
+ https://github.com/latex3/graphics-def/issues/6
+
+2017-03-17 David Carlisle <latex-bugs@latex-project.org>
+
+ * graphics.dtx: add \leavevmode to \includegraphics
+ so that \everypar is cleared. (The \leavevmode in \Gin@setfile is
+ too late for this use, but has been left for compatibility.)
+
+2016-12-23 David Carlisle <latex-bugs@latex-project.org>
+
+ * grfguide.tex: fix the a.ps example file to match the Bounding box
+ change from 2014 (Rolf Niepraschk)
+
+2016-11-18 David Carlisle <latex-bugs@latex-project.org>
+
+ * grfguide.tex: Updates to drivers section, and add a note about xcolor.
+
+2016-10-09 David Carlisle <latex-bugs@latex-project.org>
+
+ * graphics.dtx: Avoid arithmetic overflow on very small lengths
+ eg 5sp/2sp https://tex.stackexchange.com/q/328825
+
+2016-08-11 David Carlisle <latex-bugs@latex-project.org>
+
+ * rotating.dtx: Fix name of examples file reference in the
+ documentation (rotex.tex not examples.tex)
+
+2016-07-10 David Carlisle <latex-bugs@latex-project.org>
+
+ * graphics-drivers.ins: stop generating dvips.def
+ (moved to graphics-def)
+
+2016-06-17 David Carlisle <latex-bugs@latex-project.org>
+
+ * drivers.dtx: guards for contributed packages and plain TeX.
+
+2016-06-02 David Carlisle <latex-bugs@latex-project.org>
+
+ * graphics.dtx, color.dtx, drivers.dtx: add pagesize special support to dvips
+ option to match pdftex behaviour and add setpagesize and
+ nosetpagesize options to color and graphics packages to enable or
+ disable this feature for all drivers.
+
+2016-05-22 David Carlisle <latex-bugs@latex-project.org>
+
+ * rotating.dtx: add from rotating distribution
+ * rotex.tex: add from rotating distribution (was example.tex}
+ * cat.eps: add from rotating distribution
+ * grfguide.tex: list the rotating package.
+
+2016-05-09 David Carlisle <latex-bugs@latex-project.org>
+
+ * graphics.dtx, color.dtx: add dvisvgm option (Till Tantau)
+
+2016-01-04 David Carlisle <latex-bugs@latex-project.org>
+
+ * drivers.dtx: dvips can deal natively with compressed eps
+ (was in texlive's graphics.cfg)
+
+2016-01-03 David Carlisle <latex-bugs@latex-project.org>
+
+ * graphics.dtx, color.dtx: add luatex option. (luatex.def to be
+ distributed separately.)
+
+ * trig.dtx: make pre-calculated trig values expand to digits
+ rather than use \chardef
+
+2015-12-30 David Carlisle <latex-bugs@latex-project.org>
+
+ * drivers.dtx: dvips can deal natively with compressed eps
+ (was in texlive's graphics.cfg)
+
+2015-04-02 Joseph Wright <latex-team@latex-project.org>
+
+ * Update CTAN link in README
+
+2015-03-27 David Carlisle <latex-bugs@@latex-project.org>
+
+ * Updating copyright notices etc
+
+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-project.org>
+
+ * drivers.dtx, graphics.dtx, graphicx.dtx, keyval.dtx, trig.dtx:
+ Fixed typos in documentation found by Karl Berry.
+
+2014-10-14 <Frank.Mittelbach@latex-project.org>
+
+ * graphics.dtx: Fixed typo in error message.
+
+2014-05-08 David Carlisle <david.carlisle@latex-project.org>
+
+ * keyval.dtx: Revert change to {} parsing.
+
+
+2014-04-26 David Carlisle <david.carlisle@latex-project.org>
+
+ * grfguide.tex: Changes to allow generation of grfguide.pdf via
+ pdflatex: include a.pdf in a filecontents environment and adjust
+ examples to use a modified bounding box starting at 0 0 rather
+ than 100 100.
+
+
+2014-04-25 David Carlisle <david.carlisle@latex-project.org>
+
+ * showkeys.dtx: \leavemode and \long added for
+ graphics/1521, graphics/4296
+
+ * keyval.dtx: add \long on internal parsing macros to allow \par
+ in values, Only strip one {} group not two from values.
+ graphics/3446
+
+2014-04-23 David Carlisle <david.carlisle@latex-project.org>
+
+ * color.dtx: Add \nopagecolor, graphics/3873
+
+ * drivers.dtx: Add \nopagecolor, graphics/3873
+
+2006-02-20 Morten Hoegholm <latex-bugs@latex-project.org>
+
+ * graphics.dtx: Added demo option in graphics.
+
+2005-11-14 Morten Hoegholm <latex-bugs@latex-project.org>
+
+ * 00readme.txt: Updated to reflect the changes.
+
+ * color.dtx: Added support for dvipdfmx and XeTeX.
+
+ * Makefile: Remove pstcol and add graphics-drivers.ins.
+
+ * graphics-drivers.ins: New file for installation of driver files.
+
+ * grfguide.tex: Updated documentation to reflect changes in the
+ distribution of driver files. Added dvipdfmx and XeTeX to list of
+ options.
+
+ * graphics.ins: Removed pstcol (pr/3735) and driver files
+ installation.
+
+ * graphics.dtx: Added support for dvipdfmx and XeTeX.
+
+2004-10-21 Rainer Schoepf <latex-bugs@latex-project.org>
+
+ * grfguide.pdf: Added creation of this file, from grfguide.ps.
+
+2001-07-07 Chris Rowley <latex-bugs@latex-project.org>
+
+ * graphics.dtx:
+
+ Made \rotatebox long (not previously done for graphics/2908)
+
+2001-06-20 Chris Rowley <latex-bugs@latex-project.org>
+
+ * pstcol.dtx:
+
+ Added redefinitions for PSTricks (graphics/3233)
+
+2001-06-07 Chris Rowley <latex-bugs@latex-project.org>
+
+ * graphics.dtx:
+
+ Extended documentation of \DeclareGraphicsExtensions
+ (graphics/3228}
+
+1999-02-17 David Carlisle <latex-bugs@latex-project.org>
+
+ * dvipdfm.def: lppl (Agreed with Mark Wicks)
+
+1999-02-16 David Carlisle <latex-bugs@latex-project.org>
+
+ * grfguide.tex: lppl
+
+ * graphics.ins: lppl
+
+ * epsfig.dtx: lppl
+
+ * textures.def: lppl (Agreed with Art Ogawa)
+
+ * drivers.dtx: lppl
+
+ * lscape.dtx: lppl
+
+ * pstcol.dtx: lppl
+
+ * color.dtx: lppl
+
+ * graphicx.dtx: lppl
+
+ * 00readme.txt: lppl
+
+ * graphics.dtx: lppl
+
+1999-01-13 David Carlisle <latex-bugs@latex-project.org>
+
+ * grfguide.tex: dvipdfm and unknownkeysallowed options.
+
+ * drivers.dtx: documentation corrections.
+
+ * color.dtx: dvipdfm option
+
+ * graphics.dtx: dvipdfm option
+
+ * dvipdfm.def: (from Sebastian) For dvipdfm dvi->pdf driver.
+
+1999-01-10 David Carlisle <latex-bugs@latex-project.org>
+
+ * graphics.ins: don't generate .def files for unsupported
+ drivers
+
+ * graphicx.dtx: new option (passed to graphicx)
+
+ * keyval.dtx: new options to not generate error on unknown
+ keys.
+
+1999-01-08 David Carlisle <latex-bugs@latex-project.org>
+
+ * pdftex.def: new version (from https://www.tug.org)
+
+1999-01-07 David Carlisle <latex-bugs@latex-project.org>
+
+ * graphics.dtx: \Gscale@box@dd(dd) made long. graphics/2908
+ \@makeother\- added. graphics/2846
+
+1999-01-07 David Carlisle <latex-bugs@latex-project.org>
+
+ * graphics.dtx: \Gscale@box@dd(dd) made long. graphics/2908
+ \@makeother\- added. graphics/2846
+
+1999-01-07 David Carlisle <latex-bugs@latex-project.org>
+
+ * graphics.dtx: \Gscale@box@dd(dd) made long. graphics/2908
+ \@makeother\- added. graphics/2846
+
+1998-10-30 David Carlisle <latex-bugs@latex-project.org>
+
+ * vtex.def: new version from micropress
+
+1998-06-05 David Carlisle <latex-bugs@latex-project.org>
+
+ * pdftex.def: update for more recent pdftex (from Sebastian).
+
+ * keyval.dtx: make keyval safe if \@tempc is an \if (As
+ happens if you load amsmath and color packages, in that order)
+
+1998-05-27 David Carlisle <latex-bugs@latex-project.org>
+
+ * grfguide.tex: vtex option
+
+ * color.dtx: vtex option
+
+ * graphics.dtx: vtex option
+
+ * vtex.def: Add file (supplied by MicroPress, Inc).
+
+1998-05-03 David Carlisle <latex-bugs@latex-project.org>
+
+ * drivers.dtx: update of dvipsone.def from Berthold Horn.
+
+1997-11-10 David Carlisle <latex-bugs@latex-project.org>
+
+ * trig.dtx: Remove an ancient email address of mine.
+
+ * keyval.dtx: CHANGE so that # may appear in <value>s without
+ needing to be doubled. NOTE This will require a change if
+ anybody has used the comand= key in graphicx, the only key
+ currently distributed likely to require # in its argument. A
+ setting such as `command = uncompress ##1' now will need
+ changing to just use one #. Also fix brace handling so a
+ value of {abc}{xyz} is correctly handled. (Old version passed
+ abc{xyz}). Remove an ancient email address of mine.
+
+1997-09-09 David Carlisle <latex-bugs@latex-project.org>
+
+ * graphics.ins: Comment out generation of oztex.def.
+
+ * graphics.dtx: [oztex] == [dvips]
+
+ * color.dtx: [oztex] == [dvips]
+
+ * drivers.dtx: merge oztex and dvips support (for oztex 3.x).
+
+1997-09-02 David Carlisle <latex-bugs@latex-project.org>
+
+ * graphics.dtx: allow TAB in BoundingBox
+ comments. graphics/2587
+
+1997-06-17 David Carlisle <latex-bugs@latex-project.org>
+
+ * textures.def: New one from Arthur Ogawa.
+
+1997-06-09 David Carlisle <latex-bugs@latex-project.org>
+
+ * graphicx.dtx: Initialise ext= key to empty, so type= may be
+ used without specifying ext, for Sebastian.
+
+1997-06-07 David Carlisle <latex-bugs@latex-project.org>
+
+ * Makefile: pdftex.def
+
+ * grfguide.tex: pdftex option
+
+ * 00readme.txt: pdftex.tex driver file
+
+ * color.dtx: pdftex option
+
+ * graphics.dtx: pdftex option
+
+ * pdftex.def: add this file for Han The Thanh's TeX variant.
+
+1997-02-20 David Carlisle <latex-bugs@latex-project.org>
+
+ * graphics.ins: dvipdf missed out. graphics/2420
+
+1997-01-07 David Carlisle <latex-bugs@latex-project.org>
+
+ * color.dtx: Make errors just info messages to the log in the
+ monocrome option. graphics/2350
+
+1996-12-12 David Carlisle <latex-bugs@latex-project.org>
+
+ * drivers.dtx: new dvipsone eps code (Code from Berthold Horn)
+
+1996-12-09 David Carlisle <latex-bugs@latex-project.org>
+
+ * 00readme.txt: Remove grfguide.ps (it's in latex/doc on ctan)
+
+ * Makefile: Remove grfguide.ps (it's in latex/doc on ctan)
+
+ * grfguide.tex: Assorted improvements.
+
+1996-11-18 David Carlisle <latex-bugs@latex-project.org>
+
+ * drivers.dtx: Minor changes to dvipdf.def (Sergey Lesenko).
+
+1996-11-05 David Carlisle <latex-bugs@latex-project.org>
+
+ * epsfig.dtx: Support active ! for graphics/2302
+
+1996-11-02 David Carlisle <latex-bugs@latex-project.org>
+
+ * 00readme.txt: add old docstrip warning.
+
+1996-10-31 David Carlisle <latex-bugs@latex-project.org>
+
+ * textures.def: add pstricks compatibity code from original
+ textures.def
+
+ * drivers.dtx: tcidvi code supporting viewport/trim/clip.
+
+ * graphicx.dtx: viewport/trim code now saves original bb
+ coords.
+
+ * color.dtx: add dvipdf
+
+ * graphics.dtx: add dvipdf
+
+ * drivers.dtx: add dvipdf (after code from Sergey Lesenko).
+
+1996-10-30 David Carlisle <latex-bugs@latex-project.org>
+
+ * drivers.dtx: add truetex and tcidvi drivers. Add literal
+ postscript specials to drivers that support it. Add RGB
+ (0-255 integer rgb) model to all drivers.
+
+ * graphics.ins: add truetex (Kinch) and tcidvi (Scientific
+ Word) drivers.
+
+1996-10-29 David Carlisle <latex-bugs@latex-project.org>
+
+ * graphics.ins: new style for docstrip 2.4.
+
+ * grfguide.tex: Describe new options, improve descriptions of
+ \graphicspath (for graphics/2294) and \DeclareGraphicsRule.
+ Describe how to add new driver options in a cfg file.
+
+ * graphicx.dtx: Add hiresbb key to \includegraphics.
+
+ * graphics.dtx: Add tcidvi and truetex options, comment out
+ some old drivers. Add hiresbb package option for
+ %%HiResBoundingBox.
+
+ * color.dtx: add missing \colors@false to monochrome option.
+ Add tcidvi and truetex drivers. Comment out some old drivers.
+
+1996-10-28 David Carlisle <latex-bugs@latex-project.org>
+
+ * pstcol.dtx: clean up documentation a bit.
+
+ * Makefile: Add SCRIPTDIR
+
+1996-09-16 David Carlisle <latex-bugs@latex-project.org>
+
+ * color.dtx: add debugshow option, mainly so I can go
+ \usepackage[debugshow]{graphics,color} without color
+ complaining
+
+ * graphics.dtx: stop infinite loop if requested size is zero
+ graphics/2259.
+
+1996-08-05 David Carlisle <latex-bugs@latex-project.org>
+
+ * graphicx.dtx: Missing % for /2244
+
+1996-06-11 David Carlisle <latex-bugs@latex-project.org>
+
+ * graphics.ins: pctex32
+
+1996-06-10 David Carlisle <latex-bugs@latex-project.org>
+
+ * graphics.dtx: use \@gtempa not \g@tempa graphics/2090
+
+ * graphicx.dtx: Fix misplaced = in changes
+ entry. graphics/2034
+
+1996-05-29 David Carlisle <latex-bugs@latex-project.org>
+
+ * 00readme.txt: Tidy up.
+
+ * graphicx.dtx: Declare it version 1 (no other change).
+
+ * graphics.dtx: Declare it version 1 (no other change).
+
+ * color.dtx: Declare it version 1 (no other change).
+
+ * drivers.dtx: Change arithmetic in dvips' \Ginclude@eps (and
+ the identical code for pctex32) to avoid overflow on very
+ large posters. (Andreas Schott)
+
+1996-04-11 David Carlisle <latex-bugs@latex-project.org>
+
+ * drivers.dtx: Add pctex32 driver file based on code from pti.
+ Add support for wmf in Y&Y's dviwindo.
+
+ * epsfig.dtx: allow space after [ in \epsfbox bb argument.
+ add `silent' key to \epsfig (ignored).
+
+1996-02-20 David Carlisle <latex-bugs@latex-project.org>
+
+ * grfguide.ps: Bad dvips configuration forcing A4 paper fixed.
+
+ * textures.def: \gread -> \gread@ typo fixed.
+
+ * graphics.dtx: \gread -> \gread@ typo fixed.
+
+ * graphics.ins: dvi2ps dvitops dvilaser dvialw added back to
+ the .ins file, so the code gets extracted
+
+1995-12-07 David Carlisle <latex-bugs@latex-project.org>
+
+ * color.dtx: Remove \showhyphens and \underbar Now all
+ commands are colour safe already in the kernel. CHANGE Add
+ \leavevmode to \textcolor so that it works out right at the
+ start of a \parbox[t] (and other places)
+
+ * grfguide.tex: Bring up to date.
+
+1995-12-06 David Carlisle <latex-bugs@latex-project.org>
+
+ * graphicx.dtx: Use \Gin@exclamation to save active !
+ problems. Rename key to keepaspectratio.
+
+ * graphics.dtx: Add \Gin@exclamation for French graphicx
+ mainly
+
+1995-12-04 David Carlisle <latex-bugs@latex-project.org>
+
+ * drivers.dtx: New dviwin code after correspondence with
+ Hippocrates Sendoukas.
+
+ * graphics.ins: remove textures.def generation
+
+ * textures.def: New version, not generated from drivers.dtx.
+ Code supplied by Arthur Ogawa.
+
+1995-11-10 David Carlisle <latex-bugs@latex-project.org>
+
+ * graphics.ins: New version for concurrent docstrip
+
+ * graphicx.dtx: Support height= and width= better for bitmap
+ formats where natural size not known to LaTeX, but known to
+ the driver.
+
+ * graphics.dtx: Support height= and width= better for bitmap
+ formats where natural size not known to LaTeX, but known to
+ the driver.
+
+1995-10-31 David Carlisle <latex-bugs@latex-project.org>
+
+ * lscape.dtx: \StopEventually{\end{landscape}} for
+ graphics/1744
+
+1995-09-29 David Carlisle <latex-bugs@latex-project.org>
+
+ * graphics.dtx: Support isoscale code in \Gscale@box@dddd
+
+ * graphicx.dtx: Support new isoscale key for \includegraphics.
+
+1995-09-28 David Carlisle <latex-bugs@latex-project.org>
+
+ * graphicx.dtx: Add origin key for \includegraphics rotation.
+
+1995-09-27 David Carlisle <latex-bugs@latex-project.org>
+
+ * graphicx.dtx: Modify \Gin@esetsize to support calc package
+
+ * graphics.dtx: Modify \Gscale@div to support calc package
+
+1995-09-22 David Carlisle <latex-bugs@latex-project.org>
+
+ * graphicx.dtx: Fix typo in natheight and natwidth keys.
+
+ * drivers.dtx: Fix bitmap support in dvips for graphics/1879
+
+1995-09-21 David Carlisle <latex-bugs@latex-project.org>
+
+ * keyval.dtx: Documentation changes for graphics/1698
+
+1995-09-18 David Carlisle <latex-bugs@latex-project.org>
+
+ * drivers.dtx: (Berthold Horn) Fix up clipping code in Y&Y
+ drivers.
+
+1995-09-11 David Carlisle <latex-bugs@latex-project.org>
+
+ * drivers.dtx: Fix up named colour support for dvipsone.
+
+1995-09-07 David Carlisle <latex-bugs@latex-project.org>
+
+ * color.dtx: Merge dvipsone and dviwindo options.
+
+ * grfguide.tex: Document the totalheight key which got omitted
+ before.
+
+ * graphics.ins: Remove generation of dviwindo.def
+
+ * drivers.dtx: Fix bounding box spec in dvipsone (should be in
+ sp) Remove generation of dviwindo.def: dviwindo option now
+ uses dvipsone.def
+
+ * graphicx.dtx: Arithmetic in viewport was wrong. (Michel
+ Goossens)
+
+ * graphics.dtx: Merge the two Y&Y options together making
+ dviwindo.def obsolete.
+
+1995-08-11 David Carlisle <latex-bugs@latex-project.org>
+
+ * grfguide.tex (section{Colour}): Refer to X Window system in
+ the approved manner.
+
+1995-06-26 David Carlisle <latex-bugs@latex-project.org>
+
+ * graphicx.dtx: Typos fixed in bb.... keys for graphics/1685
+
+1995-06-23 David Carlisle <latex-bugs@latex-project.org>
+
+ * epsfig.dtx: oops. \ifGin@viewport renamed to \ifGin@bbox
+
+1995-06-19 David Carlisle <latex-bugs@latex-project.org>
+
+ * drivers.dtx: Add \Gin@PS@raw and \Gin@PS@restored for
+ literal PostScript \specials. (cf \pstVerb and \pstverb)
+
+1995-06-16 David Carlisle <latex-bugs@latex-project.org>
+
+ * graphics.ins: Modify docstrip options for Y&Y drivers.
+
+ * epsfig.dtx: Remove forcing of dvips option (use graphics.cfg
+ to force the default driver for your site). Modify
+ \ProvidesPackage usage
+
+ * drivers.dtx: Add \AtBeginDvi around `color2' color define
+ \special. Make Y&Y drivers dvipsone and dviwindo use `color2'
+ colour support following mail message from Berthold Horn.
+
+ * color.dtx: Use #1 not ##1 in \DeclareOption, for latex/1557
+
+1995-04-27 David Carlisle <latex-bugs@latex-project.org>
+
+ * color.dtx: Move \leavevmode earlier in box commands for
+ graphics/1512
+
+1995-04-19 David Carlisle <latex-bugs@latex-project.org>
+
+ * graphics.ins: Add template generation (commented out).
+
+ * drivers.dtx: Remove \Gin@tobp, not needed now.
+
+1995-04-12 David Carlisle <latex-bugs@latex-project.org>
+
+ * grfguide.tex: Fix mention of obsolete syntax, as reported in
+ latex/1295
+
+1995-04-11 David Carlisle <latex-bugs@latex-project.org>
+
+ * graphicx.dtx: Bounding box changes to match graphics.sty.
+ Add trim viewport and totalheight keys to \includegraphics.
+
+ * graphics.dtx: Start v0.7: \leavevmode positioning. Bounding
+ box cordinates stored as macros (so can use bp) Make more
+ catcodes safe, for binary headers of eps files.
+
+1995-01-03 David Carlisle <latex-bugs@latex-project.org>
+
+ * drivers.dtx: (Chris Hamlin) Spurious #2 deleted in
+ dviwindo.def: \def\c@lor@cmyk@#1#2,#2,#3,#4,#5\@@{%
+
+1994-12-15 David Carlisle <latex-bugs@latex-project.org>
+
+ * graphics.dtx: (Denis Roegel) Extra group to keep bb settings
+ local. (Piet van Oostrum) include `.' in \Gin@ext.
+
+1994-12-12 David Carlisle <latex-bugs@latex-project.org>
+
+ * drivers.dtx: Add ln (ln03, ln05 etc) support (untested).
+
+ * graphics.dtx: Add ln (ln03, ln05 etc) support (untested).
+
+1994-11-29 David Carlisle <latex-bugs@latex-project.org>
+
+ * grfguide.tex: New \DeclareGraphicsExtensions description.
+
+ * graphicx.dtx: Modify the type and read keys to work with new
+ graphics.sty.
+
+ * drivers.dtx: Explicitly mention `.' in all file extensions,
+ to work with graphics v0.6.
+
+ * graphics.dtx: Remove Optional argument to
+ \DeclareGraphicsExtensions Remove the notion of a
+ `separator' and now specify extensions as (eg) .eps rather
+ than eps this makes it easier to work with files without
+ extension.
+
+1994-11-22 David Carlisle <latex-bugs@latex-project.org>
+
+ * color.dtx: add color@vbox, remove a load of stuff now in the
+ kernel.
+
+1994-11-16 David Carlisle <latex-bugs@latex-project.org>
+
+ * keyval.dtx: Move the <% plain> docstrip commands which were
+ being typeset by mistake (reported by Martin Schroeder)
+
+ * trig.dtx: Move the <% plain> docstrip commands which were
+ being typeset by mistake (reported by Martin Schroeder)
+
+1994-11-08 David Carlisle <latex-bugs@latex-project.org>
+
+ * color.dtx: Add \color@hbox and \color@endbox
+
+1994-11-04 David Carlisle <latex-bugs@latex-project.org>
+
+ * graphics.ins: add psprint.def (accidentally omitted)
+
+1994-11-02 David Carlisle <latex-bugs@latex-project.org>
+
+ * graphics.dtx: fix catcodes of ctrl-D and \endlinechar when
+ reading eps files.
+
+1994-10-27 David Carlisle <latex-bugs@latex-project.org>
+
+ * pstcol.dtx: add gradbegin and gradend colours.
+
+1994-10-24 David Carlisle <latex-bugs@latex-project.org>
+
+ * graphics.dtx: Modify support for ! in \resizebox (Old code
+ added to support active ! broke \width etc)
+ \DeclareGraphicsRule Check #3 (not #2) is * (Reported by
+ Arthur Ogawa). Missing \expandafter in \Gin@setfile
+ (Reported by Arthur Ogawa).
+
+ * drivers.dtx: Missing \the in dvitops \special. Reported by
+ Arthur Ogawa.
+
+1994-10-17 David Carlisle <latex-bugs@latex-project.org>
+
+ * drivers.dtx: removed xdvi.def: xdvi now calls
+ dvips,monochrome
+
+1994-10-16 David Carlisle <latex-bugs@latex-project.org>
+
+ * trig.dtx: Changed \@xc to \nin@ty (old name clashed with
+ some other package)
+
+1994-10-14 David Carlisle <latex-bugs@latex-project.org>
+
+ * grfguide.tex: Minor improvements to my English.
+
+1994-10-07 David Carlisle <latex-bugs@latex-project.org>
+
+ * drivers.dtx: Removed out of date table. Added new code for
+ pctex drivers submitted by PTI.
+
+1994-10-05 David Carlisle <latex-bugs@latex-project.org>
+
+ * lscape.dtx: converted the old 209 style to dtx form and base
+ on graphics package.
+
+ * drivers.dtx: added hsb colour to drivers that support it.
+
+1994-10-04 David Carlisle <latex-bugs@latex-project.org>
+
+ * color.dtx: Make \definecolor and \DefineNamedColor give an
+ Info message if the colour was previously defined.
+
+ * drivers.dtx: Add support for bounding box to pctex drivers,
+ remove support for scaling which did not work anyway.
+
+1994-10-03 David Carlisle <latex-bugs@latex-project.org>
+
+ * color.dtx: Add usenames option.
+
+ * graphics.dtx: Error if no driver specified.
+
+1994-09-29 David Carlisle <latex-bugs@latex-project.org>
+
+ * drivers.dtx: Modifications to fit in \DefineNamedColor.
+ textures code redone based on mail from Constantin Kahn (Who
+ owns a Mac which is and advantage when writing code for
+ textures:-)
+
+ * color.dtx (section{Defining Colours}): \DefineNamedColor Add
+ this system, after conversations with Constantin Kahn about
+ the textures support.
+
+1994-09-21 David Carlisle <latex-bugs@latex-project.org>
+
+ * drivers.dtx (section{Generic PostScript Colour}): Modify
+ textures code, to force trailing .0.
+
+1994-09-19 David Carlisle <latex-bugs@latex-project.org>
+
+ * color.dtx: small changes to \pagecolor.
+
+1994-09-15 David Carlisle <latex-bugs@latex-project.org>
+
+ * drivers.dtx: Add in pctex drivers from Sebastian.
+
+1994-09-14 David Carlisle <latex-bugs@latex-project.org>
+
+ * color.dtx: Add fix for footnote bug (should really be in
+ ltfloat/ltoutput)
+
+1994-09-13 David Carlisle <latex-bugs@latex-project.org>
+
+ * color.dtx (subsection{Coloured Boxes} New implementation of
+ \fcolorbox and \colorbox. Now share code.
+
+1994-09-12 David Carlisle <latex-bugs@latex-project.org>
+
+ * trig.dtx: Improve docstrip handling.
+
+ * keyval.dtx: Improve docstrip handling.
+
+ * color.dtx: Re-organise options, as for graphics package.
+
+ * graphics.dtx (subsection{Options}): Re-organise, so that it
+ is more efficient to specify a default option in
+ graphics.cfg.
+
+ * graphicx.dtx: Make \includegraphics check for 2nd optional
+ arg. Use standard `graphics.sty' form if 2nd arg is there.
+
+1994-07-27 David Carlisle <latex-bugs@latex-project.org>
+
+ * graphics.dtx: Add missing 3rd argument to \InputIfFileExists
+
+1994-07-21 David Carlisle <latex-bugs@latex-project.org>
+
+ * graphics.dtx: documentation changes.
+
+1994-07-20 Sebastian Rahtz <latex-bugs@latex-project.org>
+
+ * drivers.dtx: Fix textures graphics inclusion.
+
+1994-07-20 David Carlisle <latex-bugs@latex-project.org>
+
+ * pstcol.sty: Package modifying pstrics colour interface to
+ work with LaTeX colours.
+
+ * graphics.dtx (subsection{Stretching and Scaling}): Support
+ active ! for French.
+
+ * drivers.dtx: extensive changes to cope with the new code in
+ graphics.dtx and color.dtx.
+
+ * graphics.dtx: Add default rule possibility, so eg a PS
+ driver can handle any unknown extension as eps, rather than
+ generate an error.
+
+ * color.dtx: Completely new implementation of the internal
+ colour commands. Conversion from `user syntax' to `special
+ syntax' is now in a separate (driver dependant) command,
+ distinct from the commands to define or use colours.
+
+1994-06-10 David Carlisle <latex-bugs@latex-project.org>
+
+ * color.dtx: minor change to error texts. (dated 1994/05/14:-)
+
+ * drivers.dtx: (From Sebastian) fix for dviwin.
+
+1994-05-30 David Carlisle <latex-bugs@latex-project.org>
+
+ * graphics.dtx: Rename egraphics to graphicx.
+
+ * testx.tex: new name to match graphicx.
+
+ * graphicx.dtx: Rename from egraphics (8+3).
+
+ * epsfig.dtx: (From Sebastian) Make epsfig default to [dvips]
+ RequirePackage{graphicx} not egraphics. Remove \wlog as now
+ done by \ProvidesPackage.
+
+1994-05-13 David Carlisle <latex-bugs@latex-project.org>
+
+ * color.dtx: Remove all support for the test release of
+ LaTeX2e. Add optional argument to \NeedsTeXFormat to show
+ this. Define new versions of the `kernel' colour commands,
+ \color@{begin|end|set}group and \normalcolor. Remove
+ redefinition of tabbing commands, now colour-safe in the
+ kernel.
+
+1994-05-09 David Carlisle <latex-bugs@latex-project.org>
+
+ * test.tex: Remove `times' package from test.tex. (Not part of
+ `base' distribution of LaTeX2e.)
+
+ * color.dtx: improve wording of error messages.
+
+ * drivers.dtx: patch to oztex support from Andrew
+ Trevorrow. (via Sebastian)
+
+1994-05-06 David Carlisle <latex-bugs@latex-project.org>
+
+ * graphics.dtx (subsection{Options}): notdraft renamed again
+ to final.
+
+ * drivers.dtx: Replace grot@ by Grot@ throughout.
+
+ * egraphics.dtx: Removed weird and incorrect setting of
+ \let\Gin@scalex\@empty and \let\Gin@scaley\@empty that I
+ must have added while asleep:-) Now the earlier correct
+ settings actually take effect.
+
+ * graphics.dtx: Changed the handling of `missing file' errors.
+ If no extension is supplied, each extension in the list is
+ tried until a file is found. A File not found error is
+ generated if this search fails. If an extension is
+ supplied, only a warning is given if the file does not
+ exist. This allows the file to be created `on the fly' eg by
+ extracting the file from a tar or zip archive.
+
+1994-04-29 David Carlisle <latex-bugs@latex-project.org>
+
+ * drivers.dtx: Removed rotation from drivers.dtx
+ documentation, so it can be processed at any site.
+
+1994-04-28 David Carlisle <latex-bugs@latex-project.org>
+
+ * drivers.dtx: added PS rules for Mac drivers
+
+ * graphics.dtx: Improve the wording of error messages.
+
+1994-04-21 David Carlisle <latex-bugs@latex-project.org>
+
+ * drivers.dtx: Added missing \ProvidesFile for xdvi and
+ dvitops
+
+1994-04-20 David Carlisle <latex-bugs@latex-project.org>
+
+ * graphics.dtx: initialise \Gin@extensions with
+ \providecommand so that definitions in the .def file are not
+ zapped.
+
+1994-04-18 David Carlisle <latex-bugs@latex-project.org>
+
+ * color.dtx: Stop \normalfont resetting the
+ colour. (\reset@font does still reset the colour. This
+ allows \rm to work as expected. Fix marginpar, so the
+ baseline is correctly aligned.
+
+ * README Create initial change log from comments in the README
+
+1994-04-13 David Carlisle <latex-bugs@latex-project.org>
+
+ * notdraft renamed to nodraft
+
+ * zaprotate zapscale renamed to hiderotate hidescale
+
+ * kludges for graphics and colour to work with Feb 1994
+ release now automatically included (so colfix.sty gone)
+
+1994-03-23 David Carlisle <latex-bugs@latex-project.org>
+
+ * rotatebox now correctly rotates about the left hand side.
+
+ * spurious spaces in \resizebox removed
+
+ * no BoundingBox error message improved
+
+ * zaprotate and zapscale options added (probably bad names)
+
+ * notdraft option added to cancel a global draft option.
+
+ * Graphics files now listed by \listfiles
+
+ * PS drivers now support \current@ps@color
+
+ * colfix.sty put back until next release of LaTeX2e.
+
+1994-03-09 David Carlisle <latex-bugs@latex-project.org>
+
+ * \reflectbox added.
+
+ * \rotatebox* removed
+
+ * The order of the arguments of \includegraphics corrected
+
+ * \includegraphics[lower-l,lower-r][upper-l,upper-r]{file}
+
+ * \definecolor not \newcolor to define colours
+
diff --git a/macros/latex/required/graphics/color.dtx b/macros/latex/required/graphics/color.dtx
new file mode 100644
index 0000000000..d85b78349d
--- /dev/null
+++ b/macros/latex/required/graphics/color.dtx
@@ -0,0 +1,963 @@
+%
+% \iffalse
+%
+%% color.dtx Copyright (C) 1994--1999 David Carlisle
+%% Copyright (C) 2005--2016 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
+%% License, as described in lppl.txt in the base LaTeX distribution.
+%% Either version 1.3c or, at your option, any later version.
+%%
+%% This file has the LPPL maintenance status "maintained".
+%%
+%<*dtx>
+ \ProvidesFile{color.dtx}
+%</dtx>
+%<package>\NeedsTeXFormat{LaTeX2e}[1995/12/01]
+%<package>\ProvidesPackage{color}
+%<driver> \ProvidesFile{color.drv}
+% \fi
+% \ProvidesFile{color.dtx}
+ [2016/07/10 v1.1e Standard LaTeX Color (DPC)]
+%
+% \iffalse
+%<*driver>
+\documentclass{ltxdoc}
+\newenvironment{option}[1]{\expandafter\macro\expandafter{%
+ \csname ds@#1\endcsname}}{\endmacro}
+\begin{document}
+ \DocInput{color.dtx}
+\end{document}
+%</driver>
+% \fi
+%
+% \GetFileInfo{color.dtx}
+%
+% \title{The \textsf{color} package\thanks{This file
+% has version number \fileversion, last
+% revised \filedate.}}
+% \author{D. P. Carlisle}
+% \date{\filedate}
+% \MaintainedByLaTeXTeam{graphics}
+% \maketitle
+%
+%
+%
+% \title{The implementation of the \LaTeX\ Colour interface.}
+%
+% \section{Introduction}
+% This package implements \LaTeX\ support for colour, for those
+% \texttt{dvi} drivers that can produce coloured text.
+%
+% The user level documentation of this package is contained in the
+% document \emph{Packages in the `graphics' bundle} in the file
+% \texttt{grfguide.tex}.
+%
+% \StopEventually{}
+%
+%
+% \section{Options}
+%
+% \changes{v0.2a}{1994/04/13}
+% {TEMP KLUDGE for Feb 94 release of 2e:
+% Add extra groups}
+% \changes{v0.2d}{1994/05/13}
+% {All support for Feb 1994 release removed (so used optional arg
+% of \cs{NeedsTeXFormat}).}
+% \changes{v1.0}{1996/05/29}
+% {Version 1 at last}
+%
+% \begin{macrocode}
+%<*package>
+% \end{macrocode}
+%
+% First we save the catcodes of some characters, and set them to
+% fixed values whilst this file is being read.
+% \changes{v0.3b}{1994/09/14}
+% {Save and restore catcodes}
+% \begin{macrocode}
+\edef\Gin@codes{%
+ \catcode`\noexpand\^^A\the\catcode`\^^A\relax
+ \catcode`\noexpand\"\the\catcode`\"\relax
+ \catcode`\noexpand\*\the\catcode`\*\relax
+ \catcode`\noexpand\!\the\catcode`\!\relax
+ \catcode`\noexpand\:\the\catcode`\:\relax}
+\catcode`\^^A=\catcode`\%
+\catcode`\"=12
+\catcode`\*=11
+\catcode`\!=12
+\catcode`\:=12
+% \end{macrocode}
+%
+% \begin{macro}{\Gin@driver}
+% Initialize the macro to hold the driver file name.
+% \begin{macrocode}
+\providecommand\Gin@driver{}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\c@lor@error}
+% \changes{v1.0d}{1997/01/07}
+% {Macro added for graphics/2350}
+% Helper macro for error handling (redefined by the monochrome option
+% to make errors warnings).
+% \begin{macrocode}
+\def\c@lor@error#1{%
+ \@latex@error{Undefined color #1}\@ehd}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{option}{monochrome}
+% The |monochrome| option should be used \emph{in addition}
+% to one of the standard driver options.
+% \changes{v0.3j}{1995/06/16}
+% {Use single hash for latex/1557}
+% \changes{v1.0b}{1996/10/29}
+% {Add \cs{colors@false}}
+% \changes{v1.0d}{1997/01/07}
+% {Add \cs{c@lor@error} for graphics/2350}
+% \begin{macrocode}
+\DeclareOption{monochrome}{%
+ \def\c@lor@error#1{\PackageInfo{color}{Undefined color #1}}%
+ \AtEndOfPackage{%
+ \colors@false
+ \def\set@color{%
+ \c@lor@special\m@ne
+ {color push \current@color}\aftergroup\reset@color}%
+ \def\reset@color{\c@lor@special\m@ne{color pop}}%
+ \def\set@page@color{%
+ \c@lor@special\m@ne{background \current@color}}%
+ \def\define@color#1#2{%
+ \c@lor@special\m@ne{define #1 #2}}}}
+% \end{macrocode}
+% \end{option}
+%
+% \begin{option}{debugshow}
+% The |debugshow| option turns on debugging info (perhaps).
+% \changes{v1.0a}{1996/09/16}
+% {debugshow option added}
+% \begin{macrocode}
+\DeclareOption{debugshow}{\catcode`\^^A=9 \let\GDebug\typeout}
+% \end{macrocode}
+% \end{option}
+%
+% \begin{option}{setpagesize}
+% \begin{option}{nosetpagesize}
+% The |setpagesize| option requests that the driver option sets the page size.
+% \changes{v1.1d}{2016/06/02}
+% {(no)setpagesize options added}
+% (Whichever option is used, the page size is not set by this package if |\mag|
+% has been changed from its default value.)
+% \begin{macrocode}
+\newif\ifGin@setpagesize\Gin@setpagesizetrue
+\DeclareOption{setpagesize}{\Gin@setpagesizetrue}
+\DeclareOption{nosetpagesize}{\Gin@setpagesizefalse}
+% \end{macrocode}
+% \end{option}
+% \end{option}
+%
+% Now the options for supported drivers.
+%
+% \begin{option}{dvips}
+% \begin{option}{xdvi}
+% Tom Rokicki's dvips driver, and the X Windows previewer, xdvi which uses
+% (a subset of) the same |\specials|.
+% \begin{macrocode}
+\DeclareOption{dvips}{\def\Gin@driver{dvips.def}%
+ \def\c@lor@namefile{dvipsnam.def}}
+\DeclareOption{xdvi}{\ExecuteOptions{dvips,monochrome}}
+% \end{macrocode}
+% \end{option}
+% \end{option}
+%
+% \begin{option}{dvipdf}
+% \changes{v1.0c}{1996/10/31}
+% {dvipdf added}
+% Sergey Lesenko's dvipdf driver.
+% \begin{macrocode}
+\DeclareOption{dvipdf}{\def\Gin@driver{dvipdf.def}}
+% \end{macrocode}
+% \end{option}
+%
+% \begin{option}{dvipdfm}
+% \changes{v1.0h}{1999/01/13}
+% {dvipdfm added}
+% Mark Wick's dvipdfm driver.
+% \begin{macrocode}
+\DeclareOption{dvipdfm}{\def\Gin@driver{dvipdfm.def}}
+% \end{macrocode}
+% \end{option}
+%
+% \begin{option}{dvipdfmx}
+% \changes{v1.0j}{2005/11/14}
+% {dvipdfmx added}
+% The driver for the dvipdfmx project.
+% \begin{macrocode}
+\DeclareOption{dvipdfmx}{\def\Gin@driver{dvipdfmx.def}}
+% \end{macrocode}
+% \end{option}
+%
+% \begin{option}{pdftex}
+% \changes{v1.0e}{1997/06/07}
+% {pdftex added}
+% Han The Thanh's \TeX\ variant.
+% \begin{macrocode}
+\DeclareOption{pdftex}{\def\Gin@driver{pdftex.def}}
+% \end{macrocode}
+% \end{option}
+%
+% \begin{option}{luatex}
+% \changes{v1.1b}{2016/01/03}
+% {luatex added}
+% Lua\TeX\ \TeX\ variant.
+% \begin{macrocode}
+\DeclareOption{luatex}{\def\Gin@driver{luatex.def}}
+% \end{macrocode}
+% \end{option}
+%
+% \begin{option}{luatex}
+% \changes{v1.1c}{2016/05/09}
+% {dvisvgm added}
+% dvisvgm driver.
+% \begin{macrocode}
+\DeclareOption{dvisvgm}{\def\Gin@driver{dvisvgm.def}}
+% \end{macrocode}
+% \end{option}
+%
+% \begin{option}{xetex}
+% \changes{v1.0j}{2005/11/14}
+% {xetex added}
+% Jonathan Kew's \TeX\ variant.
+% \begin{macrocode}
+\DeclareOption{xetex}{\def\Gin@driver{xetex.def}}
+% \end{macrocode}
+% \end{option}
+%
+% \begin{option}{dvipsone}
+% \begin{option}{dviwindo}
+% \changes{v0.3k}{1995/09/07}
+% {Merge dviwindo and dvipsone options}
+% The drivers of the Y\&Y \TeX\ system.
+% (Which use the same |\specials|).
+% \begin{macrocode}
+\DeclareOption{dvipsone}{\def\Gin@driver{dvipsone.def}}
+\DeclareOption{dviwindo}{\ExecuteOptions{dvipsone}}
+% \end{macrocode}
+% \end{option}
+% \end{option}
+%
+% \begin{option}{emtex}
+% \begin{option}{dviwin}
+% Freely available drivers for PCs.
+% \begin{macrocode}
+\DeclareOption{emtex}{\def\Gin@driver{emtex.def}}
+\DeclareOption{dviwin}{\def\Gin@driver{dviwin.def}}
+% \end{macrocode}
+% \end{option}
+% \end{option}
+%
+% \begin{option}{oztex}
+% \changes{v1.0f}{1997/09/09}
+% {Merge dvips and oztex options}
+% The Oz\TeX\ system for a Macintosh.
+% Since release 3 of Oz\TeX, merge with dvips back end.
+% \begin{macrocode}
+\DeclareOption{oztex}{\ExecuteOptions{dvips}}
+% \end{macrocode}
+% \end{option}
+%
+% \begin{option}{textures}
+% Blue sky's Textures system on a Macintosh.
+% \begin{macrocode}
+\DeclareOption{textures}{\def\Gin@driver{textures.def}}
+% \end{macrocode}
+% \end{option}
+%
+% \begin{option}{pctexps}
+% \begin{option}{pctexwin}
+% \begin{option}{pctexhp}
+% \begin{option}{pctex32}
+% \changes{v1.0b}{1996/10/29}
+% {pctex32 option added}
+% The drivers for PTI's \TeX\ system on PCs.
+% \begin{macrocode}
+\DeclareOption{pctexps}{\def\Gin@driver{pctexps.def}}
+\DeclareOption{pctexwin}{\def\Gin@driver{pctexwin.def}}
+\DeclareOption{pctexhp}{\def\Gin@driver{pctexhp.def}}
+\DeclareOption{pctex32}{\def\Gin@driver{pctex32.def}}
+% \end{macrocode}
+% \end{option}
+% \end{option}
+% \end{option}
+% \end{option}
+%
+% \begin{option}{truetex}
+% \begin{option}{tcidvi}
+% \changes{v1.0b}{1996/10/29}
+% {truetex and tcidvi options added}
+% The drivers of the Kinch \TeX\ system on PCs, and its
+% version with extra |\special| handling dll's as shipped with
+% TCI's Scientific Word.
+% \begin{macrocode}
+\DeclareOption{truetex}{\def\Gin@driver{truetex.def}}
+\DeclareOption{tcidvi}{\def\Gin@driver{tcidvi.def}}
+% \end{macrocode}
+% \end{option}
+% \end{option}
+%
+% \begin{option}{vtex}
+% \changes{v1.0g}{1998/05/27}
+% {vtex option added}
+% V\TeX\ driver.
+% \begin{macrocode}
+\DeclareOption{vtex}{\def\Gin@driver{vtex.def}}
+% \end{macrocode}
+% \end{option}
+%
+% \begin{option}{dvi2ps}
+% \begin{option}{dvialw}
+% \begin{option}{dvilaser}
+% \begin{option}{dvitops}
+% \begin{option}{psprint}
+% \begin{option}{pubps}
+% \begin{option}{ln}
+% \changes{v1.0b}{1996/10/29}
+% {old driver options depreciated}
+% Old, probably obsolete, drivers commented out. See the section
+% on `Driver support' in grfguide to see how to re-enable these
+% options in |color.cfg| if you need them.
+% \begin{macrocode}
+%\DeclareOption{dvi2ps}{\def\Gin@driver{dvi2ps.def}}
+%\DeclareOption{dvialw}{\def\Gin@driver{dvialw.def}}
+%\DeclareOption{dvilaser}{\def\Gin@driver{dvilaser.def}}
+%\DeclareOption{dvitops}{\def\Gin@driver{dvitops.def}}
+%\DeclareOption{psprint}{\def\Gin@driver{psprint.def}}
+%\DeclareOption{pubps}{\def\Gin@driver{pubps.def}}
+%\DeclareOption{ln}{\def\Gin@driver{ln.def}}
+% \end{macrocode}
+% \end{option}
+% \end{option}
+% \end{option}
+% \end{option}
+% \end{option}
+% \end{option}
+% \end{option}
+%
+%
+% \begin{option}{dvipsnames}
+% \begin{option}{nodvipsnames}
+% By default the named colour model has no pre-declared names.
+% The |dvipsnames| option predeclares all the names in the colour
+% prologue of dvips. The |dvips| option automatically implies
+% |dvipsnames| unless this choice is overruled with the |nodvipsnames|
+% option. For other drivers, eg |textures| you may use this option to
+% explicitly request that these names be declared.
+% \begin{macrocode}
+\DeclareOption{dvipsnames}{\def\c@lor@namefile{dvipsnam.def}}
+\DeclareOption{nodvipsnames}{\let\c@lor@namefile\relax}
+% \end{macrocode}
+% \end{option}
+% \end{option}
+%
+% \begin{option}{usenames}
+% The |usenames| option modifies the behaviour of |\DefineNamedColor|
+% So that it declares the same name as a ```user's colour'' for use in
+% a |\color| command, as well as a name in the |named| colour model.
+% The normal behaviour is just to declare the name in the named colour
+% model.
+% \begin{macrocode}
+\let\c@lor@usename\@gobble
+% \end{macrocode}
+%
+% \begin{macrocode}
+\DeclareOption{usenames}{%
+ \def\c@lor@usename#1{%
+ \expandafter\color@named\csname\string\color @#1\endcsname{#1}}}
+% \end{macrocode}
+% \end{option}
+%
+% \section{Using Colours}
+%
+% \subsection{Declarative form}
+%
+% \begin{macro}{\color}
+% |\color{|\emph{declared-colour}|}| switches to the colour
+% \emph{declared-colour}, which must previously have been defined
+% using |\definecolor|. This colour will stay in effect until the end of
+% the current \TeX\ group.
+%
+% |\color[|\emph{model}|]{|\emph{colour-specification}|}| is similar
+% to the above, but uses a colour not declared by |\definecolor|. The
+% allowed \emph{model}'s vary depending on the driver. The syntax of
+% the \emph{colour-specification} argument depends on the model.
+%
+% \changes{v0.3a}{1994/07/20}
+% {Make \cs{color} robust}
+% \begin{macrocode}
+\DeclareRobustCommand\color{%
+ \@ifnextchar[\@undeclaredcolor\@declaredcolor}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@undeclaredcolor}
+% \changes{v0.2c}{1994/05/09}
+% {Improve error messages}
+% \changes{v0.3a}{1994/07/20}
+% {New internal implementation of colour commands}
+% Call the driver-dependent command |\color@|\meta{model} to define
+% |\current@color|, then call |\set@color| to change the current colour
+% accordingly.
+% \begin{macrocode}
+\def\@undeclaredcolor[#1]#2{%
+ \@ifundefined{color@#1}%
+ {\c@lor@error{model `#1'}}%
+ {\csname color@#1\endcsname\current@color{#2}%
+ \set@color}%
+ \ignorespaces}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@declaredcolor}%
+% \changes{v0.1c}{1994/04/01}
+% {Add \cs{ignorespaces}}
+% \changes{v0.1e}{1994/05/14}
+% {Minor change to error message}
+% \changes{v0.3a}{1994/07/20}
+% {New internal implementation of colour commands}
+% |\let| |\current@color| to the internal representation of the colour
+% if the colour has been declared, otherwise generate an error.
+% Finally call |\set@color| to effect the colour change.
+% \begin{macrocode}
+\def\@declaredcolor#1{%
+ \@ifundefined{\string\color @#1}%
+ {\c@lor@error{`#1'}}%
+ {\expandafter\let\expandafter\current@color
+ \csname\string\color @#1\endcsname
+ \set@color}%
+ \ignorespaces}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsection{Command (Argument) Form}
+%
+% \begin{macro}{\textcolor}
+% |\textcolor{|\emph{declared-colour}|}{|\emph{text}|}| and
+% |\textcolor[|\emph{model}|]{|\emph{colour-spec}|}{|\emph{text}|}|
+% are just alternative syntax for |\color|, in
+% which the groups are added implicitly. Thus \emph{text} appears in the
+% specified colour, but then the colour reverts to its previous value.
+% The naming is by analogy with |\textrm| (as opposed to |\rm| and
+% |\rmfamily|) although it is slightly a misnomer as the command also
+% works in math-mode.
+%
+% Since December 95, in fact this command has one other difference
+% from |\color|. It calls |\leavevmode| to ensure the start of
+% horizontal mode. Specifically this means that a construction
+% such as
+%\begin{verbatim}
+% xxx\parbox[t]{1cm}{\textcolor{red}{a}.....
+%\end{verbatim}
+% now works as expected, with the |xxx| and the red |a| lining up
+% correctly.
+% \changes{v0.3a}{1994/07/20}
+% {Stop command being \cs{long}, and make robust.}
+% \changes{v0.3l}{1995/12/07}
+% {Add \cs{leavevmode}}
+% \begin{macrocode}
+\def\textcolor#1#{\@textcolor{#1}}
+\def\@textcolor#1#2#3{\protect\leavevmode{\color#1{#2}#3}}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsection{Background (Page) Colour}
+%
+% \begin{macro}{\pagecolor}
+% |\pagecolor|, which has the same argument forms as |\color|, specifies
+% the background colour for the current, and all following, pages. It is
+% a global declaration which does not respect \TeX\ groups.
+%
+% \changes{v0.1c}{1994/04/01}
+% {end the group even if the colour command generates an error}
+% \changes{v0.3c}{1994/09/19}
+% {Use \cs{color} to parse arguments}
+% \begin{macrocode}
+\def\pagecolor{%
+ \begingroup
+ \let\ignorespaces\endgroup
+ \let\set@color\set@page@color
+ \color}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\nopagecolor}
+% |\nopagecolor| (suggested by Heiko Oberdiek) removes any currently specified page colour
+% returning to the default transparent background. It is not yet supported by all driver options
+% and so generates a warning if there is no definition in the driver file.
+%
+% \changes{v1.1a}{2014/04/23}
+% {add \cs{nopagecolor} graphics/3873}
+% \begin{macrocode}
+\def\nopagecolor{%
+ \@ifundefined{no@page@color}{%
+ \PackageInfo{color}{\string\nopagecolor\space is not supported}%
+ }{%
+ \no@page@color
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \section{Defining Colours}
+%
+% \begin{macro}{\definecolor}
+% |\definecolor{|\emph{name}|}{|\emph{model}|}{|\emph{colour-spec}|}|
+% defines the color \emph{name}, which may then be used in subsequent
+% |\color| or |\textcolor| commands to refer to a colour specified by
+% \emph{colour-spec} in the colour model \emph{model}.
+%
+% |\definecolor| associates the \emph{name} the to a colour in
+% \emph{model}. So |\color{|\emph{name}|}| would check \emph{name}
+% then issue a |\special| for the colour model \emph{model}.
+%
+% |\definecolor| just calls an internal macro that defines the colour
+% for a particular model. This macro must have been defined by the
+% driver file that supports the requested \emph{model}.
+%
+% \changes{v0.1b}{1994/03/15}
+% {change name from \cs{newcolor} to \cs{definecolor}}
+% \changes{v0.1e}{1994/05/14}
+% {Minor change to error message}
+% \changes{v0.3a}{1994/07/20}
+% {New internal implementation of colour commands}
+% \changes{v0.3f}{1994/10/04}
+% {Give info about redefinitions}
+% \begin{macrocode}
+\def\definecolor#1#2#3{%
+ \@ifundefined{color@#2}%
+ {\c@lor@error{model `#2'}}%
+ {\@ifundefined{\string\color @#1}{}%
+ {\PackageInfo{color}{Redefining color #1}}%
+ \csname color@#2\expandafter\endcsname
+ \csname\string\color @#1\endcsname{#3}}}
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\DefineNamedColor}
+% \changes{v0.3d}{1994/09/29}
+% {Macro added}
+% \changes{v0.3e}{1994/10/03}
+% {usenames option added}
+% \changes{v0.3f}{1994/10/04}
+% {Give info about redefinitions}
+%
+% Driver files may opt to define a `named' colour model.
+% Placing colour names rather than numeric specifications into the dvi
+% file has certain advantages, in that post processing software can
+% tune the colour specifications to the particular technology being
+% used, and more easily make colour separations for that colour.
+% The disadvantage is that the driver must `know' the colour
+% names.
+%
+% The `color1' drivers (dvips) currently ignore the specification of
+% the colour, and once a name is defined, just put the colour name in
+% the dvi file. For dvips, The header file \texttt{color.pro} is used to
+% give the cmyk equivalents of the names.
+%
+% The `color2' drivers (textures) use a special postscript operator
+% that takes both the name and the cmyk equivalent. so if the names are
+% not being used, `fall back' definitions in the cmyk model are available.
+% These drivers also allow a numeric value to affect the `density'
+% of the colour to use.
+%
+% Drivers based on `color3' do not support named colours at the dvi
+% level, but to ease document portability, the named model is still
+% defined, but the |\special|'s just put the colour specifications, not
+% the names, into the dvi file.
+%
+% Normally after a colour, say |JungleGreen|, has been declared with:\\
+% |\DefineNamedColor{named}{JungleGreen}{cmyk}{1,2,3,4}|\\
+% it is available in the `named' colour model, for
+% instance by\\
+% |\color[named]{JungleGreen}|\\
+% A user may give a more convenient name, using\\
+% |\definecolor{mygreen}{named}{JungleGreen}|\\
+% If however you are happy with the original names, and want to use
+% them directly, as in |\color{JungleGreen}| without specifying
+% |[named]| all the time, just give the package option |usenames|, which
+% will redefine |\DefineNamedColor|, so that the colour name is declared
+% as a user-colour as well as a name in the `named' model.
+% \begin{macrocode}
+\def\DefineNamedColor#1#2#3#4{%
+ \@ifundefined{define@color@#1}%
+ {\c@lor@error{model `#1'}}%
+ {\@ifundefined{color@#3}%
+ {\c@lor@error{model `#3'}}%
+ {\@ifundefined{c@lor@#1@#2}{}%
+ {\PackageInfo{color}{Redefining color #2 in named color model}}%
+ \csname color@#3\endcsname\@tempa{#4}%
+ \csname define@color@#1\endcsname{#2}\@tempa
+ \c@lor@usename{#2}}}}
+\@onlypreamble\DefineNamedColor
+% \end{macrocode}
+% \end{macro}
+%
+% \section{Colour Switch}
+%
+% \begin{macro}{\ifcolors@}
+% This boolean can be tested by higher level macros that may want to
+% alter their behaviour if a monochrome driver is being used.
+% \begin{macrocode}
+\newif\ifcolors@
+\colors@true
+% \end{macrocode}
+% \end{macro}
+%
+% \section{Whatsit\ldots}
+%
+% \begin{macro}{\c@lor@special}
+% Some drivers can not support all the features of this package. They
+% should always put a \meta{whatsit} in the current list though. The
+% following macro has most of the features of |\special|, but does not
+% put anything into the |dvi| file. It does write to the log file or the
+% terminal (depending on the value of |#1|).
+% \begin{macrocode}
+\def\c@lor@special#1#2{%
+ \edef\@tempa{\write#1{#2}}\@tempa}
+% \end{macrocode}
+% \end{macro}
+%
+% \section{Processing Options}
+%
+% A local configuration file may declare more options.
+% It should also make one driver option the default, by calling
+% |\ExecuteOptions| with the appropriate option.
+% \begin{macrocode}
+\InputIfFileExists{color.cfg}{}{}
+% \end{macrocode}
+%
+% After the options are processed, load the appropriate driver file.
+% If a site wants a default driver (eg |dvips|) it just needs to put
+% |\ExecuteOptions{dvips}| in a |color.cfg| file.
+% \changes{v0.3b}{1994/09/14}
+% {New style of loading driver files}
+% \begin{macrocode}
+\ProcessOptions
+% \end{macrocode}
+%
+% \begin{macrocode}
+\if!\Gin@driver!
+ \PackageError{color}
+ {No driver specified}
+ {You should make a default driver option in a file \MessageBreak
+ color.cfg\MessageBreak
+ eg: \protect\ExecuteOptions{dvips}%
+ }
+\else
+ \PackageInfo{color}{Driver file: \Gin@driver}
+ \@ifundefined{ver@\Gin@driver}{\input{\Gin@driver}}{}
+\fi
+% \end{macrocode}
+%
+% \begin{macrocode}
+\@ifundefined{c@lor@namefile}{}{\input{\c@lor@namefile}}
+% \end{macrocode}
+%
+% \section{Default Colour}
+%
+% \begin{macro}{\normalcolor}
+% Early versions of this package redefined |\reset@font| to reset the
+% color as well. Current versions do not do this (there are too many
+% |\reset@font| commands hidden in strange places) and so defines a
+% separate command, |\normalcolor| to reset the colour to the colour in
+% effect at the start of the document.
+%
+% |\normalcolor| is defined (to |\relax|) in the \LaTeX\ kernel, so it
+% is safe to use this in macros that may possibly be used in
+% conjunction with colour. It will have no effect until the |color|
+% package is also loaded.
+% \changes{v0.2b}{1994/04/18}
+% {Only reset the colour with \cmd{\reset@font} not
+% \cmd{\normalfont}}
+% \changes{v0.2d}{1994/05/13}
+% {Stop changing \cs{reset@font}. Use the new \cs{normalfont}
+% instead.}
+% \begin{macrocode}
+\def\normalcolor{\let\current@color\default@color\set@color}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\default@color}
+% Internal macro to store the `default' colour used by |\normalcolor|.
+% \begin{macrocode}
+\AtBeginDocument{\let\default@color\current@color}
+% \end{macrocode}
+% \end{macro}
+%
+% |\current@color| contains an internal representation of the colour
+% at this point in the document. (This can only be an approximation to
+% the truth as the `macro layer' of \TeX\ does not know where the output
+% routine is going to re-insert floats. This is why drivers must
+% maintain their own stack of colours in order to fully support these
+% commands.
+%
+% For dvips, the |\current@color| it is something like `|Black|' or
+% `|rgb 0 1 0|', but other packages should not rely on any particular
+% format for this macro.
+%
+% The driver file \emph{must} initialise |\current@color| to a
+% specification for Black. This initialisation can not occur here, as
+% the possible colour models (and thus the syntax for `black')
+% are not known at this point.
+%
+% \section{Higher Level Commands}
+%
+% With the basic colour primitives specified above we may define a few
+% higher level commands for coloured boxes etc. This is still quite a low
+% level and presumably packages and classes making use of colour will
+% define more appropriate document-level commands.
+%
+% \subsection{Colour Block}
+%
+% \begin{macro}{\color@block}
+% |\color@block{|\emph{width}|}{|\emph{height}|}{|\emph{depth}|}|\\
+% Should take up no space for \TeX, but produce a block in the current
+% colour of the specified size. It is mainly used for producing box
+% backgrounds.
+%
+% The definition here works by selecting a colour, and then drawing a
+% \TeX\ rule (unless |\ifcolors@false|). This allows the `driver
+% independent' colour specials to be used. However it is defined using
+% |\providecommand|, so that this file will not over-write any other
+% definition of this command. A graphics package may want to define it
+% using a special to produce (for example) a PostScript line. Producing
+% the line in the |\special| has the advantage that on a preview that
+% does not understand |\special|s, the line is automatically omited,
+% without needing to modify the source of the document (for instance by
+% adding the |monochrome| option).
+%
+% \begin{macrocode}
+\def\color@block#1#2#3{%
+ {\set@color\rlap{\ifcolors@\vrule\@width#1\@height#2\@depth#3\fi}}}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsection{Coloured Boxes}
+%
+% \begin{macro}{\colorbox}
+% |\colorbox| takes the same argument forms as |\textcolor|, but the
+% colour specifies the \emph{background} colour of the box.
+% \changes{v0.3b}{1994/09/14}
+% {New implementation}
+% \begin{macrocode}
+\def\colorbox#1#{\color@box{#1}}
+% \end{macrocode}
+% \end{macro}
+%
+% \changes{v0.3i}{1995/04/27}
+% {Move \cs{leavevmode} for graphics/1521}
+% \begin{macro}{\color@box}
+% \begin{macrocode}
+\def\color@box#1#2{\color@b@x\relax{\color#1{#2}}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\fcolorbox}
+% |\fcolorbox| has an extra \emph{colour-spec} argument, and puts a
+% frame of the first colour around a box with a background specified by
+% the second colour. If an optional argument is given, it specifies the
+% colour model for both colours.
+% \changes{v0.3b}{1994/09/14}
+% {New implementation}
+% \begin{macro}{\fcolorbox}
+% \begin{macrocode}
+\def\fcolorbox#1#{\color@fbox{#1}}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\color@fbox#1#2#3{%
+ \color@b@x{\fboxsep\z@\color#1{#2}\fbox}{\color#1{#3}}}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+
+% \begin{macro}{\color@b@x}
+% Internal macro for |\colorbox| and |\fcolorbox|.
+% \changes{v0.3b}{1994/09/14}
+% {Macro added.}
+% \changes{v0.3i}{1995/04/27}
+% {Add \cs{leavevmode} for graphics/1521}
+% \begin{macrocode}
+\long\def\color@b@x#1#2#3{%
+ \leavevmode
+ \setbox\z@\hbox{\kern\fboxsep{\set@color#3}\kern\fboxsep}%
+ \dimen@\ht\z@\advance\dimen@\fboxsep\ht\z@\dimen@
+ \dimen@\dp\z@\advance\dimen@\fboxsep\dp\z@\dimen@
+ {#1{#2\color@block{\wd\z@}{\ht\z@}{\dp\z@}%
+ \box\z@}}}
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \section{Extra Groups}
+% Turning on extra groups in the standard \LaTeX\ commands, so that
+% colour commands are scoped correctly.
+%
+% Like |\normalcolor|, the following five commands are defined in the
+% kernel, with empty definitions (|\relax|). This means that they can
+% be used to make macros in packages `colour safe'. The commands
+% will not have any effect unless a user also uses this colour
+% package, when the `active definitions' here will take effect and
+% keep colour commands correctly scoped.
+%
+% \begin{macro}{\color@setgroup}
+% This is to be used in contexts (eg `lrbox') where text is to be
+% saved and used after some other, unknown, text that may contain
+% colour commands. A matching |\color@endgroup| should be used at the
+% end of the text.
+% \changes{v0.2d}{1994/05/13}
+% {Macro added}
+% \begin{macrocode}
+\def\color@setgroup{\begingroup\set@color}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\color@begingroup}
+% This is to be used at the start of contexts that may contain colour
+% commands, but where it is not necessary to save the current colour.
+% Examples of this are in the box commands of |ltboxes.dtx| where
+% user-supplied text is saved internally in a box between
+% |\color@begingroup|, |\color@endgroup|, but the box is used before
+% any other colour commands could intervene. A matching
+% |\color@endgroup| should be used at the end of the text.
+% \changes{v0.2d}{1994/05/13}
+% {New definition, was previously like \cs{color@setgroup}}
+% \begin{macrocode}
+\let\color@begingroup\begingroup
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\color@endgroup}
+% To be used to close the `group' started by one of the above two
+% commands. The |\endgraf| in its definition is required in the case
+% of groups of text in vertical `par' mode, but doesn't do any harm in
+% horizontal `LR' contexts.
+% \changes{v0.2d}{1994/05/13}
+% {New definition, was previously just \cs{endgroup}}
+% \begin{macrocode}
+\def\color@endgroup{\endgraf\endgroup}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\color@hbox}
+% To be used to open a `coloured hbox'
+% \changes{v0.3g}{1994/11/08}
+% {Macro added}
+% \begin{macrocode}
+\def\color@hbox{\hbox\bgroup\color@begingroup}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\color@vbox}
+% To be used to open a `coloured hbox'
+% \changes{v0.3h}{1994/11/22}
+% {Macro added}
+% \begin{macrocode}
+\def\color@vbox{\vbox\bgroup\color@begingroup}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\color@endbox}
+% To be used to close a `coloured hbox'
+% \changes{v0.3g}{1994/11/08}
+% {Macro added}
+% \begin{macrocode}
+\def\color@endbox{\color@endgroup\egroup}
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \changes{v0.2d}{1994/05/13}
+% {tabbing support removed (now in kernel)}
+%
+% \changes{v0.3l}{1995/12/07}
+% {\cs{underbar} removed (now in kernel)}
+%
+% \changes{v0.3h}{1994/11/22}
+% {marginpar, phantom and smash now supported in kernel}
+%
+% \changes{v0.3l}{1995/12/07}
+% {\cs{showhyphens} removed (now in kernel)}
+%
+%
+% \section{Predefining Colours}
+%
+% As long as the driver file has defined sufficient colour models, we
+% define a few colours, just to get people started.
+%
+% \begin{macro}{black}
+% \begin{macro}{white}
+% Black and white `colours'.
+% \begin{macrocode}
+\ifx\color@gray\@undefined
+ \ifx\color@rgb\@undefined
+ \else
+ \definecolor{black}{rgb}{0,0,0}
+ \definecolor{white}{rgb}{1,1,1}
+ \fi
+\else
+ \definecolor{black}{gray}{0}
+ \definecolor{white}{gray}{1}
+\fi
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{red}
+% \begin{macro}{green}
+% \begin{macro}{blue}
+% Additive primaries.
+% \begin{macrocode}
+\ifx\color@rgb\@undefined\else
+ \definecolor{red}{rgb}{1,0,0}
+ \definecolor{green}{rgb}{0,1,0}
+ \definecolor{blue}{rgb}{0,0,1}
+\fi
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{cyan}
+% \begin{macro}{magenta}
+% \begin{macro}{yellow}
+% Subtractive primaries.
+% \begin{macrocode}
+\ifx\color@cmyk\@undefined\else
+ \definecolor{cyan}{cmyk}{1,0,0,0}
+ \definecolor{magenta}{cmyk}{0,1,0,0}
+ \definecolor{yellow}{cmyk}{0,0,1,0}
+\fi
+% \end{macrocode}
+%
+% \begin{macrocode}
+%</package>
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+%
+% \section{And Finally}
+%
+% Restore Catcodes
+% \begin{macrocode}
+\Gin@codes
+\let\Gin@codes\relax
+% \end{macrocode}
+%
+% \Finale
+%
diff --git a/macros/latex/required/graphics/color.pdf b/macros/latex/required/graphics/color.pdf
new file mode 100644
index 0000000000..b717d3dc6d
--- /dev/null
+++ b/macros/latex/required/graphics/color.pdf
Binary files differ
diff --git a/macros/latex/required/graphics/drivers.dtx b/macros/latex/required/graphics/drivers.dtx
new file mode 100644
index 0000000000..07c201cf87
--- /dev/null
+++ b/macros/latex/required/graphics/drivers.dtx
@@ -0,0 +1,1701 @@
+%
+% \iffalse
+%
+%% 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
+%%
+%% This file is part of the Standard LaTeX `Graphics Bundle'.
+%% It may be distributed under the terms of the LaTeX Project Public
+%% License, as described in lppl.txt in the base LaTeX distribution.
+%% Either version 1.3 or, at your option, any later version.
+%%
+%<template, >\ProvidesFile{template.def}
+%<dvips, >\ProvidesFile{dvips.def}
+%<dvipsnames>\ProvidesFile{dvipsnam.def}
+%<dvipdf, >\ProvidesFile{dvipdf.def}
+%<emtex, >\ProvidesFile{emtex.def}
+%<dviwin, >\ProvidesFile{dviwin.def}
+%<dvipsone, >\ProvidesFile{dvipsone.def}
+%<pctexps, >\ProvidesFile{pctexps.def}
+%<pctex32, >\ProvidesFile{pctex32.def}
+%<pctexwin, >\ProvidesFile{pctexwin.def}
+%<pctexhp, >\ProvidesFile{pctexhp.def}
+%<truetex, >\ProvidesFile{truetex.def}
+%<tcidvi, >\ProvidesFile{tcidvi.def}
+%<oztex, >\ProvidesFile{oztex.def}
+%<textures, >\ProvidesFile{textures.def}
+%<dvialw, >\ProvidesFile{dvialw.def}
+%<dvilaser, >\ProvidesFile{dvilaser.def}
+%<psprint, >\ProvidesFile{psprint.def}
+%<dvi2ps, >\ProvidesFile{dvi2ps.def}
+%<pubps, >\ProvidesFile{pubps.def}
+%<dvitops, >\ProvidesFile{dvitops.def}
+%<ln, >\ProvidesFile{ln.def}
+%
+%<*driver>
+ \NeedsTeXFormat{LaTeX2e}
+ \ProvidesFile{drivers.dtx}
+%</driver>
+ [2016/06/17 v3.0m Driver-dependent file (DPC,SPQR)]
+%
+%<*driver>
+ \documentclass{ltxdoc}
+ \GetFileInfo{drivers.dtx}
+ \begin{document}
+ \title{Graphics drivers for \LaTeXe\thanks
+ {Version \fileversion, revised \filedate}}
+ \author{Sebastian Rahtz and David Carlisle}
+ \date{\filedate}
+ \MaintainedByLaTeXTeam{graphics}
+ \maketitle
+ \DocInput{drivers.dtx}
+ \end{document}
+%</driver>
+% \fi
+%
+%
+%
+% \providecommand\OzTeX{O\kern-.03em z\kern-.15em\TeX}
+%
+% \section{Driver files}
+%
+% This file implements some of the currently supported drivers.
+% If the driver you use is not in this list then a `.def' file
+% may be distributed with This graphics bundle,
+% or may be distributed with your driver.
+%
+% If not, send us some details of the driver's |\special| syntax, and
+% we will try to produce a suitable file.
+%
+% Note that some of these files are for drivers to which we have no
+% access, so they are untested. Please send any corrections to the
+% latexbugs address.
+%
+%
+%
+%
+% \StopEventually{}
+%
+%
+% \section{Colour}
+%
+% Most of the drivers that support colour use one of three methods.
+% \begin{itemize}
+% \item color1: `dvips' style colour specials.
+% \item color2: `textures' style colour specials.
+% \item color3: Colour implemented via literal PostScript specials.
+% \item color4: Colour implemented by specials that only support RGB,
+% i.e., Red Green Blue specified as integers in the range
+% 0--255. Other models converted to this within \TeX.
+% \end{itemize}
+% Some drivers do not use any of these modules and have their own code.
+% Note that drivers using the `color3' code can not fully support the
+% \LaTeX\ colour commands.
+% \begin{macrocode}
+%<*color1|color2|color3|color4>
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\c@lor@arg#1{%
+ \dimen@#1\p@
+ \ifdim\dimen@<\z@\dimen@\maxdimen\fi
+ \ifdim\dimen@>\p@
+ \PackageError{color}{Argument `#1' not in range [0,1]}\@ehd
+ \fi}
+% \end{macrocode}
+%
+% Need to make sure of a trailing .0 for textures. Apparently it
+% is OK to always add a . as 1.3. is accepted by textures.
+% textures gray special is reversed, so just use rgb instead.
+%
+% \begin{macrocode}
+\def\color@gray#1#2{%
+ \c@lor@arg{#2}%
+%<color4> \c@lor@rgb@RGB\@tempa
+%<color1> \edef#1{gray #2}%
+%<color2> \edef#1{rgb #2. #2. #2.}%
+%<color3> \edef#1{#2 setgray}%
+%<color4> \edef#1{\@tempa\@tempa\@tempa}%
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\color@cmyk#1#2{\c@lor@@cmyk#2\@@#1}
+\def\c@lor@@cmyk#1,#2,#3,#4\@@#5{%
+ \c@lor@arg{#4}%
+%<color4> \dimen@ii#4\p@
+ \c@lor@arg{#1}%
+%<color4> \c@lor@cmyk@RGB\@tempa
+ \c@lor@arg{#2}%
+%<color4> \c@lor@cmyk@RGB\@tempb
+ \c@lor@arg{#3}%
+%<color4> \c@lor@cmyk@RGB\@tempc
+%<color1> \edef#5{cmyk #1 #2 #3 #4}%
+%<color2> \edef#5{cmyk #1. #2. #3. #4.}%
+%<color3> \edef#5{#1 #2 #3 #4 setcmykcolor}%
+%<color4> \edef#5{\@tempa\@tempb\@tempc}%
+ }
+% \end{macrocode}
+%
+% A 0--1 range value will have been left in |\dimen@| by |\c@lor@arg|.
+% The black value (0--1) will be stored in |\dimen@ii|.
+% Covert to 0--255 integer, and leave in |#1|.
+% \begin{macrocode}
+%<*color4>
+\def\c@lor@cmyk@RGB#1{%
+ \advance\dimen@-\p@
+ \advance\dimen@\dimen@ii
+ \dimen@-\@cclv\dimen@
+ \divide\dimen@\p@
+ \count@\ifdim\dimen@<\z@\z@\else\dimen@\fi
+ \edef#1{\the\count@\space}}
+%</color4>
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\color@rgb#1#2{\c@lor@@rgb#2\@@#1}
+\def\c@lor@@rgb#1,#2,#3\@@#4{%
+ \c@lor@arg{#1}%
+%<color4> \c@lor@rgb@RGB\@tempa
+ \c@lor@arg{#2}%
+%<color4> \c@lor@rgb@RGB\@tempb
+ \c@lor@arg{#3}%
+%<color4> \c@lor@rgb@RGB\@tempc
+%<color1> \edef#4{rgb #1 #2 #3}%
+%<color2> \edef#4{rgb #1. #2. #3.}%
+%<color3> \edef#4{#1 #2 #3 setrgbcolor}%
+%<color4> \edef#4{\@tempa\@tempb\@tempc}%
+ }
+% \end{macrocode}
+%
+% A 0--1 range value will have been left in |\dimen@| by |\c@lor@arg|.
+% Convert to 0--255 integer, and leave in |#1|.
+% \begin{macrocode}
+%<*color4>
+\def\c@lor@rgb@RGB#1{%
+ \dimen@\@cclv\dimen@
+ \count@\dimen@
+ \divide\count@\p@
+ \edef#1{\the\count@\space}}
+%</color4>
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\color@RGB#1#2{\c@lor@@RGB#2\@@#1}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\c@lor@@RGB#1,#2,#3\@@#4{%
+%<!color4> \c@lor@RGB@rgb{#1}\@tempa
+%<!color4> \c@lor@RGB@rgb{#2}\@tempb
+%<!color4> \c@lor@RGB@rgb{#3}\@tempc
+%<!color4> \c@lor@@rgb\@tempa,\@tempb,\@tempc\@@#4%
+%<color4> \edef#4{#1 #2 #3}%
+ }
+% \end{macrocode}
+% % Convert 0--255 integer, |#1|, to 0--1 real, and leave in |#2|.
+% \begin{macrocode}
+%<*!color4>
+\def\c@lor@RGB@rgb#1#2{%
+ \dimen@#1\p@
+ \divide\dimen@\@cclv
+ \edef#2{\strip@pt\dimen@}}
+%</!color4>
+% \end{macrocode}
+%
+% \begin{macrocode}
+%<*color1|color3>
+\def\color@hsb#1#2{\c@lor@@hsb#2\@@#1}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\c@lor@@hsb#1,#2,#3\@@#4{%
+ \c@lor@arg{#1}%
+ \c@lor@arg{#2}%
+ \c@lor@arg{#3}%
+%<color1> \edef#4{hsb #1 #2 #3}%
+%<color3> \edef#4{#1 #2 #3 sethsbcolor}%
+ }
+%</color1|color3>
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\color@named#1#2{\c@lor@@named#2,,\@@#1}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\c@lor@@named#1,#2,#3\@@#4{%
+ \@ifundefined{col@#1}%
+ {\PackageError{color}{Undefined color `#1'}\@ehd}%
+%<color1&!dvipsone> {\edef#4{ #1}}%
+%<color2> {\edef#4{ #1 \if!#2!\else #2.\fi}}%
+%<color3|dvipsone|color4> {\edef#4{\csname col@#1\endcsname}}%
+ }
+% \end{macrocode}
+%
+% Conversion from |\special| syntax to PostScript (for PSTricks).
+% \begin{macrocode}
+%<*color1|color2>
+\def\c@lor@to@ps#1 #2\@@{\csname c@lor@ps@#1\endcsname#2 \@@}
+%</color1|color2>
+%<*color3>
+\def\c@lor@to@ps#1\@@{#1}
+%</color3>
+%<*color4>
+\def\c@lor@to@ps#1#2 #3 #4\@@{%
+ #1#2 255 div #3 255 div #4 255 div setrgbcolor}
+%</color4>
+% \end{macrocode}
+%
+% \begin{macrocode}
+%<*color1>
+\def\c@lor@ps@#1 #2\@@{TeXDict begin #1 end}
+\def\c@lor@ps@rgb#1\@@{#1 setrgbcolor}
+\def\c@lor@ps@hsb#1\@@{#1 sethsbcolor}
+\def\c@lor@ps@cmyk#1\@@{#1 setcmykcolor}
+\def\c@lor@ps@gray#1\@@{#1 setgray}
+%</color1>
+%<*color2>
+\def\c@lor@to@ps@#1 #2\@@{\csname c@lor@ps@#1@\endcsname#2 \@@}
+\def\c@lor@ps@#1 #2\@@{%
+ \expandafter\expandafter\expandafter
+ \c@lor@to@ps@\csname col@#1\expandafter\endcsname\space#2. \@@{#1}}
+\def\c@lor@ps@rgb#1. #2. #3. #4\@@{#1 #2 #3 setrgbcolor}
+\def\c@lor@ps@rgb@#1. #2. #3. #4. #5\@@#6{#1 #2 #3 setrgbcolor}
+\def\c@lor@ps@cmyk#1. #2. #3. #4. #5. #6\@@{#1 #2 #3 #4 setcmykcolor}
+\def\c@lor@ps@cmyk@#1. #2. #3. #4. #5. #6\@@#7{%
+ #1 #2 #3 #4 (#7) findcustomcmykcolor
+ \if!\@firstofone#5!1 \else#5 \fi setcustomcolor}
+%</color2>
+% \end{macrocode}
+%
+% \begin{macrocode}
+%<color1&!dvipsone>\def\current@color{ Black}
+%<color1&dvipsone>\def\current@color{gray 0}
+%<color2>\def\current@color{rgb 0. 0. 0.}
+%<color3>\def\current@color{0 setgray}
+%<color4>\def\current@color{0 0 0}
+% \end{macrocode}
+%
+% \changes{v3.0j}{2014/04/23}
+% {add \cs{nopagecolor} for dvips graphics/3873}
+% \begin{macrocode}
+%<*color1>
+\def\set@color{%
+%<!dvipsone&!dvipdf> \special{color push \current@color
+%<dvipsone> \special{color push}\special{color \current@color
+%<dvipdf> \special{pdf: /C \current@color\space<<
+ }\aftergroup\reset@color}
+\def\reset@color{\special{%
+%<!dvipdf> color pop}}
+%<dvipdf> pdf: /C >> }}
+\def\set@page@color{\special{%
+%<!dvipdf> background \current@color}}
+%<dvipdf> pdf: /BG \current@color}}
+\def\define@color@named#1#2{%
+%<!dvipsone> \expandafter\let\csname col@#1\endcsname\@nnil}
+%<dvipsone> \expandafter\edef\csname col@#1\endcsname{#2}}
+%<dvips> \def\no@page@color{\special{background \string"newpath clip}}
+%</color1>
+%<*color2>
+\def\set@color{%
+ \special{color push}%
+ \special{color \current@color}%
+ \aftergroup\reset@color}
+\def\reset@color{\special{color pop}}
+\def\set@page@color{\c@lor@special\sixt@@n{background \current@color}}
+\def\define@color@named#1#2{%
+ \AtBeginDvi{\special{color define #1 #2}}%
+ \expandafter\edef\csname col@#1\endcsname{#2}}
+%</color2>
+%<*color3>
+\def\set@color{%
+ \Gin@PS@raw{\current@color}\aftergroup\reset@color}
+\def\reset@color{\Gin@PS@raw{\current@color}}
+%</color3>
+%<*color4>
+\def\set@color{%
+ \special{textcolor: \current@color}\aftergroup\reset@color}
+\def\reset@color{\special{textcolor: \current@color}}
+%</color4>
+%<*color3|color4>
+\def\set@page@color{%
+ \c@lor@special\sixt@@n{background color ignored: \current@color}}
+\def\define@color@named#1#2{%
+ \expandafter\edef\csname col@#1\endcsname{#2}}
+%</color3|color4>
+% \end{macrocode}
+%
+% \begin{macrocode}
+%</color1|color2|color3|color4>
+% \end{macrocode}
+%
+% \begin{macrocode}
+%<*colorfix>
+\AtBeginDocument{%
+ \let\@ldc@l@r\color
+ \def\color{\if@inlabel\leavevmode\fi\@ldc@l@r}%
+ \let\@lduseb@x\usebox
+ \def\usebox#1{\@lduseb@x{#1}\set@color}}
+%</colorfix>
+% \end{macrocode}
+%
+% \begin{macrocode}
+%<*dvipsnames>
+\DefineNamedColor{named}{GreenYellow} {cmyk}{0.15,0,0.69,0}
+\DefineNamedColor{named}{Yellow} {cmyk}{0,0,1,0}
+\DefineNamedColor{named}{Goldenrod} {cmyk}{0,0.10,0.84,0}
+\DefineNamedColor{named}{Dandelion} {cmyk}{0,0.29,0.84,0}
+\DefineNamedColor{named}{Apricot} {cmyk}{0,0.32,0.52,0}
+\DefineNamedColor{named}{Peach} {cmyk}{0,0.50,0.70,0}
+\DefineNamedColor{named}{Melon} {cmyk}{0,0.46,0.50,0}
+\DefineNamedColor{named}{YellowOrange} {cmyk}{0,0.42,1,0}
+\DefineNamedColor{named}{Orange} {cmyk}{0,0.61,0.87,0}
+\DefineNamedColor{named}{BurntOrange} {cmyk}{0,0.51,1,0}
+\DefineNamedColor{named}{Bittersweet} {cmyk}{0,0.75,1,0.24}
+\DefineNamedColor{named}{RedOrange} {cmyk}{0,0.77,0.87,0}
+\DefineNamedColor{named}{Mahogany} {cmyk}{0,0.85,0.87,0.35}
+\DefineNamedColor{named}{Maroon} {cmyk}{0,0.87,0.68,0.32}
+\DefineNamedColor{named}{BrickRed} {cmyk}{0,0.89,0.94,0.28}
+\DefineNamedColor{named}{Red} {cmyk}{0,1,1,0}
+\DefineNamedColor{named}{OrangeRed} {cmyk}{0,1,0.50,0}
+\DefineNamedColor{named}{RubineRed} {cmyk}{0,1,0.13,0}
+\DefineNamedColor{named}{WildStrawberry}{cmyk}{0,0.96,0.39,0}
+\DefineNamedColor{named}{Salmon} {cmyk}{0,0.53,0.38,0}
+\DefineNamedColor{named}{CarnationPink} {cmyk}{0,0.63,0,0}
+\DefineNamedColor{named}{Magenta} {cmyk}{0,1,0,0}
+\DefineNamedColor{named}{VioletRed} {cmyk}{0,0.81,0,0}
+\DefineNamedColor{named}{Rhodamine} {cmyk}{0,0.82,0,0}
+\DefineNamedColor{named}{Mulberry} {cmyk}{0.34,0.90,0,0.02}
+\DefineNamedColor{named}{RedViolet} {cmyk}{0.07,0.90,0,0.34}
+\DefineNamedColor{named}{Fuchsia} {cmyk}{0.47,0.91,0,0.08}
+\DefineNamedColor{named}{Lavender} {cmyk}{0,0.48,0,0}
+\DefineNamedColor{named}{Thistle} {cmyk}{0.12,0.59,0,0}
+\DefineNamedColor{named}{Orchid} {cmyk}{0.32,0.64,0,0}
+\DefineNamedColor{named}{DarkOrchid} {cmyk}{0.40,0.80,0.20,0}
+\DefineNamedColor{named}{Purple} {cmyk}{0.45,0.86,0,0}
+\DefineNamedColor{named}{Plum} {cmyk}{0.50,1,0,0}
+\DefineNamedColor{named}{Violet} {cmyk}{0.79,0.88,0,0}
+\DefineNamedColor{named}{RoyalPurple} {cmyk}{0.75,0.90,0,0}
+\DefineNamedColor{named}{BlueViolet} {cmyk}{0.86,0.91,0,0.04}
+\DefineNamedColor{named}{Periwinkle} {cmyk}{0.57,0.55,0,0}
+\DefineNamedColor{named}{CadetBlue} {cmyk}{0.62,0.57,0.23,0}
+\DefineNamedColor{named}{CornflowerBlue}{cmyk}{0.65,0.13,0,0}
+\DefineNamedColor{named}{MidnightBlue} {cmyk}{0.98,0.13,0,0.43}
+\DefineNamedColor{named}{NavyBlue} {cmyk}{0.94,0.54,0,0}
+\DefineNamedColor{named}{RoyalBlue} {cmyk}{1,0.50,0,0}
+\DefineNamedColor{named}{Blue} {cmyk}{1,1,0,0}
+\DefineNamedColor{named}{Cerulean} {cmyk}{0.94,0.11,0,0}
+\DefineNamedColor{named}{Cyan} {cmyk}{1,0,0,0}
+\DefineNamedColor{named}{ProcessBlue} {cmyk}{0.96,0,0,0}
+\DefineNamedColor{named}{SkyBlue} {cmyk}{0.62,0,0.12,0}
+\DefineNamedColor{named}{Turquoise} {cmyk}{0.85,0,0.20,0}
+\DefineNamedColor{named}{TealBlue} {cmyk}{0.86,0,0.34,0.02}
+\DefineNamedColor{named}{Aquamarine} {cmyk}{0.82,0,0.30,0}
+\DefineNamedColor{named}{BlueGreen} {cmyk}{0.85,0,0.33,0}
+\DefineNamedColor{named}{Emerald} {cmyk}{1,0,0.50,0}
+\DefineNamedColor{named}{JungleGreen} {cmyk}{0.99,0,0.52,0}
+\DefineNamedColor{named}{SeaGreen} {cmyk}{0.69,0,0.50,0}
+\DefineNamedColor{named}{Green} {cmyk}{1,0,1,0}
+\DefineNamedColor{named}{ForestGreen} {cmyk}{0.91,0,0.88,0.12}
+\DefineNamedColor{named}{PineGreen} {cmyk}{0.92,0,0.59,0.25}
+\DefineNamedColor{named}{LimeGreen} {cmyk}{0.50,0,1,0}
+\DefineNamedColor{named}{YellowGreen} {cmyk}{0.44,0,0.74,0}
+\DefineNamedColor{named}{SpringGreen} {cmyk}{0.26,0,0.76,0}
+\DefineNamedColor{named}{OliveGreen} {cmyk}{0.64,0,0.95,0.40}
+\DefineNamedColor{named}{RawSienna} {cmyk}{0,0.72,1,0.45}
+\DefineNamedColor{named}{Sepia} {cmyk}{0,0.83,1,0.70}
+\DefineNamedColor{named}{Brown} {cmyk}{0,0.81,1,0.60}
+\DefineNamedColor{named}{Tan} {cmyk}{0.14,0.42,0.56,0}
+\DefineNamedColor{named}{Gray} {cmyk}{0,0,0,0.50}
+\DefineNamedColor{named}{Black} {cmyk}{0,0,0,1}
+\DefineNamedColor{named}{White} {cmyk}{0,0,0,0}
+%</dvipsnames>
+% \end{macrocode}
+%
+% \section{dvips}
+% A \LaTeXe\ graphics driver file for Tom Rokicki's \emph{dvips}
+% driver; tested with version 5.58f.
+%
+% \begin{macrocode}
+%<*dvips>
+% \end{macrocode}
+%
+% \subsection{Colour}
+% Uses the generic `color1' code.
+%
+% \subsection{File inclusion}
+%
+% \begin{macro}{\Ginclude@eps}
+% |#1| input file (or command)
+% \begin{macrocode}
+\def\Ginclude@eps#1{%
+ \message{<#1>}%
+ \bgroup
+% \end{macrocode}
+% \emph{dvips} likes to work with its own pixel resolution, so
+% mangle the sizes slightly.
+% \begin{macrocode}
+ \def\@tempa{!}%
+ \dimen@\Gin@req@width
+ \dimen@ii.1bp%
+ \divide\dimen@\dimen@ii
+ \@tempdima\Gin@req@height
+ \divide\@tempdima\dimen@ii
+ \special{PSfile="#1"\space
+ llx=\Gin@llx\space
+ lly=\Gin@lly\space
+ urx=\Gin@urx\space
+ ury=\Gin@ury\space
+ \ifx\Gin@scalex\@tempa\else rwi=\number\dimen@\space\fi
+ \ifx\Gin@scaley\@tempa\else rhi=\number\@tempdima\space\fi
+ \ifGin@clip clip\fi}%
+ \egroup}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\Ginclude@bmp}
+% |#1| input file; if zero size is requested, the graphic will
+% come at `natural' size.
+% \begin{macrocode}
+\def\Ginclude@bmp#1{%
+ \message{<#1>}%
+ \dimen@\Gin@req@height
+ \advance\dimen@ by-\Gin@lly bp
+ \kern-\Gin@llx bp\raise\Gin@req@height\hbox{%
+ \ifdim\Gin@urx bp=\z@
+ \ifdim\Gin@ury bp=\z@
+ \special{em: graph #1}%
+ \else
+ \special{em: graph #1,\Gin@urx bp}%
+ \fi
+ \else
+ \special{em: graph #1,\Gin@urx bp,\Gin@ury bp}%
+ \fi
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\Ginclude@pict}
+% \begin{macro}{\Ginclude@pntg}
+% \begin{macro}{\oztex@include}
+% PICT/PNTG format from the Mac. Actually only currently supported by
+% the version of dvips distributed with \OzTeX, and with the built in
+% \OzTeX\ drivers, but put here anyway as it is not much code and
+% increases portability between the systems as now |[dvips]| and
+% |[oztex]| share the same back end.
+% \begin{macrocode}
+\def\oztex@include#1#2{%
+ \dimen@1bp%
+ \divide\Gin@req@width\dimen@
+ \divide\Gin@req@height\dimen@
+ \special{#1=#2\space
+ \@width=\number\Gin@req@width \space
+ \@height=\number\Gin@req@height}}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\Ginclude@pntg{\oztex@include{pntg}}
+\def\Ginclude@pict{\oztex@include{pict}}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \subsection{Rotation}
+% \begin{macrocode}
+\def\Grot@start{%
+ \special{ps: gsave currentpoint
+ currentpoint translate \Grot@angle\space neg
+ rotate neg exch neg exch translate}}
+\def\Grot@end{\special{ps: currentpoint grestore moveto}}
+% \end{macrocode}
+% \subsection{Scaling}
+% \begin{macrocode}
+\def\Gscale@start{\special{ps: currentpoint currentpoint translate
+ \Gscale@x\space \Gscale@y\space scale neg exch neg exch translate}}
+\def\Gscale@end{\special{ps: currentpoint currentpoint translate
+ 1 \Gscale@x\space div 1 \Gscale@y\space div scale
+ neg exch neg exch translate}}
+% \end{macrocode}
+%
+% \section{Literal Postscript}
+%
+% Raw PostScript code, no save/restore.
+% \begin{macrocode}
+\def\Gin@PS@raw#1{\special{ps: #1}}
+% \end{macrocode}
+%
+% PostScript code, to be surrounded by save/restore by the driver.
+% Coordinate system standard PostScript, but with origin
+% at current (\TeX) position.
+% \begin{macrocode}
+\def\Gin@PS@restored#1{\special{" #1}}
+% \end{macrocode}
+%
+% PostScript code to be inserted in the Header section of the final
+% PostScript. Must be issued on the first page of a document.
+% \begin{macrocode}
+\def\Gin@PS@literal@header#1{\AtBeginDvi{\special{! #1}}}
+% \end{macrocode}
+%
+% Name of external file, the contents of which are to be inserted in
+% the Header section of the final PostScript. Must be issued on the
+% first page of a document.
+% \begin{macrocode}
+\def\Gin@PS@file@header#1{\AtBeginDvi{\special{header=#1}}}
+% \end{macrocode}
+%
+% \section{Page Size}
+%
+% \changes{v3.0l}{2016/06/02}{page size special added to patch pdftex.def}
+% \changes{v3.0m}{2016/06/17}{guards for contributed packages and plain TeX}
+% \begin{macrocode}
+\@ifundefined{ifGin@setpagesize}
+ {\expandafter\let\csname ifGin@setpagesize\expandafter\endcsname
+ \csname iftrue\endcsname}
+ {}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\ifGin@setpagesize
+\ifx\paperwidth\@undefined\else
+ \AtBeginDocument{\AtBeginDvi{%
+ \begingroup
+ \ifx\stockwidth\@undefined\else
+ \paperwidth\stockwidth
+ \paperheight\stockheight
+ \fi
+ \ifdim\paperwidth>\z@
+ \ifdim\paperheight>\z@
+ \special{papersize=\the\paperwidth,\the\paperheight}%
+ \fi
+ \fi
+ \endgroup}}
+\fi
+\fi
+% \end{macrocode}
+%
+% \begin{macrocode}
+%</dvips>
+% \end{macrocode}
+%
+%
+% \section{dvipdf}
+% A \LaTeXe\ graphics driver file for \emph{dvipdf} driver.
+%
+% \begin{macrocode}
+%<*dvipdf>
+% \end{macrocode}
+%
+% \subsection{Colour}
+% Uses the generic `color1' code.
+%
+% \subsection{File inclusion}
+%
+% \begin{macro}{\Ginclude@eps}
+% |#1| input file (or command)
+% \begin{macrocode}
+\def\Ginclude@eps#1{%
+ \message{<#1>}%
+ \bgroup
+% \end{macrocode}
+% \emph{dvips} likes to work with its own pixel resolution, so
+% mangle the sizes slightly.
+% \begin{macrocode}
+ \def\@tempa{!}%
+ \dimen@\Gin@req@width
+ \dimen@ii.1bp%
+ \divide\dimen@\dimen@ii
+ \@tempdima\Gin@req@height
+ \divide\@tempdima\dimen@ii
+ \special{PSfile="#1"\space
+ llx=\Gin@llx\space
+ lly=\Gin@lly\space
+ urx=\Gin@urx\space
+ ury=\Gin@ury\space
+ \ifx\Gin@scalex\@tempa\else rwi=\number\dimen@\space\fi
+ \ifx\Gin@scaley\@tempa\else rhi=\number\@tempdima\space\fi
+ \ifGin@clip clip\fi}%
+ \egroup}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\Ginclude@bmp}
+% |#1| input file; if zero size is requested, the graphic will
+% come at `natural' size.
+% \begin{macrocode}
+\def\Ginclude@bmp#1{%
+ \message{<#1>}%
+ \dimen@\Gin@req@height
+ \advance\dimen@ by-\Gin@lly bp
+ \kern-\Gin@llx bp\raise\Gin@req@height\hbox{%
+ \ifdim\Gin@urx bp=\z@
+ \ifdim\Gin@ury bp=\z@
+ \special{pdf: /GRAPH #1}%
+ \else
+ \special{pdf: /GRAPH #1 \number\Gin@req@width sp}%
+ \fi
+ \else
+ \special{pdf: /GRAPH #1 \number\Gin@req@width sp
+ \number\Gin@req@height sp}%
+ \fi}}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsection{Rotation}
+% \begin{macrocode}
+\def\Grot@start{%
+\special{pdf: /ROT \Grot@angle\space << }}
+\def\Grot@end{\special{pdf: /ROT >> }}
+% \end{macrocode}
+%
+% \subsection{Scaling}
+% \begin{macrocode}
+\def\Gscale@start{\special{pdf: /S \Gscale@x\space \Gscale@y\space << }}
+\def\Gscale@end{\special{pdf: /S \space >> }}
+% \end{macrocode}
+%
+% \section{Literal Postscript}
+%
+% Raw PostScript code, no save/restore.
+% \begin{macrocode}
+\def\Gin@PS@raw#1{\special{ps: #1}}
+% \end{macrocode}
+%
+% PostScript code, to be surrounded by save/restore by the driver.
+% Coordinate system standard PostScript, but with origin
+% at current (\TeX) position.
+% \begin{macrocode}
+\def\Gin@PS@restored#1{\special{" #1}}
+% \end{macrocode}
+%
+% PostScript code to be inserted in the Header section of the final
+% PostScript. Must be issued on the first page of a document.
+% \begin{macrocode}
+\def\Gin@PS@literal@header#1{\AtBeginDvi{\special{! #1}}}
+% \end{macrocode}
+%
+% Name of external file, the contents of which are to be inserted in
+% the Header section of the final PostScript. Must be issued on the
+% first page of a document.
+% \begin{macrocode}
+\def\Gin@PS@file@header#1{\AtBeginDvi{\special{header=#1}}}
+% \end{macrocode}
+%
+% \subsection{File extensions}
+%
+% \begin{macrocode}
+\@namedef{Gin@rule@.msp}#1{{bmp}{.bb}{#1}}
+\@namedef{Gin@rule@.jpg}#1{{bmp}{.bb}{#1}}
+\@namedef{Gin@rule@.bmp}#1{{bmp}{.bb}{#1}}
+% \end{macrocode}
+%
+% \begin{macrocode}
+%</dvipdf>
+% \end{macrocode}
+%
+% \section{\OzTeX}
+%
+% A \LaTeXe\ graphics driver file for \OzTeX\
+% (versions 1.42 and later),
+% by Andrew Trevorrow.
+% \begin{macrocode}
+%<*oztex>
+% \end{macrocode}
+%\subsection{Graphics inclusion}
+% \begin{macrocode}
+\def\Ginclude@eps{\Oztex@Include{epsf}}
+\def\Ginclude@pntg{\Oztex@Include{pntg}}
+\def\Ginclude@pict{\Oztex@Include{pict}}
+\def\Oztex@Include#1#2{%
+ \ifGin@clip
+ \typeout{No clipping support in OzTeX}%
+ \fi
+ \divide\Gin@req@width by 65781% convert sp to bp
+ \divide\Gin@req@height by 65781%
+ \special{#1=#2\space
+ width=\number\Gin@req@width \space
+ height=\number\Gin@req@height
+ }%
+}
+%</oztex>
+% \end{macrocode}
+%\section{Textures}
+% A \LaTeXe\ graphics driver file for Blue Sky's Textures
+%
+% \textbf{WARNING! There is ongoing work to produce a new version of
+% the textures support. Do not rely on anything in this file being in
+% the next version!}
+%
+%
+% \begin{macrocode}
+%<*textures>
+% \end{macrocode}
+% \subsection{Graphics inclusion}
+%
+%
+% \begin{macrocode}
+\PackageInfo{graphics/color}
+ {This file uses the advanced color support\MessageBreak
+ available in textures1.7\MessageBreak
+ If you are using color with an earlier version\MessageBreak
+ of textures, edit graphics.ins where marked,\MessageBreak
+ and re-latex graphics.ins.\MessageBreak\MessageBreak
+ If you are using textures1.7\MessageBreak
+ you may want to delete this warning\MessageBreak
+ from textures.def.\MessageBreak\MessageBreak
+ The code for scaling/rotation and file inclusion\MessageBreak
+ in this file is still rudimentary, and does not\MessageBreak
+ use textures' full capabilities.\MessageBreak\MessageBreak
+ A new textures.def is currently being developed\@gobble}
+% \end{macrocode}
+%
+%
+% \begin{macrocode}
+\def\Ginclude@eps{\Textures@Include{illustration}}
+\def\Ginclude@pict{\Textures@Include{pictfile}}
+\def\Textures@Include#1#2{%
+ \def\@tempa{!}%
+ \ifx\Gin@scaley\@tempa
+ \let\Gin@scaley\Gin@scalex
+ \else
+ \ifx\Gin@scalex\@tempa\let\Gin@scalex\Gin@scaley\fi
+ \fi
+ \setlength\@tempdima{\Gin@scalex pt}%
+ \setlength\@tempdimb{\Gin@scaley pt}%
+ \ifdim\@tempdima>\@tempdimb
+ \let\Gin@scalex\Gin@scaley
+ \fi
+ \ifGin@clip
+ \typeout{no clipping support in Textures}%
+ \fi
+ \@tempdimb=1000sp%
+ \setlength\@tempdima{\Gin@scalex\@tempdimb}%
+ \special{#1 #2\space scaled \number\@tempdima}%
+}
+% \end{macrocode}
+% \subsection{Rotation}
+% This code was written when no unprotected postscript code was allowed;
+% it could almost certainly be rewritten now with `rawpostscript'.
+% \begin{macrocode}
+\def\Grot@start{\special{postscript
+ 0 0 transform
+ grestore
+ matrix currentmatrix
+ 3 1 roll
+ itransform
+ dup 3 -1 roll
+ dup 4 1 roll exch
+ translate
+ \Grot@angle\space neg rotate
+ neg exch neg exch translate
+ gsave}}
+\def\Grot@end{\special{postscript grestore setmatrix gsave}}
+% \end{macrocode}
+% \subsection{Colour}
+% This will only work for versions 1.6 and Version 1.7 uses `color2'.
+% \begin{macrocode}
+%<color3>\def\Gin@PS@raw#1{\special{rawpostscript #1}}
+%</textures>
+% \end{macrocode}
+%
+% \section{dvialw}
+% A \LaTeXe\ graphics driver file for dvialw, by Nelson Beebe
+% \begin{macrocode}
+%<*dvialw>
+% \end{macrocode}
+% \subsection{Rotation}
+% \begin{macrocode}
+\def\Ginclude@eps#1{%
+ \def\@tempa{!}%
+ \ifx\Gin@scaley\@tempa
+ \let\Gin@scaley\Gin@scalex
+ \else
+ \ifx\Gin@scalex\@tempa\let\Gin@scalex\Gin@scaley\fi
+ \fi
+ \ifGin@clip
+ \typeout{no clipping support in dvialw}%
+ \fi
+ \special{language "PS",
+ literal "\Gin@scalex\space
+ \Gin@scaley\space scale",
+ position = "bottom left",
+ include "#1\space"}%
+}
+%</dvialw>
+% \end{macrocode}
+% \section{emtex}
+% A \LaTeXe\ graphics driver file for Eberhard Mattes' emTeX
+% \begin{macrocode}
+%<*emtex>
+% \end{macrocode}
+% \subsection{Graphics file inclusion}
+% \begin{macrocode}
+\def\Ginclude@bmp#1{%
+ \raise\Gin@req@height\hbox{\special{em:graph #1}}%
+\typeout{WARNING: emtex does not permit graphics to be scaled}%
+}
+%</emtex>
+% \end{macrocode}
+% \section{dvilaser/ps}
+% A \LaTeXe\ graphics driver file for Arbortext's dvilaser/ps
+% \begin{macrocode}
+%<*dvilaser>
+% \end{macrocode}
+%\subsection{Graphic file inclusion}
+% \begin{macrocode}
+\def\Ginclude@eps#1{%
+\ifGin@clip
+ \typeout{no clipping support in dvilaser/ps}%
+\fi
+\special{ps: epsfile #1\space \the\Gin@req@width}%
+}
+%</dvilaser>
+% \end{macrocode}
+% \section{psprint}
+% A \LaTeXe\ graphics driver file for Trevorrow's psprint
+% \begin{macrocode}
+%<*psprint>
+% \end{macrocode}
+%\subsection{Graphic file inclusion}
+% \begin{macrocode}
+\def\Ginclude@eps#1{%
+ \def\@tempa{!}%
+ \ifx\Gin@scaley\@tempa
+ \let\Gin@scaley\Gin@scalex
+ \else
+ \ifx\Gin@scalex\@tempa\let\Gin@scalex\Gin@scaley\fi
+ \fi
+ \ifGin@clip
+ \typeout{no clipping support in psprint}%
+ \fi
+ \special{#1\space
+ \Gin@scalex\space \Gin@scaley\space scale
+ \Gin@llx\space neg
+ \Gin@lly \space neg translate
+}%
+}
+%</psprint>
+% \end{macrocode}
+% \section{dvipsone}
+%
+% A \LaTeXe\ graphics driver file for Y\&Y's dvipsone
+% \begin{macrocode}
+%<*dvipsone>
+% \end{macrocode}
+%
+% \subsection{Graphic file inclusion}
+%
+% PostScript Files.
+% \begin{macrocode}
+\def\Ginclude@eps#1{%
+ \message{<#1>}%
+ \bgroup
+ \def\@tempa{!}%
+ \dimen@\Gin@req@width
+ \dimen@ii.1bp%
+ \divide\dimen@\dimen@ii
+ \@tempdima\Gin@req@height
+ \divide\@tempdima\dimen@ii
+ \special{PSfile="#1"\space
+ llx=\Gin@llx\space
+ lly=\Gin@lly\space
+ urx=\Gin@urx\space
+ ury=\Gin@ury\space
+ \ifx\Gin@scalex\@tempa\else rwi=\number\dimen@\space\fi
+ \ifx\Gin@scaley\@tempa\else rhi=\number\@tempdima\space\fi
+ \ifGin@clip clip\fi}%
+ \egroup}
+% \end{macrocode}
+%
+% Tiff files.
+% \begin{macrocode}
+\def\Ginclude@tiff#1{%
+\message{<#1>}%
+ \special{insertimage: #1 \number\Gin@req@width\space
+ \number\Gin@req@height}}
+% \end{macrocode}
+%
+% Windows Metafiles.
+% \begin{macrocode}
+\def\Ginclude@wmf#1{%
+ \message{<#1>}%
+ \special{insertmf: #1 0 0 \number\Gin@req@width\space
+ \number\Gin@req@height}}
+% \end{macrocode}
+%
+% \begin{macrocode}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\Gin@PS@raw#1{\special{ps: #1}}
+% \end{macrocode}
+%
+% \subsection{Rotation}
+% \begin{macrocode}
+\def\Grot@start{%
+ \special{ps: gsave currentpoint
+ currentpoint translate \Grot@angle\space
+ rotate neg exch neg exch translate}}
+\def\Grot@end{%
+ \special{ps: currentfont currentpoint grestore moveto setfont}}
+% \end{macrocode}
+%
+% \subsection{Scaling}
+% \begin{macrocode}
+\def\Gscale@start{\special{ps: currentpoint currentpoint translate
+ \Gscale@x\space \Gscale@y\space scale neg exch neg exch translate}}
+\def\Gscale@end{\special{ps: currentpoint currentpoint translate
+ 1 \Gscale@x\space div 1 \Gscale@y\space div scale
+ neg exch neg exch translate}}
+% \end{macrocode}
+%
+% \subsection{File Extensions}
+%
+% \begin{macrocode}
+\@namedef{Gin@rule@.wmf}#1{{wmf}{}{#1}}
+\@namedef{Gin@rule@.clp}#1{{wmf}{}{#1}}
+% \end{macrocode}
+%
+% \section{Literal Postscript}
+%
+% Raw PostScript code, no save/restore.
+% \begin{macrocode}
+\def\Gin@PS@raw#1{\special{ps: #1}}
+% \end{macrocode}
+%
+% PostScript code, to be surrounded by save/restore by the driver.
+% Coordinate system standard PostScript, but with origin
+% at current (\TeX) position.
+% \begin{macrocode}
+\def\Gin@PS@restored#1{\special{" #1}}
+% \end{macrocode}
+%
+% PostScript code to be inserted in the Header section of the final
+% PostScript. Must be issued on the first page of a document.
+% \begin{macrocode}
+\def\Gin@PS@literal@header#1{\AtBeginDvi{\special{headertext=#1}}}
+% \end{macrocode}
+%
+% Name of external file, the contents of which are to be inserted in
+% the Header section of the final PostScript. Must be issued on the
+% first page of a document.
+% \begin{macrocode}
+\def\Gin@PS@file@header#1{\AtBeginDvi{\special{header=#1}}}
+% \end{macrocode}
+%
+% \begin{macrocode}
+%</dvipsone>
+% \end{macrocode}
+%
+% \section{dviwindo}
+% A \LaTeXe\ graphics driver file for Y\&Y's dviwindo.
+%
+% This driver now uses the same file as |dvipsone|.
+%
+% \section{dvitops}
+% A \LaTeXe\ graphics driver file for James Clark's dvitops
+% \begin{macrocode}
+%<*dvitops>
+% \end{macrocode}
+% \subsection{Rotation}
+% \begin{macrocode}
+\newcount\Grot@count
+\Grot@count=\@ne
+\def\Grot@start{\special{dvitops: origin
+ rot\the\@tempdima}%
+\special{dvitops: begin rot\the\Grot@count}}%
+\def\Grot@end{\special{dvitops: end}%
+\special{dvitops: rotate rot\the\Grot@count \space
+ \Grot@angle}%
+\global\advance\Grot@count by\@ne}%
+% \end{macrocode}
+% \subsection{Graphic file inclusion}
+% \begin{macrocode}
+\def\Ginclude@eps#1{%
+% These cause an arithmetic overflow, so I've commented them
+% out. Presumably they were there for some reason.
+% Any dvitops users out there??
+% \multiply\Gin@req@width by \@m
+% \multiply\Gin@req@height by \@m
+\ifGin@clip
+ \typeout{no clipping support in dvitops}%
+\fi
+\special{import #1\space \the\Gin@req@width\space
+ \the\Gin@req@height\space fill}}
+% \end{macrocode}
+%
+% \begin{macrocode}
+%</dvitops>
+% \end{macrocode}
+%
+%\section{dvi2ps}
+% A \LaTeXe\ graphics driver file for original dvi2ps
+% \begin{macrocode}
+%<*dvi2ps>
+% \end{macrocode}
+%
+% \subsection{Graphic file inclusion}
+% \begin{macrocode}
+\def\Ginclude@eps#1{%
+ \def\@tempa{!}%
+ \ifx\Gin@scaley\@tempa
+ \let\Gin@scaley\Gin@scalex
+ \else
+ \ifx\Gin@scalex\@tempa\let\Gin@scalex\Gin@scaley\fi
+ \fi
+ \ifGin@clip
+ \typeout{no clipping support in dvi2ps}%
+ \fi
+ \special{psfile=#1\space
+ hscale=\Gin@scalex\space 1000 mul
+ vscale=\Gin@scaley\space 1000 mul}}
+% \end{macrocode}
+%
+% \begin{macrocode}
+%</dvi2ps>
+% \end{macrocode}
+%
+% \section{pctexps}
+% A \LaTeXe\ graphics driver file for Personal TeX's PTI Laser/PS;
+% from information supplied by Lance Carnes and Tao Wang
+% |<pti@crl.com>|.
+% \begin{macrocode}
+%<*pctexps>
+% \end{macrocode}
+%
+% \subsection{Graphic file inclusion}
+%
+% \begin{macrocode}
+\def\Ginclude@eps#1{%
+\message{<#1>}%
+ \ifGin@clip
+ \typeout{no clipping support in pctexps}%
+ \fi
+ \Gin@req@width.03515\Gin@req@width
+ \Gin@req@height.03515\Gin@req@height
+ \special{ps:#1\space x=\strip@pt\Gin@req@width cm,
+ y=\strip@pt\Gin@req@height cm}}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\Ginclude@ps#1{%
+\message{<#1>}%
+ \ifGin@clip
+ \typeout{no clipping support in pctexps}%
+ \fi
+ \hbox{\kern-\Gin@llx bp\raise-\Gin@lly bp\hbox{\special{ps:#1}}}%
+ \typeout{^^J%
+---------------------------------------------------------^^J%
+.ps graphics without bounding box information cannot be^^J%
+scaled. If the file actually contains the information,^^J%
+please rename the file to .eps file extension.^^J%
+---------------------------------------------------------^^J}}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\Gin@extensions{.eps,.ps}
+\@namedef{Gin@rule@.ps}#1{{ps}{.ps}{#1}}
+\@namedef{Gin@rule@.eps}#1{{eps}{.eps}{#1}}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\Gin@PS@raw#1{\special{ps::#1}}
+\def\Grot@start{%
+ \special{ps::gsave currentpoint
+ currentpoint translate \Grot@angle\space
+ rotate neg exch neg exch translate}}
+\def\Grot@end{\special{ps:: currentpoint grestore moveto}}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\Gscale@start{\special{ps:: currentpoint currentpoint translate
+ \Gscale@x\space \Gscale@y\space scale neg exch neg exch translate}}
+\def\Gscale@end{\special{ps:: currentpoint currentpoint translate
+ 1 \Gscale@x\space div 1 \Gscale@y\space div scale
+ neg exch neg exch translate}}
+% \end{macrocode}
+%
+% \begin{macrocode}
+%</pctexps>
+% \end{macrocode}
+%
+% \section{pctex32}
+% A \LaTeXe\ graphics driver file for Personal TeX's PC TeX for 32 bit
+% Windows; Code supplied by Tao Wang |<pti@crl.com>|.
+%
+% \subsection{Colour}
+% Uses the generic `color1' code.
+%
+% \begin{macrocode}
+%<*pctex32>
+% \end{macrocode}
+%
+% \subsection{Graphic file inclusion}%
+% \begin{macrocode}
+% including PostScript graphics
+\def\Ginclude@eps#1{%
+ \message{<#1>}%
+ \bgroup
+ \def\@tempa{!}%
+ \dimen@\Gin@req@width
+ \dimen@ii.1bp%
+ \divide\dimen@\dimen@ii
+ \@tempdima\Gin@req@height
+ \divide\@tempdima\dimen@ii
+ \special{PSfile="#1"\space
+ llx=\Gin@llx\space
+ lly=\Gin@lly\space
+ urx=\Gin@urx\space
+ ury=\Gin@ury\space
+ \ifx\Gin@scalex\@tempa\else rwi=\number\dimen@\space\fi
+ \ifx\Gin@scaley\@tempa\else rhi=\number\@tempdima\space\fi
+ \ifGin@clip clip\fi}%
+ \egroup}
+% \end{macrocode}
+%
+% including BMP graphics
+% \begin{macrocode}
+\def\Ginclude@bmp#1{%
+\message{<#1>}%
+ \ifGin@clip
+ \typeout{no clipping support for BMP graphics in PCTeX32}%
+ \fi
+ \Gin@req@width.03515\Gin@req@width
+ \Gin@req@height.03515\Gin@req@height
+ \special{bmp:#1\space x=\strip@pt\Gin@req@width cm,
+ y=\strip@pt\Gin@req@height cm}}
+% \end{macrocode}
+%
+% including WMF graphics
+% \begin{macrocode}
+\def\Ginclude@wmf#1{%
+\message{<#1>}%
+ \ifGin@clip
+ \typeout{no clipping support for WMF graphics in PCTeX32}%
+ \fi
+ \Gin@req@width.03515\Gin@req@width
+ \Gin@req@height.03515\Gin@req@height
+ \special{wmf:#1\space x=\strip@pt\Gin@req@width cm,
+ y=\strip@pt\Gin@req@height cm}}
+% \end{macrocode}
+%
+% \subsection{Scaling and Rotating}
+% PostScript rotation and scaling
+% \begin{macrocode}
+\def\Grot@start{%
+ \special{ps:: gsave currentpoint
+ currentpoint translate \Grot@angle\space neg
+ rotate neg exch neg exch translate}}
+\def\Grot@end{\special{ps:: currentpoint grestore moveto}}
+\def\Gscale@start{\special{ps:: currentpoint currentpoint translate
+ \Gscale@x\space \Gscale@y\space scale neg exch neg exch translate}}
+\def\Gscale@end{\special{ps:: currentpoint currentpoint translate
+ 1 \Gscale@x\space div 1 \Gscale@y\space div scale
+ neg exch neg exch translate}}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\Gin@PS@raw#1{\special{ps:: #1}}
+\def\Gin@PS@restored#1{\special{" #1}}
+% \end{macrocode}
+%
+% \subsection{Default Extensions}
+%
+% \begin{macrocode}
+\def\Gin@extensions{.eps,.ps,.wmf,.bmp}
+\@namedef{Gin@rule@.ps}#1{{eps}{.ps}{#1}}
+\@namedef{Gin@rule@.eps}#1{{eps}{.eps}{#1}}
+\@namedef{Gin@rule@.bmp}#1{{bmp}{}{#1}}
+\@namedef{Gin@rule@.wmf}#1{{wmf}{}{#1}}
+% \end{macrocode}
+%
+% \begin{macrocode}
+%</pctex32>
+% \end{macrocode}
+%
+% \section{pctexwin}
+% A \LaTeXe\ graphics driver file for Personal TeX's PC TeX for Windows;
+% from information supplied by Lance Carnes and Tao Wang
+% |<pti@crl.com>|.
+% \begin{macrocode}
+%<*pctexwin>
+% \end{macrocode}
+%
+% \subsection{Graphic file inclusion}
+%
+% \begin{macrocode}
+\def\Ginclude@eps#1{%
+\message{<#1>}%
+ \ifGin@clip
+ \typeout{no clipping support in pctexwin}%
+ \fi
+ \Gin@req@width.03515\Gin@req@width
+ \Gin@req@height.03515\Gin@req@height
+ \special{eps:#1\space x=\strip@pt\Gin@req@width cm,
+ y=\strip@pt\Gin@req@height cm}}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\Ginclude@ps#1{%
+\message{<#1>}%
+ \ifGin@clip
+ \typeout{no clipping support in pctexwin}%
+ \fi
+ \hbox{\kern-\Gin@llx bp\raise-\Gin@lly bp\hbox{\special{ps:#1}}}%
+ \typeout{^^J%
+---------------------------------------------------------^^J%
+.ps graphics without bounding box information cannot be^^J%
+scaled. If the file actually contains the information,^^J%
+please rename the file to .eps file extension.^^J%
+---------------------------------------------------------^^J%
+}}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\Ginclude@bmp#1{%
+\message{<#1>}%
+ \ifGin@clip
+ \typeout{no clipping support in pctexwin}%
+ \fi
+ \Gin@req@width.03515\Gin@req@width
+ \Gin@req@height.03515\Gin@req@height
+ \special{bmp:#1\space x=\strip@pt\Gin@req@width cm,
+ y=\strip@pt\Gin@req@height cm}}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\Ginclude@wmf#1{%
+\message{<#1>}%
+ \ifGin@clip
+ \typeout{no clipping support in pctexwin}%
+ \fi
+ \Gin@req@width.03515\Gin@req@width
+ \Gin@req@height.03515\Gin@req@height
+ \special{wmf:#1\space x=\strip@pt\Gin@req@width cm,
+ y=\strip@pt\Gin@req@height cm}}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\Gin@extensions{.eps,.ps,.wmf,.bmp}
+\@namedef{Gin@rule@.bmp}#1{{bmp}{}{#1}}
+\@namedef{Gin@rule@.wmf}#1{{wmf}{}{#1}}
+\@namedef{Gin@rule@.ps}#1{{ps}{.ps}{#1}}
+\@namedef{Gin@rule@.eps}#1{{eps}{.eps}{#1}}
+% \end{macrocode}
+%
+% \begin{macrocode}
+%</pctexwin>
+% \end{macrocode}
+%
+% \section{pctexhp}
+% A \LaTeXe\ graphics driver file for Personal TeX's PTI Laser/HP;
+% from information supplied by Lance Carnes and Tao Wang
+% |<pti@crl.com>|.
+% \begin{macrocode}
+%<*pctexhp>
+% \end{macrocode}
+% \subsection{Graphic file inclusion}
+% \begin{macrocode}
+\def\Ginclude@pcl#1{%
+\message{<#1>}%
+ \ifGin@clip
+ \typeout{no clipping support in pctexhp}%
+ \fi
+ \hbox{\kern-\Gin@llx bp\raise-\Gin@lly bp\hbox{\special{pcl:#1}}}%
+ \typeout{WARNING: pctexhp does not permit graphics to be scaled}}
+\@namedef{Gin@rule@.pcl}#1{{pcl}{}{#1}}
+\def\Gin@extensions{.pcl}
+%</pctexhp>
+% \end{macrocode}
+%
+% \section{pubps}
+% A \LaTeXe\ graphics driver file for Arbortext's PUBps;
+% information from Peter R Wilson |pwilson@rdrc.rpi.edu|.
+% \begin{macrocode}
+%<*pubps>
+% \end{macrocode}
+% \subsection{Rotation}
+% \begin{macrocode}
+\def\Grot@start{\special{ps: gsave currentpoint
+ currentpoint translate \Grot@angle\space
+ rotate neg exch neg exch translate}}
+\def\Grot@end{\special{ps: currentpoint grestore moveto}}
+%</pubps>
+% \end{macrocode}
+%
+% \section{dviwin}
+% A \LaTeXe\ graphics driver file for Hippocrates Sendoukas' dviwin
+% \begin{macrocode}
+%<*dviwin>
+% \end{macrocode}
+% \subsection{Graphic file inclusion}
+% Dviwin sorts out the graphics type itself based on extension.
+% They all use the same |\special|, so as far as graphics.sty is
+% concerned they are all the same `type'. Use `bmp' for the type
+% as that is as good a name as any. Make this the default.
+% \begin{macrocode}
+\@namedef{Gin@rule@*}#1{{bmp}{}{#1}}
+\def\Ginclude@bmp#1{%
+ \raise\Gin@req@height\hbox{%
+ \special{anisoscale #1,
+ \the\Gin@req@width\space \the\Gin@req@height}}}
+% \end{macrocode}
+% The only exception is EPS files, as they may be read for BoundingBox
+% \begin{macrocode}
+\@namedef{Gin@rule@.ps}#1{{eps}{.ps}{#1}}
+\@namedef{Gin@rule@.eps}#1{{eps}{.eps}{#1}}
+\let\Ginclude@eps\Ginclude@bmp
+% \end{macrocode}
+% Add a few default extensions so |\includegraphics{a}|
+% will pick up |a.eps| or |a.wmf|.
+% This list can be reset with |\DeclareGraphicsExtensions|.
+% Other extensions not in the list may be used explicitly, eg
+% |\includegraphics{a.gif}| should work as long as dviwin has access
+% to a gif filter. If |.gif| is added using |\DeclareGraphicsExtensions|
+% then |\includegraphics{a}| would also find |a.gif|.
+% \begin{macrocode}
+\def\Gin@extensions{.eps,.ps,.wmf,.tif}
+% \end{macrocode}
+%
+% \begin{macrocode}
+%</dviwin>
+% \end{macrocode}
+%
+% \section{ln}
+% A \LaTeXe\ graphics driver file for B Hamilton Kelly's ln03 driver.
+% Untested, but based on the graphics macros distributed with the
+% driver.
+% \begin{macrocode}
+%<*ln>
+% \end{macrocode}
+% \subsection{Graphic file inclusion}
+% \begin{macrocode}
+\def\Ginclude@sixel#1{\special{ln03:sixel #1}}
+%</ln>
+% \end{macrocode}
+%
+% \section{truetex}
+% A \LaTeXe\ graphics driver file for Kinch `truetex' driver.
+% \begin{macrocode}
+%<*truetex>
+% \end{macrocode}
+%
+% \subsection{Colour}
+% Uses the `color4' colour code.
+%
+% \subsection{Graphic file inclusion}
+%
+% EPS File inclusion: DVIPS style.
+% \begin{macrocode}
+\def\Ginclude@eps#1{%
+ \message{<#1>}%
+ \bgroup
+ \def\@tempa{!}%
+ \dimen@\Gin@req@width
+ \dimen@ii.1bp%
+ \divide\dimen@\dimen@ii
+ \@tempdima\Gin@req@height
+ \divide\@tempdima\dimen@ii
+ \special{PSfile="#1"\space
+ llx=\Gin@llx\space
+ lly=\Gin@lly\space
+ urx=\Gin@urx\space
+ ury=\Gin@ury\space
+ \ifx\Gin@scalex\@tempa\else rwi=\number\dimen@\space\fi
+ \ifx\Gin@scaley\@tempa\else rhi=\number\@tempdima\space\fi
+ \ifGin@clip clip\fi}%
+ \egroup}
+% \end{macrocode}
+%
+% bmp File Inclusion.
+% \begin{macrocode}
+\def\Ginclude@bmp#1{%
+ \message{<#1>}%
+ \special{bmpfile #1}}
+% \end{macrocode}
+%
+% tif(f) File inclusion
+% \begin{macrocode}
+\def\Ginclude@tiff#1{%
+ \message{<#1>}%
+ \special{tifffile #1}}
+% \end{macrocode}
+%
+% \subsection{Literal PostScript}
+% This is not supported, so uses `nops' code.
+%
+% \subsection{Default Rules}
+% Support (e)ps, tif and bmp, default to eps.
+% \begin{macrocode}
+\def\Gin@extensions{.eps,.ps}
+\@namedef{Gin@rule@.ps}#1{{eps}{.ps}{#1}}
+\@namedef{Gin@rule@.eps}#1{{eps}{.eps}{#1}}
+\@namedef{Gin@rule@.tif}#1{{tiff}{}{#1}}
+\@namedef{Gin@rule@.bmp}#1{{bmp}{}{#1}}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\@namedef{Gin@rule@*}#1{{eps}{\Gin@ext}{#1}}
+% \end{macrocode}
+%
+% \begin{macrocode}
+%</truetex>
+% \end{macrocode}
+%
+% \section{tcidvi}
+% A \LaTeXe\ graphics driver file for Scientific Word/Workplace.
+% Actually for the Kinch truetex driver, augmented with extra
+% |\special| handling with the DLL supplied with SW.
+% \begin{macrocode}
+%<*tcidvi>
+% \end{macrocode}
+%
+% \subsection{Colour}
+% Uses the `color4' colour code.
+%
+% The above colours are handled by the Kinch-supplied dll
+% The TCI dll adds support for |\colorbox|, but only grey scale
+% The code below accepts any color model, but only the red
+% component is used.
+% \begin{macrocode}
+\AtBeginDocument{\def\color@block#1#2#3{%
+ {\rlap{\ifcolors@
+ \@defaultunits\count@\current@color\@nnil
+ \dimen@\count@\p@
+ \divide\dimen@\@cclv
+ \dimen@ii#2%
+ \advance\dimen@ii#3%
+ \lower#3\hbox{%
+ \special{language "Scientific Word";%
+ type "greybox";%
+ greyscale \strip@pt\dimen@;%
+ height \the\dimen@ii;%
+ width \the#1;%
+ depth 0pt;}}%
+ \fi}}}}
+% \end{macrocode}
+%
+% \subsection{Graphic file inclusion}
+%
+% EPS File inclusion.
+% \begin{macrocode}
+\def\Ginclude@eps#1{%
+ \message{<#1>}%
+ \raise\Gin@req@height\hbox{%
+% \end{macrocode}
+%
+% If the bounding box has been changed by a trim or viewport
+% key then need to calculate the crop ratios based on the original
+% bb coordinates. (This assumes that clip key is also used).
+% \begin{macrocode}
+ \ifx\Gin@ollx\@undefined
+ \else
+ \@tempdimb \Gin@ourx bp%
+ \advance\@tempdimb-\Gin@ollx bp%
+ \@tempdima\Gin@llx bp%
+ \advance\@tempdima-\Gin@ollx bp%
+ \Gscale@div\TCI@cropleft\@tempdima\@tempdimb
+ \@tempdima\Gin@urx bp%
+ \advance\@tempdima-\Gin@ollx bp%
+ \Gscale@div\TCI@cropright\@tempdima\@tempdimb
+ \@tempdimb \Gin@oury bp%
+ \advance\@tempdimb-\Gin@olly bp%
+ \@tempdima\Gin@lly bp%
+ \advance\@tempdima-\Gin@olly bp%
+ \Gscale@div\TCI@cropbottom\@tempdima\@tempdimb
+ \@tempdima\Gin@ury bp%
+ \advance\@tempdima-\Gin@olly bp%
+ \Gscale@div\TCI@croptop\@tempdima\@tempdimb
+ \fi
+% \end{macrocode}
+%
+% \begin{macrocode}
+ \special{%
+ language \TCI@language;%
+ type \TCI@type;%
+ valid_file \TCI@validfile;%
+ width \the\Gin@req@width;%
+ height \the\Gin@req@height;%
+ depth 0pt;%
+ original-width \the\Gin@nat@width;%
+ original-height \the\Gin@nat@height;%
+ cropleft "\TCI@cropleft";%
+ croptop "\TCI@croptop";%
+ cropright "\TCI@cropright";%
+ cropbottom "\TCI@cropbottom";%
+ filename '#1';%
+ \ifx\TCI@temp\@empty\else tempfilename \TCI@temp;\fi
+ }}}
+% \end{macrocode}
+%
+% Default values so documents produced elsewhere should work
+% \begin{macrocode}
+\def\TCI@language{"Scientific Word"}
+\def\TCI@type{"GRAPHIC"}
+\def\TCI@validfile{'F'}
+\def\TCI@cropleft{0}
+\def\TCI@croptop{1}
+\def\TCI@cropright{1}
+\def\TCI@cropbottom{0}
+\let\TCI@temp\@empty
+% \end{macrocode}
+%
+% Non PS Graphic files.
+%
+% File inclusion macro is always the same. Use a different name though
+% as LaTeX thinks it can read eps files for BoundingBox.
+% \begin{macrocode}
+\let\Ginclude@bmp\Ginclude@eps
+% \end{macrocode}
+%
+% \subsection{Literal PostScript}
+% This is not supported, so uses `nops' code.
+%
+% \subsection{Default Rules}
+% SW always gives the full name with extension.
+% So leave this list empty.
+% \begin{macrocode}
+\def\Gin@extensions{}
+% \end{macrocode}
+%
+% .ps .PS .eps .EPS are (E)PS
+% rest are `bmp' which is a catch all type for anything
+% that the import filter can handle.
+% \begin{macrocode}
+\@namedef{Gin@rule@.ps}#1{{eps}{.ps}{#1}}
+\@namedef{Gin@rule@.eps}#1{{eps}{.eps}{#1}}
+\@namedef{Gin@rule@.PS}#1{{eps}{.PS}{#1}}
+\@namedef{Gin@rule@.EPS}#1{{eps}{.EPS}{#1}}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\@namedef{Gin@rule@*}#1{{bmp}{\Gin@ext}{#1}}
+% \end{macrocode}
+%
+% \begin{macrocode}
+%</tcidvi>
+% \end{macrocode}
+%
+% \section{Literal Postscript}
+% Most drivers writing to PostScript allow some form of `literal'
+% PostScript |\special| that inserts code into the final PostScript
+% output. However Non-PS drivers can not support this (and some PS
+% one's can't either). The code here makes all these commands no ops.
+% Individual driver sections may define the commands to do something
+% useful.
+%
+% \begin{macrocode}
+%<*nops>
+% \end{macrocode}
+%
+% Raw PostScript code, no save/restore. Coordinate system unspecified.
+% \begin{macrocode}
+\def\Gin@PS@raw#1{}
+% \end{macrocode}
+%
+% PostScript code, to be surrounded by save/restore by the driver.
+% Coordinate system standard PostScript, but with origin
+% at current (\TeX) position.
+% \begin{macrocode}
+\def\Gin@PS@restored#1{}
+% \end{macrocode}
+%
+% PostScript code to be inserted in the Header section of the final
+% PostScript. Must be issued on the first page of a document.
+% \begin{macrocode}
+\def\Gin@PS@literal@header#1{}
+% \end{macrocode}
+%
+% Name of external file, the contents of which are to be inserted in
+% the Header section of the final PostScript. Must be issued on the
+% first page of a document.
+% \begin{macrocode}
+\def\Gin@PS@file@header#1{}
+% \end{macrocode}
+%
+% \begin{macrocode}
+%</nops>
+% \end{macrocode}
+%
+% \section{Graphics Inclusion Rules}
+% \begin{macrocode}
+%<*psrules>
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\Gin@extensions{.eps,.ps}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\@namedef{Gin@rule@.ps}#1{{eps}{.ps}{#1}}
+\@namedef{Gin@rule@.eps}#1{{eps}{.eps}{#1}}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\@namedef{Gin@rule@*}#1{{eps}{\Gin@ext}{#1}}
+% \end{macrocode}
+%
+% \begin{macrocode}
+%</psrules>
+%<*psrulesZ>
+% \end{macrocode}
+%
+% \changes{v3.0j}{2014/04/23}
+% {add .mps for metapost generated postscript to match pdftex graphics/4050}
+% \begin{macrocode}
+\def\Gin@extensions{.eps,.ps,.eps.gz,.ps.gz,.eps.Z,.mps}
+% \end{macrocode}
+%
+% \changes{v3.0k}{2015/12/30}
+% {compressed files don't require gunzip for dvips/xdvi}
+% \begin{macrocode}
+\@namedef{Gin@rule@.ps}#1{{eps}{.ps}{#1}}
+\@namedef{Gin@rule@.eps}#1{{eps}{.eps}{#1}}
+\@namedef{Gin@rule@.mps}#1{{eps}{.mps}{#1}}
+\@namedef{Gin@rule@.pz}#1{{eps}{.bb}{#1}}
+\@namedef{Gin@rule@.eps.Z}#1{{eps}{.eps.bb}{#1}}
+\@namedef{Gin@rule@.ps.Z}#1{{eps}{.ps.bb}{#1}}
+\@namedef{Gin@rule@.ps.gz}#1{{eps}{.ps.bb}{#1}}
+\@namedef{Gin@rule@.eps.gz}#1{{eps}{.eps.bb}{#1}}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\@namedef{Gin@rule@*}#1{{eps}{\Gin@ext}{#1}}
+% \end{macrocode}
+%
+% \begin{macrocode}
+%</psrulesZ>
+%<*dosrules>
+% \end{macrocode}
+%
+% \begin{macrocode}
+%<!psrulesZ>\def\Gin@extensions{.eps,.ps,.pcx,.bmp}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\@namedef{Gin@rule@.pcx}#1{{bmp}{}{#1}}
+\@namedef{Gin@rule@.bmp}#1{{bmp}{}{#1}}
+\@namedef{Gin@rule@.msp}#1{{bmp}{}{#1}}
+% \end{macrocode}
+%
+% \begin{macrocode}
+%</dosrules>
+%<*macrules>
+%\def\Gin@extensions{{},.ps,.eps,.pict}
+%\@namedef{Gin@rule@.ps}#1{{eps}{.ps}{#1}}
+%\@namedef{Gin@rule@.eps}#1{{eps}{.eps}{#1}}
+\@namedef{Gin@rule@.pict}#1{{pict}{}{#1}}
+\@namedef{Gin@rule@.pntg}#1{{pntg}{}{#1}}
+%\@namedef{Gin@rule@}#1{{pict}{\relax}{#1}}
+%</macrules>
+%<*tiffrules>
+\@namedef{Gin@rule@.tif}#1{{tiff}{}{#1}}
+%</tiffrules>
+% \end{macrocode}
+%
+% \Finale
+%
diff --git a/macros/latex/required/graphics/drivers.pdf b/macros/latex/required/graphics/drivers.pdf
new file mode 100644
index 0000000000..b3ddf7fb61
--- /dev/null
+++ b/macros/latex/required/graphics/drivers.pdf
Binary files differ
diff --git a/macros/latex/required/graphics/epsfig.dtx b/macros/latex/required/graphics/epsfig.dtx
new file mode 100644
index 0000000000..ba37d771cc
--- /dev/null
+++ b/macros/latex/required/graphics/epsfig.dtx
@@ -0,0 +1,142 @@
+%
+% \iffalse
+%
+%% epsfig.dtx Copyright (C) 1994-1996 1999 Sebastian Rahtz
+%% Copyright (C) 2000--2015,2017 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
+%% License, as described in lppl.txt in the base LaTeX distribution.
+%% Either version 1.3 or, at your option, any later version.
+%%
+%<*dtx>
+ \ProvidesFile{epsfig.dtx}
+%</dtx>
+%<package>\NeedsTeXFormat{LaTeX2e}[1994/06/01]
+%<package>\ProvidesPackage{epsfig}
+%<driver> \ProvidesFile{epsfig.drv}
+% \fi
+% \ProvidesFile{epsfig.dtx}
+ [2017/06/25 v1.7b (e)psfig emulation (SPQR)]
+%
+% \iffalse
+%<*driver>
+\documentclass{ltxdoc}
+\begin{document}
+ \DocInput{epsfig.dtx}
+\end{document}
+%</driver>
+% \fi
+%
+% \GetFileInfo{epsfig.dtx}
+%
+% \title{The \textsf{epsfig} package\thanks{This file
+% has version number \fileversion, last
+% revised \filedate.}}
+% \author{Sebastian Rahtz\\latex-team@latex-project.org}
+% \date{\filedate}
+% \MaintainedByLaTeXTeam{graphics}
+% \maketitle
+%
+%
+% \StopEventually{}
+%
+% \section{Preface}
+% \begin{macrocode}
+%<*package>
+\DeclareOption*{\PassOptionsToPackage{\CurrentOption}{graphicx}}
+\ProcessOptions
+\RequirePackage{graphicx}
+% \end{macrocode}
+% \subsection{Emulation of `psfig' syntax}
+% Emulate "epsfig.sty", and most varieties of psfig
+% \begin{macro}{\psfig,\epsfig}
+% \begin{macrocode}
+\def\psfig#1{%
+ \let\Gin@ewidth\Gin@exclamation\let\Gin@eheight\Gin@ewidth
+ \def\Gin@req@sizes{%
+ \def\Gin@scalex{1}\let\Gin@scaley\Gin@exclamation
+ \Gin@req@height\Gin@nat@height
+ \Gin@req@width\Gin@nat@width}%
+ \begingroup
+ \let\Gfigname\relax
+ \@tempswafalse
+ \toks@{\Ginclude@graphics{\Gfigname}}%
+ \setkeys{Gin}{#1}%
+ \Gin@esetsize
+ \ifx\Gfigname\relax\ErrorNoFile\else
+ \the\toks@
+ \fi
+ \endgroup}
+\define@key{Gin}{figure}{\def\Gfigname{#1}}
+\define@key{Gin}{file}{\def\Gfigname{#1}}
+\define@key{Gin}{prolog}{\typeout{epsfig: header files are not needed}}
+\define@key{Gin}{silent}[]{}
+\def\psdraft{\Gin@drafttrue}
+\def\psfull{\Gin@draftfalse}
+\def\pssilent{\typeout{epsfig option `silent' ignored}}
+\def\psnoisy{\typeout{epsfig option `noisy' ignored}}
+\let\epsfig\psfig
+\def\psfigdriver#1{\makeatletter\input{#1.def}\makeatother}
+% \end{macrocode}
+% \end{macro}
+% \subsection{Emulation of `epsf' syntax}
+% Emulate Rokicki's "epsf.tex" supplied with the ever-popular dvips.
+% \begin{macro}{\epsfbox,\epsffile}
+% \begin{macrocode}
+\newdimen\epsfxsize
+\newdimen\epsfysize
+\epsfysize\z@
+\epsfxsize\z@
+\def\epsfsize#1#2{\epsfxsize}
+\def\epsfbox{%
+ \@ifnextchar[%
+ {\Gin@bboxtrue\epsf@bb@box}%
+ {\Gin@bboxfalse\epsf@box}%
+}
+\def\epsf@bb@box[#1#2]{%
+ \expandafter\Gread@parse@bb#1#2 \\
+ \epsf@box}
+\def\epsf@box#1{%
+ \bgroup
+ \def\Gin@req@sizes{%
+ \epsfxsize\epsfsize{\Gin@nat@width}{\Gin@nat@height}%
+ \ifdim\epsfxsize=\z@
+ \ifdim\epsfysize=\z@
+ \Gin@req@height\Gin@nat@height
+ \Gin@req@width\Gin@nat@width
+ \else
+ \let\Gin@scalex\Gin@exclamation
+ \Gin@req@height\epsfysize
+ \Gscale@div\Gin@scaley\Gin@req@height\Gin@nat@height
+ \Gin@req@width\Gin@scaley\Gin@nat@width
+ \fi
+ \else
+ \Gin@req@width\epsfxsize
+ \Gscale@div\Gin@scalex\Gin@req@width\Gin@nat@width
+ \ifdim\epsfysize=\z@
+ \let\Gin@scaley\Gin@exclamation
+ \Gin@req@height\Gin@scalex\Gin@nat@height
+ \else
+ \Gin@req@height\epsfysize
+ \Gscale@div\Gin@scaley\Gin@req@height\Gin@nat@height
+ \fi
+ \fi
+ }%
+ \Ginclude@graphics{#1}%
+ \egroup
+ \epsfysize\z@
+ \epsfxsize\z@
+}
+\let\epsffile\epsfbox
+\def\epsfclipon{\Gin@cliptrue}
+\def\epsfclipoff{\Gin@clipfalse}
+\def\epsfverbosetrue{\typeout{epsf verbose option ignored}}
+\def\epsfverbosefalse{\typeout{epsf verbose option ignored}}
+%</package>
+% \end{macrocode}
+% \end{macro}
+%
+% \Finale
+%
+
diff --git a/macros/latex/required/graphics/epsfig.pdf b/macros/latex/required/graphics/epsfig.pdf
new file mode 100644
index 0000000000..2dd00588ca
--- /dev/null
+++ b/macros/latex/required/graphics/epsfig.pdf
Binary files differ
diff --git a/macros/latex/required/graphics/graphics-drivers.ins b/macros/latex/required/graphics/graphics-drivers.ins
new file mode 100644
index 0000000000..dda92883ae
--- /dev/null
+++ b/macros/latex/required/graphics/graphics-drivers.ins
@@ -0,0 +1,92 @@
+%%
+%% This file is part of the Standard LaTeX `Graphics Bundle'.
+%% It may be distributed under the terms of the LaTeX Project Public
+%% License, as described in lppl.txt in the base LaTeX distribution.
+%% Either version 1.3c or, at your option, any later version.
+%%
+%% This file has the LPPL maintenance status "maintained".
+
+\input docstrip
+
+
+\preamble
+\endpreamble
+
+\keepsilent
+\askforoverwritefalse
+
+%% Generate a `template' .def file as an example for a new driver.
+%% (This is not set up yet.)
+%%\generate{\file{template.def}{%
+%% \from{drivers.dtx}{template}}}
+
+% These ones probably work
+\generate{%
+% dvips.def moved to graphics-def distribution
+% \file{dvips.def}{%
+% \from{drivers.dtx}{dvips,color1,psrulesZ,dosrules,macrules}}
+ \file{dvipdf.def}{%
+ \from{drivers.dtx}{dvipdf,color1,psrulesZ}}
+ \file{dvipsone.def}{%
+ \from{drivers.dtx}{tiffrules,dvipsone,color1,dosrules,psrules}}
+ \file{dviwin.def}{%
+ \from{drivers.dtx}{dviwin,nops}}
+ \file{emtex.def}{%
+ \from{drivers.dtx}{emtex,dosrules,nops}}
+% OzTeX (>3.0) uses dvips.def
+% \file{oztex.def}{%
+% \from{drivers.dtx}{oztex,macrules,nops}}
+ \file{pctexps.def}{%
+ \from{drivers.dtx}{pctexps,color3,colorfix}}
+ \file{pctex32.def}{%
+ \from{drivers.dtx}{pctex32,color1}}
+ \file{pctexhp.def}{%
+ \from{drivers.dtx}{pctexhp,nops}}
+ \file{pctexwin.def}{%
+ \from{drivers.dtx}{pctexwin,nops}}
+ \file{truetex.def}{%
+ \from{drivers.dtx}{truetex,color4,nops}}
+ \file{tcidvi.def}{%
+ \from{drivers.dtx}{tcidvi,color4,nops}}
+ \file{dvipsnam.def}{%
+ \from{drivers.dtx}{dvipsnames}}}
+
+
+% these ones are largely untested and no longer generated by default.
+%\generate{%
+% \file{pubps.def}{%
+% \from{drivers.dtx}{pubps,psrules}}
+% \file{psprint.def}{%
+% \from{drivers.dtx}{psprint,psrules}}
+%% The textures code generated by this option does more or less work
+%% I believe, but it does not use all of textures features, and as I
+%% have not got a Mac to test it on, it seems better to remove it for
+%% now.
+%% This release of the graphics distribution contains a textures.def
+%% written by Arthur Ogawa which is distributed as a separate file.
+%% It should however be installed in the same directory as the .def
+%% files generated by this .ins installation script.
+%% \file{textures.def}{%
+%% \from{drivers.dtx}{textures,color2,macrules}}
+%%
+%%%% Old versions of textures (prior to 1.7) do not have colour specials.
+%%%% To use colour with these versions, uncomment the next two lines.
+%%
+%%%% \file{textures.def}{%
+%%%% \from{drivers.dtx}{textures,color3,colorfix,macrules}}
+%%
+%%
+% \file{ln.def}{%
+% \from{drivers.dtx}{ln}}
+% \file{dvi2ps.def}{%
+% \from{drivers.dtx}{dvi2ps,psrules}}
+% \file{dvitops.def}{%
+% \from{drivers.dtx}{dvitops,psrules}}
+% \file{dvilaser.def}{%
+% \from{drivers.dtx}{dvilaser,psrules}}
+% \file{dvialw.def}{%
+% \from{drivers.dtx}{dvialw,psrules}}}
+%
+%
+%
+\endbatchfile
diff --git a/macros/latex/required/graphics/graphics.dtx b/macros/latex/required/graphics/graphics.dtx
new file mode 100644
index 0000000000..028f065852
--- /dev/null
+++ b/macros/latex/required/graphics/graphics.dtx
@@ -0,0 +1,1962 @@
+%
+% \iffalse
+%
+%% graphics.dtx Copyright (C) 1994 David Carlisle Sebastian Rahtz
+%% Copyright (C) 1995--2017 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
+%% License, as described in lppl.txt in the base LaTeX distribution.
+%% Either version 1.3c or, at your option, any later version.
+%%
+%% This file has the LPPL maintenance status "maintained".
+%%
+%<*dtx>
+ \ProvidesFile{graphics.dtx}
+%</dtx>
+%<package>\NeedsTeXFormat{LaTeX2e}[1995/12/01]
+%<package>\ProvidesPackage{graphics}
+%<driver> \ProvidesFile{graphics.drv}
+% \fi
+% \ProvidesFile{graphics.dtx}
+ [2017/06/25 v1.2c Standard LaTeX Graphics (DPC,SPQR)]
+%
+% \iffalse
+%<*driver>
+\documentclass{ltxdoc}
+\newenvironment{option}[1]{\expandafter\macro\expandafter{%
+ \csname ds@#1\endcsname}}{\endmacro}
+\begin{document}
+ \DocInput{graphics.dtx}
+\end{document}
+%</driver>
+% \fi
+%
+% \GetFileInfo{graphics.dtx}
+%
+% \title{The \textsf{graphics} package\thanks{This file
+% has version number \fileversion, last
+% revised \filedate.}}
+% \author{D. P. Carlisle\and S. P. Q. Rahtz}
+% \date{\filedate}
+% \MaintainedByLaTeXTeam{graphics}
+% \maketitle
+%
+%
+% \changes{v0.3a}{1994/02/24}
+% {First DPC version (after prototype by SPQR).}
+% \changes{v0.4e}{1994/05/30}
+% {Rename egraphics to graphicx}
+% \changes{v1.0}{1996/05/29}
+% {Version 1 at last}
+%
+%
+% \def\star{{\ttfamily*}}
+% \makeatletter
+% \def\Describe@Macro#1{\endgroup
+% \setbox0=\lastbox\llap{\PrintDescribeMacro{#1}}}%
+% \makeatother
+% \marginparsep0pt
+%
+% \section{Introduction}
+%
+% This package implements various `graphics' functions. The main
+% features are a) inclusion of `graphics' files. b) Rotation of sections
+% of the page, c) Scaling of sections of the page.
+%
+% The design is split into three `levels'.
+% \begin{itemize}
+% \item The user interface. This is the collection of commands designed
+% to appear in a document text. Actually two separate user interface
+% have been implemented. The `standard' interface, described here, and a
+% more powerful, and more `user-friendly' interface provided by the
+% |graphicx| package.
+% \item The core functions. These functions, which are also implemented
+% in this file do all the `main work'. The `user-interface functions
+% just collect together the information from any optional-arguments or
+% star-forms, and then call one of these functions.
+% \item The driver files. It is not possible to achieve the
+% functionality of this package just using \TeX. The |dvi| driver used
+% must be given additional instructions. (Using the |\special| command
+% of \TeX.) Unfortunately, the capabilities of various drivers differ,
+% and the syntax required to pass instructions to the drivers is also
+% not standardised. So the `core functions' never access |\special|
+% directly, but rather call a series of commands that must be defined in
+% a special file customised for each driver. The accompanying file,
+% |drivers.dtx| has suitable files for a range of popular drivers.
+% \end{itemize}
+%
+% \section{Package Options}
+% Most of the options, such as |dvips|, |textures| etc., specify the
+% driver that is to be used to print the document. You may wish to set
+% up a configuration file so that this option always takes effect, even
+% if not specified in the document. To do this, produce a file
+% |graphics.cfg| containing the line:\\
+% |\ExecuteOptions{dvips}|\\
+% (or whichever other driver you wish.)
+%
+% Apart from the driver options there are a few other options to control
+% the behaviour of the package.
+% \begin{description}
+% \item[draft]
+% Do not include graphics files, but instead print a box of the size
+% the graphic would take up, and the file name. This greatly speeds up
+% previewing on most systems.
+% \item[final]
+% Turns off the |draft| option.
+% \item[debugshow]
+% Show a lot of tracing information on the terminal. If you are not me
+% you probably do not want to use this option.
+% \item[hiderotate]
+% Do not show rotated text. Sometimes useful if your previewer can not
+% rotate text.
+% \item[hidescale]
+% Do not show scaled text.
+% \item[hiresbb]
+% Look for Bounding Box lines of the form |%%HiResBoundingBox| instead
+% of the standard |%%BoundingBox|. These are used by some applications
+% to get round the restriction that BoundingBox comments should only
+% have integer values.
+% \item[setpagesize, nosetpagesize]
+% The |setpagesize| option requests that the driver option sets the page size.
+% (Whichever option is used, the page size is not set by this package if |\mag|
+% has been changed from its default value.)
+% \item[demo] Instead of including a graphics file, make
+% |\includegraphics| insert a black rectangle of size 150\,pt by
+% 100\,pt unless either dimension was already specified by another
+% option.
+% \end{description}
+%
+% \section{Standard Interface}
+%
+% \subsection{Graphics Inclusion}
+%
+% \DescribeMacro
+% \includegraphics\star\oarg{llx,lly}\oarg{urx,ury}\marg{file}\\
+% Include a graphics file.
+%
+% If \star\ is present, then the graphic is `clipped' to the size
+% specified. If \star\ is omitted, then any part of the graphic that is
+% outside the specified `bounding box' will over-print the surrounding
+% text.
+%
+% If the optional arguments are omitted, then the size of the graphic
+% will be determined by reading an external file as described below.
+% If \oarg{urx,ury} is present, then it should specify the coordinates
+% of the top right corner of the image, as a pair of \TeX\ dimensions.
+% If the units are omitted they default to |bp|. So |[1in,1in]| and
+% |[72,72]| are equivalent. If only one optional argument appears, the
+% lower left corner of the image is assumed to be at |[0,0]|. Otherwise
+% \oarg{llx,lly} may be used to specify the coordinates of this point.
+%
+% \DescribeMacro
+% \graphicspath\marg{dir-list}\\
+% This optional declaration may be used to specify a list of directories
+% in which to search for graphics files. The format is as for the
+% \LaTeXe\ primitive |\input@path|, a list of directories, each in a
+% |{}| group (even if there is only one in the list). For example:
+% |\graphicspath{{eps/}{tiff/}}|
+% would cause the system to look in the subdirectories |eps| and |tiff|
+% of the current directory. The default setting of this path is
+% |\input@path| that is: graphics files will be found wherever \TeX\
+% files are found.
+%
+% \DescribeMacro
+% \DeclareGraphicsExtensions\marg{ext-list}\\
+% This specifies the behaviour of the system when the filename argument to
+% |\includegraphics| does not have an extension specified.
+% Here \marg{ext-list} should be a comma-separated list of file
+% extensions, each with a leading period (\texttt{.}).
+% A file name is produced by appending \emph{sep} and one extension.
+% If a file is found, the system acts as if that extension had been
+% specified. If not, the next extension in \emph{ext-list} is tried.
+% \changes{v1.0m}{2001/06/07}{Extended documentation (CAR) graphics/3228}
+%
+% Each use of |\DeclareGraphicsExtensions| overwrites all previous
+% definitions. It is not possible to add an extension to an
+% existing list.
+%
+% Early versions of this package defined a default argument for this
+% command. This has been removed.
+%
+% \DescribeMacro
+% \DeclareGraphicsRule
+% \marg{ext}\marg{type}\marg{read-file}\marg{command}\\
+% Any number of these declarations can be made. They determine how the
+% system behaves when a file with extension \emph{ext} is specified.
+% (The extension may be specified explicitly or, if the argument to
+% |\includegraphics| does not have an extension, it may be a default
+% extension from the \emph{ext-list} specified with
+% |\DeclareGraphicsExtensions|.)
+%
+% \emph{ext} is the \emph{extension} of the file. Any file with this
+% extension will be processed by this graphics rule. Normally a file
+% with an extension for which no rule has been declared will generate an
+% error, however you may use |*| as the extension to define a
+% \emph{default rule}. For instance the |dvips| driver file declares all
+% files to be of type |eps| unless a more specific rule is declared.
+%
+% Since Version v0.6, extensions should be specified including the |.|
+% that is, |.eps| not |eps|.
+%
+% \emph{type} is the `type' of file involved. All files of the same type
+% will be input with the same internal command (which must be defined in
+% a `driver file'). For example files with extensions |ps|, |eps|,
+% |ps.gz| may all be classed as type |eps|.
+%
+% \emph{read-file} determines the extension of the file that should be
+% read to determine size information. It may be the same as \emph{ext}
+% but it may be different, for example |.ps.gz| files are not readable
+% easily by \TeX, so you may want to put the bounding box information in
+% a separate file with extension |.ps.bb|. If \emph{read-file} is empty,
+% |{}|, then the system will not try to locate an external file for size
+% info, and the size must be specified in the arguments of
+% |\includegraphics|. As a special case |*| may be used to denote the
+% same extension as the graphic file. This is mainly of use in
+% conjunction with using |*| as the extension, as in that case the
+% particular graphic extension is not known. For example
+%\begin{verbatim}
+% \DeclareGraphicsRule{*}{eps}{*}{}
+%\end{verbatim}
+% This would declare a default rule, such that all unknown extensions
+% would be treated as EPS files, and the graphic file would be read for
+% a BoundingBox comment.
+%
+% If the driver file specifies a procedure for
+% reading size files for \emph{type}, that will be used, otherwise the
+% procedure for reading |eps| files will be used. Thus the size of
+% bitmap files may be specified in a file with a PostScript style
+% |%%BoundingBox| line, if no other specific format is available.
+%
+% \emph{command} is usually empty, but if non empty it is used in place
+% of the filename in the |\special|. Within this argument, |#1| may be
+% used to denote the filename. Thus using the dvips driver, one may
+% use\\
+% |\DeclareGraphicsRule{.ps.gz}{eps}{.ps.bb}{`zcat #1}|\\
+% the final argument causes dvips to use the |zcat| command to unzip the
+% file before inserting it into the PostScript output.
+%
+% \subsection{Rotation}
+%
+% \DescribeMacro
+% \rotatebox\marg{angle}\marg{text}\\
+% Rotate \emph{text} \emph{angle} degrees anti-clockwise. Normally
+% the rotation is about the left-hand end of the baseline of
+% \emph{text}.
+%
+% \subsection{Scaling}
+%
+% \DescribeMacro
+% \scalebox\marg{h-scale}\oarg{v-scale}\marg{text}\\
+% Scale \emph{text} by the specified amounts. If \emph{v-scale} is
+% omitted, the vertical scale factor is the same as the horizontal one.
+%
+% \DescribeMacro
+% \resizebox\star\marg{h-length}\marg{v-length}\marg{text}\\
+% Scale \emph{text} so that the width is \emph{h-length}.
+% If |!| is used as either length argument, the other argument is used
+% to determine a scale factor that is used in both directions.
+% Normally \emph{v-length} refers to the height of the box, but in the
+% star form, it refers to the `height + depth'.
+% As normal for \LaTeXe\ box length arguments, |\height|,
+% |\width|, |\totalheight| and |\depth| may be used to refer to the
+% original size of the box.
+%
+% \section{The Key=Value Interface}
+% As mentioned in the introduction, apart from the above `standard
+% interface', there is an alternative syntax to the |\includegraphics|
+% and |\rotatebox| commands that some people may prefer. It is provided
+% by the accompanying |graphicx| package.
+%
+% \StopEventually{}
+%
+% \section{The Graphics Kernel Functions}
+%
+% \subsection{Graphics Inclusion}
+%
+% \DescribeMacro
+% {\Ginclude@graphics}\marg{file}\\
+% Insert the contents of the file \emph{file} at the current point.
+% |\Ginclude@graphics| may use the four macros |\Gin@llx|, |\Gin@lly|,
+% |\Gin@urx|, |\Gin@ury| to determine the `bounding box' of the graphic.
+% The result will be a \TeX\ box of width $\mathit{urx}-\mathit{llx}$
+% and height $\mathit{ury}-\mathit{lly}$. If |\Gin@clip| is \meta{true}
+% then part of the graphic that is outside this box should not be
+% displayed. (Not all drivers can support this `clipping'.) Normally all
+% these parameters are set by the `user interface level'.
+%
+%
+% \DescribeMacro
+% {\Gread@eps}\marg{file}\\
+% For each \emph{type} of graphics file supported, the driver file must
+% define |\Ginclude@|\emph{type} and, optionally |\Gread@|\emph{type}.
+% The read command is responsible for obtaining size information from
+% the file specified in the |\DeclareGraphicsRule| command. However the
+% kernel defines a function, |\Gread@eps|, which can read PostScript
+% files to find the
+% |%%BoundingBox| comment. This function will be used for any type for
+% which a specific function has not been declared. |\Gread@eps| accepts
+% a generalised version of the bounding box comment. \TeX\ units may be
+% used (but there must be no space before the unit). If the unit is
+% omitted |bp| is assumed. So\\
+% |%%BoundingBox 0 0 2in 3in|\\
+% Would be accepted by this function, to produce a 2in wide, by 3in high
+% graphic.
+%
+% \subsection{Rotation}
+%
+% \DescribeMacro
+% {\Grot@box}\\
+% Rotate the contents of |\box0| through |\Grot@angle| degrees
+% (anti-clockwise). The user-interface is responsible for setting the
+% macro |\Grot@angle|, and putting the appropriate text in |\Grot@box|.
+%
+% \subsection{Scaling}
+%
+% \DescribeMacro
+% {\Gscale@box}\marg{xscale}\oarg{yscale}\marg{text}\\
+% (The second argument is not optional.)
+% Scale \emph{text} by the appropriate scale factors.
+%
+% \DescribeMacro
+% {\Gscale@box@dd}\marg{dima}\marg{dimb}\marg{text}\\
+% Scale \emph{text} in both directions by a factor
+% \emph{dima}/\emph{dimb}.
+%
+% \DescribeMacro
+% {\Gscale@box@dddd}
+% \marg{dima}\marg{dimb}\marg{dimc}\marg{dimd}\marg{text}\\
+% Scale \emph{text} in horizontally by a factor \emph{dima}/\emph{dimb},
+% and vertically by a factor of \emph{dimc}/\emph{dimd}.
+%
+% \DescribeMacro
+% {\Gscale@div}\marg{cmd}\marg{dima}\marg{dimb}\\
+% Define the macro \emph{cmd} to be the ratio of the lengths
+% \emph{dima}/\emph{dimb}.
+%
+%
+% \section{Interface to the Driver Files}
+%
+% \subsection{Graphics Inclusion}
+%
+% Each driver file must declare that its driver can include graphics of
+% certain \emph{types}. It does this by declaring for each type a
+% command of the form:\\
+% |\Ginclude@|\emph{type}\\
+% The Graphics kernel function will call this driver-defined function
+% with the filename as argument, and certain additional information will
+% be provided as follows.:
+%
+% \noindent\begin{tabular}{p{.4\textwidth}p{.5\textwidth}}
+% |\Gin@llx|, |\Gin@lly|,\newline
+% |\Gin@urx|, |\Gin@ury| &Macros storing the `bounding box'\\
+% |\Gin@nat@width|\newline |\Gin@nat@height| &
+% Registers storing the natural size.\\
+% |\Gin@req@width|\newline |\Gin@req@height| &
+% Registers storing the required size, after scaling.\\
+% |\Gin@scalex|, |\Gin@scaley| & macros with the scale factors. A value
+% of |!| means: Scale by the same amount as the other direction.\\
+% |\ifGin@clip| & |\newif| token, true if the graphic should be
+% `clipped' to the bounding box.
+% \end{tabular}
+%
+% Optionally the driver may define a command of the form:\\
+% |\Gread@|\emph{type}\\
+% This is responsible for reading an external file to find the bounding
+% box information. If such a command is not declared, but a read-file is
+% specified the command |\Gread@eps|, which is defined in the Graphics
+% Kernel will be used.
+%
+% \subsection{Literal Postscript}
+% Drivers that are producing PostScript output may want to define
+% the following macros. They each take one argument which should be
+% passed to an appropriate special. They are not used directly by this
+% package but allow other packages to use the standard configuration
+% file and package options to customise to various drivers:\\
+% |\Gin@PS@raw|, Literal PostScript special.\\
+% |\Gin@PS@restored|, Literal PostScript special, the driver will
+% surround this with a save-restore pair.\\
+% |\Gin@PS@literal@header|, Postscript to be inserted in the header
+% section of the PostScript file.\\
+% |\Gin@PS@file@header|, external file to be inserted in the header
+% section of the PostScript file.
+%
+%
+% \subsection{Rotation}
+%
+% |\Grot@start|, |\Grot@end| These macros must be defined to insert the
+% appropriate |\special| to rotate the text between them by
+% |\Grot@angle| degrees. The kernel function will make sure that the
+% correct \TeX\ spacing is produced, these functions only need insert
+% the |\special|.
+%
+% \subsection{Scaling}
+%
+% |\Gscale@start|, |\Gscale@end|, as for rotation, but here scale the
+% text by |\Gscale@x| and |\Gscale@y|.
+%
+%
+% \section{Implementation}
+%
+% \begin{macrocode}
+%<*package>
+% \end{macrocode}
+%
+% \subsection{Initialisation}
+%
+% \begin{macro}{\Gin@codes}
+% First we save the catcodes of some characters, and set them to
+% fixed values whilst this file is being read.
+% \changes{v0.5a}{1994/07/20}
+% {Save and restore catcodes}
+% \begin{macrocode}
+\edef\Gin@codes{%
+ \catcode`\noexpand\^^A\the\catcode`\^^A\relax
+ \catcode`\noexpand\"\the\catcode`\"\relax
+ \catcode`\noexpand\*\the\catcode`\*\relax
+ \catcode`\noexpand\!\the\catcode`\!\relax
+ \catcode`\noexpand\:\the\catcode`\:\relax}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\catcode`\^^A=\catcode`\%
+\@makeother\"%
+\catcode`\*=11
+\@makeother\!%
+\@makeother\:%
+% \end{macrocode}
+% \end{macro}
+%
+% We will need to have an implementation of the trigonometric
+% functions for the rotation feature. May as well load it now.
+% \begin{macrocode}
+\RequirePackage{trig}
+% \end{macrocode}
+%
+% \begin{macro}{\Grot@start}
+% \begin{macro}{\Grot@end}
+% Initialise the rotation primitives.
+% \begin{macrocode}
+\providecommand\Grot@start{\@latex@error{Rotation not supported}\@ehc
+ \global\let\Grot@start\relax}
+\providecommand\Grot@end{}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\Gscale@start}
+% \begin{macro}{\Gscale@end}
+% Initialise the scaling primitives.
+% \begin{macrocode}
+\providecommand\Gscale@start{\@latex@error{Scaling not supported}\@ehc
+ \global\let\Gscale@start\relax}
+\providecommand\Gscale@end{}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\Gread@BBox}
+% \changes{v1.0b}{1996/10/29}
+% {Moved to initial section, for hiresbb option}
+% |%%BoundingBox| as a macro for testing with |\ifx|.
+% This may be redefined by the hiresbb option.
+% \begin{macrocode}
+\edef\Gread@BBox{\@percentchar\@percentchar BoundingBox}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsection{Options}
+%
+% \begin{option}{draft}
+% \begin{option}{final}
+% \changes{v0.3i}{1994/03/23}
+% {notdraft option added}
+% \changes{v0.4a}{1994/04/13}
+% {Rename option to nodraft}
+% \changes{v0.4d}{1994/05/06}
+% {Rename option to final}
+% \begin{macrocode}
+\DeclareOption{draft}{\Gin@drafttrue}
+\DeclareOption{final}{\Gin@draftfalse}
+% \end{macrocode}
+% \end{option}
+% \end{option}
+%
+% \begin{macro}{\ifGin@draft}
+% True in draft mode.
+% \begin{macrocode}
+\newif\ifGin@draft
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{option}{hiresbb}
+% \changes{v1.0b}{1996/10/29}
+% {hiresbb option added}
+% If given this option the package will look for bounding box comments
+% of the form |%%HiResBoundingBox| (which typically have real values)
+% instead of the standard |%%BoundingBox| (which should have integer
+% values).
+% \begin{macrocode}
+\DeclareOption{hiresbb}{%
+ \edef\Gread@BBox{\@percentchar\@percentchar HiResBoundingBox}}
+% \end{macrocode}
+% \end{option}
+%
+% \begin{option}{demo}
+% \changes{v1.0o}{2006/02/20}{demo option added}
+% If given this option the package will disregard the actual
+% graphics file and insert a black box unless width or height are
+% already specified.
+% \begin{macrocode}
+\DeclareOption{demo}{%
+ \AtBeginDocument{%
+ \def\Ginclude@graphics#1{%
+ \rule{\@ifundefined{Gin@@ewidth}{150pt}{\Gin@@ewidth}}%
+ {\@ifundefined{Gin@@eheight}{100pt}{\Gin@@eheight}}}}}
+% \end{macrocode}
+% \end{option}
+%
+% \begin{option}{setpagesize}
+% \begin{option}{nosetpagesize}
+% The |setpagesize| option requests that the driver option sets the page size.
+% (Whichever option is used, the page size is not set by this package if |\mag|
+% has been changed from its default value.)
+% \changes{v1.0s}{2016/06/02}
+% {(no)setpagesize options added}
+% \begin{macrocode}
+\newif\ifGin@setpagesize\Gin@setpagesizetrue
+\DeclareOption{setpagesize}{\Gin@setpagesizetrue}
+\DeclareOption{nosetpagesize}{\Gin@setpagesizefalse}
+% \end{macrocode}
+% \end{option}
+% \end{option}
+%
+% \begin{macro}{\Gin@driver}
+% Driver in use.
+% \begin{macrocode}
+\providecommand\Gin@driver{}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{option}{dvips}
+% \changes{v0.3g}{1994/03/15}
+% {Use dvips def file not development version}
+% \begin{option}{xdvi}
+% Tomas Rockicki's PostScript driver (unix, MSDOS, VMS\ldots).
+% The |X11| previewer |xdvi| supports basically the same set of
+% |\specials|.
+% \begin{macrocode}
+\DeclareOption{dvips}{\def\Gin@driver{dvips.def}}
+\DeclareOption{xdvi}{\ExecuteOptions{dvips}}
+% \end{macrocode}
+% \end{option}
+% \end{option}
+%
+% \begin{option}{dvipdf}
+% \changes{v1.0c}{1996/10/31}
+% {dvipdf added}
+% Sergey Lesenko's dvipdf driver.
+% \begin{macrocode}
+\DeclareOption{dvipdf}{\def\Gin@driver{dvipdf.def}}
+% \end{macrocode}
+% \end{option}
+%
+% \begin{option}{dvipdfm}
+% \changes{v1.0k}{1999/01/13}
+% {dvipdfm added}
+% \changes{v1.2a}{2017/06/01}
+% {make dvipdfm an alias for dvipdfmx}
+% Mark Wick's dvipdfm driver (now merged with xdvipdfmx).
+% \begin{macrocode}
+\DeclareOption{dvipdfm}{\def\Gin@driver{dvipdfmx.def}}
+% \end{macrocode}
+% \end{option}
+%
+% \begin{option}{dvipdfmx}
+% \changes{v1.0m}{2005/11/14}
+% {dvipdfmx added}
+% The driver for the dvipdfmx project (also supports xdvipdfmx).
+% \begin{macrocode}
+\DeclareOption{dvipdfmx}{\def\Gin@driver{dvipdfmx.def}}
+% \end{macrocode}
+% \end{option}
+%
+% \begin{option}{xetex}
+% \changes{v1.0m}{2005/11/14}
+% {xetex added}
+% Jonathan Kew's \TeX\ variant.
+% \begin{macrocode}
+\DeclareOption{xetex}{\def\Gin@driver{xetex.def}}
+% \end{macrocode}
+% \end{option}
+%
+% \begin{option}{pdftex}
+% \changes{v1.0d}{1997/06/07}
+% {pdftex added}
+% Han The Thanh's \TeX\ variant.
+% \begin{macrocode}
+\DeclareOption{pdftex}{\def\Gin@driver{pdftex.def}}
+% \end{macrocode}
+% \end{option}
+%
+% \begin{option}{luatex}
+% \changes{v1.0q}{2016/01/03}
+% {luatex added}
+% Lua\TeX\ \TeX\ variant.
+% \begin{macrocode}
+\DeclareOption{luatex}{\def\Gin@driver{luatex.def}}
+% \end{macrocode}
+% \end{option}
+%
+% \begin{option}{luatex}
+% \changes{v1.0r}{2016/05/09}
+% {dvisvgm added}
+% dvisvgm driver.
+% \begin{macrocode}
+\DeclareOption{dvisvgm}{\def\Gin@driver{dvisvgm.def}}
+% \end{macrocode}
+% \end{option}
+%
+% \begin{option}{dvipsone}
+% \begin{option}{dviwindo}
+% \changes{v0.3c}{1994/03/04}
+% {dviwindo support.}
+% \changes{v0.7c}{1995/09/07}
+% {Merge dviwindo option with dvipsone}
+% The drivers for the Y\&Y \TeX\ system.
+% \begin{macrocode}
+\DeclareOption{dvipsone}{\def\Gin@driver{dvipsone.def}}
+\DeclareOption{dviwindo}{\ExecuteOptions{dvipsone}}
+% \end{macrocode}
+% \end{option}
+% \end{option}
+%
+% \begin{option}{emtex}
+% \begin{option}{dviwin}
+% Two freely available sets of drivers for MSDOS, OS/2 and Windows.
+% \begin{macrocode}
+\DeclareOption{emtex}{\def\Gin@driver{emtex.def}}
+\DeclareOption{dviwin}{\def\Gin@driver{dviwin.def}}
+% \end{macrocode}
+% \end{option}
+% \end{option}
+%
+% \begin{option}{oztex}
+% \changes{v1.0f}{1997/09/09}
+% {Merge dvips and oztex options}
+% Oz\TeX\ (Macintosh).
+% Since release 3 of Oz\TeX, merge with dvips back end.
+% \begin{macrocode}
+\DeclareOption{oztex}{\ExecuteOptions{dvips}}
+% \end{macrocode}
+% \end{option}
+%
+% \begin{option}{textures}
+% Textures (Macintosh).
+% \begin{macrocode}
+\DeclareOption{textures}{\def\Gin@driver{textures.def}}
+% \end{macrocode}
+% \end{option}
+%
+% \begin{option}{pctexps}
+% \begin{option}{pctexwin}
+% \begin{option}{pctexhp}
+% \begin{option}{pctex32}
+% \changes{v1.0b}{1996/10/29}
+% {pctex32 option added}
+% PC\TeX\ (MSDOS/Windows) .
+% \begin{macrocode}
+\DeclareOption{pctexps}{\def\Gin@driver{pctexps.def}}
+\DeclareOption{pctexwin}{\def\Gin@driver{pctexwin.def}}
+\DeclareOption{pctexhp}{\def\Gin@driver{pctexhp.def}}
+\DeclareOption{pctex32}{\def\Gin@driver{pctex32.def}}
+% \end{macrocode}
+% \end{option}
+% \end{option}
+% \end{option}
+% \end{option}
+%
+% \begin{option}{truetex}
+% \changes{v1.0b}{1996/10/29}
+% {truetex and tcidef options added}
+% \begin{option}{tcidvi}
+% Kinch TrueTeX, and its version with extended special support as
+% shipped by Scientific Word.
+% \begin{macrocode}
+\DeclareOption{truetex}{\def\Gin@driver{truetex.def}}
+\DeclareOption{tcidvi}{\def\Gin@driver{tcidvi.def}}
+% \end{macrocode}
+% \end{option}
+% \end{option}
+%
+% \begin{option}{vtex}
+% \changes{v1.0h}{1998/05/27}
+% {vtex option added}
+% V\TeX\ driver.
+% \begin{macrocode}
+\DeclareOption{vtex}{\def\Gin@driver{vtex.def}}
+% \end{macrocode}
+% \end{option}
+%
+% \begin{option}{dvi2ps}
+% \begin{option}{dvialw}
+% \begin{option}{dvilaser}
+% \begin{option}{dvitops}
+% \begin{option}{psprint}
+% \begin{option}{pubps}
+% \begin{option}{ln}
+% \changes{v0.6b}{1994/12/12}
+% {ln support (untested)}
+% \changes{v1.0b}{1996/10/29}
+% {options for historic drivers depreciated}
+% If \emph{anyone} is using any of these driver options
+% would they let me know. All these are essentially untried
+% and untested as far as I know.
+% \begin{macrocode}
+%\DeclareOption{dvi2ps}{\def\Gin@driver{dvi2ps.def}}
+%\DeclareOption{dvialw}{\def\Gin@driver{dvialw.def}}
+%\DeclareOption{dvilaser}{\def\Gin@driver{dvilaser.def}}
+%\DeclareOption{dvitops}{\def\Gin@driver{dvitops.def}}
+%\DeclareOption{psprint}{\def\Gin@driver{psprint.def}}
+%\DeclareOption{pubps}{\def\Gin@driver{pubps.def}}
+%\DeclareOption{ln}{\def\Gin@driver{ln.def}}
+% \end{macrocode}
+% \end{option}
+% \end{option}
+% \end{option}
+% \end{option}
+% \end{option}
+% \end{option}
+% \end{option}
+%
+% \begin{option}{debugshow}
+% You probably don't want to use this\ldots
+% \begin{macrocode}
+\DeclareOption{debugshow}{\catcode`\^^A=9 \let\GDebug\typeout}
+% \end{macrocode}
+% \end{option}
+%
+% A local configuration file may define more options.
+% It should also make one driver option the default, by calling
+% |\ExecuteOptions| with the appropriate option.
+% \changes{v0.4f}{1994/07/27}
+% {Add missing 3rd argument to \cs{InputIfFileExists}}
+% \begin{macrocode}
+\InputIfFileExists{graphics.cfg}{}{}
+% \end{macrocode}
+%
+% \begin{option}{hiderotate}
+% \changes{v0.4a}{1994/04/13}
+% {Rename option to hiderotate}
+% \begin{macrocode}
+\DeclareOption{hiderotate}{%
+ \def\Grot@start{\begingroup\setbox\z@\hbox\bgroup}
+ \def\Grot@end{\egroup\endgroup}}
+% \end{macrocode}
+% \end{option}
+%
+% \begin{option}{hidescale}
+% \changes{v0.4a}{1994/04/13}
+% {Rename option to hidescale}
+% \begin{macrocode}
+\DeclareOption{hidescale}{%
+ \def\Gscale@start{\begingroup\setbox\z@\hbox\bgroup}
+ \def\Gscale@end{\egroup\endgroup}}
+% \end{macrocode}
+% \end{option}
+%
+% After the options are processed, load the appropriate driver file.
+% If a site wants a default driver (eg |textures|) it just needs to put
+% |\ExecuteOptions{textures}| in a |graphics.cfg| file.
+% \begin{macrocode}
+\ProcessOptions
+% \end{macrocode}
+%
+% Check that a driver has been specified (either as an option, or as a
+% default option in the configuration file). Then load the `def' file
+% for that option, if it has not already been loaded by some other
+% package (for instance the \textsf{color} package).
+% \changes{v0.5c}{1994/10/03}
+% {Error if no driver specified}
+% \begin{macrocode}
+\if!\Gin@driver!
+ \PackageError{graphics}
+ {No driver specified}
+ {You should make a default driver option in a file \MessageBreak
+ graphics.cfg\MessageBreak
+ eg: \protect\ExecuteOptions{textures}%
+ }
+\else
+ \PackageInfo{graphics}{Driver file: \Gin@driver}
+ \@ifundefined{ver@\Gin@driver}{\input{\Gin@driver}}{}
+\fi
+% \end{macrocode}
+%
+%
+% \subsection{Graphics Inclusion}
+%
+% This Graphics package uses a lot of dimension registers. \TeX\ only
+% has a limited number of registers, so rather than allocate new ones,
+% re-use some existing \LaTeX\ registers. This is safe as long as all
+% uses of the registers are \emph{local}, and that you can be sure
+% that you \emph{never} need to have access to both uses within the
+% same scope.
+%
+% \begin{macro}{\Gin@llx}
+% \begin{macro}{\Gin@lly}
+% \begin{macro}{\Gin@urx}
+% \begin{macro}{\Gin@ury}
+% In fact these four lengths are now stored as macros not as dimen
+% registers, mainly so that integer |bp| lengths may be passed exactly.
+% \changes{v0.7a}{1995/04/11}
+% {Bounding box coords no longer in registers}
+% \begin{macrocode}
+\def\Gin@llx{0}
+\let\Gin@lly\Gin@llx
+\let\Gin@urx\Gin@llx
+\let\Gin@ury\Gin@llx
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\Gin@nat@width}
+% \begin{macro}{\Gin@nat@height}
+% The `natural' size of the graphic, before any scaling.
+% \begin{macrocode}
+\let\Gin@nat@width\leftmarginv
+\let\Gin@nat@height\leftmarginvi
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\ifGin@clip}
+% This switch is \meta{true} if any graphics outside the specified
+% bounding box (really viewport) should not be printed.
+% \begin{macrocode}
+\newif\ifGin@clip
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\DeclareGraphicsExtensions}
+% \changes{v0.6a}{1994/11/29}
+% {Remove optional argument, ignore spaces in main argument.}
+% Declare a comma separated list of default extensions to be used
+% if the file is specified with no extension.
+% \begin{macrocode}
+\newcommand\DeclareGraphicsExtensions[1]{%
+ \edef\Gin@extensions{\zap@space#1 \@empty}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\Gin@extensions}
+% Initialise the list of possible extensions.
+% \changes{v0.4b}{1994/04/20}
+% {Use \cmd{\providecommand} in case a previous def file has
+% already defined it}
+% \begin{macrocode}
+\providecommand\Gin@extensions{}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\includegraphics}
+% \changes{v1.1a}{2017/03/17}
+% {\cs{leavevmode} added before the group in \cs{Gin@iii} so that
+% settings in \cs{everypar} are cleared}
+% Top level command for the standard interface, just look for a |*|.
+% \begin{macrocode}
+\def\includegraphics{%
+% \end{macrocode}
+% Clear |\everypar| before starting a group.
+% \begin{macrocode}
+ \leavevmode
+% \end{macrocode}
+%
+% \begin{macrocode}
+ \@ifstar
+ {\Gin@cliptrue\Gin@i}%
+ {\Gin@clipfalse\Gin@i}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\Gin@i}
+% If an optional argument is present, call |\Gin@ii| to process it,
+% otherwise call |\Ginclude@graphics|.
+% \changes{v0.3e}{1994/03/09}
+% {Now specify ll before ur coordinate}
+% \begin{macrocode}
+\def\Gin@i{%
+ \@ifnextchar[%]
+ \Gin@ii
+ {\Gin@bboxfalse\Ginclude@graphics}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\Gin@ii}
+% Look for a second optional argument.
+% \begin{macrocode}
+\def\Gin@ii[#1]{%
+ \@ifnextchar[%]
+ {\Gin@iii[#1]}
+ {\Gin@iii[0,0][#1]}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\Gin@iii}
+% Set the coordinates of the {\bfseries l}lower {\bfseries l}eft corner,
+% and the coordinates of the {\bfseries u}pper {\bfseries r}ight
+% corner. The coordinates may be any \TeX\ dimension, defaulting to |bp|.
+% \changes{v0.6c}{1994/12/15}
+% {(Denis Roegel) Extra group to keep bb settings local}
+% \begin{macrocode}
+\def\Gin@iii[#1,#2][#3,#4]#5{%
+ \begingroup
+ \Gin@bboxtrue
+ \Gin@defaultbp\Gin@llx{#1}%
+ \Gin@defaultbp\Gin@lly{#2}%
+ \Gin@defaultbp\Gin@urx{#3}%
+ \Gin@defaultbp\Gin@ury{#4}%
+ \Ginclude@graphics{#5}%
+ \endgroup}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\Gin@defaultbp}
+% \changes{v0.7a}{1995/04/11}{Macro added}
+% \begin{macro}{\Gin@def@bp}
+% \changes{v0.7a}{1995/04/11}{Macro added}
+% This macro grabs a length, |#2|, which may or may not have a unit,
+% and if a unit is supplied, converts to `bp' and stores the value in
+% |#1|. If a unit is not supplied `bp' is assumed, and |#2| is directly
+% stored in |#1|. Note that supplying `bp' is not quite the same as
+% supplying no units, as in the former case a conversion via `pt' and
+% back to `bp' takes place which can introduce rounding error. The error
+% is invisibly small but files conforming to Adobe DSC should have
+% \emph{integer} Bounding Box Coordinates, and conceivably some drivers
+% might demand integer values.
+% (Although most seem to accept real values (if they accept bounding box
+% coordinates at all) in the |\special|. This is the reason why the
+% mechanism uses |\def| and not \TeX\ lengths, as in earlier releases of
+% the package.
+% \begin{macrocode}
+\def\Gin@defaultbp#1#2{%
+ \afterassignment\Gin@def@bp\dimen@#2bp\relax{#1}{#2}}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\Gin@def@bp#1\relax#2#3{%
+ \if!#1!%
+ \def#2{#3}%
+ \else
+ \dimen@.99626\dimen@
+ \edef#2{\strip@pt\dimen@}%
+ \fi}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\DeclareGraphicsRule}
+% Declare what actions should be taken for a particular file
+% extension.
+%
+% |#1| extension, |#2| type, |#3| read-file, |#4| command,
+% \changes{v0.5d}{1994/10/24}
+% {(Arthur Ogawa) Check arg3 is *, not arg2.}
+% \begin{macrocode}
+\def\DeclareGraphicsRule#1#2#3#4{%
+ \edef\@tempa{\string *}\def\@tempb{#3}%
+ \expandafter\edef\csname Gin@rule@#1\endcsname##1%
+ {{#2}%
+ {\ifx\@tempa\@tempb\noexpand\Gin@ext\else#3\fi}%
+ {\ifx\indent#4\indent##1\else#4\fi}}}
+% \end{macrocode}
+% \end{macro}
+%
+% An example rule base.
+%\begin{verbatim}
+% ext type read command
+% \DeclareGraphicsRule{.ps} {eps} {.ps} {}
+% \DeclareGraphicsRule{.eps} {eps} {.eps} {}
+% \DeclareGraphicsRule{.ps.gz}{eps} {.ps.bb} {`zcat #1}
+% \DeclareGraphicsRule{.pcx} {bmp} {} {}
+%\end{verbatim}
+%
+% \begin{macro}{\graphicspath}
+% User level command to set the input path for graphics files.
+% A list of directories, each in a |{}| group.
+% \begin{macrocode}
+\def\graphicspath#1{\def\Ginput@path{#1}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\Ginput@path}
+% The default graphic path is |\input@path|.
+% \begin{macrocode}
+\ifx\Ginput@path\@undefined
+ \let\Ginput@path\input@path
+\fi
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\Gin@getbase}
+% \changes{v0.6a}{1994/11/29}
+% {remove \cs{Gin@sep}}
+% Given a possible extension, |#1|, check whether the file exists. If
+% it does set |\Gin@base| and |\Gin@ext| to the filename stripped of
+% the extension, and the extension, respectively.
+% \begin{macrocode}
+\def\Gin@getbase#1{%
+ \edef\Gin@tempa{%
+ \def\noexpand\@tempa####1#1\space{%
+ \def\noexpand\Gin@base{####1}}}%
+ \IfFileExists{\filename@area\filename@base#1}%
+ {\Gin@tempa
+ \expandafter\@tempa\@filef@und
+ \edef\Gin@ext{#1}}{}}%
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\Gin@ext}
+% Initialise the macro to hold the extension.
+% \begin{macrocode}
+\let\Gin@ext\relax
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\Gin@sepdefault}
+% \changes{v0.6a}{1994/11/29}
+% {remove \cs{Gin@sep}}
+% This must match the token used by |\filename@parse| to delimit the
+% extension.
+% \begin{macrocode}
+\def\Gin@sepdefault{.}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\Ginclude@graphics}
+% The main internal function implementing graphics file inclusion.
+% |#1| is the file name.
+% \changes{v0.4c}{1994/04/28}
+% {Improve the wording of error messages}
+% \changes{v0.5a}{1994/07/20}
+% {Add default (*) rule possibility}
+% \changes{v0.6a}{1994/11/29}
+% {remove \cs{Gin@sepdefault}}
+% \begin{macrocode}
+\def\Ginclude@graphics#1{%
+ \begingroup
+ \let\input@path\Ginput@path
+ \filename@parse{#1}%
+ \ifx\filename@ext\relax
+ \@for\Gin@temp:=\Gin@extensions\do{%
+ \ifx\Gin@ext\relax
+ \Gin@getbase\Gin@temp
+ \fi}%
+ \else
+ \Gin@getbase{\Gin@sepdefault\filename@ext}%
+% \end{macrocode}
+% \changes{v0.4d}{1994/05/06}
+% {Make file not found a warning not an error}
+% \changes{v0.6a}{1994/11/29}
+% {remove \cs{Gin@sep}}
+% If the user supplied an explicit extension, just give a warning if the
+% file does not exist. (It may be created later.)
+% \begin{macrocode}
+ \ifx\Gin@ext\relax
+ \@warning{File `#1' not found}%
+ \def\Gin@base{\filename@area\filename@base}%
+% \end{macrocode}
+% \changes{v0.6c}{1994/12/15}
+% {(Piet van Oostrum) include `.' in \cs{Gin@ext}}%
+% \begin{macrocode}
+ \edef\Gin@ext{\Gin@sepdefault\filename@ext}%
+ \fi
+ \fi
+% \end{macrocode}
+% If no extension is supplied, it is an error if the file does not
+% exist, as there is no way for the system to know which extension to
+% supply.
+% \begin{macrocode}
+ \ifx\Gin@ext\relax
+ \@latex@error{File `#1' not found}%
+ {I could not locate the file with any of these extensions:^^J%
+ \Gin@extensions^^J\@ehc}%
+ \else
+ \@ifundefined{Gin@rule@\Gin@ext}%
+% \end{macrocode}
+% \changes{v0.5a}{1994/07/20}
+% {Add default (*) rule possibility}
+% Handle default rule.
+% \begin{macrocode}
+ {\ifx\Gin@rule@*\@undefined
+ \@latex@error{Unknown graphics extension: \Gin@ext}\@ehc
+ \else
+ \expandafter\Gin@setfile\Gin@rule@*{\Gin@base\Gin@ext}%
+ \fi}%
+ {\expandafter\expandafter\expandafter\Gin@setfile
+ \csname Gin@rule@\Gin@ext\endcsname{\Gin@base\Gin@ext}}%
+ \fi
+ \endgroup}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ifGread@}
+% True if a file should be read to obtain the natural size.
+% \begin{macrocode}
+\newif\ifGread@\Gread@true
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\Gin@setfile}
+% Set a file to the size specified in arguments, or in a `read file'.
+% \changes{v0.5d}{1994/10/24}
+% {(Arthur Ogawa) Add missing \cs{expandafter}}
+% \begin{macrocode}
+\def\Gin@setfile#1#2#3{%
+ \ifx\\#2\\\Gread@false\fi
+ \ifGin@bbox\else
+ \ifGread@
+ \csname Gread@%
+ \expandafter\ifx\csname Gread@#1\endcsname\relax
+ eps%
+ \else
+ #1%
+ \fi
+ \endcsname{\Gin@base#2}%
+ \else
+% \end{macrocode}
+% \changes{v0.5a}{1994/07/20}
+% {New error trap for missing size arguments}
+% \changes{v0.7f}{1995/11/10}
+% {Use \cs{Gin@nosize}}
+% By now the natural size should be known either from arguments or
+% from the file. If not generate an error. (The \textsf{graphicx}
+% interface relaxes this condition slightly.)
+% \begin{macrocode}
+ \Gin@nosize{#3}%
+ \fi
+ \fi
+% \end{macrocode}
+% \changes{v0.7a}{1995/04/11}{\cs{Gin@viewport@code} added.}
+% The following call will modify the `natural size' if the user has
+% supplied a viewport or trim specification. (Not available in the
+% standard interface.)
+% \begin{macrocode}
+ \Gin@viewport@code
+% \end{macrocode}
+% Save the natural size, and then call |\Gin@req@sizes| which (in the
+% key-val interface) will calculate the required size from the natural
+% size, and any scaling info.
+% \begin{macrocode}
+ \Gin@nat@height\Gin@ury bp%
+ \advance\Gin@nat@height-\Gin@lly bp%
+ \Gin@nat@width\Gin@urx bp%
+ \advance\Gin@nat@width-\Gin@llx bp%
+ \Gin@req@sizes
+% \end{macrocode}
+%
+% Call |\Ginclude@|\emph{type} to include the figure unless
+% this is not defined, or draft mode is being used.
+% \changes{v0.7h}{1996/02/20}
+% {missing \texttt{@} added in \texttt{Gread@} csnames}
+% \begin{macrocode}
+ \expandafter\ifx\csname Ginclude@#1\endcsname\relax
+ \Gin@drafttrue
+ \expandafter\ifx\csname Gread@#1\endcsname\relax
+ \@latex@error{Can not include graphics of type: #1}\@ehc
+ \global\expandafter\let\csname Gread@#1\endcsname\@empty
+ \fi
+ \fi
+ \leavevmode
+ \ifGin@draft
+ \hb@xt@\Gin@req@width{%
+ \vrule\hss
+ \vbox to \Gin@req@height{%
+ \hrule \@width \Gin@req@width
+ \vss
+ \edef\@tempa{#3}%
+ \rlap{ \ttfamily\expandafter\strip@prefix\meaning\@tempa}%
+ \vss
+ \hrule}%
+ \hss\vrule}%
+ \else
+% \end{macrocode}
+% \changes{v0.3i}{1994/3/23}
+% {Add file list info}
+% Support |\listfiles| and then set the final box to the required size.
+% \begin{macrocode}
+ \@addtofilelist{#3}%
+ \ProvidesFile{#3}[Graphic file (type #1)]%
+ \setbox\z@\hbox{\csname Ginclude@#1\endcsname{#3}}%
+ \dp\z@\z@
+ \ht\z@\Gin@req@height
+ \wd\z@\Gin@req@width
+ \box\z@
+ \fi}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\Gin@decode}
+% \changes{v1.2c}{2017/06/25}
+% {New macro}
+% In the standard interface this is a no-op, but needs to be defined
+% to allow the caching code to be set up.
+% \begin{macrocode}
+\let\Gin@decode\@empty
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\Gin@exclamation}
+% \changes{v0.7g}{1995/12/06}{Macro added}
+% Catcode 12 |!|, in case of French, or other language styles.
+% \begin{macrocode}
+\def\Gin@exclamation{!}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\Gin@page}
+% \changes{v1.2a}{2017/06/01}
+% {New macro}
+% In the standard interface this is a no-op, but needs to be defined
+% to allow the caching code to be set up.
+% \begin{macrocode}
+\let\Gin@page\@empty
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\Gin@pagebox}
+% \changes{v1.2a}{2017/06/01}
+% {New macro}
+% In the standard interface always points to the |cropbox|.
+% \begin{macrocode}
+\def\Gin@pagebox{cropbox}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ifGin@interpolate}
+% \changes{v1.2a}{2017/06/01}
+% {New macro}
+% In the standard setting a no-op.
+% \begin{macrocode}
+\newif\ifGin@interpolate
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\Gin@log}
+% \changes{v1.2a}{2017/06/01} {New macro} In the standard interface
+% this prints to the log but can be changed via keys in \textsf{graphicx}.
+% \begin{macrocode}
+\let\Gin@log\wlog
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\Gin@req@sizes}
+% \begin{macro}{\Gin@scalex}
+% \begin{macro}{\Gin@scaley}
+% \begin{macro}{\Gin@req@height}
+% \begin{macro}{\Gin@req@width}
+% In the standard interface there is no scaling, so the required size
+% is the same as the natural size. In other interfaces |\Gin@req@sizes|
+% will be responsible for setting these parameters. Here we can set them
+% globally.
+% \changes{v0.3g}{1994/03/15}
+% {Initialise y-scale to !!}
+% \changes{v1.0g}{1998/05/14}
+% {Fix !! usage in changes entries. graphics/2724}
+% \begin{macrocode}
+\let\Gin@req@sizes\relax
+\def\Gin@scalex{1}%
+\let\Gin@scaley\Gin@exclamation
+\let\Gin@req@height\Gin@nat@height
+\let\Gin@req@width\Gin@nat@width
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\Gin@viewport@code}
+% In the standard interface there is no possibility of specifying
+% a viewport, so this is a no-op.
+% \changes{v0.7a}{1995/04/11}{Macro added}
+% \begin{macrocode}
+\let\Gin@viewport@code\relax
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\Gin@nosize}
+% \changes{v1.0p}{2014/10/14}{Fixed typo in error message}
+% \changes{v0.7f}{1995/11/10}
+% {Macro added}
+% This command is called in the case that the graphics type
+% specifies no `read file' and the user supplied no size arguments.
+% In the standard interface can only generate an error.
+% \begin{macrocode}
+\def\Gin@nosize#1{%
+ \@latex@error
+ {Cannot determine size of graphic in #1 (no size specified)}%
+ \@ehc}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsection{Reading the BoundingBox in EPS files}
+%
+% \begin{macro}{\ifGin@bbox}
+% \changes{v0.7a}{1995/04/11}{Name changed from \cs{ifGin@viewport}}
+% This switch should be set \meta{true} once a size has been found,
+% either in an argument, or in an external file.
+% \begin{macrocode}
+\newif\ifGin@bbox
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\Gread@generic}
+% \changes{v1.2a}{2017/06/01}
+% {New macro}
+% \begin{macro}{\Gread@generic@aux}
+% \begin{macro}{\Gread@eps}
+% Read an EPS file (|#1|) and search for a line
+% starting with |%%BoundingBox| and returns the result
+% by setting four dimension registers
+% |\Gin@llx|, |\Gin@lly|, |\Gin@urx| and |\Gin@ury|.
+% \changes{v0.5e}{1994/1l/02}
+% {Fix the catcodes of \cs{endlinechar} and ctrl-D}
+% \changes{v0.7a}{1995/04/11}
+% {Fix more catcodes, for binary headers of eps files}
+% \changes{v1.2a}{2017/06/01}
+% {Split to allow code reuse by \cs{Gread@extractbb} in
+% \texttt{dvipdfmx.def} driver}
+% \begin{macro}{\Gread@eps@aux}
+% \begin{macrocode}
+\def\Gread@generic#1#2{%
+ \edef\Gread@attr@hash{%
+ \ifx\Gin@pagebox\@empty\else
+ :\Gin@pagebox
+ \fi
+ \ifx\Gin@page\@empty\else
+ :P\Gin@page
+ \fi
+ }%
+ \@ifundefined{#1 bbox\Gread@attr@hash}%
+ {\Gread@generic@aux{#1}{#2}}
+ {%
+ \expandafter\global\expandafter\let\expandafter\@gtempa
+ \csname #1 bbox\Gread@attr@hash\endcsname
+ }%
+ \expandafter\Gread@parse@bb\@gtempa\\%
+}
+\def\Gread@generic@aux#1#2{%
+ \begingroup
+% \end{macrocode}
+% Make it reasonably safe to have binary headers in the EPS file
+% before the bounding box line.
+% \begin{macrocode}
+ \@tempcnta\z@
+ \loop\ifnum\@tempcnta<\@xxxii
+ \catcode\@tempcnta14 %
+ \advance\@tempcnta\@ne
+ \repeat
+ \catcode`\^^?14 %
+ \let\do\@makeother
+ \dospecials
+% \end{macrocode}
+% Make sure tab and space are accepted as white space.
+% \changes{v1.0e}{1997/09/02}
+% {Allow TAB in DSC comments graphics/2587}
+% \changes{v1.0i}{1999/01/07}
+% {Fix catcode of hyphen. graphics/2846}
+% \begin{macrocode}
+ \catcode`\ 10 %
+ \catcode`\^^I10 %
+ \catcode\endlinechar5 %
+ \@makeother\:%
+ \@makeother\-%
+% \end{macrocode}
+% The first thing we need to do is to open the
+% information file, if possible.
+% \changes{v0.4d}{1994/05/06}
+% {Improve the error message if the info file is not there.}
+% \changes{v1.2a}{2017/06/01}
+% {Allow for spaces in name of a file}
+% \begin{macrocode}
+ \immediate\openin\@inputcheck"#1" %
+ #2{#1}%
+% \end{macrocode}
+% \changes{v0.3i}{1994/03/23}
+% {Wording of error message improved}
+% \changes{v1.0}{1996/05/29}
+% {Use \cs{@gtempa} not \cs{g@tempa} /2090}
+% \changes{v1.2b}{2017/06/13}
+% {Stored bounding box data for reuse}
+% \begin{macrocode}
+ \ifGin@bbox
+ \expandafter\xdef\csname #1 bbox\Gread@attr@hash\endcsname{\@gtempa}%
+ \else
+ \@latex@error
+ {Cannot determine size of graphic in #1 (no BoundingBox)}%
+ \@ehc
+ \gdef\@gtempa{0 0 72 72 }%
+ \fi
+ \endgroup
+}
+\def\Gread@eps#1{%
+ \Gread@generic{#1}\Gread@eps@aux
+}
+\def\Gread@eps@aux#1{%
+ \ifeof\@inputcheck
+ \@latex@error{File `#1' not found}\@ehc
+ \else
+% \end{macrocode}
+% Now we'll scan lines until we find one that starts with
+% |%%BoundingBox:|
+% We need to reset the catcodes to read the file, and so this
+% is done in a group.
+% \begin{macrocode}
+ \Gread@true
+ \let\@tempb\Gread@false
+ \loop
+ \read\@inputcheck to\@tempa
+ \ifeof\@inputcheck
+ \Gread@false
+ \else
+ \expandafter\Gread@find@bb\@tempa:.\\%
+ \fi
+ \ifGread@
+ \repeat
+ \immediate\closein\@inputcheck
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\Gread@find@bb}
+% If a line in the EPS file starts with a |%%BoundingBox:|, we
+% will examine it more closely. Note using the `extra' argument |#2#3|
+% causes any space after the |:| to be gobbled.
+% \begin{macrocode}
+\long\def\Gread@find@bb#1:#2#3\\{%
+ \def\@tempa{#1}%
+ \ifx\@tempa\Gread@BBox
+ \Gread@test@atend#2#3()\\%
+ \fi}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\Gread@test@atend}
+% Determine if the stuff following the |%%BoundingBox| is `(atend)',
+% which will involve further reading of the file. This is accomplished
+% by making |\@tempb| into a no-op, so that finding a |%%BoundingBox|
+% does not stop the loop.
+% \begin{macrocode}
+\def\Gread@test@atend#1(#2)#3\\{%
+ \def\@tempa{#2}%
+ \ifx\@tempa\Gread@atend
+ \Gread@true
+ \let\@tempb\relax
+ \else
+ \gdef\@gtempa{#1}%
+ \@tempb
+ \Gin@bboxtrue
+ \fi}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\Gread@parse@bb}
+% We have |%%BoundingBox| and what follows is not `(atend)' so we
+% will parse the rest of the line as a BB with four elements.
+% PostScript files should never have units specified in the
+% BoundingBox comment, but we allow arbitrary \TeX\ units in external
+% files, or in other interfaces.
+% \begin{macrocode}
+\def\Gread@parse@bb#1 #2 #3 #4 #5\\{%
+ \Gin@defaultbp\Gin@llx{#1}%
+ \Gin@defaultbp\Gin@lly{#2}%
+ \Gin@defaultbp\Gin@urx{#3}%
+ \Gin@defaultbp\Gin@ury{#4}}%
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\Gread@atend}
+% |atend| as a macro for testing with |\ifx|.
+% \begin{macrocode}
+\def\Gread@atend{atend}
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \subsection{Rotation}
+%
+% As above, we will re-use some existing local registers.
+%
+% \begin{macro}{\Grot@height}
+% \begin{macro}{\Grot@left}
+% \begin{macro}{\Grot@right}
+% \begin{macro}{\Grot@depth}
+% Final Rotated box dimensions
+% \begin{macrocode}
+\let\Grot@height\@ovxx
+\let\Grot@left\@ovyy
+\let\Grot@right\@ovdx
+\let\Grot@depth\@ovdy
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\Grot@h}
+% \begin{macro}{\Grot@l}
+% \begin{macro}{\Grot@r}
+% \begin{macro}{\Grot@d}
+% Original box dimensions
+% \begin{macrocode}
+\let\Grot@l\@ovro
+\let\Grot@r\@ovri
+\let\Grot@h\@xdim
+\let\Grot@d\@ydim
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\Grot@x}
+% \begin{macro}{\Grot@y}
+% Coordinates of centre of rotation.
+% \begin{macrocode}
+\let\Grot@x\@linelen
+\let\Grot@y\@dashdim
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\rotatebox}
+% The angle is specified by |#1|. The box to be rotated is |#2|.
+% In the standard interface the centre of rotation is $(0,0)$.
+% Then finally call |\Grot@box| to rotate the box.
+% \changes{v0.3f}{1994/03/11}{Remove star form}
+% \changes{v0.3h}{1994/03/17}{Fix Typo}
+% \changes{v0.7a}{1995/04/11}{\cs{leavevmode} added graphics/1521}
+% \changes{v1.0n}{2001/07/07}
+% {Made long (CAR) graphics/2908 and 3345}
+% \begin{macrocode}
+\long\def\rotatebox#1#2{%
+ \leavevmode
+ \Grot@setangle{#1}%
+ \setbox\z@\hbox{{#2}}%
+ \Grot@x\z@
+ \Grot@y\z@
+ \Grot@box}
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\Grot@setangle}
+% Set the internal macro used by |\Grot@box|. In the standard
+% interface this is trivial, but other interfaces may have more
+% interesting definitions. For example:
+%\begin{verbatim}
+% \def\Grot@setangle#1{%
+% \dimen@#1\p@
+% \dimen@-57.2968\dimen@
+% \edef\Grot@angle{\strip@pt\dimen@}}
+%\end{verbatim}
+% This would cause the argument of |\rotatebox| to be interpreted as
+% an angle specified in \emph{radians}, \emph{clockwise}.
+% \begin{macrocode}
+\def\Grot@setangle#1{\edef\Grot@angle{#1}}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsection{Deriving a `bounding box' for rotated object}
+% We want to know the size of a `bounding box' enclosing the rotated
+% box.
+% We define two formulae (as \TeX\ macros) to work out the $x$ and $y$
+% coordinates of vertices of the rotated box
+% in relation to its original coordinates (i.e., its width, height
+% and depth). The box we visualize with vertices $B$, $C$,
+% $D$ and $E$ is illustrated below. The vertex
+% $S$ is the reference point on the baseline. $O$ is the centre of
+% rotation, which in the standard interface is always $S$.
+%
+% \begin{center}
+% \setlength{\unitlength}{3pt}%
+%
+% \begin{picture}(34,36)(12,44)
+% \thicklines
+% \put(20,52){\dashbox{1}(20,21){}}
+% \put(20,80){\line(0,-1){36}}
+% \put(12,58){\line(1, 0){34}}
+% \put(41,59){A}
+% \put(40,74){B}
+% \put(21,74){C}
+% \put(21,49){D}
+% \put(40,49){E}
+% \put(21,59){S}
+% \put(33,65){O}
+% \put(33,65){\circle*{1}}
+% \end{picture}
+% \end{center}
+%
+% The formulae are, for a point $P$ and angle $\alpha$:
+%\[
+% \begin{array}{l}
+% P'_x = P_x - O_x \\
+% P'_y = P_y - O_y \\
+% P''_x = ( P'_x \times \cos(\alpha)) - ( P'_y \times \sin(\alpha) ) \\
+% P''_y = ( P'_x \times \sin(\alpha)) + ( P'_y \times \cos(\alpha) ) \\
+% P'''_x = P''_x + O_x + L_x \\
+% P'''_y = P''_y + O_y
+% \end{array}
+% \]
+% The `extra' horizontal translation $L_x$ at the end is calculated so
+% that the leftmost point of the resulting box has $x$-coordinate $0$.
+% This is desirable as \TeX\ boxes must have the reference point at
+% the left edge of the box.
+%
+% \begin{macro}{\Grot@Px}
+% Work out new $x$ coordinate of point after rotation. The parameters
+% |#2| and |#3| are the original $x$ and $y$ coordinates of the point.
+% The new $x$ coordinate is stored in |#1|.
+% \begin{macrocode}
+\def\Grot@Px#1#2#3{%
+ #1\Grot@cos#2%
+ \advance#1-\Grot@sin#3}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\Grot@Py}
+% Work out new $y$ coordinate of point after rotation. The parameters
+% |#2| and |#3| are the original $x$ and $y$ coordinates of the point.
+% The new $y$ coordinate is stored in |#1|.
+% \begin{macrocode}
+\def\Grot@Py#1#2#3{%
+ #1\Grot@sin#2%
+ \advance#1\Grot@cos#3}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\Grot@box}
+% This is the tricky bit. We can rotate the box, but then need
+% to work out how much space to leave for it on the page.
+%
+% We simplify matters by working out first which quadrant we are in, and
+% then picking just the right values.
+%
+% \begin{macrocode}
+\def\Grot@box{%
+ \begingroup
+% \end{macrocode}
+% We are going to need to know the sine and cosine
+% of the angle; simplest to calculate these now.
+% \begin{macrocode}
+ \CalculateSin\Grot@angle
+ \CalculateCos\Grot@angle
+ \edef\Grot@sin{\UseSin\Grot@angle}%
+ \edef\Grot@cos{\UseCos\Grot@angle}%
+^^A \GDebug{Rotate: angle \Grot@angle, sine is \Grot@sin,
+^^A cosine is \Grot@cos}%
+% \end{macrocode}
+% Save the four extents of the original box.
+% \begin{macrocode}
+ \Grot@r\wd\z@ \advance\Grot@r-\Grot@x
+ \Grot@l\z@ \advance\Grot@l-\Grot@x
+ \Grot@h\ht\z@ \advance\Grot@h-\Grot@y
+ \Grot@d-\dp\z@ \advance\Grot@d-\Grot@y
+% \end{macrocode}
+% Now a straightforward test to see which quadrant we are
+% operating in;
+% \begin{macrocode}
+ \ifdim\Grot@sin\p@>\z@
+ \ifdim\Grot@cos\p@>\z@
+% \end{macrocode}
+% First quadrant:
+% Height=$By$, Right=$Ex$, Left=$Cx$, Depth=$Dy$
+% \begin{macrocode}
+ \Grot@Py\Grot@height \Grot@r\Grot@h%B
+ \Grot@Px\Grot@right \Grot@r\Grot@d%E
+ \Grot@Px\Grot@left \Grot@l\Grot@h%C
+ \Grot@Py\Grot@depth \Grot@l\Grot@d%D
+ \else
+% \end{macrocode}
+% Second quadrant:
+% Height=$Ey$, Right=$Dx$, Left=$Bx$, Depth=$Cy$
+% \begin{macrocode}
+ \Grot@Py\Grot@height \Grot@r\Grot@d%E
+ \Grot@Px\Grot@right \Grot@l\Grot@d%D
+ \Grot@Px\Grot@left \Grot@r\Grot@h%B
+ \Grot@Py\Grot@depth \Grot@l\Grot@h%C
+ \fi
+ \else
+ \ifdim\Grot@cos\p@<\z@
+% \end{macrocode}
+% Third quadrant:
+% Height=$Dy$, Right=$Cx$, Left=$Ex$, Depth=$By$
+% \begin{macrocode}
+ \Grot@Py\Grot@height \Grot@l\Grot@d%D
+ \Grot@Px\Grot@right \Grot@l\Grot@h%C
+ \Grot@Px\Grot@left \Grot@r\Grot@d%E
+ \Grot@Py\Grot@depth \Grot@r\Grot@h%B
+ \else
+% \end{macrocode}
+% Fourth quadrant:
+% Height=$Cy$, Right=$Bx$, Left=$Dx$, Depth=$Ey$
+% \begin{macrocode}
+ \Grot@Py\Grot@height \Grot@l\Grot@h%C
+ \Grot@Px\Grot@right \Grot@r\Grot@h%B
+ \Grot@Px\Grot@left \Grot@l\Grot@d%D
+ \Grot@Py\Grot@depth \Grot@r\Grot@d%E
+ \fi
+ \fi
+% \end{macrocode}
+% Now we should translate back by $(O_x,O_y)$, but \TeX\ can not really
+% deal with boxes that do not have the reference point at the left edge.
+% (Everything with a $-$ve $x$-coordinate would over-print earlier
+% text). So we modify the horizontal translation so that the
+% reference point as understood by \TeX\ \emph{is} at the left edge.
+% This means that the `centre of rotation' is not fixed by |\rotatebox|,
+% but typically moves horizontally. We also need to find the image of
+% the original reference point, $S$, as that is where the rotation
+% specials must be inserted.
+%
+% \begin{macrocode}
+ \advance\Grot@height\Grot@y
+ \advance\Grot@depth\Grot@y
+ \Grot@Px\dimen@ \Grot@x\Grot@y
+ \Grot@Py\dimen@ii \Grot@x\Grot@y
+ \dimen@-\dimen@ \advance\dimen@-\Grot@left
+ \dimen@ii-\dimen@ii \advance\dimen@ii\Grot@y
+% \end{macrocode}
+%
+% \begin{macrocode}
+^^A \GDebug{Rotate: (l,r,h,d)^^J%
+^^A Original \the\Grot@l,\the\Grot@r,\the\Grot@h,\the\Grot@d,^^J%
+^^A New..... \the\Grot@left,\the\Grot@right,%
+^^A \the\Grot@height,\the\Grot@depth}%
+% \end{macrocode}
+%
+% \begin{macrocode}
+ \setbox\z@\hbox{%
+ \kern\dimen@
+ \raise\dimen@ii\hbox{\Grot@start\box\z@\Grot@end}}%
+ \ht\z@\Grot@height
+ \dp\z@-\Grot@depth
+ \advance\Grot@right-\Grot@left\wd\z@\Grot@right
+ \leavevmode\box\z@
+ \endgroup}
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \subsection{Stretching and Scaling}
+%
+%
+% \begin{macro}{\scalebox}
+% The top level |\scalebox|. If the vertical scale factor is omitted it
+% defaults to the horizontal scale factor, |#1|.
+% \changes{v0.3d}{1994/03/06}{Better support for negative arguments.}
+% \begin{macrocode}
+\def\scalebox#1{%
+ \@ifnextchar[{\Gscale@box{#1}}{\Gscale@box{#1}[#1]}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\Gscale@box}
+% Internal version of |\scalebox|.
+% \changes{v0.7a}{1995/04/11}
+% {\cs{leavevmode} moved earlier. graphics/1521}
+% \changes{v1.0j}{1999/01/07}
+% {made long. graphics/2908}
+% \changes{v1.1b}{2017/04/14}
+% {Adjust box resizing for math mode gh issue 6}
+% \begin{macrocode}
+\long\def\Gscale@box#1[#2]#3{%
+ \leavevmode
+ \def\Gscale@x{#1}\def\Gscale@y{#2}%
+ \setbox\z@\hbox{{#3}}%
+ \setbox\tw@\hbox{\Gscale@start\rlap{\copy\z@}\Gscale@end}%
+ \ifdim#2\p@<\z@
+ \ht\tw@-#2\dp\z@
+ \dp\tw@-#2\ht\z@
+ \else
+ \ht\tw@#2\ht\z@
+ \dp\tw@#2\dp\z@
+ \fi
+ \ifdim#1\p@<\z@
+ \hb@xt@-#1\wd\z@{\kern-#1\wd\z@\box\tw@\hss}%
+ \else
+ \hb@xt@#1\wd\z@{\box\tw@\kern#1\wd\z@\hss}%
+ \fi}
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\reflectbox}
+% Just an abbreviation for the appropriate scale to get reflection.
+% \changes{v0.3e}{1994/03/09}{Macro added}
+% \begin{macrocode}
+\def\reflectbox{\Gscale@box-1[1]}
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\resizebox}
+% \changes{v0.3b}{1994/03/01}{Recode \cmd\resizebox.}
+% \changes{v0.7b}{1995/04/27}
+% {Add \cs{leavevmode} for graphics/1512}
+% Look for a |*|, which specifies that a final vertical size refers to
+% `height + depth' not just `height'.
+% \begin{macrocode}
+\def\resizebox{%
+ \leavevmode
+ \@ifstar{\Gscale@@box\totalheight}{\Gscale@@box\height}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\Gscale@@box}
+% Look for the |!| in the arguments.
+% \changes{v0.5a}{1994/07/20}
+% {Support French active !!}
+% \changes{v0.5d}{1994/10/24}
+% {Correct the support for !!}
+% \changes{v0.7g}
+% {1995/12/06}{Use \cs{Gin@exclamation}}
+% \begin{macrocode}
+\def\Gscale@@box#1#2#3{%
+ \let\@tempa\Gin@exclamation
+ \expandafter\def\expandafter\@tempb\expandafter{\string#2}%
+ \expandafter\def\expandafter\@tempc\expandafter{\string#3}%
+ \ifx\@tempb\@tempa
+ \ifx\@tempc\@tempa
+ \toks@{\mbox}%
+ \else
+ \toks@{\Gscale@box@dd{#3}#1}%
+ \fi
+ \else
+ \ifx\@tempc\@tempa
+ \toks@{\Gscale@box@dd{#2}\width}%
+ \else
+ \toks@{\Gscale@box@dddd{#2}\width{#3}#1}%
+ \fi
+ \fi
+ \the\toks@}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\Gscale@box@dd}
+% Scale the text |#3| in both directions by a factor $|#1|/|#2|$.
+% \changes{v0.3i}{1994/03/23}
+% {Missing percent added}
+% \changes{v1.0i}{1999/01/07}
+% {made long. graphics/2908}
+% \begin{macrocode}
+\long\def\Gscale@box@dd#1#2#3{%
+ \@begin@tempboxa\hbox{#3}%
+ \setlength\@tempdima{#1}%
+ \setlength\@tempdimb{#2}%
+ \Gscale@div\@tempa\@tempdima\@tempdimb
+ \Gscale@box\@tempa[\@tempa]{\box\@tempboxa}%
+ \@end@tempboxa}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\Gscale@box@dddd}
+% Scale the text |#5| horizontally by a factor $|#1|/|#2|$ and
+% vertically by a factor $|#3|/|#4|$.
+% \changes{v0.3i}{1994/03/23}
+% {Missing percent added}
+% \changes{v0.7e}{1995/09/29}
+% {Add \cs{ifGin@iso} code added}
+% \changes{v1.0i}{1999/01/07}
+% {made long. graphics/2908}
+% \begin{macrocode}
+\long\def\Gscale@box@dddd#1#2#3#4#5{%
+ \@begin@tempboxa\hbox{#5}%
+ \setlength\@tempdima{#1}%
+ \setlength\@tempdimb{#2}%
+ \Gscale@div\@tempa\@tempdima\@tempdimb
+ \setlength\@tempdima{#3}%
+ \setlength\@tempdimb{#4}%
+ \Gscale@div\@tempb\@tempdima\@tempdimb
+ \ifGin@iso
+ \ifdim\@tempa\p@>\@tempb\p@
+ \let\@tempa\@tempb
+ \else
+ \let\@tempb\@tempa
+ \fi
+ \fi
+ \Gscale@box\@tempa[\@tempb]{\box\@tempboxa}%
+ \@end@tempboxa}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ifGin@iso}
+% If this flag is true, then specifying two lengths to |\resizebox|
+% scales the box by the same factor in either direction, such that
+% neither length \emph{exceeds} the stated amount. No user interface
+% to this flag in the standard package, but it is used by the
+% |keepaspectratio| key to |\includegraphics| in the \textsf{graphicx}
+% package.
+% \changes{v0.7e}{1995/09/29}
+% {Macro added}
+% \begin{macrocode}
+\newif\ifGin@iso
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\Gscale@div}
+% The macro |#1| is set to the ratio of the lengths |#2| and |#3|.
+% \changes{v0.7a}{1995/04/11}
+% {Add trap for division by 0}
+% \changes{v0.7d}{1995/09/27}
+% {Use \cs{setlength} to support calc package}
+% \changes{v1.0a}{1996/09/16}
+% {Stop infinite loop if 2nd arg zero. graphics/2259}
+% \begin{macrocode}
+\def\Gscale@div#1#2#3{%
+ \setlength\dimen@{#3}%
+ \ifdim\dimen@=\z@
+ \PackageError{graphics}{Division by 0}\@eha
+ \dimen@#2%
+ \fi
+ \edef\@tempd{\the\dimen@}%
+ \setlength\dimen@{#2}%
+ \count@65536\relax
+ \ifdim\dimen@<\z@
+ \dimen@-\dimen@
+ \count@-\count@
+ \fi
+ \ifdim\dimen@>\z@
+ \loop
+% \end{macrocode}
+%
+% \changes{v1.0u}{2016/10/09}
+% {avoid overflow for small lengths eg 5sp divided by 2sp}
+% \begin{macrocode}
+ \ifdim\ifnum\count@<\tw@\maxdimen\else\dimen@\fi<8192\p@
+ \dimen@\tw@\dimen@
+ \divide\count@\tw@
+ \repeat
+ \dimen@ii\@tempd\relax
+ \divide\dimen@ii\count@
+ \divide\dimen@\dimen@ii
+ \fi
+ \edef#1{\strip@pt\dimen@}}
+% \end{macrocode}
+% \end{macro}
+%
+% Restore Catcodes
+% \begin{macrocode}
+\Gin@codes
+\let\Gin@codes\relax
+% \end{macrocode}
+%
+% \begin{macrocode}
+%</package>
+% \end{macrocode}
+%
+% \Finale
+%
diff --git a/macros/latex/required/graphics/graphics.ins b/macros/latex/required/graphics/graphics.ins
new file mode 100644
index 0000000000..95e190c9ec
--- /dev/null
+++ b/macros/latex/required/graphics/graphics.ins
@@ -0,0 +1,43 @@
+%%
+%% This file is part of the Standard LaTeX `Graphics Bundle'.
+%% It may be distributed under the terms of the LaTeX Project Public
+%% License, as described in lppl.txt in the base LaTeX distribution.
+%% Either version 1.3c or, at your option, any later version.
+%%
+%% This file has the LPPL maintenance status "maintained".
+
+\input docstrip
+
+\preamble
+
+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!)
+
+
+\endpreamble
+
+\keepsilent
+\askforoverwritefalse
+
+\usedir{tex/latex/graphics}
+
+% The packages
+
+\generate{\file{graphics.sty}{\from{graphics.dtx}{package}}}
+
+\generate{\file{color.sty}{\from{color.dtx}{package}}}
+
+\generate{\file{graphicx.sty}{\from{graphicx.dtx}{package}}}
+
+\generate{\file{trig.sty}{\from{trig.dtx}{package}}}
+
+\generate{\file{keyval.sty}{\from{keyval.dtx}{package}}}
+
+\generate{\file{epsfig.sty}{\from{epsfig.dtx}{package}}}
+
+\generate{\file{lscape.sty}{\from{lscape.dtx}{package}}}
+
+\generate{\file{rotating.sty}{\from{rotating.dtx}{package}}}
+
+\endbatchfile
diff --git a/macros/latex/required/graphics/graphics.pdf b/macros/latex/required/graphics/graphics.pdf
new file mode 100644
index 0000000000..5d018d9219
--- /dev/null
+++ b/macros/latex/required/graphics/graphics.pdf
Binary files differ
diff --git a/macros/latex/required/graphics/graphicx.dtx b/macros/latex/required/graphics/graphicx.dtx
new file mode 100644
index 0000000000..aad8460ac5
--- /dev/null
+++ b/macros/latex/required/graphics/graphicx.dtx
@@ -0,0 +1,939 @@
+%
+% \iffalse
+%
+%% graphicx.dtx Copyright (C) 1994 David Carlisle Sebastian Rahtz
+%% Copyright (C) 1995--2015,2017 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
+%% License, as described in lppl.txt in the base LaTeX distribution.
+%% Either version 1.3c or, at your option, any later version.
+%%
+%<*dtx>
+ \ProvidesFile{graphicx.dtx}
+%</dtx>
+%<package>\NeedsTeXFormat{LaTeX2e}[1995/12/01]
+%<package>\ProvidesPackage{graphicx}
+%<driver> \ProvidesFile{graphicx.drv}
+% \fi
+% \ProvidesFile{graphicx.dtx}
+ [2017/06/01 v1.1a Enhanced LaTeX Graphics (DPC,SPQR)]
+%
+% \iffalse
+%<*driver>
+\documentclass{ltxdoc}
+\newenvironment{key}[2]{\expandafter\macro\expandafter{%
+ \csname KV@#1@#2\endcsname}}{\endmacro}
+%
+\begin{document}
+ \DocInput{graphicx.dtx}
+\end{document}
+%</driver>
+% \fi
+%
+% \GetFileInfo{graphicx.dtx}
+%
+% \title{The \textsf{graphicx} package\thanks{This file
+% has version number \fileversion, last
+% revised \filedate.}}
+% \author{D. P. Carlisle\and S. P. Q. Rahtz}
+% \date{\filedate}
+% \MaintainedByLaTeXTeam{graphics}
+% \maketitle
+%
+%
+% \changes{v0.3}{1994/03/01}
+% {First DPC version (after prototype by SPQR).}
+% \changes{v0.4b}{1994/05/30}
+% {Rename from egraphics. 8+3 name for CDROM}
+% \changes{v1.0}{1996/05/29}
+% {Version 1 at last}
+%
+% \def\star{{\ttfamily*}}
+% \makeatletter
+% \def\Describe@Macro#1{\endgroup
+% \setbox0=\lastbox\llap{\PrintDescribeMacro{#1}}}%
+% \makeatother
+% \marginparsep0pt
+%
+% \section{Introduction}
+%
+% This package provides an alternative interface to the \LaTeXe\
+% graphics functions. The command names provided are the same as in the
+% standard package, and they use the same internal functions. However
+% the meaning of the optional arguments is different. Note \emph{only}
+% the optional arguments have changed: any document which only uses the
+% graphics commands with the mandatory arguments and/or the star-forms
+% will work identically (with essentially identical implementation) with
+% the two packages.
+%
+% \section{Key=Value Interface}
+% When the decision to produce \LaTeXe\ was made, certain `guiding
+% principles' were made (and published in the original announcement).
+% One of these was that all new features would `conform to the
+% conventions of version 2.09'. Specifically this meant that new
+% commands would obey the same basic syntax rules for arguments as the
+% existing commands.
+%
+% Standard \LaTeX\ optional arguments are \emph{positional}. If a
+% command were to take three optional arguments, then there would be no
+% way of specifying only the third, one would have to give all three,
+% even if the first two were repeats of the default values. Basically
+% this means that `standard' optional arguments are not suitable if
+% there is more than one option. Various existing packages (for
+% \LaTeX~2.09) have recognised this, and used `named arguments' in
+% various forms. Perhaps the two most noticeable are |psfig| and
+% |pstricks|. With `named arguments' (sometimes called `attributes')
+% each option is not tied to a particular position, but rather given a
+% name (or key) and any options that must be set are set by explicitly
+% associating this name with the desired value.
+%
+% The members of the \LaTeX3 project do appreciate the importance of
+% this kind of syntax, but felt that rather than extending the syntax of
+% \LaTeX\ in an uncoordinated way, it would be better to keep with
+% `standard arguments' in \LaTeXe, which is intended as a `consolidation
+% of existing \LaTeX\ variants'. The long term planning for an eventual
+% \LaTeX3 release will then be able to consider the whole \LaTeX\
+% user interface, and a suitable syntax for named arguments. It is
+% important that such an interface design is not hampered by having to
+% retain compatibility with earlier attempts at a named argument
+% syntax. For this reason this |graphicx| package, which uses the named
+% argument mechanism from the |keyval| package should be considered `non
+% standard' although it is supported by the same mechanism, and same
+% authors as the `standard' |graphics| package.
+%
+% \section{The User Interface}
+%
+% \DescribeMacro
+% \includegraphics\star\oarg{key-val list}\marg{file}\\
+% \DescribeMacro
+% \includegraphics\star\oarg{llx,lly}\oarg{urx,ury}\marg{file}\\
+% Include a graphics file.
+%
+% The star form is just for
+% compatibility with the standard interface, and essentially just adds
+% |clip| to the keys specified. Similarly the second, two-optional
+% argument form is for increased compatibility with the standard
+% package. The two optional argument form is not needed in the |keyval|
+% interface.
+%
+% Various `keys' or named arguments are supported.
+% \begin{description}
+% \item[bb] Set the bounding box. The argument should be four
+% dimensions, separated by spaces.
+% \item[bbllx,bblly,bburx,bbury] Set the bounding box. Mainly for
+% compatibility with older packages. |bbllx=a,bblly=b,bburx=c,bbury=d|
+% is equivalent to |bb = a b c d|.
+% \item[natwidth,natheight] Again an alternative to |bb|.
+% |natheight=h,natwidth=w| is equivalent to |bb = 0 0 h w|.
+% \item[viewport] Modify the bounding box specified in the file.
+% The four values specify a bounding box \emph{relative} to the
+% |llx|,|lly| coordinate of the original box.
+% \item[trim] Modify the bounding box specified in the file.
+% The four values specify the amounts to remove from
+% the left, bottom, right and top of the original box.
+% \item[hiresbb] Boolean valued key. Defaults to |true|.
+% Causes \TeX\ to look for |%%HiResBoundingBox| comments rather than
+% the standard |%%BoundingBox|. May be set to |false| to override
+% a default setting of true specified by the |hiresbb| package option.
+% \item[angle] Rotation angle.
+% \item[origin] Rotation origin (see |\rotatebox|, below).
+% \item[width] Required width, a dimension (default units |bp|). The
+% graphic will be scaled to make the width the specified dimension.
+% \item[height] Required height. a dimension (default units |bp|).
+% \item[totalheight] Required totalheight (i.e., height $+$ depth). a
+% dimension (default units |bp|). Most useful after a rotation (when the
+% height might be zero).
+% \item[keepaspectratio] Boolean valued key (like |clip|). If it is set
+% to true, modify the meaning of the |width| and |height| (and
+% |totalheight|) keys such that if both are specified then rather than
+% distort the figure the figure is scaled such that neither dimension
+% \emph{exceeds} the stated dimensions.
+% \item[scale] Scale factor.
+% \item[clip] Either `true' or `false' (or no value, which is equivalent
+% to `true'). Clip the graphic to the bounding box (or viewport if one
+% is specified).
+% \item[draft] a boolean valued key, like `clip'. locally switches to
+% draft mode, ie.\ do not include the graphic, but leave the
+% correct space, and print the filename.
+% \item[type] Specify the file type. (Normally determined from the file
+% extension.)
+% \item[ext] Specify the file extension.
+% \emph{Only} for use with |type|.
+% \item[read] Specify the `read file' which is used for determining the
+% size of the graphic. \emph{Only} for use with |type|.
+% \item[command] Specify the file command.
+% \emph{Only} for use with |type|.
+% \item[quiet] Turns off writing information about graphics to the |.log|.
+% \item[page] The page of a multi-page PDF graphic to be used.
+% \item[interpolate] Enables interpolation of bitmap images by viewers.
+% \item[pagebox] Specifies which PDF box should be used for the natural image size, one of
+% mediabox, cropbox, bleedbox, trimbox, artbox. The default is driver-specific.
+% \end{description}
+%
+% The arguments are interpreted left to right. |clip|, |draft|, |bb|,,
+% and |bbllx| etc.\ have the same effect wherever they appear. but the
+% scaling and rotation keys interact.
+%
+% Any scaling that is specified \emph{before} rotation, is handled by
+% the internal graphics inclusion function. Rotation, or any later
+% scaling is handled by implicitly calling |\rotatebox| or |\scalebox|.
+% So |[height=1in,angle=90]| scales the graphic to 1in, then rotates it,
+% so it is one inch wide. |[angle=90,height=1in]| first rotates, then
+% scales the result so that it is 1in high. A driver that can scale
+% included graphics, but not arbitrary text will not be able to support
+% the second form, as it will require a call to |\scalebox|, but the
+% first form should work as there the scaling is handled by
+% |\Ginclude@graphics|.
+%
+% \DescribeMacro
+% \rotatebox\oarg{key-val list}\marg{angle}\marg{text}\\
+% Rotate \emph{text}.
+%
+% The keys supported by |\rotatebox| are:
+% \begin{description}
+% \item[origin] Specify the centre of rotation. |origin=|\meta{label},
+% where the labels are up to two of |lrctbB| (|B| denotes the
+% baseline, as for PSTricks).
+% \item[x,y] An alternative to
+% |origin|. |x=|\meta{dimen}|,y=|\meta{dimen} The $x,y$ coordinate of
+% the centre of rotation. As usual |\height| etc may be used.
+% \item[units] Specify the units used in the main argument. eg
+% |units=-360| would mean that the argument referred to degrees
+% \emph{clockwise} instead of the default anti-clockwise rotation.
+% \end{description}
+%
+% As an example |\rotatebox[origin=c]{180}{text}| will rotate ``text''
+% around its centre, thus creating a final box of the same dimensions as
+% the original box. This is to be contrasted to the default behaviour,
+% which rotates around the reference point on the baseline, thus
+% producing a box that is mainly \emph{below} the baseline.
+%
+% \StopEventually{}
+%
+%
+% \section{Implementation}
+%
+% \begin{macrocode}
+%<*package>
+% \end{macrocode}
+%
+% One new option is handled by keyval. It suppresses the error
+% normally generated if an unknow keyval key is used.
+% (This helps porting between drivers that use extended interfaces.)
+% \changes{v1.0e}{1999/01/10}{new unknownkeysallowed option}
+% \begin{macrocode}
+\DeclareOption{unknownkeysallowed}
+ {\PassOptionsToPackage\CurrentOption{keyval}}
+% \end{macrocode}
+%
+% All other options are handled by the \textsf{graphics} package.
+% \begin{macrocode}
+\DeclareOption*{\PassOptionsToPackage\CurrentOption{graphics}}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\ProcessOptions
+% \end{macrocode}
+%
+% This package requires these two building blocks.
+% \begin{macrocode}
+\RequirePackage{keyval,graphics}
+% \end{macrocode}
+%
+%
+% \subsection{Graphics Inclusion}
+%
+%
+% First we declare the `bounding box' keys. These all use
+% |\Gin@defaultbp| so that the \meta{value} can be given as a length in
+% the usual \TeX\ units such as |cm| or as an integer, taken as |bp|.
+%
+% \begin{key}{Gin}{bb}
+% \begin{macrocode}
+\define@key{Gin}{bb}
+ {\Gin@bboxtrue\Gread@parse@bb#1 \\}
+% \end{macrocode}
+% \end{key}
+%
+% \begin{key}{Gin}{bbllx}
+% \begin{key}{Gin}{bblly}
+% \begin{key}{Gin}{bburx}
+% \begin{key}{Gin}{bbury}
+% \changes{v0.3b}{1994/03/11}{use bbllx not llx}
+% \changes{v0.3b}{1994/03/11}{add natheight and natwidth}
+% \changes{v0.6a}{1995/04/11}{New \cs{Gin@defaultbb} code}
+% \changes{v0.6b}{1995/06/26}{typos fixed for graphics/1685}
+% \begin{macrocode}
+\define@key{Gin}{bbllx}
+ {\Gin@bboxtrue\Gin@defaultbp\Gin@llx{#1}}
+\define@key{Gin}{bblly}
+ {\Gin@bboxtrue\Gin@defaultbp\Gin@lly{#1}}
+\define@key{Gin}{bburx}
+ {\Gin@bboxtrue\Gin@defaultbp\Gin@urx{#1}}
+\define@key{Gin}{bbury}
+ {\Gin@bboxtrue\Gin@defaultbp\Gin@ury{#1}}
+% \end{macrocode}
+% \end{key}
+% \end{key}
+% \end{key}
+% \end{key}
+%
+% \begin{key}{Gin}{hiresbb}
+% \changes{v1.0b}{1996/10/29}
+% {hiresbb key added}
+% If set to true (the default) \TeX\ will look for bounding box
+% comments of the form |%%HiResBoundingBox| (which typically have
+% real values) instead of the standard |%%BoundingBox| (which should
+% have integer values).
+% It may be set to false to override a package option of hiresbb.
+% \begin{macrocode}
+\define@key{Gin}{hiresbb}[true]{%
+ \edef\Gread@BBox{%
+ \@percentchar\@percentchar
+ \csname if#1\endcsname HiRes\fi
+ BoundingBox}}
+% \end{macrocode}
+% \end{key}
+%
+% \begin{key}{Gin}{natheight}
+% \begin{key}{Gin}{natheight}
+% \changes{v0.6d}{1995/09/22}
+% {typos fixed in natheight and natwidth keys}
+% \begin{macrocode}
+\let\KV@Gin@natwidth\KV@Gin@bburx
+\let\KV@Gin@natheight\KV@Gin@bbury
+% \end{macrocode}
+% \end{key}
+% \end{key}
+%
+% \begin{key}{Gin}{viewport}
+% \begin{key}{Gin}{trim}
+% \changes{v0.6a}{1995/04/11}{viewport and trim keys added}
+% \changes{v0.6c}{1995/09/07}{arithmetic in viewport key fixed}
+% A `viewport' is a user-specified area of the graphic to be included.
+% It should not be confused with the `Bounding Box' of a PS file.
+% In fact, the origin for a viewport specification is the (llx,lly)
+% lower left coordinate of the bounding box. If a viewport is
+% specified, and clipping is turned on, clipping is based on the
+% viewport, not on the boundingbox.
+%
+% Both `viewport' and `trim' were suggested (and originally, but
+% differently, implemented) by Arthur Ogawa.
+% \begin{macrocode}
+\define@key{Gin}{viewport}
+ {\let\Gin@viewport@code\Gin@viewport\Gread@parse@vp#1 \\}
+\define@key{Gin}{trim}
+ {\let\Gin@viewport@code\Gin@trim\Gread@parse@vp#1 \\}
+% \end{macrocode}
+% \end{key}
+% \end{key}
+%
+% \begin{macro}{\Gread@parse@vp}
+% Grabs four bounding box values like |\Gread@parse@bp| but saves them
+% in alternative macros that are used in the viewport and trim cases to
+% modify the bounding box read from the file.
+% \begin{macrocode}
+\def\Gread@parse@vp#1 #2 #3 #4 #5\\{%
+ \Gin@defaultbp\Gin@vllx{#1}%
+ \Gin@defaultbp\Gin@vlly{#2}%
+ \Gin@defaultbp\Gin@vurx{#3}%
+ \Gin@defaultbp\Gin@vury{#4}}%
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\Gin@viewport}
+% \changes{v1.0c}{1996/10/31}{Original bb saved}
+% If a viewport is specified, reset the bounding box coordinates
+% by adding the original origin, |\Gin@llx|, |\Gin@lly| to the new
+% values specified as the viewport. The original Bounding box
+% coordinates are saved in |\Gin@ollx|\ldots\ some drivers
+% might need this information (currently just |tcidvi|).
+% \begin{macrocode}
+\def\Gin@viewport{%
+ \let\Gin@ollx\Gin@llx
+ \let\Gin@olly\Gin@lly
+ \let\Gin@ourx\Gin@urx
+ \let\Gin@oury\Gin@ury
+ \dimen@\Gin@llx\p@\advance\dimen@ \Gin@vurx\p@
+ \edef\Gin@urx{\strip@pt\dimen@}%
+ \dimen@\Gin@lly\p@\advance\dimen@ \Gin@vury\p@
+ \edef\Gin@ury{\strip@pt\dimen@}%
+ \dimen@\Gin@llx\p@\advance\dimen@ \Gin@vllx\p@
+ \edef\Gin@llx{\strip@pt\dimen@}%
+ \dimen@\Gin@lly\p@\advance\dimen@ \Gin@vlly\p@
+ \edef\Gin@lly{\strip@pt\dimen@}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\Gin@trim}
+% \changes{v1.0c}{1996/10/31}{Original bb saved}
+% If a trim is specified, reset the bounding box coordinates
+% by trimming the four specified values off each side of the
+% graphic.
+% \begin{macrocode}
+\def\Gin@trim{%
+ \let\Gin@ollx\Gin@llx
+ \let\Gin@olly\Gin@lly
+ \let\Gin@ourx\Gin@urx
+ \let\Gin@oury\Gin@ury
+ \dimen@\Gin@llx\p@\advance\dimen@ \Gin@vllx\p@
+ \edef\Gin@llx{\strip@pt\dimen@}%
+ \dimen@\Gin@lly\p@\advance\dimen@ \Gin@vlly\p@
+ \edef\Gin@lly{\strip@pt\dimen@}%
+ \dimen@\Gin@urx\p@\advance\dimen@ -\Gin@vurx\p@
+ \edef\Gin@urx{\strip@pt\dimen@}%
+ \dimen@\Gin@ury\p@\advance\dimen@ -\Gin@vury\p@
+ \edef\Gin@ury{\strip@pt\dimen@}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\Gin@vllx}
+% \begin{macro}{\Gin@vlly}
+% \begin{macro}{\Gin@vurx}
+% \begin{macro}{\Gin@vury}
+% Four macros to hold the modifiers for the bounding box for viewport
+% and trim specifications.
+% \begin{macrocode}
+\let\Gin@vllx\Gin@llx\let\Gin@vlly\Gin@llx
+\let\Gin@vurx\Gin@llx\let\Gin@vury\Gin@llx
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \begin{key}{Gin}{angle}
+% Specify a rotation. This is just handled by wrapping the
+% |\includegraphics| command in a call to the internal version of
+% |\rotatebox|. Normally this is the `standard' version but if an
+% |origin| key is used in |\includegraphics| then the \emph{keyval}
+% version of origin is used, and the |origin| key is passed on.
+% \begin{macrocode}
+\define@key{Gin}{angle}
+ {\Gin@esetsize
+ \@tempswatrue
+ \edef\@tempa{\toks@{\noexpand\Gin@erotate{#1}{\the\toks@}}}%
+ \@tempa}
+% \end{macrocode}
+% \end{key}
+%
+% \begin{key}{Gin}{origin}
+% Pass the origin key value on to |\rotatebox|. |\Gin@erotate| is
+% initialised to |\Grot@box@std| later in the file, after the latter has
+% been defined.
+% \changes{v0.6e}{1995/09/28}
+% {key added}
+% \begin{macrocode}
+\define@key{Gin}{origin}[c]{%
+ \def\Gin@erotate{\Grot@box@kv[origin=#1]}}
+% \end{macrocode}
+% \end{key}
+%
+% \begin{key}{Gin}{width}
+% \begin{key}{Gin}{height}
+% Save the required height and width. The actual scaling is done later.
+% \begin{macrocode}
+\define@key{Gin}{width}{\def\Gin@ewidth{#1}}
+\define@key{Gin}{height}{\def\Gin@eheight{#1}}
+% \end{macrocode}
+% \end{key}
+% \end{key}
+%
+% \begin{key}{Gin}{totalheight}
+% \changes{v0.6a}{1995/04/11}{New totalheight key}
+% The same as |height| key, but locally changes |\Gin@eresize| to
+% |\totalheight| from its default value of |\height|.
+% \begin{macrocode}
+\define@key{Gin}{totalheight}{%
+ \def\Gin@eresize{\totalheight}\def\Gin@eheight{#1}}
+% \end{macrocode}
+% \end{key}
+%
+% \begin{key}{Gin}{keepaspectratio}
+% Boolean valued key (like |clip|). If it is set to true,
+% modify the meaning of the |width| and |height| (and |totalheight|)
+% keys such that if both are specified then rather than distort the
+% figure the figure is scaled such that neither dimension \emph{exceeds}
+% the stated dimensions.
+% \changes{v0.6e}{1995/09/28}
+% {key added}
+% \changes{v0.6h}{1995/12/06}
+% {Name changed to keepaspectratio}
+% \begin{macrocode}
+\define@key{Gin}{keepaspectratio}[true]{%
+ \lowercase{\Gin@boolkey{#1}}{iso}}
+% \end{macrocode}
+% \end{key}
+%
+% \begin{key}{Gin}{scale}
+% \changes{v0.6h}{1995/12/06}
+% {Use \cs{Gin@exclamation}}
+% If the scaling is being handled externally, wrap |\includegraphics| in
+% the internal form of |\scalebox|, otherwise locally define
+% |\Gin@req@sizes| to calculate the required sizes based on
+% scale factor.
+% \begin{macrocode}
+\define@key{Gin}{scale}{%
+ \if@tempswa
+ \edef\@tempa{\toks@{\noexpand\Gscale@box{#1}[#1]{\the\toks@}}}%
+ \@tempa
+ \else
+ \def\Gin@req@sizes{%
+ \def\Gin@scalex{#1}\let\Gin@scaley\Gin@exclamation
+ \Gin@req@height\Gin@scalex\Gin@nat@height
+ \Gin@req@width\Gin@scalex\Gin@nat@width}%
+ \fi
+ \@tempswatrue}
+% \end{macrocode}
+% \end{key}
+%
+% \begin{key}{Gin}{draft}
+% Locally set the draft switch to true. This is used by the code in
+% \textsf{graphics} package to suppress the file inclusion.
+% \begin{macrocode}
+\define@key{Gin}{draft}[true]{%
+ \lowercase{\Gin@boolkey{#1}}{draft}}
+% \end{macrocode}
+% \end{key}
+%
+% \begin{key}{Gin}{clip}
+% Locally set the clip switch to true. This is used by the code in
+% \textsf{graphics} package to suppress the printing of anything outside
+% the bounding box specified.
+% \begin{macrocode}
+\define@key{Gin}{clip}[true]{%
+ \lowercase{\Gin@boolkey{#1}}{clip}}
+% \end{macrocode}
+% \end{key}
+%
+% \begin{key}{Gin}{type}
+% If you use `type' you must use no extension in the main argument
+% and you must use `ext'. You can also use `read' and `command'.
+% \changes{v0.5a}{1994/11/29}
+% {remove \cs{Gin@sep}}
+% \begin{macrocode}
+\define@key{Gin}{type}{%
+ \def\Ginclude@graphics##1{%
+ \begingroup
+ \def\Gin@base{##1}%
+ \edef\@tempa{{#1}{\Gin@eread}{\Gin@ecom{##1\Gin@eext}}}%
+ \expandafter\Gin@setfile\@tempa
+ \endgroup}}
+% \end{macrocode}
+% \end{key}
+%
+% \begin{key}{Gin}{ext}
+% \changes{v1.0d}{1997/06/09}{initialise ext to empty}
+% Specify an extension, for use with the `type' key.
+% \begin{macrocode}
+\define@key{Gin}{ext}{\def\Gin@eext{#1}}
+\let\Gin@eext\@empty
+% \end{macrocode}
+% \end{key}
+%
+% \begin{key}{Gin}{read}
+% Specify a read file, for use with the `type' key.
+% You may want to globally set this to |*| using |\setkeys|.
+% |*| means read the graphic file for size info, as in
+% |\DeclareGraphicsRule|.
+% \changes{v0.5a}{1994/11/29}
+% {Add default * possibility.}
+% \begin{macrocode}
+\define@key{Gin}{read}{%
+ \def\Gin@eread{#1}%
+ \def\@tempa{*}\ifx\@tempa\Gin@eread\def\Gin@eread{\Gin@eext}\fi}
+\let\Gin@eread\@empty
+% \end{macrocode}
+% \end{key}
+%
+% \begin{key}{Gin}{command}
+% Specify a command, for use with the `type' key.
+% \begin{macrocode}
+\define@key{Gin}{command}{\def\Gin@ecom##1{#1}}
+\let\Gin@ecom\@firstofone
+% \end{macrocode}
+% \end{key}
+%
+% \begin{key}{Gin}{decodearray}
+% \changes{v1.1b}{2017/06/25}{New decodearray key}
+% For manipulating bitmap images.
+% \begin{macrocode}
+\define@key{Gin}{decodearray}{%
+ \def\Gin@decode{#1}%
+}
+% \end{macrocode}
+% \end{key}
+%
+% \begin{key}{Gin}{quiet}
+% \changes{v1.1a}{2017/06/01}{New quiet key}
+% Skip writing to the log.
+% \begin{macrocode}
+\define@key{Gin}{quiet}{%
+ \let\Gin@log\@gobble
+}
+% \end{macrocode}
+% \end{key}
+%
+% \begin{key}{Gin}{page}
+% \changes{v1.1a}{2017/06/01}{New page key}
+% Page of a multi-page (PDF) graphic.
+% \begin{macrocode}
+\define@key{Gin}{page}{%
+ \def\Gin@page{#1}%
+ \ifx\Gin@page\@empty
+ \else
+ \edef\Gin@page{\number\Gin@page}%
+ \fi
+}
+% \end{macrocode}
+% \end{key}
+%
+% \begin{key}{Gin}{interpolate}
+% \changes{v1.1a}{2017/06/01}{New interpolate key}
+% Enable/disable interpolation of bitmap images by the viewer.
+% \begin{macrocode}
+\define@key{Gin}{interpolate}[true]{%
+ \lowercase{\Gin@boolkey{#1}}{interpolate}}
+% \end{macrocode}
+% \end{key}
+%
+% \begin{key}{Gin}{pagebox}
+% \changes{v1.1a}{2017/06/01}{New pagebox key}
+% Specify which PDF box to use for the natural image size in PDF inclusions.
+% \begin{macrocode}
+\define@key{Gin}{pagebox}{%
+ \expandafter\let\expandafter\Gin@pagebox
+ \csname Gin@pagebox@#1\endcsname
+ \ifx\Gin@pagebox\relax
+ \let\Gin@pagebox\Gin@pagebox@cropbox
+ \@warning{%
+ Unknown value `#1' for `pagebox'.\MessageBreak
+ Supported values:\MessageBreak
+ mediabox, cropbox, bleedbox, trimbox, artbox%
+ }%
+ \fi
+ }
+ \def\Gin@pagebox@mediabox{mediabox}%
+ \def\Gin@pagebox@cropbox{cropbox}%
+ \def\Gin@pagebox@bleedbox{bleedbox}%
+ \def\Gin@pagebox@trimbox{trimbox}%
+ \def\Gin@pagebox@artbox{artbox}%
+% \end{macrocode}
+% \end{key}
+%
+% \begin{macro}{\Gin@boolkey}
+% Helper function for defining boolean valued functions. The order of
+% arguments allows |\lowercase| to only act on the user-supplied
+% argument.
+% \changes{v0.4a}{1994/04/14}{Make `empty'!=true so clip!= works}
+% \begin{macrocode}
+\def\Gin@boolkey#1#2{%
+ \csname Gin@#2\ifx\relax#1\relax true\else#1\fi\endcsname}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\Gin@esetsize}
+% \changes{v0.6h}{1995/12/06}
+% {Use \cs{Gin@exclamation}}
+% Arrange for the final size to be set, either by wrapping the include
+% graphics call in |\scalebox|, or by redefining |\Gin@req@sizes|
+% appropriately.
+% \begin{macrocode}
+\def\Gin@eresize{\height}
+\def\Gin@esetsize{%
+ \let\@tempa\Gin@exclamation
+ \if@tempswa
+% \end{macrocode}
+% External. Wrap the |\includegraphics| command in a call to the
+% internal form of |\scalebox| to handle the rotation.
+% \begin{macrocode}
+ \edef\@tempa{\toks@{\noexpand
+ \Gscale@@box\noexpand\Gin@eresize
+ {\Gin@ewidth}{\Gin@eheight}{\the\toks@}}}%
+ \@tempa
+ \else
+% \end{macrocode}
+% Internal. Handle scaling with the |\includegraphics| command directly
+% rather than calling |\scalebox|.
+% \begin{macrocode}
+ \ifx\Gin@ewidth\@tempa
+ \ifx\Gin@eheight\@tempa
+% \end{macrocode}
+% No resizing.
+% \begin{macrocode}
+ \else
+% \end{macrocode}
+% Just height specified.
+% \changes{v0.6e}{1995/09/28}
+% {Use \cs{setlength} to support calc package}
+% \changes{v0.6h}{1995/12/06}
+% {Use \cs{Gin@exclamation}}
+% \begin{macrocode}
+ \let\Gin@@eheight\Gin@eheight
+ \def\Gin@req@sizes{%
+ \Gscale@div\Gin@scaley\Gin@@eheight\Gin@nat@height
+ \let\Gin@scalex\Gin@exclamation
+ \setlength\Gin@req@height\Gin@@eheight
+ \Gin@req@width\Gin@scaley\Gin@nat@width}%
+ \fi
+ \else
+ \ifx\Gin@eheight\@tempa
+% \end{macrocode}
+% Just width specified.
+% \changes{v0.6e}{1995/09/28}
+% {Use \cs{setlength} to support calc package}
+% \changes{v0.6h}{1995/12/06}
+% {Use \cs{Gin@exclamation}}
+% \begin{macrocode}
+ \let\Gin@@ewidth\Gin@ewidth
+ \def\Gin@req@sizes{%
+ \Gscale@div\Gin@scalex\Gin@@ewidth\Gin@nat@width
+ \let\Gin@scaley\Gin@exclamation
+ \setlength\Gin@req@width\Gin@@ewidth
+ \Gin@req@height\Gin@scalex\Gin@nat@height}%
+ \else
+% \end{macrocode}
+% Both height and width specified.
+% \begin{macrocode}
+ \let\Gin@@ewidth\Gin@ewidth
+ \let\Gin@@eheight\Gin@eheight
+% \end{macrocode}
+% \changes{v0.6g}{1995/11/10}
+% {Use \cs{ifGin@iso} to support isoscale key}
+% At this point can locally redefine |\Gin@nosize|. Instead
+% of generating an error, just set the `natural' size to be the
+% `requested size'. Previous versions of this package did not
+% allow the use of |height| and |width| unless the natural size was
+% known as otherwise \LaTeX\ can not calculate the scale factor.
+% However many drivers (especially for bitmap formats) can work this out
+% themselves, so as long as both |height| and |width| are given, so
+% \LaTeX\ knows the size to leave, accept this. This assumes the code in
+% the driver file will use the `required height' information, not the
+% scale factors, which will be set to 1!.
+% \changes{v1.0a}{1996/08/05}
+% {Missing percent added for graphics/2244}
+% \begin{macrocode}
+ \def\Gin@nosize##1{%
+ \KV@Gin@natwidth\Gin@@ewidth
+ \KV@Gin@natheight\Gin@@eheight}%
+% \end{macrocode}
+%
+% \begin{macrocode}
+ \def\Gin@req@sizes{%
+ \Gscale@div\Gin@scalex\Gin@@ewidth\Gin@nat@width
+ \Gscale@div\Gin@scaley\Gin@@eheight\Gin@nat@height
+% \end{macrocode}
+% \changes{v0.6f}{1995/09/29}
+% {Use \cs{ifGin@iso} to support isoscale key}
+% Donald Arseneau requested this feature. If both |height|
+% and |width| are chosen, choose the smaller scale factor rather than
+% distort the graphic. This mode is turned on with the
+% \textsf{keepaspectratio} key.
+% \begin{macrocode}
+ \ifGin@iso
+ \ifdim\Gin@scaley\p@>\Gin@scalex\p@
+ \let\Gin@scaley\Gin@scalex
+ \else
+ \let\Gin@scalex\Gin@scaley
+ \fi
+ \fi
+ \Gin@req@width\Gin@scalex\Gin@nat@width
+ \Gin@req@height\Gin@scaley\Gin@nat@height}%
+ \fi
+ \fi
+ \fi
+ \let\Gin@ewidth\Gin@exclamation
+ \let\Gin@eheight\Gin@ewidth}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\Gin@req@height}
+% \begin{macro}{\Gin@req@width}
+% The required final size.
+% \begin{macrocode}
+\newdimen\Gin@req@height
+\newdimen\Gin@req@width
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\Gin@outer@scalex}
+% \begin{macro}{\Gin@outer@scaley}
+% Scale factors to pass to |\scalebox|.
+% \begin{macrocode}
+\let\Gin@outer@scalex\relax
+\let\Gin@outer@scaley\relax
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\Gin@angle}
+% Rotation angle.
+% \begin{macrocode}
+\let\Gin@angle\relax
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\Gin@ewidth}
+% \changes{v0.6h}{1995/12/06}
+% {Use \cs{Gin@exclamation}}
+% \begin{macro}{\Gin@eheight}
+% Final size, initialised for no scaling.
+% \begin{macrocode}
+\let\Gin@ewidth\Gin@exclamation
+\let\Gin@eheight\Gin@ewidth
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\Gin@scalex}
+% \begin{macro}{\Gin@scaley}
+% \changes{v0.6h}{1995/12/06}
+% {Use \cs{Gin@exclamation}}
+% Scale factors. Initialised for no scaling.
+% \begin{macrocode}
+\def\Gin@scalex{1}
+\let\Gin@scaley\Gin@exclamation
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\Gin@i}
+% Use the same top level |\includegraphics| command as the standard
+% interface. This will set the clipping switch, and then call |\Gin@i|.
+% \changes{v0.3c}{1994/03/15}{Dont locally initialise width/height}
+% \changes{v0.3c}{1994/03/15}{Always call \cmd{\Gin@ii}}
+% \changes{v0.4c}{1994/09/12}{Use `standard' version if two opt.\ args.}
+% \begin{macrocode}
+\def\Gin@i{%
+ \def\Gin@req@sizes{%
+ \Gin@req@height\Gin@nat@height
+ \Gin@req@width\Gin@nat@width}%
+ \@ifnextchar[\Gin@ii{\Gin@ii[]}}
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\Gin@ii}
+% Look for a second optional argument.
+% If one optional argument is present, call |\setkeys| to process it,
+% \begin{macrocode}
+\def\Gin@ii[#1]#2{%
+ \def\@tempa{[}\def\@tempb{#2}%
+ \ifx\@tempa\@tempb
+ \def\@tempa{\Gin@iii[#1][}%
+ \expandafter\@tempa
+ \else
+ \begingroup
+ \@tempswafalse
+ \toks@{\Ginclude@graphics{#2}}%
+ \setkeys{Gin}{#1}%
+ \Gin@esetsize
+ \the\toks@
+ \endgroup
+ \fi}
+% \end{macrocode}
+% \end{macro}
+%
+% \changes{v0.4b}{1994/05/06}
+% {Remove incorrect initialisation of \cs{Gin@scalex}}
+%
+% \section{Rotation}
+%
+% \begin{macro}{\rotatebox}
+% Look for an optional argument.
+% \changes{v0.3b}{1994/03/11}{Remove star form}
+% \changes{v1.0g}{2014/04/25}{\cs{leavevmode} added graphics/1521}
+% \begin{macrocode}
+\def\rotatebox{%
+ \leavevmode
+ \@ifnextchar[\Grot@box@kv\Grot@box@std}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\Grot@box@std}
+% If no KV argument, just repeat the standard definition.
+% \changes{v1.0g}{2014/04/25}{Made long graphics/4296}
+% \begin{macrocode}
+\long\def\Grot@box@std#1#2{%
+ \Grot@setangle{#1}%
+ \setbox\z@\hbox{{#2}}%
+ \Grot@x\z@
+ \Grot@y\z@
+ \Grot@box}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\Grot@box@kv}
+% \changes{v1.0g}{2014/04/25}{Made long graphics/4296}
+% \begin{macrocode}
+\long\def\Grot@box@kv[#1]#2#3{%
+ \@begin@tempboxa\hbox{#3}%
+ \Grot@x\width \divide\Grot@x\tw@
+ \Grot@y\height \advance\Grot@y-\depth \divide\Grot@y\tw@
+ \setkeys{Grot}{#1}%
+ \setbox\z@\box\@tempboxa
+ \Grot@setangle{#2}%
+ \Grot@box
+ \@end@tempboxa}
+% \end{macrocode}
+% \end{macro}
+%
+%
+% There are two ways of specifying the centre of rotation.
+%
+% \begin{key}{Grot}{origin}
+% |origin=|\meta{label}, where the labels are up to two of |lrctbB|
+% (|B| denotes the baseline, as for PSTricks).
+% \begin{macrocode}
+\define@key{Grot}{origin}[c]{%
+ \@tfor\@tempa:=#1\do{%
+ \if l\@tempa \Grot@x\z@\else
+ \if r\@tempa \Grot@x\width\else
+ \if t\@tempa \Grot@y\height\else
+ \if b\@tempa \Grot@y-\depth\else
+ \if B\@tempa \Grot@y\z@\fi\fi\fi\fi\fi}}
+% \end{macrocode}
+% \end{key}
+%
+% \begin{key}{Grot}{x}
+% \begin{key}{Grot}{y}
+% |x=|\meta{dimen}|,y=|\meta{dimen} The $x,y$ coordinate of the centre
+% of rotation. As usual |\height| etc may be used.
+% \begin{macrocode}
+\define@key{Grot}{x}{\setlength\Grot@x{#1}}
+\define@key{Grot}{y}{\setlength\Grot@y{#1}}
+% \end{macrocode}
+% \end{key}
+% \end{key}
+%
+% \begin{key}{Grot}{units}
+% `units' specifies the number or units in one anti-clockwise circle.
+% So the default is $360$. $-360$ gives clockwise rotation, $6.283185$
+% gives radians etc.
+% \begin{macrocode}
+\define@key{Grot}{units}{%
+ \def\Grot@setangle##1{%
+ \dimen@##1\p@
+ \dimen@ii#1\p@
+ \divide\dimen@ii360\relax
+ \divide\dimen@\dimen@ii
+ \edef\Grot@angle{\number\dimen@}}}
+% \end{macrocode}
+% \end{key}
+%
+% \begin{macro}{\Gin@erotate}
+% Initialise the rotation command to use in |\includegraphics|.
+% \changes{v0.6e}{1995/09/28}{macro added}
+% \begin{macrocode}
+\let\Gin@erotate\Grot@box@std
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macrocode}
+%</package>
+% \end{macrocode}
+%
+% \Finale
+%
diff --git a/macros/latex/required/graphics/graphicx.pdf b/macros/latex/required/graphics/graphicx.pdf
new file mode 100644
index 0000000000..f957612356
--- /dev/null
+++ b/macros/latex/required/graphics/graphicx.pdf
Binary files differ
diff --git a/macros/latex/required/graphics/grfguide.pdf b/macros/latex/required/graphics/grfguide.pdf
new file mode 100644
index 0000000000..c7e94d774b
--- /dev/null
+++ b/macros/latex/required/graphics/grfguide.pdf
Binary files differ
diff --git a/macros/latex/required/graphics/grfguide.tex b/macros/latex/required/graphics/grfguide.tex
new file mode 100644
index 0000000000..b00a86d307
--- /dev/null
+++ b/macros/latex/required/graphics/grfguide.tex
@@ -0,0 +1,1031 @@
+%% grfguide.tex Copyright (C) 1994 1995 1996 1998 1999 David Carlisle
+%% Copyright (C) 2005 2014 2016 2017 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
+%% License, as described in lppl.txt in the base LaTeX distribution.
+%% Either version 1.3c or, at your option, any later version.
+%%
+%% This file has the LPPL maintenance status "maintained".
+
+\begin{filecontents*}{a.ps}
+%!
+%%BoundingBox:0 0 72 72
+0 0 moveto
+72 72 rlineto
+72 neg 0 rlineto
+72 72 neg rlineto
+stroke
+0 0 moveto
+/Times-Roman findfont
+72 scalefont
+setfont
+(A) show
+showpage
+\end{filecontents*}
+\begin{filecontents*}{a.pdf}
+%PDF-1.4
+%%%%%
+1 0 obj
+<<
+/Pages 2 0 R
+/Type /Catalog
+>>
+ endobj
+2 0 obj
+<<
+/Kids [3 0 R]
+/Type /Pages
+/Count 1
+>>
+ endobj
+3 0 obj
+<<
+/Rotate 0
+/Parent 2 0 R
+/MediaBox [0 0 72 72]
+ /Resources
+<<
+/ExtGState 4 0 R
+/Font 5 0 R
+/ProcSet [/PDF /Text]
+>>
+/pdftk_PageNum 1
+/Type /Page
+/Contents 6 0 R
+>>
+ endobj
+4 0 obj
+<<
+/R7 7 0 R
+>>
+ endobj
+5 0 obj
+<<
+/R8 8 0 R
+>>
+ endobj
+6 0 obj
+<<
+/Length 135
+>>
+stream
+q 0.1 0 0 0.1 0 0 cm
+/R7 gs
+10 w
+0 G
+0 0 m
+720 720 l
+0 720 l
+720 0 l
+S
+0 g
+q
+10 0 0 10 0 0 cm BT
+/R8 72 Tf
+1 0 0 1 0 0 Tm
+(A)Tj
+ET
+Q
+Q
+
+ endstream
+ endobj
+7 0 obj
+<<
+/Type /ExtGState
+/OPM 1
+>>
+ endobj
+8 0 obj
+<<
+/BaseFont /Times-Roman
+/LastChar 65
+/Subtype /Type1
+/FontDescriptor 9 0 R
+/Widths [722]
+/Type /Font
+/Encoding /WinAnsiEncoding
+/FirstChar 65
+>>
+ endobj
+9 0 obj
+<<
+/FontName /Times-Roman
+/StemV 105
+/CharSet (/A)
+/Ascent 674
+/Flags 65568
+/Descent 0
+/ItalicAngle 0
+/MissingWidth 250
+/FontBBox [0 0 706 674]
+/Type /FontDescriptor
+/CapHeight 674
+>>
+ endobj
+10 0 obj
+<<
+/Producer (GPL Ghostscript 9.06)
+/ModDate (D:20140426202438+01'00')
+/CreationDate (D:20140426202438+01'00')
+>>
+endobj xref
+0 11
+0000000000 65535 f
+0000000015 00000 n
+0000000066 00000 n
+0000000125 00000 n
+0000000308 00000 n
+0000000341 00000 n
+0000000374 00000 n
+0000000563 00000 n
+0000000610 00000 n
+0000000774 00000 n
+0000000975 00000 n
+trailer
+
+<<
+/Info 10 0 R
+/Root 1 0 R
+/Size 11
+/ID [<4ca1370d594acd28b9d948a5e8b925c3> <4ca1370d594acd28b9d948a5e8b925c3>]
+>>
+startxref
+1106
+%%EOF
+\end{filecontents*}
+\documentclass{ltxguide}
+
+%%% No driver option specified
+%%% set up the files color.cfg and graphics.cfg for your site.
+%%% for example:
+%%%
+%%% \ExecuteOptions{dvips}
+%%%
+\usepackage{color,graphicx,shortvrb}
+
+%% Just as an example, and to make sure, in case some
+%% driver option has not declared a default rule for
+%% .ps files:
+%\DeclareGraphicsRule{.ps}{eps}{.ps}{}
+%\DeclareGraphicsExtensions{.pdf,.ps}
+%% Which means:
+%% .ps files are (to be treated as) EncapsulatedPostScript
+%% files. The .ps file is to be read for the BoundingBox.
+%% No `special' commands need to be applied by the driver.
+
+
+\renewcommand\star{{\ttfamily*}}
+
+\let\package\textsf
+
+\newlength{\gxlen}
+\settowidth{\gxlen}{\package{graphicx}: }
+\newcommand\gs{\makebox[\gxlen][l]{\package{graphics}:}}
+\newcommand\gx{\makebox[\gxlen][l]{\package{graphicx}:}}
+
+\MakeShortVerb{\|}
+
+\begin{document}
+\title{Packages in the `graphics' bundle}
+\author{D. P. Carlisle \and The \LaTeX3 Project}
+\date{2017-06-01}
+
+\maketitle
+
+\tableofcontents
+
+\section{Introduction}
+This document serves as a user-manual for the packages \package{color},
+\package{graphics}, and \package{graphicx}. Further documentation may be
+obtained by processing the source (|dtx|) files of the individual
+packages.
+
+\section{Driver support}\label{drivers}
+All these packages rely on features that are not in \TeX\ itself.
+These features must be supplied by the `driver' used to print the
+|dvi| file. Unfortunately not all drivers support the same features, and
+even the internal method of accessing these extensions varies between
+drivers. Consequently all these packages take options such as
+`|dvips|' to specify which driver is being used.
+
+Normally you should \emph{not} specify the driver option explicitly
+in the document, but allow it to be defaulted automatically.
+This allows the document to be portable between different systems.
+
+Your \TeX\ distribution should have included |graphics.cfg| and
+|color.cfg| configuration files to specify these defaults.
+Standard versions of the configuration files are maintained by the
+\LaTeX\ Project and distributed in the CTAN |graphics-cfg| collection.
+
+For special requirements you may edit a copy of these |cfg| files
+to set up a site default for these options. Suppose that you wish
+the \package{color} package to always default to use specials for the
+PostScript driver, |dvisvgm|. In that case, create a file |color.cfg|
+containing the line:\\
+|\ExecuteOptions{dvisvgm}|\\
+Normally you will want an identical file |graphics.cfg| to set a similar
+default for the graphics packages.
+
+The following driver options are declared in the packages.
+The matching definition files (\emph{driver}|.def|)
+are now also maintained by the \LaTeX\ project,
+but distributed separately, in the CTAN |graphics-def| collection.
+\begin{quote}\raggedright
+ |dvipdfmx|, |dvips|, |dvisvgm|, |luatex|, |pdftex|, |xetex|
+\end{quote}
+
+
+The following two options are also supported, they do not correspond
+to separate definition files, but are essentially aliases for the
+|dvips| option (and |monochrome| in the case of |xdvi|).
+\begin{quote}\raggedright
+ |xdvi|, |oztex|
+\end{quote}
+
+The following set of options are supported by these packages
+with associated driver files extracted from the |drivers.dtx|
+documented source in this bundle. These are now, mainly of historic
+interest but the documented sources do contain some useful code
+and advice if you need to produce a new definition file for a new
+driver or \TeX\ system. |drivers.dtx| also contains documented
+sources for older driver files that are no longer extracted.
+\begin{quote}\raggedright
+ |dvipdf|, |dvipdfm|, |dviwin|, |dvipsone|,
+ |emtex|, |pctexps|, |pctexwin|, |pctexhp|, |pctex32|,
+ |truetex|, |tcidvi|, |vtex|
+\end{quote}
+
+The final driver option is an alias for |dvipsone|.
+\begin{quote}\raggedright
+ |dviwindo|
+\end{quote}
+
+
+\section[Colour]{Colour\footnote{%
+The basic \package{color} package functionality described here
+will be enough for many uses, however a much extended version
+is available in the contributed \package{xcolor} package, distributed
+and maintained separately. All the color commands described here are
+also available if you specify \package{xcolor} in your document.}%
+}
+The colour support is built around the idea of a system of
+\emph{Colour Models}. The Colour models supported by a driver vary,
+but typically include
+\begin{description}
+\item[rgb] Red Green Blue: A comma separated list of three numbers
+ between~0 and~1, giving the components of the colour.
+\item[cmyk] Cyan Magenta Yellow [K]Black: A comma separated list of
+ four numbers between~0 and~1, giving the components of the colour
+ according to the additive model used in most printers.
+\item[gray] Grey scale: a single number between~0 and~1.
+\item[named] Colours accessed by name, e.g.\ `JungleGreen'. Not all
+ drivers support this model. The names must either be `known' to the
+ driver or added using commands described in |color.dtx|. Some drivers
+ support an extended form of the named model in which an `intensity' of
+ the colour may also be specified, so `\mbox{JungleGreen, 0.5}' would
+ denote that colour at half strength.
+\end{description}
+Note that the \textbf{named} model is really just given as an example
+of a colour model that takes names rather than a numeric specification.
+Other options may be provided locally that provide different colour
+models, eg \textbf{pantone} (An industry standard set of colours),
+\textbf{x11} (Colour names from the X Window System), etc. The
+standard distribution does not currently have such models, but the
+\textbf{named} model could be used as an example of how to define a new
+colour model. The names used in the \textbf{named} model are those
+suggested by Jim Hafner in his \textsf{colordvi} and \textsf{foiltex}
+packages, and implemented originally in the |color.pro| header file for
+the \texttt{dvips} driver.
+
+\subsection{Package Options}
+Most of the options to the \package{color} package just specify a
+driver, e.g., \ |dvips|, as discussed in section~\ref{drivers}.
+
+One special option for the \package{color} package
+that is of interest is |monochrome.|
+If this option is selected the colour commands are all
+disabled so that they do not generate errors, but do not generate colour
+either. This is useful if previewing with a previewer that can not
+produce colour.
+
+Three other package options control the use of the \textbf{named} model.
+The |dvips| driver (by default) pre-defines 68 colour names. The |dvips|
+option normally makes these names available in the \textbf{named} colour
+model. If you do not want these names to be declared in this model
+(Saving \TeX\ some memory) you may give the |nodvipsnames|
+option. Conversely, if you are using another driver, you may wish to
+add these names to the named model for that driver (especially if you
+are processing a document originally produced on |dvips|). In this case
+you could use the |dvipsnames| option. Lastly the |usenames| option
+makes all names in the \textbf{named} model directly available, as
+described below.
+
+\subsection{Defining Colours}
+
+The colours |black|, |white|, |red|, |green|, |blue|, |cyan|,
+|magenta|, |yellow| should be predefined, but should you wish to mix
+your own colours use the |\definecolor| command.
+
+\begin{decl}
+|\definecolor|\arg{name}\arg{model}\arg{colour specification}
+\end{decl}
+
+
+This defines \m{name} as a colour which can be used in later colour
+commands. For example
+\begin{verbatim}
+\definecolor{light-blue}{rgb}{0.8,0.85,1}
+\definecolor{mygrey}{gray}{0.75}
+\end{verbatim}
+\definecolor{light-blue}{rgb}{0.8,0.85,1}
+\definecolor{mygrey}{gray}{0.75}
+
+Now |light-blue| and |mygrey| may be used in addition to the
+predefined colours above.
+
+\subsection{Using Colours}
+
+\subsubsection{Using predefined colours}
+The syntax for colour changes is designed to mimic font changes.
+The basic syntax is:
+
+\begin{decl}
+|\color|\arg{name}
+\end{decl}
+
+This is a \emph{declaration}, like |\bfseries| It changes the current
+colour to \m{name} until the end of the current group or
+environment.
+
+An alternative command syntax is to use a \emph{command} form that
+takes the text to be coloured as an \emph{argument}. This is similar
+to the font commands such as |\textbf|:
+
+\begin{decl}
+|\textcolor|\arg{name}\arg{text}
+\end{decl}
+
+
+So the above is essentially equivalent to
+|{\color|\arg{name}\emph{text}|}|.
+
+\subsubsection{Using colour specifications directly}
+
+
+\begin{decl}
+|\color|\oarg{model}\arg{specification}\\
+|\textcolor|\oarg{model}\arg{specification}\arg{text}
+\end{decl}
+
+Normally one would predeclare all the colours used in a package, or in
+the document preamble, but sometimes it is convenient to directly use
+a colour without naming it first. To achieve this |\color| (and all
+the other colour commands) take an optional argument specifying the
+model. If this is used then the mandatory argument takes a
+\m{colour specification} instead of a \m{name}. For example:\\
+|\color[rgb]{1,0.2,0.3}|\\
+would directly select that colour.
+
+This is particularly useful for accessing the \textbf{named} model:\\
+|\color[named]{BrickRed}| selects the |dvips| colour BrickRed.
+
+Rather than repeatedly use |[named]| you may use |\definecolor| to
+provide convenient aliases:\\
+|\definecolor{myred}{named}{WildStrawberry}|
+ \ldots\ |\color{myred}|\ \ldots
+
+Alternatively if you are happy to use the existing names from the
+\textbf{named} model, you may use the |usenames| package option, which
+effectively calls |\definecolor| on every colour in the \textbf{named}
+model, thus allowing |\color{WildStrawberry}| in addition to
+|\color[named]{WildStrawbery}|.
+
+\subsection{Named Colours}
+Using the \textbf{named} colour model has certain advantages over
+using other colour models.
+
+Firstly as the |dvi| file contains a request
+for a colour by \emph{name}, the actual mix of primary colours used to
+obtain the requested colour can be tuned to the characteristics of a
+particular printer. In the |dvips| driver the meanings of the colour
+names are defined in the header file |color.pro|. Users are encouraged
+to produce different versions of this file for any printers they use. By
+this means the same dvi file should produce colours of similar
+appearance when printed on printers with different colour
+characteristics.
+
+Secondly, apart from the so called `process colours' that are produced
+by mixing primary colours during the print process, one may want to use
+`spot' or `custom' colours. Here a particular colour name does not
+refer to a mix of primaries, but to a particular ink. The parts of the
+document using this colour will be printed separately using this named
+ink colour.
+
+\subsection{Page Colour}
+
+
+\begin{decl}
+|\pagecolor|\arg{name}\\
+|\pagecolor|\oarg{model}\arg{specification}\\
+|\nopagecolor|
+\end{decl}
+
+The background colour of the whole page can be set using
+|\pagecolor|. This takes the same argument forms as |\color| but sets
+the background colour for the current and all subsequent pages. It is
+a global declaration, so you need to use
+|\nopagecolor|\NEWfeature{2014/04/23}\ to `get back to normal'.
+If that is not supported, you may use |\pagecolor{white}| although that
+will make a white background rather than the default transparent background.
+
+\subsection{Box Backgrounds}
+Two commands similar to |\fbox| produce boxes with the backgrounds
+shaded an appropriate colour.
+
+\begin{decl}
+|\colorbox|\arg{name}\arg{text}\\
+|\colorbox|\oarg{model}\arg{specification}\arg{text}\\
+|\fcolorbox|\arg{name1}\arg{name2}\arg{text}\\
+|\fcolorbox|\oarg{model}%
+ \arg{specification1}\arg{specification2}\arg{text}
+\end{decl}
+
+
+The former produces a box coloured with \emph{name}
+\colorbox{mygrey}{like this}. The latter is similar but puts a frame of
+colour \emph{name1} around the box coloured \emph{name2}.
+
+These commands use the |\fbox| parameters |\fboxrule| and |\fboxsep|
+to determine the thickness of the rule, and the size of the shaded area.
+
+\subsection{Possible Problems}
+
+\TeX\ was not designed with colour in mind, and producing colours
+requires a lot of help from the driver program. Thus, depending on the
+driver, some or all features of the \package{color} package may not be
+available.
+
+Some drivers do not maintain a special `colour stack'. These drivers are
+likely to get confused if you nest colour changes, or use colours in
+floating environments.
+
+Some drivers do not maintain colours over a page break, so that if the
+page breaks in the middle of a coloured paragraph, the last part of the
+text will incorrectly be printed in black.
+
+There is a different type of problem that will occur for all drivers.
+Due to certain technical difficulties\footnote{At least two causes:
+1) The presence of a \texttt{\char`\\special} \m{whatsit} prevents
+\texttt{\char`\\addvspace} `seeing' space on the current vertical list,
+so causing it to incorrectly add extra vertical space. 2) A
+\m{whatsit} as the first item in a \texttt{\char`\\vtop} moves the
+reference point of the box.}%
+, it is possible that at points
+where the colour changes, the \emph{spacing} is affected. For this
+reason the |monochrome| option does not completely disable the colour
+commands, it redefines them to write to the log file. This will have the
+same effects on spacing, so you can produce monochrome drafts of your
+document, at least knowing that the final spacing is being shown.
+\section{The Graphics packages}
+There are two graphics packages:
+\begin{description}
+\item[\package{graphics}] The `standard' graphics package.
+\item[\package{graphicx}] The `extended' or `enhanced' graphics
+ package.
+\end{description}
+The two differ only in the format of optional arguments for the
+commands defined. The command names, and the mandatory arguments are
+the same for the two packages.
+
+\subsection{Package Options}
+As discussed in section~\ref{drivers}, the graphics packages share the
+same `driver' options as the \package{color} package. As for colour
+you should set up a site-default in a file,
+|graphics.cfg|, containing the line (for |dvips|):\\
+|\ExecuteOptions{dvips}|
+
+The graphics packages have some other options for controlling how many
+of the features to enable:
+\begin{description}
+\item[draft] suppress all the `special' features. In particular
+ graphics files are not included (but they are still read for size
+ info) just the filename is printed in a box of the correct size.
+\item[final] The opposite of |draft|. Useful to over-ride a global
+ |draft| option specified in the |\documentclass| command.
+\item[hiderotate] Do not show rotated text (presumably because the
+ previewer can not rotate).
+\item[hidescale] Do not show scaled text (presumably because the
+ previewer can not scale).
+\item[hiresbb] Look for size specifications in |%%HiResBoundingBox|
+ lines rather than standard |%%BoundingBox| lines.%
+ \NEWfeature{1996/10/29}
+\item[demo] Instead of inserting an image file |\includegraphics|
+ draws a 150\,pt by 100\,pt rectangle unless other dimensions are
+ specified manually.\NEWfeature{2006/02/20}
+\end{description}
+\subsection{Rotation}
+
+\begin{decl}
+\gs |\rotatebox|\arg{angle}\arg{text}\\
+\gx |\rotatebox|\oarg{key val list}\arg{angle}\arg{text}
+\end{decl}
+
+This puts \emph{text} in a box, like |\mbox|, but rotates the box
+through \emph{angle} degrees, \rotatebox{15}{like this}.
+
+The standard version always rotates around the reference point of the
+box, but the \package{keyval} version takes the following keys:
+
+\begin{decl}
+|origin|=\m{label}\\
+|x|=\m{dimen}\\
+|y|=\m{dimen}\\
+|units|=\m{number}
+\end{decl}
+
+So you may specify both |x| and |y|, which give the coordinate of
+the centre of rotation relative to the reference point of the box, eg
+|[x=2mm, y=5mm]|. Alternatively, for the most common points, one may use
+|origin| with a \emph{label} containing one or two of the following:
+|lrctbB| (|B| denotes the baseline, as for \package{PSTricks}). For
+example, compare a default rotation of $180^\circ$
+\ldots\rotatebox{180}{Like This}\ldots\ to the effects gained by using
+the |origin| key:\\
+|[origin = c]| rotates about the centre of the box,\ldots
+ \rotatebox[origin=c]{180}{Like This}\ldots\\
+|[origin = tr]| rotates about the top right hand corner\ldots
+ \rotatebox[origin=tr]{180}{Like This}\ldots
+
+The |units| key allows a change from the default units of degrees
+anti-clockwise. Give the number of units in one full anti-clockwise
+rotation. For example:\\
+|[units = -360]| specifies degrees clockwise.\\
+|[units= 6.283185]| specifies radians.
+
+\subsection{Scaling}
+
+\subsubsection{Scaling by scale factor}
+
+\begin{decl}
+|\scalebox|\arg{h-scale}\oarg{v-scale}\arg{text}
+\end{decl}
+
+Again this is basically like |\mbox| but scales the \emph{text}.
+If \emph{v-scale} is not specified it defaults to \emph{h-scale}.
+If it is specified the text is distorted as the horizontal and
+vertical stretches are different, \scalebox{3}[.7]{Like This}.
+
+
+\begin{decl}
+|\reflectbox|\arg{text}
+\end{decl}
+
+An abbreviation for |\scalebox{-1}[1]|\arg{text}.
+
+\subsubsection{Scaling to a requested size}
+
+\begin{decl}
+|\resizebox|\star\arg{h-length}\arg{v-length}\arg{text}
+\end{decl}
+
+ Scale \emph{text} so that the width is \emph{h-length}.
+ If |!| is used as either length argument, the other argument is used
+ to determine a scale factor that is used in both directions.
+ Normally \emph{v-length} refers to the height of the box, but in the
+ star form, it refers to the `height + depth'.
+ As normal for \LaTeXe\ box length arguments, |\height|,
+ |\width|, |\totalheight|, |\depth| may be used to refer to the
+ original size of the box.
+
+|\resizebox{1in}{\height}{Some text}|:
+\resizebox{1in}{\height}{Some text}
+
+|\resizebox{1in}{!}{Some text}|:
+\resizebox{1in}{!}{Some text}
+
+\subsection{Including Graphics Files}
+The functions for graphics inclusion try to give the same user syntax
+for including any kind of graphics file that can be understood by the
+driver. This relies on the file having an extension that identifies
+the file type. The `driver options' will define a collection of file
+extensions that the driver can handle, although this list may be
+extended using the declarations described below.
+
+If the file's extension is unknown to the driver, the system may try a
+default file type. The PostScript driver files set this default to be
+|eps| (PostScript), but this behaviour may be customised if other
+defaults are required.
+
+\begin{decl}
+\gs |\includegraphics|\star\oarg{llx,lly}\oarg{urx,ury}\arg{file}\\
+\gx |\includegraphics|\star\oarg{key val list}\arg{file}
+\end{decl}
+ Include a graphics file.
+
+ If \star\ is present, then the graphic is `clipped' to the size
+ specified. If \star\ is omitted, then any part of the graphic that is
+ outside the specified `bounding box' will over-print the surrounding
+ text.
+
+ If the optional arguments are omitted, then the size of the graphic
+ will be determined by reading an external file as described below.
+
+\paragraph{\package{graphics} version}
+ If \oarg{urx,ury} is present, then it should specify the coordinates
+ of the top right corner of the image, as a pair of \TeX\ dimensions.
+ If the units are omitted they default to |bp|. So |[1in,1in]| and
+ |[72,72]| are equivalent. If only one optional argument appears, the
+ lower left corner of the image is assumed to be at |[0,0]|. Otherwise
+ \oarg{llx,lly} may be used to specify the coordinates of this point.
+
+\paragraph{\package{graphicx} version}
+Here the star form is just for compatibility with the standard
+version. It just adds |clip| to the list of keys specified.
+(Also, for increased compatibility, if \emph{two} optional arguments are
+used, the `standard' version of |\includegraphics| is always used, even
+if the \package{graphicx} package is loaded.)
+
+The allowed keys are listed below.
+\begin{description}
+\item[bb] The argument should be four dimensions, separated by spaces.
+ These denote the `Bounding Box' of the printed region within
+ the file.
+\item[bbllx,bblly,bburx,bbury] Set the bounding box. Mainly for
+ compatibility with older packages.
+ Specifying |bbllx=a,bblly=b,bburx=c,bbury=d|
+ is equivalent to specifying |bb = a b c d|.
+\item[natwidth,natheight] Again an alternative to |bb|.
+ |natheight=h,natwidth=w| is equivalent to |bb = 0 0 h w|.
+\item[hiresbb]\NEWfeature{1996/10/29}
+ Boolean valued key. If set to |true| (just specifying |hiresbb|
+ is equivalent to |hiresbb=true|) then \TeX\ will look for
+ |%%HiResBoundingBox| lines rather than |%%BoundingBox|. It may be set
+ to |false| to overrule a default setting of |true| set by the
+ |hiresbb| package option.
+\item[pagebox]\NEWfeature{2017/06/01}
+PDF files do not have BoundingBox but may specify up to four predefined
+rectangles.
+
+|MediaBox|: the boundaries of the physical medium.
+|CropBox|: the region to which the contents of the page are to be
+ clipped when displayed.
+|BleedBox|: the region to which the contents of the
+ page should be clipped in production.
+|TrimBox|: the intended dimensions of the finished page.
+|ArtBox|: the extent of the page's meaningful content.
+
+The driver will set the image size based on |CropBox| if present,
+otherwise it will not use one of the others,
+with a driver-defined order of preference.
+|MediaBox| is always present.
+
+The |pagebox| key may be used to specify which bounding box specification to use,
+The value should be one of
+|mediabox|, |cropbox|, |bleedbox|, |trimbox|, |artbox|.
+\item[viewport]\NEWfeature{1995/06/01}
+ The |viewport| key takes four arguments, just like
+ |bb|. However in this case the values are taken relative to the
+ origin specified by the bounding box in the file. So to `view' the
+ 1in square in the bottom left hand corner of the area specified by
+ the bounding box, use the argument |viewport=0 0 72 72|.
+\item[trim]\NEWfeature{1995/06/01}
+ Similar to viewport, but here the four lengths specify the
+ amount to remove or add to each side. |trim= 1 2 3 4| `crops' the
+ picture by 1bp at the left, 2bp at the bottom, 3bp on the right and
+ 4bp at the top.
+\item[angle] Rotation angle.
+\item[origin]\NEWfeature{1995/09/28}
+ Origin for rotation. See the documentation of |\rotatebox|.
+\item[width] Required width. The
+ graphic is scaled to this width.
+\item[height] Required height. The
+ graphic is scaled to this height.
+\item[totalheight]\NEWfeature{1995/06/01}
+ Specify the total height (height $+$ depth) of the figure.
+ This will differ from the `height' if rotation has occurred.
+ In particular if the figure has been rotated by $-90^\circ$
+ then it will have zero height but large depth.
+\item[keepaspectratio]\NEWfeature{1995/09/27}
+ Boolean valued key like `clip'.
+ If set to true then specifying both `width' and `height' (or
+ `totalheight') does not distort the figure but scales such that
+ neither of the specified dimensions is \emph{exceeded}.
+\item[scale] Scale factor.
+\item[clip] Either `true' or `false' (or no value, which is equivalent
+ to `true'). Clip the graphic to the bounding box.
+\item[draft] a boolean valued key, like `clip'. Locally switches to
+ draft mode.
+\item[type] Specify the graphics type.
+\item[ext] Specify the file extension. This should \emph{only} be
+ used in conjunction with |type|.
+\item[read] Specify the file extension of the `read file'. This
+ should \emph{only} be used in conjunction with |type|.
+\item[command] Specify any command to be applied to the file. This
+ should \emph{only} be used in conjunction with |type|.
+\item[quiet]\NEWfeature{2017/06/01}
+ Skip writing information to the log.
+\item[page]\NEWfeature{2017/06/01}
+Page of a multi-page PDF file. (by default the first page will be used.)
+\item[interpolate]\NEWfeature{2017/06/01}
+Enable/disable interpolation of bitmap images by the viewer.
+\end{description}
+
+For the keys specifying the original size (i.e,, the bounding box,
+trim and viewport keys) the units can be omitted, in
+which case bp (i.e., PostScript points) are assumed.
+
+The first seven keys specify the original size of the image. This size
+needs to be specified in the case that the file can not be read by
+\TeX, or it contains an incorrect size `BoundingBox' specification.
+
+|bbllx|\ldots\ |\bbury| are mainly for compatibility for older
+packages.\\
+|bbllx=a, bblly=b, bburx=c, bbury=d|\\
+is equivalent to\\
+|bb = a b c d|.
+
+|natheight| and |natwidth| are just shorthands for setting the lower
+left coordinate to 0 0 and the upper right coordinate to the specified
+width and height.
+
+The next few keys specify any scaling or rotation to be applied to the
+image. To get these effects using the standard package, the
+|\includegraphics| call must be placed inside the argument of a
+|\rotatebox| or |\scalebox| command.
+
+The keys are read left-to-right, so |[angle=90, height=1in]| means
+rotate by 90 degrees, and then scale to a height of 1in.
+|[height=1in, angle=90]| would result in a final \emph{width} of 1in.
+
+If the \textsf{calc} package is also loaded the lengths may use
+\textsf{calc} syntax, for instance to specify a width of 2\,cm
+less than the text width: |[width=\textwidth-2cm]|.
+
+\TeX\ leaves the space specified either in the file, or in
+the optional arguments. If any part of the image is actually outside
+this area, it will by default overprint the surrounding text.
+If the star form is used, or |clip| specified, any part of the image
+outside this area will not be printed.
+
+The last four keys suppress the parsing of the filename. If they are
+used, the main \emph{file} argument should not have the file
+extension. They correspond to the arguments of |\DeclareGraphicsRule|
+described below.
+
+To see the effect that the various options have consider the file
+|a.ps|. This file contains the bounding box specification
+\begin{verbatim}
+%%BoundingBox:0 0 72 72
+\end{verbatim}
+That is, the printed region consists of a one-inch square, in
+the bottom left hand corner of the paper.
+
+In all the following examples the input will be of the form
+\begin{verbatim}
+left---\fbox{\includegraphics{a}}---right
+\end{verbatim}
+With different options supplied to |\includegraphics|.
+
+No optional argument.\\
+left---\fbox{\includegraphics{a}}---right
+
+\gs |\scalebox{0.5}{\includegraphics{a}}|\\
+\gx |\includegraphics[scale=.5]{a}|\\
+left---\fbox{\includegraphics[scale=.5]{a}}---right
+
+\gs |\includegraphics[15,10][35,45]{a}}|\\
+\gx |\includegraphics[viewport= 15 10 35 45]{a}|\\
+left---\fbox{\includegraphics[viewport= 15 10 35 45]{a}}---right
+
+\gs |\includegraphics*[15,10][35,45]{a}}|\\
+\gx |\includegraphics[viewport= 15 10 35 45,clip]{a}|\\
+left---\fbox{\includegraphics[viewport= 15 10 35 45,clip]{a}}---right
+
+\gs |\scalebox{0.5}{\includegraphics{a}}|
+ and |draft| option.\\
+\gx |\includegraphics[scale=.5, draft]{a}|\\
+left---\fbox{\includegraphics[scale=.5, draft]{a}}---right
+
+\subsection{Other commands in the \package{graphics} package}
+
+\begin{decl}
+|\graphicspath|\arg{dir-list}
+\end{decl}
+This optional declaration may be used to specify a list of directories
+in which to search for graphics files. The format is the same as for
+the \LaTeXe\ primitive |\input@path|. A list of directories, each in a
+|{}| group (even if there is only one in the list). For example:\\
+ |\graphicspath{{eps/}{tiff/}}|\\
+ would cause the system to look in the subdirectories |eps| and |tiff|
+ of the current directory. (All modern \TeX{} systems use |/|
+ as the directory separator, even on Windows.)
+
+ The default setting of this path is
+ |\input@path| that is: graphics files will be found wherever \TeX\
+ files are found.
+
+\begin{decl}
+|\DeclareGraphicsExtensions|\arg{ext-list}
+\end{decl}
+ \NEWdescription{1994/12/01}
+ This specifies the behaviour of the system when no file extension
+ is specified in the argument to |\includegraphics|.
+ \arg{ext-list} should be a comma separated list of file extensions.
+ (White space is ignored between the entries.)
+ A file name is produced by appending one extension from the list.
+ If a file is found, the system acts as if that extension had been
+ specified. If not, the next extension in \emph{ext-list} is tried.
+
+
+Note that if the extension is not specified in the |\includegraphics|
+command, the graphics file must exist at the time \LaTeX\ is run, as
+the existence of the file is used to determine which extension from
+the list to choose. However if a file extension \emph{is} specified,
+e.g.\ |\includegraphics{a.ps}| instead of |\includegraphics{a}|, then
+the graphics file need not exist at the time \LaTeX\ is used. (In
+particular it may be created on the fly by the \m{command}
+specified in the |\DeclareGraphicsRule| command described below.)
+\LaTeX\ does however need to be able to determine the size of the
+image so this size must be specified in arguments, or the `read file'
+must exist at the time \LaTeX\ is used.
+
+\begin{decl}
+|\DeclareGraphicsRule|\arg{ext}\arg{type}\arg{read-file}\arg{command}
+\end{decl}
+ Any number of these declarations can be made. They determine how the
+ system behaves when a file with extension \emph{ext} is specified.
+ (The extension may be specified explicitly or, if the argument to
+ |\includegraphics| does not have an extension, it may be a default
+ extension from the \emph{ext-list} specified with
+ |\DeclareGraphicsExtensions|.)
+
+\emph{ext} the file extension for which this rule applies. As a special
+case, \emph{ext} may be given as |*| to denote the default behaviour for
+all undeclared extensions (see the example below).
+
+\emph{type} is the `type' of file involved. All files of the same type
+will be input with the same internal command (which must be defined in
+a `driver file'). For example files with extensions |ps|, |eps|,
+|ps.gz| may all be classed as type |eps|.
+
+\emph{read-file} determines the extension of the file that should be
+read to determine size information. It may be the same as \emph{ext}
+but it may be different, for example |.ps.gz| files are not readable
+easily by \TeX, so you may want to put the bounding box information in
+a separate file with extension |.ps.bb|. If \emph{read-file} is empty,
+|{}|, then the system will not try to locate an external file for size
+info, and the size must be specified in the arguments of
+|\includegraphics|. If the driver file specifies a procedure for
+reading size files for \emph{type}, that will be used, otherwise the
+procedure for reading |eps| files will be used. Thus the size of
+bitmap files may be specified in a file with a PostScript style
+|%%BoundingBox| line, if no other specific format is available.
+
+As a special case |*| may be used to denote the
+same extension as the graphic file. This is mainly of use in
+conjunction with using |*| as the extension, as in that case the
+particular graphic extension is not known. For example
+\begin{verbatim}
+ \DeclareGraphicsRule{*}{eps}{*}{}
+\end{verbatim}
+This would declare a default rule, such that all unknown extensions
+would be treated as EPS files, and the graphic file would be read for
+a BoundingBox comment.
+
+\emph{command} is usually empty, but if non empty it is used in place
+of the filename in the |\special|. Within this argument, |#1| may be
+used to denote the filename. Thus using the dvips driver, one may
+use\\
+|\DeclareGraphicsRule{.ps.gz}{eps}{.ps.bb}{`zcat #1}|\\
+the final argument causes dvips to use the |zcat| command to unzip the
+file before inserting it into the PostScript output.
+
+Note that \LaTeX\ will find the graphics file by searching along
+TEXINPUTS (and possibly other places, as specified with
+|\graphicspath|) however it may be that the command you specify
+in this argument can not find such files unless they are in the
+current directory. On some systems it may be possible to modify
+the command so that it will find any files that \LaTeX\ can find.
+For example on newer web2c \TeX\ releases on unix, one may modify the
+above command so that the last argument is:\\
+|{`zcat `kpsewhich -n latex tex #1`}|\\
+which incantation causes the |kpsewhich| program to find the
+file, by searching along \LaTeX's path, and then pass the full path
+name to the |zcat| program so that it can uncompress the file.
+Any such uses are very system dependent, and would best be placed in
+a |graphics.cfg| file, thus keeping the document itself portable.
+
+\subsection{Global setting of keys}
+
+Most of the \package{keyval} keys used in the \package{graphicx} package
+may also be set using the command |\setkeys| provided by the
+\package{keyval} package.%
+\footnote{\texttt{clip}, \texttt{scale} and \texttt{angle} may not be set via
+\texttt{\string\setkeys} prior to calling
+\texttt{\string\includegraphics}.}
+
+For instance, suppose you wanted all the files to be included in the
+current document to be scaled to 75\% of the width of the lines of text,
+then one could issue the following command:\\
+|\setkeys{Gin}{width=0.75\textwidth}|\\
+Here `|Gin|' is the name used for the \package{keyval} keys associated
+with `Graphics inclusion'. All following
+|\includegraphics| commands (within the same group or environment) will
+act as if |[width=0.75\textwidth]| had been specified, in addition to
+any other key settings actually given in the optional argument.
+
+Similarly to make all |\rotatebox| arguments take an argument in
+radians, one just needs to specify:\\
+|\setkeys{Grot}{units=6.28318}|
+
+\subsection{Compatibility between \package{graphics} and
+ \package{graphicx}}
+
+For a document author, there are not really any problems of
+compatibility between the two packages. You just choose the interface
+that you personally prefer, and then use the appropriate package.
+
+For a package or class writer the situation is slightly
+different. Suppose that you are writing a letter class that needs to
+print a company logo as part of the letterhead.
+
+As the author of the class you may want to give the users the
+possibility of using either interface in their letters (should they
+need to include any further graphics into the letter body).
+In this case the class should load the \package{graphics} package (not
+\package{graphicx}, as this would commit any users of the class to the
+\package{keyval} interface). The logo should be included with
+|\includegraphics| either with \emph{no} optional argument (if the
+correct size information is in the file) or \emph{both} optional
+arguments otherwise.
+Do not use the \emph{one} optional argument form, as the meaning of this
+argument would change (and generate errors) if the user were to load
+\package{graphicx} as well as your class.
+
+\section{Remaining packages in the graphics bundle}
+
+\subsection{Epsfig}
+This is a small package essentially a `wrapper' around the
+\package{graphicx} package, defining a command |\psfig| which has the
+syntax\\
+|\psfig{file=xxx,...}| rather than |\includegraphics[...]{xxx}|.\\
+It also has a few more commands to make it slightly more compatible with
+the old \LaTeX~2.09 style of the same name.
+
+\subsection{Rotating}
+An extension package to \package{graphicx}, mainly used for providing
+rotated float environments.
+
+\subsection{Trig}
+The trig package is not intended to be used directly in documents. It
+calculates sine, cosine and tangent trigonometric functions. These
+are used to calculate the space taken up by a rotated box. This
+package is also used by the |fontinst| program which converts
+PostScript files to a form usable by \TeX.
+
+As well as being used as a \LaTeX\ package, the macros may be extracted
+with the \package{docstrip} options \texttt{plain,package}. In this case
+the \LaTeX\ package declarations are omitted from the file, and the
+macros may be directly used as part of another macro file (they work
+with any format based on plain \TeX.)
+
+\subsection{Keyval}
+The \package{keyval} package is intended to be used by other
+packages. It provides a generic way of setting `keys' as used by the
+\package{graphicx} package, and splitting up the comma separated lists
+of \m{key}~=~\m{value} pairs.
+
+Like the \package{trig} package, these macros may be extracted and used
+as part of another macro file, based on plain \TeX, as well as the
+standard use as a \LaTeX\ package.
+
+By default an undeclared key will generate an error.
+If however the option \texttt{unknownkeysallowed} is used, then
+unknown keys will be silently ignored (leaving a message in the log
+file). This option is also accepted by the \textsf{graphicx} package.
+
+\iffalse
+
+\subsection{Pstcol}
+\package{PSTricks}, by Timothy Van Zandt is an immensely powerful
+package that enables a very full featured interface between PostScript
+and \TeX. Unfortunately the colour support in \package{PSTricks} is
+slightly incompatible with the colour mechanism defined in the
+\package{color} package. The \package{pstcol} package is a (hopefully
+temporary) package that modifies a very small number of internal
+PSTricks functions, to remove this incompatibility. If
+\package{pstricks} is loaded via this package, you may use any colours
+defined by \package{color} package commands within \package{pstricks}
+commands, and vice versa.
+
+\fi
+
+\subsection{Lscape}
+The \package{lscape} package requires and takes the same options
+as the \package{graphics} package. It defines a |landscape| environment
+within which page bodies are rotated through 90 degrees. The page head
+and foot are not affected, they appear in the standard (portrait)
+position.
+\end{document}
diff --git a/macros/latex/required/graphics/keyval.dtx b/macros/latex/required/graphics/keyval.dtx
new file mode 100644
index 0000000000..f656961d0b
--- /dev/null
+++ b/macros/latex/required/graphics/keyval.dtx
@@ -0,0 +1,419 @@
+%
+% \iffalse
+%% keyval.dtx Copyright (C) 1993 1994 1995 1997 1998 1999 David Carlisle
+%% Copyright (C) 2000--2015 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
+%% License, as described in lppl.txt in the base LaTeX distribution.
+%% Either version 1.3c or, at your option, any later version.
+%%
+%
+%<*dtx>
+ \ProvidesFile{keyval.dtx}
+%</dtx>
+%<*!plain>
+%<package&!plain>\NeedsTeXFormat{LaTeX2e}
+%<package&!plain>\ProvidesPackage{keyval}
+%<driver> \ProvidesFile{keyval.drv}
+% \fi
+% \ProvidesFile{keyval.dtx}
+ [2014/10/28 v1.15 key=value parser (DPC)]
+%
+% \iffalse
+%</!plain>
+%<*driver>
+\documentclass{ltxdoc}
+\usepackage{keyval}
+\begin{document}
+ \DocInput{keyval.dtx}
+\end{document}
+%</driver>
+% \fi
+%
+% \GetFileInfo{keyval.dtx}
+% \title{The \textsf{keyval} package\thanks{This file
+% has version number \fileversion, last
+% revised \filedate.}}
+% \author{David Carlisle}
+% \date{\filedate}
+% \MaintainedByLaTeXTeam{graphics}
+% \maketitle
+%
+% \begin{abstract}
+% A \LaTeX\ package implementing a system allowing the setting
+% of parameters (or `named arguments' with a
+% \meta{key}${}={}$\meta{value} syntax.
+%
+% Eg: |\foo[height=3in, shadow = true ]{bar}|
+% \end{abstract}
+%
+%
+% \changes{v1.03}
+% {1993/10/13}{Initial version}
+% \changes{v1.04}{1993/11/15}
+% {Upgrade after comments from Timothy van Zandt}
+% \changes{v1.05}{1993/11/17}
+% {Further small improvements}
+% \changes{v1.06}{1994/02/01}
+% {Update to LaTeX2e}
+% \changes{v1.07}{1994/03/15}
+% {New style ltxdoc}
+% \changes{v1.08}{1994/09/12}
+% {Improve docstrip handling}
+% \changes{v1.09}{1995/09/21}
+% {Move a comma for graphics/1698}
+% \changes{v1.14}{2014/04/25}
+% {Make most definitions \cs{long} to allow \cs{par} in values: graphics/3446}
+% \changes{v1.14}{2014/04/25}
+% {Only strip a single brace pair from values: graphics/3446}
+% \changes{v1.15}{2014/05/08}
+% {revert this change: Only strip a single brace pair from values: graphics/3446}
+%
+%
+% This package implements a system of defining and using sets of
+% parameters, which are set using the syntax \meta{key}=\meta{value}.
+%
+% For each keyword in such a set, there exists a function which is
+% called whenever the parameter appears in a parameter list. For
+% instance if the set |dpc| is to have the keyword |scale| then I
+% would define.\\
+% | \define@key{dpc}{scale}{scale ({\tt\string#1})\\}|\\
+% The first argument of |\define@key| is the set of keywords being
+% used, the second is the keyword, and the third is the function to
+% call. This function will be given as |#1| the \meta{value} specified
+% by the user.
+%
+% Normally it is an error to omit the `=\meta{value}' however if an
+% optional \meta{value} is supplied when the keyword is defined, then
+% just the keyword need be supplied.\\
+% |\define@key{dpc}{clip}[true]{...}|\\
+% For `|clip|' you can go `|clip = true|' or `|clip = false|' or
+% just `|clip|', which is the same as `|clip = true|'
+%
+% To use these keywords, just call `|\setkeys|' with a comma
+% separated list of settings, each of the form
+% \meta{key}=\meta{value}, or just \meta{key}. Any white space around
+% the `|=|' and `|,|' is ignored.
+%
+% As the \meta{key} is passed as a macro argument, if it consists
+% entirely of a |{ }| group, the outer braces are stripped off. Thus
+% |,key=foo,| and |,key={foo},| are equivalent. This fact enables one to
+% `hide' any commas or equals signs that must appear in the value. i.e.\
+% in |foo={1,2,3},bar=4|, |foo| gets the value |1,2,3|, the comma after
+% |1| does not terminate the keyval pair, as it is `hidden' by the
+% braces.
+%
+% Empty entries, with nothing between the commas, are silently ignored.
+% This means that it is not an error to have a comma after the last
+% term, or before the first.
+%
+% \section{Example}
+%
+% We may extend the examples above to give a `fake' graphics
+% inclusion macro, with a syntax similar to that used in the psfig
+% macros.
+%
+% \makeatletter
+% \def\dpcgraphics{\@ifnextchar[\@dpcgraphics{\@dpcgraphics[]}}
+%
+% |\dpcgraphics| has one optional argument which is passed through
+% |\setkeys|, and one mandatory argument, the filename. It actually
+% just typesets its arguments, for demonstration.
+%
+% \def\@dpcgraphics[#1]#2{{\setkeys{dpc}{#1}INPUT: #2}}%
+%
+% \define@key{dpc}{scale}{scale ({\tt\string#1\relax})\\}
+% \define@key{dpc}{height}{height ({\tt#1})\\}
+% \define@key{dpc}{width}{width ({\tt#1})\\}
+% \define@key{dpc}{bb}{bounding box ({\tt#1})\\}
+% \define@key{dpc}{clip}[true]{clip ({\tt\string#1\relax})\\}
+% \makeatother
+%
+% The declared keys are: |scale|, |height|, |width|, |bb|,
+% and |clip|. Except for the last, they must all be given a value if
+% used.
+%
+% Note how in the following, any white space around |=| or |,| is
+% ignored, as are the `empty' arguments caused by extra commas. Note
+% also that each macro receives \emph{exactly} the tokens that you
+% specify as arguments, no premature expansion is done.
+%
+% \begin{verbatim}
+% \def\dpcgraphics{\@ifnextchar[\@dpcgraphics{\@dpcgraphics[]}}
+% \def\@dpcgraphics[#1]#2{{\setkeys{dpc}{#1}INPUT: #2}}
+%
+% \define@key{dpc}{scale}{scale ({\tt\string#1\relax})\\}
+% \define@key{dpc}{clip}[true]{clip ({\tt\string#1\relax})\\}
+% \end{verbatim}
+%
+% \begin{minipage}{.4\textwidth}
+% \begin{verbatim}
+% \def\scalemacro{9}
+% \dpcgraphics
+% [ height =4in, ,
+% width = 3in,
+% scale = \scalemacro,
+% bb = 20 20 300 400 ,
+% clip,
+% ]{aaa}
+% \end{verbatim}
+% \end{minipage}
+% \hfill
+% \begin{minipage}{.4\textwidth}
+% \def\scalemacro{9}
+%\dpcgraphics
+% [ height =4in, ,
+% width = 3in,
+% scale = \scalemacro ,
+% bb = 20 20 300 400 ,
+% clip ,
+% ]{aaa}
+% \end{minipage}
+%
+%
+% \section{The Internal Interface}
+% A declaration of the form:\\
+% |\define@key{family}{key}{...}|\\
+% Defines a macro |\KV@prefix@key| with one argument. When used in a
+% keyval list, the macro receives the value as its argument.
+%
+% A declaration of the form:\\
+% |\define@key{family}{key}[default]{...}|\\
+% Defines a macro |\KV@family@key| as above, however it also defines the
+% macro |\KV@family@key@default| as a macro with no arguments, and
+% definition\\
+% |\KV@family@key{default}|.
+%
+% Thus if macros are defined using |\define@key|, the use of a key with
+% no value \ldots|,foo,|\ldots\ is always equivalent to the use of the
+% key with some value, \ldots|,foo=default,|\ldots. However a package
+% writer may wish that the `default' behaviour for some key is not
+% directly equivalent to using that key with a value. (In particular, as
+% pointed out to me by Timothy Van Zandt, you may wish to omit error
+% checking on the default value as you know it is correct.) In these
+% cases one simply needs to define the two macros
+% |\KV@|\meta{family}|@key| and |\KV@|\meta{family}|@key@default|
+% directly using |\def| (or |\newcommand|). I do not supply a user
+% interface for this type of definition, but it is supported in the
+% sense that I will try to ensure that any future upgrades of this
+% package do not break styles making use of these `low level'
+% definitions.
+%
+% \StopEventually{}
+%
+% \section{The Macros}
+%
+% From version~1.05, all `internal' macros associated to keys have names
+% of the form:\\
+% |\KV@|\meta{family}|@|\meta{key} or
+% |\KV@|\meta{family}|@|\meta{key}|@|\meta{default}
+%
+% \begin{macrocode}
+%<*package>
+% \end{macrocode}
+%
+% \begin{macro}{\setkeys}
+% The top level macro. |#2| should be a comma separated values of the
+% form \meta{key} |=| \meta{value} or just simply \meta{key}.
+% The macro associated with this key in the `family' |#1| is called with
+% argument \meta{value}. The second form is only allowed if the key was
+% declared with a default value.
+% \begin{macrocode}
+\long\def\setkeys#1#2{%
+% \end{macrocode}
+% Save the `family' for later. Then begin acting on the comma
+% separated list.
+% \changes{v1.11}{1998/06/05}
+% {Make \cs{@tempc} safe (in case it is an \cs{if}.}
+% \begin{macrocode}
+ \def\KV@prefix{KV@#1@}%
+ \let\@tempc\relax
+ \KV@do#2,\relax,}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\KV@do}
+% Iterate down the list of comma separated argument pairs.
+% \changes{v1.14}{2014/04/25}
+% {Add \cs{@empty} not \cs{empty}}
+% \begin{macrocode}
+\long\def\KV@do#1,{%
+ \ifx\relax#1\@empty\else
+ \KV@split#1==\relax
+ \expandafter\KV@do\fi}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\KV@split}
+% Split up the keyword and value, and call the appropriate command.
+% This macro was slightly reorganised for version 1.04, after some
+% suggestions from Timothy Van Zandt.
+% \begin{macrocode}
+\long\def\KV@split#1=#2=#3\relax{%
+ \KV@@sp@def\@tempa{#1}%
+ \ifx\@tempa\@empty\else
+ \expandafter\let\expandafter\@tempc
+ \csname\KV@prefix\@tempa\endcsname
+ \ifx\@tempc\relax
+%<plain> \KV@err
+%<!plain> \KV@errx
+ {\@tempa\space undefined}%
+ \else
+ \ifx\@empty#3\@empty
+ \KV@default
+ \else
+ \KV@@sp@def\@tempb{#2}%
+ \expandafter\@tempc\expandafter{\@tempb}\relax
+ \fi
+ \fi
+ \fi}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\KV@default}
+% Run the default code, or raise an error.
+% \begin{macrocode}
+\def\KV@default{%
+ \expandafter\let\expandafter\@tempb
+ \csname\KV@prefix\@tempa @default\endcsname
+ \ifx\@tempb\relax
+ \KV@err{No value specified for \@tempa}%
+ \else
+ \@tempb\relax
+ \fi}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\KV@err}
+% \changes{v1.10}{1997/11/10}
+% {Use \cs{PackageError}}
+% \changes{v1.12}{1998/11/18}
+% {Option system added}
+% Error messages.
+% \begin{macrocode}
+%<plain>\def\KV@err#1{\errmessage{key-val: #1}}
+%<*!plain>
+\DeclareOption{unknownkeysallowed}{%
+ \def\KV@errx#1{\PackageInfo{keyval}{#1}}}
+\DeclareOption{unknownkeyserror}{%
+ \def\KV@errx#1{\PackageError{keyval}{#1}\@ehc}}
+\ExecuteOptions{unknownkeyserror}
+\let\KV@err\KV@errx
+\ProcessOptions
+%</!plain>
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\KV@@sp@def}
+% \changes{v1.10}{1997/11/10}
+% {Reorganise to not require doubled hash tokens, and to not
+% lose initial brace groups.}
+% \begin{macro}{\KV@@sp@b}
+% \begin{macro}{\KV@@sp@c}
+% \begin{macro}{\KV@@sp@d}
+% |\KV@@sp@def|\meta{cmd}\meta{token list} is like |\def|, except that
+% a space token at the beginning or end of \meta{token list} is
+% removed before making the assignment. \meta{token list} may not
+% contain the token |\@nil|, unless it is within a brace group.
+% The names of these commands were changed at version~1.05 to ensure
+% that they do not clash with `internal' macros in a key family `sp'.
+%
+% Since v1.10, |#| may appear in the second argument without it
+% needing to be doubled as |##|. Also earlier versions would
+% drop any initial brace group, so |{abc}d| would incorrectly
+% be treated as |abcd|. The current version only removes brace
+% groups that surround the entire value, so |{abcd}| \emph{is} treated
+% correctly as |abcd|. Prior to v1.14, two levels of bracing are removed, if
+% you require the entire argument to be a single brace group, you had
+% use |{{{abcd}}}|, from v1.14 exactly one brace group is removed, so to make
+% the entire value be a brace group you need |{{abc}}|.
+%
+% \begin{macrocode}
+\def\@tempa#1{%
+% \end{macrocode}
+%
+% \begin{macrocode}
+\long\def\KV@@sp@def##1##2{%
+ \futurelet\KV@tempa\KV@@sp@d##2\@nil\@nil#1\@nil\relax##1}%
+% \end{macrocode}
+%
+% Early release removed initial space by having an `extra' argument
+% in |\KV@@sp@b| but that removed too many braces, so now make
+% |\KV@@sp@b| explicitly remove a single space token. That unfortunately
+% means we need the new |\KV@@sp@d| command to add a space token if
+% one was not there before.
+% \begin{macrocode}
+\def\KV@@sp@d{%
+ \ifx\KV@tempa\@sptoken
+ \expandafter\KV@@sp@b
+ \else
+ \expandafter\KV@@sp@b\expandafter#1%
+ \fi}%
+% \end{macrocode}
+%
+% \changes{v1.14}{2014/04/25}
+% {Add \cs{@empty} to avoid dropping a brace pair: graphics/3446}
+% \changes{v1.15}{2014/05/08}
+% {revert last change}
+% \begin{macrocode}
+\long\def\KV@@sp@b#1##1 \@nil{\KV@@sp@c##1}%
+% \end{macrocode}
+%
+% \begin{macrocode}
+%<plain>\def\@sptoken{#1}%
+% \end{macrocode}
+%
+% Make the above definitions, inserting the space token where needed.
+% \begin{macrocode}
+ }
+\@tempa{ }
+% \end{macrocode}
+%
+% \changes{v1.14}{2014/04/25}
+% {Add \cs{expandafter} to remove the extra \cs{@empty} token: graphics/3446}
+% \changes{v1.15}{2014/05/08}
+% {revert last change}
+% \begin{macrocode}
+\long\def\KV@@sp@c#1\@nil#2\relax#3{\KV@toks@{#1}\edef#3{\the\KV@toks@}}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\KV@toks@}
+% Macro register used above to prevent |#| doubling.
+% Avoid uding one of the normal scratch registers, as this code
+% is not in a local group.
+% \begin{macrocode}
+\newtoks\KV@toks@
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\define@key}
+% Define the command associated to the key |#2| in the family |#1|.
+% First looks for a default argument (the default value for the
+% key)
+% \begin{macrocode}
+\def\define@key#1#2{%
+ \@ifnextchar[{\KV@def{#1}{#2}}{\long\@namedef{KV@#1@#2}####1}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\KV@def}
+% Make the definitions of the command, and the default value.
+% \begin{macrocode}
+\def\KV@def#1#2[#3]{%
+ \long\@namedef{KV@#1@#2@default\expandafter}\expandafter
+ {\csname KV@#1@#2\endcsname{#3}}%
+ \long\@namedef{KV@#1@#2}##1}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macrocode}
+%</package>
+% \end{macrocode}
+% \Finale
+%
+\endinput
diff --git a/macros/latex/required/graphics/keyval.pdf b/macros/latex/required/graphics/keyval.pdf
new file mode 100644
index 0000000000..e04af31b5a
--- /dev/null
+++ b/macros/latex/required/graphics/keyval.pdf
Binary files differ
diff --git a/macros/latex/required/graphics/lscape.dtx b/macros/latex/required/graphics/lscape.dtx
new file mode 100644
index 0000000000..733e183ee6
--- /dev/null
+++ b/macros/latex/required/graphics/lscape.dtx
@@ -0,0 +1,135 @@
+%
+% \iffalse
+%
+%% lscape.dtx Copyright (C) 1994 1999-2000 David Carlisle
+%% Copyright (C) 2000--2015 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
+%% License, as described in lppl.txt in the base LaTeX distribution.
+%% Either version 1.3c or, at your option, any later version.
+%%
+%<*dtx>
+ \ProvidesFile{lscape.dtx}
+%</dtx>
+%<package>\NeedsTeXFormat{LaTeX2e}[1994/06/01]
+%<package>\ProvidesPackage{lscape}
+%<driver> \ProvidesFile{lscape.drv}
+% \fi
+% \ProvidesFile{lscape.dtx}
+ [2000/10/22 v3.01 Landscape Pages (DPC)]
+%
+% \iffalse
+%<*driver>
+\documentclass{ltxdoc}
+\usepackage{lscape}
+\begin{document}
+ \DocInput{lscape.dtx}
+\end{document}
+%</driver>
+% \fi
+%
+% \GetFileInfo{lscape.dtx}
+%
+% \title{The \textsf{lscape} package\thanks{This file
+% has version number \fileversion, last
+% revised \filedate.}}
+% \author{D. P. Carlisle}
+% \date{\filedate}
+%
+%
+% \begin{landscape}
+% \MaintainedByLaTeXTeam{graphics}
+% \maketitle
+%
+% All text, within the \texttt{landscape} environment is rotated through
+% 90 degrees. The environment may span several pages. It works well
+% with, and was originally created for, use with \textsf{longtable} to
+% produce long wide tables.
+%
+% All the work is done by the \textsf{graphics} package, the trick is to
+% call it at the right place in the output routine to rotate the current
+% page before the page head and foot are added.
+%
+%
+% \StopEventually{\end{landscape}}
+% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% \changes{v1.00}{1992/04/28}{Initial release}
+% \changes{v2.00}{1992/11/18}{Support for footnotes and floats.
+% Special thanks to Sarah J. McQuay for testing this release}
+% \changes{v3.00}{1994/10/05}{Update using LaTeX2e graphics package}
+% \changes{v3.01}{1999/06/22}{Added better pdfTeX support
+% by Scott Pakin, from graphics/3063}
+%
+%
+% \begin{macrocode}
+%<*package>
+% \end{macrocode}
+% Here is what Scott Pakin wrote about the pdftex option:
+% \begin{quote}
+% I've made a minor improvement to lscape.dtx that I'd like to share
+% with the world. My addition makes lscape rotate the PDF "paper" --
+% not just the text on the page -- when given the "pdftex" option.
+% (Naturally, this works only with pdfLaTeX.) The result is that the
+% text is viewable online without the reader having to rotate his/her
+% head 90 degrees. The document still prints normally.
+% \end{quote}
+%
+%
+% \begin{macrocode}
+\newif\ifGin@pdftex
+\Gin@pdftexfalse
+\DeclareOption{pdftex}{%
+ \PassOptionsToPackage\CurrentOption{graphics}
+ \Gin@pdftextrue
+}
+\DeclareOption*{\PassOptionsToPackage\CurrentOption{graphics}}
+\ProcessOptions
+\RequirePackage{graphics}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\let\LS@makecol=\@makecol
+\let\LS@makefcolumn=\@makefcolumn
+\def\LS@rot{%
+ \setbox\@outputbox\vbox{\hbox{\rotatebox{90}{\box\@outputbox}}}}
+% \end{macrocode}
+%
+% First set up the page size for landscape.
+% \begin{macrocode}
+\def\landscape{%
+ \clearpage
+ \begingroup
+ \vsize=\textwidth
+ \hsize=\textheight
+ \linewidth=\hsize
+ \columnwidth=\hsize
+ \@colroom=\vsize
+ \textheight=\vsize
+ \@colht=\vsize
+% \end{macrocode}
+% Rotate the page body (text and float pages).
+% \begin{macrocode}
+ \def\@makecol{\LS@makecol\LS@rot}%
+ \def\@makefcolumn##1{\LS@makefcolumn{##1}\LS@rot}}
+% \end{macrocode}
+%
+% Restore everything. This is where the pdftex option makes a
+% difference.
+% \begin{macrocode}
+\def\endlandscape{%
+ \ifGin@pdftex
+ \pdfpageattr{/Rotate 90}
+ \fi
+ \clearpage
+ \endgroup
+ \global\@colht=\textheight
+ \global\vsize=\textheight
+ \global\@colroom=\textheight}
+%</package>
+% \end{macrocode}
+%
+%
+% \Finale
+%
diff --git a/macros/latex/required/graphics/lscape.pdf b/macros/latex/required/graphics/lscape.pdf
new file mode 100644
index 0000000000..50843756bb
--- /dev/null
+++ b/macros/latex/required/graphics/lscape.pdf
Binary files differ
diff --git a/macros/latex/required/graphics/rotating.dtx b/macros/latex/required/graphics/rotating.dtx
new file mode 100644
index 0000000000..41bd399d4e
--- /dev/null
+++ b/macros/latex/required/graphics/rotating.dtx
@@ -0,0 +1,686 @@
+%
+% \iffalse
+%
+%
+% File: rotating.dtx
+%% Copyright 1995--1999 Sebastian Rahtz and Leonor Barroca
+%% Copyright 2001--2003,2007--2009 Robin Fairbairns
+%% Copyright 2016 LaTeX3 Project
+%
+% 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'.
+%
+%
+% This work consists of the file rotating.dtx
+% and the derived file rotating.sty, and testing material
+% rotex.tex and cat.eps
+%
+% \begin{macrocode}
+\NeedsTeXFormat{LaTeX2e}
+%<*dtx>
+\ProvidesFile{rotating.dtx}%
+%</dtx>
+%<package>\ProvidesPackage{rotating}%
+ [2016/08/11 v2.16d
+%<package> rotated objects in LaTeX%
+%<*dtx>
+ rotating package source file%
+%</dtx>
+ ]
+%<*dtx>
+\documentclass{ltxdoc}
+\GetFileInfo{rotating.dtx}
+\begin{document}
+ \title{A package for rotated objects in \LaTeX\thanks{This file has
+ version number \fileversion, last revised \filedate}}
+ \author{Robin Fairbairns
+ \and Sebastian Rahtz \and Leonor Barroca}
+ \date{printed \today}
+ \MaintainedByLaTeXTeam{graphics}
+ \maketitle
+ \tableofcontents
+% \listoffigures
+% \listoftables
+ \DocInput{rotating.dtx}
+\end{document}
+%</dtx>
+% \fi
+%
+% \begin{abstract}
+% This article documents a \LaTeX\ package, `rotating.sty',
+% which performs most sorts of
+% rotation one might like, including rotation of complete floating
+% figures and tables.
+% \end{abstract}
+%
+% \section{Introduction}
+%
+% The package provides:
+% \begin{itemize}
+% \item two new environments, \texttt{sidewaystable} and
+% \texttt{sidewaysfigure}, each of which produces a single page-size
+% float with contents rotated $\pm90$\,degrees; and
+% \item a variety of other rotation-related commands and environments.
+% \end{itemize}
+%
+% Note that the package uses rotation facilities from the
+% \textsf{graphicx} package. When generating DVI output, users should
+% note that rotation is typically \emph{not} visible in a DVI viewer:
+% conversion to, and viewing, PostScript or PDF is necessary.
+%
+% \section{Usage}
+%
+% \subsection{Package options}
+%
+% Sideways figures and tables always take up the whole page. In
+% single-sided documents, they may be rotated so that the bottom of
+% the figures is on the left (package option
+% `\texttt{counterclockwise}') or the right (package option
+% `\texttt{clockwise}'). The default is to turn so that the bottom is
+% on the right (option `\texttt{clockwise}').
+%
+% Option `\texttt{anticlockwise}' is an alias for
+% `\texttt{counterclockwise}'.
+%
+% If the `\texttt{twoside}' option has been given to the main document
+% class (either explicitly, or implicitly as in the default for book
+% class), the package will rotate sideways figures according to the
+% page number (this requires at least two passes through \LaTeX{}).
+% If you want the `\texttt{twoside}' option, but want the figures
+% always in one direction, use the `\texttt{figuresright}' or
+% `\texttt{figuresleft}' options to the package.
+%
+% The package can produce a lot of logging information; the
+% amount of information is controlled by the package options
+% `\texttt{quiet}' (fewest messages; default), `\texttt{log}' and
+% `\texttt{chatter}' (most messages).
+%
+% All other options are passed to the \textsf{graphicx} package when
+% it is loaded to provide rotation functions.
+%
+% \subsection{Float environments}
+%
+% The environments \texttt{sidewaystable} and \texttt{sidewaysfigure}
+% introduce landscape-form floating tables and figures, respectively.
+% (Each of the environments has a ``starred'' version, such as
+% \texttt{sidewaystable*}, for a single-column float in a double-column
+% area of the document.)
+%
+% New rotated environments may be declared using the combined
+% facilities of the float and rotfloat packages.
+%
+% \subsection{Other environments and commands}
+% The package provides other \LaTeX\ environments:
+% \begin{description}
+% \item[\mdseries\ttfamily sideways] prints the contents of the
+% environment turned through 90 degrees counterclockwise;
+% \item[\mdseries\ttfamily turn] prints the contents turned through an
+% arbitrary angle (the argument to the environment);
+% \item[\mdseries\ttfamily rotate] prints the contents turned through
+% an arbitrary angle but does \emph{not} leave any space for the result
+% \end{description}
+%
+% The command \cs{turnbox}\marg{angle}\marg{matter to turn} is a macro
+% version of the \texttt{rotate} environment.
+%
+% A set of examples is given in the file \texttt{rotex.tex}
+%
+% \subsection{Positioning}
+%
+% Floats appear one to a page, and are positioned by spacer skips that
+% appear (logically) above and below the floating object. The skips,
+% \cs{rotFPtop} and \cs{rotFPbot}, are initialised from the standard
+% \LaTeX{} (internal) \cs{@fptop} and \cs{@fpbot} skips. As a result,
+% by default, rotated floats appear horizontally centred on their
+% float pages.
+%
+% Some sensible values for the registers are:
+% \par\noindent
+% \begin{tabular}{@{}llp{3in}@{}}
+% \cs{rotFPtop} & \cs{rotFPbot} & Effect \\
+% \hline
+% 0pt plus 1fil & 0pt plus 1fil & figure/table appears in middle
+% (default value) \\
+% 0pt & 0pt plus 1fil & figure/table appears with its top
+% nearest the edge of the page \\
+% 0pt plus 1fil & 0pt plus 2fil & figure/table's bottom appears
+% twice as far from the edge as the
+% top does
+% \end{tabular}
+%
+% \StopEventually{}
+%
+% \section{Setup}
+% Now we present the documented code. First, package options.
+%
+% Note that the \texttt{clockwise} and \texttt{counterclockwise}
+% options are present for compatibility only.
+% \begin{macrocode}
+%<*package>
+\DeclareOption{clockwise}{%
+ \AtBeginDocument{\setkeys{Grot}{units=360}}%
+}
+\DeclareOption{counterclockwise}{%
+ \AtBeginDocument{\setkeys{Grot}{units=-360}}%
+}
+\DeclareOption{anticlockwise}{\ds@counterclockwise}
+% \end{macrocode}
+% Control figure orientation
+% \begin{macrocode}
+\DeclareOption{figuresleft}{%
+ \@rot@twosidefalse
+ \def\rot@LR{0}%
+}
+\DeclareOption{figuresright}{%
+ \@rot@twosidefalse
+ \def\rot@LR{-1}%
+}
+% \end{macrocode}
+%
+% control messages:
+% \begin{macrocode}
+\newif\ifrot@messages
+\DeclareOption{quiet}{%
+ \rot@messagesfalse
+ \let\rot@message\@gobble % pro tem -- should suppress altogether
+}
+\DeclareOption{log}{%
+ \rot@messagestrue
+ \def\rot@message{\PackageInfo{rotating}}%
+}
+\DeclareOption{chatter}{%
+ \rot@messagestrue
+ \def\rot@message{\PackageWarning{rotating}}%
+}
+% \end{macrocode}
+%
+% \begin{macro}{\if@rot@twoside}
+% \begin{macro}{\rot@LR}
+% A couple of commands for passing rotation direction around
+% \begin{macrocode}
+\newif\if@rot@twoside
+\if@twoside
+ \@rot@twosidetrue
+\else
+ \@rot@twosidefalse
+\fi
+\def\rot@LR{-1}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% Pass any unknown options to the \textsf{graphicx} package, and
+% set up defaults and process the options.
+% \begin{macrocode}
+\DeclareOption*{\PassOptionsToPackage{\CurrentOption}{graphicx}}
+\ExecuteOptions{clockwise,quiet}
+\ProcessOptions
+% \end{macrocode}
+%
+% Other initialisation
+% \begin{macrocode}
+\RequirePackage{graphicx}
+\RequirePackage{ifthen}
+% \end{macrocode}
+%
+% \begin{macro}{\rotdriver}
+% The command \cs{rotdriver} allows a user to specify an initialisation file,
+% a sort of non-automatically-loaded driver (in the graphics, hyperref
+% sense).
+% \begin{macrocode}
+\def\rotdriver#1{\makeatletter\input{#1.def}\makeatother}
+% \end{macrocode}
+% \end{macro}
+%
+% The \texttt{r@tfl@t} counter is used when generating `labels' for
+% determining what side of the page the float is on, in twoside mode.
+% \begin{macrocode}
+\newcounter{r@tfl@t}
+\setcounter{r@tfl@t}{0}
+% \end{macrocode}
+%
+% Positioning skips (see above).
+% \begin{macrocode}
+\newskip\rotFPtop \rotFPtop=\@fptop
+\newskip\rotFPbot \rotFPbot=\@fpbot
+% \end{macrocode}
+%
+% \section{Turning and rotation environments}
+% \begin{macro}{sideways}
+% Environment to turn the contents through 90 degrees.
+% \begin{macrocode}
+\def\sideways{%
+ \Grot@setangle{90}%
+ \setbox\z@\color@hbox\ignorespaces}
+\def\endsideways{%
+ \unskip\color@endbox
+ \Grot@x\z@
+ \Grot@y\z@
+ \Grot@box
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{turn}
+% Rotate the contents of the environment, leaving the appropriate space
+% \begin{macrocode}
+\def\turn#1{%
+ \Grot@setangle{#1}%
+ \setbox\z@\color@hbox\ignorespaces}
+\def\endturn{%
+ \unskip\color@endbox
+ \Grot@x\z@
+ \Grot@y\z@
+ \Grot@box
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{rotate}
+% Rotate the contents of the environment, leaving \emph{no space}.
+% \begin{macrocode}
+\def\rotate#1{%
+ \Grot@setangle{#1}%
+ \setbox\z@\color@hbox\ignorespaces}
+\def\endrotate{%
+ \unskip\color@endbox
+ \Grot@x\z@
+ \Grot@y\z@
+ \wd0\z@\dp0\z@\ht0\z@
+ \Grot@box
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\turnbox}
+% A macro version of the `rotate' environment.
+% \begin{macrocode}
+\def\turnbox#1#2{%
+ \Grot@setangle{#1}%
+% \end{macrocode}
+% Note: grouping within the box makes \cs{color@hbox} unnecessary, I think.
+% \begin{macrocode}
+ \setbox\z@\hbox{{#2}}%
+ \Grot@x\z@\Grot@y\z@
+ \wd0\z@\dp0\z@\ht0\z@
+ \Grot@box
+}
+% \end{macrocode}
+% \end{macro}
+% \section{Sideways figures and tables}
+% Now for the macros to provide a complete
+% environment for sideways figures and tables.
+% We define two environments |sidewaysfigure| and
+% |sidewaystable| that
+% fit in with the normal table and figure floats. These are `fixed'
+% environments that just do 90 degree rotation, but it would be easy
+% to parameterize this to do other rotations if needed (the mind
+% boggles\ldots)
+%
+% \begin{macro}{\@rotfloat}
+% \begin{macro}{\@xrotfloat}
+% \begin{macro}{\rot@float@box}
+% First a generalised `rotfloat' environment. We need to intercept
+% \LaTeX's float macros, in order to change the assumed width of a
+% float being |\columnwidth|. We want it to work on a width of
+% |\textheight| so that when we rotate the float, it comes out
+% the right height. This is not actually very satisfactory, since what
+% we \emph{really} want is for rotated floats to occupy the space they
+% actually \emph{use}. The captions are a problem --- since they can
+% precede the figure or table, we cannot set them in a box of the
+% right width (ie the \emph{height} of the forthcoming object), because
+% it has not happened yet. The result of these difficulties is that
+% rotated figures always end up as full page figures.
+% \begin{macrocode}
+\newsavebox\rot@float@box
+\def\@rotfloat#1{%
+ \@ifnextchar[%
+ {\@xrotfloat{#1}}%
+ {\edef\@tempa{\noexpand\@xrotfloat{#1}[\csname fps@#1\endcsname]}\@tempa}%
+}
+\def\@xrotfloat#1[#2]{%
+ \@float{#1}[#2]%
+% \end{macrocode}
+% Set the float contents in
+% a box of width \cs{textheight} instead of \cs{columnwidth}.
+% \begin{macrocode}
+ \begin{lrbox}\rot@float@box
+ \begin{minipage}\textheight
+ }
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\end@rotfloat}
+% We call \LaTeX's \cs{end@float} macro having previously rotated
+% the box \cs{@currbox}.
+% The rotation is either clockwise or
+% anti-clockwise, depending on whether the page is odd or even;
+% in oneside mode it is always odd.
+% \begin{macrocode}
+\def\end@rotfloat{%
+% \end{macrocode}
+% If we are going to know whether pages are odd or even,
+% we need to use the a variant \cs{pageref} mechanism and our own
+% specialised labels.
+% \begin{macrocode}
+ \end{minipage}\end{lrbox}%
+ \stepcounter{r@tfl@t}%
+ \rot@label{RF\ther@tfl@t}%
+ \rot@pageref{RF\ther@tfl@t}{\R@@page}%
+ \edef\@tempa{Adding sideways \@captype\space on page \R@@page\space}
+ \rot@mess@toks\expandafter{\@tempa}
+ \wd\rot@float@box\z@
+ \ht\rot@float@box\z@
+ \dp\rot@float@box\z@
+ \vbox to \textheight{%
+% \end{macrocode}
+% We need to know for sure which direction rotation is going to
+% be in, so locally reset the graphics units.
+% \begin{macrocode}
+ \setkeys{Grot}{units=360}%
+ \if@rot@twoside
+ \else
+ \let\R@@page\rot@LR
+ \fi
+ \ifthenelse{\isodd{\R@@page}}{%
+ \if@rot@twoside
+ \rot@mess@toks\expandafter{\the\rot@mess@toks (right hand page)}%
+ \fi
+ \vfill
+ \@@line{%
+ \hskip\rotFPtop
+ \rotatebox{90}{\box\rot@float@box}%
+ \hskip\rotFPbot
+ }%
+ }{%
+ \if@rot@twoside
+ \rot@mess@toks\expandafter{\the\rot@mess@toks (left hand page)}%
+ \fi
+ \@@line{%
+ \hskip\rotFPbot
+ \rotatebox{-90}{\box\rot@float@box}%
+ \hskip\rotFPtop
+ }%
+ \vfill
+ }%
+ \rot@message{\the\rot@mess@toks}
+ }%
+ \end@float
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\sidewaysfigure}
+% \begin{macro}{\endsidewaysfigure}
+% \begin{macro}{\sidewaystable}
+% \begin{macro}{\endsidewaystable}
+% The following definitions set up two environments,
+% \texttt{sidewaystable} and \texttt{sidewaysfigure}, which uses this
+% type of float. Naturally, users may need to change these to suit
+% their local style. Both contribute to the normal lists of figures
+% and tables.
+% \begin{macrocode}
+\def\sidewaysfigure{\@rotfloat{figure}}
+%
+\let\endsidewaysfigure\end@rotfloat
+%
+\def\sidewaystable{\@rotfloat{table}}
+\let\endsidewaystable\end@rotfloat
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\@rotdblfloat}
+% \begin{macro}{\end@rotdblfloat}
+% Handling double column floats
+% \begin{macrocode}
+\def\@rotdblfloat{%
+ \if@twocolumn\expandafter\@rotdbflt\else\expandafter\@rotfloat\fi
+}
+\def\@rotdbflt#1{\@ifnextchar[{\@rotxdblfloat{#1}}{\@rotxdblfloat{#1}[tp]}}
+\def\@rotxdblfloat#1[#2]{%
+ \@float{#1}[#2]%
+ \hsize\textwidth\linewidth\textwidth
+ \begin{lrbox}\rot@float@box
+ \begin{minipage}\textheight
+}
+\def\end@rotdblfloat{%
+% \end{macrocode}
+% If we are going to know whether pages are odd or even,
+% we need to use the \cs{pageref} mechanism, and labels. But
+% Labels won't work \emph{unless} the user has put in a
+% caption. Beware!
+% \begin{macrocode}
+ \end{minipage}\end{lrbox}%
+ \stepcounter{r@tfl@t}%
+ \rot@label{RF\ther@tfl@t}%
+ \rot@pageref{RF\ther@tfl@t}{\R@@page}%
+ \edef\@tempa{Adding sideways \@captype\space on page \R@@page\space}
+ \rot@mess@toks\expandafter{\@tempa}
+ \@tempdima\ht\rot@float@box
+ \advance\@tempdima by \dp\rot@float@box
+% \ifrot@messages
+% \rot@message{BOX wd: \the\wd\rot@float@box,
+% ht: \the\ht\rot@float@box, dp: \the\dp\rot@float@box:
+% so shift by .5 of \the\@tempdima}%
+% \fi
+ \wd\rot@float@box\z@
+ \ht\rot@float@box\z@
+ \dp\rot@float@box\z@
+ \vbox to \textheight{%
+% \end{macrocode}
+% We need to know for sure which direction rotation is going to
+% be in, so locally reset the graphics units.
+% \begin{macrocode}
+ \setkeys{Grot}{units=360}%
+ \if@rot@twoside
+ \else
+ \let\R@@page\rot@LR
+ \fi
+ \ifthenelse{\isodd{\R@@page}}{%
+ \ifrot@messages
+ \if@rot@twoside
+ \rot@mess@toks\expandafter{\the\rot@mess@toks (right hand page)}%
+ \fi
+ \fi
+ \vfill
+ \@@line{%
+ \hskip\rotFPtop
+ \rotatebox{90}{\box\rot@float@box}%
+ \hskip\rotFPbot
+ }%
+ }{%
+ \ifrot@messages
+ \if@rot@twoside
+ \rot@mess@toks\expandafter{\the\rot@mess@toks (left hand page)}%
+ \fi
+ \fi%
+ \@@line{%
+ \hskip\rotFPbot
+ \rotatebox{-90}{\box\rot@float@box}%
+ \hskip\rotFPtop
+ }%
+ \vfill
+ }%
+ \rot@message{\the\rot@mess@toks}%
+ }%
+ \end@dblfloat
+}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{environment}{sidewaysfigure*}
+% \begin{environment}{sidewaystable*}
+% \begin{macrocode}
+\newenvironment{sidewaystable*}
+ {\@rotdblfloat{table}}
+ {\end@rotdblfloat}
+\newenvironment{sidewaysfigure*}
+ {\@rotdblfloat{figure}}
+ {\end@rotdblfloat}
+
+% \end{macrocode}
+% \end{environment}
+% \end{environment}
+%
+% \begin{macro}{\rot@label}
+% \begin{macro}{\rot@thepage}
+% \begin{macro}{\rot@pageref}
+% \begin{macro}{\rot@protected@write}
+% \begin{macro}{\if@rot@refundefined}
+% Note that we used \cs{rot@label}, not \cs{label}; this
+% variant writes (just) the \emph{true} page number, not the
+% value of \cs{thepage}; this ``true'' value then needs special
+% treatment in \cs{protected@write}, just as
+% \cs{thepage} already has.
+% \cs{rot@pageref}\marg{generated label name}\marg{cs to set to
+% pageno} then returns the labelled page's number (or 0 if label not
+% yet defined). If label not defined, flags using
+% \cs{rot@refundefinedtrue} for end-document to pick up. (later...)
+% \begin{macrocode}
+\def\rot@thepage{\@arabic\c@page}
+\def\rot@label#1{\@bsphack
+ \rot@protected@write{\@auxout}{}%
+ {\string\newlabel{#1}{\rot@thepage}}%
+ \@esphack}
+\def\rot@pageref#1#2{%
+ \expandafter\ifx\csname r@#1\endcsname\relax
+ \global\@rot@refundefinedtrue
+ \def#2{0}%
+ \else
+ \edef#2{\csname r@#1\endcsname}%
+ \fi
+}
+\long\def\rot@protected@write#1#2#3{%
+ \begingroup
+ \let\rot@thepage\relax
+ #2%
+ \let\protect\@unexpandable@protect
+ \edef\reserved@a{\write#1{#3}}%
+ \reserved@a
+ \endgroup
+ \if@nobreak\ifvmode\nobreak\fi\fi
+}
+\newif\if@rot@refundefined
+\global\@rot@refundefinedfalse
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\rot@mess@toks}
+% A token register to build up debugging messages
+% \begin{macrocode}
+\newtoks\rot@mess@toks
+% \end{macrocode}
+% \end{macro}
+%
+% \subsection{Rotated captions only}
+%
+% \begin{macro}{\rotcaption}
+% \begin{macro}{\@makerotcaption}
+% Sometimes you may find that the rotation of complete figures does
+% not give quite the right result, since they always take up the whole
+% page. You may prefer to rotate the caption and the float contents
+% separately within a conventional figure. Here we offer a suggestion
+% for a \cs{rotcaption} command, which inserts the caption rotated
+% by 90 degrees. It is essentially a copy of the normal captioning
+% code.
+% Packages which define the \cs{@makecaption} command may also need
+% to define \cs{@makerotcaption}.
+% \begin{macrocode}
+\def\rotcaption{\refstepcounter\@captype\@dblarg{\@rotcaption\@captype}}
+\long\def\@rotcaption#1[#2]#3{%
+ \addcontentsline{\csname ext@#1\endcsname}{#1}{%
+ \protect\numberline{\csname the#1\endcsname}{\ignorespaces #2}}%
+ \par
+ \begingroup
+ \@parboxrestore
+ \normalsize
+ \@makerotcaption{\csname fnum@#1\endcsname}{#3}%
+ \endgroup}
+ \long\def\@makerotcaption#1#2{%
+ \setbox\@tempboxa\color@hbox#1: #2\color@endbox
+ \ifdim \wd\@tempboxa > .8\vsize
+ \rotatebox{90}{%
+ \begin{minipage}{.8\textheight}#1: #2\end{minipage}%
+ }%
+ \else%
+ \rotatebox{90}{\box\@tempboxa}%
+ \fi
+ \nobreak
+ \hspace{12pt}%
+}
+%</package>
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \section{Last-minute infrastructure}
+%
+% \begin{macro}{\color@hbox}
+% \begin{macro}{\color@endbox}
+% These macros aren't provided in \LaTeX{}, by default (I seem to have
+% assumed that they were\dots)
+% \begin{macrocode}
+\AtBeginDocument{%
+ \providecommand\color@hbox{\hbox\bgroup}%
+ \providecommand\color@vbox{\vbox\bgroup}%
+ \providecommand\color@endbox{\egroup}%
+}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \section{History}
+%
+% Version 2.0 is a complete re-write, with most of the work now
+% being done by the \LaTeXe\ graphics package.
+%
+% Version 2.1 provides a `clockwise' option to reinstate the behaviour
+% described in the `\LaTeX\ Companion'
+%
+% Version 2.2 just intercepts the standard float macros instead
+% of copying and changing the. The `twoside' option is obeyed.
+%
+% Version 2.5 corrects problems in sideways figures.
+%
+% Version 2.6 is a rewrite of the sideways floats via Frank Mittelbach
+% (to whom many thanks for looking at the mangy code).
+%
+% Version 2.7 is checked for \LaTeX\ of December 94, and adds the option
+% of twoside behaviour independent of the general twoside.
+%
+% Version 2.8 cleans up some mistakes pointed out by Harald Axel
+% Sommerfeldt.
+%
+% Version 2.9 cleans up some (more) mistakes pointed out by Harald
+% Axel Sommerfeldt.
+%
+% Version 2.13a permits positioning of rotated floats in the same way
+% as they are positioned in `normal' floats.
+%
+% Version 2.14 is the first to be published anywhere as the outcome of
+% maintenance by Robin Fairbairns.
+%
+% Version 2.15 deals with page-numbering bug for auto-float-rotation,
+% and tidying of messages; published to ctan
+%
+% Version 2.16 uses colour boxes as necessary; published to ctan.
+% Version 2.16a provides the colour box commands \cs{AtBeginDocument}.
+%
+% \Finale
+\endinput
+%
diff --git a/macros/latex/required/graphics/rotating.pdf b/macros/latex/required/graphics/rotating.pdf
new file mode 100644
index 0000000000..3283a885dc
--- /dev/null
+++ b/macros/latex/required/graphics/rotating.pdf
Binary files differ
diff --git a/macros/latex/required/graphics/rotex.pdf b/macros/latex/required/graphics/rotex.pdf
new file mode 100644
index 0000000000..0eea374668
--- /dev/null
+++ b/macros/latex/required/graphics/rotex.pdf
Binary files differ
diff --git a/macros/latex/required/graphics/rotex.tex b/macros/latex/required/graphics/rotex.tex
new file mode 100644
index 0000000000..9dabfd37f7
--- /dev/null
+++ b/macros/latex/required/graphics/rotex.tex
@@ -0,0 +1,500 @@
+\errorcontextlines32
+\documentclass[twoside]{report}
+\usepackage[chatter]{rotating}
+\usepackage{fancyvrb}
+\makeatletter
+\newsavebox{\@display}
+\newcommand\@@Display[1]{%
+ \sbox\@display{%
+ \begin{minipage}[b]{.45\textwidth}%
+ #1\end{minipage}%
+ }\raisebox{\depth}{\usebox{\@display}}%
+}
+
+\newcommand\@@VDisplay[1]{%
+ \sbox\@display{%
+ \begin{minipage}[b]{.45\textwidth}%
+ \BVerbatimInput[fontsize=\small]{#1}%
+ \end{minipage}}%
+ \usebox{\@display}%
+}
+\newcommand\SideBySide[2]{%
+\bgroup\def\baselinestretch{1}%
+ \trivlist\item[]%
+ \leavevmode
+ \makebox[\textwidth][l]{\@@Display{#1}\hspace{1em}%
+ \@@VDisplay{#2}}%
+ \endtrivlist
+ \egroup
+}
+\newcommand\BeginExample{%
+ \nobreak
+ \VerbatimEnvironment
+ \catcode`\<=12
+ \begin{VerbatimOut}{\jobname.ex}%
+}
+\newcommand{\EndExample}{\end{VerbatimOut}}
+
+\newenvironment{example}
+ {\nobreak
+ \VerbatimEnvironment
+ \catcode`\<=12
+ \begin{VerbatimOut}{\jobname.ex}%
+ }
+ {\end{VerbatimOut}
+ \SideBySide {\input{\jobname.ex}}%
+ {\jobname.ex}}
+\makeatother
+%-------------------------------------------------------
+\def\degrees{{\small$^{\mathrm{o}}$}}
+%-------------------------------------------------------
+
+\begin{document}
+
+\title{Test of `rotating' package}
+\author{Sebastian Rahtz and Leonor Barroca\thanks{Now maintained as part of the \LaTeX\ graphics bundle.}}
+\date{November 19th 1994\thanks{Updated for graphics bundle 2016/05/22}}
+\maketitle
+
+`Rotating' provides a generalised rotation environment, where the text
+will be rotated (anti-clockwise) by the number of degrees specified as
+a parameter to the environment, but no special arrangement is made to
+find space for the result.
+
+\begin{example}
+Start here
+\begin{rotate}{-56}
+Save whales
+\end{rotate}
+End here
+\end{example}
+
+A complete example of rotating text without leaving space
+would the `Save the whale' text
+written at 10 degree intervals round the compass. We use
+`rlap' to ensure that all the texts are printed at the same point.
+Just to show that \TeX\ can handle PostScript muckings-about
+properly\ldots
+\begin{example}
+\newcount\wang
+\newsavebox{\wangtext}
+\newdimen\wangspace
+\def\wheel#1{\savebox{\wangtext}{#1}%
+\wangspace\wd\wangtext
+\advance\wangspace by 1cm%
+\centerline{%
+\rule{0pt}{\wangspace}%
+\rule[-\wangspace]{0pt}{\wangspace}%
+\wang=-180\loop\ifnum\wang<180
+\rlap{\begin{rotate}{\the\wang}%
+\rule{1cm}{0pt}#1\end{rotate}}%
+\advance\wang by 10\repeat}}
+\wheel{Save the whale}
+\end{example}
+
+If the user
+desires \LaTeX\ to leave space for the rotated box, then `turn' is used:
+\begin{example}
+ Start here \begin{turn}{56}%
+ Save the whale
+ \end{turn} end here
+\end{example}
+The environment `Sideways' is a special case, setting the rotation to $-90$,
+and leaving the correct space for the rotated box.
+\begin{example}
+Start here
+\begin{sideways}%
+Save the whale
+\end{sideways}
+End here
+\end{example}
+
+If you deal with whole paragraphs of text, you realize that \TeX\
+boxes are not as simple as they sometimes look: they have a height
+{\em and} a depth. So when you rotate, you rotate about the point on
+the left-hand edge of the box that meets the baseline. The results can
+be unexpected, as shown in the full set of paragraph rotations in
+Figures \ref{angles1} and \ref{angles2}. If you really want to turn a
+paragraph so that it appears to rotate about the {\em real} bottom of
+the \TeX\ box,
+you have to adjust the box in the normal \LaTeX\ way:
+\begin{example}
+\newsavebox{\foo}
+\savebox{\foo}{\parbox{1in}{Save
+the whales Save the whale
+Save the whale
+Save the whale}}%
+Start
+\begin{turn}{45}\usebox{\foo}\end{turn}
+End
+\end{example}
+\begin{example}
+\savebox{\foo}{\parbox[b]{1in}{Save
+the whales Save the whale
+Save the whale
+Save the whale}}%
+Start
+\begin{turn}{45}\usebox{\foo}\end{turn}
+End
+\end{example}
+
+\def\testrot#1{%
+\savebox{\foo}{\parbox{1in}{Save
+the whales Save the whale Save the whale Save the whale}}%
+\framebox{---\begin{turn}{#1}\framebox{\usebox{\foo}}\end{turn}---}}%
+
+\begin{figure*}
+\begin{tabular}{|c|c|c|}
+\hline
+\testrot{0} &\testrot{-40}&\testrot{-80}\\
+0\degrees & -40\degrees & -80\degrees \\
+\hline
+\testrot{-120}&\testrot{-160}&\testrot{-200}\\
+120\degrees & -160\degrees & -200\degrees \\
+\hline
+\testrot{-240}&\testrot{-280}&\testrot{-320}\\
+-240\degrees & -280\degrees & -320\degrees \\
+\hline
+\end{tabular}
+\caption{Rotation of paragraphs between 0 and -320 degrees \label{angles1}}
+\end{figure*}
+
+\begin{figure*}
+\begin{tabular}{|c|c|c|}
+\hline
+\testrot{-180} &\testrot{40}&\testrot{80}\\
+-180\degrees & 40\degrees & 80\degrees \\
+\hline
+\testrot{120}&\testrot{160}&\testrot{200}\\
+120\degrees & 160\degrees & 200\degrees \\
+\hline
+\testrot{240}&\testrot{280}&\testrot{320}\\
+240\degrees & 280\degrees & 320\degrees \\
+\hline
+\end{tabular}
+\caption{Rotation of paragraphs between 0 and 320 degrees\label{angles2}}
+\end{figure*}
+
+
+We can set tabular material in this way; at the same time, we
+demonstrate that the rotation can be nested:
+\begin{example}
+\begin{sideways}
+\rule{1in}{0pt}
+\begin{tabular}{|lr|}
+\em Word & \begin{rotate}{90}%
+Occurrences\end{rotate}
+\\
+\hline
+hello & 33\\
+goodbye & 34\\
+\hline
+\end{tabular}
+\end{sideways}
+\end{example}
+
+\begin{example}
+\begin{quote}
+\rule{0pt}{1.5in}\begin{tabular}{rrr}
+\begin{rotate}{45}Column 1\end{rotate}&
+\begin{rotate}{45}Column 2\end{rotate}&
+\begin{rotate}{45}Column 3\end{rotate}\\
+\hline
+1& 2& 3\\
+4& 5& 6\\
+7& 8& 9\\
+\hline
+\end{tabular}
+\end{quote}
+\end{example}
+
+\begin{example}
+\begin{quote}
+\begin{tabular}{rrr}
+\begin{turn}{45}Column 1\end{turn}&
+\begin{turn}{45}Column 2\end{turn}&
+\begin{turn}{45}Column 3\end{turn}\\
+\hline
+1& 2& 3\\
+4& 5& 6\\
+7& 8& 9\\
+\hline
+\end{tabular}
+\end{quote}
+\end{example}
+
+\begin{example}
+\begin{quote}
+\rule{0pt}{1.5in}\begin{tabular}{rrr}
+\begin{rotate}{45}Column 1\end{rotate}
+\rule{.5cm}{0pt}&
+\begin{rotate}{45}Column 2\end{rotate}
+\rule{.5cm}{0pt}&
+\begin{rotate}{45}Column 3\end{rotate}
+\rule{.5cm}{0pt}\\
+\hline
+1& 2& 3\\
+4& 5& 6\\
+7& 8& 9\\
+\hline
+\end{tabular}
+\end{quote}
+\end{example}
+
+\begin{example}
+\begin{sideways}
+\begin{tabular}{|l|c|c|c|c|c|p{1in}|}
+\hline
+&&\multicolumn{4}{c}{NUMBER OF SITES}\vline &ACCEPT or\\
+\cline{3-6} &STUDY AREA&&\multicolumn{3}{c}{%
+IN BOUNDARY ZONE}\vline&REJECT\\
+\cline{4-6}&&&&\multicolumn{2}{c}{EXPECTED}
+\vline&NULL\\
+\cline{5-6}&&TOT&OBS&FROM&TO&HYPOTH\\
+\cline{2-7}
+&FULL SAMPLE&41&31&10.3&27.0&REJECT\\
+&SAMPLE AREA 1&23&16&4.3&16.7&ACCEPT\\
+&SAMPLE AREA 2&18&15&2.8&13.7&REJECT\\
+&RUSHEN&13&9&1.2&10.4&ACCEPT\\
+&ARBORY&10&7&0.6&8.8&ACCEPT\\
+&MAROWN&10&8&0.4&8.6&ACCEPT\\
+\rule{0.5cm}{0pt}
+\begin{rotate}{90}PRIMARY UNITS%
+\end{rotate}\rule{0.5cm}{0pt}
+&SANTON&8&7&0.0&7.3&ACCEPT\\
+\hline
+\end{tabular}
+\end{sideways}
+\end{example}
+
+If you are interested in setting rotated material in tables or
+figures, this presents no problem. Figure \ref{fig1} shows how
+PostScript files which are being incorporated using can be
+rotated at will, while Figure \ref{fig2} shows, in contrast, how
+`includegraphics' itself handles rotation. It is also possible to rotate the
+whole of the figure environment, including caption,
+by using the `sidewaysfigure' ands `sidewaystable' environments
+in place of `figure' and `table'.
+
+Sideways figures and tables always take up the whole page. They can be
+rotated so that the bottom ot the figures is on the left or the right;
+the default is to always turn to the right. If the `twoside' option
+has been given to the main document class, this package then starts
+rotating sideways figures according to the page number (this requires
+two passes through \LaTeX{} at least). If you want the `twoside'
+option, but want the figures always in one direction, use the
+`figuresright' or `riguresleft' options to `rotating'.
+
+The code used to produce figures
+\ref{rotfloat1}--\ref{rotfloat4} is as follows:
+\begin{description}
+
+\item[Figure \ref{rotfloat1}]
+{\small\begin{verbatim}
+\begin{sidewaystable}
+\centering
+\caption{This is a narrow table, which should be centred vertically
+on the final page.\label{rotfloat1}}
+ \begin{tabular}{|ll|}
+\hline
+ a & b \\
+ c & d \\
+ e & f \\
+ g & h \\
+ i & j \\
+\hline
+ \end{tabular}
+\end{sidewaystable}
+\end{verbatim}
+}
+
+\item[Figure \ref{rotfloat2}]
+{\scriptsize\begin{verbatim}
+\begin{sidewaystable}
+\centering
+\begin{tabular}{|llllllllp{1in}lp{1in}|}
+\hline
+Context &Length &Breadth/ &Depth &Profile &Pottery &Flint &Animal &Stone &Other &C14 Dates \\
+ & &Diameter & & & & &
+Bones&&&\\
+\hline
+&&&&&&&&&&\\
+\multicolumn{10}{|l}{\bf Grooved Ware}&\\
+784 &--- &0.9m &0.18m &Sloping U &P1 &$\times$46 & $\times$8 && $\times$2 bone& 2150$\pm$ 100 BC\\
+785 &--- &1.00m &0.12 &Sloping U &P2--4 &$\times$23 & $\times$21 & Hammerstone &---&---\\
+962 &--- &1.37m &0.20m &Sloping U &P5--6 &$\times$48 & $\times$57* & ---& ---&1990 $\pm$ 80 BC (Layer 4) 1870 $\pm$90 BC (Layer 1)\\
+983 &0.83m &0.73m &0.25m &Stepped U &--- &$\times$18 & $\times$8 & ---& Fired clay&---\\
+&&&&&&&&&&\\
+\multicolumn{10}{|l}{\bf Beaker}&\\
+552 &--- &0.68m &0.12m &Saucer &P7--14 &--- & --- & --- &--- &---\\
+790 &--- &0.60m &0.25m &U &P15 &$\times$12 & --- & Quartzite-lump&--- &---\\
+794 &2.89m &0.75m &0.25m &Irreg. &P16 &$\times$3 & --- & --- &--- &---\\
+\hline
+\end{tabular}
+
+\caption[Grooved Ware and Beaker Features, their Finds and
+Radiocarbon Dates]{Grooved Ware and Beaker Features, their
+Finds and Radiocarbon Dates; For a breakdown of the Pottery
+Assemblages see Tables I and III; for
+the Flints see Tables II and IV; for the
+Animal Bones see Table V.}\label{rotfloat2}
+\end{sidewaystable}
+\end{verbatim}
+}
+
+\item[Figure \ref{rotfloat3}]
+{\small\begin{verbatim}
+\begin{table}
+\centering
+\rotcaption{Minimum number of individuals; effect of rotating table
+and caption separately}\label{rotfloat3}%
+\begin{sideways}
+\begin{tabular}[b]{cccccccccp{1cm}}
+\hline
+Phase&Total&Cattle&Sheep&Pig&Red Deer&Horse&Dog&Goat&Other\\
+\hline
+&1121&54&12&32&1&1&1&1&1 polecat\\
+3&8255&58&6&35&1&1&1&1&1 roe deer, 1 hare, 1 cat, 1 otter\\
+4&543&45&6&45&4&1&1&---&---\\
+\hline
+&9919&157&24&112&6&3&3&2&5\\
+\hline
+\end{tabular}
+\end{sideways}
+\end{table}
+\end{verbatim}
+}
+
+\item[Figure \ref{rotfloat4}]
+{\small\begin{verbatim}
+\begin{sidewaysfigure}
+ \centering
+ \includegraphics[width=.8\textheight,height=.4\textwidth]{cat}
+\caption{A pathetically squashed rotated pussycat}\label{rotfloat4}
+\end{sidewaysfigure}
+\end{verbatim}
+}
+\end{description}
+
+\begin{figure}
+\begin{example}
+---\begin{turn}{156}
+\includegraphics[width=1in]{cat}
+\end{turn}---
+\end{example}
+
+\begin{example}
+---\begin{sideways}
+\includegraphics[width=1in]{cat}
+\end{sideways}---
+\end{example}
+
+\begin{example}
+---\includegraphics[width=1in]{cat}---
+\end{example}
+\caption{A normal, and sideways, pictures within a figure\label{fig1}}
+\end{figure}
+
+\begin{figure}
+\begin{example}
+\includegraphics[width=1in,%
+angle=-56]{cat}
+\end{example}
+
+\caption{Figures rotated with `includegraphics'\label{fig2}}
+\end{figure}
+\begin{sidewaystable}
+\centering
+\caption{This is a narrow table, which should be centred vertically
+on the final page.\label{rotfloat1}}
+ \begin{tabular}{|ll|}
+\hline
+ a & b \\
+ c & d \\
+ e & f \\
+ g & h \\
+ i & j \\
+\hline
+ \end{tabular}
+\end{sidewaystable}
+
+
+
+\begin{sidewaystable}
+\centering
+\begin{tabular}{|llllllllp{1in}lp{1in}|}
+\hline
+Context &Length &Breadth/ &Depth &Profile &Pottery &Flint &Animal &Stone &Other &C14 Dates \\
+ & &Diameter & & & & &
+Bones&&&\\
+\hline
+&&&&&&&&&&\\
+\multicolumn{10}{|l}{\bf Grooved Ware}&\\
+784 &--- &0.9m &0.18m &Sloping U &P1 &$\times$46 & $\times$8 && $\times$2 bone& 2150$\pm$ 100 BC\\
+785 &--- &1.00m &0.12 &Sloping U &P2--4 &$\times$23 & $\times$21 & Hammerstone &---&---\\
+962 &--- &1.37m &0.20m &Sloping U &P5--6 &$\times$48 & $\times$57* & ---& ---&1990 $\pm$ 80 BC (Layer 4) 1870 $\pm$90 BC (Layer 1)\\
+983 &0.83m &0.73m &0.25m &Stepped U &--- &$\times$18 & $\times$8 & ---& Fired clay&---\\
+&&&&&&&&&&\\
+\multicolumn{10}{|l}{\bf Beaker}&\\
+552 &--- &0.68m &0.12m &Saucer &P7--14 &--- & --- & --- &--- &---\\
+790 &--- &0.60m &0.25m &U &P15 &$\times$12 & --- & Quartzite-lump&--- &---\\
+794 &2.89m &0.75m &0.25m &Irreg. &P16 &$\times$3 & --- & --- &--- &---\\
+\hline
+\end{tabular}
+
+\caption[Grooved Ware and Beaker Features, their Finds and
+Radiocarbon Dates]{Grooved Ware and Beaker Features, their
+Finds and Radiocarbon Dates; For a breakdown of the Pottery
+Assemblages see Tables I and III; for
+the Flints see Tables II and IV; for the
+Animal Bones see Table V.}\label{rotfloat2}
+\end{sidewaystable}
+
+\begin{table}
+\centering
+\hbox{
+\rotcaption{Minimum number of individuals; effect of rotating table
+and caption separately}\label{rotfloat3}%
+\begin{sideways}
+\begin{tabular}[t]{cccccccccp{1cm}}
+\hline
+Phase&Total&Cattle&Sheep&Pig&Red Deer&Horse&Dog&Goat&Other\\
+\hline
+&1121&54&12&32&1&1&1&1&1 polecat\\
+3&8255&58&6&35&1&1&1&1&1 roe deer, 1 hare, 1 cat, 1 otter\\
+4&543&45&6&45&4&1&1&---&---\\
+\hline
+&9919&157&24&112&6&3&3&2&5\\
+\hline
+\end{tabular}
+\end{sideways}
+}
+\end{table}
+
+
+\begin{sidewaysfigure}
+ \centerline{\includegraphics[width=.8\textheight,height=.4\textwidth]{cat}}
+\caption{A pathetically squashed rotated pussycat (1)}
+\end{sidewaysfigure}
+
+\begin{sidewaysfigure}
+ \centerline{\includegraphics[width=.8\textheight,height=.4\textwidth]{cat}}
+\caption{A pathetically squashed rotated pussycat (2)}
+\end{sidewaysfigure}
+
+\begin{sidewaysfigure}
+ \centerline{\includegraphics[width=.8\textheight,height=.4\textwidth]{cat}}
+\caption{A pathetically squashed rotated pussycat (3)}
+\end{sidewaysfigure}
+
+\begin{sidewaysfigure}
+ \centerline{\includegraphics[width=.8\textheight,height=.4\textwidth]{cat}}
+\caption{A pathetically squashed rotated pussycat (4)}
+\end{sidewaysfigure}
+
+\begin{sidewaysfigure}
+ \centerline{\includegraphics[width=.8\textheight,height=.4\textwidth]{cat}}
+\caption{A pathetically squashed rotated pussycat}\label{rotfloat4}
+\end{sidewaysfigure}
+
+\end{document}
diff --git a/macros/latex/required/graphics/trig.dtx b/macros/latex/required/graphics/trig.dtx
new file mode 100644
index 0000000000..712db13ba2
--- /dev/null
+++ b/macros/latex/required/graphics/trig.dtx
@@ -0,0 +1,329 @@
+% \iffalse
+%% File: trig.dtx Copyright (C) 1993 1994 1995 1996 1997 1999 David Carlisle
+%% Copyright (C) 2000--2015 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
+%% License, as described in lppl.txt in the base LaTeX distribution.
+%% Either version 1.3c or, at your option, any later version.
+%%
+%
+%<*dtx>
+ \ProvidesFile{trig.dtx}
+%</dtx>
+%<*!plain>
+%<package&!plain>\NeedsTeXFormat{LaTeX2e}
+%<package&!plain>\ProvidesPackage{trig}
+%<driver> \ProvidesFile{trig.drv}
+% \fi
+% \ProvidesFile{trig.dtx}
+ [2016/01/03 v1.10 sin cos tan (DPC)]
+%
+% \iffalse
+%</!plain>
+%<*driver>
+\documentclass{ltxdoc}
+\usepackage{trig}
+\begin{document}
+ \DocInput{trig.dtx}
+\end{document}
+%</driver>
+% \fi
+%
+% \GetFileInfo{trig.dtx}
+% \title{The \textsf{trig} package\thanks{This file
+% has version number \fileversion, last
+% revised \filedate.}}
+% \author{David Carlisle}
+% \date{\filedate}
+% \MaintainedByLaTeXTeam{graphics}
+% \maketitle
+%
+%
+% \changes{v1.00}{1993/00/00}{Undocumented versions}
+% \changes{v1.05}{1993/10/07}{Documented, added tan}
+% \changes{v1.06}{1994/02/01}{Update for LaTeX2e}
+% \changes{v1.07}{1994/03/15}{Use ltxdoc}
+% \changes{v1.08}{1994/10/16}{Change \cs{@xc} to \cs{nin@ty}}
+%
+% \section{Introduction}
+%
+% These macros implement the trigonometric functions, sin, cos and tan.
+% In each case two commands are defined. For instance the command
+% |\CalculateSin{33}| may be issued at some point, and then anywhere
+% later in the document, the command |\UseSin{33}| will return the
+% decimal expansion of $\sin(33^\circ)$.
+%
+% The arguments to these macros do not have to be whole numbers,
+% although in the case of whole numbers, \LaTeX\ or plain \TeX\ counters
+% may be used. In \TeX{}Book syntax, arguments must be of type:
+% \meta{optional signs}\meta{factor}
+%
+% Some other examples are:\\
+% |\CalculateSin{22.5}|, |\UseTan{\value{mycounter}}|,
+% |\UseCos{\count@}|.
+%
+% Note that unlike the psfig macros, these save all previously
+% computed values. This could easily be changed, but I thought that in
+% many applications one would want many instances of the
+% same value. (eg rotating all the headings of a table by the
+% \emph{same} amount).
+%
+% I don't really like this need to pre-calculate the values, I
+% originally implemented |\UseSin| so that it automatically calculated
+% the value if it was not pre-stored. This worked fine in testing, until
+% I remembered why one needs these values. You want to be able to say
+% |\dimen2=\UseSin{30}\dimen0|. Which means that |\UseSin| must
+% \emph{expand} to a \meta{factor}.
+%
+% \StopEventually{}
+%
+% \section{The Macros}
+%
+% \begin{macrocode}
+%<*package>
+% \end{macrocode}
+%
+% \begin{macro}{\nin@ty}\begin{macro}{\@clxx}
+% \begin{macro}{\@lxxi}\begin{macro}{\@mmmmlxviii}
+% Some useful constants for converting between degrees and radians.
+% $$\frac{\pi}{180}\simeq\frac{355}{113\times180}=\frac{71}{4068}$$
+% \begin{macrocode}
+\chardef\nin@ty=90
+\chardef\@clxx=180
+\chardef\@lxxi=71
+\mathchardef\@mmmmlxviii=4068
+% \end{macrocode}
+% \end{macro}\end{macro}\end{macro}\end{macro}
+%
+% The approximation to $\sin$. I experimented with various
+% approximations based on Tchebicheff polynomials, and also some
+% approximations from a SIAM handbook `Computer Approximations' However
+% the standard Taylor series seems sufficiently accurate, and used by
+% far the fewest \TeX\ tokens, as the coefficients are all rational.
+% \begin{eqnarray*}
+% \sin(x)& \simeq& x - (1/3!)x^3 + (1/5!)x^5 - (1/7!)x^7 + (1/9!)x^9\\
+% &\simeq&\frac{((((7!/9!x^2-7!/7!)x^2+7!/5!)x^2 +7!/3!)x^2+7!/1!)x}
+% {7!}\\
+% &=&\frac{((((1/72x^2-1)x^2+42)x^2 +840)x^2+5040)x}
+% {5040}
+% \end{eqnarray*}
+% The nested form used above reduces the number of operations required.
+% In order to further reduce the number of operations, and more
+% importantly reduce the number of tokens used, we can precompute the
+% coefficients. Note that we can not use $9!$ as the denominator as
+% this would cause overflow of \TeX's arithmetic.
+% \begin{macro}{\@coeffz}\begin{macro}{\@coeffa}\begin{macro}{\@coeffb}
+% \begin{macro}{\@coeffc}\begin{macro}{\@coeffd}
+% Save the coefficients as |\|(|math|)|char|s.
+% \begin{macrocode}
+\chardef\@coeffz=72
+%\chardef\@coefa=1
+\chardef\@coefb=42
+\mathchardef\@coefc=840
+\mathchardef\@coefd=5040
+% \end{macrocode}
+% \end{macro}\end{macro}\end{macro}\end{macro}\end{macro}
+%
+% \begin{macro}{\TG@rem@pt}
+% The standard trick of getting a real number out of a \meta{dimen}.
+% This gives a maximum accuracy of approx.\ 5 decimal places, which
+% should be sufficient. It puts a space after the number, perhaps it
+% shouldn't.
+% \begin{macrocode}
+{\catcode`t=12\catcode`p=12\gdef\noPT#1pt{#1}}
+\def\TG@rem@pt#1{\expandafter\noPT\the#1\space}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\TG@term}
+% Compute one term of the above nested series. Multiply the previous sum
+% by $x^2$ (stored in |\@tempb|, then add the next coefficient, |#1|.
+% \begin{macrocode}
+\def\TG@term#1{%
+ \dimen@\@tempb\dimen@
+ \advance\dimen@ #1\p@}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\TG@series}
+% Compute the above series. the value in degrees will be in |\dimen@|
+% before this is called.
+% \begin{macrocode}
+\def\TG@series{%
+ \dimen@\@lxxi\dimen@
+ \divide \dimen@ \@mmmmlxviii
+% \end{macrocode}
+% |\dimen@| now contains the angle in radians, as a \meta{dimen}. We
+% need to remove the units, so store the same value as a \meta{factor}
+% in |\@tempa|.
+% \begin{macrocode}
+ \edef\@tempa{\TG@rem@pt\dimen@}%
+% \end{macrocode}
+% Now put $x^2$ in |\dimen@| and |\@tempb|.
+% \begin{macrocode}
+ \dimen@\@tempa\dimen@
+ \edef\@tempb{\TG@rem@pt\dimen@}%
+% \end{macrocode}
+% The first coefficient is $1/72$.
+% \begin{macrocode}
+ \divide\dimen@\@coeffz
+ \advance\dimen@\m@ne\p@
+ \TG@term\@coefb
+ \TG@term{-\@coefc}%
+ \TG@term\@coefd
+% \end{macrocode}
+% Now the cubic in $x^2$ is completed, so we need to multiply by $x$ and
+% divide by $7!$.
+% \begin{macrocode}
+ \dimen@\@tempa\dimen@
+ \divide\dimen@ \@coefd}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\CalculateSin}
+% If this angle has already been computed, do nothing, else store the
+% angle, and call |\TG@@sin|.
+% \begin{macrocode}
+\def\CalculateSin#1{{%
+ \expandafter\ifx\csname sin(\number#1)\endcsname\relax
+ \dimen@=#1\p@\TG@@sin
+ \expandafter\xdef\csname sin(\number#1)\endcsname
+ {\TG@rem@pt\dimen@}%
+ \fi}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\CalculateCos}
+% As above, but use the relation $\cos(x) = \sin(90-x)$.
+% \begin{macrocode}
+\def\CalculateCos#1{{%
+ \expandafter\ifx\csname cos(\number#1)\endcsname\relax
+ \dimen@=\nin@ty\p@
+ \advance\dimen@-#1\p@
+ \TG@@sin
+ \expandafter\xdef\csname cos(\number#1)\endcsname
+ {\TG@rem@pt\dimen@}%
+ \fi}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\TG@reduce}
+% Repeatedly use one of the the relations
+% $\sin(x)=\sin(180-x)=\sin(-180-x)$ to get $x$ in the range $-90 \leq
+% x\leq 90$. Then call |\TG@series|.
+% \begin{macrocode}
+\def\TG@reduce#1#2{%
+\dimen@#1#2\nin@ty\p@
+ \advance\dimen@#2-\@clxx\p@
+ \dimen@-\dimen@
+ \TG@@sin}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\TG@@sin}
+% Slightly cryptic, but it seems to work\ldots
+% \begin{macrocode}
+\def\TG@@sin{%
+ \ifdim\TG@reduce>+%
+ \else\ifdim\TG@reduce<-%
+ \else\TG@series\fi\fi}%
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\UseSin}
+% \begin{macro}{\UseCos}
+% Use a pre-computed value.
+% \begin{macrocode}
+\def\UseSin#1{\csname sin(\number#1)\endcsname}
+\def\UseCos#1{\csname cos(\number#1)\endcsname}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% A few shortcuts to save space.
+% \changes{v1.10}{2016/01/03}{make these expand to digits so safe to use in ctm}
+% \begin{macrocode}
+\def\z@num{0 }
+\def\@tempa{1 }
+\def\@tempb{-1 }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\expandafter\let\csname sin(0)\endcsname\z@num
+\expandafter\let\csname cos(0)\endcsname\@tempa
+\expandafter\let\csname sin(90)\endcsname\@tempa
+\expandafter\let\csname cos(90)\endcsname\z@num
+\expandafter\let\csname sin(-90)\endcsname\@tempb
+\expandafter\let\csname cos(-90)\endcsname\z@num
+\expandafter\let\csname sin(180)\endcsname\z@num
+\expandafter\let\csname cos(180)\endcsname\@tempb
+% \end{macrocode}
+%
+% A few more added in 1.10 (previously in pdftex.def)
+% \begin{macrocode}
+\expandafter\let\csname sin(270)\endcsname\@tempb
+\expandafter\let\csname cos(270)\endcsname\z@num
+\expandafter\let\csname sin(360)\endcsname\z@num
+\expandafter\let\csname cos(360)\endcsname\@tempa
+\expandafter\let\csname sin(-180)\endcsname\z@num
+\expandafter\let\csname cos(-180)\endcsname\@tempb
+\expandafter\let\csname sin(-270)\endcsname\@tempa
+\expandafter\let\csname cos(-270)\endcsname\z@num
+\expandafter\let\csname sin(-360)\endcsname\z@num
+\expandafter\let\csname cos(-360)\endcsname\@tempa
+% \end{macrocode}
+%
+% \begin{macro}{\CalculateTan}
+% Originally I coded the Taylor series for tan, but it seems to be
+% more accurate to just take the ratio of the sine and cosine.
+% This is accurate to 4 decimal places for angles up to
+% $50^\circ$, after that the accuracy tails off, giving
+% 57.47894 instead of 57.2900 for $89^\circ$.
+% \begin{macrocode}
+\def\CalculateTan#1{{%
+ \expandafter\ifx\csname tan(\number#1)\endcsname\relax
+ \CalculateSin{#1}%
+ \CalculateCos{#1}%
+ \@tempdima\UseCos{#1}\p@
+ \divide\@tempdima\@iv
+ \@tempdimb\UseSin{#1}\p@
+ \@tempdimb\two@fourteen\@tempdimb
+ \divide\@tempdimb\@tempdima
+ \expandafter\xdef\csname tan(\number#1)\endcsname
+ {\TG@rem@pt\@tempdimb}%
+ \fi}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\UseTan}
+% Just like |\UseSin|.
+% \begin{macrocode}
+\def\UseTan#1{\csname tan(\number#1)\endcsname}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\two@fourteen}
+% \begin{macro}{\@iv}
+% two constants needed to keep the division within \TeX's range.
+% \begin{macrocode}
+\mathchardef\two@fourteen=16384
+\chardef\@iv=4
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% Predefine $\tan(\pm90)$ to be an error.
+% \begin{macrocode}
+\expandafter\def\csname tan(90)\endcsname{\errmessage{Infinite tan !}}
+\expandafter\let\csname tan(-90)\expandafter\endcsname
+ \csname tan(90)\endcsname
+% \end{macrocode}
+%
+% \begin{macrocode}
+%</package>
+% \end{macrocode}
+%
+% \Finale
+%
+\endinput
diff --git a/macros/latex/required/graphics/trig.pdf b/macros/latex/required/graphics/trig.pdf
new file mode 100644
index 0000000000..c851ce2a55
--- /dev/null
+++ b/macros/latex/required/graphics/trig.pdf
Binary files differ
diff --git a/macros/latex/required/latexbug/README.md b/macros/latex/required/latexbug/README.md
new file mode 100644
index 0000000000..4a0865f299
--- /dev/null
+++ b/macros/latex/required/latexbug/README.md
@@ -0,0 +1,2 @@
+# latexbug
+latexbug package required to sent bug reports to the LaTeX bug database
diff --git a/macros/latex/required/latexbug/changes.txt b/macros/latex/required/latexbug/changes.txt
new file mode 100644
index 0000000000..1effc259a4
--- /dev/null
+++ b/macros/latex/required/latexbug/changes.txt
@@ -0,0 +1,5 @@
+2018-12-31 <Frank.Mittelbach@latex-project.org>
+
+ * latexbug.dtx:
+ AMS classes are not supported by the LaTex team but by the AMS
+
diff --git a/macros/latex/required/latexbug/latexbug.dtx b/macros/latex/required/latexbug/latexbug.dtx
new file mode 100644
index 0000000000..907272c781
--- /dev/null
+++ b/macros/latex/required/latexbug/latexbug.dtx
@@ -0,0 +1,976 @@
+% \iffalse meta-comment
+%
+% Package latexbug for use with LaTeX2e
+%
+% Copyright 2016-2018
+%
+% The LaTeX3 Project and any individual authors listed elsewhere
+% in this file.
+%
+% This file is part of the Standard LaTeX (separate distribution)
+% ---------------------------------------------------------------
+%
+% 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.
+%
+% This file has the LPPL maintenance status "maintained".
+%
+%
+% \fi
+%
+% \title{The \texttt{latexbug} package\thanks{This file
+% has version number \fileversion, last
+% revised \filedate.}}
+% \author{The \LaTeX{} Team} ^^A Frank Mittelbach
+% \date{\filedate}
+%
+% \MaintainedByLaTeXTeam{latex}
+%
+% \maketitle
+%
+%
+% \section{Introduction}
+%
+% Software has bugs and \LaTeX{} unfortunately is no exception. If
+% somebody encounters a bug then it helps if that bug gets reported to
+% the right people so that the bug can be resolved (or a workaround
+% documented or whatever is most appropriate). The problem is to know
+% to whom to report the bug.
+%
+% The \LaTeX{} Project Team maintains a bug database for its own code
+% base (which consists of the \LaTeX{} kernel and some packages that
+% have been written by people in the \LaTeX{} Project
+% Team). However, the \LaTeX{} universe consists of several thousand
+% contributed packages maintained by individuals all over the
+% world. And if a bug happens in one of those packages it doesn't help
+% anybody if it is dumped at the \LaTeX{} Project's doorstep.
+%
+% For one, we can't actually change other people's code even if we are able to
+% identify the issue. Furthermore we are only a few people and simply
+% do not have the bandwidth to analyze bugs in other people's work.
+%
+% We have therefore written this little package called
+% \texttt{latexbug} that should help in identifying the rightful
+% addressee for a bug report. We ask that it will be loaded in any
+% test file that is intended to be sent to the \LaTeX{} bug database
+% as part of a bug report.
+%
+% The package will determine if the test file is in a suitable state
+% to be sent to us or if it should be modified first or if it should be
+% sent to somebody
+% else because the bug is (likely) to be in code not maintained by the
+% \LaTeX{} Project Team.
+%
+% Bug reports sent to the \LaTeX{} bug database
+% without that prior verification are likely to
+% get closed without being looked at at our end in the future.
+%
+%
+%
+% \section{The user interface}
+%
+% The user interface is simple: the package has no option and doesn't
+% define any new commands to be used. All that is required is that the
+% package is loaded as the very first step in the test file that shows
+% the bug --- in other words before the \verb=\documentclass=.
+% For that reason it
+% must be loaded using \verb=\RequirePackage= instead of the usual
+% \verb=\usepackage= that is used in the preamble of a document.
+%
+% Thus, a bug report test files should look like this:
+% \begin{verbatim}
+% \RequirePackage{latexbug} % <- required first line
+% % followed by:
+% \documentclass{article} % or some other class
+% % followed by:
+% ... % <- code showing the bug ...
+% \end{document}
+% \end{verbatim}
+%
+% If the test file runs through (showing the bug) without any
+% complains for \texttt{latexbug} then the test file is ready to be
+% sent to the \LaTeX{} bug database. The procedure for uploading and
+% the location is documented at
+% \begin{quote}
+% \texttt{https://www.latex-project.org/bugs/}
+% \end{quote}
+% If \texttt{latexbug} does generate an error, however, then this
+% error needs to be addressed first and the depending on the
+% resolution the bug report may has to be sent to somebody else.
+%
+% An error is generated if the test file makes use of third-party code
+% that is not maintained by the \LaTeX{} Project Team. For example, if
+% the file would load \texttt{geometry}, \texttt{footmisc} and
+% \texttt{hyperref} you
+% would see the following:
+% \begin{verbatim}
+% Package latexbug Error: Third-party file(s)
+% (latexbug)
+% (latexbug) This test file uses third-party file(s)
+% (latexbug)
+% (latexbug) ==============
+% (latexbug) geometry.sty -> Hideo Umeki
+% (latexbug) <latexgeometry [at] gmail [dot] com>
+% (latexbug) footmisc.sty
+% (latexbug) hyperref.sty -> Heiko Oberdiek
+% (latexbug) https://github.com/ho-tex/hyperref/issues
+% (latexbug) ==============
+% (latexbug)
+% \end{verbatim}
+% It then continues with advice to remove such third-party code from the
+% test file. If that is not possible, because the bug goes away if a
+% package is removed, then the problem is (most likely) with this
+% package and the bug report should be sent to the maintainer of that
+% package and not to the \LaTeX{} bug database.
+% \begin{verbatim}
+% (latexbug) So you should contact the authors
+% (latexbug) of these files, not the LaTeX Team!
+% (latexbug) (Or remove the packages that load
+% (latexbug) them, if they are not necessary to
+% (latexbug) exhibit the problem).
+% \end{verbatim}
+% To make life somewhat easier \texttt{latexbug} will tell you the
+% name of the maintainer (if we know it and have added it in) and if
+% possible also the canonical bug address for the package (like in the
+% case of \texttt{geometry} and \texttt{hyperref}).
+% If we don't have that information, you
+% need to find it out for yourself by looking at the package
+% documentation.
+%
+% There may be cases where third-party code is essential to exhibit
+% a bug in core \LaTeX{} code maintained by the the \LaTeX{} Team. The
+% error text therefore finishes off with the following sentence:
+% \begin{verbatim}
+% (latexbug) If you think the bug is in core LaTeX
+% (latexbug) (as maintained by the LaTeX Team) but
+% (latexbug) these files are needed to demonstrate
+% (latexbug) the problem, please continue and mention
+% (latexbug) this explicitly in your bug report
+% (latexbug) (with an explanation why you think so).
+% \end{verbatim}
+% Please explain your reasoning why you think this is the case in
+% detail as part of the bug report.
+%
+% \vspace*{1ex}
+%
+% \begin{center}
+% \fbox{\fbox{\parbox{.6\textwidth}{\itshape Thank you for taking
+% the time to report a bug and prepare a test
+% file showing it!}}}
+% \end{center}
+%
+% \vspace*{3ex}
+%
+%
+% \subsection{A note on the database content in the package}
+%
+% When a document is run through \LaTeX{} it will load a number of
+% files and bug reports that are to be sent to the \LaTeX{} Team should only
+% load files that we maintain and not third-party packages.
+%
+% The database, if you want to call that, inside \texttt{latexbug} is
+% simply a comma separated key value list consisting of file names
+% \texttt{=} maintainer info. Most of the time the maintainer info is
+% \texttt{us} or \texttt{us*} (meaning we maintain it, so the file is
+% fine) or \texttt{ignore} (meaning we do not maintain it, but it is a
+% file that is likely to appear for one or the other reason and we
+% should accept such a bug report nonetheless).
+%
+% Any file loaded in the bug report not listed will show up in the
+% error listing flagged as ``third-party'' code that should be removed
+% as explained above.
+%
+% For a small number of popular third-party packages we have collected
+% the name of the external maintainer and if available to us some
+% extra info so that it is easier to send to the rightful addressee if
+% you encounter a bug in such a third-party package. But to keep this
+% manageable this is only done for a very small number of the 5000+
+% packages out there (though we might add one or the other over time).
+%
+% It is however not impossible that we missed one or the other file
+% that should have been listed as ``maintained by us'' but isn't and
+% thus incorrectly generates an error. If you run into that problem or
+% notice an omission of that sort, please send us a bug report or open
+% an issue at the GitHub source of the package which is located at:
+% \begin{quote}
+% \texttt{https://github.com/latex3/latexbug/}
+% \end{quote}
+%
+%
+% \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
+% \texttt{docstrip} program.
+% \begin{macrocode}
+%<*driver>
+\RequirePackage{latexbug}
+\documentclass{ltxdoc}
+\GetFileInfo{latexbug.sty}
+%\usepackage{geometry,footmisc,hyperref} % uncomment for latexbug error
+%\usepackage{xparse} % uncomment for latexbug error
+\EnableCrossrefs
+%\DisableCrossrefs % Say \DisableCrossrefs if index is ready
+%\OnlyDescription % Comment out for implementation details
+\begin{document}
+ \DocInput{latexbug.dtx}
+\end{document}
+%</driver>
+% \end{macrocode}
+%
+% \section{The implementation}
+%
+% \begin{macrocode}
+%<*package>
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{latexbug}[2018/12/31 v1.0e Bug-classification]
+% \end{macrocode}
+%
+% \begin{macro}{\latexbug@empty}
+% \begin{macro}{\latexbug@us}
+% \begin{macro}{\latexbug@ustar}
+% \begin{macro}{\latexbug@ignore}
+% Fixed text used in checking what actions to take with different files.
+% \begin{macrocode}
+\def\latexbug@empty{}
+\def\latexbug@us{us}
+\def\latexbug@usstar{us*}
+\def\latexbug@ignore{ignore}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\Contact}
+% A very simple piece of markup, really.
+% \begin{macrocode}
+\def\Contact{\MessageBreak \@spaces}
+% \end{macrocode}
+% \end{macro}
+%
+% The database of packages is set up in a group so we can throw away the
+% loop command.
+% \begin{macrocode}
+\begingroup
+% \end{macrocode}
+%
+% \begin{macro}{\latexbug@loop}
+% A simple loop set up which reads a known format for the file-to-maintainer
+% mapping. The trailing space is important (stripping it is not really worth
+% it for this very limited use case).
+% \begin{macrocode}
+\long\def\latexbug@loop #1 = #2 , {% spaces matter
+ \global\@namedef{latexbug@@#1}{#2}%
+ \ifx\latexbug@empty#1\else\expandafter\latexbug@loop\fi}
+% \end{macrocode}
+% \end{macro}
+%
+% A simple database of files. The value \texttt{us} means we accept
+% bugs for it. We also take bug reports for \texttt{us*} (expl3) entries, but
+% they need to go to a different GitHub repository, so are handled separately
+% (and only show up
+% if there doesn't seem to be anything else to pick up). A value of
+% \texttt{ignore} means that its not our code, but we understand that it may
+% show up in legitimate test files and should therefore not trigger an error.
+%
+% Any file not in there will trigger an error if loaded and any file
+% in there with some other value than \texttt{us} or \texttt{ignore}
+% will also trigger an error displaying the value (which hopefully is
+% the maintainers name). (Handling for \texttt{us*} means these files may
+% not show up, depending on the nature of the use case.)
+%
+% \begin{quote} \itshape
+% The database format is somewhat fragile: one needs to have a space on both sides
+% of the equal sign (or one gets a nasty low-level error) and names can't have
+% no-ascii characters in them, so they end up crippled (sorry for that).
+% \end{quote}
+%
+% \begin{macrocode}
+\latexbug@loop
+%---------------------------------
+latexbug.sty = us ,
+regression-test = us ,
+%--------------------------------- base
+alltt.sty = us ,
+ansinew.def = us ,
+applemac.def = us ,
+article.cls = us ,
+article.sty = us ,
+ascii.def = us ,
+bezier.sty = us ,
+bk10.clo = us ,
+bk11.clo = us ,
+bk12.clo = us ,
+book.cls = us ,
+book.sty = us ,
+cp1250.def = us ,
+cp1252.def = us ,
+cp1257.def = us ,
+cp437.def = us ,
+cp437de.def = us ,
+cp850.def = us ,
+cp852.def = us ,
+cp858.def = us ,
+cp865.def = us ,
+decmulti.def = us ,
+doc.sty = us ,
+docstrip.tex = us ,
+exscale.sty = us ,
+fix-cm.sty = us ,
+fixltx2e.sty = us ,
+flafter.sty = us ,
+fleqn.clo = us ,
+fleqn.sty = us ,
+fltrace.sty = us ,
+fontenc.sty = us ,
+fontmath.cfg = us ,
+fontmath.ltx = us ,
+fonttext.cfg = us ,
+fonttext.ltx = us ,
+graphpap.sty = us ,
+hyphen.ltx = us ,
+idx.tex = us ,
+ifthen.sty = us ,
+inputenc.sty = us ,
+lablst.tex = us ,
+latex.ltx = us ,
+latex209.def = us ,
+latexbug.tex = us ,
+latexrelease.sty = us ,
+latexsym.sty = us ,
+latin1.def = us ,
+latin10.def = us ,
+latin2.def = us ,
+latin3.def = us ,
+latin4.def = us ,
+latin5.def = us ,
+latin9.def = us ,
+lcyenc.dfu = us ,
+leqno.clo = us ,
+leqno.sty = us ,
+letter.cls = us ,
+letter.sty = us ,
+lppl.tex = us ,
+ltluatex.lua = us ,
+ltluatex.tex = us ,
+ltnews.cls = us ,
+ltxcheck.tex = us ,
+ltxdoc.cls = us ,
+ltxguide.cls = us ,
+ly1enc.dfu = us ,
+macce.def = us ,
+makeidx.sty = us ,
+minimal.cls = us ,
+newlfont.sty = us ,
+next.def = us ,
+nfssfont.tex = us ,
+oldlfont.sty = us ,
+omlcmm.fd = us ,
+omlcmr.fd = us ,
+omlenc.def = us ,
+omllcmm.fd = us ,
+omscmr.fd = us ,
+omscmsy.fd = us ,
+omsenc.def = us ,
+omsenc.dfu = us ,
+omslcmsy.fd = us ,
+omxcmex.fd = us ,
+omxlcmex.fd = us ,
+openbib.sty = us ,
+ot1cmdh.fd = us ,
+ot1cmfib.fd = us ,
+ot1cmfr.fd = us ,
+ot1cmr.fd = us ,
+ot1cmss.fd = us ,
+ot1cmtt.fd = us ,
+ot1cmvtt.fd = us ,
+ot1enc.def = us ,
+ot1enc.dfu = us ,
+ot1lcmss.fd = us ,
+ot1lcmtt.fd = us ,
+ot2enc.dfu = us ,
+ot4enc.def = us ,
+preload.cfg = us ,
+preload.ltx = us ,
+proc.cls = us ,
+proc.sty = us ,
+report.cls = us ,
+report.sty = us ,
+sample2e.tex = us ,
+sfonts.def = us ,
+shortvrb.sty = us ,
+showidx.sty = us ,
+size10.clo = us ,
+size11.clo = us ,
+size12.clo = us ,
+slides.cls = us ,
+slides.def = us ,
+slides.sty = us ,
+small2e.tex = us ,
+source2e.tex = us ,
+syntonly.sty = us ,
+t1cmdh.fd = us ,
+t1cmfib.fd = us ,
+t1cmfr.fd = us ,
+t1cmr.fd = us ,
+t1cmss.fd = us ,
+t1cmtt.fd = us ,
+t1cmvtt.fd = us ,
+t1enc.def = us ,
+t1enc.dfu = us ,
+t1enc.sty = us ,
+t1lcmss.fd = us ,
+t1lcmtt.fd = us ,
+t2aenc.dfu = us ,
+t2benc.dfu = us ,
+t2cenc.dfu = us ,
+testpage.tex = us ,
+texsys.cfg = us ,
+textcomp.sty = us ,
+tracefnt.sty = us ,
+ts1cmr.fd = us ,
+ts1cmss.fd = us ,
+ts1cmtt.fd = us ,
+ts1cmvtt.fd = us ,
+ts1enc.def = us ,
+ts1enc.dfu = us ,
+ucmr.fd = us ,
+ucmss.fd = us ,
+ucmtt.fd = us ,
+ulasy.fd = us ,
+ullasy.fd = us ,
+utf8-test.tex = us ,
+utf8.def = us ,
+utf8enc.dfu = us ,
+utf8test.tex = us ,
+x2enc.dfu = us ,
+%--------------------------------- tools
+afterpage.sty = us ,
+array.sty = us ,
+bm.sty = us ,
+calc.sty = us ,
+dcolumn.sty = us ,
+delarray.sty = us ,
+e.tex = us ,
+enumerate.sty = us ,
+fontsmpl.sty = us ,
+fontsmpl.tex = us ,
+ftnright.sty = us ,
+h.tex = us ,
+hhline.sty = us ,
+indentfirst.sty = us ,
+layout.sty = us ,
+longtable.sty = us ,
+multicol.sty = us ,
+q.tex = us ,
+r.tex = us ,
+rawfonts.sty = us ,
+s.tex = us ,
+showkeys.sty = us ,
+somedefs.sty = us ,
+tabularx.sty = us ,
+thb.sty = us ,
+thc.sty = us ,
+thcb.sty = us ,
+theorem.sty = us ,
+thm.sty = us ,
+thmb.sty = us ,
+thp.sty = us ,
+trace.sty = us ,
+varioref.sty = us ,
+verbatim.sty = us ,
+verbtest.tex = us ,
+x.tex = us ,
+xr.sty = us ,
+xspace.sty = us ,
+%--------------------------------- babel (part supported by us)
+UKenglish.sty = us ,
+USenglish.sty = us ,
+afrikaans.sty = us ,
+albanian.sty = us ,
+american.sty = us ,
+austrian.sty = us ,
+babel.def = us ,
+babel.sty = us ,
+bahasa.sty = us ,
+bahasam.sty = us ,
+basque.sty = us ,
+blplain.tex = us ,
+bplain.tex = us ,
+breton.sty = us ,
+british.sty = us ,
+bulgarian.sty = us ,
+catalan.sty = us ,
+croatian.sty = us ,
+czech.sty = us ,
+danish.sty = us ,
+dutch.sty = us ,
+english.sty = us ,
+esperanto.sty = us ,
+estonian.sty = us ,
+finnish.sty = us ,
+francais.sty = us ,
+galician.sty = us ,
+germanb.sty = us ,
+greek.sty = us ,
+hebrew.sty = us ,
+hyphen.cfg = us ,
+icelandic.sty = us ,
+interlingua.sty = us ,
+irish.sty = us ,
+italian.sty = us ,
+latin.sty = us ,
+lsorbian.sty = us ,
+luababel.def = us ,
+magyar.sty = us ,
+naustrian.sty = us ,
+ngermanb.sty = us ,
+nil.ldf = us ,
+norsk.sty = us ,
+plain.def = us ,
+polish.sty = us ,
+portuges.sty = us ,
+romanian.sty = us ,
+russianb.sty = us ,
+samin.sty = us ,
+scottish.sty = us ,
+serbian.sty = us ,
+slovak.sty = us ,
+slovene.sty = us ,
+spanish.sty = us ,
+swedish.sty = us ,
+switch.def = us ,
+turkish.sty = us ,
+ukraineb.sty = us ,
+usorbian.sty = us ,
+welsh.sty = us ,
+xebabel.def = us ,
+%--------------------------------- graphics
+color.cfg = us ,
+color.sty = us ,
+dvipdf.def = us ,
+dvipdfmx.def = us ,
+dvips.def = us ,
+dvipsnam.def = us ,
+dvipsone.def = us ,
+dviwin.def = us ,
+emtex.def = us ,
+epsfig.sty = us ,
+graphics.cfg = us ,
+graphics.sty = us ,
+graphicx.sty = us ,
+keyval.sty = us ,
+lscape.sty = us ,
+luatex.def = us ,
+pctex32.def = us ,
+pctexhp.def = us ,
+pctexps.def = us ,
+pctexwin.def = us ,
+pdftex.def = us ,
+pdftex.def = us ,
+tcidvi.def = us ,
+trig.sty = us ,
+truetex.def = us ,
+xetex.def = us ,
+%--------------------------------- mfnfss
+oldgerm.sty = us ,
+ot1panr.fd = us ,
+ot1pss.fd = us ,
+pandora.sty = us ,
+uyfrak.fd = us ,
+uygoth.fd = us ,
+uyinit.fd = us ,
+uyswab.fd = us ,
+%--------------------------------- amsmath
+amsbsy.sty = us ,
+amscd.sty = us ,
+amsgen.sty = us ,
+amsmath.sty = us ,
+amsopn.sty = us ,
+amstex.sty = us ,
+amstext.sty = us ,
+amsxtra.sty = us ,
+%--------------------------------- amscls (AMS)
+amsart.cls = American Mathematical Society \Contact tech-support [at] ams [dot] org ,
+amsbook.cls = American Mathematical Society \Contact tech-support [at] ams [dot] org ,
+amsbooka.sty = American Mathematical Society \Contact tech-support [at] ams [dot] org ,
+amsdtx.cls = American Mathematical Society \Contact tech-support [at] ams [dot] org ,
+amsldoc.cls = American Mathematical Society \Contact tech-support [at] ams [dot] org ,
+amsmidx.sty = American Mathematical Society \Contact tech-support [at] ams [dot] org ,
+amsproc.cls = American Mathematical Society \Contact tech-support [at] ams [dot] org ,
+amsthm.sty = American Mathematical Society \Contact tech-support [at] ams [dot] org ,
+upref.sty = American Mathematical Society \Contact tech-support [at] ams [dot] org ,
+%--------------------------------- amsfonts (AMS)
+amsfonts.sty = American Mathematical Society \Contact tech-support [at] ams [dot] org ,
+amssymb.sty = American Mathematical Society \Contact tech-support [at] ams [dot] org ,
+cmmib57.sty = American Mathematical Society \Contact tech-support [at] ams [dot] org ,
+eucal.sty = American Mathematical Society \Contact tech-support [at] ams [dot] org ,
+eufrak.sty = American Mathematical Society \Contact tech-support [at] ams [dot] org ,
+euscript.sty = American Mathematical Society \Contact tech-support [at] ams [dot] org ,
+ueuex.fd = ignore ,
+ueuf.fd = ignore ,
+ueur.fd = ignore ,
+ueus.fd = ignore ,
+umsa.fd = ignore ,
+umsb.fd = ignore ,
+%--------------------------------- psnfss
+8rbch.fd = us ,
+8rpag.fd = us ,
+8rpbk.fd = us ,
+8rpcr.fd = us ,
+8rphv.fd = us ,
+8rpnc.fd = us ,
+8rppl.fd = us ,
+8rptm.fd = us ,
+8rput.fd = us ,
+8rpzc.fd = us ,
+avant.sty = us ,
+bookman.sty = us ,
+chancery.sty = us ,
+charter.sty = us ,
+courier.sty = us ,
+helvet.sty = us ,
+mathpazo.sty = us ,
+mathpple.sty = us ,
+mathptm.sty = us ,
+mathptmx.sty = us ,
+newcent.sty = us ,
+omlbch.fd = us ,
+omlpag.fd = us ,
+omlpbk.fd = us ,
+omlpcr.fd = us ,
+omlphv.fd = us ,
+omlpnc.fd = us ,
+omlppl.fd = us ,
+omlptm.fd = us ,
+omlptmcm.fd = us ,
+omlput.fd = us ,
+omlpzc.fd = us ,
+omlzplm.fd = us ,
+omlzpple.fd = us ,
+omlztmcm.fd = us ,
+omsbch.fd = us ,
+omspag.fd = us ,
+omspbk.fd = us ,
+omspcr.fd = us ,
+omsphv.fd = us ,
+omspnc.fd = us ,
+omsppl.fd = us ,
+omsptm.fd = us ,
+omsput.fd = us ,
+omspzc.fd = us ,
+omspzccm.fd = us ,
+omszplm.fd = us ,
+omszpple.fd = us ,
+omsztmcm.fd = us ,
+omxpsycm.fd = us ,
+omxzplm.fd = us ,
+omxzpple.fd = us ,
+omxztmcm.fd = us ,
+ot1bch.fd = us ,
+ot1pag.fd = us ,
+ot1pbk.fd = us ,
+ot1pcr.fd = us ,
+ot1phv.fd = us ,
+ot1pnc.fd = us ,
+ot1ppl.fd = us ,
+ot1pplj.fd = us ,
+ot1pplx.fd = us ,
+ot1ptm.fd = us ,
+ot1ptmcm.fd = us ,
+ot1put.fd = us ,
+ot1pzc.fd = us ,
+ot1zplm.fd = us ,
+ot1zpple.fd = us ,
+ot1ztmcm.fd = us ,
+palatino.sty = us ,
+pifont.sty = us ,
+t1bch.fd = us ,
+t1pag.fd = us ,
+t1pbk.fd = us ,
+t1pcr.fd = us ,
+t1phv.fd = us ,
+t1pnc.fd = us ,
+t1ppl.fd = us ,
+t1pplj.fd = us ,
+t1pplx.fd = us ,
+t1ptm.fd = us ,
+t1put.fd = us ,
+t1pzc.fd = us ,
+times.sty = us ,
+ts1bch.fd = us ,
+ts1pag.fd = us ,
+ts1pbk.fd = us ,
+ts1pcr.fd = us ,
+ts1phv.fd = us ,
+ts1pnc.fd = us ,
+ts1ppl.fd = us ,
+ts1pplj.fd = us ,
+ts1pplx.fd = us ,
+ts1ptm.fd = us ,
+ts1put.fd = us ,
+ts1pzc.fd = us ,
+ufplm.fd = us ,
+ufplmbb.fd = us ,
+upsy.fd = us ,
+upzd.fd = us ,
+utopia.sty = us ,
+%--------------------------------- expl3
+expl3.sty = us* ,
+l3sort.sty = us* ,
+l3regex.sty = us* ,
+l3tl-analysis.sty = us* ,
+xfrac.sty = us* ,
+xparse.sty = us* ,
+xtemplate.sty = us* ,
+xfrac.sty = us* ,
+xcoffins.sty = us* ,
+xgalley.sty = us* ,
+l3keys2e.sty = us* ,
+expl3-code.tex = ignore ,
+%--------------------------------- USEFUL FOR BUG REPORTS
+blindtext.sty = ignore ,
+etoolbox.sty = ignore ,
+lipsum.sty = ignore ,
+%--------------------------------- EXTERNALLY SUPPORTED
+%
+beamer.cls = Joseph Wright
+ \Contact https://github.com/josephwright/beamer/issues ,
+fontspec.sty = Will Robertson
+ \Contact https://github.com/wspr/fontspec/issues ,
+geometry.sty = Hideo Umeki
+ \Contact <latexgeometry [at] gmail [dot] com> ,
+hpdftex.def = ignore ,
+hluatex.def = ignore ,
+hxetex.def = ignore ,
+hyperref.cfg = ignore ,
+hyperref.sty = Heiko Oberdiek
+ \Contact https://github.com/ho-tex/hyperref/issues ,
+luatex85.sty = Joseph Wright
+ \Contact https://github.com/josephwright/luatex85/issues ,
+pd1enc.def = ignore ,
+puenc.def = ignore ,
+siunitx.sty = Joseph Wright
+ \Contact https://github.com/josephwright/siunitx/issues ,
+%--------------------------------- babel external
+basque.ldf = Juan M. Aguirregabiria
+ \Contact <http://tp.lc.ehu.es/jma.html> ,
+belarusian.ldf = Aleksey Novodvorsky, Andrew Shadura
+ \Contact <andrew [at] shadura [dot] me> ,
+bosnian.ldf = Samir Halilcevic %% HalilÄević
+ \Contact <samir [dot] halilcevic [at] fet [dot] ba> ,
+bulgarian.ldf = Georgi N. Boshnakov
+ \Contact <Georgi Boshnakov [at] manchester [dot] ac [dot] uk> ,
+croatian.ldf = Ivan Kokan
+ \Contact <ivan [dot] kokan [at] gmail [dot] com> ,
+estonian.ldf = Jaan Vajakas
+ \Contact <jaanvajakas [at] hot [dot] ee> ,
+frenchb.ldf = Daniel Flipo
+ \Contact <daniel [dot] flipo [at] free [dot] fr> ,
+friulan.ldf = Claudio Beccari
+ \Contact <claudio [dot] beccari [at] gmail [dot] com> ,
+georgian.ldf = Levan Shoshiashvili
+ \Contact <shoshia [at] hotmail [dot] com> ,
+austrian.ldf = Juergen Spitzmueller
+ \Contact <juergen [at] spitzmueller [dot] org> ,
+german.ldf = Juergen Spitzmueller
+ \Contact <juergen [at] spitzmueller [dot] org> ,
+germanb.ldf = Juergen Spitzmueller
+ \Contact <juergen [at] spitzmueller [dot] org> ,
+naustrian.ldf = Juergen Spitzmueller
+ \Contact <juergen [at] spitzmueller [dot] org> ,
+ngerman.ldf = Juergen Spitzmueller
+ \Contact <juergen [at] spitzmueller [dot] org> ,
+ngermanb.ldf = Juergen Spitzmueller
+ \Contact <juergen [at] spitzmueller [dot] org> ,
+nswissgerman.ldf = Juergen Spitzmueller
+ \Contact <juergen [at] spitzmueller [dot] org> ,
+swissgerman.ldf = Juergen Spitzmueller
+ \Contact <juergen [at] spitzmueller [dot] org> ,
+greek.ldf = Guenter Milde
+ \Contact <milde [at] users [dot] sf [dot] net> ,
+magyar.ldf = Peter Szabo %% Péter Szabó
+ \Contact <http://www.math.bme.hu/latex/> ,
+italian.ldf = Claudio Beccari
+ \Contact <claudio [dot] beccari [at] gmail [dot] com> ,
+japanese.ldf = Japanese TEX Development Community
+ \Contact <https://github.com/texjporg/babel-japanese> ,
+latin.ldf = Claudio Beccari
+ \Contact <claudio [dot] beccari [at] gmail [dot] com> ,
+macedonian.ldf = Stojan Trajanovski
+ \Contact <stojan [dot] trajanovski [at] gmail [dot] com> ,
+occitan.ldf = Cedric Valmary %% Cédric Valmary
+ \Contact <cvalmary [at] yahoo [dot] fr> ,
+piedmontese.ldf = Claudio Beccari
+ \Contact <claudio [dot] beccari [at] gmail [dot] com> ,
+pinyin.ldf = Werner Lemberg
+ \Contact <wl [at] gnu [dot] org> ,
+romansh.ldf = Claudio Beccari
+ \Contact <claudio [dot] beccari [at] gmail [dot] com> ,
+russain.ldf = Igor A [dot] Kotelnikov
+ \Contact <kia999 [at] mail [dot] ru> ,
+serbianc.ldf = Filip Brcic
+ \Contact <brcha [at] users [dot] sourceforge [dot] net> ,
+spanglish.ldf = J [dot] Luis Rivera
+ \Contact <jlrn77 [at] gmail [dot] com> ,
+spanish.ldf = Javier Bezos
+ \Contact <http://www.texnia.com/contact.html> ,
+thaicjk.ldf = Werner Lemberg
+ \Contact <wl [at] gnu [dot] org> ,
+ukraineb.ldf = Sergiy Ponomarenko
+ \Contact <sergiy [dot] pono­marenko [at] gmail [dot] com> ,
+vietnamese.ldf = Werner Lemberg
+ \Contact <wl [at] gnu [dot] org> ,
+%--------------------------------- LAST LINE
+{\latexbug@empty} = {} ,
+% \end{macrocode}
+%
+% Keep the data but throw away the loop function.
+% \begin{macrocode}
+\endgroup
+% \end{macrocode}
+%
+% \begin{macro}{\latexbug@addtofilelist}
+% Save the kernel version of \cs{@addtofilelist}.
+% \begin{macrocode}
+\let\latexbug@addtofilelist\@addtofilelist
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\latexbug@zzzz}
+% \begin{macro}{\latexbug@expl}
+% Storage for third-party files and those from the \LaTeX3 set on GitHub.
+% \begin{macrocode}
+\def\latexbug@zzzz{}
+\def\latexbug@expl{}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\latexbug@process@table}
+% \begin{macro}{\process@table}
+% A hook into a convenient place in the document set up: the
+% initialization of NFSS during the \cs{document} macro. If either
+% \cs{latexbug@zzzz} or \cs{latexbug@expl} have any content then there is
+% a message to issue, it's just a question of deciding which one.
+% \begin{macrocode}
+\let\latexbug@process@table\process@table
+\def\process@table{\global\let\@addtofilelist\latexbug@addtofilelist
+ \latexbug@process@table
+ \ifx\latexbug@zzzz\latexbug@empty
+ \ifx\latexbug@expl\latexbug@empty
+ \else
+ \PackageError{latexbug}%
+ {LaTeX3 file(s)\MessageBreak
+\MessageBreak
+This test files uses the LaTeX3 file(s)\MessageBreak
+\MessageBreak
+ ==============\MessageBreak
+ \latexbug@expl
+ ==============\MessageBreak
+ \MessageBreak
+You should report bugs in these packages\MessageBreak
+at the LaTeX3 GitHub site,\MessageBreak
+https://github.com/latex3/latex3/issues\MessageBreak
+(Or remove them from your example,\MessageBreak
+if they are not necessary to\MessageBreak
+exhibit the problem).\MessageBreak
+}{Please correct your test file prior
+ to submitting the bug report.\MessageBreak
+ Otherwise it is likely to be rejected!}%
+ \fi
+ \else
+ \PackageError{latexbug}%
+ {Third-party file(s)\MessageBreak
+\MessageBreak
+This test file uses third-party file(s)\MessageBreak
+\MessageBreak
+ ==============\MessageBreak
+ \latexbug@zzzz
+ ==============\MessageBreak
+ \MessageBreak
+So you should contact the authors\MessageBreak
+of these files, not the LaTeX Team!\MessageBreak
+(Or remove the packages that load\MessageBreak
+them, if they are not necessary to\MessageBreak
+exhibit the problem).\MessageBreak
+\MessageBreak
+If you think the bug is in core LaTeX\MessageBreak
+(as maintained by the LaTeX Team) but\MessageBreak
+these files are needed to demonstrate\MessageBreak
+the problem, please continue and mention\MessageBreak
+this explicitly in your bug report\MessageBreak
+(with an explanation why you think so)}{Please
+ correct your test file prior
+ to submitting the bug report.\MessageBreak
+ Otherwise it is likely to be rejected!}%
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\@addtofilelist}
+% \begin{macro}{\latexbug@iftoplevel}
+% First, a test to see if we are at the top level: there's no need to
+% test dependencies of packages. Assuming we are doing a check, the aim
+% is to see if the current name is known, and if it is whether it fits into
+% one of our special cases. If it's one of the \LaTeX3 GitHub packages it
+% gets recorded in a dedicated space. Third-party package can also have
+% information about where to report issues: this is all stored for reporting
+% later.
+% \begin{macrocode}
+\def\@addtofilelist#1{%
+% \show\@currnamestack
+ \expandafter\latexbug@iftoplevel\@currnamestack {}\@nil
+ \begingroup
+ \xdef\latexbug@x{#1}% TODO: one-level sanitize
+ \expandafter
+ \ifx\csname latexbug@@\latexbug@x\endcsname\relax
+ \def\latexbug@y{}%
+ \else
+ \xdef\latexbug@y{\csname latexbug@@\latexbug@x\endcsname}%
+ \fi
+ \ifx\latexbug@y\latexbug@us\else
+ \ifx\latexbug@y\latexbug@usstar
+ \begingroup
+ \let\MessageBreak\relax
+ \xdef\latexbug@expl{%
+ \latexbug@expl\latexbug@x
+ \MessageBreak
+ }%
+ \endgroup
+ \else
+ \ifx\latexbug@y\latexbug@ignore\else
+ {\let\MessageBreak\relax
+ \xdef\latexbug@zzzz{\latexbug@zzzz\latexbug@x
+ \ifx\latexbug@y\latexbug@empty\else
+ \space\space -> \space \latexbug@y\fi
+ \MessageBreak}}%
+ \fi
+ \fi
+ \fi
+ \endgroup
+ \fi
+ \latexbug@addtofilelist{#1}}
+\def\latexbug@iftoplevel #1#2\@nil{%
+ \def\next{#1}%
+ \ifx\next\@empty
+}
+\endinput
+%</package>
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \Finale
+%
diff --git a/macros/latex/required/latexbug/latexbug.ins b/macros/latex/required/latexbug/latexbug.ins
new file mode 100644
index 0000000000..1f1af46a6e
--- /dev/null
+++ b/macros/latex/required/latexbug/latexbug.ins
@@ -0,0 +1,65 @@
+%%
+%% 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 2016
+%% The LaTeX3 Project and any individual authors listed elsewhere
+%% in this file.
+%%
+%% This file is part of the Standard LaTeX `latexbug' module.
+%% ----------------------------------------------------------
+%%
+%% 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.
+%%
+%% In particular, NO PERMISSION is granted to modify the contents of this
+%% file since it contains the legal notices that are placed in the files
+%% it generates.
+%%
+%%
+%% --------------- 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
+ http://latex-project.org/bugs/
+or
+ https://github.com/latex3/latexbug/
+
+Copyright 2016
+The LaTeX3 Project and any individual authors listed elsewhere
+in this file.
+
+This file was generated from file(s) of the Standard LaTeX `latexbug' module.
+-----------------------------------------------------------------------------
+
+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.
+
+\endpreamble
+
+
+\generateFile{latexbug.sty}{t}{\from{latexbug.dtx}{package}}
+
+
+\endbatchfile
diff --git a/macros/latex/required/latexbug/latexbug.pdf b/macros/latex/required/latexbug/latexbug.pdf
new file mode 100644
index 0000000000..82f2c1103d
--- /dev/null
+++ b/macros/latex/required/latexbug/latexbug.pdf
Binary files differ
diff --git a/macros/latex/required/psnfss/00readme.txt b/macros/latex/required/psnfss/00readme.txt
new file mode 100644
index 0000000000..572e6df2a3
--- /dev/null
+++ b/macros/latex/required/psnfss/00readme.txt
@@ -0,0 +1,264 @@
+------------------------------------------------------------
+ PSNFSS 9.2 -- installation instructions
+------------------------------------------------------------
+ 2004-09-15
+ Walter Schmidt
+
+
+Contents
+--------
+
+- Overview
+- Removing obsolete files
+- Installing the virtual fonts, metrics and .fd files
+- Installing the PSNFSS macro packages
+- Installing the documentation
+- Fonts required for PSNFSS
+- Font map files
+- The encoding vector 8r.enc
+- Extra packages required for PSNFSS
+- Making sure that everything works
+- Files from PSNFSS v7.x, which are no longer part of the
+ distribution.
+
+
+
+Overview
+--------
+
+PSNFSS, originally developed by Sebastian Rahtz, is a set of
+LaTeX2e package files to use common PostScript text and
+symbol fonts, together with packages for typesetting math
+using virtual math fonts to match Times and Palatino.
+
+The macro packages are useless without the font description
+(fd) files, virtual fonts (vf) and font metric (tfm) files
+for the font families used. On CTAN, those for the Base 35
+fonts are provided in the archive lw35nfss.zip. The
+metrics, fd's and font map files for the free Utopia,
+Charter, FPL and Pazo fonts are provided in the archive file
+freenfss.zip.
+
+The PSNFSS collection does, however, NOT include the actual
+PostScript fonts, i.e., the .pfb and .afm files. See the
+below section "Fonts required for PSNFSS" .
+
+This document describes how to _install_ or _update_ PSNFSS.
+Detailed instructions how to _use_ PSNFSS with LaTeX can be
+found in the PDF document psnfss2e.pdf.
+
+
+
+Removing obsolete files
+-----------------------
+
+* If your current version of PSNFSS is 7.0 or older, you
+should remove manually _all_ macro files, .fd files, font
+metrics and virtual fonts, that have to do with the PSNFSS
+system or with the Base35, Utopia, Charter or Pazo fonts.
+
+* If your current version of PSNFSS is 8.x or 9.1, delete
+the files ot1fplmbb.fd and t1fplmbb.fd. In a TDS-compliant
+TeX system, they should reside in the directory
+texmf/tex/latex/psnfss.
+
+* Previous distributions of PSNFSS 9.0x would erroneously
+comprise a number of files named *8a.tfm in the directory
+texmf/fonts/tfm/adobe/palatino. These files did not do any
+harm, yet they are useless and should be deleted -- unless
+you are using VTeX, which does require them.
+
+
+
+Installing the virtual fonts, metrics and .fd files
+---------------------------------------------------
+Obtain the archive files lw35nfss.zip and freenfss.zip from
+CTAN:macros/latex/required/psnfss. If the file system
+layout of your TeX system complies with TDS, unzip them in
+the texmf root directory (usually named texmf) of your TeX
+system; all files will be unpacked into the right
+directories then. Otherwise you have to sort out manually
+the files from the .zip archives and copy them to the
+appropriate directories of your TeX system.
+
+The archives do _not_ include TFM files for the "raw" (= not
+re-encoded) PostScript text fonts. These files are required
+by VTeX only (and they are not PSNFSS-specific, anyway).
+
+
+
+Installing the PSNFSS macro packages
+------------------------------------
+
+Copy the files
+
+ 00readme.txt
+ changes.txt
+ manifest.txt
+ mathtest.tex
+ pitest.tex
+ psfonts.dtx
+ psfonts.ins
+ psnfss2e.tex
+ test0.tex
+ test1.tex
+ test2.tex
+ test3.tex
+
+to a directory where you keep documented LaTeX sources.
+In a TDS-compliant system this should be the directory
+
+ texmf/source/latex/psnfss/ .
+
+Run LaTeX on the installation script psfonts.ins to create
+the package (.sty) files. Move them to a directory where
+LaTeX will find them. In a TDS-compliant system this should
+be the directory
+
+ texmf/tex/latex/psnfss/ .
+
+The latter step is executed automagically by the
+installation script, provided that your DocStrip program has
+been configured appropriately and the target directory
+exists already.
+
+
+
+Installing the documentation
+----------------------------
+
+Copy the documentation file psnfss2e.pdf to a suitable
+directory; in a TDS-compliant system this should be
+
+ texmf/doc/latex/psnfss .
+
+
+
+Fonts required for PSNFSS
+-------------------------
+
+The "Base 35" fonts
+ Free substitutes for the commercial PostScript Base fonts
+ are available from the CTAN directory fonts/urw/base35.
+
+Adobe Utopia
+Bitstream Charter
+ The Type1 font files can be obtained for free from various
+ sources, e.g., CTAN:fonts/utopia and CTAN:fonts/charter.
+
+| The Utopia fonts are no longer a "required" component of
+| the LaTeX system, because of their license conditions.
+| Yet YOU MUST NOT OMIT the related font metrics and map
+| file records, regardless of whether or not the Type1 font
+| files are actually installed. Thus, the user will be
+| able to add the fonts without any further changes;
+| besides, other packages or virtual fonts may rely on
+| these TFMs.
+
+FPL (=Palatino SC/OsF)
+ Free substitutes for the commercial Palatino SC/OsF fonts
+ are available from CTAN:fonts/fpl
+
+Pazo
+ The Type1 fonts can be obtained from the CTAN directory
+ fonts/mathpazo. Notice that PSNFSS 9 needs version 1.003
+ (2002-05-17) of the Pazo fonts.
+
+Computer Modern
+RSFS (Ralph Smith's Formal Script)
+Euler Math
+ These font families are required when typesetting math
+ using the packages mathptm, mathptmx, mathpple, or
+ mathpazo. They are available in Type1 as well as METAFONT
+ format Make sure to install at least the Type1 variants,
+ possibly beside .mf.
+
+
+
+Font map files
+--------------
+
+The following font map files (in a format that suits dvips
+and pdfTeX) are provided in the PSNFSS distribution. Use
+them immediately or merge them into one common map file:
+
+ psnfss.map: for the Base35 fonts, eurmo10 and eurbo10
+ charter.map: for Bitstream Charter
+ utopia.map: for Adobe Utopia
+ pazo.map for the Pazo math fonts
+ fpls.map for the free substitutes (FPL) of the
+ Palatino SC/OsF fonts
+
+psnfss.map is primarily destined for use with dvips. The
+entries for the fonts "eurmo10" and "eurbo10" may need to be
+customized: Feel free to change the /FontName's (EURM10 and
+EURB10) to lower case, if you have got the Type1 fonts from
+MicroPress rather than the BlueSky collection. This
+particular change is _not_ regarded as a violation of the
+license conditions.
+
+psnfss.map does _not_ make dvips embed the Base35 fonts.
+For use with pdfTeX you will, most likely, have to create a
+modified copy, which specifies embedding of all Base fonts.
+The other map files are equally suitable for use with either
+dvips or pdfTeX.
+
+Other applications, such as VTeX, need a different format of
+the font map files. They may also require entries for the
+raw (= not reencoded) fonts. When creating these map files,
+take those for dvips/pdfTeX as a model!
+
+
+
+The encoding vector 8r.enc
+--------------------------
+
+Most Type1 text fonts, when used from TeX, are reencoded to
+the so-called TeXBase1 encoding, in order to make all glyphs
+accessible. This is performed using the reencoding file
+
+ 8r.enc
+
+which distributed with PSNFSS. Consult the documentation of
+your TeX system, where to store this file!
+
+|
+| PSNFSS 9.x includes version 2.0 of 8r.enc. Make sure
+| that there exist no other, obsolete, instances of 8r.enc
+| in the applicable search path of your TeX system
+|
+
+
+
+Extra packages required for PSNFSS
+----------------------------------
+
+The "Graphics" bundle must be installed, since PSNFSS makes
+use of the package keyval.sty.
+
+
+
+Making sure that everything works
+---------------------------------
+
+Run the test following files through LaTeX:
+
+ test0.tex
+ test1.tex
+ test2.tex
+ test3.tex
+ mathtest.tex
+ pitest.tex
+
+
+
+Files from PSNFSS v7.x, which are no longer part of the
+distribution
+-------------------------------------------------------
+
+The files to support the commercial Lucida Bright and
+MathTime fonts are now distributed from the CTAN directories
+macros/latex/contrib/psnfssx/ and fonts/metrics/bh/lucida/.
+
+
+-- finis
diff --git a/macros/latex/required/psnfss/8r.enc b/macros/latex/required/psnfss/8r.enc
new file mode 100644
index 0000000000..40dbe90419
--- /dev/null
+++ b/macros/latex/required/psnfss/8r.enc
@@ -0,0 +1,143 @@
+% File 8r.enc TeX Base 1 Encoding Revision 2.0 2002-10-30
+%
+% @@psencodingfile@{
+% author = "S. Rahtz, P. MacKay, Alan Jeffrey, B. Horn, K. Berry,
+% W. Schmidt, P. Lehman",
+% version = "2.0",
+% date = "30 October 2002",
+% filename = "8r.enc",
+% email = "tex-fonts@@tug.org",
+% docstring = "This is the encoding vector for Type1 and TrueType
+% fonts to be used with TeX. This file is part of the
+% PSNFSS bundle, version 9"
+% @}
+%
+% The idea is to have all the characters normally included in Type 1 fonts
+% available for typesetting. This is effectively the characters in Adobe
+% Standard encoding, ISO Latin 1, Windows ANSI including the euro symbol,
+% MacRoman, and some extra characters from Lucida.
+%
+% Character code assignments were made as follows:
+%
+% (1) the Windows ANSI characters are almost all in their Windows ANSI
+% positions, because some Windows users cannot easily reencode the
+% fonts, and it makes no difference on other systems. The only Windows
+% ANSI characters not available are those that make no sense for
+% typesetting -- rubout (127 decimal), nobreakspace (160), softhyphen
+% (173). quotesingle and grave are moved just because it's such an
+% irritation not having them in TeX positions.
+%
+% (2) Remaining characters are assigned arbitrarily to the lower part
+% of the range, avoiding 0, 10 and 13 in case we meet dumb software.
+%
+% (3) Y&Y Lucida Bright includes some extra text characters; in the
+% hopes that other PostScript fonts, perhaps created for public
+% consumption, will include them, they are included starting at 0x12.
+% These are /dotlessj /ff /ffi /ffl.
+%
+% (4) hyphen appears twice for compatibility with both ASCII and Windows.
+%
+% (5) /Euro was assigned to 128, as in Windows ANSI
+%
+% (6) Missing characters from MacRoman encoding incorporated as follows:
+%
+% PostScript MacRoman TeXBase1
+% -------------- -------------- --------------
+% /notequal 173 0x16
+% /infinity 176 0x17
+% /lessequal 178 0x18
+% /greaterequal 179 0x19
+% /partialdiff 182 0x1A
+% /summation 183 0x1B
+% /product 184 0x1C
+% /pi 185 0x1D
+% /integral 186 0x81
+% /Omega 189 0x8D
+% /radical 195 0x8E
+% /approxequal 197 0x8F
+% /Delta 198 0x9D
+% /lozenge 215 0x9E
+%
+/TeXBase1Encoding [
+% 0x00
+ /.notdef /dotaccent /fi /fl
+ /fraction /hungarumlaut /Lslash /lslash
+ /ogonek /ring /.notdef /breve
+ /minus /.notdef /Zcaron /zcaron
+% 0x10
+ /caron /dotlessi /dotlessj /ff
+ /ffi /ffl /notequal /infinity
+ /lessequal /greaterequal /partialdiff /summation
+ /product /pi /grave /quotesingle
+% 0x20
+ /space /exclam /quotedbl /numbersign
+ /dollar /percent /ampersand /quoteright
+ /parenleft /parenright /asterisk /plus
+ /comma /hyphen /period /slash
+% 0x30
+ /zero /one /two /three
+ /four /five /six /seven
+ /eight /nine /colon /semicolon
+ /less /equal /greater /question
+% 0x40
+ /at /A /B /C
+ /D /E /F /G
+ /H /I /J /K
+ /L /M /N /O
+% 0x50
+ /P /Q /R /S
+ /T /U /V /W
+ /X /Y /Z /bracketleft
+ /backslash /bracketright /asciicircum /underscore
+% 0x60
+ /quoteleft /a /b /c
+ /d /e /f /g
+ /h /i /j /k
+ /l /m /n /o
+% 0x70
+ /p /q /r /s
+ /t /u /v /w
+ /x /y /z /braceleft
+ /bar /braceright /asciitilde /.notdef
+% 0x80
+ /Euro /integral /quotesinglbase /florin
+ /quotedblbase /ellipsis /dagger /daggerdbl
+ /circumflex /perthousand /Scaron /guilsinglleft
+ /OE /Omega /radical /approxequal
+% 0x90
+ /.notdef /.notdef /.notdef /quotedblleft
+ /quotedblright /bullet /endash /emdash
+ /tilde /trademark /scaron /guilsinglright
+ /oe /Delta /lozenge /Ydieresis
+% 0xA0
+ /.notdef /exclamdown /cent /sterling
+ /currency /yen /brokenbar /section
+ /dieresis /copyright /ordfeminine /guillemotleft
+ /logicalnot /hyphen /registered /macron
+% 0xD0
+ /degree /plusminus /twosuperior /threesuperior
+ /acute /mu /paragraph /periodcentered
+ /cedilla /onesuperior /ordmasculine /guillemotright
+ /onequarter /onehalf /threequarters /questiondown
+% 0xC0
+ /Agrave /Aacute /Acircumflex /Atilde
+ /Adieresis /Aring /AE /Ccedilla
+ /Egrave /Eacute /Ecircumflex /Edieresis
+ /Igrave /Iacute /Icircumflex /Idieresis
+% 0xD0
+ /Eth /Ntilde /Ograve /Oacute
+ /Ocircumflex /Otilde /Odieresis /multiply
+ /Oslash /Ugrave /Uacute /Ucircumflex
+ /Udieresis /Yacute /Thorn /germandbls
+% 0xE0
+ /agrave /aacute /acircumflex /atilde
+ /adieresis /aring /ae /ccedilla
+ /egrave /eacute /ecircumflex /edieresis
+ /igrave /iacute /icircumflex /idieresis
+% 0xF0
+ /eth /ntilde /ograve /oacute
+ /ocircumflex /otilde /odieresis /divide
+ /oslash /ugrave /uacute /ucircumflex
+ /udieresis /yacute /thorn /ydieresis
+] def
+
diff --git a/macros/latex/required/psnfss/README b/macros/latex/required/psnfss/README
new file mode 120000
index 0000000000..5d84037450
--- /dev/null
+++ b/macros/latex/required/psnfss/README
@@ -0,0 +1 @@
+00readme.txt \ No newline at end of file
diff --git a/macros/latex/required/psnfss/changes.txt b/macros/latex/required/psnfss/changes.txt
new file mode 100644
index 0000000000..e4da98f6fb
--- /dev/null
+++ b/macros/latex/required/psnfss/changes.txt
@@ -0,0 +1,242 @@
+2005-04-12 PSNFSS 9.2a
+
+ fix for psnfss/3773, affecting only helvet.sty:
+ the package can now be loaded before \documentclass
+
+2004-10-18
+
+ * freenfss.zip: fixed a major bug in the Charter font metrics
+ (will I ever get them right?)
+
+2004-09-15 PSNFSS 9.2
+
+ * Charter: improved kerning data (once again...)
+
+ * Palatino: additional font families pplx and pplj with real
+ smallcaps and oldstyle figures and improved kerning tables;
+ the free FPL fonts can be used as a substitute for te required
+ Palatino SC/OsF fonts
+
+ * mathpazo, mathptmx: beside \upDelta and \upOmega also the
+ other upright uppercase Greek letters are explicitly accessible.
+
+ * documentation psnfss2e.tex(.pdf) updated
+
+ * font map files: new file fpls.map for the FPL fonts.
+
+ * minor changes to mathtest.tex
+
+ (* lw35nfss.zip is unchanged)
+
+2004-01-26 PSNFSS 9.1b
+
+ * freenfss.zip with fixed VFs and metrics for the Bitstream
+ Charter fonts: New kerning pairs Y-g and Y-s; corrected
+ \fontdimen1 of the italic shapes; improved italic Euro symbols
+
+ * helvet.sty: Fixed implementation of the key-value interface.
+
+ * Warning messages added to obsolete packages.
+
+2003-11-17 PSNFSS 9.1
+
+ * Updated VFs for all Adobe text font families, except Utopia:
+ Added \texteuro, fixed zdot and \textasteriskcentered.
+
+ * Courier: normal asterisk (*) is now vertically centered.
+
+ * New VFs for Bitstream Charter with revised kerning data and
+ faked \texteuro. In particular, the overly tight kerning
+ between L and quoteright has been abolished.
+
+ * The Pazo doublestroke font is now assigned the encoding U,
+ rather than T1 and OT1. The files t1fplmbb.fd and ot1fplm.fd
+ are replaced by ufplmbb.fd.
+
+ * The Utopia fonts are no longer regarded as "required"; the
+ package utopia.sty is marked as "obsolete".
+
+ * Documentation psnfss2e.* updated accordingly.
+
+ * Test files enhanced to test the Euro symbols and the Pazo
+ doublestroke font, while Utopia is omitted now.
+
+
+2003-03-02 PSNFSS 9.0c
+
+ * mathptmx,sty, mathpazo.sty: \upOmega and \UpDelta are of
+ type \mathord now, to make sure that they are always upright
+
+ * pifont.sty: \Pifill and \dingfill should no longer fail at
+ the beginning or end of a paragraph. (Bug fix suggested by FMi.)
+
+ * mathptm(x).sty: \jmath, \coprod, and \amalg will now generate
+ error messages rather than print black squares. (Suggested by
+ FMi.)
+
+ * Small changes to the documentation psnfss2e.*.
+
+ * Enhanced test0.tex to test also the math alphabets.
+
+ * 8r.enc: version 2.0, comprising all of the Mac Roman
+ character set, too.
+
+ * The *.map files and the file 8r.enc have been moved out of the
+ ZIP archives, since their final location in the texmf tree may
+ vary wrt/ changes in the TDS specs.
+
+2002-09-08 PSNFSS 9.0a
+
+ * Fixed TFM and VF files for mathpazo. The size of certain
+ symbols was wrong, because of a bug in the fontinst program.
+
+ * psfonts.dtx: Changed definition of \hbar in mathpazo.sty
+ to improve spacing.
+
+ * Fixed identification strings in 8rpcr.fd and t1put.fd.
+
+ * Fixed comments in 8r.enc.
+
+ * Removed one unneeded file from lw35nfss.zip.
+
+2002-07-04
+
+ * Improved installation instructions (file 00readme.txt)
+
+2002-05-17 Pazo fonts v1.003
+
+ * Changed the positioning of the double stroke in X and Z in
+ Pazo Math Blackboard Bold (suggested by Marco Kuhlmann).
+ The font metrics are unchanged.
+
+2002-04-24 PSNFSS-9.0
+
+ * mathptmx.sty: Improved \hbar. Added missing redefinitions
+ of \defaultscriptratio and \defaultscriptscriptratio.
+
+ * psnfss2e.pdf: All fonts are embedded now.
+
+2002-04-10 PSNFSS-9.0 pre-release
+
+ * 8r.enc: The TeXBase1Encoding includes the Euro symbol in
+ slot 128 now. Thus, future fonts that provide the Euro, can
+ be supported. This does, however, NOT affect the present
+ Base35, Charter and Utopia fonts.
+
+ * mathpazo.sty: The undocumented macro ppljeuro is no longer
+ provided.
+
+ * freenfss.zip: The VFs and TFMs are to be used with version
+ 1.002 of the Pazo fonts now.
+
+ * Palatino text fonts: The textcompanion fonts of the
+ Palatino family provide the Euro symbol \texteuro as well as
+ the Omega \textohm now. The letters are actually taken from
+ the Pazo fonts.
+
+ * Documentation psnfss2e.tex updated and slightly improved.
+
+2002-02-28 Pazo fonts v1.002
+
+ * Added all the remaining uppercase latin letters and digit
+ "one" to Pazo Math Blackboard Bold.
+
+ * Re-designed \Phi to make it better proportioned
+
+ * Re-designed \varsigma to give it a more recognisable shape
+ (suggested by Pablo Rodriguez). Re-designed \xi and \zeta to
+ match the new \varsigma.
+
+
+2001-06-04 PSNFSS-v8.2
+
+ * mathpazo.sty: Changed behavior of the options sc and osf.
+ \jmath and \imath changed back to type 'mathord', as in normal
+ LaTeX.
+
+ * mathptm.sty: Revoked the changes re. AMS fonts, since the
+ package is only provided for use with legacy douments, anyway.
+
+ * Many changes to the documentation (psnfss2e.*).
+
+ * test1.tex, test2.tex, test3.tex: Fixed typo.
+
+2001/05/27 PSNFSS-v8.2beta
+
+ * mathpazo.sty:
+ An improved version of this package is now part of the PSNFSS
+ distribution.
+
+ * freenfss.zip:
+ Added TFM, VF and FD files for the Pazo fonts.
+
+ * mathptmx.sty
+ New option: [slantedGreek]
+
+ * The AMS fonts are scaled properly now, when used together
+ with the packages mathptm, mathptmx, mathpple or mathpazo.
+ Specifying the [psamsfonts] option for the packages amsfonts or
+ amssymb may be needed wrt/ the Euler Fraktur fonts, but will not
+ affect the scaling of the others.
+
+ * ot1*.fd:
+ additional font shape substitition bx/ui -> b/it
+
+ * fixed TFM file zptmcm7y.tfm so as to raise the subscripts
+ generated by mathptmx (pr/3279)
+
+ * fixed FD files for Adobe Courier so as to disable hyphenation
+ (I wonder why this bug was never noticed...)
+
+ * test files completely revised
+
+2000-01-12 PSNFSS-v8.1
+
+ * support for commercial fonts is no longer part of the basic
+ PSNFSS distribution.
+
+ * new, enhanced user documentation
+
+ * freenfss.zip:
+ new file, containing metrics, vf's, fd's and map files for
+ Bitstream Charter and Adobe Utopia
+
+ * lw35nfss.zip:
+ removed tfm's and vf's for `raw' fonts and the duplicate
+ psyr.tfm; removed tfm's and vf's for Helvetica Light, which
+ isn't free; removed the related entries from the .fd files, too;
+ added the fd/tfm/vf files of the mathpple collection.
+
+ * metrics (general):
+ removed the checksums, which are useless anyway; added missing
+ macron accent to all sc fonts; removed 1-1 kern pair from
+ Palatino.
+
+ * map files: concatenated all .map files for the Base 35
+ fonts plus mathpple.map to one single psnfss.map; removed
+ duplicate entries; the map file will unpack to dvips/psnfss/
+ now.
+
+ * 8r.enc: the file is now distributed as part of lw35nfss.zip
+ and will unpack to the directory dvips/psnfss/.
+
+ * psfonts.dtx:
+ added courier.sty, which was previously not generated from a
+ .dtx source; added charter.sty and utopia.sty, which were
+ previously generated from dtx's of their own; added
+ mathpple.sty.
+
+ * mathptm.sty, mathptmx.sty:
+ fixed problems in conjunction with latexsym.sty and amssymb.sty
+ (pr/2910, pr/2762) as FMi had suggested; fixed the weird warning
+ message with \boldmath (pr/2994); made \hbar work with Times;
+ fixed \big & friends for font sizes <> 10pt;
+
+ * mathpple.sty:
+ this package is now part of the PSNFSS distribution;
+ slightly enlarged font sizes for super- and subscripts in math;
+ \Re, \Im, \infty taken from Euler now.
+
+ * helvet.sty: new option for scaling Helvetica
+
+%% finis
diff --git a/macros/latex/required/psnfss/charter.map b/macros/latex/required/psnfss/charter.map
new file mode 100644
index 0000000000..d1b30ddd2a
--- /dev/null
+++ b/macros/latex/required/psnfss/charter.map
@@ -0,0 +1,7 @@
+bchb8r CharterBT-Bold " TeXBase1Encoding ReEncodeFont " <8r.enc <bchb8a.pfb
+bchbi8r CharterBT-BoldItalic " TeXBase1Encoding ReEncodeFont " <8r.enc <bchbi8a.pfb
+bchbo8r CharterBT-Bold " .167 SlantFont TeXBase1Encoding ReEncodeFont " <8r.enc <bchb8a.pfb
+bchr8r CharterBT-Roman " TeXBase1Encoding ReEncodeFont " <8r.enc <bchr8a.pfb
+bchri8r CharterBT-Italic " TeXBase1Encoding ReEncodeFont " <8r.enc <bchri8a.pfb
+bchro8r CharterBT-Roman " .167 SlantFont TeXBase1Encoding ReEncodeFont " <8r.enc <bchr8a.pfb
+
diff --git a/macros/latex/required/psnfss/fpls.map b/macros/latex/required/psnfss/fpls.map
new file mode 100644
index 0000000000..280c2e8dbf
--- /dev/null
+++ b/macros/latex/required/psnfss/fpls.map
@@ -0,0 +1,5 @@
+pplbj8r TeXPalladioL-BoldOsF "TeXBase1Encoding ReEncodeFont " <8r.enc <fplbj8a.pfb
+pplbij8r TeXPalladioL-BoldItalicOsF "TeXBase1Encoding ReEncodeFont " <8r.enc <fplbij8a.pfb
+pplrc8r TeXPalladioL-SC "TeXBase1Encoding ReEncodeFont " <8r.enc <fplrc8a.pfb
+pplrij8r TeXPalladioL-ItalicOsF "TeXBase1Encoding ReEncodeFont " <8r.enc <fplrij8a.pfb
+
diff --git a/macros/latex/required/psnfss/manifest.txt b/macros/latex/required/psnfss/manifest.txt
new file mode 100644
index 0000000000..473ac3dc9a
--- /dev/null
+++ b/macros/latex/required/psnfss/manifest.txt
@@ -0,0 +1,28 @@
+The following files constitute the PSNFSS bundle and must be
+distributed as a whole.
+This restriction does NOT affect 8r.enc, which is originally
+distributed from <http://tug.org/fontname/8r.enc> and is
+included here for the sake of completeness only.
+
+00readme.txt
+changes.txt
+freenfss.zip (or all files included in this archive)
+lw35nfss.zip (or all files included in this archive)
+manifest.txt
+mathtest.tex
+pitest.tex
+psfonts.dtx
+psfonts.ins
+psnfss2e.tex
+psnfss2e.pdf
+test0.tex
+test1.tex
+test2.tex
+test3.tex
+charter.map
+pazo.map
+psnfss.map
+utopia.map
+8r.enc
+
+% finis
diff --git a/macros/latex/required/psnfss/mathtest.tex b/macros/latex/required/psnfss/mathtest.tex
new file mode 100644
index 0000000000..8d3172377e
--- /dev/null
+++ b/macros/latex/required/psnfss/mathtest.tex
@@ -0,0 +1,116 @@
+% This file is part of PSNFSS 9.2
+
+\listfiles
+\documentclass{article}
+\usepackage{geometry}
+%\pagestyle{empty}
+\usepackage[sc,osf,slantedGreek]{mathpazo}
+\linespread{1.08} % Palatino needs more leading
+\usepackage[scaled]{helvet}
+\usepackage{courier}
+\parindent=0pt
+\pagestyle{empty}
+\normalfont
+\usepackage[T1]{fontenc}
+
+\begin{document}
+
+\begin{center}
+\scshape\Large Sebastian's math test
+\end{center}
+The default math mode font is $Math\ Italic$. This should not be
+confused with ordinary \emph{Text Italic} -- notice the different spacing\,!
+\verb|\mathbf| produces bold roman letters: $ \mathbf{abcABC} $.
+If you wish to embolden complete formulas,
+use the \verb|\boldmath| command \emph{before} going into math mode.
+This changes the default math fonts to bold.
+
+\begin{tabular}{ll}
+\texttt{normal} & $ x = 2\pi \Rightarrow x \simeq 6.28 $\\
+\texttt{mathbf} & $\mathbf{x} = 2\pi \Rightarrow \mathbf{x} \simeq 6.28 $\\
+\texttt{boldmath} & {\boldmath $x = \mathbf{2}\pi \Rightarrow x
+ \simeq{\mathbf{6.28}} $}\\
+\end{tabular}
+\smallskip
+
+Greek is available in upper and lower case:
+$\alpha,\beta \dots \Omega$, and there are special
+symbols such as $ \hbar$.
+The following letters should be upright: $\upGamma, \upDelta\dots \upOmega$.
+Digits in formulas $1, 2, 3\dots$ may differ from those in text: 4, 5, 6\dots
+
+There is a calligraphic alphabet \verb|\mathcal| for upper case letters
+$ \mathcal{ABCDE}\dots $, and there are letters for number sets: $\mathbb{A\dots Z} $,
+which are produced using \verb|\mathbb|.
+
+\begin{equation}
+ \sigma(t)=\frac{1}{\sqrt{2\pi}}
+ \int^t_0 e^{-x^2/2} dx
+\end{equation}
+
+\begin{equation}
+ \prod_{j\geq 0}
+ \left(\sum_{k\geq 0}a_{jk} z^k\right)
+= \sum_{k\geq 0} z^n
+ \left( \sum_{{k_0,k_1,\ldots\geq 0}
+ \atop{k_0+k_1+\ldots=n} }
+ a{_0k_0}a_{1k_1}\ldots \right)
+\end{equation}
+
+\begin{equation}
+\pi(n) = \sum_{m=2}^{n}
+ \left\lfloor \left(\sum_{k=1}^{m-1}
+ \lfloor(m/k)/\lceil m/k\rceil
+ \rfloor \right)^{-1}
+ \right\rfloor
+\end{equation}
+
+\begin{equation}
+\{\underbrace{%
+ \overbrace{\mathstrut a,\ldots,a}^{k\ a's},
+ \overbrace{\mathstrut b,\ldots,b}^{l\ b's}}
+ _{k+l\ \mathrm{elements}} \}
+\end{equation}
+
+\[
+\mbox{W}^+\
+\begin{array}{l}
+\nearrow\raise5pt\hbox{$\mu^+ + \nu_{\mu}$}\\
+\rightarrow \pi^+ +\pi^0 \\[5pt]
+\rightarrow \kappa^+ +\pi^0 \\
+\searrow\lower5pt\hbox{$\mathrm{e}^+
+ +\nu_{\scriptstyle\mathrm{e}}$}
+\end{array}
+\]
+
+\[
+\frac{\pm
+\left|\begin{array}{ccc}
+x_1-x_2 & y_1-y_2 & z_1-z_2 \\
+l_1 & m_1 & n_1 \\
+l_2 & m_2 & n_2
+\end{array}\right|}{
+\sqrt{\left|\begin{array}{cc}l_1&m_1\\
+l_2&m_2\end{array}\right|^2
++ \left|\begin{array}{cc}m_1&n_1\\
+n_1&l_1\end{array}\right|^2
++ \left|\begin{array}{cc}m_2&n_2\\
+n_2&l_2\end{array}\right|^2}}
+\]
+
+Mathematical accents:
+\[
+\mbox{ acute=}\acute{a}
+\mbox{ grave=}\grave{a}
+\mbox{ ddot=}\ddot {a}
+\mbox{ tilde=}\tilde{a}
+\mbox{ bar=}\bar {a}
+\mbox{ breve=}\breve{a}
+\mbox{ check=}\check{a}
+\mbox{ hat=}\hat {a}
+\mbox{ vec=}\vec {a}
+\mbox{ dot=}\dot {a}
+\]
+
+
+\end{document}
diff --git a/macros/latex/required/psnfss/pazo.map b/macros/latex/required/psnfss/pazo.map
new file mode 100644
index 0000000000..9b0dd8c8dc
--- /dev/null
+++ b/macros/latex/required/psnfss/pazo.map
@@ -0,0 +1,6 @@
+fplmr PazoMath <fplmr.pfb
+fplmri PazoMath-Italic <fplmri.pfb
+fplmb PazoMath-Bold <fplmb.pfb
+fplmbi PazoMath-BoldItalic <fplmbi.pfb
+fplmbb PazoMathBlackboardBold <fplmbb.pfb
+
diff --git a/macros/latex/required/psnfss/pitest.tex b/macros/latex/required/psnfss/pitest.tex
new file mode 100644
index 0000000000..4d59d05179
--- /dev/null
+++ b/macros/latex/required/psnfss/pitest.tex
@@ -0,0 +1,66 @@
+\documentclass[11pt]{article}
+\pagestyle{empty}
+
+\renewcommand{\rmdefault}{ptm}
+\usepackage{pifont}
+
+\begin{document}
+
+\begin{dinglist}{74}
+\item \ding{101} was Dingbat 101
+\item \verb|\dingfill| (with the usual numeric parameter)
+ acts like other filling commands, but fills the
+space with a chosen Dingbat \dingfill{101} like that.
+{
+\fontfamily{pzc}\itshape\selectfont
+\item \verb|\dingline| generates a freestanding line of the little chaps:
+\dingline{44}
+\item Inevitably, the `dinglist' environment sets up an itemized
+list, but has a Dingbat instead of a bullet (you are reading a
+\verb|dinglist| at the moment).
+}
+\end{dinglist}
+
+\begin{Pilist}{psy}{74}
+\item \Pisymbol{psy}{101} was symbol 101
+\item \verb|\Pifill{psy}| (with the usual numeric parameter)
+ acts like other filling commands, but fills the
+space with a chosen symbol \Pifill{psy}{101} like that.
+\item \verb|\Piline| generates a freestanding line of the little chaps:
+\Piline{psy}{44}
+\item Inevitably, the `Pilist' environment sets up an itemized
+list, but has a symbol instead of a bullet (you are reading a
+\verb|Pilist| at the moment).
+\end{Pilist}
+
+\begin{Piautolist}{pzd}{'254}
+\item text inside list,
+ \begin{Piautolist}{psy}{'141}
+ \item text inside list,
+ \item text inside list,
+ \begin{enumerate}
+ \item text inside list,
+ \begin{Piautolist}{pzd}{'56}
+ \item text inside list,\label{pilabel}
+ \item text inside list,
+ \end{Piautolist}
+ \item text inside list,
+ \end{enumerate}
+ \item text inside list,
+ \end{Piautolist}
+\item text inside list
+\end{Piautolist}
+So we can refer to item \ref{pilabel} as usual.
+
+\begin{Pilist}{pzd}{'246}
+\item \verb|\Pisymbol| generates a Pi character; it has two
+parameters: the font family, and the character number. Thus
+\verb|\Pisymbol{pzd}{'166}| generates \Pisymbol{pzd}{'166}.
+\item \verb|\Pifill| (with the same parameters)
+ acts like the other filling commands in \TeX, but fills the
+space with a chosen symbol \Pifill{pzd}{'340} like that.
+\item \verb|\Piline| generates a freestanding line of the little chaps:
+\Piline{pzd}{36}
+\end{Pilist}
+
+\end{document}
diff --git a/macros/latex/required/psnfss/psfonts.dtx b/macros/latex/required/psnfss/psfonts.dtx
new file mode 100644
index 0000000000..2be328867b
--- /dev/null
+++ b/macros/latex/required/psnfss/psfonts.dtx
@@ -0,0 +1,1014 @@
+%\CheckSum{1101}
+%
+% \iffalse
+%
+% file: psfonts.dtx
+%
+% Copyright 1995--1998 Sebastian Rahtz
+% Copyright 1999--2005 Sebastian Rahtz, Walter Schmidt
+%
+% This program may be distributed and/or modified under the
+% conditions of the LaTeX Project Public License, either version 1.2
+% 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.2 or later is part of all distributions of LaTeX
+% version 1999/12/01 or later.
+%
+% This program consists of all files listed in manifest.txt.
+%
+% \fi
+%
+% \iffalse
+%<*driver>
+\ProvidesFile{psfonts.drv}
+%</driver>
+%<times>\ProvidesPackage{times}%
+%<mathptm>\ProvidesPackage{mathptm}%
+%<mathptmx>\ProvidesPackage{mathptmx}%
+%<mathpple>\ProvidesPackage{mathpple}%
+%<palatino>\ProvidesPackage{palatino}%
+%<chancery>\ProvidesPackage{chancery}%
+%<pifont>\ProvidesPackage{pifont}%
+%<bookman>\ProvidesPackage{bookman}%
+%<newcent>\ProvidesPackage{newcent}%
+%<avant>\ProvidesPackage{avant}%
+%<helvet>\ProvidesPackage{helvet}%
+%<courier>\ProvidesPackage{courier}%
+%<charter>\ProvidesPackage{charter}%
+%<utopia>\ProvidesPackage{utopia}%
+%<mathpazo>\ProvidesPackage{mathpazo}%
+[2005/04/12 PSNFSS-v9.2a
+%<times>(SPQR)
+%<mathptm>Times w/ Math (SPQR, WaS)
+%<mathptmx>Times w/ Math, improved (SPQR, WaS)
+%<mathpple>Palatino w/ Math (WaS)
+%<palatino>(SPQR)
+%<chancery>(SPQR)
+%<pifont>Pi font support (SPQR)
+%<bookman>(SPQR)
+%<newcent>(SPQR)
+%<avant>(SPQR)
+%<helvet>(WaS)
+%<courier>(WaS)
+%<charter>(P.Dyballa)
+%<utopia>(P.Dyballa)
+%<mathpazo> Palatino w/ Pazo Math (D.Puga, WaS)
+]
+%
+%<*driver>
+\documentclass{ltxdoc}
+\begin{document}
+ \DocInput{psfonts.dtx}
+\end{document}
+%</driver>
+% \fi
+%
+% \DeleteShortVerb{\|}
+% \MakeShortVerb{\+}
+% \GetFileInfo{psfonts.drv}
+% \title{The packages of the PSNFSS bundle}
+% \author{Walter Schmidt\thanks{\texttt{<w-a-schmidt@arcor.de>}}}
+% \date{\fileversion{} -- \filedate}
+% \maketitle
+%
+% \noindent
+% The source file \texttt{psfonts.dtx} contains suitable package files
+% to use common PostScript fonts with \LaTeX.
+% See the file \texttt{00readme.txt} for the installation instructions;
+% it also explains how to obtain the
+% related Type1 fonts, font definition files, font metrics and virtual fonts.
+%
+% See the document `Using common PostScript fonts with \LaTeX',
+% filename \texttt{psnfss2e.pdf}, for a description of the user interface.
+%
+% \StopEventually{}
+%
+% \section{The \textsf{times} package}
+% \begin{macrocode}
+%<*times>
+\renewcommand{\sfdefault}{phv}
+\renewcommand{\rmdefault}{ptm}
+\renewcommand{\ttdefault}{pcr}
+%</times>
+% \end{macrocode}
+%
+% \section{The \textsf{palatino} package}
+% \begin{macrocode}
+%<*palatino>
+\renewcommand{\rmdefault}{ppl}
+\renewcommand{\sfdefault}{phv}
+\renewcommand{\ttdefault}{pcr}
+%</palatino>
+% \end{macrocode}
+%
+% \section{The \textsf{helvet} package}
+% Options processing uses the \textsf{keyval} package
+% and a hack borrowed from \textsf{hyperref}:
+% \begin{macrocode}
+%<*helvet>
+\RequirePackage{keyval}
+\define@key{Hel}{scaled}[.95]{%
+ \def\Hv@scale{#1}}
+\def\ProcessOptionsWithKV#1{%
+ \let\@tempc\relax
+ \let\Hv@tempa\@empty
+ \ifx\@classoptionslist\relax\else
+ \@for\CurrentOption:=\@classoptionslist\do{%
+ \@ifundefined{KV@#1@\CurrentOption}%
+ {}%
+ {%
+ \edef\Hv@tempa{\Hv@tempa,\CurrentOption,}%
+ \@expandtwoargs\@removeelement\CurrentOption
+ \@unusedoptionlist\@unusedoptionlist
+ }%
+ }%
+ \fi
+ \edef\Hv@tempa{%
+ \noexpand\setkeys{#1}{%
+ \Hv@tempa\@ptionlist{\@currname.\@currext}%
+ }%
+ }%
+ \Hv@tempa
+ \let\CurrentOption\@empty
+}
+\ProcessOptionsWithKV{Hel}
+\AtEndOfPackage{%
+ \let\@unprocessedoptions\relax
+}
+% \end{macrocode}
+% The +.fd+ files will evaluate the macro +\Hv@scale+ and scale
+% Helvetica appropriately.
+%
+% Now it's time to redefine the default sans font:
+% \begin{macrocode}
+\renewcommand{\sfdefault}{phv}
+%</helvet>
+% \end{macrocode}
+%
+% \section{The \textsf{avant} package}
+% \begin{macrocode}
+%<*avant>
+\renewcommand{\sfdefault}{pag}
+%</avant>
+% \end{macrocode}
+%
+% \section{The \textsf{newcent} package}
+% \begin{macrocode}
+%<*newcent>
+\renewcommand{\rmdefault}{pnc}
+\renewcommand{\sfdefault}{pag}
+\renewcommand{\ttdefault}{pcr}
+%</newcent>
+% \end{macrocode}
+%
+% \section{The \textsf{bookman} package}
+% \begin{macrocode}
+%<*bookman>
+\renewcommand{\rmdefault}{pbk}
+\renewcommand{\sfdefault}{pag}
+\renewcommand{\ttdefault}{pcr}
+%</bookman>
+% \end{macrocode}
+%
+% \section{The \textsf{courier} package}
+% \begin{macrocode}
+%<*courier>
+\renewcommand{\ttdefault}{pcr}
+%</courier>
+% \end{macrocode}
+%
+% \section{The \textsf{pifont} package}
+% Some useful commands for Pi fonts (Dingbats, Symbol etc); they
+% all assume you know the character number of the (unmapped) font
+% \begin{macrocode}
+%<*pifont>
+\newcommand{\Pifont}[1]{\fontfamily{#1}\fontencoding{U}%
+\fontseries{m}\fontshape{n}\selectfont}
+\newcommand{\Pisymbol}[2]{{\Pifont{#1}\char#2}}
+\newcommand{\Pifill}[2]{\leavevmode
+ \leaders\hbox{\makebox[0.2in]{\Pisymbol{#1}{#2}}}\hfill
+ \kern\z@}
+\newcommand{\Piline}[2]{\par\noindent\hspace{0.5in}\Pifill{#1}{#2}%
+ \hspace{0.5in}\kern\z@\par}
+\newenvironment{Pilist}[2]%
+{\begin{list}{\Pisymbol{#1}{#2}}{}}%
+{\end{list}}%
+% \end{macrocode}
+% A Pi number generator (from ideas by David Carlisle), for use in
+% lists where items are suffixed by symbols taken in sequence from a
+% Pi font. Usage is in lists just like enumerate.
+%
+% +\Pinumber+ outputs the appropriate symbol, where +#2+ is the name of a
+% \LaTeX\ counter and +#1+ is the font family.
+% \begin{macrocode}
+\def\Pinumber#1#2{\protect\Pisymbol{#1}{\arabic{#2}}}
+\newenvironment{Piautolist}[2]{%
+\ifnum \@enumdepth >3 \@toodeep\else
+ \advance\@enumdepth \@ne
+% \end{macrocode}
+% We force the labels and cross-references into a very plain style (e.g.,
+% no brackets around `numbers', or dots after them).
+% \begin{macrocode}
+ \edef\@enumctr{enum\romannumeral\the\@enumdepth}%
+ \expandafter\def\csname p@enum\romannumeral\the\@enumdepth\endcsname{}%
+ \expandafter\def\csname labelenum\romannumeral\the\@enumdepth\endcsname{%
+ \csname theenum\romannumeral\the\@enumdepth\endcsname}%
+ \expandafter\def\csname theenum\romannumeral\the\@enumdepth\endcsname{%
+ \Pinumber{#1}{enum\romannumeral\the\@enumdepth}}%
+ \list{\csname label\@enumctr\endcsname}{%
+ \@nmbrlisttrue
+ \def\@listctr{\@enumctr}%
+ \setcounter{\@enumctr}{#2}%
+ \addtocounter{\@enumctr}{-1}%
+ \def\makelabel##1{\hss\llap{##1}}}
+\fi
+}{\endlist}
+% \end{macrocode}
+% All the old Dingbat commands still work;
+% they are now implemented using the +\Pi...+ commands.
+% \begin{macrocode}
+\newcommand{\ding}{\Pisymbol{pzd}}
+\def\dingfill#1{\Pifill{pzd}{#1}}
+\def\dingline#1{\Piline{pzd}{#1}}
+\newenvironment{dinglist}[1]{\begin{Pilist}{pzd}{#1}}%
+ {\end{Pilist}}
+\newenvironment{dingautolist}[1]{\begin{Piautolist}{pzd}{#1}}%
+ {\end{Piautolist}}
+{\Pifont{pzd}}
+{\Pifont{psy}}
+%</pifont>
+% \end{macrocode}
+%
+% \section{The \textsf{chancery} package}
+% \begin{macrocode}
+%<*chancery>
+\renewcommand{\rmdefault}{pzc}
+%</chancery>
+% \end{macrocode}
+%
+% \section{The \textsf{mathptm} and \textsf{mathptmx} packages}
+% Setting up the fonts for \textsf{mathptm}:
+% \begin{macrocode}
+%<*mathptm>
+\PackageWarningNoLine{mathptm}{%
+ This package is to be regarded as obsolete.\MessageBreak
+ See the PSNFSS documentation}
+\def\rmdefault{ptm}
+\DeclareSymbolFont{operators} {OT1}{ptmcm}{m}{n}
+\DeclareSymbolFont{letters} {OML}{ptmcm}{m}{it}
+\DeclareSymbolFont{symbols} {OMS}{pzccm}{m}{n}
+\DeclareSymbolFont{largesymbols}{OMX}{psycm}{m}{n}
+\DeclareSymbolFont{bold} {OT1}{ptm}{bx}{n}
+\DeclareSymbolFont{italic} {OT1}{ptm}{m}{it}
+%</mathptm>
+% \end{macrocode}
+%
+% Setting up the fonts for \textsf{mathptmx}:
+% \begin{macrocode}
+%<*mathptmx>
+\def\rmdefault{ptm}
+\DeclareSymbolFont{operators} {OT1}{ztmcm}{m}{n}
+\DeclareSymbolFont{letters} {OML}{ztmcm}{m}{it}
+\DeclareSymbolFont{symbols} {OMS}{ztmcm}{m}{n}
+\DeclareSymbolFont{largesymbols}{OMX}{ztmcm}{m}{n}
+\DeclareSymbolFont{bold} {OT1}{ptm}{bx}{n}
+\DeclareSymbolFont{italic} {OT1}{ptm}{m}{it}
+%</mathptmx>
+% \end{macrocode}
+%
+% Define +\mathbf+ and +\mathit+:
+% \begin{macrocode}
+%<*mathptm|mathptmx>
+\@ifundefined{mathbf}{}{\DeclareMathAlphabet{\mathbf}{OT1}{ptm}{bx}{n}}
+\@ifundefined{mathit}{}{\DeclareMathAlphabet{\mathit}{OT1}{ptm}{m}{it}}
+% \end{macrocode}
+%
+% An +\omicron+ command, to fill the gap:
+% \begin{macrocode}
+\DeclareMathSymbol{\omicron}{0}{operators}{`\o}
+% \end{macrocode}
+%
+% Lock unavailabe symbols:
+% \begin{macrocode}
+\renewcommand{\jmath}{%
+ \PackageError
+%<mathptm> {mathptm}
+%<mathptmx> {mathptmx}
+ {The symbols \protect\jmath, \protect\amalg\space and
+ \protect\coprod\MessageBreak
+ are not available with this package}
+ {Type \space <return> \space to proceed;
+ your command will be ignored.}}
+\let\amalg=\jmath
+\let\coprod=\jmath
+% \end{macrocode}
+%
+% Reduce the space around math operators:
+% \begin{macrocode}
+\thinmuskip=2mu
+\medmuskip=2.5mu plus 1mu minus 1mu
+\thickmuskip=4mu plus 1.5mu minus 1mu
+%</mathptm|mathptmx>
+% \end{macrocode}
+%
+% Make +\hbar+ work with Times.
+% \begin{macrocode}
+%<*mathptm>
+\def\hbar{{\mskip1.6mu\mathchar'26\mkern-7.6muh}}
+%</mathptm>
+% \end{macrocode}
+% With \textsf{mathptmx}, PSNFSS 9.0 and later is using an improved definition,
+% which was adopted from Frank Mittelbach's \textsf{mathtime} package:
+% \begin{macrocode}
+%<*mathptmx>
+\DeclareRobustCommand\hbar{{%
+ \dimen@.03em%
+ \dimen@ii.06em%
+ \def\@tempa##1##2{{%
+ \lower##1\dimen@\rlap{\kern##1\dimen@ii\the##2 0\char22}}}%
+ \mathchoice\@tempa\@ne\textfont
+ \@tempa\@ne\textfont
+ \@tempa\defaultscriptratio\scriptfont
+ \@tempa\defaultscriptscriptratio\scriptscriptfont
+ h}}
+%</mathptmx>
+% \end{macrocode}
+%
+% No bold math:
+% \begin{macrocode}
+%<*mathptm|mathptmx>
+\def\boldmath{%
+ \PackageWarning%
+%<mathptm> {mathptm}%
+%<mathptmx> {mathptmx}%
+ {There are no bold math fonts}%
+ \global\let\boldmath=\relax
+}
+%</mathptm|mathptmx>
+% \end{macrocode}
+%
+% Use larger font sizes for super- and subscripts:
+% \begin{macrocode}
+%<*mathptmx>
+\def\defaultscriptratio{.74}
+\def\defaultscriptscriptratio{.6}
+%</mathptmx>
+%<*mathptm|mathptmx>
+\DeclareMathSizes{5}{5}{5}{5}
+\DeclareMathSizes{6}{6}{5}{5}
+\DeclareMathSizes{7}{7}{5}{5}
+\DeclareMathSizes{8}{8}{6}{5}
+\DeclareMathSizes{9}{9}{7}{5}
+\DeclareMathSizes{10}{10}{7.4}{6}
+\DeclareMathSizes{10.95}{10.95}{8}{6}
+\DeclareMathSizes{12}{12}{9}{7}
+\DeclareMathSizes{14.4}{14.4}{10.95}{8}
+\DeclareMathSizes{17.28}{17.28}{12}{10}
+\DeclareMathSizes{20.74}{20.74}{14.4}{12}
+\DeclareMathSizes{24.88}{24.88}{17.28}{14.4}
+%</mathptm|mathptmx>
+% \end{macrocode}
+%
+% Option: Use slanted greek capitals (with \textsf{mathptmx} only):
+% \begin{macrocode}
+%<*mathptmx>
+\DeclareOption{slantedGreek}{%
+ \DeclareMathSymbol{\Gamma}{\mathalpha}{letters}{0}
+ \DeclareMathSymbol{\Delta}{\mathalpha}{letters}{1}
+ \DeclareMathSymbol{\Theta}{\mathalpha}{letters}{2}
+ \DeclareMathSymbol{\Lambda}{\mathalpha}{letters}{3}
+ \DeclareMathSymbol{\Xi}{\mathalpha}{letters}{4}
+ \DeclareMathSymbol{\Pi}{\mathalpha}{letters}{5}
+ \DeclareMathSymbol{\Sigma}{\mathalpha}{letters}{6}
+ \DeclareMathSymbol{\Upsilon}{\mathalpha}{letters}{7}
+ \DeclareMathSymbol{\Phi}{\mathalpha}{letters}{8}
+ \DeclareMathSymbol{\Psi}{\mathalpha}{letters}{9}
+ \DeclareMathSymbol{\Omega}{\mathalpha}{letters}{10}
+}
+\DeclareMathSymbol{\upGamma}{\mathord}{operators}{0}
+\DeclareMathSymbol{\upDelta}{\mathord}{operators}{1}
+\DeclareMathSymbol{\upTheta}{\mathord}{operators}{2}
+\DeclareMathSymbol{\upLambda}{\mathord}{operators}{3}
+\DeclareMathSymbol{\upXi}{\mathord}{operators}{4}
+\DeclareMathSymbol{\upPi}{\mathord}{operators}{5}
+\DeclareMathSymbol{\upSigma}{\mathord}{operators}{6}
+\DeclareMathSymbol{\upUpsilon}{\mathord}{operators}{7}
+\DeclareMathSymbol{\upPhi}{\mathord}{operators}{8}
+\DeclareMathSymbol{\upPsi}{\mathord}{operators}{9}
+\DeclareMathSymbol{\upOmega}{\mathord}{operators}{10}
+% \end{macrocode}
+%
+% Options processing:
+% \begin{macrocode}
+\ProcessOptions\relax
+%</mathptmx>
+% \end{macrocode}
+%
+% \begin{macrocode}
+%<*mathptm|mathptmx>
+\let\s@vedhbar\hbar
+\AtBeginDocument{%
+%</mathptm|mathptmx>
+% \end{macrocode}
+% Ensure proper scaling of the AMS fonts, even when not used
+% through the amssymb or amsfonts packages (\textsf{mathptmx} only):
+% \begin{macrocode}
+%<*mathptmx>
+ \DeclareFontFamily{U}{msa}{}%
+ \DeclareFontShape{U}{msa}{m}{n}{<->msam10}{}%
+ \DeclareFontFamily{U}{msb}{}%
+ \DeclareFontShape{U}{msb}{m}{n}{<->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}{}%
+%</mathptmx>
+% \end{macrocode}
+% In case the \textsf{amsfonts} package is loaded additionally,
+% we must restore our +\hbar+:
+% \begin{macrocode}
+%<*mathptm|mathptmx>
+ \@ifpackageloaded{amsfonts}{\let\hbar\s@vedhbar}{}
+% \end{macrocode}
+% Take care of +\big+ \&\ friends working with scaled math extension font,
+% unless amsmath.sty is also loaded:
+% \begin{macrocode}
+ \@ifpackageloaded{amsmath}{}{%
+ \newdimen\big@size
+ \addto@hook\every@math@size{\setbox\z@\vbox{\hbox{$($}\kern\z@}%
+ \global\big@size 1.2\ht\z@}
+ \def\bBigg@#1#2{%
+ {\hbox{$\left#2\vcenter to#1\big@size{}\right.\n@space$}}}
+ \def\big{\bBigg@\@ne}
+ \def\Big{\bBigg@{1.5}}
+ \def\bigg{\bBigg@\tw@}
+ \def\Bigg{\bBigg@{2.5}}
+ }
+}
+%</mathptm|mathptmx>
+% \end{macrocode}
+%
+% \subsection*{Credits}
+% The virtual mathptm and mathptmx fonts and the related packages
+% were created by Alan Jeffrey, Sebastian Rahtz and Ulrik Vieth.
+%
+% \section{The \textsf{mathpple} package}
+% Suppress info about math fonts being redefined:
+% \begin{macrocode}
+%<*mathpple>
+\PackageWarningNoLine{mathpple}{%
+ This package is to be regarded as obsolete.\MessageBreak
+ See the PSNFSS documentation}
+\let\s@ved@info\@font@info
+\let\@font@info\@gobble
+% \end{macrocode}
+%
+% Make Palatino the default roman font:
+% \begin{macrocode}
+\renewcommand{\rmdefault}{ppl}
+% \end{macrocode}
+%
+% Typeset mathematics using the mathpple fonts:
+% \begin{macrocode}
+\DeclareSymbolFont{operators} {OT1}{zpple}{m}{n}
+\DeclareSymbolFont{letters} {OML}{zpple}{m}{it}
+\DeclareSymbolFont{symbols} {OMS}{zpple}{m}{n}
+\DeclareSymbolFont{largesymbols}{OMX}{zpple}{m}{n}
+\DeclareMathAlphabet{\mathbf} {OT1}{zpple}{b}{n}
+\DeclareMathAlphabet{\mathit} {OT1}{ppl}{m}{it}
+% \end{macrocode}
+%
+% Support for bold mathversion:
+% \begin{macrocode}
+\SetSymbolFont{operators}{bold}{OT1}{zpple}{b}{n}
+\SetSymbolFont{letters}{bold}{OML}{zpple}{b}{it}
+\SetSymbolFont{symbols}{bold}{OMS}{zpple}{b}{n}
+\SetSymbolFont{largesymbols}{bold}{OMX}{zpple}{m}{n}
+\SetMathAlphabet\mathit{bold}{OT1}{ppl}{b}{it}
+% \end{macrocode}
+%
+% Reduce the space around math operators:
+% \begin{macrocode}
+%\thinmuskip=2.5mu
+\medmuskip=3.5mu plus 1mu minus 1mu
+%\thickmuskip=4.5mu plus 1.5mu minus 1mu
+% \end{macrocode}
+%
+% Compensate for increased letter spacing
+% \begin{macrocode}
+\def\joinrel{\mathrel{\mkern-3.45mu}}
+% \end{macrocode}
+%
+% Make +\hbar+ work with Palatino:
+% \begin{macrocode}
+\def\hbar{{\mathchar'26\mkern-7muh}}
+% \end{macrocode}
+%
+% Define a new math alphabet for bold italic variables:
+% \begin{macrocode}
+\DeclareMathAlphabet{\mathbold}{OML}{zpple}{b}{it}
+% \end{macrocode}
+%
+% Make +\mathbold+ act on lowercase greek, too:
+% \begin{macrocode}
+\DeclareMathSymbol{\alpha}{\mathalpha}{letters}{11}
+\DeclareMathSymbol{\beta}{\mathalpha}{letters}{12}
+\DeclareMathSymbol{\gamma}{\mathalpha}{letters}{13}
+\DeclareMathSymbol{\delta}{\mathalpha}{letters}{14}
+\DeclareMathSymbol{\epsilon}{\mathalpha}{letters}{15}
+\DeclareMathSymbol{\zeta}{\mathalpha}{letters}{16}
+\DeclareMathSymbol{\eta}{\mathalpha}{letters}{17}
+\DeclareMathSymbol{\theta}{\mathalpha}{letters}{18}
+\DeclareMathSymbol{\iota}{\mathalpha}{letters}{19}
+\DeclareMathSymbol{\kappa}{\mathalpha}{letters}{20}
+\DeclareMathSymbol{\lambda}{\mathalpha}{letters}{21}
+\DeclareMathSymbol{\mu}{\mathalpha}{letters}{22}
+\DeclareMathSymbol{\nu}{\mathalpha}{letters}{23}
+\DeclareMathSymbol{\xi}{\mathalpha}{letters}{24}
+\DeclareMathSymbol{\pi}{\mathalpha}{letters}{25}
+\DeclareMathSymbol{\rho}{\mathalpha}{letters}{26}
+\DeclareMathSymbol{\sigma}{\mathalpha}{letters}{27}
+\DeclareMathSymbol{\tau}{\mathalpha}{letters}{28}
+\DeclareMathSymbol{\upsilon}{\mathalpha}{letters}{29}
+\DeclareMathSymbol{\phi}{\mathalpha}{letters}{30}
+\DeclareMathSymbol{\chi}{\mathalpha}{letters}{31}
+\DeclareMathSymbol{\psi}{\mathalpha}{letters}{32}
+\DeclareMathSymbol{\omega}{\mathalpha}{letters}{33}
+\DeclareMathSymbol{\varepsilon}{\mathalpha}{letters}{34}
+\DeclareMathSymbol{\vartheta}{\mathalpha}{letters}{35}
+\DeclareMathSymbol{\varpi}{\mathalpha}{letters}{36}
+\DeclareMathSymbol{\varphi}{\mathalpha}{letters}{39}
+\let\varrho\rho
+\let\varsigma\sigma
+% \end{macrocode}
+%
+% We redefine the default sizes for super- and subscripts.
+% Palatino, like most other type 1 fonts, is scaled linearly, so the
+% default ratios (.7 and .5) may produce unreadably small characters:
+% \begin{macrocode}
+\def\defaultscriptratio{.76}
+\def\defaultscriptscriptratio{.6}
+% \end{macrocode}
+%
+% These default ratios are not used for any sizes that have been
+% explicitly declared, so we redeclare the sizes used by the standard
+% classes. At least for the lower sizes this is important as we don't
+% want to end up with a 5pt font being reduced even further:
+% \begin{macrocode}
+\DeclareMathSizes{5} {5} {5} {5}
+\DeclareMathSizes{6} {6} {5} {5}
+\DeclareMathSizes{7} {7} {5} {5}
+\DeclareMathSizes{8} {8} {6} {5}
+\DeclareMathSizes{9} {9} {7} {5}
+\DeclareMathSizes{10} {10} {7.6} {6}
+\DeclareMathSizes{10.95}{10.95}{8} {6}
+\DeclareMathSizes{12} {12} {9} {7}
+\DeclareMathSizes{14.4} {14.4} {10} {8}
+\DeclareMathSizes{17.28}{17.28}{12} {10}
+\DeclareMathSizes{20.74}{20.74}{14.4} {12}
+\DeclareMathSizes{24.88}{24.88}{20.74}{14.4}
+% \end{macrocode}
+%
+% Option: Use slanted greek capitals:
+% \begin{macrocode}
+\DeclareOption{slantedGreek}{%
+ \DeclareMathSymbol{\Gamma}{\mathalpha}{letters}{0}
+ \DeclareMathSymbol{\Delta}{\mathalpha}{letters}{1}
+ \DeclareMathSymbol{\Theta}{\mathalpha}{letters}{2}
+ \DeclareMathSymbol{\Lambda}{\mathalpha}{letters}{3}
+ \DeclareMathSymbol{\Xi}{\mathalpha}{letters}{4}
+ \DeclareMathSymbol{\Pi}{\mathalpha}{letters}{5}
+ \DeclareMathSymbol{\Sigma}{\mathalpha}{letters}{6}
+ \DeclareMathSymbol{\Upsilon}{\mathalpha}{letters}{7}
+ \DeclareMathSymbol{\Phi}{\mathalpha}{letters}{8}
+ \DeclareMathSymbol{\Psi}{\mathalpha}{letters}{9}
+ \DeclareMathSymbol{\Omega}{\mathalpha}{letters}{10}
+}
+\let\upOmega\Omega
+\let\upDelta\Delta
+% \end{macrocode}
+%
+% Options processing:
+% \begin{macrocode}
+\ProcessOptions\relax
+% \end{macrocode}
+%
+% \begin{macrocode}
+\let\s@vedhbar\hbar
+\AtBeginDocument{%
+% \end{macrocode}
+% Ensure proper scaling of the AMS fonts, even when not used
+% through the amssymb or amsfonts packages:
+% \begin{macrocode}
+ \DeclareFontFamily{U}{msa}{}%
+ \DeclareFontShape{U}{msa}{m}{n}{<->s*[1.042]msam10}{}%
+ \DeclareFontFamily{U}{msb}{}%
+ \DeclareFontShape{U}{msb}{m}{n}{<->s*[1.042]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}{}%
+% \end{macrocode}
+% In case the \textsf{amsfonts} package is loaded additionally,
+% we must restore our +\hbar+:
+% \begin{macrocode}
+ \@ifpackageloaded{amsfonts}{\let\hbar\s@vedhbar}{}
+% \end{macrocode}
+% Take care of +\big+ \&\ friends working with scaled math extension font,
+% unless amsmath.sty is also loaded:
+% \begin{macrocode}
+ \@ifpackageloaded{amsmath}{}{%
+ \newdimen\big@size
+ \addto@hook\every@math@size{\setbox\z@\vbox{\hbox{$($}\kern\z@}%
+ \global\big@size 1.2\ht\z@}
+ \def\bBigg@#1#2{%
+ {\hbox{$\left#2\vcenter to#1\big@size{}\right.\n@space$}}}
+ \def\big{\bBigg@\@ne}
+ \def\Big{\bBigg@{1.5}}
+ \def\bigg{\bBigg@\tw@}
+ \def\Bigg{\bBigg@{2.5}}
+ }
+}
+% \end{macrocode}
+%
+% Restore font info:
+% \begin{macrocode}
+\let\@font@info\s@ved@info
+%</mathpple>
+% \end{macrocode}
+%
+% \subsection*{Credits}
+% \textsf{mathpple} is based on the package \textsf{mathppl}
+% and the related virtual fonts, created by Aloysius Helminck.
+% These were distributed in conjunction with \textsc{fontinst}~v1.335,
+% but are no longer available from CTAN.
+% The main changes with regard to Helminck's model are:
+% \begin{itemize}
+% \item
+% italic Greek letters from the Euler fonts;
+% \item
+% +\mathcal+ from CM instead of Zapf~Chancery;
+% \item
+% positioning of math accents substantially improved;
+% \item
+% improved spacing;
+% \item
+% use those Type~1 fonts only, which are part of the free
+% `BlueSky' distribution.
+% \end{itemize}
+% Special thanks to Daniel Schlieper, who suggested the
+% development of the \textsf{mathpple} package,
+% contributed many good ideas and helped with testing.
+%
+%
+% \section{The \textsf{charter} package}
+% \begin{macrocode}
+%<*charter>
+\renewcommand{\rmdefault}{bch}
+\renewcommand{\bfdefault}{b}
+%</charter>
+% \end{macrocode}
+%
+% \section{The \textsf{utopia} package}
+% \begin{macrocode}
+%<*utopia>
+\PackageWarningNoLine{utopia}{%
+ This package is to be regarded as obsolete.\MessageBreak
+ See the PSNFSS documentation}
+\renewcommand{\rmdefault}{put}
+\renewcommand\bfdefault{b}
+%</utopia>
+% \end{macrocode}
+%
+%
+% \section{The \textsf{mathpazo} package}
+% Suppress info about math fonts being redefined:
+% \begin{macrocode}
+%<*mathpazo>
+\let\s@ved@info\@font@info
+\let\@font@info\@gobble
+% \end{macrocode}
+%
+% Options processing:
+% \begin{macrocode}
+\newif\ifpazo@osf
+\newif\ifpazo@sc
+\newif\ifpazo@slGreek
+\newif\ifpazo@BB \pazo@BBtrue
+\DeclareOption{osf}{\pazo@osftrue}
+\DeclareOption{sc}{\pazo@sctrue}
+\DeclareOption{slantedGreek}{\pazo@slGreektrue}
+\DeclareOption{noBBpl}{\pazo@BBfalse}
+\DeclareOption{osfeqnnum}{\OptionNotUsed}
+\ProcessOptions\relax
+% \end{macrocode}
+%
+% Make Palatino (+ppl+) the default roman font.
+% If the options +osf+ or +sc+ were specified,
+% use +pplj+ or +pplx+ instead,
+% and make sure that +\oldstylenums+ switches to +pplj+, too.
+% \begin{macrocode}
+\ifpazo@osf
+ \renewcommand{\rmdefault}{pplj}
+ \renewcommand{\oldstylenums}[1]{%
+ {\fontfamily{pplj}\selectfont #1}}
+\else\ifpazo@sc
+ \renewcommand{\rmdefault}{pplx}
+ \renewcommand{\oldstylenums}[1]{%
+ {\fontfamily{pplj}\selectfont #1}}
+\else
+ \renewcommand{\rmdefault}{ppl}
+\fi\fi
+% \end{macrocode}
+%
+% The Pazo fonts provide an Euro symbol, which is now available in the
+% Palatino text companion fonts. For the sake of compatibility, we still define
+% the macro +\ppleuro+, which was introduced with version 8.2, and
+% we make it work with the
+% \textsf{eurofont} and \textsf{europs} packages:
+% \begin{macrocode}
+\newcommand{\ppleuro}{{\fontencoding{U}\fontfamily{fplm}\selectfont \char160}}
+\AtBeginDocument{\@ifpackageloaded{europs}{\renewcommand{\EURtm}{\ppleuro}}{}}
+% \end{macrocode}
+%
+% Now we declare the math fonts. The \textsf{mathpazo} package uses
+% a Palatino text font family with OT1 encoding
+% as the +operators+ and +\mathit+ alphabets.
+% If the +sc+ option was specified, we use the family +pplx+.
+% Otherwise we just take +ppl+, thus making sure that no oldstyle digits are
+% used in math mode. Note that specifying both +sc+ and +osf+ gives
+% oldstyle numbers in text and uses the family +pplx+ in math mode,
+% so that the +ppl+ family is not required at all. Thus, the number
+% of TFM's loaded by \TeX{} is minimized.
+% \begin{macrocode}
+\ifpazo@sc
+ \DeclareSymbolFont{operators} {OT1}{pplx}{m}{n}
+ \SetSymbolFont{operators}{bold} {OT1}{pplx}{b}{n}
+ \DeclareMathAlphabet{\mathit} {OT1}{pplx}{m}{it}
+ \SetMathAlphabet{\mathit}{bold} {OT1}{pplx}{b}{it}
+\else
+ \DeclareSymbolFont{operators} {OT1}{ppl}{m}{n}
+ \SetSymbolFont{operators}{bold} {OT1}{ppl}{b}{n}
+ \DeclareMathAlphabet{\mathit} {OT1}{ppl}{m}{it}
+ \SetMathAlphabet{\mathit}{bold} {OT1}{ppl}{b}{it}
+\fi
+% \end{macrocode}
+% Uppercase upright Greek
+% and math symbols such as `plus', `equal' and others
+% are taken from a new symbol font named +upright+.
+% Its spacing is less tight than in the text font.
+% \begin{macrocode}
+\DeclareSymbolFont{upright} {OT1}{zplm}{m}{n}
+\DeclareSymbolFont{letters} {OML}{zplm}{m}{it}
+\DeclareSymbolFont{symbols} {OMS}{zplm}{m}{n}
+\DeclareSymbolFont{largesymbols} {OMX}{zplm}{m}{n}
+% \end{macrocode}
+% \begin{macrocode}
+\SetSymbolFont{upright}{bold} {OT1}{zplm}{b}{n}
+\SetSymbolFont{letters}{bold} {OML}{zplm}{b}{it}
+\SetSymbolFont{symbols}{bold} {OMS}{zplm}{b}{n}
+\SetSymbolFont{largesymbols}{bold}{OMX}{zplm}{m}{n}
+% \end{macrocode}
+% \begin{macrocode}
+\DeclareMathAlphabet{\mathbf} {OT1}{zplm}{b}{n}
+\DeclareMathAlphabet{\mathbold} {OML}{zplm}{b}{it}
+% \end{macrocode}
+% \begin{macrocode}
+\DeclareSymbolFontAlphabet{\mathrm} {operators}
+\DeclareSymbolFontAlphabet{\mathnormal}{letters}
+\DeclareSymbolFontAlphabet{\mathcal} {symbols}
+% \end{macrocode}
+%
+% The following symbols used to come from `operators';
+% we take them from the `upright' symbol font now:
+% \begin{macrocode}
+\DeclareMathSymbol{!}{\mathclose}{upright}{"21}
+\DeclareMathSymbol{+}{\mathbin}{upright}{"2B}
+\DeclareMathSymbol{:}{\mathrel}{upright}{"3A}
+% \DeclareMathSymbol{;}{\mathpunct}{operators}{"3B} % punctuation!
+\DeclareMathSymbol{=}{\mathrel}{upright}{"3D}
+\DeclareMathSymbol{?}{\mathclose}{upright}{"3F}
+\DeclareMathDelimiter{(}{\mathopen} {upright}{"28}{largesymbols}{"00}
+\DeclareMathDelimiter{)}{\mathclose}{upright}{"29}{largesymbols}{"01}
+\DeclareMathDelimiter{[}{\mathopen} {upright}{"5B}{largesymbols}{"02}
+\DeclareMathDelimiter{]}{\mathclose}{upright}{"5D}{largesymbols}{"03}
+\DeclareMathDelimiter{/}{\mathord}{upright}{"2F}{largesymbols}{"0E}
+% \DeclareMathSymbol{\colon}{\mathpunct}{operators}{"3A} % punctuation!
+\DeclareMathAccent{\acute}{\mathalpha}{upright}{"13}
+\DeclareMathAccent{\grave}{\mathalpha}{upright}{"12}
+\DeclareMathAccent{\ddot}{\mathalpha}{upright}{"7F}
+\DeclareMathAccent{\tilde}{\mathalpha}{upright}{"7E}
+\DeclareMathAccent{\bar}{\mathalpha}{upright}{"16}
+\DeclareMathAccent{\breve}{\mathalpha}{upright}{"15}
+\DeclareMathAccent{\check}{\mathalpha}{upright}{"14}
+\DeclareMathAccent{\hat}{\mathalpha}{upright}{"5E}
+\DeclareMathAccent{\dot}{\mathalpha}{upright}{"5F}
+\DeclareMathAccent{\mathring}{\mathalpha}{upright}{"17}
+\DeclareMathSymbol{\mathdollar}{\mathord}{upright}{"24}
+% \end{macrocode}
+% As to uppercase Greek, see below!
+%
+% The follwowing symbols used to come from `letters'.
+% Now they are taken from `operators', with respect to
+% correct spacing of decimal numbers:
+% \begin{macrocode}
+\DeclareMathSymbol{,}{\mathpunct}{operators}{44}
+\DeclareMathSymbol{.}{\mathord}{operators}{46}
+% \end{macrocode}
+%
+% Use Pazo as (partial) +\mathbb+ font:
+% \begin{macrocode}
+\ifpazo@BB
+ \AtBeginDocument{%
+ \let\mathbb\relax
+ \DeclareMathAlphabet\PazoBB{U}{fplmbb}{m}{n}
+ \newcommand{\mathbb}{\PazoBB}
+ }
+\fi
+% \end{macrocode}
+%
+% Reduce the space around math operators:
+% \begin{macrocode}
+%\thinmuskip=2.5mu
+\medmuskip=3.5mu plus 1mu minus 1mu
+%\thickmuskip=4.5mu plus 1.5mu minus 1mu
+% \end{macrocode}
+%
+% Compensate for increased letter spacing:
+% \begin{macrocode}
+\def\joinrel{\mathrel{\mkern-3.45mu}}
+% \end{macrocode}
+%
+% Make +\hbar+ work with Palatino:
+% \begin{macrocode}
+\renewcommand{\hbar}{{\mkern0.8mu\mathchar'26\mkern-6.8muh}}
+% \end{macrocode}
+%
+% Optionally use slanted greek capitals:
+% \begin{macrocode}
+\ifpazo@slGreek
+ \DeclareMathSymbol{\Gamma} {\mathalpha}{letters}{"00}
+ \DeclareMathSymbol{\Delta} {\mathalpha}{letters}{"01}
+ \DeclareMathSymbol{\Theta} {\mathalpha}{letters}{"02}
+ \DeclareMathSymbol{\Lambda} {\mathalpha}{letters}{"03}
+ \DeclareMathSymbol{\Xi} {\mathalpha}{letters}{"04}
+ \DeclareMathSymbol{\Pi} {\mathalpha}{letters}{"05}
+ \DeclareMathSymbol{\Sigma} {\mathalpha}{letters}{"06}
+ \DeclareMathSymbol{\Upsilon}{\mathalpha}{letters}{"07}
+ \DeclareMathSymbol{\Phi} {\mathalpha}{letters}{"08}
+ \DeclareMathSymbol{\Psi} {\mathalpha}{letters}{"09}
+ \DeclareMathSymbol{\Omega} {\mathalpha}{letters}{"0A}
+\else
+ \DeclareMathSymbol{\Gamma}{\mathalpha}{upright}{"00}
+ \DeclareMathSymbol{\Delta}{\mathalpha}{upright}{"01}
+ \DeclareMathSymbol{\Theta}{\mathalpha}{upright}{"02}
+ \DeclareMathSymbol{\Lambda}{\mathalpha}{upright}{"03}
+ \DeclareMathSymbol{\Xi}{\mathalpha}{upright}{"04}
+ \DeclareMathSymbol{\Pi}{\mathalpha}{upright}{"05}
+ \DeclareMathSymbol{\Sigma}{\mathalpha}{upright}{"06}
+ \DeclareMathSymbol{\Upsilon}{\mathalpha}{upright}{"07}
+ \DeclareMathSymbol{\Phi}{\mathalpha}{upright}{"08}
+ \DeclareMathSymbol{\Psi}{\mathalpha}{upright}{"09}
+ \DeclareMathSymbol{\Omega}{\mathalpha}{upright}{"0A}
+\fi
+% \end{macrocode}
+% These symbols should always be upright:
+% \begin{macrocode}
+\DeclareMathSymbol{\upGamma}{\mathord}{upright}{0}
+\DeclareMathSymbol{\upDelta}{\mathord}{upright}{1}
+\DeclareMathSymbol{\upTheta}{\mathord}{upright}{2}
+\DeclareMathSymbol{\upLambda}{\mathord}{upright}{3}
+\DeclareMathSymbol{\upXi}{\mathord}{upright}{4}
+\DeclareMathSymbol{\upPi}{\mathord}{upright}{5}
+\DeclareMathSymbol{\upSigma}{\mathord}{upright}{6}
+\DeclareMathSymbol{\upUpsilon}{\mathord}{upright}{7}
+\DeclareMathSymbol{\upPhi}{\mathord}{upright}{8}
+\DeclareMathSymbol{\upPsi}{\mathord}{upright}{9}
+\DeclareMathSymbol{\upOmega}{\mathord}{upright}{10}
+% \end{macrocode}
+% Make +\mathbold+ act on lowercase greek too
+% \begin{macrocode}
+\DeclareMathSymbol{\alpha}{\mathalpha}{letters}{"0B}
+\DeclareMathSymbol{\beta}{\mathalpha}{letters}{"0C}
+\DeclareMathSymbol{\gamma}{\mathalpha}{letters}{"0D}
+\DeclareMathSymbol{\delta}{\mathalpha}{letters}{"0E}
+\DeclareMathSymbol{\epsilon}{\mathalpha}{letters}{"0F}
+\DeclareMathSymbol{\zeta}{\mathalpha}{letters}{"10}
+\DeclareMathSymbol{\eta}{\mathalpha}{letters}{"11}
+\DeclareMathSymbol{\theta}{\mathalpha}{letters}{"12}
+\DeclareMathSymbol{\iota}{\mathalpha}{letters}{"13}
+\DeclareMathSymbol{\kappa}{\mathalpha}{letters}{"14}
+\DeclareMathSymbol{\lambda}{\mathalpha}{letters}{"15}
+\DeclareMathSymbol{\mu}{\mathalpha}{letters}{"16}
+\DeclareMathSymbol{\nu}{\mathalpha}{letters}{"17}
+\DeclareMathSymbol{\xi}{\mathalpha}{letters}{"18}
+\DeclareMathSymbol{\pi}{\mathalpha}{letters}{"19}
+\DeclareMathSymbol{\rho}{\mathalpha}{letters}{"1A}
+\DeclareMathSymbol{\sigma}{\mathalpha}{letters}{"1B}
+\DeclareMathSymbol{\tau}{\mathalpha}{letters}{"1C}
+\DeclareMathSymbol{\upsilon}{\mathalpha}{letters}{"1D}
+\DeclareMathSymbol{\phi}{\mathalpha}{letters}{"1E}
+\DeclareMathSymbol{\chi}{\mathalpha}{letters}{"1F}
+\DeclareMathSymbol{\psi}{\mathalpha}{letters}{"20}
+\DeclareMathSymbol{\omega}{\mathalpha}{letters}{"21}
+\DeclareMathSymbol{\varepsilon}{\mathalpha}{letters}{"22}
+\DeclareMathSymbol{\vartheta}{\mathalpha}{letters}{"23}
+\DeclareMathSymbol{\varpi}{\mathalpha}{letters}{"24}
+\DeclareMathSymbol{\varrho}{\mathalpha}{letters}{"25}
+\DeclareMathSymbol{\varsigma}{\mathalpha}{letters}{"26}
+\DeclareMathSymbol{\varphi}{\mathalpha}{letters}{"27}
+% \end{macrocode}
+%
+% Finally, we save our new definition of +\hbar+ and defer some code
+% until +\begin{document}+:
+% \begin{macrocode}
+\let\s@vedhbar\hbar
+\AtBeginDocument{%
+% \end{macrocode}
+% Ensure proper scaling of the AMS fonts, even when not used
+% through the amssymb or amsfonts packages:
+% \begin{macrocode}
+ \DeclareFontFamily{U}{msa}{}%
+ \DeclareFontShape{U}{msa}{m}{n}{<->s*[1.042]msam10}{}%
+ \DeclareFontFamily{U}{msb}{}%
+ \DeclareFontShape{U}{msb}{m}{n}{<->s*[1.042]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}{}%
+% \end{macrocode}
+% In case the \textsf{amsfonts} package is loaded additionally,
+% we must restore our +\hbar+:
+% \begin{macrocode}
+ \@ifpackageloaded{amsfonts}{\let\hbar\s@vedhbar}{}
+% \end{macrocode}
+% Take care of +\big+ \&\ friends working with scaled math extension font,
+% unless amsmath.sty is also loaded:
+% \begin{macrocode}
+ \@ifpackageloaded{amsmath}{}{%
+ \newdimen\big@size
+ \addto@hook\every@math@size{\setbox\z@\vbox{\hbox{$($}\kern\z@}%
+ \global\big@size 1.2\ht\z@}
+ \def\bBigg@#1#2{%
+ {\hbox{$\left#2\vcenter to#1\big@size{}\right.\n@space$}}}
+ \def\big{\bBigg@\@ne}
+ \def\Big{\bBigg@{1.5}}
+ \def\bigg{\bBigg@\tw@}
+ \def\Bigg{\bBigg@{2.5}}
+ }
+}
+% \end{macrocode}
+%
+% We redefine the default sizes for super and subscripts.
+% Palatino, like most other type 1 fonts, is scaled linearly, so the
+% default ratios (0.7 and 0.5) may produce unreadably small characters.
+% \begin{macrocode}
+\def\defaultscriptratio{.76}
+\def\defaultscriptscriptratio{.6}
+% \end{macrocode}
+% These default ratios are not used for any sizes that have been
+% explicitly declared, so we redeclare the sizes used by the standard
+% classes. At least for the lower sizes this is important as we don't
+% want to end up with a 5pt font being reduced even further.
+% \begin{macrocode}
+\DeclareMathSizes{5} {5} {5} {5}
+\DeclareMathSizes{6} {6} {5} {5}
+\DeclareMathSizes{7} {7} {5} {5}
+\DeclareMathSizes{8} {8} {6} {5}
+\DeclareMathSizes{9} {9} {7} {5}
+\DeclareMathSizes{10} {10} {7.6} {6}
+\DeclareMathSizes{10.95}{10.95}{8} {6}
+\DeclareMathSizes{12} {12} {9} {7}
+\DeclareMathSizes{14.4} {14.4} {10} {8}
+\DeclareMathSizes{17.28}{17.28}{12} {10}
+\DeclareMathSizes{20.74}{20.74}{14.4} {12}
+\DeclareMathSizes{24.88}{24.88}{20.74}{14.4}
+% \end{macrocode}
+%
+% Restore font info:
+% \begin{macrocode}
+\let\@font@info\s@ved@info
+%</mathpazo>
+% \end{macrocode}
+%
+% \subsection*{Credits}
+% The Pazo fonts and the related virtual fonts
+% were created by Diego Puga.
+% The \textsf{mathpazo} package was written by D.~Puga and W.~Schmidt.
+% \Finale
+%
+\endinput
+%
+%% \CharacterTable
+%% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
+%% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
+%% Digits \0\1\2\3\4\5\6\7\8\9
+%% Exclamation \! Double quote \" Hash (number) \#
+%% Dollar \$ Percent \% Ampersand \&
+%% Acute accent \' Left paren \( Right paren \)
+%% Asterisk \* Plus \+ Comma \,
+%% Minus \- Point \. Solidus \/
+%% Colon \: Semicolon \; Less than \<
+%% Equals \= Greater than \> Question mark \?
+%% Commercial at \@ Left bracket \[ Backslash \\
+%% Right bracket \] Circumflex \^ Underscore \_
+%% Grave accent \` Left brace \{ Vertical bar \|
+%% Right brace \} Tilde \~}
diff --git a/macros/latex/required/psnfss/psfonts.ins b/macros/latex/required/psnfss/psfonts.ins
new file mode 100644
index 0000000000..82db7cefa2
--- /dev/null
+++ b/macros/latex/required/psnfss/psfonts.ins
@@ -0,0 +1,24 @@
+%\NeedsTeXFormat{LaTeX2e}[1996/12/01]
+\input docstrip
+\usedir{tex/latex/psnfss}
+\askonceonly
+\keepsilent
+
+\generate{\file{times.sty} {\from{psfonts.dtx}{times}}
+ \file{palatino.sty} {\from{psfonts.dtx}{palatino}}
+ \file{courier.sty} {\from{psfonts.dtx}{courier}}
+ \file{helvet.sty}{\from{psfonts.dtx}{helvet}}
+ \file{avant.sty}{\from{psfonts.dtx}{avant}}
+ \file{newcent.sty} {\from{psfonts.dtx}{newcent}}
+ \file{bookman.sty} {\from{psfonts.dtx}{bookman}}
+ \file{chancery.sty} {\from{psfonts.dtx}{chancery}}
+ \file{pifont.sty} {\from{psfonts.dtx}{pifont}}
+ \file{mathpple.sty} {\from{psfonts.dtx}{mathpple}}
+ \file{mathptm.sty} {\from{psfonts.dtx}{mathptm}}
+ \file{mathptmx.sty} {\from{psfonts.dtx}{mathptmx}}
+ \file{charter.sty} {\from{psfonts.dtx}{charter}}
+ \file{utopia.sty} {\from{psfonts.dtx}{utopia}}
+ \file{mathpazo.sty} {\from{psfonts.dtx}{mathpazo}}
+}
+
+\endbatchfile
diff --git a/macros/latex/required/psnfss/psnfss.map b/macros/latex/required/psnfss/psnfss.map
new file mode 100644
index 0000000000..2069eb4102
--- /dev/null
+++ b/macros/latex/required/psnfss/psnfss.map
@@ -0,0 +1,48 @@
+% dvips font map file for the Base35 fonts [PSNFSS 8.1 (WaS)]
+%
+eurmo10 EURM10 " .167 SlantFont" <eurm10.pfb
+eurbo10 EURB10 " .167 SlantFont" <eurb10.pfb
+pagd8r AvantGarde-Demi "TeXBase1Encoding ReEncodeFont" <8r.enc
+pagdo8r AvantGarde-DemiOblique "TeXBase1Encoding ReEncodeFont" <8r.enc
+pagk8r AvantGarde-Book "TeXBase1Encoding ReEncodeFont" <8r.enc
+pagko8r AvantGarde-BookOblique "TeXBase1Encoding ReEncodeFont" <8r.enc
+pbkd8r Bookman-Demi "TeXBase1Encoding ReEncodeFont" <8r.enc
+pbkdi8r Bookman-DemiItalic "TeXBase1Encoding ReEncodeFont" <8r.enc
+pbkdo8r Bookman-Demi " .167 SlantFont TeXBase1Encoding ReEncodeFont" <8r.enc
+pbkl8r Bookman-Light "TeXBase1Encoding ReEncodeFont" <8r.enc
+pbkli8r Bookman-LightItalic "TeXBase1Encoding ReEncodeFont" <8r.enc
+pbklo8r Bookman-Light " .167 SlantFont TeXBase1Encoding ReEncodeFont" <8r.enc
+pcrb8r Courier-Bold "TeXBase1Encoding ReEncodeFont" <8r.enc
+pcrbo8r Courier-BoldOblique "TeXBase1Encoding ReEncodeFont" <8r.enc
+pcrr8r Courier "TeXBase1Encoding ReEncodeFont" <8r.enc
+pcrro8r Courier-Oblique "TeXBase1Encoding ReEncodeFont" <8r.enc
+phvb8r Helvetica-Bold "TeXBase1Encoding ReEncodeFont" <8r.enc
+phvb8rn Helvetica-Narrow-Bold "TeXBase1Encoding ReEncodeFont" <8r.enc
+phvbo8r Helvetica-BoldOblique "TeXBase1Encoding ReEncodeFont" <8r.enc
+phvbo8rn Helvetica-Narrow-BoldOblique "TeXBase1Encoding ReEncodeFont" <8r.enc
+phvr8r Helvetica "TeXBase1Encoding ReEncodeFont" <8r.enc
+phvr8rn Helvetica-Narrow "TeXBase1Encoding ReEncodeFont" <8r.enc
+phvro8r Helvetica-Oblique "TeXBase1Encoding ReEncodeFont" <8r.enc
+phvro8rn Helvetica-Narrow-Oblique "TeXBase1Encoding ReEncodeFont" <8r.enc
+pncb8r NewCenturySchlbk-Bold "TeXBase1Encoding ReEncodeFont" <8r.enc
+pncbi8r NewCenturySchlbk-BoldItalic "TeXBase1Encoding ReEncodeFont" <8r.enc
+pncbo8r NewCenturySchlbk-Bold " .167 SlantFont TeXBase1Encoding ReEncodeFont" <8r.enc
+pncr8r NewCenturySchlbk-Roman "TeXBase1Encoding ReEncodeFont" <8r.enc
+pncri8r NewCenturySchlbk-Italic "TeXBase1Encoding ReEncodeFont" <8r.enc
+pncro8r NewCenturySchlbk-Roman " .167 SlantFont TeXBase1Encoding ReEncodeFont" <8r.enc
+pplb8r Palatino-Bold "TeXBase1Encoding ReEncodeFont" <8r.enc
+pplbi8r Palatino-BoldItalic "TeXBase1Encoding ReEncodeFont" <8r.enc
+pplbo8r Palatino-Bold " .167 SlantFont TeXBase1Encoding ReEncodeFont" <8r.enc
+pplr8r Palatino-Roman "TeXBase1Encoding ReEncodeFont" <8r.enc
+pplri8r Palatino-Italic "TeXBase1Encoding ReEncodeFont" <8r.enc
+pplro8r Palatino-Roman " .167 SlantFont TeXBase1Encoding ReEncodeFont" <8r.enc
+psyr Symbol
+psyro Symbol " .167 SlantFont "
+ptmb8r Times-Bold "TeXBase1Encoding ReEncodeFont" <8r.enc
+ptmbi8r Times-BoldItalic "TeXBase1Encoding ReEncodeFont" <8r.enc
+ptmbo8r Times-Bold " .167 SlantFont TeXBase1Encoding ReEncodeFont" <8r.enc
+ptmr8r Times-Roman "TeXBase1Encoding ReEncodeFont" <8r.enc
+ptmri8r Times-Italic "TeXBase1Encoding ReEncodeFont" <8r.enc
+ptmro8r Times-Roman " .167 SlantFont TeXBase1Encoding ReEncodeFont" <8r.enc
+pzcmi8r ZapfChancery-MediumItalic "TeXBase1Encoding ReEncodeFont" <8r.enc
+pzdr ZapfDingbats
diff --git a/macros/latex/required/psnfss/psnfss2e.pdf b/macros/latex/required/psnfss/psnfss2e.pdf
new file mode 100644
index 0000000000..c7f27997cd
--- /dev/null
+++ b/macros/latex/required/psnfss/psnfss2e.pdf
Binary files differ
diff --git a/macros/latex/required/psnfss/psnfss2e.tex b/macros/latex/required/psnfss/psnfss2e.tex
new file mode 100644
index 0000000000..2e60445264
--- /dev/null
+++ b/macros/latex/required/psnfss/psnfss2e.tex
@@ -0,0 +1,887 @@
+% file: psnfss2e.tex as of 2004-09-15
+%
+% Copyright 2000--2004 Walter Schmidt
+%
+% This file may be distributed and/or modified under the
+% conditions of the LaTeX Project Public License, either version 1.2
+% 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.2 or later is part of all distributions of LaTeX
+% version 1999/12/01 or later.
+
+\newif\ifutopia
+
+% \utopiatrue
+% If you have got the Utopia fonts, uncomment the above line,
+% or put \utopiatrue into your ltxguide.cfg.
+
+\NeedsTeXFormat{LaTeX2e}[1995/12/01]
+
+\documentclass[11pt]{ltxguide}[1995/11/28]
+\DeleteShortVerb{\|}
+
+% You may provide a configuration file ltxguide.cfg
+% to set up your preferred paper size and page layout.
+% The .cfg file should, however, not change the fonts used!
+
+\usepackage{mathptmx,courier}
+\usepackage[scaled=0.92]{helvet}
+\normalfont
+\usepackage{pifont,tabularx,varioref,url}
+\usepackage[T1]{fontenc}
+\usepackage{textcomp}
+\usepackage{ragged2e}
+
+\usepackage[colorlinks=false, pdfborder={0 0 0}]{hyperref}
+
+% some dirty hacks to make the ltxguide class look better:
+\makeatletter
+\renewcommand\section{\@startsection{section}{1}{\z@}%
+{-3.5ex \@plus -.75ex}%
+{1ex}%
+{\normalfont\Large\bfseries}}
+\renewcommand\subsection{\@startsection{subsection}{2}{\z@}%
+{-2.5ex plus -.5ex}%
+{.75ex}%
+{\normalfont\large\bfseries}}
+\renewcommand\subsubsection{\@startsection{subsubsection}{3}{\z@}%
+{-2.5ex plus -.5ex}%
+{.5ex}%
+{\normalsize\bfseries}}
+\setlength{\parskip}{1ex plus 2pt minus 1pt \relax}
+% borrowed from tdsguide.cls:
+\labelsep=1.1em % increase distance between item & text
+\topsep=0pt % no extra skip above list in paragraph
+\partopsep=0pt % no extra skip above list starting par.
+\itemsep=0pt % no extra space between items
+\parsep=.9\parskip % between paragraphs in items
+\def\@listI{%
+ \leftmargin\leftmargini
+ }
+\let\@listi\@listI
+\@listi
+\def\@listii{%
+ \leftmargin\leftmarginii
+ \labelwidth\leftmarginii \advance \labelwidth-\labelsep
+ }
+\def\@listiii{%
+ \leftmargin\leftmarginiii
+ \labelwidth\leftmarginiii \advance \labelwidth-\labelsep
+ }
+\makeatother
+
+% the (La)TeX logos for use with Times:
+\def\ptmTeX{T\kern-.1667em\lower.5ex\hbox{E}\kern-.075emX\@}
+\makeatletter
+\DeclareRobustCommand{\ptmLaTeX}{L\kern-.25em
+ {\setbox0\hbox{T}%
+ \vbox to\ht0{\hbox{%
+ \csname S@\f@size\endcsname
+ \fontsize\sf@size\z@
+ \math@fontsfalse\selectfont
+ A}%
+ \vss}%
+ }%
+ \kern-.10em
+ \TeX}
+\makeatother
+\let\TeX=\ptmTeX
+\let\LaTeX=\ptmLaTeX
+
+% a bit of logical markup:
+\newcommand{\ps}{PostScript}
+\newcommand{\Lpack}[1]{\textsf{#1}}
+
+% the macros for the typeface samples:
+\newlength{\rightwidth}
+ \rightwidth=11cm
+\newlength{\leftwidth}
+ \leftwidth=\textwidth
+ \addtolength{\leftwidth}{-\rightwidth}
+ \addtolength{\leftwidth}{-1em} % ?
+\newcommand{\sample}[5]{%
+ \parbox[t]{\leftwidth}{%
+ {\raggedright\footnotesize
+ #1\\
+ #3/#4\par}}
+ \hfill
+ \parbox[t]{\rightwidth}{
+ {\RaggedRight \fontfamily{#2}\fontsize{#3}{#4}\selectfont #5
+ The sun was just rising as Dr.\ Robert entered his wife's room.
+ An orange glow, and against it the jagged silhouette of the mountains.
+ Then suddenly a dazzling sickle of incandescence between two peaks.
+ The sickle became a half circle and the first long shadows,
+ the first shafts of golden light crossed the garden outside the window.
+ And when one looked up again at the mountains there was the whole
+ unbearable glory of the risen sun.
+ \par}}
+ \par
+ \medskip}
+
+
+\title{Using common \ps\ fonts with \LaTeX}
+
+\author{Walter Schmidt}
+
+\date{PSNFSS version 9.2 \\ 2004-09-15}
+
+
+\hypersetup{pdfauthor={Walter Schmidt},
+ pdftitle={Using common PostScript fonts with LaTeX},
+ pdfsubject={PSNFSS v9.2},
+ pdfkeywords={LaTeX PSNFSS PostScript fonts}}
+
+
+\begin{document}
+\MakeShortVerb{\+}
+
+\maketitle
+
+\tableofcontents
+%\pagebreak
+
+
+\section{What is PSNFSS\,?}
+
+The PSNFSS collection includes a set of files
+that provide a complete working setup of the \LaTeX{} font selection scheme
+(NFSS2) for use with common \ps\ fonts.
+It covers the so-called `Base~35' fonts
+(which are built into any Level~2 \ps\ printing device
+and the Ghostscript interpreter)
+and %the free Charter, Utopia and Pazo fonts.
+a number of free fonts.
+
+
+
+\section{Package overview}
+
+The easiest way to make use of the above-mentioned typefaces is to completely
+replace one or more of the font families used by \LaTeX{} as
+`roman', `sans serif' and `typewriter' family and for math.
+This is accomplished by the packages listed in table \ref{tab:packages}.
+Its first row lists the default (Computer Modern) font families.
+An empty column indicates that a package does not change the particular
+font family. Some of these packages need more detailed explanation and
+are described in the below sections \ref{sec:helvet}, \ref{sec:mathpazo}
+and \ref{sec:mathptmx}.
+
+The PSNFSS distribution includes also a package
+\Lpack{pifont}, which serves for accessing symbol fonts (aka `Pi~fonts'),
+such as Symbol and Zapf Dingbats, see section~\ref{sec:pifont}.
+
+
+\begin{table}[h!]
+\caption{Packages for using common \ps\ fonts}
+\label{tab:packages}
+\medskip
+{\footnotesize
+\begin{center}
+\renewcommand{\arraystretch}{1.2}
+\begin{tabular}{|l|p{1.8cm}p{2.2cm}p{2.4cm}p{2.2cm}|}
+\hline
+\textbf{package} & \textbf{roman} & \textbf{sans serif} & \textbf{typewriter} & \textbf{formulas} \\\hline\hline
+(none) & CM Roman & CM Sans Serif & CM Typewriter & $\approx$ CM Roman\\\hline
+\Lpack{mathpazo} & Palatino
+ &
+ &
+ & $\approx$ Palatino\\\hline
+\Lpack{mathptmx} & Times
+ &
+ &
+ & $\approx$ Times\\\hline
+\Lpack{helvet} &
+ & Helvetica
+ &
+ & \\\hline
+\Lpack{avant} &
+ & Avant~Garde
+ &
+ & \\\hline
+\Lpack{courier} &
+ &
+ & Courier
+ & \\\hline
+\Lpack{chancery} & Zapf Chancery
+ &
+ &
+ & \\\hline
+\Lpack{bookman} & Bookman
+ & Avant~Garde
+ & Courier
+ & \\\hline
+\Lpack{newcent} & New Century Schoolbook
+ & Avant~Garde
+ & Courier
+ & \\\hline
+\Lpack{charter} & Charter
+ &
+ &
+ & \\\hline
+\end{tabular}
+\end{center}
+}
+\end{table}
+
+
+
+\section{Special considerations}
+
+\subsection{Output font encoding}
+None of the packages listed in table~\ref{tab:packages} changes the
+output font encoding from its default setting OT1.
+It is, however, highly recommended to use the fonts with the extended
+T1 and TS1 (text symbols) encodings by means of the commands:
+\begin{quote}
+ +\usepackage[T1]{fontenc}+\\
+ +\usepackage{textcomp}+
+\end{quote}
+When using \ps\ fonts that come from `outside the \TeX{} world',
+there is no reason at all to stay with the obsolete OT1~encoding,
+which would not provide access to all available glyphs.
+However, since these fonts were not particularly designed
+for use with \TeX{}, they do \emph{not} include all of the
+text companion (TS1) symbols.
+
+
+\subsection{Euro support}
+%% \NEWfeature{2003-11-17 v9.1}
+From PSNFSS version~9.1 on, all supported text font families,
+with the exception of \texttt{put} (Utopia), provide
+a built-in Euro symbol +\texteuro+.
+Using this command requires the \Lpack{textcomp} package; see above.
+
+
+\subsection{Inter-line spacing}
+With certain font families, the leading of the standard \LaTeX{}
+document classes may be too small.
+This results from the larger x-height of these typefaces, as compared with
+Computer Modern.
+Since it is a question of document design and line width,
+the packages of the PSNFSS bundle do \emph{not} take care of this.
+Issuing the command
+\begin{quote}
+ +\linespread+ \arg{factor}
+\end{quote}
+in the preamble will globally enlarge the leading by the given factor.
+Typical values for \m{factor} are in the range of $1.04\dots1.1$.
+
+
+\subsection{Using sans serif fonts}
+The packages \Lpack{helvet} and \Lpack{avant} do not change the
+default text font family from `roman'.
+If required, the additional command
+\begin{quote}
+ +\renewcommand{\familydefault}{\sfdefault}+
+\end{quote}
+makes \LaTeX{} use the sans serif font family (Helvetica or Avant~Garde)
+as the default one in text mode. Notice, however, that this does not change the fonts
+used in the formulas!
+
+
+
+\section{The package \Lpack{helvet}}
+\label{sec:helvet}
+Helvetica is actually somewhat larger than other typefaces
+of the same nominal size.
+As a result, mixing, \eg Times and Helvetica within running text
+may look bad.
+\begin{decl}
+ \texttt{[scaled=}\m{scale}\texttt{]}\\
+ \texttt{[scaled]}
+\end{decl}
+This can be fixed by loading the package with the option
+\texttt{[scaled=}\m{scale}\texttt{]},
+for instance:
++\usepackage[scaled=.92]{helvet}+.
+As a result, the font family \texttt{phv} (Helvetica) will be
+scaled down to 92\% of its `natural' size, which is suitable
+for use with Adobe Times.
+Specifying +[scaled]+ alone is equivalent to +[scaled=0.95]+% and makes
+%the height of the Helvetica capital letters comply with many other typeface
+%families
+.
+
+
+
+\section{The package \Lpack{mathpazo}}
+\label{sec:mathpazo}
+Loading
+%% \NEWfeature{2001-06-04 v8.2}
+this package changes the default roman font family
+to Adobe Palatino, and the virtual `mathpazo' fonts will be used
+for math.
+These virtual fonts are made up basically from Palatino Italic, with the
+missing math symbols coming from the CM and Pazo math fonts.
+
+\subsection{Package options}
+
+\begin{decl}
+ +[sc]+\\
+ +[osf]+
+\end{decl}
+By default, the package \Lpack{mathpazo} uses
+the typeface family +ppl+ as the roman text font family.
+The option +[sc]+ selects Palatino with real smallcaps (family +pplx+) insread.
+Correspondingly, the option +[osf]+ selects Palatino with smallcaps and default
+oldstyle figures (family +pplj+).
+Of course, oldstyle figures will be used only in text mode, as opposed to formulas.
+\NEWfeature{2004-09-15 v9.2}
+Using either option is strongly recommended:
+Beside the real smallcaps, the font families +pplx+ and +pplj+ show further
+improvements over +ppl+: Increased word space, enhanced kerning tables,
+additional `dotlessj' glyph.
+
+\begin{decl}
+ +[slantedGreek]+
+\end{decl}
+When the package is loaded with the +[slantedGreek]+ option,
+uppercase Greek letters in math will be italic by default.
+
+\begin{decl}
+ +[noBBpl]+
+\end{decl}
+This option disables the use of the Pazo fonts as a partial
++\mathbb+ alphabet -- see below. The option should be specified,
+if you want to use a different `blackboard bold' font.
+
+
+\subsection{New commands}
+
+\begin{decl}
+ +\upGamma+, +\upDelta+ \dots +\upOmega+
+\end{decl}
+\NEWfeature{2004-09-15 v9.2}
+Regardless of the \texttt{slantedGreek} option,
+these commands always yield upright uppercase Greek letters.
+Upright \emph{lowercase} Greek is, however, not available.
+
+\begin{decl}
+ +\mathbold+\\
+ +\mathbb+
+\end{decl}
++\mathbold+ is a math alphabet for typesetting variables (incl.\ Greek)
+in a {\bfseries\itshape bold italic} style. Do not mix this up with +\mathbf+,
+which selects a {\bfseries\upshape bold upright} text font
+for use in math!
+
++\mathbb+ is a `blackboard bold' alphabet, whose characters
+are taken from the Pazo fonts. %% \NEWfeature{2002-04-10 v9.0}
+All upper case letters and the numeral `1' are available.
+If you want to use a different, external, doublestroke alphabet,
+load the package \Lpack{mathpazo} with the package option +[noBBppl]+, see above.
+
+\iffalse
+\begin{decl}
+ +\ppleuro+
+\end{decl}
+The command +\ppleuro+ typesets the Euro
+symbol in a way that suits Palatino using the appropriate glyphs
+from the Pazo Math font family. It is compatible with both the
+\Lpack{eurofont} and \Lpack{europs} packages, and one can continue to use either
+one of these packages, using the +\euro+ command from the
+\Lpack{eurofont} package or the +\EUR+ command from the \Lpack{europs} package.
+\fi
+
+
+\subsection{Font size of the `large' math symbols}
+With \Lpack{mathpazo}, the `large' math symbols are automatically
+scaled to fit the base font size.
+In contrast to standard \LaTeX{} you need not
+load the package \Lpack{exscale} for this purpose!
+
+
+\subsection{Known problems}
+
+In contrast to the standard CM fonts, the virtual \Lpack{mathpazo} fonts
+do not provide any Greek letters in the math alphabet +\mathrm+.
+Applying this math alphabet command to Greek letters
+will result in garbage output.
+
+
+
+\section{The package \Lpack{mathptmx}}
+\label{sec:mathptmx}
+Loading this package changes the default roman font family
+to Times, and the virtual `mathptmx' fonts will be used
+for math.
+These virtual fonts are made up basically from Times Italic, with the
+missing math symbols coming from CM, RSFS (for +\mathcal+) and
+Adobe~Symbol.
+
+\subsection{Package options}
+\begin{decl}
+ +[slantedGreek]+
+\end{decl}
+%% \NEWfeature{2001-06-04 v8.2}
+When the package is loaded with this option,
+uppercase Greek letters in math will be italic by default.
+
+\subsection{New commands}
+\begin{decl}
+ +\upGamma+, +\upDelta+ \dots +\upOmega+
+\end{decl}
+\NEWfeature{2004-09-15 v9.2}
+Regardless of the \texttt{slantedGreek} option,
+these commands always yield upright uppercase Greek letters.
+Upright \emph{lowercase} Greek is, however, not available.
+
+
+\subsection{Font size of the `large' math symbols}
+With \Lpack{mathptmx}, the `large' math symbols are automatically scaled
+to fit the base font size. In contrast to standard \LaTeX{} you need not
+load the package \Lpack{exscale} for this purpose!
+
+
+\subsection{Known bugs and deficiencies}
+\begin{itemize}
+ \item There are no bold math fonts, and +\boldmath+ has no effect.
+ Use of the package \Lpack{bm} in conjunction with \Lpack{mathptmx}
+ is not recommended.
+ \item The symbols
+ +\jmath+, +\coprod +and +\amalg+
+ are not available.
+\end{itemize}
+
+
+
+\section{The package \Lpack{pifont}}
+\label{sec:pifont}
+
+Using symbol fonts is supported by means of the
+\Lpack{pifont} package, providing commands for using the Zapf Dingbats font,
+as well as an interface to other families.\footnote{%
+This section was adopted, with minor changes,
+from \cite{companion}, 1st ed.}
+
+\subsection{Commands for using Zapf Dingbats}
+
+\begin{decl}
+ +\ding+ \arg{number}
+\end{decl}
+
+A given character can be chosen via the +\ding+ command.
+Its parameter is an integer that specifies the character to be
+typeset. For example, +\ding{38}+ gives \ding{38};
+see table~\vref{tab:dingbats}.
+
+\begin{decl}
+ +\begin{dinglist}+ \arg{number}\\
+ +\begin{dingautolist}+ \arg{number}
+\end{decl}
+
+The +dinglist+ environment is a special itemized list.
+The argument specifies the number of the character to be used
+as the beginning of each item. For example,
+\begin{verbatim}
+\begin{dinglist}{43}
+ \item The first item in the list
+ \item The second item in the list
+ \item The third item in the list
+\end{dinglist}
+\end{verbatim}
+prints
+\begin{dinglist}{43}
+ \item The first item in the list
+ \item The second item in the list
+ \item The third item in the list
+\end{dinglist}
+
+There also exists an environment +dingautolist+, which
+allows you to build an enumerated list with a set of Zapf Dingbats
+characters. In this case, the argument specifies the number
+of the first character in the list. Subsequent items will be numbered
+with the character following the previous one. E.g.,
+\begin{verbatim}
+\begin{dingautolist}{192}
+ \item The first item
+ \item The second item
+ \item The third item
+\end{dingautolist}
+\end{verbatim}
+prints
+\begin{dingautolist}{192}
+ \item The first item
+ \item The second item
+ \item The third item
+\end{dingautolist}
+
+\begin{decl}
+ +\dingfill+ \arg{number}\\
+ +\dingline+ \arg{number}
+\end{decl}
+
++\dingfill+ acts like the other filling commands in \TeX, but
+fills the space with a chosen symbol \dingfill{224} like that.
+
++\dingline+ generates a freestanding line filled with the given symbol,
+with a little space on the left and right:
+\dingline{34}
+
+
+\begin{table}[bt!]
+ \caption{The characters in the \ps{} font Zapf Dingbats}
+ \label{tab:dingbats}
+ \medskip
+
+{\footnotesize
+\begin{tabular}{|rr|rr|rr|rr|rr|rr|rr|rr|}
+\hline
+32 & \ding{32} & 33 & \ding{33} & 34 & \ding{34} & 35 & \ding{35} & 36 & \ding{36} & 37 & \ding{37} & 38 & \ding{38} & 39 & \ding{39} \\ \hline
+40 & \ding{40} & 41 & \ding{41} & 42 & \ding{42} & 43 & \ding{43} & 44 & \ding{44} & 45 & \ding{45} & 46 & \ding{46} & 47 & \ding{47} \\ \hline
+48 & \ding{48} & 49 & \ding{49} & 50 & \ding{50} & 51 & \ding{51} & 52 & \ding{52} & 53 & \ding{53} & 54 & \ding{54} & 55 & \ding{55} \\ \hline
+56 & \ding{56} & 57 & \ding{57} & 58 & \ding{58} & 59 & \ding{59} & 60 & \ding{60} & 61 & \ding{61} & 62 & \ding{62} & 63 & \ding{63} \\ \hline
+64 & \ding{64} & 65 & \ding{65} & 66 & \ding{66} & 67 & \ding{67} & 68 & \ding{68} & 69 & \ding{69} & 70 & \ding{70} & 71 & \ding{71} \\ \hline
+72 & \ding{72} & 73 & \ding{73} & 74 & \ding{74} & 75 & \ding{75} & 76 & \ding{76} & 77 & \ding{77} & 78 & \ding{78} & 79 & \ding{79} \\ \hline
+80 & \ding{80} & 81 & \ding{81} & 82 & \ding{82} & 83 & \ding{83} & 84 & \ding{84} & 85 & \ding{85} & 86 & \ding{86} & 87 & \ding{87} \\ \hline
+88 & \ding{88} & 89 & \ding{89} & 90 & \ding{90} & 91 & \ding{91} & 92 & \ding{92} & 93 & \ding{93} & 94 & \ding{94} & 95 & \ding{95} \\ \hline
+96 & \ding{96} & 97 & \ding{97} & 98 & \ding{98} & 99 & \ding{99} & 100 & \ding{100} & 101 & \ding{101} & 102 & \ding{102} & 103 & \ding{103} \\ \hline
+104 & \ding{104} & 105 & \ding{105} & 106 & \ding{106} & 107 & \ding{107} & 108 & \ding{108} & 109 & \ding{109} & 110 & \ding{110} & 111 & \ding{111} \\ \hline
+112 & \ding{112} & 113 & \ding{113} & 114 & \ding{114} & 115 & \ding{115} & 116 & \ding{116} & 117 & \ding{117} & 118 & \ding{118} & 119 & \ding{119} \\ \hline
+120 & \ding{120} & 121 & \ding{121} & 122 & \ding{122} & 123 & \ding{123} & 124 & \ding{124} & 125 & \ding{125} & 126 & \ding{126} & & \\ \hline
+ & & 161 & \ding{161} & 162 & \ding{162} & 163 & \ding{163} & 164 & \ding{164} & 165 & \ding{165} & 166 & \ding{166} & 167 & \ding{167} \\ \hline
+168 & \ding{168} & 169 & \ding{169} & 170 & \ding{170} & 171 & \ding{171} & 172 & \ding{172} & 173 & \ding{173} & 174 & \ding{174} & 175 & \ding{175} \\ \hline
+176 & \ding{176} & 177 & \ding{177} & 178 & \ding{178} & 179 & \ding{179} & 180 & \ding{180} & 181 & \ding{181} & 182 & \ding{182} & 183 & \ding{183} \\ \hline
+184 & \ding{184} & 185 & \ding{185} & 186 & \ding{186} & 187 & \ding{187} & 188 & \ding{188} & 189 & \ding{189} & 190 & \ding{190} & 191 & \ding{191} \\ \hline
+192 & \ding{192} & 193 & \ding{193} & 194 & \ding{194} & 195 & \ding{195} & 196 & \ding{196} & 197 & \ding{197} & 198 & \ding{198} & 199 & \ding{199} \\ \hline
+200 & \ding{200} & 201 & \ding{201} & 202 & \ding{202} & 203 & \ding{203} & 204 & \ding{204} & 205 & \ding{205} & 206 & \ding{206} & 207 & \ding{207} \\ \hline
+208 & \ding{208} & 209 & \ding{209} & 210 & \ding{210} & 211 & \ding{211} & 212 & \ding{212} & 213 & \ding{213} & 214 & \ding{214} & 215 & \ding{215} \\ \hline
+216 & \ding{216} & 217 & \ding{217} & 218 & \ding{218} & 219 & \ding{219} & 220 & \ding{220} & 221 & \ding{221} & 222 & \ding{222} & 223 & \ding{223} \\ \hline
+224 & \ding{224} & 225 & \ding{225} & 226 & \ding{226} & 227 & \ding{227} & 228 & \ding{228} & 229 & \ding{229} & 230 & \ding{230} & 231 & \ding{231} \\ \hline
+232 & \ding{232} & 233 & \ding{233} & 234 & \ding{234} & 235 & \ding{235} & 236 & \ding{236} & 237 & \ding{237} & 238 & \ding{238} & 239 & \ding{239} \\ \hline
+ & & 241 & \ding{241} & 242 & \ding{242} & 243 & \ding{243} & 244 & \ding{244} & 245 & \ding{245} & 246 & \ding{246} & 247 & \ding{247} \\ \hline
+248 & \ding{248} & 249 & \ding{249} & 250 & \ding{250} & 251 & \ding{251} & 252 & \ding{252} & 253 & \ding{253} & 254 & \ding{254} & & \\ \hline
+\end{tabular}
+\par}
+
+\end{table}
+
+\subsection{Generic commands}
+The \Lpack{pifont} package has a general mechanism for coping with
+Pi fonts. It provides the following generic commands with, in each case,
+the first argument \m{family} specifying the name of the
+Pi font family in question (such as \texttt{psy} for the Symbol font,
+and \texttt{pzd} for the Zapf Dingbats font, see table~\vref{tab:families}).
+If indicated, a second argument \m{number}
+specifies the decimal position of a symbol in that font.
+
+\begin{decl}
+ +\Pifont+ \arg{family}
+\end{decl}
+
+This switches to the font family \m{family}
+and the encoding U.
+
+\begin{decl}
+ +\Pisymbol+ \arg{family} \arg{number}
+\end{decl}
+
+This command typesets the specified symbol
+(compare this with the +\ding+ command).
+
+\begin{decl}
+ +\begin{Pilist}+ \arg{family} \arg{number}\\
+ +\begin{Piautolist}+ \arg{family} \arg{number}
+\end{decl}
+
+In the +Pilist+ environment the specified symbol is used in front
+of each item in an itemized list (compare with the +dinglist+
+environment).
+
++Piautolist+ is an environment where a series of symbols starting
+with the one at the decimal position \m{number} in font family
+\m{family} is used to number the items in an enumerated list
+(compare with the +dingautolist+ environment).
+
+\begin{decl}
+ +\Pifill+ \arg{family} \arg{number}\\
+ +\Piline+ \arg{family} \arg{number}
+\end{decl}
+
++\Pifill+ acts like the other filling commands in \TeX, but
+fills the space with a chosen symbol (compare with +\dingfill+).
+
++\Piline+ typesets a line consisting of several copies of
+the specified symbol, with some space at the left and right
+(compare with +\dingline+).
+
+
+
+\section{NFSS classification}
+Table~\vref{tab:families} lists all text and symbol font shapes
+supported by the basic PSNFSS distribution,
+and the related \ps\ fonts.
+\NEWdescription{2004-09-15 v9.2}
+With the exception of Charter and Utopia, these fonts are commercial products.
+Therefore, most \TeX\ systems include free substitutes instead.
+
+Available encodings are OT1, T1 and TS1, except for
+Symbol and Zapf~Dingbats, which are implemented with encoding U.
+See \cite{fntguide} for how to access a given font shape directly.
+
+Only the font families +pplx+ and +pplj+ provide true small capitals
+(and only in the regular series).
+With the other families the shape `sc' refers to so-called `faked' small capitals,
+whose typographical quality is -- at least -- questionable.
+
+The math font families loaded by the
+\Lpack{mathptm}, \Lpack{mathptmx}, \Lpack{mathpazo} and \Lpack{mathpple} packages
+are not listed here.
+See the documented source file \texttt{psfonts.dtx}
+for information on this topic.
+
+\begin{table}[p]
+ \caption{Font shapes supported by the basic PSNFSS distribution}
+ \label{tab:families}
+ \medskip
+
+ {\small
+ \begin{tabularx}{\linewidth}{|l|l|l|>{\raggedright\arraybackslash}X|}
+ \hline
+ \textbf{family} & \textbf{series} & \textbf{shape(s)} & \textbf{\ps{} font names}\\
+ \hline\hline
+ \multicolumn{4}{|c|}{\textit{Avant Garde}}\\ \hline
+ pag & m & n, sl, sc & AvantGarde-Book, AvantGarde-BookOblique\\ \hline
+ pag & b & n, sl, sc & AvantGarde-Demi, AvantGarde-DemiOblique\\ \hline \hline
+ \multicolumn{4}{|c|}{\textit{Bookman}}\\ \hline
+ pbk & l & n, sl, it, sc & Bookman-Light, Bookman-LightItalic\\ \hline
+ pbk & db & n, sl, it, sc & Bookman-Demi, Bookman-DemiItalic\\ \hline \hline
+ \multicolumn{4}{|c|}{\textit{Charter}}\\ \hline
+ bch & m & n, sl, it, sc & CharterBT-Roman, CharterBT-Italic\\ \hline
+ bch & b & n, sl, it, sc & CharterBT-Bold, CharterBT-BoldItalic\\ \hline \hline
+ \multicolumn{4}{|c|}{\textit{Courier}}\\ \hline
+ pcr & m & n, sl, sc & Courier, CourierOblique\\ \hline
+ pcr & b & n, sl, sc & Courier-Bold, Courier-BoldOblique\\ \hline \hline
+ \multicolumn{4}{|c|}{\textit{Helvetica}}\\ \hline
+ phv & m & n, sl, sc & Helvetica, Helvetica-Oblique\\ \hline
+ phv & b & n, sl, sc & Helvetica-Bold, Helvetica-BoldOblique\\ \hline
+ phv & mc & n, sl, sc & Helvetica-Narrow, Helvetica-Narrow-Oblique\\ \hline
+ phv & bc & n, sl, sc & Helvetica-Narrow-Bold, Helvetica-Narrow-BoldOblique\\\hline \hline
+ \multicolumn{4}{|c|}{\textit{New Century Schoolbook}}\\ \hline
+ pnc & m & n, sl, it, sc & NewCenturySchlbk-Roman, NewCenturySchlbk-Italic\\ \hline
+ pnc & b & n, sl, it, sc & NewCenturySchlbk-Bold, NewCenturySchlbk-BoldItalic\\ \hline \hline
+ \multicolumn{4}{|c|}{\textit{Palatino}}\\ \hline
+ ppl & m & n, sl, it, sc & Palatino-Roman, Palatino-Italic\\ \hline
+ ppl & b & n, sl, it, sc & Palatino-Bold, Palatino-BoldItalic\\ \hline
+ pplx & m & n, it, sc & Palatino-Roman, Palatino-Italic, Palatino-SC\\ \hline
+ pplx & b & n, it & Palatino-Bold, Palatino-BoldItalic\\ \hline
+ pplj & m & n, it, sc & Palatino-Roman, Palatino-SC, Palatino-Italic, Palatino-ItalicOsF\\ \hline
+ pplj & b & n, it & Palatino-Bold, Palatino-BoldOsF, Palatino-BoldItalic, Palatino-BoldItalicOsF\\ \hline \hline
+ \multicolumn{4}{|c|}{\textit{Times}}\\ \hline
+ ptm & m & n, sl, it, sc & Times-Roman, Times-Italic\\ \hline
+ ptm & b & n, sl, it, sc & Times-Bold, Times-BoldItalic\\ \hline \hline
+ \multicolumn{4}{|c|}{\textit{Zapf Chancery}}\\ \hline
+ pzc & mb & it & ZapfChancery-MediumItalic\\ \hline \hline
+ \multicolumn{4}{|c|}{\textit{Utopia}}\\ \hline
+ put & m & n, sl, it, sc & Utopia-Regular, Utopia-Italic\\ \hline
+ put & b & n, sl, it, sc & Utopia-Bold, Utopia-BoldItalic\\ \hline \hline
+ \multicolumn{4}{|c|}{\textit{Symbol}}\\ \hline
+ psy & m & n & Symbol\\ \hline \hline
+ \multicolumn{4}{|c|}{\textit{Zapf Dingbats}}\\ \hline
+ pzd & m & n & ZapfDingbats\\ \hline
+ \end{tabularx}
+ \par}
+\end{table}
+
+
+
+\section{Obsolete packages}
+The macro packages listed in table \vref{tab:obsolete} should be considered as obsolete.
+They are provided for compatibility with existing documents only.
+
+\begin{table}[hbt]
+\caption{Obsolete packages in the PSNFSS collection}
+\label{tab:obsolete}
+\medskip
+{\footnotesize
+\begin{center}
+\renewcommand{\arraystretch}{1.2}
+\begin{tabular}{|l|p{1.8cm}p{2.2cm}p{2.4cm}p{2.2cm}|}
+\hline
+\textbf{package} & \textbf{roman} & \textbf{sans serif} & \textbf{typewriter} & \textbf{math} \\\hline\hline
+\Lpack{times} & Times
+ & Helvetica
+ & Courier
+ & \\\hline
+\Lpack{palatino} & Palatino
+ & Helvetica
+ & Courier
+ & \\\hline
+\Lpack{mathptm} & Times
+ &
+ &
+ & $\approx$ Times\\\hline
+\Lpack{mathpple} & Palatino
+ &
+ &
+ & $\approx$ Palatino\\\hline
+\Lpack{utopia} & Utopia
+ &
+ &
+ & \\\hline
+\end{tabular}
+\end{center}
+}
+\end{table}
+
+
+\subsection{The packages \Lpack{times} and \Lpack{palatino}}
+These packages do not load suitable math fonts,
+and they do not scale the Helvetica fonts appropriately
+to match Times and Palatino -- see section \ref{sec:helvet}.
+Use \Lpack{mathptmx} or \Lpack{mathpazo} in conjunction with
+\Lpack{helvet} and \Lpack{courier} instead!
+
+In case you need to load Times or Palatino \emph{without} the
+related math fonts of the PSNFSS bundle, you can still use the
+basic NFSS commands. For instance,
+\begin{quote}
++\renewcommand{\rmdefault}{ptm}+
+\end{quote}
+changes only the default roman font family to
+\texttt{ptm}, i.e.\ Times.
+
+\subsection{The package \Lpack{mathptm}}
+The package \Lpack{mathptm} is a predecessor to \Lpack{mathptmx}.
+In contrast to the latter and to \LaTeX's standard behavior,
+lowercase Greek in math is typeset upright.
+Zapf Chancery is used as the calligraphic math alphabet,
+which causes some problems with proper spacing.
+\Lpack{mathptm} needs the font \texttt{cmex9}, which may not
+be available in Type~1 format.
+
+\subsection{The package \Lpack{mathpple}}
+\Lpack{mathpple} is a predecessor to \Lpack{mathpazo},
+using also a set of virtual math fonts to go with Palatino.
+The Greek alphabet is, however, taken from the
+Euler fonts (which get slanted), rather than from the Pazo fonts.
+The package \Lpack{mathpple} does not support the
+Palatino SC/OsF fonts, and there is no `blackboard bold' math alphabet.
+Further flaws are:
+\begin{itemize}
+ \item The spacing within numbers and function names in formulas
+ is somewhat too loose.
+ \item The +\coprod+ symbol is missing.
+ \item There are no bold variants of +\partial+ and +\infty+.
+ \item +\jmath+ is taken from the CM math italic font, which does
+ not blend well with Palatino.
+ \item DVI viewers may exhibit problems as to rendering of the artificially slanted
+ Greek letters.
+\end{itemize}
+The newer \Lpack{mathpazo} package can be considered as
+superior; yet you may still use \Lpack{mathpple}, if you prefer
+the shape of its Greek letters.
+
+\subsection{The package \Lpack{utopia}}
+Use %%\NEWdescription{2003-11-17 v9.1}
+of the \Lpack{utopia}
+package is no longer recommended, because
+the newer package \Lpack{fourier} provides a basically improved
+interface to the Utopia typeface and loads suitable math fonts, too.
+Notice that this package does \emph{not} belong to the PSNFSS collection!
+
+Furthermore, the \LaTeX3 team does no longer regard the Utopia
+fonts as a \emph{required} component of \LaTeX{},
+because their license does not comply with the strict
+guidelines of the FSF.
+
+
+\section{Typeface samples}
+
+The following samples show the regular font of each typeface family
+supported by PSNFSS.
+The particular font size and baselineskip is indicated below the font name.
+Notice that Helvetica is scaled to 92\,\% of the nominal size.
+
+\medskip
+
+\sample{Times}{ptm}{10}{12pt}{}
+
+\sample{Palatino}{pplx}{10}{12.4pt}{}
+
+\sample{Bookman}{pbk}{9.6}{11.5pt}{}
+
+\sample{Charter}{bch}{10}{12.4pt}{}
+
+\sample{New Century Schoolbook}{pnc}{9.6}{12pt}{}
+
+\ifutopia
+ \sample{Utopia}{put}{9.6}{12pt}{}
+\fi
+
+\sample{Helvetica}{phv}{10}{12pt}{}
+
+\parbox[t]{\leftwidth}{%
+ {\raggedright\footnotesize
+ \mbox{}Avant\-Garde\\
+ 9.6pt
+ \par}}
+\hfill
+\parbox[t]{\rightwidth}{
+{\fontfamily{pag}\fontsize{9.6}{11.5pt}\selectfont\raggedright
+ Don't use Avant Garde for typesetting larger portions of text\,!
+\par}}\medskip
+
+\parbox[t]{\leftwidth}{
+ {\raggedright\footnotesize
+ Courier\\
+ 10/12pt
+ \par}}
+\hfill
+\parbox[t]{\rightwidth}{
+{\fontfamily{pcr}\fontsize{10}{12pt}\selectfont\raggedright
+ A monospaced typeface, suitable for typesetting filenames, URLs etc.
+\par}}\medskip
+
+\parbox[t]{\leftwidth}{
+ {\raggedright\footnotesize
+ Zapf Chancery\\
+ 14.4pt
+ \par}}
+\hfill
+\parbox[t]{\rightwidth}{
+{\fontfamily{pzc}\Large\raggedright
+To Hermann Zapf -- whose strokes are the best.
+\par}}\medskip
+
+
+
+\section*{Credits}
+The PSNFSS system was originally developed by Sebastian Rahtz.
+
+The virtual \Lpack{mathptm} and \Lpack{mathptmx} fonts and the related packages
+were created by Alan Jeffrey, Sebastian Rathz and Ulrik Vieth.
+
+The \Lpack{mathpple} package and its virtual fonts are based
+on earlier work by Aloysius Helminck. Special thanks to Daniel Schlieper
+without whose initiative the package would not have been developed.
+
+The Pazo math fonts and the related virtual fonts were created
+by Diego Puga.
+
+
+
+\begin{thebibliography}{1}
+\raggedright
+
+\bibitem{companion}
+Frank Mittelbach et al.:
+\textit{The LaTeX Companion}.\\
+2nd edition. Addison Wesley, 2004.
+
+%\bibitem{gcompanion}
+%Michel Goossens, Sebastian Rahtz, and
+%Frank Mittelbach:\\
+%\textit{The LaTeX Graphics Companion}.\\
+%Addison Wesley Longman, 1997.
+
+\bibitem{fntguide}
+\LaTeX3 Project Team (Ed.):
+\textit{LaTeX2e font selection.}\\
+CTAN: \path{macros/latex/doc/fntguide.pdf}\\
+(Part of the \LaTeX{} online documentation)
+\end{thebibliography}
+
+
+\end{document}
diff --git a/macros/latex/required/psnfss/test0.tex b/macros/latex/required/psnfss/test0.tex
new file mode 100644
index 0000000000..743f6c6dca
--- /dev/null
+++ b/macros/latex/required/psnfss/test0.tex
@@ -0,0 +1,118 @@
+\documentclass[11pt]{article}
+\usepackage{mathptmx}
+\usepackage[scaled=0.92]{helvet}
+\usepackage{courier}
+\usepackage[T1]{fontenc}
+\parskip=2pt\parindent 0pt
+
+\begin{document}
+\section{A simple test of PSNFSS2e in new and old encoding}
+
+\subsection{T1 encoding}
+
+\begin{quote}\begin{tabular}{|ll|ll|ll|}\hline
+\verb|\rm| & \rm Roman & \verb|\itshape| & \itshape Italic
+ & \verb|\scshape| & \scshape Small Caps \\
+\verb|\em| & \em Emphatic & \verb|\slshape| & \slshape Slanted
+ & \verb|\ttfamily| & \ttfamily Typewriter \\
+\verb|\bfseries| & \bfseries Boldface & \verb|\sffamily| & \sffamily Sans Serif & &
+\\ \hline
+\end{tabular}\end{quote}
+
+\begin{quote}\begin{tabular}{|*{5}{ll|}}\hline
+\`{o} & \verb|\`{o}| & \~{o} & \verb|\~{o}| & \v{o} & \verb|\v{o}| &
+\c{o} & \verb|\c{o}| & \'{o} & \verb|\'{o}| \\
+\={o} & \verb|\={o}| & \H{o} & \verb|\H{o}| & \d{o} & \verb|\d{o}| &
+\^{o} & \verb|\^{o}| & \.{o} & \verb|\.{o}| \\
+\t{oo} & \verb|\t{oo}| & \b{o} & \verb|\b{o}| & \"{o} & \verb|\"{o}| &
+\u{o} & \verb|\u{o}| && \\ \hline
+\end{tabular}\end{quote}
+
+\begin{quote}\begin{tabular}{|*{4}{ll|}}\hline
+\dag & \verb|\dag| & \S & \verb|\S| &
+\copyright & \verb|\copyright| &\i & \verb|\i|\\
+\ddag & \verb|\ddag| & \P & \verb|\P| &
+\pounds & \verb|\pounds| & {\j} & \verb|\j|\\
+\oe & \verb|\oe| & \OE & \verb|\OE| &
+\ae & \verb|\ae| & & \\
+\AE & \verb|\AE| & \aa & \verb|\aa| &
+\AA & \verb|\AA| && \\
+\o & \verb|\o| & \O & \verb|\O| &
+\l & \verb|\l| && \\
+\L & \verb|\L| & \ss & \verb|\ss| &
+?` & \verb|?`| && \\
+!` & \verb|!`| & \ldots & \verb|\ldots| &
+\LaTeX & \verb|\LaTeX| && \\
+\hline
+\end{tabular}\end{quote}
+{This costs `\pounds' 45 to do; {\sffamily this costs \pounds 45 to do;
+\em this costs \pounds 45 in sans italic to do;}
+\scshape this costs ``\pounds'' 45 to do; \em this costs \pounds 45 to do
+\bfseries this costs \pounds 45 to do for a f\'ee. And so on.}
+The s\=un has got his h\=at in, hip hip hip hooray! !`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\^{o}le in fluffy souffl\'{e}s?
+
+\newpage
+\fontencoding{OT1}\renewcommand{\encodingdefault}{OT1}\selectfont
+
+\subsection{OT1 encoding}
+
+Note: do \emph{not} expect the pounds sign to be quite correct --- it
+will always be in italic, and will be a dollar in the Helvetica fonts.
+
+\begin{quote}\begin{tabular}{|ll|ll|ll|}\hline
+\verb|\rm| & \rm Roman & \verb|\itshape| & \itshape Italic
+ & \verb|\scshape| & \scshape Small Caps \\
+\verb|\em| & \em Emphatic & \verb|\slshape| & \slshape Slanted
+ & \verb|\ttfamily| & \ttfamily Typewriter \\
+\verb|\bfseries| & \bfseries Boldface & \verb|\sffamily| & \sffamily Sans Serif & &
+\\ \hline
+\end{tabular}\end{quote}
+
+\begin{quote}\begin{tabular}{|*{5}{ll|}}\hline
+\`{o} & \verb|\`{o}| & \~{o} & \verb|\~{o}| & \v{o} & \verb|\v{o}| &
+\c{o} & \verb|\c{o}| & \'{o} & \verb|\'{o}| \\
+\={o} & \verb|\={o}| & \H{o} & \verb|\H{o}| & \d{o} & \verb|\d{o}| &
+\^{o} & \verb|\^{o}| & \.{o} & \verb|\.{o}| \\
+\t{oo} & \verb|\t{oo}| & \b{o} & \verb|\b{o}| & \"{o} & \verb|\"{o}| &
+\u{o} & \verb|\u{o}| && \\ \hline
+\end{tabular}\end{quote}
+
+\begin{quote}\begin{tabular}{|*{4}{ll|}}\hline
+\dag & \verb|\dag| & \S & \verb|\S| &
+\copyright & \verb|\copyright| &\i & \verb|\i|\\
+\ddag & \verb|\ddag| & \P & \verb|\P| &
+\pounds & \verb|\pounds| & {\j} & \verb|\j|\\
+\oe & \verb|\oe| & \OE & \verb|\OE| &
+\ae & \verb|\ae| & & \\
+\AE & \verb|\AE| & \aa & \verb|\aa| &
+\AA & \verb|\AA| && \\
+\o & \verb|\o| & \O & \verb|\O| &
+\l & \verb|\l| && \\
+\L & \verb|\L| & \ss & \verb|\ss| &
+?` & \verb|?`| && \\
+!` & \verb|!`| & \ldots & \verb|\ldots| &
+\LaTeX & \verb|\LaTeX| && \\
+\hline
+\end{tabular}\end{quote}
+{This costs `\pounds' 45 to do; {\sffamily this costs \pounds 45 to do;
+\em this costs \pounds 45 in sans italic to do;}
+\scshape this costs ``\pounds'' 45 to do; \em this costs \pounds 45 to do
+\bfseries this costs \pounds 45 to do for a f\'ee. And so on.}
+{\itshape Let's try USD in italic, too: \$ 45.}
+The s\=un has got his h\=at in, hip hip hip hooray! !`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\^{o}le in fluffy souffl\'{e}s?
+
+\section{Math alphabets used with Times}
+\begin{quote}\begin{tabular}{|ll|}
+\hline
+$1, 2, 3, \sin, \log $ & \verb|$1, 2, 3, \sin, \log $| \\
+$c, v, f, \beta, \Gamma $ & \verb|$c, v, f, \beta, \Gamma $| \\
+$\mathcal{A B C F} $ & \verb|$\mathcal{A, B, C, F} $|\\
+\hline
+\end{tabular}\end{quote}
+\end{document}
diff --git a/macros/latex/required/psnfss/test1.tex b/macros/latex/required/psnfss/test1.tex
new file mode 100644
index 0000000000..77be282aeb
--- /dev/null
+++ b/macros/latex/required/psnfss/test1.tex
@@ -0,0 +1,51 @@
+\documentclass[11pt]{article}
+
+\renewcommand{\rmdefault}{ptm}
+\usepackage[scaled=0.92]{helvet}
+\renewcommand{\bfdefault}{b}
+
+\usepackage[T1]{fontenc}
+\usepackage{textcomp}
+
+\begin{document}
+\frenchspacing
+\title{PSNFSS:\\ Times, Helvetica, Courier}
+\author{Sebastian Rahtz \and Walter Schmidt}
+\date{2004-09-06}
+\maketitle
+\def\Try#1#2{%
+{\fontfamily{#1}\selectfont
+This is typeset in #2 (#1):
+\begin{quote}
+\raggedright
+A regular f\'ee costs 123\,\texteuro.\\
+\textit{An italic f\'ee.costs 123\,\texteuro.}\\
+\textsl{A slanted f\'ee costs 123\,\texteuro.}\\
+\textsc{A SmallCaps f\'ee.}\\
+{\bfseries A bold f\'ee costs 123\,\texteuro.\\
+ \textit{A bold italic f\'ee costs 123\,\texteuro.}\\
+ \textsl{A bold slanted f\'ee costs 123\,\texteuro.}\\
+ \textsc{A bold SmallCaps f\'ee.}\\
+}
+\end{quote}
+\par
+}}
+
+\Try{ptm}{Adobe Times Roman}
+\Try{phv}{Adobe Helvetica}
+\Try{pcr}{Adobe Courier}
+
+\textsf{In Helvetica we can try the narrow font series, too.\footnote{Thanks to Frank
+ Poppe for putting this in.}}
+\begin{quote}
+\raggedright
+\fontfamily{phv}\fontseries{mc}\selectfont
+\upshape A narrow f\'ee costs 123\,\texteuro.\\
+\slshape A narrow slanted f\'ee costs 123\,\texteuro.\\
+{\fontseries{bc}\selectfont
+\upshape A bold narrow f\'ee costs 123\,\texteuro.\\
+\slshape A bold narrow slanted f\'ee costs 123\,\texteuro.
+}
+\end{quote}
+
+\end{document}
diff --git a/macros/latex/required/psnfss/test2.tex b/macros/latex/required/psnfss/test2.tex
new file mode 100644
index 0000000000..94e1f7ad2a
--- /dev/null
+++ b/macros/latex/required/psnfss/test2.tex
@@ -0,0 +1,39 @@
+\documentclass[11pt]{article}
+
+\renewcommand{\rmdefault}{ppl}
+\renewcommand{\bfdefault}{b}
+\linespread{1.05}
+
+\usepackage[T1]{fontenc}
+\usepackage{textcomp}
+
+\begin{document}
+\frenchspacing
+\title{PSNFSS:\\ Palatino, Bookman, \\ NewCenturySchoolbook, AvantGarde}
+\author{Sebastian Rahtz \and Walter Schmidt}
+\date{2003-09-30}
+\maketitle
+\def\Try#1#2{%
+{\fontfamily{#1}\selectfont
+This is typeset in #2 (#1):
+\begin{quote}
+\raggedright
+A regular f\'ee costs 123\,\texteuro.\\
+\textit{An italic f\'ee costs 123\,\texteuro.}\\
+\textsl{A slanted f\'ee costs 123\,\texteuro.}\\
+\textsc{A SmallCaps f\'ee.}\\
+{\bfseries A bold f\'ee costs 123\,\texteuro.\\
+ \textit{A bold italic f\'ee costs 123\,\texteuro.}\\
+ \textsl{A bold slanted f\'ee costs 123\,\texteuro.}\\
+ \textsc{A bold SmallCaps f\'ee.}\\
+}
+\end{quote}
+\par
+}}
+
+\Try{ppl}{Adobe Palatino}
+\Try{pbk}{Adobe Bookman}
+\Try{pnc}{Adobe NewCenturySchoolbook}
+\Try{pag}{Adobe AvantGarde}
+
+\end{document}
diff --git a/macros/latex/required/psnfss/test3.tex b/macros/latex/required/psnfss/test3.tex
new file mode 100644
index 0000000000..69535f626f
--- /dev/null
+++ b/macros/latex/required/psnfss/test3.tex
@@ -0,0 +1,43 @@
+\documentclass[11pt]{article}
+
+\usepackage{charter}
+\linespread{1.05}
+
+\usepackage[T1]{fontenc}
+\usepackage{textcomp}
+
+\begin{document}
+\frenchspacing
+\title{PSNFSS:\\ Zapf Chancery and Charter}
+\author{Sebastian Rahtz \and Walter Schmidt}
+\date{2003-09-30}
+\maketitle
+\def\Try#1#2{%
+\fontfamily{#1}\selectfont
+This is typeset in #2 (#1):
+\begin{quote}
+\raggedright
+A regular f\'ee costs 123\,\texteuro.\\
+\textit{An italic f\'ee costs 123\,\texteuro}\\
+\textsl{A slanted f\'ee costs 123\,\texteuro.}\\
+\textsc{A SmallCaps f\'ee.}\\
+{\bfseries A bold f\'ee costs 123\,\texteuro.\\
+ \textit{A bold italic f\'ee costs 123\,\texteuro.}\\
+ \textsl{A bold slanted f\'ee costs 123\,\texteuro.}\\
+ \textsc{A bold SmallCaps f\'ee.}\\
+}
+\end{quote}
+\par
+}
+
+% Zapf Chancery is available as italic font shape only:
+This is typeset in Adobe Zapf Chancery (pzc):
+\begin{quote}
+\fontfamily{pzc}\fontshape{it}\selectfont
+An italic f\'ee costs 123\,\texteuro.
+\end{quote}
+
+\Try{bch}{Bitstream Charter}
+
+
+\end{document}
diff --git a/macros/latex/required/psnfss/utopia.map b/macros/latex/required/psnfss/utopia.map
new file mode 100644
index 0000000000..a25d08c666
--- /dev/null
+++ b/macros/latex/required/psnfss/utopia.map
@@ -0,0 +1,7 @@
+putb8r Utopia-Bold " TeXBase1Encoding ReEncodeFont " <8r.enc <putb8a.pfb
+putbi8r Utopia-BoldItalic " TeXBase1Encoding ReEncodeFont " <8r.enc <putbi8a.pfb
+putbo8r Utopia-Bold " .167 SlantFont TeXBase1Encoding ReEncodeFont " <8r.enc <putb8a.pfb
+putr8r Utopia-Regular " TeXBase1Encoding ReEncodeFont " <8r.enc <putr8a.pfb
+putri8r Utopia-Italic " TeXBase1Encoding ReEncodeFont " <8r.enc <putri8a.pfb
+putro8r Utopia-Regular " .167 SlantFont TeXBase1Encoding ReEncodeFont " <8r.enc <putr8a.pfb
+
diff --git a/macros/latex/required/tools/README.md b/macros/latex/required/tools/README.md
new file mode 100644
index 0000000000..cbd8f80e40
--- /dev/null
+++ b/macros/latex/required/tools/README.md
@@ -0,0 +1,81 @@
+## README for the `tools` bundle
+
+
+This bundle consists of LaTeX2e packages written and supported by
+members of the LaTeX3 Project Team.
+
+The documented source code of each package is in a file with extension
+`.dtx`. Running LaTeX on the file `tools.ins` will produce all the
+package files, and some associated files.
+
+So you should first process `tools.ins`:
+
+ latex tools.ins
+
+The files with extensions `.sty` and `.tex` (including a file whose
+name is just `.tex`) should then be moved to a directory on LaTeX's
+standard input path.
+
+Documentation for the individual packages may then be obtained by
+running LaTeX on the `.dtx` files.
+
+For example:
+
+ latex array.dtx
+
+will produce the file `array.pdf`, documenting the array package.
+
+
+The file `manifest.txt` contains a list of the main files in the
+distribution together with a one-or-two line summary of each package.
+
+
+### Copyright
+
+Copyright is maintained on each of these packages by the author(s)
+of the package.
+
+
+### Distribution Conditions
+
+All the files in this bundle may be distributed 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 Tools Bundle is
+given in the file `manifest.txt`.
+
+Commercial users of the `multicol` package are asked to read the
+notice at the head of the file multicol.dtx.
+
+The use of these files is otherwise unrestricted.
+
+
+### Reporting Bugs
+
+If you wish to report a problem or bug in any of these packages
+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!
+
+
+
+### Copyright
+
+This README file is copyright 1993-2017 The LaTeX3 Project.
+
diff --git a/macros/latex/required/tools/README.txt b/macros/latex/required/tools/README.txt
new file mode 100644
index 0000000000..1020fac5a4
--- /dev/null
+++ b/macros/latex/required/tools/README.txt
@@ -0,0 +1,97 @@
+
+%
+% Copyright 1993-2017
+% 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'.
+%
+
+
+README for the `tools' bundle
+=============================
+
+This `bundle' consists of LaTeX2e packages written and supported by
+members of the LaTeX3 Project Team.
+
+The documented source code of each package is in a file with extension
+`.dtx'. Running LaTeX on the file tools.ins will produce all the
+package files, and some associated files.
+
+So you should first process tools.ins:
+
+ latex tools.ins
+
+The files with extensions `.sty' and `.tex' (including a file whose
+name is just `.tex') should then be moved to a directory on LaTeX's
+standard input path.
+
+See the Note at the end of this file if you have problems processing
+the tools.ins file.
+
+Documentation for the individual packages may then be obtained by
+running LaTeX on the `.dtx' files.
+
+For example:
+
+ latex array.dtx
+
+will produce the file array.dvi, documenting the array package.
+
+
+The file manifest.txt contains a list of the main files in the
+distribution together with a one-or-two line summary of each package.
+
+
+Copyright
+=========
+Copyright is maintained on each of these packages by the author(s)
+of the package.
+
+
+Distribution Conditions
+=======================
+
+All the files in this bundle may be distributed under the conditions
+of the LaTeX Project Public License, either version 1.1 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.1 or later is part of all distributions of LaTeX
+version 1999/06/01 or later.
+
+The list of all files belonging to the `Tools Bundle' is
+given in the file `manifest.txt'.
+
+Commercial users of the multicol package are asked to read the
+notice at the head of the file multicol.dtx.
+
+The use of these files is otherwise unrestricted.
+
+
+Reporting Bugs
+==============
+
+If you wish to report a problem or bug in any of these packages, use
+the latexbug.tex program that comes with the standard LaTeX
+distribution. Please ensure that you enter `tools' category when
+prompted with a menu of categories, so that the message will be
+automatically forwarded to the appropriate part of our database.
+
+When reporting bugs, please produce a small test file that shows the
+problem, and ensure that you are using the current version of the
+package, and of the base LaTeX software.
+
+
diff --git a/macros/latex/required/tools/afterpage.dtx b/macros/latex/required/tools/afterpage.dtx
new file mode 100644
index 0000000000..01817368c0
--- /dev/null
+++ b/macros/latex/required/tools/afterpage.dtx
@@ -0,0 +1,385 @@
+% \iffalse meta-comment
+%
+% Copyright 1993-2014
+%
+% 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/required/tools/afterpage.ins b/macros/latex/required/tools/afterpage.ins
new file mode 100644
index 0000000000..2f704e10d7
--- /dev/null
+++ b/macros/latex/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 1993-2017
+%% 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 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'.
+
+\endpreamble
+
+
+\generate{\file{afterpage.sty}{\from{afterpage.dtx}{package}}}
+
+\endbatchfile
diff --git a/macros/latex/required/tools/afterpage.pdf b/macros/latex/required/tools/afterpage.pdf
new file mode 100644
index 0000000000..9cec0bfad4
--- /dev/null
+++ b/macros/latex/required/tools/afterpage.pdf
Binary files differ
diff --git a/macros/latex/required/tools/array-2016-10-06.sty b/macros/latex/required/tools/array-2016-10-06.sty
new file mode 100644
index 0000000000..0b619362d4
--- /dev/null
+++ b/macros/latex/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/required/tools/array.dtx b/macros/latex/required/tools/array.dtx
new file mode 100644
index 0000000000..ba92928941
--- /dev/null
+++ b/macros/latex/required/tools/array.dtx
@@ -0,0 +1,3084 @@
+% \iffalse meta-comment
+%
+% Copyright 1993-2018
+%
+% 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{}{2018-04-30}
+%<+package>
+%<+package>\ProvidesPackage{array}
+%<+package> [2018/12/30 v2.4k 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{\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}}%
+% \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/required/tools/array.pdf b/macros/latex/required/tools/array.pdf
new file mode 100644
index 0000000000..e2320dfc79
--- /dev/null
+++ b/macros/latex/required/tools/array.pdf
Binary files differ
diff --git a/macros/latex/required/tools/bm.dtx b/macros/latex/required/tools/bm.dtx
new file mode 100644
index 0000000000..b8be6530eb
--- /dev/null
+++ b/macros/latex/required/tools/bm.dtx
@@ -0,0 +1,1697 @@
+% \iffalse meta-comment
+%
+% Copyright 1993-2017
+%
+% 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
+%% 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}
+ [2017/01/16 v1.2c 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}
+%
+% |\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
+\@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}
+% \begin{macrocode}
+ \let\bm@prime\copy
+ \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/required/tools/bm.ins b/macros/latex/required/tools/bm.ins
new file mode 100644
index 0000000000..8e6b2b1075
--- /dev/null
+++ b/macros/latex/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 1993-2017
+%% 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 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'.
+
+\endpreamble
+
+
+\generate{\file{bm.sty}{\from{bm.dtx}{package}}}
+
+\endbatchfile
diff --git a/macros/latex/required/tools/bm.pdf b/macros/latex/required/tools/bm.pdf
new file mode 100644
index 0000000000..d2ab8ca3d5
--- /dev/null
+++ b/macros/latex/required/tools/bm.pdf
Binary files differ
diff --git a/macros/latex/required/tools/calc.dtx b/macros/latex/required/tools/calc.dtx
new file mode 100644
index 0000000000..ce6aeae034
--- /dev/null
+++ b/macros/latex/required/tools/calc.dtx
@@ -0,0 +1,1357 @@
+% \iffalse meta-comment
+%
+% Copyright 1993-2017
+%
+% 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/required/tools/calc.pdf b/macros/latex/required/tools/calc.pdf
new file mode 100644
index 0000000000..d34692b29c
--- /dev/null
+++ b/macros/latex/required/tools/calc.pdf
Binary files differ
diff --git a/macros/latex/required/tools/changes.txt b/macros/latex/required/tools/changes.txt
new file mode 100644
index 0000000000..977b7aa4fb
--- /dev/null
+++ b/macros/latex/required/tools/changes.txt
@@ -0,0 +1,1634 @@
+=======================================================================
+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-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
+ an 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/required/tools/dcolumn.dtx b/macros/latex/required/tools/dcolumn.dtx
new file mode 100644
index 0000000000..ea3dddc343
--- /dev/null
+++ b/macros/latex/required/tools/dcolumn.dtx
@@ -0,0 +1,361 @@
+% \iffalse meta-comment
+%
+% Copyright 1993-2014
+%
+% 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/required/tools/dcolumn.pdf b/macros/latex/required/tools/dcolumn.pdf
new file mode 100644
index 0000000000..62899edd4d
--- /dev/null
+++ b/macros/latex/required/tools/dcolumn.pdf
Binary files differ
diff --git a/macros/latex/required/tools/delarray.dtx b/macros/latex/required/tools/delarray.dtx
new file mode 100644
index 0000000000..79d69e1b0c
--- /dev/null
+++ b/macros/latex/required/tools/delarray.dtx
@@ -0,0 +1,206 @@
+% \iffalse meta-comment
+%
+% Copyright 1993-2014
+%
+% 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/required/tools/delarray.pdf b/macros/latex/required/tools/delarray.pdf
new file mode 100644
index 0000000000..0d0f227b7e
--- /dev/null
+++ b/macros/latex/required/tools/delarray.pdf
Binary files differ
diff --git a/macros/latex/required/tools/enumerate.dtx b/macros/latex/required/tools/enumerate.dtx
new file mode 100644
index 0000000000..43976903e7
--- /dev/null
+++ b/macros/latex/required/tools/enumerate.dtx
@@ -0,0 +1,335 @@
+% \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
+% \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/required/tools/enumerate.pdf b/macros/latex/required/tools/enumerate.pdf
new file mode 100644
index 0000000000..06f8279326
--- /dev/null
+++ b/macros/latex/required/tools/enumerate.pdf
Binary files differ
diff --git a/macros/latex/required/tools/fileerr.dtx b/macros/latex/required/tools/fileerr.dtx
new file mode 100644
index 0000000000..089149df97
--- /dev/null
+++ b/macros/latex/required/tools/fileerr.dtx
@@ -0,0 +1,123 @@
+% \iffalse meta-comment
+%
+% Copyright 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005
+% 2006 2008 2009
+% 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/required/tools/fileerr.pdf b/macros/latex/required/tools/fileerr.pdf
new file mode 100644
index 0000000000..95ee1d706a
--- /dev/null
+++ b/macros/latex/required/tools/fileerr.pdf
Binary files differ
diff --git a/macros/latex/required/tools/fontsmpl.dtx b/macros/latex/required/tools/fontsmpl.dtx
new file mode 100644
index 0000000000..5c8af97e7e
--- /dev/null
+++ b/macros/latex/required/tools/fontsmpl.dtx
@@ -0,0 +1,338 @@
+% \iffalse meta-comment
+%
+% Copyright 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005
+% 2006 2008 2009
+% 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/required/tools/fontsmpl.pdf b/macros/latex/required/tools/fontsmpl.pdf
new file mode 100644
index 0000000000..28c71aec26
--- /dev/null
+++ b/macros/latex/required/tools/fontsmpl.pdf
Binary files differ
diff --git a/macros/latex/required/tools/ftnright.dtx b/macros/latex/required/tools/ftnright.dtx
new file mode 100644
index 0000000000..31b3033522
--- /dev/null
+++ b/macros/latex/required/tools/ftnright.dtx
@@ -0,0 +1,1018 @@
+% \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
+%\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/required/tools/ftnright.pdf b/macros/latex/required/tools/ftnright.pdf
new file mode 100644
index 0000000000..41fbf65b7d
--- /dev/null
+++ b/macros/latex/required/tools/ftnright.pdf
Binary files differ
diff --git a/macros/latex/required/tools/hhline.dtx b/macros/latex/required/tools/hhline.dtx
new file mode 100644
index 0000000000..6d08658ef9
--- /dev/null
+++ b/macros/latex/required/tools/hhline.dtx
@@ -0,0 +1,322 @@
+% \iffalse meta-comment
+%
+% Copyright 1993-2014
+%
+% 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/required/tools/hhline.pdf b/macros/latex/required/tools/hhline.pdf
new file mode 100644
index 0000000000..de167c7b3c
--- /dev/null
+++ b/macros/latex/required/tools/hhline.pdf
Binary files differ
diff --git a/macros/latex/required/tools/indentfirst.dtx b/macros/latex/required/tools/indentfirst.dtx
new file mode 100644
index 0000000000..6d9a564e58
--- /dev/null
+++ b/macros/latex/required/tools/indentfirst.dtx
@@ -0,0 +1,77 @@
+% \iffalse meta-comment
+%
+% Copyright 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005
+% 2006 2008 2009
+% 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/required/tools/indentfirst.pdf b/macros/latex/required/tools/indentfirst.pdf
new file mode 100644
index 0000000000..8372244456
--- /dev/null
+++ b/macros/latex/required/tools/indentfirst.pdf
Binary files differ
diff --git a/macros/latex/required/tools/layout.dtx b/macros/latex/required/tools/layout.dtx
new file mode 100644
index 0000000000..40f790aed9
--- /dev/null
+++ b/macros/latex/required/tools/layout.dtx
@@ -0,0 +1,1025 @@
+% \iffalse meta-comment
+%
+% Copyright 1993-2014
+%
+% 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/required/tools/layout.pdf b/macros/latex/required/tools/layout.pdf
new file mode 100644
index 0000000000..b6bfa427bb
--- /dev/null
+++ b/macros/latex/required/tools/layout.pdf
Binary files differ
diff --git a/macros/latex/required/tools/longtable.dtx b/macros/latex/required/tools/longtable.dtx
new file mode 100644
index 0000000000..07823b9574
--- /dev/null
+++ b/macros/latex/required/tools/longtable.dtx
@@ -0,0 +1,2150 @@
+% \iffalse meta-comment
+%
+% Copyright 1993-2014
+%
+% 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-2001 David Carlisle
+%
+%<*dtx>
+ \ProvidesFile{longtable.dtx}
+%</dtx>
+%<package>\NeedsTeXFormat{LaTeX2e}[1995/06/01]
+%<package>\ProvidesPackage{longtable}
+%<driver> \ProvidesFile{longtable.drv}
+% \fi
+% \ProvidesFile{longtable.dtx}
+ [2014/10/28 v4.11 Multi-page Table package (DPC)+ FMi change]
+%
+% \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
+%FMi
+ \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
+%FMi
+ \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/required/tools/longtable.ins b/macros/latex/required/tools/longtable.ins
new file mode 100644
index 0000000000..381c415b62
--- /dev/null
+++ b/macros/latex/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 1993-2017
+%% 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 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'.
+
+\endpreamble
+
+
+\generate{\file{longtable.sty}{\from{longtable.dtx}{package}}}
+
+\endbatchfile
diff --git a/macros/latex/required/tools/longtable.pdf b/macros/latex/required/tools/longtable.pdf
new file mode 100644
index 0000000000..63339d3f32
--- /dev/null
+++ b/macros/latex/required/tools/longtable.pdf
Binary files differ
diff --git a/macros/latex/required/tools/manifest.txt b/macros/latex/required/tools/manifest.txt
new file mode 100644
index 0000000000..8b0f9e32d0
--- /dev/null
+++ b/macros/latex/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/required/tools/multicol-2017-04-11.sty b/macros/latex/required/tools/multicol-2017-04-11.sty
new file mode 100644
index 0000000000..e8558e4ce0
--- /dev/null
+++ b/macros/latex/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/required/tools/multicol.dtx b/macros/latex/required/tools/multicol.dtx
new file mode 100644
index 0000000000..fd77d6247d
--- /dev/null
+++ b/macros/latex/required/tools/multicol.dtx
@@ -0,0 +1,4415 @@
+% \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-2018 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}
+ [2018/12/27 v1.8v 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}{{\sf 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 {\sf 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.
+%
+%
+% 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 {\sf
+% doc.sty} (see ``The {\tt 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 {\sf 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 {\sf.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 {\sf 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 `{\sf 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.
+%
+% Additionally you can set another counter, the `{\sf 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.
+%
+% Unlike `{\sf collectmore},' the `{\sf 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 {\sf 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
+% {\sf 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., {\tt
+% 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 {\tt t}, {\tt b}, and/or {\tt p} in their optional
+% argument, but {\tt 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 {\sf figure} or {\sf 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 `{\sf 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 {\sf 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 {\sf minipage} as shown in
+% \ref{tab:newcmds} where a {\sf multicols} environment within a
+% {\sf 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 {\sf 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 misbehaviour 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\mbox{\tt 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 {\sf 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 {\tt
+% 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 {\sf 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 pagewide 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 (pagewide 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 bahve 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 pagewide
+% footnotes\footnote{I'm not sure that I really want pagewide
+% 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 `{\sf 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 longlasting 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|. Normlly 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 theorey there is a possibility to sneak
+% in a whoe 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 sich 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 `{\sf 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 initalize |\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 intext 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 discarable 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 signalled 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 {\sf true}
+% or {\sf 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 inbetween. 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| {\sf -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}
+% 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 an 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 selfcanceling 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
+% preceeded 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@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 modelled 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/required/tools/multicol.ins b/macros/latex/required/tools/multicol.ins
new file mode 100644
index 0000000000..ee295fed17
--- /dev/null
+++ b/macros/latex/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 1993-2018
+%% 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 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'.
+
+\endpreamble
+
+
+\generateFile{multicol.sty}{t}{%
+ \from{multicol.dtx}{package,badness,check,marktrace,nobalance}}
+
+
+\endbatchfile
diff --git a/macros/latex/required/tools/multicol.pdf b/macros/latex/required/tools/multicol.pdf
new file mode 100644
index 0000000000..af52be07b8
--- /dev/null
+++ b/macros/latex/required/tools/multicol.pdf
Binary files differ
diff --git a/macros/latex/required/tools/rawfonts.dtx b/macros/latex/required/tools/rawfonts.dtx
new file mode 100644
index 0000000000..51502c631e
--- /dev/null
+++ b/macros/latex/required/tools/rawfonts.dtx
@@ -0,0 +1,219 @@
+% \iffalse meta-comment
+%
+% Copyright 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005
+% 2006 2008 2009
+% 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/required/tools/rawfonts.pdf b/macros/latex/required/tools/rawfonts.pdf
new file mode 100644
index 0000000000..151b7c5d81
--- /dev/null
+++ b/macros/latex/required/tools/rawfonts.pdf
Binary files differ
diff --git a/macros/latex/required/tools/shellesc.dtx b/macros/latex/required/tools/shellesc.dtx
new file mode 100644
index 0000000000..ebc436ad96
--- /dev/null
+++ b/macros/latex/required/tools/shellesc.dtx
@@ -0,0 +1,240 @@
+% \iffalse
+%% Source File: shellesc.dtx
+%% Copyright 2015-2016 LaTeX3 project
+%%
+%% 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.02a 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/required/tools/shellesc.pdf b/macros/latex/required/tools/shellesc.pdf
new file mode 100644
index 0000000000..80d8635189
--- /dev/null
+++ b/macros/latex/required/tools/shellesc.pdf
Binary files differ
diff --git a/macros/latex/required/tools/showkeys.dtx b/macros/latex/required/tools/showkeys.dtx
new file mode 100644
index 0000000000..14ac876627
--- /dev/null
+++ b/macros/latex/required/tools/showkeys.dtx
@@ -0,0 +1,905 @@
+% \iffalse meta-comment
+%
+% Copyright 1993-2014
+%
+% 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-2014 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/required/tools/showkeys.pdf b/macros/latex/required/tools/showkeys.pdf
new file mode 100644
index 0000000000..d772c3e656
--- /dev/null
+++ b/macros/latex/required/tools/showkeys.pdf
Binary files differ
diff --git a/macros/latex/required/tools/somedefs.dtx b/macros/latex/required/tools/somedefs.dtx
new file mode 100644
index 0000000000..bad29b0043
--- /dev/null
+++ b/macros/latex/required/tools/somedefs.dtx
@@ -0,0 +1,172 @@
+% \iffalse meta-comment
+%
+% Copyright 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005
+% 2006 2008 2009
+% 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/required/tools/somedefs.pdf b/macros/latex/required/tools/somedefs.pdf
new file mode 100644
index 0000000000..eecebfb273
--- /dev/null
+++ b/macros/latex/required/tools/somedefs.pdf
Binary files differ
diff --git a/macros/latex/required/tools/tabularx.dtx b/macros/latex/required/tools/tabularx.dtx
new file mode 100644
index 0000000000..5eaabbe310
--- /dev/null
+++ b/macros/latex/required/tools/tabularx.dtx
@@ -0,0 +1,968 @@
+% \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
+% \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/required/tools/tabularx.ins b/macros/latex/required/tools/tabularx.ins
new file mode 100644
index 0000000000..0953bdea54
--- /dev/null
+++ b/macros/latex/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 1993-2017
+%% 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 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'.
+
+\endpreamble
+
+\generate{\file{tabularx.sty}{\from{tabularx.dtx}{package}}}
+
+\endbatchfile
diff --git a/macros/latex/required/tools/tabularx.pdf b/macros/latex/required/tools/tabularx.pdf
new file mode 100644
index 0000000000..cc78234679
--- /dev/null
+++ b/macros/latex/required/tools/tabularx.pdf
Binary files differ
diff --git a/macros/latex/required/tools/theorem.dtx b/macros/latex/required/tools/theorem.dtx
new file mode 100644
index 0000000000..5a76fdb200
--- /dev/null
+++ b/macros/latex/required/tools/theorem.dtx
@@ -0,0 +1,1144 @@
+% \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
+%
+%%
+%
+%
+\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/required/tools/theorem.pdf b/macros/latex/required/tools/theorem.pdf
new file mode 100644
index 0000000000..c3305bbfc3
--- /dev/null
+++ b/macros/latex/required/tools/theorem.pdf
Binary files differ
diff --git a/macros/latex/required/tools/tools-overview.pdf b/macros/latex/required/tools/tools-overview.pdf
new file mode 100644
index 0000000000..b8ccf9ed60
--- /dev/null
+++ b/macros/latex/required/tools/tools-overview.pdf
Binary files differ
diff --git a/macros/latex/required/tools/tools-overview.tex b/macros/latex/required/tools/tools-overview.tex
new file mode 100644
index 0000000000..817a37ced5
--- /dev/null
+++ b/macros/latex/required/tools/tools-overview.tex
@@ -0,0 +1,212 @@
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesFile{tools-overview.tex}[2015/03/31 v1.0 Tools overview]
+
+% Copyright (c) 2006-2014 Heiko Oberdiek
+% (c) 2015-2016 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/required/tools/tools.ins b/macros/latex/required/tools/tools.ins
new file mode 100644
index 0000000000..817e149bca
--- /dev/null
+++ b/macros/latex/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 1993-2017
+%% 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 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'.
+
+\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/required/tools/trace.dtx b/macros/latex/required/tools/trace.dtx
new file mode 100644
index 0000000000..dabec8aa00
--- /dev/null
+++ b/macros/latex/required/tools/trace.dtx
@@ -0,0 +1,733 @@
+% \iffalse meta-comment
+%
+% Copyright 1993-2018
+%
+% 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 1999-2018 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/required/tools/trace.pdf b/macros/latex/required/tools/trace.pdf
new file mode 100644
index 0000000000..2986128e0b
--- /dev/null
+++ b/macros/latex/required/tools/trace.pdf
Binary files differ
diff --git a/macros/latex/required/tools/varioref.dtx b/macros/latex/required/tools/varioref.dtx
new file mode 100644
index 0000000000..2417e9b120
--- /dev/null
+++ b/macros/latex/required/tools/varioref.dtx
@@ -0,0 +1,2147 @@
+% \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
+% \iffalse
+%% 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.
+%%
+%
+%<package>\NeedsTeXFormat{LaTeX2e}[1995/05/16]
+%<package>\ProvidesPackage{varioref}
+%<package> [2016/02/16 v1.5c 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}
+
+%
+% \newcommand\NewIn[1]{\marginpar{\fbox{\fbox{\sffamily\tabular{l}New in\\#1\endtabular}}}}
+%
+% \title{The \texttt{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{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| and except that
+% it will produce the string that is saved in |\reftextcurrent| if
+% label and reference fall onto the same page. 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.
+%
+% You can put 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
+% \NewIn{1998}
+% 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
+% \texttt{ifthen} package)
+%\begin{verbatim}
+% \newcommand\amusingversion[2]{%
+% \vrefpagenum\firstnum{#1}%
+% \vrefpagenum\secondnum{#2}%
+% the definition%
+% \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 the are on different pages.
+%
+%
+% The user commands |\vref|, |\vpageref|, and |\vpagerefrange| all
+% \NewIn{2001}
+% 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 is too late to change the default behaviour I've added star
+% versions of the macros which do not add any space before the
+% generated text (they do nevertheless remove space at the left).
+%
+%
+%
+% \DescribeMacro\labelformat
+% \NewIn{2002}
+% 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. If, for
+% example, references to equations are always to be typeset as
+% ``equation (\textit{number})'', one has to code
+% ``\verb=equation (\ref{=\textit{key}\verb=})=''. With |\labelformat|
+% the \texttt{varioref} package offers a possibility to generate such
+% frills automatically. The command takes two arguments: the first is
+% the name of a counter and the second is its representation when
+% referenced. This means that for a successful usage, one has to know
+% the counter name being used for generating the label, though in
+% practice this should not pose a problem. The current counter number
+% is picked up as an argument.
+% Here are two examples:
+%\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). To overcome this problem \texttt{varioref}
+% introduces the commands |\Ref| and |\Vref| that behave like
+% |\ref| and |\{vref| except that they uppercase the first token
+% of the generated string.
+%
+% To make |\Ref| or |\Vref| work properly the very first token in
+% the second argument of |\labelformat| has to be a simple \textsc{ascii}
+% 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)
+% 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}|.
+%
+% \DescribeMacro\vpagerefnum
+% 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 |\vpagerefnum| 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 \texttt{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 \texttt{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}
+%
+% 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).
+%
+%
+% \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 \texttt{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 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
+% \texttt{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}
+% \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}
+%
+% 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
+% \texttt{babel} package).
+% \begin{macrocode}
+\ExecuteOptions{english,final}
+\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 which means: do not add a
+% space in front of the generated text---ever.
+% \begin{macrocode}
+\DeclareRobustCommand\vpageref{\@ifstar
+ {\let\vref@space\relax\vp@geref}%
+ {\let\vref@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 \texttt{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}
+% The default for the second optional argument is a space which is
+% prefixed by |\unskip| to get rid of any leading space inserted
+% already.
+% \changes{v1.0h}{1994/06/11}{Pass first argument in both cases}
+% \changes{v1.0i}{1994/06/20}{Do it correctly}
+% \begin{macrocode}
+ {\@@vpageref{#1}}{\@@vpageref{#1}[\unskip\vref@space]}}
+% \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 and also
+% removes any leading space.
+% \begin{macrocode}
+ \leavevmode\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 \texttt{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}
+% \changes{v1.1g}{1998/05/10}{Test if inside AMS display (pr2175)}
+% Inside displays of the \texttt{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. Since we have removed
+% any leading space we now insert a space (unless this was the star
+% form of the command) and then compare the two
+% page references.
+% \begin{macrocode}
+ \vref@space
+ \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.
+% \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
+ #2%
+% \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 \texttt{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}{\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
+% \texttt{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}
+% \changes{v1.3a}{2001/04/12}{Scan for star form}
+% We start by scanning for a star form in which case we do not put
+% any space before the generated text (only remove some).
+% \begin{macro}{\vr@f}
+% \begin{macrocode}
+\DeclareRobustCommand\vref{\@ifstar
+ {\let\vref@space\relax\vr@f}%
+ {\let\vref@space\nobreakspace\vr@f}}
+% \end{macrocode}
+% And now we do the real work\ldots
+% \changes{v1.3c}{2001/09/04}{Correct typo in name}
+% \begin{macrocode}
+\def\vr@f#1{%
+% \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}}
+%
+% Above comments all refer to the earlier versions where there was
+% no possibility to suppress the space at all. By now we have
+% |\vref*| and |\vpageref*| to suppress the in internally generated
+% space by redefining |\vref@space| appropriately.
+% \begin{macrocode}
+ \leavevmode\unskip\vref@space
+ \ref{#1}%
+% \end{macrocode}
+% That means we have have to use |\vpageref| and not the internal
+% |\@vpageref| --- otherwise we would pick up the
+% ``current'' definition for |\vref@space| instead of setting it
+% back to |\space|.
+% \changes{v1.4c}{2002/06/18}{Use \cs{vpageref} not \cs{@vpageref} (pr/3403)}
+% \begin{macrocode}
+ \vpageref[\unskip]{#1}}
+% \end{macrocode}
+% \end{macro}
+% \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}
+%
+%
+% \subsection{An extension of counter referencing}
+%
+% \begin{macro}{\refstepcounter}
+% \changes{v1.4a}{2002/02/24}{Macro redefined}
+%
+% At the moment a reference to a counter |foo| will generate the
+% equivalent of |\p@foo\thefoo| although not quite in this form. For
+% some applications it would be nice of one could have |\thefoo| being
+% an argument to |\p@foo| to be able to put material before and after
+% the number generated by |\thefoo|. This can be easily achieved with
+% a small change to one of the kernel commands as follows:
+% \begin{macrocode}
+\def\refstepcounter#1{\stepcounter{#1}%
+ \protected@edef\@currentlabel
+ {\csname p@#1\expandafter\endcsname\csname the#1\endcsname}%
+}
+% \end{macrocode}
+% The trick is to ensure that |\csname the#1\endcsname| is turned into
+% a single token before |\p@...| is expanded further. This way, if the
+% |\p@...| command is a macro with one argument it will receive
+% |\the...|. With the kernel code (i.e., without the |\expandafter|)
+% it will instead pick up |\csname| which would be disastrous.
+%
+% Using |\expandafter| instead of braces delimiting the argument is
+% better because, assuming that the |\p@...| command is not defined as
+% a macro with one argument, the braces will stay and prohibit kerning
+% that might otherwise happen between the glyphs generated by
+% |\the...| and surrounding glyphs.
+% \end{macro}
+%
+% \begin{macro}{\labelformat}
+% \changes{v1.4a}{2002/02/24}{Macro added}
+% A shortcut to set the |\p@...| macro for a counter. It will pick
+% up the counter representation as an argument so that it can be
+% specially formatted.
+% \begin{macrocode}
+\def\labelformat#1{\expandafter\def\csname p@#1\endcsname##1}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\Ref}
+% \changes{v1.4a}{2002/02/24}{Macro added}
+% This macro expands the result of |\ref| and then uppercases the
+% first token. Only useful if the label was generated via
+% |\labelformat| and contains some lower case letter at its start. If
+% the label starts with a complicated construct (e.g., an accented
+% letter) one has to surround everything that needs uppercasing in
+% a brace group in the definition of |\labelformat|.\footnote{There
+% is one problem with this approach: the braces are kept in a
+% normal \texttt{\textbackslash ref} which might spoil kerning.
+% Perhaps one day this needs redoing.}
+% \begin{macrocode}
+\DeclareRobustCommand\Ref[1]{\protected@edef\@tempa{\ref{#1}}%
+ \expandafter\MakeUppercase\@tempa}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\Vref}
+% \changes{v1.4a}{2002/02/24}{Macro added}
+% \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)}
+% |\Vref| is the counterpart to |\vref| with |\ref| replaced by
+% |\Ref| in its definition.
+% \begin{macrocode}
+\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}}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macrocode}
+%</package>
+% \end{macrocode}
+% \Finale
+%
+\endinput
+
diff --git a/macros/latex/required/tools/varioref.ins b/macros/latex/required/tools/varioref.ins
new file mode 100644
index 0000000000..6c0482ddd0
--- /dev/null
+++ b/macros/latex/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 1993-2017
+%% 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 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'.
+
+\endpreamble
+
+
+\generateFile{varioref.sty}{t}{\from{varioref.dtx}{package}}
+
+
+\endbatchfile
diff --git a/macros/latex/required/tools/varioref.pdf b/macros/latex/required/tools/varioref.pdf
new file mode 100644
index 0000000000..f94de53235
--- /dev/null
+++ b/macros/latex/required/tools/varioref.pdf
Binary files differ
diff --git a/macros/latex/required/tools/verbatim.dtx b/macros/latex/required/tools/verbatim.dtx
new file mode 100644
index 0000000000..4b85f1a3ad
--- /dev/null
+++ b/macros/latex/required/tools/verbatim.dtx
@@ -0,0 +1,1858 @@
+% \iffalse meta-comment
+%
+% Copyright 1993-2014
+%
+% 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/required/tools/verbatim.pdf b/macros/latex/required/tools/verbatim.pdf
new file mode 100644
index 0000000000..766dabebb8
--- /dev/null
+++ b/macros/latex/required/tools/verbatim.pdf
Binary files differ
diff --git a/macros/latex/required/tools/xr.dtx b/macros/latex/required/tools/xr.dtx
new file mode 100644
index 0000000000..7889f713e9
--- /dev/null
+++ b/macros/latex/required/tools/xr.dtx
@@ -0,0 +1,177 @@
+% \iffalse meta-comment
+%
+% Copyright 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005
+% 2006 2008 2009 2018 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) 1994-1994 2018 2019 David Carlisle
+%
+%<package>\NeedsTeXFormat{LaTeX2e}
+%<package>\ProvidesPackage{xr}
+%<package> [2019/01/05 v5.04 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.02}{1994/05/28}{Fix for conditionals in aux file}
+%
+%
+% 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|.
+%
+% \StopEventually{}
+%
+% \section{The macros}
+%
+% \begin{macrocode}
+%<*package>
+% \end{macrocode}
+%
+% Check for the optional argument.
+% \begin{macrocode}
+\def\externaldocument{\@ifnextchar[\XR@{\XR@[]}}
+% \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\@input
+ \let\XR@tempa\@secondoftwo
+ \fi\fi
+ \XR@tempa{\newlabel{\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/required/tools/xr.pdf b/macros/latex/required/tools/xr.pdf
new file mode 100644
index 0000000000..98bea94d32
--- /dev/null
+++ b/macros/latex/required/tools/xr.pdf
Binary files differ
diff --git a/macros/latex/required/tools/xspace.dtx b/macros/latex/required/tools/xspace.dtx
new file mode 100644
index 0000000000..4fd2de18e7
--- /dev/null
+++ b/macros/latex/required/tools/xspace.dtx
@@ -0,0 +1,507 @@
+% \iffalse meta-comment
+%
+% Copyright 1993-2014
+%
+% 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/required/tools/xspace.pdf b/macros/latex/required/tools/xspace.pdf
new file mode 100644
index 0000000000..99c6ca61a8
--- /dev/null
+++ b/macros/latex/required/tools/xspace.pdf
Binary files differ