The bottom line at the top.
Don't try this at home kids! Using MnSymbol with unicode-math will kill your time!
The symbols provided by MnSymbol are not set up for use with unicode-math
. Some are missing, some are not scalable in size. These need to be replaced by a different math font.
For my opinion XITS Math does a good job. One just needs to find the unicode characters due to fix.
Partial differential \partial
:
\setmathfont[range={"2202} ]{XITS Math}
The integrals with an additional little tweak:
\setmathfont[range={"222B-"2233,"2A0B-"2A1C}]{XITS Math}
\newcommand{\intX}[2]{\int\limits_{\mkern-15mu #1}^{#2} \mkern-15mu}
For the sum symbol I personally find the Latin Modern Math symbol a better match:
\setmathfont[range={"2211} ]{Latin Modern Math}
The brackets come with a quite heavy weight in XITS Math, so also used Latin Modern Math in this case:
\setmathfont[range={"005B,"005D,"0028,"0029,"007B,"007D} ]{Latin Modern Math}
The vertical line character though, is too bold there, so back to XITS Math
\setmathfont[range={"007C} ]{XITS Math}
Fixing the root:
\setmathfont[range={"002F,"221A}]{XITS Math}
and the comma:
\setmathfont[range={"002C} ]{XITS Math}
and finally the \mathscr
and additionally the \mathrm
characters
\setmathfont[range=\mathscr,StylisticSet={1}]{XITS Math}
\setmathrm{Minion Pro}
The letter \epsilon
is missing, but \varepsilon
is working. As we use unicode-math the replacement with \let
needs to be done at the begin of the document:
\AtBeginDocument{%
\let\phi\varphi
\let\epsilon\varepsilon
}
or \AfterEndPreamble
in case there are problems with hyperref and the etoolbox package.
One further problem is the slash /
, where it is a matter of taste, which font should be use for replacement.
\setmathfont[range={"002F,"2215}]{Latin Modern Math}
But the actual mistake of the author of the original MWE was, that he should have used \mathbin{/}
instead of /
for a better spacing.
All these fixes together give a pleasant result:
\documentclass[a4paper]{article}
\usepackage{amsmath,amssymb,mathrsfs}
\usepackage{fontspec}
\usepackage{unicode-math}
\setmainfont[Numbers = OldStyle,Ligatures = TeX,SmallCapsFeatures = {Renderer=Basic}]{Minion Pro}
\setsansfont[Numbers={OldStyle,Proportional},Scale=MatchLowercase]{Minion Pro}
\setmonofont[Numbers=OldStyle,Scale=MatchLowercase]{Minion Pro}
\setmathfont{MnSymbol}
\setmathfont[range=\mathup/{num,latin,Latin,greek,Greek}]{Minion Pro}
\setmathfont[range=\mathbfup/{num,latin,Latin,greek,Greek}]{MinionPro-Bold}
\setmathfont[range=\mathit/{num,latin,Latin,greek,Greek}]{MinionPro-It}
\setmathfont[range=\mathbfit/{num,latin,Latin,greek,Greek}]{MinionPro-BoldIt}
\setmathfont[range=\mathscr,StylisticSet={1}]{XITS Math}
\setmathfont[range={"005B,"005D,"0028,"0029,"007B,"007D} ]{Latin Modern Math} % brackets
\setmathfont[range={"2202} ]{XITS Math} % partial
\setmathfont[range={"2211} ]{Latin Modern Math} % sum
\setmathfont[range={"007C} ]{XITS Math} % vertical
\setmathfont[range={"221A} ]{XITS Math} % root
\setmathfont[range={"222B-"2233,"2A0B-"2A1C}]{XITS Math} % integrals
\setmathfont[range={"002F,"2215}]{Latin Modern Math} % /
\setmathfont[range={"002C} ]{XITS Math} % ,
\setmathrm{Minion Pro}
\newcommand{\intX}[2]{\int\limits_{\mkern-15mu #1}^{#2} \mkern-15mu}
\AtBeginDocument{\let\epsilon\varepsilon}
\begin{document}
...
Also the output produced by \blindmathpaper
looks nice:
The neverending story.
Probably you will still find something missing. The last issue I encountered before I gave up, was the missing full stop/punctuation mark as discussed in this question and also solved with this answer. But even then commands like \dots
still did not work. Realizing that one needs to fix almost everything of MnSymbol, so actually nothing is left, I decided to use another math font and just included some certain symbols of MnSymbol I'd liked.
I finally use this settings:
\setmathfont{XITS Math}
\setmathfont[range=\mathup/{num,latin,Latin,greek,Greek}]{Minion Pro}
\setmathfont[range=\mathbfup/{num,latin,Latin,greek,Greek}]{MinionPro-Bold}
\setmathfont[range=\mathit/{num,latin,Latin,greek,Greek}]{MinionPro-It}
\setmathfont[range=\mathbfit/{num,latin,Latin,greek,Greek}]{MinionPro-BoldIt}
\setmathfont[range=\mathscr,StylisticSet={1}]{XITS Math}
\setmathfont[range={"005B,"005D,"0028,"0029,"007B,"007D,"2211,"002F,"2215 } ]{Latin Modern Math} % brackets, sum, /
\setmathfont[range={"002B,"002D,"003A-"003E} ]{MnSymbol} % + - < = >
\setmathrm{Minion Pro}
The bottom line at the bottom.
Don't try this at home kids! Using MnSymbol with unicode-math will kill your time!
The whole thing is so buggy, that it is not worth trying. Maybe in the future. Using another font as base and include certain symbols from MnSymbol seems appropriate though.
Best Answer
Note that this explanation is actually a guess. I do not know enough about how these things work to be sure. Caveat emptor.
A real solution requires extending the opentype versions of MnSymbol quite significantly, I think. (I explain why below - I don't mean that the coverage is insufficient.)
No. This is not correct.
It is unfortunately more complicated even in the case of text. It is several times of magnitude more complex again in the case of maths. I begin with the text case because it is simpler.
Text
What XeTeX and LuaTeX do is enable you to access all of the bells and whistles featured in sophisticated opentype fonts. This is fantastic in terms of providing access to 'regular' fonts. Suddenly, you do not need any special support package to write your text - or maths - using the same fonts used by any other application on your system.
The downside of this is that the opentype fonts need the bells and whistles. For example:
So opentype will allow you to access the oldstyle figures, say, via the
onum
feature of the font. What does this mean? It means that the font has the relevant characters, of course. That is, it has to actually include 0, 1, 2 etc. oldstyle figures. But it also needs to do something else as this screenshot fromfontforge
shows:If the font contained the characters but not the mappings needed for the font feature
onum
, we'd be stuck.In contrast, (pdf)TeX cannot use fonts without specialised support files. This of course limits the fonts you may use. Even if you know how to prepare such files yourself, it is time-consuming and fiddly to do so.
On the other hand, the information the fonts themselves need to provide is relatively minimal. Essentially, they need to provide the glyphs (the pictures of each character), some basic information about each character (width, height etc.) and, ideally, kerning information (which says how the spacing should be adjusted when particular pairs of characters occur), and some general information about the font itself (name, encoding, x-height etc.). If some of this information is wrong, you can actually compensate for it in preparing the support files. For example, you can tell TeX that the character in slot 83 is a comma even if the font itself claims it is the capital A. That's more work, but it is doable.
Furthermore, any bells and whistles get specified in the support files. For example, suppose that you want to enable
e.swash
as an end-of-word swash character. In an opentype font, you must hope that the font specifies this as part of a font feature which can be accessed straightforwardly via Xe/LuaTeX. In (pdf)TeX, you don't have to hope - there's no point. This can't be specified in type1 fonts and (pdf)TeX couldn't use that information anyway. Instead, the support files must provide TeX with this information. So whoever writes those files specifies the relevant relationships.So the onus in the case of Xe/LuaTeX and opentype fonts (absent special work arounds etc.) is very much on the font features being configured correctly. Xe/LuaTeX provide a general interface to any font, provided that font has the relevant features.
The onus in the case of (pdf)TeX with type1 (or truetype for pdfTeX) fonts is to a much larger extent on the font features being configured in the TeX support files. This is why it can make sense, for example, to write a package such as
cfr-lm
which provides access to exactly the same type1 fonts aslmodern
.cfr-lm
provides access to features of the fonts not supported bylmodern
(which is why I wrote it).So whether or not LuaTeX or XeTeX provide improved access depends very much on the font in question. In the case of a font with no TeX support files or no type1/truetype format, any access is obviously an improvement. In the case of fonts with sophisticated TeX support packages, Lua/XeTeX may or may not provide improved access, depending on
lmodern
does not provide access to oldstyle, proportional figures for use as default in text even though this access can be provided ascfr-lm
demonstrates.Maths
Mathematics is more complex. (pdf)TeX requires specially designed fonts plus specialised support files in order to typeset maths correctly. Unlike the text case, you cannot get very far trying to create support files for arbitrary fonts. As far as the fonts themselves are concerned, the issue here is primarily to do with coverage - you need various symbols and they need to fit together for the whole thing to work. Generally, only fonts designed for TeX have these.
Xe/LuaTeX similarly requires coverage i.e. the needed characters must be there. However, just as something more was required in the text case in the form of the relevant font features (e.g.
onum
), something more is required in the case of maths as well.As I understand it,
unicode-math
provides access to the mathematical extension of the opentype specification developed by Microsoft for Office 2007. This essentially defines something a little like opentype features for text but for maths. Merely having a font with the requisite characters in opentype format is not sufficient. The font also needs to implement the relevant parts of the maths extension.To see the problem, consider the following screenshots from
fontforge
. These were taken usingElement
>Other Info
>Math Info
>Exten Shapes
. The first shows part of this table for Latin Modern Math:The second is the table for MnSymbol at 10pt:
Similar comparisons can be done for other aspects of the maths configuration of these fonts.
Conclusion
In conclusion, MinionPro + MnSymbol is better supported by (pdf)TeX than it can be by
unicode-math
. To work straightforwardly with Xe/LuaTeX andunicode-math
, the opentype versions of MnSymbol would need to be extended to support the relevant parts of the opentype maths extension.Postscript
It turns out that there is a further problem with the opentype version of MnSymbol in combination with LuaTeX which has nothing to do with its lack of support for maths. This is actually why LuaLaTeX fails with a fatal error rather than just producing a crappy-looking PDF.
The following MWE can be used to reproduce the error:
LuaLaTeX fails with a fatal error. XeLaTeX compiles the document fine. I am not sure whether this is a bug in LuaLaTeX or MnSymbol or both. The analogous document using MdSymbol works OK with both engines.
Seeing the effect of using an opentype font without support for maths
To see why an opentype font which does not support the maths extension cannot be used straightforwardly, I therefore use MdSymbol with MinionPro. The following example compares this combination with Latin Modern with Latin Modern Math, which is default.