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