This will be more an answer to your answer than to your question! ;-) Indeed I just want to clarify this issue of mathastext vs fontspec with or without its option no-math. What you say in your answer is due to the use of mathspec in your code. Indeed, here is an extract from mathspec.pdf:
Actually, mathspec ordinarily loads
fontspec with the no-math option. To
cancel this, explicitly use the math
option: e.g.
\usepackage[math]{mathspec}.
Package mathspec (for XeLaTeX) is specially designed to set up the math fonts (for the Latin letters, Digits, and Greek letters) and it provides commands for defining also the math alphabets. It automatically loads fontspec with option no-math. It can be used to set up the Greek letters, and then one can load mathastext to set up the Latin letters and Digits (as well as a few more punctuation characters from the Basic Latin set).
Package mathastext was designed for traditional TeX engines, but it is usable with Unicode engines; as clearly stated in its docs it only deals with the Basic Latin subset of the Unicode universe. Thanks to your question/answer, I realize that it is possible to use it together with mathspec (I initially thought they would work one against the other). For example one can use mathspec to set up the font for the Greek letters, and let mathastext do its modest job with the Basic Latin characters. Already with standard LaTeX and T1 encoding, mathastext does nothing special for letters with diacritics such as é or à directly input in the source in math mode (I believe the same applies to mathspec).
Here is now a small document allowing you to test mathastext under XeTeX (or LuaLaTeX) with various Unicode fonts of your choice, with or without mathspec (XeTeX only), and also, when not using mathspec with or without the option no-math to fontspec. As it stands, the source does not input mathspec and you will be able to see the importance of no-math option of fontspec when using mathastext. But to see the Greek letters, also when input directly in math mode as $α$ for example, you will need to uncomment the mathspec loading (XeTeX only). Hope it helps!
\documentclass[12pt]{article}
\usepackage{amsmath} % problem with `\- !!! (see below)
%% \usepackage{mathspec}
%% \setmathsfont(Greek)[Uppercase=Regular,Lowercase=Regular]{Arial}
\usepackage[no-math]{fontspec}
% The no-math option should be used for not interfering with
% mathsastext. Important: mathspec loads by default fontspec with
% the no-math option.
%\defaultfontfeatures{Ligatures=TeX} % syntaxe pour luatex
\defaultfontfeatures{Mapping=tex-text} % syntaxe pour xetex
\usepackage[noendash]{mathastext}
% noendash because of amsmath, see first line
% after \begin{document}
%%% mathastext allows to define multiple math versions,
%%% beyond the default "normal" one:
\setmainfont{Times New Roman} % or any other font
\Mathastext[times] % no space in the math version name
\setmainfont{Impact} % this is a very heavy upright
% font
\Mathastext[impact] % available on the computer at
% my office
\setmainfont{Arial}
\Mathastext[arial]
\newcommand{\textandmathandgreek}{
\centerline{abcdefghijklmnopqrstuvwxyz\rlap{ (text)}}
\centerline{$abcdefghijklmnopqrstuvwxyz$\rlap{ (math)}}
\centerline{ABCDEFGHIJKLMNOPQRSTUVWXYZ\rlap{ (text)}}
\centerline{$ABCDEFGHIJKLMNOPQRSTUVWXYZ$\rlap{ (math)}}
\centerline{0123456789\rlap{ (text)}}
\centerline{$\mathrm{0123456789}$\rlap{ (math with \texttt{\symbol{92}mathrm})}}
\centerline{$0123456789$\rlap{ (math)}}
\centerline{!\,?\,*\,,\,.\,:\,;\,+\,\textendash\,=\,(\,)\,[\,]\,/\,\#\,%
\$\,\%\,\&\,<\,>\,|\,\{\,\}\,\symbol{92}\rlap{ (text)}}
\centerline{$!\,?\,*\,,\,.\,:\,;\,+\,-\,=\,(\,)\,[\,]\,/\,\#\,%
\$\,\%\,\&\,<\,>\,|\,\{\,\}\,\backslash$\rlap{ (math)}}
\centerline{αβγΔΓΦ\rlap{ (text)}}
\centerline{$αβγΔΓΦ$\rlap{ (math, direct input)}}
\centerline{$\alpha\beta\gamma\Delta\Gamma\Phi$\rlap{
(math, named letters)}}
\medskip
}
\pagestyle{empty}
\begin{document}
% FIX FOR THE AMSMATH PROBLEM WITH MINUS SIGN
%\luatexUmathcode`\-="2 \symmtoperatorfont "2013 \relax
\XeTeXmathcode`\- ="2 \symmtoperatorfont "2013 \relax
\MTversion{normal} % font at the time of loading mathastext
\centerline{Default Text Font}
\textandmathandgreek
\MTversion{times}
\centerline{Times New Roman}
\textandmathandgreek
\MTversion{impact}
\centerline{Impact}
\textandmathandgreek
\MTversion{arial}
\centerline{Arial}
\textandmathandgreek
The main job of mathastext is to allow to
type the characters from the Basic Latin set \emph{as is} in math mode,
and to have them without further ado be in the same font as
the document text (possibly in italic, with
\emph{italic} passed to the package, and when the font used
does exist in Italic Style). But for Unicode
characters not in the Basic Latin set (such as é, or æ or ŋ)
they should be input in math mode within a \verb|\mathrm| or
similar math alphabet commands $\zeta=\int
\frac{\mathrm{é}}{\mathbf{æ}}d\mathit{ŋ}$, or alternatively
within a \verb|\text| command (from package amsmath)
$\zeta=\int \frac{\text{é}}{\text{\bfseries
æ}}d\text{\itshape ŋ}$ (this offers more possibilities
as the \verb|\math..| commands are not cumulative).
Mathastext has options related to Greek letters but only in
relation to fonts in \TeX\ format (fonts in LGR encoding, or
the Euler font, or the Symbol font). The Greek letters can
be set up arbitrarily by another package: with Xe\TeX{}
one can use the package \emph{mathspec} to specify the Greek
letters, this is compatible with loading also mathastext for
dealing with Latin letters and Digits (a job which can also
be done by mathspec).
\end{document}
italicto packagemathastextyou will see that it does work with Times New Roman, or any other font with an italic version, but not with Impact, or say, Arial Black. This is normal behavior ofmathastextand would be the same with traditional TeX fonts (the absence of italic shape provoking probably a substitution warning in the LaTeX log file). – May 04 '11 at 14:28mathspec. Thanks to your answer which made me finally realize that! – May 04 '11 at 14:51mathspecautomatically loadsfontspecand pass options to it, so in the code above, if one un-comments themathspecline, one can comment-out thefontspecone. – May 04 '11 at 15:03\textbackslashrather than\symbol{92}– May 04 '11 at 16:13\rm, correct? Also, if one wants formulas to have italic Roman script, thenmathastextneeds optionitalic, but in that case when math formatting is applied to non-formulas within the same document, they will be italicized unless they are explicitly turned off, for example with\rm. Correct? – brannerchinese May 04 '11 at 19:09\rmis frowned upon, although perhaps in math mode it is not that bad (as I never use it I forgot its defects), because the\mathrm,\mathit, etc... share the defects of\rmetc... of not cumulating effects. The\textmacro of amsmath is better. – May 04 '11 at 20:26\setmainfont{Times} \usepackage[noendash,italic]{mathastext} \let\olditdefault\itdefault \renewcommand{\itdefault}{\rmdefault} \Mathastext[Upright] \renewcommand{\itdefault}{\olditdefault}in your preamble you can alternate in your document between upright Basic Latin letters in math mode and italic ones: after\MTversion{Upright}letters will be as if you had used\rmon them, and after\MTversion{normal}you return to the italic. This macro has to be called outside of math mode. – May 04 '11 at 20:30\rm abin math mode is about exactly like\mathrm{ab}so I shouldn't have denigrated it; but this is only for short variable names, if one wants spaces one has to use\textrmwhich behaves better ifamsmathis loaded (or onlyamstextwhich would avoid the Unicode difficulty we talked about elsewhere), and even has the shorter form\text(which takes the style of the surrounding text off math mode). – May 04 '11 at 20:46itdefault. And you're quite right about\rm; I just use it for speed and readability. – brannerchinese May 04 '11 at 21:20