21

What can i put into \setmathfont{<...>.otf} for the unicode-math package to make it all work (with XeLaTeX or LuaLaTeX)?

There are several suggestions on the GitHub page of unicode-math, but the first option is commercial, and the second and the third do not work with the following example:

% !TEX TS-program = xelatex

\documentclass{article}
\usepackage{unicode-math}
\setmathfont{latinmodern-math.otf}
% \setmathfont{texgyrepagella-math.otf}
% \setmathfont{xits-math.otf}

\begin{document}
$X\setminus Y$
\end{document}

I do not get the \setminus character in the output.

The \setminus character is also missing if i do not set a math font at all (i do not know which font is used in this case). It works with xits-math, but i do not like it.

Is it expected by the way that the \setminus character is left blank without giving any warning?

  • 3
    You get a warning in the log file, not on the terminal. With xelatex on your document as posted I get: Missing character: There is no ⧵ in font [latinmodern-math.otf]/ICU:script=math ;language=DFLT;! – David Carlisle Oct 23 '13 at 15:33
  • Thanks for the explanation. I am still wondering if i can find a usual-looking font with all common math characters, or if i should change back to amssymb. – Alexey Oct 23 '13 at 15:47
  • 1
    I had forgotten, but turns out I made a bug report to the font creators, about exactly one year ago, via an email to Boguslaw Jackowski with title \setminus symbol does not show in pdf (Termes, Pagella, Latin Modern). Perhaps a second attempt should be done? – user4686 Oct 23 '13 at 22:00
  • At least for LuaTeX with fontspec, it seems that an Open Type font is deemed to be a "math" font if it has the ssty feature. Whether or not it has the characters you need, is another story. – user103221 Dec 14 '16 at 20:17
  • Your title sounds like a duplicate of “Which OpenType Math Fonts are Available?”, but the answers are all about a separate issue you raise in your last paragraph: the missing \setminus in Latin Modern Math. Should I edit to match the very useful answers? – Davislor Jan 10 at 19:24
19

It's quite strange that the symbol is missing in Latin Modern Math, TeX Gyre Termes Math and TeX Gyre Pagella and it's probably worth a bug report.

You can supplement single symbols with the range option to \setmathfont:

\documentclass{article}
\usepackage{unicode-math}
%\setmathfont{Latin Modern Math} % default
\setmathfont[range=\setminus]{Asana Math}

\begin{document}
$X\setminus Y$
\end{document}

enter image description here

A different possibility is to use \backslash made into a binary operator:

$X \mathbin{\backslash} Y$

that gives

enter image description here

In this case

\renewcommand{\setminus}{\mathbin{\backslash}}

would make \setminus doing what's expected. However, the redefinition must be issued at begin document, because unicode-math prepares its internal math symbol tables at that moment.

\documentclass{article}
\usepackage{unicode-math}
%\setmathfont{Latin Modern Math} % default

\AtBeginDocument{% to do this after unicode-math has done its work
  \renewcommand{\setminus}{\mathbin{\backslash}}%
}

\begin{document}
$X\setminus Y$
\end{document}
|improve this answer|||||
  • 2
    sorry I did make a bug report to Boguslaw Jackowski on October 27, 2012. – user4686 Oct 23 '13 at 21:58
  • 1
    unicode-math offers an option to specify the slash provided by the font. For example, on page 14, the manual explains how to get slashes with Cambria even though it does not provide all of those specified by unicode. Just before that, it lists the different versions of backward slashes. Yet there seems to be no similar option for telling unicode-math what the font provides in this case. If filing bugs on the fonts is proving unproductive, maybe it would be worth a feature request to whoever maintains unicode-math? – cfr Mar 25 '14 at 0:35
  • 1
    @egreg Perhaps this is an area where unicode-math could offer (or provide an interface) to substitute one slash with another. – Will Robertson Jul 1 '14 at 0:46
  • 2
    @Socowi \AtBeginDocument{\renewcommand{\setminus}{...}} – egreg Jun 5 '18 at 11:17
  • 1
    @Socowi I guess that five years ago this wasn't necessary; I took the occasion for improving my answer, thanks. – egreg Jun 5 '18 at 11:22
10

It works with

\setmathfont{Asana-Math.otf}

or as noted in the question, with

\setmathfont{xits-math.otf}

as mentioned in comments, if it doesn't work you get a warning in the log, eg with latinmodern:

Missing character: There is no ⧵ in font [latinmodern-math.otf]/ICU:script=math ;language=DFLT;!
|improve this answer|||||
  • I have notice this, but it looks like a rather incompatible replacement for amssymb with the regular font. Is there no way to make it look like the usual font with unicode-math? – Alexey Oct 23 '13 at 16:22
  • @Alexey well in principle youjust... need to pull the amsfonts together and re-encode them into a big otf font in Unicode order, I assume that's the way latin-modern is headed but I do not know the details of any work in that area. – David Carlisle Oct 23 '13 at 16:34
2

load all traditional math stuff before unicode-math

\documentclass{article}
\usepackage{amssymb}
\usepackage{unicode-math}
\setmathfont{XITSMath}

\begin{document}
$X\setminus Y$
\end{document}
|improve this answer|||||
  • I get fontspec error: "font-not-found" at \setmathfont{XITSMath}. What should i install? – Alexey Oct 23 '13 at 21:44
  • In any case, doing \usepackage{amssymb} before \usepackage{unicode-math} does not help. – Alexey Oct 23 '13 at 21:48
  • @Alexey Why should it help? In amssymb there's no mention of \setminus and unicode-math redefines it to choose U+29F5 REVERSE SOLIDUS OPERATOR. – egreg Oct 23 '13 at 21:58
  • ok, so this answer was not about getting \setminus back. – Alexey Oct 23 '13 at 22:27
  • 1
    @Alexey: no, only \smallsetminus is defined by all math otf fonts. And \setminus only by XITS, Asana, and Cambria. However, the otf math font should be loaded after the other "traditional" math stuff. That's what my example shows. – user2478 Oct 24 '13 at 12:44
2

A possible workaround for this issue (which still exists 6 years later) is to use \smallsetminus as a replacement.

% !TEX TS-program = xelatex

\documentclass{article}
\usepackage{unicode-math}
\setmathfont{latinmodern-math.otf}
% \setmathfont{texgyrepagella-math.otf}
% \setmathfont{xits-math.otf}

\begin{document}
$X\smallsetminus Y$
\end{document}

gives:

X \ Y

If you are lazy, you can even add at the end of your preamble:

\AtBeginDocument{
\renewcommand{\setminus}{\smallsetminus}
}
|improve this answer|||||
  • Oops, I just realized that this answer was given here as well. – Clément Nov 21 '19 at 19:41
  • Six years? There’s an open bug report from 2011. Nine years ago, as I write. – Davislor Jan 11 at 0:48
2

According to the documentation of unicode-math, \setminus is the character U+29F5 (⧵), the Unicode reverse solidus operator. Asana Math, STIX Two Math, XITS Math, Libertinus Math and Cambria Math all have it, at least. I believe that Latin Modern, the TeX Gyre fonts and Fira Math do not (as of 2020). Generally, XITS and STIX Two attempt to be absolutely comprehensive.

The very similar Unicode set minus symbol, U+2216 (∖), is much more widely supported. This is called \smallsetminus in unicode-math, and in some fonts has a less vertical slant than the traditional LaTeX \setminus. As of 2020, Latin Modern and all the TeX Gyre fonts have it.

There is an an open bug report about this from 2011 on the unicode-math tracker, which didn’t result in any consensus on how to resolve the issue. So nothing was ever done, although that doesn’t let GUST off the hook for never updating Latin Modern and the TeX Gyre fonts. The root of the problem was that Microsoft and STIX mapped the Unicode code points differently, and the developers decided not to add a package option for backward slashes like they did for forward slashes. They might also have expected GUST to fix the issue with their fonts sometime that decade.

|improve this answer|||||
1

As an alternative to the other solutions mentioned here, you could also directly use the Unicode character ∖ for "set minus" in your tex file. (Hopefully your editor uses a font that has a glyph for it like mine.) For me it works with both TeX Gyre Termes and TeX Gyre Pagella.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.