% \iffalse meta-comment
%    Time-stamp: <12-03-2011 10:58:48 CET JF>
%    File `mathastext.dtx'
%    
%    Copyright (C) 2011 by Jean-Francois Burnol
%   
%    This file may be distributed and/or modified under the
%    conditions of the LaTeX Project Public License,
%    either version 1.3 of this license or (at your
%    option) any later version.  The latest version of
%    this license is in
%    http://www.latex-project.org/lppl.txt 
%    and version 1.3 or later is part of all distributions of
%    LaTeX version 2003/12/01 or later.  
%
%    Please report errors to jfbu (at) free.fr
%    Numerous examples are available at
%        http://jf.burnol.free.fr/mathastext.html
%    
% \fi 
% \iffalse
%<*dtx>    
\ProvidesFile{mathastext.dtx}
             [2011/03/11 1.13 Use the text font in simple mathematics]
%</dtx>
% 
%<*driver>
\documentclass[a4paper]{ltxdoc}
\setlength{\topmargin}{0pt} 
\setlength{\headsep}{12pt}
\setlength{\headheight}{10pt}
\setlength{\textheight}{600pt}
\setlength{\footskip}{34pt}
\setlength{\textwidth}{360pt}
\setlength{\oddsidemargin}{46pt}
\setlength{\marginparwidth}{100pt}
%% The Symbol font will be used in the text
\DeclareSymbolFont{mtpsymbol}{U}{psy}{m}{n}
\makeatletter
  \DeclareFontFamily{U}{psy}{}
  \DeclareFontShape{U}{psy}{m}{n}{<-> psyr}{}
%% the following is taken from the package itself
\let\prod\undefined
\DeclareMathSymbol{\prod}{\mathop}{mtpsymbol}{213}
\let\sum\undefined
\DeclareMathSymbol{\sum}{\mathop}{mtpsymbol}{229}
\DeclareMathSymbol{\mt@implies}{\mathrel}{mtpsymbol}{222}
\DeclareRobustCommand{\implies}{\;\mt@implies\;}
\DeclareMathSymbol{\mt@impliedby}{\mathrel}{mtpsymbol}{220}
\DeclareRobustCommand{\impliedby}{\;\mt@impliedby\;}
\DeclareRobustCommand{\iff}{\;\mt@impliedby\mathrel{\mkern-3mu}\mt@implies\;}
\DeclareMathSymbol{\mt@iff}{\mathrel}{mtpsymbol}{219}
\DeclareRobustCommand{\shortiff}{\;\mt@iff\;}
\DeclareMathSymbol{\mt@to}{\mathrel}{mtpsymbol}{174}
\DeclareMathSymbol{\mt@trait}{\mathrel}{mtpsymbol}{190}
\DeclareRobustCommand\to{\mt@to}
\DeclareRobustCommand\longto{\mkern2mu\mt@trait\mathrel{\mkern-10mu}\mt@to}
\DeclareRobustCommand\mapsto{\mapstochar\mathrel{\mkern0.2mu}\mt@to}
\DeclareRobustCommand\longmapsto{%
\mapstochar\mathrel{\mkern2mu}\mt@trait\mathrel{\mkern-10mu}\mt@to}
\makeatother
%%
\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{\ast}{\mathbin}{mtpsymbol}{42}
\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}
\DeclareMathSymbol{\Re}{\mathord}{mtpsymbol}{"C2}
\DeclareMathSymbol{\Im}{\mathord}{mtpsymbol}{"C1}
\DeclareMathSymbol{\DotTriangle}{\mathord}{mtpsymbol}{92}
%\RecordChanges
%\OnlyDescription
\begin{document}
 \DocInput{mathastext.dtx}
\end{document}
%</driver>
% \fi
% \changes{1.13}{2011/03/11}{
%    * option LGRgreek: for fonts also available in LGR-encoding
%    * internal changes: systematic use of `if' conditionals
%    for better readability of the code and easier error-checking
%    (done a bit late for that aspect, though... )
%    }
% 
% \changes{1.12b}{2011/02/09}{
%    * a completely stupid bug regarding uppercase Greek is
%    corrected
%    * I take this opportunity to add LY1 as one of the supported
%    encoding for math accents 
%    * and I correct an  orthographical mistake in the README
%    }
%
% \changes{1.12}{2011/02/07}{
%    * annoying silly bug in 1.11 about using \cs{MessageBreak} in
%    the \cs{typeout} things
%    * there was in 1.11 an even sillier bug which made the
%    option nominus provoke an error.  
%    * I have improved the way |mathastext| deals with the
%    encoding-dependent things, especially with respect to
%    the handling of unicode engines.
%    }
% 
% \changes{1.11}{2011/02/06}{
%    * bugs from version 1.1 have been fixed. 
%         * Among them the non correct behavior when
%         eulergreek and one of the symbol options were used
%         at the same time. 
%         * Also the macro \cs{Mathastext} did not
%         contrarily to what was said in the docs pick up
%         the font defaults at the time of it being used in
%         the preamble. 
%         * the endash option provoked an error when used
%         with XeTeX or LuaTeX.
%    * for brevity sake long macro names starting with
%    \cs{Mathastext\cdots} now exist in the form
%    \cs{MT\cdots} 
%    * the |endash| option is made default, as well as the
%    |alldelims| option. A new |symboldelimiters| option
%    specifies to use the Symbol font for characters others
%    then letters and digits. 
%    * the \cs{fouriervec} command must be explicitely
%    requested by the |fouriervec| option
%    * the command \cs{Mathastext} now accepts an optional
%    argument which, if present, makes \cs{Mathastext} acts
%    as \cs{MathastextDeclareVersion} with the current font
%    defaults, the optional argument giving the name of the
%    version. This mechanism allows to use |mathastext| with
%    unicode fonts (XeTeX or LuaTeX with |fontspec|)
%    * |mathastext| is more clever for the dotless i and j
%    and the hbar with respect to encoding problems; and it
%    knows also their Unicode locations.
%    }
%
% \changes{1.1}{2011/02/01}{
%   * option |italic|: this is the main change for the user. Internally we now
%   have two distinct fonts, however they differ only in shape. 
%       * the mechanism of math versions is extended to accomodate this: the
%       macros \cs{MathastextWillUse} and \cs{MathastextDeclareVersion} now
%       accept an optional argument for specifying the letters' shape  
%       * |frenchmath| sets the uppercase Latin letters nevertheless in the
%       digits font 
%       * \cs{mathnormal}, \cs{mathrm}, \cs{mathbf} work in the same way as in
%       standard \LaTeX{}, but with the |mathastext| font. But I do nothing
%       with the other default alphabet changing commands.
%   * the minus sign can be represented as an en-dash. This seems to be clever
%   enough to accomodate all 8bit encodings, not limited to OT1 or T1.
%   * the |noplusnominus| option is split into two
%   * I change the way the encoding is chosen for the math accents: I use the
%   default encoding at the time of loading. So there is nothing more in the
%   code at AtBeginDocument for this. I do not know an automatic way to go
%   from the encoding to the accent slots, and I did not want to manually
%   incorporate here all possible or at least many encodings, so basically
%   only OT1 and T1 are ok. Default to OT1. Of course in case on more than one
%   math versions, they should have the same encoding for everything to work
%   everywhere. 
%   * same change for \cs{imath}: but defaults to T1.
%   * some attention devoted to |hbar|. Works ok, or at least reasonably with
%   the fonts I tested. Adjusts to whether or not the |italic| option was used. 
%   * |defaultvec| deprecated, rather we now have \cs{fouriervec} command to
%   access the vec accent from the Fourier font. 
%   * new alphabet commands \cs{mathnormalbold}, \cs{MathEulerBold}, and
%   \cs{MathEuler} and \cs{MathPSymbol} have new names.
%   * names for the capital Greek letters which look like their Latin versions.
%   * bug fixed: the character slot for \cs{Xi} in the Symbol font was wrong.
%   **** limitations: 
%        * the \cs{pmvec} accent will not change its size when
%        used in subscripts or exponents
%        * now that internally we have two fonts for letters and
%        digits they could be entirely unrelated, it is just a
%        question of providing the user macros to pass the info to
%        the package, and to duplicate some variables. As this
%        goes really against the initial design goals, and adds
%        complications, I did not do it.}
%
% \changes{1.0}{2011/01/25}{Initial version.}
%
% \GetFileInfo{mathastext.dtx}
%
% \begin{center}
%   {\Large The \texttt{mathastext} package}\\
%   Jean-Fran\c cois \textsc{Burnol}\\
%   \texttt{jfbu at free dot fr}
% \end{center}
%
%  \begin{abstract}
%    The |mathastext| package\footnote{This document
%    describes |mathastext| version \fileversion\
%    (\filedate).} propagates the document {\em text} font
%    to {\em mathematical} mode, for the letters and digits
%    of the Latin alphabet and a few further
%    characters. Various possibilities are provided for
%    Greek letters, including picking them up in the font
%    itself, if the font is available in LGR-encoding. The
%    initial idea was to produce handouts or research papers
%    with a less book-like typography than what is typical
%    of standard \TeX-\LaTeX{} with the Computer Modern
%    fonts, but equipped with a very uniform look (with the
%    hope to coerce the reader into concentrating more onto
%    the contents ;-).) A side-effect is that 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, |mathastext|
%    provides a simple mechanism in order to use more than
%    one math-as-text font in the same document (not that we
%    recommend it!).  A final aspect is that |mathastext|
%    helps sometimes produce smaller PDF files.
% 
%  \begin{center}
%    Numerous examples are available here:\\
%    |http://jf.burnol.free.fr/mathastext.html|
%  \end{center}
%  \end{abstract}
%
%  \section{Description of what the package does}
%
%    \subsection{Motivation}
%
%    |mathastext| was conceived as a result of frustration of
%    distributing to students \TeX-crafted mathematical handouts with
%    a subsequent realization that not much had made it to a
%    semi-permanent brain location. So, I forced \LaTeX\ to produce
%    material as if written on a primitive typewriter, a little bit
%    like the good old seminar notes of the Cartan and Grothendieck
%    days. Don't ask me if this helped, I have long since opted for a
%    positive attitude in life.
%    
%    The package |mathastext| is less extreme, but retains
%    the idea of using inside mathematics the same font as
%    is used for text for the letters of the Latin
%    alphabet and the digits:\\
%    \centerline{abcdefghijklmnopqrstuvwxyz}
%    \centerline{ABCDEFGHIJKLMNOPQRSTUVWXYZ}
%    \centerline{0123456789} By
%    default the text font will also be used for:\\
%    \DeleteShortVerb{\|}
%    \centerline{!\,?\,*\,,\,.\,:\,;\,+\,\textendash\,=\,(\,)\,[\,]\,/\,\#\,%
%    \$\,\%\,\&\,$\mathord{<}\,\mathord{>}\,\mathord{|}$\,\{\,\}
%    and $\backslash$} 
%    
%    Note: if the package detects OT1 as default encoding it
%    will take out from the list
%    $\mathord{<}\,\mathord{>}\,\mathord{|}$\,\{\,\} and
%    $\backslash$\MakeShortVerb{\|} as they are not available
%    in OT1, except for the typewriter fonts; the option
%    |alldelims| forces re-integration in this case.
%
%    The commands \cs{mathnormal}, \cs{mathrm} and
%    \cs{mathbf} are modified to now make use of the text
%    font; but nothing is changed to \cs{mathit} and the
%    other math alphabet commands which will use the default
%    math fonts, not the text font.
%
%    The en-dash (\textendash{}) is used for the minus sign,
%    rather than the hyphen (-) character. Additionally,
%    some further glyphs will also be picked up in the text
%    font: the dotless i and j, the hbar and the math
%    accents. Version |1.12| brought a better compatibility
%    with a Unicode setting (assuming that |fontspec| is
%    made use of), but the scope of |mathastext| does not
%    include letters with diacritics such as \'e, \`a, \"o
%    in math mode. Users of Unicode engines and fonts are
%    advised to look at the |mathspec| and |unicode-math|
%    packages which have a much wider scope than
%    |mathastext|.
%
%    Even when typesetting simple mathematics, some glyphs
%    (almost) must be taken from the default math fonts: in
%    particular the prime ${}'$ for derivatives, as the text
%    font {}'{} is not, as a rule, a satisfying
%    alternative. Also, the package does nothing special
%    regarding the large math symbols (except for $\prod$
%    and $\sum$ whose ``non-large'' versions may be taken
%    from the Symbol Font).
%
%    \subsection{The italic option}
%
%    In the initial version |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, I explained above
%    why I did this on purpose.
%
%    Nevertheless, soon after I posted the initial version
%    of the package to CTAN, I was overwhelmed by
%    numerous\footnote{this means ``more then 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.
%
%    Starting with version |1.1| the default is still, as in
%    version |1.0|, for everything to be in upright shape,
%    but it suffices to pass to the package the option
%    |italic| to have italic Latin letters in math
%    mode. There is also an option |frenchmath|\footnote{in
%    versions of the package prior to |1.13|, it was
%    necessary to also pass the option |italic| to enable
%    |frenchmath|. This is now superfluous.} to make the uppercase letters
%    nevertheless upright, because this is the way of
%    traditional French mathematical typography.
%
%    \subsection{Greek letters}
%
%    The Computer Modern fonts are very light 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 |mathastext|:
%    \begin{description}
%    \item[$<$\textemdash$>$:] 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 |fourier| package with option
%      `upright', which gives upright Greek letters.
%    \item[LGRgreek:] this is for fonts which additionally
%      to Latin letters also provide Greek letters in LGR
%      encoding.\footnote{among examples known to the author are
%      the Comfortaa and the Droid (serif and sans) fonts,
%      and of course the Greek Font Society fonts such as
%      GFS Didot.} The letters (but see below) will be in
%      the same shape as the Latin letters, or upright in
%      case of the option |frenchmath|.
%    \item[eulergreek:] the Greek letters will be taken from
%      the Euler font which is included in all \LaTeX{}
%      distributions (although no package loading is
%      necessary for the user, nor done by |mathastext|, the
%      file |uzeur.fd| from the |eulervm| package must be
%      accessible to \LaTeX{} 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) Symbol font. A command is provided
%      so that the user can scale the Symbol font to let it
%      better mix with the text font. The letters are upright.
%    \item[selfGreek:] this option has limited use; it is
%      for OT1-encoded text fonts which do provide the
%      glyphs for the capital Greek letters. It does nothing
%      for the lowercase Greek letters.
%    \end{description}
%
%    \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 font are not available in italic
%    shape, so this raises issues only in the case of the
%    options |LGRgreek| and |selfGreek|. The |mathastext|
%    default is to let the Greek letters have the same shape
%    as the Latin letters (and be upright in the case of
%    option |frenchmath|.)
%    
%    A finer control is provided by options |upgreek|,
%    |itgreek|, |upGreek|, |itGreek|: the former first two
%    control both lower- and uppercase, the latter control
%    only the uppercase shape. So classic \TeX{} is
%    |itgreek|+|upGreek|, ISO is |itgreek|, and French is
%    |upgreek|.
%
%    Note that, as mentioned before, the options |italic|
%    and |frenchmath| act on both Latin and Greek letters,
%    so |italic| gives ISO behavior, and |frenchmath| gives
%    French behavior,\footnote{In fact, |frenchmath| confers
%    to the Greek letters and uppercase Latin letters the
%    same shape as to the operator-names and digits, so
%    generally speaking this will be the \cs{shapedefault}
%    at the time of loading the package. If this shape is
%    not the upright one and one still wants upright Greek,
%    then it is thus necessary to use |upgreek|.}  without
%    need to use the \DeleteShortVerb{|}\MakeShortVerb{*}
%    *[up|it][g|G]reek*\DeleteShortVerb{*}\MakeShortVerb{|}
%    options.
%
%    Again, all of this applies only in case of option
%    |LGRgreek| and to a lesser extent, |selfGreek|. And to
%    recapitulate, people wanting the classic \TeX{}
%    behavior will use |italic|+|upGreek|, or
%    |itgreek|+|upGreek| in the absence of |italic|.
%
%    
%
%    \subsection{Advanced use:  math versions}
%
%    
%    It is not infrequent to use two different text fonts in
%    the same document. In the context of the |mathastext|
%    design goals it was thus necessary to find a way to let
%    changes of the text font also propagate to math
%    mode. For this the package extends the \LaTeX{}
%    mechanism of math versions. However this is only for
%    Latin letters, digits, and the other characters
%    mentioned above, but not for Greek letters: the choice
%    of a Greek-related option (or none) at the time of
%    loading the package will affect all math versions. This
%    does mean though that in the case of the |LGRgreek|
%    option changing the text font will also change the font
%    for the Greek letters. But it is not possible (in the
%    current version of the package) to have one part of the
%    document use the Euler font for Greek letters and
%    another part use the Symbol font (it is possible to
%    use both fonts simultaneously but Symbol will then be
%    employed for various mathematical symbols, not for
%    Greek, see option |symbolmax|).
%
%    Let us now see a small document using four math versions:
%    \begin{verbatim}
%    \documentclass{minimal}
%    \usepackage[T1]{fontenc}
%    \usepackage{mathastext}
%    %    declares Latin Modern Typewriter Proportional:
%    \MTDeclareVersion{lmvtt}{T1}{lmvtt}{m}{n}
%    %    declares Baskervald, italic letters in math:
%    \MTDeclareVersion[it]{baskervald}{T1}{ybv}{m}{n}
%    %    declares Helvetica-Bold-Slanted, but upright
%    %    letters in math mode:
%    \MTDeclareVersion[n]{helvetica}{T1}{phv}{b}{sl}
%    \begin{document}
%    \MTVersion{helvetica}
%    Bold-slanted Helvetica in text,
%    $bold\ upright\ Helvetica\ in\ math$.\\
%    \MTVersion[lmvtt]{baskervald}
%    Text in lmvtt but $math\ in\ Baskervald-Italic$.\\
%    \MTVersion{normal}
%    The normal version uses the default text font at
%    the time of loading mathastext, $in\ math\ also\ of\ course$.
%    \end{document}
%    \end{verbatim}
%    The encodings of the various |mathastext|-defined versions
%    can be arbitrary; but as |mathastext| decides at the time
%    when it is loaded where to look for things like the en-dash,
%    or the dotless i and j, or the math accents, which are
%    encoding-dependent, there are obviously some limitations to
%    the use of these things in more than one math
%    version. 
%
%    
%    The package provides various macros to interface with
%    its `math versions' functionalities. These commands are
%    detailed in a later section. As an example, here is an
%    equivalent manner to set up our small document:
%    \begin{verbatim}
%    \documentclass{minimal}
%    \usepackage[T1]{fontenc}
%    \usepackage{mathastext}
%    \renewcommand{\rmdefault}{lmvtt}
%    \Mathastext[lmvtt]  % Declares the `lmvtt' version
%    \renewcommand{\rmdefault}{ybv}
%    \MTlettershape{it}
%    \Mathastext[baskervald] % Declares the `baskervald' version
%    \renewcommand{\shapedefault}{sl}
%    \renewcommand{\rmdefault}{phv}
%    \renewcommand{\mddefault}{b}
%    \MTlettershape{n}
%    \Mathastext[helvetica] % Declares the `helvetica' version
%    \begin{document}
%    \MTVersion{helvetica} % use `helvetica' both in text and math
%    Bold-slanted Helvetica in text, $bold\ upright\ Helvetica\ in\ math$.\\
%    \MTVersion[lmvtt]{baskervald}
%    Text in lmvtt but $math\ in\ Baskervald-Italic$.\\
%    \MTVersion{normal}
%    The normal version uses the default text font at
%    the time of loading mathastext, $in\ math\ also\ of\ course$.
%    \end{document}
%    \end{verbatim}
%    Unicode \TeX{} engines and fonts can also be
%    accomodated. It is recommended to load the package
%    |fontspec|. Of course |mathastext| is extremely far
%    from really defining a math font, as it applies
%    basically only to a subset of the 32-127 ascii
%    range. And it does not know how to use a given Unicode font
%    simultaneously for Latin and Greek letters: interested people are
%    advised to look at packages |mathspec| and
%    |unicode-math|. Here is an example (a bit
%    schizophrenic) of a document with mathastext-versions
%    for a Xe\TeX{} or Lua\LaTeX{} user:
%    \begin{verbatim}
%    \documentclass{minimal}
%    \usepackage[no-math]{fontspec}
%    \setmainfont{comfortaa}
%    \usepackage{mathastext}  % the normal version uses Comfortaa
%    \setmainfont{TeX Gyre Pagella}
%    \Mathastext[pagella]     % the pagella version uses
%                             % TeX Gyre Pagella
%    \MTDeclareVersion{times}{T1}{ptm}{m}{n} 
%              %  this is a T1-encoded URW Times. 
%              %  Do not use this interface for a Unicode font,
%              %  use rather as above the \setmainfont
%              %  command of |fontspec|, followed by \Mathastext
%    \setmainfont{TeX Gyre Schola}
%    \Mathastext[schola] % and the schola version uses 
%                        % unicode TeX Gyre Schola
%    \begin{document}
%    \MTVersion{pagella}
%    This is in TeX Gyre Pagella $and\ this\ also$ (unicode font).
%    \MTVersion{times}
%    Now we are in URW Times, $here\ also$ (T1 encoded font).
%    \MTVersion[normal]{schola}
%    Text in Unicode Comfortaa and $math\ in\ Unicode\ Schola$.
%    \end{document}
%    \end{verbatim}
%    
%
%    \subsection{Main options}
%    \begin{description}
%    \item[{\tt italic, frenchmath:}] italic letters in
%    math, upright uppercase if |frenchmath|.
%    \item[{\tt LGRgreek, eulergreek, symbolgreek:}] the
%      Greek letters will be taken, respectively from the
%      text font itself (in LGR encoding), or from the Euler
%      font, or from the Postscript Symbol font.
%    \item[{\tt symbolmax:}] all characters listed supra,
%      other than letters and digits, are taken from the
%      Symbol font. This option also makes a number of
%      further glyphs available, including some basic
%      mathematical arrows, as well as the sum and product
%      signs. For documents with very simple needs in
%      mathematical symbols, |mathastext| with option
%      |symbolmax| may give in the end a PDF file quite
%      smaller than the one one would get without the
%      package.
%    \item[{\tt defaultmathsizes:}] the package |mathastext| opts for bigger
%      subscripts (and, copied from the |moresize| package, redefines
%      \cs{Huge} and defines \cs{HUGE}). Use this option to prevent it from
%      doing so.
%    \end{description}
%
%    \subsection{Miscellaneous}
%
%    \begin{description}
%    \item[the en-dash as minus sign:] Very often the -
%      character from the text font does not give a good
%      minus sign. So by default, the package uses the
%      en-dash sign \textendash{}. Use |noendash| to
%      deactivate it. Starting with version |1.12| of the
%      package this `en-dash as minus' should work in all
%      encodings, including Unicode (if |fontspec| has been
%      loaded).
%
%
%    \item[hbar:] The definition of \cs{hbar} inherited from
%      default \LaTeX{} will 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 the bar
%      accross the |h| will come from the original default
%      math font for letters (usually |cmmi|), and
%      furthermore its placement on the |h| can be
%      odd-looking. So we redefine \cs{hbar} to use only the
%      text font (and this will be aware of the |italic|
%      option). Our construction does not always give an
%      optimal result (and its scope is limited to the OT1,
%      LY1 and T1 encodings), so an option |nohbar|
%      deactivates it. There is no \cs{hslash} provided by
%      the package, though. The version |1.12| of the
%      package when dealing with a Unicode font tries to get
%      the \cs{hbar} directly as a glyph from the font.
%
%
%    \item[dotless i and j:] By default the package redefines
%      \cs{i} and \cs{j} to give the dotless i and j (if it
%      exists at all), \emph{also in math mode,} in the text
%      font. Will overwrite the default commands \cs{imath}
%      and \cs{jmath}. In version |1.12| of the package this
%      should work in all encodings, including Unicode (it
%      is then assumed that |fontspec| has been loaded, and
%      of course that the glyphs are indeed in the font).
%
%
%      \item[Xe\TeX{} and Lua\LaTeX{}:] for the en-dash
%    and the dotless i and j, the package expects to detect
%    either the EU1 encoding for XeTeX{} or the EU2 encoding
%    for Lua\LaTeX{} (this will be true if |fontspec| was
%    loaded), or one of OT1, LY1 or T1, else it
%    will renounce and not attempt to access the en-dash or the
%    dotless i and j glyphs. With \LaTeX{} and Pdf\LaTeX{},
%    there is no such limitation and all 8bit-encodings
%    (containing these glyphs) should be ok.
%
%     \item[fontspec:] one more note to users of
%    Xe\TeX{}/Lua\LaTeX{} with |fontspec|: it has to be
%    loaded \emph{with the option} |no-math|, 
%    \emph{and before} |mathastext|.
%
%    \item[vec accent:] The default \cs{vec} accent is not
%      appropriate for upright letters, so  |mathastext|
%      provides a \cs{fouriervec} which takes its glyph in a
%      Fourier font, and an Ersatz \cs{pmvec} 
%      which is reasonably good looking on upright letters
%      and works with the \cs{rightarrow} glyph. Contrarily
%      to version |1.0|, the default \cs{vec} is not
%      overwritten with \cs{fouriervec}. And contrarily to
%      version |1.1|, one now needs to pass the option
%      |fouriervec| to have the math accent \cs{fouriervec}
%      defined by the package.
%
%
%    \item[math alphabets:] The \cs{mathnormal}, \cs{mathrm}, and \cs{mathbf} are
%      modified to use the text font (or the arbitrarily
%      specified font for a math version), and behave as in
%      standard \LaTeX{}. But we provide a new
%      \cs{mathnormalbold}, to access the bold letters while
%      maintaining their italic shape (or whatever shape has
%      been specified for them) in case of the |italic|
%      option. Other math alphabet changing commands are
%      \cs{MathEulerBold}, \cs{MathEuler} and
%      \cs{MathPSymbol}. Note though that it is not possible
%      to use too many of such commands in the same
%      document, due to some limitations of
%      \LaTeX{}. Declaring them does not seem to be a
%      problem, and I will welcome any information by
%      knowledgeable people.
%
%    \item[math accents:] an option |mathaccents| is
%      provided to pick up the accents in math mode from the
%      text font, but the package knows only T1, LY1 or
%      OT1-compatible encodings.
%  
%    \end{description}
%
%    Regarding the encoding-dependent glyphs: the en-dash,
%    the dotless i and j, the math accents, the hbar, are
%    encoding dependent and the relevant decisions are made
%    by |mathastext| at the time it is loaded. So you can
%    use math versions with different encodings but,
%    regarding these characters only those with the same
%    encoding as the normal math version will display them
%    correctly. 
%
%  \section{Commands}    
%    
%    \subsection{Preamble-only commands}
%    Nothing is necessary besides loading |mathastext|, possibly
%    with some customizing options. The following commands provide
%    enhancements to the basic use of the package.
%    \begin{itemize}
%    \item |\Mathastext|: reinitializes |mathastext| according to the current
%      defaults of encoding, family, series and shape.
%      \begin{itemize}
%      \item It can also be preceded optionally by one or
%        more of\footnote{these commands exist also with
%        long names: \texttt{\char92Mathastextencoding},
%        etc\dots{} The same applies to the other commands
%        mentioned in this section.}
%      |\MTencoding|\marg{enc},
%        |\MTfamily|\marg{fam},
%        |\MTseries|\marg{ser},
%        |\MTshape|\marg{sh}, and, new with version
%        |1.1|, |\MTlettershape|\marg{sh}. For
%        example valid values 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.
%      \item starting with version |1.12| \cs{Mathastext} accepts an
%      optional argument, which will serve as a name to
%      designate the corresponding math version. Without
%      optional argument \cs{Mathastext} redefines the default
%      normal and bold versions. This argument, being
%      optional, must be enclosed within square brackets.
%      \end{itemize}
%      \item
%        |\MTWillUse|\oarg{ltsh}\marg{enc}\marg{fam}\marg{ser}\marg{sh}:
%        tells |mathastext| 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
%      |\MTDeclareVersion|\oarg{ltsh}\marg{name}\marg{enc}\marg{fam}\marg{ser}\marg{sh}:
%      declares that the document will have access to the font
%      with the specified characteristics, under the version name
%      \meta{name}. For
%      example:\\
%      \hbox
%      to\hsize{\hss|\MTDeclareVersion[sc]{palatino}{T1}{ppl}{b}{sl}|\hss}
%      declares under the name |palatino| a version where
%      mathematics will be typset 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
%      optional argument is absent, and |mathastext| was loaded
%      with the |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.
%    \item |\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 |mathastext|. When used before the declaration
%      of a version, decides the way \cs{mathbf} will act in this version.
%    \item |\MTEulerScale|\marg{factor}: scales the Euler font by
%      \meta{factor}.
%    \item |\MTSymbolScale|\marg{factor}: scales the Symbol font by
%      \meta{factor}.
%    \end{itemize}
%
%    \subsection{Body Text and Math commands}
%
%    \begin{itemize}
%    \item
%      |\MTVersion|\oarg{nametext}\marg{namemath}:\footnote{\cs{MTVersion}
%      is also available as \cs{MTversion}.} in the absence
%      of the optional argument changes simultaneously the
%      text and the math font to be the font corresponding
%      to the version \meta{namemath}. If there is an
%      optional argument then the text font will use
%      \meta{nametext} and the math mode will use
%      \meta{namemath}. To change only the math font, use
%      the \LaTeX{} command \cs{mathversion}.
%    \end{itemize}
%    All further commands are for math mode only.
%    \begin{itemize}
%    \item \cs{hbar}: this is constructed
%      (in a way compatible with the |italic| option) from
%      the |h| letter and the \={ } accent from the
%      |mathastext| font. Note that \cs{mathrm}|{\hbar}| and
%      \cs{mathbf}|{\hbar}| should work and that \cs{hbar}
%      does scale in subscripts and exponents. Only for T1
%      and OT1 (or LY1) encodings.
%    \item |\fouriervec|: this is a |\vec| accent taken from the Fourier font;
%    the |fourier| package need not be loaded. Active only
%    if option |fouriervec|.
%    \item |\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 |\Mathnormal|, |\Mathrm|, |\Mathbf|: suitable modifications of the
%      original \cs{mathnormal}, \cs{mathrm}, \cs{mathbf}. By default, the
%      originals are also overwritten by the new commands.
%    \item |\mathnormalbold|: a bold version of \cs{mathnormal}.
%    \item |\inodot|, |\jnodot|: the corresponding glyphs in
%      the chosen font for math mode. By default, will
%      overwrite |\imath| and |\jmath|. With version |1.12|
%      by default |\i| and |\j| work also in math mode and
%      give then |\inodot|, resp. |\jnodot|. This should work for
%      all 8bit-encodings having these glyphs, and 
%      also in Unicode. 
%    \item |\MathEuler|, |\MathEulerBold|: math alphabets to access
%    all the glyphs of the Euler font, if option |eulergreek| (or
%    |eulerdigits|) was passed to the package.
%    \item |\MathPSymbol|: math alphabet to access the Symbol font.
%    \item Capital Greek letters: macro 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} are
%      provided for the capital Greek letters which look
%      like their Latin counterparts, when one of the
%      options |symbolgreek| (no \cs{Digamma} for Symbol),
%      |eulergreek| or |selfGreek| was passed to the
%      package. Also an \cs{omicron} control sequence is
%      provided.
%    \item LGR Greek and `var'-letters: only the
%      \cs{varsigma} is from the font, others such as
%      \cs{varphi} will load the previous default math
%      font. So when re-compiling a previously written
%      document it might be suitable to
%      \cs{let}\cs{varphi}$=$\cs{phi},
%      \cs{let}\cs{varepsilon}$=$\cs{epsilon}, etc\dots,
%      when only the `variant' form of the letter was used
%      therein.
%    \item Miscelleneous mathematical symbols from the
%      postscript Symbol font are made available (or
%      replaced) when option |symbolmisc| is passed. 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}~$\bullet$ \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$).
%    \end{itemize}
%
%  \section{Complete list of options}
%
%  \begin{itemize}
%  \item |basic|: only mathastextify letters and digits.
%  \item |italic|: the letters will default to italic shape in
%  math mode.
% \item |frenchmath|: |italic|, but uppercase Latin letters
%   in the same font as for digits and operator names. In
%   general this means that they will be upright. In case of
%   the |LGRgreek| option, this generally upright shape will
%   be applied also to Greek letters.
%  \item |endash|, |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 |noendash|: the minus sign will be the - from the
% text font, not the en-dash \textendash.
% \item |nohbar|: prevents |mathastext| from defining its own
%   \cs{hbar}.
% \item |nolessnomore|: besides
%   !\,?\,*\,,\,.\,:\,;\,+\,-\,=\,(\,)\,[\,]\,/\,\#\,\$\,\%\,\&
%   |mathastext| treats also \DeleteShortVerb{\|}
%   $\mathord{<}\,\mathord{>}\,\mathord{|}$\, \{\,\} and
%   $\backslash$.\MakeShortVerb{\|} Use this option to not
%   do it. The option |nolessnomore| is activated by default
%   in case of OT1-encoding.
%  \item further excluding options: |noexclam|\ !\,?\
%    |noasterisk|\ *\ |nopunct|\ ,\,.\,:\,;\ |noplus|,
%    |nominus|, |noplusnominus|\ +\,\textendash{} |noequal|\ =\
%    |noparenthesis|\, (\,)\,[\,]\,/ \ |nospecials|\
%    \#\,\$\,\%\,\& and |nodigits|.
%  \item |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 |symbolgreek|, |symboldigits|: to let Greek letters (digits) use the
%    Symbol font.
%  \item |symbolre|: replaces \cs{Re} and \cs{Im} by the
%  Symbol glyphs $\Re, \Im$ and defines a
%    \cs{DotTriangle} command ($\DotTriangle$).
%  \item |symbolmisc|: takes quite a few glyphs, including logical arrows,
%    product and sum signs from Symbol. They are listed \emph{supra}.. You may
%    also consider \cs{renewcommand}|{\int}{\smallint}| to maximize still more
%    the use of the Symbol font.
%  \item |symboldelimiters|: the characters apart from
%  letters and digits will be taken from the Symbol font. 
%  \item |symbol|: combines |symbolgreek|, |symbolre|, and |symbolmisc|.
%  \item |symbolmax|: combines |symbol| and |symboldelimiters|.
%  \item |eulergreek|, |eulerdigits|: to let Greek letters (digits) use the
%    Euler font.
%  \item |LGRgreek|: this is for a font which is also available in LGR-encoding.
%  \item |selfGreek|: this is for a font which has the capital Greek
%    letters at the OT1 slot positions.
%  \item |upgreek|, |itgreek|, |upGreek|, |itGreek|:
%  optional specification of the shapes of the Greek
%  letters, or only of the uppercase Greek letters. Only operant
%  in the case of the |LGRgreek| and |selfGreek| options.
%  \item |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. Will work only for T1, LY1, or OT1-compatible encodings.
%  \item |defaultrm|, |defaultbf|, |defaulnormal|: do not
%  overwrite the default \cs{mathrm}, \cs{mathbf}, \cs{mathnormal}.
%  \item |defaultimath|: do not overwrite \cs{imath} and
%  \cs{jmath}, do not extend \cs{i} and \cs{j} to math mode use.
%  \item |defaultmathsizes|: do not change the \LaTeX{} defaults.
%  \item |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.
%  \end{itemize}
%
% Thanks to Kevin~\textsc{Klement}, Tariq~\textsc{Perwez}
% and Ricard~\textsc{Torres} for bug reports and feature requests.
%
% \StopEventually{}
% 
% \section{Commented source code}
%
%
%    \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}
\ProvidesFile{mathastext.sty}
         [2011/03/11 1.13 Use the text font in simple mathematics]
%    \end{macrocode}
% I copied these macros from the |iftex| package of Vafa~\textsc{Khalighi}.
% Perhaps I should rather require the package? 
%    \begin{macrocode}
\newif\ifXeTeX
\begingroup\expandafter\expandafter\expandafter\endgroup
\expandafter\ifx\csname XeTeXinterchartoks\endcsname\relax
  \XeTeXfalse
\else
  \XeTeXtrue
\fi
\newif\ifLuaTeX
\begingroup\expandafter\expandafter\expandafter\endgroup
\expandafter\ifx\csname directlua\endcsname\relax
  \LuaTeXfalse
\else
  \LuaTeXtrue
\fi
%    \end{macrocode}
% We turn off the official loggings as we intend to write our owns
%    \begin{macrocode}
\def\mt@font@info@off{
\let\m@stext@info\@font@info
\let\m@stext@warning\@font@warning
\let\@font@info\@gobble
\let\@font@warning\@gobble}
\def\mt@font@info@on{
\let\@font@info\m@stext@info
\let\@font@warning\m@stext@warning}
\mt@font@info@off
%    \end{macrocode}
%   \begin{macro}{\m@stextenc}
%   \begin{macro}{\m@stextfam}
%   \begin{macro}{\m@stextser}
%   \begin{macro}{\m@stextsh}
%   \begin{macro}{\m@stextbold}
%   \begin{macro}{\m@stextshletter}
%     Internal variables. Will be redefined with \cs{def} later.
%    \begin{macrocode}
  \edef\m@stextenc{\encodingdefault}
  \edef\m@stextfam{\familydefault}
  \edef\m@stextser{\seriesdefault}
  \edef\m@stextsh{\shapedefault}
  \edef\m@stextbold{\bfdefault}
  \edef\m@stextshletter{\shapedefault}
\newif\ifmt@proceed
\newif\ifmt@failed
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% March 9, 2011: v1.13 introduces the option LGRgreek; and I
% make systematic use of \cs{if...} conditionals, for better
% readability of the code and error checking (too late for
% that!), although this means using a bit more of TeX
% resources.
%    \begin{macrocode}
\def\mt@oti{OT1}\def\mt@ti{T1}
\def\mt@eui{EU1}\def\mt@euii{EU2}
\def\mt@lyi{LY1}
%    \end{macrocode}
% \begin{macro}{Package options}
%    \begin{macrocode}
\newif\ifmt@italic\DeclareOption{italic}{\mt@italictrue
         \edef\m@stextshletter{\itdefault}}
\newif\ifmt@frenchmath
\DeclareOption{frenchmath}{\mt@frenchmathtrue
                        \ExecuteOptions{italic}}
%%
\newif\ifmt@endash\mt@endashtrue  
\DeclareOption{endash}{\mt@endashtrue}
\DeclareOption{noendash}{\mt@endashfalse}
\newif\ifmt@emdash\DeclareOption{emdash}{\mt@emdashtrue\mt@endashfalse}
%%
\newif\ifmt@alldelims
\DeclareOption{alldelims}{\mt@alldelimstrue}
\ifx\mt@oti\m@stextenc\else\mt@alldelimstrue\fi 
\DeclareOption{nolessnomore}{\mt@alldelimsfalse}
%%
\newif\ifmt@noplus\DeclareOption{noplus}{\mt@noplustrue}
\newif\ifmt@nominus\DeclareOption{nominus}{\mt@nominustrue}
\DeclareOption{noplusnominus}{\ExecuteOptions{noplus,nominus}}
%%
\newif\ifmt@noparen\DeclareOption{noparenthesis}{\mt@noparentrue}
\newif\ifmt@nopunct\DeclareOption{nopunctuation}{\mt@nopuncttrue}
\newif\ifmt@noequal\DeclareOption{noequal}{\mt@noequaltrue}
\newif\ifmt@noexclam\DeclareOption{noexclam}{\mt@noexclamtrue}
\newif\ifmt@noast\DeclareOption{noasterisk}{\mt@noasttrue}
\newif\ifmt@nospecials\DeclareOption{nospecials}{\mt@nospecialstrue}
\DeclareOption{basic}{\ExecuteOptions{noparenthesis,nopunctuation,%
noplusnominus,noequal,noexclam,noasterisk,nospecials,nolessnomore}}
%%
\newif\ifmt@nohbar\DeclareOption{nohbar}{\mt@nohbartrue}
\newif\ifmt@nodigits\DeclareOption{nodigits}{\mt@nodigitstrue}
\newif\ifmt@defaultimath\DeclareOption{defaultimath}{\mt@defaultimathtrue}
\newif\ifmt@mathaccents\DeclareOption{mathaccents}{\mt@mathaccentstrue}
%%
\newif\ifmt@selfGreek
    \DeclareOption{selfGreek}{\mt@selfGreektrue}
    \DeclareOption{selfgreek}{\mt@selfGreektrue}
\newif\ifmt@LGRgreek\DeclareOption{LGRgreek}{\mt@LGRgreektrue}
%%
\newif\ifmt@needsymbol
\newif\ifmt@symboldelimiters
\DeclareOption{symboldelimiters}{\mt@needsymboltrue\mt@symboldelimiterstrue}
\newif\ifmt@symboldigits
\DeclareOption{symboldigits}{\mt@needsymboltrue\mt@symboldigitstrue}
\newif\ifmt@symbolgreek
\DeclareOption{symbolgreek}{\mt@needsymboltrue\mt@symbolgreektrue}
\newif\ifmt@symbolre
\DeclareOption{symbolre}{\mt@needsymboltrue\mt@symbolretrue}
\newif\ifmt@symbolmisc
\DeclareOption{symbolmisc}{\mt@needsymboltrue\mt@symbolmisctrue}
\DeclareOption{symbol}{\ExecuteOptions{symbolgreek,symbolmisc,symbolre}}
\DeclareOption{symbolmax}{\ExecuteOptions{symbol,symboldelimiters}}
%%
\newif\ifmt@needeuler
\newif\ifmt@eulerdigits
\DeclareOption{eulerdigits}{\mt@needeulertrue\mt@eulerdigitstrue}
\newif\ifmt@eulergreek
\DeclareOption{eulergreek}{\mt@needeulertrue\mt@eulergreektrue}
%%
\newif\ifmt@twoshapesforgreek
\newif\ifmt@upgreek
\newif\ifmt@itgreek
\newif\ifmt@upGreek
\newif\ifmt@itGreek
\DeclareOption{upgreek}{\mt@upgreektrue}
\DeclareOption{itgreek}{\mt@itgreektrue}
\DeclareOption{upGreek}{\mt@twoshapesforgreektrue\mt@upGreektrue}
\DeclareOption{itGreek}{\mt@twoshapesforgreektrue\mt@itGreektrue}
%%
\newif\ifmt@defaultnormal
\DeclareOption{defaultnormal}{\mt@defaultnormaltrue}
\newif\ifmt@defaultrm
\DeclareOption{defaultrm}{\mt@defaultrmtrue}
\newif\ifmt@defaultbf
\DeclareOption{defaultbf}{\mt@defaultbftrue}
%    \end{macrocode}
% We intend to change the default script and scriptscript sizes, and also to
% declare a \cs{HUGE} size and modify the \cs{Huge} one at 12pt (taken from
% the |moresize| package). So we have an option to maintain default situation.
%    \begin{macrocode}
\newif\ifmt@defaultsizes\DeclareOption{defaultmathsizes}{\mt@defaultsizestrue}
\newif\ifmt@twelve\DeclareOption{12pt}{\mt@twelvetrue}
\newif\ifmt@fouriervec\DeclareOption{fouriervec}{\mt@fouriervectrue}
\DeclareOption*{\PackageWarning{mathastext}{Unknown option `\CurrentOption'}}
%%
\ProcessOptions\relax
%    \end{macrocode}
% \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}
    {\m@stextenc}{\m@stextfam}{\m@stextser}{\m@stextsh}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{mtletterfont}
%   In version 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}
       {\m@stextenc}{\m@stextfam}{\m@stextser}{\m@stextshletter}
\DeclareSymbolFontAlphabet{\Mathnormal}{mtletterfont}
\DeclareSymbolFontAlphabet{\Mathrm}{mtoperatorfont}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{LGRgreek}
% \begin{macro}{mtlgrfont}
% \begin{macro}{mtlgrfontupper}
% The LGRgreek option necessitates to define at least one
% additional symbol font |mtlgrfont|, and possibly a further
% one |mtlgrfontupper| for uppercase Greek.
%    \begin{macrocode}
\ifmt@LGRgreek
    \DeclareFontEncoding{LGR}{}{}
    \DeclareSymbolFont{mtlgrfont}{LGR}
            {\m@stextfam}{\m@stextser}{\m@stextshletter}
    \def\mtlgrfontupper{mtlgrfont}
    \ifmt@twoshapesforgreek
       \ifmt@upGreek
       \DeclareSymbolFont{mtlgrfontupper}{LGR}{\m@stextfam}{\m@stextser}{n}
       \else
       \DeclareSymbolFont{mtlgrfontupper}{LGR}{\m@stextfam}{\m@stextser}{it}
       \fi
     \def\mtlgrfontupper{mtlgrfontupper}
    \fi
