3

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...

2
  • You need to find a way to either load mathspec before Lyx loads fontspec or you must prevent Lyx from loading fontspec itself. Feb 13, 2012 at 8:51
  • 1
    yes, indeed, that would appear to be the question. (It appears that lyx loads fontspec automatically. I don't know why it does this, if this is a result of one of my document settings or not, or a default behavior, or if this is a modifiable behavior or not, or ...I was hoping some one might have run across this problem before, because it seems quite unlikely that I am the first person to consider using the two together, and if they have and have done so successfully, I would be most obliged to know how, and if they haven't done so successfully, why on earth haven't they complained about it!)
    – asllearner
    Feb 14, 2012 at 16:16

2 Answers 2

2

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
2

Lyx loads the fontspec pachage most likely because in Document Settings->Fonts the setting 'Use Non-TeX fonts' was selected. An error is generated when you try to load it again through the mathspec package. To resolve this issue deselect 'Use non-Tex fonts' and set all the fonts to default. Now you can load the mathspec package yourself in the preamble. Add the following to the Document Settings->LaTeX Preamble to load the mathspec (and automatically the fontspec) package and set all text (main and math) to Minion Pro:

\usepackage{mathspec}
\setallmainfonts[Numbers={Lining,Proportional}]{Minion Pro}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .