[Tex/LaTex] LyX and mathspec gives fontspec error, unicode-math no better

fontspeclyxmathspecunicode-math

I get the following error message whenever using mathspec in LyX

...Package[\eu@zf@math]{fontspec}[2008/08/09]
The package fontspec has already been loaded with options:   [] There has now been
an attempt to load it with options   [no-math] Adding the global
options:   ,no-math to your \documentclass declaration may fix this.
Try typing  <return>  to proceed.

Here is my preamble in LyX

\usepackage[no-math]{mathspec} 
\setmathsfont(Latin)[Scale=MatchLowercase,Uppercase=Regular,Lowercase=Italic]{SNsanafonmaruP}
\setmathsfont(Greek)[Scale=MatchLowercase,Uppercase=Regular,Lowercase=Regular]{SNsanafonmaruP}
\setmathsfont(Digits)[Numbers={Lining}]{SNsanafonmaruP} 

(n.b. mathspec loads fontspec with no-math by default. I put it in there explicitly, but the error occurs even when it is not there.)

The problem is that LyX loads fontspec automatically and this is throwing the error.

I am not sure how to proceed.

I am using XeTeX as my output…

UPDATE 2/29/12

I have tried to use unicode-math instead of mathspec, as follows:

usepackage[vargreek-shape=unicode]{unicode-math}
\unimathsetup{math-style=TeX} % sets whther vars are upper or lc vars and lating chars in math
\setmathfont{lmmath-regular.otf} % this is obligatory or no math font will be set...
\setmathfont[range=\mathup/{latin, Latin, num}]{SNsanafonmaruP} %  upper and lower case  latin and numbers
\setmathfont[range=\mathup/{Greek,greek}]{SNsanafonmaruP} % upper case Greek
\setmathfont[range=\mathit/{latin, Latin, num}]{SNsanafonmaruP}
\setmathfont[range=\backepsilon]{SNsanafonmaruP}
\setmathfont[range=\mathit/{greek,Greek}]{SNsanafonmaruP}

but unicode-math doesn't default (e.g. to computer modern…I am not pleased with the traditional Unicode alternatives Asana and STIX (too fat, especially the summation signs, and I like the default symbols, I just want my own font for the greek and latin and numerals) to anything, which would be nice, so I have to include the first \setmathfont and specify a default font,
but when I try to put in "Computer Modern" or "Computer Modern Math" it doesn't find it, and I guess it couldn't cause it isn't Unicode??, so I tried lmmath-regular.otf or Latin Modern Math, and I probably have to install these, but I cant find a package for it in MikTeX, and anyway, according to the bug list on unicode-math this will break mathcal so I shouldn't, and to boot it doesn't work, since the font is not found.

so it seems like I am so close, and yet so far, as the saying goes…

Best Answer

UPDATE 3/4/12 though still curious about original query re: mathspec, I will add the following update, for others with a similar problem:

I found the Latin Modern Font online, which is based on Computer Modern Math, so now I can use this to get essentially what I was looking for. The bonus of using unicode-math was I could fine tune specific characters, e.g. backepsilon, though it took some interpretation of the manual and educated guesswork to get to the working solution, which I thereby record here merely for posterity and completeness:

%\usepackage[vargreek-shape=TeX]{unicode-math}
\usepackage[vargreek-shape=unicode]{unicode-math} %controls which shape of epsilon and phi are considered default
\unimathsetup{math-style=french} % uses so called french style italic lc latin, upright everything else
\setmathfont{Latin Modern Math} % this is obligatory or no math font will be set...

% MATHUP Case
\setmathfont[range=\mathup/{latin, Latin, num}]{SNsanafonmaruP} %  upper and lower case  latin and numbers
\setmathfont[range=\mathup/{Greek,greek}]{SNsanafonkakuP} % upper lower case Greek

% Italic
\setmathfont[range=\mathit/{latin, Latin}]{SNsanafonmaruP} %  upper and lower case  latin and numbers
%\setmathfont[range=\mathit/{greek,Greek}]{SNsanafonmaruP} % italic greek

\setmathfont[range=\mathbfup/{num}]{nagurigaki} %  boldface uppercase numbers

% SPECIAL Characters
\setmathfont[range=\phi]{Cambria Math} % this doesn't work
\setmathfont[range=\varphi]{Cambria Math} % this doesn't work
\setmathfont[range=\upvarphi]{Courier New Bold} % this works
\setmathfont[range=\upphi]{Courier New Bold} % this works
\setmathfont[range=\Phi]{Courier New Bold} % this doesn't work
\setmathfont[range=\upPhi]{Courier New Bold} % this works  
\setmathfont[range=\Upphi]{SNsanafonmaruP} % this doesn't work

\setmathfont[range=\epsilon]{Cambria Math} % this doesn't work
\setmathfont[range=\upepsilon]{Courier New Bold} % this works
\setmathfont[range=\upvarepsilon]{Courier New Bold} % this works

\setmathfont[range=\Epsilon]{Cambria Math} % this doesn't work
\setmathfont[range=\upEpsilon]{Cambria Math} % this works

\setmathfont[range=\backepsilon]{Courier New Bold} % this doesn't work
\setmathfont[range=\upbackepsilon]{Courier New Bold} % this works and fixes backepsilon

\setmathfont[range=\in]{Cambria Math} % this works / not in courier new bold
\setmathfont[range=\ni]{Cambria Math} % this works / not in courier new bold
\setmathfont[range=\upin]{Cambria Math} % this doesn't bomb but doesn't work
%\setmathfont[range=\upni]{SNsanafonmaruP} % this bombs latex!?
\setmathfont[range=\implies]{Latin Modern Math} % this doesn't bomb but doesn't work I believe..using \rightarrow instead
Related Question