\else
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{selfGreek}
% \begin{macro}{mtselffontupper}
% \begin{macro}{\mt@uppergreekfont}
% We must also make provisions for a possible additional
% font for uppercase Greek, in the case of the option
% selfGreek, when the shape is not necessarily
% \cs{m@stextsh} (that is \cs{shapedefault}). 
%    \begin{macrocode}
\ifmt@selfGreek\mt@proceedfalse
    \ifmt@upGreek\def\mt@tmp{n}\mt@proceedtrue\else
    \ifmt@upgreek\def\mt@tmp{n}\mt@proceedtrue\else
    \ifmt@itGreek\def\mt@tmp{it}\mt@proceedtrue\else
    \ifmt@itgreek\def\mt@tmp{it}\mt@proceedtrue
    \fi\fi\fi\fi
    \ifmt@proceed
       \def\mt@uppergreekfont{mtselffontupper}
       \DeclareSymbolFont{mtselffontupper}{\m@stextenc} % should be OT1!
            {\m@stextfam}{\m@stextser}{\mt@tmp}
    \else
       \ifmt@frenchmath
       \def\mt@uppergreekfont{mtoperatorfont}
       \else
       \def\mt@uppergreekfont{mtletterfont}
       \fi
%    \end{macrocode}
%       Used to be mtoperatorfont in versions prior to 1.13, so typically
%       upright. Not the case anymore (in the case of option italic for
%       example), to comply to ISO standard. Use upGreek if necessary. 
%    \begin{macrocode}
    \fi
\fi\fi
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{mteulervm}
% \begin{macro}{\MathEuler}
% In case we need the Euler font, we declare it here. It will use
% |uzeur.fd| from the |eulervm| package of Walter~\textsc{Schmidt}
%    \begin{macrocode}
\ifmt@needeuler
\DeclareSymbolFont{mteulervm}{U}{zeur}{m}{n}
\DeclareSymbolFontAlphabet{\MathEuler}{mteulervm}
\fi
\newcommand\MTEulerScale[1]{\edef\zeu@Scale{#1}}
\let\MathastextEulerScale\MTEulerScale
%    \end{macrocode}
% \end{macro}
% \end{macro}
% In the end, I moved the bold stuff to \cs{Mathastext} as
% the user may want his choice of |boldvariant| to have
% effect on the Euler font (it is possible to use
% \cs{Mathastextboldvariant}|{m}|).
% 
% \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. 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. It would be tricky but not
% impossible to coerce \cs{mathbf} to do something
% reasonable. I posted the method I have in mind to the
% texhax mailing list
% (|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 follow the simpler idea of the |eulervm| package and
% define \cs{MathEuler} and \cs{MathEulerBold} alphabet
% commands (the |eulervm| package does this only for the
% bold font).
% \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}
\ifmt@needsymbol
 \def\psy@scale{1}
 \DeclareSymbolFont{mtpsymbol}{U}{psy}{m}{n}
 \DeclareSymbolFontAlphabet{\MathPSymbol}{mtpsymbol}
\fi
\newcommand\MTSymbolScale[1]{\edef\psy@scale{#1}}
\let\MathastextSymbolScale\MTSymbolScale
%    \end{macrocode}
% I did not choose the name \cs{MathSymbol} as this name 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
%    \begin{macrocode}
\DeclareRobustCommand\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}.
%    \begin{macrocode}
\ifmt@fouriervec
  \DeclareFontEncoding{FML}{}{}
  \DeclareFontSubstitution{FML}{futm}{m}{it}
  \DeclareSymbolFont{mtfourierpourvec}{FML}{futm}{m}{it}
  \SetSymbolFont{mtfourierpourvec}{bold}{FML}{futm}{b}{it}
  \DeclareMathAccent{\fouriervec}{\mathord}{mtfourierpourvec}{"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 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.
%    \begin{macrocode}
\DeclareRobustCommand\MTencoding[1]{\def\m@stextenc{#1}}
\DeclareRobustCommand\MTfamily[1]{\def\m@stextfam{#1}}
\DeclareRobustCommand\MTseries[1]{\def\m@stextser{#1}}
\DeclareRobustCommand\MTshape[1]{\def\m@stextsh{#1}
  \ifmt@italic\else\def\m@stextshletter{#1}\fi}
\DeclareRobustCommand\MTboldvariant[1]{\def\m@stextbold{#1}}
\DeclareRobustCommand\MTlettershape[1]{\def\m@stextshletter{#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}{\MTWillUse}
% This is a preamble-only command, it can be called more than once, only the
% latest call counts.
%    \begin{macrocode}
\DeclareRobustCommand\MTWillUse[5][\@empty]{
  \MTencoding{#2}
  \MTfamily{#3}
  \MTseries{#4}
  \MTshape{#5}
  \ifx\@empty#1 
  \else 
%% we check if optional argument was [],  this does not detect [ ]
  \def\mt@empty{}\def\mt@tmp{#1}
   \ifx\mt@empty\mt@tmp\else\MTlettershape{#1}\fi
  \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 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 1.12, an optional argument makes
%    \cs{Mathastext} act as the Declaration of a math
%    version, to be later used in the document.
%    \begin{macrocode}
\DeclareRobustCommand\Mathastext[1][\@empty]{
  \mt@font@info@off
\ifx\@empty#1 % no optional argument 
  \edef\mt@encoding@normal{\m@stextenc}
  \edef\mt@family@normal{\m@stextfam}
  \edef\mt@series@normal{\m@stextser}
  \edef\mt@shape@normal{\m@stextsh}
  \edef\mt@ltshape@normal{\m@stextshletter}
  \edef\mt@boldvariant@normal{\m@stextbold}
  \edef\mt@encoding@bold{\m@stextenc}
  \edef\mt@family@bold{\m@stextfam}
  \edef\mt@series@bold{\m@stextbold}
  \edef\mt@shape@bold{\m@stextsh}
  \edef\mt@ltshape@bold{\m@stextshletter}
  \edef\mt@boldvariant@bold{\m@stextbold}
%%
   \SetSymbolFont{mtletterfont}{normal}{\mt@encoding@normal}
                                       {\mt@family@normal}
                                       {\mt@series@normal}
                                       {\mt@ltshape@normal}
   \SetSymbolFont{mtletterfont}{bold}  {\mt@encoding@bold}
                                       {\mt@family@bold}
                                       {\mt@series@bold}
                                       {\mt@ltshape@bold}
  \SetSymbolFont{mtoperatorfont}{normal}{\mt@encoding@normal}
                                       {\mt@family@normal}
                                       {\mt@series@normal}
                                       {\mt@shape@normal}
  \SetSymbolFont{mtoperatorfont}{bold} {\mt@encoding@bold}
                                       {\mt@family@bold}
                                       {\mt@series@bold}
                                       {\mt@shape@bold}
%    \end{macrocode}
% \begin{macro}{\Mathbf}
% 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). 
%    \begin{macrocode}
   \DeclareMathAlphabet{\Mathbf}  {\mt@encoding@bold}
                                 {\mt@family@bold}
                                 {\mt@series@bold}
                                 {\mt@shape@bold}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\mathnormalbold}
% We add a new Alphabet changing macro to standard \LaTeX{}
%    \begin{macrocode}
  \DeclareMathAlphabet{\mathnormalbold}  {\mt@encoding@bold}
                                 {\mt@family@bold}
                                 {\mt@series@bold}
                                 {\mt@ltshape@bold}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\MathEulerBold}
% We define it here as we leave open the possibility for the
% user to type \cs{Mathastextboldvariant}|{m}|.
%    \begin{macrocode}
 \ifmt@needeuler
    \SetSymbolFont{mteulervm}{bold}{U}{zeur}{\mt@boldvariant@normal}{n}
    \DeclareMathAlphabet{\MathEulerBold}{U}{zeur}{\mt@boldvariant@normal}{n}
 \fi
%    \end{macrocode}
% \end{macro}
%    \begin{macrocode}
 \ifmt@needsymbol\SetSymbolFont{mtpsymbol}{bold}
                     {U}{psy}{\mt@boldvariant@normal}{n}
 \fi
%    \end{macrocode}
% \begin{macro}{LGRgreek}
% LGRgreek option.
%    \begin{macrocode}
 \ifmt@LGRgreek
   \ifmt@upgreek\def\mt@tmp{n}
   \else\ifmt@itgreek\def\mt@tmp{it}
   \else\ifmt@frenchmath\def\mt@tmp{\mt@shape@normal}
   \else\def\mt@tmp{\mt@ltshape@normal}
   \fi\fi\fi
   \SetSymbolFont{mtlgrfont}{normal}{LGR}
            {\mt@family@normal}{\mt@series@normal}{\mt@tmp}
   \SetSymbolFont{mtlgrfont}{bold}{LGR}
            {\mt@family@bold}{\mt@boldvariant@normal}{\mt@tmp}
     \ifmt@twoshapesforgreek
       \ifmt@upGreek\def\mt@tmp{n}\else\def\mt@tmp{it}\fi
       \SetSymbolFont{mtlgrfontupper}{normal}{LGR}
            {\mt@family@normal}{\mt@series@normal}{\mt@tmp}
       \SetSymbolFont{mtlgrfontupper}{bold}{LGR}
            {\mt@family@bold}{\mt@boldvariant@bold}{\mt@tmp}
     \fi
%    \end{macrocode}
% \end{macro}
% \begin{macro}{selfGreek}
% selfGreek option.
%    \begin{macrocode}
 \else
 \ifmt@selfGreek
    \mt@proceedfalse
    \ifmt@upGreek\def\mt@tmp{n}\mt@proceedtrue\else
    \ifmt@upgreek\def\mt@tmp{n}\mt@proceedtrue\else
    \ifmt@itGreek\def\mt@tmp{it}\mt@proceedtrue\else
    \ifmt@itgreek\def\mt@tmp{it}\mt@proceedtrue
    \fi\fi\fi\fi
    \ifmt@proceed
       \SetSymbolFont{mtselffontupper}{normal}{\mt@encoding@normal}
            {\mt@family@normal}{\mt@series@normal}{\mt@tmp}
       \SetSymbolFont{mtselffontupper}{bold}{\mt@encoding@bold}
            {\mt@family@bold}{\mt@boldvariant@bold}{\mt@tmp}
    \fi
\fi\fi
%    \end{macrocode}
% \end{macro}
%    \begin{macrocode}
\typeout{** Latin letters in math versions normal (resp. bold) are now^^J%
    ** set up to use the fonts 
\mt@encoding@normal/\mt@family@normal/\mt@series@normal%
(\mt@boldvariant@normal)/\mt@ltshape@normal}
\ifmt@nodigits\else
  \typeout{** Other characters (digits, ...) and
    \protect\log-like names will be^^J%
** typeset with the \expandafter`\mt@shape@normal' shape.}
 \fi
\else % optional argument, then we rather do DeclareVersion
 \edef\mt@tmp{#1}\def\mt@empty{}
 \ifx\mt@tmp\mt@empty
    \Mathastext  % no infinite loop!
  \else
    \MTDeclareVersion[\m@stextshletter]{#1}
         {\m@stextenc}{\m@stextfam}{\m@stextser}{\m@stextsh}
 \fi
\fi
\mt@font@info@on
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\MTDeclareVersion}
% The \cs{MTDeclareVersion} command is to be used in the preamble to
% declare a math version. I refrained from providing a more complicated one
% which 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}||{version}||{U}{zeur}{bx}{n}| if one
% wants to have a math version with bold Euler characters.
%
% For version 1.1 we add an optional parameter specifying the shape to be used
% for letters: most users will want `it' (thus going contrary to the
% philosophy which motivated me writing this package!). If the package option
% `italic' was passed, `it' is the default.
%    \begin{macrocode}
\DeclareRobustCommand\MTDeclareVersion[6][\@empty]{
  \mt@font@info@off
  \edef\mt@version{#2}
  \DeclareMathVersion{\mt@version}
  \expandafter\edef\csname mt@encoding@\mt@version\endcsname{#3}
  \expandafter\edef\csname mt@family@\mt@version\endcsname{#4}
  \expandafter\edef\csname mt@series@\mt@version\endcsname{#5}
  \expandafter\edef\csname mt@shape@\mt@version\endcsname{#6}
  \expandafter\edef\csname mt@boldvariant@\mt@version\endcsname{\m@stextbold}
  \newif\ifmt@reallynoopt\mt@reallynoopttrue
    \ifx\@empty#1
    \else % we check nevertheless for [] situation, will not work with [ ]
       \def\mt@@tmp{#1}\def\mt@empty{}
       \ifx\mt@@tmp\mt@empty\else\mt@reallynooptfalse\fi
    \fi
  \ifmt@reallynoopt
    \ifmt@italic
      \SetSymbolFont{mtletterfont}{#2}{#3}{#4}{#5}{\m@stextshletter}
    \typeout{** Latin letters in math version `#2' will use the font
    #3/#4/#5/\m@stextshletter^^J%    
    ** Other characters (digits, ...) and \protect\log-like names 
                    will be in `#6' shape.}
      \expandafter\edef\csname mt@ltshape@\mt@version\endcsname{\m@stextshletter}
    \else
      \SetSymbolFont{mtletterfont}{#2}{#3}{#4}{#5}{#6}
    \typeout{** Latin letters in math version `#2' will use the fonts
    #3/#4/#5(\m@stextbold)/#6}
      \expandafter\edef\csname mt@ltshape@\mt@version\endcsname{#6}
    \fi
  \else
      \SetSymbolFont{mtletterfont}{#2}{#3}{#4}{#5}{#1}
    \typeout{** Latin letters in math version `#2' will use the font
    #3/#4/#5/#1^^J%
    ** Other characters (digits, ...) and \protect\log-like
    names will be in `#6' shape.} 
      \expandafter\edef\csname mt@ltshape@\mt@version\endcsname{#1}
  \fi
  \SetMathAlphabet{\Mathbf}{#2}{#3}{#4}{\m@stextbold}{#6}
  \SetSymbolFont{mtoperatorfont}{#2}{#3}{#4}{#5}{#6}
  \ifmt@needeuler
      \SetMathAlphabet{\MathEulerBold}{#2}{U}{zeur}{\m@stextbold}{n}
  \fi
%    \end{macrocode}
% \begin{macro}{mtlgrfont}
% In the case of option LGRgreek, it is expected that the
% fonts used in each math versions exist in LGR encoding.
%    \begin{macrocode}
 \ifmt@LGRgreek
   \ifmt@upgreek\def\mt@tmp{n}
   \else\ifmt@itgreek\def\mt@tmp{it}
   \else\ifmt@frenchmath\def\mt@tmp{\csname mt@shape@\mt@version\endcsname}
   \else\def\mt@tmp{\csname mt@ltshape@\mt@version\endcsname}
   \fi\fi\fi
      \SetSymbolFont{mtlgrfont}{#2}{LGR}{#4}{#5}{\mt@tmp}
%%    \typeout{** Greek letters in math version `#2' will use the font
%%     LGR/#4/#5/\mt@tmp}
   \ifmt@twoshapesforgreek
       \ifmt@upGreek\def\mt@tmp{n}\else\def\mt@tmp{it}\fi
       \SetSymbolFont{mtlgrfontupper}{#2}{LGR}{#4}{#5}{\mt@tmp}
%%    \typeout{** Uppercase Greek letters in math version `#2' will use the font
%%     LGR/#4/#5/\mt@tmp}
   \fi
%    \end{macrocode}
% \end{macro}
% \begin{macro}{mtlgrfont}
% selfGreek
%    \begin{macrocode}
\else
 \ifmt@selfGreek 
    \mt@proceedfalse
    \ifmt@upGreek\def\mt@tmp{n}\mt@proceedtrue\else
    \ifmt@upgreek\def\mt@tmp{n}\mt@proceedtrue\else
    \ifmt@itGreek\def\mt@tmp{it}\mt@proceedtrue\else
    \ifmt@itgreek\def\mt@tmp{it}\mt@proceedtrue
    \fi\fi\fi\fi
    \ifmt@proceed
       \SetSymbolFont{mtselffontupper}{#2}{#3}{#4}{#5}{\mt@tmp}
    \fi
\fi\fi
%    \end{macrocode}
% \end{macro}
%    \begin{macrocode}
  \mt@font@info@on
}
\let\MathastextDeclareVersion\MTDeclareVersion
%    \end{macrocode}
% \end{macro}
% We redefine our internal variables without expansion
% so that they get a chance to be also (indirectly or
% directly) modified by user later choices regarding
% \cs{encodingdefault}, etc\dots, previous to a user call to
% \cs{Mathastext} or \cs{Mathastextwilluse}.
%    \begin{macrocode}
  \def\m@stextenc{\encodingdefault}
  \def\m@stextfam{\familydefault}
  \def\m@stextser{\seriesdefault}
  \def\m@stextsh{\shapedefault}
  \def\m@stextbold{\bfdefault}
  \def\m@stextshletter{\shapedefault}
  \ifmt@italic\def\m@stextshletter{\itdefault}\fi
%    \end{macrocode}
% Initialization call:
%    \begin{macrocode}
\Mathastext
%    \end{macrocode}
% \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 |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{macrocode}
\def\operator@font{\mathgroup\symmtoperatorfont}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\mathnormal}
% \begin{macro}{\mathrm}
% \begin{macro}{\mathbf}
% We redefine the normal, rm and bf alphabets. In version 1.1 we
% follow the standard: normal gives the font for letters, rm gives
% the font for digits and log-like names, bf for the bold series
% of the font for digits and log-like names. 
%
% We will access by default (if no option is passed for
% Greek) the \cs{omicron} via \cs{mathnormal}. So we save it
% for future use.  But unfortunately the Fourier package
% with the upright option does not have an upright omicron
% obtainable by simply typing \cs{mathnormal}|{o}|. So in
% this case we shall use \cs{mathrm} and not
% \cs{mathnormal}.
%    \begin{macrocode}
\let\mt@saved@mathnormal\mathnormal 
\@ifpackageloaded{fourier}{\ifsloped\else\let\mt@saved@mathnormal\mathrm\fi}{}
\ifmt@defaultnormal\else\renewcommand{\mathnormal}{\Mathnormal}\fi
\ifmt@defaultrm\else\renewcommand{\mathrm}{\Mathrm}\fi
\ifmt@defaultbf\else\renewcommand{\mathbf}{\Mathbf}\fi
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% We write appropriate messages to the terminal and the log.
%    \begin{macrocode}
%% \ifmt@LGRgreek
%%     \typeout{** Greek letters will use the font
%%     LGR/\mt@family@normal/\mt@series@normal/\mt@ltshape@normal}
%% \else
\ifmt@selfGreek
     \typeout{** Capital Greek letters will be taken from the fonts
       declared for latin letters:^^J%  
** only for OT1 or compatible encodings; glyphs may be unavailable.}
\else
\ifmt@eulergreek
      \typeout{** Greek letters will use the Euler font. Use^^J%
** \protect\MathastextEulerScale{<factor>} to scale the font.}
\else
\ifmt@symbolgreek
       \typeout{** Greek letters will use the PostScript Symbol font. Use^^J%
** \protect\MathastextSymbolScale{<factor>} to scale the font.}
\fi\fi\fi
%%\fi
%    \end{macrocode}
% \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 font.
%    \begin{macrocode}
\DeclareRobustCommand\MTVersion[2][\@empty]{%
    \mathversion{#2}%
    \ifx\@empty#1% no optional argument
        \edef\mt@tmp{#2}
    \else% we check nevertheless for [] situation, will not work with [ ]
       \def\mt@@tmp{#1}\def\mt@empty{}%
       \ifx\mt@@tmp\mt@empty\edef\mt@tmp{#2}%
       \else\edef\mt@tmp{#1}%
       \fi%
    \fi%
    \usefont{\csname mt@encoding@\mt@tmp\endcsname}%
        {\csname mt@family@\mt@tmp\endcsname}%
        {\csname mt@series@\mt@tmp\endcsname}%
        {\csname mt@shape@\mt@tmp\endcsname}%
    \edef\mt@@encoding{\csname mt@encoding@\mt@tmp\endcsname}%
\renewcommand{\encodingdefault}{\mt@@encoding}%
    \edef\mt@@family{\csname mt@family@\mt@tmp\endcsname}%
\renewcommand{\rmdefault}{\mt@@family}%
    \edef\mt@@series{\csname mt@series@\mt@tmp\endcsname}%
\renewcommand{\mddefault}{\mt@@series}%
    \edef\mt@@shape{\csname mt@shape@\mt@tmp\endcsname}%
\renewcommand{\updefault}{\mt@@shape}%
    \edef\mt@@boldvariant{\csname mt@boldvariant@\mt@tmp\endcsname}%
\renewcommand{\bfdefault}{\mt@@boldvariant}}
\let\MathastextVersion\MTVersion
\let\Mathastextversion\MTVersion
\let\MTversion\MTVersion
%    \end{macrocode}
% \end{macro}
% At last we now change the font for the letters of the latin alphabet. 
% In version 1.1, Latin letters have their own font (shape). 
%    \begin{macrocode}
\DeclareMathSymbol{a}{\mathalpha}{mtletterfont}{`a}
\DeclareMathSymbol{b}{\mathalpha}{mtletterfont}{`b}
\DeclareMathSymbol{c}{\mathalpha}{mtletterfont}{`c}
\DeclareMathSymbol{d}{\mathalpha}{mtletterfont}{`d}
\DeclareMathSymbol{e}{\mathalpha}{mtletterfont}{`e}
\DeclareMathSymbol{f}{\mathalpha}{mtletterfont}{`f}
\DeclareMathSymbol{g}{\mathalpha}{mtletterfont}{`g}
\DeclareMathSymbol{h}{\mathalpha}{mtletterfont}{`h}
\DeclareMathSymbol{i}{\mathalpha}{mtletterfont}{`i}
\DeclareMathSymbol{j}{\mathalpha}{mtletterfont}{`j}
\DeclareMathSymbol{k}{\mathalpha}{mtletterfont}{`k}
\DeclareMathSymbol{l}{\mathalpha}{mtletterfont}{`l}
\DeclareMathSymbol{m}{\mathalpha}{mtletterfont}{`m}
\DeclareMathSymbol{n}{\mathalpha}{mtletterfont}{`n}
\DeclareMathSymbol{o}{\mathalpha}{mtletterfont}{`o}
\DeclareMathSymbol{p}{\mathalpha}{mtletterfont}{`p}
\DeclareMathSymbol{q}{\mathalpha}{mtletterfont}{`q}
\DeclareMathSymbol{r}{\mathalpha}{mtletterfont}{`r}
\DeclareMathSymbol{s}{\mathalpha}{mtletterfont}{`s}
\DeclareMathSymbol{t}{\mathalpha}{mtletterfont}{`t}
\DeclareMathSymbol{u}{\mathalpha}{mtletterfont}{`u}
\DeclareMathSymbol{v}{\mathalpha}{mtletterfont}{`v}
\DeclareMathSymbol{w}{\mathalpha}{mtletterfont}{`w}
\DeclareMathSymbol{x}{\mathalpha}{mtletterfont}{`x}
\DeclareMathSymbol{y}{\mathalpha}{mtletterfont}{`y}
\DeclareMathSymbol{z}{\mathalpha}{mtletterfont}{`z}
\ifmt@frenchmath\def\mt@font@tbu{mtoperatorfont}
   \else\def\mt@font@tbu{mtletterfont}\fi
\DeclareMathSymbol{A}{\mathalpha}{\mt@font@tbu}{`A}
\DeclareMathSymbol{B}{\mathalpha}{\mt@font@tbu}{`B}
\DeclareMathSymbol{C}{\mathalpha}{\mt@font@tbu}{`C}
\DeclareMathSymbol{D}{\mathalpha}{\mt@font@tbu}{`D}
\DeclareMathSymbol{E}{\mathalpha}{\mt@font@tbu}{`E}
\DeclareMathSymbol{F}{\mathalpha}{\mt@font@tbu}{`F}
\DeclareMathSymbol{G}{\mathalpha}{\mt@font@tbu}{`G}
\DeclareMathSymbol{H}{\mathalpha}{\mt@font@tbu}{`H}
\DeclareMathSymbol{I}{\mathalpha}{\mt@font@tbu}{`I}
\DeclareMathSymbol{J}{\mathalpha}{\mt@font@tbu}{`J}
\DeclareMathSymbol{K}{\mathalpha}{\mt@font@tbu}{`K}
\DeclareMathSymbol{L}{\mathalpha}{\mt@font@tbu}{`L}
\DeclareMathSymbol{M}{\mathalpha}{\mt@font@tbu}{`M}
\DeclareMathSymbol{N}{\mathalpha}{\mt@font@tbu}{`N}
\DeclareMathSymbol{O}{\mathalpha}{\mt@font@tbu}{`O}
\DeclareMathSymbol{P}{\mathalpha}{\mt@font@tbu}{`P}
\DeclareMathSymbol{Q}{\mathalpha}{\mt@font@tbu}{`Q}
\DeclareMathSymbol{R}{\mathalpha}{\mt@font@tbu}{`R}
\DeclareMathSymbol{S}{\mathalpha}{\mt@font@tbu}{`S}
\DeclareMathSymbol{T}{\mathalpha}{\mt@font@tbu}{`T}
\DeclareMathSymbol{U}{\mathalpha}{\mt@font@tbu}{`U}
\DeclareMathSymbol{V}{\mathalpha}{\mt@font@tbu}{`V}
\DeclareMathSymbol{W}{\mathalpha}{\mt@font@tbu}{`W}
\DeclareMathSymbol{X}{\mathalpha}{\mt@font@tbu}{`X}
\DeclareMathSymbol{Y}{\mathalpha}{\mt@font@tbu}{`Y}
\DeclareMathSymbol{Z}{\mathalpha}{\mt@font@tbu}{`Z}
%%
\ifmt@nodigits\else
\def\mt@font@tbu{mtoperatorfont}
%    \end{macrocode}
% In version 1.1, we have now separated digits from letters, so paradoxically
% it is less problematic to give them the |mathalpha| type. 
%    \begin{macrocode}
\ifmt@symboldigits \def\mt@font@tbu{mtpsymbol} \fi
\ifmt@eulerdigits \def\mt@font@tbu{mteulervm} \fi
\DeclareMathSymbol{0}{\mathalpha}{\mt@font@tbu}{`0}
\DeclareMathSymbol{1}{\mathalpha}{\mt@font@tbu}{`1}
\DeclareMathSymbol{2}{\mathalpha}{\mt@font@tbu}{`2}
\DeclareMathSymbol{3}{\mathalpha}{\mt@font@tbu}{`3}
\DeclareMathSymbol{4}{\mathalpha}{\mt@font@tbu}{`4}
\DeclareMathSymbol{5}{\mathalpha}{\mt@font@tbu}{`5}
\DeclareMathSymbol{6}{\mathalpha}{\mt@font@tbu}{`6}
\DeclareMathSymbol{7}{\mathalpha}{\mt@font@tbu}{`7}
\DeclareMathSymbol{8}{\mathalpha}{\mt@font@tbu}{`8}
\DeclareMathSymbol{9}{\mathalpha}{\mt@font@tbu}{`9}
\fi
%    \end{macrocode}
% When |symboldelimiters| is passed as an option, we use the
% Symbol font for the printable characters other than
% letters and digits. 
%    \begin{macrocode}
\ifmt@symboldelimiters 
\def\mt@font@tbu{mtpsymbol}
\mt@endashfalse
\mt@emdashfalse
\else
\def\mt@font@tbu{mtoperatorfont}
\fi
%%
\ifmt@noexclam\else
\DeclareMathSymbol{!}{\mathclose}{\mt@font@tbu}{"21}
\DeclareMathSymbol{?}{\mathclose}{\mt@font@tbu}{"3F}
\fi
%%
\ifmt@noast\else
\DeclareMathSymbol{*}{\mathalpha}{\mt@font@tbu}{"2A} 
\fi
%    \end{macrocode}
% We completely 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 |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).
%    \begin{macrocode}
\ifmt@nopunct\else
\DeclareMathSymbol{,}{\mathpunct}{\mt@font@tbu}{"2C}
\DeclareMathSymbol{.}{\mathord}{\mt@font@tbu}{"2E}
\DeclareMathSymbol{:}{\mathrel}{\mt@font@tbu}{"3A} % relation spacing
\@ifpackageloaded{amsmath}
    {} %\colon defined in amsmath.sty (enlarged punctuation spacing)
    {\let\colon\undefined  % no amsmath, use punctuation spacing
    \DeclareMathSymbol{\colon}{\mathpunct}{\mt@font@tbu}{"3A}} 
\DeclareMathSymbol{;}{\mathpunct}{\mt@font@tbu}{"3B}
\fi
%    \end{macrocode}
% \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.
%    \begin{macrocode}
\ifmt@nominus\else
\edef\mt@minus@sign{\mathord{\expandafter\mathchar\number\mathcode`\-}}
\def\relbar{\mathrel{\smash\mt@minus@sign}}
\def\rightarrowfill{$\m@th\mt@minus@sign\mkern-7mu%
  \cleaders\hbox{$\mkern-2mu\mt@minus@sign\mkern-2mu$}\hfill
  \mkern-7mu\mathord\rightarrow$}
\def\leftarrowfill{$\m@th\mathord\leftarrow\mkern-7mu%
  \cleaders\hbox{$\mkern-2mu\mt@minus@sign\mkern-2mu$}\hfill
  \mkern-7mu\smash\mt@minus@sign$}
\fi
%    \end{macrocode}
% \end{macro}
% \begin{macro}{endash}
%   2011/01/29, v1.1 Producing this next piece of code was
%   not a piece of cake for a novice like myself!  I got
%   some LaTeX internal info from ltoutenc.dtx. However this
%   will only work in the math versions having the same
%   encoding as defined by default.
%   2011/02/05, v1.11. Compatibility with Unicode (via
%   fontspec encodings EU1 and EU2)
%   2011/02/07, v1.12. Improved dealing of unicode engines.
%    \begin{macrocode}
\def\do@the@endashstuff{\edef\mt@enc{\m@stextenc}
\ifx\mt@enc\mt@eui % xetex+fontspec
  \XeTeXmathcode`\-="2 "\the\symmtoperatorfont "2013 \relax
\else
\ifx\mt@enc\mt@euii % luatex+fontspec
   \luatexUmathcode`\-="2 "\the\symmtoperatorfont "2013 \relax
\else 
\ifx\mt@enc\mt@ti % T1
   \DeclareMathSymbol{-}{\mathbin}{mtoperatorfont}{21}
\else
\ifx\mt@enc\mt@oti % OT1
   \DeclareMathSymbol{-}{\mathbin}{mtoperatorfont}{123}
\else
\ifx\mt@enc\mt@lyi % LY1
   \DeclareMathSymbol{-}{\mathbin}{mtoperatorfont}{150}
\else % make sure we have neither xetex nor luatex
   \ifXeTeX\mt@failedtrue\else\ifLuaTeX\mt@failedtrue\else
   \DeclareMathSymbol{-}{\mathbin}{mtoperatorfont}
{\expandafter\the\expandafter\csname\mt@enc\string\textendash\endcsname}
   \fi\fi
\fi\fi\fi\fi\fi}
\def\do@the@emdashstuff{\edef\mt@enc{\m@stextenc}
\ifx\mt@enc\mt@eui % xetex+fontspec
  \XeTeXmathcode`\-="2 "\the\symmtoperatorfont "2014 \relax
\else
\ifx\mt@enc\mt@euii % luatex+fontspec
   \luatexUmathcode`\-="2 "\the\symmtoperatorfont "2014 \relax
\else 
\ifx\mt@enc\mt@ti % T1
   \DeclareMathSymbol{-}{\mathbin}{mtoperatorfont}{22}
\else
\ifx\mt@enc\mt@oti % OT1
   \DeclareMathSymbol{-}{\mathbin}{mtoperatorfont}{124}
\else
\ifx\mt@enc\mt@lyi % LY1
   \DeclareMathSymbol{-}{\mathbin}{mtoperatorfont}{151}
\else % make sure we have neither xetex nor luatex
   \ifXeTeX\mt@failedtrue\else\ifLuaTeX\mt@failedtrue\else
   \DeclareMathSymbol{-}{\mathbin}{mtoperatorfont}
{\expandafter\the\expandafter\csname\mt@enc\string\textemdash\endcsname}
   \fi\fi
\fi\fi\fi\fi\fi}
\ifmt@nominus\else
\mt@failedfalse
\ifmt@endash\do@the@endashstuff\else
\ifmt@emdash\do@the@emdashstuff\else
   \DeclareMathSymbol{-}{\mathbin}{\mt@font@tbu}{"2D}
\fi\fi
\ifmt@failed\DeclareMathSymbol{-}{\mathbin}{\mt@font@tbu}{"2D}\fi
\fi
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\hbar}
% \begin{macro}{\mt@ltbar}
% 2011/01/31, v1.1 I decide to settle the question of the |\hbar|. First, I
% should repeat the \LaTeX{} definition
%    \begin{macrocode}
%%\def\hbar{{\mathchar'26\mkern-9muh}} 
%% (original definition from latex.ltx)
%    \end{macrocode}
% Well, the fact is that there is a DeclareMathSymbol in |amsfonts.sty|, so I
% can not always rely on the original which had the advantage that at least
% |h| would be in the correct font. But of course not the macron character
% (|\=|, |\bar|). And there is also the issue of the kern whose length is
% given in a way which depends on |cmsy| (18mu=1em and em taken from info in
% |cmsy|). The first problem is that I don't know how to get the slot position
% of the macron, given the encoding. So I found another way. 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|.
%    \begin{macrocode}
\def\mathrlap{\mathpalette\mathrlapinternal}
\def\mathrlapinternal#1#2{\rlap{$\mathsurround=0pt#1{#2}$}}
\def\do@the@hbarstuff{\edef\mt@enc{\m@stextenc}
\ifx\mt@enc\mt@eui % xetex and unicode font
  \XeTeXmathchardef\hbar="7 "\the\symmtoperatorfont "0127 \relax 
\else
\ifx\mt@enc\mt@euii % luatex and unicode font
   \luatexUmathchardef\hbar="7 "\the\symmtoperatorfont "0127 \relax %% or 210F?
\else % I must leave open the T1, OT1 possibility also for XeTeX or LuaTeX 
    \ifx\mt@ti\mt@enc
    \DeclareMathAccent{\mt@ltbar}{\mathalpha}{mtletterfont}{9}
       \else  %% assume OT1. Bad idea? Should not provoke an error anyhow
    \DeclareMathAccent{\mt@ltbar}{\mathalpha}{mtletterfont}{22}
    \fi
    \def\hbar{\mathrlap{\mt@ltbar{\ }}h}
\fi\fi}
\ifmt@nohbar\else\do@the@hbarstuff\fi
%    \end{macrocode}
% \end{macro}
% \end{macro}
% As |h| is from |mtletterfont|, the accent \cs{mt@ltbar} is the
% \cs{bar} accent from that same font. Of course, if the user
% defines math versions with other encodings than the default one
% when loading the package this will probably not work there (if I
% knew how to do for accents what I did for the endash I could do
% it for all encodings. Surely easy for a \TeX{}pert.)  Not to
% mention if he/she changes the letter shape... one never should
% give so much freedom to users ;-) Well this construction gives
% an acceptable result for some of the fonts I have tested,
% whether upright or in italics.
% \begin{macro}{+,=,\Relbar}
%    \begin{macrocode}
\ifmt@noplus\else
\DeclareMathSymbol{+}{\mathbin}{\mt@font@tbu}{"2B}
\fi
\ifmt@noequal\else
\edef\mt@equal@sign{{\expandafter\mathchar\number\mathcode`\=}}
\DeclareRobustCommand\Relbar{\mathrel{\mt@equal@sign}}
\DeclareMathSymbol{=}{\mathrel}{\mt@font@tbu}{"3D}
\fi
%    \end{macrocode}
% \end{macro}
% \begin{macro}{(,),[,],/}
%    \begin{macrocode}
\ifmt@noparen\else
\DeclareMathDelimiter{(}{\mathopen} {\mt@font@tbu}{"28}{largesymbols}{"00}
\DeclareMathDelimiter{)}{\mathclose}{\mt@font@tbu}{"29}{largesymbols}{"01}
\DeclareMathDelimiter{[}{\mathopen} {\mt@font@tbu}{"5B}{largesymbols}{"02}
\DeclareMathDelimiter{]}{\mathclose}{\mt@font@tbu}{"5D}{largesymbols}{"03}
\DeclareMathDelimiter{/}{\mathord}{\mt@font@tbu}{"2F}{largesymbols}{"0E}
\DeclareMathSymbol{/}{\mathord}{\mt@font@tbu}{"2F}
\fi
%    \end{macrocode}
% \end{macro}
% \begin{macro}{alldelims}
%    \begin{macrocode}
\ifmt@alldelims
%%   \ifmt@symboldelimiters\else
%%   \ifx\mt@ti\mt@enc\else
%%   \typeout{** mathastext: `alldelims'. Characters <,>,{,},| will be assumed
%%        to^^J% 
%%       ** be located as in ascii. True for T1 fonts or OT1 fixed-width fonts.}
%%    \fi\fi
\DeclareMathDelimiter{<}{\mathopen}{\mt@font@tbu}{"3C}{largesymbols}{"0A}
\DeclareMathDelimiter{>}{\mathclose}{\mt@font@tbu}{"3E}{largesymbols}{"0B}
\DeclareMathSymbol{<}{\mathrel}{\mt@font@tbu}{"3C}
\DeclareMathSymbol{>}{\mathrel}{\mt@font@tbu}{"3E}
%    \end{macrocode}
% There is no backslash in the Symbol font
%    \begin{macrocode}
\expandafter\DeclareMathDelimiter\@backslashchar
                        {\mathord}{mtoperatorfont}{"5C}{largesymbols}{"0F}
\DeclareMathDelimiter{\backslash}   
    {\mathord}{mtoperatorfont}{"5C}{largesymbols}{"0F}
\DeclareMathSymbol\setminus\mathbin{mtoperatorfont}{"5C}
\DeclareMathSymbol{|}\mathord{\mt@font@tbu}{"7C}
\DeclareMathDelimiter{|}{\mt@font@tbu}{"7C}{largesymbols}{"0C}
%    \end{macrocode}
% I stopped short of redeclaring also \cs{Vert}!
%    \begin{macrocode}
\DeclareMathDelimiter\vert
                 \mathord{\mt@font@tbu}{"7C}{largesymbols}{"0C}
\DeclareMathSymbol\mid\mathrel{\mt@font@tbu}{"7C}
\DeclareMathDelimiter{\lbrace}
   {\mathopen}{\mt@font@tbu}{"7B}{largesymbols}{"08}
\DeclareMathDelimiter{\rbrace}
   {\mathclose}{\mt@font@tbu}{"7D}{largesymbols}{"09}
\fi
%    \end{macrocode}
% \end{macro}
% \begin{macro}{specials}
% We never take the specials from the Symbol (Adobe) font, as they are not all
% available there.
%    \begin{macrocode}
\ifmt@nospecials\else
\renewcommand{\#}{\ifmmode\edef\ms@tmp{7\the\symmtoperatorfont23}%
\mathchar\expandafter"\ms@tmp\relax\else\char"23\relax\fi}
\renewcommand{\$}{\ifmmode\edef\ms@tmp{7\the\symmtoperatorfont24}%
\mathchar\expandafter"\ms@tmp\relax\else\char"24\relax\fi}
\renewcommand{\%}{\ifmmode\edef\ms@tmp{7\the\symmtoperatorfont25}%
\mathchar\expandafter"\ms@tmp\relax\else\char"25\relax\fi}
\renewcommand{\&}{\ifmmode\edef\ms@tmp{7\the\symmtoperatorfont26}%
\mathchar\expandafter"\ms@tmp\relax\else\char"26\relax\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{macrocode}
\ifmt@symbolmisc   
\let\prod\undefined
\DeclareMathSymbol{\prod}{\mathop}{mtpsymbol}{213}
\let\sum\undefined
\DeclareMathSymbol{\sum}{\mathop}{mtpsymbol}{229}
\DeclareMathSymbol{\mt@implies}{\mathrel}{mtpsymbol}{222}
\DeclareRobustCommand{\implies}{\;\mt@implies\;}
\DeclareMathSymbol{\mt@impliedby}{\mathrel}{mtpsymbol}{220}
\DeclareRobustCommand{\impliedby}{\;\mt@impliedby\;}
\DeclareRobustCommand{\iff}{\;\mt@impliedby\mathrel{\mkern-3mu}\mt@implies\;}
\DeclareMathSymbol{\mt@iff}{\mathrel}{mtpsymbol}{219}
\DeclareRobustCommand{\shortiff}{\;\mt@iff\;}
\DeclareMathSymbol{\mt@to}{\mathrel}{mtpsymbol}{174}
\DeclareMathSymbol{\mt@trait}{\mathrel}{mtpsymbol}{190}
\DeclareRobustCommand\to{\mt@to}
\DeclareRobustCommand\longto{\mkern2mu\mt@trait\mathrel{\mkern-10mu}\mt@to}
\DeclareRobustCommand\mapsto{\mapstochar\mathrel{\mkern0.2mu}\mt@to}
\DeclareRobustCommand\longmapsto{%
\mapstochar\mathrel{\mkern2mu}\mt@trait\mathrel{\mkern-10mu}\mt@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{*}{\mathbin}{mtpsymbol}{42} 
\DeclareMathSymbol{\ast}{\mathbin}{mtpsymbol}{42}
\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}
\ifmt@symbolre
\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 
% 
% v1.11 I correct some bugs on how eulergreek and
% symbolgreek interacted.
%
% v1.12b I introduced another very stupid bug (regarding
% uppercase Greek) in v1.1. This is corrected here. All this
% business of checking for \cs{digamma} was truly stupid as
% some package might well have defined the font for Greek
% without having defined \cs{digamma}, I don't know what
% crossed my dumb mind when I committed this insane code and
% started redefining uppercase Greek, and it is even worse
% than that as I was redefining not only relatively benign
% things such as \cs{Alpha} but also \cs{Phi} etc\dots
%
% v1.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.  
%       * version 1.12b did not define the \cs{omicron} in the case when no
%       Greek-related option was passed to the package. This was a bug.  
%    \begin{macrocode}
\let\mt@mathord\mathalpha
\mt@proceedtrue
\ifmt@selfGreek 
    \def\mt@font@tbu{\mt@uppergreekfont}
 \else
\ifmt@eulergreek 
    \def\mt@font@tbu{mteulervm} 
 \else
\ifmt@symbolgreek 
    \def\mt@font@tbu{mtpsymbol}
    \let\mt@mathord\mathord
 \else
\ifmt@LGRgreek
     \mt@proceedfalse
 \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}
       \mt@proceedfalse
       \ifx\omicron\undefined
       \newcommand{\omicron}{\mt@saved@mathnormal{o}}
       \fi  
\fi\fi\fi\fi
\ifmt@proceed
\DeclareMathSymbol{\Alpha}{\mt@mathord}{\mt@font@tbu}{"41}
\DeclareMathSymbol{\Beta}{\mt@mathord}{\mt@font@tbu}{"42}
\DeclareMathSymbol{\Epsilon}{\mt@mathord}{\mt@font@tbu}{"45}
\DeclareMathSymbol{\Zeta}{\mt@mathord}{\mt@font@tbu}{"5A}
\DeclareMathSymbol{\Eta}{\mt@mathord}{\mt@font@tbu}{"48}
\DeclareMathSymbol{\Iota}{\mt@mathord}{\mt@font@tbu}{"49}
\DeclareMathSymbol{\Kappa}{\mt@mathord}{\mt@font@tbu}{"4B}
\DeclareMathSymbol{\Mu}{\mt@mathord}{\mt@font@tbu}{"4D}
\DeclareMathSymbol{\Nu}{\mt@mathord}{\mt@font@tbu}{"4E}
\DeclareMathSymbol{\Omicron}{\mt@mathord}{\mt@font@tbu}{"4F}
\DeclareMathSymbol{\Rho}{\mt@mathord}{\mt@font@tbu}{"50}
\DeclareMathSymbol{\Tau}{\mt@mathord}{\mt@font@tbu}{"54}
\DeclareMathSymbol{\Chi}{\mt@mathord}{\mt@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\mt@mathord\mathord
%    \end{macrocode}
%  symbolgreek but neither eulergreek nor selfGreek
%    \begin{macrocode}
%% attention le P de Symbol est un \Pi pas un \Rho
\DeclareMathSymbol{\Rho}{\mathord}{mtpsymbol}{"52}
%% attention le X de Symbol est un \Xi pas un \Chi
\DeclareMathSymbol{\Chi}{\mathord}{mtpsymbol}{"43}
%% attention le F de Symbol est un \Phi. Il n'y a pas de \Digamma
\DeclareMathSymbol{\Gamma}{\mathord}{mtpsymbol}{"47}
\DeclareMathSymbol{\Delta}{\mathord}{mtpsymbol}{"44}
\DeclareMathSymbol{\Theta}{\mathord}{mtpsymbol}{"51}
\DeclareMathSymbol{\Lambda}{\mathord}{mtpsymbol}{"4C}
\DeclareMathSymbol{\Xi}{\mathord}{mtpsymbol}{"58}
\DeclareMathSymbol{\Pi}{\mathord}{mtpsymbol}{"50}
\DeclareMathSymbol{\Sigma}{\mathord}{mtpsymbol}{"53}
\DeclareMathSymbol{\Upsilon}{\mathord}{mtpsymbol}{"A1}
\DeclareMathSymbol{\Phi}{\mathord}{mtpsymbol}{"46}
\DeclareMathSymbol{\Psi}{\mathord}{mtpsymbol}{"59}
\DeclareMathSymbol{\Omega}{\mathord}{mtpsymbol}{"57}
\else
%    \end{macrocode}
%  not symbolgreek but eulergreek or selfGreek or both
%    \begin{macrocode}
\DeclareMathSymbol{\Digamma}{\mathalpha}{\mt@font@tbu}{"46}
\DeclareMathSymbol\Gamma    {\mathalpha}{\mt@font@tbu}{"00}
\DeclareMathSymbol\Delta    {\mathalpha}{\mt@font@tbu}{"01}
\DeclareMathSymbol\Theta    {\mathalpha}{\mt@font@tbu}{"02}
\DeclareMathSymbol\Lambda   {\mathalpha}{\mt@font@tbu}{"03}
\DeclareMathSymbol\Xi       {\mathalpha}{\mt@font@tbu}{"04}
\DeclareMathSymbol\Pi       {\mathalpha}{\mt@font@tbu}{"05}
\DeclareMathSymbol\Sigma    {\mathalpha}{\mt@font@tbu}{"06}
\DeclareMathSymbol\Upsilon  {\mathalpha}{\mt@font@tbu}{"07}
\DeclareMathSymbol\Phi      {\mathalpha}{\mt@font@tbu}{"08}
\DeclareMathSymbol\Psi      {\mathalpha}{\mt@font@tbu}{"09}
\DeclareMathSymbol\Omega    {\mathalpha}{\mt@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}
\ifmt@proceed
\ifmt@eulergreek
\DeclareMathSymbol{\alpha}  {\mathalpha}{mteulervm}{"0B}
\DeclareMathSymbol{\beta}   {\mathalpha}{mteulervm}{"0C}
\DeclareMathSymbol{\gamma}  {\mathalpha}{mteulervm}{"0D}
\DeclareMathSymbol{\delta}  {\mathalpha}{mteulervm}{"0E}
\DeclareMathSymbol{\epsilon}{\mathalpha}{mteulervm}{"0F}
\DeclareMathSymbol{\zeta}   {\mathalpha}{mteulervm}{"10}
\DeclareMathSymbol{\eta}    {\mathalpha}{mteulervm}{"11}
\DeclareMathSymbol{\theta}  {\mathalpha}{mteulervm}{"12}
\DeclareMathSymbol{\iota}   {\mathalpha}{mteulervm}{"13}
\DeclareMathSymbol{\kappa}  {\mathalpha}{mteulervm}{"14}
\DeclareMathSymbol{\lambda} {\mathalpha}{mteulervm}{"15}
\DeclareMathSymbol{\mu}     {\mathalpha}{mteulervm}{"16}
\DeclareMathSymbol{\nu}     {\mathalpha}{mteulervm}{"17}
\DeclareMathSymbol{\xi}     {\mathalpha}{mteulervm}{"18}
\let\omicron\undefined
\DeclareMathSymbol{\omicron}{\mathalpha}{mteulervm}{"6F}
\DeclareMathSymbol{\pi}     {\mathalpha}{mteulervm}{"19}
\DeclareMathSymbol{\rho}    {\mathalpha}{mteulervm}{"1A}
\DeclareMathSymbol{\sigma}  {\mathalpha}{mteulervm}{"1B}
\DeclareMathSymbol{\tau}    {\mathalpha}{mteulervm}{"1C}
\DeclareMathSymbol{\upsilon}{\mathalpha}{mteulervm}{"1D}
\DeclareMathSymbol{\phi}    {\mathalpha}{mteulervm}{"1E}
\DeclareMathSymbol{\chi}    {\mathalpha}{mteulervm}{"1F}
\DeclareMathSymbol{\psi}    {\mathalpha}{mteulervm}{"20}
\DeclareMathSymbol{\omega}  {\mathalpha}{mteulervm}{"21}
\DeclareMathSymbol{\varepsilon}{\mathalpha}{mteulervm}{"22}
\DeclareMathSymbol{\vartheta}{\mathalpha}{mteulervm}{"23}
\DeclareMathSymbol{\varpi}  {\mathalpha}{mteulervm}{"24}
\let\varrho=\rho
\let\varsigma=\sigma
\DeclareMathSymbol{\varphi} {\mathalpha}{mteulervm}{"27}
\DeclareMathSymbol{\partial}{\mathalpha}{mteulervm}{"40}
\DeclareMathSymbol{\wp}{\mathalpha}{mteulervm}{"7D}
\DeclareMathSymbol{\ell}{\mathalpha}{mteulervm}{"60}
\else
\ifmt@symbolgreek
\DeclareMathSymbol{\alpha}{\mathord}{mtpsymbol}{"61}
\DeclareMathSymbol{\beta}{\mathord}{mtpsymbol}{"62}
\DeclareMathSymbol{\gamma}{\mathord}{mtpsymbol}{"67}
\DeclareMathSymbol{\delta}{\mathord}{mtpsymbol}{"64}
\DeclareMathSymbol{\epsilon}{\mathord}{mtpsymbol}{"65}
\DeclareMathSymbol{\zeta}{\mathord}{mtpsymbol}{"7A}
\DeclareMathSymbol{\eta}{\mathord}{mtpsymbol}{"68}
\DeclareMathSymbol{\theta}{\mathord}{mtpsymbol}{"71}
\DeclareMathSymbol{\iota}{\mathord}{mtpsymbol}{"69}
\DeclareMathSymbol{\kappa}{\mathord}{mtpsymbol}{"6B}
\DeclareMathSymbol{\lambda}{\mathord}{mtpsymbol}{"6C}
\DeclareMathSymbol{\mu}{\mathord}{mtpsymbol}{"6D}
\DeclareMathSymbol{\nu}{\mathord}{mtpsymbol}{"6E}
\DeclareMathSymbol{\xi}{\mathord}{mtpsymbol}{"78}
\let\omicron\undefined
\DeclareMathSymbol{\omicron}{\mathord}{mtpsymbol}{"6F}
\DeclareMathSymbol{\pi}{\mathord}{mtpsymbol}{"70}
\DeclareMathSymbol{\rho}{\mathord}{mtpsymbol}{"72}
\DeclareMathSymbol{\sigma}{\mathord}{mtpsymbol}{"73}
\DeclareMathSymbol{\tau}{\mathord}{mtpsymbol}{"74}
\DeclareMathSymbol{\upsilon}{\mathord}{mtpsymbol}{"75}
\DeclareMathSymbol{\phi}{\mathord}{mtpsymbol}{"66}
\DeclareMathSymbol{\chi}{\mathord}{mtpsymbol}{"63}
\DeclareMathSymbol{\psi}{\mathord}{mtpsymbol}{"79}
\DeclareMathSymbol{\omega}{\mathord}{mtpsymbol}{"77}
\let\varepsilon=\epsilon 
\DeclareMathSymbol{\vartheta}{\mathord}{mtpsymbol}{"4A}
\DeclareMathSymbol{\varpi}{\mathord}{mtpsymbol}{"76}
\let\varrho=\rho 
\DeclareMathSymbol{\varsigma}{\mathord}{mtpsymbol}{"56}
\DeclareMathSymbol{\varphi}{\mathord}{mtpsymbol}{"6A}
\DeclareMathSymbol{\partial}{\mathord}{mtpsymbol}{"B6}
\DeclareMathSymbol{\wp}{\mathord}{mtpsymbol}{"C3}
\fi\fi\fi
%%
\ifmt@LGRgreek
\DeclareMathSymbol{\Alpha}{\mathalpha}{\mtlgrfontupper}{65}
\DeclareMathSymbol{\Beta}{\mathalpha}{\mtlgrfontupper}{66}
\DeclareMathSymbol{\Gamma}{\mathalpha}{\mtlgrfontupper}{71}
\DeclareMathSymbol{\Delta}{\mathalpha}{\mtlgrfontupper}{68}
\DeclareMathSymbol{\Epsilon}{\mathalpha}{\mtlgrfontupper}{69}
\DeclareMathSymbol{\Zeta}{\mathalpha}{\mtlgrfontupper}{90}
\DeclareMathSymbol{\Eta}{\mathalpha}{\mtlgrfontupper}{72}
\DeclareMathSymbol{\Theta}{\mathalpha}{\mtlgrfontupper}{74}
\DeclareMathSymbol{\Iota}{\mathalpha}{\mtlgrfontupper}{73}
\DeclareMathSymbol{\Kappa}{\mathalpha}{\mtlgrfontupper}{75}
\DeclareMathSymbol{\Lambda}{\mathalpha}{\mtlgrfontupper}{76}
\DeclareMathSymbol{\Mu}{\mathalpha}{\mtlgrfontupper}{77}
\DeclareMathSymbol{\Nu}{\mathalpha}{\mtlgrfontupper}{78}
\DeclareMathSymbol{\Xi}{\mathalpha}{\mtlgrfontupper}{88}
\DeclareMathSymbol{\Omicron}{\mathalpha}{\mtlgrfontupper}{79}
\DeclareMathSymbol{\Pi}{\mathalpha}{\mtlgrfontupper}{80}
\DeclareMathSymbol{\Rho}{\mathalpha}{\mtlgrfontupper}{82}
\DeclareMathSymbol{\Sigma}{\mathalpha}{\mtlgrfontupper}{83}
\DeclareMathSymbol{\Tau}{\mathalpha}{\mtlgrfontupper}{84}
\DeclareMathSymbol{\Upsilon}{\mathalpha}{\mtlgrfontupper}{85}
\DeclareMathSymbol{\Phi}{\mathalpha}{\mtlgrfontupper}{70}
\DeclareMathSymbol{\Chi}{\mathalpha}{\mtlgrfontupper}{81}
\DeclareMathSymbol{\Psi}{\mathalpha}{\mtlgrfontupper}{89}
\DeclareMathSymbol{\Omega}{\mathalpha}{\mtlgrfontupper}{87}
%
\DeclareMathSymbol{\alpha}{\mathalpha}{mtlgrfont}{97}
\DeclareMathSymbol{\beta}{\mathalpha}{mtlgrfont}{98}
\DeclareMathSymbol{\gamma}{\mathalpha}{mtlgrfont}{103}
\DeclareMathSymbol{\delta}{\mathalpha}{mtlgrfont}{100}
\DeclareMathSymbol{\epsilon}{\mathalpha}{mtlgrfont}{101}
\DeclareMathSymbol{\zeta}{\mathalpha}{mtlgrfont}{122}
\DeclareMathSymbol{\eta}{\mathalpha}{mtlgrfont}{104}
\DeclareMathSymbol{\theta}{\mathalpha}{mtlgrfont}{106}
\DeclareMathSymbol{\iota}{\mathalpha}{mtlgrfont}{105}
\DeclareMathSymbol{\kappa}{\mathalpha}{mtlgrfont}{107}
\DeclareMathSymbol{\lambda}{\mathalpha}{mtlgrfont}{108}
\DeclareMathSymbol{\mu}{\mathalpha}{mtlgrfont}{109}
\DeclareMathSymbol{\nu}{\mathalpha}{mtlgrfont}{110}
\DeclareMathSymbol{\xi}{\mathalpha}{mtlgrfont}{120}
\DeclareMathSymbol{\omicron}{\mathalpha}{mtlgrfont}{111}
\DeclareMathSymbol{\pi}{\mathalpha}{mtlgrfont}{112}
\DeclareMathSymbol{\rho}{\mathalpha}{mtlgrfont}{114}
\DeclareMathSymbol{\varsigma}{\mathalpha}{mtlgrfont}{99}  
\DeclareMathSymbol{\sigma}{\mathalpha}{mtlgrfont}{115}       
\DeclareMathSymbol{\tau}{\mathalpha}{mtlgrfont}{116}
\DeclareMathSymbol{\upsilon}{\mathalpha}{mtlgrfont}{117}
\DeclareMathSymbol{\phi}{\mathalpha}{mtlgrfont}{102}
\DeclareMathSymbol{\chi}{\mathalpha}{mtlgrfont}{113}
\DeclareMathSymbol{\psi}{\mathalpha}{mtlgrfont}{121}
\DeclareMathSymbol{\omega}{\mathalpha}{mtlgrfont}{119}
\DeclareMathSymbol{\digamma}{\mathalpha}{mtlgrfont}{147}   
\DeclareMathSymbol{\Digamma}{\mathalpha}{mtlgrfont}{195}    
% cf http://milde.users.sourceforge.net/LGR/lgrxenc.def.html
% et greek.ldf du package babel
\fi
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\inodot}
% \begin{macro}{\jnodot}
%   In v1.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.
%    \begin{macrocode}
\edef\mt@enc{\m@stextenc}
\mt@proceedtrue
\ifx\mt@enc\mt@eui % xetex and unicode font
  \XeTeXmathchardef\inodot="7 "\the\symmtletterfont "0131 \relax
  \XeTeXmathchardef\jnodot="7 "\the\symmtletterfont "0237 \relax
\else
\ifx\mt@enc\mt@euii % luatex and unicode font
   \luatexUmathchardef\inodot="7 "\the\symmtletterfont "0131 \relax
   \luatexUmathchardef\jnodot="7 "\the\symmtletterfont "0237 \relax
\else 
\ifx\mt@enc\mt@ti % T1
   \DeclareMathSymbol{\inodot}{\mathalpha}{mtletterfont}{25}
   \DeclareMathSymbol{\jnodot}{\mathalpha}{mtletterfont}{26}
\else
\ifx\mt@enc\mt@oti % OT1
   \DeclareMathSymbol{\inodot}{\mathalpha}{mtletterfont}{16}
   \DeclareMathSymbol{\jnodot}{\mathalpha}{mtletterfont}{17}
\else
\ifx\mt@enc\mt@lyi % LY1
   \DeclareMathSymbol{\inodot}{\mathalpha}{mtletterfont}{16}
   \DeclareMathSymbol{\jnodot}{\mathalpha}{mtletterfont}{17}
\else
   \ifXeTeX\mt@proceedfalse\else\ifLuaTeX\mt@proceedfalse\else
   \DeclareMathSymbol{\inodot}{\mathalpha}{mtletterfont}
{\expandafter\the\expandafter\csname\mt@enc\string\i\endcsname}
   \DeclareMathSymbol{\jnodot}{\mathalpha}{mtletterfont}
{\expandafter\the\expandafter\csname\mt@enc\string\j\endcsname}
   \fi\fi
\fi\fi\fi\fi\fi
\ifmt@defaultimath\else
  \ifmt@proceed
    \renewcommand{\imath}{\inodot}
    \renewcommand{\jmath}{\jnodot}
    \let\mt@oldi\i \let\mt@oldj\j
    \DeclareRobustCommand{\i}{\ifmmode\inodot\else\mt@oldi\fi}
    \DeclareRobustCommand{\j}{\ifmmode\jnodot\else\mt@oldj\fi}
  \fi
\fi
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{math accents}
%   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 mathaccents 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.
%   v1.12b: I add LY1 which is quasi like OT1
%    \begin{macrocode}
\edef\mt@enc{\m@stextenc} %% rather one too many than sorry 
\ifmt@mathaccents 
\ifx\mt@ti\mt@enc
\DeclareMathAccent{\acute}{\mathalpha}{mtoperatorfont}{1}
\DeclareMathAccent{\grave}{\mathalpha}{mtoperatorfont}{0}
\DeclareMathAccent{\ddot}{\mathalpha}{mtoperatorfont}{4}
\DeclareMathAccent{\tilde}{\mathalpha}{mtoperatorfont}{3}
\DeclareMathAccent{\bar}{\mathalpha}{mtoperatorfont}{9}
\DeclareMathAccent{\breve}{\mathalpha}{mtoperatorfont}{8}
\DeclareMathAccent{\check}{\mathalpha}{mtoperatorfont}{7}
\DeclareMathAccent{\hat}{\mathalpha}{mtoperatorfont}{2}
\DeclareMathAccent{\dot}{\mathalpha}{mtoperatorfont}{10}
\DeclareMathAccent{\mathring}{\mathalpha}{mtoperatorfont}{6}
\else 
\DeclareMathAccent{\acute}{\mathalpha}{mtoperatorfont}{19}
\DeclareMathAccent{\grave}{\mathalpha}{mtoperatorfont}{18}
\DeclareMathAccent{\ddot}{\mathalpha}{mtoperatorfont}{127}
\DeclareMathAccent{\tilde}{\mathalpha}{mtoperatorfont}{126}
\DeclareMathAccent{\bar}{\mathalpha}{mtoperatorfont}{22}
\DeclareMathAccent{\breve}{\mathalpha}{mtoperatorfont}{21}
\DeclareMathAccent{\check}{\mathalpha}{mtoperatorfont}{20}
\DeclareMathAccent{\hat}{\mathalpha}{mtoperatorfont}{94}
\DeclareMathAccent{\dot}{\mathalpha}{mtoperatorfont}{95}
\DeclareMathAccent{\mathring}{\mathalpha}{mtoperatorfont}{23}
  \ifx\mt@lyi\mt@enc   % LY1 encoding
    \DeclareMathAccent{\dot}{\mathalpha}{mtoperatorfont}{5}
  \else
     \ifx\mt@oti\mt@enc\else
      \typeout{** mathastext: math accents have been assumed to be^^J%
        ** as in OT1 encoding.}
      \fi
   \fi
\fi\fi
%    \end{macrocode}
% \end{macro}
% \begin{macro}{Math sizes}
% I took the code for \cs{Huge} and \cs{HUGE} from the |moresize| package of
% Christian~\textsc{Cornelssen}
%    \begin{macrocode}
\ifmt@defaultsizes\else
\providecommand\@xxxpt{29.86}
\providecommand\@xxxvipt{35.83}
\ifmt@twelve  
  \def\Huge{\@setfontsize\Huge\@xxxpt{36}}
  \def\HUGE{\@setfontsize\HUGE\@xxxvipt{43}}
\typeout{** \protect\Huge\space and \protect\HUGE\space have been (re)-defined.}
\else 
  \def\HUGE{\@setfontsize\HUGE\@xxxpt{36}}
\typeout{** \protect\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}
\typeout{** mathastext has declared larger sizes for subscripts.^^J%
** To keep LaTeX defaults, use option `defaultmathsizes'.}
\fi
%    \end{macrocode}
% \end{macro}
% Scaling mechanism for the Symbol font.
%    \begin{macrocode}
\AtBeginDocument{
  \ifmt@needsymbol
  \DeclareFontFamily{U}{psy}{}
  \DeclareFontShape{U}{psy}{m}{n}{<->s*[\psy@scale] psyr}{}
  \fi
}
%    \end{macrocode}
% Time to reactivate the standard font infos and warnings and we are done.
%    \begin{macrocode}
\mt@font@info@on
\endinput
%    \end{macrocode}
% \iffalse
%</code>
%<*dtx>
% \fi
%
% \CharacterTable
%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%   Digits        \0\1\2\3\4\5\6\7\8\9
%   Exclamation   \!     Double quote  \"     Hash (number) \#
%   Dollar        \$     Percent       \%     Ampersand     \&
%   Acute accent  \'     Left paren    \(     Right paren   \)
%   Asterisk      \*     Plus          \+     Comma         \,
%   Minus         \-     Point         \.     Solidus       \/
%   Colon         \:     Semicolon     \;     Less than     \<
%   Equals        \=     Greater than  \>     Question mark \?
%   Commercial at \@     Left bracket  \[     Backslash     \\
%   Right bracket \]     Circumflex    \^     Underscore    \_
%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%   Right brace   \}     Tilde         \~}
%
% \iffalse
%</dtx>
% \fi
%
% \CheckSum{2757}
% \Finale
\endinput