When compiling a file using XeLaTex in TeXShop on Mac OS X, the console persistently hangs after the detection of the XeTeX driver:
*geometry* driver: auto-detecting
*geometry* detected driver: xetex
./paper.tex:53: Extended mathchar used as mathchar (71311379).
<to be read again>
\relax
l.53 \begin{document}
It's possible to continue the compilation, but I'd like to understand what is going on. The problem seems to be related to the mathastext package, which I use to allow math and text formatting both to use the TeX Gyre Termes font; commenting out the \usepackage line for mathastext relieves the problem.
I've seen discussions from 2006 (long predating the existence of mathastext) saying that there is a bug in the XeTeX distro (v. 0.995 rev. D) and the only solution is to compile from source. (Google search results here.) The version of XeTeX currently installed on Mac OS 10.6.7 by TeX Live is 0.9997.4, but the problem persists, and I wonder if there is any newer intelligence on how to repair it or what causes it. I am having trouble building XeTeX manually.
Edit, 20110505
Because the discussion below became quite involved, I am summarizing the two main conclusions:
- There turns to be a bug in
amsmaththat requires the optionnoendashto be passed tomathastext. An alternate fix is offered by Philipp. - Discussion of how to get math formatting to apply to non-math text, without looking like math mode, was transfered to a different posting: applying math formatting to a non-math font.
your code loading mathspec which itself caused behind the scenes fontspec to be loaded with option no-math?
Edit: minimal example, as requested by Philipp
%!TEX TS-program = xelatex
%!TEX encoding = UTF-8 Unicode
\documentclass[12pt]{article}
\usepackage{geometry}
\usepackage{amsmath}
\usepackage{mathspec} % replaces amssymb; do not use unicode-math
\usepackage[italic]{mathastext} % propagates document text font to math mode
\usepackage{xeCJK}
\usepackage{fontspec}
\defaultfontfeatures{Mapping=tex-text}
\setromanfont{TeX Gyre Termes}
\begin{document}
The expected number of collisions in a given unit is \[E(collisions)=k\times\left(1-\left(1-\left(1/n\right)\right)^{{\left(k-1\right)}}\right)\]
\end{document}
Another edit, 2011.05.04, replying to JFBU's comment about [no-math].
With no-math being passed to fontspec:
\usepackage[no-math]{fontspec}
...
\setmainfont[Scale=1,Mapping=tex-text]{TeX Gyre Termes}
...
\usepackage[italic,noendash]{mathastext} % set *after* setmainfont
...
\begin{document}
au\(_{\rm3yā}\)
\end{document}
I get
. But without no-math being passed to fontspec:
\usepackage{fontspec}
...
\setmainfont[Scale=1,Mapping=tex-text]{TeX Gyre Termes}
...
\usepackage[italic,noendash]{mathastext} % set *after* setmainfont
...
\begin{document}
au\(_{\rm3yā}\)
\end{document}
I get
. I believe these are the same; I chose ā because the height of the macron is very distinctive in Termes.
Edit, 2011.05.04b: In response to another comment of @JFBU, appearance of \centerline{0123456789}\centerline{$0123456789$} with and without no-math passed to fontspec.
With no-math:

W/o no-math:

I see no obvious difference.
mathastexthas hardly been tested with unicode engines (I know from first-hand source that the author does not even have a working xe(la)tex on his system... and only did a bit of testing with LuaLaTeX). The source of your problem may indeed quite probably be withmathastext. Try loading it with thebasicoption to see if it helps. – May 03 '11 at 13:33mathastexthas informed me that at his office, they have TL2010 since a few days, and that for the first time he could try out XeLaTeX. He says that a minimal document works fine: ` \documentclass{article} \usepackage[no-math]{fontspec} \setmainfont{Andale Mono} \usepackage{mathastext} \setmainfont{Arial Black} \Mathastext[Arial] \begin{document} \MTversion{normal} Hello $world$\MTversion{Arial} Hi $again$ \end{document}` so please provide a minimal example.
– May 03 '11 at 13:45mathastext, one should load it after thesetmainfontcommand. To return to your problem, it goes away whenamsmathis not loaded. This should help locate the source of the error inmathastext. Will transmit to its author. – May 03 '11 at 14:41\rmswitches to the main document font (this is set-up to be so by mathastext; it would also be the case with fontspec alone without the no-math option). Try\centerline{0123456789}\centerline{$0123456789$}with and without the no-math option to fontspec and you will see the difference. If you don't pass the option no-math to fontspec the digits in math mode will be typeset in CMR, but if you pass the option no-math they will be typeset in TeX Gyre Termes. – May 04 '11 at 09:37no-math, there is no apparent difference between the two strings you prescribed (and withmathastextstill being introduced aftersetmainfont). Adding the character ā to both strings, it appears in the first string but not in the second; it is not being made. I'll edit the OP again to show what I am seeing (without character ā added to your strings). – brannerchinese May 04 '11 at 11:22au\(_{3yā}\)with\rmremoved. Without\rm, the vowel ā does not appear, regardless of whetherno-mathis present or not. Bottom line: to apply math formatting to non-math characters, I apparently need bothtextasmathand\rm. – brannerchinese May 04 '11 at 11:23mathspecwhich itself caused behind the scenesfontspecto be loaded with option no-math? this would provide more complete information to the casual browser. – May 05 '11 at 09:07commathpackage. Clearly there are multiple culprits. – oLas Mar 02 '16 at 10:46