% -*- coding: iso-latin-1; time-stamp-format: "%02d-%02m-%:y at %02H:%02M:%02S %Z"; time-stamp-active: nil -*-
% N.B.: this dtx file does NOT use \DocInput, it only uses docstrip.
% The LaTeX source of the documentation is NOT prefixed with %'s.
%<*dtx>
\def\dtxtimestamp {Time-stamp: <26-07-2024 at 11:21:35 CEST>}
\def\docdate{2024/07/27}
% To extract run etex on this file, then to build documentation run
% latexmk on mathastext.tex then dvipdfmx on the dvi.
% For more information see http://jf.burnol.free.fr/v13/INSTALL.txt
% The encoding is deliberately an 8bit one, do not convert to utf-8
% due to usage of § (<A7>) as an active character.
%</dtx>
%<*drv>
\def\MSTpkgdate    {2024/07/27}
\def\MSTpkgversion {1.4b}
%</drv>
%<*dtx>
\iffalse % meta-comment
%</dtx>
%<*readme>
<!-- -->
            +-------------------------------------------+
            +                                           +
            +                mathastext                 +
            +                                           +
            +     'Use the text font in math mode'      +
            +                                           +
            +-------------------------------------------+

This Work may be distributed and/or modified under the conditions
of the [LPPL 1.3c](https://www.latex-project.org/lppl/lppl-1-3c.txt)

The Author of this Work is Jean-Francois Burnol (`jfbu at free dot fr`)

Copyright (C) 2011-2019, 2022-2024 Jean-Francois Burnol

      Source: mathastext.dtx 1.4b 2024/07/27

%</readme>
%<*dtx>
\fi % end of meta-comment
%</dtx>
%<*!readme&!changelog>
%%----------------------------------------------------------------
%% Package: mathastext
%% Info:    Use the text font in math mode (JFB)
%% Version: 1.4b 2024/07/27
%% License: LPPL 1.3c (http://www.latex-project.org/lppl/lppl-1-3c.txt)
%% Copyright (C) 2011-2019, 2022-2024 Jean-Francois Burnol
%%                                   <jfbu at free dot fr>
%% Examples of use of mathastext:
%%        http://jf.burnol.free.fr/mathastext.html
%%        http://jf.burnol.free.fr/showcase.html
%%----------------------------------------------------------------
%</!readme&!changelog>
%<*dtx>
\chardef\noetex 0
\ifx\numexpr\undefined\chardef\noetex 1 \fi
\ifnum\noetex=1 \chardef\extractfiles 0 % extract files, then stop
\else
    \ifx\ProvidesFile\undefined
      \chardef\extractfiles 0 % etex etc.. on mathastext.dtx
    \else % latex/pdflatex on mathastext.tex or on mathastext.dtx
      \ifx\Withdvipdfmx\undefined
        % latex run is on mathastext.dtx, we will extract all files
        \chardef\extractfiles 1 % 1 = extract all and typeset doc
        \chardef\Withdvipdfmx 0 % 0 = pdflatex or latex+dvips
        \chardef\NoSourceCode 1 % 
        \NeedsTeXFormat{LaTeX2e}%
        \PassOptionsToClass{a4paper,fontsize=11pt}{scrartcl}%
      \else % latex run is on mathastext.tex, 
        \chardef\extractfiles 2 % no extractions
      \fi
    \ProvidesFile{mathastext.dtx}%
    [bundle source (\MSTpkgversion, \MSTpkgdate) and documentation (\docdate)]%
    \fi
\fi
\ifnum\extractfiles<2 % extract files
\def\MessageDeFin{\newlinechar10 \let\Msg\message
\Msg{^^J}%
\Msg{********************************************************************^^J}%
\Msg{*^^J}%
\Msg{* To finish the installation you have to move the following^^J}%
\Msg{* file into a directory searched by TeX:^^J}%
\Msg{*^^J}%
\Msg{*\space\space\space\space mathastext.sty^^J}%
\Msg{*^^J}%
\Msg{* To produce the documentation with source code included run latex^^J}%
\Msg{* thrice on file mathastext.tex and then dvipdfmx on mathastext.dvi^^J}%
\Msg{*^^J}%
\Msg{* Happy TeXing!^^J}%
\Msg{*^^J}%
\Msg{********************************************************************^^J}%
}%
\begingroup
\input docstrip.tex
\askforoverwritefalse
\generate{\nopreamble\nopostamble
    \file{README.md}{\from{mathastext.dtx}{readme}}
    \file{ChangeLog.md}{\from{mathastext.dtx}{changelog}}
  \usepostamble\defaultpostamble
    \file{mathastext.tex}{\from{mathastext.dtx}{drv}}
  \usepreamble\defaultpreamble
    \file{mathastext.sty}{\from{mathastext.dtx}{package}}%
}
\endgroup
\fi % end of file extractions
\ifnum\extractfiles=0 
% tex/etex/xetex/etc on mathastext.dtx, files are now extracted, stop
  \MessageDeFin\expandafter\end
\fi
% no file extractions if latex compilation was on mathastext.tex
\ifdefined\MessageDeFin\AtEndDocument{\MessageDeFin}\fi
\begingroup\catcode1 0 \catcode`\\ 12 
% This is to fool TeX's recognition of \if/\else/\fi like tokens in test files,
% but on 2024/07/14 I removed from the dtx four previously included such filss.
^^Aiffalse
%</dtx>
%<*readme>

DESCRIPTION
===========

Optimal typographical results for documents containing
mathematical symbols can only be hoped for with math fonts
specifically designed to match a given text typeface.
Although the list of freely available math fonts (alongside
the Computer Modern and AMS extension fonts) is slowly
expanding (fourier, kpfonts, mathdesign, pxfonts, txfonts,
newpx, newtx, ...) it remains limited, and the situation is
even worse with Unicode fonts (XeTeX/LuaTeX). So if you can't
find a math font which fits well with your favorite text
font, and wish to still be able to typeset mathematical
documents, perhaps not of the highest typographical quality,
but at least not subjected to obvious visual incompatibilities 
between your text font and the math fonts, try out mathastext: 
it will simply use the text font also for the math!

- http://jf.burnol.free.fr/mathastext.html
- http://jf.burnol.free.fr/showcase.html


USAGE
=====

`mathastext` is a LaTeX package

      \usepackage{mathastext}

The document will use in math mode the text font as configured at
package loading time, for these characters:

      abcdefghijklmnopqrstuvwxyz
      ABCDEFGHIJKLMNOPQRSTUVWXYZ
      0123456789
      !?,.:;+-=()[]/#$%&<>|{}\
%$ because emacs buffer fontification

Main options: `italic`, `frenchmath`, `subdued`, `LGRgreek`.
- Use the `italic` option to get the Latin letters in math mode
  be in italics. Digits and log-like operator names (pre-defined
  as well as user-defined) will be in the same shape as the text
  font (usually this means upright).
- each `\Mathastext[<name>]` in the preamble defines a math version
  to be later activated in the document body via the command
  `\MTversion{<name>}`.
- With the `subdued` option, mathastext will be active
  only inside such math versions.
- For documents needing Greek letters the following is
  possible:
  - no option: Greek letters defined by other packages,
  - `eulergreek`: use the Euler font for the Greek letters,
  - `symbolgreek`: use the Postscript Symbol font for the
     Greek letters.
  - `LGRgreek`: use the document text font in LGR encoding.
     Further options specify the shape of the lowercase
     and uppercase Greek glyphs; starting with v1.15c it is
     possible to use multiple distinct LGR fonts in the
     same document.
- Commands are provided to scale the Euler and Symbol fonts by an
  arbitrary factor to let them fit better with the document text
  font.
- `\MTsetmathskips` allows to set up extra spacings around letters.


RECENT CHANGES
==============

%</readme>
%<*changelog>
MATHASTEXT CHANGE LOG
=====================

%</changelog>
%<*readme|changelog>
1.4b \[2024/07/27\]
----

* Fix a regression at `1.4` regarding option `nodigits`.

* New option: `noletters`.  I am in old age now so I can provide an option
  completely antithetical to my life work.

* Option `everymath` which is destined to be removed at next major
  release warns user about it.  As major releases tend to happen once
  per decade I think the constant nagging will become insufferable
  and you will adapt to the `1.4` changes rather than persisting into
  using this option.

1.4a \[2024/07/20\]
----

* There was a documentation glitch in 1.4 and also a problem with the
  `\MTprimeskip` feature being lost under the emergency fall-back
  `everymath` option.

1.4 \[2024/07/20\]
---

* Since 1.2 of 2012/12/20, mathastext has used mathematically active
  characters to propose certain advanced functionalities.  For reasons half
  lost in the mists of time but whose main one was surely to keep the
  meaning of the active shape of characters unchanged outside of math mode,
  this mathematical activation, and (in most cases) the definitions of what
  active characters do, were done again at *each* entrance into math mode.
  At this 1.4 release, mathastext does not inject *any* code whatsoever into
  the `\everymath` and `\everydisplay` toks registers anymore (except for
  one font-related hack needed under LuaLaTeX, see below).  Your documents
  will compile a tiny bit faster.

* In (unsual) documents where users play with catcodes and mathcodes it is
  impossible to keep exact backward compatibility, because documented user
  commands which acted formerly a toggles with delayed action now will enact
  changes immediately if in the document body.  In practice consequences are
  expected to be few, because catcode active characters are (as was already
  the case with earlier releases) hacked only when they are Babel shorthands
  and they are then modified in a way altering only their action in math
  mode.  The precise description of what mathastext does when mathematically
  activating (or not) a character, depending on circumstances, is to be
  found among small-print comments in the section "Extended scope of the
  math alphabets commands".  See also the documentation of the
  `\MTmathactiveletters` command for some specifics regarding ascii letters.

* New option: `everymath`. It instructs mathastext to revert (partially)
  to its legacy code which uses `\everymath/\everydisplay`.  This reversal
  is partial, the handling of ascii letters not being included into it.  The
  `everymath` option is there only to try as a quick fix in case transition
  to this release causes a major problem in a user document and time is
  lacking to investigate.  Please report to the author such issues.  Option
  `everymath` is destined to be removed at next major release.

* New option: `activedigits`.  Enjoy.

* It is now easier to hook into the mathastext architecture for
  mathematically activated ascii letters.  See the new section "Hacking
  letters (and even digits) for special tasks".

* Bugfix: do not override special behavior of the math mode dot in
  babel-spanish.

* Bugfix: A desperate hack related to LuaLaTeX font matters and dating
  back to 1.3o 2016/05/03 had been for some years in dire need of an update
  regarding fonts using `Renderer=HarfBuzz`.  This is done now.  Thanks to
  tex.sx `user691586` for report.  This is currently the sole remaining
  usage of `\everymath/\everydisplay`.

* Bugfix: an optional feature related to `\{` and `\}` was broken since an
  upstream LaTeX change at its 2020-02-02 release.

* With option symbolmisc, those math symbol macros formerly defined via
  `\DeclareRobustCommand` are now declared via `\protected\def`.

* Removal of legacy branches previously kept to support LaTeX earlier than
  2020-02-02.

* Removal of support for EU1 and EU2 font encodings.

* Option `noasterisk` deprecated at 1.2d 2013/01/02 has (finally) been removed.

* Four test files previously included and auto-extracted from the
  distributed dtx have been dropped.  One of them is still available
  on the package homepage.

* Some parts of the documentation have been massively re-ordered and even to some
  extent improved.  But there may be some occasions where obsolete statements will
  be found having the legacy `\everymath/\everydisplay` situation as background.

1.3zb \[2023/12/29\]
-----

* Update to the `frenchmath*` option to maintain compatibility
  with the [frenchmath](https://ctan.org/pkg/frenchmath)
  package whose release 2.7 (2023/12/23) has replaced
  the ncccomma package by the decimalcomma package.

* The `frenchmath+` option holds the former meaning of `frenchmath*`.

* Option `decimalcomma` to load the eponymous package by Antoine
  Missier.  This is tacitly done by `frenchmath*`.

* No more messages sent to the console output during loading,
  only info messages going into the log, and using (more or less)
  the official LaTeX interface: after close to 13 years of development
  of this package it was perhaps finally the time to do it.

* Documentation improvements.  Close to 13 years after the
  birth of the package, and as it nowadays rarely wakes up from
  dormancy, this was almost last chance to try to improve a few
  things.

1.3za \[2023/12/20\]
-----

* Under `LGRgreek` and `LGRgreeks` options, new math alphabets
  `\mathgreekupbold` and `\mathgreekitbold`.

* New options `LGRgreek+` and `LGRgreeks+`.

  Thanks to Holger Gerhardt for feature request and code ideas.
  Please find and read the relevant documentation in the PDF.

* The meaning of `defaultalphabets` and related individual
  options such as `defaultbf` has been modified (reverted to pre
  `1.15f` release): even under these options, the package always
  creates `\mathnormalbold`, `\Mathnormal`, `\Mathrm`, `\Mathbf`
  etc..., commands.  This may break documents which used these
  options in order to reserve these command names.  This was done
  with some hesitancy, but for the sake of internal logical
  coherence.

* Fix an obscure bug with no real consequences regarding
  interaction of `subdued` with `LGRgreek` and `\MTgreekfont`.
  See the `LGRgreek` documentation in the complete list of
  options for details.

* Fix long-standing hyperlink problems in the documentation:
  blue color words should now all be functioning hyperlinks.

%</readme|changelog>
%<*changelog>
1.3z \[2023/09/01\]
----

Fix 1.3y regression which broke `selfGreek` option due to internal
renamings.  Thanks to Stephan Korell for report.

1.3y \[2022/11/04\]
----

(the 1.3x had an annoying documentation bug, and had already
been pushed to CTAN, hence the version increase to 1.3y)

* mathastext now requires the `\expanded` primitive (which is
  available with all major engines since TeXLive 2019).

* Revisit parts of the documentation (mainly
  the Examples, and the section on Greek letters) and shuffle
  the other parts to surely improve things. Mention
  the [mathfont](https://ctan.org/pkg/mathfont)
  and [frenchmath](https://ctan.org/pkg/frenchmath) packages.

* Add the `ncccomma` option which loads the
  [ncccomma](https://ctan.org/pkg/ncccomma)
  package to allow the comma as decimal separator.

* Add the `binarysemicolon` option to let the semi-colon
  be of type `\mathbin`, not `\mathpunct`.

* Add the `frenchmath*` option which does all three of
  `frenchmath`, `ncccomma` and `binarysemicolon`.

* Under the `LGRgreek` and `LGRgreeks` options only:

  - make available upright and italic Greek letters in math mode
    via `\alphaup`, `\alphait`, ...  control sequences, in
    addition to those not using such postfixed-names.

  - add `\mathgreekup` and `\mathgreekit` math alphabets.

  - add `\MTgreekupdefault` and `\MTgreekitdefault`.  The former
    replaces `\updefault` which was used in some places and since
    LaTeX 2020-02-02 caused systematic Font Warnings about the
    substitution of `up` by `n`.

  These new features required an extensive internal refactoring
  which is expected to not induce changes to most existing
  documents.  But it may induce changes to those using some
  unusual configuration in the preamble, as made possible via the
  package macros; this can apply only to documents authored by
  those few people who actually read the documentation.  For full
  details make sure to read the PDF documentation about this
  change.

* Fix "`\Digamma` under `LGRgreek` option uses the shape for
  lowercase not uppercase Greek".

* Fix some incongruities in log messages related to Greek
  letters and emitted during math version creation in the
  preamble.

1.3w \[2019/11/16\]
----

* LaTeX 2019-10-01 release (up to patch level 3 inclusive)
  together with `amsmath` conspired `:-)` to break `mathastext`,
  in connexion with math accents. This has been fixed upstream,
  but I am releasing nevertheless a hot fix to this
  https://github.com/latex3/latex2e/issues/216 issue
  (this is compatible with future LaTeX releases).

* Fix: the `\hbar` is originally a robust command but
  becomes a `\mathchardef` token if (e.g.) `amsfonts` is
  loaded and then with recent LaTeX `\hbar<space>` is
  made undefined and `mathastext` definition of it
  remained without effect. The `\mathastext` own `\hbar`
  is now defined `\protected`.

* Fix: option `noendash` (or `symboldelimiters` which implies
  it) caused (since `1.3u`) a bug under Unicode engines when
  setting up the minus sign.

* Version names declared via the optional argument of
  `\Mathastext` or as first argument of `\MTDeclareVersion`
  must not be `normal` or `bold`. Enforce that! (this was
  marked as a bug to fix since `2012/10/24`...)


1.3v \[2019/09/19\]
----

* LaTeX 2019-10-01 release has made more math macros robust.
  This applies in particular to the math accents and to the
  `\hbar`. This required for mathastext to adapt. Also
  `\leftarrowfill` and `\rightarrowfill` are now defined
  robust by the kernel, hence mathastext does the same. These
  changes are dropped if mathastext detects an older LaTeX
  format.

* These LaTeX kernel changes motivated an examination of some
  redefinitions done (optionally) by mathastext:

  - The user math alphabet macros got redefined as expanding
  to some other (robust) math alphabet macros, but were not
  robust in the strict sense. This does cause some issues for
  moving arguments in the context of multiple math versions,
  hence it was a bug. The special behavior of the math
  alphabet commands (they redefine themselves and other macros
  on first use) makes is somewhat problematic for mathastext
  to keep them updated across math versions and at the same
  time strictly LaTeX2e robust. Thus mathastext now requires
  the e-TeX primitive `\protected` and uses it for the
  definitions of the user level math alphabet macros.

  - There are a number of `\mathchardef` tokens which (under
  certain options and/or configuration via the package user
  interface), mathastext redefines as macros. These macros
  cause no issue in moving arguments (they are not "fragile"),
  still it is probably better if they expand only at the time
  of typesetting. To this effect they are now also
  `\protected`: `\exists`, `\forall`, `\colon`, `\setminus`,
  `\mid`, `\prod`, `\sum`, `\imath`, `\jmath`.

  - The macro `\vert` (which expands to a `\delimiter`) is now
  defined robust by LaTeX. Its mathastext redefinition is a
  `\protected` one rather.

  - The `\{` and `\}` (which get redefined only under
  `\MTexplicitbracesobeymathxx` regime) are now strictly
  robust in the LaTeX2e sense (formerly they were `\let` to
  some robust macros, and this did not make them strictly
  LaTeX2e-robust entities).

* The various changes in mathastext described in the previous item
  apply independently of the LaTeX release version. The
  LaTeX format itself requires the e-TeX extensions since 2015.


1.3u \[2019/08/20\]
----

* new feature: the initial release dealt with only one font, and
  although shortly thereafter the 1.11 version added support for
  extended math versions, it was documented that some font-dependent
  set-up (minus as endash, dotless i and j, hbar, math accents) was
  done only once. This release makes the relevant characters font
  encoding savvy in each mathastext-extended math version. Thus,
  they should render correctly even with multiple math versions
  using fonts with varying encodings.

  This reinforces importance of using `\MTversion` and not the
  LaTeX `\mathversion` when switching to a new math version (which
  got declared via the package interface). The implementation is
  compatible with Unicode engines and mixed usage of `TU` encoding
  (OpenType fonts) with traditional 8bits TeX font encodings. For
  all engines, all used (8bits) encodings must have been passed as
  options to the `fontenc` package.

  Thanks to Falk Hanisch for feature request and code suggestions.

* new option `unimathaccents`: this adds to option `mathaccents`
  the demand to use the text font accents for OpenType fonts in math
  mode via the `\Umathaccent` primitive. Indeed, as my testing
  showed that this gave non-satisfactory results both with XeTeX
  and LuaTeX regarding the horizontal placement of the accents,
  the main option `mathaccents` acts only on 8bits encoded fonts.
  
* bugfix: the `\Mathastext` without optional argument forgot to
  repeat some font-encoding dependent initialization set-up done
  originally during package loading.

* bugfix: under the `subdued` option macros `\MTmathactiveletters`
  or `\MTnonlettersobeymathxx` now act like no-ops if
  issued explicitly while in the `normal` or `bold` math version.
  Formerly, this was not the case and could cause bugs such as a
  disappearing minus sign in math mode.

* bugfix: the letter `h` used in the `\hbar` obeyed the extra
  skips as set-up by `\MTsetmathskips`, badly interfering with the
  horizontal positioning of the bar accent. They are now ignored
  (as well as the added italic correction).


1.3t \[2018/08/22\]
----

* bugfix: the 1.3s bugfix about `subdued` compatibility with
  `fontspec` was deficient.

* bugfix: very old (v1.2, 2012/12/20) bug causing low-level TeX error
  during package loading (with pdflatex) when setting up the math minus
  sign to be the text font endash character, in cases with
  `\encodingdefault` other than OT1, T1 or LY1, e.g. something like
  T2A.

* `\imath` and `\jmath` obey the `subdued` regime. And the minus sign
  is now handled especially to ensure perfect compatibility with the
  `subdued` option.

* breaking change: `mathastext` does not redefine anymore
  `\i` and `\j` to let them be usable both in text and math mode.


1.3s \[2018/08/21\]
----

* fix to an issue with `subdued` option in a `fontspec` context.

% https://tex.stackexchange.com/q/444565/4686

1.3r \[2016/11/06\]
----

* documentation tweaks.


1.3q \[2016/10/31\]
----

* new option `unicodeminus`.

* the `Recent Changes` section of the documentation has been removed as it
  was a duplicate of information available in the `Change Log`.

* some other
  changes in the documentation, in particular the use of straight quotes
  in verbatim.


1.3p \[2016/05/13\]
----

* bugfix: release `1.3n` had forgotten to activate by default its new
  customization of the amsmath macro `\newmcodes@` (it was done from
  using `\MTversion` in the document body but not by default at start
  of body.)

* public name `\MTfixmathfonts` for a `1.3o` macro.


1.3o \[2016/05/03\]
----

* `mathastext` fixes an issue related to a feature of `LuaLaTeX` and
  `luaotfload` that OpenType fonts are declared in one of two modes:
  `node` and `base`, and only the latter is functional in math mode. But
  by default text fonts are declared in mode `node`. Thus `mathastext`
  now intervenes to make it so that the font it declares in math mode
  will use mode `base`. This fixes issues with for example old style
  figures being used while the text font used lining figures (or vice
  versa, depending on the font). But see the code comments for more.


1.3n \[2016/04/22\]
----

* at long last, `mathastext` takes care properly of annoying and perplexing
  amsmath's `\newmcodes@`. The very recent change in `amsopn.sty` finally
  made it compatible with Unicode engines, but anyhow, `mathastext` must do
  its own patch to use the correct font. All of this taking into account
  the various options passed to the package. Lots of trouble for a tiny thing.


1.3m \[2016/04/02\]
----

* minor code maintenance before annual TL freeze.
 
 
1.3l \[2016/01/29\]
----

* compatibility with fontspec's upcoming switch from `EU1/EU2` to
  `TU` common to both Unicode engines.
 
 
1.3k \[2016/01/24\]
----

* typos fixed in the documentation. In particular, the README link to
  the package homepage had remained broken from day one of the package
  releases: `mathastext.html` therein was misspelled as
  `mathsastext.html` ! (but the pdf documentation had the correct link;
  as well as the CTAN catalogue).
 
 
1.3j \[2016/01/15\]
----

* renamed and modified recent `1.3i`'s `\MTactivemathoff` into
  `\MTeverymathoff`. Added `\MTeverymathdefault`.

* `subdued` mode is a bit stronger: also the asterisk reverts to the
  default (if it was modified due to option `asterisk`), the added
  extra `\mskip`'s (useful with upright fonts) for `'`, `\exists`,
  and `\forall` are suppressed rather than re-configured to use `0mu`.
  Related new commands `\MTexistsdoesskip`, `\MTforalldoesskip`,
  `\MTprimedoesskip`, `\MTnormalexists`, `\MTnormalforall`,
  `\MTnormalprime`.

* the toggle for using mathematically active letters is only emitted
  once during package loading; the `\Mathastext` command does not do
  it anymore; the use in the preamble of `\MTmathstandardletters`,
  or `\MTnoicinmath` and related commands is not overruled by later
  use of `\Mathastext`.

* quite a few documentation improvements and rewrites, particularly
  in the description of commands which are related to the
  modifications of mathcodes (mainly for math activation of
  characters or letters) as done by mathastext at `\everymath` or
  `\everydisplay`.


1.3i \[2016/01/06\]
----

* `\url` from `url.sty` as well as `\url` and `\nolinkurl` from
  `hyperref.sty` use math mode and (by default) the monospace text
  font. To avoid mathastext overwriting the special preparation done
  by `{url,hyperref}.sty` the commands `\url/\nolinkurl` are patched
  to do automatically `\MTactivemathoff` (now `\MTeverymathoff`)
  before entering math mode.

* the extra skips specified by `\MTsetmathskips` are not inserted
  around letters if inside the arguments of math alphabet commands,
  or within operator names.

* the added explicit italic corrections (for non-oblique fonts) were
  disabled within math alphabet scopes, except `mathnormal`; they
  are now disabled within all math alphabets, inclusive of
  `mathnormal`.


1.3h \[2015/10/31\]
----

* bugfixes: since `1.3d 2014/05/23` the option `symbolgreek` caused
  `\ell` to become undefined, and, similarly but far worse, options
  `selfGreek`, `selfGreeks` caused all lowercase Greek letters
  `\alpha`, `\beta`, etc.. to become undefined.
  

1.3g \[2015/10/15\]
----

* following `2015/10/01` LaTeX release, removal of the `"luatex"` 
  prefix from the names of the LuaLaTeX math primitives. Compatibility
  maintained with older LaTeX formats.
  

1.3f \[2015/09/12\]
----

* the replacement of amsmath's `\resetMathstrut@`, when it is
  done, emits an Info rather than a Warning as this could be
  potentially stressful to some users.

* the `README` self-extracts from the `dtx` source, as a text
  file `README.md` with Markdown syntax.


1.3e \[2015/09/10\]
----

* bugfix: under option nosmalldelims, `\lbrace` and `\rbrace` were
  redefined as math symbols and could not be used as delimiters.


1.3d \[2014/05/23\]
----

* A 2015/02/26 edit to the documentation mentions the
  improved compatibility of mathastext
  with the latest (3.34) beamer release: no more need for
  `\usefonttheme{professionalfonts}`.

* new commands `\MTstandardgreek` and `\MTcustomgreek`.

* The Greek letters, in case of use of one of the package related
  options, are left to their defaults in the normal and bold math
  versions if the subdued option was also used (this was so far
  the case only with options LGRgreek/LGRgreeks).

* `\newmcodes@` of amsmath is left untouched if package
  lualatex-math is detected.

1.3c \[2013/12/14\]
----

* added a starred variant to `\MTversion` which tells mathastext to
  only do the math set-up and not modify the text fonts.

* added second optional version name argument to `\Mathastext` and
  to `\MTDeclareVersion`, to transfer settings for things not
  otherwise changed by mathastext from a math version to the one
  declared. This is mainly for symbols and large symbols to be the
  bold ones when the user sets up the series of a mathastextified
  font to be bold in a mathastext-declared version.

* renamed `\defaultprod` to `\MToriginalprod`, `\defaultsum` to
  `\MToriginalsum`, (this is in case of option symbolmisc).

* changes to the dtx organization; options for generating the
  documentation can be customized in generated mathastext.tex file.

* 1.2d code for `\#`, `\$`, `\%`, and `\&` modified erroneously the
  earlier correct 1.2c code and created a bug showing up with more
  than 16 math families (a possibility only with lualatex or
  xelatex).

1.3a \[2013/09/04\]
----

* the somewhat silly `\string`'s are removed from the
  `\MTsetmathskips` command of release 1.3, thus allowing its first
  argument to be a macro, or any expandable code, giving a letter.

* the amsmath `\resetMathstrut@`, which is incompatible with a
  mathematically active parenthesis ( is now modified only if
  necessary (i.e.\@ only when `\MTnonlettersobeymathxx` is issued) and
  is restored to its original value if not needed anymore (i.e.
  after `\MTnonlettersdonotobeymathxx`, as for example when
  switching to the normal version under option subdued).

* improved documentation.

1.3  \[2013/09/02\]
----

* commands `\MTsetmathskips` and `\MTunsetmathskips` added.

* commands `\MTmathactiveletters` and `\MTmathstandardletters` to
  govern the math activation of letters independently of its use
  for insertion of the italic corrections (`\MTicinmath` and
  `\MTnoicinmath` correspondingly modified).

* the new `\luatexUmathcodenum` as available since TL2013 allows
  identical treatment by mathastext of = and - under both LuaTeX
  and XeTeX.

* `\newmcodes@` of amsmath is left untouched in case of option basic.

* a sentence containing | which was written to the log during the
  loading caused a problem if | was active (typically if
  `\MakeShortVerb`{\|} was added to the preamble prior to the
  loading of mathastext).

* some preemptive measures taken regarding things such as `\mid`,
  `\lbrace`, and `\rbrace`, as some packages define these things in
  manners which made the re-definitions done by mathastext issue
  errors.

1.2f \[2013/01/21\]
----

* minor code improvements. Change log added to the user manual.

1.2e \[2013/01/10\]
----

This version should be the last one in the 1.2 series as it seems to
correct most of the main problems which were introduced with the massive
use of mathematically active characters in versions 1.2 and 1.2b.

* It is indeed a thorny point when one wants to modify an active character in
  math mode only (without breaking usage in label's and ref's for example).
  The package now does that _only_ if the activation originated in the Babel
  system as it is then possible to modify appropriately the Babel macros
  `\user@active<char>` and `\normal@char<char>`, at the time of entering math
  mode (mathastext does all its activation job at `\everymath` and
  `\everydisplay`).

  The relevant issues are discussed in section 2.10 of the user manual, in the
  test file mathastexttestalphabets.tex, and in the source code comments for
  macro `\mst@mathactivate`. The inherent incompatibility of Babel with
  packages having made mathematically active the characters itself makes
  document active is circumvented by this interference of mathastext. A
  generally applicable Babel patch could be derived from the method used by
  mathastext.

  For the non catcode active characters, mathematical activation is used.
  This is done at the entrance in math mode.

* Sadly, the feature of added italic corrections introduced in
     version 1.2b did not behave as described in the user manual, due to
     forgotten group braces. Fixed.

* The command `\MTlowerast` from the user manual of v1.2d was not the
     one implemented in the source code. Fixed.

* The test files automatically extracted from a latex run on the dtx
     file have been revised and extended.

* The code is better documented.

1.2d \[2013/01/02\]
----

*  an incompatibility with amsmath (its macro `\resetMathstrut@`),
      exists since version 1.2 of the package. This is fixed
      here.

*  various improvements in dealing with the asterisk and in the
      mechanism of letting non-letter symbols obey the math alphabet
      commands.

*  the `noasterisk` option is deprecated and made a no-op.

*  documentation extended and improved.

1.2c \[2012/12/31\]
----

*  mathastext now inserts automatically after all (latin)
      letters in math mode their italic corrections, if the font
      used is upright (sic). This improves the spacings for the
      positioning of subscripts. The feature is de-activated
      inside the math alphabets commands (apart from `\mathnormal`),
      so as to not prohibit the formation of ligatures.

*  the documentation has been extended to explain in detail the
      issues which are relevant to the new feature of added italic
      corrections.

* version 1.2 had some bad bugs when confronted to active
  characters. This is corrected and additionally
  `\MTnonlettersdonotobeymathxx` is made the default, as the user
  input is too much constrained in its absence.

*  a less fatal, but still annoying, typo had made the dot in 1.2
      of type `\mathpunct` rather than `\mathord`.

*  the inner namespace has been rationalized a bit.

1.2 \[2012/12/20\]
----

*  a new command sets up the amount of space to be automatically
      inserted before the derivative glyph (useful when using an
      upright font).

*  the scope of the math alphabets has been extended to apply
      to the non-alphabetical characters, and also to operator
      names.

*  the format of the dtx file has changed. The package file
      is self-extracting from the dtx, and four additional test
      files are also produced during `latex mathastext.dtx`.

1.15f and 1.15g \[2012/10/25\]
----

*  `\$`, `\#`, `\&`, and `\%` had been re-defined by mathastext since its
      inception in a rather strange (but working) way, which
      could cause surprises to other packages. Fixed.

*  the subdued mechanism for the math alphabets is implemented
      in a simpler and more efficient manner than in 1.15e.

*  the `defaultxx` options act a bit differently, and are more
      useful in case of a `too many math alphabets` situation.

*  various improvements in the documentation.

*  general clean up and better commenting of the source code.

1.15e \[2012/10/22\]
----

*  new user commands to specify skip or glue to be
      inserted after the math symbols `\exists` and `\forall`

*  complete (user transparent) rewrite of the code
      implementing the subdued option; and its action has
      been extended to apply also to the `\mathbf`, `\mathit`,
      `\mathsf`, `\mathtt` alphabets and not only to `\mathrm` and
      `\mathnormal` as in the previous versions.

*  improvements in the documentation.

1.15d \[2012/10/13\]
----

* the Unicode situation is now correctly treated, throughout the
  code (this had been left in a half-done way from version 1.14 of
  April 2011).

* this includes an issue related to amsmath and its
  DeclareMathOperator macro which has been fixed,

* and the code related to `\relbar` and `\Relbar` (and
  `\models`) has been revised.

1.15c \[2012/10/05\]
----

*  it is now possible to use distinct fonts in LGR encoding
      for the Greek letters according to the current math
      version.

*  improvements to the documentation.

1.15b
----

*  corrected a 'feature' of 1.15 which was backward-incompatible

*  improvements to the pdf documentation

1.15  \[2012/09/26\]
----

*  the subdued option allows the mathastextification to
      act only locally.

*  some measures taken to deal with amsmath related
      issues when using xetex or luatex.

1.14c
----

*  a bug is fixed: the `\Mathastext` macro reinitializes
      the fonts in the normal and bold math versions, but it
      also erroneously redeclared the math alphabet changing
      commands which could have been set up in previously
      defined math versions (via earlier calls to
      `\Mathastext`\[version_name\]).

1.14b \[2011/04/03\]
----

*  there was a bug with `\$`, `\#`, `\&`, `\%` in math mode which
      showed up when ten or more math families had been
      declared. This bug affected also the minus sign under
      the same circumstances, when Unicode engines were
      used. Fixed.

*  the options LGRgreek and selfGreek act now a bit
      differently, and new options LGRgreeks and selfGreeks
      have been defined.

*  I also cleaned up a bit the code, for a more
      structured namespace.

1.14
----

*  mathastext now modifies also the math alphabets `\mathit`,
      `\mathsf` and `\mathtt`, thus making it a quite generic
      complete manner to adapt the math configuration to fonts
      provided with no math support.

1.13d
----

*  new macros `\MTstandardgreek` and `\MTcustomgreek`

1.13b
----

*  when the Symbol font is used for `\prod` and `\sum` this
      will be only for inline math; display math will use the
      default glyphs

1.13 \[2011/03/11\]
----

*  the LGRgreek option is added.

*  internal changes for better readability of the code.

1.12
----

*  various bugs have been corrected.

*  the endash and alldelims options are active by default.

*  the package is more Unicode aware.

*  the `\Mathastext` command has been improved to
      facilitate the mechanism of math versions also when
      using XeTeX or LuaTeX (with package fontspec.)

*  the en-dash and dotless i and j now work with all
      encodings, Unicode inclusive.

1.11 \[2011/02/06\]
----

*  optional argument to `\Mathastext` macro.

1.1  \[2011/02/01\]
----

*  options italic and frenchmath.

1.0  \[2011/01/25\]
----

*  Initial version.

%</changelog>
%<*drv>
%% This is a generated file. Run latex thrice on this file mathastext.tex then
%% run dvipdfmx on mathastext.dvi to produce the documentation mathastext.pdf,
%% with the package source code included.
%%
%% Customize as desired the class options and the two toggles below.
%%
%% See mathastext.dtx for the copyright and the conditions for distribution
%% and/or modification of this work.
%%
\NeedsTeXFormat{LaTeX2e}
\ProvidesFile{mathastext.tex}%
[\MSTpkgdate\space v\MSTpkgversion\space 
       driver file for mathastext documentation (JFB)]%
\PassOptionsToClass{a4paper,fontsize=11pt}{scrartcl}
\chardef\Withdvipdfmx 1 % replace 1<space> by 0<space> for using latex/pdflatex
\chardef\NoSourceCode 0 % replace 0<space> by 1<space> for no source code
\input mathastext.dtx
%%% Local Variables:
%%% mode: latex
%%% End:
%</drv>
%<*dtx>
^^Afi^^Aendgroup % end of big \iffalse block including generated files
% Removal of the *sfixed found in tex/latex/mlmodern/omxmlmex.fd
\DeclareFontFamily{OMX}{mlmex}{}
\DeclareFontShape{OMX}{mlmex}{m}{n}{%
   <->mlmex10%
   }{}
% customization should be done in mathastext.tex, not here.
\documentclass{scrartcl}
\makeatletter
%%% START OF CUSTOM doc.sty LOADING (May 21, 2022 in xint.dtx)
%%% (October 29, 2022 here, comments trimmed)
% Let's load the doc=V2 version to avoid having to work around
% hypdoc loading interfering with my use of hyperref.
\ifdefined\IfFormatAtLeastTF
  \IfFormatAtLeastTF{2022/06/01}%
  {%
    \IfFileExists{doc-2021-06-01.sty}%
     {\usepackage{doc}[=v2]}%
% Why on earth do I lose my time doing this?
     {\GenericError
          {(mathastext build doc)\@spaces}%
          {mathastext build error: %
      Your LaTeX installation seems to be broken, format is\MessageBreak
      2022-06-01 or later but `doc' package in its `v2' version\MessageBreak
      seems to not be available. \space Will try with `doc' but if\MessageBreak
      its `v3' is used there will be an option clash error\MessageBreak
      regarding hyperref.}%
          {}%
          {Please make sure `doc' package matches your LaTeX format.}%
      \usepackage{doc}%
     }%
  }%
  {\usepackage{doc}}%
\else
\usepackage{doc}
\fi
% Let's emulate here the little I appear to need from ltxdoc.cls and
% srcdoc.cls.
%
\AtBeginDocument{\MakeShortVerb{\|}}
\DeclareFontShape{OT1}{cmtt}{bx}{n}{<-> ssub * cmtt/m/n}{}
\DeclareFontFamily{OMS}{cmtt}{\skewchar\font 48}  % '60
\DeclareFontShape{OMS}{cmtt}{m}{n}{<-> ssub * cmsy/m/n}{}
\DeclareFontShape{OMS}{cmtt}{bx}{n}{<-> ssub * cmsy/b/n}{}
\DeclareFontShape{OT1}{cmss}{m}{it}{<->ssub*cmss/m/sl}{}
\ifnum\NoSourceCode=1
  \OnlyDescription
\fi
\CodelineNumbered
\EnableCrossrefs
% \setcounter{StandardModuleDepth}{1} % we don't use this mechanism currently
\def\cmd#1{\cs{\expandafter\cmd@to@cs\string#1}}
\def\cmd@to@cs#1#2{\char\number`#2\relax}
% Here I am loading doc=v2 but formerly I was using ltxdoc via scrdoc
% which I dropped at (etoc) release 1.4l (2022-05-29) and without much
% thinking I had kept this.
\DeclareRobustCommand\cs[1]{\texttt{\bslash#1}}
% As I may have the * active, or macro names with _ or ^, I should
% add \detokenize.  But see below for a redefinition anyhow.
%
% More urgent is that I am also using hyperref and this definition gives wrong
% bookmarks if \cs is used in section titles.  As I had very very few usags of
% \cs in the whole of xint.dtx, it took me a while to realize the problem
% here.  Turns out that doc=v3 by default loads hypdoc which includes this
% configuation for hyperref compatibility:
\AtBeginDocument{%
\pdfstringdefDisableCommands{\def\cs#1{\textbackslash\detokenize{#1}}}%
}%
% As I have not loaded hyperref yet I must delay it to AtBeginDocument.
\providecommand\marg[1]{%
  {\ttfamily\char`\{}\meta{#1}{\ttfamily\char`\}}}
\providecommand\oarg[1]{%
  {\ttfamily[}\meta{#1}{\ttfamily]}}
\providecommand\parg[1]{%
  {\ttfamily(}\meta{#1}{\ttfamily)}}
% \@addtoreset{CodelineNo}{part}% No need for this here
% \def\partname{File}% \partname is "fixed" somewhere further down anyhow
% No need for this, anyhow I don't build the indices
%
% There is very little we seem to need from the scrdoc extras: page geometry
% is set by geometry package and a4paper option from xint.tex file.  So it
% seems I only need the hologo loading:
\usepackage{hologo}
% 1.4 fix to some extra line spacing obviously caused by usage of the
% \hologo macro.
% I opened  https://github.com/ho-tex/hologo/issues/9
% after testing, actually only XeTeX and XeLaTeX are problematic
% update: as per @u-fischer the problem goes away if graphicx package
% is loaded, but we don't use it in this document...
\def\msthologo#1{\smash{\hologo{#1}}}
\DeclareRobustCommand*{\eTeX}{\msthologo{eTeX}}%
\DeclareRobustCommand*{\pdfLaTeX}{\msthologo{pdfLaTeX}}%
\DeclareRobustCommand*{\LuaTeX}{\msthologo{LuaTeX}}%
\DeclareRobustCommand*{\LuaLaTeX}{\msthologo{LuaLaTeX}}%
\DeclareRobustCommand*{\XeTeX}{\msthologo{XeTeX}}%
\DeclareRobustCommand*{\XeLaTeX}{\msthologo{XeLaTeX}}%
%
\makeatother
%%% end of ltxdoc+srcdoc emulation from June 2022 xint.dtx,
%%% copied over almost verbatim to mathastext.dtx on 2022/10/29.

\ifnum\NoSourceCode=1 \OnlyDescription\fi
\makeatletter
\ifnum\Withdvipdfmx=1
% peut-être je devrais plutôt passer dvipdfmx en option à la classe.
   \@for\@tempa:=hyperref,bookmark,graphicx,color\do
            {\PassOptionsToPackage{dvipdfmx}\@tempa}
   %
   \PassOptionsToPackage{dvipdfm}{geometry}
   \PassOptionsToPackage{bookmarks=true}{hyperref}
   \PassOptionsToPackage{dvipdfmx-outline-open}{hyperref}
%   \PassOptionsToPackage{dvipdfmx-outline-open}{bookmark}
   %
   \def\pgfsysdriver{pgfsys-dvipdfm.def}
\else
   \PassOptionsToPackage{bookmarks=true}{hyperref}
\fi
\makeatother

\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath}\allowdisplaybreaks
\usepackage{mlmodern}
\DeclareEncodingSubset{TS1}{mlmtt}{0}
% cf https://github.com/latex3/latex2e/issues/905
% How to **quickly** know whether 0 is ok ?
% Not willing to waste half an hour, more probably
% an hour on this (already done, almost).
\usepackage{enumitem}

\DeclareSymbolFont{largesymbols}{OMX}{txex}{m}{n}
\SetSymbolFont{largesymbols}{bold}{OMX}{txex}{bx}{n}
\DeclareFontSubstitution{OMX}{txex}{m}{n}

% in order to cancel the removal of comment characters
% inside verbatim blocks caused by doc.sty's redefinition
% of \@verbatim (a macro which is not used by tagging code,
% by the way)
\makeatletter\let\check@percent\relax\makeatother

\usepackage{color}
\definecolor{DarkMagenta}{RGB}{139,0,139} 
\definecolor{joli}{RGB}{225,95,0}
\definecolor{monmarron}{RGB}{136,24,24}
\usepackage{xspace}
%\usepackage{metalogo}% on utilise dejà hologo
\usepackage{framed}
\usepackage{colorframed}
\definecolor{shadecolor}{gray}{0.94}

\usepackage[hscale=0.66]{geometry}

\usepackage{hyperref}

\hypersetup{linktoc=all,%
colorlinks=true,%
linkcolor={blue},%
urlcolor={joli},
pdfauthor={Jean-François Burnol},%
pdftitle={The mathastext package},%
pdfsubject={LaTeX, math fonts},%
pdfkeywords={LaTeX, Fonts},%
pdfstartview=FitH,%
pdfpagemode=UseOutlines,%
}

\usepackage{bookmark}

\usepackage{centeredline}

\DeclareRobustCommand\cs[1]% j'utilisais avant 189, j'ai essayé 23
        {{\ttfamily\hyphenchar\font=127 \char`\\#1}}
\DeclareRobustCommand\csb[1]%
        {\hyperref[#1]{\ttfamily\hyphenchar\font=127 \char`\\#1}}

\newcommand*\blueit[1]{\texorpdfstring{\blueitaux #1\relax}{#1}}
% utiliser \texttt plutôt que \ttfamily ?
\def\blueitaux #1#2\relax{\hyperref[#2]{\ttfamily #1#2}}

% 2 septembre 2013, 22:25
% je réussis avec un minimum de modifs dans la source à convertir tous mes
% mots-clés bleus en hyperliens; les labels sont créés simplement en modifiant
% plus loin \@jfendshrtverb
\catcode`\§=13
\makeatletter
\def§{\leavevmode\begingroup
           \let\do\@makeother\dospecials
      \@jfendshrtverb }
\def\@jfendshrtverb #1#2§{\hyperref[#2]{\ttfamily\hyphenchar\font=127 #1#2}\endgroup}
\makeatother

\newcommand\mst{%
\texorpdfstring{{\color{joli}\ttfamily\bfseries mathastext}}
{mathastext}\xspace}

\let\oldexists\exists\let\oldforall\forall
\let\originalbullet\bullet

% MEMO: due to LGRgreek option, symbol font alphabets mtgreekup and mtgreekit
% are declared using the \familydefault at times of loading so here mlmr.
% It is not important that mlmr does not exist in LGR encoding, because
% we will not use the \mathgreekup or \mathgreekit alphabet in the subdued
% normal math versions, and besides the Greek letters are left untouched.
\usepackage[subdued,%
            asterisk,%
            defaultmathsizes,%
            symbolmisc,symbolre,%
            LGRgreek+,
            activedigits]{mathastext}
\let\symbolbullet\bullet
\let\bullet\originalbullet
% This version will use the mlmodern font which is current
% last loaded font package in preamble
\Mathastext[upright]

% The mlmodern font with letters in it shape
\MTlettershape{it}
\Mathastext[italic]

\MTlettershape{n}% \updefault would create needless substitution and Font Warning
\MTupgreek % le lettershape suffirait mais plus clair
\MTgreekfont{cmtt}
\MTfamily{lmvtt}
\Mathastext[lmvtt]

\usepackage{newcent}% attention that it modifies all three of \rmdefault,
                  % \sfdefault and \ttdefault
\MTfamily{\rmdefault}
\MTlettershape{it}
\MTitgreek\MTupGreek
\Mathastext[newcent]

\MTseries{b}
\Mathastext[boldnewcent][bold]

\usepackage{times}% attention that it modifies all three of \rmdefault,
                  % \sfdefault and \ttdefault
\MTfamily{\rmdefault}
\MTlettershape{it}
\MTseries{m}
\MTgreekfont{txr}
\MTitgreek\MTupGreek
\Mathastext[times]

\MTlettershape{n}
\MTupgreek
\MTseries{bx}
\Mathastext[timesbold][bold]

\usepackage[scaled]{helvet}% attention modifie \sfdefault
\MTfamily{\sfdefault}% phv
\MTlettershape{it}
\MTseries{m}
\MTitgreek
\MTgreekfont{cmss}
\Mathastext[helvet]

\renewcommand{\ttdefault}{mlmtt}
\MTfamily{LibertinusSerif-TLF}
\MTlettershape{n}
\MTseries{m}
\MTgreekfont{LibertinusSerif-TLF}
\MTupgreek
\Mathastext[libertinus]
\MTseries{sb}
% attention je veux pas courier quand je ferai \texttt avec cette version
% donc (a été déplacé plus haut)
% \renewcommand{\ttdefault}{mlmtt}
\Mathastext[libertinussemibold]

\MTlettershape{it}
\MTitgreek\MTupGreek
\MTseries{m}
\Mathastext[libertinustexstyle]

% la ligne suivante semble superflue maintenant
\renewcommand\familydefault\sfdefault% attention that it is phv at this stage

% pas nécessaire car je fais \MTversion{normal} après \begin{document}
% \renewcommand\rmdefault{mlmr}%   counteract effect of various font packages
%                              %   earlier
% \renewcommand\sfdefault{mlmss}%
% \renewcommand\ttdefault{mlmtt}%

\usepackage{etoc}

% - à partir de 1.3j: _très très_ peu satisfaisant mais pas envie d'y passer
% du temps.
%
% - je refais très vite pour 1.3q: \RLNote remplace \RightNote et est fait
% différemment, \CHANGED aussi a été refait. Finalement 1.3r utilise ttfamily.

\def\RLNote #1#2{\leavevmode\strut\vadjust{\kern-\dp\strutbox
 \hbox to\textwidth
  {\vtop to \dp\strutbox{}%
   \footnotesize\normalfont\ttfamily
   \color{magenta}%
   \llap{\smash{#1\kern10pt}}\kern\textwidth\rlap{\smash{\kern10pt(#2)}}%
  }%
 }%
}

\def\RightNote {\RLNote {}}

% modifié pour la doc de 1.3q. Bordel de Koma-Script. Il utilise des em.
% À droite je vais normaliser à 10pt pour que ça soit coordonné avec \RightNote.
% refait pour 1.3r
% ** À utiliser au tout début d'une footnote **
\def\CHANGED #1{\leavevmode\kern-1em
 {\ttfamily\color{magenta}\llap{changed:\kern10pt}%
  \kern\textwidth\rlap{\kern10pt(#1)}\kern-\textwidth}%
 \kern1em }

% pour 1.3q
% attention que doc.sty n'utilise pas \@noligs
% or upquote ne patche que \@noligs
\usepackage{textcomp}
\begingroup\makeatletter
  \catcode`'=\active
  \catcode``=\active
  \g@addto@macro\verbatim@nolig@list{\let'\textquotesingle\let`\textasciigrave}
\endgroup

% KOMA-script est HORRIPILANT.
\def\rm {\normalfont}
\def\bf {\normalfont\bfseries}
\def\tt {\normalfont\ttfamily}
% mais bon, en fait je ne les utilise pas.

% 2023/12/27
\DeclareRobustCommand\ctanpkg[1]
      {\texorpdfstring{\href{https://ctan.org/pkg/#1}{#1}}{#1}}

% 2024/07/10
% Attention que si la cible n'existe pas il n'y a AUCUN warning
% dans le log...
\newcommand\mstrelease[1]{\hyperlink{#1}{\texttt{#1}}}

\begin{document}
% \makeatletter\show\mv@normal\makeatother
% contient
% \getanddefine@fonts
% \symmtgreekup \LGR/mlmr/m/n \getanddefine@fonts \symmtgreekit \LGR/mlmr/m/it
% 
% donc au premier mode mathématique (par \footnote je suppose)
%
% LaTeX Font Info:    Trying to load font information for LGR+mlmr on input line 
% 1712.
% LaTeX Font Info:    No file LGRmlmr.fd. on input line 1712.

\MTversion{normal}
\renewcommand\familydefault\sfdefault
\pdfbookmark[1]{Title page}{TOP}

\nonfrenchspacing

\begin{center}
  {\normalfont\LARGE The \mst  package}\\
\textsc{\small Jean-François Burnol}\par
  \footnotesize \ttfamily \frenchspacing
  jfbu (at) free (dot) fr\par
  \let\thefootnote\empty
  Package version: \MSTpkgversion\ (\MSTpkgdate)%
  \footnote{Documentation generated from the
    source file with \dtxtimestamp.}\par
\end{center}
\setcounter{footnote}{0}


 \begin{small}
   \noindent The \mst package changes the fonts which are used in math
   mode for letters, digits and a few other punctuation and symbol signs
   to replace them with the font as used for the document text. Thus,
   the package makes it possible to use a quite arbitrary font without
   worrying too much that it does not have specially designed
   accompanying math fonts. Also, \mst provides a simple mechanism in
   order to use more than one math-as-text font in the same
   document.\baselineskip.9\baselineskip\par
 \end{small}

\medskip

\begin{verbatim}
          `mathastext' is a LaTeX package

              \usepackage{mathastext}

          The document will use in math mode the text font
          as configured at package loading time, for these
          characters:

              abcdefghijklmnopqrstuvwxyz
              ABCDEFGHIJKLMNOPQRSTUVWXYZ
              0123456789
              !?,.:;+-=()[]/#$%&<>|{}\

          The command \MTsetmathskips allows to set up extra
          spacings around each given letter.

          Use multiple \Mathastext[name]'s to define in the
          preamble various math versions using each a given
          text font, to be later activated in the document  
          body via the command \MTversion{name}.

          With the subdued option, mathastext will be active
          only inside such math versions distinct from the
          normal and bold.

          Main options: italic, frenchmath, defaultmathsizes,
                        subdued, asterisk, LGRgreek.
\end{verbatim}

\clearpage

\etoctoclines
\renewcommand\etocaftertitlehook
   {\hypersetup{hidelinks}% added 1.3
      \setlength{\columnseprule}{.4pt}%
      \renewcommand{\columnseprulecolor}{\color{DarkMagenta}}%
      }
\renewcommand\etocbelowtocskip{1ex}
\etocruledstyle{\color{DarkMagenta}\normalfont\large\bfseries\contentsname }
% pdfbookmark added 2013/12/11. Attention si je le mets dans ruled style
% il est exécuté deux fois et ça cause un problème.
% et le aftertitlehook est trop bas.
\pdfbookmark[1]{Table of contents}{MAINTOC}
\tableofcontents
{\color{DarkMagenta}\hrule}%
\vskip 5ex plus 2ex minus 1ex


\section{What \mst does}

If you have used the package before please make sure to check first
\autoref{sec:changelog} where all changes across releases are recorded.

All blue colored words, such as §\Mathastext§ or §italic§, are hyperlinked to
their offical descriptions located either in the \autoref{sec:cmd} (Package
commands) or \autoref{sec:opt} (Complete list of options).


\subsection{Aim of this package and basic usage}

The initial ideology of \mst was to produce mathematical texts with
a very uniform look, not separating math from text as strongly as
is usually done. 

\mst's basic aim is thus to have the same font for text and mathematics. With
hundreds of free text fonts packaged for \LaTeX{} and only a handful of
math ones, chances are your favorite text font does not mix so well with
the available math ones; \mst may then help. Note that \mst was initially
developed for the traditional \TeX{} fonts and engines, and that compatibility
with Unicode engines and OpenType fonts is partial.

Here is a minimal example of what may go into
the preamble:
\begin{verbatim}
\usepackage[T1]{fontenc}
\usepackage{times}
\usepackage[italic]{mathastext}
\end{verbatim}
The package records which font is set up for text, at the time it is
loaded,
and
then arranges things in order for this text font to be used in math mode as
well. So, with the preamble as above
all letters, digits, and punctuation signs inside math mode will then be
typeset in Times.\footnote{let's do as if we did not know the excellent
  \ctanpkg{txfonts} package which employs Times for text and has a very complete
  math support, including many additional mathematical glyphs in
  comparison to the CM fonts. \emph{This was written many years ago, nowadays,
  \emph{\ctanpkg{newtx}} is the successor of \emph{\ctanpkg{txfonts}}.}}
The exact list of characters concerned by
\mst is a subset of the basic |ASCII| set:

  \begin{framed}\centering\MTversion{timesbold}%
    \begingroup\color{joli}%
      $abcdefghijklmnopqrstuvwxyz$\par
      $ABCDEFGHIJKLMNOPQRSTUVWXYZ$\par
      $0123456789$\par
      \DeleteShortVerb{\|}% global!
      ${!}\,{?}\,{*}\,{,}\,{.}\,{:}\,{;}\,{+}\,{-}\,{=}\,{(}\,{)}\,
       {[}\,{]}\,{/}\,{\#}\,{\$}\,{\%}\,{\&}\,{<}\,{>}\,{|}\,{\{}\,{\}}
       \textrm{ \color{black}\mdseries and }{\backslash}$%
   \endgroup\par\MakeShortVerb{\|}%
  \end{framed}

As one can see, this is a very limited list! Some possibilities exist
regarding Greek letters and will be described later. 


\subsection{Examples}
\label{sec:examples}

Here is another simple example:
\begin{verbatim}
\usepackage{libertinus-type1}
\usepackage[italic,LGRgreek,defaultmathsizes]{mathastext}
\end{verbatim}
The §LGRgreek§ option is there to take advantage that the \ctanpkg{libertinus-type1} package%
%
\footnote{Bob \textsc{Tennent}, \emph{Support for using Libertinus fonts with
    \LaTeX/\pdfLaTeX}, \url{https://ctan.org/pkg/libertinus-type1}.}
%
also provides Greek letters in LGR encoding, which can thus be used by \mst in
math mode.  And we do here as if we did not know about the existence of the
\ctanpkg{libertinust1math} package!%
%
\footnote{Michael \textsc{Sharpe}, \emph{A Type 1 font and \LaTeX\ support for Libertinus
    Math}, \url{https://ctan.org/pkg/libertinust1math}.}
%
This would have been the obvious choice, but then one wouldn't need \mst and I
couldn't even start this documentation.


More sophisticated preambles will use multiple times the §\Mathastext§ command
in the preamble with its optional argument \oarg{math\_version} in order to
define \emph{math versions} corresponding to a given font configuration.
These \mst-enriched math versions are then activated in the document body via
the §\MTversion§\marg{math\_version} command, which modifies \emph{both} the text
font and the math font.


We now give some examples with a verbatim copy of the preamble code
corresponding to them, as can be found in the source of this documentation.
The detailed option and command descriptions will be given later.

\def\DeepestMathematicsText{%
Let $(X,Y)$ be two functions of a variable $a$. If they obey  the differential
system  $(VI_{\nu,n})$: 
  \begin{align*} 
  a\frac{d}{da} X &= \nu
  X - (1 - X^2)\frac{2n a}{1 - a^2}\frac{aX+Y}{1+a XY} \\  
a\frac{d}{da} Y &= -(\nu+1) Y
 + (1 - Y^2)\frac{2n a}{1 - a^2}\frac{X+aY}{1+a XY} 
  \end{align*}
then the quantity $q = a \frac{aX+Y}{X+aY}$
satisfies as function of $b= a^2$  the $P_{VI}$ differential equation:
\begin{equation*}
\begin{split}
  \frac{d^2 q}{db^2} = \frac12\left\{\frac1q+\frac1{q-1}
  +\frac1{q-b}\right\}\left(\frac{dq}{db}\right)^2 - \left\{\frac1b+\frac1{b-1}
  +\frac1{q-b}\right\}\frac{dq}{db}\\+\frac{q(q-1)(q-b)}{b^2(b-1)^2}\left\{\alpha+\frac{\beta
    b}{q^2} + \frac{\gamma (b-1)}{(q-1)^2}+\frac{\delta
    b(b-1)}{(q-b)^2}\right\}
\end{split}
\end{equation*}
with
parameters
$(\alpha,\beta,\gamma,\delta) = (\frac{(\nu+n)^2}2,
\frac{-(\nu+n+1)^2}2, \frac{n^2}2, \frac{1 - n^2}2)$.\par
Test of uppercase Greek in math: $\Alpha\Beta\Gamma\Delta\Xi\Omega$.\par
}

First of all, the package was loaded using this:
\begin{verbatim}
\usepackage[subdued,%
            asterisk,%
            defaultmathsizes,%
            symbolmisc,symbolre,%
            LGRgreek]{mathastext}
\end{verbatim}
In the definitions of the \mst-enriched \emph{math versions} we keep commands
which may have been redundant in the original preamble, because they were
issued earlier for a previous math version definition.

Let's start with Latin Modern typewriter proportional.  Its usage was
configured in the preamble using this:
\begin{verbatim}
\MTlettershape{n}
\MTupgreek
\MTgreekfont{cmtt}
\MTfamily{lmvtt}
\Mathastext[lmvtt]
\end{verbatim}
Its usage is triggered using \centeredline{|\MTversion{lmvtt}|} in the
document. Here is an example:

{\advance\leftskip.1\linewidth\advance\rightskip.1\linewidth
 \MTversion{lmvtt}
 \DeepestMathematicsText
}

Both the Latin and Greek letters are upright, in conformity to the
way the |lmvtt| version was defined.

\bigskip

Now with the fonts from the |libertinus-type1| distribution%
%
\footnote{Bob \textsc{Tennent}, \emph{Support for using Libertinus fonts with
    \LaTeX/\pdfLaTeX}, \url{https://ctan.org/pkg/libertinus-type1}.}.
%
The preamble code is:
\begin{verbatim}
\MTfamily{LibertinusSerif-TLF}
\MTlettershape{n}
\MTseries{m}
\MTgreekfont{LibertinusSerif-TLF}
\MTupgreek
\Mathastext[libertinus]
\MTseries{sb}
\Mathastext[libertinussemibold]
\end{verbatim}
Its usage in the document body for the example below is triggered via
\centeredline{|\MTversion[libertinus]{libertinussemibold}|} This syntax
modifies the text fonts to be those which were defined to hold for the
\mst-math version passed as optional argument, and sets the math fonts
according to the mandatory argument.  Hence the math mode uses semibold font
but the text font uses the normal weight.

{\advance\leftskip.1\linewidth\advance\rightskip.1\linewidth
 \MTversion[libertinus]{libertinussemibold}
 \DeepestMathematicsText
}

\bigskip

Now with a Times clone.  We will configure Latin letters to be in italic
shape, and Greek letters to be italic for lowercase and upright for uppercase:
\begin{verbatim}
\usepackage{times}% it modifies the \{rm,sf,tt}default's
\MTfamily{\rmdefault}
\MTlettershape{it}
\MTseries{m}
\MTgreekfont{txr}
\MTitgreek\MTupGreek
\Mathastext[times]
% \MTversion{times} will change not only math but also text, so it
% will re-enact the \rmdefault, \sfdefault, \ttdefault from loading times.sty
\end{verbatim}
We now use this in the document body via
\centeredline{|\MTversion{times}|}

{\advance\leftskip.1\linewidth\advance\rightskip.1\linewidth
 \MTversion{times}
 \DeepestMathematicsText
}

\bigskip
Let us be a bit more original and have our mathematics with italic letters
from the sans serif font Helvetica, while the letters in text use New Century
Schoolbook.  Also we want Greek letters (both lowercase and uppercase) to be
in italic shape. The preamble code was:
\begin{verbatim}
\usepackage{newcent}% attention that it modifies all three of \rmdefault,
                    % \sfdefault and \ttdefault
\MTfamily{\rmdefault}
\MTlettershape{it}
% \MTitgreek\MTupGreek % our demo does not use newcent for math anyway
\Mathastext[newcent]

\usepackage[scaled]{helvet}
\MTfamily{\sfdefault}
\MTlettershape{it}  % redundant here
\MTseries{m}
\MTitgreek          % make both lowercase and uppercase Greek italic
\MTgreekfont{cmss}
\Mathastext[helvet]
\end{verbatim}
And the next demo is configured in the document body via
\centeredline{|\MTversion[newcent]{helvet}|}

{\advance\leftskip.1\linewidth\advance\rightskip.1\linewidth
 \MTversion[newcent]{helvet}
 \DeepestMathematicsText
}

\bigskip
And after all that, we may wish to return to the default math typesetting (let's
shorten the extract here in case the reader makes an indigestion \dots).  This
is easy because all previous usages were enclosed in braces |{...}| so as to
limit the scope.  As \mst was loaded with option §subdued§ the default rendering
(i.e.\@ in the \emph{normal} and \emph{bold} math versions) is (almost) as if
the package was not loaded at all, and it simply matches the document font
configuration.  Here it thus matches the
\centeredline{|\usepackage{mlmodern}|} which was included in the document
preamble prior to loading \mst.

{\advance\leftskip.1\linewidth\advance\rightskip.1\linewidth
Let $(X,Y)$ be two functions of a variable $a$. If they obey  the differential
system  $(VI_{\nu,n})$: 
  \begin{align*} 
  a\frac{d}{da} X &= \nu
  X - (1 - X^2)\frac{2n a}{1 - a^2}\frac{aX+Y}{1+a XY} \\  
a\frac{d}{da} Y &= -(\nu+1) Y
 + (1 - Y^2)\frac{2n a}{1 - a^2}\frac{X+aY}{1+a XY} 
  \end{align*}
  then the quantity $q = a \frac{aX+Y}{X+aY}$ satisfies as function of $b=
  a^2$ the $P_{VI}$ differential equation with parameters
  $(\alpha,\beta,\gamma,\delta) = (\frac{(\nu+n)^2}2, \frac{-(\nu+n+1)^2}2,
  \frac{n^2}2, \frac{1 - n^2}2)$.\par
Test of uppercase Greek in math: $%\Alpha\Beta
                                  \Gamma\Delta\Xi\Omega$ (no \string\Alpha, no
                                  \string\Beta).\par
}

\bigskip

If the scope of our earlier examples using \mst-enriched math versions
had not been limited we would have issued \centeredline{|\MTversion{normal}|}
to return to the normal (almost not influenced by \mst{}) math version.


The Greek letters varied across our examples thanks to the §LGRgreek§ option
which made the §\MTgreekfont§ command active for configuration of the math
versions.%
%
\footnote{The document used the \texttt{cmtt}, \texttt{cmss}, \texttt{txr}, as well
  as \texttt{LibertinusSerif-TLF} font families in \texttt{LGR} encoding.  The
  first two are available (with no need to
  load explicitly any package in the document) if the \LaTeX{} installation
  provides the
  \ctanpkg{cbfonts} (or \ctanpkg{cbgreek-complete}) \& \ctanpkg{babel} packages, and the |LGR| encoded |txr| font
  (again no package loading is necessary) is part of the files of the
  \ctanpkg{txfontsb} package.  For \texttt{LibertinusSerif-TLF}, the files of the
  \ctanpkg{libertinus-type1} package must be present.}

% \href{http://mirrors.ctan.org/help/Catalogue/entries/cbgreek-complete.html}{cbfonts},
% \href{http://mirrors.ctan.org/help/Catalogue/entries/txfontsb.html}{txfontsb}.

\emph{Since \mstrelease{1.3y} this documentation uses globally the |mlmodern|%
%
\footnote{Daniel Benjamin \textsc{Miller}, \emph{A blacker Type 1 version of Computer Modern, with multilingual
    support}, \url{https://ctan.org/pkg/mlmodern}. I have added to the preamble
  \centeredline{\texttt{\string\DeclareEncodingSubset\{TS1\}\{mlmtt\}\{0\}}}
to circumvent some \LaTeX\ complaints about \texttt{\string\textasciigrave}
(this is a widespread problem when not using default fonts)
related to occurrences of the backtick character in verbatim displays.}
 font
  package
and has added an example using the Libertinus font in type-1 format%
%
\footnote{Bob \textsc{Tennent}, \emph{Support for using Libertinus fonts with
    \LaTeX/\pdfLaTeX}, \url{https://ctan.org/pkg/libertinus-type1}.}
%
although there is an existing accompanying math font%
\footnote{Michael \textsc{Sharpe}, \emph{A Type 1 font and \LaTeX\ support for Libertinus
    Math},\\ \url{https://ctan.org/pkg/libertinust1math}. Note that it is then highly
advantageous to use \texttt{latex+dvipdfmx} and not \texttt{pdflatex} for
reasons of PDF file size.}%
.%
}

\subsection{Main options}

   \subsubsection{The \blueit{italic} option}

In the initial version \mstrelease{1.0}, the Latin letters in
mathematical mode assumed the exact same shape as in
text mode, and this meant, generally speaking, that
they would turn up upright. Doing this gives a very
uniform look to the document, so that one has to make
an effort and read it with attention, and this was
one of the design goals of \mst.

Nevertheless, soon after I posted the initial version
of the package to CTAN, I was overwhelmed by
numerous\footnote{this means ``more than one.''}
questions\footnote{I thank in particular
Tariq~\textsc{Perwez} and Kevin~\textsc{Klement} for
their kind remarks (chronological order).}  on how to
have the letters be in italic shape.

The default is still, as in version \mstrelease{1.0}, for everything to be in
upright shape, but it suffices to pass to the package the option
§italic§\RightNote{\mstrelease{1.1}} to let the Latin letters in math mode be
in italic shape.%
%
\footnote{more precisely stated, the value of \cs{itdefault}
is used.}

\subsubsection{The \blueit{frenchmath} option}

It is a variant of the §italic§ option which keeps the uppercase
Latin letters in upright shape%
%
\footnote{more precisely
stated, the value of \cs{shapedefault} is used.}.
%
Also lets the Greek letters, if
the latter are under \mst influence, be all upright, lowercase as
uppercase.


\subsubsection[The defaultmathsizes option]{The \blueit{defaultmathsizes} option}

The default sizes give for subscripts of subscripts barely legible glyphs
(author's opinion!). So \mst makes more reasonable choices. It  also
redefines \cs{Huge} and defines a \cs{HUGE} size, copied from 
the \ctanpkg{moresize} package. To cancel all of this use option
§defaultmathsizes§.

\subsubsection[The subdued option]{The \blueit{subdued} option}\label{sec:subdued}

This option was introduced in |v1.15|.\RightNote{\mstrelease{1.15}} It provides a manner to
switch on the \mst-\emph{ification} only for limited portions of
the document, with the help  of the mechanism of math versions. Without the
§subdued§ option, the \emph{mathastextification} applies by default
to the whole of the document (and one may also define additional
math versions in the preamble); with the §subdued§ option the
\emph{mathastextification} is done only in \emph{math versions} distinct from
the standard and bold ones.

Despite some limitations I will now partially describe, the §subdued§ option
has its utility, as I think is illustrated enough by the examples given at the
start of this document and it works reasonably well.

\begin{shaded*}
  \mst was not written initially in order to allow its action to
  be completely canceled. It does not store (all) mathcodes nor
  does it set them (all) when changing math versions; only that would
  allow a perfect subdued mode (and \LaTeX\ is rather obstinate in
  making that tricky or at least uneasy if sticking to its
  official interface to math mode, as it is almost entirely
  preamble only).

  Releases \mstrelease{1.3t} and \mstrelease{1.3u} do this kind of things to maintain
  usability across multiple \mst-ified math versions of characters
  which are obviously font encoding dependent such as the minus
  sign as en-dash (or unicode minus), the dotless i, the |\hbar|,
  the text accents.

  But this should be extended to all \mst-ified characters which
  basically would amount to an extensive rewrite of large legacy
  portions of the code. Currently the support for the |subdued|
  mode and to multiple math versions amounts to some kind of a
  kludge, added to an initial design which handled a single unique
  text font.
\end{shaded*}

To get the displayed math
(almost) as if \mst had not been loaded, one must also
use the option §defaultmathsizes§. But this does not quite suffice,
as, for example, the colon, the dot, and the minus sign belong
in the default \LaTeX{} math mode set-up to three distinct fonts
whereas \mst will pick (even subdued) the three of them in the same
font,%
\footnote{\RightNote{\mstrelease{1.3t}}The minus sign is now perfectly subdued,
because its original mathcode is stored and restored; this was only
way to handle the case with Unicode engines
where the math operator font is in a classic
\TeX\ encoding, but the minus sign is configured by \mst to use a Unicode
en-dash or minus character in non-subdued math versions.}
%
and although it will make a reasonable choice of this font,
this is not an exact re-installement of the previously prevailing situation. And
then other packages could have done arbitrary things regarding character
mathcodes, so to
be on the safe side one needs the §basic§ option which limits the
mathastextification to letters and digits.%
%
\footnote{\RightNote{\mstrelease{1.3d}}The §subdued§ mode does extinguish
in the normal and bold math versions the action of options §selfGreek§,
§eulergreek§, and §symbolgreek§ (previously only §LGRgreek§ was
subdue-able).}
\footnote{\RightNote{\mstrelease{1.3t}}The \texttt{\string\imath} and
\texttt{\string\jmath} now obey the subdued regime.}
\footnote{\RightNote{\mstrelease{1.3u}}Also \texttt{\string\hbar} 
and the math accents (see §mathaccents§ option) obey the subdued regime.}
%
Even then, in some circumstances, this may not suffice: for example the
\ctanpkg{euler} package declares the digits to be picked from the same font as
the Latin letters, but the subdued \mst ``normal'' math version will pick them
from the same font as used for operator names, which here with the
\ctanpkg{euler} package is the document body default text font.

\begin{snugshade}
  The §frenchmath§ option effect applies \emph{also} to the |subdued|
  ``normal'' and ``bold'' math versions.
\end{snugshade}

\subsubsection[The LGRgreek option]{The \blueit{LGRgreek} option}

  There is the issue of Greek letters. Sometimes the text font has
  Greek glyphs, in |LGR| encoding%
\footnote{For example the default CM and its replacement Latin Modern for european
  languages are (transparently to the user) extended with |LGR|
  encoded fonts from the |cbfonts| (\ctanpkg{cbgreek-complete})
  \TeX Live package.} 
 (this should be mentioned in the
  documentation of the font package). Then option §LGRgreek§ tells
  \mst to pick up these Greek letters.

It is naturally possible to leave the
  responsability to set up Greek letters to some other packages
  loaded previously to \mst. And even if \mst has been loaded with one of its
Greek related options the command §\MTstandardgreek§ will locally cancel its
customization of Greek letters.  The command §\MTcustomgreek§ reenables the
customization done by \mst, if it was loaded with the §LGRgreek§ or one of the
other Greek related options.

\begin{shaded*}
  Release \mstrelease{1.3y} has added important new aspects to the handling of Greek
  letters via the §LGRgreek§ option.  Make sure to read the \autoref{sec:newgreek}.
\end{shaded*}

\subsection{Miscellanea}

Please note that most material to be found in this section was written many
years ago (except the two subsections on §frenchmath§ on one hand and 
intervals on the other hand).  But it should still be valid!

Ultimately most information here should be moved into the
reference sections \autoref{sec:cmd} and \autoref{sec:opt}, and only some
generalities should be kept here.

\subsubsection{Load \mst always last}

The ``large'' math symbols are not modified in any way by \mst. Only loading
some math font packages such as \ctanpkg{fourier}, \ctanpkg{kpfonts}, \ctanpkg{mathabx}, \ctanpkg{mathdesign},
\ctanpkg{txfonts}, \ctanpkg{newtxmath}, \ctanpkg{libertinust1math}, others\dots{} will change them. Think of loading these
packages before \mst, else they might undo what \mst did.

More generally any package (such as \ctanpkg{amsmath}) dealing with math mode should be
loaded \emph{before} \mst.

\subsubsection{Avoid \texorpdfstring{\texttt{OT1}}{OT1} encoding}

  The default |OT1| does not have the
  {\color{joli}\DeleteShortVerb{\|}
  $\mathord{<}\,\mathord{>}\,\mathord{|}$\,\{\,\}} and
  {\color{joli}$\backslash$\MakeShortVerb{\|}} glyphs. If
  \mst detects |OT1| as the default encoding it will leave these characters to
  their defaults from the math fonts.%
%
\footnote{The §subdued§ option, described next,
  acts a bit otherwise, it forces, contrarily to its usual low-key character,
  the replacement of |OT1| by |T1| for the fonts ultimately used with letters
  and digits in math mode.}
%
\begin{shaded*}
  If \mst detects the obsolete |OT1| encoding it does not do anything with
  \DeleteShortVerb{\|}<, >, |, \{, and \} which (except for monospace fonts)
  are not available in that encoding.\MakeShortVerb{\|}
   To fully benefit from \mst it is
  recommended to use some other encoding having these glyphs such as |T1| or
  |LY1|.
\end{shaded*}


\subsubsection{Derivative, minus, asterisk}

The text characters {}'{} and  {}-{} are not used, and the asterisk is
done only optionally:
\begin{itemize}
\item the derivative sign ${}'$ is left to its default as the text font
  glyph {}'{} is not, as a rule, a satisfying alternative.%
%
\footnote{|v1.2| adds
 a customizable tiny space before ${}'$ to separate it from the previous
 letter, this is really needed when using upright letters in math mode with
 the CM derivative glyph.{\MTversion{upright}\sffamily\MTprimeskip{.5mu}%
   Compare $f'$ with \MTprimeskip{0mu}$f'$.} }

\item   for the minus sign \mst uses the endash character
  \textendash, if available, and not the hyphen character -.  With 
an OpenType font, \mst uses per default the EN DASH U+2013 (see §unicodeminus§).

\item the §asterisk§ option is required for \mst to use the text font for the
  binary infix math operator $*$ and
  the control sequence \cs{ast}.  They will use then the text asterisk
  * suitably lowered, and with the correct spaces around it as binary
  operator.
  \begin{snugshade}
    Attention that with this option, inputs such as |$R^*$| or |$R^\ast$|
    raise errors and \emph{must} be replaced by |$R^{*}$|, respectively
    |$R^{\ast}$|.
  \end{snugshade}
\end{itemize}

\subsubsection{Large symbols and delimiters}

Nothing is changed to the ``large'' math symbols, except for
$\MToriginalprod$ and $\MToriginalsum$ in inline math which, like here:
$\prod\sum$, will be taken from the Symbol Font if option §symbolmisc§
was used. 

The left and right delimiters are taken from
the text font only for the base size: any one of |\big|, |\bigl|, |\bigr|,
etc\dots will trigger the use of the original math symbols. 

\subsubsection{amsmath}
The behavior of the
  \cs{DeclareMathOperator}\RightNote{\mstrelease{1.3n}} command
  of |amsmath| is modified by \mst for it to use the correct font.
  Additionally, release \mstrelease{1.3n} of \mst at long last also handles an extra
  operation done by |amsmath| for |'.:/-*| to be used in operator names
  without the extra math spacing.%
%
\footnote{To the experts: there is a long story here that \cs{newmcodes@}
  hardcodes the font, that it was not compatible with Unicode engines, that
  during some time (2013-2016) \texttt{lualatex-math} fixed that and very
  recently |amsopn.sty 2016/03/08 v2.02| also, so now \texttt{lualatex-math
    1.6} does nothing as it is already fixed ``upstream'' in |amsopn.sty|, but
  anyhow in both cases, this still hardcoded the font, so finally \mst does
  the right thing from its point of view. See the code comments for more,
  there is an issue here with \LuaLaTeX\ not applying the curly right quote
  contrarily to \XeLaTeX.}
%
This customization is suppressed in §subdued§ mode for the |normal| and |bold|
math versions.

\subsubsection{hbar}
The default \LaTeX\ definition of §\hbar§ would in our context
  make use of the |h| of the current math font (so for us, it is also the text
  font, perhaps in italic shape), but with a bar accross the |h| from the
  original default math font for letters (usually |cmmi|). We redefine
  \cs{hbar} to use the text font macron accent (|\=|) as a mock math accent
  (this takes into account the §italic§ option and is compatible with
  subscripts and superscripts).

  Since \mstrelease{1.12} \mst when dealing with a Unicode font sets the \cs{hbar}
  to be the character from the font having hexadecimal codepoint |U+0127|.

  Since \mstrelease{1.3u} the general 8bits font encoding is
  supported\RightNote{\mstrelease{1.3u}} (see discussion of the |mathaccents| option
  at end of this list for the shared limitations). Brief testing with
  various usual \TeX\ fonts shows that the vertical positioning of
  the bar isn't satisfying. It is planned to either add a parameter to
  adjust it or to modify altogether the mode of construction of the |\hbar|.

  Use §nohbar§ to tell \mst not do provide its own |\hbar|.


\subsubsection{Dotless i and j}
By default the package redefines \cs{imath} and
  \cs{jmath} to give (in math mode) the dotless i and j (if it exists at
  all) from the text font.%

 \subsubsection{fontspec}

\fbox{\ctanpkg{fontspec}
has to be
loaded {with the option} |no-math|}, 
\emph{and before} \mst.

\subsubsection{vec accent}

The default \cs{vec} accent is not appropriate for upright letters, so \mst
provides under option §fouriervec§ a math accent control sequence
\cs{fouriervec} which takes its glyph in a Fourier font.  A poorman Ersatz
\cs{pmvec} is always available ; it is reasonably good looking on upright
letters and works with the \cs{rightarrow} glyph.

\subsubsection{math accents}
If option §mathaccents§ is used then \mst attempts to let
  the math accents |\acute|, |\grave|, etc... use the suitable glyphs from the
  text font.

  The |\vec| math accent is not handled here, as it is not available in the
  usual 8bits font encodings. See the §fouriervec§ option or the §\pmvec§
  command.

  The math accents obey the §subdued§ option\RightNote{\mstrelease{1.3u}}
  and will change in sync with the \mst-ified text font used in
  each non subdued math version.

\begin{footnotesize}
  (Very) brief testing during \mstrelease{1.3u} development with \XeTeX\ and \LuaTeX\ let
  the author conclude that usage with the \cs{Umathaccent} primitive of an
  OpenType accent glyph slot (which in the text font is for usage as a
  postpended combining character) gives definitely bad horizontal placements
  for both engines (each in its own way). Thus, the redefinitions of accents
  for a \mst declared math version with an OpenType font is by default
  canceled.%
%
\footnote{I.e., the \cs{grave} etc... control sequences will, in math versions
  with an OpenType \mst-ified font, expand to macros holding their initial
  meanings, unmodified by \mst, which was in force at the
  |\string\begin\string{document\string}|.}
%
  Use §unimathaccents§ to force usage of the OpenType font text
  accents glyph slots with the \cs{Umathaccent} primitive. Expert users are
  invited to check out the code and to contribute suggestions if some extras
  can improve it.\par
\end{footnotesize}
 

\subsubsection{Sans serif in math}

The following set-up often gives esthetically pleasing results: it is to
use the sans-serif member of the font family for math, and the serif for
text. 
\begin{verbatim}
\renewcommand\familydefault\sfdefault
\usepackage{mathastext}
\renewcommand\familydefault\rmdefault
\begin{document}
\end{verbatim}

\subsubsection{\mst with \ctanpkg{beamer}}\label{ssec:beamer}

Starting
with release |3.34| of \ctanpkg{beamer}%
%
\footnote{Till \textsc{Tantau}, Joseph \textsc{Wright}, Vedran \textsc{Mileti\'c}, \emph{A \LaTeX{} class for producing presentations and slides}, \url{https://ctan.org/pkg/beamer}.},
%
\mst is recognized as a ``math font package''.

\emph{Only with \emph{\textbf{earlier} \ctanpkg{beamer} versions} is it necessary to issue}
\centeredline{|\usefonttheme{professionalfonts}|}
\emph{in the preamble.} Example:

\begin{verbatim}
\documentclass{beamer}
%\usefonttheme{professionalfonts}% obsolete for mathastext since beamer 3.34
\usepackage{newcent}
\usepackage[scaled=.9]{helvet}
\renewcommand{\familydefault}{\rmdefault}
\usepackage[defaultmathsizes,symbolgreek]{mathastext}
\renewcommand{\familydefault}{\sfdefault}
\begin{document}
\begin{frame}
  This is some text and next comes some math: $E=mc^2$
  \[
  E=mc^2=a^n+b^n-c^n=\alpha\beta\gamma
  \]
  \begin{align}
    E&=mc^2\\
    E&=h\nu
  \end{align}
  And again some text.
\end{frame}
\end{document}
\end{verbatim}

\subsubsection{\mst with \ctanpkg{frenchmath}}\label{ssec:frenchmath}

To use \mst concurrently with the
\ctanpkg{frenchmath} package%
%
\footnote{Antoine~\textsc{Missier}, \emph{Typesetting mathematics according to French rules}, \url{https://ctan.org/pkg/frenchmath}.}
%
%
\footnote{The package \ctanpkg{mismath}
also by the Antoine~\textsc{Missier} may probably be used with \mst, but not in a fully
inter-operative way, as the two packages conflict on some aspects.  Reports
welcome, we have not tested this.}%
%
of
Antoine~\textsc{Missier}:
\begin{itemize}
\item load
\ctanpkg{frenchmath} with its option
|capsit|,
\item and load \mst afterwards (with possibly some font packages loaded in-between), passing it
  the option §frenchmath*§.
\end{itemize}

Limited testing indicated that the combination of the two packages (using the
options as indicated above) works satisfactorily. 
There may be some minor adjustments to do, as the \mst-ified math font may
cause issues to some of
the \ctanpkg{frenchmath} macros: for exemple \cs{Oijk} may not work
well simply due to the font lacking a dotless |j|, but use then
§defaultimath§.

You can either use the Greek related options of \ctanpkg{frenchmath} or those
of \mst.  Quite certainly better not to use both at same time, anyhow this has not
been tested and is not supported.

\subsubsection{Intervals and separators}

For appropriate mark-up and typesetting of intervals with conventions
about opening and closing delimiters which are not the default \TeX\ ones, one
may use
the \ctanpkg{mathtools}%
%
\footnote{Morten \textsc{Høgholm}, Lars \textsc{Madsen} and the
\textsc{\LaTeX3} project, \emph{Mathematical tools to use with amsmath},
\url{https://ctan.org/pkg/mathtools}.
As explained elsewhere in this documentation always load \mst after
\ctanpkg{mathtools}.}
%
provided \cs{DeclarePairedDelimiterX}.  For example, here is how one can
define an \cs{Ioo} macro (the letter ``o'' standing for ``open'') for typesetting an
open (in the mathematical meaning of the word) interval using square brackets:
%
\centeredline{|\DeclarePairedDelimiterX\Ioo[2]{]}{[}{#1;#2}|}
% 
Use then |$I = \Ioo{A}{B}$| type mark-up in your source, and the derived
variants |\Ioo*| or |\Ioo[\Big]| for example will also work.

\begin{footnotesize}
Note for very advanced users: if employing §\MTnonlettersobeymathxx§, our
\cs{Ioo} must be used as \cs{Ioo*} or |\Ioo[\Big]| (for example) else it
raises an error.  Alternatively, replace in the above |]| by
|{|{$\mskip2mu$}|]}| and |[| by |{[|{$\mskip2mu$}|}| and then \cs{Ioo} works
(and also |\Ioo[\Big]|).  But \cs{Ioo*} is broken.
This is a
known limitation of the §\MTnonlettersobeymathxx§ functionality, and is one
reason why \mst does not make it the default behavior.\par
\end{footnotesize}

We used in this example the semi-colon as separator.  This is seen sometimes
in contexts where the interval extremities are decimal numbers, and the
language convention is to use the comma as decimal point.  The
§binarysemicolon§ option tells \mst to configure the |;| character to use in
math mode ``binary infix operator'' type spacing, matching observed practice in some
mathematical contexts.  The §binarysemicolon§ option is executed automatically
by \mst on receiving either the §frenchmath*§ or the §frenchmath+§ options.

On the topic of the decimal point, it is recommended to use the \cs{np}
macro from the \ctanpkg{numprint}%
%
\footnote{Harald Harders, \emph{Print numbers with separators and exponent if necessary},
\url{https://ctan.org/pkg/numprint}.}
%
package with its \texttt{autolanguage} and
\texttt{np} options.  This is the best choice if one may have to also use the
same mathematical expression with numerical quantities in another language
having different conventions.

For those languages such as French where the convention is to use as decimal
separator a colon, you may alternatively pass to \mst either the
§decimalcomma§ or the §ncccomma§ options, to tell it to load the eponymous
packages \ctanpkg{decimalcomma}%
%
\footnote{Antoine~\textsc{Missier}, \emph{Comma for decimal numbers}, \url{https://ctan.org/pkg/decimalcomma}.}
%
or \ctanpkg{ncccomma}%
%
\footnote{Alexander I.~\textsc{Rozhenko}, \emph{Use comma as decimal separator in mathematics}, \url{https://ctan.org/pkg/ncccomma}.}
%
respectively, which make
the comma (to some extent) `intelligent', i.e. decide on the spacing type
(ordinary or punctuation) depending on next token.  Do not load directly the packages
but simply use the corresponding option and \mst will do the loading and take
appropriate needed measures for compatibility. The\RightNote{\mstrelease{1.3zb}} §decimalcomma§ option is
included in the §frenchmath*§ option, and the §ncccomma§
option is included in the §frenchmath+§ option.\RightNote{\mstrelease{1.3zb}}

Let's give another example of usage of \ctanpkg{mathtools} here to define a
macro for integer ranges:
%
\centeredline{|\DeclarePairedDelimiterX\Iffint[2]{\llbracket}{\rrbracket}{#1,#2}|}
%
This used control sequences \cs{llbracket} and \cs{rrbracket} from the
\ctanpkg{fourier} package (and possibly others).  A poorman definition might
be:
%
\centeredline{|\ifdefined\llbracket\else \def\llbracket{{[\![}}\fi|}
\centeredline{|\ifdefined\rrbracket\else \def\rrbracket{{]\!]}}\fi|}

Regarding open intervals in the French notation such as \texttt{]a,b[}, an
alternative avoiding usage of specific mark-up is provided by the \ctanpkg{ibrackets}%
%
\footnote{Antoine~\textsc{Missier}, \emph{Intelligent brackets}, \url{https://ctan.org/pkg/ibrackets}.}
%
package which makes the square brackets mathematically active, in the same
spirit as for the (semi) `intelligent' comma mentioned above.
Brief testing indicates this package is compatible with \mst, even when using
multiple math versions.  Read the fine print below for some limitations though.

\begin{footnotesize}
  Note for very advanced users: compatibility is only partial as the effect of
  \ctanpkg{ibrackets} is canceled after §\MTnonlettersobeymathxx§.  This is
  expected and a special compatibility layer would be needed, of the same type
  as has been done to support fully the \ctanpkg{decimalcomma} and
  \ctanpkg{ncccomma} packages via eponymous \mst options.  There is no plan at
  this time to add such a patch making the compatibility exhaustive.

  It is possible to use the §noparenthesis§ option to turn off completely the
  \mst actions on square brackets (and parentheses).\par
\end{footnotesize}

\subsubsection{Unicode engines}

\mst is minimally Unicode aware since \mstrelease{1.12} and can be used with \XeTeX{} or
\LuaTeX{}. Starting with release \mstrelease{1.3}, it needs |luatex| to be at least
as recent as the one which was provided with the TL2013 distribution.

However \mst applies only to (a subset of) the |32-127| ascii range, and
optionally to Greek letters, but for the latter only if provided via ``\TeX\
fonts'' such as Euler, Symbol or LGR-encoded fonts. 
It does not know how to use a given Unicode font simultaneously for Latin and
Greek letters. 

Thus, first consider much better alternatives:
\begin{itemize}
\item Since 2018, the package \ctanpkg{mathfont}%
%
\footnote{Conrad \textsc{Kosowsky}, \emph{Use TrueType and OpenType fonts in math mode}
\url{https://ctan.org/pkg/mathfont}.}
%
adapts Unicode text fonts to usage in math mode.  It works with both \XeTeX\
and \LuaTeX.
\item For \XeTeX\ only, \ctanpkg{mathspec}%
%
\footnote{Andrew Gilbert \textsc{Moschou}, \emph{Specify arbitrary fonts for mathematics in \XeTeX}
\url{https://ctan.org/pkg/mathspec}.}
%
also allows usage of arbitrary text fonts in mathematics.
\item and of course
\ctanpkg{unicode-math}%
%
\footnote{Will \textsc{Robertson}, et al., \emph{Unicode mathematics with
    support for XeTeX and LuaTeX} \url{https://ctan.org/pkg/unicode-math}.}
%
is the standard package for using OpenType fonts which are equipped with the needed extra
support being used in \TeX\ math mode.
\end{itemize}

If using any one of the above you probably don't need, don't want, and should
not use \mst.

Let me insist that \mst has not been tested in any systematic
manner under the Unicode engines; and that it is expected to be most definitely
incompatible with \ctanpkg{unicode-math}, although your mileage may vary and some
features may appear to work.

When using \mst with either \XeTeX{} or \LuaTeX{} it is recommended to use the
\ctanpkg{fontspec} package (see remark below on \cs{encodingdefault}).  Furthermore,
if using \ctanpkg{fontspec} it is \emph{necessary} to load it with its
|no-math| option, and this \emph{must} happen before loading \mst.
\begin{shaded*}
\begin{itemize}[label=$\bullet$, leftmargin=1em]
\item
  Use \ctanpkg{fontspec} with its
  \emph{no-math} option, and load it \emph{prior} to \mst. As some packages
  load \ctanpkg{fontspec} themselves (for example |polyglossia|), a
  \centeredline{|\PassOptionsToPackage{no-math}{fontspec}|} early in the
  preamble might be needed.

\item
  The \ctanpkg{amsmath} package, if used, \emph{must} be loaded \emph{prior} to \mst.

\item
  Under |lualatex| engine, it is recommended to also load the package
  \ctanpkg{lualatex-math}.%  Please check its documentation as possibly it has now
  % been incorporated upstream (I am not following up on the situation).
\end{itemize}
\end{shaded*}

I already mentioned in the \autoref{sec:ic} the fact that
the italic corrections were not available for OpenType fonts
under the \XeTeX{} engine and only partially available for the
\LuaTeX{} engine, with the result that the spacings in math
mode when using for the letters an upright text font will be
less satisfying than with the standard PDF\TeX{} engine (the
OpenType fonts not being usable with the latter engine, this is
not a criterion of choice anyhow).

To define math versions when using unicode fonts, use \ctanpkg{fontspec}'s
\cs{setmainfont} before the \cs{Mathastext}\oarg{version} command, or simply
before loading \mst for the default math versions.

It is possible to mix usage of Unicode fonts and classical \TeX{}
fonts. All used 8bits font encoding must have been passed as
options to the \ctanpkg{fontenc} package.

\subsubsection{The unicodeminus option}

For legacy reason, \mst uses by default the |EN DASH U+2013| for the minus
sign in math mode, if the font is determined to be a ``Unicode'' font.

There is now the §unicodeminus§\RightNote{\mstrelease{1.3q}} to use rather
% BORDEL DE BORDEL DE FAIT CHIER \verb ET Text for \verb command ended by end
% of line. je l'ai patché dans etoc et xint mais pas ici encore.
|MINUS SIGN U+2212|.%
\footnote{Thanks to Tobias~\textsc{Brink} who asked for this feature.}
%
Check \hyperref[nicodeminus]{\ttfamily\hyphenchar\font=189 its documentation}
on page \pageref{nicodeminus}.

\subsubsection{Two examples with OpenType fonts}

\begingroup\def\MacroFont{\normalfont\footnotesize\ttfamily}
I include
here two examples which compiled successfully (a long time ago!) with \XeTeX{} and
\LuaLaTeX{}, the first one on a Linux machine, the second one on a Mac
OS X machine.
\begin{verbatim}
\documentclass{article}
\usepackage[hscale=0.8]{geometry}
\usepackage{multicol}
\usepackage[no-math]{fontspec}
\usepackage{lmodern}
\usepackage[subdued,italic]{mathastext}
\setmainfont[Color=999999]{Verdana}      \Mathastext[Verdana]
\setmainfont[Color=0000FF]{Arial}        \Mathastext[Arial]
\setmainfont[Color=00FF00]{DejaVu Serif} \Mathastext[DejaVu]
\MTDeclareVersion{times}{T1}{ptm}{m}{n}
\setmainfont[Color=FF0000]{Andale Mono}  \Mathastext[Andale]
\begin{document}
\newcommand\TEST[1]{\MTversion{#1}%
\begin{multicols}{2}
\hbox to\columnwidth{\hbox to\columnwidth{\hfil
                $abcdefghijklmnopqrstuvwxyz$\hfil}\kern-2.5em{#1}}
   \centerline{ $ABCDEFGHIJKLMNOPQRSTUVWXYZ$ }
   \centerline{ $0123456789$ }
   \centerline{ $!\,?\,*\,,\,.\,:\,;\,+\,-\,=\,(\,)\,[\,]\,/\,\#\,%
   \$\,\%\,\&\,<\,>\,|\,\{\,\}\,\backslash$ }
\columnbreak
   \centerline{ abcdefghijklmnopqrstuvwxyz }
   \centerline{ ABCDEFGHIJKLMNOPQRSTUVWXYZ }
   \centerline{ 0123456789}
   \centerline{ !\,?\,*\,,\,.\,:\,;\,+\,-\,=\,(\,)\,[\,]\,/\,\#\,%
   \$\,\%\,\&\,<\,>\,|\,\{\,\}\,\char92 }
\end{multicols}}
\begin{multicols}{2} 
   \centerline{\textbf{math mode}} 
\columnbreak
   \centerline{ \textbf{text} }
\end{multicols}
\TEST{DejaVu}\TEST{Verdana}\TEST{times}\TEST{Andale}
\TEST{Arial}\TEST{bold}\TEST{normal}
\end{document}
\end{verbatim}
And now the same thing with fonts available on Mac OS X:
\begin{verbatim}
\documentclass{article}
\usepackage[hscale=0.8]{geometry}
\usepackage{multicol}
\usepackage[no-math]{fontspec}
\usepackage{lmodern}
\usepackage[subdued,italic]{mathastext}
\setmainfont[Color=FF0000]{Hoefler Text}  \Mathastext[Hoefler]
\setmainfont[Color=336633]{American Typewriter}\Mathastext[Typewriter]
\setmainfont[Color=0000FF]{Herculanum}    \Mathastext[Herculanum]
\setmainfont[Color=FF00FF]{Didot}         \Mathastext[Didot]
\setmainfont[Color=999999]{Comic Sans MS} \Mathastext[Comic]
\begin{document}
   --- copy here the code from the previous example ---
\TEST{Didot}\TEST{Comic}\TEST{normal}\TEST{Herculanum}
\TEST{Hoefler}\TEST{Typewriter}\TEST{bold}
\end{document}
\end{verbatim}
\endgroup


\subsubsection{Compatibility with other packages}\label{sec:compat}

Regarding the namespace of the package: all internal macros use
\cs{mst@} (or \cs{ifmst@} for \TeX{} conditionals) as prefix.  Almost all user
commands have \cs{MT} prefix, the oldest ones
may use \cs{Mathastext} or variants.%
%
\footnote{It is only years after initial release that I became aware that
package \ctanpkg{mathtools} used \cs{MT\string_} prefix (with an underscore as
shown) for most internal constructs, and sometimes \cs{MT@}, and those can not
clash with our \cs{MT[a-z\string|A-Z]} for public commands and \cs{mst@} for
internal macros.  They do have however user commands \cs{MTFlushSpaceAbove} and
\cs{MTFlushSpaceBelow}, but nothing else hence some retroactive relief.}

Compatibility issues are often questions of who decides last.  They are
naturally to be expected with packages dealing with the math setting.  The fix
is simply to load \mst last. In particular one should \emph{always} load \mst
\emph{after} \ctanpkg{amsmath} (this is especially needed with Unicode engines
but applies in general as well).

Any definition made in a package loaded before \mst of the font to be
used for letters or for the common characters in the |ascii| basic range
will be overruled by the loading of \mst.
Conversely most of the set-up done by \mst may well be overruled by
packages loaded later which do math related things.

Starting with version \mstrelease{1.2}, \mst makes some characters
`mathematically active' to achieve certain effects: automatic insertion of the
italic corrections when using an upright text font in math (\autoref{sec:ic}),
extended scope of the math alphabet commands which now apply to non-letter
symbols (\autoref{sec:mathxx}; and also to math operator names, but this is
much easier to achieve). And the (already mathematically active) right quote
is modified to have some extra space added before the derivative glyph ${}'$
(see §\MTprimeskip§).

This mathematical activation is compatible with the \cs{label} and \cs{ref}
commands in and outside of math mode.

But a difficulty arises when some other package has
made the character `catcode active' everywhere in the document. If it is
detected for such a character that \mst wishes to make `mathematically active'
that it is already `catcode active', \mst then checks if it is handling a Babel
shorthand.  If yes, it then hacks into \ctanpkg{babel} support macros for that
character to let it do what it desires it to do in math mode.  And it does not
make the character mathematically active, to the contrary it makes sure
that the character is \emph{not} mathematically active.

\begin{footnotesize}
  This last paragraph applies to the characters
  {{;}\,{,}\,{:}\,{!}\,{?}\,{+}\,{\textendash}\,{=}\,{<}\,{>}\,{(}\,{)}\,{[}\,{]}*}
  mentioned in \autoref{sec:mathxx} as `hard non-letters'.  The right tick
  (which is already mathematically active per default) is also handled via a
  similar process, and in particular is tested for being a Babel shorthand
  (which happens in particular with the Spanish language |activeacute| option).

  The reason for avoiding in general for a catcode active character to be at
  same time mathematically active is illustrated in next shaded box.

  In the case of the Spanish active |'|, the advantage of \mst intervention to
  reset its mathcode is that in case of a faulty input as a curly right tick
  |U+8217| ', which \LaTeX{} will map to \cs{textquoteright} which itself
  gives the catcode 12 |'|, it will show as curly quote in output not as prime
  glyph, as \mst removes its mathematical activation.  This complements the
  \LaTeX{} warnings about \cs{textquoteright} being invalid in math mode.

  The ascii letters can not have been made active by Babel interface (see code
  comments of \cs{mst@do@activecase}) so if an ascii letter is catcode active
  when \mst examines it, nothing will change to its meaning.

  \CHANGED{\mstrelease{1.4}}At \mstrelease{1.4} these actions are done for
  ascii letters at loading of the package or via \csb{MTmathactiveletters},
  which is itself done by \csb{MTversion} when entering non-subdued math
  version.  Check documentation of \csb{MTmathactiveletters} for some relevant
  details.\par
\end{footnotesize}

\begin{shaded*}
\footnotesize
On matters of \emph{mathematical} versus \emph{catcode} active character
tokens, here is some code, not involving \mst, that you should \textbf{not}
try at home:
\begin{verbatim}
    \documentclass{article}
    \usepackage[french]{babel}
    \usepackage{mathtools}\mathtoolsset{centercolon}
    \begin{document}
    $:$
    \end{document}
\end{verbatim}
\fbox{DO NOT DO THIS AT HOME}\thinspace: it creates (with |pdflatex|) an infinite
loop.
% %
% \footnote{This seems to still be the case with Babel |3.9f| and
%   frenchb.ldf |2.6e|, as tested on Sep. 2, 2013. Again tested with up-to-date
%   TL2015 Jan. 15, 2016 with same result. Again tested July 11, 2024 with
% up-to-date TL2024 with the
% same result.}
% %
This is due
to the fact that the colon is simultaneously active (this is made by
\ctanpkg{babel-french} at begin document) and mathematically active (done by
\ctanpkg{mathtools} in the preamble). The interaction gives an infinite loop.
%
%  Such a
% situation will be cured by \mst, even loaded before \ctanpkg{mathtools},
% \emph{if} use is made of §\MTnonlettersobeymathxx§.
%
%  At each math formula
% \mst will detect that Babel has activated the colon, and will cancel the
% mathematical activation (the precise definition done by \ctanpkg{mathtools} was
% already lost at begin document due to overwriting by \ctanpkg{babel} but the fact that
% the character was mathematically active remained true).
\par
\end{shaded*}


  Regarding mathematical activation,  an incompatibility of
  another type arose with \ctanpkg{amsmath}.  To fix it, \mst now replaces
  an inner macro of \ctanpkg{amsmath}
  (\cs{resetMathstrut@}) with its own version.\\
  \null\hspace{1cm}\fbox{Always load \ctanpkg{amsmath} before \mst.}

\begin{footnotesize}
  Actually this last commandment was already made necessary by the use of the
  text endash to represent the minus sign in math mode, and, especially for
  Unicode engines, some aspects of the \cs{DeclareMathOperator} macro from
  \ctanpkg{amsmath}.\par
\end{footnotesize}



    \begin{shaded*}
      \textcolor{magenta}{\bfseries New with 1.3i:} \mst patches |\url| of
      packages \ctanpkg{url} and \ctanpkg{hyperref}, and also |\nolinkurl|, to force them
      to do automatically §\MTeverymathoff§. Indeed they use math mode, and it
      is better to turn \mst off for their dealings.

      See the §\MTeverymathoff§ documentation.
    \end{shaded*}
   


\subsection{Math alphabets}

Let us first recall fundamental facts of life, in the
  world of traditional PDF\TeX\ engine and \TeX\ fonts, as background for
  understanding what \mst does in this context.
  People familiar with using Unicode engines and \ctanpkg{unicode-math}, please be
  aware that the semantics there of the \LaTeX\ math alphabet commands are
  \textbf{significantly} modified!
\begin{shaded*}
\begin{itemize}
\item In the default \LaTeX\ set-up all five of §\mathrm§, §\mathbf§,
  §\mathit§, §\mathsf§ and §\mathtt§ tell \TeX\ to use for their arguments
  specific \texttt{OT1}-encoded fonts.
\item If the document body uses, as will be the case probably with any
  language other than English or its variants, some other encoding such as
  \texttt{T1} for its fonts, there is no change whatsoever to the math
  configuration, indeed most font packages ignore it completely.
\item It is thus a priori wrong to think of these commands as switching to
  some body text font, although letters within their scopes will act as in a
  text font, and in particular obey ligatures (this also applies to operator
  names defined by |amsmath|'s \cs{DeclareMathOperator} which are, with some
  extras not mentioned here, as using §\mathrm§).
\item These commands are completely different in spirit from the \LaTeX\
  \cs{textrm}, \cs{textbf}, and others, which change only some font axis;
  indeed the math alphabet commands inherit from legacy Knuth's \cs{rm},
  \cs{bf}, and others which are complete font specifiers.
\item In particular when nesting, it is the inner-most which wins.
\item Only mathematical characters (such as letters) which are declared to
  \TeX\ as being of ``variable family type'' react to being in the argument of
  a math alphabet command.
\item Lowercase Greek letters are by default in \LaTeX\ immune to math
  alphabets (so \verb|\mathrm{\pi}| induces no change in output), but the
  eleven uppercase Greek letters are of ``variable family type'' because they
  are picked in the \texttt{OT1}-encoded font also used for operator names
  (the one to which §\mathrm§ maps), \emph{and they occupy the exact same
    slots in the \emph{\texttt{OML}}-encoding to which} §\mathnormal§ maps! So
  in default \TeX, \verb|\mathnormal{\Gamma}| gives a slanted glyph. The slots
  occupied in \texttt{OML}-encoding by the lowercase Greek letters (to which
  encoding they are a priori assigned) give
  completely unrelated glyphs in the \texttt{OT1}-encoding, so it makes sense
  that the default \LaTeX\ declares lowercase Greek to not react to math alphabets.
  Notice though, that if \LaTeX\ had declared a \cs{mathnormalbold}, mapping
  to a bold \texttt{OML}-encoded font, it would have made sense to also have
  \cs{alpha}, \cs{beta}, etc... be of ``variable family type''.
\item But of course even if |\pi| is of such ``variable family type'' then
  |\mathbf{\pi}| will give garbage because the default §\mathbf§ selects an
  \texttt{OT1}-encoded font, where there is no pi glyph whatsoever and in
  particular not at the slot (which is 25) of $\pi$ in the \texttt{OML} encoding!
\end{itemize}
\end{shaded*}

Please keep all the above in mind when trying to understand what \mst does
with math alphabets.  The most significant point described next naturally is that
\mst will sync §\mathnormal§, §\mathrm§, §\mathbf§, §\mathit§, §\mathsf§ and
§\mathtt§ to map to the \mst-ified body text fonts.
  \begin{itemize}
  \item §\mathnormal§, §\mathrm§, §\mathbf§, §\mathit§,
    §\mathsf§ and §\mathtt§ are modified to use the \mst-ified
    text fonts; this can be disabled via §defaultalphabets§ and
    related individual options, but the package always provides
    §\Mathnormal§, §\Mathrm§, etc..., to match the \mst font
    configuration (\RLNote{changed:}{\mstrelease{1.3za}}prior to \mstrelease{1.3za}
    §defaultalphabets§ and related options also caused the \mst
    alphabet commands not to be defined).  Recall that there may
    arise a ``too many math alphabets'' error if too many of these
    commands are \emph{used} in the document: 
    \emph{declaring} them is not by itself the cause of the error.  See the
    \LaTeX\ news entry of its \texttt{2021-11-15} release for
    the counter \texttt{localmathalphabets} (with default value 2)
    which can be now be used if one hits such a difficulty.
  \item We define a new math alphabet command
    §\mathnormalbold§ which gives direct access to
    the bold version of the §\mathnormal§ alphabet
    (rather than using either the \cs{bm} command from
    the \ctanpkg{bm} package or the \cs{boldsymbol} command
    from the \ctanpkg{amsbsy} package). As it does not
    exist in the default \LaTeX{} math font set-up, this
    alphabet is \emph{not} subjected to the {subdued option} action.

\item Version \RightNote{\mstrelease{1.2}}\mstrelease{1.2} of \mst has extended the scope of the math
  alphabets to apply to non-alphabetical characters and to
  operator names. This respects the automatic white spaces
  added by \TeX{} around math symbols.  See the devoted \autoref{sec:mathxx}.
\item The optional\RightNote{\mstrelease{1.3i}}
  extra skips around letters (see \autoref{sec:mathskips} and
  \autoref{sec:ic}) are removed in the scope of the math alphabets.

  \item Depending on options, further math alphabet commands
    are defined by the package: §\MathEulerBold§,
    §\MathEuler§, §\MathPSymbol§, and since \mstrelease{1.3y} under
    the §LGRgreek§ family of options\RightNote{\mstrelease{1.3y}} also
    §\mathgreekup§ and §\mathgreekit§.  See
    \autoref{sec:newgreek}.  And also §\mathgreekupbold§ and
    §\mathgreekitbold§ under the §LGRgreek§ family of
    options.\RightNote{\mstrelease{1.3za}}

  \item With\RightNote{\mstrelease{1.3za}} the §LGRgreek+§ option
    which enhances Greek letters with a specific behavior when in the
    arguments of the §\mathrm§, §\mathbf§, etc..., math alphabet
    commands, this special behavior is not triggered by the §\Mathrm§,
    §\Mathbf§, et al., which are genuine unmodifed math alphabet commands.  See
    \autoref{sec:newgreekplus}.
  \end{itemize}


\subsection{Math versions}\label{sec:mathversions}

\LaTeX{} has the concept of \emph{math versions}%
%
\footnote{|math versions| are discussed in the document
|fntguide.pdf| from your \TeX{} distribution.}%
%
, but most font packages
do not define any such version beyond the default normal and bold (the
package \ctanpkg{unicode-math} for unicode engines does use this concept).

\mst extends the concept of math versions in order to allow the math mode
fonts (for letters, digits, punctuation and a few other ascii symbols) used in
the different parts of the document to be kept in sync with the text
fonts.

Most math symbols (sums, products, integrals, logical signs,
etc\dots) are kept the same throughout the document though as it is not in
\mst power to modify them.

For examples see the earlier \autoref{sec:examples}.  The interface to define
a |math version| includes the commands §\Mathastext§ and
§\MTDeclareVersion§.

Once such a |math versions| has been defined in the preamble,
§\MTversion§|{name_of_version}|, or equivalently
§\Mathastextversion§|{name_of_version}|, enacts the font switches when
encountered in the body of the document. As is usual with \LaTeX{} one can
limit the scope to inside a group, or also switch back to the main
set-up via \cs{Mathastextversion\{normal\}}.

When §\Mathastext§ is used in the preamble, it records the current text font
defaults (\cs{familydefault} et al.\@ or what has been configured by
§\MTfamily§ and similar commands) and (except for the |normal| and |bold|
versions if in §subdued§ regime) sets up \emph{both} the math font and the
text font in the defined \mst-math version to be this text font.
%
It is still possible to switch on via §\MTversion§ in the document body
  distinct fonts for text and math: an optional argument (the name of another
  \mst-declared math version) to \cs{MTversion} is allowed (such as for
  example \cs{MTversion[newcent]\{helvet\}} for one of the examples of the
  \autoref{sec:examples}). It instructs to use as text font the font which was
  configured to be used in this second \mst-math version.%
%
\footnote{When not using math versions at all (so not using \texttt{subdued}
mode either) another way to achieve distinct fonts in text and math is
naturally to modify the document text font \emph{after} having loaded \mst (or
after last usage of \csb{Mathastext} without optional argument).
Another way is to use \csb{MTfamily}, \csb{MTencoding}, \csb{MTseries},
\csb{MTshape}, \csb{MTlettershape} in the preamble before a call to
\csb{Mathastext} which will configure math fonts without having modified the
document text fonts.  However if one does \texttt{\string\MTversion\{normal\}}
in the document then the text font will be reset to what was recorded as math
font by the \csb{Mathastext} call in the preamble (as said above, when not
using \texttt{subdued} option).}

The native \LaTeX{} command \cs{mathversion}\marg{version\_name} would change
only the fonts for the math mode, not the text mode fonts. It is important to
use rather the package command \csb{MTversion} (or one of its synonyms
\cs{mathastextversion}, \cs{Mathastextversion}, \cs{MTVersion}), with its
mandatory argument \marg{version\_name}, as it does additional actions:
\begin{itemize}
\item it sets the font for math mode (letters, math operator names, digits,
  punctuations, some other symbols) according to the version name given as
  mandatory argument,
\item it resets the text font of the document and the
  |\(family,rm,sf,...)default|s to their values as registered at the time of
  definition of the version. \emph{Use the starred variant in case this is not
    desired.} As explained above tt is possible to specify within brackets an extra optional
  version name, and the text font will be set according to it.
\end{itemize}
For all math versions if not using the §subdued§ option, or only
for the non-\emph{normal} and non-\emph{bold} math versions if
using the §subdued§ option, \cs{MTversion} does further additional tasks:
\begin{itemize}
\item it resets\RightNote{\mstrelease{1.3u}} the §\hbar§, \cs{imath}
  (see §\inodot§), \cs{jmath}, math accents (see option
  §mathaccents§) and minus sign as en dash according to the used
  font encoding for the \mst-ified text font,
\item (see \autoref{sec:mathskips} and \autoref{sec:ic}) it re-issues the
  command §\MTmathactiveletters§ to let a to z, A to Z, be mathematically
  active in order to automatically insert the skips as defined by the user
  with §\MTsetmathskips§, and the italic corrections (if the font is not
  italic or slanted),
\item (see \autoref{sec:extraskips}) it resets the extra spaces after the
  symbols $\exists$, $\forall$ and before the derivative ${}'$ to the values as
  decided by the user in the preamble on a \emph{per version} basis,
\item (see \autoref{sec:mathxx}) it re-issues the commands
  §\MTmathoperatorsobeymathxx§ and §\MTeasynonlettersobeymathxx§  to let
  the math operator names and (`easy') non letter characters obey the math
  alphabets,
\item in case of option §asterisk§, it re-issues §\MTactiveasterisk§,
\item it does the additional set-up for Greek letters in case of the package
  received one of the Greek related options.
\end{itemize}
The scope is limited to the current \LaTeX{}
environment or group.


It is sometimes not compatible with \mst to load a font package after it, as the
font package may contain instructions which will modify the math set-up. This
may be a bit hidden to the user: for example the \ctanpkg{epigrafica} package loads
|pxfonts|. Hence it will interfere with \mst if it is loaded after
it.\footnote{may typically give a `too many math alphabets' error message.} But
one can use instead |\renewcommand{\rmdefault}{epigrafica}|,\footnote{sometimes
  one needs to look in the |.sty| file of the font package to figure out the
  font name (it is rarely as here with \ctanpkg{epigrafica}, the same as the package name), and,
  if one does not know the arcanes of finding |.fd| files in one's \TeX{}
  distribution, one should look at the log file of a test document to see if for
  example |T1| is available for that font; for |epigrafica| it is not, only
  |OT1| and |LGR| are possible.} followed with \cs{Mathastext}, or also
|\MTfamily{epigrafica}\Mathastext| which will only change the font in math.

To use |epigrafica| for Greek in math mode one can use the
package option §LGRgreek§ and the command
|\MTgreekfont{epigrafica}\Mathastext|. Or
\cs{usepackage}|{epigrafica}| followed with
|\usepackage[LGRgreek]{mathastext}|.

\subsection{Greek letters}

\subsubsection{The Greek-related options}

The Computer Modern fonts are very light and thin in comparison
to many text fonts, and as a result rarely mix
well with them (particularly if the Latin letters in
math mode are upright). The following options are
provided by \mst:
\begin{description}
\item[no option:] nothing is done by the
  package, Greek letters are the default Computer
  Modern ones or have been set-up by other packages;
  for example by the \ctanpkg{fourier} package with option
  `upright', which gives upright Greek letters
  or by the author \ctanpkg{lgrmath} package.
\item[§LGRgreek§:] (this was substantially updated at \mstrelease{1.3y}, make sure to
  read the new documentation at \autoref{sec:newgreek})
  this option is for fonts which additionally to Latin
  letters also provide Greek letters in |LGR| encoding. Here is
  a list from a 2012 standard \TeX{} installation: the Computer
  Modern, Latin Modern, and the CM-LGC fonts; the Greek Font
  Society fonts (such as GFS Didot), the epigrafica and kerkis
  packages, the txfontsb package which extends the txfonts
  package with LGR-encoded Greek letters; the Droid fonts, the
  DejaVu fonts, the Comfortaa font, and the Open Sans font. The
  |LGR| encoded |CM/LM| fonts (in serif, sans-serif and typewriter
  family) give the nice Greek letters in upright shape from the
  \ctanpkg{cbfonts} package. To get these letters in your \mst math
  mode, you can do the following:
\begin{verbatim}
% instructions to load the document fonts:
\usepackage{nice_font}
% and then the following:
\renewcommand{\familydefault}{cmr} % or cmss or cmtt for sans resp. mono
\usepackage[LGRgreek]{mathastext}
\renewcommand{\familydefault}{\rmdefault} 
\Mathastext % this re-initializes mathastext with the nice_font,
% without changing the LGR font cmr/cmss/cmtt used for Greek letters
% in math mode.
\begin{document}
\end{verbatim}
 If you use the §italic§ option note that the italic Greek
 letters from the |cbfonts| are not the same glyphs as 
  the default Greek letters from the |OML| encoded font |cmmi|.
\item[§LGRgreek+§:] \RightNote{\mstrelease{1.3za}}extends §LGRgreek§ to allow abusive
  usage of \cs{mathrm} and alike commands with Greek letters.
  This is very much not in the spirit (especially with traditional
  ``8bit'' \TeX\ fonts) of the \LaTeX\ kernel concept of math alphabet
  commands. Check \autoref{sec:newgreekplus} for
  relevant information.
\item[§eulergreek§:] the Greek letters will be taken from the Euler font (the
  document does not have to load the eulervm package, \mst directly uses
  some file included in this package, as it provides a mechanism to scale
  by an arbitrary factor the Euler font.) The letters are upright.
\item[§symbolgreek§:] the Greek letters will be taken
  from the (Adobe Postscript) Symbol font. A command is provided
  so that the user can scale the Symbol font to let it
  better fit with the text font. The letters are upright.
\item[§selfGreek§:] this option concerns only the eleven Greek
  capitals from the |OT1|-encoding. It does nothing for the
  lowercase Greek letters. The encoding used in the document does
  not have to be |OT1|.
\end{description}

There is also §LGRgreeks§ (and §LGRgreeks+§) which tells \mst to
pick up in each math version the letters from the |LGR| encoded
font used in that version, and §selfGreeks§ to tell \mst to do
as for §selfGreek§ but separately in all math versions.

Under the §subdued§ option the Greek letters in the normal and bold math
versions are kept to their defaults as found at the time of loading the
package. 

The commands §\MTstandardgreek§  allow at any point
in the document to turn inactive any Greek related option passed to \mst. And
conversely §\MTcustomgreek§ reactivates it.


\subsubsection{Shape of Greek letters}

Classic \TeX{} uses in math mode italic lowercase and
upright uppercase Greek letters. French typography uses
upright shape for both lowercase and uppercase. And the
ISO standard is to use italic shape for both lowercase
and uppercase.

The Euler and Symbol fonts not being available in other than their
default upright shape, this question of shapes for Greek letters
raises issues only in the case of the options §LGRgreek§ and
§selfGreek§.

The options §frenchmath§, §itgreek§, §upgreek§, §itGreek§ and §upGreek§
modify the Greek letter shapes according to the following rules, listed
from the lowest to the highest priority:
\begin{description}
\item[no option:] the lowercase Greek letters are in the same shape as
  Latin letters, and the uppercase in the same shape as is applied to digits
  and operator names,
\item[§frenchmath§:] both lowercase and uppercase are in the same shape as
  the digits and operator names (most of the time this means ``upright
  shape'', but it can be otherwise),
\item[§itgreek§]: says that Greek letters (both lowercase and uppercase) will
  be in `|it|' shape. \RLNote{changed:}{\mstrelease{1.3y}}More precisely the expansion of
  §\MTgreekitdefault§ is used.

  This was changed at \mstrelease{1.3y}, formerly the value of \cs{itdefault} which was in
  force at the time of using §\Mathastext§ (or at time of loading the package
  if no use is made of §\Mathastext§) was used.
\item[§upgreek§]:  says that Greek letters (both lowercase and uppercase) will
  be in `|n|' shape. \RLNote{changed:}{\mstrelease{1.3y}}More precisely the expansion of
  §\MTgreekupdefault§ is used.

  This was changed at \mstrelease{1.3y}, formerly the value of \cs{updefault} which was in
  force at the time of using §\Mathastext§ (or at time of loading the package
  if no use is made of §\Mathastext§) was used.  But since \LaTeX{}
  |2020-02-02| this caused many Font Warnings in the log because
  \cs{updefault} is now `|up|', not `|n|' as formerly.
\item[§itGreek§, §upGreek§:] same but they apply only to the uppercase Greek
  letters.  Their effect is computed after having taken into account either
  §itgreek§ or §upgreek§ presence.
\end{description}

So, the default gives the classic \TeX{} behavior when option §italic§
was passed.

As mentioned already the package allows to define various ``math
versions''.  There are commands to be used inside the preamble to
influence the shapes, and even the font, used for Greek letters
in each given \mst-declared math version: §\MTitgreek§,
§\MTupgreek§, §\MTitGreek§, §\MTupGreek§ and
§\MTgreekfont§|{name_of_font}|.

Their effect is as the options of the alike name, except that
the effect applies only to \mst-math versions declared
\emph{next} in the preamble (be it via §\Mathastext§ or
§\MTDeclareVersion§).

To use §\MTgreekfont§ you need to know the name of a suitable
font family available in |LGR| encoding: for example |lmr|,
|txr| (needs \ctanpkg{txfontsb} package on your system),
|DejaVuSerif-TLF| (needs \ctanpkg{dejavu} package on your system),
etc\dots

\begin{shaded*}
  §\MTitgreek§, §\MTupgreek§, §\MTitGreek§, §\MTupGreek§
  have some effect only if one of the §LGRgreek§, §LGRgreeks§,
  §selfGreek§ or §selfGreeks§ options was passed to the package.

  Once any of these commands has been made use of, changes in the shape
  configuration of the Latin letters will stop having any influence on the
  shape of the Greek letters.

  §\MTgreekfont§ has an effect only for §LGRgreek§ and §selfGreek§.  It is
  without any effect with §LGRgreeks§ and §selfGreeks§.
\end{shaded*}


\subsubsection{Control sequences to access directly upright or italic
  shape for Greek under \texttt{LGRgreek} option}
\label{sec:newgreek}

Some changes were made at \mstrelease{1.3y} to enhance the §LGRgreek§ (and §LGRgreeks§)
options with new features.  Everything which will be explained here applies
only to these two options.

First of all the package now makes available control sequences to access
either the upright or italic shape of the Greek letters: \cs{alphaup},
\cs{alphait}, etc...%
%
\footnote{No check is done of pre-existing such math symbol, they will be
  replaced by the \mst definition with no warning.  If they happen to be
  pre-defined as \LaTeX\ commands, not as math symbols, errors will happen
  during the loading of \mst.}
%
Which shape is meant by `up' or `it' is configured via defining
§\MTgreekupdefault§ and §\MTgreekitdefault§ respectively prior a §\Mathastext§
command in the preamble (possibly with \oarg{version\_name} optional
argument).  Their default definitions are to expand to `|n|' and `|it|'
respectively.  They can also be defined prior to loading \mst.

See\RightNote{\mstrelease{1.3y}} the \autoref{table:greekup} and \autoref{table:greekit}
for illustrations (using here the Libertinus Serif font).
\begin{table}[htbp]
\MTversion{libertinus}
\begin{framed}
\begin{multicols}{4}
\noindent
\string\Alphaup\ $\Alphaup$\\
\string\Betaup\ $\Betaup$\\
\string\Gammaup\ $\Gammaup$\\
\string\Deltaup\ $\Deltaup$\\
\string\Epsilonup\ $\Epsilonup$\\
\string\Zetaup\ $\Zetaup$\\
\string\Etaup\ $\Etaup$\\
\string\Thetaup\ $\Thetaup$\\
\string\Iotaup\ $\Iotaup$\\
\string\Kappaup\ $\Kappaup$\\
\string\Lambdaup\ $\Lambdaup$\\
\string\Muup\ $\Muup$\\
\string\Nuup\ $\Nuup$\\
\string\Xiup\ $\Xiup$\\
\string\Omicronup\ $\Omicronup$\\
\string\Piup\ $\Piup$\\
\string\Rhoup\ $\Rhoup$\\
\string\Sigmaup\ $\Sigmaup$\\
\string\Tauup\ $\Tauup$\\
\string\Upsilonup\ $\Upsilonup$\\
\string\Phiup\ $\Phiup$\\
\string\Chiup\ $\Chiup$\\
\string\Psiup\ $\Psiup$\\
\string\Omegaup\ $\Omegaup$\\
\string\Digammaup\ $\Digammaup$\\
% \columnbreak ne fonctionne pas comme espéré
\mbox{}\\
\string\alphaup\ $\alphaup$\\
\string\betaup\ $\betaup$\\
\string\gammaup\ $\gammaup$\\
\string\deltaup\ $\deltaup$\\
\string\epsilonup\ $\epsilonup$\\
\string\zetaup\ $\zetaup$\\
\string\etaup\ $\etaup$\\
\string\thetaup\ $\thetaup$\\
\string\iotaup\ $\iotaup$\\
\string\kappaup\ $\kappaup$\\
\string\lambdaup\ $\lambdaup$\\
\string\muup\ $\muup$\\
\string\nuup\ $\nuup$\\
\string\xiup\ $\xiup$\\
\string\omicronup\ $\omicronup$\\
\string\piup\ $\piup$\\
\string\rhoup\ $\rhoup$\\
\string\sigmaup\ $\sigmaup$\\
\string\tauup\ $\tauup$\\
\string\upsilonup\ $\upsilonup$\\
\string\phiup\ $\phiup$\\
\string\chiup\ $\chiup$\\
\string\psiup\ $\psiup$\\
\string\omegaup\ $\omegaup$\\
\string\digammaup\ $\digammaup$\\
\string\varsigmaup\ $\varsigmaup$
\end{multicols}
\end{framed}
% il y a bien sûr d'horribles espacement verticaux typiques de LaTeX
\vspace*{-\baselineskip}
\caption{Greek letters via `up' control sequences (math mode only)}
\label{table:greekup}
\end{table}
\begin{table}[htbp]
\MTversion{libertinus}
\begin{framed}
\begin{multicols}{4}
\noindent
\string\Alphait\ $\Alphait$\\
\string\Betait\ $\Betait$\\
\string\Gammait\ $\Gammait$\\
\string\Deltait\ $\Deltait$\\
\string\Epsilonit\ $\Epsilonit$\\
\string\Zetait\ $\Zetait$\\
\string\Etait\ $\Etait$\\
\string\Thetait\ $\Thetait$\\
\string\Iotait\ $\Iotait$\\
\string\Kappait\ $\Kappait$\\
\string\Lambdait\ $\Lambdait$\\
\string\Muit\ $\Muit$\\
\string\Nuit\ $\Nuit$\\
\string\Xiit\ $\Xiit$\\
\string\Omicronit\ $\Omicronit$\\
\string\Piit\ $\Piit$\\
\string\Rhoit\ $\Rhoit$\\
\string\Sigmait\ $\Sigmait$\\
\string\Tauit\ $\Tauit$\\
\string\Upsilonit\ $\Upsilonit$\\
\string\Phiit\ $\Phiit$\\
\string\Chiit\ $\Chiit$\\
\string\Psiit\ $\Psiit$\\
\string\Omegait\ $\Omegait$\\
\string\Digammait\ $\Digammait$\\
% \columnbreak ne fonctionne pas comme espéré
\mbox{}\\
\string\alphait\ $\alphait$\\
\string\betait\ $\betait$\\
\string\gammait\ $\gammait$\\
\string\deltait\ $\deltait$\\
\string\epsilonit\ $\epsilonit$\\
\string\zetait\ $\zetait$\\
\string\etait\ $\etait$\\
\string\thetait\ $\thetait$\\
\string\iotait\ $\iotait$\\
\string\kappait\ $\kappait$\\
\string\lambdait\ $\lambdait$\\
\string\muit\ $\muit$\\
\string\nuit\ $\nuit$\\
\string\xiit\ $\xiit$\\
\string\omicronit\ $\omicronit$\\
\string\piit\ $\piit$\\
\string\rhoit\ $\rhoit$\\
\string\sigmait\ $\sigmait$\\
\string\tauit\ $\tauit$\\
\string\upsilonit\ $\upsilonit$\\
\string\phiit\ $\phiit$\\
\string\chiit\ $\chiit$\\
\string\psiit\ $\psiit$\\
\string\omegait\ $\omegait$\\
\string\digammait\ $\digammait$\\
\string\varsigmait\ $\varsigmait$
\end{multicols}
\end{framed}
% il y a bien sûr d'horribles espacement verticaux typiques de LaTeX
\vspace*{-\baselineskip}
\caption{Greek letters via `it' control sequences (math mode only)}
\label{table:greekit}
\end{table}

The regular control sequences without `|up|' or `|it|' postfix will map to
either one of the two versions according to how the shapes were configured,
i.e.\@ in almost all cases via usage of either the §itgreek§, §upgreek§,
etc\dots\ options or §\MTitgreek§ et al.\@ commands.  This is on a per \mst-enriched
math version basis, depending only on how the options or commands were used
in the preamble.

Furthermore\RightNote{\mstrelease{1.3y}} two math alphabets are provided
\centeredline{§\mathgreekup§}
\centeredline{§\mathgreekit§}
which can be used to map a letter to the corresponding Greek fonts:
{\MTversion{libertinus}
\centeredline{|$\mathgreekup{a}=\mathgreekup{\alpha}=\mathgreekup{\alphait}=\alphaup$|}
\centeredline{$\mathgreekup{a}=\mathgreekup{\alpha}=\mathgreekup{\alphait}=\alphaup$}
\centeredline{|$\mathgreekup{G}=\mathgreekup{\Gamma}=\mathgreekup{\Gammait}=\Gammaup$|}
\centeredline{$\mathgreekup{G}=\mathgreekup{\Gamma}=\mathgreekup{\Gammait}=\Gammaup$}
\centeredline{|$\mathgreekit{z}=\mathgreekit{\zeta}=\mathgreekit{\zetaup}=\zetait$|}
\centeredline{$\mathgreekit{z}=\mathgreekit{\zeta}=\mathgreekit{\zetaup}=\zetait$}
\centeredline{|$\mathgreekit{W}=\mathgreekit{\Omega}=\mathgreekit{\Omegaup}=\Omegait$|}
\centeredline{$\mathgreekit{W}=\mathgreekit{\Omega}=\mathgreekit{\Omegaup}=\Omegait$}
}

Some\RightNote{\mstrelease{1.3y}} refactoring%
%
\footnote{Technically, formerly two symbol fonts were declared, one for the
  lowercase Greek letters and one for the uppercase Greek letters; now those
  are dropped and replaced by two symbol fonts, one for `italic' Greek letters,
  the other for `upright' Greek letters.}
%
was required to achieve this at \mstrelease{1.3y}
and it is not 100\% backwards compatible: if none of the §itgreek§ etc\dots\
things was used, the Greek letters formerly would follow the shape of Latin
letters (for lowercase Greek) and of operator names (for uppercase Greek).
Now, some check is made for each of these two shapes whether it is `|it|' or
`|sl|' and then the `italic' shape, i.e.\@ §\MTgreekitdefault§
which by default is `|it|' (without the quotes) is used, else the `upright'
shape, i.e.\@ §\MTgreekupdefault§ which by default expands to `|n|'
(without the quotes) is used.  Naturally these checks are
done on a per \mst-math version basis, if multiple math versions are used.

So for example those who used some adventurous `|sc|' for the main shape (the
one used per default for operator names) and used the option §LGRgreek§ but
none of the §itgreek§ et al.\@ options, and none of the §\MTitgreek§ et
al.\@ commands, now will need to adjust §\MTgreekupdefault§ to expand to
`|sc|' prior to some §\Mathastext§ or §\Mathastext§\oarg{version\_name} or
§\MTDeclareVersion§ in the preamble depending on context.

It is hoped most documents, even those using multiple math versions, which
made use of the §LGRgreek§ (or §LGRgreeks§) option will simply produce
unmodified output.  Please report to the author unexpected results not fitting
the above attempted description of the only partial backwards
compatibility.


\subsubsection{\cs{mathgreekupbold} and \cs{mathgreekitbold}}
\label{sec:newgreekbold}

Again this applies only to §LGRgreek§ and §LGRgreeks§ options (and the \mstrelease{1.3za}
added §LGRgreek+§ and §LGRgreeks+§).

See\RightNote{\mstrelease{1.3za}} the \autoref{table:greekupbold} and \autoref{table:greekitbold}
for illustration of usage (in math mode only) of code such as
\begin{verbatim}
    \mathgreekupbold{\alpha}
or  \mathgreekitbold{\alpha}
\end{verbatim}
Note that all three of  \cs{alpha}, \cs{alphaup} and \cs{alphait}
would give the same output. 
These two tables again use the
Libertinus Serif font via an \mst math version which was
configured in the preamble using this set-up (and the package §LGRgreek§
option):
\begin{verbatim}
\MTfamily{LibertinusSerif-TLF}
\MTlettershape{n}
\MTseries{m}
\MTgreekfont{LibertinusSerif-TLF}
\MTupgreek
\Mathastext[libertinus]
\end{verbatim}
Some examples here to illustrate the effet of the math alphabet
commands on Latin letters also:
{%\MTversion{libertinus}
\centeredline{|$\mathgreekupbold{a}=\mathgreekupbold{\alpha}$|}
\centeredline{\MTversion{libertinus}$\mathgreekupbold{a}=\mathgreekupbold{\alpha}$}
\centeredline{|$\mathgreekupbold{G}=\mathgreekupbold{\Gamma}$|}
\centeredline{\MTversion{libertinus}$\mathgreekupbold{G}=\mathgreekupbold{\Gamma}$}
\centeredline{|$\mathgreekitbold{z}=\mathgreekitbold{\zeta}$|}
\centeredline{\MTversion{libertinus}$\mathgreekitbold{z}=\mathgreekitbold{\zeta}$}
\centeredline{|$\mathgreekitbold{W}=\mathgreekitbold{\Omega}$|}
\centeredline{\MTversion{libertinus}$\mathgreekitbold{W}=\mathgreekitbold{\Omega}$}
}

\begin{table}[htbp]
\MTversion{libertinus}
\begin{framed}
\begin{multicols}{4}
\noindent
\string\Alpha\ $\rightarrow\mathgreekupbold{\Alpha}$\\
\string\Beta\ $\rightarrow\mathgreekupbold{\Beta}$\\
\string\Gamma\ $\rightarrow\mathgreekupbold{\Gamma}$\\
\string\Delta\ $\rightarrow\mathgreekupbold{\Delta}$\\
\string\Epsilon\ $\rightarrow\mathgreekupbold{\Epsilon}$\\
\string\Zeta\ $\rightarrow\mathgreekupbold{\Zeta}$\\
\string\Eta\ $\rightarrow\mathgreekupbold{\Eta}$\\
\string\Theta\ $\rightarrow\mathgreekupbold{\Theta}$\\
\string\Iota\ $\rightarrow\mathgreekupbold{\Iota}$\\
\string\Kappa\ $\rightarrow\mathgreekupbold{\Kappa}$\\
\string\Lambda\ $\rightarrow\mathgreekupbold{\Lambda}$\\
\string\Mu\ $\rightarrow\mathgreekupbold{\Mu}$\\
\string\Nu\ $\rightarrow\mathgreekupbold{\Nu}$\\
\string\Xi\ $\rightarrow\mathgreekupbold{\Xi}$\\
\string\Omicron\ $\rightarrow\mathgreekupbold{\Omicron}$\\
\string\Pi\ $\rightarrow\mathgreekupbold{\Pi}$\\
\string\Rho\ $\rightarrow\mathgreekupbold{\Rho}$\\
\string\Sigma\ $\rightarrow\mathgreekupbold{\Sigma}$\\
\string\Tau\ $\rightarrow\mathgreekupbold{\Tau}$\\
\string\Upsilon\ $\rightarrow\mathgreekupbold{\Upsilon}$\\
\string\Phi\ $\rightarrow\mathgreekupbold{\Phi}$\\
\string\Chi\ $\rightarrow\mathgreekupbold{\Chi}$\\
\string\Psi\ $\rightarrow\mathgreekupbold{\Psi}$\\
\string\Omega\ $\rightarrow\mathgreekupbold{\Omega}$\\
\string\Digamma\ $\rightarrow\mathgreekupbold{\Digamma}$\\
% \columnbreak ne fonctionne pas comme espéré
\mbox{}\\
\string\alpha\ $\rightarrow\mathgreekupbold{\alpha}$\\
\string\beta\ $\rightarrow\mathgreekupbold{\beta}$\\
\string\gamma\ $\rightarrow\mathgreekupbold{\gamma}$\\
\string\delta\ $\rightarrow\mathgreekupbold{\delta}$\\
\string\epsilon\ $\rightarrow\mathgreekupbold{\epsilon}$\\
\string\zeta\ $\rightarrow\mathgreekupbold{\zeta}$\\
\string\eta\ $\rightarrow\mathgreekupbold{\eta}$\\
\string\theta\ $\rightarrow\mathgreekupbold{\theta}$\\
\string\iota\ $\rightarrow\mathgreekupbold{\iota}$\\
\string\kappa\ $\rightarrow\mathgreekupbold{\kappa}$\\
\string\lambda\ $\rightarrow\mathgreekupbold{\lambda}$\\
\string\mu\ $\rightarrow\mathgreekupbold{\mu}$\\
\string\nu\ $\rightarrow\mathgreekupbold{\nu}$\\
\string\xi\ $\rightarrow\mathgreekupbold{\xi}$\\
\string\omicron\ $\rightarrow\mathgreekupbold{\omicron}$\\
\string\pi\ $\rightarrow\mathgreekupbold{\pi}$\\
\string\rho\ $\rightarrow\mathgreekupbold{\rho}$\\
\string\sigma\ $\rightarrow\mathgreekupbold{\sigma}$\\
\string\tau\ $\rightarrow\mathgreekupbold{\tau}$\\
\string\upsilon\ $\rightarrow\mathgreekupbold{\upsilon}$\\
\string\phi\ $\rightarrow\mathgreekupbold{\phi}$\\
\string\chi\ $\rightarrow\mathgreekupbold{\chi}$\\
\string\psi\ $\rightarrow\mathgreekupbold{\psi}$\\
\string\omega\ $\rightarrow\mathgreekupbold{\omega}$\\
\string\digamma\ $\rightarrow\mathgreekupbold{\digamma}$\\
\string\varsigma\ $\rightarrow\mathgreekupbold{\varsigma}$
\end{multicols}
\end{framed}
% il y a bien sûr d'horribles espacement verticaux typiques de LaTeX
\vspace*{-\baselineskip}
\caption{Greek control sequences in the argument of
  \texttt{\cs{mathgreekupbold}}.}
\label{table:greekupbold}
\end{table}
\begin{table}[htbp]
\MTversion{libertinus}
\begin{framed}
\begin{multicols}{4}
\noindent
\string\Alpha\ $\rightarrow\mathgreekitbold{\Alpha}$\\
\string\Beta\ $\rightarrow\mathgreekitbold{\Beta}$\\
\string\Gamma\ $\rightarrow\mathgreekitbold{\Gamma}$\\
\string\Delta\ $\rightarrow\mathgreekitbold{\Delta}$\\
\string\Epsilon\ $\rightarrow\mathgreekitbold{\Epsilon}$\\
\string\Zeta\ $\rightarrow\mathgreekitbold{\Zeta}$\\
\string\Eta\ $\rightarrow\mathgreekitbold{\Eta}$\\
\string\Theta\ $\rightarrow\mathgreekitbold{\Theta}$\\
\string\Iota\ $\rightarrow\mathgreekitbold{\Iota}$\\
\string\Kappa\ $\rightarrow\mathgreekitbold{\Kappa}$\\
\string\Lambda\ $\rightarrow\mathgreekitbold{\Lambda}$\\
\string\Mu\ $\rightarrow\mathgreekitbold{\Mu}$\\
\string\Nu\ $\rightarrow\mathgreekitbold{\Nu}$\\
\string\Xi\ $\rightarrow\mathgreekitbold{\Xi}$\\
\string\Omicron\ $\rightarrow\mathgreekitbold{\Omicron}$\\
\string\Pi\ $\rightarrow\mathgreekitbold{\Pi}$\\
\string\Rho\ $\rightarrow\mathgreekitbold{\Rho}$\\
\string\Sigma\ $\rightarrow\mathgreekitbold{\Sigma}$\\
\string\Tau\ $\rightarrow\mathgreekitbold{\Tau}$\\
\string\Upsilon\ $\rightarrow\mathgreekitbold{\Upsilon}$\\
\string\Phi\ $\rightarrow\mathgreekitbold{\Phi}$\\
\string\Chi\ $\rightarrow\mathgreekitbold{\Chi}$\\
\string\Psi\ $\rightarrow\mathgreekitbold{\Psi}$\\
\string\Omega\ $\rightarrow\mathgreekitbold{\Omega}$\\
% \string\Digamma\ $\rightarrow\mathgreekitbold{\Digamma}$\\
\string\Digamma\ $\rightarrow N/A$\\
% \columnbreak ne fonctionne pas comme espéré
\mbox{}\\
\string\alpha\ $\rightarrow\mathgreekitbold{\alpha}$\\
\string\beta\ $\rightarrow\mathgreekitbold{\beta}$\\
\string\gamma\ $\rightarrow\mathgreekitbold{\gamma}$\\
\string\delta\ $\rightarrow\mathgreekitbold{\delta}$\\
\string\epsilon\ $\rightarrow\mathgreekitbold{\epsilon}$\\
\string\zeta\ $\rightarrow\mathgreekitbold{\zeta}$\\
\string\eta\ $\rightarrow\mathgreekitbold{\eta}$\\
\string\theta\ $\rightarrow\mathgreekitbold{\theta}$\\
\string\iota\ $\rightarrow\mathgreekitbold{\iota}$\\
\string\kappa\ $\rightarrow\mathgreekitbold{\kappa}$\\
\string\lambda\ $\rightarrow\mathgreekitbold{\lambda}$\\
\string\mu\ $\rightarrow\mathgreekitbold{\mu}$\\
\string\nu\ $\rightarrow\mathgreekitbold{\nu}$\\
\string\xi\ $\rightarrow\mathgreekitbold{\xi}$\\
\string\omicron\ $\rightarrow\mathgreekitbold{\omicron}$\\
\string\pi\ $\rightarrow\mathgreekitbold{\pi}$\\
\string\rho\ $\rightarrow\mathgreekitbold{\rho}$\\
\string\sigma\ $\rightarrow\mathgreekitbold{\sigma}$\\
\string\tau\ $\rightarrow\mathgreekitbold{\tau}$\\
\string\upsilon\ $\rightarrow\mathgreekitbold{\upsilon}$\\
\string\phi\ $\rightarrow\mathgreekitbold{\phi}$\\
\string\chi\ $\rightarrow\mathgreekitbold{\chi}$\\
\string\psi\ $\rightarrow\mathgreekitbold{\psi}$\\
\string\omega\ $\rightarrow\mathgreekitbold{\omega}$\\
% \string\digamma\ $\rightarrow\mathgreekitbold{\digamma}$\\
\string\digamma\ $\rightarrow N/A$\\
\string\varsigma\ $\rightarrow\mathgreekitbold{\varsigma}$
\end{multicols}
\end{framed}
% il y a bien sûr d'horribles espacement verticaux typiques de LaTeX
\vspace*{-\baselineskip}
\caption{Greek control sequences in the argument of the
  \texttt{\cs{mathgreekitbold}} command.  This font has
  no bold italic Digamma nor digamma (last tested 2023/12/19).}
\label{table:greekitbold}
\end{table}
% 2023/12/19 mais comme j'ai configuré Latexmk pour lever une
% erreur en cas de "bad warning" je supprime de la source
% le test avec \Digamma et \digamma

\subsubsection{Special behavior of
  \cs{mathrm}, \cs{mathbf}, \cs{mathit} with Greek letters via
  the \texttt{LGRgreek+} option}
\label{sec:newgreekplus}

With option\RightNote{\mstrelease{1.3za}} §LGRgreek+§ or §LGRgreeks+§, \mst makes Greek
letters control sequences \cs{alpha}, \cs{beta}, ... (but not \cs{alphaup} or
\cs{betait} and the others) react in a special manner within the scope of
§\mathnormal§, §\mathrm§, §\mathit§, §\mathbf§, and §\mathnormalbold§, but not
further math alphabet commands, and not when using the \mst defined commands
named with an uppercased initial.

Here is an example%
{\MTversion{libertinustexstyle}\[\def\zzz{abCD\alpha\pi\Delta\Gamma}%
  \begin{array}{rc}
    &\zzz\\
    mathnormal& \mathnormal{\zzz}\\
    mathrm& \mathrm{\zzz}\\% \mathrm on Greek is like \mathgreekup
    mathit& \mathit{\zzz}\\% \mathit on Greek is like \mathgreekit
    mathbf& \mathbf{\zzz}\\% \mathbf on Greek is like \mathgreekupbold
    mathnormalbold& \mathnormalbold{\zzz}\\
    mathgreekup& \mathgreekup{\zzz}\\%
    mathgreekit& \mathgreekit{\zzz}\\%
    mathgreekupbold& \mathgreekupbold{\zzz}\\%
    mathgreekitbold& \mathgreekitbold{\zzz}%
  \end{array}
\]
}%
It used this source:
\begin{verbatim}
\[\def\zzz{abCD\alpha\pi\Delta\Gamma}
  \begin{array}{rc}
    &\zzz\\
    mathnormal& \mathnormal{\zzz}\\
    mathrm& \mathrm{\zzz}\\% \mathrm on Greek is like \mathgreekup
    mathit& \mathit{\zzz}\\% \mathit on Greek is like \mathgreekit
    mathbf& \mathbf{\zzz}\\% \mathbf on Greek is like \mathgreekupbold
    mathnormalbold& \mathnormalbold{\zzz}\\
    mathgreekup& \mathgreekup{\zzz}\\%
    mathgreekit& \mathgreekit{\zzz}\\%
    mathgreekupbold& \mathgreekupbold{\zzz}\\%
    mathgreekitbold& \mathgreekitbold{\zzz}%
  \end{array}
\]
\end{verbatim}
This was typeset here using a ``libertinustexstyle'' math version which
(differently from the one used in an earlier section) has the default \TeX\
settings for the shape of Latin and Greek letters: i.e.\@ italic Latin and lowercase
Greek, upright uppercase Greek.  Its preamble definition was something like
this:
\begin{verbatim}
\MTfamily{LibertinusSerif-TLF}
\MTgreekfont{LibertinusSerif-TLF}
\MTlettershape{it}% not needed with italic option if nothing was changed prior
\MTitgreek\MTupGreek% this is also the default configuration
\Mathastext[libertinustexstyle]
\end{verbatim}
%
The difference with using only §LGRgreek§ option is that with the latter the
Latin math alphabets such as §\mathrm§, §\mathit§, §\mathbf§ produce a Latin
letter when acting on a Greek control sequence, as the latter are defined by
\mst under §LGRgreek§ to be of ``variable family type'' for usage with
§\mathgreekup§ and §\mathgreekit§.  With §LGRgreek+§, the Greek control
sequences are not mathchar tokens anymore but macros with conditionals
detecting some flag set by custom §\mathnormal§, §\mathnormalbold§, §\mathrm§,
§\mathit§, and §\mathbf§.

\mst has no logical way to sync shape of Latin and Greek letters once usage
has been made of Greek related commands.  Hence §\mathnormal§ is currently
configured to do nothing on Greek letters.  This may change, please consider
this behavior unstable.

Remark: this §LGRgreek+§ functionality is considered by its author an abuse of
the concept of a math alphabet command and required accomodating a serious
deviation from internal logical design of \mst. I don't know if it is because
\LaTeX\ documentations are deficient or misleading on such matters but it
appears many \LaTeX\ users are surprised when |$\mathrm{\pi}$| does not give
an upright pi letter but this is completely to be expected in a world with
fonts having only 128 or 256 glyphs, and from the fact that §\mathrm§ and
§\mathbf§ originate in Plain \TeX\ \cs{rm} and \cs{bf} and are still quite
akin to it, they are font switching commands nothing more or less.

\subsection{Advanced capacities}

Some such capacities are on per default (but if with §subdued§ option will be
turned off in the \emph{normal} and \emph{bold} math versions), others require
an action from the user for activation.

\subsubsection{Extra spaces around letters}
\label{sec:mathskips}

This is a new feature%
%
\footnote{It was new in 2013 indeed.  Not so much new now, but it is never too
late to try it out.}
%
added with release \mstrelease{1.3}: the command §\MTsetmathskips§ allows the
user to set up some spaces (more precisely, `mu glue'; but stretch and shrink
are discarded) to be automatically inserted around the letters in math
mode. Some (very) unrealistic uses:
\begin{verbatim}
% this may be anywhere in the document (also within a math group):
\MTsetmathskips{x}{20.33mu}{15.66mu}% 20.33mu before all x's and 15.66mu after.
\MTsetmathskips{y}{\thickmuskip}{\thickmuskip}%
\MTsetmathskips{z}{10mu}{5mu}% stretch and shrink are anyhow without effect.
\MTsetmathskips{A}{\muexpr \thickmuskip*2}{\muexpr \medmuskip-\thinmuskip/2}%
\end{verbatim}
Here is what |$wxtytz^{wxtytz}=BAC^{BAC}$| then gives using the Times font: 
\begingroup
\MTsetmathskips{x}{20.33mu}{15.66mu}%
\MTsetmathskips{y}{\thickmuskip}{\thickmuskip}%
\MTsetmathskips{z}{10mu}{5mu}%
\MTsetmathskips{A}{\muexpr \thickmuskip*2}{\muexpr \medmuskip-\thinmuskip/2}%
\MTversion{times}%
$wxtytz^{wxtytz}=BAC^{BAC}$.\endgroup{} Any \TeX{} group or \LaTeX{} environment
limits as usual the scope of this command. Furthermore the command
§\MTunsetmathskips§ cancels previous use of \cs{MTsetmathskips} for a given
letter.

The implementation relies on the `mathematical activation' of letters, which
is done by default by the package since release \mstrelease{1.2b}. Should this
cause compatibility problems, the command §\MTmathstandardletters§ cancels it
entirely. To reactivate it, there is §\MTmathactiveletters§. Note that
§\MTmathactiveletters§ is done automatically (as part of §\MTicinmath§) by
\mst when loaded (if not with §subdued§ option), and also each time the
package enhanced math-version-switch command §\MTversion§ is used, except for
the normal and bold math versions under the §subdued§ option.

\begin{shaded*}
  The extra skips are set at natural width; they do not contribute to the
  overall stretchability or shrinkability of the math formula and do not
  create break points. 

  \textcolor{magenta}{\bfseries Changed with \mstrelease{1.3i}}: they are \emph{not}
  applied within the scope of math alphabet commands.
\end{shaded*}

\subsubsection{Background on italic corrections in math mode}
\label{sec:ic}

{\small Note: this is somewhat technical discussion which may well be skipped in
  its entirety on first reading.\par}

\begingroup
\fboxsep0pt\fboxrule.1pt

With the §italic§ option the letters in math will be generally in italic shape
(and, normally, upright in operator names).

For the built-in placement routines of \TeX{} in math mode to work as well as
they usually do, the characters from the math italic font obviously should have
their bounding boxes wide enough for the glyphs not to collide with other
symbols. A letter from a text italic font  such as \emph{f} 
extends way out of its declared bounding box; let us
compare the bounding boxes\footnote{let's be honest, we are lying here about
  what exactly the first of these is bounding; this is explained later!} for the
letter $f$ in the math italic font to the one from the text italic font:
\fbox{$f$} vs. {\itshape\fbox{f}}.

This could make us think that attempting to use in math a text italic font will
lead to disaster. Well, surprisingly the situation is not that bad. Sure
|$f(x)$| is wider with the standard math italic \fbox{$f(x)$}
(\setbox0=\hbox{$f(x)$}\texttt{\the\wd0}) than it is with the text italic font
used in math:\footnote{we used simply \texttt{\$\string\mathit\{f(x)\}\$}.}
\fbox{$\mathit{f(x)}$} (\setbox0=\hbox{$\mathit{f(x)}$}\texttt{\the\wd0}) but we
should be surprised that our text italic {\itshape f} did not end up even closer
to the opening parenthesis. Why is it so?

The explanation is that \TeX{} uses in such a situation the \emph{italic
  correction} for the letter {\itshape f}. The italic correction also exists and
is used for the math italic font, it was inserted in |$f$| without us having to
ask anything. Its value is \texttt{1.17865pt} for the math italic $f$ and
\texttt{1.8919pt} for the text italic \emph{f}.\footnote{these values are for
  the Latin Modern fonts of course.} With the italic corrections included our
bounding boxes are indeed more alike: \fbox{\usefont{OML}{lmm}{m}{it}f\/} vs
\fbox{\itshape f\/}.

Without the italic corrections\footnote{here we give correctly the bounding box
  for the math italic $f$... without its italic correction!} it is
\fbox{\usefont{OML}{lmm}{m}{it}f} 
vs \fbox{\itshape f}. I said that |$f$| included the italic correction
automatically, 
but if we  tell \TeX{} to use the text italic in math, and typeset the alphabet,
we obtain something exactly identical to typing the letters in text, hence
without any italic
correction:\par
{\leftskip2cm\rightskip5cm%
  \noindent{\itshape abcdefghijklmnopqrstuvwxyz}\hfill\rlap{\texttt{text italic
      in text}}\break $\mathit{abcdefghijklmnopqrstuvwxyz}$\hfill
\rlap{\texttt{text italic in math}}\break
$abcdefghijklmnopqrstuvwxyz$\hfill
\rlap{\texttt{math italic in math}}\break
  {\usefont{OML}{mlmm}{m}{it}abcdefghijklmnopqrstuvwxyz}\hfill 
\rlap{\texttt{math italic in text}}\par} 
Where are our italic corrections gone? the last line
was done with \cs{usefont\{OML\}\{mlmm\}\{m\}\{it\}} and the
line before that using math mode is longer and confirms that italic
corrections have been used for the math italic in math mode.

Turning to the \TeX book (and its Appendix G) we learn that in such
circumstances, for the italic corrections to be put in from the font, one of its
parameters, the interword space (aka \cs{fontdimen2}), should
be zero. It is indeed zero for the math italic font, not for the text italic.

It is possible to make \TeX{} believe it is. Doing so, we obtain in math mode
with the text italic:\par
{\leftskip2cm\rightskip5cm%
\noindent{\mathastextversion{italic}%
$\xdef\mstrestorefontdimen{\fontdimen2\textfont\symmtletterfont=
\the\fontdimen2\textfont\symmtletterfont}%
\fontdimen2\textfont\symmtletterfont=0pt%
   abcdefghijklmnopqrstuvwxyz$}\hfill\rlap{\texttt{text italic in math}}\break
   $abcdefghijklmnopqrstuvwxyz$\hfill\rlap{\texttt{math italic in math}}\par}


 We saw that the italic correction was taken into acount automatically
 (independently of the value of the interword space font parameter) in
 expressions such as |$f(x)$|. Another clever thing done by \TeX{} is to use it
 for the placement of superscripts; the next examples systematically
 use the text italic in math. We see that
 {\mathastextversion{italic}$\mstrestorefontdimen f^j$} is very different
 from $\hbox{\itshape f}^j$... where the latter was coded with 
|$\hbox{\itshape f}^j$|. The inputs |$\mathit{\hbox{\itshape f\/}^j}$| and
|$\mathit{f^j}$| give almost identical results: \fbox{$\mathit{\hbox{\itshape
      f\/}^j}$}  vs.
 \fbox{$\mathit{f^j}$}. Close examination reveals
 that the horizontal spacing is exactly identical, however the exponent in the
 second case is a bit lower. Anyway, the point is that in the second case the
 italic correction for $\mathit f$ was indeed used.

 Subscripts are another matter: they do \emph{not} take into
 account the italic correction. For example |$\mathit{f_i}$|
 gives the same horizontal positions as
 |$\mathit{\hbox{\itshape f}_i}$|: $\mathit{f_i}$ vs.
 $\mathit{\hbox{\itshape f}_i}$. Printing them one on another
 gives \rlap{$\mathit{f_i}$}$\mathit{\hbox{\itshape f}_i}$ and
 reveals (use the zoom of your viewer!) that only the vertical
 placement was affected, not the horizontal placement.

We learn in Appendix G of the \TeX book that the italic correction is used for
the horizontal shift of the superscript with respect to the position of
% CETTE LIGNE PROVOQUE L'AJOUT D'UN LINESKIP
% the subscript: $\mathit{f_i^j}$, or,
% En fait déjà en Plain TeX, configuration de base la hauteur totale de
% $f_i^j$ est > 12pt = baselineskip !
% Work-around ad hoc
the subscript: \smash{$\mathit{f_i^j}$}, or,
going back now to the standard math italics $f_i^j$. In the next paragraphs
we use \smash{$f_i^i$} for more accurate comparison of the positioning of the sub- and superscript.

If we try something like this: |${f\/}_i^i$| we obtain ${f\/}_i^i$. Our
overlapping game with |\rlap{$f_i^i$}${f\/}_i^i$| gives
\rlap{$f_i^i$}${f\/}_i^i$. We discover that the effect of the explicit italic
correction has mainly been to translate the subscript horizontally to be
positioned exactly below the superscript!\footnote{there are also some tiny
  vertical displacements of the sub- and superscripts.} We most probably do
\emph{not} want this to happen for our indices and exponents in math mode. So
perhaps we can rejoice in how astute \TeX{} has been in judiciously using the
italic correction data, and there seems to be no need into fiddling with this
algorithm which seems to work well even when applied to a text italic font. Actually we may even be of the opinion that the text italic
version $\mathit{f_i^i}$  is a bit better-looking than the
true math italic $f_i^i$ . . .


But wait... \mst was initially developed to easily use in math mode the document
text font not in its italic variant, but as is, so, usually, upright. And
upright \TeX{} fonts may also have italic correction data! And what I just said
about the shift of the superscript with respect to the subscript apply equally
well to such a font, if \TeX{} has been told to use it. Let's try Latin Modern
Upright for letters in math: |$f_i^i$| now gives\footnote{we just use
  \texttt{\$\string\mathrm\{f\_i\^{}i\}\$}.} $\mathrm{f_i^i}$. We see the italic
correction in action for the positioning of the superscript! Compare with
|$\mathrm{\hbox{f}_i^i}$|: $\mathrm{\hbox{f}_i^i}$. Overlapping with
|\rlap{$\mathrm{f_i^i}$}$\mathrm{\hbox{f}_i^i}$| gives
\rlap{$\mathrm{f_i^i}$}$\mathrm{\hbox{f}_i^i}$ and shows that the upright
$\mathrm{f}$ has an italic correction which was used to shift the superscript to
the right (and it is now in a slightly lower position). Let's now do
|$\mathrm{{f\/}_i^i}$|: this gives $\mathrm{{f\/}_i^i}$ and the subscript is
shifted to the right, and is now on the same vertical axis as the superscript.
There are also some slight vertical displacements,
|\rlap{$\mathrm{f_i^i}$}$\mathrm{{f\/}_i^i}$| gives
\rlap{$\mathrm{f_i^i}$}$\mathrm{{f\/}_i^i}$. 

People will tell me crazy, but if we decide for using upright fonts in math,
wouldn't it be satisfying to have the subscript and superscript positioned
on the same vertical axis? the letter has no slant, why should the indices
display one?

We end up in this strange situation that it is attractive to systematically
incorporate the italic corrections after the upright Latin letters in math! But
we don't want to do this inside the arguments to math alphabets as this would
make impossible the formation of ligatures (the standard |$\mathrm{ff}$|,
|$\mathit{ff}$|, |$\mathbf{ff}$|, |$\mathsf{ff}$| all give ligatures
$\mathrm{ff}$, $\mathit{ff}$, $\mathbf{ff}$, and $\mathsf{ff}$ and we would like
to preserve this behavior).
% http://tex.stackexchange.com/questions/35298/error-with-hyperref-tabular-footnotes-in-tabular
% pas le temps aujourd'hui de regarder plus, j'ai déjà rencontré ce problème,
% j'avais peut-être autre chose. Voir aussi
% http://tex.stackexchange.com/questions/6090/clickable-table-footnote

\makeatletter
\begin{framed}\kern-.75\baselineskip
  \begin{framed}
    Starting with version |v1.2b|, \mst adds the italic correction automatically
    after each letter of the Latin alphabet in math mode, \emph{except} when
    these letters are italic or slanted.\footnotemark\par
 %\global\let\saved@Href@A\Hy@footnote@currentHref 
    These
    italic corrections are canceled inside the arguments to the math alphabet
    commands, to allow the formation of ligatures as
    is expected in the standard default \TeX{} font set-up in math.%
  \end{framed}\vskip-.75\baselineskip
\end{framed}
\footnotetext{the situation is rather ironical! by the way, the warnings in
  \autoref{sec:mathxx} with \texttt{\$x\^{}?\$} or similar are less of an
  issue here, because the letter is only \emph{followed} by \texttt{\char92/}
  and anyhow the whole is put by \mst within group braces, so no surprises
  with \texttt{\$x\^{}y\$} or \texttt{\$\char92mathbin x\$}. Nevertheless it
  is still true that (in math mode only) the letters |a-z|, |A-Z|, expand to
  composite objects, something which could surprise other packages. The
  command \csb{MTmathstandardletters} cancels this mechanism.}

\makeatother

The feature-implementing commands §\MTicinmath§, §\MTnoicinmath§,
§\MTicalsoinmathxx§ are described in \autoref{sec:cmds}.
\endgroup

\textbf{\hbox{Note:}} \emph{from brief testing on 2012/12/28, \XeTeX{} seems not
  to obey in math mode italic corrections for OpenType fonts. Hence the \TeX{}
  placement algorithms for math mode described in this section do not work well
  when an OpenType (text) font is used for the letters in math mode, and the
  document is compiled with the \XeTeX{} engine. On the other hand \LuaLaTeX{}
  seems to implement the italic corrections when using OpenType fonts, but only
  with italic fonts (as far as I could tell). Try the following (which will use
  the OpenType Latin Modern font) on a recent \TeX{}
  installation and compare the output of both engines:}\par
\kern-.5\baselineskip
\indent\vbox{\begin{verbatim}
\documentclass{article}
\usepackage{fontspec}
\begin{document}
\Huge
$\mathit{f_i^i}$\par $\mathrm{f_i^i}$
\end{document}\end{verbatim}
\kern-.75\baselineskip}\\%\end{verbatim} FIX DU FONT-LOCKING DE AUCTEX (11.89.6)
\emph{Comment out the} |fontspec| \emph{line and use pdf\LaTeX{}. All
  three outputs are different on my \TeX{} installation. \XeTeX{} does not have
  the italic corrections. \LuaLaTeX{} does, but only for the italic font.
  pdf\LaTeX{} has them for both the italic and the upright font.}%
\footnote{2016/11/04: the situation hasn't changed,
at least on current TL2016.

\noindent\kern-0.5em\relax2022/10/29: no change with current TL2022.}

\subsubsection{Extra glue after \texorpdfstring{\cs{exists}}{\textbackslash
exists}, \texorpdfstring{\cs{forall}}{\textbackslash forall}, and before the prime glyph}
\label{sec:extraskips}

\begingroup\MTversion{upright}\renewcommand\familydefault\sfdefault
\makeatletter % c'est parce que sinon ils sont pris dans Symbol
\let\mst@exists@original\oldexists
\let\mst@forall@original\oldforall
\makeatother

\csb{MTforallskip}, \csb{MTexistsskip}, and \csb{MTprimeskip} are three
commands with each a mandatory argument like for example 
|3mu plus 1mu minus 1mu| or just |2.5mu|. They are especially useful 
when using an
upright font in math mode. {The |mu| is a unit length used in
  math mode (`math unit', 1/18th of the `quad' value of the symbol font
  in the current style). Its value is relative to the current math
  style. Its use is \textcolor{DarkMagenta}{mandatory} in the commands
  described here.}
\begin{itemize}
\item compare $\forall B$ with\MTforallskip{2mu} $\forall B$, typeset after 
|\MTforallskip{2mu}|, 
\item compare $\exists N$ with\MTexistsskip{2mu} $\exists N$, typeset after
|\MTexistsskip{2mu}|, 
\item and finally compare $f'$ with\MTprimeskip{2mu} $f'$, typeset after 
|\MTprimeskip{2mu}|.
\end{itemize}

These three commands may be used throughout the document, or also in the
preamble, in which case the declared math versions will record the then current
values of the skips. \mst applies the following (small) default skips:
|0.6667mu| for the skip after $\forall$, |1mu| for the skip after $\exists$, and
|0.5mu| for the skip before the prime. The examples above become
\MTforallskip{.6667mu}\MTexistsskip{1mu}\MTprimeskip{.5mu}$\forall B$, $\exists
N$ and $f'$.\footnote{the derivative glyph from the \ctanpkg{txfonts} math symbols
  adapts itself better to an upright letter, no skip seems to be needed then.}

With the §italic§ option the defaults are set to zero.
\MTversion{italic}\renewcommand\familydefault\sfdefault Indeed
$\forall B$, $\exists N$ and $f'$ look fine without additional skips. If the
document decides then to declare in the preamble a math version with an upright
font it is thus recommended to use the commands in the preamble before the
\cs{Mathastext}\oarg{version\_name} (or \cs{MTDeclareVersion}) command defining
the version. They will be remembered when this math version is entered in the
document. The commands may also be used directly in the document body.

Under the §subdued§ option, the \emph{normal} math version (at the start of
the document body, or after |\MTversion{normal}|) and the \emph{bold} math
version (either at the start of the document body after \cs{boldmath}, or after
|\MTversion{bold}|) do not have any extra skip inserted (even one of zero
width) after $\oldforall$, $ \oldexists$, or before the ${}'$.

\endgroup

\subsubsection{Extended scope of the math alphabets commands}
\label{sec:mathxx}

\begingroup
\MTversion{italic}\renewcommand\familydefault\sfdefault
\MTnormalasterisk

Ever since the initial version of the package, some characters usually
unaffected by the math alphabet commands \cs{mathbf}, \cs{mathtt},
\cs{mathsf}\dots{} are declared to be of `variable family type', in order for
them to obey these commands: for example the hash sign $\#$ gives $\mathbf{\#}$
if input as |$\mathbf{\#}$| (\mst, especially in its beginnings, wanted as many
characters as possible to be picked up from the text font and to behave
similarly to letters and digits).

So it was especially frustrating that mathematical characters such as $+$, or
$<$, or $]$ could not be declared of `variable family' (in addition to being
picked up in the text font) as this would, for reasons of the inner workings of
\TeX{}, not be compatible with the automatically inserted spaces around them.

A revolutionary\RightNote{\mstrelease{1.2}} ;-) novelty is introduced with
version \mstrelease{1.2} of the package:
\begin{enumerate}
\item the pre-declared or user-declared (using the |amsmath|
  \cs{DeclareMathOperator} or equivalent) operator names obey the math
  alphabet commands,\footnote{contrarily to the next feature, this one is not
    likely to create incompatibilities with other packages, so it is
    activated by default.}
\item as well as all non alphabetical characters treated by \mst.
\end{enumerate}

The non-letters handled by \mst (if not disabled by options) fall into two
groups:
\begin{itemize}[nosep]
\item Those to which \TeX{} associates some specific spacings:
  \centeredline{${!}\,{?}\,{,}\,{:}\,{;}\,{+}\,{-}\,{=}\,%
                 {(}\,{)}\,{[}\,{]}\,{<}\,{>}\,{\{}\,{\}}\,*$}
      We call them the ``hard'' ones.
\item Those for which \TeX{} uses so-called ordinary spacings:
  \centeredline{$.\,/\,\vert\,\backslash\,{\#}\,{\$}\,{\%}\,{\&}$}
      We call them the ``easy'' ones.
\end{itemize}
The ``easy'' non-letters are handled \emph{easily} by \mst, simply
by declaring them to be of ``variable family type''.  This will
be done automatically.%
\footnote{%
  ${\#}\,{\$}\,{\%}\,{\&}$ obey the math alphabets since the initial version
  of \mst; the dot $.$, the slash $/$, the vertical bar $\vert$ and the
  backslash $\backslash$ do not have specific spacings inserted by \TeX{}
  around them, and the procedure is then activated by default since
  \texttt{1.2} for these characters as they are `easy non-letters'. But for
  \cs{mid} and \cs{setminus} which are $\vert$ and $\backslash$ with special
  spacing (of type \cs{mathrel} and \cs{mathbin} resp.) the
  activation requires \csb{MTnonlettersobeymathxx}.}
%

The ``hard'' non-letters require a more complex approach using a concept
called ``mathematical activation''.  For reasons explained next, this is not
done automatically and requires the user to employ the command
§\MTnonlettersobeymathxx§ (or, for the specific case of the asterisk the option
§asterisk§).

\begin{shaded*}
  It is a fundamental feature that the spacing added by \TeX{} before and
  after each such \mst-ified non-letter is in no way modified.
\end{shaded*}


Let us compare, for example, the new behavior of \cs{mathtt} and \cs{mathbf}
when §\MTnonlettersobeymathxx§ has been used
\MTmathoperatorsobeymathxx
\MTnonlettersobeymathxx
\MTeasynonlettersobeymathxx
\[ new:\quad \mathtt{(\sin(n!)<\cos(m-p)?)}\qquad \mathbf{[\sin(x+y)=\cos(z-t)]}\] 
with the traditional default behavior one observes without \mst or in
§subdued§ normal or bold math version:
\MTmathoperatorsdonotobeymathxx
\MTnonlettersdonotobeymathxx
\MTeasynonlettersdonotobeymathxx
\[ standard:\quad \mathtt{(\sin(n!)<\cos(m-p)?)}\qquad \mathbf{[\sin(x+y)=\cos(z-t)]}\] 

The commands for
\emph{deactivation} are:\\
\mbox{}\hspace{1cm}\csb{MTmathoperatorsdonotobeymathxx},\\
\mbox{}\hspace{1cm}\csb{MTeasynonlettersdonotobeymathxx},\\
\mbox{}\hspace{1cm}\csb{MTnonlettersdonotobeymathxx},\\
and those for \emph{activation}:\\
\mbox{}\hspace{1cm}\csb{MTmathoperatorsobeymathxx} (done by default),\\
\mbox{}\hspace{1cm}\csb{MTeasynonlettersobeymathxx} (done by default),\\
\mbox{}\hspace{1cm}\csb{MTnonlettersobeymathxx} is \emph{not} done by default
(see explanations why in the shaded box next) and applies to the ``hard''
non-letters mentioned above and also to \cs{mid} and \cs{setminus}.
Furthermore, it applies to
the braces ${\{}\,{\}}$ only if \csb{MTexplicitbracesobeymathxx} is also used.


\begin{shaded*}
  \textbf{Important:} the package does not execute on its own
  \csb{MTnonlettersobeymathxx}. The reason is that the
  mechanism in effet replaces the original ``hard'' characters such as 
  |?|, |[|, |<| by (in math mode only) a more complex structure, which
  ceases looking to \TeX{} as only one token, and as a consequence |$x^?$|, |$R^+$|
  or |$\mathopen<A\mathclose>$| raise an error, the workaround being to
  employ additional braces: |$x^{?}$|, |$R^{+}$| and |$\mathopen{<}A\mathclose{>}$|.

  Similarly |$R^*$| does not work anymore under option §asterisk§, the user is
  supposed to know that with this option |$R^{*}$| is the mark-up to use.

  Thus, if one adds
  \centeredline{|\usepackage{mathastext}|§\MTnonlettersobeymathxx§} to a
  pre-existing document, it is needed to check if the mark-up satisfies
  to the above guidelines.  For this reason the mechanism is by default
  not activated and the user has to execute:
  \centeredline{§\MTnonlettersobeymathxx§}
  This can be done in the preamble and will trigger actual modifications
  only at time of |\begin{document}|.
\end{shaded*}



\begin{footnotesize}
Some \TeX nical notes:%
%
\footnote{The complete truth is only to be found in source code.  Here are
  some extra details:

  The
  dollar sign and the curly braces are not tested for mathematical or catcode
  activation.

  The $*$\RLNote{changed:}{\mstrelease{1.4}} is tested as
  are the ``hard'' non-letters, except under option §everymath§. On the
  other hand \cs{ast} will be modified independently of what is decided for
  $*$.  Comprenne qui pourra.}

\begin{itemize}[nosep]
\item
The asterisk $*$ is associated with its own option §asterisk§, because
independently of the matter of its behavior in the scope of math alphabets
commands, its handling by \mst (via the §\MTlowerast§ associated
configuration) always requires it to be made mathematically active and to
expand to a more complex structure.  So once this option is received by the
package, it goes full steam and also adds by default the responsiveness to
math alphabet commands (in non-§subdued§ math versions).

\item The legacy situation which is a bit late to change is that the
  responsiveness of the asterisk to math alphabets being on by default under
  option §asterisk§, it was decided that this responsiveness would be turned
  off by §\MTeasynonlettersdonotobeymathxx§ and back on by
  §\MTeasynonlettersobeymathxx§, although the $*$ is part of the ``hard''
  non-letters.  One can use §\MTnormalasterisk§ to stop the $*$ to obey math
  alphabet commands, but it also cancels the §\MTlowerast§ mechanism.

\item At\RLNote{changed:}{\mstrelease{1.4}} \mstrelease{1.4} ``easy''
  non-letters found out to be (at |\begin{document}| or with §\MTversion§
    except for §subdued§ \emph{normal} or \emph{bold}) mathematically active
    characters will not get overridden by \mst.
    This applies for example with
    the dot ``.'' under \ctanpkg{babel} with Spanish language.  Its special
    behavior to transform into a comma ``,'' if before a digit is now
    kept.  As an amusing side note, if §\MTnonlettersobeymathxx§ is used, this
    comma does obey math alphabet commands.

\item An ``easy'' non-letter which (at |\begin{document}| or with §\MTversion§
  except for §subdued§ \emph{normal} or \emph{bold}) is catcode active will
  still be set by \mst to be of ``variable family type'', if it is not
  mathematically active.  The catcode status is not checked nor modified, only
  the mathcode as per previous item.  Now whether the \mst-ification has any
  effect depends on how the user has configured the catcode active character
  to behave if in math mode.

\item When \mst wants to employ mathematical activation for a non-letter
  character among the ``hard'' cases (inclusive of the asterisk), which is done
  at |\begin{document}| if not §subdued§ or with every §\MTversion§ except for
    §subdued§ \emph{normal} or \emph{bold}, it first checks if this character
    is currently catcode active.  If this is the case, it then checks if the
    character is a \ctanpkg{babel} shorthand.  If yes, it then hooks into
    \ctanpkg{babel} internals to modify the way this shorthand acts in math
    mode, so that now the character will respond to math alphabet commands.
    If however the catcode active character does not appear to be a
    \ctanpkg{babel} shorthand, then \mst does not do anything at all (beyond
    its general business at package loading time to set-up the
    font used for the non-active token).
%
  In relation to this context  \mst should always be loaded \emph{after} \ctanpkg{babel}.
  And also \emph{after} the \ctanpkg{amsmath} package.

\item
The braces |\{| and |\}| remain unresponsive to the alphabet changing commands
even after \csb{MTnonlettersobeymathxx}. The user must employ for this
\centeredline{\csb{MTexplicitbracesobeymathxx}}
This has the disadvantage that |\{| and
|\}| become then unusable as variable-size delimiters: |\big\{| or |\big\}|
create errors and one must make use of |\big\lbrace| and |\big\rbrace|. But
%
\MTmathoperatorsobeymathxx
\MTnonlettersobeymathxx
\MTexplicitbracesobeymathxx
%
one can now enjoy $\mathtt{\{a, a>b\}}$, $\mathbf{\{a, a>b\}}$,
$\mathsf{\{a, a>b\}}$, or even $\mathnormalbold{\{a, a>b\}}$.%
%
\footnote{This
  last example uses the \csb{mathnormalbold} additional alphabet defined by
  \mst.}%
%
\footnote{Let me recall that braces will anyhow not be handled at all
  by \mst if the document
  font encoding is |OT1|, except under option |alldelims|.}

\item
Even with \csb{MTnonlettersobeymathxx}, the parentheses-like symbols $($, $)$, 
$[$, $]$, $<$ and $>$ and the slashes $/$, $\backslash$, \emph{if used as
  left/right delimiters} (i.e.\@ with |\left/\right|) will not respond to math
alphabet commands. This is mainly explained by the fact that the text font
will not contain suitable glyphs, hence no attempt was made by \mst to make the
delimiters pick up their glyphs there.

But \mst does try to pick up most of the `small variants' of the delimiters
from the text font: |$\left<x\right>$| gives $\left<x\right>$ but
|$\left<b\right>$| gives $\left<b\right>$.  Notice that this differs from
standard \LaTeX{} for which |$\left< x\right>$| gives $\langle x\rangle$. As
it is perhaps a bit strange to have $\left< x\right>$ and $\left< y\right>$
not use the same bracketing glyphs, there is an option §nosmalldelims§: with
this option the small-sized variants of the delimiters are not modified by
\mst (option §nosmalldelims§ has the side effect that, for the non-delimiter
uses of |\{, \}| to be \mst-ified it is necessary to issue
\csb{MTnonlettersobeymathxx} and \csb{MTexplicitbracesobeymathxx}.)\par

\item
At any rate, as said above, whether `small' or not, delimiters will remain
unresponsive to math alphabet commands, due to technical aspects of \TeX, and
the way \mst handles these things. Examples:
\begin{itemize}[nosep]
\item |\mathbf{<a,b>}| gives $\mathbf{<a,b>}$: no use of |\left/\right|, hence
  brackets do obey the math alphabets --- as we issued
  §\MTnonlettersobeymathxx§ a bit earlier, 
\item |\mathbf{\left<a,b\right>}| gives
  $\mathbf{\left<a,b\right>}$:  delimiters used with |\left/\right| will not obey
  the math alphabets,
\item |\mathbf{\mathopen{<}a,b \mathclose{>}}| gives
  $\mathbf{\mathopen{<} a,b \mathclose{>}}$: no |\left/\right|, so the
  brackets do obey the math alphabets due to §\MTnonlettersobeymathxx§.
\item 
\MTnonlettersdonotobeymathxx
to compare, the \LaTeX{} standard for
|\mathbf{\mathopen{<}a,b\mathclose{>}}| is to produce
$\mathbf{\mathopen{<} a,b \mathclose{>}}$: neither brackets nor the comma are
responding to \cs{mathbf}.
\end{itemize}
\end{itemize}
\end{footnotesize}

\endgroup

\subsubsection{Hacking letters (and even digits) for special tasks}
\label{ssec:hackingletters}

For some ascii characters, i.e.\@ the ``hard'' non-letters considered in the
previous section, and even more spectacularly for all ascii letters, \mst
achieves the capabilities describes in earlier sections via a \TeX nique known
as ``mathematically active characters''.  For letters this is turned on by
default, but for the non-letter characters it is the command
\cs{MTnonlettersobeymathxx} which triggers this mathematical activation.

It is possible for daring \LaTeX{} users to hook into this architecture.
Release \mstrelease{1.4} has made this especially easy regarding ascii letters
(and even for digits if using the package option §activedigits§).

Except if told otherwise, \mst will make all Latin ascii letters mathematically
active, and when \TeX{} encounters e.g.\@ `e' in math mode it replaces it with
the macro having name \cs{MTcommandlettere} (mind the ending |e|).  Its
default definition inserts \hyperref[sec:mathskips]{optional extra skips}
and/or an \hyperref[sec:ic]{italic correction}.

You can redefine this \cs{MTcommandlettere}, or any
\cs{MTcommandletter}\meta{ascii-letter}, to achieve (globally or locally)
custom goals.%
%
\footnote{\CHANGED{\mstrelease{1.4}}%
Prior to \mstrelease{1.4}, there was no equivalent to
\cs{MTcommandletter}\meta{letter}.  An internal macro \cs{mst@}\meta{letter}
stood for what is denoted now \cs{MTmathcharletter}\meta{letter}, but required
a \cs{protected} if redefined as it was submitted to an \cs{edef} during
processing.}
%
Attention, this redefinition should not use `e' itself as a ``naked''
character to typeset in math mode, else an infinite loop will arise at time of
use. To access a symbol equivalent to the ``naked'' `e', use
\cs{MTmathcharlettere} (again mind the ending |e|).  For example:
\begin{verbatim}
\renewcommand\MTcommandlettere{\mathsf{\MTmathcharlettere}}% not \mathsf{e}!
\end{verbatim}
In this case we could do the simpler approach with \cs{textsf}, which works
as it will then typeset the |e| in text mode, not math mode.
\begin{verbatim}
\renewcommand\MTcommandlettere{\textsf{e}}%                  not \mathsf{e}!
\end{verbatim}
This gives a priori the same result in our \mst context, which
picks the font for \cs{mathsf} from the one used by \cs{textsf}, assuming here
default configuration in the preamble following the loading of \mst.%
%
\footnote{This example simply reassigns \texttt{e} to another font, and one
could use also the \LaTeX{} command \cs{DeclareMathSymbol} for this.  But few
\LaTeX{} users are familiar with its interface, and such an approach could
cost adding an extra math symbol font, depending on what one wants to do.
Besides \cs{DeclareMathSymbol} is a preamble-only command, which limits
considerably its usability, forcing basically the change to apply to the whole
document. Using the \mst interface via mathematically active characters opens
up the possibility of arbitrary replacements, of local scope in the document
body.}

 
It is recommended in general to add an extra pair of braces
to avoid problems when used with |_| and |^|.  Let's give an other example and
demonstrate its output:
\begin{verbatim}
\[
\renewcommand\MTcommandlettere{{\mathcolor{blue}{\mathsf{\MTmathcharlettere}}}}%
abcde^efgh
\]
\end{verbatim}
\MTversion{times}
\[
\renewcommand\MTcommandlettere{{\mathcolor{blue}{\mathsf{\MTmathcharlettere}}}}%
abcde^efgh
\]%
\MTversion{normal}%
As this document is in §subdued§ mode, we had, to show the effect, to
switch temporarily to some math version activating \mst, and we used here a
|times| math version with Times and Helvetica clones.

If you redefine \cs{MTcommandlettere} as described in this section the optional extra
math skips added before or after via §\MTsetmathskips§ will be lost, as well
as the automatic italic correction |\/| added by \mst for an upright font, and it
is up to the redefinition of \cs{MTcommandlettere} to do the job.

The explanations above apply to any (ascii) Latin letters \meta{ascii-letter}
with associed macros \cs{MTcommandletter}\meta{ascii-letter} and ``naked''
symbol command \cs{MTmathcharletter}\meta{ascii-letter}.

With option §activedigits§ you can even extend the game to digits.  The
``raw'' digit symbol is kept as a math symbol control sequence
\cs{MTmathchardigit}\meta{y} where \meta{y} stands for the Roman version of
the digit: empty
for $0$, then |i|, |ii|, etc... until |ix|.  The macro to redefine for special
effect is \cs{MTcommanddigit}\meta{y}. Example:
\begin{verbatim}
\[
\renewcommand\MTcommanddigit{{\MTmathchardigit^{\mathcolor{blue}{1}}
                                             _{\mathcolor{red}{2}}}}%
\renewcommand\MTcommanddigiti{{\boxed{\mathbf{\MTmathchardigiti}}}}
0^0_0
\]
\end{verbatim}
\MTversion{times}
\[
\renewcommand\MTcommanddigit{{\MTmathchardigit^{\mathcolor{blue}{1}}
                                             _{\mathcolor{red}{2}}}}%
\renewcommand\MTcommanddigiti{{\boxed{\mathbf{\MTmathchardigiti}}}}
0^0_0
\]%
\MTversion{normal}%
(\cs{boxed} is from \ctanpkg{amsmath}) Let's hope you find better
usage... recall that you can't use digit $0$ in its redefinition but must use
\cs{MTcommanddigit}.  But you can of course use other digits... except if
their definitions use the digit $0$ rather than the non-active symbol control
sequence \cs{MTmathchardigit}.

See also §\MTmathactiveletters§ and §\MTmathactivedigits§.



% 2 septembre 2013; finalisé 22:58
% Mardi 19 décembre 2023: l'utilisation de bleu alors que ce n'est
% pas un lien était très mauvais.
% New mark-up \mstopt, and \mstcmd I had been too lazy and could
% never resolved some issues of missing hyperlinks with the trick
% formerly used here to redefine the short verb §foo§.
\makeatletter
\newcounter{machin}
\def\mstopt#1{{\textcolor{monmarron}{#1}\refstepcounter{machin}\expandafter\label\expandafter{\@gobble#1}}}
\def\mstcmd#1{{\textcolor{monmarron}{\ttfamily\@backslashchar#1}\label{#1}}}
\makeatother

\newsavebox\boite

\section{Package commands}
\label{sec:cmd}

\subsection{Commands for regular usage}

\subsubsection{Preamble-only commands}
These commands mainly facilitate the definition of math versions, in a \mst
extended sense. It is not necessary to use them to activate the package
basic functionalities, as loading \mst is enough (except with the |subdued|
option). 
\begin{enumerate}[label=$\bullet$, leftmargin=1em]
\item \mstcmd{Mathastext} (or \mstcmd{mathastext}) reinitializes \mst: it sets the
  fonts used in math mode (in versions |normal| and |bold|) for letters,
  digits and a few ascii symbols to the \emph{current} defaults of encoding,
  family, series and shape.\footnote{\csb{Mathastext} updates also
    the font and shapes for the Greek letters (|LGRgreek| option), and the
    skips to be inserted after the symbols $\oldforall$ and $\oldexists$,
    see \emph{infra.}} Both the normal and bold math version are modified by
  this action of §\Mathastext§.
  \item %\textbf{math versions:} 
    \csb{Mathastext}\oarg{version\_name} rather than redefining the
    fonts for math mode, §\Mathastext§ declares a new \emph{math version}, and
    it is this 
    math version which will use the then current text font in math
    mode.\footnote{The allowed version names are as for 
      the \LaTeX{} \cs{DeclareMathVersion} macro. \emph{Do not use}
        |\string\Mathastext[foo]| \emph{with
        |foo| equal to ``normal'' or ``bold'';} this is already taken care of by the
      initial loading of the package or a later command \csb{Mathastext}
      without any optional argument.  And it will be rejected.}
  \item %\textbf{inheritance:}
    \csb{Mathastext}\oarg{version\_name}\oarg{parent\_name}
    declares \meta{version\_name} and configures it to inherit
    from \meta{parent\_name} all which is not under the scope of
    \mst, such as large symbols. The main use will be with
    |[bold]| in order for the symbols and large symbols to be
    typeset as in the |bold| math version. For example, this
    document has in its preamble:\hfill\break\begingroup\small
    \begin{lrbox}{\boite}|\usepackage{newcent}% this package makes New Century the roman font|\end{lrbox}\rlap{\usebox{\boite}}\hfill\break
    |\Mathastext[newcent]% this math version will use New Century|\hfill\break
    |\MTseries{b}        % next \Mathastext will use a bold font|\hfill\break
    \begin{lrbox}{\boite}|\Mathastext[boldnewcent][bold]% large symbols, etc, will be bold too|\end{lrbox}\rlap{\usebox{\boite}}\hfill\break\endgroup
    We can check that it does work:
    \centeredline{|\MTversion{newcent}:|\MTversion{newcent}
      $abcde\displaystyle\ointop\bigvee\biguplus\bigotimes\bigoplus$}
    \centeredline{|\MTversion{boldnewcent}:|\MTversion{boldnewcent}
      $abcde\displaystyle\ointop\bigvee\biguplus\bigotimes\bigoplus$}
    Naturally, for this one needs an initial math font setup with some nice
    bold fonts also for large symbols. This is the case with the excellent
    \ctanpkg{txfonts} package of Young~\textsc{Ryu}. As the present document must
    use many fonts and declares many math alphabets, we did not load the full
    package and fonts but only the |largesymbols|:\hfill\break
    |\DeclareSymbolFont{largesymbols}{OMX}{txex}{m}{n}|\hfill\break
    |\SetSymbolFont{largesymbols}{bold}{OMX}{txex}{bx}{n}|\hfill\break
    |\DeclareFontSubstitution{OMX}{txex}{m}{n}|

  \item 
    \mstcmd{MTencoding}\marg{enc},
    \mstcmd{MTfamily}\marg{fam},
    \mstcmd{MTseries}\marg{ser},
    \mstcmd{MTshape}\marg{sh}, and
    \mstcmd{MTlettershape}\marg{sh}.%
%
\footnote{These commands exist also with
    long names: \csb{Mathastextencoding},
    etc\dots{} The same applies to the other commands
    mentioned in this section.}
% 
For example valid respective arguments are, respectively, \meta{T1},
\meta{phv}, \meta{m}, \meta{n}, and \meta{it}: this is the
Helvetica font in T1-encoding, regular (medium) series, upright
shape, and the letters will be in italic shape. Once used their
effect applies to all succeeding calls to \cs{Mathastext}, and
can only be undone by using them again with other settings, again
followed by a call to \cs{Mathastext}.

NOTE: \emph{only} if
\cs{Mathastext} is used next (possibly with a version name as
optional argument) will these commands have any real effect.

  \item
    \mstcmd{MTWillUse}\oarg{ltsh}\marg{enc}\marg{fam}\marg{ser}\marg{sh}
    tells \mst to use the font with the
    specified encoding, family, series, and shape for
    the letters and digits (and all other afflicted
    characters) in math mode. The optional argument
    \meta{ltsh} specifies a shape for the letters, for
    example \cs{itdefault}, or directly \meta{it} or
    \meta{sc}. 
  
\item  \mstcmd{MTDeclareVersion}\oarg{ltsh}\marg{name}\marg{enc}\marg{fam}\marg{ser}\marg{sh}\oarg{other\_version}:
  declares that the document will have access to the font
  with the specified characteristics, under the math version name
  \meta{name}. For example:
  \centeredline{|\MTDeclareVersion[sc]{palatino}{T1}{ppl}{b}{sl}|}
  declares under the name |palatino| a version where
  mathematics will be typeset using the Palatino font in
  T1-encoding, bold, slanted, and the letters will in fact be
  in caps and small caps (and bold).\footnote{I do not
  especially recommend to use this in real life!} When the initial
  optional argument is absent, and \mst was loaded
  with the \blueit{italic} option, then the default letter shape
  will be |it|,\footnote{more precisely, the shape is the
  latest value passed in one of the previously used package
  commands to specify the shape of letters, or the \cs{itdefault}
  of the time of loading the package.}  else letters will
  have the same shape as used for digits and operator-names.

  Another optional argument may be used as last argument.\RightNote{\mstrelease{1.3c}}
  Similarly as its
  use with §\Mathastext§ this makes the declared math version inherit, for
  things not modified by \mst like large symbols, the font set up of the math
  version whose name was passed as optional argument (typical use will be
  with |[bold]|).

\item \mstcmd{MTboldvariant}\marg{var}: when used before §\Mathastext§,
  specifies which bold
  (|b|, |sb|, |bx|, \dots) to be used by \cs{mathbf} (and
  \cs{boldmath}). Default is the \cs{bfdefault} at the time of
  loading \mst. When used before the declaration
  of a version, decides the way \cs{mathbf} will act in this version.
\item \mstcmd{MTEulerScale}\marg{factor}: scales the Euler font by
  \meta{factor}.
\item \mstcmd{MTSymbolScale}\marg{factor}: scales the Symbol font by
  \meta{factor}.
\item \mstcmd{MTitgreek}, \mstcmd{MTupgreek}, \mstcmd{MTitGreek},
  \mstcmd{MTupGreek}: these commands are active in case the \blueit{LGRgreek}
  option was used; they act as the options of the similar names §itgreek§,
  §upgreek§, §itGreek§, §upGreek§, but only for the Greek letters in the
  versions yet to be defined.  Their effect become recorded only when the
  version is declared via §\Mathastext§ or §\MTDeclareVersion§.
\item \mstcmd{MTgreekfont}\marg{fontfamily}: a command with a mandatory argument
  which specifies the font family for Greek letters in all \mst math versions
  declared afterwards via §\Mathastext§ or §\MTDeclareVersion§. Only
  effective if §LGRgreek§ (or §LGRgreek+§) or §selfGreek§ option was passed to the package.

  Check the §LGRgreek§ documentation for some relevant information.
\end{enumerate}

\subsubsection{Commands for body or math}

\begin{enumerate}[label=$\bullet$, leftmargin=1em]
\item \mstcmd{MTversion}\oarg{nametext}\marg{namemath},
  §\MTversion§$\ast$\marg{namemath}, also known as
  \mstcmd{Mathastextversion} (and as \cs{MTVersion}, and
  \cs{mathastextversion}):
  \begin{enumerate}[label=$\bullet$]
  \item the non-starred version changes
    \emph{both} the document text fonts and the math fonts (for those characters
    treated by \mst): the mandatory argument is the math version to be used
    for math; the optional argument is the name of (another) \mst-declared math
    version, the font which was chosen during its declaration will be set as
    document text font (and |\familydefault| etc\dots also are
    redefined). In the absence of the optional argument, the mandatory one is
    used. The versions \emph{must} be either |normal|, or |bold|, or previously
    declared ones via §\Mathastext§ or §\MTDeclareVersion§. 
  \item the starred variant\RightNote{\mstrelease{1.3c}} does the math set-up, but changes \emph{nothing} to
    the text fonts (see \autoref{sec:mathversions} for a description of the math
    set-up, which summarizes 
    what is done additionally to only using \LaTeX{}'s |\mathversion|).
  \end{enumerate}
  §\MTversion§\oarg{nametext}\marg{namemath} does §\MTeverymathdefault§
  (except for |\MTversion{normal}| and |\MTversion{bold}| under package option
  |subdued|), which in particular activates the insertion of skips around
  letters specified by §\MTsetmathskips§ and also, if the font used is not
  oblique the insertion of italic corrections (for better positioning of
  subscripts; see the discussion in \autoref{sec:ic}). Under the §frenchmath§
  option the package checks separately the letter shape for lowercase and
  uppercase. 

  \RightNote{\mstrelease{1.3j}}§\MTversion§ also does §\MTexistsdoesskip§,
  §\MTforalldoesskip§, and also §\MTprimedoesskip§,
  \csb{MTmathoperatorsobeymathxx}, except under the |subdued| option for
  \emph{normal} and \emph{bold}, in which case it does the opposite actions.

\item \mstcmd{hbar}: this macro is by default redefined (in a way compatible with
  the |italic| option) combining the |h| letter and the \={ } accent from the
  \mst font. Note that \cs{mathrm}|{\hbar}| and \cs{mathbf}|{\hbar}| will
  work and that \cs{hbar} does scale in subscripts and exponents. Since
  \mstrelease{1.3u}, this is a priori compatible with all 8bits text font
  encodings\RightNote{\mstrelease{1.3u}} supporting the |\=| text accent in
  the LaTeX way.%
%
\footnote{\RightNote{\mstrelease{1.3u}}The horizontal skips for letter |h| from
  \csb{MTsetmathskips} are ignored for \cs{hbar}.}
\footnote{\RightNote{\mstrelease{1.3u}}The \cs{hbar} redefinition is canceled in normal and
  bold math versions under the |subdued| option.}
  
\item \mstcmd{fouriervec}: this is a |\vec| accent taken from the Fourier font;
the \ctanpkg{fourier} package need not be loaded. Active only
if option §fouriervec§.
\item \mstcmd{pmvec}: this provides a poor man \cs{vec} accent command, for
upright letters. It uses the right arrow. Does not change
size in subscripts and exponents.
\item \RLNote{new description:}{\mstrelease{1.3za}}\mstcmd{Mathnormal}, \mstcmd{Mathrm},
  \mstcmd{Mathbf}, \mstcmd{Mathit}, \mstcmd{Mathsf}, \mstcmd{Mathtt}: they use the
  \mst-ified fonts.  By default, \mstcmd{mathnormal}, \mstcmd{mathrm},
  \mstcmd{mathbf}, \mstcmd{mathit}, \mstcmd{mathsf}, \mstcmd{mathtt} are redefined
  to map to these new commands using the \mst fonts.  The option
  §defaultalphabets§ tells to keep them with their original
  meanings.  Alternatively the original commands can be saved
  under other names before loading \mst: the underlying
  architecture is not deleted by the package, and aliases
  defined before loading \mst will work as expected.
\item \mstcmd{mathnormalbold}: a bold version of \cs{mathnormal}, i.e. picks
  up the math alphabet used for ascii letters as mathematical variables, but
  in a bold weight.  When the package typesets such letters in the same shape
  as for operator names (i.e.\@ neither §italic§ option nor the
  §\MTlettershape§ command have been used) the output is as the one of
  §\mathbf§.

   This command is also made available under §subdued§ option in
   the ``normal'' and ``bold'' math versions, as \LaTeX\ does not define it a
   priori, contrarily to §\mathbf§ and other math alphabet commands.
 \item \RightNote{\mstrelease{1.3y}}\mstcmd{mathgreekup}: math alphabet, only available
   under §LGRgreek§ (or §LGRgreeks§) option, which gives access to `upright'
   Greek letters (picked up from a font available in |LGR|-encoding).  Note
   that the package also defines \cs{alphaup}, \dots, \cs{piup}, \dots\
   mathematical character tokens, see \autoref{sec:newgreek}.  What
   ``\texttt{up}'' shape really means may be math version dependent.  It is
   configurable in the preamble via re-defining §\MTgreekupdefault§ and then
   declaring the math version via §\Mathastext§ (with optional argument if for
   a math version other than the ``normal'' one), or §\MTDeclareVersion§.  The
   font used is also math version dependent: it is the one which was similarly
   configured via usage of §\MTgreekfont§ prior to the §\Mathastext§ or
   §\MTDeclareVersion§ step.  In absence of any such configuration in the
   preamble, it will be (in all math versions) the family default at time of
   loading the package (which thus has then to be available in \texttt{LGR}
   encoding; it is not a problem if the family default has no \texttt{LGR}
   support as long as suitable usage of §\MTgreekfont§ later on configures a
   suitable font).

  \RightNote{\mstrelease{1.3za}}Also \mstcmd{mathgreekupbold}.

\begin{footnotesize}
  These math alphabets are also available under §subdued§ option in the
  ``normal'' and ``bold'' math versions, as \LaTeX\ does not (a priori) define
  analog ones, so \mst has no reason not to leave them live.  Note though that
  |\mathgreekup{\pi}| will work only if the original \cs{pi} is of ``variable
  family type'' which is not the case except if some math package handling
  Greek was used, but then why load \mst with option §LGRgreek§?

  But you can use |\mathgreekup{p}| as the slot number of
  \texttt{p} in the \LaTeX\ font for mathematical letters is the same as the slot
  number of $\pi$ in \texttt{LGR} encoding.

  Or, use rather \cs{piup} because it is not undefined by \mst in §subdued§
  normal mode, as \LaTeX\ has no a priori definition for it.  Or use (but
  why?) |\mathgreekup{\piit}|.

  The \texttt{LGR} font family used will be the latest one configured by
  §\MTgreekfont§ usage followed by §\Mathastext§ (\emph{without} optional
  argument) in the preamble which is what is needed to modify the non-subdued
  aspects of subdued ``normal'' math; if no such configuration was done, the
  font family will be the family default found at time of loading the package.

  Worse: $\Delta$ is per \LaTeX\ default of variable family type but its slot
  number in its assigned font is not at all the one of the \texttt{LGR}
  encoding, so |\mathgreekupbold{\Delta}| will give some unrelated
  glyph.  This is because \mst restores the pristine \cs{Delta} in §subdued§
  normal mode to its original meaning.  But it keeps its own defined
  \cs{Deltaup} and \cs{Deltait}, so you can use |\mathgreekupbold{\Deltaup}|
  for example.  Or |\mathgreekupbold{D}| as the mathematical letter \texttt{D}
  slot number in \LaTeX\ is also the one of $\Delta$ in \texttt{LGR} encoding.

  I am sorry for such lengthy explanations, but this is to comment on why \mst
  keeps also in §subdued§ normal math some of its Greek related functionality,
  if option §LGRgreek§ was used.  Most \mst users will not use
  the §subdued§ option anyhow.\par
\end{footnotesize}

\item \RightNote{\mstrelease{1.3y}}\mstcmd{mathgreekit}: math alphabet, only available
  under §LGRgreek§ (or §LGRgreeks§) option, which gives access to `italic'
  Greek letters (picked up from a font available in |LGR|-encoding).  The
  actual shape is configurable via re-defining §\MTgreekitdefault§ and then
  redeclaring the math version via §\Mathastext§ (with optional argument if
  for a math version other than the ``normal'' one), or §\MTDeclareVersion§.

  \RightNote{\mstrelease{1.3za}}Also \mstcmd{mathgreekitbold}.

  \begin{footnotesize}
    See the discussion of §\mathgreekup§ for some \TeX\ hacker level
    information on what happens with §subdued§ option 
    in the ``normal'' (or ``bold'') math version.\par
  \end{footnotesize}
\item \mstcmd{inodot}, \mstcmd{jnodot}: the corresponding glyphs in the \mst-ified
  font for use in math mode. By default, |\imath| and |\jmath| are redefined to use
  them. Since \texttt{1.3t}, these macros obey the \texttt{subdued}
  regime.
\item \mstcmd{MathEuler}, \mstcmd{MathEulerBold}: math alphabets to access
all the glyphs of the Euler font, if option |eulergreek| (or
|eulerdigits| was passed to the package.
\item \mstcmd{MathPSymbol}: math alphabet to access the Symbol font.
\item when one of the options \blueit{symbolgreek},
  \blueit{eulergreek}, or \blueit{selfGreek} is passed to the package
  the capital Greek letters which look like their Latin
  counterparts acquire  names: \cs{Digamma},
  \cs{Alpha}, \cs{Beta}, \cs{Epsilon}, \cs{Zeta},
  \cs{Eta}, \cs{Iota}, \cs{Kappa}, \cs{Mu}, \cs{Nu},
  \cs{Omicron}, \cs{Rho}, \cs{Tau}, \cs{Chi} (no
  \cs{Digamma} for Symbol). Also an \cs{omicron}
  control sequence is provided.
\item |LGR| Greek and `var'-letters: only the
  \cs{varsigma} is available in this encoding, so using
  for example \cs{varphi} will load the previous default math
  font. It might thus be suitable when recompiling
  already written \LaTeX{} sources to add to the preamble
  \cs{let}\cs{varphi}$=$\cs{phi},
  \cs{let}\cs{varepsilon}$=$\cs{epsilon}, etc\dots,
  in case only the `variant' form of the letter was used
  in the documents.
\item \hypertarget{symbolmisc}{Miscellaneous mathematical symbols} from the
  postscript Symbol font are made available (or replaced) by option
  §symbolmisc§.\footnote{option \blueit{asterisk} is also required to treat the
    $*$. 
    Recall from \autoref{sec:mathxx} that the asterisk in math mode (also
    when using the control sequence \cs{ast}) appears then to \TeX{} to be
    a composite object.}
  \MTactiveasterisk They are
  \cs{prod}~$\prod$ \cs{sum}~$\sum$ \cs{implies}~$\implies$
  \cs{impliedby}~$\impliedby$ \cs{iff}~$\iff$ \cs{shortiff}~$\shortiff$
  \cs{to}~$\to$ \cs{longto}~$\longto$ \cs{mapsto}~$\mapsto$
  \cs{longmapsto}~$\longmapsto$ \cs{aleph}~$\aleph$ \cs{inftypsy}~$\inftypsy$
  \cs{emptyset}~$\emptyset$ \cs{surd}~$\surd$ \cs{nabla}~$\nabla$
  \cs{angle}~$\angle$ \cs{forall}~$\forall$ \cs{exists}~$\exists$
  \cs{neg}~$\neg$ \cs{clubsuit}~$\clubsuit$ \cs{diamondsuit}~$\diamondsuit$
  \cs{heartsuit}~$\heartsuit$ \cs{spadesuit}~$\spadesuit$
  \cs{smallint}~$\smallint$ \cs{wedge}~$\wedge$ \cs{vee}~$\vee$ \cs{cap}~$\cap$
  \cs{cup}~$\cup$ \cs{bullet}~$\symbolbullet$ \cs{div}~$\div$ \cs{otimes}~$\otimes$
  \cs{oplus}~$\oplus$ \cs{pm}~$\pm$ \cs{ast}~$\ast$ \cs{times}~$\times$
  \cs{proptopsy}~$\proptopsy$ \cs{mid}~$\mid$ \cs{leq}~$\leq$ \cs{geq}~$\geq$
  \cs{approx}~$\approx$ \cs{supset}~$\supset$ \cs{subset}~$\subset$
  \cs{supseteq}~$\supseteq$ \cs{subseteq}~$\subseteq$ \cs{in}~$\in$
  \cs{sim}~$\sim$ \cs{cong}~$\cong$ \cs{perp}~$\perp$ \cs{equiv}~$\equiv$
  \cs{notin}~$\notin$ \cs{langle}~$\langle$ \cs{rangle}~$\rangle$. And a
  \cs{DotTriangle}~$\DotTriangle$ is made available by option §symbolre§ (which
  overwrites \cs{Re} and \cs{Im}: $\Re,\Im$). The \cs{inftypsy} and
  \cs{proptopsy} have these names to leave up to the user the choice to replace
  (or no) the original (larger) \cs{infty} $\infty$ and \cs{propto} $\propto$.

  Regarding the \cs{prod} and \cs{sum} commands: they will use the Symbol
  glyphs $\prod\sum$ in inline math, and in display math the Computer Modern
  ones (or whatever is set up by other packages; here we have the symbols from
  |txfonts|): \[\prod\sum\] The package
  provides \cs{prodpsy} and \cs{sumpsy}: if one really wants in all
  situations the Symbol glyphs, one can do \cs{let}\cs{prod}\cs{prodpsy} and
  \cs{let}\cs{sum}\cs{sumpsy}. Also \cs{MToriginalprod} and \cs{MToriginalsum}
  will refer to the \cs{prod} and \cs{sum} before redefinition by the
  package: this is to allow constructs such as |$\displaystyle\MToriginalprod$|
  or |\[\textstyle\MToriginalprod\]|, because they would not work with the
  \cs{prod} and \cs{sum} as re-defined by the package.

\end{enumerate}


\subsection{Commands for expert usage}

A few preliminary comments, mainly destined to advanced users aware of some
\TeX\ innards (more extensive explanations are to be found in the code
comments).

The timing for actions of \mst falls into three cases:

\begin{enumerate}
\item things done by \mst itself during its loading (some are delayed to
  |\begin{document}|),
\item things done as the result of user commands, either in the preamble or in
  the body of the document, (but note that some commands if used in preamble
  have a real effect only  at the time of |\begin{document}|),
\item things done everytime math mode is entered.
\end{enumerate}

At \mstrelease{1.4}\RLNote{changed:}{\mstrelease{1.4}} a very significant
change took place: the last category, the one of things done everytime math mode
is entered, has become \emph{empty}.%
%
\footnote{There ia always an exception to a good
rule, and here it is: only with \LuaLaTeX{} engine, a certain
command is executed as part of \cs{everymath}.  For details see
\csb{MTfixfonts}.}

The §everymath§ option added at \mstrelease{1.4} re-establishes the legacy
behavior.  Except for ascii letters: they will not even then be made
mathematically active at each entrance in to math mode, but only once at time
of package loading (if not §subdued§) and also when using §\MTversion§ (for
non-§subdued§ math versions).

\begin{shaded*}
Under §everymath§ option some commands described here as being usable
everywhere have in fact an effect only if used externally of math mode.
The documentation is only accurate for the default \mstrelease{1.4}
configuration, not for the legacy one as re-enacted by §everymath§.
\end{shaded*}

\subsubsection{Expert commands which are preamble-only}

\begin{enumerate}[label=$\bullet$, leftmargin=1em]
\item \mstcmd{MTgreekupdefault}:\RightNote{\mstrelease{1.3y}} a command with
  no argument whose expansion specifies, under §LGRgreek§ regime, the
  shape for the `|up|' Greek control sequences (and for the no-postfix
  Greek control sequences under §upgreek§ option) in all \mst math
  versions declared \emph{afterwards} via \cs{Mathastext} or
  \cs{MTDeclareVersion}.  The a priori default for this shape is `|n|'
  (without the quotes).  See
  \autoref{sec:newgreek}.

  This command can also be defined \emph{prior} to loading the package,
  as the package itself only does:
  \centeredline{|\providecommand*\MTgreekupdefault{n}|}

\item \mstcmd{MTgreekitdefault}:\RightNote{\mstrelease{1.3y}} a command with
  no argument whose expansion specifies, under §LGRgreek§ regime, the
  shape for the `|it|' Greek control sequences (and for the no-postfix
  Greek control sequences under §itgreek§ option) in all \mst math
  versions declared \emph{afterwards} via \cs{Mathastext} or
  \cs{MTDeclareVersion}.  The a priori default for this shape is `|it|'
  (without the quotes).
  See \autoref{sec:newgreek}.

  This command can also be defined \emph{prior} to loading the package,
  as the package itself only does:
  \centeredline{|\providecommand*\MTgreekitdefault{it}|}
\end{enumerate}


\subsubsection{Expert commands usable everywhere}\label{sec:cmds}

\begin{enumerate}[label=$\bullet$, leftmargin=1em]

  \item \mstcmd{MTcustomgreek}:\RightNote{\mstrelease{1.3d}} in case \mst has been loaded with one of its
    Greek related options, this activates the corresponding
    customization of Greek letters in math mode. It is issued
    automatically by the package in the preamble (except if loaded with
    |subdued| option) and at each switch of math version via
    |\MTversion| or |\MTversion*| (except for the normal and bold math
    versions in subdued mode). Also available as
    |\Mathastextcustomgreek|. May be used even inside of math mode.

  \item \mstcmd{MTstandardgreek}:\RightNote{\mstrelease{1.3d}} in case \mst was loaded with one of the Greek
    related options this command reverts the customization, it resets the Greek
    letters to their definitions in force at package loading time. Can be used
    in the preamble, but is mainly for the document body (may even be used
    inside math mode ...). Done automatically
    under the |subdued| option when switching to the normal or bold math
    version. Also available as |\Mathastextstandardgreek|.


\DeleteShortVerb{\|}%

\item \mstcmd{MTsetmathskips}\marg{a-z|A-Z}\marg{muglue\_before}\marg{muglue\_after}:
%
\MakeShortVerb{\|}%
%
  is\RightNote{\mstrelease{1.3a}} used to specify extra skips (or rather mu glue) to be
  inserted in math mode, before and after a letter. The rationale is that
  standard text fonts used in math mode may sometimes cause glyph (near-)
  collisions with math symbols, as \TeX{} has some implicit expectations on the
  design of fonts for math letters. 

  \begin{snugshade}
    These extra skips around letters are set at their natural width and do not
    add any stretchability or shrinkability to the math formula as a whole,
    nor do they result in extra potential break points.
  \end{snugshade}
  
  Random (silly) examples:
  \centeredline{|\MTsetmathskips{x}{\medmuskip}{\thickmuskip}|} \centeredline
  {|\MTsetmathskips{A}{.5mu}{2.3mu}|} and the effect:
  \begingroup\MTversion{italic}\MTsetmathskips{x}{\medmuskip}{\thickmuskip}%
             \MTsetmathskips{A}{.5mu}{2.3mu}%
  $vwxyzABC^{vwxyzABC}$\endgroup. The effect obeys the usual \LaTeX{} scoping
  rules.

  The first argument of §\MTsetmathskips§ may be any expandable code giving a
  letter; this facilitates use of |\MTsetmathskip| in |\@for| loops such as
  this one:
\begin{verbatim}
\makeatletter
\@for\@tempa:=a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z\do{%
              \MTsetmathskips{\@tempa}{2mu}{2mu}}%
\makeatother
\end{verbatim}

  \begin{snugshade}
    \emph{\color{magenta}\bfseries Starting with |v1.3i|:} the extra skips are
    \emph{not} applied to the letters within the scope of math alphabet
    commands, or the letters from operator names (pre-defined or user
    declared).
  \end{snugshade}

{\footnotesize
  Note that contrarily to the \csb{MTexistsskip}, \csb{MTforallskip}, and
  \csb{MTprimeskip} commands described next, these extra skips (which may be
  specified in the preamble) are not recorded in the definition of the math
  version (as defined via \csb{Mathastext} with its optional argument or via
  \csb{MTDeclareVersion}). The declared skips hold thoughout the document
  until modified or canceled, independently of math versions (of
  course, \mst cancels the skips in the normal and bold math versions if
  package option \blueit{subdued} was used).\par}

\DeleteShortVerb{\|}

\item \mstcmd{MTunsetmathskips}\marg{a-z|A-Z}:
%
\MakeShortVerb{\|}
%
  cancels the skips 
  for that letter (they are not set to |0mu| but completely removed).

  The argument may be a macro (or any expandable code) expanding to a letter.


\item \RightNote{\mstrelease{1.3j}}\mstcmd{MTnormalexists}, \mstcmd{MTexistsdoesskip}: the
  latter (done by default if not |subdued|, and also on each use of
  |\MTversion| in the body of the document) makes it so that $\oldexists$
  takes into account the math glue as specified by §\MTexistsskip§. The
  former is its opposite.

\item \mstcmd{MTexistsskip}\marg{math glue}: specifies the amount of skip or more
  generally glue to put after each $\oldexists$ math symbol. Indeed, upright
  letters (or digits for that matter) often appear to be positioned a bit too
  close to the quantifier: $\oldexists\mathrm{B}$. The package default is to
  add a |1mu| skip (this default is set to zero in the case of |italic|):
  $\oldexists\mskip 1mu\mathrm{B}$. One can change the default with the
  following syntax: |\MTexistsskip{2mu plus 1mu minus 1mu}|, which if used in
  the preamble and followed with a \csb{Mathastext} command (or
  \csb{MTDeclareVersion}), will be recorded in the definition of this math
  version (and subsequent ones). One may also use the command at any time in
  the document. In the case of the option |subdued|, the skip is canceled in
  the \emph{normal} and \emph{bold} math versions.
  In the case of the option |italic|, the
  default skip is set to zero.

\item \RightNote{\mstrelease{1.3j}}\mstcmd{MTnormalforall}, \mstcmd{MTforalldoesskip}: the
  latter (done by default if not |subdued|, and also on each use of
  |\MTversion| in the body of the document) makes it so that $\oldforall$
  takes into account the math glue as specified by §\MTforallskip§. The
  former is its opposite.

\item \mstcmd{MTforallskip}\marg{math glue}: the default is to add a |.6667mu| math
  skip after each $\oldforall$ (except with the option |italic| for which the
  default skip is set to zero). Compare $\oldforall\mskip.6667mu\mathrm{F}$
  (has the skip) with $\oldforall\mathrm{F}$ (has no skip). Use this command
  in the preamble to set up the skip or glue to be used in the \emph{next to
    be declared} math versions. In the case of the option |subdued|, the skip
  is canceled in the \emph{normal} and \emph{bold} math
  versions.
  In the
  case of the option |italic|, the default skip is zero for all math versions.
  One may use the command at any location in the document.

\item \RightNote{\mstrelease{1.3j}}\mstcmd{MTnormalprime},
  \mstcmd{MTprimedoesskip}: the latter (done by default if not |subdued|,
  and also on each use of \csb{MTversion} in the body of the document except
  for the §subdued§ \emph{normal} and \emph{bold} math version) makes it so
  that $'$ takes into account the math glue as specified by
  §\MTprimeskip§. The former is its opposite. In all cases the right quote
  |'| is a mathematically active character throughout the document producing
  ${}'$ as is the default in \TeX, it is only its meaning which changes to
  include or not an extra skip.

  \begin{footnotesize}
    Even though §\MTprimedoesskip§ is not done in the §subdued§ case, it is
    \emph{not} a no-op even then in the preamble or in the \emph{normal} and
    \emph{bold} math versions.\par
  \end{footnotesize}

\item \mstcmd{MTprimeskip}\marg{math glue}: specifies the amount of math
  skip to add before the derivative glyph.  The default iniitial value is
  |0.5mu|, except with the |italic| option where it is |0mu|.  In the case
  of the option |subdued|, the skip is canceled in the \emph{normal} and
  \emph{bold} math versions.

\item \mstcmd{MTnormalasterisk}, \mstcmd{MTactiveasterisk}: the latter will
  use for |*| and |\ast| the text font asterisk, suitably lowered; the former
  if used in the preamble tells \mst to not modify the non-\mst situation, or
  if used in the body to revert to it. Both are no-op's in absence of option
  §asterisk§.

\begin{footnotesize}
  A legacy feature is that §\MTactiveasterisk§ is \emph{not} a no-op in
  §subdued§ \emph{normal} or \emph{bold} math versions, and does let the
  asterisk obey the §\MTlowerast§ configuration, if used explicitly by user
  (even in the preamble). 

  At \mstrelease{1.4}\RLNote{changed:}{\mstrelease{1.4}} \mst checks at
  |\begin{document}| (or each time §\MTaciveasterisk§ is made use of) if
  * is a Babel shorthand (which I far as I know is the case of no
  language) or is already mathematically active.  In the latter case the
  * is not modified in math mode; and it is not modified either if
  found to be catcode active but not a \ctanpkg{babel} shorthand.  In
  contrast, the \cs{ast} will always be set to obey §\MTlowerast§
  configuration after §\MTactiveasterisk§.

\end{footnotesize}

\item \mstcmd{MTlowerast}\marg{dimen}: under option §asterisk§
  a \cs{raisebox} command is
  used to lower the text asterisk to produce a reasonable math
  asterisk. The package uses this command initially with
  argument |0.3\height|, this will have to be fine-tuned for
  each given text font but worked out ok with the fonts we
  tried.  The dimension argument will be used also in
  sub-scripts and sub-sub-scripts, so it is best not to use an
  absolute dimension.  The dimension specification is for text
  it can not be with |mu| unit.

\item \mstcmd{MTmathoperatorsobeymathxx}, \mstcmd{MTmathoperatorsdonotobeymathxx}: the
  former is done by default, it makes operator names obey math alphabets. See
  also \autoref{sec:mathxx}. This functionality \emph{does
    {\normalfont\bfseries not} rely}
  on ``math active characters''. Automatically issued by each \cs{MTversion},
  except under option |subdued| when switching to \emph{normal} or \emph{bold}.

\item \mstcmd{MTmathactiveletters}:\RightNote{\mstrelease{1.3}}
   `math activation' of all ascii Latin
  letters. This is done by the package automatically except under the
  §subdued§ option.

  At \mstrelease{1.4}\RLNote{changed:}{\mstrelease{1.4}} its behavior was
  modified significantly: instead of setting some toggle obeyed only at
  entrance of math mode, it acts on the spot immediately.
\begin{snugshade}
  Formerly, this command was only a configuration toggle with no immediate
  impact (and was not usable from inside math mode).  Indeed, the \mst work of
  mathematical activation was done (or not done) \emph{each time} math mode
  was entered (if not in §subdued§), and the ascii letters kept standard
  mathcodes outside of math mode.

  The command now does the mathematical activation on the spot and the meaning
  of the active shape of the ascii letters --- a priori undefined because
  typesetting a document with an active ascii letter is near impossible, as no
  \LaTeX{} command name used in the document can contain it --- is modified
  here and then; but of course the catcodes are not modified only the
  mathcodes are. Except if \mst is loaded with the §subdued§ option, this
  mathematical activation is executed already at package loading time.

  If with the §subdued§ option, the command is inactive in the preamble, as
  well as in the \emph{normal} and \emph{bold} math versions.  In all cases it
  gets (re-)executed automatically when §\MTversion§ is used for activating a
  non-subdued math version.

  \begin{footnotesize}
    The new situation may be dangerous if the document author makes a letter,
    say |A|, catcode active at some point, with a definition of the active
    state using |\string A|.  As \mst has (earlier, in the preamble) set |A|
    to be mathematically active as well, and as the \cs{string} changes
    nothing to that, an infinite loop will be triggered by such an |A| in math
    mode.

    But, having an active ascii letter can only be in very localized portions
    of a document, and only be authored by experts.  The experts should
    carefully make sure the mathcode of the letter is not active if they set
    the catcode to active and let the active meaning use \cs{string} on the
    letter itself, thus we can trust that the mathematical activation done
    earlier by \mst is undone and there will be no problems.\par
  \end{footnotesize}

  This \mstrelease{1.4} change may thus need to be followed by some
  adjustments in some quite special circumstances caused by some expert
  interventions.

  See \autoref{sec:mathskips} and \autoref{sec:ic} for the rationale of this
  mathematical activation, and \autoref{ssec:hackingletters} for ways to
  use it for other goals.
\end{snugshade}
  \begin{footnotesize}
    If you do want mathematically active letters also in subdued \emph{normal}
    or \emph{bold} math versions (to apply tricks such as those of
    \autoref{ssec:hackingletters}) there is \cs{mst@mathactivateletters} which
    does not check the §subdued§ status.\par
  \end{footnotesize}
  
\item \mstcmd{MTmathstandardletters}:\RightNote{\mstrelease{1.3}}
  turns off the mathematical active
  ascii letters, i.e.\@ reverts their mathcodes to package font configuration.
  Here ``standard'' only means
  that the letters will not be mathematically active, but they are still under the
  influence of \mst regarding the typeface they use, so they are only
  ``standard'' from \mst point of view.

  At \mstrelease{1.4}\RLNote{changed:}{\mstrelease{1.4}} its behavior was
  modified: instead of setting some toggle obeyed only at entrance of math
  mode, it acts on the spot immediately.
  \begin{snugshade}
    §\MTmathstandardletters§ will not try to restore the meaning associated to
    the catcode active variant of the letter token which may have been in place
    at the time of §\MTmathactiveletters§.  This meaning is not saved for
    later reset.

    \emph{Except} if the \emph{letter} was an active Babel-shorthand at the time
    of §\MTmathactiveletters§, which is in fact almost impossible to achieve
    via the \ctanpkg{babel} interface.

    And if the letter was catcode-active due to user action,
    §\MTmathactiveletters§ will not have made it mathematically active, nor
    will it have modified its active meaning.  So the active meaning may get
    overwritten only for a letter having a normal catcode at time of
    §\MTmathactiveletters§ but which for some reason has some meaning
    associated to its catcode active variant.
  \end{snugshade}

\item \mstcmd{MTmathactivedigits}:\RLNote{new:}{\mstrelease{1.4}}
  is a no-op except under option
  §activedigits§.  It then makes all digits mathematically active and is
  executed during package loading, except if §subdued§.  It is again executed
  when entering any non-§subdued§ math version in the document body.  See
  \autoref{ssec:hackingletters} for an example of use.

  \begin{footnotesize}
    If you do want mathematically active digits also in subdued \emph{normal}
    or \emph{bold} math versions (to apply tricks such as those of
    \autoref{ssec:hackingletters}) there is \cs{mst@mathactivatedigits} which
    does not check the §subdued§ status.\par
  \end{footnotesize}

\item \mstcmd{MTmathstandarddigits}:\RLNote{new:}{\mstrelease{1.4}}
  a no-op except under option
  §activedigits§.  Under this option it resets the digits to their normal
  mathcodes as configured by the package.

\item \mstcmd{MTicinmath}: this command is executed by default by \mst except in
  case of option |subdued| or if the user chosen letter shape is oblique (|it|
  or |sl|). It tells \mst to add italic corrections after all letters in math
  mode, except within the scope of math alphabets.

  This\RLNote{changed:}{\mstrelease{1.4}}
  command and the next ones in this item can be used anywhere in the
  document and even from inside math mode.  In case of §subdued§ option, using the
  command from within the preamble remains without effect, as the
  document body will start in the subdued normal math version anyhow.
  Each \cs{MTversion} in the body reemits \cs{MTicinmath} (in case of
  non-oblique letter shape), except if the
  |subdued| option was used and the chosen math version is \emph{normal} or
  \emph{bold}.

  The effect of this and the other commands of this item is local to the group
  or environment in which it has been issued.

{\footnotesize

  The description above about the command not being executed if the letter
  shape is italic or slanted is not quite right, as it refers only to the
  act of inserting or not italic correction.  The
  §\MTmathactiveletters§ component is always executed, however it will be a
  no-op in |subdued| \emph{normal} and \emph{bold}.

  \mstcmd{MTnoicinmath}: this command deactivates the package added
  italic corrections. It can be used inside as well as outside
  of math mode (or in the preamble of the document).  Note that it does not
  deactivate the mathematical activation of the ascii letters.  Use
  §\MTmathstandardletters§ for that.

  \mstcmd{MTICinmath}, \mstcmd{MTnoICinmath}: only acts on the uppercase
  letters. But recall that \cs{MTicinmath} is done by default, thus
  using italic corrections only for uppercase needs to go via
  \cs{MTnoicinmath} then \cs{MTICinmath}.

 \mstcmd{MTicalsoinmathxx}: this command de-activates the de-activation of
  the italic corrections inside the arguments to the math alphabet
  commands.
  It can be issued inside as well as outside of math mode. Will be effective
  only if §\MTicinmath§ or §\MTICinmath§ is in force.
  To cancel its effect either enclose it in a group or
    environment or re-issue §\MTicinmath§ after it.

}

\item \mstcmd{MTeasynonlettersobeymathxx}, \mstcmd{MTeasynonlettersdonotobeymathxx}: the
  former is done by default, it makes characters \verb+.+, \verb+/+, \verb+|+,
  \verb+\+, \verb+#+, \verb+$+, \verb+%+, and \verb+&+
  (if not excluded by package options) obey math alphabet commands. See also
  \autoref{sec:mathxx}. This functionality does \emph{not} make the
  characters ``math active'' (but it does modify |\mathcode|'s, naturally).

\item \mstcmd{MTnonlettersobeymathxx}, \mstcmd{MTnonlettersdonotobeymathxx}: the former
  will make (except if excluded by relevant package options) \verb|!|,
  \verb|?|, \verb|,|, \verb|:|, \verb|;|, \verb|+|, \verb|-|, \verb|=|,
  \verb|(|, \verb|)|, \verb|[|, \verb|]|, \verb|<|, and \verb|>| obey the math
  alphabet commands (when not used as delimiters). These characters are made
  ``math active'', and each one now expands to two
  tokens. This makes for example |$a^!$| illegal input and
  it will have to be coded |$a^{!}$|. Hence, by default, the package does
  §\MTnonlettersdonotobeymathxx§.

\item \mstcmd{MTexplicitbracesobeymathxx}: extends an earlier §\MTnonlettersobeymathxx§
  to also treat  \verb|\{| and \verb|\}|. But then |\left\{|, |\right\}| must
  be coded |\left\lbrace|, |\right\rbrace| rather. There is also
  \mstcmd{MTexplicitbracesdonotobeymathxx}.

\item \RightNote{\mstrelease{1.3j}}\mstcmd{MTeverymathdefault}: this hook is executed by
  \csb{MTversion}\marg{version\_name} (but if under option |subdued|
  and switching to the \emph{normal} or \emph{bold} math version its default
  effect is overruled by an §\MTeverymathoff§ executed after it). Its
  default meaning is:
\begin{verbatim}
    \MTactiveasterisk % this has no effect without option asterisk
    \MTprimedoesskip  % this makes prime glyph obey extra space
    \MTeasynonlettersobeymathxx
    \MTicinmath       % this does \MTmathactiveletters, hence the extra
                      % skips from \MTsetmathskips are obeyed.
    \MTmathactivedigits % this is a no-op in absence of option activedigits
    \MTfixfonts       % only operant under LuaLaTeX.
\end{verbatim}
  {\footnotesize Under |subdued| option, switching to the
    \emph{normal} or \emph{bold} version does \csb{MTeverymathoff} which
    includes §\MTnonlettersdonotobeymathxx§.

    The default
    §\MTeverymathdefault§ which is issued when going back to a
    non-\emph{normal} or \emph{bold} math version doesn't do
    §\MTnonlettersobeymathxx§: thus it is up to the user to correct this if
    desired.


Notice also that \csb{MTversion}\marg{version\_name}, except for \emph{normal}
or \emph{bold} if |subdued| does \csb{MTforalldoesskip} and
\csb{MTexistsdoesskip}, which are not included in \cs{MTeverymathdefault}
actions as they are not related to \cs{everymath} and \cs{everydisplay}.\par

At \mstrelease{1.4}, the name of this command diverges somewhat from its
action as mathematical activation of ascii letters (or, optionally, of digits)
will happen on the spot and not during \cs{everymath} or \cs{everydisplay}
execution.\par
}

\item \RightNote{\mstrelease{1.3j}}\mstcmd{MTeverymathoff}: does §\MTnormalasterisk§,
  §\MTnormalprime§, §\MTnonlettersdonotobeymathxx§,
  §\MTeasynonlettersdonotobeymathxx§, §\MTmathstandardletters§,
  §\MTmathstandarddigits§\RightNote{\mstrelease{1.4}} and
  §\MTdonotfixfonts§.

    Automatically done by \csb{MTversion}|{normal}| (or |{bold}|) under option |subdued|
    (and
    also \csb{MTnormalexists} and
    \csb{MTnormalforall} are executed then).


  {\footnotesize \RightNote{\mstrelease{1.3i}}The commands
    |\url/\nolinkurl| of package |hyperref| and |\url| from |url.sty| (which
    use math mode under the hood) are patched by \mst to do §\MTeverymathoff§
    automatically: this is needed because \mst modifies anew some mathcodes
    \emph{each time math mode is entered,} hence may overwrite to some extent
    the specific preparations done by |{url,hyperref}.sty|.

    \RightNote{\mstrelease{1.4}}However, in some cases it may be interesting to
    be able to apply hacks as described in \autoref{ssec:hackingletters}.
    You can use now §\MTeverymathoff§ as a hook inside
    |\url| and |\nolinkurl| commands.  Perhaps redefine it (locally) to do
    all of the above except §\MTmathstandardletters§ and/or
    §\MTmathstandarddigits§, and use the \autoref{ssec:hackingletters}
    instructions to achieve special effects for some letters or digits in
    the URLs rendered via |\url| and |\nolinkurl|.
  \par
  }

\end{enumerate}

\subsubsection{Expert commands usable only outside of math mode}\label{sec:cmdsoutmath}

There is only one pair of commands here: §\MTfixfonts§ and §\MTdonotfixfonts§.
They are operant only under \LuaLaTeX{}.  As §\MTeverymathdefault§ and
§\MTeverymathoff§ use them, they arguably could have been listed here, but
only for engine \LuaLaTeX{}.

\small

\begin{enumerate}[label=$\bullet$, leftmargin=1em]

\item \RightNote{\mstrelease{1.3o}}\mstcmd{MTfixfonts}: this is operant only under
  \LuaLaTeX{}. It has the effect that each time math mode is entered macro
  \csb{MTfixmathfonts} will be executed. The latter forces so-called |base|
  mode for the used text font in math mode, in an effort to (only partially,
  see code comments) fix the fact that OpenType features such as Lining
  Figures were in some cases not being applied in math mode when one uses text
  fonts there (text fonts are declared by \LuaTeX+|luaotfload| to use |node|
  or |harf| mode, which are non-functional in math.) It is invoked automatically by the
  package (except for |normal| and |bold| math versions under |subdued|
  option), and in normal situations, there is no reason to use it directly.

  \RLNote{changed:}{\mstrelease{1.4}}The hack was updated at \mstrelease{1.4}
  in order to also handle fonts using |Renderer=HarfBuzz|.

% pas envie de perdre mon temps là-dessus. D'ailleurs peut-être déjà pour
% commencer bm ne fonctionne pas avec fontes OpenType.

% Notice (not tested) that package |bm| is presumably not compatible.

\item \RightNote{\mstrelease{1.3o}}\mstcmd{MTdonotfixfonts}: cancels the job of
  |\MTfixfonts|. Done automatically in §subdued§ mode when in the |normal| or
  |bold| math version; in normal contexts, there is no reason to use this
  command. Only operant under \LuaLaTeX.

\end{enumerate}

\subsubsection{Expert commands usable only in math mode}

\begin{enumerate}[label=$\bullet$, leftmargin=1em]

\item\RightNote{\mstrelease{1.3p}}%
\mstcmd{MTfixmathfonts}: this used to be an internal package macro
  but it is given a public name at \mstrelease{1.3p} because I discovered that
  |$..\hbox{\mathversion{foo}$..$}..$| causes an
  issue and one needs to invoke again \cs{MTfixmathfonts} \emph{after} the
  \verb|\hbox|, for some reason. To be used \emph{only} under \LuaLaTeX{} and only for
  such rare cases where it may be needed.\par

\end{enumerate}

\normalsize

\section{Package options}

\subsection{Summary of main options}

\begin{description}
\item[{\blueit{italic}}:] tells \mst to typeset the ascii letters in math
  using italic shape; indeed, its legacy historical default is to typeset them
  in roman (upright) shape.
\item[{\blueit{frenchmath}}:] lowercase ascii letters in italic shape,
  uppercase in upright shape.  Also lets the Greek letters, if the latter are
  under \mst influence, be upright, i.e.\@ also the lowercase ones.
\item[{\blueit{subdued}}:] tells \mst to not change the default fonts or the math
   alphabets for the normal and bold math versions.  The \mst-ification
   activates only after §\MTversion§\marg{version\_name} usage in the
   document body, where the \meta{version\_name} was declared as an \mst
   enriched math version in the preamble via §\Mathastext§\oarg{version\_name}
   or akin package commands.%
\item[{\blueit{LGRgreek}, \blueit{eulergreek}, \blueit{symbolgreek}}:] the
  Greek letters will be taken, respectively from the text font itself (which
  must be available in |LGR| encoding), or respectively the Euler or Symbol
  font.
\item[{\blueit{symbolmax}}:] all characters
  other than letters and digits, are taken from the
  Symbol font. This option also makes a number of
  further glyphs available, such as some basic
  mathematical arrows, and the sum and product
  signs. For documents with very simple needs in
  mathematical symbols, \mst with option
  §symbolmax§ may give in the end a PDF file size quite
  smaller than the one one would get without the
  package.%
%
\footnote{It is even better if compiled via \texttt{latex+dvipdfmx}.}

\item[{\blueit{defaultmathsizes}}:] prevents \mst from setting up, as it does
  per default, larger subscripts and superscripts in math mode, and from
  copying code from the \ctanpkg{moresize} package%
%
\footnote{Christian \textsc{Cornelssen}, \emph{Allows font sizes up to 35.83pt}, \url{https://ctan.org/pkg/moresize}.}
%
  in order to redefine \cs{Huge} and define a \cs{HUGE} command.
\end{description}

\subsection{Complete list of options}
\label{sec:opt}

 Some items are described succinctly as more developed descriptions were
 given earlier.  They may sometimes simplify by omission
 and not consider all possible configurations, particularly those
 resulting from usage of the package commands in the preamble to
 configure  math versions.

 Note that this list in not in alphabetical order, the items are grouped
 roughly by themes.  So, objectively, the best for the diligent reader is to
 read thoroughly all descriptions.
 \begin{enumerate}[label=$\bullet$, leftmargin=1em]
 \item \mstopt{basic}: only mathastextify (ascii) letters and digits.  Can
  be combined with either §nodigits§ or §noletters§.
 \item \mstopt{subdued}:  acts in a subdued way, which means that the \LaTeX\
  ``normal'' (default) and ``bold'' (triggered by \cs{boldmath} or
  \cs{mathversion}|{bold}|, undone by \cs{unboldmath} or on exit from a
  scope limiting context such as an environment) math versions are
  left (not quite: check \autoref{sec:subdued} for specifics) unchanged and the
  \mst action is triggered only when switching via
  §\MTversion§\marg{version\_name} (or its starred variant) in the document
  body to a version previously defined in the preamble via
  §\Mathastext§\oarg{version\_name} (or alternative declarative interface such
  as §\MTDeclareVersion§).
%
\footnote{Under this option
   \cs{MTversion\{normal\}} and \cs{MTversion\{bold\}} execute automatically
   \csb{MTmathoperatorsdonotobeymathxx}, \csb{MTeasynonlettersdonotobeymathxx},
   \csb{MTnonlettersdonotobeymathxx}, \csb{MTmathstandardletters}.}

 \item \mstopt{italic}: let the Latin letters (both lowercase and uppercase) use
   the italic shape (\cs{itdefault}) in math mode. If the package
   handles Greek letters, also lowercase (but not uppercase) Greek
   letters will use this a priori italic shape except if some other
   option such as \blueit{upgreek} was used.%
   \footnote{Since \texttt{1.3y}, in presence of the \blueit{LGRgreek}
     option in addition to \blueit{italic}, the \csb{MTgreekitdefault}
     shape is then used for lowercase Greek letters and
     \csb{MTgreekupdefault} for uppercase.}
 \item \mstopt{frenchmath}: configures the lowercase Latin letters to use
   italic shape (\cs{itdefault}), and uppercase Latin letters to be in
   same shape as for digits and operator names (i.e.\@ a priori
   \cs{shapedefault}).

   If the package handles Greek letters both
   lowercase (if under control of \mst, i.e. not for §selfGreek§)
   and uppercase Greek letters will use the same shape as
   operator names, except if some other option such as \blueit{itgreek}
   was used.%
   \footnote{Under \blueit{LGRgreek} and since \mstrelease{1.3y}, the
     \csb{MTgreekupdefault} is used for Greek letters if no other option
     such as \blueit{itgreek} was employed.}

   \begin{snugshade}
   \begin{footnotesize}
     This configuration (i.e.\@ that uppercase Latin letters will
     be in the same shape as the one for digits and operator
     names) is \textbf{not} undone in the §subdued§ ``normal''
     and ``bold'' math versions.  It holds throughout the
     document.

     As a bonus, note that doing
     \centeredline{|\usepackage[basic,subdued,frenchmath]{mathastext}|} 
     provides a simple manner to obtain the
     expected shapes of Latin letters in French mathematical typography, in
     an arbitrary math font configuration from other packages, in case those
     packages do not provide an option to achieve this.

     But, even if \mst is used via §LGRgreek§ to configure Greek letters, on
     the other hand the control sequences for Greek letters are all really
     restored to their defaults (or whatever was configured by other packages
     loaded prior to \mst)
     in the subdued ``normal'' math version, which limitates the usefulness of
     the previous paragraph.

     On the bright side, the \cs{alphaup}, \cs{alphait}, \dots, control
     sequences will however be with their \mst meaning, see §LGRgreek§ for
     more information.

     It is \emph{not} possible (except of course if one is ready to do some
     low-level \TeX\ coding to re-execute where needed in the document body a
     few lines of the package internals with appropriate modifications; I said
     \TeX, not \LaTeX, as the latter is very much decided to make impossible
     any kind of math configuration change at this level if not in the
     preamble) to achieve a ``French math'' style only in some math versions
     and not in others.  The reason why is that to achieve distinct shapes for
     uppercase versus lowercase Latin letters, the uppercase letters are
     assigned internally to the font (which can change from math version to
     math version) used for operator names.  One can still make them slanted
     using §\MTshape§, but this will also slant the digits, as they are picked
     from the same font.  On the other hand if we do not use the §frenchmath§
     option, both uppercase and lowercase Latin letters are always assigned to
     the same font, so no math version can give them separate distinct shapes.
     For a small demo though, one can naturally painstakingly use either the
     §\mathrm§ or §\mathnormal§ alphabet commands to obtain, say under the
     §italic§ option and no additional configuration, respectively the up
     shape and the italic shape.
     \par
   \end{footnotesize}
   \end{snugshade}


%\begin{footnotesize}
  None of the §frenchmath§, §frenchmath*§, and §frenchmath+§ options bear any
  direct connection with the \ctanpkg{frenchmath} package by Antoine
  \textsc{Missier} (this is in contrast with the fact that the §decimalcomma§
  option is directly related with the \ctanpkg{decimalcomma} package by the
  same author as it tells \mst to require it).  But see
  \autoref{ssec:frenchmath} for important information about the utility of
  §frenchmath*§ if the two packages are to be used concurrently.\par
%\end{footnotesize}


\item \mstopt{defaultalphabets}: \RLNote{new behavior}{\mstrelease{1.3za}}\mst
  always defines \cs{Mathnormal}, \cs{Mathrm}, \cs{Mathbf} etc... to
  refer to the \mst-ified text fonts, and redefines the math
  alphabets \cs{mathrm}, \cs{mathit}, \cs{mathtt} etc\dots{} (but
  not \cs{mathcal} of course) to use them.  To avoid the remapping
  and keep the \cs{mathrm} et al.\@ to refer to the non \mst-ified
  fonts, use this option.  The \cs{Mathnormal} et al.\@ commands with an
  initial uppercase will always
  be available whether or not this option is made use of.

  \begin{footnotesize}
    Prior to \mstrelease{1.3za} (and since \mstrelease{1.15f}), this option also prevented the
    package to declare the \cs{Mathnormal} et al.\@ and \cs{mathnormalbold}
    commands.  In this context, recall that the dreaded ``too many math
    alphabets'' error can only occur on \emph{use} in the document of too many
    of such commands, and not at the time of their declarations.  The author's
    notes from time of \mstrelease{1.15f} release (|2012/10/25|) only say that it may not
    be ``useful'' to package user to have both (for example) |\mathrm| and
    |\Mathrm|, which sounds weird if they are to acquire distinct meanings.
    So since \mstrelease{1.3za} both will exist.  In the default package configuration
    |\mathrm| is configured to expand to |\Mathrm| (with some extra behavior
    under §LGRgreek+§), and with this option or the §defaultrm§ option
    |\mathrm| is kept with its original meaning (and the §LGRgreek+§ extras do
    not work).\par
  \end{footnotesize}

\item \RLNote{changed:}{\mstrelease{1.3za}}\mstopt{defaultnormal}, \mstopt{defaultrm},
  \mstopt{defaultbf}, \mstopt{defaultit}, \mstopt{defaultsf},
  \mstopt{defaulttt}: tell \mst to not set up, respectively, the
  \cs{mathnormal}, \cs{mathrm}, \cs{mathbf}, \cs{mathit}, \cs{mathsf}, and
  \cs{mathtt} commands to use the mathastext-ified font which are accessible
  always via \cs{Mathnormal}, \cs{Mathrm}, \cs{Mathbf}, \cs{Mathit}, etc...

  \begin{footnotesize}
    Prior to \mstrelease{1.3za} these options also prevented the creation of the
    corresponding \mst command with an uppercased initial.\par
  \end{footnotesize}

\item \mstopt{ncccomma}:\RightNote{\mstrelease{1.3y}} it triggers the loading of the
  \ctanpkg{ncccomma} package%
%
\footnote{Alexander I. \textsc{Rozhenko}, \emph{Use comma as decimal
    separator in mathematics}, \url{https://ctan.org/pkg/ncccomma}.}
%
and configures \mst for compatibility (this is canceled if
\blueit{nopunctuation} option is used, or \blueit{basic} as it implies it).
\emph{Note that \emph{\mst} has \emph{NO} auto-detection mechanism of
  \emph{\ctanpkg{ncccomma}}, the correct way is to use the eponymous option.}

The effect of the \ctanpkg{ncccomma} package will
apply to the entire document body, even to portions using the
\emph{normal} or \emph{bold} math versions with \mst having been loaded with
the \blueit{subdued}
option.  Also,  in case of usage of package |babel| with |french| option, the
effect of \ctanpkg{ncccomma} will also apply to
those parts of the document using another language than French.%
%
\footnote{There is a `feature' of \ctanpkg{babel-french} that the effect of
  package \ctanpkg{ncccomma} is canceled if one
  switches from French to English; and switching back to French does not
  reenact it.  For background on this issue see
  \url{https://github.com/latex3/babel/issues/190}.

  This does not apply to \ctanpkg{decimalcomma} \mstrelease{1.3} or later.}
\item \mstopt{decimalcomma}:\RightNote{\mstrelease{1.3zb}} it triggers the loading of the
  \ctanpkg{decimalcomma} package%
%
\footnote{Antoine \textsc{Missier}, \emph{Comma for decimal numbers},
  \url{https://ctan.org/pkg/decimalcomma}.}.
%
The same remarks apply as for the §ncccomma§ option.  In particular \emph{note
  that \emph{\mst} has \emph{NO} auto-detection mechanism of
  \emph{\texttt{decimalcomma}}, the correct way is to use the eponymous
  option.}

\item \mstopt{binarysemicolon}:\RightNote{\mstrelease{1.3y}} sets (except if
  \blueit{nopunctuation} is used) the semi-colon to let \TeX\ use
  spacing of binary type, not punctuation type, around the semi-colon
  (it is often used in French mathematical typesetting as separator in
  interval denotations, when the extremities are decimal numbers, as the
  comma is used as decimal separator).

  The effect applies to all math versions, even the \emph{normal} and
  \emph{bold} math versions with \mst having been loaded with the
  \blueit{subdued} option.
\item \mstopt{frenchmath*}:\RLNote{CHANGED!}{\mstrelease{1.3zb}} does all three of \blueit{frenchmath},
  \blueit{decimalcomma} and \blueit{binarysemicolon}.

\begin{footnotesize}
  Prior to \mstrelease{1.3zb}, this option did what is now available via §frenchmath+§.
  The \mstrelease{1.3zb}
  change was made as a follow-up consecutive to the |2.7| release \ctanpkg{frenchmath}.
  Indeed this option as explained in \autoref{ssec:frenchmath} is provided as
  a compatiblity layer with \ctanpkg{frenchmath}, and it was mandatory to
  modify its meaning to refer to package \ctanpkg{decimalcomma}, not \ctanpkg{ncccomma},
  consecutive to the internal change of \ctanpkg{frenchmath} at its |2.7|
  release to use \ctanpkg{decimalcomma}.\par
\end{footnotesize}
\item \mstopt{frenchmath+}:\RightNote{\mstrelease{1.3zb}} does all three of \blueit{frenchmath},
  \blueit{ncccomma} and \blueit{binarysemicolon}.  This is what used to be
  called §frenchmath*§ prior to \mstrelease{1.3zb}.
\item \mstopt{endash}, \mstopt{emdash}: use the text font en-dash (\textendash) or even
 the em-dash (\textemdash, but this seems crazy) for the minus sign
 rather than {}-{}. §endash§ option is default for the package.
\item \mstopt{unicodeminus}:\RightNote{\mstrelease{1.3q}} use the |MINUS SIGN U+2212| (requires
  \ctanpkg{fontspec}.) Or, in the form |unicodeminus=HHHH| with four \emph{uppercased}
  hexadecimal digits: use the |U+HHHH| code point. As §noendash§ really means
  ``use the hyphen from the text font'', §unicodeminus§ remains without effect
  under it, or, naturally, under §nominus§. Without this option,
  \mst uses the |EN DASH U+2013| by default for OpenType fonts.
\item \mstopt{asterisk}: this tells \mst to replace the binary math operator $*$
  and the control sequence \cs{ast} with versions which uses the text asterisk
  * suitably lowered, and with the correct spaces around it as binary
  operator.  The amount of lowering%
%
\footnote{With the option
    \texttt{symbolmisc}, the asterisk is picked from the Symbol font, and the
    amount of lowering is non-customizable; however if a math alphabet command
    is used, the asterisk is then again from a text font and the lowering will
    be as specified by \cs{MTlowerast}.}
%
  is decided by the mandatory argument to the command
  \csb{MTlowerast}\marg{dimen}. The package does
  \cs{MTlowerast}|{.3\height}|. Using the |ex| unit as in
  \cs{MTlowerast}|{.5ex}| is not a good idea as it does not scale properly in
  the script and scriptscript styles.

  Attention that if using this option, inputs such as |$R^*$| or |$R^\ast$|
  raise errors and \emph{must} be replaced by |$R^{*}$|, respectively
  |$R^{\ast}$|.  The $*$ is now `mathematically active'\thinspace%
%
\footnote{In
    a hopefully safe way, for example {\ttfamily\$\string\label\{eq*1\}\$} is
    ok.}
%
  and |*| and |\ast| will obey the math alphabet
  commands (see \autoref{sec:mathxx}).
 
\item \mstopt{activedigits}:\RLNote{new:}{\mstrelease{1.4}}
  it makes all digits mathematically active!  This is
  reserved to expert \LaTeX{} users.  See \autoref{ssec:hackingletters} for an
  example.  Do not use this option if you don't intend to make use of such
  techniques to achieve special effects at some location of your document at
  least. (I know this goes without saying, but passing this option and not
  using it is only adding overhead to all your equations with digits).

\item \mstopt{nodigits}: no \mst-ification of digits.
\item \mstopt{noletters}:\RLNote{new:}{\mstrelease{1.4b}}
   This is quite antithetical to the package core aim, but here you go.

   \begin{footnotesize}
     This option implies §nohbar§ and §defaultimath§.

     Note though that \mst will still declare to \LaTeX{} two extra symbol
     fonts and define alphabet commands such as §\Mathrm§, §\Mathnormal§ and
     §\mathnormalbold§ which map to them.  But ascii letters will if not in
     arguments of these commands not use the \mst-font and all business of
     active letters (see \autoref{ssec:hackingletters}) is now irrevocably
     inaccessible.

     If you simply want to avoid the overhead of math active
     letters, use rather §\MTmathstandardletters§ in the preamble after having
     loaded the package (although this does not undo the fact that \mst will
     have redefined what a letter does if it is catcode active but that remark
     should have been made in an even smaller typeface).\par
   \end{footnotesize}
 \item \mstopt{nohbar}: prevents \mst from defining its own
  \cs{hbar}.
\item \mstopt{noendash}: the minus sign will be the - from the
 text font, not the en-dash \textendash.
\item \mstopt{nolessnomore}: besides
  !\,?\,,\,.\,:\,;\,+\,\textendash\,=\,(\,)\,[\,]\,/\,\#\,\$\,\%\,\&
  \mst treats also \DeleteShortVerb{\|}
  $\mathord{<}\,\mathord{>}\,\mathord{|}$\, \{\,\} and
  $\backslash$.\MakeShortVerb{\|} Use this option to let it not
  do it. This is the default
  in case of |OT1|-encoding.
\item further excluding options: \mstopt{noexclam} !\,?\
\ \mstopt{nopunctuation} ,\,.\,:\,;\ \mstopt{noplus},
\mstopt{nominus}, \mstopt{noplusnominus}\ +\,\textendash{} \mstopt{noequal} =\
\mstopt{noparenthesis} (\,)\,[\,]\,/\ \mstopt{nospecials}
\#\,\$\,\%\,\&\ (and §nodigits§ and §noletters§ mentioned earlier).
 \item \mstopt{alldelims}: true by default, means that the
characters excluded by §nolessnomore§ are
treated. Use this option in case of a mono-width
|OT1|-encoded font.
\item \mstopt{nosmalldelims}: this prevents \mst from trying to pick up in the text
  font the `small variants' of some math delimiters; it only affects what
  happens when a character such as a left parenthesis $($ or $[$ is used as a
  delimiter, and in the event that \TeX{} has chosen the smallest sized
  variant. This has no impact on what happens when they are not used as
  delimiters: then, and if not disabled by the corresponding options, these
  characters are always picked up from the text font.\footnote{in this very
    special situation of option nosmalldelims, the braces are an exception to
    this rule and they require both of \csb{MTnonlettersobeymathxx} and
    \csb{MTexplicitbracesobeymathxx} for being picked up from the text font
    when not used as delimiters.}
 \item \mstopt{symbolgreek}, \mstopt{symboldigits}: to let Greek letters (digits) use the
Symbol font.
 \item \mstopt{symbolre}: replaces \cs{Re} and \cs{Im} by the
 Symbol glyphs $\Re, \Im$ and defines a
\cs{DotTriangle} command ($\DotTriangle$).
\item \mstopt{symbolmisc}: takes quite a few glyphs, including logical arrows, product
  and sum signs from Symbol. They are listed
  \hyperlink{symbolmisc}{\emph{supra}}. Doing
  \cs{renewcommand\{\string\int\}\{\string\smallint\}} will maximize
  even more the use of the Symbol font.
 \item \mstopt{symboldelimiters}: the characters apart from
 letters and digits will be taken from the Symbol font. 
 \item \mstopt{symbol}: combines §symbolgreek§, §symbolre§, and §symbolmisc§.
 \item \mstopt{symbolmax}: combines §symbol§ and §symboldelimiters§.
 \item \mstopt{eulergreek}, \mstopt{eulerdigits}: to let Greek letters (digits) use the
Euler font.
\item \mstopt{LGRgreek}: this configures the Greek letters in math mode to use
  the text font (i.e. a priori the font which was default at time of loading
  the package) in LGR-encoding.  The command §\MTgreekfont§ can be used to set
  a specific (LGR-encoded) font family.  Each use of §\MTgreekfont§ must be
  followed at some point by a §\Mathastext§ or
  §\Mathastext§\oarg{version\_name} to be effective.  Any subsequent math
  version declaration will be influenced by it until §\MTgreekfont§ is used
  again to configure another font for Greek letters.%
  %
  \footnote{You can check the documentation of the
  \url{https://ctan.org/pkg/lgrmath} package for how to find out systematically which
  fonts are available on your system in \texttt{LGR} encoding.}

  If §\MTgreekfont§ is never used the font family for Greek under
  option §LGRgreek§ will be, in all math versions except under §subdued§ for
  the ``normal'' and ``bold'', the family which was the default at time of
  loading the package.  You must use §\MTgreekfont§ to change it.

  See further on this topic the §upgreek§, §itgreek§, §upGreek§ and §itGreek§
  options as well as the §\MTupgreek§, §\MTitgreek§, §\MTupGreek§ and
  §\MTitGreek§ commands.

  It is up to the user to ascertain that the font family is indeed available
  in the LGR encoding; if it is not, only at time of the first math mode
  typesetting will \LaTeX\ issue warnings such as this one:%
  %
  \centeredline{|Font shape `LGR/ptm/m/n' undefined|}%
  \centeredline{|using `LGR/cmr/m/n' instead on input line 28|}%
  %

  The §LGRgreek§ option also triggers pre-definition of Greek character tokens
  such as \cs{alphaup} or \cs{betait}, see \autoref{sec:newgreek} for the
  explanations.

  \begin{footnotesize}
    Although under §subdued§ option \mst restores Latin (but see §frenchmath§)
    and Greek letters in the ``normal'' and ``bold'' math
    versions it still under §LGRgreek§ option keeps in these ``subdued'' math
    versions the package
    declared |\alphaup|, |\alphait|, ...., and the 
    associated §\mathgreekup§
    and §\mathgreekit§ commands to access the underlying fonts, and also since
    \mstrelease{1.3za} §\mathgreekupbold§ and §\mathgreekitbold§.

    The font used by these math
    alphabet commands in the subdued ``normal'' and ``bold'' is either
    the one in \texttt{LGR} encoding which was the family default
    at time of loading the package or the one configured last by
    §\MTgreekfont§ when the command §\Mathastext§ (without
    optional argument) was used in the preamble.

    \mstrelease{1.3za} fixes here a bug which froze the target font to be
    the one at time of loading the package: this bug applied
    (only) to the subdued ``normal'' and ``bold'' math versions
    and was not readily visible as there is a priori no reason to
    use in these subdued math versions these \mst-provided Greek
    font alphabets.\par
  \end{footnotesize}

\item \mstopt{LGRgreeks}: each declared math version will be supposed to be
  with a font which is also available in LGR-encoding.  This is a shortcut to
  using §\MTgreekfont§ systematically to keep in sync in all declared math
  versions the font for Greek with the font for Latin letters.  Please note
  that macro §\MTgreekfont§ becomes then inoperant, and if you need one math
  version without this Latin-Greek synching, you will have to use rather
  §LGRgreek§ and then §\MTgreekfont§ manually appropriately.

\item \mstopt{LGRgreek+} and
  \mstopt{LGRgreeks+}:\RightNote{\mstrelease{1.3za}} they extend
  respectively §LGRgreek§ or §LGRgreeks§ to let Greek letters
  control sequences when in the scope of §\mathrm§, §\mathit§,
  and §\mathbf§ behave as would be expected by LaTeX users who
  have not read \texttt{fntguide.pdf} or any other \LaTeX\
  documentation but have used \ctanpkg{unicode-math}. See
  \autoref{sec:newgreekplus} for details.

\item \mstopt{selfGreek}: this is for a font which is also available in
  |OT1|-encoding and contains the glyphs for the default eleven capital Greek
  letters.

  \begin{footnotesize}
    This option should have been named \texttt{OT1Greek} as it bears about the
    same relation with \texttt{OT1} encoding (for eleven capital Greek
    letters) as §LGRgreek§ does with the \texttt{LGR} encoding (for the
    complete no-diacritics Greek alphabet).\par
  \end{footnotesize}
\item \mstopt{selfGreeks}: each declared math version will be supposed to be
  with a font with the eleven capital Greek letters in its |OT1|-encoded
  version.
\item \mstopt{upgreek}, \mstopt{itgreek}: options to tell \mst to use
  §\MTgreekupdefault§ or §\MTgreekitdefault§ for the lowercase and uppercase
  Greek letters shape. These two commands can be defined prior to loading the
  package.  This option is operant only under the |LGRgreek(s)| or
  |selfGreek(s)| options.
\item \mstopt{upGreek}, \mstopt{itGreek}: influence only uppercase Greek.
 \item \mstopt{mathaccents}: use the text font also for the math
accents. As in vanilla \LaTeX{}, they are taken from the font
for the digits and \cs{log}-like names. Obey the alphabet
changing commands.
 \item \mstopt{unimathaccents}:\RightNote{\mstrelease{1.3u}} extends |mathaccents| to
OpenType fonts. Gave bad results in my brief testing.
 \item \mstopt{defaultimath}: do not overwrite \cs{imath} and
 \cs{jmath} to use \cs{inodot} and \cs{jnodot}.
 \item \mstopt{defaultmathsizes}: do not change the \LaTeX{} defaults for the sizes
 of exponents and subscripts.
 \item \mstopt{fouriervec}: provides a \cs{fouriervec} command. The user can then
 add in the preamble \cs{let}\cs{vec}$=$\cs{fouriervec}. There is also
 always available a ``poor man'' vec accent \cs{pmvec} for upright letters.
\item \mstopt{everymath}:\RLNote{new:}{\mstrelease{1.4}} this option tells
  \mst to employ as in the \mstrelease{1.3} releases the
  \cs{everymath}/\cs{everydisplay} registers to store certain actions to be
  executed at each entrance into math mode.  The main change with
  \mstrelease{1.4} is that mathcode changes done by user (or possibly via
  language changes in a multilingual \ctanpkg{babel} context) in the document
  body, and which apply to those characters which \mst used to handle as part of
  \cs{everymath}/\cs{everydisplay}, will now have an effect, whereas with
  earlier releases or this one
  with the §everymath§ option, they may get overruled by \mst.  Use
  §everymath§ for backward compatibility if needed (and \emph{only} if needed).
  Notice though that regarding ascii letters, there is no return to the
  pre-\mstrelease{1.4}: they will not acquire their mathcode active status only
  at each entrance into math mode, even with this option,
  but once and for all at package loading time, if not §subdued§, or when using
  §\MTversion§ to enter a non-§subdued§ math version.

  Please report breakages due to the \mstrelease{1.4} release, which made it
  necessary for you to use this option §everymath§ as workaround.

  The option is destined to be removed at next major release and it will warn
  the user about this.
\end{enumerate}

Thanks to Kevin~\textsc{Klement}, Tariq~\textsc{Perwez}
and Ricard~\textsc{Torres} for sending bug reports and feature requests when
the first version of the package was issued.

 \begin{center}
Numerous examples will be found there:\\
   \url{http://jf.burnol.free.fr/mathastext.html}\\
   \url{http://jf.burnol.free.fr/showcase.html}
 \end{center}

\catcode`\§=12

% ATTENTION
\clearpage


\normalsize

\section{Change log}
\label{sec:changelog}

\begingroup
\hyphenation{Lua-La-TeX}

\def\MacroFont{\footnotesize\normalfont}
% utilisé par verbatim en classe scrdoc (ou plutôt shortvrb)
% (rappel: macrocode utilise \macro@font qui est MacroFont at begin document)

\makeatletter

\def\@verbatim{%
\parindent \z@ \parfillskip \@flushglue \parskip \tw@\p@
\let \do \@makeother \dospecials \catcode`\ =10 }

% et donc on ne fait pas \obeylines, ni \@noligs
\def\endverbatim{}
\let\@vobeyspaces\relax

% 2015/09/10 -- 2015/09/12
% Dorénavant README.md (et possiblement un CHANGES.txt ou CHANGES.md)
% sont auto-extraits du .dtx.
% 
% Ici je dois faire un input approprié.

% 2019/08/12: le ChangeLog.md est directement disponible, alors qu'auparavant
% il était inclus dans le README.md.
%
% Les items sont initiés par des *
% Il faut se débarrasser des ---- et remplacer les \[, \]
% Il faut aussi gérer les `.

\catcode`*=\active
\def*{\ifvmode\smallskip
  \leavevmode\kern.5em\smash{\raisebox{-.3\height}{\char42}}\kern1em
  \else\smash{\raisebox{-.3\height}{\char42}}\fi }%

\begingroup
    \lccode`\~`1
\lowercase{\endgroup\def~}{\ifvmode\medskip\expandafter\@DTXLOGhelper\fi 1}

% 2024/07/10 hypertargets pour \mstrelease (importé de etoc, et j'ai déjà ici
% toute une infrastructure rendant le truc trivial avec un fol 1 actif).  Par
% contre j'ai fait une modification s/#1\[/#1 \[/ car le #1 avant se terminait
% par un espace.\]\]
% Et attention au detokenize...
% Il y a juste un problème avec le cas "1.15f and 1.15g".
\begingroup
    \catcode`\| 0
    \catcode`\\ 12
% Je réduis à --- ici.
|long|gdef|@DTXLOGhelper #1 ---#2|par{|@@DTXLOGhelper #1 \[\]|par}
|long|gdef|@@DTXLOGhelper #1 \[#2\]#3|par%
    {|hypertarget{|detokenize|expandafter{|fixonexv#1 and|relax}}{|textbf{#1}} %
     |ifx|relax #2|relax|else [#2]|fi
     |par|nopagebreak}
|endgroup

% uniquement pour s'occuper de "1.15f and 1.15g" et en profitant du fait qu'il
% n'y a de référence à 1.15g nulle part.
\def\fixonexv#1 and#2\relax{#1}

\catcode`-=\active
\def-{%
  \catcode`M\active
  \begingroup
  \lccode`\-`M % MATHASTEXT CHANGE LOG est la première ligne...
  \lowercase{\endgroup\long\def-}##1\par{\catcode`\M=12 \catcode`\-=12 }%
  \catcode`1=\active
  \catcode`\` 9 % légèrement ennuyeux mais bon, c'est le plus simple.
  \nonfrenchspacing
  \input ChangeLog.md
}

\makeatother

\begin{multicols}{2}
\begin{verbatim}
-
\end{verbatim}
\end{multicols}
\endgroup


\ifnum\NoSourceCode=1 
\bigskip
\begin{framed}
\def\givesomestretch{%
\fontdimen2\font=0.33333\fontdimen6\font
\fontdimen3\font=0.16666\fontdimen6\font
\fontdimen4\font=0.11111\fontdimen6\font
}%
  \ttfamily\small\givesomestretch\hyphenchar\font45 This documentation
  has been compiled without the source code. To produce the
  documentation with the source code included, run "tex mathastext.dtx" to
  generate mathastext.tex (if not already available), then thrice latex on
  mathastext.tex and finally dvipdfmx on mathastext.dvi.
\end{framed}
\fi


\StopEventually{\end{document}\endinput}

\cleardoublepage
\newgeometry{hmarginratio=2:1}
\small

\section{Implementation}
% The catcode hackery next is to avoid to have <*package> to be listed
% in the commented source code...
% (c) 2012/11/19 jf burnol ;-)
\MakePercentIgnore
%
% \catcode`\<=0 \catcode`\>=11 \catcode`\*=11 \catcode`\/=11
% \let</dtx>\relax
% \def<*package>{\catcode`\<=12 \catcode`\>=12 \catcode`\*=12 \catcode`\/=12}
%
%</dtx>
%<*package>
% The comments are a kind of palimpsest.  Indeed they are not destined to the
% reader but to the author: when coming back to the source code perhaps years
% after having last looked at it, all bits of past information even if
% obsolete are useful.  Not only comments but perhaps also some ancient parts
% of the code itself are a bit strange (the author hardly new any \LaTeX{} at
% that time).
%
% For about the same reason, there may be some long macro names which do not
% fit in the margins and that one sees only partially.  The author sometimes
% has used a workaround to hyphenate, but not systematically.  Life is
% time-limited.  At \mstrelease{1.4} large chunks of code have been re-ordered
% but the global architecture is still somewhat of a mess and doing some such
% large diffs makes it sometimes difficult to follow small bits of code across
% commit history, so this is done reluctantly.
%
% The usual catcode regime for letters and digits is assumed and some
% characters such as |*|, |`|, |"|, |=| are supposed to be of catcode other at
% the time of loading of \mst. The source of \mst takes precautions for some
% other characters such as the right quote |'|, which may thus be active with
% no harm at the time of loading (note added |2024/07/16|: very hard to
% understand why I was so paranoid, but I have kept this annoying constraint).
%
% By the way, I think \LaTeX2e should have provided to authors a
% standard macro to be used at the beginning of a style file to make sure the
% catcodes are standard. Shorthands created by Babel should be mostly no problem
% as Babel does the activation only at the |\begin{document}|.
%
% \mstrelease{1.4} removes a few code branches still there for support to
% old \LaTeX{} and requires \LaTeX{} |2020-02-02| (which made |\{| and |\}|
% \cs{protected}; earlier release |2019-10-01| had math macros such as the
% math accents and \cs{hbar} robust and so far we kept supporting both new and
% old contexts).
%    \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}[2020/02/02]
\ProvidesPackage {mathastext}
  [2024/07/27 v1.4b Use the text font in math mode (JFB)]
%    \end{macrocode}
% \mstrelease{1.3zb} avoids writing \mst info messages also to console output, only log file.
% Make prefix occupy 20 not 25 characters for alignment with \texttt{LaTeX Font Info},
% as the latter often issues info messages.  For similar reason the usages of
% \cs{PackageInfo} will be done with empty lines above and below for better visual
% separation from the voluminous output of the \LaTeX\ font system.
%    \begin{macrocode}
\def\mst@infoline#1{\immediate\write\m@ne
                    {(\space\space\space mathastext:\space\space\space) #1}}
\immediate\write\m@ne{}
\PackageInfo{mathastext}{Starting the math mode configuration\@gobble}
%    \end{macrocode}
% Testing for \XeTeX\ and \LuaLaTeX.
%
% \mstrelease{1.3g} |2015/10/15|: update for the naming of primitives, the situation has
% evolved both on \XeTeX\ side and on the \LuaLaTeX\ side (LaTeX base
% |2015/10/01|): I was told "U" named math primitives were always available
% for \LuaLaTeX. For \XeTeX, the XeTeX prefix got replaced by U prefix with
% 0.99.. a certain number of 9. I opted for rather simple approach of just
% trying the "modern" names and if they don't exist fall back on earlier (and
% in danger of being deprecated) names.
%    \begin{macrocode}
  \let\mst@Umathcharnumdef\Umathcharnumdef
  \let\mst@Umathcodenum   \Umathcodenum
  \let\mst@Umathcode      \Umathcode
  \let\mst@Umathchardef   \Umathchardef
  \let\mst@Umathaccent    \Umathaccent
\newif\ifmst@XeTeX
\ifx\XeTeXinterchartoks\@undefined
  \mst@XeTeXfalse
\else
  \mst@XeTeXtrue
  \ifx\mst@Umathcharnumdef\@undefined
    \let\mst@Umathcharnumdef\XeTeXmathcharnumdef
    \let\mst@Umathcodenum   \XeTeXmathcodenum
    \let\mst@Umathcode      \XeTeXmathcode
    \let\mst@Umathchardef   \XeTeXmathchardef
    \let\mst@Umathaccent    \XeTeXmathaccent
  \fi
\fi
\newif\ifmst@LuaTeX
\ifx\directlua\@undefined
  \mst@LuaTeXfalse
\else
  \mst@LuaTeXtrue
  \ifx\mst@Umathcharnumdef\@undefined
    \let\mst@Umathcharnumdef\luatexUmathcharnumdef
    \let\mst@Umathcodenum   \luatexUmathcodenum
    \let\mst@Umathcode      \luatexUmathcode
    \let\mst@Umathchardef   \luatexUmathchardef
    \let\mst@Umathaccent    \luatexUmathaccent
  \fi
\fi
\newif\ifmst@XeOrLua
\ifmst@LuaTeX\mst@XeOrLuatrue\fi
\ifmst@XeTeX \mst@XeOrLuatrue\fi
%    \end{macrocode}
% \mstrelease{1.4}.  I only checked this is correct with TL2024.
% The macro will be used with |#1| a catcode 11 or 12 token or a one character
% control sequence such as |\#|.
%    \begin{macrocode}
\ifmst@XeTeX
  \def\mst@OnlyIfNotMathActive#1{%
      \ifnum\mst@Umathcodenum`#1="1FFFFF
           \expandafter\@gobble
      \else\expandafter\@firstofone
      \fi
   }
\else\ifmst@LuaTeX
  \def\mst@OnlyIfNotMathActive#1{%
      \ifnum\mst@Umathcodenum`#1="1000000
           \expandafter\@gobble
      \else\expandafter\@firstofone
      \fi
   }
\else
  \def\mst@OnlyIfNotMathActive#1{%
      \ifnum\mathcode`#1="8000
           \expandafter\@gobble
      \else\expandafter\@firstofone
      \fi
   }
\fi\fi
%    \end{macrocode}
% \mstrelease{1.2}: all inner macros of \mst now starts with |\mst@| for a cleaner
% name-space. 
%
% \mstrelease{1.3l} |2016/01/29|: hmmm... at this late stage where nobody would expect me
% to still look at the code, I have found at least two macros which still
% didn't: \cs{do@the@endashstuff} and \cs{do@the@emdashstuff}.
%
% Ok, doing something more serious: compatibility with upcoming TL2016
% fontspec and its switch to |`TU'| NFSS font encoding in replacement of
% |`EU1/EU2'| Anyhow, the code in \mst has been common to the two Unicode
% engines for a while, hence it is not hard to adapt to the replacement of
% |EU1/EU2| by |TU|, maintaining compatibility with legacy installations.
%
% At \mstrelease{1.4} the support for obsolete |EU1| and |EU2| font encodings
% has been removed.
%
% \begin{macro}{\mst@OneifUniEnc}
% The \cs{mst@OneifUniEnc} is expandable but must be used after
% having set \cs{mst@tmp@enc}... 
%    \begin{macrocode}
\def\mst@oti{OT1}
\def\mst@tu{TU}
\def\mst@OneifUniEnc{\ifx\mst@tmp@enc\mst@tu1\else0\fi}
\newif\ifmst@goahead
\newif\ifmst@abort
%    \end{macrocode}
% \end{macro}
%  \begin{macro}{\mst@enc}
%  \begin{macro}{\mst@fam}
%  \begin{macro}{\mst@ser}
%  \begin{macro}{\mst@opsh}
%  \begin{macro}{\mst@bold}
%  \begin{macro}{\mst@ltsh}
%    Macros to store the font settings, each math version will store its
%    own records. 
%    \begin{macrocode}
  \def\mst@enc{\encodingdefault}
  \def\mst@fam{\familydefault}
  \def\mst@ser{\seriesdefault}
%    \end{macrocode}
% \noindent\cs{mst@opsh} will hold default shape for operator names.\newline
% \cs{mst@ltsh} will hold default shape for letters.
%    \begin{macrocode}
  \def\mst@opsh{\shapedefault}
  \def\mst@bold{\bfdefault}
  \def\mst@ltsh{\shapedefault}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%  \begin{macro}{\mst@greekfont}
%    \mstrelease{1.15c}: for use by the LGRgreek and selfGreek options. Defined as
%    an \cs{edef} in order to be able to set-up once and for all the
%    Greek at the time of \cs{usepackage}. Modifiable in the preamble
%    via \cs{MTgreekfont}\marg{font\_name}\cs{Mathastext}.
%    \begin{macrocode}
  \edef\mst@greekfont{\familydefault}
%    \end{macrocode}
%  \end{macro}
% \begin{macro}{Package options}
%   |2011/03/09|: \mstrelease{1.13} introduces the option LGRgreek and systematic use
%   of \cs{if...} conditionals, for better readability (by myself) of
%   the code.
%
%   \mstrelease{1.3y} of |2022/11/03| adds |ncccomma|, |binarysemicolon| and
%   |frenchmath*| options.
%
%   \mstrelease{1.3za} adds |LGRgreek+| and |LGRgreeks+|.
%
%   \mstrelease{1.3zb} adds |decimalcomma| and modifies |frenchmath*| to use
%   it.  And provides |frenchmath+| as an alias to former |frenchmath*|.
%   Consecutive to the change at |v2.7| of \ctanpkg{frenchmath} which replaced
%   \ctanpkg{ncccomma} by \ctanpkg{decimalcomma} and broke the compatibility
%   recipe explained in \autoref{ssec:frenchmath}.
%
%   \mstrelease{1.4} adds options |everymath| and |activedigits|.
%
%   \mstrelease{1.4b} adds |noletters|.
%    \begin{macrocode}
\newif\ifmst@italic
\newif\ifmst@frenchmath
\newif\ifmst@ncccomma
\newif\ifmst@decimalcomma
\newif\ifmst@binarysemicolon
    \DeclareOption{italic}{\mst@italictrue
        \def\mst@ltsh{\itdefault}}
    \DeclareOption{frenchmath}{\mst@frenchmathtrue\mst@italictrue
      \def\mst@ltsh{\itdefault}}
    \DeclareOption{ncccomma}{\mst@ncccommatrue}
    \DeclareOption{decimalcomma}{\mst@decimalcommatrue}
    \DeclareOption{binarysemicolon}{\mst@binarysemicolontrue}
    \DeclareOption{frenchmath*}{\mst@frenchmathtrue\mst@italictrue
      \def\mst@ltsh{\itdefault}\mst@decimalcommatrue\mst@binarysemicolontrue}
    \DeclareOption{frenchmath+}{\mst@frenchmathtrue\mst@italictrue
      \def\mst@ltsh{\itdefault}\mst@ncccommatrue\mst@binarysemicolontrue}
\newif\ifmst@endash\mst@endashtrue  
    \DeclareOption{endash}{\mst@endashtrue}
    \DeclareOption{noendash}{\mst@endashfalse}
\newif\ifmst@emdash
    \DeclareOption{emdash}{\mst@emdashtrue\mst@endashfalse}
\newif\ifmst@alldelims
\edef\mst@tmp{\encodingdefault}\ifx\mst@oti\mst@tmp\else\mst@alldelimstrue\fi 
    \DeclareOption{alldelims}{\mst@alldelimstrue}
    \DeclareOption{nolessnomore}{\mst@alldelimsfalse}
\newif\ifmst@nosmalldelims
    \DeclareOption{nosmalldelims}{\mst@nosmalldelimstrue}
\newif\ifmst@noplus
    \DeclareOption{noplus}{\mst@noplustrue}
\newif\ifmst@nominus
    \DeclareOption{nominus}{\mst@nominustrue}
\DeclareOption{noplusnominus}{\ExecuteOptions{noplus,nominus}}
\newif\ifmst@noparen
    \DeclareOption{noparenthesis}{\mst@noparentrue}
\newif\ifmst@nopunct
    \DeclareOption{nopunctuation}{\mst@nopuncttrue}
\newif\ifmst@noequal
    \DeclareOption{noequal}{\mst@noequaltrue}
\newif\ifmst@noexclam
    \DeclareOption{noexclam}{\mst@noexclamtrue}
\newif\ifmst@asterisk
    \DeclareOption{asterisk}{\mst@asterisktrue}
\newif\ifmst@nospecials
    \DeclareOption{nospecials}{\mst@nospecialstrue}
\newif\ifmst@basic
    \DeclareOption{basic}{\mst@basictrue
    \ExecuteOptions{noparenthesis,nopunctuation,%
                    noplusnominus,noequal,noexclam,nospecials,nolessnomore}}
\newif\ifmst@nohbar
    \DeclareOption{nohbar}{\mst@nohbartrue}
%    \end{macrocode}
% \mstrelease{1.4} adds option |activedigits|.
%    \begin{macrocode}
\newif\ifmst@activedigits
    \DeclareOption{activedigits}{\mst@activedigitstrue}
\newif\ifmst@nodigits
    \DeclareOption{nodigits}{\mst@nodigitstrue}
\newif\ifmst@defaultimath
    \DeclareOption{defaultimath}{\mst@defaultimathtrue}
%    \end{macrocode}
% \mstrelease{1.4b} adds option |noletters|.
%    \begin{macrocode}
\newif\ifmst@noletters
    \DeclareOption{noletters}{\mst@noletterstrue\ExecuteOptions{nohbar,defaultimath}}
\newif\ifmst@mathaccents
    \DeclareOption{mathaccents}{\mst@mathaccentstrue}
\newif\ifmst@unimathaccents
    \DeclareOption{unimathaccents}{\mst@mathaccentstrue\mst@unimathaccentstrue}
\newif\ifmst@needsymbol
\newif\ifmst@symboldelimiters
    \DeclareOption{symboldelimiters}{\mst@needsymboltrue\mst@symboldelimiterstrue}
\newif\ifmst@symboldigits
    \DeclareOption{symboldigits}{\mst@needsymboltrue\mst@symboldigitstrue}
\newif\ifmst@symbolgreek
\newif\ifmst@customgreek
    \DeclareOption{symbolgreek}{\mst@needsymboltrue\mst@symbolgreektrue
                                \mst@customgreektrue }
\newif\ifmst@symbolre
    \DeclareOption{symbolre}{\mst@needsymboltrue\mst@symbolretrue}
\newif\ifmst@symbolmisc
    \DeclareOption{symbolmisc}{\mst@needsymboltrue\mst@symbolmisctrue}
    \DeclareOption{symbol}{\ExecuteOptions{symbolgreek,symbolmisc,symbolre}}
    \DeclareOption{symbolmax}{\ExecuteOptions{symbol,symboldelimiters}}
\newif\ifmst@needeuler
\newif\ifmst@eulerdigits
    \DeclareOption{eulerdigits}{\mst@needeulertrue\mst@eulerdigitstrue}
\newif\ifmst@eulergreek
    \DeclareOption{eulergreek}{\mst@needeulertrue\mst@eulergreektrue
                               \mst@customgreektrue }
\newif\ifmst@selfGreek
    \DeclareOption{selfGreek}{\mst@selfGreektrue\mst@customgreektrue}
\newif\ifmst@selfGreeks
    \DeclareOption{selfGreeks}{\mst@selfGreekstrue\mst@selfGreektrue
                               \mst@customgreektrue }
\newif\ifmst@LGRgreek
    \DeclareOption{LGRgreek}{\mst@LGRgreektrue\mst@customgreektrue}
\newif\ifmst@LGRgreeks
    \DeclareOption{LGRgreeks}{\mst@LGRgreekstrue\mst@LGRgreektrue
                              \mst@customgreektrue}
\newif\ifmst@greekplus
    \DeclareOption{LGRgreek+}{\ExecuteOptions{LGRgreek}\mst@greekplustrue}
    \DeclareOption{LGRgreeks+}{\ExecuteOptions{LGRgreeks}\mst@greekplustrue}
\def\mst@greek@select{0}
\newif\ifmst@itgreek
\newif\ifmst@upgreek
    \DeclareOption{itgreek}{\mst@itgreektrue}
    \DeclareOption{upgreek}{\mst@upgreektrue}
    \DeclareOption{itGreek}{\def\mst@greek@select{1}}
    \DeclareOption{upGreek}{\def\mst@greek@select{2}}
%    \end{macrocode}
% Starting with \mstrelease{1.15f} the meaning of the `defaultxx' options has changed. They
% now prevent |mathastext| from defining additional alphabets rather than
% prevent it from identifying the `mathxx' with the new `Mathxx'. The
% `Mathnormal' and `Mathrm' alphabet commands are always created as they are
% SymbolFontAlphabets.
%
% This was again changed at \mstrelease{1.3za}.  The additional alphabets are
% always declared, the options only prevent mapping the existing
% `mathxx' to the new `Mathxx'.  This may be breaking change if
% people used these options because they had a need for the
% |\Mathbf| etc... names.
%    \begin{macrocode}
\newif\ifmst@defaultnormal
    \DeclareOption{defaultnormal}{\mst@defaultnormaltrue}
\newif\ifmst@defaultrm
    \DeclareOption{defaultrm}{\mst@defaultrmtrue}
\newif\ifmst@defaultbf
    \DeclareOption{defaultbf}{\mst@defaultbftrue}
\newif\ifmst@defaultit
    \DeclareOption{defaultit}{\mst@defaultittrue}
\newif\ifmst@defaultsf
    \DeclareOption{defaultsf}{\mst@defaultsftrue}
\newif\ifmst@defaulttt
    \DeclareOption{defaulttt}{\mst@defaulttttrue}
%    \end{macrocode}
% Here and elsewhere \mstrelease{1.3za} has removed an
% \cs{ifmst@nonormalbold} conditional.
%    \begin{macrocode}
\DeclareOption{defaultalphabets}{\ExecuteOptions{defaultnormal,defaultrm,%
defaultbf,defaultit,defaultsf,defaulttt}}
%    \end{macrocode}
% |mathastext| considers the default script and especially scriptscript sizes to
% be far too small, and it will modify them. An option maintains the default. 
%    \begin{macrocode}
\newif\ifmst@defaultsizes
    \DeclareOption{defaultmathsizes}{\mst@defaultsizestrue}
\newif\ifmst@twelve
    \DeclareOption{12pt}{\mst@twelvetrue}
\newif\ifmst@fouriervec
    \DeclareOption{fouriervec}{\mst@fouriervectrue}
%    \end{macrocode}
% \mstrelease{1.15}: the |subdued| option. 
%    \begin{macrocode}
\newif\ifmst@subdued
    \DeclareOption{subdued}{\mst@subduedtrue}
%    \end{macrocode}
% \mstrelease{1.4}: the |everymath| option.
%    \begin{macrocode}
\newif\ifmst@everymath
    \DeclareOption{everymath}{\mst@everymathtrue
\PackageWarningNoLine{mathastext}{%
        `everymath\string' will be removed at next major release.\MessageBreak
        Please report to the author the circumstances\MessageBreak
        which mandated its use in the present document}%
}
%    \end{macrocode}
%   \mstrelease{1.3q}: the |unicode| option. Thanks to Tobias~\textsc{Brink}
%   for suggesting its incorporation. The parsing of \cs{CurrentOption} does
%   not seek any robustness, it just does its job if the option is used
%   correctly.
%    \begin{macrocode}
\def\mst@unicodeminus {2013}
\def\mst@checkoption #1unicodeminus#2\mst@#3\mst@@
   {\ifx\\#3\\\PackageWarningNoLine{mathastext}
               {Unknown option `\CurrentOption\string'}\else
    \ifx\\#2\\\def\mst@unicodeminus {2212}\else
    \expandafter\def\expandafter\mst@unicodeminus\expandafter{\@secondoftwo#2}%
    \fi\fi}
\DeclareOption*%
  {\expandafter\mst@checkoption\CurrentOption\mst@ unicodeminus\mst@\mst@@}
%    \end{macrocode}
% \end{macro}
%    \begin{macrocode}
\ProcessOptions\relax
%    \end{macrocode}
% \begin{macro}{\mst@DeclareMathAccent}
%
%   I somehow missed realizing \LaTeX{} |2019-10-01| if used together
%   with |amsmath| made repeated usage of \cs{DeclareMathAccent} trigger
%   an error: \url{https://github.com/latex3/latex2e/issues/216}.
%
%   This broke usage of \cs{Mathastext} macro in preamble.
%
%   \mstrelease{1.3w} works around this via \cs{mst@DeclareMathAccent}. And other
%   changes were made in \mst code to cope with these complications around
%   robustness.
%    \begin{macrocode}
\def\mst@DeclareMathAccent#1{\let#1\mst@undefined
  \expandafter
  \let\csname\expandafter\@gobble\string#1\space\endcsname\mst@undefined
  \DeclareMathAccent{#1}}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\mst@normalversionname}
% \begin{macro}{\mst@boldversionname}
% Helper macros to test math version names. User is not allowed to redefine
% via \cs{Mathastext} with optional argument or via \cs{MTDeclareVersion} the
% |normal| and |bold| math versions. Added at \mstrelease{1.3w}, about 7 years late.
%    \begin{macrocode}
\def\mst@normalversionname{normal}%
\def\mst@boldversionname{bold}%
%    \end{macrocode}
% \end{macro}\end{macro}
% \begin{macro}{\mst@OnlyIfNotSubdued}
%   \mstrelease{1.3u} adds this check that we are not in a subdued normal or
%   bold math version. We do not push the |#1| out of the TeX conditionals,
%   and anyhow there was no real need for expandable coding.
%    \begin{macrocode}
\def\mst@OnlyIfNotSubdued#1{%
    \ifmst@subdued
      \ifx\math@version\mst@normalversionname
      \else
        \ifx\math@version\mst@boldversionname
        \else
          #1%
        \fi
      \fi
    \else
      #1%
    \fi
}%
%    \end{macrocode}
% \end{macro}
%  \begin{macro}{\exists} \begin{macro}{\mst@exists@skip}
%  \begin{macro}{\forall} \begin{macro}{\mst@forall@skip} 
%  \begin{macro}{\MTnormalexists}
%  \begin{macro}{\MTexistsdoesskip }
%  \begin{macro}{\MTnormalforall}
%  \begin{macro}{\MTforalldoesskip }
%  
%      \mstrelease{1.15e} |2012/10/21|: math skip/glue \emph{after} \cs{exists} and
%      \cs{forall}, this is useful with upright letters in math mode.
%      Each math version has its own user defined values for the skips,
%      stored as macros. The redefinitions of $\exists$ and $\forall$ are
%      done only at the end of the package as the |symbol| option will
%      also want to redefine these math symbols.
%
%      The subdued option (later and only for the normal and bold math
%      version) and the italic option (here) set to zero the package
%      default skips. With \mstrelease{1.2} the skips can be modified on the fly in
%      the document, they are not necessarily set in the preamble once
%      and for all for each math version.
%
%      \mstrelease{1.3j} adds \cs{MTnormalexists}, \cs{MTexistsdoesskip},
%      \cs{MTnormalforall}, \cs{MTforalldoesskip}.
%
%      Earlier to \mstrelease{1.3j}, |\let\mst@exists@original\exists| was done at End of
%      Package, now it is done at Begin Document, and same for |\forall|. We
%      pay attention that use of \cs{MTnormalexists} etc... inside the
%      preamble does not create self-let's.
%
%      Also |subdued| mode will do \cs{MTnormalexists}, \cs{MTnormalforall}
%      (earlier than \mstrelease{1.3j}, it only set the muskips to |0mu|.) Same when
%      using |\MTversion{normal}|, if |subdued|.
%
%      For some (random, legacy) reason, the handling of $\exists$ and
%      $\forall$ is part of the things
%      not included inside |\everymath/\everydisplay|.
%
%      \mstrelease{1.3v} The \mst-defined \cs{exists} and \cs{forall} are created
%      \cs{protected}. We feel this matches better with their default
%      definition as \cs{mathchardef} tokens than dealing with \LaTeX2e robust
%      macros. Besides, the coding is simpler.
%    \begin{macrocode}
\newmuskip\mst@exists@muskip
\newmuskip\mst@forall@muskip
\def\mst@exists@skip{1mu}
\def\mst@forall@skip{.6667mu}
\ifmst@italic\ifmst@frenchmath\else
    \def\mst@exists@skip{0mu}
    \def\mst@forall@skip{0mu}
    \def\mst@prime@skip {0mu}
\fi\fi
\protected\def\mst@exists{\mst@exists@original\mskip\mst@exists@muskip}
\protected\def\mst@forall{\mst@forall@original\mskip\mst@forall@muskip}
\AtBeginDocument{%
   \let\mst@exists@original\exists
   \let\mst@forall@original\forall
   \def\MTnormalexists   {\let\exists\mst@exists@original }%
   \def\MTexistsdoesskip {\let\exists\mst@exists }%
   \def\MTnormalforall   {\let\forall\mst@forall@original }%
   \def\MTforalldoesskip {\let\forall\mst@forall }%
%    \end{macrocode}
% The document body starts in the normal math version, whether or not
% \cs{Mathastext} command as been used in the preamble (which either re-defines
% the normal/bold math version or defines another one in case of optional
% argument), and in case of |subdued| option should use the standard $\forall$
% and $\exists$.
%    \begin{macrocode}
   \ifmst@subdued
   \else
     \MTexistsdoesskip
     \MTforalldoesskip
   \fi
}%
\newcommand*\MTnormalexists   {\AtBeginDocument {\MTnormalexists   }}
\newcommand*\MTexistsdoesskip {\AtBeginDocument {\MTexistsdoesskip }}
\newcommand*\MTnormalforall   {\AtBeginDocument {\MTnormalforall   }}
\newcommand*\MTforalldoesskip {\AtBeginDocument {\MTforalldoesskip }}
%    \end{macrocode}
%  \end{macro}\end{macro}\end{macro}\end{macro}
%  \end{macro}\end{macro}\end{macro}\end{macro}
%  \begin{macro}{\prime}
%  \begin{macro}{\mst@prime@skip}
%  \begin{macro}{\active@math@prime}
%  \begin{macro}{\MTnormalprime}
%  \begin{macro}{\MTprimedoesskip}
%
%    \mstrelease{1.2} |2012/12/17|: math skip/glue \emph{before} the \cs{prime}
%    glyph. This is useful with the default CM glyph and upright letters
%    (in contrast the prime from |txfonts| works fine with upright
%    letters). For this we replace the \LaTeX{} kernel \cs{active@math@prime}
%    with our own skip-enhanced version \cs{mst@active@math@prime}.
%
%    \mstrelease{1.2b} |2012/12/31|: doing\\
%    \null\hspace{1cm}|{\catcode`\'=\active \global\let'\mst@active@math@prime}|\\
%    is awfully wrong when the right quote is made active at begin document by
%    some other package (as happens with |babel| for some languages). So \mst
%    treats now the right quote with the same method as applied to the other
%    characters it makes mathematically active. This uses the macro
%    \cs{mst@mathactivate} which is defined later in the package.
%
%    Babel does |\let\prim@s\bbl@prim@s| when |'| is made active via its
%    services (the czech and slovak languages also store the initial
%    version of \cs{prim@s}, else the quote would not work correctly
%    when being again of |catcode 12|), and it doesn't matter if \mst is
%    loaded before or after this happens, as the \cs{mst@mathactivate}
%    does its job only as part of the \cs{everymath} and
%    \cs{everydisplay} token lists.
%
%    \mstrelease{1.2e} being paranoid, we take precautions against a possibly
%    catcode active right quote at
%    the time of loading mathastext.
%
% \mstrelease{1.3i} adds \cs{MTactiveprime}.
% 
% \mstrelease{1.3j} renames it to \cs{MTprimedoesskip}. Besides, it makes use in the
% preamble of \cs{MTnormalprime} or \cs{MTprimedoesskip}.
%
% \mstrelease{1.4} adds the support for the new ``non-everymath''
% implementation, which has to satisfy to very different constraints.
%
% The \cs{MTprimedoesskip} is not a |no-op| in |subdued| math version.
% This is legacy situation, not changed at \mstrelease{1.4}.
%
%    \begin{macrocode}
\newmuskip\mst@prime@muskip
\def\mst@prime@skip{.5mu}
\ifmst@italic\ifmst@frenchmath\else\def\mst@prime@skip{0mu}\fi\fi
%    \end{macrocode}
% Shouldn't I have rather hacked \cs{prim@s}? (answer: perhaps related to
% Babel see a comment above).\par
% \noindent
% TODO: clarify why I used \cs{sp} not |^| in
% \cs{mst@active@math@prime} in 2012/2013.\newline
% TODO: clarify why I am paranoid regarding the |'| catcode here.
%
% The |everymath| branch was initially superficially refactored at
% \mstrelease{1.4}, but unfortunately as \cs{mst@mathactivate} had been
% modified to not handle mathematically active characters, this meant that the
% \mst feature of extra math skip was lost under the |everymath| option, due to
% an oversight by the author.  For this among other reasons having mainly to
% do with code comments we did \mstrelease{1.4a}.
%
% At \mstrelease{1.4} we can not go via \cs{mst@mathactivate} (defined further
% down in the code) which filters out the already mathematically active
% characters.
%
% Why am I paranoid here about |'| catcode at package loading time? (this
% looks ridiculous...).
%    \begin{macrocode}
\def\mst@tmp#1{%
\def\mst@mathactivateprime{%
  \ifnum\catcode`#1=\active
    \@ifundefined{active@char#1}
                 {}
                 {\mst@do@activecase #1{}{\mst@active@math@prime}}%
  \else
    \mst@@mathactivate #1{}{\mst@active@math@prime}%
  \fi
}%
%    \end{macrocode}
% The ``undo'' is needed at \mstrelease{1.4} (but not if |everymath|).
%    \begin{macrocode}
\def\mst@undo@mathactivateprime{\mst@mathdeactivate#1{"8000}}%
}\expandafter\mst@tmp\string'
\def\mst@active@math@prime{\sp\bgroup\mskip\mst@prime@muskip\prim@s}
\ifmst@everymath
    \newcommand*\MTnormalprime  {\let\mst@modifyprime\@empty}
    \newcommand*\MTprimedoesskip{\let\mst@modifyprime\mst@mathactivateprime}%
    \AtBeginDocument{%
      \everymath\expandafter
               {\the\everymath    \mst@modifyprime \MTnormalprime}%
      \everydisplay\expandafter
               {\the\everydisplay \mst@modifyprime \MTnormalprime}%
%    \end{macrocode}
% MEMO: |subdued| case will do its own \cs{MTnormalprime} at
% |\begin{document}| later as part of \cs{MTeverymathoff}.
%    \begin{macrocode}
      \MTprimedoesskip
    }
\else
%    \end{macrocode}
% \mstrelease{1.4} must do things a bit differently.
%    \begin{macrocode}
    \newcommand*\MTnormalprime  {\mst@undo@mathactivateprime}
    \newcommand*\MTprimedoesskip{\mst@mathactivateprime}
%    \end{macrocode}
% MEMO: |subdued| case will do its own \cs{MTnormalprime} at
% |\begin{document}| later as part of \cs{MTeverymathoff}.
%    \begin{macrocode}
    \AtBeginDocument{\MTprimedoesskip}
\fi
%    \end{macrocode}
%  \end{macro}\end{macro}\end{macro}\end{macro}\end{macro}
% \begin{macro}{\MTexistsskip}
% \begin{macro}{\MTforallskip}
% \begin{macro}{\MTprimeskip}
%   \mstrelease{1.15e}: These user macros set up the amount of muglue after
%   \cs{exists} or \cs{forall}. The normal and
%   bold math versions inherit the same skips; these skips are set to
%   zero in case of the subdued, or the italic option. Each command
%   \cs{Mathastext}\oarg{version\_name} stores the current values in
%   the definition of the math version.
%
%   \mstrelease{1.2}: \cs{MTprimeskip} added, the silly \cs{@onlypreamble} are removed
%   and the macros are modified to have immediate effect in the document,
%   independently of their possible use in the preamble for the math
%   versions to store values.
%
%   Note (september 2013): the names were badly chosen; \cs{MTsetprimeskipto}
%   for example would have been a better choice.
%    \begin{macrocode}
\newcommand*\MTexistsskip[1]{\edef\mst@exists@skip{#1}%
    \mst@exists@muskip\mst@exists@skip\relax}
\newcommand*\MTforallskip[1]{\edef\mst@forall@skip{#1}%
    \mst@forall@muskip\mst@forall@skip\relax}
\newcommand*\MTprimeskip[1]{\edef\mst@prime@skip{#1}%
    \mst@prime@muskip\mst@prime@skip\relax}
\let\Mathastextexistsskip\MTexistsskip
\let\Mathastextforallskip\MTforallskip
\let\Mathastextprimeskip\MTprimeskip
\let\mathastextexistsskip\MTexistsskip
\let\mathastextforallskip\MTforallskip
\let\mathastextprimeskip\MTprimeskip
%    \end{macrocode}
%  \end{macro}\end{macro}
%  \end{macro}
%  \begin{macro}{\resetMathstrut@}
%        |2012/12/31|: The |amsmath| macro \cs{resetMathstrut@} is not compatible
%        with a
%        mathematically active opening parenthesis: it does \\
%        \null\hspace{1cm}|\mathchardef\@tempa\mathcode`\(\relax|\\
%        and is made a part of the hook \cs{every@math@size} inside
%        \cs{glb@settings}. 
%        This is called from \cs{check@mathfonts} which is done in
%        particular in \cs{frozen@everymath}, hence \emph{before} (but wait)
%        what \mst puts in \cs{everymath}. Also, \cs{glb@settings} is triggered
%        by \cs{mathversion} which must be done outside of math mode.
%
%        Alas, with things such as |$...\hbox{...$..$..}...$| \mst will have
%        already made the parenthesis (mathematically) active. And
%        \cs{boldsymbol} from |amsbsy| disables the \cs{@nomath} switch and
%        executes \cs{mathversion\{bold\}} directly in math mode. So we have a
%        problem with \cs{resetMathstrut@}. 
%
%        |lualatex-math| replaces \cs{resetMathstrut@} with its own version
%        (which also looks at |)|) and no error is signaled when \mst has done
%        |\mathcode`(="8000|, but the \cs{Mathstrutbox@} created by \mst is then
%        wrong.
%
%        The replacement macro avoids a potentially math active |(|. It
%        assumes that there is still some appropriate glyph in slot |40| of
%        |operators| and it sets the height and depth of \cs{Mathstrutbox@}
%        to be large enough to accomodate both this glyph and the one from the
%        mathastext font (both in the current math version). If option
%        |noparenthesis| was used, we leave everything untouched.
%
%    In \mstrelease{1.3a}, |2013/09/04|, the modification is done only at the time of
%    \cs{MTnonlettersobeymathxx}. It is canceled by
%    \cs{MTnonlettersdonotobeymathxx}. So the code has been moved to these
%    macros and here we just store at the begin document the then meaning of
%    \cs{resetMathstrut@}, and check also if \cs{MTnonlettersobeymathxx} has
%    been invoked in the preamble.
%
%    \mstrelease{1.3f} |2015/09/12| issues only an Info message not a Warning, as I am
%    becoming aware from another context (etoc) that Warnings are stressful to
%    users, in some integrated environments for editing and compiling \LaTeX{}
%    source files.
%
%    \mstrelease{1.4} adds here an \cs{AtEndOfPackage}.  As this must be
%    executed (if not in the legacy |everymath| context) after the
%    redefinition of \cs{MTnonlettersobeymathxx} which happens at begin
%    document.
%    \begin{macrocode}
\ifmst@noparen\else
\AtEndOfPackage{%
  \AtBeginDocument{%
    \@ifundefined{resetMathstrut@}
      {}%
      {%
       \let\mst@savedresetMathstrut@\resetMathstrut@
%    \end{macrocode}
% The |\ifx\mst@the\the| is true iff \cs{MTnonlettersobeymathxx} was used in preamble
% (last compared to \cs{MTnonlettersdonotobeymathxx}).
% Setting \cs{mst@the} to \cs{@gobble} here wiil cause \cs{MTnonlettersobeymathxx}
% to indeed modify \cs{resetMathstrut@} (and it resets \cs{mst@the} to \cs{the} for
% its behavior in \cs{everymath}).
%    \begin{macrocode}
       \ifx\mst@the\the
         \let\mst@the\@gobble
         \MTnonlettersobeymathxx
       \fi
      }%
  }%
}%
\fi
%    \end{macrocode}
%  \end{macro} 
%
%      \mstrelease{1.2} |2012/12/20| does some rather daring \emph{math} activation of
%      \verb$; , : ! ? + - = < > ( ) [ ]$  in
%      math mode to achieve something I wanted to do since a long time: overcome
%      the mutually excluding relation between the variable-family concept and
%      the automatic spacing concept. After loading \mst, these characters now
%      obey the math alphabets commands but still have the automatic spacing.
%      The use as delimiters for those concerned is also ok.
%
%    The activation is done via setting the \cs{mathcode} to |"8000| through the
%    macro \cs{mst@mathactivate} which in turn is put into the \cs{everymath}
%    and \cs{everydisplay} token lists. No character is made active in the sense
%    of the \cs{catcode} (the issues with catcode active characters at
%    the entrance of the math mode are discussed later),\\
%    \null\hspace{1cm}\fbox{but the concerned characters will now expand in math
%    mode to \emph{two} tokens.}\\
%      \mstrelease{1.2c} |2012/12/31|: hence, this current
%      implementation puts constraints on the input: |$x^?$| or |$x\mathrel?y$|
%      now create errors. They must be input
%      |$x^{?}$|, respectively |$x\mathrel{?}y$|.\\
%   \null\hspace{1cm} \fbox{The disactivating
%        macro \cs{MTnonlettersdonotobeymathxx} is made the default.}
%
%        The mechanism is (even more) off by default for |\{| and |\}| as this
%        is not compatible with their use as delimiters (|\lbrace| and |\rbrace|
%        should be used instead) but it can be activated for them too.
%      
%
%    \mstrelease{1.2b} |2012/12/30|: there were bad oversights in the \mstrelease{1.2} code
%    for \cs{mst@mathactivate} related to the possibility for some
%    characters to have been made active (in the sense of the catcode)
%    elsewhere (something which often is done by language definition
%    files of the |babel| system). The code from |v1.2b| tried to
%    provide correct behavior using a prefix called \cs{mst@fork} (its
%    definition and its use has since been modified) which let the
%    active character expand to the \mst re-definition \emph{only} in
%    math mode and \emph{only} if \cs{protect} was
%    \cs{@typeset@protect}. This indeed took care of situations such as
%    |$\hbox{?}$| with an active |?| or |$\label{eq:1}$| with an active
%    |:| (assuming for the latter that things would have worked ok before
%    the twiddling by \mst).
%
%    \mstrelease{1.2e} |2013/01/09|: alas |$\ref{eq:1}$| still was a problem.
%    Indeed in that case the \mst prefix had no means to know it was
%    inside a \cs{ref} so it made the character expand to its \mst
%    redefinition, which is not acceptable inside a
%    |\csname...\endcsname|. What happens with Babel is that it patches
%    things such as \cs{ref}, \cs{newlabel},... we can test the
%    \cs{if@safe@actives} flag to detect it in that case, but this is
%    Babel specific. After having thought hard about this I see no
%    general solution except patching all macros such as \cs{ref}...(in
%    an imitation of what Babel does). So the final decision is to not
%    do anything when the character is catcode active \emph{except} it
%    it seems that Babel is behind the scenes.
% 
%    Incidently, Babel and TikZ are buggy with characters which are
%    mathcode actives. For example the combination of |[french]{babel}|
%    and |mathtools| with its |centercolon| turns |$:$| into an
%    \emph{infinite loop} !! 
%
%    In the case of Babel the reason is that, generally (but not always,
%    the right quote |'| is an exception), the
%    \cs{normal@char}\meta{char} fall-back is \cs{string}\meta{char}.
%    But this is wrong if the mathcode is |32768|! The fall-back becomes
%    the default if the user switches to a language where \meta{char} is
%    `normal' and then an infinite loop arises.
%
%    As a further example (I am not familiar with other languages from
%    the Babel system) with |frenchb| the active |!?;:| expand in math
%    mode to \cs{string}|! or ? or ; or :|. This creates an infinite
%    loop if the mathcode is |32768|.
%
%    For the special case of the right quote |'| when it is made active
%    by Babel, its fall-back does not invoke |\string'| so being still
%    of mathcode |32768| is not a problem.
%  
%    I have posted online ^^A on TeX StackExchange 
%    how Babel should possibly modify
%    its definitions and I use this here. I simplify a bit my proposed
%    replacement of \cs{normal@char}\meta{char} as the check for
%    \cs{protect} is superfluous, I think, having been
%    done already at the level of the Babel prefix.
%
%    Replacing \cs{user@active}\meta{char} is indeed not enough, and
%    \cs{normal@char}\meta{char} also must be changed, because when the
%    user switches back to a language where the character is `normal' it
%    remains catcode active. The crucial thing is the test of
%    \cs{if@safe@actives} in the replacement of the
%    \cs{normal@char}\meta{char}, besides of course the test for math
%    mode in both replacements.
%
%    When the character is not catcode active, then \mst uses the math
%    activation method. As the mathcode is not looked at in \cs{edef},
%    \cs{write} or inside |\csname...\endcsname| nothing special needs
%    to be done, I think, in terms of protection against premature
%    expansion. (I did not know that initially). 
%
%    So, to recapitulate, \mst will use the mechanism of the active
%    |mathcode| if the character is not |catcode| active, and in the
%    opposite case will do something only in the context of Babel,
%    modifying directly its \cs{user@active}\meta{char} and its
%    \cs{normal@char}\meta{char} macros and \fbox{it does NOT then set
%    the mathcode to 32768!!}, rather it makes \emph{sure} the character
%    is not mathematically active.
%
%    As \mstrelease{1.2e} is a bit paranoid it takes precautions against
%    the possibility of characters it treats being active at
%    the time of its loading. Excepted from the scope of the
%    paranoia are the latin letters (that would be crazy!) and
%    also |*|, |"| and the left quote |`|.
%
%    \mstrelease{1.2f} |2013/01/21| with earlier versions (*) it was important not
%    to do twice the business of \cs{mst@mathactivate} (think
%    |$\hbox{$?$}$|), so I used (this was a bit wasteful) some sort of
%    boolean macro for each character. But now that there are the
%    |\mst@the..| prefixes, let's just use them! (don't know why I did
%    not think of that earlier; perhaps I had in mind some more general
%    character per character customization initially, which I just dropped.)
%
%    (*) it is still important to not do twice the thing when the
%    character is active, in which case the |babel| macros are patched.
%
%    As an aside, |$\hbox{\catcode`?=\active $?$}$| for an |?| which was
%    unactive at the first |$| will just make \mst overwrite the
%    definition (assumed here to have been done earlier) of an active
%    |?|, but the result is that the inner |?| can not be used in
%    |\label| or |\ref|. So testing for active characters should be done
%    always... many things should be done always... I leave as is.
%
%    \mstrelease{1.3i} |2016/01/06| removes a spurious end of line space in
%    \cs{mst@mathactivate} (did not show as anyhow done in math mode).
%
%    \mstrelease{1.4} has significantly refactored the coding, there were
%    simplication from a changed way to use \cs{mst@mathactivate} for letters
%    and added branches to accomodate the renouncement to \cs{everymath}.
% \begin{macro}{\mst@do@activecase}
% Called by \cs{mst@mathactivate} if |#1| is catcode active.
%
% Check if token activation originates apparently into \ctanpkg{babel}:
% \begin{itemize}[nosep]
% \item if NO, nothing is done. The active meaning of |#1| is not modified.
% \item if YES, we hook into \ctanpkg{babel} associated macros so
%   that in math mode the catcode active token does what \mst expects it to
%   do. Its \cs{mathcode} is set to the
%   one of the associated \cs{mathalpha} symbol as declared by \mst, except
%   for asterisk and right tick which simply use their ascii number as mathcode.
% \end{itemize}
%
% In the case of \ctanpkg{babel}-spanish which has a catcode active right
% tick, resetting its mathcode has the advantage to reveal in output the case
% of a faulty input using the curly right tick U+8217 which one can get easily
% from copy paste, for example from the |babel-spanish.pdf| file.
%
% And in general it is dangerous to have a character both catcode active and
% mathcode active. 
%
% Some auxiliaries.
%    \begin{macrocode}
\def\mst@magic@v #1#2#3#4#5{#1#3#4}
\def\mst@magic@vi #1#2#3#4#5#6{#1#2#4#5}
\def\mst@fork{\ifmmode\mst@magic@v\fi\@thirdofthree}
\def\mst@safefork{\ifmmode\if@safe@actives\else\mst@magic@vi\fi\fi\@thirdofthree}
%    \end{macrocode}
% Some refactoring (and streamlining) at \mstrelease{1.4} here.
% \begin{footnotesize}
%   There was at some point in the case of a Babel-active token a special
%   hanlding for |#1| to use \cs{MTmathcharletter}|#1| (and event for
%   digits!).  But this is almost impossible to arise in practice:
% \begin{itemize}[nosep]
% \item Babel commands to set up a shorthand are preamble only (they use
%   \cs{AtBeginDocument}),
% \item A shorthand is made active at begin document, and we don't want that
%   for a letter!
% \item Activation is recorded as an instruction in the |.aux| file which
%   breaks it almost surely (except perhaps for letter |Z| or such not
%   likely to appear in macro names in the |.aux| file).
% \item Even if we somehow hack against that (which I did to test) a more
%   subtle problem arises that Babel updates \cs{nfss@catcodes}, so that the
%   latter will want to make (e.g.) |a| of catcode 12! This causes breakage
%   very easily at the time of \cs{process@table} almost as easily as with
%   the |a| set to be an active character...
% \end{itemize}
%
%^^A In revisiting and
%^^A improving the coding here (following up on a simplification of
%^^A \cs{mst@mathactivate} itself, I discovered a bug of earlier releases: in
%^^A this fictitious "letter made active by Babel" branch the insertion of mu
%^^A glue around the letter was lost, only the italic correction was kept in the
%^^A modified meaning of Babel active letter in math mode.  This bug was
%^^A dissolved by the new way \cs{mst@mathactivate} is used by
%^^A \cs{mst@DeclareMathLetter} and the ensuing simplifcation here.  But in fact
%^^A as summarized above this is purely fictitious code, which will never get
%^^A executed in real life!
%^^A As I am not of the repenting type, I also add at \mstrelease{1.4} a similar
%^^A fictituous layer for catcode active digits...\par
% \end{footnotesize}
% |#1| here is a character token of catcode 11 or 12.
% We do something only if the catcode activation appears to have been triggered
% by \ctanpkg{babel}.  The test has been moved earlier at \mstrelease{1.4}.
%    \begin{macrocode}
\def\mst@do@activecase#1#2#3{%
%    \end{macrocode}
% As letters and digits are impossible here, |#2| is either empty (which
% happens only now for asterisk and right tick) or a single token (\cs{mathclose},
% \cs{mathopen},... ).  When |#2| is not empty, |#3| is always a mathchar
% token.  For safety we make sure then the mathcode is not active.
%
% The rationale is
% to avoid context where people have both catcode and math active and use
% |\string|.  In the case of \ctanpkg{babel}-spanish with
% |activeacute| option it allows to reveal more easily input errors using
% curly right tick U+8217.
%
% Arguably I probably mainly wanted to do this if the character was found
% catcode active but not a Babel shorthand.  But it ended into the Babel
% branch and the non-Babel branch for active catcode is to do nothing.
%
% |#2| is empty exactly for the case of the right tick and the asterisk.
% In all other cases, then |#3| is a mathchar token.
%    \begin{macrocode}
    \ifx\relax #2\relax\mathcode`#1=`#1\relax\else\mathcode`#1=#3\relax\fi
%    \end{macrocode}
% Less \cs{expandafter}'s at \mstrelease{1.4}.  Also, it is now required
% to make sure:
% \begin{itemize}[nosep]
% \item not do it twice in succession (else infinite loop),
% \item and undo it when deactivating.
% \end{itemize}
% This was easily done under legacy code (now only used under |everymath|
% option, and only for non-letters) as it activated only when entering into
% math mode.
%
% This is more annoying when activation happens in an uncontrolled
% scope, and we handle this via a \cs{mst@hackedshorthand@<char>} flag.
%
% MEMO: the undoing is done in \cs{mst@mathdeactivate} which is invoked
% only for those non-letters submitted to \cs{mst@mathactivate}.
%    \begin{macrocode}
    \ifmst@everymath\else\@ifundefined{mst@hackedshorthand@#1}{\fi
    \expandafter\let\csname mst@orig@user@active#1\expandafter\endcsname
                    \csname user@active#1\endcsname
    \expandafter\let\csname mst@orig@normal@char#1\expandafter\endcsname
                    \csname normal@char#1\endcsname
    \ifmst@everymath\else}{}\fi
%    \end{macrocode}
% No more \cs{edef}'s at \mstrelease{1.4}.  At this release, in letter case
% |#3| is empty and |#2| is a single token which needs no extra brace
% pair as this brace pair will come from its expansion.
% We can use |{#2}{#3}| in all cases rather than either |{{#2#3}}{}| versus
% |{#2}#3| depending on whether |#1| is letter or not as was done in the past.
% Attention that |#2| and |#3| may each be empty.
%    \begin{macrocode}
    \def\mst@tmp##1##2{\def##1{\mst@fork{#2}{#3}##2}}%
    \expandafter\mst@tmp\csname user@active#1\expandafter\endcsname
                        \csname mst@orig@user@active#1\endcsname
    \def\mst@tmp##1##2{\def##1{\mst@safefork{#2}{#3}##2}}%
    \expandafter\mst@tmp\csname normal@char#1\expandafter\endcsname
                        \csname mst@orig@normal@char#1\endcsname
    \ifmst@everymath
    \else
      \expandafter\let\csname mst@hackedshorthand@#1\endcsname\@empty
    \fi
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\mst@@mathactivate}
%    \begin{macrocode}
\begingroup
  \catcode`\~=\active
  \def\x{%
\endgroup
%    \end{macrocode}
% |##1| is always a token of catcode 11 or 12.
%    \begin{macrocode}
\ifmst@everymath
   \def\mst@@mathactivate##1##2##3{%
      \begingroup
      \lccode`~=`##1
      \lccode`##1=`##1
%    \end{macrocode}
% Careful here as |##2| is empty in the asterisk and prime case.  And |##3|
% also is at \mstrelease{1.4} empty for letters.
%    \begin{macrocode}
      \lowercase{\endgroup
%    \end{macrocode}
%   Refactoring at \mstrelease{1.4} merged the catcode 11 and catcode 12
%   branches here and in particular avoided in former case an \cs{edef}.  This
%   helped into providing the \cs{MTcommandletter}\meta{letter} as a
%   customizable macro. There was no equivalent to this macro, which here is
%   |##2|, prior to \mstrelease{1.4}.
%    \begin{macrocode}
        \mathcode`##1="8000
        \def~{##2##3}%
      }%
    }%
\else
   \def\mst@@mathactivate##1##2##3{%
      \begingroup
      \lccode`~=`##1
      \lccode`##1=`##1
      \lowercase{\endgroup
        \mathcode`##1="8000
%    \end{macrocode}
% Also, \mstrelease{1.4} possibly execute \cs{mst@mathactivate} everywhere
% in document body (at version changes for example) or at begin document.
% Hence this modifies globally the active meaning.  So we add some safeguard
% here using an \cs{ifmmode}.  And we store the original meaning of the
% active variant of the token to reset it when ``undoing''.
%
% Careful not to do it twice in a row... (but this means \cs{mst@deactivate}
% might not revert to a user custom redefinition done in-between but to a
% prior one; although if the character is made active the second
% \cs{mst@mathactivate} would not have been done).
%    \begin{macrocode}
        \@ifundefined{mst@prioractivemeaning@##1}
                     {\expandafter\let
                      \csname mst@prioractivemeaning@##1\endcsname ~}
                     {}%
        \def~{\ifmmode##2##3\else##1\fi}%
      }%
    }%
\fi
}\x
%    \end{macrocode}
%   At \mstrelease{1.4} the macro was split into two, to test first whether the
%   character which is encountered is currently with active catcode.
%
%   At \mstrelease{1.4}  the non-catcode active branch is entered only if the
%   character isn't mathematically active at time of use..
%
%   Careful that |#2| and |#3| may each be empty.  The test for being a Babel
%   shorthand is done here and not as prior to \mst@release{1.4} inside
%   \cs{mst@do@activecase}.
%    \begin{macrocode}
\def\mst@mathactivate#1#2#3{%
    \ifnum\catcode`#1=\active
      \@ifundefined{active@char#1}{}{\mst@do@activecase #1{#2}{#3}}%
    \else
      \mst@OnlyIfNotMathActive{#1}{\mst@@mathactivate #1{#2}{#3}}%
    \fi
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\mst@mathdeactivate}
% This is needed at \mstrelease{1.4} for non-letters which are mathematically
% activated.  See comments above in \cs{mst@do@activecase}.  Works in
% sync with \cs{mst@addtodo@nonletters}.
%
% The \cs{mst@mathdeactivate} is active (sic) only in the non |everymath|
% situation.  It will restore a previously existing active meaning if it has
% been changed.
%    \begin{macrocode}
\ifmst@everymath
\else
\def\mst@mathdeactivate#1#2{%
  \mathcode`#1=#2\relax
  \@ifundefined{active@char#1}
      {\@ifundefined{mst@prioractivemeaning@#1}
             {}%
             {\mst@restoreactivemeaning#1%
              \expandafter\let\csname mst@prioractivemeaning@#1\endcsname\relax}%
      }
      {\@ifundefined{mst@hackedshorthand@#1}
       {}
       {\expandafter\let\csname user@active#1\expandafter\endcsname
                        \csname mst@orig@user@active#1\endcsname
        \expandafter\let\csname normal@char#1\expandafter\endcsname
                       \csname mst@orig@normal@char#1\endcsname
        \expandafter\let\csname mst@hackedshorthand@#1\endcsname\relax
       }%
      }%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\mst@restoreactivemeaning}
%   At \mstrelease{1.4} when we undo the mathematical activation we now also
%   restore the prior existing active meaning, if any.  Only in the ``no
%   |everymath|'' branch (because in the |everymath| \TeX{} itself takes care
%   of that on exiting the scope of the math mode).
%    \begin{macrocode}
\def\mst@restoreactivemeaning#1{%
    \begingroup
    \lccode`~=`#1
    \lccode`#1=`#1
    \lowercase{\endgroup
      \expandafter\let\expandafter~\csname mst@prioractivemeaning@#1\endcsname
    }%
}
\fi
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\mst@do@nonletters}
% \begin{macro}{\mst@addtodo@nonletters}
% \begin{macro}{\mst@the}
% \begin{macro}{\MTnonlettersobeymathxx}
% \begin{macro}{\MTnonlettersdonotobeymathxx}
%    These macros are modified in version \mstrelease{1.3a} |2013/09/04| in order to
%    cleverly adjust, or not, the |amsmath| \cs{resetMathstrut@}. When used in
%    the preamble, they just modify \cs{mst@the}. And there is code at begin
%    document to check the status there of \cs{mst@the} and if its meaning is
%    \cs{the}, then \cs{MTnonlettersobeymathxx} is activated again to do the
%    patch. When used in the body they adjust \cs{resetMathstrut@}.
%
%    Notice that the saved meaning is the one at begin document (thus,
%    possibly patched by |lualatex-math| --- not anymore since 1.5 of March
%    2016, as |amsmath.sty| now maintained by LaTeX team has modified
%    \cs{resetMathStrut@} to make it compatible to Unicode engines) but
%    modifications done after that would not be seen in
%    |\mst@savedresetMathstrut@|.
%
%    The new version of \cs{resetMathStrut@} from LaTeX team release
%    |2016/03/03 v2.15a| of |amsmath.sty| is still not compatible with a math
%    active opening parenthesis. Hence my patch here is still needed.
%
%    At \mstrelease{1.3u} \cs{MTnonlettersobeymathxx} and \cs{MTeasynonlettersobeymathxx}
%    are made no-ops under subdued mode. This fixes some bug if for example
%    the former was used in preamble or immediately after |\begin{document}|
%    making the minus sign math active although the \mst action was
%    supposedly subdued. Similarly \cs{MTmathactiveletters} is now a no-op
%    if issued under subdued mode in the \emph{normal} or \emph{bold} math
%    versions.
%    \begin{macrocode}
\newtoks\mst@do@nonletters
\ifmst@everymath
\else
    \newtoks\mst@undo@nonletters
\fi
%    \end{macrocode}
% |#1| is a category 12 character, |#2| is a \cs{mathopen}, or \cs{mathclose},
% etc..., |#3| is a \cs{mathchar} (of variable family type).
%
% At \mstrelease{1.4}, \cs{mst@mathactivate} will not do anything if |#1|
% is mathcode active (but not catcode active) at time of use.
%    \begin{macrocode}
\ifmst@everymath
    \def\mst@addtodo@nonletters#1#2#3{\mst@do@nonletters\expandafter
                   {\the\mst@do@nonletters\mst@mathactivate#1#2#3}%
    }%
\else
%    \end{macrocode}
% We need to automatize some safeguards related to \cs{mst@do@activecase} when
% deactivating.
%    \begin{macrocode}
    \def\mst@addtodo@nonletters#1#2#3{\mst@do@nonletters\expandafter
                   {\the\mst@do@nonletters\mst@mathactivate#1#2#3}%
        \edef\mst@tmp{\noexpand\mst@mathdeactivate#1{\the\mathcode`#1}}%
        \mst@undo@nonletters\expandafter\expandafter\expandafter
                  {\expandafter\mst@tmp\the\mst@undo@nonletters}%
    }%
\fi
\let\mst@the\@gobble
%    \end{macrocode}
% As \cs{mst@savedresetMathstrut@} will only be defined at begin document,
% the next two macros are no-op in the preamble.
%    \begin{macrocode}
\def\mst@redefine@resetMathstrut@{%
      \@ifundefined{mst@savedresetMathstrut@}
      {}
      {%
        \ifmst@symboldelimiters
          \def\resetMathstrut@{%
           \setbox\z@\hbox{\the\textfont\symmtpsymbol\char40
                        \the\textfont\symmtoperatorfont\char40
                        \the\textfont\symoperators\char40}%
           \ht\Mathstrutbox@\ht\z@ \dp\Mathstrutbox@\dp\z@}%
        \else
          \def\resetMathstrut@{%
           \setbox\z@\hbox{\the\textfont\symmtoperatorfont\char40
                        \the\textfont\symoperators\char40}%
           \ht\Mathstrutbox@\ht\z@ \dp\Mathstrutbox@\dp\z@}%
        \fi
        \PackageInfo{mathastext}{\string\resetMathstrut@\space 
        from amsmath replaced for this\MessageBreak group or environment}%
      }%
}%
\def\mst@restore@resetMathstrut@{%
      \@ifundefined{mst@savedresetMathstrut@}{}{%
        \PackageInfo{mathastext}{restoring for this group or environment
                                 the original\MessageBreak
                                 amsmath \protect\resetMathstrut@}%
      \let\resetMathstrut@\mst@savedresetMathstrut@}%
}%
\ifmst@everymath
  \newcommand*\MTnonlettersobeymathxx{%
    \mst@OnlyIfNotSubdued{%
        \ifx\mst@the\the
        \else
           \mst@redefine@resetMathstrut@
        \fi
        \let\mst@the\the
    }%
  }%
  \newcommand*\MTnonlettersdonotobeymathxx{%
    \ifx\mst@the\@gobble
    \else
      \mst@restore@resetMathstrut@
    \fi
    \let\mst@the\@gobble
  }%
\else
  \newcommand*\MTnonlettersobeymathxx{%
     \mst@OnlyIfNotSubdued{%
        \AtBeginDocument{\MTnonlettersobeymathxx}%
     }%
  }%
  \newcommand*\MTnonlettersdonotobeymathxx{%
     \AtBeginDocument{\MTnonlettersdonotobeymathxx}%
  }%
  \AtBeginDocument{%
    \renewcommand*\MTnonlettersobeymathxx{%
        \mst@OnlyIfNotSubdued{%
             \the\mst@do@nonletters
             \ifx\mst@the\the
             \else
                \mst@redefine@resetMathstrut@
             \fi
             \let\mst@the\the
         }%
    }%
    \renewcommand*\MTnonlettersdonotobeymathxx{%
        \the\mst@undo@nonletters
        \ifx\mst@the\@gobble
        \else
           \mst@restore@resetMathstrut@
        \fi
        \let\mst@the\@gobble
    }%
  }%
\fi
%    \end{macrocode}
% \end{macro}\end{macro}\end{macro}\end{macro}\end{macro}
% \begin{macro}{\MTeasynonlettersobeymathxx}
% \begin{macro}{\MTeasynonlettersdonotobeymathxx}
%    \begin{macrocode}
\newtoks\mst@do@easynonletters
\ifmst@everymath
    \newcommand*\MTeasynonlettersdonotobeymathxx{\let\mst@theeasy\@gobble}%
    \newcommand*\MTeasynonlettersobeymathxx{%
                \mst@OnlyIfNotSubdued{\let\mst@theeasy\the}%
    }%
    \MTeasynonlettersobeymathxx
\else
    \newtoks\mst@undo@easynonletters
    \newcommand*\MTeasynonlettersdonotobeymathxx{\the\mst@undo@easynonletters}
    \newcommand*\MTeasynonlettersobeymathxx{%
                \mst@OnlyIfNotSubdued{\the\mst@do@easynonletters}%
    }%
    \AtEndOfPackage{\MTeasynonlettersobeymathxx}%
\fi
%    \end{macrocode}
% \end{macro}\end{macro}
% \begin{macro}{\mst@addtodo@easynonletters}
% |#1| is a one character control sequence (|\.|, |\/|, |\#|, |\%| or |\&|)
% and |#2| is a mathchar.
%
% Perhaps I should use the Unicode engine \cs{Umathcode} et alia.  I do this
% at other places.  However
% I realized in 2013 and it is still true in 2024 that \LaTeX{} interface
% \cs{DeclareSymbolFont} does not allow to declare more than 16 font
% families even with \LuaLaTeX{} despite the latter allowing 256 such.
%
% So why bother?
%
% \mstrelease{1.4} adds to this legacy branch a test to not override
% a mathematically active ``easy'' non-letter.  Main case is the dot
% with Babel Spanish.
%    \begin{macrocode}
\ifmst@everymath
    \def\mst@addtodo@easynonletters#1#2{%
      \mst@do@easynonletters\expandafter{%
          \the\mst@do@easynonletters
          \mst@OnlyIfNotMathActive{#1}{\mathcode`#1=#2}%
      }%
    }%
    \def\mst@addtodo@easynonletters@U#1#2{%
      \mst@do@easynonletters\expandafter{%
          \the\mst@do@easynonletters
          \mst@OnlyIfNotMathActive{#1}{\mst@Umathcodenum`#1=#2}%
      }%
    }%
\else
%    \end{macrocode}
% The character may have been made mathcode active
% exterior to \mst.  We can not test this for sure at begin document as it
% may happen later.  If such an ``easy'' character is mathcode active,
% this can not originate in \mst.  So we should not overwrite when
% we issue \cs{MTeasynonlettersdonotobeymathxx}.  Example I know is
% with \ctanpkg{babel} Spanish which makes the dot math active.  With PDF\LaTeX{}
% it is also catcode active
%
% This macro may be used with Unicoe engines, and \LuaTeX{} and \XeTeX{}
% differ regarding math active characters.  I have only tested this (anew)
% for \mstrelease{1.4} for which this branch is needed, so in 2024.
%    \begin{macrocode}
    \def\mst@addtodo@easynonletters#1#2{%
      \mst@do@easynonletters\expandafter
                            {\the\mst@do@easynonletters
                             \mst@OnlyIfNotMathActive{#1}{\mathcode`#1=#2}}%
      \def\mst@tmp##1\relax{%
          \def\mst@tmp{\mst@OnlyIfNotMathActive{#1}{\mathcode`#1=##1\relax}}%
      }%
      \expandafter\mst@tmp\the\mathcode`#1\relax
      \mst@undo@easynonletters\expandafter\expandafter\expandafter
               {\expandafter\mst@tmp\the\mst@undo@easynonletters}%
    }%
    \def\mst@addtodo@easynonletters@U#1#2{%
      \mst@do@easynonletters\expandafter{%
         \the\mst@do@easynonletters
         \mst@OnlyIfNotMathActive{#1}{\mst@Umathcodenum`#1=#2}%
      }%
      \def\mst@tmp##1\relax{%
          \def\mst@tmp{\mst@OnlyIfNotMathActive{#1}{\mst@Umathcodenum`#1=##1\relax}}%
      }%
      \expandafter\mst@tmp\the\mst@Umathcodenum`#1\relax
      \mst@undo@easynonletters\expandafter\expandafter\expandafter
               {\expandafter\mst@tmp\the\mst@undo@easynonletters}%
    }%
\fi
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\newmcodes@}
% \begin{macro}{\mst@newmcodes@}
% \begin{macro}{\MTresetnewmcodes}
% \begin{macro}{\MTcustomizenewmcodes}
%   \mstrelease{1.15d}: the \cs{newmcodes@} amsmath macro causes an error in
%   Unicode engines as soon someone assigns a Unicode mathcode to the minus
%   sign, and then makes a \cs{DeclareMathOperator} declaration. Furthermore
%   it hard-codes the font family 0 as being the one to be used. Moreover just
%   putting the concerned signs |-|, |:|, |.|, |\| ,|'|, |*| inside braces
%   emulates enough the behavior (although the tick will give a prime).
%   
%   \mstrelease{1.3}: now tests if `basic' option was used.
%
%   \mstrelease{1.3d}: I should re-examine the situation with |\newmcodes@|. In the
%   meantime its relaxification will not be done if lualatex-math is
%   loaded. And the whole thing is put at begin document.
%
%   \mstrelease{1.3m}: |lualatex-math 1.5| n'a pas modifié son traitement de |\newmcodes@|
%   mais par contre a supprimé le patch de \cs{resetMathstrut@}. Mais la date
%   de release est restée à |2015/09/22| (date de \mstrelease{1.4a}) au lieu de quelque
%   chose comme |2016/03/13| (date pour l'annonce sur CTAN). Il faudra suivre
%   l'évolution future de |amsmath.sty| maintenant assurée par D.C.
%
%   \mstrelease{1.3n} |2016/04/22|: there is no more a patch of |\newmcodes@| by
%   |lualatex-math 1.6| |(2016/04/16)|, as |amsmath 2016/03/10 v2.15b| has now
%   a version compatible with \LuaLaTeX.
%
%   My very radical |\let\newmcodes@\relax| was only a temporary measure I
%   adopted for lack of time on October 13, 2012, and apart from avoiding to
%   do that in case |lualatex-math| was detected, I never came back... finally
%   I handle it myself for \mstrelease{1.3n}. The remaining problem of this macro (now
%   that it does not anymore crash |lualatex| or vice versa) is that (also
%   with |amsmath| version |2016/03/10 v2.15b|) it hardcodes the font used.
%   The aim of the macro is to modify the type of spacing affected to symbols
%   |'|, |*|, |.|, |-|, |/|, |:|, in case they are used in operator names.
%
%   \begin{itemize}
%   \item As I don't want to monopolize a count register only for
%     computations, let's just be mean if \eTeX\ not there.
%   \item \mst makes (or not, depending on commands issued by the user) these
%     characters math active (the right tick already is), which complicates
%     recovery of former mathcode. We have mathchar type \emph{macros}, but
%     then the complication is in diverging behaviors of the engines:
%     |\numexpr\mst@varfam@minus\relax| works with \LuaTeX, not with \XeTeX.
%   \item the |*| must presumably really be the non-lowered text glyph.
%   \item for the |-| I hesitated but do use the hyphen in the end.
%   \item seems I simply don't understand what the amsmath code does with
%     \cs{std@minus}. It is used in \cs{relbar} and it escapes me why
%     \cs{newmcodes@} would ever want to redefine it, and more importantly why
%     on earth it tests the mathcode of |-| for that ? yes, \cs{std@minus} is
%     defined (at begin document) using the mathcode of |-|, but what's the
%     connexion to \cs{newmcodes@} ?? Any way \mst defines \cs{relbar} with
%     \cs{mst@minus@sign}. Thus I just drop this conditional.
%   \item things are complicated by the options such as |nominus|,
%     |noparenthesis|.
%   \item the \cs{newmcodes@} macro is anyhow assuming that if a new math font
%     is used it occupies math groups |0| and |1| !! very bad; fixing it in
%     passing if the character has not been handled by \mst could be
%     envisioned, but that's not \mst's job.
%     \item years go by, and I remain as baffled as ever about the story of
%     ``more than 16 math families''. I will not test again, but I am pretty
%     sure that \cs{DeclareMathSymbol} does not work with more than 16
%     families, thus when I try to be a good boy and use \cs{Umathcode} syntax
%     with |symmtoperatorfont| I am perhaps doing unnecessary efforts.
%   \item I noticed that \LuaLaTeX\ does not apply the ``TeX Ligature'' (bad
%     name) regarding the right tick APOSTROPHE being transformed into RIGHT
%     SINGLE QUOTATION MARK in math mode, but \XeLaTeX\ does. From the point
%     of view of \mst, the behavior of \XeLaTeX\ is the coherent one. It
%     appears that \LuaLaTeX\ use in math mode of a text font does not obey
%     the set features.^^A like this
%^^A     \url{http://tex.stackexchange.com/questions/208688/oldstylefigure-issue-with-lualatex-and-mathastext}
%^^A     perhaps illustrates.
%     I opened a ticket at
%     \url{https://github.com/wspr/fontspec/issues/238}, but as usual it is
%     hard to figure out the best place where to report font matters.
%     \emph{This item might be obsolete -- not checked (1.3q).}
%     \item Some hesitation about what to do under option |symboldelimiters|. I
%     temporarily used |\symmtpsymbol|, except for the right quote and for the
%     hyphen, but finally  I drop that and use |\symmtoperatorfont| always.
%     (after testing how it looked like).
%   \end{itemize}
% All in all this is a great deal of trouble and I understand I postponed back
% in 2012! I spent some hours on this small thing, with consequent testing and
% for example this TeX Ligature issue with Unicode engines.
%
% Since \mstrelease{1.3v} we require e-\TeX{} extensions, so a test for
% \cs{numexpr} has been dropped here.
%    \begin{macrocode}
\ifmst@basic
\else
 \ifmst@XeOrLua
  \AtBeginDocument {%
  \ifx\newmcodes@\@undefined\else
  \edef\mst@newmcodes@{%
   \mst@Umathcode `\noexpand\' 0 \symmtoperatorfont 39\relax
   \ifmst@asterisk
    \mst@Umathcode `\noexpand\* 0 \symmtoperatorfont 42\relax 
   \else\mathcode`\noexpand\* 42 
   \fi
   \ifmst@nopunct\mathcode `\noexpand\."613A \mathcode `\noexpand\: "603A
   \else
    \mst@Umathcode `\noexpand\. 6 \symmtoperatorfont 46\relax 
    \mst@Umathcode `\noexpand\: 6 \symmtoperatorfont 58\relax 
   \fi
   \ifmst@nominus\mathcode`\noexpand\- 45 
   \else
      \mst@Umathcode `\noexpand\- 0 \symmtoperatorfont 45\relax
   \fi
   \ifmst@noparen\mathcode `\noexpand\/  47 
   \else
      \mst@Umathcode `\noexpand\/ 0 \symmtoperatorfont 47\relax
   \fi
  }%
  \let\mst@originalnewmcodes@\newmcodes@
  \fi
  }%
 \else
  \AtBeginDocument {%
  \ifx\newmcodes@\@undefined\else
  \edef\mst@newmcodes@{%
    \mathcode`\noexpand\' \the\numexpr\symmtoperatorfont*\@cclvi+39\relax
    \mathcode`\noexpand\* 
      \the\numexpr\ifmst@asterisk\symmtoperatorfont*\@cclvi\fi+42\relax
    \ifmst@nopunct\mathcode `\noexpand\."613A \mathcode `\noexpand\: "603A
    \else
      \mathcode`\noexpand\. \the\numexpr\mst@varfam@dot-"1000\relax
      \mathcode`\noexpand\: \the\numexpr\mst@varfam@colon-"1000\relax
    \fi
    \mathcode`\noexpand\- 
     \the\numexpr\unless\ifmst@nominus\symmtoperatorfont*\@cclvi\fi+45\relax
    \mathcode`\noexpand\/ 
     \the\numexpr\unless\ifmst@noparen\symmtoperatorfont*\@cclvi\fi+47\relax\relax
    }%
  \let\mst@originalnewmcodes@\newmcodes@
  \fi
  }%
 \fi
\fi
\newcommand*\MTresetnewmcodes{\ifx\mst@originalnewmcodes@\undefined\else
                               \let\newmcodes@\mst@originalnewmcodes@\fi}
\newcommand*\MTcustomizenewmcodes{\ifx\mst@originalnewmcodes@\undefined\else
                               \let\newmcodes@\mst@newmcodes@\fi}
%    \end{macrocode}
% \end{macro}\end{macro}\end{macro}\end{macro}
% \begin{macro}{mtoperatorfont}
%   Declaration of the current default font as our math
%   font. The characteristics of the used font can be
%   changed by a user call to the macros \cs{Mathastext} or
%   \cs{Mathastextwilluse}, which will be defined next. We
%   will also make one internal call to \cs{Mathastext} to
%   set up the normal and bold math versions, so we will
%   also employ \cs{SetSymbolFont} later. 
%    \begin{macrocode}
\DeclareSymbolFont{mtoperatorfont}{\mst@enc}{\mst@fam}{\mst@ser}{\mst@opsh}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\operator@font}
%   We modify this \LaTeX{} internal variable in order for the
%   predefined \cs{cos}, \cs{sin}, etc\dots to be typeset with the
%   |mathastext| font.  This will also work for things declared
%   through the \ctanpkg{amsmath} package command
%   \cs{DeclareMathOperator}. The alternative would have been to
%   redefine the `operators' Math Symbol Font. Obviously people
%   who expect that \cs{operator@font} will always refer to the
%   `operators' math font might be in for a surprise\dots{} well,
%   we'll see.
% \begin{macro}{\MTmathoperators-}\begin{macro}{obeymathxx}
% \begin{macro}{\MTmathoperators-}\begin{macro}{donot-}\begin{macro}{obeymathxx}
%       \mstrelease{1.2}: rather than just replacing \cs{symoperators} by
%       \cs{symmtoperatorfont} I add a modification which makes the
%       declared operator names sensitive to the math alphabets... ouh le
%       vilain!
%    \begin{macrocode}
\newcommand*{\MTmathoperatorsobeymathxx}
{\def\operator@font{\mathgroup\ifnum\fam=\m@ne\symmtoperatorfont\else\fam\fi}}
\newcommand*{\MTmathoperatorsdonotobeymathxx}
{\def\operator@font{\mathgroup\symmtoperatorfont}}
\MTmathoperatorsobeymathxx
%    \end{macrocode}
% \end{macro}\end{macro}\end{macro}\end{macro}\end{macro}\end{macro}
% \begin{macro}{mtletterfont}
%   At version \mstrelease{1.1}, we add the possibility to mimick the standard
%   behavior, that is to have italic letters and upright
%   digits. Thanks to Tariq~\textsc{Perwez} and
%   Kevin~\textsc{Klement} who asked for such a feature.
%    \begin{macrocode}
\DeclareSymbolFont{mtletterfont}{\mst@enc}{\mst@fam}{\mst@ser}{\mst@ltsh}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\MTfixmathfonts}
%   There is a long-standing issue
%   \url{https://github.com/lualatex/luaotfload/issues/204} on \LuaLaTeX{} not
%   applying OpenType features in math mode (this impacts |\url| macro too, as
%   it uses math mode.) Lua\TeX{} has two modes for handling of OpenType
%   fonts, the default in text being to use the |node| mode, and this mode is
%   non-working in math, thus \mst needs to force use of |base| mode. Else one
%   sees old style figures where one does not expect them, or the opposite,
%   depending on the default font feature.
%^^A see for example \url{http://tex.stackexchange.com/questions/208688/oldstylefigure-issue-with-lualatex-and-mathastext/277628}.
%
%   Once we know the cause, the fix is relatively easy. I will go for the
%   |\everymath| way, because I don't want to dwelve at all with the details
%   of \LaTeX's handling of math fonts, of size changes, of math versions
%   etc... perhaps in the future \LaTeX{} will fix the issue upstream by modifying
%   \cs{DeclareSymbolFont} under \LuaLaTeX{} + |luaotfload| regime, then the
%   present patch by \mst will be unneeded. Naturally, here we care only about
%   the two math fonts used by \mst: |mtoperatorfont| and |mtletterfont|.
%
%   For the |\url| situation, I have posted online a patch.
%^^A   \url{http://tex.stackexchange.com/questions/264206/cant-get-oldstyle-figures-in-url-with-lualatex}.
%
%   Not all is resolved, as I comment online
%^^A   \url{http://tex.stackexchange.com/a/307585/4686} and at
%   at \url{https://github.com/lualatex/luaotfload/issues/204#issuecomment-216465680}
%   that with |TeX Gyre Termes| for example I can not get simultaneously Old
%   Style and Tabular Figures to work in math mode, although the font name as
%   constructed by my patch (which is like the code below, only simpler as we
%   only have to consider |\textfont0|) is the correct one. Similarly with
%   |Vollkorn|: I can then not get the two features |lnum| and |tnum| to work
%   simultaneously when specified with |mode=base|. It does work with
%   |mode=node| but this mode ``does not work in math mode.''
%
% Done for \mstrelease{1.3o} of |2016/05/03|.
%
% \mstrelease{1.3p} renames the macro to \cs{MTfixmathfonts} for public access.
%
% \mstrelease{1.4} intercepts also |mode=harf|. Cf
% \url{https://tex.stackexchange.com/questions/722084/change-number-style-with-mathastext}
% (thanks to |user691586| for bug report).  The new code unconditionally
% replaces |mode=foo| by |mode=base|.  The complications due to the output of
% |\fontname| using only category 12 characters are handled in a different way
% than the |2016| code.
%
% The \url{https://github.com/latex3/fontspec/issues/525} problem causes
% additional complications.
%
% Perhaps I should simply zap spaces always rather than check for quotes?
% Anyway this appears to work.
%    \begin{macrocode}
\def\mst@fixmathfonts@#1.#2.#3.{%
\def\mst@fixmathfonts@##1##2#1=##3;##4##5\relax##6\@empty##7{%
  \ifx##3\empty\else
   \if"##1%
    \font\mst@mathfont=##1##2#1=base;##4##5\relax
   \else
    \mst@arrrrgh@fixmathfonts##1##2#1=base;##4##5#2\empty#3\relax
   \fi
   ##7=\mst@mathfont
  \fi
}%
\def\mst@arrrrgh@fixmathfonts##1#2##2##3#3##4\relax{%
  \ifx##2\empty
    \font\mst@mathfont="##1"\relax
  \else
    \font\mst@mathfont="##1"#2##2##3#3\relax
  \fi
}%
}%
\expandafter\mst@fixmathfonts@\detokenize{mode. at.pt.}%
\def\MTfixmathfonts#1{%
\def\MTfixmathfonts{%
  \expandafter\mst@fixmathfonts@\fontname\textfont\symmtoperatorfont
  \relax\relax #1=;\empty\relax\@empty{\textfont\symmtoperatorfont}%
  \expandafter\mst@fixmathfonts@\fontname\scriptfont\symmtoperatorfont
  \relax\relax #1=;\empty\relax\@empty{\scriptfont\symmtoperatorfont}%
  \expandafter\mst@fixmathfonts@\fontname\scriptscriptfont\symmtoperatorfont
  \relax\relax #1=;\empty\relax\@empty{\scriptscriptfont\symmtoperatorfont}%
  \expandafter\mst@fixmathfonts@\fontname\textfont\symmtletterfont
  \relax\relax #1=;\empty\relax\@empty{\textfont\symmtletterfont}%
  \expandafter\mst@fixmathfonts@\fontname\scriptfont\symmtletterfont
  \relax\relax #1=;\empty\relax\@empty{\scriptfont\symmtletterfont}%
  \expandafter\mst@fixmathfonts@\fontname\scriptscriptfont\symmtletterfont
  \relax\relax #1=;\empty\relax\@empty{\scriptscriptfont\symmtletterfont}%
}}%
\expandafter\MTfixmathfonts\expandafter{\detokenize{mode}}%
\ifmst@LuaTeX
  \everymath\expandafter{\the\everymath\mst@fixmathfonts}%
  \everydisplay\expandafter{\the\everydisplay\mst@fixmathfonts}%
\fi
\newcommand*\MTfixfonts{\let\mst@fixmathfonts\MTfixmathfonts}%
\newcommand*\MTdonotfixfonts{\let\mst@fixmathfonts\empty}%
\MTfixfonts
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\Mathnormal}
% \begin{macro}{\Mathrm}
% \begin{macro}{\Mathbf}
% \begin{macro}{\Mathit}
% \begin{macro}{\Mathsf}
% \begin{macro}{\Mathtt}
% \begin{macro}{\Mathnormalbold}
%   We redefine the default normal, rm, bf, it, sf, and tt alphabets,
%   but this will be done via |\renewcommand*{\mathrm}{\Mathrm}| etc\dots
%   (not anymore, see comment below).
%
%   We follow the standard \LaTeX{} behavior for \cs{mathbf}, which is
%   to pick up the bold series of the roman font (digits and operator
%   names).
%
%   We will access (if no option is passed for Greek) the \cs{omicron}
%   via \cs{mathnormal}. But unfortunately the \ctanpkg{fourier} package with the
%   upright option does not have an upright omicron obtainable by simply
%   typing \cs{mathnormal}|{o}|. So if |fourier| is loaded we use
%   \cs{mathrm} and not \cs{mathnormal}.
%
%   Actually math alphabet macros are created robust since \LaTeX{} from 2005,
%   so at \mstrelease{1.3v} |2019/09/19| I decided to modify the old \mst approach a bit.
%   Indeed with the old approach a \cs{mathtt} in a moving argument translates
%   ultimately into \cs{Mathtt} but if for example the new context where it
%   gets expanded is a subdued normal math version, this does not give the same
%   as \cs{mathtt} would have given there. This was a bug: imagine
%   |\section{$\mathtt{X}$}| issued in a math version, but the TOC is done in
%   subdued normal version; the output in TOC will often differ (fontsize being
%   put aside) both from out it looked at the section title and from what
%   direct usage of \cs{mathtt} in the TOC would have given. I have no strong
%   preference between the two possibilities (to be as in section title, or to
%   be as if \cs{mathtt} gets executed in TOC and obeys its local regime), but
%   it is a bug if the result is still a third one. Thus I decided to follow
%   \LaTeX2e and that \cs{mathtt} had to remain \cs{mathtt} when moving.
%
%   But a math alphabet command such as \cs{Mathtt} redefines its unprotected
%   meaning on first use as well as the one of the math version macro, hence a
%   |\letrobustmacro\mathtt\Mathtt| of sorts is no good at all. I thus opted to
%   not hack into the math \LaTeX{} font support across math versions and to
%   simply use |\protected\def| in place of obeying strictly \LaTeX2e
%   robustness (except of course in the subdued math versions as there the math
%   alphabets acquire back their original robust meanings.)
%
%   Potential breaking change at \mstrelease{1.3za}, the |defaultbf| etc... options do
%   not prevent the package declaring |\Mathbf| etc... commands.
%
%   \mstrelease{1.3za} defines a \cs{Mathnormalbold} and then defines \cs{mathnormalbold}
%   in terms of it in place of defining directly \cs{mathnormalbold} as a math
%   alphabet.  This is in relation to implementation of the |LGRgreek+|
%   option.  There was some hesitation though to restrict this change to that
%   option only or not.
%    \begin{macrocode}
\let\mst@alph@omicron\mathnormal 
\@ifpackageloaded{fourier}{\ifsloped\else\let\mst@alph@omicron\mathrm\fi}{}
\DeclareSymbolFontAlphabet{\Mathnormal}{mtletterfont}
\DeclareSymbolFontAlphabet{\Mathrm}{mtoperatorfont}
   \DeclareMathAlphabet{\Mathnormalbold}{\mst@enc}{\mst@fam}{\mst@bold}{\mst@ltsh}
   \protected\def\mathnormalbold{\Mathnormalbold}
   \DeclareMathAlphabet{\Mathbf}{\mst@enc}{\mst@fam}{\mst@bold}{\mst@opsh}
   \DeclareMathAlphabet{\Mathit}{\mst@enc}{\mst@fam}{\mst@ser}{\itdefault}
   \DeclareMathAlphabet{\Mathsf}{\mst@enc}{\sfdefault}{\mst@ser}{\mst@opsh}
   \DeclareMathAlphabet{\Mathtt}{\mst@enc}{\ttdefault}{\mst@ser}{\mst@opsh}
%    \end{macrocode}
% The \cs{mathxx} macros being \LaTeX2e robust, or course the meanings here
% are known, and «original» macros are sort of superfluous but well it works.
%    \begin{macrocode}
\let\mst@original@normal\mathnormal
\let\mst@original@rm\mathrm
\let\mst@original@bf\mathbf
\let\mst@original@it\mathit
\let\mst@original@sf\mathsf
\let\mst@original@tt\mathtt
\def\mst@restorealphabets{%
    \let\mathnormal\mst@original@normal
    \let\mathrm\mst@original@rm
    \let\mathbf\mst@original@bf
    \let\mathit\mst@original@it
    \let\mathsf\mst@original@sf
    \let\mathtt\mst@original@tt
  }
\ifmst@greekplus
%    \end{macrocode}
% \begin{macro}{\mst@mathalph}
% The \LaTeX\ kernel code regarding math fonts is too complex and rigid for
% there to be a robust and easy way to know when one is in the argument of
% \cs{mathrm} or \cs{mathbf}, and the code is spread on various chapters of
% \texttt{source2e.pdf}, and the comments are often not up-to-date.  So I did
% not try a too complex hack and decided for \mstrelease{1.3za} to add a numeric
% indicator to let Greek letters react to it. It incorporates a space to be
% self-delimiting in an \cs{ifcase} to maintain expandability in numeric
% context of the to-be-defined Greek control sequences.
%    \begin{macrocode}
  \def\mst@mathalph{-1}
  \def\mst@setalphabets{%
    \protected\def
    \mathnormalbold##1{\def\mst@mathalph{4 }\Mathnormalbold{##1}\def\mst@mathalph{-1 }}%
    \ifmst@defaultnormal\else
        \protected\def
        \mathnormal##1{\def\mst@mathalph{0 }\Mathnormal{##1}\def\mst@mathalph{-1 }}%
    \fi
    \ifmst@defaultrm\else
        \protected\def
        \mathrm##1{\def\mst@mathalph{1 }\Mathrm{##1}\def\mst@mathalph{-1 }}%
    \fi
    \ifmst@defaultbf\else
        \protected\def
        \mathbf##1{\def\mst@mathalph{2 }\Mathbf{##1}\def\mst@mathalph{-1 }}%
    \fi
    \ifmst@defaultit\else
        \protected\def
        \mathit##1{\def\mst@mathalph{3 }\Mathit{##1}\def\mst@mathalph{-1 }}%
    \fi
    \ifmst@defaultsf\else\protected\def\mathsf{\Mathsf}\fi
    \ifmst@defaulttt\else\protected\def\mathtt{\Mathtt}\fi
  }
\else
  \def\mst@setalphabets{%
    \ifmst@defaultnormal\else\protected\def\mathnormal{\Mathnormal}\fi
    \ifmst@defaultrm\else\protected\def\mathrm{\Mathrm}\fi
    \ifmst@defaultbf\else\protected\def\mathbf{\Mathbf}\fi
    \ifmst@defaultit\else\protected\def\mathit{\Mathit}\fi
    \ifmst@defaultsf\else\protected\def\mathsf{\Mathsf}\fi
    \ifmst@defaulttt\else\protected\def\mathtt{\Mathtt}\fi
  }
\fi
\ifmst@subdued\else\mst@setalphabets\fi
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{LGRgreek}
% \begin{macro}{\MTgreekupdefault}
% \begin{macro}{\MTgreekitdefault}
% \begin{macro}{selfGreek}
%   \mstrelease{1.14b}: We can not move the \cs{DeclareSymbolFont} to the
%   \cs{Mathastext} macro because it resets the font family in *all*
%   math versions, and some could have been defined by the user with
%   previous calls to \cs{Mathastext}. So we have to have them here.
%   The problem is that at this stage it is impossible to know if we
%   really need (in the case of LGRgreek) two separate shapes for
%   upper and lowercase, and (in the case of selfGreek) a shape
%   distinct from the one used in |mtoperatorfont|. So I opted in the
%   end for declaring possibly one too many font. To achieve more
%   economy the only way would be to keep cumulative track of all
%   previously declared math versions and to redeclare appropriately
%   the LGR or self greek fonts at each call to \cs{Mathastext} (with
%   no optional argument): a bit painful, and as I am possibly the
%   sole user in the world of this possibility of multiple math
%   versions with this package. Also the advantage to systematically
%   allocate a font for the selfGreek option is that we can force the
%   use of the OT1 encoding.
%
%   First we establish the cumulative effect of the greek related options.
%
%   \mstrelease{1.15c} introduces some possibilities to change the shapes of Greek letters
%   in each math versions, and even the Greek font (in LGR encoding). The
%   commands \cs{MTitgreek} etc... will be used in-between calls to
%   \cs{Mathastext} and re-adjust the shapes. And the command \cs{MTgreekfont}
%   changes the Greek font family.
%
%   Note that \cs{mst@ltsh} expands to \cs{shapedefault} or \cs{itdefault}
%   at this location.
%
%   Note added |2022/11/02|: using \cs{MTitgreek} etc... once implies that
%   from then on, for subsequent \mst-math versions, the shape of Greek
%   letters will not be kept in sync with the shape and lettershape version
%   parameters, but only react to the configuration decided by these commands
%   (and |italic/frenchmath| options).
%
%   Note |2022/10/29|: for some time \cs{updefault} was made into |up| by
%   \LaTeX\ (since 2020-02-02 now that I check this out). As a result this
%   triggered Font Warnings in the log about the replacement of |up| by |n|.
%
%   \mstrelease{1.3y} refactors completely the handling of Greek letter shapes under the
%   |LGRgreek(s)| options (and only under them).  Under these options we don't
%   use one font for lowercase Greek and anotherone for uppercase Greek (some
%   above code comments have not been updated) but one math font |mtgreekit| for italic Greek
%   and one math font |mtgreekup| for upright Greek.  What `italic' and
%   `upright' mean is decided by the expansion of \cs{MTgreekitdefault} and
%   \cs{MTgreekupdefault}, which give respectively |it| and |n| per default.
%
%   If no |itgreek| et al.\@ options or \cs{MTitgreek} et al.\@ commands
%   have been used, we need to map \cs{mst@ltsh} (which was used for
%   lowercase Greek, except under |frenchmath| option) and \cs{mst@opsh} to
%   either `italic' or `upright'.  This is done by testing if they hold `it'
%   or `sl'.  If yes we map to `italic' by setting to false an `up' Boolean,
%   if not we leave the `up' Boolean to true.
%
%   In order to maintain perfect identical code for non-|LGRgreek|, the
%   |LGRgreek| related code is simply added to previously shared
%   constructions.  The |LGRgreek| behavior will remain identical in most
%   documents, but for example those who used some adventurous `|sc|' for the
%   main shape (the one used per default for operator names) need to adjust
%   \cs{MTgreekupdefault} to be `|sc|', for the math version being defined, or
%   the default one if this is followed by usage of \cs{Mathastext}.
%
%   The new |LGRgreek|-specific commands \cs{MTgreekupdefault} and
%   \cs{MTgreekitdefault} are the only ones in the package which can possibly
%   be defined previously to loading it.  (Perhaps some other macros could be
%   also converted to being modifiable prior to loading \mst, thus avoiding
%   potential need to use \cs{Mathastext} at least once after loading the
%   package; to be examined next time --- which may be a long time in
%   future!).
%
%   Unfortunately the \mstrelease{1.3y} did some internal renamings here (using
%   |@lgr@| in macro names in place of |@greek@|) which were not everywhere
%   followed up, and this broke the |selfGreek| option.  Fixed at \mstrelease{1.3z}.
%
%    \begin{macrocode}
\providecommand*\MTgreekupdefault{n}
\providecommand*\MTgreekitdefault{it}
\newif\ifmst@greek@lower@up
\newif\ifmst@greek@upper@up
\def\mst@update@greeksh{
    \def\mst@greek@lsh{\mst@ltsh}
    \def\mst@greek@ush{\mst@opsh}
      \mst@greek@lower@uptrue
      \expandafter\in@\expanded{{\mst@ltsh.}}{it.,sl.}%
      \ifin@\mst@greek@lower@upfalse\fi
      \mst@greek@upper@uptrue
      \expandafter\in@\expanded{{\mst@opsh.}}{it.,sl.}%
      \ifin@\mst@greek@upper@upfalse\fi
    \ifmst@itgreek
      \def\mst@greek@lsh{\MTgreekitdefault}
      \def\mst@greek@ush{\MTgreekitdefault}
        \mst@greek@lower@upfalse
        \mst@greek@upper@upfalse
    \fi
    \ifmst@upgreek
      \def\mst@greek@lsh{\MTgreekupdefault}
      \def\mst@greek@ush{\MTgreekupdefault}
        \mst@greek@lower@uptrue
        \mst@greek@upper@uptrue
    \fi
    \ifmst@frenchmath
      \ifmst@itgreek\else
      \ifmst@upgreek\else
        \def\mst@greek@lsh{\mst@opsh}
        \def\mst@greek@ush{\mst@opsh}
          \mst@greek@lower@uptrue
          \mst@greek@upper@uptrue
      \fi\fi
    \fi
    \ifcase\mst@greek@select
        \or
          \def\mst@greek@ush{\MTgreekitdefault}
            \mst@greek@upper@upfalse
       \or
          \def\mst@greek@ush{\MTgreekupdefault}
            \mst@greek@upper@uptrue
    \fi
}
\mst@update@greeksh
%    \end{macrocode}
% \begin{macro}{mtgreekup}
% \begin{macro}{mtgreekit}
% \begin{macro}{\mathgreekup}
% \begin{macro}{\mathgreekit}
% \begin{macro}{\mathgreekupbold}
% \begin{macro}{\mathgreekitbold}
% The \mstrelease{1.3y} refactoring was done in order to be able to define \cs{alphaup},
% etc \dots\ control sequences (\cs{mathchar}'s), as well as the italic ones.
% Formerly two math fonts were created but to be used respectively with
% lowercase or uppercase Greek.  Now we have two fonts indexed by their shape,
% and we take advantage to create two math alphabets mapping to the two
% defined symbol fonts |mtgreekup| and |mtgreekit|.
%
% \mstrelease{1.3za} adds \cs{mathgreekupbold} and \cs{mathgreekitbold}.
%    \begin{macrocode}
\ifmst@LGRgreek
    \DeclareFontEncoding{LGR}{}{}
    \DeclareSymbolFont{mtgreekup}{LGR}{\mst@fam}{\mst@ser}{\MTgreekupdefault}
    \DeclareSymbolFont{mtgreekit}{LGR}{\mst@fam}{\mst@ser}{\MTgreekitdefault}
    \DeclareSymbolFontAlphabet{\mathgreekup}{mtgreekup}
    \DeclareSymbolFontAlphabet{\mathgreekit}{mtgreekit}
    \DeclareMathAlphabet{\mathgreekupbold}{LGR}{\mst@fam}{\mst@bold}{\MTgreekupdefault}
    \DeclareMathAlphabet{\mathgreekitbold}{LGR}{\mst@fam}{\mst@bold}{\MTgreekitdefault}
\else
%    \end{macrocode}
% \begin{macro}{mtselfGreekfont}
%    \begin{macrocode}
\ifmst@selfGreek
    \DeclareSymbolFont{mtselfGreekfont}{OT1}{\mst@fam}{\mst@ser}{\mst@greek@ush}
\fi\fi
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{mteulervm}
% \begin{macro}{\MathEuler}
% \begin{macro}{\MathEulerBold}
% In case we need the Euler font, we declare it here. It will use
% |uzeur.fd| from the \ctanpkg{eulervm} package of Walter~\textsc{Schmidt}
%    \begin{macrocode}
\ifmst@needeuler
\mst@infoline{will use Euler font; command \string\MTEulerScale}
  \DeclareSymbolFont{mteulervm}{U}{zeur}{m}{n}
  \DeclareSymbolFontAlphabet{\MathEuler}{mteulervm}
  \DeclareMathAlphabet{\MathEulerBold}{U}{zeur}{\mst@bold}{n}
\fi
\newcommand*\MTEulerScale[1]{\edef\zeu@Scale{#1}}
\let\MathastextEulerScale\MTEulerScale
%    \end{macrocode}
% \LaTeXe{} has a strange initial configuration where the
% capital Greek letters are of type |mathalpha|, but the
% lower Greek letters of type |mathord|, so that \cs{mathbf}
% does not act on them, although lowercase Greek letters and
% Latin letters are from the same font. ^^A qui est cmmi encodage OML
% This is because
% \cs{mathbf} is set up to be like a bold version of
% \cs{mathrm}, and \cs{mathrm} uses the `operators' font, by
% default |cmr|, where there are NO lowercase greek
% letters. This set-up is ok for the Capital Greek letters
% which are together with the Latin letters in both |cmmi|
% and |cmr|.
%
% The package eulervm sets the lowercase Greek letters to be
% of type |mathalpha|, the default \cs{mathbf} and
% \cs{mathrm} will act wierdly on them, but a \cs{mathbold}
% is defined which will use the bold series of the Euler
% roman font, it gives something coherent for Latin and
% Greek \emph{lowercase} letters, and this is possible
% because the same font contains upright forms for them all.
%
% Here in |mathastext|, Latin letters and Greek letters (lower and upper case)
% must be (generally) assumed to come from two different fonts, as a result the
% standard \cs{mathbf} (and \cs{mathrm}) will give weird results when used for
% Greek letters. We could coerce \cs{mathbf} to do something reasonable (cf
% |http://tug.org/pipermail/texhax/2011-January/016605.html|) but at this time
% |30-01-2011 09:42:27 CET| I decided I would not try to implement it here. I
% prefer to respect the default things.
%
% I followed the simpler idea of the \ctanpkg{eulervm} package and
% defineed \cs{MathEuler} and \cs{MathEulerBold} alphabet
% commands (the \ctanpkg{eulervm} package does this only for the
% bold font).
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{mtpsymbol}
% \begin{macro}{\MathPSymbol}
% In case we need the Symbol font, we declare it here. The macro
% \cs{psy@scale} will be used to scale the font (see at the
% very end of this file).
%    \begin{macrocode}
\ifmst@needsymbol
  \mst@infoline{will use Symbol font; command \string\MTSymbolScale}
  \def\psy@scale{1}
  \DeclareSymbolFont{mtpsymbol}{U}{psy}{m}{n}
  \DeclareSymbolFontAlphabet{\MathPSymbol}{mtpsymbol}
  \AtBeginDocument{%
    \DeclareFontFamily{U}{psy}{}%
    \DeclareFontShape{U}{psy}{m}{n}{<->s*[\psy@scale] psyr}{}%
  }
\fi
\newcommand*\MTSymbolScale[1]{\edef\psy@scale{#1}}
\let\MathastextSymbolScale\MTSymbolScale
%    \end{macrocode}
% I did not choose for name \cs{MathSymbol} as this may
% be defined somewhere for another thing.  There is no bold
% for the postscript Symbol font distributed with the
% \LaTeXe{} |psnffs| core package.
% \end{macro}
% \end{macro}
% \begin{macro}{\pmvec}
% Definition of a poor man version of the \cs{vec} accent.
% Done using \cs{protected}\cs{def} at \mstrelease{1.4}.
%    \begin{macrocode}
\protected\def\pmvec#1{%
    \mathord{\stackrel{\raisebox{-.5ex}{\tiny\boldmath$\mathord{\rightarrow}$}}%
                      {{}#1}%
            }%
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\fouriervec}
%   The glyph is taken from the Fourier font of
%   Michel~\textsc{Bovani}. Note: (oct 2012) I should not allocate an
%   entire symbol font just for one glyph! But I have not given any
%   serious thought to what one can do to simulate a math accent
%   without doing such a wasteful thing.
%    \begin{macrocode}
\ifmst@fouriervec
  \DeclareFontEncoding{FML}{}{}
  \DeclareFontSubstitution{FML}{futm}{m}{it}
  \DeclareSymbolFont{mathastextfourier}{FML}{futm}{m}{it}
  \SetSymbolFont{mathastextfourier}{bold}{FML}{futm}{b}{it}
  \mst@DeclareMathAccent{\fouriervec}{\mathord}{mathastextfourier}{"7E}
\fi
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\MTencoding}
% \begin{macro}{\MTfamily}
% \begin{macro}{\MTseries}
% \begin{macro}{\MTshape}
% \begin{macro}{\MTboldvariant}
% \begin{macro}{\MTlettershape}
%   Some public macros to modify our private internals, and
%   we will use them also ourself.
%
%   In version \mstrelease{1.1} we add the possibility to have two
%   distinct font shapes for letters and digits. So in fact
%   we could as well have two really unrelated fonts but
%   this is really not the spirit of the package.
%
%   Note that using these macros in the preamble allows \cs{Mathastext}
%   to set up math versions with a given font for math mode, and at the
%   same time not modifying the \cs{familydefault} or \cs{romandefault}
%   etc\dots
%
%   At time of \mstrelease{1.3za} I considered letting |LGRgreeks| and |selfGreeks|
%   support \cs{MTgreekfont} and this needed a chaneg to \cs{MTfamily}
%   here but I dropped the idea.  Too wary of documentation changes.
%    \begin{macrocode}
\newcommand*\MTencoding[1]{\def\mst@enc{#1}}
\newcommand*\MTfamily[1]{\def\mst@fam{#1}}
\newcommand*\MTseries[1]{\def\mst@ser{#1}}
\newcommand*\MTshape[1]{\def\mst@opsh{#1}\ifmst@italic\else\def\mst@ltsh{#1}\fi}
\newcommand*\MTboldvariant[1]{\def\mst@bold{#1}}
\newcommand*\MTlettershape[1]{\def\mst@ltsh{#1}}
\let\Mathastextencoding\MTencoding
\let\Mathastextfamily\MTfamily
\let\Mathastextseries\MTseries
\let\Mathastextshape\MTshape
\let\Mathastextboldvariant\MTboldvariant
\let\Mathastextlettershape\MTlettershape
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{\MTitgreek}
% \begin{macro}{\MTupgreek}
% \begin{macro}{\MTitGreek}
% \begin{macro}{\MTupGreek}
% \begin{macro}{\MTgreekfont}
%   \mstrelease{1.15c}: These new macros can be used in-between calls to \cs{Mathastext}.
%   They reset the shapes for Greek letters (applies to LGRgreek(s) and
%   selfGreek(s) options). The \cs{MTgreekfont} presupposes either LGRgreek or
%   selfGreek (it is inoperant under |LGRgreeks| or |selfGreeks|).
%   |\MTgreekfont{\familydefault}| is somewhat like using LGRgreeks or
%   selfGreeks.
%
%   At time of \mstrelease{1.3za} I let \cs{MTgreekfont} also have an effect under option
%   |LGRgreeks| or |selfGreeks|, via a refactoring which also modified \cs{MTfamily}.
%    \begin{macrocode}
\newcommand*\MTitgreek{\mst@itgreektrue\mst@upgreekfalse\def\mst@greek@select{0}}
\newcommand*\MTupgreek{\mst@upgreektrue\mst@itgreekfalse\def\mst@greek@select{0}}
\newcommand*\MTitGreek{\def\mst@greek@select{1}}
\newcommand*\MTupGreek{\def\mst@greek@select{2}}
\let\Mathastextitgreek\MTitgreek
\let\Mathastextupgreek\MTupgreek
\let\MathastextitGreek\MTitGreek
\let\MathastextupGreek\MTupGreek
\newcommand*\MTgreekfont[1]{\def\mst@greekfont{#1}}
\let\Mathastextgreekfont\MTgreekfont
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% At (long...) last we now change the font for the letters of the
% latin alphabet. In version \mstrelease{1.1}, Latin letters have their own font
% (shape).
%
%    \mstrelease{1.2b} |2012/12/28| now that we understand the great advantages of |"8000|
%    we do it also for all letters a-z and A-Z to insert automatically the
%    italic corrections. See the \hyperref[sec:ic]{discussion} in the user
%    manual. Ironically I wrote the code initially for the |italic| option only
%    to realize later it was more suitable to using an \emph{upright} text font
%    in math mode! So this mathematical activation of the letters is not done if
%    the font shape is detected to be |it| or |sl|; to bypass this the command
%    \cs{MTicinmath} is provided.
%
%    \mstrelease{1.2e} |2013/01/10| corrects a bad oversight of \mstrelease{1.2b} in
%    \cs{mst@mathactivate} which made the reproduction of the user manual
%    illustrations with |$f_i^i$| impossible. As \cs{mst@mathactivate} was
%    originally used also to get the non-letters obey math alphabet while
%    maintaining the \TeX{} spacings, it added no extra braces. The braces
%    should however be added for expansion of math active letters, in order of
%    things like |x^y| to work as expected. (the group braces do not prevent
%    ligatures when the letters are arguments to the math alphabet commands,
%    the added macros \cs{mst@itcorr} and \cs{mst@before@<letter>} expanding to
%    nothing).
%
%    Added note |2016/01/06|: it should be explicitly said that the extra
%    |{..}| in |\mst@mathactivate| for letters end up creating |\hbox|'es
%    around each letter with its extra skips and explicit italic correction,
%    when present. These skips are thus set at natural width and do not add
%    any break point.
%
%    Added note at \mstrelease{1.4}: the extra pair of braces is inserted here
%    at \cs{mst@DeclareMathLetter}, not at \cs{mst@mathactivate}.
%
%    \mstrelease{1.3} |2013/09/02| extends the use of mathematically active letters to
%    allow the user to specify muglue before and after the letter itself (see
%    \cs{MTsetmathskips}, below).
%    Mathematically active letters were previously used only to add the italic
%    correction; the math activation has now been separated and put in
%    \cs{MTmathactiveletters}. There is also \cs{MTmathactiveLetters} to allow
%    math activation only for the uppercase letters. To cancel the (now default,
%    even with option |italic|) math
%    activation of letters, there is \cs{MTmathstandardletters}. Version \mstrelease{1.3a}
%    removes some silly |\string|'s from the code, which prevented to pass
%    macros as first argument to the command.
%
% Added note |2016/01/06|:
%   Notice that the initially |\relax| tokens \verb+\mst@[before|after]@<letter>+
%   formed with |\csname...\endcsname| do not modify TeX's math layout:
%   |{\relax f\relax}| is like |f| (also for ligatures inside |\mathrm| for
%   example).
%
% The code here was refactored at \mstrelease{1.4} and this simplified
% \cs{mst@mathactivate} definition.
%
% The \cs{mst@before}\meta{letter} were renamed at \mstrelease{1.4} into
% \cs{mst@before@}\meta{letter} and are incorporated at the
% \cs{mst@DeclareMathLetter} location.  Formerly \cs{mst@}\meta{letter} was
% only the math symbol, now \cs{MTmathcharletter}\meta{letter} is used for that and
% \cs{MTcommandletter}\meta{letter} is the whole thing to which the active letter
% expands (the definition of the active letter done by \cs{mst@mathactivate}
% is done with a \cs{def}, not a \cs{let}).
% \begin{macro}{\mst@DeclareMathLetter}
%
% \mstrelease{1.4b} adds |noletters| option.
%    \begin{macrocode}
\ifmst@noletters
  \let\MTmathactiveletters\@empty
  \let\MTmathactiveLetters\@empty
  \let\MTmathstandardletters\@empty
\else
\def\mst@DeclareMathLetter#1#2#3#4#5{%
    \DeclareMathSymbol {#1}{\mathalpha}{mtletterfont}{`#1}%
    \DeclareMathSymbol {#4}{\mathalpha}{mtletterfont}{`#1}%
    \def#2{{#3#4#5\mst@itcorr}}%
}%
\@tfor\mst@tmp:=abcdefghijklmnopqrstuvwxyz\do{%
   \expandafter\expandafter\expandafter\mst@DeclareMathLetter
   \expandafter\mst@tmp
               \csname MTcommandletter\mst@tmp\expandafter\endcsname
               \csname mst@before@\mst@tmp\expandafter\endcsname
               \csname MTmathcharletter\mst@tmp\expandafter\endcsname
               \csname mst@after@\mst@tmp\endcsname
}%
\ifmst@frenchmath \def\mst@font@tbu{mtoperatorfont}%
   \else          \def\mst@font@tbu{mtletterfont}%
\fi
\def\mst@DeclareMathLetter #1#2#3#4#5{%
    \DeclareMathSymbol {#1}{\mathalpha}{\mst@font@tbu}{`#1}%
    \DeclareMathSymbol {#4}{\mathalpha}{\mst@font@tbu}{`#1}%
    \def#2{{#3#4#5\mst@ITcorr}}%
}%
\@tfor\mst@tmp:=ABCDEFGHIJKLMNOPQRSTUVWXYZ\do{%
   \expandafter\expandafter\expandafter\mst@DeclareMathLetter
   \expandafter\mst@tmp
               \csname MTcommandletter\mst@tmp\expandafter\endcsname
               \csname mst@before@\mst@tmp\expandafter\endcsname
               \csname MTmathcharletter\mst@tmp\expandafter\endcsname
               \csname mst@after@\mst@tmp\endcsname
}%
\def\mst@mathactivate@lowercase{%
    \@tfor\mst@tmp:=abcdefghijklmnopqrstuvwxyz\do{%
      \expandafter\expandafter\expandafter
      \mst@mathactivate\expandafter\mst@tmp\csname MTcommandletter\mst@tmp\endcsname{}%
     }%
}%
\def\mst@mathactivate@uppercase{%
    \@tfor\mst@tmp:=ABCDEFGHIJKLMNOPQRSTUVWXYZ\do{%
      \expandafter\expandafter\expandafter
      \mst@mathactivate\expandafter\mst@tmp\csname MTcommandletter\mst@tmp\endcsname{}%
     }%
}%
\def\mst@mathdeactivate@lowercase{%
    \@tfor\mst@tmp:=abcdefghijklmnopqrstuvwxyz\do{%
      \expandafter\mathcode\expandafter`\mst@tmp=\csname MTmathcharletter\mst@tmp\endcsname
     }%
}%
\def\mst@mathdeactivate@uppercase{%
    \@tfor\mst@tmp:=ABCDEFGHIJKLMNOPQRSTUVWXYZ\do{%
      \expandafter\mathcode\expandafter`\mst@tmp=\csname MTmathcharletter\mst@tmp\endcsname
     }%
}%
%    \end{macrocode}
% We redo the definitions with some added layer (silly because will never
% happen in pratice that a letter is Babel-active) related to
% \cs{mst@do@activecase} in \ctanpkg{babel} context.
%    \begin{macrocode}
\ifmst@everymath
\else
  \def\mst@mathdeactivate@lowercase{%
    \@tfor\mst@tmp:=abcdefghijklmnopqrstuvwxyz\do{%
      \expandafter\mathcode\expandafter`\mst@tmp=
             \csname MTmathcharletter\mst@tmp\endcsname
     }%
  }%
  \def\mst@mathdeactivate@uppercase{%
    \@tfor\mst@tmp:=ABCDEFGHIJKLMNOPQRSTUVWXYZ\do{%
      \expandafter\mathcode\expandafter`\mst@tmp=
             \csname MTmathcharletter\mst@tmp\endcsname
     }%
  }%
\fi
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\MTmathactiveletters}
% \begin{macro}{\MTmathstandardletters}
%
% Important changes at \mstrelease{1.4}.
%
% Ascii letters are math-activated at package loading time, rather than again and
% again each time math mode is entered.  But not under |subdued| mode, then
% the activation is done as part of switching to some math version.
%
% The ordering in this code source is a bit of a mess, and it may be too early
% here to execute \cs{MTmathactiveletters} (I think it is fine now after some
% major moving around of code chunks but will not waste time checking
% it) so this will be postponed to end of package loading.  Prior to
% \mstrelease{1.4} \cs{MTmathactiveletters} could be executed here as it only
% set some toggle to be obeyed at every math mode entrance.
%    \begin{macrocode}
\def\mst@mathactivateletters{%
    \mst@mathactivate@lowercase
    \mst@mathactivate@uppercase
}%
\newcommand*\MTmathactiveletters{%
    \mst@OnlyIfNotSubdued
    \mst@mathactivateletters
}%
\AtEndOfPackage{\MTmathactiveletters}%
%    \end{macrocode}
% Duplication due to some legacy reasons, do not rely on these internal
% macro names, beware they change at future release.
%    \begin{macrocode}
\def\mst@mathactivateLetters{\mst@activate@uppercase}%
\newcommand*\MTmathactiveLetters{%
    \mst@OnlyIfNotSubdued
    \mst@mathactivateLetters
}%
\newcommand*\MTmathstandardletters{%
    \mst@mathdeactivate@lowercase
    \mst@mathdeactivate@uppercase
}%
\fi
%    \end{macrocode}
% \end{macro}\end{macro}
%  \begin{macro}{\MTicinmath}
%  \begin{macro}{\MTICinmath}
%  \begin{macro}{\MTnoicinmath}
%  \begin{macro}{\MTicalsoinmathxx}
%      \cs{MTnoicinmath} can also be used from inside math mode. 
%
%      \cs{MTicalsoinmathxx} is destined to be used inside
%      \cs{mathnormalbold} as I didn't want to add the complication of
%      extracting the family number used inside \cs{mathnormalbold} (will
%      perhaps come back if I have time to spend on
%      |source2e|). Added note |2016/01/06|: this number is a priori simply
%      |symmtletterfont+1|.
%
%      \cs{MTicinmath} can also be used inside math mode, to revert an
%      earlier \cs{MTnoicinmath} from inside the same math group.
%
%      \mstrelease{1.3i} |2016/01/06|: For some reason which I have now forgotten I did
%      until then:
% \begin{verbatim}
% \def\mst@itcorr{\ifnum\fam=\m@ne\/\else\ifnum\fam=\symmtletterfont\/\fi\fi}%
% \end{verbatim}
%      hence italic corrections were also applied inside \cs{mathnormal} (for
%      upright fonts; \cs{mathnormalbold} math alphabet was not treated like
%      \cs{mathnormal}). I now drop this to be more in sync with the handling
%      of the extra skips around letters. Everything gets suppressed inside
%      all math alphabets, allowing ligatures, even for \cs{mathnormal}.
%
%    \begin{macrocode}
\newcommand*\MTicinmath{% 
    \MTmathactiveletters
    \def\mst@itcorr{\ifnum\fam=\m@ne\/\fi}%
    \let\mst@ITcorr\mst@itcorr
}
\newcommand*\MTICinmath{%
    \MTmathactiveLetters 
    \def\mst@ITcorr{\ifnum\fam=\m@ne\/\fi}%
}
\newcommand*\MTnoicinmath{\let\mst@itcorr\@empty\let\mst@ITcorr\@empty}
\newcommand*\MTnoICinmath{\let\mst@ITcorr\@empty}
\newcommand*\MTicalsoinmathxx{%
    \ifx\mst@itcorr\@empty\else\def\mst@itcorr{\/}\fi
    \ifx\mst@ITcorr\@empty\else\def\mst@ITcorr{\/}\fi
}
%    \end{macrocode}
% \end{macro}\end{macro}\end{macro}\end{macro}
% \begin{macro}{\MTsetmathskips}
% \begin{macro}{\MTunsetmathskips}
%   \mstrelease{1.3} |2013/09/02|: user level command to specify extra spaces in math mode
%   around the letters (only the 7bit a,b,..,z and A,B,..,Z). First parameter is
%   the letter, second is the math skip to be inserted before, and third the
%   skip to be inserted after; for example \cs{thickmuskip} or explicitly
%   |0.1mu|.
%
%   For this, letters are made mathematically active. This is now the package
%   default (version \mstrelease{1.2} did this only in the absence of option |italic|, or
%   more precisely when the font used was not of shape |it| or |sl|). But if
%   \cs{MTsetmathskips} has not been used for that letter, the only effect of
%   the math activation is, as in \mstrelease{1.2}, to add the italic correction
%   automatically, except when the font shape is detected to be |it| or |sl|; in
%   these latter cases, although mathematically active, the letter acts in the
%   standard way.
%
%   The command \cs{MTmathstandardletters} turns off math activation and its
%   effects for all letters.
%
%   Ligatures within the argument of a math alphabet command are impeached by
%   skips; so \cs{MTunsetmathskips} is provided to cancel the skips for one
%   specific letter (|f| for example).
%
%   \mstrelease{1.3a} |2013/09/04|: I strangely had |\string#1| inside \cs{MTsetmathskips}.
%   Phobic of catcode active letters... but with |\string| one needs some
%   |\expandafter| to use \cs{MTsetmathskips} in an |\@for| loop for example. It
%   is better to allow the first argument to be a macro or anything expanding to
%   a letter, and to not be paranoid about improbable catcode active letters
%   (the user just has to tame them at the time of the \cs{MTsetmathskip}) so I
%   take out these |\string|'s.
%
%   \mstrelease{1.3i} |2016/01/06|: the extra skips are suppressed for the arguments of
%   math alphabet commands. This applies in particular for amsmath's
%   \cs{DeclareMathOperator}.
%
%    \begin{macrocode}
\newcommand*\MTsetmathskips[3]{%
    \@namedef{mst@before@#1}{\ifnum\fam=\m@ne\mskip#2\relax\fi}%
    \@namedef{mst@after@#1}{\ifnum\fam=\m@ne\mskip#3\relax\fi}%
}
\newcommand*\MTunsetmathskips[1]{%
    \@namedef{mst@before@#1}{}%
    \@namedef{mst@after@#1}{}%
}
%    \end{macrocode}
% \end{macro}\end{macro}
% \begin{macro}{\mst@DeclareMathDigit}
% \begin{macro}{\MTmathactivedigits}
% \begin{macro}{\MTmathstandarddigits}
% In version \mstrelease{1.1}, we have now separated digits from letters, so paradoxically
% it is less problematic to give them the |mathalpha| type.
%
% \mstrelease{1.4} had defined some no-op \cs{MTmathstandarddigits} and
% \cs{MTmathactivedigits} but if not under option |nodigits|.  As they are
% used in \cs{MTeverymathoff} and \cs{MTeverymathdefault} though this broke
% the option |nodigits| (either with |subdued| or when using \cs{MTversion}).
%
% Defining them as \cs{empty} so that \LaTeX{} defensive mechanism with
% \cs{newcommand} works but this is sooooooo hypothetical context!
%    \begin{macrocode}
\let\MTmathactivedigits\empty
\let\MTmathstandarddigits\empty
\ifmst@nodigits\else
  \def\mst@font@tbu{mtoperatorfont}%
  \ifmst@symboldigits \def\mst@font@tbu{mtpsymbol}\fi
  \ifmst@eulerdigits  \def\mst@font@tbu{mteulervm}\fi
  \DeclareMathSymbol{0}{\mathalpha}{\mst@font@tbu}{`0}%
  \DeclareMathSymbol{1}{\mathalpha}{\mst@font@tbu}{`1}%
  \DeclareMathSymbol{2}{\mathalpha}{\mst@font@tbu}{`2}%
  \DeclareMathSymbol{3}{\mathalpha}{\mst@font@tbu}{`3}%
  \DeclareMathSymbol{4}{\mathalpha}{\mst@font@tbu}{`4}%
  \DeclareMathSymbol{5}{\mathalpha}{\mst@font@tbu}{`5}%
  \DeclareMathSymbol{6}{\mathalpha}{\mst@font@tbu}{`6}%
  \DeclareMathSymbol{7}{\mathalpha}{\mst@font@tbu}{`7}%
  \DeclareMathSymbol{8}{\mathalpha}{\mst@font@tbu}{`8}%
  \DeclareMathSymbol{9}{\mathalpha}{\mst@font@tbu}{`9}%
%    \end{macrocode}
% \mstrelease{1.4} adds possibility of mathematically active digits.
%    \begin{macrocode}
  \ifmst@activedigits
    \def\mst@DeclareMathDigit #1#2#3{%
      \DeclareMathSymbol{#3}{\mathalpha}{\mst@font@tbu}{`#1}%
      \def#2{#3}%
    }%
    \@tfor\mst@tmp:=0123456789\do{%
      \expandafter\expandafter\expandafter\mst@DeclareMathDigit
      \expandafter\mst@tmp
               \csname MTcommanddigit\romannumeral\mst@tmp\expandafter\endcsname
               \csname MTmathchardigit\romannumeral\mst@tmp\endcsname
    }%
    \def\mst@mathactivatedigits{%
      \@tfor\mst@tmp:=0123456789\do{%
      \expandafter\expandafter\expandafter\mst@mathactivate
      \expandafter\mst@tmp\csname MTcommanddigit\romannumeral\mst@tmp\endcsname{}%
     }%
    }%
    \def\MTmathactivedigits{\mst@OnlyIfNotSubdued\mst@mathactivatedigits}%
    \MTmathactivedigits
    \ifmst@everymath
      \def\MTmathstandarddigits{%
        \@tfor\mst@tmp:=0123456789\do{%
        \expandafter\mathcode\expandafter`\mst@tmp
            =\csname MTmathchardigit\romannumeral\mst@tmp\endcsname
         }%
      }%
    \else
%    \end{macrocode}
% We inject some extra layer (silly because will never happen in pratice
% that a digit token is Babel-active) related to \cs{mst@do@activecase} in
% \ctanpkg{babel} context.
%    \begin{macrocode}
      \def\MTmathstandarddigits{%
        \@tfor\mst@tmp:=0123456789\do{%
        \expandafter\mathcode\expandafter`\mst@tmp
            =\csname MTmathchardigit\romannumeral\mst@tmp\endcsname
         }%
      }%
    \fi
  \fi
\fi
%    \end{macrocode}
% \end{macro}\end{macro}\end{macro}
% When |symboldelimiters| is passed as an option, we use the
% Symbol font for the printable characters other than
% letters and digits. 
%    \begin{macrocode}
\ifmst@symboldelimiters 
\def\mst@font@tbu{mtpsymbol}%
\mst@endashfalse
\mst@emdashfalse
\else
\def\mst@font@tbu{mtoperatorfont}%
\fi
%    \end{macrocode}
% \mstrelease{1.2} adds the tricks to let non letters/digits obey math alphabets. We have
% to double the definitions for easy switch on-off of the mechanism, via a token
% list which is put into \cs{everymath} and \cs{everydisplay}.
%    \begin{macrocode}
\ifmst@noexclam\else\mst@infoline{\string! and \string?}%
\DeclareMathSymbol{!}{\mathclose}{\mst@font@tbu}{"21}%
\DeclareMathSymbol{\mst@varfam@exclam}{\mathalpha}{\mst@font@tbu}{"21}%
\expandafter\mst@addtodo@nonletters\string!\mathclose\mst@varfam@exclam
\DeclareMathSymbol{?}{\mathclose}{\mst@font@tbu}{"3F}%
\DeclareMathSymbol{\mst@varfam@question}{\mathalpha}{\mst@font@tbu}{"3F}%
\expandafter\mst@addtodo@nonletters\string?\mathclose\mst@varfam@question
\fi
%    \end{macrocode}
% \begin{macro}{\MTlowerast}
% \begin{macro}{\mst@doasterisk}
% \begin{macro}{\mst@@doasterisk}
% \begin{macro}{\MTnormalasterisk}
% \begin{macro}{\MTactiveasterisk}
%   \mstrelease{1.12d} The \cs{ast} or |*| is defined in |fontmath.ltx| as a binary
%   operator from the |symbols| font. Usually the asterisk from the text
%   font is in a raised position. Previous versions of \mst did nothing
%   with \cs{ast} but strangely defined |*| to be the one from the text
%   font, with type \cs{mathalpha}. The package now leaves by default
%   both |*| and |\ast| untouched, and if passed option |asterisk|
%   replaces both of them with a lowered text asterisk (or the one from
%   the Symbol font), and of type \cs{mathbin}. A trick is used to
%   optionally get both |*| and \cs{ast} obey the math alphabets.
%
% The user macro \cs{MTlowerast} sets the amount
% of lowering to be applied to the text asterisk.
%
%   \mstrelease{1.12e} Somehow there was a big omission in \mstrelease{1.12d}, the
%   command \cs{MTlowerast} as described in the manual was missing!
%
% \mstrelease{1.3i} adds \cs{MTnormalasterisk} and \cs{MTactiveasterisk}.
% They do nothing if package is loaded without option |asterisk|.
%
% \mstrelease{1.4} uses \cs{protected} rather than robust commands.
% And implements the support for the new default of not using \cs{everymath}.
%
% The first two \cs{newcommand*} are because the commands were previously
% defined unconditionally anyhow, in a way making them no-op's without
% option |asterisk|. Finally using \cs{let} here with \cs{empty} with
% the idea of less impact on \TeX{} internals, but losing \LaTeX{} check.
%    \begin{macrocode}
\let\MTnormalasterisk\empty
\let\MTactiveasterisk\empty
\ifmst@asterisk\mst@infoline{asterisk: \string\ast\space and *}
  \ifmst@symbolmisc
    \protected\def\mst@bin@ast{\mathbin{\mathchoice
           {\raisebox{-.1\height}{\the\textfont\symmtpsymbol\char42}}%
           {\raisebox{-.1\height}{\the\textfont\symmtpsymbol\char42}}%
           {\raisebox{-.1\height}{\the\scriptfont\symmtpsymbol\char42}}%   
           {\raisebox{-.1\height}{\the\scriptscriptfont\symmtpsymbol\char42}}}%
                     }%
  \else
    \protected\def\mst@bin@ast{\mathbin{\mathchoice
           {\raisebox{-\mst@lowerast}{\the\textfont\symmtoperatorfont\char42}}%
           {\raisebox{-\mst@lowerast}{\the\textfont\symmtoperatorfont\char42}}%
           {\raisebox{-\mst@lowerast}{\the\scriptfont\symmtoperatorfont\char42}}%
           {\raisebox{-\mst@lowerast}{\the\scriptscriptfont\symmtoperatorfont\char42}}}%
                     }%
  \fi
  \protected\def\mst@varfam@ast{\ifnum\fam=\m@ne
                      \mst@bin@ast
                      \else
                      \mathbin{\mathchoice
           {\raisebox{-\mst@lowerast}{\the\textfont\fam\char42}}%
           {\raisebox{-\mst@lowerast}{\the\textfont\fam\char42}}%
           {\raisebox{-\mst@lowerast}{\the\scriptfont\fam\char42}}%
           {\raisebox{-\mst@lowerast}{\the\scriptscriptfont\fam\char42}}}%
                      \fi}%
  \let\mst@ast\mst@bin@ast
  \newcommand*\MTlowerast[1]{\def\mst@lowerast{#1}}
  \MTlowerast{.3\height}
%    \end{macrocode}
% Arguably \mst should have used the ``hard'' non-letters affiliation here.
% Probably too late to change this in 2024... and costly in documentation
% time.
%    \begin{macrocode}
  \mst@do@easynonletters\expandafter{%
      \the\mst@do@easynonletters\let\mst@ast\mst@varfam@ast
  }%
  \ifmst@everymath
     \def\mst@@doasterisk  {\let\ast\mst@ast\mst@mathactivate*{}\mst@ast}%
     \def\MTnormalasterisk {\let\mst@doasterisk\relax}
     \def\MTactiveasterisk {\let\mst@doasterisk\mst@@doasterisk}
     \MTactiveasterisk
     \AtBeginDocument{%
       \everymath\expandafter
              {\the\everymath   \mst@doasterisk \MTnormalasterisk }%
       \everydisplay\expandafter
              {\the\everydisplay\mst@doasterisk \MTnormalasterisk }%
     }%
  \else
     \def\MTnormalasterisk{\AtBeginDocument{\MTnormalasterisk}}
     \def\MTactiveasterisk{\AtBeginDocument{\MTactiveasterisk}}
%    \end{macrocode}
% For legacy reasons the responsiveness to math alphabets is made part of the
% handling of ``easy'' non letters (probably because it is on per default),
% and this causes me problems of internal logic and even more annoyingly of
% documentation.  I am leaving this standing because it would be too much of a
% pain at this stage to document a change and it was already quite annoying to
% better document actual situation.
%    \begin{macrocode}
     \mst@undo@easynonletters\expandafter{%
          \the\mst@do@easynonletters\let\mst@ast\mst@bin@ast
     }%
%    \end{macrocode}
% For legacy reasons the action of \cs{MTactiveasterisk} is not testing if
% in |subdued| mode.
%
% MEMO: if |subdued| there is \cs{MTeverymathoff} added to |\begin{document}|
% near end of package and it will do \cs{MTnormalasterisk}.
%    \begin{macrocode}
     \AtBeginDocument{%
         \let\mst@orig@abd@ast\ast
         \edef\MTnormalasterisk{\noexpand\mst@mathdeactivate*{\the\mathcode`\*}%
                                \let\noexpand\ast\noexpand\mst@orig@abd@ast}%
         \def\MTactiveasterisk{\def\ast{\mst@ast}%
                               \mst@mathactivate*{}\mst@ast
                              }%
         \MTactiveasterisk
     }
  \fi
\fi
%    \end{macrocode}
% \end{macro}\end{macro}\end{macro}\end{macro}\end{macro}
% (2011) I renounced to try to do things with all the various dots, they are
% defined in many different ways, and there is the amsmath also. Dealing with
% this issue would mean a lot a time for a minuscule result. Better to leave the
% user use the \ctanpkg{mathdots} package and accept that we can not avoid the default
% fonts in that case. So here I just treat |.| (in the hope to really lessen by
% 1 the number of fonts embedded at the end in the PDF). 
%
% [(Dec. 2012) should I reexamine these definitive sounding remarks?]
%
% \begin{macro}{ncccomma}
% \begin{macro}{decimalcomma}
% \mstrelease{1.3y} of |2022/11/03| adds support for |ncccomma| option.
%
% Some non-obvious hack is needed for compatibility with our home-made
% mechanism of non-letters obeying math alphabet commands.  Alternative would
% have been to not load at all \ctanpkg{ncccomma} (or since \mstrelease{1.3zb}
% \ctanpkg{decimalcomma}) and provide the functionality purely by our own
% means; because here in order to support \cs{MTnonlettersobeymathxx} we are
% almost contrived to override quasi entirely the contents of these tiny
% packages.
%
% \mstrelease{1.3zb} adds support for the |decimalcomma| option.  This was mandatory to
% keep a compatibility layer with \ctanpkg{frenchmath} after its |2.7| release
% of |2023/12/23|.
%
% Hesitation if I should also make it shadow the |ncccomma| option if both are
% used at same time, or let the older option have priority.  Well, let's give
% priority to the new one so that one can do \cs{PassOptionsToPackage} and
% recycle old documents compiled via \cs{input} to tell them to use the new
% option.
%
% Much ado about these tiny packages!
%    \begin{macrocode}
\ifmst@nopunct\else\mst@infoline{punctuation\string: \string, \string. \string:
    \string; and \string\colon}
  \DeclareMathSymbol{,}{\mathpunct}{\mst@font@tbu}{"2C}
  \DeclareMathSymbol{\mst@varfam@comma}{\mathalpha}{\mst@font@tbu}{"2C}
  \ifmst@decimalcomma
    \mst@infoline{loading package decimalomma for `smart comma\string'}
    \RequirePackage{decimalcomma}[2023/12/28]% 1.3 or later
%    \end{macrocode}
% Attention
% that the \textbf{BREAKING CHANGE} to \cs{AtBeginDocument} at October 2020
% \LaTeX{} release means that, \emph{taking into account that \emph{\mst} already has
% employed some \emph{\cs{AtBeginDocument}} prior to loading} \ctanpkg{decimalcomma}, any
% code here will be executed \textbf{BEFORE} the \cs{AtBeginDocument} material
% from \ctanpkg{decimalcomma}!
% \centeredline{\url{https://github.com/latex3/latex2e/issues/1226}} So we
% definitely should not do here some |\mathcode`\,="8000\relax| in the
% \cs{AtBeginDocument}, and by the way I don't even recall why I had this line
% at some point which ended up causing me some much suffering and pain and
% lost sleep.  It seems to have been a silly copy-paste from the |ncccomma|
% branch next, and that I started experimenting before having even re-read the
% code I copied pasted and whether it was needed.
%
% \ctanpkg{decimalcomma} is a rewrite of \ctanpkg{icomma} and it loads the
% latter for which \ctanpkg{babel-french} has a dectection mechanism, which as
% a result avoids the bad interactions with \ctanpkg{numprint} plus its
% |autolanguage| option, which are mentioned below in the \ctanpkg{ncccomma}
% branch.  So we don't need here the workaround done below in the
% |ncccomma| branch.  Notice though that in both cases, the `intelligent'
% comma feature will be applied to the whole document, even inside those
% portions where the user has switched to another language such as English.
% This is to be expected here as nothing is done in a language specific
% manner, but if we wanted to do so, we might then be confronted with
% the \ctanpkg{babel} issue mentioned next in the |ncccomma| branch.
%    \begin{macrocode}
    \let\mathcomma\relax
    \DeclareMathSymbol{\mathcomma}{\mathpunct}{\mst@font@tbu}{"2C}
%    \end{macrocode}
% Due to package \ctanpkg{decimalcomma} internals, the hack here, which has to do
% with the ``non letters obey math alphabets'' optional \mst feature, has
% to be done differently than the one we apply below for |ncccomma|.  One can not
% really talk of a hack, as we basically have to redo the whole thing to
% insert an \cs{aftergroup} trick.
%^^A {\mathord} pas autorisé; pas plus que \mathord\mathpunct
%^^A mais \mathord\@gobble\mathpunct ok
%    \begin{macrocode}
    \def\mst@sm@rtcomma{\begingroup\@tfor\@tempa:=0123456789%
                        \do{\expandafter\ifx\@tempa\@let@token
                                                  \aftergroup\mathord
                                                  \aftergroup\@gobble
                                                  \@break@tfor\fi}%
                        \endgroup\mathpunct\mathcomma}
    \mst@do@nonletters\expandafter{\the\mst@do@nonletters
      \let\mathcomma\mst@varfam@comma
      \let\sm@rtcomma\mst@sm@rtcomma
      }
    \ifmst@everymath
    \else
      \edef\mst@tmp{\mathchardef\mathcomma=\the\mathcode`\,\relax}%
      \mst@undo@nonletters\expandafter\expandafter\expandafter
                  {\expandafter\mst@tmp\the\mst@undo@nonletters}%
    \fi
  \else
%    \end{macrocode}
% Work around some bad interaction of \ctanpkg{ncccomma}, \ctanpkg{numprint}
% with |autolanguage| and \ctanpkg{babel-french}.  See
% \centeredline{\url{https://github.com/latex3/babel/issues/190}} for
% background.  Some hesitation whether I should use the \cs{noextrasfrench} to
% work around \ctanpkg{babel-french} code influencing non-French sections in
% the document.  Update: I think the last sentence means I was hesitating at
% time of \mstrelease{1.3y} whether to insert some extra code inside the
% \cs{noextrasfrench}.
%    \begin{macrocode}
  \ifmst@ncccomma
    \mst@infoline{loading package ncccomma for `smart comma\string'}
    \RequirePackage{ncccomma}%
    \AtBeginDocument{%
      \mathcode`\,="8000\relax
      \@ifpackageloaded{babel}{%
                 \addto\noextrasfrench{\mathcode`\,="8000\relax}%
                 \addto\extrasfrench{\mathcode`\,="8000\relax}%
                 }{}%
    }
    \let\mathcomma\relax
    \DeclareMathSymbol{\mathcomma}{\mathpunct}{\mst@font@tbu}{"2C}
%    \end{macrocode}
% Complications for compatibility with the \cs{MTnonlettersobeymathxx}
% mechanism.  No fix done here for usage by \ctanpkg{ncccomma} of \cs{@tempb}
% with no restoration of its meaning.
%    \begin{macrocode}
    \edef\mst@NCC@comma{\let\noexpand\@empty\mathpunct
                        \unexpanded\expandafter{\NCC@comma}%
                        \let\noexpand\@empty\noexpand\empty}
    \mst@do@nonletters\expandafter{\the\mst@do@nonletters
      \let\mathcomma\mst@varfam@comma
      \let\NCC@comma\mst@NCC@comma
      }
    \ifmst@everymath
    \else
%    \end{macrocode}
% Attention that \ctanpkg{ncccomma} (contrarily to \ctanpkg{icomma} loaded by
% \ctanpkg{decimalcomma} has made the comma math active already when we loaded it.
% So we don't use |\the\mathcode`\,\relax| here.
%    \begin{macrocode}
      \edef\mst@tmp{\mathchardef\mathcomma=\the\mathcomma\relax}%
      \mst@undo@nonletters\expandafter\expandafter\expandafter
                  {\expandafter\mst@tmp\the\mst@undo@nonletters}%
    \fi
  \else
%    \end{macrocode}
% Neither option |ncccomma| nor |decimalcomma|.  The \mstrelease{1.4} non-use
% of \cs{everymath} and consequences is accounted for automatically by
% \cs{mst@addtodo@nonletters}.
%    \begin{macrocode}
    \expandafter\mst@addtodo@nonletters\string,\mathpunct\mst@varfam@comma
  \fi\fi
%    \end{macrocode}
% math dot.
%    \begin{macrocode}
  \DeclareMathSymbol{.}{\mathord}{\mst@font@tbu}{"2E}
  \DeclareMathSymbol{\mst@varfam@dot}{\mathalpha}{\mst@font@tbu}{"2E}
  \mst@addtodo@easynonletters\.\mst@varfam@dot
%    \end{macrocode}
% math colon.
%    \begin{macrocode}
  \DeclareMathSymbol{:}{\mathrel}{\mst@font@tbu}{"3A}
  \DeclareMathSymbol{\mst@varfam@colon}{\mathalpha}{\mst@font@tbu}{"3A}
  \expandafter\mst@addtodo@nonletters\string:\mathrel\mst@varfam@colon
  \@ifpackageloaded{amsmath}
%    \end{macrocode}
% \cs{colon} gets defined in \ctanpkg{amsmath} in terms of |:| with some enlarged explicit
% spacing. No need to intervene. 
%    \begin{macrocode}
  {}
%    \end{macrocode}
% No \ctanpkg{amsmath}, use standard punctuation spacing.
%
% The reason for |\et\colon\undefined| is if some package has redefined
% \cs{colon} which then can not be used in \cs{DeclareMathSymbol} anymore (we
% shamelessly overwrite...)
%    \begin{macrocode}
  {%
    \let\colon\undefined 
    \DeclareMathSymbol{\colon}{\mathpunct}{\mst@font@tbu}{"3A}
    \let\mst@colon\colon
%    \end{macrocode}
% \mstrelease{1.3v} uses \cs{protected} for the (optional) \cs{colon} redefinition.
%    \begin{macrocode}
    \mst@do@nonletters\expandafter{%
        \the\mst@do@nonletters
        \protected\def\colon{\mathpunct{\mst@varfam@colon}}%
    }%
%    \end{macrocode}
% \mstrelease{1.4} needs extras.
%    \begin{macrocode}
    \ifmst@everymath
    \else
        \mst@undo@nonletters\expandafter{%
            \the\mst@undo@nonletters
            \let\colon\mst@colon
         }%
    \fi
  }
%    \end{macrocode}
% Semi-colon.
% \mstrelease{1.3y} adds |binarysemicolon| option.
%    \begin{macrocode}
  \DeclareMathSymbol{\mst@varfam@pointvirgule}{\mathalpha}{\mst@font@tbu}{"3B}
  \ifmst@binarysemicolon
    \mst@infoline{semi-colon set to be of type \string\mathbin}
    \DeclareMathSymbol{;}{\mathbin}{\mst@font@tbu}{"3B}
    \expandafter\mst@addtodo@nonletters\string;\mathbin\mst@varfam@pointvirgule
  \else
    \DeclareMathSymbol{;}{\mathpunct}{\mst@font@tbu}{"3B}
    \expandafter\mst@addtodo@nonletters\string;\mathpunct\mst@varfam@pointvirgule
  \fi
\fi
%    \end{macrocode}
% \end{macro}\end{macro}
% \begin{macro}{\relbar}
% Due to the way = and - are used by \LaTeX{} in arrows, we will
% have to redefine \cs{Relbar} and \cs{relbar} in order for 
% them to preserve their original meanings.
%
% \mstrelease{1.15d}: Oct 13, 2012. Belated amendment of the code to be compatible
% with Unicode engines in case someone changed the mathcode of -.
% However, for the time being I can do it in an easy way only for
% \XeTeX, not for \LuaLaTeX. Also I do my modifications to \cs{relbar}
% in a manner testing for the presence of amsmath.
%
% \mstrelease{1.3v} |2019/09/19|: \LaTeX{} of |2019-10-01| defines \cs{leftarrowfill}
% and \cs{rightarrowfill} as robust macros, so we do the same.
%
% I need to put amsmath under surveillance to check if it decides to
% robustify \cs{relbar} at some point, now that the \LaTeX\ team has
% taken over maintenance.
%
% |2019/09/16| Use \cs{protected} for \cs{right\textbar{}leftarrowfill} in the non
% \cs{DeclareRobustCommand} branch?
%    \begin{macrocode}
\ifmst@nominus
\else
  \ifmst@XeOrLua
    \mst@Umathcharnumdef\mst@minus@sign=\mst@Umathcodenum`\-\relax
%    \end{macrocode}
% I used this prior to the new \cs{luatexUmathcodenum}, as available since TL2013:
% \centeredline{|\mathchardef\mst@minus@sign=8704\relax % "2200|}
%^^A L'alignement est bizarre dans l'output.
%    \begin{macrocode}
  \else
    \mathchardef\mst@minus@sign=\mathcode`\-\relax
  \fi
  \@ifpackageloaded{amsmath}
    {\def\relbar{\mathrel{\mathpalette\mathsm@sh\mst@minus@sign}}}
    {\DeclareRobustCommand\relbar{\mathrel{\smash\mst@minus@sign}}}
  \DeclareRobustCommand\rightarrowfill{$\m@th\mathord{\relbar}\mkern-7mu%
  \cleaders\hbox{$\mkern-2mu\relbar\mkern-2mu$}\hfill
  \mkern-7mu\mathord\rightarrow$}
  \DeclareRobustCommand\leftarrowfill{$\m@th\mathord\leftarrow\mkern-7mu%
  \cleaders\hbox{$\mkern-2mu\relbar\mkern-2mu$}\hfill
  \mkern-7mu\mathord{\relbar}$}
\fi
%    \end{macrocode}
% \end{macro}
% \begin{macro}{endash}
%  \mstrelease{1.1} |2011/01/29|: Producing this next piece of code was not a piece
%   of cake for a novice like myself!\newline
%  \mstrelease{1.11} |2011/02/05|: Compatibility with Unicode (via use of fontspec
%   encodings EU1 and EU2)\newline
%  \mstrelease{1.12} |2011/02/07|: Improved dealing of Unicode possibility.\newline
%  \mstrelease{1.14b} |2011/04/02|: Corrected some very irresponsible bug in the
%   Unicode part which caused a problem when 10 or more math families have
%   been allocated.\newline
%  \mstrelease{1.15} |2012/09/24|: Added AtBeginDocument to circumvent some amsmath
%   problem with unicode engines.
%
% \mstrelease{1.3l} |2016/01/29|: anticipating TL2016 fontspec's switch to |TU|.
%
% \mstrelease{1.3t} |2018/08/22|: fix to very ancient (|2012/12/20|) bug with
% |\DeclareMathSymbol| lacking last argument if encoding not T1, OT1 or
% LY1 when setting up math mode to use the en-dash character as minus
% sign (PDF\TeX\ engine).
%
% \begin{macro}{\mst@subduedminus}
% \begin{macro}{\mst@nonsubduedminus}
% \mstrelease{1.3t} Further, new macros |\mst@subduedminus| and |\mst@nonsubduedminus|,
% for the good functioning of the subdued option also in case of
% presence of fontspec. This is the only character for which subdued
% option works (now) by setting the mathcode on each math version
% change. Indeed, a typical issue is when the Unicode EN DASH or MINUS
% is used, but the actual font in subdued normal math version is
% originally in OT1 or T1 encoding. The only reasonable way to address
% this is by actually modifying the assigned mathcode at each version
% change. This means also that |\MTversion| and not |\mathversion|
% must be used for good functioning.
%
% \mstrelease{1.3u} improves the handling of the minus sign by letting it be compatible
% with math versions (and not only with the with subdued mechanism but all
% math versions) having varying font encodings, even possibly classic 8bit
% font encoding mixed with TU encoding for Unicode engines. For this it is
% needed to work around a feature of XeTeX/LuaLaTeX, here is original comment:
%
% \begin{quotation}
%     afaict it is
%     impossible to use straightforwardly in extended mathcode assignments
%     a control sequence as created by \cs{Umathchardef}.
%     This is counter-intuitive and breaks expectations.
% \end{quotation}
%
% But the \mstrelease{1.3u} mechanism with \cs{mst@UmathchardefWorkAround@i} introduced a
% bug which showed under option |noendash| (hence also |symboldelimiters|) with
% Unicode engines. Fixed at \mstrelease{1.3w}.
%    \begin{macrocode}
\let\mst@subduedminus\empty
\let\mst@nonsubduedminus\empty
\def\mst@dothe@endashstuff#1#2#3{%
  \edef\mst@tmp@enc{#3}%
  \if1\mst@OneifUniEnc
    \mst@Umathchardef#1=2 \symmtoperatorfont "\mst@unicodeminus\relax
    \mst@Umathchardef#2=7 \symmtoperatorfont "\mst@unicodeminus\relax
  \else
    \DeclareMathSymbol{#1}{\mathbin}{mtoperatorfont}
                      {\csname\mst@tmp@enc\string\textendash\endcsname}
    \DeclareMathSymbol{#2}{\mathalpha}{mtoperatorfont}
                      {\csname\mst@tmp@enc\string\textendash\endcsname}
  \fi
}%
\def\mst@dothe@emdashstuff#1#2#3{%
  \edef\mst@tmp@enc{#3}%
  \if1\mst@OneifUniEnc
    \mst@Umathchardef#1=2 \symmtoperatorfont "2014\relax
    \mst@Umathchardef#2=7 \symmtoperatorfont "2014\relax
  \else
    \DeclareMathSymbol{#1}{\mathbin}{mtoperatorfont}
                      {\csname\mst@tmp@enc\string\textemdash\endcsname}
    \DeclareMathSymbol{#2}{\mathalpha}{mtoperatorfont}
                      {\csname\mst@tmp@enc\string\textemdash\endcsname}
  \fi
}%
\def\mst@dothe@hyphenstuff#1#2{%
  \DeclareMathSymbol{#1}{\mathbin}{\mst@font@tbu}{"2D}%
  \DeclareMathSymbol{#2}{\mathalpha}{\mst@font@tbu}{"2D}%
}%
\def\mst@varfam@minus{\@nameuse{mst@varfam@minus@mv\math@version}}%
\ifmst@nominus\else
  \expandafter\mst@addtodo@nonletters\string-\mathbin\mst@varfam@minus
  \def\mst@nonsubduedminus{%
    \edef\mst@tmp@enc{\csname mst@encoding@\math@version\endcsname}%
    \if1\mst@OneifUniEnc
     \mst@Umathcode`\-=\expandafter
                       \mst@UmathchardefWorkAround@i
                       \csname mst@minus@mv\math@version\endcsname
                       \relax
    \else
     \mathcode`\-=\@nameuse{mst@minus@mv\math@version}%
    \fi
   }%
%    \end{macrocode}
% The above works only if the \cs{mst@minus@mv<name>} was really
% defined via \cs{Umathchardef}. If it was defined via \cs{DeclareMathSymbol}
% then it is a \cs{mathchar}, not a \cs{Umathchar}. At least currently (2019).
% So we need to correct the definition of \cs{mst@nonsubduedminus}.
%    \begin{macrocode}
  \ifmst@endash\else\ifmst@emdash\else
    \def\mst@nonsubduedminus{%
      \mathcode`\-=\@nameuse{mst@minus@mv\math@version}%
      }%
  \fi\fi
\fi
\def\mst@UmathchardefWorkAround@i
    {\expandafter\mst@UmathchardefWorkAround@ii\meaning}%
\def\mst@UmathchardefWorkAround@ii#1"{"}%
%    \end{macrocode}
% \end{macro}\end{macro}\end{macro}
% \begin{macro}{\mst@hbar@mvnormal}
% \begin{macro}{\mst@ltbar@mvnormal}
%   |2011/01/31|, \mstrelease{1.1} I decide to settle the question of the |\hbar|. The
%   \LaTeX{} definition is |\def\hbar{{\mathchar'26\mkern-9muh}}|
%   and its advantage is that |h| is in the correct font. But of course not
%   the macron character (|\=|, |\bar|). And anyway |amsfonts| uses a
%   \cs{DeclareMathSymbol}. Also there is the kern whose length depends on
%   |cmsy| (18mu=1em and em taken from info in |cmsy|).
%
%   I will need an |rlap| adapted to math
%   mode, and this is provided by code from Alexander~R.~\textsc{Perlis} in
%   his TugBoat article 22 (2001), 350--352, which I found by googling |rlap|.
%   (as an aside, I am only now (April 2, 2011) aware that the package
%   |mathtools| provides the |mathrlap| etc... )
%
%   \mstrelease{1.3l} |2016/01/29|: anticipating TL2016 fontspec's switch to |TU|.
%
%   \mstrelease{1.3u} |2019/08/20|: encoding (8bits) agnostic construct for hbar, using same
%   method as for |mathaccents| option. I should add some way to adjust the
%   vertical positioning.
%
%   On this occasion I replace |h| by |\mst@h| because the mechanism for
%   before and after skips does not interact well with the rlap construct.
%
%   \mstrelease{1.3v} |2019/09/19| adapts to maintain the robustness of \cs{hbar} which now
%   applies with \LaTeX{} |2019-10-01|.
%
%   \mstrelease{1.3w} works around \url{https://github.com/latex3/latex2e/issues/216} via
%   \cs{mst@DeclareMathAccent}. The upstream bug affected the definition of
%   \cs{mst@ltbar@mvnormal} and broke usage of \cs{Mathastext} in preamble.
%
%   \mstrelease{1.3w} also fixes oversight that \cs{hbar} may have been redefined via
%   \cs{DeclareMathSymbol} by some package (e.g. |amsfonts|) and with \LaTeX{}
%   |2019-10-01| this means \cs{hbar<space>} is now undefined. Modifying it
%   changed nothing to \cs{hbar} behavior in such circumstances. Finally we
%   opt for a \cs{protected} \cs{hbar} and choose to ignore completely if
%   there is a \cs{hbar<space>} or not. To avoid extra steps we do not
%   undefine it if it exists, because we would need to restore it in
%   subdued math versions.
%    \begin{macrocode}
\let\mst@subduedhbar\@empty
\let\mst@nonsubduedhbar\@empty
\ifmst@nohbar\else
  \def\mst@subduedhbar{\let\hbar\mst@original@hbar}%
  \def\mst@nonsubduedhbar{\expandafter
       \let\expandafter\hbar\csname mst@hbar@mv\math@version\endcsname}%
\fi
\def\mst@mathrlap{\mathpalette\mst@mathrlapinternal}
\def\mst@mathrlapinternal#1#2{\rlap{$\mathsurround=0pt#1{#2}$}}
\def\mst@dothe@hbarstuff#1#2#3{%
  \edef\mst@tmp@enc{#3}%
  \if1\mst@OneifUniEnc
    \mst@Umathchardef#1="7 \symmtletterfont "0127 \relax %% or 210F?
  \else
    \begingroup
    \def\@text@composite##1\@text@composite##2{##2}%
    \let\add@accent\@firstoftwo
    \mst@DeclareMathAccent{#2}{\mathalpha}{mtletterfont}%
                      {\csname\mst@tmp@enc\string\=\endcsname{}}%
    \endgroup
    \protected\def#1{\mst@mathrlap{#2{\ }}\MTmathcharletterh}%
  \fi
}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \mstrelease{1.15d}: Oct 13, 2012. The \cs{mathcode} thing with = is (belatedly,
% sorry!) made Unicode compatible.
% \begin{macro}{+,=,\Relbar}
%    \begin{macrocode}
\ifmst@noplus\else\mst@infoline{\string+ and \string=}
\DeclareMathSymbol{+}{\mathbin}{\mst@font@tbu}{"2B}
\DeclareMathSymbol{\mst@varfam@plus}{\mathalpha}{\mst@font@tbu}{"2B}
\expandafter\mst@addtodo@nonletters\string+\mathbin\mst@varfam@plus
\fi
\ifmst@noequal\else
\ifmst@XeOrLua
    \mst@Umathcharnumdef\mst@equal@sign=\mst@Umathcodenum`\=\relax
\else
    \mathchardef\mst@equal@sign=\mathcode`\=\relax
\fi
\@ifpackageloaded{amsmath}
{\def\Relbar{\mathrel\mst@equal@sign}}
{\DeclareRobustCommand\Relbar{\mathrel{\mst@equal@sign}}}
\DeclareMathSymbol{=}{\mathrel}{\mst@font@tbu}{"3D}
\DeclareMathSymbol{\mst@varfam@equal}{\mathalpha}{\mst@font@tbu}{"3D}
%    \end{macrocode}
% \begin{macro}{\nfss@catcodes}
% |2012/12/18|: Activating = (only in math mode actually) seems very bad but
% surprisingly works well. However I had a problem with |eu2lmtt.fd| which
% should not be loaded with an active =.
% |2012/12/25|: Since then I had switched to only math activation. And in fact
% the problematic = from |eu2lmtt.fd| end up in \cs{csname}...\cs{endcsname}
% and I have
% learnt since that \TeX{} does not look at the |mathcode| inside a
% \cs{csname}...\cs{endcsname}. Example:
% \begin{verbatim}
% \mathcode`x="8000
% \begingroup
% \catcode`x=\active
% \global\everymath{\defx{Hello}}
% \endgroup
% \def\foox{World!}
% $x \csname foox\endcsname$ 
% \end{verbatim}
% We need nevertheless to inactivate the =, for the following reason. Imagine
% someone did |\catcode`==\active\def={\string=}|, or another definition which
% would not lead to a tragedy in a \cs{csname}...\cs{endcsname}. Then the = is
% active and the re-definition done by |mathastext| will not be compatible with
% loading |eu2lmtt.fd| (for the first time) from math mode, as this
% re-definition can not be expanded inside a
% \cs{csname}...\cs{endcsname}.
%
% |2012/12/28|: to be on the safe side, I add also |;| and |+| and do it
% without discriminating between engines
%    \begin{macrocode}
\mst@infoline{adding \string= \string; and \string+ to \string\nfss@catcodes}
\g@addto@macro\nfss@catcodes{%
  \@makeother\=%
  \@makeother\;%
  \@makeother\+%
}
\expandafter\mst@addtodo@nonletters\string=\mathrel\mst@varfam@equal
\fi
%    \end{macrocode}
% \end{macro}\end{macro}
% \begin{macro}{noparenthesis}
% \begin{macro}{(,),[,],/}
%   \cs{lbrack} and \cs{rbrack} are defined in |latex.ltx| by
%   |\def\lbrack{[}\def\rbrack{]}| so this fits well with what we do here.
%   \cs{lparen} and \cs{rparen} are similarly defined in |mathtools|. On the
%   other hand in |latex.ltx| with |\{| and |\}| are defined (in math mode) in
%   terms of the control sequences \cs{lbrace} and \cs{rbrace}. Such control
%   sequences can not be simultaneously math symbols and math delimiters,
%   thus, this complicates things for the mathastextification.
%    \begin{macrocode}
\ifmst@noparen\else
\mst@infoline{parentheses \string( \string) \string[ \string] and slash \string/}
\ifmst@nosmalldelims
    \DeclareMathSymbol{(}{\mathopen}{\mst@font@tbu}{"28}
    \DeclareMathSymbol{)}{\mathclose}{\mst@font@tbu}{"29}
    \DeclareMathSymbol{[}{\mathopen} {\mst@font@tbu}{"5B}
    \DeclareMathSymbol{]}{\mathclose}{\mst@font@tbu}{"5D}
    \DeclareMathSymbol{/}{\mathord}{\mst@font@tbu}{"2F}
\else
    \DeclareMathDelimiter{(}{\mathopen}{\mst@font@tbu}{"28}{largesymbols}{"00}
    \DeclareMathDelimiter{)}{\mathclose}{\mst@font@tbu}{"29}{largesymbols}{"01}
    \DeclareMathDelimiter{[}{\mathopen} {\mst@font@tbu}{"5B}{largesymbols}{"02}
    \DeclareMathDelimiter{]}{\mathclose}{\mst@font@tbu}{"5D}{largesymbols}{"03}
    \DeclareMathDelimiter{/}{\mathord}{\mst@font@tbu}{"2F}{largesymbols}{"0E}
\fi
\DeclareMathSymbol{\mst@varfam@lparen}{\mathalpha}{\mst@font@tbu}{40}
\DeclareMathSymbol{\mst@varfam@rparen}{\mathalpha}{\mst@font@tbu}{41}
\DeclareMathSymbol{\mst@varfam@lbrack}{\mathalpha}{\mst@font@tbu}{"5B}
\DeclareMathSymbol{\mst@varfam@rbrack}{\mathalpha}{\mst@font@tbu}{"5D}
\DeclareMathSymbol{\mst@varfam@slash}{\mathalpha}{\mst@font@tbu}{"2F}
\expandafter\mst@addtodo@nonletters\string(\mathopen\mst@varfam@lparen
\expandafter\mst@addtodo@nonletters\string)\mathclose\mst@varfam@rparen
\expandafter\mst@addtodo@nonletters\string[\mathopen\mst@varfam@lbrack
\expandafter\mst@addtodo@nonletters\string]\mathclose\mst@varfam@rbrack
\mst@addtodo@easynonletters\/\mst@varfam@slash
\fi
%    \end{macrocode}
% \end{macro}\end{macro}
% \begin{macro}{alldelims}
% \begin{macro}{<,>,\}\begin{macro}{\setminus}\begin{macro}{\backslash}
%    \begin{macrocode}
\ifmst@alldelims\mst@infoline{alldelims: \string< \string>
  \string\backslash\space\string\setminus\space\string|
  \string\vert\space\string\mid\space\string\{\space \string\}}
\ifmst@nosmalldelims
%    \end{macrocode}
% Dec 18, 2012. We then want |\let\backslash\mst@varfam@backslash| to do nothing
% when the \cs{backslash} is used as a delimiter. So here the original
% definition from |latex.ltx| is copied, generally speaking when people use
% other math symbol fonts they do respect the encoding of the CM symbols and
% largesymbols, so this is 90\% safe. But in truth I should extract from the
% meaning of \cs{backslash} the |delcode|.
%
% At \mstrelease{1.4} I am a bit perplexed at the \cs{mathalpha} here.
% Adding a a \cs{mst@mathord@backslash} for matters of option |noeverymath|.
%    \begin{macrocode}
    \DeclareMathDelimiter{\mst@varfam@backslash}
        {\mathalpha}{symbols}{"6E}{largesymbols}{"0F}
    \let\mst@mathord@backslash\backslash
\else
    \DeclareMathDelimiter{<}{\mathopen}{\mst@font@tbu}{"3C}{largesymbols}{"0A}
    \DeclareMathDelimiter{>}{\mathclose}{\mst@font@tbu}{"3E}{largesymbols}{"0B}
%    \end{macrocode}
% There is no backslash in the Symbol font hence |mtoperatorfont| here.
%    \begin{macrocode}
    \DeclareMathDelimiter{\mst@mathord@backslash}
        {\mathord}{mtoperatorfont}{"5C}{largesymbols}{"0F}
    \let\backslash\mst@mathord@backslash
    \DeclareMathDelimiter{\mst@varfam@backslash}
        {\mathalpha}{mtoperatorfont}{"5C}{largesymbols}{"0F}
\fi    
\DeclareMathSymbol{<}{\mathrel}{\mst@font@tbu}{"3C}
\DeclareMathSymbol{>}{\mathrel}{\mst@font@tbu}{"3E}
\DeclareMathSymbol{\mst@varfam@less}{\mathalpha}{\mst@font@tbu}{"3C}
\DeclareMathSymbol{\mst@varfam@more}{\mathalpha}{\mst@font@tbu}{"3E}
\expandafter\mst@addtodo@nonletters\string<\mathrel\mst@varfam@less
\expandafter\mst@addtodo@nonletters\string>\mathrel\mst@varfam@more
\mst@do@easynonletters\expandafter{\the\mst@do@easynonletters
            \let\backslash\mst@varfam@backslash}
%    \end{macrocode}
% Extras for \mstrelease{1.4} are needed:
%    \begin{macrocode}
\ifmst@everymath
\else
  \mst@undo@easynonletters\expandafter{\the\mst@undo@easynonletters
            \let\backslash\mst@mathord@backslash}
\fi
\DeclareMathSymbol{\setminus}{\mathbin}{mtoperatorfont}{"5C}
\let\mst@setminus\setminus
\DeclareMathSymbol{\mst@varfam@setminus}{\mathalpha}{mtoperatorfont}{"5C}
%    \end{macrocode}
% \mstrelease{1.3v} adds a \cs{protected} here for \cs{setminus}.
%    \begin{macrocode}
\mst@do@nonletters\expandafter{%
     \the\mst@do@nonletters
     \protected\def\setminus{\mathbin{\mst@varfam@setminus}}%
}
%    \end{macrocode}
% Extras for \mstrelease{1.4} are needed:
%    \begin{macrocode}
\ifmst@everymath
\else
    \mst@undo@nonletters\expandafter{%
         \the\mst@undo@nonletters
         \let\setminus\mst@setminus
    }
\fi
%    \end{macrocode}
% \end{macro}\end{macro}\end{macro}
% \begin{macro}{\models}
% \mstrelease{1.15d}: 13 oct 2012. Before modifying \string| we must preserve \cs{models}. 
%    \begin{macrocode}
\ifmst@XeOrLua
  \mst@Umathcharnumdef\mst@vert@bar=\mst@Umathcodenum`\|\relax
\else
  \mathchardef\mst@vert@bar=\mathcode`\|\relax
\fi
\DeclareRobustCommand\models{\mathrel{\mst@vert@bar}\joinrel\Relbar}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{|,\mid,\vert}
%   (2011) I did not do anything then to try to emulate \cs{Vert} with the
%   vertical bar from the text font... and now (2012) \mst is not as radical as
%   it used to be anyhow, so it is too late. Or not (2019)? maybe I
%   \emph{should} do something here...
%
%   \mstrelease{1.3v} |2019/09/19|: I discover this rather radical legacy
%   \verb+\def\vert{|}+, which is done here once in the preamble, but I leave
%   it unmodified apart from prefixing it with \cs{protected}. I also add a
%   \cs{protected} for the definition of \cs{mid} (which applies only under
%   \cs{MTnonlettersobeymathxx} regime).
%    \begin{macrocode}
\ifmst@nosmalldelims
    \DeclareMathSymbol{|}{\mathord}{\mst@font@tbu}{124}
\else
    \DeclareMathDelimiter{|}{\mathord}{\mst@font@tbu}{124}{largesymbols}{"0C}
\fi    
\protected\def\vert{|}
\DeclareMathSymbol{\mst@varfam@vbar}{\mathalpha}{\mst@font@tbu}{124}
\mst@addtodo@easynonletters\|\mst@varfam@vbar
\let\mid\undefined
\DeclareMathSymbol{\mid}{\mathrel}{\mst@font@tbu}{124}
\let\mst@mid\mid
\mst@do@nonletters\expandafter{%
    \the\mst@do@nonletters
    \protected\def\mid{\mathrel\mst@varfam@vbar}%
}
%    \end{macrocode}
% Extras for \mstrelease{1.4} are needed:
%    \begin{macrocode}
\ifmst@everymath
\else
    \mst@undo@nonletters\expandafter{%
        \the\mst@undo@nonletters
        \let\mid\mst@mid
    }
\fi
%    \end{macrocode}
% \begin{macro}{\MTexplicitbraces-}\begin{macro}{obeymathxx}
% \begin{macro}{\MTexplicitbraces-}\begin{macro}{donotobeymathxx}
%       Braces. With version \mstrelease{1.2}, |\{| and |\}| will not be acceptable as
%       delimiters anymore if the redefinitions below in \cs{mst@dobraces} are
%       enacted. But they will obey math alphabets. Improvements in \mstrelease{1.2a}, to
%       preserve robustness.
%
%       For \mstrelease{1.3} I make |\lbrace| and |\rbrace| undefined first, else problems
%       may arise with some packages.
%
%       \mstrelease{1.3e} suppresses under option
%       |nosmalldelims| the definitions of |\lbrace| and |\rbrace| as math
%       symbols as this made |\left\lbrace| cause an error, it was a bug.
%
%       (obsolete) LaTeX2e defines |\{| and |\}| as robust commands since a long time
%       (I don't know since when). The \mst redefinition is done only if user
%       has executed \cs{MTexplicitbracesobeymathxx}, and it is done only when
%       entering math mode, but there could be some |\hbox| inside math, hence
%       it has to be careful to be valid in text too.
%
%       \mstrelease{1.3v} maintains strict \LaTeX2e robustness for |\{| and |\}|.
%       This assumes no one fiddled with |\{| and |\}| proper (without space
%       in the name).
%
%       \LaTeX{} made |\{| and |\}| \cs{protected}, not robust, at its
%       |2020-02-02| release, so the code used by \mst under
%       \cs{MTexplicitbracesobeymathxx} toggle remained without effect since
%       as it configured a change to |\{<space>| and |\}<space>|.  Fixed at
%       \mstrelease{1.4}.
%    \begin{macrocode}
  \ifmst@nosmalldelims
  \else
     \let\lbrace\undefined \let\rbrace\undefined
     \DeclareMathDelimiter{\lbrace}
        {\mathopen}{\mst@font@tbu}{123}{largesymbols}{"08}
     \DeclareMathDelimiter{\rbrace}
        {\mathclose}{\mst@font@tbu}{125}{largesymbols}{"09}
  \fi
\DeclareMathSymbol{\mst@varfam@lbrace}{\mathalpha}{\mst@font@tbu}{123} 
\DeclareMathSymbol{\mst@varfam@rbrace}{\mathalpha}{\mst@font@tbu}{125}
%    \end{macrocode}
%    \begin{macrocode}
\protected\def\mst@lbrace{\ifmmode\mathopen\mst@varfam@lbrace\else\textbraceleft\fi}
\protected\def\mst@rbrace{\ifmmode\mathclose\mst@varfam@rbrace\else\textbraceright\fi}
\mst@do@nonletters\expandafter{%
    \the\mst@do@nonletters
    \mst@dobraces{\let\{\mst@lbrace\let\}\mst@rbrace}%
}
\fi
\newcommand*{\MTexplicitbracesobeymathxx}{\let\mst@dobraces\@firstofone}
\newcommand*{\MTexplicitbracesdonotobeymathxx}{\let\mst@dobraces\@gobble}
%    \end{macrocode}
% Extras for \mstrelease{1.4} are needed:
%    \begin{macrocode}
\ifmst@everymath
\else
    \renewcommand*\MTexplicitbracesobeymathxx{%
        \let\mst@dobraces\@firstofone
        \MTnonlettersobeymathxx
    }%
    \renewcommand*\MTexplicitbracesdonotobeymathxx{%
        \let\mst@dobraces\@gobble
        \protected\def\{{\ifmmode \lbrace \else \textbraceleft \fi}%
        \protected\def\}{\ifmmode \rbrace \else \textbraceright \fi}%
    }%
    \mst@undo@nonletters\expandafter{\the\mst@undo@nonletters
        \protected\def\{{\ifmmode \lbrace \else \textbraceleft \fi}%
        \protected\def\}{\ifmmode \rbrace \else \textbraceright \fi}%
    }%
\fi         
\MTexplicitbracesdonotobeymathxx
%    \end{macrocode}
% \end{macro}\end{macro}\end{macro}\end{macro}
% \end{macro}\end{macro}
% \begin{macro}{specials}
%   \leavevmode\kern\parindent \mstrelease{1.14b} |2011/04/02|: the redefinitions of
%   \#, \$, \% and \& were buggy (this showed up when 10 or more math
%   families had been created).
%
%   \mstrelease{1.15f} |2012/10/23|: the code, although working, was perhaps a bit insane
%   and
%   had definitions which could surprise other packages. For example, it did:\\
%   \null\hspace{1cm}|\renewcommand{\%}{\ifmmode\mt@mmode@percent\else\char37\relax\fi}|\\
%   But it seems this provokes a problem with |microtype|. Perhaps the problem
%   was that the command was not declared robust? For the dollar \LaTeX{} itself does\\
%   \null\hspace{1cm}|\DeclareRobustCommand{\$}{\ifmmode\mathdollar\else\textdollar\fi}|\\
%   So here I just modify \cs{mathdollar}. Then we have in
%   |latex.ltx| the same definitions as in |plain.tex|:
%  |\chardef\%=`\%|, 
%  |\chardef\&=`\&|, and 
%  |\chardef\#=`\#|. It turns out that we can just adjust the mathcodes of these
%  characters and achieve exactly what is wanted for the corresponding one char
%  control sequences. In math mode the control sequence will use the specified
%  mathcode. So here it is \emph{not} a redefinition of  the control sequences,
%  purely an adjustment of mathcodes.
%
%  \mstrelease{1.2d} |2013/01/01|: previous versions imposed the variable family type. I
%  hereby make it possible to de-activate this feature with the macro
%  \cs{MTeasynonlettersdonotobeymathxx}. Besides, I have absolutely no idea
%  why I had different looking code depending on the engine \XeTeX, \LuaTeX\ or
%  default. Removed.
%
%  \mstrelease{1.3c} |2013/12/14|: I have absolutely no idea why I removed the \XeTeX\
%  and \LuaTeX\ code at the time of \mstrelease{1.2d}! the code for tex/pdftex engine
%  could not accomodate more than 16 math families. Code for \XeTeX\ and
%  \LuaTeX\ again added. (and since TL2013 no more problems with
%  |\luatexUmathcode|.)
%
% \mstrelease{1.4} has done slight refactoring here to share more code related
% to math activation across the two branches.
%    \begin{macrocode}
\ifmst@nospecials
\else
  \mst@infoline{\string\#\space\string\mathdollar\space
                \string\%\space\string\&\space}
  \ifmst@XeOrLua
    \mst@Umathcode`\#=0 \symmtoperatorfont "23 \relax
    \mst@Umathchardef\mathdollar=0 \symmtoperatorfont "24 \relax
    \mst@Umathcode`\%=0 \symmtoperatorfont "25 \relax
    \mst@Umathcode`\&=0 \symmtoperatorfont "26 \relax
    \mst@Umathchardef\mst@varfam@mathhash      = 7 \symmtoperatorfont "23 \relax
    \mst@Umathchardef\mst@varfam@mathdollar    = 7 \symmtoperatorfont "24 \relax
    \mst@Umathchardef\mst@varfam@mathpercent   = 7 \symmtoperatorfont "25 \relax
    \mst@Umathchardef\mst@varfam@mathampersand = 7 \symmtoperatorfont "26 \relax
    \mst@addtodo@easynonletters@U\#\mst@varfam@mathhash
    \mst@addtodo@easynonletters@U\%\mst@varfam@mathpercent
    \mst@addtodo@easynonletters@U\&\mst@varfam@mathampersand
  \else
    \count@=\symmtoperatorfont
    \multiply\count@ by \@cclvi
    \advance\count@ by 35
        \mathcode`\#\count@
    \advance\count@ by \@ne
        \mathchardef\mathdollar\count@
    \advance\count@ by \@ne
        \mathcode`\%\count@
    \advance\count@ by \@ne
        \mathcode`\&\count@
    \count@=\symmtoperatorfont
    \multiply\count@ by \@cclvi
    \advance\count@ by 28707 % = "7023
        \mathchardef\mst@varfam@mathhash\count@
    \advance\count@ by \@ne
        \mathchardef\mst@varfam@mathdollar\count@
    \advance\count@ by \@ne
        \mathchardef\mst@varfam@mathpercent\count@
    \advance\count@ by \@ne
        \mathchardef\mst@varfam@mathampersand\count@
    \mst@addtodo@easynonletters\#\mst@varfam@mathhash
    \mst@addtodo@easynonletters\%\mst@varfam@mathpercent
    \mst@addtodo@easynonletters\&\mst@varfam@mathampersand
  \fi
%    \end{macrocode}
% It is possible to mathematically activate the dollar sign, and to use
% it in math mode as |\string$|... well, how many documents will have
% done that? But we do not modify the mathcode of the |$| character
% anyhow, so why should I add here a \cs{mst@OnlyIfNotMathActive}?
% There is no good reason for that.
%    \begin{macrocode}
  \mst@do@easynonletters\expandafter{\the\mst@do@easynonletters
    \let\mathdollar\mst@varfam@mathdollar}%
%    \end{macrocode}
% Extras for \mstrelease{1.4} are needed.  Here too we do not worry
% about math active dollar character.
%    \begin{macrocode}
  \ifmst@everymath\else
      \edef\mst@tmp{\ifmst@XeOrLua\mst@Umathcharnumdef\else\mathchardef\fi
                    \mathdollar=\the\mathdollar\relax}%
      \mst@undo@easynonletters\expandafter\expandafter\expandafter
               {\expandafter\mst@tmp\the\mst@undo@easynonletters}%
  \fi
\fi
%    \end{macrocode}
% \end{macro}
% \begin{macro}{symbolmisc}
% We construct (with some effort) some long arrows from the Symbol glyphs, of
% almost the same lengths as the standard ones. By the way, I always found the
% \cs{iff} to be too wide, but I follow here the default. Also, although
% there is a \cs{longmapsto} in standard \LaTeX{}, if I am not mistaken, there
% is no \cs{longto}. So I define one here. I could not construct in the same
% manner \cs{Longrightarrow} etc\dots{} as the = sign from Symbol does not
% combine easily with the logical arrows, well, I could have done some box
% manipulations, but well, life is finite.
% \begin{macro}{\prod}
% \begin{macro}{\sum}
%   \mstrelease{1.13b}: I correct the brutal re-definitions of \cs{prod} and \cs{sum} from
%   the earlier versions of the package; most of the time the Symbol glyphs do
%   appear to be too small in display mode. The new redefinitions do have some
%   defects: |$\displaystyle\prod_1^2$| changes the position of limits but not
%   the glyph itself, and |$$\textstyle\prod_1^2$$| change the limits but
%   switches to the CM inline math glyph. So I tried\\
%   |\renewcommand{\prod}{\mathchoice{\mst@prod}{\prodpsy}{\prodpsy}{\prodpsy}}|\\
%   but this did not go well with subscripts and exponents. 
%    
% October 2012: maybe I should re-examine what I did?
%
% \mstrelease{1.3c} (|2013/12/14|) renames |\defaultprod| to |\MToriginalprod| and
% |\defaultsum| to 
% |\MToriginalsum|.
%
% \mstrelease{1.3v} hesitates about making robust here \cs{prod} and \cs{sum}. Finally I
% use \cs{protected} for them.
%
% \mstrelease{1.4} finally replaces all control sequences defines earlier via
% \cs{DeclareRobustCommand} to be defined using \cs{protected}\cs{def}.  It
% also removes \cs{mst@prod} and \cs{mst@sum} which were aliases of
% \cs{MToriginalprod} and \cs{MToriginalsum}, and having both must have
% been some left-over of earlier versions in 2012 or 2013 (unchecked).
%    \begin{macrocode}
\ifmst@symbolmisc
\mst@infoline{symbolmisc: miscellaneous math symbols from Symbol font}
\let\MToriginalprod\prod
\DeclareMathSymbol{\prodpsy}{\mathop}{mtpsymbol}{213}
\protected\def\prod{\ifinner\prodpsy\else\MToriginalprod\fi}
\let\MToriginalsum\sum
\DeclareMathSymbol{\sumpsy}{\mathop}{mtpsymbol}{229}
\protected\def\sum{\ifinner\sumpsy\else\MToriginalsum\fi}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%    \begin{macrocode}
\DeclareMathSymbol{\mst@implies}{\mathrel}{mtpsymbol}{222}
\protected\def\implies{\;\mst@implies\;}
\DeclareMathSymbol{\mst@impliedby}{\mathrel}{mtpsymbol}{220}
\protected\def\impliedby{\;\mst@impliedby\;}
\protected\def\iff{\;\mst@impliedby\mathrel{\mkern-3mu}\mst@implies\;}
\DeclareMathSymbol{\mst@iff}{\mathrel}{mtpsymbol}{219}
\protected\def\shortiff{\;\mst@iff\;}
%    \end{macrocode}
% \mstrelease{1.4} drops defining a \cs{mst@to} and employs \cs{to}
% in subsequent definitions
%    \begin{macrocode}
\let\to\relax
\DeclareMathSymbol{\to}{\mathrel}{mtpsymbol}{174}
\DeclareMathSymbol{\mst@trait}{\mathrel}{mtpsymbol}{190}
\protected\def\longto{\mkern2mu\mst@trait\mathrel{\mkern-10mu}\to}
\protected\def\mapsto{\mapstochar\mathrel{\mkern0.2mu}\to}
\protected\def\longmapsto{%
    \mapstochar\mathrel{\mkern2mu}\mst@trait\mathrel{\mkern-10mu}\to
}
\DeclareMathSymbol{\aleph}{\mathord}{mtpsymbol}{192}
\DeclareMathSymbol{\inftypsy}{\mathord}{mtpsymbol}{165} 
\DeclareMathSymbol{\emptyset}{\mathord}{mtpsymbol}{198}
\let\varnothing\emptyset
\DeclareMathSymbol{\nabla}{\mathord}{mtpsymbol}{209}
\DeclareMathSymbol{\surd}{\mathop}{mtpsymbol}{214}
\let\angle\undefined
\DeclareMathSymbol{\angle}{\mathord}{mtpsymbol}{208}
\DeclareMathSymbol{\forall}{\mathord}{mtpsymbol}{34}
\DeclareMathSymbol{\exists}{\mathord}{mtpsymbol}{36}
\DeclareMathSymbol{\neg}{\mathord}{mtpsymbol}{216}
\DeclareMathSymbol{\clubsuit}{\mathord}{mtpsymbol}{167}
\DeclareMathSymbol{\diamondsuit}{\mathord}{mtpsymbol}{168}
\DeclareMathSymbol{\heartsuit}{\mathord}{mtpsymbol}{169}
\DeclareMathSymbol{\spadesuit}{\mathord}{mtpsymbol}{170}
\DeclareMathSymbol{\smallint}{\mathop}{mtpsymbol}{242}
\DeclareMathSymbol{\wedge}{\mathbin}{mtpsymbol}{217}
\DeclareMathSymbol{\vee}{\mathbin}{mtpsymbol}{218}
\DeclareMathSymbol{\cap}{\mathbin}{mtpsymbol}{199}
\DeclareMathSymbol{\cup}{\mathbin}{mtpsymbol}{200}
\DeclareMathSymbol{\bullet}{\mathbin}{mtpsymbol}{183}
\DeclareMathSymbol{\div}{\mathbin}{mtpsymbol}{184}
\DeclareMathSymbol{\otimes}{\mathbin}{mtpsymbol}{196}
\DeclareMathSymbol{\oplus}{\mathbin}{mtpsymbol}{197}
\DeclareMathSymbol{\pm}{\mathbin}{mtpsymbol}{177}
\DeclareMathSymbol{\times}{\mathbin}{mtpsymbol}{180}
\DeclareMathSymbol{\proptopsy}{\mathrel}{mtpsymbol}{181}
\DeclareMathSymbol{\mid}{\mathrel}{mtpsymbol}{124} 
\DeclareMathSymbol{\leq}{\mathrel}{mtpsymbol}{163}
\DeclareMathSymbol{\geq}{\mathrel}{mtpsymbol}{179}
\DeclareMathSymbol{\approx}{\mathrel}{mtpsymbol}{187}
\DeclareMathSymbol{\supset}{\mathrel}{mtpsymbol}{201}
\DeclareMathSymbol{\subset}{\mathrel}{mtpsymbol}{204}
\DeclareMathSymbol{\supseteq}{\mathrel}{mtpsymbol}{202}
\DeclareMathSymbol{\subseteq}{\mathrel}{mtpsymbol}{205}
\DeclareMathSymbol{\in}{\mathrel}{mtpsymbol}{206}
\DeclareMathSymbol{\sim}{\mathrel}{mtpsymbol}{126}
\let\cong\undefined
\DeclareMathSymbol{\cong}{\mathrel}{mtpsymbol}{64} 
\DeclareMathSymbol{\perp}{\mathrel}{mtpsymbol}{94}
\DeclareMathSymbol{\equiv}{\mathrel}{mtpsymbol}{186}
\let\notin\undefined
\DeclareMathSymbol{\notin}{\mathrel}{mtpsymbol}{207}
\DeclareMathDelimiter{\rangle}
   {\mathclose}{mtpsymbol}{241}{largesymbols}{"0B}
\DeclareMathDelimiter{\langle}
   {\mathopen}{mtpsymbol}{225}{largesymbols}{"0A}
\fi
%    \end{macrocode}
% \end{macro}
% \begin{macro}{symbolre}
% I like the \cs{Re} and \cs{Im} from Symbol, so I overwrite the CM ones.
%    \begin{macrocode}
\ifmst@symbolre
\mst@infoline{symbolre: \string\Re\space and \string\Im\space from Symbol font}
\DeclareMathSymbol{\Re}{\mathord}{mtpsymbol}{"C2}
\DeclareMathSymbol{\Im}{\mathord}{mtpsymbol}{"C1}
\DeclareMathSymbol{\DotTriangle}{\mathord}{mtpsymbol}{92}
\fi
%    \end{macrocode}
% \end{macro}
% \begin{macro}{Greek letters}
% LGRgreek $>$ selfGreek $>$ eulergreek $>$ symbolgreek 
% 
% \mstrelease{1.11} I correct some bugs on how eulergreek and
% symbolgreek interacted.
%
% \mstrelease{1.12b} more bug fixes.
%
% \mstrelease{1.13} 
%
%       * Option LGRgreek. 
%
%       * Also, a behavior has been changed: it regards the selfGreek case,
%       the default shape is now the one for letters, not for operator-names
%       and digits. This complies to the ISO standard.  
%
%       * bugfix: version \mstrelease{1.12b} did not define the \cs{omicron} in the
%       case when no Greek-related option was passed to the package. 
%
% \mstrelease{1.13d} has new macros |\MTstandardgreek| and |\MTcustomgreek|.
%       And in the subdued case |\MTstandardgreek| is done when switching to
%       the normal or bold math versions (previously something like this
%       was only done in case of |LGRgreek| option. )
%    \begin{macrocode}
\let\mst@mathord\mathalpha
\mst@goaheadtrue
\ifmst@selfGreek 
    \def\mst@font@tbu{mtselfGreekfont}
\else
    \ifmst@eulergreek 
        \def\mst@font@tbu{mteulervm} 
    \else
      \ifmst@symbolgreek 
        \def\mst@font@tbu{mtpsymbol}
        \let\mst@mathord\mathord
      \else
         \ifmst@LGRgreek
            \mst@goaheadfalse
         \else
%    \end{macrocode}
% The \cs{omicron} requires special treatment. By default we use the o from the
% (original) normal alphabet, if eulergreek or symbolgreek we adapt.  There is
% also a special adjustment  if the package |fourier| was loaded in its
% |upright| variant: we then take \cs{omicron} from the (original) rm alphabet.
%    \begin{macrocode}
           \mst@goaheadfalse
           \def\mst@omicron {\mst@alph@omicron{o}}
         \fi
      \fi
   \fi
\fi
\ifmst@goahead
  \DeclareMathSymbol{\mst@Alpha}{\mst@mathord}{\mst@font@tbu}{"41}
  \DeclareMathSymbol{\mst@Beta}{\mst@mathord}{\mst@font@tbu}{"42}
  \DeclareMathSymbol{\mst@Epsilon}{\mst@mathord}{\mst@font@tbu}{"45}
  \DeclareMathSymbol{\mst@Zeta}{\mst@mathord}{\mst@font@tbu}{"5A}
  \DeclareMathSymbol{\mst@Eta}{\mst@mathord}{\mst@font@tbu}{"48}
  \DeclareMathSymbol{\mst@Iota}{\mst@mathord}{\mst@font@tbu}{"49}
  \DeclareMathSymbol{\mst@Kappa}{\mst@mathord}{\mst@font@tbu}{"4B}
  \DeclareMathSymbol{\mst@Mu}{\mst@mathord}{\mst@font@tbu}{"4D}
  \DeclareMathSymbol{\mst@Nu}{\mst@mathord}{\mst@font@tbu}{"4E}
  \DeclareMathSymbol{\mst@Omicron}{\mst@mathord}{\mst@font@tbu}{"4F}
  \DeclareMathSymbol{\mst@Rho}{\mst@mathord}{\mst@font@tbu}{"50}
  \DeclareMathSymbol{\mst@Tau}{\mst@mathord}{\mst@font@tbu}{"54}
  \DeclareMathSymbol{\mst@Chi}{\mst@mathord}{\mst@font@tbu}{"58}
%    \end{macrocode}
%  When we in fact use Symbol, we  have to correct \cs{Rho} and
%  \cs{Chi}. And \cs{Digamma} is non-existent in fact (no F
%  in Symbol, F codes a \cs{Phi}).
%    \begin{macrocode}
  \ifx\mst@mathord\mathord
%    \end{macrocode}
% \noindent symbolgreek but neither eulergreek nor selfGreek\newline
% Attention le P de Symbol est un \cs{Pi} pas un \cs{Rho}.\newline
% Attention le X de Symbol est un \cs{Xi} pas un \cs{Chi}.\newline
% Attention le F de Symbol est un \cs{Phi}. Il n'y a pas de \cs{Digamma}.
%    \begin {macrocode}
    \DeclareMathSymbol{\mst@Rho}{\mathord}{mtpsymbol}{"52}
    \DeclareMathSymbol{\mst@Chi}{\mathord}{mtpsymbol}{"43}
    \DeclareMathSymbol{\mst@Gamma}{\mathord}{mtpsymbol}{"47}
    \DeclareMathSymbol{\mst@Delta}{\mathord}{mtpsymbol}{"44}
    \DeclareMathSymbol{\mst@Theta}{\mathord}{mtpsymbol}{"51}
    \DeclareMathSymbol{\mst@Lambda}{\mathord}{mtpsymbol}{"4C}
    \DeclareMathSymbol{\mst@Xi}{\mathord}{mtpsymbol}{"58}
    \DeclareMathSymbol{\mst@Pi}{\mathord}{mtpsymbol}{"50}
    \DeclareMathSymbol{\mst@Sigma}{\mathord}{mtpsymbol}{"53}
    \DeclareMathSymbol{\mst@Upsilon}{\mathord}{mtpsymbol}{"A1}
    \DeclareMathSymbol{\mst@Phi}{\mathord}{mtpsymbol}{"46}
    \DeclareMathSymbol{\mst@Psi}{\mathord}{mtpsymbol}{"59}
    \DeclareMathSymbol{\mst@Omega}{\mathord}{mtpsymbol}{"57}
  \else
%    \end{macrocode}
% not symbolgreek but eulergreek or selfGreek. Note |2015/10/31| : apparemment à
% un moment dans le passé je considérais eulergreek et selfGreek comme pouvant
% être utilisés simultanément car j'avais ici "or both". Mais je laisse tomber
% tout effort réel de m'en préoccuper.
%    \begin{macrocode}
    \DeclareMathSymbol\mst@Digamma  {\mathalpha}{\mst@font@tbu}{"46}
    \DeclareMathSymbol\mst@Gamma    {\mathalpha}{\mst@font@tbu}{"00}
    \DeclareMathSymbol\mst@Delta    {\mathalpha}{\mst@font@tbu}{"01}
    \DeclareMathSymbol\mst@Theta    {\mathalpha}{\mst@font@tbu}{"02}
    \DeclareMathSymbol\mst@Lambda   {\mathalpha}{\mst@font@tbu}{"03}
    \DeclareMathSymbol\mst@Xi       {\mathalpha}{\mst@font@tbu}{"04}
    \DeclareMathSymbol\mst@Pi       {\mathalpha}{\mst@font@tbu}{"05}
    \DeclareMathSymbol\mst@Sigma    {\mathalpha}{\mst@font@tbu}{"06}
    \DeclareMathSymbol\mst@Upsilon  {\mathalpha}{\mst@font@tbu}{"07}
    \DeclareMathSymbol\mst@Phi      {\mathalpha}{\mst@font@tbu}{"08}
    \DeclareMathSymbol\mst@Psi      {\mathalpha}{\mst@font@tbu}{"09}
    \DeclareMathSymbol\mst@Omega    {\mathalpha}{\mst@font@tbu}{"0A}
  \fi
\fi
%    \end{macrocode}
% There are differences regarding Euler and Symbol with respect to the
% available var-letters. We include one or two things like the |wp| and the
% |partial|.
%
% The lower case Greek letters in default \LaTeX{} are of type |mathord|. If
% we use the Euler font it is perhaps better to have them be of type
% |mathalpha|
%    \begin{macrocode}
\ifmst@goahead
 \ifmst@eulergreek
  \DeclareMathSymbol{\mst@alpha}  {\mathalpha}{mteulervm}{"0B}
  \DeclareMathSymbol{\mst@beta}   {\mathalpha}{mteulervm}{"0C}
  \DeclareMathSymbol{\mst@gamma}  {\mathalpha}{mteulervm}{"0D}
  \DeclareMathSymbol{\mst@delta}  {\mathalpha}{mteulervm}{"0E}
  \DeclareMathSymbol{\mst@epsilon}{\mathalpha}{mteulervm}{"0F}
  \DeclareMathSymbol{\mst@zeta}   {\mathalpha}{mteulervm}{"10}
  \DeclareMathSymbol{\mst@eta}    {\mathalpha}{mteulervm}{"11}
  \DeclareMathSymbol{\mst@theta}  {\mathalpha}{mteulervm}{"12}
  \DeclareMathSymbol{\mst@iota}   {\mathalpha}{mteulervm}{"13}
  \DeclareMathSymbol{\mst@kappa}  {\mathalpha}{mteulervm}{"14}
  \DeclareMathSymbol{\mst@lambda} {\mathalpha}{mteulervm}{"15}
  \DeclareMathSymbol{\mst@mu}     {\mathalpha}{mteulervm}{"16}
  \DeclareMathSymbol{\mst@nu}     {\mathalpha}{mteulervm}{"17}
  \DeclareMathSymbol{\mst@xi}     {\mathalpha}{mteulervm}{"18}
  \DeclareMathSymbol{\mst@omicron}{\mathalpha}{mteulervm}{"6F}
  \DeclareMathSymbol{\mst@pi}     {\mathalpha}{mteulervm}{"19}
  \DeclareMathSymbol{\mst@rho}    {\mathalpha}{mteulervm}{"1A}
  \DeclareMathSymbol{\mst@sigma}  {\mathalpha}{mteulervm}{"1B}
  \DeclareMathSymbol{\mst@tau}    {\mathalpha}{mteulervm}{"1C}
  \DeclareMathSymbol{\mst@upsilon}{\mathalpha}{mteulervm}{"1D}
  \DeclareMathSymbol{\mst@phi}    {\mathalpha}{mteulervm}{"1E}
  \DeclareMathSymbol{\mst@chi}    {\mathalpha}{mteulervm}{"1F}
  \DeclareMathSymbol{\mst@psi}    {\mathalpha}{mteulervm}{"20}
  \DeclareMathSymbol{\mst@omega}  {\mathalpha}{mteulervm}{"21}
%
  \DeclareMathSymbol{\mst@varepsilon}{\mathalpha}{mteulervm}{"22}
  \DeclareMathSymbol{\mst@vartheta}{\mathalpha}{mteulervm}{"23}
  \DeclareMathSymbol{\mst@varpi}  {\mathalpha}{mteulervm}{"24}
  \let\mst@varrho=\mst@rho
  \let\mst@varsigma=\mst@sigma
  \DeclareMathSymbol{\mst@varphi} {\mathalpha}{mteulervm}{"27}
%
  \DeclareMathSymbol{\mst@partial}{\mathalpha}{mteulervm}{"40}
  \DeclareMathSymbol{\mst@wp}{\mathalpha}{mteulervm}{"7D}
  \DeclareMathSymbol{\mst@ell}{\mathalpha}{mteulervm}{"60}
 \else
  \ifmst@symbolgreek
  \DeclareMathSymbol{\mst@alpha}{\mathord}{mtpsymbol}{"61}
  \DeclareMathSymbol{\mst@beta}{\mathord}{mtpsymbol}{"62}
  \DeclareMathSymbol{\mst@gamma}{\mathord}{mtpsymbol}{"67}
  \DeclareMathSymbol{\mst@delta}{\mathord}{mtpsymbol}{"64}
  \DeclareMathSymbol{\mst@epsilon}{\mathord}{mtpsymbol}{"65}
  \DeclareMathSymbol{\mst@zeta}{\mathord}{mtpsymbol}{"7A}
  \DeclareMathSymbol{\mst@eta}{\mathord}{mtpsymbol}{"68}
  \DeclareMathSymbol{\mst@theta}{\mathord}{mtpsymbol}{"71}
  \DeclareMathSymbol{\mst@iota}{\mathord}{mtpsymbol}{"69}
  \DeclareMathSymbol{\mst@kappa}{\mathord}{mtpsymbol}{"6B}
  \DeclareMathSymbol{\mst@lambda}{\mathord}{mtpsymbol}{"6C}
  \DeclareMathSymbol{\mst@mu}{\mathord}{mtpsymbol}{"6D}
  \DeclareMathSymbol{\mst@nu}{\mathord}{mtpsymbol}{"6E}
  \DeclareMathSymbol{\mst@xi}{\mathord}{mtpsymbol}{"78}
  \DeclareMathSymbol{\mst@omicron}{\mathord}{mtpsymbol}{"6F}
  \DeclareMathSymbol{\mst@pi}{\mathord}{mtpsymbol}{"70}
  \DeclareMathSymbol{\mst@rho}{\mathord}{mtpsymbol}{"72}
  \DeclareMathSymbol{\mst@sigma}{\mathord}{mtpsymbol}{"73}
  \DeclareMathSymbol{\mst@tau}{\mathord}{mtpsymbol}{"74}
  \DeclareMathSymbol{\mst@upsilon}{\mathord}{mtpsymbol}{"75}
  \DeclareMathSymbol{\mst@phi}{\mathord}{mtpsymbol}{"66}
  \DeclareMathSymbol{\mst@chi}{\mathord}{mtpsymbol}{"63}
  \DeclareMathSymbol{\mst@psi}{\mathord}{mtpsymbol}{"79}
  \DeclareMathSymbol{\mst@omega}{\mathord}{mtpsymbol}{"77}
  \let\mst@varepsilon=\mst@epsilon
  \DeclareMathSymbol{\mst@vartheta}{\mathord}{mtpsymbol}{"4A}
  \DeclareMathSymbol{\mst@varpi}{\mathord}{mtpsymbol}{"76}
  \let\mst@varrho=\mst@rho
  \DeclareMathSymbol{\mst@varsigma}{\mathord}{mtpsymbol}{"56}
  \DeclareMathSymbol{\mst@varphi}{\mathord}{mtpsymbol}{"6A}
  \DeclareMathSymbol{\mst@partial}{\mathord}{mtpsymbol}{"B6}
  \DeclareMathSymbol{\mst@wp}{\mathord}{mtpsymbol}{"C3}
  \fi
 \fi
\fi
%    \end{macrocode}
% \begin{macro}{\alphaup etc...}
% Completely refactored at \mstrelease{1.3y} to define |\Alphaup|, |\Alphait|,
% |\alphaup|, |\alphait|, etc\dots{} and prepare templates |\Alpha|, \dots{},
% |\alpha|, \dots{}, which when activating a math version will be submitted to
% an |\expanded|, whose behavior will depend on version-specific conditionals.
%    \begin{macrocode}
\ifmst@LGRgreek
% cf http://milde.users.sourceforge.net/LGR/lgrxenc.def.html
% et greek.ldf du package babel
  \DeclareMathSymbol{\Alphaup}{\mathalpha}{mtgreekup}{65}
  \DeclareMathSymbol{\Betaup}{\mathalpha}{mtgreekup}{66}
  \DeclareMathSymbol{\Epsilonup}{\mathalpha}{mtgreekup}{69}
  \DeclareMathSymbol{\Zetaup}{\mathalpha}{mtgreekup}{90}
  \DeclareMathSymbol{\Etaup}{\mathalpha}{mtgreekup}{72}
  \DeclareMathSymbol{\Iotaup}{\mathalpha}{mtgreekup}{73}
  \DeclareMathSymbol{\Kappaup}{\mathalpha}{mtgreekup}{75}
  \DeclareMathSymbol{\Muup}{\mathalpha}{mtgreekup}{77}
  \DeclareMathSymbol{\Nuup}{\mathalpha}{mtgreekup}{78}
  \DeclareMathSymbol{\Omicronup}{\mathalpha}{mtgreekup}{79}
  \DeclareMathSymbol{\Rhoup}{\mathalpha}{mtgreekup}{82}
  \DeclareMathSymbol{\Tauup}{\mathalpha}{mtgreekup}{84}
  \DeclareMathSymbol{\Chiup}{\mathalpha}{mtgreekup}{81}
  %
  \DeclareMathSymbol{\Alphait}{\mathalpha}{mtgreekit}{65}
  \DeclareMathSymbol{\Betait}{\mathalpha}{mtgreekit}{66}
  \DeclareMathSymbol{\Epsilonit}{\mathalpha}{mtgreekit}{69}
  \DeclareMathSymbol{\Zetait}{\mathalpha}{mtgreekit}{90}
  \DeclareMathSymbol{\Etait}{\mathalpha}{mtgreekit}{72}
  \DeclareMathSymbol{\Iotait}{\mathalpha}{mtgreekit}{73}
  \DeclareMathSymbol{\Kappait}{\mathalpha}{mtgreekit}{75}
  \DeclareMathSymbol{\Muit}{\mathalpha}{mtgreekit}{77}
  \DeclareMathSymbol{\Nuit}{\mathalpha}{mtgreekit}{78}
  \DeclareMathSymbol{\Omicronit}{\mathalpha}{mtgreekit}{79}
  \DeclareMathSymbol{\Rhoit}{\mathalpha}{mtgreekit}{82}
  \DeclareMathSymbol{\Tauit}{\mathalpha}{mtgreekit}{84}
  \DeclareMathSymbol{\Chiit}{\mathalpha}{mtgreekit}{81}
%    \end{macrocode}
% \mstrelease{1.3w} and earlier had a bug regarding Digamma which was set up
% to use same font shape as for lowercase digamma.
%    \begin{macrocode}
  \DeclareMathSymbol{\Digammaup}{\mathalpha}{mtgreekup}{195}
  \DeclareMathSymbol{\Digammait}{\mathalpha}{mtgreekit}{195}
  %
  \DeclareMathSymbol{\Gammaup}{\mathalpha}{mtgreekup}{71}
  \DeclareMathSymbol{\Deltaup}{\mathalpha}{mtgreekup}{68}
  \DeclareMathSymbol{\Thetaup}{\mathalpha}{mtgreekup}{74}
  \DeclareMathSymbol{\Lambdaup}{\mathalpha}{mtgreekup}{76}
  \DeclareMathSymbol{\Xiup}{\mathalpha}{mtgreekup}{88}
  \DeclareMathSymbol{\Piup}{\mathalpha}{mtgreekup}{80}
  \DeclareMathSymbol{\Sigmaup}{\mathalpha}{mtgreekup}{83}
  \DeclareMathSymbol{\Upsilonup}{\mathalpha}{mtgreekup}{85}
  \DeclareMathSymbol{\Phiup}{\mathalpha}{mtgreekup}{70}
  \DeclareMathSymbol{\Psiup}{\mathalpha}{mtgreekup}{89}
  \DeclareMathSymbol{\Omegaup}{\mathalpha}{mtgreekup}{87}
  %
  \DeclareMathSymbol{\Gammait}{\mathalpha}{mtgreekit}{71}
  \DeclareMathSymbol{\Deltait}{\mathalpha}{mtgreekit}{68}
  \DeclareMathSymbol{\Thetait}{\mathalpha}{mtgreekit}{74}
  \DeclareMathSymbol{\Lambdait}{\mathalpha}{mtgreekit}{76}
  \DeclareMathSymbol{\Xiit}{\mathalpha}{mtgreekit}{88}
  \DeclareMathSymbol{\Piit}{\mathalpha}{mtgreekit}{80}
  \DeclareMathSymbol{\Sigmait}{\mathalpha}{mtgreekit}{83}
  \DeclareMathSymbol{\Upsilonit}{\mathalpha}{mtgreekit}{85}
  \DeclareMathSymbol{\Phiit}{\mathalpha}{mtgreekit}{70}
  \DeclareMathSymbol{\Psiit}{\mathalpha}{mtgreekit}{89}
  \DeclareMathSymbol{\Omegait}{\mathalpha}{mtgreekit}{87}
  %
  \def\mst@Alpha{\ifmst@greek@upper@up\Alphaup\else\Alphait\fi}%
  \def\mst@Beta{\ifmst@greek@upper@up\Betaup\else\Betait\fi}%
  \def\mst@Epsilon{\ifmst@greek@upper@up\Epsilonup\else\Epsilonit\fi}%
  \def\mst@Zeta{\ifmst@greek@upper@up\Zetaup\else\Zetait\fi}%
  \def\mst@Eta{\ifmst@greek@upper@up\Etaup\else\Etait\fi}%
  \def\mst@Iota{\ifmst@greek@upper@up\Iotaup\else\Iotait\fi}%
  \def\mst@Kappa{\ifmst@greek@upper@up\Kappaup\else\Kappait\fi}%
  \def\mst@Mu{\ifmst@greek@upper@up\Muup\else\Muit\fi}%
  \def\mst@Nu{\ifmst@greek@upper@up\Nuup\else\Nuit\fi}%
  \def\mst@Omicron{\ifmst@greek@upper@up\Omicronup\else\Omicronit\fi}%
  \def\mst@Rho{\ifmst@greek@upper@up\Rhoup\else\Rhoit\fi}%
  \def\mst@Tau{\ifmst@greek@upper@up\Tauup\else\Tauit\fi}%
  \def\mst@Chi{\ifmst@greek@upper@up\Chiup\else\Chiit\fi}%
  %
  \def\mst@Digamma{\ifmst@greek@upper@up\Digammaup\else\Digammait\fi}%
  %
  \def\mst@Gamma{\ifmst@greek@upper@up\Gammaup\else\Gammait\fi}%
  \def\mst@Delta{\ifmst@greek@upper@up\Deltaup\else\Deltait\fi}%
  \def\mst@Theta{\ifmst@greek@upper@up\Thetaup\else\Thetait\fi}%
  \def\mst@Lambda{\ifmst@greek@upper@up\Lambdaup\else\Lambdait\fi}%
  \def\mst@Xi{\ifmst@greek@upper@up\Xiup\else\Xiit\fi}%
  \def\mst@Pi{\ifmst@greek@upper@up\Piup\else\Piit\fi}%
  \def\mst@Sigma{\ifmst@greek@upper@up\Sigmaup\else\Sigmait\fi}%
  \def\mst@Upsilon{\ifmst@greek@upper@up\Upsilonup\else\Upsilonit\fi}%
  \def\mst@Phi{\ifmst@greek@upper@up\Phiup\else\Phiit\fi}%
  \def\mst@Psi{\ifmst@greek@upper@up\Psiup\else\Psiit\fi}%
  \def\mst@Omega{\ifmst@greek@upper@up\Omegaup\else\Omegait\fi}%
  %
  \DeclareMathSymbol{\alphaup}{\mathalpha}{mtgreekup}{97}
  \DeclareMathSymbol{\betaup}{\mathalpha}{mtgreekup}{98}
  \DeclareMathSymbol{\gammaup}{\mathalpha}{mtgreekup}{103}
  \DeclareMathSymbol{\deltaup}{\mathalpha}{mtgreekup}{100}
  \DeclareMathSymbol{\epsilonup}{\mathalpha}{mtgreekup}{101}
  \DeclareMathSymbol{\zetaup}{\mathalpha}{mtgreekup}{122}
  \DeclareMathSymbol{\etaup}{\mathalpha}{mtgreekup}{104}
  \DeclareMathSymbol{\thetaup}{\mathalpha}{mtgreekup}{106}
  \DeclareMathSymbol{\iotaup}{\mathalpha}{mtgreekup}{105}
  \DeclareMathSymbol{\kappaup}{\mathalpha}{mtgreekup}{107}
  \DeclareMathSymbol{\lambdaup}{\mathalpha}{mtgreekup}{108}
  \DeclareMathSymbol{\muup}{\mathalpha}{mtgreekup}{109}
  \DeclareMathSymbol{\nuup}{\mathalpha}{mtgreekup}{110}
  \DeclareMathSymbol{\xiup}{\mathalpha}{mtgreekup}{120}
  \DeclareMathSymbol{\omicronup}{\mathalpha}{mtgreekup}{111}
  \DeclareMathSymbol{\piup}{\mathalpha}{mtgreekup}{112}
  \DeclareMathSymbol{\rhoup}{\mathalpha}{mtgreekup}{114}
  \DeclareMathSymbol{\sigmaup}{\mathalpha}{mtgreekup}{115}
  \DeclareMathSymbol{\tauup}{\mathalpha}{mtgreekup}{116}
  \DeclareMathSymbol{\upsilonup}{\mathalpha}{mtgreekup}{117}
  \DeclareMathSymbol{\phiup}{\mathalpha}{mtgreekup}{102}
  \DeclareMathSymbol{\chiup}{\mathalpha}{mtgreekup}{113}
  \DeclareMathSymbol{\psiup}{\mathalpha}{mtgreekup}{121}
  \DeclareMathSymbol{\omegaup}{\mathalpha}{mtgreekup}{119}
  %
  \DeclareMathSymbol{\digammaup}{\mathalpha}{mtgreekup}{147}
%    \end{macrocode}
% Only varsigma defined (I should check this again).
%    \begin{macrocode}
  \DeclareMathSymbol{\varsigmaup}{\mathalpha}{mtgreekup}{99}
  %
  \DeclareMathSymbol{\alphait}{\mathalpha}{mtgreekit}{97}
  \DeclareMathSymbol{\betait}{\mathalpha}{mtgreekit}{98}
  \DeclareMathSymbol{\gammait}{\mathalpha}{mtgreekit}{103}
  \DeclareMathSymbol{\deltait}{\mathalpha}{mtgreekit}{100}
  \DeclareMathSymbol{\epsilonit}{\mathalpha}{mtgreekit}{101}
  \DeclareMathSymbol{\zetait}{\mathalpha}{mtgreekit}{122}
  \DeclareMathSymbol{\etait}{\mathalpha}{mtgreekit}{104}
  \DeclareMathSymbol{\thetait}{\mathalpha}{mtgreekit}{106}
  \DeclareMathSymbol{\iotait}{\mathalpha}{mtgreekit}{105}
  \DeclareMathSymbol{\kappait}{\mathalpha}{mtgreekit}{107}
  \DeclareMathSymbol{\lambdait}{\mathalpha}{mtgreekit}{108}
  \DeclareMathSymbol{\muit}{\mathalpha}{mtgreekit}{109}
  \DeclareMathSymbol{\nuit}{\mathalpha}{mtgreekit}{110}
  \DeclareMathSymbol{\xiit}{\mathalpha}{mtgreekit}{120}
  \DeclareMathSymbol{\omicronit}{\mathalpha}{mtgreekit}{111}
  \DeclareMathSymbol{\piit}{\mathalpha}{mtgreekit}{112}
  \DeclareMathSymbol{\rhoit}{\mathalpha}{mtgreekit}{114}
  \DeclareMathSymbol{\sigmait}{\mathalpha}{mtgreekit}{115}
  \DeclareMathSymbol{\tauit}{\mathalpha}{mtgreekit}{116}
  \DeclareMathSymbol{\upsilonit}{\mathalpha}{mtgreekit}{117}
  \DeclareMathSymbol{\phiit}{\mathalpha}{mtgreekit}{102}
  \DeclareMathSymbol{\chiit}{\mathalpha}{mtgreekit}{113}
  \DeclareMathSymbol{\psiit}{\mathalpha}{mtgreekit}{121}
  \DeclareMathSymbol{\omegait}{\mathalpha}{mtgreekit}{119}
  %
  \DeclareMathSymbol{\digammait}{\mathalpha}{mtgreekit}{147}
  \DeclareMathSymbol{\varsigmait}{\mathalpha}{mtgreekit}{99}
  %
  \def\mst@alpha{\ifmst@greek@lower@up\alphaup\else\alphait\fi}%
  \def\mst@beta{\ifmst@greek@lower@up\betaup\else\betait\fi}%
  \def\mst@gamma{\ifmst@greek@lower@up\gammaup\else\gammait\fi}%
  \def\mst@delta{\ifmst@greek@lower@up\deltaup\else\deltait\fi}%
  \def\mst@epsilon{\ifmst@greek@lower@up\epsilonup\else\epsilonit\fi}%
  \def\mst@zeta{\ifmst@greek@lower@up\zetaup\else\zetait\fi}%
  \def\mst@eta{\ifmst@greek@lower@up\etaup\else\etait\fi}%
  \def\mst@theta{\ifmst@greek@lower@up\thetaup\else\thetait\fi}%
  \def\mst@iota{\ifmst@greek@lower@up\iotaup\else\iotait\fi}%
  \def\mst@kappa{\ifmst@greek@lower@up\kappaup\else\kappait\fi}%
  \def\mst@lambda{\ifmst@greek@lower@up\lambdaup\else\lambdait\fi}%
  \def\mst@mu{\ifmst@greek@lower@up\muup\else\muit\fi}%
  \def\mst@nu{\ifmst@greek@lower@up\nuup\else\nuit\fi}%
  \def\mst@xi{\ifmst@greek@lower@up\xiup\else\xiit\fi}%
  \def\mst@omicron{\ifmst@greek@lower@up\omicronup\else\omicronit\fi}%
  \def\mst@pi{\ifmst@greek@lower@up\piup\else\piit\fi}%
  \def\mst@rho{\ifmst@greek@lower@up\rhoup\else\rhoit\fi}%
  \def\mst@sigma{\ifmst@greek@lower@up\sigmaup\else\sigmait\fi}%
  \def\mst@tau{\ifmst@greek@lower@up\tauup\else\tauit\fi}%
  \def\mst@upsilon{\ifmst@greek@lower@up\upsilonup\else\upsilonit\fi}%
  \def\mst@phi{\ifmst@greek@lower@up\phiup\else\phiit\fi}%
  \def\mst@chi{\ifmst@greek@lower@up\chiup\else\chiit\fi}%
  \def\mst@psi{\ifmst@greek@lower@up\psiup\else\psiit\fi}%
  \def\mst@omega{\ifmst@greek@lower@up\omegaup\else\omegait\fi}%
    %
  \def\mst@digamma{\ifmst@greek@lower@up\digammaup\else\digammait\fi}%
  \def\mst@varsigma{\ifmst@greek@lower@up\varsigmaup\else\varsigmait\fi}%
\fi
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\MTstandardgreek}
% \begin{macro}{\MTcustomgreek}
% \begin{macro}{\MTrecordstandardgreek}
%   \mstrelease{1.3d} |2014/05/23| defines the commands |\MTstandardgreek| and
%   |\MTcustomgreek| for package and user. I leave |\MTrecordstandardgreek|
%   undocumented as I don't want to encourage people to load math packages
%   after \mst.
%
% \mstrelease{1.3h} |2015/10/31|: corrected |\MTcustomgreek| as it caused |\ell| to
% become undefined under option |symbolgreek| and, much more catastrophic,
% caused |\alpha|, etc.. to become undefined under option |selfGreek| !
%    \begin{macrocode}
\newcommand*{\MTstandardgreek}{}
\newcommand*{\MTcustomgreek}{}
\newcommand*{\MTrecordstandardgreek}{}
\ifmst@customgreek
 \renewcommand*{\MTrecordstandardgreek}{%
    \let\mst@origAlpha\Alpha
    \let\mst@origBeta\Beta
    \let\mst@origGamma\Gamma
    \let\mst@origDelta\Delta
    \let\mst@origEpsilon\Epsilon
    \let\mst@origZeta\Zeta
    \let\mst@origEta\Eta
    \let\mst@origTheta\Theta
    \let\mst@origIota\Iota
    \let\mst@origKappa\Kappa
    \let\mst@origLambda\Lambda
    \let\mst@origMu\Mu
    \let\mst@origNu\Nu
    \let\mst@origXi\Xi
    \let\mst@origOmicron\Omicron
    \let\mst@origPi\Pi
    \let\mst@origRho\Rho
    \let\mst@origSigma\Sigma
    \let\mst@origTau\Tau
    \let\mst@origUpsilon\Upsilon
    \let\mst@origPhi\Phi
    \let\mst@origChi\Chi
    \let\mst@origPsi\Psi
    \let\mst@origOmega\Omega
%
    \let\mst@origalpha\alpha
    \let\mst@origbeta\beta
    \let\mst@origgamma\gamma
    \let\mst@origdelta\delta
    \let\mst@origepsilon\epsilon
    \let\mst@origvarepsilon\varepsilon
    \let\mst@origzeta\zeta
    \let\mst@origeta\eta
    \let\mst@origtheta\theta
    \let\mst@origvartheta\vartheta
    \let\mst@origiota\iota
    \let\mst@origkappa\kappa
    \let\mst@origlambda\lambda
    \let\mst@origmu\mu
    \let\mst@orignu\nu
    \let\mst@origxi\xi
    \let\mst@origomicron\omicron
    \let\mst@origpi\pi
    \let\mst@origvarpi\varpi
    \let\mst@origrho\rho
    \let\mst@origvarrho\varrho
    \let\mst@origsigma\sigma
    \let\mst@origvarsigma\varsigma
    \let\mst@origtau\tau
    \let\mst@origupsilon\upsilon
    \let\mst@origphi\phi
    \let\mst@origvarphi\varphi
    \let\mst@origchi\chi
    \let\mst@origpsi\psi
    \let\mst@origomega\omega
    \let\mst@origDigamma\Digamma
    \let\mst@origdigamma\digamma
%
    \let\mst@origpartial\partial
    \let\mst@origwp\wp
    \let\mst@origell\ell }%
\MTrecordstandardgreek 
\renewcommand*{\MTstandardgreek}{%
    \let\Alpha\mst@origAlpha
    \let\Beta\mst@origBeta
    \let\Gamma\mst@origGamma
    \let\Delta\mst@origDelta
    \let\Epsilon\mst@origEpsilon
    \let\Zeta\mst@origZeta
    \let\Eta\mst@origEta
    \let\Theta\mst@origTheta
    \let\Iota\mst@origIota
    \let\Kappa\mst@origKappa
    \let\Lambda\mst@origLambda
    \let\Mu\mst@origMu
    \let\Nu\mst@origNu
    \let\Xi\mst@origXi
    \let\Omicron\mst@origOmicron
    \let\Pi\mst@origPi
    \let\Rho\mst@origRho
    \let\Sigma\mst@origSigma
    \let\Tau\mst@origTau
    \let\Upsilon\mst@origUpsilon
    \let\Phi\mst@origPhi
    \let\Chi\mst@origChi
    \let\Psi\mst@origPsi
    \let\Omega\mst@origOmega
%
    \let\alpha\mst@origalpha
    \let\beta\mst@origbeta
    \let\gamma\mst@origgamma
    \let\delta\mst@origdelta
    \let\epsilon\mst@origepsilon
    \let\varepsilon\mst@origvarepsilon
    \let\zeta\mst@origzeta
    \let\eta\mst@origeta
    \let\theta\mst@origtheta
    \let\vartheta\mst@origvartheta
    \let\iota\mst@origiota
    \let\kappa\mst@origkappa
    \let\lambda\mst@origlambda
    \let\mu\mst@origmu
    \let\nu\mst@orignu
    \let\xi\mst@origxi
    \let\omicron\mst@origomicron
    \let\pi\mst@origpi
    \let\varpi\mst@origvarpi
    \let\rho\mst@origrho
    \let\varrho\mst@origvarrho
    \let\sigma\mst@origsigma
    \let\varsigma\mst@origvarsigma
    \let\tau\mst@origtau
    \let\upsilon\mst@origupsilon
    \let\phi\mst@origphi
    \let\varphi\mst@origvarphi
    \let\chi\mst@origchi
    \let\psi\mst@origpsi
    \let\omega\mst@origomega
    \let\Digamma\mst@origDigamma
    \let\digamma\mst@origdigamma
%
    \let\partial\mst@origpartial
    \let\wp\mst@origwp
    \let\ell\mst@origell
}%
\ifmst@greekplus
%    \end{macrocode}
%   \mstrelease{1.3za} implementation of |LGRgreek+| option.  It is not exactly
%   clear what we should do for \cs{mathnormal} and \cs{mathnormalbold}.
%
%   This definition allows usage of \cs{alpha} for example in numerical
%   context.  To be completely clean perhaps we should get rid of
%   final \cs{fi}, but old-fashioned \LaTeX\ does not have built-in
%   conveniences, were it not for the nested if's simple \cs{expandafter}
%   would do, but here we would need three in four places. Or simply
%   wrap the whole in \cs{expanded}.  Anyway, not really important.
%    \begin{macrocode}
\def\mst@define@lowergreekletter#1#2{%
    \protected\def#1{\ifcase\mst@mathalph
        \ifmst@greek@lower@up\mathgreekup{#2}\else\mathgreekit{#2}\fi
      \or % rm
        \mathgreekup{#2}%
      \or % bf
        \mathgreekupbold{#2}%
      \or % it
        \mathgreekit{#2}%
      \or % normalbold
        \ifmst@greek@lower@up\mathgreekupbold{#2}\else\mathgreekitbold{#2}\fi
      \else #2\fi}%
    }
\def\mst@define@uppergreekletter#1#2{%
    \protected\def#1{\ifcase\mst@mathalph
        \ifmst@greek@upper@up\mathgreekup{#2}\else\mathgreekit{#2}\fi
      \or % rm
        \mathgreekup{#2}%
      \or % bf
        \mathgreekupbold{#2}%
      \or % it
        \mathgreekit{#2}%
      \or % mathnormalbold
        \ifmst@greek@upper@up\mathgreekupbold{#2}\else\mathgreekitbold{#2}\fi
      \else #2\fi}%
    }
\renewcommand*{\MTcustomgreek}{%
    \mst@define@uppergreekletter\Alpha\mst@Alpha
    \mst@define@uppergreekletter\Beta\mst@Beta
    \mst@define@uppergreekletter\Epsilon\mst@Epsilon
    \mst@define@uppergreekletter\Zeta\mst@Zeta
    \mst@define@uppergreekletter\Eta\mst@Eta
    \mst@define@uppergreekletter\Iota\mst@Iota
    \mst@define@uppergreekletter\Kappa\mst@Kappa
    \mst@define@uppergreekletter\Mu\mst@Mu
    \mst@define@uppergreekletter\Nu\mst@Nu
    \mst@define@uppergreekletter\Omicron\mst@Omicron
    \mst@define@uppergreekletter\Rho\mst@Rho
    \mst@define@uppergreekletter\Tau\mst@Tau
    \mst@define@uppergreekletter\Chi\mst@Chi
    \mst@define@uppergreekletter\Digamma\mst@Digamma
    \mst@define@uppergreekletter\Gamma\mst@Gamma
    \mst@define@uppergreekletter\Delta\mst@Delta
    \mst@define@uppergreekletter\Theta\mst@Theta
    \mst@define@uppergreekletter\Lambda\mst@Lambda
    \mst@define@uppergreekletter\Xi\mst@Xi
    \mst@define@uppergreekletter\Pi\mst@Pi
    \mst@define@uppergreekletter\Sigma\mst@Sigma
    \mst@define@uppergreekletter\Upsilon\mst@Upsilon
    \mst@define@uppergreekletter\Phi\mst@Phi
    \mst@define@uppergreekletter\Psi\mst@Psi
    \mst@define@uppergreekletter\Omega\mst@Omega
    \mst@define@lowergreekletter\alpha\mst@alpha
    \mst@define@lowergreekletter\beta\mst@beta
    \mst@define@lowergreekletter\gamma\mst@gamma
    \mst@define@lowergreekletter\delta\mst@delta
    \mst@define@lowergreekletter\epsilon\mst@epsilon
    \mst@define@lowergreekletter\zeta\mst@zeta
    \mst@define@lowergreekletter\eta\mst@eta
    \mst@define@lowergreekletter\theta\mst@theta
    \mst@define@lowergreekletter\iota\mst@iota
    \mst@define@lowergreekletter\kappa\mst@kappa
    \mst@define@lowergreekletter\lambda\mst@lambda
    \mst@define@lowergreekletter\mu\mst@mu
    \mst@define@lowergreekletter\nu\mst@nu
    \mst@define@lowergreekletter\xi\mst@xi
    \mst@define@lowergreekletter\omicron\mst@omicron
    \mst@define@lowergreekletter\pi\mst@pi
    \mst@define@lowergreekletter\rho\mst@rho
    \mst@define@lowergreekletter\sigma\mst@sigma
    \mst@define@lowergreekletter\tau\mst@tau
    \mst@define@lowergreekletter\upsilon\mst@upsilon
    \mst@define@lowergreekletter\phi\mst@phi
    \mst@define@lowergreekletter\chi\mst@chi
    \mst@define@lowergreekletter\psi\mst@psi
    \mst@define@lowergreekletter\omega\mst@omega
    \mst@define@lowergreekletter\varsigma\mst@varsigma
    \mst@define@lowergreekletter\digamma\mst@digamma
}%
\else
%    \end{macrocode}
%   Under |selfGreek| or other Greek option but not |LGRgreek|, these Greek
%   letter control sequences are already |\mathchar|'s, but under |LGRgreek|
%   they need (well not really, but I feel it is cleaner) expansion which will
%   react to the Boolean saying if using `upright' or `italic'. This Boolean
%   setting is recorded when declaring a math version and reenacted when
%   \cs{MTversion} is encountered in the document body. We must be careful not
%   to contaminate things in the principal mode from math version declarations
%   but I think my (now quite old) code is globally designed to achieve this
%   protection see how \cs{MTDeclareVersion} is done.  The \cs{MTcustomgreek}
%   will always be executed in preamble at least once, except under |subdued|
%   option.
%
%   The \cs{expanded}'s act on unexpanding tokens if not used under |LGRgreek|
%   regimen.
%    \begin{macrocode}
\renewcommand*{\MTcustomgreek}{%
  \expanded{%
    \let\noexpand\Alpha\mst@Alpha
    \let\noexpand\Beta\mst@Beta
    \let\noexpand\Epsilon\mst@Epsilon
    \let\noexpand\Zeta\mst@Zeta
    \let\noexpand\Eta\mst@Eta
    \let\noexpand\Iota\mst@Iota
    \let\noexpand\Kappa\mst@Kappa
    \let\noexpand\Mu\mst@Mu
    \let\noexpand\Nu\mst@Nu
    \let\noexpand\Omicron\mst@Omicron
    \let\noexpand\Rho\mst@Rho
    \let\noexpand\Tau\mst@Tau
    \let\noexpand\Chi\mst@Chi
  }%
%    \end{macrocode}
% \mstrelease{1.3h}: \cs{mst@Digamma} not defined if |symbolgreek| option.
%    \begin{macrocode}
    \ifmst@symbolgreek\else
        \expanded{\let\noexpand\Digamma\mst@Digamma}%
    \fi
  \expanded{%
    \let\noexpand\Gamma\mst@Gamma
    \let\noexpand\Delta\mst@Delta
    \let\noexpand\Theta\mst@Theta
    \let\noexpand\Lambda\mst@Lambda
    \let\noexpand\Xi\mst@Xi
    \let\noexpand\Pi\mst@Pi
    \let\noexpand\Sigma\mst@Sigma
    \let\noexpand\Upsilon\mst@Upsilon
    \let\noexpand\Phi\mst@Phi
    \let\noexpand\Psi\mst@Psi
    \let\noexpand\Omega\mst@Omega
  }%
%    \end{macrocode}
% \mstrelease{1.3h} |2015/10/31| adds this conditional to correct the bad bug in 
% \mstrelease{1.3d} |2014/05/23| which caused |\alpha| etc... to become undefined 
% under option |selfGreek|.
%    \begin{macrocode}
 \ifmst@selfGreek\else
  \expanded{%
    \let\noexpand\alpha\mst@alpha
    \let\noexpand\beta\mst@beta
    \let\noexpand\gamma\mst@gamma
    \let\noexpand\delta\mst@delta
    \let\noexpand\epsilon\mst@epsilon
    \let\noexpand\zeta\mst@zeta
    \let\noexpand\eta\mst@eta
    \let\noexpand\theta\mst@theta
    \let\noexpand\iota\mst@iota
    \let\noexpand\kappa\mst@kappa
    \let\noexpand\lambda\mst@lambda
    \let\noexpand\mu\mst@mu
    \let\noexpand\nu\mst@nu
    \let\noexpand\xi\mst@xi
    \let\noexpand\omicron\mst@omicron
    \let\noexpand\pi\mst@pi
    \let\noexpand\rho\mst@rho
    \let\noexpand\sigma\mst@sigma
    \let\noexpand\tau\mst@tau
    \let\noexpand\upsilon\mst@upsilon
    \let\noexpand\phi\mst@phi
    \let\noexpand\chi\mst@chi
    \let\noexpand\psi\mst@psi
    \let\noexpand\omega\mst@omega
    \let\noexpand\varsigma\mst@varsigma
  }%
%    \end{macrocode}
% \mstrelease{1.3h}: digamma only defined with option |LGRgreek|.
%    \begin{macrocode}
    \ifmst@LGRgreek
        \expanded{\let\noexpand\digamma\mst@digamma}%
    \fi
%    \end{macrocode}
% Conditional added \mstrelease{1.3h} |2015/10/31|.
%    \begin{macrocode}
    \ifmst@LGRgreek\else
      \let\varepsilon\mst@varepsilon
      \let\vartheta\mst@vartheta
      \let\varpi\mst@varpi
      \let\varrho\mst@varrho
      \let\varphi\mst@varphi
      \let\partial\mst@partial
      \let\wp\mst@wp
%    \end{macrocode}
%   \mstrelease{1.3h}: no \cs{mst@ell} if |symbolgreek| (bugfix
%   \mstrelease{1.3h} |2015/10/31|).
%    \begin{macrocode}
      \ifmst@symbolgreek\else\let\ell\mst@ell\fi
    \fi
 \fi
}%
\fi
\fi
\let\Mathastextstandardgreek\MTstandardgreek
\let\Mathastextcustomgreek\MTcustomgreek
\ifmst@subdued\else\MTcustomgreek\fi
%    \end{macrocode}
% \end{macro}\end{macro}\end{macro}
% \begin{macro}{\inodot}
% \begin{macro}{\jnodot}
%   In \mstrelease{1.0}, I had them of type |mathord|, here I choose |mathalpha|. If I
%   used \cs{i} and \cs{j} from the text font the problem would be with the
%   fontsize, if in scriptstyle. The amsmath \cs{text} would do the trick.
%
% \mstrelease{1.14b} |2011/04/02|: again this bug in the EU1/EU2 encoding part, as in the
% code redefining \$ etc in math mode (see above). Fixed.
%
% \mstrelease{1.3l} |2016/01/29|: anticipating TL2016 fontspec's switch to |TU|.
%
% \mstrelease{1.3t} |2018/08/22| removes the definitions done of |\i| and |\j|
% since \mstrelease{1.12} (as robust commands usable both in text and math mode).
%
% \mstrelease{1.3u} lets the \cs{imath} and \cs{jmath} react to the font encoding at each
% math version.
%
% \mstrelease{1.3v} lets the redefined \cs{imath} and \cs{jmath} be \cs{protected}.
%    \begin{macrocode}
\def\mst@subduedinodot{%
   \let\inodot\mst@original@imath
   \let\jnodot\mst@original@jmath
}%
\def\mst@nonsubduedinodot{%
   \expandafter\let\expandafter\inodot
               \csname mst@inodot@mv\math@version\endcsname
   \expandafter\let\expandafter\jnodot
               \csname mst@jnodot@mv\math@version\endcsname
}%
\def\mst@dothe@inodotstuff#1#2#3{%
  \edef\mst@tmp@enc{#3}%
  \if1\mst@OneifUniEnc
    \mst@Umathchardef#1="7 \symmtletterfont "0131 \relax
    \mst@Umathchardef#2="7 \symmtletterfont "0237 \relax
  \else 
   \DeclareMathSymbol{#1}{\mathalpha}{mtletterfont}
                     {\csname\mst@tmp@enc\string\i\endcsname}
   \DeclareMathSymbol{#2}{\mathalpha}{mtletterfont}
                     {\csname\mst@tmp@enc\string\j\endcsname}
  \fi}%
\ifmst@defaultimath\else\mst@infoline{\string\imath\space and \string\jmath\space}
    \AtEndOfPackage{\AtBeginDocument{%
        \protected\def\imath{\inodot}%
        \protected\def\jmath{\jnodot}%
    }}%
\fi
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{math accents}
%   \emph{Obsolete comments relative to the 2011 code:}
%   \begin{quote}
%   I don't know how to get from the encoding to the slot
%   positions of the accents (apart from going to look at
%   all possible encodings definition files and putting this
%   info here).  In standard \LaTeX{}, the math accents are
%   taken from the `operators' font. So we do the same
%   here. Of course there is the problem that the user can
%   define math versions with different encodings. Here I
%   take T1 if it was the default at the time of loading the
%   package, else OT1.
%   \mstrelease{1.12b}: I add LY1 which is quasi like OT1.
%   \end{quote}
%
%   At \mstrelease{1.3u} |2019/08/20| I decide to remove the hard-coded slot positions
%   for OT1, T1 and LY1, and replace them with some hack which assumes
%   LaTeX2e way of handling text accents got executed by the encoding
%   definition file. If not, some breakage on package loading could occur, but
%   this whole thing is conditional on the |mathaccents| option anyway, which
%   per default is not executed.
%
%   The |\vec| accent is not considered here because it has no suitable
%   available glyph in a standard 8bits text font encodings.
%
%   Also at \mstrelease{1.3u} the math accents adapt to the font encoding at each math
%   version.
%
%   (obsolete at \mstrelease{1.4}) \mstrelease{1.3v} adapts to \LaTeX{}
%   |2019-10-01| which now comes with robust math accent macros. The
%   «original»-named macros are without the robustifying space (NOT true
%   anymore, see \mstrelease{1.3w} next), as they only serve as meaning
%   holders.
%
%   (obsolete at \mstrelease{1.4}) On the other hand the macros indexed by
%   math version names are (in the pdflatex branch) always defined via
%   \cs{DeclareMathAccent} hence they will be robust with |2019-10-01| or
%   later and we must use the \cs{mst@robustifyingspace} with them to access
%   their real meaning (this thus differs from the situation with \cs{hbar}).
%
%   \mstrelease{1.3w} The above was a bit optimistic as |amsmath| for example modifies
%   \LaTeX{} internals and handles math accents differently.
%
%   We thus needed to double our
%   |\let|'s as, if |amsmath| is loaded, the cs with space will exist but not
%   be paired in expected way with the original cs. This breaks things by the
%   way if some math accent is written to an external file under a certain
%   context and executed in another context. The new context will be probably
%   ignored if |amsmath| is loaded, as the external file will have an already
%   expanded-once meaning.
%
%   Some macros with space in name might thus be created as |\relax|. Should I
%   rather create \cs{protected} macros for the math accents with Unicode
%   engines? Anyway, the construct does give good result with the few OpenType
%   text fonts I tested.
%    \begin{macrocode}
\let\mst@subduedmathaccents\@empty
\let\mst@nonsubduedmathaccents\@empty
\ifmst@mathaccents
\def\mst@subduedmathaccents{%
  \@tfor\@tempa:={grave}{acute}{check}{breve}{bar}%
                 {dot}{ddot}{mathring}{hat}{tilde}%
  \do
  {\expandafter\let\csname\@tempa\expandafter\endcsname
                   \csname mst@original@\@tempa\endcsname
   \expandafter\let\csname\@tempa\space\expandafter\endcsname
                   \csname mst@original@\@tempa\space\endcsname
   }%
}%
\def\mst@nonsubduedmathaccents{%
  \@tfor\@tempa:={grave}{acute}{check}{breve}{bar}%
                 {dot}{ddot}{mathring}{hat}{tilde}%
  \do
  {\expandafter\let\csname\@tempa\expandafter\endcsname
                   \csname mst@\@tempa @mv\math@version\endcsname
   \expandafter\let\csname\@tempa\space\expandafter\endcsname
                   \csname mst@\@tempa @mv\math@version\space\endcsname
}%
}%
\def\mst@dothe@mathaccentsstuff#1#2{%
  \begingroup
  \edef\mst@tmp@enc{#2}%
  \def\@text@composite##1\@text@composite##2{##2}%
  \let\add@accent\@firstoftwo
  \let\add@unicode@accent\@firstoftwo
  \if1\mst@OneifUniEnc
    \ifmst@unimathaccents
      \expandafter\xdef\csname mst@grave@mv#1\mst@robustifyingspace\endcsname
       {\mst@Umathaccent
        7
        \number\symmtoperatorfont\space
        \csname#2\string\`\endcsname{}\relax}%
      \expandafter\xdef\csname mst@acute@mv#1\mst@robustifyingspace\endcsname
       {\mst@Umathaccent
        7
        \number\symmtoperatorfont\space
        \csname#2\string\'\endcsname{}\relax}%
      \expandafter\xdef\csname mst@check@mv#1\mst@robustifyingspace\endcsname
       {\mst@Umathaccent
        7
        \number\symmtoperatorfont\space
        \csname#2\string\v\endcsname{}\relax}%
      \expandafter\xdef\csname mst@breve@mv#1\mst@robustifyingspace\endcsname
       {\mst@Umathaccent
        7
        \number\symmtoperatorfont\space
        \csname#2\string\u\endcsname{}\relax}%
      \expandafter\xdef\csname mst@bar@mv#1\mst@robustifyingspace\endcsname
       {\mst@Umathaccent
        7
        \number\symmtoperatorfont\space
        \csname#2\string\=\endcsname{}\relax}%
      \expandafter\xdef\csname mst@dot@mv#1\mst@robustifyingspace\endcsname
       {\mst@Umathaccent
        7
        \number\symmtoperatorfont\space
        \csname#2\string\.\endcsname{}\relax}%
      \expandafter\xdef\csname mst@ddot@mv#1\mst@robustifyingspace\endcsname
       {\mst@Umathaccent
        7
        \number\symmtoperatorfont\space
        \csname#2\string\"\endcsname{}\relax}%
      \expandafter\xdef\csname mst@mathring@mv#1\mst@robustifyingspace\endcsname
       {\mst@Umathaccent
        7
        \number\symmtoperatorfont\space
        \csname#2\string\r\endcsname{}\relax}%
      \expandafter\xdef\csname mst@hat@mv#1\mst@robustifyingspace\endcsname
       {\mst@Umathaccent
        7
        \number\symmtoperatorfont\space
        \csname#2\string\^\endcsname{}\relax}%
      \expandafter\xdef\csname mst@tilde@mv#1\mst@robustifyingspace\endcsname
       {\mst@Umathaccent
        7
        \number\symmtoperatorfont\space
        \csname#2\string\~\endcsname{}\relax}%
    \else
%    \end{macrocode}
% \mstrelease{1.3u} used some \cs{def} but this made the accent macro meanings look
% slightly different depending on whether the math version being set-up was
% with an 8bit encoding or TU encoding.
%
% For the sake of uniform treatment we modify this at \mstrelease{1.3v}, but this is a
% bit complicated regarding timing: we need, in absence of |unimathaccents|
% option, in math versions with an OpenType font, to let the \cs{acute} etc...
% acquire back some prior non-\mst meanings. To allow maximal flexibility,
% these original meaning get stored at begin document only. But
% \cs{mst@nonsubduedmathaccents} assigns to \cs{acute} etc... (in the robust
% sense with \LaTeX{} |2019-10-01| or later) the meaning stored in the macros
% with the math version in their names. Such \cs{mst@acute@mvnormal} etc...
% must thus be ready before \cs{mst@nonsubduedmathaccents} (or at least before
% the last such) execution: the code here must get executed after the
% definition of the «original»-named macros but prior to the (last one, if
% multiple) \cs{mst@nonsubduedmathaccents}.
%
% Hence \mstrelease{1.3v} delayed a bit the initial execution of this macro (see further
% down in the code) compared to what happened in \mstrelease{1.3u}.
%
% We are in a group but \cs{AtEndOfPackage} does the right thing.
%    \begin{macrocode}
      \AtEndOfPackage{\AtBeginDocument{%
      \@tfor\@tempa:={grave}{acute}{check}{breve}{bar}%
                     {dot}{ddot}{mathring}{hat}{tilde}%
      \do
      {\expandafter\let
          \csname mst@\@tempa @mv#1\expandafter\endcsname
          \csname mst@original@\@tempa\endcsname
       \expandafter\let
          \csname mst@\@tempa @mv#1\space\expandafter\endcsname
          \csname mst@original@\@tempa\space\endcsname}%
      }}%
    \fi
%    \end{macrocode}
% This is needed because the pdflatex engine branch will use
% \cs{DeclareMathAccent} and it creates robust macros with \LaTeX{}
% |2019-10-01| or later. As we want elsewhere in the package code not to have
% to check if under Unicode engine or not, we need to handle here also some
% definition of robust macros.
%
% But wouldn't it be simpler to manage \cs{protected} macros?
%    \begin{macrocode}
      \@tfor\@tempa:={grave}{acute}{check}{breve}{bar}%
                     {dot}{ddot}{mathring}{hat}{tilde}%
      \do
      {\expandafter\xdef\csname mst@\@tempa @mv#1\endcsname
         {\noexpand\protect
          \expandafter\noexpand\csname mst@\@tempa @mv#1 \endcsname}%
      }%
  \else
%    \end{macrocode}
% \cs{DeclareMathAccent} works \cs{global}ly. And with \LaTeX{} |2019-10-01|
% or later it creates robust macros.
%
% \cs{mst@DeclareMathAccent} to work around \url{https://github.com/latex3/latex2e/issues/216}
%    \begin{macrocode}
    \expandafter\mst@DeclareMathAccent\expandafter
               {\csname mst@grave@mv#1\endcsname}{\mathalpha}{mtoperatorfont}%
               {\csname#2\string\`\endcsname{}}
    \expandafter\mst@DeclareMathAccent\expandafter
               {\csname mst@acute@mv#1\endcsname}{\mathalpha}{mtoperatorfont}%
               {\csname#2\string\'\endcsname{}}
    \expandafter\mst@DeclareMathAccent\expandafter
               {\csname mst@check@mv#1\endcsname}{\mathalpha}{mtoperatorfont}%
               {\csname#2\string\v\endcsname{}}
    \expandafter\mst@DeclareMathAccent\expandafter
               {\csname mst@breve@mv#1\endcsname}{\mathalpha}{mtoperatorfont}%
               {\csname#2\string\u\endcsname{}}
    \expandafter\mst@DeclareMathAccent\expandafter
               {\csname mst@bar@mv#1\endcsname}{\mathalpha}{mtoperatorfont}%
               {\csname#2\string\=\endcsname{}}
    \expandafter\mst@DeclareMathAccent\expandafter
               {\csname mst@dot@mv#1\endcsname}{\mathalpha}{mtoperatorfont}%
               {\csname#2\string\.\endcsname{}}
    \expandafter\mst@DeclareMathAccent\expandafter
               {\csname mst@ddot@mv#1\endcsname}{\mathalpha}{mtoperatorfont}%
               {\csname#2\string\"\endcsname{}}
    \expandafter\mst@DeclareMathAccent\expandafter
               {\csname mst@mathring@mv#1\endcsname}{\mathalpha}{mtoperatorfont}%
               {\csname#2\string\r\endcsname{}}
    \expandafter\mst@DeclareMathAccent\expandafter
               {\csname mst@hat@mv#1\endcsname}{\mathalpha}{mtoperatorfont}%
               {\csname#2\string\^\endcsname{}}
    \expandafter\mst@DeclareMathAccent\expandafter
               {\csname mst@tilde@mv#1\endcsname}{\mathalpha}{mtoperatorfont}%
               {\csname#2\string\~\endcsname{}}
  \fi
  \endgroup
}%
\fi
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\MTDeclareVersion}
%   The \cs{MTDeclareVersion} command is to be used in the preamble
%   to declare a math version. A more complicated variant would also
%   specify a choice of series for the Euler and Symbol font: anyhow
%   Symbol only has the medium series, and Euler has medium and bold,
%   so what is lacking is the possibility to create a version with a
%   bold Euler. There is already one such version: the default |bold|
%   one. And there is always the possibility to add to the preamble
%   \cs{SetSymbolFont}|{mteulervm}||{versionname}||{U}{zeur}{bx}{n}| if
%   one wants to have a math version with bold Euler characters.
%
%   For version \mstrelease{1.1} we add an optional parameter specifying the shape
%   to be used for letters.
%
%   Note: (|2012/10/24|) I really should check whether the user attempts to
%   redefine the `normal' and `bold' versions and issue a warning in
%   that case! Finally done at  \mstrelease{1.3w} |2019/11/16|! Better late than never...
%
%   \mstrelease{1.3c} (|2013/12/14|) adds an extra optional parameter after all
%   previous ones, to inherit the settings from another version. Typically
%   to be used with [bold]. I take this opportunity to sanitize a bit some
%   line endings to avoid generating (in the preamble, document macros were
%   already careful of course) too many space
%   tokens, at least inside macros. And I modifiy (correct? perhaps it was on
%   purpose) the strange way I used |\@onlypreamble| in earlier
%   version.
%
%   \mstrelease{1.3u} adds storage of macros holding the needed meanings for
%   \cs{imath}, \cs{hbar}, math accents, and the minus symbol,
%   version wise.
%
%   \mstrelease{1.3w} adds the check to forbid |normal| and |bold| as version names.
%    \begin{macrocode}
\newcommand*\MTDeclareVersion[6][]{%
  \edef\mst@declareversionargs{{#1}{#2}{#3}{#4}{#5}{#6}}%
  \edef\mst@version{#2}%
  \if0\ifx\mst@version\mst@normalversionname0\else
      \ifx\mst@version\mst@boldversionname0\else
      1\fi\fi
   \expandafter\expandafter\expandafter
   \MTDoNotDeclareVersion@\expandafter\@gobblefour
  \fi
  \relax\DeclareMathVersion{\mst@version}\MTDeclareVersion@
}%
\newcommand*\MTDoNotDeclareVersion@[1][]{%
   \PackageWarningNoLine{mathastext}{You asked to declare a version with name
   `\mst@version'.^^J%
   \@spaces Sorry but you are not allowed to do that.^^J%
   \@spaces \ifmst@subdued Anyway the `subdued' option is in force\else
         Use rather \string\Mathastext\space macro (with no optional argument)\fi
}}%
\newcommand*\MTDeclareVersion@[1][]{%
    \edef\mst@tmp{#1}%
    \ifx\mst@tmp\empty\else
      \global\expandafter\let\csname mv@\mst@version\expandafter\endcsname
                             \csname mv@#1\endcsname
      \PackageInfo{mathastext}
                  {Math version `\mst@version\string'\MessageBreak
                   declared\on@line\MessageBreak
                   inherits from `#1\string'\@gobble}%
    \fi
    \expandafter\MTDeclareVersion@@\mst@declareversionargs
}%
\newcommand*\MTDeclareVersion@@[6]{%
  \expandafter\edef\csname mst@encoding@\mst@version\endcsname{#3}%
  \expandafter\edef\csname mst@family@\mst@version\endcsname{#4}%
  \expandafter\edef\csname mst@series@\mst@version\endcsname{#5}%
  \expandafter\edef\csname mst@shape@\mst@version\endcsname{#6}%
  \expandafter\edef\csname mst@boldvariant@\mst@version\endcsname{\mst@bold}%
  \expandafter\edef\csname mst@itdefault@\mst@version\endcsname{\itdefault}%
  \expandafter\edef\csname mst@rmdefault@\mst@version\endcsname{\rmdefault}%
  \expandafter\edef\csname mst@sfdefault@\mst@version\endcsname{\sfdefault}%
  \expandafter\edef\csname mst@ttdefault@\mst@version\endcsname{\ttdefault}%
  \expandafter\edef\csname mst@exists@skip@\mst@version\endcsname
        {\mst@exists@skip}%
  \expandafter\edef\csname mst@forall@skip@\mst@version\endcsname
        {\mst@forall@skip}%
  \expandafter\edef\csname mst@prime@skip@\mst@version\endcsname
        {\mst@prime@skip}%
  \def\mst@tmp{#1}%
  \ifx\mst@tmp\empty
    \ifmst@italic
      \SetSymbolFont{mtletterfont}{#2}{#3}{#4}{#5}{\mst@ltsh}%
      \immediate\write\m@ne{}%
      \PackageInfo{mathastext}%
                        {\ifmst@noletters
                         \else
                         Latin letters in math version `#2\string'\MessageBreak
                         declared\on@line\MessageBreak
                         will use the font #3/#4/#5/\mst@ltsh
                         \ifmst@frenchmath\space(uppercase: #6)\fi\MessageBreak
                         \fi
                         Other characters (digits, ...) and \protect\log-like names\MessageBreak 
                         \ifmst@noletters
                         will use the font #3/#4/#5/#6%
                         \else
                         will be in `#6\string' shape%
                         \fi\@gobble}%
      \immediate\write\m@ne{}%
      \expandafter\edef\csname mst@ltshape@\mst@version\endcsname{\mst@ltsh}%
    \else
      \SetSymbolFont{mtletterfont}{#2}{#3}{#4}{#5}{#6}%
      \ifmst@noletters
      \else
      \immediate\write\m@ne{}%
      \PackageInfo{mathastext}%
                        {Latin letters in math version `#2\string'\MessageBreak
                         declared\on@line\MessageBreak
                         will use the fonts #3/#4/#5(\mst@bold)/#6\@gobble}%
      \fi
      \immediate\write\m@ne{}%
      \expandafter\edef\csname mst@ltshape@\mst@version\endcsname{#6}%
    \fi
  \else
%    \end{macrocode}
% |#1| not empty.
%    \begin{macrocode}
    \SetSymbolFont{mtletterfont}{#2}{#3}{#4}{#5}{#1}%
    \immediate\write\m@ne{}%
    \PackageInfo{mathastext}%
                        {\ifmst@noletters
                         \else
                         Latin letters in math version `#2\string'\MessageBreak
                         declared\on@line\MessageBreak
                         will use the font #3/#4/#5/#1%
                         \ifmst@frenchmath\space(uppercase: #6)\fi\MessageBreak
                         \fi
                         Other characters (digits, ...) and
                         \protect\log-like names\MessageBreak
                         \ifmst@noletters
                         will use the font #3/#4/#5/#6%
                         \else
                         will be in `#6\string' shape%
                         \fi\@gobble}%
    \immediate\write\m@ne{}%
    \expandafter\edef\csname mst@ltshape@\mst@version\endcsname{#1}%
  \fi
%    \end{macrocode}
% Here and elsewhere \mstrelease{1.3za} has removed an
% \cs{ifmst@nonormalbold} conditional.
%    \begin{macrocode}
       \SetMathAlphabet{\Mathnormalbold}{#2}{#3}{#4}{\mst@bold}%
                   {\csname mst@ltshape@\mst@version\endcsname}%
  \SetSymbolFont{mtoperatorfont}{#2}{#3}{#4}{#5}{#6}%
%    \end{macrocode}
% Since \mstrelease{1.3za} (and prior to \mstrelease{1.15f}) these math alphabet
% commands are always defined.
%    \begin{macrocode}
  \SetMathAlphabet{\Mathbf}{#2}{#3}{#4}{\mst@bold}{#6}
  \SetMathAlphabet{\Mathit}{#2}{#3}{#4}{#5}{\itdefault}
  \SetMathAlphabet{\Mathsf}{#2}{#3}{\sfdefault}{#5}{#6}
  \SetMathAlphabet{\Mathtt}{#2}{#3}{\ttdefault}{#5}{#6}
  \ifmst@needeuler
      \SetMathAlphabet{\MathEulerBold}{#2}{U}{zeur}{\mst@bold}{n}%
  \fi
%    \end{macrocode}
% \begin{macro}{LGRgreeks}
% \begin{macro}{selfGreeks}
%   In the case of option LGRgreeks (selfGreeks), it is expected that
%   the fonts used in each math versions exist in LGR (OT1) encoding. We
%   first recalculate the shapes to be used for lowercase and uppercase
%   Greek letters depending on the frenchmath and [it/up][g/G]reek
%   options as well as on the (local to this version) shapes for letters
%   and digits.
%
%   \mstrelease{1.3y} replaces \cs{updefault} by \cs{MTgreekupdefault} and
%   \cs{itdefault} by \cs{MTgreekitdefault}.  It also prepares to store
%   two Boolean settings saying whether lowercase respectively uppercase
%   Greek letters will use `upright' or `italic' (|LGRgreek(s)| only).
%
%   The \mstrelease{1.3y} refactoring of |LGRgreek| is done via a decoupling,
%   thus things are done here under |selfGreek| or other Greek options
%   which ultimately serve nothing and conversely things are done here
%   for |LGRgreek| which are superfluous.
%    \begin{macrocode}
  \def\mst@greek@lsh@loc{\csname mst@ltshape@\mst@version\endcsname}%
  \def\mst@greek@ush@loc{\csname mst@shape@\mst@version\endcsname}%
  \mst@greek@lower@uptrue
      \expandafter\in@\expanded{{\mst@greek@lsh@loc.}}{it.,sl.}%
      \ifin@\mst@greek@lower@upfalse\fi
  \mst@greek@upper@uptrue
      \expandafter\in@\expanded{{\mst@greek@ush@loc.}}{it.,sl.}%
      \ifin@\mst@greek@upper@upfalse\fi
  \ifmst@itgreek
    \def\mst@greek@lsh@loc{\MTgreekitdefault}%
    \def\mst@greek@ush@loc{\MTgreekitdefault}%
      \mst@greek@lower@upfalse
      \mst@greek@upper@upfalse
  \fi
  \ifmst@upgreek
    \def\mst@greek@lsh@loc{\MTgreekupdefault}%
    \def\mst@greek@ush@loc{\MTgreekupdefault}%
      \mst@greek@lower@uptrue
      \mst@greek@upper@uptrue
  \fi
  \ifmst@frenchmath
      \ifmst@itgreek\else
      \ifmst@upgreek\else
        \def\mst@greek@lsh@loc{\csname mst@shape@\mst@version\endcsname}%
        \def\mst@greek@ush@loc{\csname mst@shape@\mst@version\endcsname}%
        \mst@greek@lower@uptrue
        \mst@greek@upper@uptrue
      \fi\fi
  \fi
  \ifcase\mst@greek@select
        \or
          \def\mst@greek@ush@loc{\MTgreekitdefault}%
          \mst@greek@upper@upfalse
        \or
          \def\mst@greek@ush@loc{\MTgreekupdefault}%
          \mst@greek@upper@uptrue
  \fi
%    \end{macrocode}
% \mstrelease{1.3za} refactoring to reduce code duplication; I briefly considered
% trying to enhance \cs{MTgreekfont} to work also with |LGRgreeks| and
% |selfGreeks| but I have dropped the idea for now.
%    \begin{macrocode}
    \ifmst@LGRgreeks \def\mst@greekfont{#4}\fi
    \ifmst@selfGreeks\def\mst@greekfont{#4}\fi
    \ifmst@LGRgreek 
      \SetSymbolFont{mtgreekup}{#2}{LGR}{\mst@greekfont}{#5}{\MTgreekupdefault}%
      \SetSymbolFont{mtgreekit}{#2}{LGR}{\mst@greekfont}{#5}{\MTgreekitdefault}%
      \SetMathAlphabet{\mathgreekupbold}{#2}{LGR}{\mst@greekfont}
                                                 {\mst@bold}{\MTgreekupdefault}%
      \SetMathAlphabet{\mathgreekitbold}{#2}{LGR}{\mst@greekfont}
                                                 {\mst@bold}{\MTgreekitdefault}%
%    \end{macrocode}
%  This is where the shape of uppercase/lowercase Greek letters is recorded,
%  for \cs{MTversion}'s triggered \cs{MTcustomgreek} to do the right thing.
%    \begin{macrocode}
      \expandafter\let\csname ifmst@greek@\mst@version @upper@up\expandafter\endcsname
                      \csname ifmst@greek@upper@up\endcsname
      \expandafter\let\csname ifmst@greek@\mst@version @lower@up\expandafter\endcsname
                      \csname ifmst@greek@lower@up\endcsname
\immediate\write\m@ne{}%
\PackageInfo{mathastext}{Greek letters (upper:
      `\ifmst@greek@upper@up\MTgreekupdefault\else\MTgreekitdefault\fi\string',
                                 lower:
      `\ifmst@greek@lower@up\MTgreekupdefault\else\MTgreekitdefault\fi\string')\MessageBreak
                         will use font family `\mst@greekfont\string' (LGR)\MessageBreak
                         in mathastext
                         math version `\mst@version\string'\MessageBreak
                         declared}%
\immediate\write\m@ne{}%
    \else
     \ifmst@selfGreek
       \SetSymbolFont{mtselfGreekfont}{#2}{OT1}{\mst@greekfont}{#5}{\mst@greek@ush@loc}%
\immediate\write\m@ne{}%
\PackageInfo{mathastext}{Capital Greek letters (shape `\mst@greek@ush@loc\string'
                           will use the font\MessageBreak
                         family `\mst@greekfont\string' (OT1) in mathastext\MessageBreak
                         math version `\mst@version\string' declared}%
\immediate\write\m@ne{}%
     \fi
    \fi
  \edef\mst@tmp{\expandafter\noexpand\csname mst@hbar@mv#2\endcsname
                \expandafter\noexpand\csname mst@ltbar@mv#2\endcsname}%
  \expandafter\mst@dothe@hbarstuff\mst@tmp{#3}%
  \edef\mst@tmp{\expandafter\noexpand\csname mst@inodot@mv#2\endcsname
                \expandafter\noexpand\csname mst@jnodot@mv#2\endcsname}%
  \expandafter\mst@dothe@inodotstuff\mst@tmp{#3}%
  \ifmst@mathaccents
    \mst@dothe@mathaccentsstuff{#2}{#3}%
  \fi
  \edef\mst@tmp{\expandafter\noexpand\csname mst@minus@mv#2\endcsname
                \expandafter\noexpand\csname mst@varfam@minus@mv#2\endcsname}%
  \ifmst@endash
    \expandafter\mst@dothe@endashstuff\mst@tmp{#3}%
  \else
    \ifmst@emdash
      \expandafter\mst@dothe@emdashstuff\mst@tmp{#3}%
    \else
      \expandafter\mst@dothe@hyphenstuff\mst@tmp
    \fi
  \fi
}%
\let\MathastextDeclareVersion\MTDeclareVersion
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{\MTversion}
% \begin{macro}{\MTversion@}
% \begin{macro}{\MTversion@s}
% \begin{macro}{\MTversion@@}
%   This is a wrapper around \LaTeX{}'s \cs{mathversion}: here we have an
%   optional argument allowing a quick and easy change of the text fonts
%   additionally to the math fonts. Present already in the initial
%   version of the package (January 2011.)
%  
%   \mstrelease{1.15}: some modifications for the subdued option vs LGRgreek and
%   for the math muskips after \cs{exists} and \cs{forall}.
%
%   \mstrelease{1.2}: with the subdued option sets the math alphabets in the
%   normal and bold math versions do not apply to operator
%   names and non-alphabetical symbols. The switch for braces
%   is left as it is.
%
%   \mstrelease{1.2b}: with the subdued option, the italic corrections are not added.
%   Else, we check the shape of letters in this version. Also, there was a bug
%   since \mstrelease{1.15}: the values of the math skips were taken not from the
%   settings for the math version (\#2) but from those of the optional argument
%   (\#1), if present...
%
%   \mstrelease{1.3}: activation of italic corrections is now separated from actual math
%   activation of letters.
%
%   \mstrelease{1.3c}: a starred variant is added which does not modify the text fonts,
%   only the math set-tup.
%
%   \mstrelease{1.3d}: replaced in |\MTversion@| things like |\edef\mst@encoding{...}| and
%   \centeredline{|\renewcommand{\encodingdefault}{\mst@@encoding}|} by
%   |\edef\encodingdefault{...}| etc\dots All those |\mst@@...| things were
%   useless. I also redefine |\seriesdefault| rather than |\mddefault|.
%
%   \mstrelease{1.3d}: mechanism of restoration of Greek in subdued normal and bold
%   versions has been to all cases, and not only for the
%   |LGRgreek| option.
%
%   \mstrelease{1.3u}: version savvy (i.e.\@ font-encoding savvy) minus sign,
%   \cs{hbar}, \cs{imath}, math accents.
%
%   \mstrelease{1.3y}: Booleans recovered from stored data in the math version will
%   configure the things \cs{MTcustomgreek} do, under |LGRgreek| option.
%    \begin{macrocode}
\newcommand*\MTversion {\@ifstar\MTversion@s\MTversion@}
\newcommand*\MTversion@s [1]{\mathversion{#1}\MTversion@@}
\newcommand*\MTversion@ [2][]{%
%    \end{macrocode}
% This defines \cs{math@version} as expanded |#2|.
%    \begin{macrocode}
    \mathversion{#2}%
    \edef\mst@tmpa{#1}%
    \ifx\mst@tmpa\empty
        \let\mst@tmp\math@version
    \else
        \let\mst@tmp\mst@tmpa
    \fi
    \edef\encodingdefault {\csname mst@encoding@\mst@tmp\endcsname}%
    \edef\familydefault   {\csname mst@family@\mst@tmp\endcsname}%
    \edef\seriesdefault   {\csname mst@series@\mst@tmp\endcsname}%        
    \edef\shapedefault    {\csname mst@shape@\mst@tmp\endcsname}%
    \edef\bfdefault {\csname mst@boldvariant@\mst@tmp\endcsname}%
    \edef\itdefault {\csname mst@itdefault@\mst@tmp\endcsname}%
    \edef\rmdefault {\csname mst@rmdefault@\mst@tmp\endcsname}%
    \edef\sfdefault {\csname mst@sfdefault@\mst@tmp\endcsname}%
    \edef\ttdefault {\csname mst@ttdefault@\mst@tmp\endcsname}%
    \usefont{\encodingdefault}{\familydefault}{\seriesdefault}{\shapedefault}%
    \MTversion@@
}%
%    \end{macrocode}
%   \mstrelease{1.3j} has a stronger subdued which does \cs{MTnormalprime},
%   \cs{MTnormalexists}, \cs{MTnormalforall} rather than setting the skips to
%   |0mu|. Hence \cs{MTversion} by default should do \cs{MTprimedoesskip},
%   \cs{MTexistsdoesskip}, \cs{MTforalldoesskip}.
%
%   \mstrelease{1.3u} drops the argument, as the info is in \cs{math@version} from
%   \LaTeX2e code.
%    \begin{macrocode}
\newcommand*\MTversion@@ {%
    \MTexistsdoesskip
    \MTforalldoesskip
    \MTprimedoesskip
%    \end{macrocode}
% |v1.15e|: muskips.
%    \begin{macrocode}
     \mst@exists@muskip\csname mst@exists@skip@\math@version\endcsname\relax
     \mst@forall@muskip\csname mst@forall@skip@\math@version\endcsname\relax
%    \end{macrocode}
% |v1.2|: muskip for \cs{prime}.
%    \begin{macrocode}
     \mst@prime@muskip\csname mst@prime@skip@\math@version\endcsname\relax
%    \end{macrocode}
% |v1.2b|: italic corrections except for italic/slanted (sic) letters, and of
% course except in the subdued normal and bold math versions.
%
% |v1.3|: by default, letters are made mathematically active, even if italic
% corrections are not used, to allow the action of \cs{MTsetmathskips}.
%    \begin{macrocode}
    \edef\mst@tmpa{\csname mst@ltshape@\math@version\endcsname}%
    \edef\mst@tmpb{\csname mst@shape@\math@version\endcsname}%
%    \end{macrocode}
% \mstrelease{1.15c}: extending subdued to LGRgreek.
%
% \mstrelease{1.15f}: subdueing math alphabets in a simpler way than in \mstrelease{1.15e}.
%
% \mstrelease{1.2b}: subdueing the activation of characters in math mode.
%
% \mstrelease{1.2d}: special treatment of the asterisk.
%
% \mstrelease{1.3d}: extended LGRgreek mechanism of activation/restoration of Greek to all
% cases.
%
% \mstrelease{1.3j}: use of \cs{MTeverymathdefault}, which includes \cs{MTicinmath}, but
% must be corrected then according to shape of letters and presence or absence
% of option |frenchmath|. We do only |\def\mst@ITcorr{\ifnum\fam=\m@ne\/\fi}|
% and not \cs{MTICinmath} to not overwrite some user-defined
% \cs{MTeverymathdefault}. Code for italic corrections or not according to
% letter shape is executed after \cs{MTeverymathdefault} which limits a bit
% user customizing possibilities, but if I moved it later, I would possibly
% have to put inside the \cs{MTicinmath} the check for |it| ot |sl|. Similary
% the \cs{MTcustomgreek} always executed (if not |subdued|).
%
% MEMO: \cs{MTeverymathdefault} is executed \emph{also} if in |subdued| mode
% but there is a \cs{MTeverymathoff} done next in the \emph{normal} and
% \emph{bold} version.  It does \cs{MTicinmath} and \cs{MTmathactivedigits}
% which however are no-ops (only partly for the former, and for the latter
% always anyhow if no option |activedigits|) in subdude mode.
%    \begin{macrocode}
    \MTmathoperatorsobeymathxx
    \MTeverymathdefault
    \MTcustomizenewmcodes       
    \@for\mst@tmpc:=it,sl\do{\ifx\mst@tmpc\mst@tmpa\MTnoicinmath\fi}%
    \ifmst@frenchmath
      \def\mst@ITcorr{\ifnum\fam=\m@ne\/\fi}%
      \@for\mst@tmpc:=it,sl\do{\ifx\mst@tmpc\mst@tmpb\MTnoICinmath\fi}%
    \fi
%    \end{macrocode}
% \mstrelease{1.3j} has a stronger subdued which does \cs{MTnormalprime},
% \cs{MTnormalexists}, \cs{MTnormalforall} rather than simply setting the
% skips to |0mu|. Note: \cs{MTnormalprime} is done as part of
% \cs{MTeverymathoff}.
%
% The |subdued| mode does \emph{not} undo the effect of the |frenchmath|
% option on uppercase
% Latin letters: they will use the same shape as digits and operator names!
% (This should have been made more prominent in user manual more than ten
% years ago, but is done only today |2023/12/28|...).
%    \begin{macrocode}
    \ifmst@subdued
      \ifx\math@version\mst@normalversionname
        \mst@restorealphabets
        \MTstandardgreek
        \MTmathoperatorsdonotobeymathxx
        \MTnormalexists
        \MTnormalforall
%    \end{macrocode}
% \mstrelease{1.4} has kept \cs{MTmathstandardletters} inside
% \cs{MTeverymathoff} but its action is now quite different from earlier
% situation as it resets mathcodes from active to normal status on the spot.
%    \begin{macrocode}
        \MTeverymathoff
        \MTresetnewmcodes
%    \end{macrocode}
% \mstrelease{1.3t} adds better compatibility with |subdued| mode for
% |\imath/\jmath| and perfect compatibility for the minus sign.
%
% \mstrelease{1.3u} extends this further to allow per-math-version meanings
% for them.
%    \begin{macrocode}
        \mst@subduedhbar
        \mst@subduedinodot
        \mst@subduedmathaccents
        \mst@subduedminus
      \else
        \ifx\math@version\mst@boldversionname
          \mst@restorealphabets
          \MTstandardgreek
          \MTmathoperatorsdonotobeymathxx
          \MTnormalexists
          \MTnormalforall
          \MTeverymathoff
          \MTresetnewmcodes
          \mst@subduedhbar
          \mst@subduedinodot
          \mst@subduedmathaccents
          \mst@subduedminus
        \else
          \mst@setalphabets
%    \end{macrocode}
% \mstrelease{1.3y} addition for \cs{MTcustomgreek} under |LGRgreeks| option.
%
% MEMO: the needed mathematical re-activation of letters when switching from
% \emph{normal} or \emph{bold} to a non-|subdued| math version has already
% been done above from the \cs{MTicinmath} which is part of
% \cs{MTeverymathdefault}.
%
% MEMO: idem for digits under option |activedigits|.
%    \begin{macrocode}
    \expandafter\let\csname ifmst@greek@upper@up\expandafter\endcsname
                    \csname ifmst@greek@\math@version @upper@up\endcsname
    \expandafter\let\csname ifmst@greek@lower@up\expandafter\endcsname
                    \csname ifmst@greek@\math@version @lower@up\endcsname
          \MTcustomgreek
          \mst@nonsubduedhbar
          \mst@nonsubduedinodot
          \mst@nonsubduedmathaccents
          \mst@nonsubduedminus
        \fi
      \fi
    \else
%    \end{macrocode}
% \mstrelease{1.3y} addition for \cs{MTcustomgreek} under |LGRgreek| option.
%
% MEMO: the mathematical activation of letters happened above from
% \cs{MTeverymathdefault}.  Idem if |activedigits| for digits.
%    \begin{macrocode}
    \expandafter\let\csname ifmst@greek@upper@up\expandafter\endcsname
                    \csname ifmst@greek@\math@version @upper@up\endcsname
    \expandafter\let\csname ifmst@greek@lower@up\expandafter\endcsname
                    \csname ifmst@greek@\math@version @lower@up\endcsname
      \MTcustomgreek
      \mst@nonsubduedhbar
      \mst@nonsubduedinodot
      \mst@nonsubduedmathaccents
      \mst@nonsubduedminus
    \fi
}%
\let\MathastextVersion\MTversion
\let\Mathastextversion\MTversion
\let\MTVersion\MTversion
\let\mathastextversion\MTversion
%    \end{macrocode}
% \end{macro}\end{macro}\end{macro}\end{macro}
% \begin{macro}{\MTWillUse}
% This is a preamble-only command, which can be used more than once, only the
% latest one counts. Sets up the math fonts in the normal and bold
% versions, as does \cs{Mathastext}.
%    \begin{macrocode}
\newcommand*\MTWillUse[5][]{
  \MTencoding{#2}
  \MTfamily{#3}
  \MTseries{#4}
  \MTshape{#5}
    \ifmst@italic\MTlettershape{\itdefault}\fi
  \edef\mst@tmp{#1}
  \ifx\mst@tmp\empty\else\MTlettershape{#1}\fi
  \Mathastext}
\let\MathastextWillUse\MTWillUse
\let\Mathastextwilluse\MTWillUse
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\Mathastext}
%    The command \cs{Mathastext} can be used anywhere in the
%    preamble and any number of time, the last one is the
%    one that counts.
%
%    In version \mstrelease{1.1} we have two fonts: they only differ in
%    shape. The |mtletterfont| is for letters, and the
%    |mtoperatorfont| for digits and log-like operator
%    names. The default is that both are upright.
%
%    Starting with version \mstrelease{1.12}, an optional argument makes
%    \cs{Mathastext} act as the declaration of a math
%    version, to be later used in the document.
%
%    Versions \mstrelease{1.15x} brought some adaptations related to the subdued
%    option.
%
%    \mstrelease{1.3c} adds a second optional parameter to inherit previous settings
%    from another version; mostly done to inherit the bold version fonts for
%    symbols and large symbols. This is done in |\MTDeclareVersion|.
%
%    \mstrelease{1.3j} moves the code related to \cs{MTicinmath} from \cs{Mathastext@} to
%    \cs{AtBeginDocument} (code depending on whether |subdued| option in use).
%    But we omit for this from \cs{MTicinmath} the \cs{MTmathactiveletters}
%    and issue the latter during loading of package, hence allowing
%    \cs{MTmathstandardletters} to be effective in the preamble.
%
%    I forgot to document that under |subdued| option the \cs{Mathastext}
%    command without optional parameter does not any |\SetSymbolFont| etc...
%    but it has a few other tasks to complete nevertheless.
%
% \mstrelease{1.3u} fixes some long-standing bug that \cs{Mathastext} did not repeat some
% font-encoding dependent things: they got done only once during package
% loading (things regarding the \cs{hbar}, \cs{imath}, the math accents and
% the minus sign). They are now part of the contents of \cs{Mathastext} macro
% itself (which is executed during package loading).
%
% \mstrelease{1.3y} has refactored the |LGRgreek| associated math fonts.
%    \begin{macrocode}
\def\Mathastext {\@ifnextchar[\Mathastext@declare\Mathastext@}% ]
\def\Mathastext@declare [#1]{%
  \edef\mst@tmp{#1}%
  \ifx\mst@tmp\empty
       \expandafter\@firstoftwo
  \else\expandafter\@secondoftwo
  \fi
  \Mathastext@
  {\MTDeclareVersion[\mst@ltsh]{#1}{\mst@enc}{\mst@fam}{\mst@ser}{\mst@opsh}}%
}%
\def\Mathastext@ {%
  \mst@update@greeksh 
  \edef\mst@encoding@normal{\mst@enc}%
  \edef\mst@family@normal{\mst@fam}%
  \edef\mst@series@normal{\mst@ser}%
  \edef\mst@shape@normal{\mst@opsh}%
  \edef\mst@ltshape@normal{\mst@ltsh}%
  \edef\mst@itdefault@normal{\itdefault}%
  \edef\mst@rmdefault@normal{\rmdefault}%
  \edef\mst@sfdefault@normal{\sfdefault}%
  \edef\mst@ttdefault@normal{\ttdefault}%
  \edef\mst@boldvariant@normal{\mst@bold}%
  \edef\mst@exists@skip@normal{\mst@exists@skip}%
  \edef\mst@forall@skip@normal{\mst@forall@skip}%
  \edef\mst@prime@skip@normal{\mst@prime@skip}%
  \edef\mst@encoding@bold{\mst@enc}%
  \edef\mst@family@bold{\mst@fam}%
  \edef\mst@series@bold{\mst@bold}%
  \edef\mst@shape@bold{\mst@opsh}%
  \edef\mst@ltshape@bold{\mst@ltsh}%
  \edef\mst@boldvariant@bold{\mst@bold}%
  \edef\mst@itdefault@bold{\itdefault}%
  \edef\mst@rmdefault@bold{\rmdefault}%
  \edef\mst@sfdefault@bold{\sfdefault}%
  \edef\mst@ttdefault@bold{\ttdefault}%
  \edef\mst@exists@skip@bold{\mst@exists@skip}%
  \edef\mst@forall@skip@bold{\mst@forall@skip}%
  \edef\mst@prime@skip@bold{\mst@prime@skip}%
  \ifmst@subdued
%    \end{macrocode}
% Since \mstrelease{1.3j} this branch is actually almost superfluous, as entering
% |normal| or |bold| with \cs{MTversion} does \cs{MTnormalexists},
% \cs{MTnormalforall}, and \cs{MTnormalprime}. But some default values are
% needed if the user insists on issuing \cs{MTexistsdoesskip}, etc...
% nevertheless.
%    \begin{macrocode}
    \def\mst@exists@skip@normal{0mu}%
    \def\mst@forall@skip@normal{0mu}%
    \def\mst@prime@skip@normal{0mu}%
    \def\mst@exists@skip@bold{0mu}%
    \def\mst@forall@skip@bold{0mu}%
    \def\mst@prime@skip@bold{0mu}%
  \else
    \ifmst@italic
      \ifmst@frenchmath
        \mst@exists@muskip\mst@exists@skip\relax
        \mst@forall@muskip\mst@forall@skip\relax
        \mst@prime@muskip\mst@prime@skip\relax
      \else
       \def\mst@exists@skip@normal{0mu}%
       \def\mst@forall@skip@normal{0mu}%
       \def\mst@prime@skip@normal{0mu}%
       \def\mst@exists@skip@bold{0mu}%
       \def\mst@forall@skip@bold{0mu}%
       \def\mst@prime@skip@bold{0mu}%
      \fi
    \else
        \mst@exists@muskip\mst@exists@skip\relax
        \mst@forall@muskip\mst@forall@skip\relax
        \mst@prime@muskip\mst@prime@skip\relax
    \fi
  \fi
%    \end{macrocode}
% Here and elsewhere \mstrelease{1.3za} has removed usage of an
% \cs{ifmst@nonormalbold} conditional which was added at \mstrelease{1.15f}.
%    \begin{macrocode}
   \SetMathAlphabet{\Mathnormalbold}{normal}{\mst@encoding@normal}%
                                 {\mst@family@normal}%
                                 {\mst@boldvariant@normal}%
                                 {\mst@ltshape@normal}%
   \SetMathAlphabet{\Mathnormalbold}{bold}{\mst@encoding@bold}%
                                 {\mst@family@bold}%
                                 {\mst@boldvariant@bold}%
                                 {\mst@ltshape@bold}%
  \ifmst@subdued\else
   \SetSymbolFont{mtletterfont}{normal}{\mst@encoding@normal}%
                                       {\mst@family@normal}%
                                       {\mst@series@normal}%
                                       {\mst@ltshape@normal}%
   \SetSymbolFont{mtletterfont}{bold}  {\mst@encoding@bold}%
                                       {\mst@family@bold}%
                                       {\mst@series@bold}%
                                       {\mst@ltshape@bold}%
   \SetSymbolFont{mtoperatorfont}{normal}{\mst@encoding@normal}%
                                       {\mst@family@normal}%
                                       {\mst@series@normal}%
                                       {\mst@shape@normal}%
   \SetSymbolFont{mtoperatorfont}{bold} {\mst@encoding@bold}%
                                       {\mst@family@bold}%
                                       {\mst@series@bold}%
                                       {\mst@shape@bold}%
%    \end{macrocode}
% \mstrelease{1.3za} removes the \mstrelease{1.15f} added conditional checks.
%    \begin{macrocode}
    \SetMathAlphabet{\Mathbf}{normal}{\mst@encoding@normal}%
                                 {\mst@family@normal}%
                                 {\mst@series@bold}%
                                 {\mst@shape@normal}%
    \SetMathAlphabet{\Mathbf}{bold}{\mst@encoding@bold}%
                                 {\mst@family@bold}%
                                 {\mst@series@bold}%
                                 {\mst@shape@bold}%
    \SetMathAlphabet{\Mathit}{normal}{\mst@encoding@normal}%
                                 {\mst@family@normal}%
                                 {\mst@series@normal}%
                                 {\mst@itdefault@normal}%
    \SetMathAlphabet{\Mathit}{bold}{\mst@encoding@bold}%
                                 {\mst@family@bold}%
                                 {\mst@series@bold}%
                                 {\mst@itdefault@bold}%
    \SetMathAlphabet{\Mathsf}{normal}{\mst@encoding@normal}%
                                 {\mst@sfdefault@normal}%
                                 {\mst@series@normal}%
                                 {\mst@shape@normal}%
    \SetMathAlphabet{\Mathsf}{bold}{\mst@encoding@bold}%
                                 {\mst@sfdefault@bold}%
                                 {\mst@series@bold}%
                                 {\mst@shape@bold}%
    \SetMathAlphabet{\Mathtt}{normal}{\mst@encoding@normal}%
                                 {\mst@ttdefault@normal}%
                                 {\mst@series@normal}%
                                 {\mst@shape@normal}%
    \SetMathAlphabet{\Mathtt}{bold}{\mst@encoding@bold}%
                                 {\mst@ttdefault@bold}%
                                 {\mst@series@bold}%
                                 {\mst@shape@bold}%
  \fi
%    \end{macrocode}
% \begin{macro}{\MathEulerBold}
%   \mstrelease{1.14c}: We reset |mteulervm| and \cs{MathEulerBold} here as the
%   variant for bold may have been changed by the user via
%   \cs{Mathastextboldvariant}|{m}|; and we should keep this local to
%   math versions.
%    \begin{macrocode}
  \ifmst@needeuler
    \SetSymbolFont{mteulervm}{bold}{U}{zeur}{\mst@boldvariant@normal}{n}%
    \SetMathAlphabet{\MathEulerBold}{normal}%
               {U}{zeur}{\mst@boldvariant@normal}{n}%
    \SetMathAlphabet{\MathEulerBold}{bold}%
               {U}{zeur}{\mst@boldvariant@bold}{n}%
  \fi
%    \end{macrocode}
% \end{macro}
%    \begin{macrocode}
  \ifmst@needsymbol\SetSymbolFont{mtpsymbol}{bold}%
                     {U}{psy}{\mst@boldvariant@bold}{n}%
  \fi
%    \end{macrocode}
% \begin{macro}{LGRgreek*}
% \begin{macro}{selfGreek*}
% LGRgreek, LGRgreeks, selfGreek, and selfGreeks options.
%
% \mstrelease{1.3y} has refactored the |LGRgreek| associated math fonts.
%
% \mstrelease{1.3za} adds the math alphabets \cs{mathgreekitbold} and
% \cs{mathgreekupbold}.
% And it executes this code also in |subdued| mode, because
% anyhow the symbolfonts |mtgreekup| and |mtgreekit| and
% associated alphabets have been declared also, at time of
% loading the package, so not doing it here means that effect
% of \cs{MTgreekfont} would be ignored; which was probably
% a bug.  And by the way, documentation says \cs{MTgreekfont}
% has no effect under |LGRgreeks| and |selfGreeks| option
% so we need to enforce it here (for time being).
%    \begin{macrocode}
   \ifmst@LGRgreeks \edef\mst@greekfont{\mst@fam}\fi
   \ifmst@selfGreeks\edef\mst@greekfont{\mst@fam}\fi
   \ifmst@LGRgreek
    \SetSymbolFont{mtgreekup}{normal}{LGR}%
            {\mst@greekfont}{\mst@series@normal}{\MTgreekupdefault}%
    \SetSymbolFont{mtgreekup}{bold}{LGR}%
            {\mst@greekfont}{\mst@boldvariant@bold}{\MTgreekupdefault}%
    \SetSymbolFont{mtgreekit}{normal}{LGR}%
            {\mst@greekfont}{\mst@series@normal}{\MTgreekitdefault}%
    \SetSymbolFont{mtgreekit}{bold}{LGR}%
            {\mst@greekfont}{\mst@boldvariant@bold}{\MTgreekitdefault}%
    \SetMathAlphabet{\mathgreekupbold}{normal}{LGR}%
            {\mst@greekfont}{\mst@boldvariant@normal}{\MTgreekupdefault}%
    \SetMathAlphabet{\mathgreekupbold}{bold}{LGR}%
            {\mst@greekfont}{\mst@boldvariant@bold}{\MTgreekupdefault}%
    \SetMathAlphabet{\mathgreekitbold}{normal}{LGR}%
            {\mst@greekfont}{\mst@boldvariant@normal}{\MTgreekitdefault}%
    \SetMathAlphabet{\mathgreekitbold}{bold}{LGR}%
            {\mst@greekfont}{\mst@boldvariant@bold}{\MTgreekitdefault}%
   \else
    \ifmst@selfGreek
     \SetSymbolFont{mtselfGreekfont}{normal}{OT1}%
            {\mst@greekfont}{\mst@series@normal}{\mst@greek@ush}%
     \SetSymbolFont{mtselfGreekfont}{bold}{OT1}%
            {\mst@greekfont}{\mst@boldvariant@bold}{\mst@greek@ush}%
    \fi
   \fi
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \mstrelease{1.3za} adds the log message in case of |selfGreek| option.
%    \begin{macrocode}
  \ifmst@subdued
  \else 
   \mst@infoline{Latin letters in the `normal\string', resp. `bold\string',}%
   \mst@infoline{math versions are now set up to use the fonts}%
   \mst@infoline{\mst@encoding@normal/\mst@family@normal/\mst@series@normal
                 /\mst@ltshape@normal, resp.
                 \mst@encoding@normal/\mst@family@normal/\mst@boldvariant@normal
                 /\mst@ltshape@normal.}%
  \ifmst@frenchmath\mst@infoline{(uppercase: \mst@shape@normal)}\fi
  \ifmst@LGRgreek
   \mst@infoline{Greek letters (upper:
      `\ifmst@greek@upper@up\MTgreekupdefault\else\MTgreekitdefault\fi\string',
                                             lower:
      `\ifmst@greek@lower@up\MTgreekupdefault\else\MTgreekitdefault\fi\string')
      will use font}%
   \mst@infoline{family `\mst@greekfont\string' (LGR).}%
   \else
     \ifmst@selfGreek
       \mst@infoline{Capital Greek letters (shape `\mst@greek@ush\string') will use font}%
       \mst@infoline{family `\mst@greekfont\string' (OT1).}%
     \fi
   \fi
   \ifmst@nodigits\else
     \mst@infoline{Other characters (digits, ...) and \string\log-like names will be}%
     \mst@infoline{typeset with the \mst@shape@normal\space shape.}%
   \fi
  \fi
  \ifmst@nohbar\else
     \mst@infoline{\string\hbar}%
     \mst@dothe@hbarstuff
         \mst@hbar@mvnormal\mst@ltbar@mvnormal\mst@encoding@normal
     \let\mst@hbar@mvbold\mst@hbar@mvnormal
  \fi
  \mst@dothe@inodotstuff\inodot\jnodot\mst@encoding@normal
  \let\mst@inodot@mvnormal\inodot
  \let\mst@inodot@mvbold\inodot
  \let\mst@jnodot@mvnormal\jnodot
  \let\mst@jnodot@mvbold\jnodot
  \ifmst@mathaccents
    \mst@infoline{math accents}%
    \mst@dothe@mathaccentsstuff{normal}\mst@encoding@normal
  \fi
  \ifmst@nominus\else
   \mst@infoline{minus as endash}%
   \ifmst@endash
    \mst@dothe@endashstuff\mst@minus@mvnormal\mst@varfam@minus@mvnormal
                          \mst@encoding@normal
    \mst@dothe@endashstuff\mst@minus@mvbold\mst@varfam@minus@mvbold
                          \mst@encoding@normal
   \else
    \ifmst@emdash
      \mst@dothe@emdashstuff\mst@minus@mvnormal\mst@varfam@minus@mvnormal
                            \mst@encoding@normal
      \mst@dothe@emdashstuff\mst@minus@mvbold\mst@varfam@minus@mvbold
                            \mst@encoding@normal
    \else
      \mst@dothe@hyphenstuff\mst@minus@mvnormal\mst@varfam@minus@mvnormal
      \let\mst@minus@mvbold\mst@minus@mvnormal
      \let\mst@varfam@minus@mvbold\mst@varfam@minus@mvnormal
    \fi
   \fi
  \fi
%    \end{macrocode}
% \mstrelease{1.3zb} moves this info line last and also explicitly mentions |italic| or
% |frenchmath| (here and at some other locations above).
%    \begin{macrocode}
  \ifmst@subdued
    \mst@infoline{Subdued `normal\string' and `bold\string' math versions.}%
  \fi
  \ifmst@italic
    \mst@infoline{The \ifmst@frenchmath frenchmath \else
                                        italic \fi option is in effect.}%
  \fi
}%
\let\mathastext\Mathastext
\Mathastext
%    \end{macrocode}
% \end{macro}
% Additional appropriate messages to the terminal and the log.
%    \begin{macrocode}
\ifmst@eulergreek
      \mst@infoline{Greek letters will use the Euler font.}%
      \mst@infoline{Use \string\MathastextEulerScale{<factor>} to scale the
               font.}%
      \ifmst@subdued
          \mst@infoline{(subdued mode: `normal\string' and `bold\string' math versions}%
          \mst@infoline{\space keep the default Greek letters).}%
      \fi
\else
\ifmst@symbolgreek
       \mst@infoline{Greek letters will use the PostScript Symbol font.}%
       \mst@infoline{Use \string\MathastextSymbolScale{<factor>} to scale the font.}%
      \ifmst@subdued
          \mst@infoline{(subdued mode: `normal\string' and `bold\string' math versions}%
          \mst@infoline{\space keep the default Greek letters).}%
      \fi
\fi\fi
%    \end{macrocode}
% \begin{macro}{Math sizes}
% I took the code for \cs{Huge} and \cs{HUGE} from the \ctanpkg{moresize} package of
% Christian~\textsc{Cornelssen}
%    \begin{macrocode}
\ifmst@defaultsizes\else
\providecommand\@xxxpt{29.86}
\providecommand\@xxxvipt{35.83}
\ifmst@twelve  
  \def\Huge{\@setfontsize\Huge\@xxxpt{36}}
  \def\HUGE{\@setfontsize\HUGE\@xxxvipt{43}}
\mst@infoline{\string\Huge\space and \string\HUGE\space have been (re)-defined.}
\else 
  \def\HUGE{\@setfontsize\HUGE\@xxxpt{36}}
\mst@infoline{\string\HUGE\space has been (re)-defined.} 
\fi
%    \end{macrocode}
% I choose rather big subscripts.
%    \begin{macrocode}
\def\defaultscriptratio{.8333}
\def\defaultscriptscriptratio{.7}
\DeclareMathSizes{9}{9}{7}{5}
\DeclareMathSizes{\@xpt}{\@xpt}{8}{6}
\DeclareMathSizes{\@xipt}{\@xipt}{9}{7}
\DeclareMathSizes{\@xiipt}{\@xiipt}{10}{8}
\DeclareMathSizes{\@xivpt}{\@xivpt}{\@xiipt}{10}
\DeclareMathSizes{\@xviipt}{\@xviipt}{\@xivpt}{\@xiipt}
\DeclareMathSizes{\@xxpt}{\@xxpt}{\@xviipt}{\@xivpt}
\DeclareMathSizes{\@xxvpt}{\@xxvpt}{\@xxpt}{\@xviipt}
\DeclareMathSizes{\@xxxpt}{\@xxxpt}{\@xxvpt}{\@xxpt}
\DeclareMathSizes{\@xxxvipt}{\@xxxvipt}{\@xxxpt}{\@xxvpt}
\mst@infoline{mathastext has declared larger sizes for subscripts.}
\mst@infoline{To keep LaTeX defaults, use option `defaultmathsizes\string'.}
\fi
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\MTeverymathoff}
%   \mstrelease{1.3i} |2016/01/06| Compatibility patch with |\url| from |url.sty| and
%   |\url/\nolinkurl| from |hyperref.sty|.
%
%   \mstrelease{1.3j} |2016/01/15| renamed the macro from |\MTactivemathoff| to
%   |\MTeverymathoff|, as it is not exclusively a matter of math active
%   characters due to |\MTeasynonlettersdonotobeymathxx|.
%
%   \mstrelease{1.3o} |2016/05/03| adds \cs{MTdonotfixfonts}. Operant with
%   \LuaLaTeX\ only.
%
%   \mstrelease{1.4} |2024/07/20| keeps the \cs{MTmathstandardletters} as a
%   component of \cs{MTeverymathoff}.  It was checked that \ctanpkg{url} and
%   \ctanpkg{hyperref} do not change mathcodes of ascii letters prior to
%   location where \cs{MTeverymathoff} gets executed, so nothing is
%   overwritten, despite the new mode of action of \cs{MTmathstandardletters}.
%
% \mstrelease{1.4} has \cs{MTmathstandarddigits} and inserts it into \cs{MTeverymathoff}.
%    \begin{macrocode}
\newcommand*\MTeverymathoff {%
    \MTnormalasterisk
    \MTnormalprime
    \MTnonlettersdonotobeymathxx
    \MTeasynonlettersdonotobeymathxx
    \MTmathstandardletters
    \MTmathstandarddigits
    \MTdonotfixfonts
}%
\AtBeginDocument {%
   \@ifpackageloaded{hyperref}
   {\def\Hurl{\begingroup\MTeverymathoff\Url}}
   {\@ifpackageloaded{url}{\DeclareUrlCommand\url{\MTeverymathoff}}{}}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\MTeverymathdefault}
%   \mstrelease{1.3j} |2016/01/15| Customizable command which gets executed by
%   \cs{MTversion} except when switching to |normal/bold| if option |subdued|.
%   The included \cs{MTicinmath} does \cs{MTmathactiveletters} which will also
%   activate the math skips around letters.
%
%   The \cs{MTeverymathdefault} does not include
%   \cs{MTmathoperatorsobeymathxx} as the latter does not correspond to
%   something done during execution of |\the\everymath|.
%
%   Should I put  |\let\newmcodes@\mst@newmcodes@| here too ? No, it is not
%   done at everymath.
%
%   During the loading, the (non subdued) package does \cs{MTactiveasterisk}
%   (if option asterisk), \cs{MTprimedoesskip}, \cs{MTeasynonlettersobeymathxx}
%   and \cs{MTmathactiveletters}. There is some code at begin document for
%   decisions about italic corrections, this code does not emit again
%   \cs{MTmathactiveletters}, hence a \cs{MTmathstandardletters} in the
%   preamble is not overruled. Furthermore the at begin document code will not
%   overrule user emitted \cs{MTnoicinmath} etc... commands in the preamble.
%
%   And user can employ \cs{MTnormalexists}, etc..., from inside the preamble,
%   it will not be overruled (as it is delayed at begin document to after \mst
%   dealings).
%
%   \mstrelease{1.3o} |2016/05/03| adds \cs{MTfixfonts}. Operant with
%   \LuaLaTeX\ only.
%
%   \cs{MTmathactivedigits} of \mstrelease{1.4} is a no-op except under option
%   |activedigits|.
%    \begin{macrocode}
\newcommand*\MTeverymathdefault {%
    \MTactiveasterisk
    \MTprimedoesskip
    \MTeasynonlettersobeymathxx
    \MTicinmath
    \MTmathactivedigits
    \MTfixfonts
}%
%    \end{macrocode}
% \end{macro}
% \let\temp~
% \def~{\rlap}
% \begin{macro}{Things to do last ~{``at begin document''}}
% \let~\temp
%
% \mstrelease{1.4} has a significant change here that mathematical
% activation of ascii letters is now not incorporated into the \cs{everymath}
% and \cs{everydisplay}.
%    \begin{macrocode}
\ifmst@everymath
  \AtBeginDocument{%
    \everymath\expandafter{\the\everymath 
        \mst@the\mst@do@nonletters \let\mst@the\@gobble
        \mst@theeasy\mst@do@easynonletters  \let\mst@theeasy\@gobble
    }%
    \everydisplay\expandafter{\the\everydisplay 
        \mst@the\mst@do@nonletters \let\mst@the\@gobble
        \mst@theeasy\mst@do@easynonletters  \let\mst@theeasy\@gobble
    }%
  }
\fi
%    \end{macrocode}
% \mstrelease{1.3j}: moved here to be executed at begin document (and not from inside
% \cs{Mathastext@}.) The \cs{MTeverymathoff} does: \cs{MTnormalasterisk},
% \cs{MTnormalprime}, \cs{MTnonlettersdonotobeymathxx},
% \cs{MTeasynonlettersdonotobeymathxx}, \cs{MTmathstandardletters}.
%
% \mstrelease{1.3m}: doing \cs{MTmathactiveletters} in subdued mode immediately after
% |\begin{document}| resulted in errors because \cs{mst@itcorr} had been left
% undefined. We thus add \cs{MTnoicinmath} to the subdued initialization.
%
% Since \mstrelease{1.3n} there is \cs{MTresetnewmcodes} which needs
% \cs{mst@originalnewmcodes@}, itself defined at begin document. Thus we have
% wrapped the whole thing in \cs{AtEndOfPackage} (at \mstrelease{1.3u} whole code
% directly moved at end of package).
%
% And \mstrelease{1.3p} adds here \cs{MTcustomizenewmcodes} which had been regrettably
% forgotten by \mstrelease{1.3n}.
%
% \mstrelease{1.3t} adds some extras to handle correctly the minus sign and
% dotless i and j in subdued mode, even in case of usage with fontspec.
%
% \mstrelease{1.3u} similarly lets math accents be correctly subdued.
%
% \mstrelease{1.3v} adapts to \cs{hbar} and math accents now being robust with \LaTeX{}
% |2019-10-01| or later.
%
% \mstrelease{1.3w} pays attention to the fact that \cs{hbar} may well be
% a |\mathchar| and not a robust macro! And no need to worry about
% \cs{hbar<space>} finally in revised code.
%    \begin{macrocode}
\AtBeginDocument{%
  \MTcustomizenewmcodes
  \let\mst@original@hbar\hbar
  \let\mst@original@imath\imath
  \let\mst@original@jmath\jmath
  \@tfor\@tempa:={grave}{acute}{check}{breve}{bar}%
                 {dot}{ddot}{mathring}{hat}{tilde}%
  \do
  {\expandafter\let\csname mst@original@\@tempa\expandafter\endcsname
                   \csname \@tempa\endcsname
   \expandafter\let\csname mst@original@\@tempa\space\expandafter\endcsname
                   \csname \@tempa\space\endcsname
  }%
  \ifmst@XeOrLua
     \edef\mst@subduedminus
         {\mst@Umathcodenum`\noexpand\-=\the\mst@Umathcodenum`\-\relax}%
  \else
     \edef\mst@subduedminus{\mathcode`\noexpand\-=\the\mathcode`\-\relax}%
  \fi
  \ifmst@subdued
    \MTeverymathoff
    \MTresetnewmcodes
    \MTnoicinmath
    \MTmathoperatorsdonotobeymathxx
    \let\inodot\imath
    \let\jnodot\jmath
    \mst@subduedminus
  \else
     \mst@nonsubduedhbar
%    \end{macrocode}
% \mstrelease{1.3v} needs \cs{mst@nonsubduedmathaccents} to get executed later (see
% code comments for \cs{mst@dothe@mathaccentsstuff}).
%    \begin{macrocode}
     \mst@nonsubduedminus
%    \end{macrocode}
% \mstrelease{1.3j}: an earlier version of this code was earlier part of \cs{Mathastext@}.
% As we are now in \cs{AtBeginDocument} we try to be careful not to overwrite
% \cs{MTicinmath}, \cs{MTnoicinmath}, \cs{MTicalsoinmathxx}, ... if issued by
% the user in the preamble, though. And we do not execute
% \cs{MTmathactiveletters}, it is issued by the package at loading time in
% order to allow user to cancel it if desired from inside the preamble.
%    \begin{macrocode}
     \ifx\mst@itcorr\@undefined
         \def\mst@itcorr{\ifnum\fam=\m@ne\/\fi}%
         \@for\mst@tmp:=it,sl\do 
           {\ifx\mst@tmp\mst@ltshape@normal\let\mst@itcorr\@empty\fi }%
     \fi
     \ifx\mst@ITcorr\@undefined
         \let\mst@ITcorr\mst@itcorr
         \ifmst@frenchmath
           \def\mst@ITcorr{\ifnum\fam=\m@ne\/\fi}%
           \@for\mst@tmp:=it,sl\do
                {\ifx\mst@tmp\mst@shape@normal\let\mst@ITcorr\@empty\fi }%
         \fi
     \fi
  \fi
}%
\AtEndOfPackage{\AtBeginDocument{\ifmst@subdued\else\mst@nonsubduedmathaccents\fi}}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{subdued}
%   \mstrelease{1.15}: The subdued code was initiated in May 2011. I returned to
%   |mathastext| on Sep 24, 2012, and decided to complete what I had started
%   then, but in the mean time I had forgotten almost all of the little I knew
%   about \LaTeX{} macro programming.
%
%   The point was to extract the data about how are `letters' and
%   `operators' in the normal and bold versions, through obtaining the
%   math families of `a' and `1', respectively$^1$. Due to the
%   reassignements done for characters by |mathastext| I also had
%   decided in 2011 that the OT1 encoding, if detected, should be
%   replaced by T1\newline
%   $^1$but the \emph{euler} package for example
%   assigns the digits to the \emph{letters} symbol font...
%
%   \mstrelease{1.15d}: Oct 13, 2012. The \cs{mathcode} thing has to be used with care
%   under Unicode engines. Unfortunately the \cs{luatexUmathcode} macro is
%   helpless as it is not possible to know if it will return a legacy mathcode
%   or a Unicode mathcode. On the other hand the much saner
%   \cs{XeTeXmathcodenum} always return a Unicode mathcode. 
%
%   {UPDATE for \mst\ 1.3 (|2013/09/02|): since the release of lualatex as
%   included in 
%   TL2013, \cs{luatexUmathcodenum} behaves as \cs{XeTeXmathcodenum} so \mst 1.3
%   treats identically under both unicode engines the equal and minus signs (and
%   the vertical bar).}
%
%   \mstrelease{1.15e}: Oct 22, 2012. I add the necessary things to also subdue the
%   \cs{mathbf}, \cs{mathit}, \cs{mathsf} and \cs{mathtt} macros (previous
%   version only took care of the symbol alphabets \cs{mathnormal} and
%   \cs{mathrm}.) [update: \mstrelease{1.15f} does that in a completely different and much
%   simpler way] Notice that the package defines a \cs{mathnormalbold} macro,
%   but it will not be subdued in the normal and bold math versions.
%
%   \mstrelease{1.15f}: Oct 23, 2012. The previous version of the code queried the math
%   family of a, respectively 1, to guess and then extract the fonts to be
%   reassigned to mtletterfont and mtoperatorfont (which is done at the end of
%   this .sty file). The present code simply directly uses letters and operators
%   (so mathastext could not subdue itself... if it was somehow cloned), but
%   obtains indeed the corresponding font specifications in normal and bold in a
%   cleaner manner. But it is so much shorter (and avoids the \LuaLaTeX{}
%   problem with \cs{luatexUmathcode}). Anyhow, for example the euler package
%   puts the digits in the letters math family! so the previous method was also
%   error prone. In fact there is no way to do this subdued mechanism on the
%   basis of the legacy code of mathastext. The only way is to rewrite entirely
%   the package to query all mathcodes of things it changes in order to be able
%   to revert these changes (and one would have to do even more hacking for
%   |\mathversion{normal}| and not only |\MTversion{normal}| to work).
%
%   \mstrelease{1.15f}: and also I take this opportunity to do the subdued math
%   alphabets things in a much much easier way, see below.
%
%   \mstrelease{1.3s} |2018/08/21|: I have half-forgotten the reasons for modifiying the
%   font encoding to current |\encodingdefault|, but at any rate this should
%   not be done in a \ctanpkg{fontspec} context, encoding default being (now) |TU| it
%   is very unlikely modifying from |TU| or to |TU| from something else will
%   do any good.
%^^A See
%^^A   \centeredline{\url{https://tex.stackexchange.com/questions/444565/mathastext-wrong-digits-in-math-mode/}}
%^^A   for original report.
%   I add workaround here for case of \ctanpkg{fontspec} being
%   detected via the |\encodingdefault| setting.
%
%   \mstrelease{1.3t} |2018/08/22|: the \mstrelease{1.3s} fix erroneously removed the
%   |OT1->T1| replacement in |TU| context.
%
%   \mstrelease{1.3u}: the whole thing will only get executed At Begin
%   Document.
%
%   I realize extremely late (|2023/12/28|) I never said explicitly anywhere
%   it seems in the code comments that the |frenchmath| option effect is
%   \emph{not} subdued: the uppercase Latin letters \cs{mathcode}'s are
%   not changed back to their defaults at start of a subdued document or when
%   going to the subdued normal math version!  Time to do so before the
%   package enters resolutely dormant maintenance status soon... and I end up
%   really forgetting enything and having wrong expectations on what is the
%   behavior of the package.
%    \begin{macrocode}
\ifmst@subdued
  \AtBeginDocument{%
  \def\mst@reserved#1\getanddefine@fonts\symletters#2#3\@nil{%
        \def\mst@normalmv@letter{#2}}%
  \expandafter\mst@reserved\mv@normal\@nil
  \def\mst@reserved#1\getanddefine@fonts\symletters#2#3\@nil{%
        \def\mst@boldmv@letter{#2}}%
  \expandafter\mst@reserved\mv@bold\@nil
  \def\mst@reserved#1\getanddefine@fonts\symoperators#2#3\@nil{%
        \def\mst@normalmv@operator{#2}}%
  \expandafter\mst@reserved\mv@normal\@nil
  \def\mst@reserved#1\getanddefine@fonts\symoperators#2#3\@nil{%
        \def\mst@boldmv@operator{#2}}%
  \expandafter\mst@reserved\mv@bold\@nil
  \edef\mst@tmp@enc{\mst@encoding@normal}%
  \def\mst@reserved#1/#2/#3/#4/{\gdef\mst@debut{#1}\gdef\mst@reste{#2/#3/#4}}%
  \begingroup\escapechar\m@ne
      \xdef\mst@funnyoti{\expandafter\string\csname OT1\endcsname}%
      \expandafter\expandafter\expandafter
          \mst@reserved\expandafter\string\mst@normalmv@operator/%
  \endgroup
  \ifx\mst@debut\mst@funnyoti\ifx\mst@tmp@enc\mst@oti\def\mst@tmp@enc{T1}\fi\fi
  \edef\mst@normalmv@operator{\expandafter\noexpand\csname 
       \if1\mst@OneifUniEnc
         \ifx\mst@debut\mst@funnyoti T1\else\mst@debut\fi
       \else
         \mst@tmp@enc
       \fi/\mst@reste\endcsname}%
  \edef\mst@tmp@enc{\mst@encoding@bold}%
  \begingroup\escapechar\m@ne
      \expandafter\expandafter\expandafter
          \mst@reserved\expandafter\string\mst@boldmv@operator/%
  \endgroup
  \ifx\mst@debut\mst@funnyoti\ifx\mst@tmp@enc\mst@oti\def\mst@tmp@enc{T1}\fi\fi
  \edef\mst@boldmv@operator{\expandafter\noexpand\csname 
       \if1\mst@OneifUniEnc
         \ifx\mst@debut\mst@funnyoti T1\else\mst@debut\fi
       \else
         \mst@tmp@enc
       \fi/\mst@reste\endcsname}%
  \expandafter\SetSymbolFont@
    \expandafter\mv@normal\mst@normalmv@letter\symmtletterfont
  \expandafter\SetSymbolFont@
    \expandafter\mv@bold\mst@boldmv@letter\symmtletterfont
  \expandafter\SetSymbolFont@
    \expandafter\mv@normal\mst@normalmv@operator\symmtoperatorfont
  \expandafter\SetSymbolFont@
    \expandafter\mv@bold\mst@boldmv@operator\symmtoperatorfont
  \immediate\write\m@ne{}%
  \PackageInfo{mathastext}{...entering subdued mode...\MessageBreak ...done}%
  \immediate\write\m@ne{}%
  }%
\fi
%    \end{macrocode}
%^^A  In the short-lived |1.15e| I was doing the following for alphabets:\\
%^^A  |\def\mst@reservedc#1#2#3#4{\def\mst@normalmv@mathbf{#4#3}}|\\
%^^A  |\def\mst@reserveda#1{%|\\
%^^A  |\def\mst@reservedb##1\install@mathalphabet#1##2##3\@nil{\mst@reservedc##2}%|\\
%^^A  |\expandafter\mst@reservedb\mv@normal\@nil}|\\
%^^A  |\expandafter\mst@reserveda\csname mathbf\space\endcsname|\\
%^^A  and later in the code:\\
%^^A  |\expandafter\expandafter\expandafter\SetMathAlphabet@|\\
%^^A  |\expandafter\expandafter\expandafter\mv@normal|\\
%^^A  |\expandafter\mst@normalmv@mathbf\csname Mathbf\space \endcsname\Mathbf|\\
%^^A  It does work! but |\let\mst@original@bf\mathbf| is so
%^^A  much simpler. And also safer, because \cs{mathbf} could have been
%^^A  redefined using \cs{DeclareSymbolFontAlphabet}... (I could have
%^^A  provided the necessary check to the already bloated code...)
% \end{macro}
% \begin{macro}{Preamble-only...}
% ``Only preamble'' restrictions. I was way too much obedient back in 2011,
% particularly taking into account how much of a pain it has been and still is
% that things such as \cs{DeclareMathSymbol} or \cs{DeclareMathAccent} are
% preamble-only. But keeping this for time being, however not using
% \cs{@onlypreamble} which breaks one's heart when tracing to see how much
% place it takes, so we do it in one go.
%    \begin{macrocode}
\expandafter \gdef \expandafter \@preamblecmds \expandafter {\@preamblecmds
\do\MTitgreek
\do\MTupgreek
\do\MTitGreek
\do\MTitGreek
\do\Mathastextitgreek
\do\Mathastextupgreek
\do\MathastextitGreek
\do\MathastextitGreek
\do\MTgreekfont
\do\Mathastextgreekfont
\do\MTgreekupdefault
\do\MTgreekitdefault
\do\MTDeclareVersion
\do\MathastextDeclareVersion
\do\MTWillUse
\do\MathastextWillUse
\do\Mathastextwilluse
\do\Mathastext
\do\mathastext
}
\immediate\write\m@ne{}
\PackageInfo{mathastext}{Loading is complete. \space You can now use \string\Mathastext
                         \space to\MessageBreak
                         modify the normal and bold math versions. \space
                         Use it\MessageBreak
                         with optional argument or use \string\MTDeclareVersion\space
                         to\MessageBreak
                         declare additional math versions\@gobble}
\endinput
%    \end{macrocode}
% \end{macro}
% \DeleteShortVerb{\|}
% \MakePercentComment
%</package>
%<*dtx>
\Finale
%%
%% End of file `mathastext.dtx'.
