Add an initial model for testing TU encodings
[latex2e.git] / latex2e-20160331 / base / ltfssdcl.dtx
blobe85b435c98cacc209f4982adc12295183b473b09
1 % \iffalse meta-comment
3 % Copyright 1993-2016
4 % The LaTeX3 Project and any individual authors listed elsewhere
5 % in this file.
7 % This file is part of the LaTeX base system.
8 % -------------------------------------------
10 % It may be distributed and/or modified under the
11 % conditions of the LaTeX Project Public License, either version 1.3c
12 % of this license or (at your option) any later version.
13 % The latest version of this license is in
14 %    http://www.latex-project.org/lppl.txt
15 % and version 1.3c or later is part of all distributions of LaTeX
16 % version 2005/12/01 or later.
18 % This file has the LPPL maintenance status "maintained".
20 % The list of all files belonging to the LaTeX base distribution is
21 % given in the file `manifest.txt'. See also `legal.txt' for additional
22 % information.
24 % The list of derived (unpacked) files belonging to the distribution
25 % and covered by LPPL is defined by the unpacking scripts (with
26 % extension .ins) which are part of the distribution.
28 % \fi
29 % \iffalse
30 %%% From File: ltfssdcl.dtx
31 %% Copyright (C) 1989-1998 Frank Mittelbach and Rainer Sch\"opf,
32 %% all rights reserved.
34 %<*driver>
35 % \fi
38 \ProvidesFile{ltfssdcl.dtx}
39             [2016/02/18 v3.0r LaTeX Kernel (NFSS Declarative Interface)]
40 % \iffalse
41 \documentclass{ltxdoc}
42 \begin{document}
43 \DocInput{ltfssdcl.dtx}
44 \end{document}
45 %</driver>
46 % \fi
48 % \iffalse
49 %<+checkmem>\def\CHECKMEM{\tracingstats=2
50 %<+checkmem>  \newlinechar=`\^^J
51 %<+checkmem>  \message{^^JMemory usage: \filename}\shipout\hbox{}}
52 %<+checkmem>\CHECKMEM
53 % \fi
57 % \GetFileInfo{ltfssdcl.dtx}
58 % \title{A new font selection scheme for \TeX{} macro packages\\
59 %        (Declarative Interface)\thanks
60 %       {This file has version number
61 %       \fileversion\ dated \filedate}}
63 % \author{Frank Mittelbach \and Rainer Sch\"opf}
65 % \MaintainedByLaTeXTeam{latex}
66 % \maketitle
68 % This file contains the main implementation of the font selection
69 % scheme commands. See other parts of the \LaTeX\ distribution, or
70 % \emph{The \LaTeX\ Companion} for higher level documentation of these
71 % commands.
73 % \begin{quote}
74 %   \textbf{Warning:}
75 %  The macro documentation is still basically the documentation from the
76 %  first NFSS release and therefore in some cases probably not
77 %  completely accurate.
78 % \end{quote}
80 % \StopEventually{}
82 % \section{Interface Commands}
84 % \changes{v3.0i}{1998/08/17}
85 %      {(RmS) Corrected minor glitches in changes entries.}
86 % \changes{v3.0b}{1995/06/15}
87 %      {(DPC) minor documentation changes}
88 % \changes{v3.0a}{1995/05/24}
89 %      {(DPC) Make file from previous file, latint.dtx 1995/05/21 v2.1t}
90 % \changes{v3.0p}{2015/02/21}
91 %         {Removed autoload code}
94 % \changes{v2.1o}{1994/11/22}
95 %         {wrap long lines}
96 % \changes{v2.1m}{1994/11/17}
97 %         {\cs{@tempa} to \cs{reserved@a}}
98 % \changes{v2.1j}{1994/05/29}{Use new error commands}
99 % \changes{v2.1h}{1994/05/13}{Removed file identification typeout}
100 % \changes{v2.1g}{1994/05/12}{Allow \cs{relax}'ed cmds to be declared}
101 % \changes{v2.1g}{1994/05/12}{Allow \cs{relax} as undefined command}
102 % \changes{v2.1e}{1994/04/28}{Removed all \cs{uppercase} in hex num
103 %                             parsing macros}
104 % \changes{v2.1d}{1994/04/18}{Removed surplus \cs{no@alphabet@error}
105 %                             (see fam.dtx)}
109 % \changes{v2.1f}{1994/05/03}{Renamed \cs{@@DeclareMathDelimiter} to
110 %                             \cs{@DeclareMathDelimiter}}
111 % \changes{v2.1c}{1994/03/13}{add 2ekernel module to omit repeated code}
114 % \begin{macro}{\in@}
115 % \changes{v3.0m}{2009/10/20}{More robust thanks to Heiko.}
116 % \changes{v3.0n}{2011/05/08}{Simplified thanks to Bruno.}
117 % \begin{macro}{\ifin@}
118 %    |\@in| is a utility macro with two arguments.  It determines
119 %    whether its first argument occurs in its second and sets the
120 %    switch |\ifin@| accordingly. The first argument may not
121 %    contain braces nor |#| (more precisely, tokens of category
122 %    code 1,~2, or~6).
123 %    \begin{macrocode}
124 %<*2ekernel>
125 \def\in@#1#2%
126  {%
127    \begingroup
128      \def\in@@##1#1{}%
129      \toks@\expandafter{\in@@#2{}{}#1}%
130      \edef\in@@{\the\toks@}%
131    \expandafter\endgroup
132    \ifx\in@@\@empty
133      \in@false
134    \else
135      \in@true
136    \fi
138 \newif\ifin@
139 %    \end{macrocode}
140 % \end{macro}
141 % \end{macro}
143 % Before the |\begin{document}| command several
144 % \meta{math versions} and \meta{math alphabet identifiers} may
145 % be declared.
146 % In principle, there should be exactly one family/series/shape
147 % combination be declared for each version/alphabet pair.
148 % But we want to allow for defaults as well for automagical
149 % filling of holes.
151 % While building the tables for math alphabet identifiers and math
152 % versions we keep several lists:
153 % \begin{itemize}
154 %   \item the list of all math versions, |\version@list|,
155 %         each entry prefixed by the control sequence |\version@elt|,
156 %         i.e.\ this list has the following form
157 %         \begin{quote}
158 %           |\version@elt|\meta{version$_1$}^^A
159 %           |\version@elt|\meta{version$_2$}\ldots\\\hspace*{\fill}^^A
160 %           |\version@elt|\meta{version$_n$}
161 %         \end{quote}
162 %   \item the list of all math alphabet identifiers.  Here every
163 %         entry has the form:\\[2pt]
164 %         \hspace*{\MacroIndent}
165 %         |\group@elt|\meta{math group number}\\
166 %         \hspace*{\MacroIndent}
167 %         |{{|\meta{default family}^^A
168 %         |}{|\meta{default series}^^A
169 %         |}{|\meta{default shape}|}}|.
170 %   \item Each defined math alphabet identifier holds a list containing
171 %         Information about the {\em versions\/} for which it is
172 %         defined.  This list has a more complicated structure: it
173 %         looks as follows:
174 %         \begin{quote}
175 %           |\set@alpha|\meta{the alphabet identifier itself}\\
176 %           \hspace*{\MacroIndent}
177 %             |\reserved@c|\meta{math version}\meta{font info}\\
178 %           \hspace*{\MacroIndent}\ldots\\
179 %           |\@nil|
180 %         \end{quote}
181 %         where \meta{font info} is either |\reserved@e|
182 %         (if the combination is not defined yet) or
183 %         \begin{quote}
184 %           |{{|\meta{family}|}{|\meta{series}^^A
185 %           |}{|\meta{shape}|}}|
186 %         \end{quote}
187 % \end{itemize}
189 % \begin{macro}{\version@list}
190 %    We initialize the version list to be empty.
191 %    \begin{macrocode}
192 \let\version@list=\@empty
193 \@onlypreamble\version@list
194 %    \end{macrocode}
195 % \end{macro}
198 % \begin{macro}{\version@elt}
199 %    \begin{macrocode}
200 \let\version@elt\relax
201 \@onlypreamble\version@elt
202 %    \end{macrocode}
203 % \end{macro}
206 % \begin{macro}{\new@mathversion}
207 %    The macro |\new@mathversion| is called with the version control
208 %    sequence as its argument.
209 %    \begin{macrocode}
210 %\def\new@mathversion#1{%
211 %    \end{macrocode}
212 %    The first thing this macro does is to check if the version
213 %    identifier is already present in |\version@list|.
214 %    We enclose |\version@list| in braces since it might be empty
215 %    (if no {\em version\/} is defined yet).  But this means that
216 %    we need a suitable number of |\expandafter| primitives.
217 %    \begin{macrocode}
218 %  \expandafter\in@\expandafter#1\expandafter{\version@list}%
219 %  \ifin@
220 %    \end{macrocode}
221 %    If so it prints an error message.
222 %    The |\next| macro is used to get rid of the four characters
223 %    |\mv@| that would otherwise appear at the begin of the
224 %    version name in the error message.
225 %    \begin{macrocode}
226 %    \@latex@error{Math version
227 %               `\expandafter\@gobblefour\string#1'
228 %               already defined}\@eha
229 %    \end{macrocode}
230 %    Otherwise we have a new version, and we can proceed with
231 %    entering it into the tables.
232 %    We add it to |\version@list|.  This is very easy:
233 %    we define |\version@elt| (which is the delimiter in
234 %    |\version@list|) to protect itself and the following token
235 %    from being expanded and simply redefine |\version@list|.
236 %    \begin{macrocode}
237 %  \else
238 %     \global\expandafter\newcount\csname c@\expandafter
239 %                                 \@gobble\string#1\endcsname
240 %     \global\csname c@\expandafter
241 %                                 \@gobble\string#1\endcsname\@ne
242 %     \def\version@elt{\noexpand\version@elt\noexpand}%
243 %     \edef\version@list{\version@list\version@elt#1}%
244 %    \end{macrocode}
245 %    Then we prepare to enter the new version into all math
246 %    alphabet identifier lists.  Remember that these lists
247 %    use |\reserved@c| as delimiter, and that there appears the
248 %    control sequence |\reserved@e| that must not be expanded.
249 %    Therefore we take suitable precautions.
250 %    \begin{macrocode}
251 %     \def\reserved@c{\noexpand\reserved@c\noexpand}%
252 %     \let\reserved@e\relax
253 %    \end{macrocode}
254 %    We will now go through the |\alpha@list| to process every
255 %    \meta{math alphabet identifier} in turn.
256 %    Since this list has |\group@elt| as a delimiter we define
257 %    this control sequence.  It has three arguments as every
258 %    entry consists of three items (as explained above).
259 %    \begin{macrocode}
260 %     \def\group@elt##1##2##3{%
261 %    \end{macrocode}
262 %    The first of these arguments is the \meta{math alphabet
263 %    identifier}.  We redefine it by appending the information
264 %    about the new version at the end of the list contained in
265 %    it.  However, there is one subtlety: the definitions for
266 %    |\reserved@c| and |\reserved@e| made above prevent the
267 %    main part of the list from being expanded.  But we still have
268 %    to take care of the header and the trailer.  To do this we
269 %    remove the trailer by means of the macro |\remove@nil|
270 %    which also protect the header from being expanded.  Its
271 %    definition is given below.  Now we can prepare to add the
272 %    new version.
273 %    \begin{macrocode}
274 %          \edef##1{\expandafter\remove@nil##1%
275 %                   \reserved@c
276 %                   #1%
277 %                   \reserved@e
278 %                   \noexpand\@nil}}%
279 %    \end{macrocode}
280 %    Finally we call |\alpha@list| which will now execute
281 %    the macro |\group@elt| once for every defined \meta{math
282 %    alphabet identifier}.  And that's all for now.
283 %    \begin{macrocode}
284 %     \alpha@list
285 %  \fi}
286 %    \end{macrocode}
287 % \end{macro}
290 % \begin{macro}{\alpha@list}
291 %    As we explained above every entry in |\alpha@list| has
292 %    the form\\[2pt]
293 %    |\alpha@elt|\\\meta{alphabet identifier}\meta{internal
294 %    group number}\meta{default font assignments}\ldots\\[2pt]
295 %    We initialize it to |\@empty|.
296 %    \begin{macrocode}
297 \let\alpha@list\@empty
298 \@onlypreamble\alpha@list
299 %    \end{macrocode}
300 % \end{macro}
303 % \begin{macro}{\alpha@elt}
304 %    \begin{macrocode}
305 \let\alpha@elt\relax
306 \@onlypreamble\alpha@elt
307 %    \end{macrocode}
308 % \end{macro}
312 %  \begin{macro}{\newgroup}
313 % Start the group (fam) allocation at 0. (Doesn't belong here.)
314 %    \begin{macrocode}
315 \count18=-1
316 %    \end{macrocode}
317 % \end{macro}
319 % \begin{macro}{\stepcounter}
320 % \changes{v3.0f}{1997/11/13}
321 %      {(DPC) Remove as never used. (Re)defined in ltcounts}
322 % \end{macro}
324 % \begin{macro}{\select@group}
325 %    We surround |\select@group| with braces so that functions using it
326 %    can be used directly after |_| or |^|.
327 % \changes{v2.1p}{1994/12/10}{Surround with braces (add fourth arg)}
328 %    However, if we use oldstyle syntax where the math alphabet
329 %    doesn't have arguments (ie if |\math@bgroup| is not |\bgroup|) we
330 %    need to get rid of the extra group.
331 % \changes{v2.1q}{1995/04/02}{fix problem for pr/1275}
332 % \changes{v3.0g}{1997/11/20}
333 %      {(DPC) inline use of \cs{stepcounter} (faster, and saves a csname
334 %       per math version as no reset list)}
335 % \changes{v3.0q}{2015/03/18}{Introduce \cs{e@mathgroup@top}}
336 %    \begin{macrocode}
337 %</2ekernel>
338 %<latexrelease>\IncludeInRelease{2015/01/01}
339 %<latexrelease>                 {\select@group}{\select@group}%
340 %<*2ekernel|latexrelease>
341 \def\select@group#1#2#3#4{%
342  \ifx\math@bgroup\bgroup\else\relax\expandafter\@firstofone\fi
343  {%
344  \ifmmode
345   \ifnum\csname c@mv@\math@version\endcsname<\e@mathgroup@top
346      \begingroup
347        \escapechar\m@ne
348        \getanddefine@fonts{\csname c@mv@\math@version\endcsname}#3%
349        \globaldefs\@ne  \math@fonts
350      \endgroup
351      \init@restore@version
352      \xdef#1{\noexpand\use@mathgroup\noexpand#2%
353              {\number\csname c@mv@\math@version\endcsname}}%
354      \global\advance\csname c@mv@\math@version\endcsname\@ne
355    \else
356      \let#1\relax
357      \@latex@error{Too many math alphabets used in
358                    version \math@version}%
359         \@eha
360    \fi
361  \else \expandafter\non@alpherr\fi
362  #1{#4}%
363  }%
365 %</2ekernel|latexrelease>
366 %<latexrelease>\EndIncludeInRelease
367 %<latexrelease>\IncludeInRelease{0000/00/00}
368 %<latexrelease>                 {\select@group}{\select@group}%
369 %<latexrelease>\def\select@group#1#2#3#4{%
370 %<latexrelease> \ifx\math@bgroup\bgroup\else\relax\expandafter\@firstofone\fi
371 %<latexrelease> {%
372 %<latexrelease> \ifmmode
373 %<latexrelease>  \ifnum\csname c@mv@\math@version\endcsname<\sixt@@n
374 %<latexrelease>     \begingroup
375 %<latexrelease>       \escapechar\m@ne
376 %<latexrelease>       \getanddefine@fonts
377 %<latexrelease>         {\csname c@mv@\math@version\endcsname}#3%
378 %<latexrelease>       \globaldefs\@ne  \math@fonts
379 %<latexrelease>     \endgroup
380 %<latexrelease>     \init@restore@version
381 %<latexrelease>     \xdef#1{\noexpand\use@mathgroup\noexpand#2%
382 %<latexrelease>             {\number\csname c@mv@\math@version\endcsname}}%
383 %<latexrelease>     \global\advance\csname c@mv@\math@version\endcsname\@ne
384 %<latexrelease>   \else
385 %<latexrelease>     \let#1\relax
386 %<latexrelease>     \@latex@error{Too many math alphabets used in
387 %<latexrelease>                   version \math@version}%
388 %<latexrelease>        \@eha
389 %<latexrelease>   \fi
390 %<latexrelease> \else \expandafter\non@alpherr\fi
391 %<latexrelease> #1{#4}%
392 %<latexrelease> }%
393 %<latexrelease>}
394 %<latexrelease>\EndIncludeInRelease
395 %<*2ekernel>
396 %    \end{macrocode}
398 %    \begin{macrocode}
399 \@onlypreamble\restore@mathversion
400 %    \end{macrocode}
401 % \end{macro}
403 % \begin{macro}{\init@restore@version}
404 % \changes{v3.0e}{1996/07/26}{Removed \cs{ifrestore@version} switch
405 %          and replaced by \cs{init@restore@version}}
406 %    \begin{macrocode}
407 \def\init@restore@version{%
408         \global\let\init@restore@version\relax
409         \xdef\restore@mathversion
410              {\expandafter\noexpand\csname mv@\math@version\endcsname
411               \global\csname c@mv@\math@version\endcsname
412               \number\csname c@mv@\math@version\endcsname\relax}%
413         \aftergroup\dorestore@version
415 \@onlypreamble\init@restore@version
416 %    \end{macrocode}
417 % \end{macro}
419 % \begin{macro}{\non@alpherr}
420 % \changes{v3.0c}{1995/10/10}
421 %         {(DPC) autoload error message}
422 % \changes{v3.0j}{2005/07/27}
423 %         {(MH) Change because command is now properly robust}
424 %    \begin{macrocode}
425 \gdef\non@alpherr#1{\@latex@error{%
426 %    \end{macrocode}
427 % The command here will have a space at the end of its name, so we make
428 % sure not to insert an extra one.
429 %    \begin{macrocode}
430     \string#1allowed only in math mode}\@ehd}
431 %    \end{macrocode}
432 % \end{macro}
434 % \begin{macro}{\dorestore@version}
435 %    \begin{macrocode}
436 \def\dorestore@version
437  {\ifmmode
438     \aftergroup\dorestore@version
439   \else
440     \gdef\init@restore@version{%
441         \global\let\init@restore@version\relax
442         \xdef\restore@mathversion
443              {\expandafter\noexpand\csname mv@\math@version\endcsname
444               \global\csname c@mv@\math@version\endcsname
445               \number\csname c@mv@\math@version\endcsname\relax}%
446         \aftergroup\dorestore@version
447     }%
448     \begingroup
449       \let\getanddefine@fonts\@gobbletwo
450       \restore@mathversion
451     \endgroup
452   \fi}%
453 \@onlypreamble\dorestore@version
454 %    \end{macrocode}
455 % \end{macro}
457 % \begin{macro}{\document@select@group}
458 %    We surround |\select@group| with braces so that functions using it
459 %    can be used directly after |_| or |^|.
460 % \changes{v2.1p}{1994/12/10}{Surround with braces (add fourth arg)}
461 % \changes{v2.1q}{1995/04/02}{fix problem for pr/1275}
462 % \changes{v3.0g}{1997/11/20}
463 %      {(DPC) inline use of \cs{stepcounter} (faster, and saves a csname
464 %       per math version as no reset list)}
465 % \changes{v3.0q}{2015/03/18}{Introduce \cs{e@mathgroup@top}}
466 %    \begin{macrocode}
467 %</2ekernel>
468 %<latexrelease>\IncludeInRelease{2015/01/01}
469 %<latexrelease>  {\document@select@group}{\document@select@group}%
470 %<*2ekernel|latexrelease>
471 \def\document@select@group#1#2#3#4{%
472  \ifx\math@bgroup\bgroup\else\relax\expandafter\@firstofone\fi
473  {%
474  \ifmmode
475    \ifnum\csname c@mv@\math@version\endcsname<\e@mathgroup@top
476      \begingroup
477        \escapechar\m@ne
478        \getanddefine@fonts{\csname c@mv@\math@version\endcsname}#3%
479        \globaldefs\@ne  \math@fonts
480      \endgroup
481      \expandafter\extract@alph@from@version
482          \csname mv@\math@version\expandafter\endcsname
483          \expandafter{\number\csname
484                        c@mv@\math@version\endcsname}%
485           #1%
486      \global\advance\csname c@mv@\math@version\endcsname\@ne
487    \else
488      \let#1\relax
489      \@latex@error{Too many math alphabets used
490                    in version \math@version}%
491         \@eha
492   \fi
493  \else \expandafter\non@alpherr\fi
494  #1{#4}%
495  }%
497 %</2ekernel|latexrelease>
498 %<latexrelease>\EndIncludeInRelease
499 %<latexrelease>\IncludeInRelease{0000/00/00}
500 %<latexrelease>  {\document@select@group}{\document@select@group}%
501 %<latexrelease>\def\document@select@group#1#2#3#4{%
502 %<latexrelease> \ifx\math@bgroup\bgroup\else\relax\expandafter\@firstofone\fi
503 %<latexrelease> {%
504 %<latexrelease> \ifmmode
505 %<latexrelease>   \ifnum\csname c@mv@\math@version\endcsname<\sixt@@n
506 %<latexrelease>     \begingroup
507 %<latexrelease>       \escapechar\m@ne
508 %<latexrelease>       \getanddefine@fonts
509 %<latexrelease>         {\csname c@mv@\math@version\endcsname}#3%
510 %<latexrelease>       \globaldefs\@ne  \math@fonts
511 %<latexrelease>     \endgroup
512 %<latexrelease>     \expandafter\extract@alph@from@version
513 %<latexrelease>         \csname mv@\math@version\expandafter\endcsname
514 %<latexrelease>         \expandafter{\number\csname
515 %<latexrelease>                       c@mv@\math@version\endcsname}%
516 %<latexrelease>          #1%
517 %<latexrelease>     \global\advance\csname c@mv@\math@version\endcsname\@ne
518 %<latexrelease>   \else
519 %<latexrelease>     \let#1\relax
520 %<latexrelease>     \@latex@error{Too many math alphabets used
521 %<latexrelease>                   in version \math@version}%
522 %<latexrelease>        \@eha
523 %<latexrelease>  \fi
524 %<latexrelease> \else \expandafter\non@alpherr\fi
525 %<latexrelease> #1{#4}%
526 %<latexrelease> }%
527 %<latexrelease>}
528 %<latexrelease>\EndIncludeInRelease
529 %<*2ekernel>
530 %    \end{macrocode}
531 % \end{macro}
533 % \begin{macro}{\process@table}
534 %    \begin{macrocode}
535 \def\process@table{%
536     \def\cdp@elt##1##2##3##4{%
537         \@font@info{Checking defaults for
538                   ##1/##2/##3/##4}%
539         \expandafter
540         \ifx\csname##1/##2/##3/##4\endcsname\relax
541 %    \end{macrocode}
542 %    Grouping is important for two reasons, first |\cdp@elt| will get
543 %    redefined if |\Declare...| functions are executed within the
544 %    external |.fd| file and secondly |\try@load@fontshape| changes a
545 %    lot of catcodes without surrounding itself with a group.
546 %    \begin{macrocode}
547           \begingroup
548            \def\f@encoding{##1}\def\f@family{##2}%
549            \try@load@fontshape
550           \endgroup
551         \fi
552         \expandafter
553         \ifx\csname##1/##2/##3/##4\endcsname\relax
554              \@latex@error{This NFSS system isn't set up properly}%
555                        {For encoding scheme ##1 the defaults
556                         ##2/##3/##4 do not form a valid font shape}%
557         \else
558              \@font@info{... okay}%
559         \fi}%
560     \cdp@list
561 %    \end{macrocode}
562 %    Now we make sure that |\error@fontshape| is okay.
563 %    \begin{macrocode}
564     \begingroup
565        \escapechar\m@ne
566        \error@fontshape
567        \expandafter\ifx\csname \curr@fontshape\endcsname\relax
568           \begingroup
569             \try@load@fontshape
570            \endgroup
571        \fi
572        \expandafter\ifx\csname \curr@fontshape\endcsname\relax
573          \@latex@error{This NFSS system isn't set up properly}%
574             {The system maintainer forgot to specify a suitable
575              substitution
576              font shape using the \noexpand\DeclareErrorFont
577              command}%
578        \fi
579     \endgroup
580 %    \end{macrocode}
581 %    Set |\select@group| to its meaning used within the document body.
582 %    \begin{macrocode}
583     \let\select@group\document@select@group
584 %    \end{macrocode}
585 %    Install the default font attributes they are currently pointing
586 %    to error font shape.
587 %    Don't use |\reset@font| since that would trigger |\selectfont|.
588 %    \begin{macrocode}
589     \fontencoding{\encodingdefault}%
590     \fontfamily{\familydefault}%
591     \fontseries{\seriesdefault}%
592     \fontshape{\shapedefault}%
593 %    \end{macrocode}
594 %    kill all macros not longer needed.
595 %    we need to add many more!!!!!!
596 %    \begin{macrocode}
597  \everyjob{}%
599 \@onlypreamble\process@table
600 %    \end{macrocode}
601 % \end{macro}
603 %    \begin{macrocode}
604 %\@onlypreamble\set@mathradical
605 %    \end{macrocode}
607 % \begin{macro}{\DeclareMathVersion}
608 %    \begin{macrocode}
609 \def\DeclareMathVersion#1{%
610   \expandafter\new@mathversion\csname mv@#1\endcsname}
611 \@onlypreamble\DeclareMathVersion
612 %    \end{macrocode}
613 % \end{macro}
615 % \begin{macro}{\new@mathversion}
616 % \changes{v3.0o}{2011/09/03}
617 %      {(Will) Remove \cs{global} before \cs{newcount} (unnecessary and caused etex bug).}
618 %    \begin{macrocode}
619 \def\new@mathversion#1{%
620   \expandafter\in@\expandafter#1\expandafter{\version@list}%
621   \ifin@
622     \@font@info{Redeclaring math version
623                `\expandafter\@gobblefour\string#1'}%
624   \else
625     \expandafter\newcount\csname c@\expandafter
626                                 \@gobble\string#1\endcsname
627     \def\version@elt{\noexpand\version@elt\noexpand}%
628     \edef\version@list{\version@list\version@elt#1}%
629   \fi
630 %    \end{macrocode}
631 %    |\toks@| is used to gather all tokens for the math version.
632 %    |\count@| will be used to count the math groups we add to this
633 %    version.
634 %    \begin{macrocode}
635   \toks@{}%
636   \count@\z@
637 %    \end{macrocode}
638 %    Now we loop over |\group@list| to add all math groups defined so
639 %    far to the version and at the same time to count them.
640 %    \begin{macrocode}
641   \def\group@elt##1##2{%
642        \advance\count@\@ne
643        \addto@hook\toks@{\getanddefine@fonts##1##2}%
644        }%
645   \group@list
646 %    \end{macrocode}
647 %    We set the counter for this math version to the number of math
648 %    groups found in |\group@list|.
649 %    \begin{macrocode}
650   \global\csname c@\expandafter\@gobble\string#1\endcsname\count@
651 %    \end{macrocode}
652 %    Now we loop over |\alpha@list| to add all math alphabets known so
653 %    far. We have to distinguish the case that an alphabet by default
654 %    should produce an error in new versions.
655 %    \begin{macrocode}
656   \def\alpha@elt##1##2##3{%
657        \ifx##2\no@alphabet@error
658          \toks@\expandafter{\the\toks@\install@mathalphabet##1%
659              {\no@alphabet@error##1}}%
660        \else
661          \toks@\expandafter{\the\toks@\install@mathalphabet##1%
662              {\select@group##1##2##3}}%
663        \fi
664           }%
665   \alpha@list
666 %    \end{macrocode}
667 %    Finally we define the math version to expand to the contents of
668 %    |\toks@|.
669 % \changes{v2.0e}{1993/08/18}{Exchanged names of encodings in warning
670 %              message of \cs{SetSymbolFont}.}
671 %    \begin{macrocode}
672   \xdef#1{\the\toks@}%
674 \@onlypreamble\new@mathversion
675 %    \end{macrocode}
676 % \end{macro}
678 % \begin{macro}{\DeclareSymbolFont}
679 %    \begin{macrocode}
680 \def\DeclareSymbolFont#1#2#3#4#5{%
681  \@tempswafalse
682  \edef\reserved@b{#2}%
683  \def\cdp@elt##1##2##3##4{\def\reserved@c{##1}%
684       \ifx\reserved@b\reserved@c \@tempswatrue\fi}%
685  \cdp@list
686  \if@tempswa
687    \@ifundefined{sym#1}{%
688 %    \end{macrocode}
690 % \changes{v3.0q}{2015/03/18}{Restrict Symbol fonts to 0-15}
691 %    \begin{macrocode}
692       \ifnum\count18<15 %
693         \expandafter\new@mathgroup\csname sym#1\endcsname
694         \expandafter\new@symbolfont\csname sym#1\endcsname
695                         {#2}{#3}{#4}{#5}%
696       \else
697          \@latex@error{Too many symbol fonts declared}\@eha
698       \fi
699      }%
700      {%
701 %    \end{macrocode}
703 %    \begin{macrocode}
704       \@font@info{Redeclaring symbol font `#1'}%
705 %    \end{macrocode}
706 % \changes{v3.0f}{1997/11/13}
707 %      {(DPC) Really update \cs{group@list} dont
708 %         leave new version in \cs{toks@}. latex/2661}
709 % Update the group list.
710 %    \begin{macrocode}
711       \def\group@elt##1##2{%
712            \noexpand\group@elt\noexpand##1%
713            \expandafter\ifx\csname sym#1\endcsname##1%
714              \expandafter\noexpand\csname#2/#3/#4/#5\endcsname
715            \else
716                \noexpand##2%
717            \fi}%
718       \xdef\group@list{\group@list}%
719 %    \end{macrocode}
720 % Update the version list.
721 %    \begin{macrocode}
722       \def\version@elt##1{%
723           \expandafter
724           \SetSymbolFont@\expandafter##1\csname#2/#3/#4/#5\expandafter
725               \endcsname \csname sym#1\endcsname
726           }%
727       \version@list
728      }%
729   \else
730     \@latex@error{Encoding scheme  `#2' unknown}\@eha
731   \fi
732   }
733 \@onlypreamble\DeclareSymbolFont
734 %    \end{macrocode}
735 % \end{macro}
737 % \begin{macro}{\group@list}
738 %    \begin{macrocode}
739 \let\group@list\@empty
740 \@onlypreamble\group@list
741 %    \end{macrocode}
742 % \end{macro}
744 % \begin{macro}{\group@elt}
745 %    \begin{macrocode}
746 \let\group@elt\relax
747 \@onlypreamble\group@elt
748 %    \end{macrocode}
749 % \end{macro}
751 % \begin{macro}{\new@symbolfont}
752 %    \begin{macrocode}
753 \def\new@symbolfont#1#2#3#4#5{%
754     \toks@\expandafter{\group@list}%
755     \edef\group@list{\the\toks@\noexpand\group@elt\noexpand#1%
756                      \expandafter\noexpand\csname#2/#3/#4/#5\endcsname}%
757     \def\version@elt##1{\toks@\expandafter{##1}%
758                    \edef##1{\the\toks@\noexpand\getanddefine@fonts
759                    #1\expandafter\noexpand\csname#2/#3/#4/#5\endcsname}%
760                   \global\advance\csname c@\expandafter
761                                  \@gobble\string##1\endcsname\@ne
762                  }%
763     \version@list
765 \@onlypreamble\new@symbolfont
766 %    \end{macrocode}
767 % \end{macro}
769 % \begin{macro}{\SetSymbolFont}
770 %    \begin{macrocode}
771 \def\SetSymbolFont#1#2#3#4#5#6{%
772  \@tempswafalse
773  \edef\reserved@b{#3}%
774  \def\cdp@elt##1##2##3##4{\def\reserved@c{##1}%
775       \ifx\reserved@b\reserved@c \@tempswatrue\fi}%
776  \cdp@list
777  \if@tempswa
778   \expandafter\SetSymbolFont@
779     \csname mv@#2\expandafter\endcsname\csname#3/#4/#5/#6\expandafter
780     \endcsname \csname sym#1\endcsname
781  \else
782   \@latex@error{Encoding scheme  `#3' unknown}\@eha
783  \fi
785 \@onlypreamble\SetSymbolFont
786 %    \end{macrocode}
787 % \end{macro}
789 % \begin{macro}{\SetSymbolFont@}
790 % \changes{v3.0l}{2007/08/31}{Font warning changed to info
791 %    for encoding change (pr/3975)}
792 %    \begin{macrocode}
793 \def\SetSymbolFont@#1#2#3{%
794   \expandafter\in@\expandafter#1\expandafter{\version@list}%
795   \ifin@
796     \expandafter\in@\expandafter#3\expandafter{\group@list}%
797     \ifin@
798       \begingroup
799         \expandafter\get@cdp\string#2\@nil\reserved@a
800         \toks@{}%
801         \def\install@mathalphabet##1##2{%
802              \addto@hook\toks@{\install@mathalphabet##1{##2}}%
803             }%
804         \def\getanddefine@fonts##1##2{%
805           \ifnum##1=#3%
806              \addto@hook\toks@{\getanddefine@fonts#3#2}%
807              \expandafter\get@cdp\string##2\@nil\reserved@b
808              \ifx\reserved@a\reserved@b\else
809                 \@font@info{Encoding `\reserved@b' has changed
810                     to `\reserved@a' for symbol font\MessageBreak
811                    `\expandafter\@gobblefour\string#3' in the
812                     math version `\expandafter
813                     \@gobblefour\string#1'}%
814              \fi
815              \@font@info{%
816                 Overwriting symbol font
817                 `\expandafter\@gobblefour\string#3' in
818                  version `\expandafter
819                 \@gobblefour\string#1'\MessageBreak
820                 \@spaces \expandafter\@gobble\string##2 -->
821                          \expandafter\@gobble\string#2}%
822           \else
823              \addto@hook\toks@{\getanddefine@fonts##1##2}%
824           \fi}%
825          #1%
826          \xdef#1{\the\toks@}%
827       \endgroup
828     \else
829        \@latex@error{Symbol font `\expandafter\@gobblefour\string#3'
830                   not defined}\@eha
831     \fi
832   \else
833     \@latex@error{Math version `\expandafter\@gobblefour\string#1'
834        is not
835        defined}{You probably misspelled the name of the math
836        version.^^JOr you have to specify an additional package.}%
837   \fi
839 \@onlypreamble\SetSymbolFont@
840 %    \end{macrocode}
841 % \end{macro}
843 % \begin{macro}{\get@cdp}
844 %    \begin{macrocode}
845 \def\get@cdp#1#2/#3\@nil#4{\def#4{#2}}
846 \@onlypreamble\get@cdp
847 %    \end{macrocode}
848 % \end{macro}
850 % \begin{macro}{\DeclareMathAlphabet}
851 % \changes{v3.0j}{2005/07/27}
852 %         {(MH) Make document commands robust}
853 %    \begin{macrocode}
854 \def\DeclareMathAlphabet#1#2#3#4#5{%
855  \@tempswafalse
856  \edef\reserved@b{#2}%
857  \def\cdp@elt##1##2##3##4{\def\reserved@c{##1}%
858       \ifx\reserved@b\reserved@c \@tempswatrue\fi}%
859  \cdp@list
860  \if@tempswa
861    \expandafter\ifx
862    \csname\expandafter\@gobble\string#1\endcsname
863    \relax
864       \new@mathalphabet#1{#2}{#3}{#4}{#5}%
865    \else
866 %    \end{macrocode}
867 %    Check if it is already a math alphabet.
868 %    \begin{macrocode}
869      \edef\reserved@a{\noexpand\in@{\string\select@group}%
870          {\expandafter\meaning\csname \expandafter
871           \@gobble\string#1\space\endcsname}}%
872      \reserved@a
873      \ifin@
874        \@font@info{Redeclaring math alphabet \string#1}%
875        \def\version@elt##1{%
876          \expandafter\SetMathAlphabet@\expandafter
877             ##1\csname#2/#3/#4/#5\expandafter\endcsname
878 %    \end{macrocode}
879 % \changes{???}{1994/04/18}{Pass correct arg (2 not 3)}
880 %    \begin{macrocode}
881             \csname M@#2\expandafter\endcsname
882             \csname \expandafter\@gobble\string#1\space\endcsname#1}%
883        \version@list
884      \else
885 %    \end{macrocode}
886 %    Check if it is a math alphabet defined via
887 %    |\DeclareSymbolFontAlphabet|.
888 %    \begin{macrocode}
889        \edef\reserved@a{\noexpand\in@{\string\use@mathgroup}%
890          {\expandafter\meaning\csname \expandafter
891           \@gobble\string#1\space\endcsname}}%
892        \reserved@a
893        \ifin@
894 %    \end{macrocode}
895 %    In that case overwriting is simple since there is nothing
896 %    inserted in the math version macros.
897 %    \begin{macrocode}
898          \@font@info{Redeclaring math alphabet \string#1}%
899          \new@mathalphabet#1{#2}{#3}{#4}{#5}%
900 %    \end{macrocode}
901 %    Otherwise panic.
902 %    \begin{macrocode}
903        \else
904          \@latex@error{Command `\string#1' already defined}\@eha
905        \fi
906      \fi
907   \fi
908  \else
909   \@latex@error{Encoding scheme  `#2' unknown}\@eha
910  \fi
911   }
912 \@onlypreamble\DeclareMathAlphabet
913 %    \end{macrocode}
914 % \end{macro}
916 % \begin{macro}{\new@mathalphabet}
917 % \changes{v3.0j}{2005/07/27}
918 %         {(MH) Make document commands robust}
919 %    \begin{macrocode}
920 \def\new@mathalphabet#1#2#3#4#5{%
921     \toks@\expandafter{\alpha@list}%
922     \edef#1{\expandafter\noexpand\csname \expandafter
923             \@gobble\string#1\space\endcsname
924             \if/#5/%
925                \noexpand\no@alphabet@error
926                \noexpand\no@alphabet@error
927             \else
928                \expandafter\noexpand\csname M@#2\endcsname
929                \expandafter\noexpand\csname#2/#3/#4/#5\endcsname
930             \fi
931            }%
932     \toks2\expandafter{#1}%
933     \edef\alpha@list{\the\toks@\noexpand\alpha@elt\the\toks2}%
934     \def\version@elt##1{\toks@\expandafter{##1}%
935                    \edef##1{\the\toks@\install@mathalphabet
936                             \expandafter\noexpand
937                             \csname \expandafter\@gobble
938                                \string#1\space\endcsname
939                            {\if/#5/%
940                              \noexpand\no@alphabet@error
941                              \noexpand#1%
942                             \else
943                              \noexpand\select@group\the\toks2
944                             \fi}}%
945                  }%
946     \version@list
947     \expandafter\edef\csname \expandafter\@gobble
948                 \string#1\space\endcsname{\if/#5/%
949               \noexpand\no@alphabet@error
950               \noexpand#1%
951             \else
952               \noexpand\select@group\the\toks2
953             \fi}%
954     \edef#1{\noexpand\protect
955             \expandafter\noexpand\csname \expandafter
956             \@gobble\string#1\space\endcsname}%
958 \@onlypreamble\new@mathalphabet
959 %    \end{macrocode}
960 % \end{macro}
962 % \begin{macro}{\SetMathAlphabet}
963 % \changes{v3.0j}{2005/07/27}
964 %         {(MH) Make document commands robust}
965 %    \begin{macrocode}
966 \def\SetMathAlphabet#1#2#3#4#5#6{%
967  \@tempswafalse
968  \edef\reserved@b{#3}%
969  \def\cdp@elt##1##2##3##4{\def\reserved@c{##1}%
970       \ifx\reserved@b\reserved@c \@tempswatrue\fi}%
971  \cdp@list
972  \if@tempswa
973   \expandafter\SetMathAlphabet@
974     \csname mv@#2\expandafter\endcsname\csname#3/#4/#5/#6\expandafter
975     \endcsname \csname M@#3\expandafter\endcsname
976     \csname \expandafter\@gobble\string#1\space\endcsname#1%
977  \else
978   \@latex@error{Encoding scheme  `#3' unknown}\@eha
979  \fi
981 \@onlypreamble\SetMathAlphabet
982 %    \end{macrocode}
983 % \end{macro}
985 % \begin{macro}{\SetMathAlphabet@}
986 %    \begin{macrocode}
987 \def\SetMathAlphabet@#1#2#3#4#5{%
988   \expandafter\in@\expandafter#1\expandafter{\version@list}%
989   \ifin@
990     \expandafter\in@\expandafter#4\expandafter{\alpha@list}%
991     \ifin@
992       \begingroup
993         \toks@{}%
994         \def\getanddefine@fonts##1##2{%
995              \addto@hook\toks@{\getanddefine@fonts##1##2}%
996             }%
997         \def\reserved@c##1##2##3##4{%                % for message below
998             \expandafter\@gobble\string##4}%
999         \def\install@mathalphabet##1##2{%
1000           \ifx##1#4%
1001              \addto@hook\toks@
1002                 {\install@mathalphabet#4{\select@group#4#3#2}}%
1003              \@font@info{Overwriting math alphabet
1004                 `\string#5' in version `\expandafter
1005                  \@gobblefour\string#1'\MessageBreak
1006                  \@spaces \reserved@c##2 -->
1007                         \expandafter\@gobble\string#2}%
1008           \else
1009              \addto@hook\toks@{\install@mathalphabet##1{##2}}%
1010           \fi
1011           }%
1012         #1%
1013         \xdef#1{\the\toks@}%
1014       \endgroup
1015     \else
1016 %    \end{macrocode}
1017 %    If the math alphabet was defined via |\DeclareSymbolFontAlphabet|
1018 %    we have remove its external definition and add it as a normal
1019 %    math alphabet to every version before trying to change it in one
1020 %    version.
1021 % \changes{v2.1b}{1994/03/11}{Changed parameter template in temporary
1022 %          macro to catch check add below.}
1023 %    \begin{macrocode}
1024        \edef\reserved@a{%
1025          \noexpand\in@{\string\use@mathgroup}{\meaning#4}}%
1026        \reserved@a
1027        \ifin@
1028          \def\reserved@b##1\use@mathgroup##2##3{%
1029              \def\reserved@b{##3}\def\reserved@c{##2}}%
1030          \expandafter\reserved@b#4%
1031          \begingroup
1032            \def\install@mathalphabet##1##2{%
1033                \addto@hook\toks@{\install@mathalphabet##1{##2}}%
1034                }%
1035             \def\getanddefine@fonts##1##2{%
1036               \addto@hook\toks@{\getanddefine@fonts##1##2}%
1037               \ifnum##1=\reserved@b
1038                  \expandafter
1039                  \addto@hook\expandafter\toks@
1040                  \expandafter{\expandafter\install@mathalphabet
1041                  \expandafter#4\expandafter
1042                        {\expandafter\select@group\expandafter
1043                          #4\reserved@c##2}}%
1044               \fi
1045                       }%
1046            \def\version@elt##1{%
1047                \toks@{}%
1048                ##1%
1049                \xdef##1{\the\toks@}%
1050               }%
1051            \version@list
1052          \endgroup
1053 %    \end{macrocode}
1054 %    Put it into the |\alpha@list| with default `error'
1055 %    \begin{macrocode}
1056          \expandafter\gdef\expandafter\alpha@list\expandafter
1057              {\alpha@list
1058               \alpha@elt #4\no@alphabet@error \no@alphabet@error}%
1059          \gdef#4{\no@alphabet@error #5}% fake things :-)
1060 %    \end{macrocode}
1061 %    Then call the internal setting routine again:
1062 %    \begin{macrocode}
1063          \SetMathAlphabet@{#1}{#2}{#3}#4#5%
1064        \else
1065          \@latex@error{Command `\string#5' not defined as a
1066                        math alphabet}%
1067             {Use \noexpand\DeclareMathAlphabet to define it.}%
1068        \fi
1069     \fi
1070   \else
1071     \@latex@error{Math version `\expandafter\@gobblefour\string#1'
1072        is not
1073        defined}{You probably misspelled the name of the math
1074        version.^^JOr you have to specify an additional package.}%
1075   \fi
1077 \@onlypreamble\SetMathAlphabet@
1078 %    \end{macrocode}
1079 % \end{macro}
1081 % \begin{macro}{\DeclareMathAlphabet}
1082 % could do with more checks like allowing single number in |#4|
1083 % lowercase in |#4| etc
1084 % \changes{v3.0r}{2016/02/18}
1085 %         {Check for mathaccent not \cs{mathaccemt}}
1086 %    \begin{macrocode}
1087 \def\DeclareMathAccent#1#2#3#4{%
1088   \expandafter\in@\csname sym#3\expandafter\endcsname
1089      \expandafter{\group@list}%
1090   \ifin@
1091     \begingroup
1092       \count\z@=#4\relax
1093       \count\tw@\count\z@
1094       \divide\count\z@\sixt@@n
1095       \count@\count\z@
1096       \multiply\count@\sixt@@n
1097       \advance\count\tw@-\count@
1098       \if\relax\noexpand#1% is command?
1099         \edef\reserved@a{\noexpand\in@
1100            {\expandafter\@gobble\string\mathaccent}{\meaning#1}}%
1101         \reserved@a
1102         \ifin@
1103           \expandafter\set@mathaccent
1104              \csname sym#3\endcsname#1#2%
1105              {\hexnumber@{\count\z@}\hexnumber@{\count\tw@}}%
1106           \@font@info{Redeclaring math accent \string#1}%
1107         \else
1108           \expandafter\ifx
1109           \csname\expandafter\@gobble\string#1\endcsname
1110           \relax
1111             \expandafter\set@mathaccent
1112                \csname sym#3\endcsname#1#2%
1113                {\hexnumber@{\count\z@}\hexnumber@{\count\tw@}}%
1114           \else
1115             \@latex@error{Command `\string#1' already defined}\@eha
1116           \fi
1117         \fi
1118       \else
1119        \@latex@error{Not a command name: `\noexpand#1'}\@eha
1120       \fi
1121     \endgroup
1122   \else
1123     \@latex@error{Symbol font `#3' is not defined}\@eha
1124   \fi
1126 \@onlypreamble\DeclareMathAccent
1127 %    \end{macrocode}
1128 % \end{macro}
1130 % \begin{macro}{\set@mathaccent}
1131 %    \begin{macrocode}
1132 \def\set@mathaccent#1#2#3#4{%
1133   \xdef#2{\mathaccent"\mathchar@type#3\hexnumber@#1#4\relax}}
1134 \@onlypreamble\set@mathaccent
1135 %    \end{macrocode}
1136 % \end{macro}
1138 % \begin{macro}{\DeclareMathSymbol}
1139 % \changes{v3.0r}{2016/02/18}
1140 %         {Check for mathchar not \cs{mathchar}}
1141 %    \begin{macrocode}
1142 \def\DeclareMathSymbol#1#2#3#4{%
1143   \expandafter\in@\csname sym#3\expandafter\endcsname
1144      \expandafter{\group@list}%
1145   \ifin@
1146     \begingroup
1147       \count\z@=#4\relax
1148       \count\tw@\count\z@
1149       \divide\count\z@\sixt@@n
1150       \count@\count\z@
1151       \multiply\count@\sixt@@n
1152       \advance\count\tw@-\count@
1153       \if\relax\noexpand#1% is command?
1154         \edef\reserved@a
1155           {\noexpand\in@{\expandafter\@gobble\string\mathchar}{\meaning#1}}%
1156         \reserved@a
1157         \ifin@
1158           \expandafter\set@mathsymbol
1159              \csname sym#3\endcsname#1#2%
1160              {\hexnumber@{\count\z@}\hexnumber@{\count\tw@}}%
1161           \@font@info{Redeclaring math symbol \string#1}%
1162         \else
1163             \expandafter\ifx
1164             \csname\expandafter\@gobble\string#1\endcsname
1165             \relax
1166             \expandafter\set@mathsymbol
1167                \csname sym#3\endcsname#1#2%
1168                {\hexnumber@{\count\z@}\hexnumber@{\count\tw@}}%
1169           \else
1170             \@latex@error{Command `\string#1' already defined}\@eha
1171           \fi
1172         \fi
1173       \else
1174         \expandafter\set@mathchar
1175           \csname sym#3\endcsname#1#2
1176           {\hexnumber@{\count\z@}\hexnumber@{\count\tw@}}%
1177       \fi
1178     \endgroup
1179   \else
1180     \@latex@error{Symbol font `#3' is not defined}\@eha
1181   \fi
1183 \@onlypreamble\DeclareMathSymbol
1184 %    \end{macrocode}
1185 % \end{macro}
1187 % \begin{macro}{\set@mathchar}
1188 %    \begin{macrocode}
1189 \def\set@mathchar#1#2#3#4{%
1190   \global\mathcode`#2="\mathchar@type#3\hexnumber@#1#4\relax}
1191 \@onlypreamble\set@mathchar
1192 %    \end{macrocode}
1193 % \end{macro}
1195 % \begin{macro}{\set@mathsymbol}
1196 %    \begin{macrocode}
1197 \def\set@mathsymbol#1#2#3#4{%
1198   \global\mathchardef#2"\mathchar@type#3\hexnumber@#1#4\relax}
1199 \@onlypreamble\set@mathsymbol
1200 %    \end{macrocode}
1201 % \end{macro}
1203 %    \begin{macrocode}
1204 %\def\mathsymbol#1#2#3{%
1205 %  \@tempcnta=#3\relax
1206 %  \@tempcntb\@tempcnta
1207 %  \divide\@tempcnta\sixt@@n
1208 %  \count@\@tempcnta
1209 %  \multiply\count@\sixt@@n
1210 %  \advance\@tempcntb-\count@
1211 %  \mathchar"\mathchar@type#1\hexnumber@#2%
1212 %             \hexnumber@\@tempcnta\hexnumber@\@tempcntb\relax}
1214 %\def\DeclareMathAlphabetCharacter#1#2#3{%
1215 %  \DeclareMathSymbol{#1}7{#2}{#3}}
1216 %    \end{macrocode}
1218 % \begin{macro}{\DeclareMathDelimiter}
1219 % \changes{v2.1m}{1994/11/18}
1220 %         {(DPC) \cs{expandafter} instead of \cs{next}}
1221 %    \begin{macrocode}
1222 \def\DeclareMathDelimiter#1{%
1223   \if\relax\noexpand#1%
1224     \expandafter\@DeclareMathDelimiter
1225   \else
1226     \expandafter\@xxDeclareMathDelimiter
1227   \fi
1228   #1}
1229 \@onlypreamble\DeclareMathDelimiter
1230 %    \end{macrocode}
1231 % \end{macro}
1233 % \begin{macro}{\@xxDeclareMathDelimiter}
1234 % \changes{v3.0h}{1998/04/15}{Macro added (pr/2662)}
1235 %    This macro checks if the second arg is a ``math type'' such
1236 %    as |\mathopen|. The undocumented original code didn't use math
1237 %    types when the delimiter was a single letter.
1238 %    For this reason the coding is a bit strange as it tries to
1239 %    support the undocumented syntax for compatibility reasons.
1240 %    \begin{macrocode}
1241 \def\@xxDeclareMathDelimiter#1#2#3#4{%
1242 %    \end{macrocode}
1243 %    7 is the default value returned in the case that |\mathchar@type|
1244 %    is passed something unexpected, like a math symbol font name.
1245 %    We locally move |\mathalpha| out of the way so if you use that
1246 %    the right branch is taken. This will still fail if an explicit
1247 %    number |7| is used!
1248 %    \begin{macrocode}
1249    \begingroup
1250     \let\mathalpha\mathord
1251     \ifnum7=\mathchar@type{#2}%
1252       \endgroup
1253 %    \end{macrocode}
1254 %    If this branch is taken we have old syntax (5 arguments).
1255 %    \begin{macrocode}
1256       \expandafter\@firstofone
1257     \else
1258 %    \end{macrocode}
1259 %    If this branch is taken |\mathchar@type| is different from 7 so
1260 %    we assume new syntax. In this case we also use the arguments to
1261 %    set up the letter as a math symbol for the case where it is not
1262 %    used as a delimiter.
1263 %    \begin{macrocode}
1264       \endgroup
1265       \DeclareMathSymbol#1{#2}{#3}{#4}%
1266 %    \end{macrocode}
1267 %    Then we arrange that |\@xDeclareMathDelimiter| only gets |#1|,
1268 %    |#3|, |#4| \ldots\ as it does not expect a math type as argument.
1269 %    \begin{macrocode}
1270       \expandafter\@firstoftwo
1271     \fi
1272     {\@xDeclareMathDelimiter#1}{#2}{#3}{#4}}
1273 \@onlypreamble\@xxDeclareMathDelimiter
1274 %    \end{macrocode}
1275 % \end{macro}
1277 % \begin{macro}{\@DeclareMathDelimiter}
1278 % \changes{v3.0r}{2016/02/18}
1279 %         {Check for delimiter not \cs{delimiter}}
1280 %    \begin{macrocode}
1281 \def\@DeclareMathDelimiter#1#2#3#4#5#6{%
1282   \expandafter\in@\csname sym#3\expandafter\endcsname
1283      \expandafter{\group@list}%
1284   \ifin@
1285     \expandafter\in@\csname sym#5\expandafter\endcsname
1286        \expandafter{\group@list}%
1287     \ifin@
1288       \begingroup
1289         \count\z@=#4\relax
1290         \count\tw@\count\z@
1291         \divide\count\z@\sixt@@n
1292         \count@\count\z@
1293         \multiply\count@\sixt@@n
1294         \advance\count\tw@-\count@
1295         \edef\reserved@c{\hexnumber@{\count\z@}\hexnumber@{\count\tw@}}%
1296       %
1297         \count\z@=#6\relax
1298         \count\tw@\count\z@
1299         \divide\count\z@\sixt@@n
1300         \count@\count\z@
1301         \multiply\count@\sixt@@n
1302         \advance\count\tw@-\count@
1303         \edef\reserved@d{\hexnumber@{\count\z@}\hexnumber@{\count\tw@}}%
1304       %
1305         \edef\reserved@a{\noexpand\in@
1306             {\expandafter\@gobble\string\delimiter}{\meaning#1}}%
1307         \reserved@a
1308         \ifin@
1309           \expandafter\set@mathdelimiter
1310              \csname sym#3\expandafter\endcsname
1311              \csname sym#5\endcsname#1#2%
1312              \reserved@c\reserved@d
1313           \@font@info{Redeclaring math delimiter \string#1}%
1314         \else
1315             \expandafter\ifx
1316             \csname\expandafter\@gobble\string#1\endcsname
1317             \relax
1318             \expandafter\set@mathdelimiter
1319               \csname sym#3\expandafter\endcsname
1320               \csname sym#5\endcsname#1#2%
1321               \reserved@c\reserved@d
1322           \else
1323             \@latex@error{Command `\string#1' already defined}\@eha
1324           \fi
1325         \fi
1326       \endgroup
1327     \else
1328       \@latex@error{Symbol font `#5' is not defined}\@eha
1329     \fi
1330   \else
1331     \@latex@error{Symbol font `#3' is not defined}\@eha
1332   \fi
1334 \@onlypreamble\@DeclareMathDelimiter
1335 %    \end{macrocode}
1336 % \end{macro}
1338 % \begin{macro}{\@xDeclareMathDelimiter}
1339 %    \begin{macrocode}
1340 \def\@xDeclareMathDelimiter#1#2#3#4#5{%
1341   \expandafter\in@\csname sym#2\expandafter\endcsname
1342      \expandafter{\group@list}%
1343   \ifin@
1344     \expandafter\in@\csname sym#4\expandafter\endcsname
1345        \expandafter{\group@list}%
1346     \ifin@
1347       \begingroup
1348         \count\z@=#3\relax
1349         \count\tw@\count\z@
1350         \divide\count\z@\sixt@@n
1351         \count@\count\z@
1352         \multiply\count@\sixt@@n
1353         \advance\count\tw@-\count@
1354         \edef\reserved@c{\hexnumber@{\count\z@}\hexnumber@{\count\tw@}}%
1355       %
1356         \count\z@=#5\relax
1357         \count\tw@\count\z@
1358         \divide\count\z@\sixt@@n
1359         \count@\count\z@
1360         \multiply\count@\sixt@@n
1361         \advance\count\tw@-\count@
1362         \edef\reserved@d{\hexnumber@{\count\z@}\hexnumber@{\count\tw@}}%
1363         \expandafter\set@@mathdelimiter
1364            \csname sym#2\expandafter\endcsname\csname sym#4\endcsname#1%
1365            \reserved@c\reserved@d
1366       \endgroup
1367     \else
1368       \@latex@error{Symbol font `#4' is not defined}\@eha
1369     \fi
1370   \else
1371     \@latex@error{Symbol font `#2' is not defined}\@eha
1372   \fi
1374 \@onlypreamble\@xDeclareMathDelimiter
1375 %    \end{macrocode}
1376 % \end{macro}
1378 % \begin{macro}{\set@mathdelimiter}
1379 %    We have to end the definition of a math delimiter like |\lfloor|
1380 %    with a space and not with |\relax| as we did before, because
1381 %    otherwise constructs involving |\abovewithdelims| will prematurely
1382 %    end (pr/1329)
1384 % \changes{v2.1q}{1995/04/02}{fix pr/1329}
1385 %    \begin{macrocode}
1386 \def\set@mathdelimiter#1#2#3#4#5#6{%
1387   \xdef#3{\delimiter"\mathchar@type#4\hexnumber@#1#5%
1388                                      \hexnumber@#2#6 }}
1389 \@onlypreamble\set@mathdelimiter
1390 %    \end{macrocode}
1391 % \end{macro}
1393 % \begin{macro}{\set@@mathdelimiter}
1394 %    \begin{macrocode}
1395 \def\set@@mathdelimiter#1#2#3#4#5{%
1396   \global\delcode`#3="\hexnumber@#1#4\hexnumber@#2#5\relax}
1397 \@onlypreamble\set@@mathdelimiter
1398 %    \end{macrocode}
1399 % \end{macro}
1401 % \begin{macro}{\DeclareMathRadical}
1402 %    \begin{macrocode}
1403 \def\DeclareMathRadical#1#2#3#4#5{%
1404 %    \end{macrocode}
1405 %    Below is a crude fix to make this macro work if |#1| is undefined
1406 %    or |\relax|.  Should be improved!
1407 % \changes{v2.1t}{1995/05/21}{Allow for undefined cs names}
1408 % \changes{v3.0r}{2016/02/18}
1409 %         {Check for radical not \cs{radical}}
1410 %    \begin{macrocode}
1411   \expandafter\ifx
1412        \csname\expandafter\@gobble\string#1\endcsname
1413        \relax
1414      \let#1\radical
1415   \fi
1416   \edef\reserved@a{\noexpand\in@
1417        {\expandafter\@gobble\string\radical}{\meaning#1}}%
1418   \reserved@a
1419   \ifin@
1420     \expandafter\in@\csname sym#2\expandafter\endcsname
1421        \expandafter{\group@list}%
1422     \ifin@
1423       \expandafter\in@\csname sym#4\expandafter\endcsname
1424          \expandafter{\group@list}%
1425       \ifin@
1426         \begingroup
1427           \count\z@=#3\relax
1428           \count\tw@\count\z@
1429           \divide\count\z@\sixt@@n
1430           \count@\count\z@
1431           \multiply\count@\sixt@@n
1432           \advance\count\tw@-\count@
1433           \edef\reserved@c{%
1434             \hexnumber@{\count\z@}\hexnumber@{\count\tw@}}%
1435           \count\z@=#5\relax
1436           \count\tw@\count\z@
1437           \divide\count\z@\sixt@@n
1438           \count@\count\z@
1439           \multiply\count@\sixt@@n
1440           \advance\count\tw@-\count@
1441           \edef\reserved@d{%
1442             \hexnumber@{\count\z@}\hexnumber@{\count\tw@}}%
1443 %    \end{macrocode}
1444 %    Coded inline instead of using |\set@mathradical|
1445 %    \begin{macrocode}
1446 %          \expandafter\set@mathradical
1447 %             \csname sym#2\expandafter\endcsname
1448 %             \csname sym#4\endcsname#1%
1449 %             \reserved@c\reserved@d
1450           \xdef#1{\radical"\expandafter\hexnumber@
1451                                 \csname sym#2\endcsname\reserved@c
1452                              \expandafter\hexnumber@
1453                                 \csname sym#4\endcsname\reserved@d
1454                   \relax}%
1455         \endgroup
1456       \else
1457         \@latex@error{Symbol font `#4' is not defined}\@eha
1458       \fi
1459     \else
1460       \@latex@error{Symbol font `#2' is not defined}\@eha
1461     \fi
1462   \else
1463     \@latex@error{Command `\string#1' already defined}\@eha
1464   \fi
1466 \@onlypreamble\DeclareMathRadical
1467 %    \end{macrocode}
1468 % \end{macro}
1470 % Definition below was wrong it contained |\delimiter| !
1472 %\begin{verbatim}
1473 %\def\set@mathradical#1#2#3#4#5{%
1474 %  \xdef#3{\radical"\hexnumber@#1#4\hexnumber@#2#5\relax}}
1475 %\end{verbatim}
1477 % \begin{macro}{\mathalpha}
1478 % just a dummy currently
1479 %    \begin{macrocode}
1480 \let\mathalpha\relax
1481 %    \end{macrocode}
1482 % \end{macro}
1484 % \begin{macro}{\mathchar@type}
1485 %    \begin{macrocode}
1486 \def\mathchar@type#1{%
1487   \ifodd 2#11 #1\else             % is this non-negative number?
1488     \ifx#1\mathord 0\else
1489      \ifx#1\mathop   1\else
1490        \ifx#1\mathbin 2\else
1491          \ifx#1\mathrel 3\else
1492            \ifx#1\mathopen 4\else
1493              \ifx#1\mathclose 5\else
1494                \ifx#1\mathpunct 6\else
1495                    7%             % anything else is variable ord
1496                \fi
1497              \fi
1498            \fi
1499          \fi
1500        \fi
1501      \fi
1502     \fi
1503   \fi}
1504 \@onlypreamble\mathchar@type
1505 %    \end{macrocode}
1506 % \end{macro}
1508 % \begin{macro}{\DeclareSymbolFontAlphabet}
1509 % \changes{v3.0j}{2005/07/27}
1510 %         {(MH) Make document commands robust}
1511 %    \begin{macrocode}
1512 \def\DeclareSymbolFontAlphabet#1#2{%
1513    \expandafter\DeclareSymbolFontAlphabet@
1514      \csname \expandafter\@gobble\string#1\space\endcsname{#2}#1}
1515 \@onlypreamble\DeclareSymbolFontAlphabet
1516 %    \end{macrocode}
1517 % \end{macro}
1519 % \begin{macro}{\DeclareSymbolFontAlphabet@}
1520 %    \begin{macrocode}
1521 \def\DeclareSymbolFontAlphabet@#1#2#3{%
1522 %    \end{macrocode}
1523 %    We use the switch |\if@tempswa| to decide if we can declare this
1524 %    symbol font alphabet.
1525 %    \begin{macrocode}
1526     \@tempswatrue
1527 %    \end{macrocode}
1528 %    First check if |#2| is known to be a symbol font
1529 %    \begin{macrocode}
1530   \expandafter\in@\csname sym#2\expandafter\endcsname
1531      \expandafter{\group@list}%
1532   \ifin@
1533 %    \end{macrocode}
1534 %    Check if |#1| is defined as a math alphabet defined via
1535 %    |\DeclareMathAlphabet|:
1536 %    \begin{macrocode}
1537     \expandafter\in@\expandafter#1\expandafter{\alpha@list}%
1538     \ifin@
1539 %    \end{macrocode}
1540 %    If so remove it from the |\alpha@list| and from all math version
1541 %    macros.
1542 %    \begin{macrocode}
1543       \@font@info{Redeclaring math alphabet \string#3}%
1544       \toks@{}%
1545       \def\alpha@elt##1##2##3{%
1546           \ifx##1#1\else\addto@hook\toks@{\alpha@elt##1##2##3}\fi}%
1547       \alpha@list
1548       \xdef\alpha@list{\the\toks@}%
1549 %    \end{macrocode}
1550 %    Now we loop over all versions and remove the math alphabet:
1551 %    \begin{macrocode}
1552       \def\version@elt##1{%
1553           \begingroup
1554             \toks@{}%
1555             \def\getanddefine@fonts####1####2{%
1556                \addto@hook\toks@{\getanddefine@fonts####1####2}}%
1557             \def\install@mathalphabet####1####2{%
1558                \ifx####1#1\else
1559                  \addto@hook\toks@{\install@mathalphabet
1560                                     ####1{####2}}\fi}%
1561             ##1%
1562             \xdef##1{\the\toks@}%
1563           \endgroup
1564           }%
1565       \version@list
1566     \else
1567 %    \end{macrocode}
1568 %    If |#3| is not defined as a math alphabet check if it is defined
1569 %    at all:
1570 %    \begin{macrocode}
1571       \expandafter\ifx
1572       \csname\expandafter\@gobble\string#1\space\endcsname
1573       \relax
1574 %    \end{macrocode}
1575 %    If it is undefined, fine otherwise check if it is a math alphabet
1576 %    defined via |\DeclareSymbolFontAlphabet|:
1577 %    \begin{macrocode}
1578       \else
1579         \edef\reserved@a{%
1580           \noexpand\in@{\string\use@mathgroup}{\meaning#1}}%
1581         \reserved@a
1582         \ifin@
1583           \@font@info{Redeclaring math alphabet \string#3}%
1584         \else
1585 %    \end{macrocode}
1586 %    Since the command |#3| is defined to be something which is not a
1587 %    math alphabet we have to skip redefining it.
1588 %    \begin{macrocode}
1589           \@tempswafalse
1590           \@latex@error{Command `\string#3' already defined}\@eha
1591         \fi
1592       \fi
1593     \fi
1594    \else
1595 %    \end{macrocode}
1596 %    Since the symbol font is not known we better skip defining this
1597 %    alphabet.
1598 %    \begin{macrocode}
1599      \@tempswafalse
1600      \@latex@error{Unknown symbol font `#2'}\@eha
1601    \fi
1602    \if@tempswa
1603 %    \end{macrocode}
1604 %    When we reach this point we are allowed to define |#1| to be a
1605 %    symbol font math alphabet. This means that we have to set it to
1606 %    \begin{quote}
1607 %      |\use@mathgroup| \meta{math-settings} |\sym|\meta{name}
1608 %    \end{quote}
1609 %    The \meta{math-settings} are the one for the encoding that is
1610 %    used in the font shape where |\sym|\meta{name} is pointing to.
1611 %    This means that we have to get it from the information stored in
1612 %    |\group@list|. Thus we loop through that list after defining
1613 %    |\group@elt| in a suitable way.
1614 % \changes{v2.1b}{1994/03/11}{Added check against use of alphabet
1615 %              switch outside of math mode.}
1616 %    \begin{macrocode}
1617      \def\group@elt##1##2{%
1618         \expandafter\ifx\csname sym#2\endcsname##1%
1619         \expandafter\reserved@a\string##2\@nil
1620         \fi}%
1621      \def\reserved@a##1##2/##3\@nil{%
1622         \def\reserved@a{##2}}%
1623      \group@list
1624      \toks@{\relax\ifmmode \else \non@alpherr#1\fi}%
1625      \edef#1{\the\toks@
1626              \noexpand\use@mathgroup
1627              \expandafter\noexpand\csname M@\reserved@a\endcsname
1628              \csname sym#2\endcsname}%
1629      \def#3{\protect#1}%
1630    \fi
1632 \@onlypreamble\DeclareSymbolFontAlphabet@
1633 %</2ekernel>
1634 %    \end{macrocode}
1635 %  \end{macro}
1637 % \Finale