# Which Unicode math fonts support \setminus?

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?

• 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;! 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. Oct 23 '13 at 15:47
• 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? Jan 10 '20 at 19:24

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}


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

$X \mathbin{\backslash} Y$


that gives

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}

• sorry I did make a bug report to Boguslaw Jackowski on October 27, 2012.
– user4686
Oct 23 '13 at 21:58
• 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
• @egreg Perhaps this is an area where unicode-math could offer (or provide an interface) to substitute one slash with another. Jul 1 '14 at 0:46
• @Socowi \AtBeginDocument{\renewcommand{\setminus}{...}} Jun 5 '18 at 11:17
• @Socowi I guess that five years ago this wasn't necessary; I took the occasion for improving my answer, thanks. Jun 5 '18 at 11:22

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;!

• 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? 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. Oct 23 '13 at 16:34

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. ETA: New Computer Modern is a replacement for Latin Modern that does.

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.

### ETA

Some other solutions no one has yet posted:

Load a math font that contains \setminus. That is, nearly all of them other than the default! Search this document for \setminus and you will get half a dozen font specimens.

If you still want to use Latin Modern math for everything else, you can load just this one symbol with:

\setmathfont{Latin Modern Math}
\setmathfont[range=\setminus, Scale=MatchUppercase]{STIX Two Math}


You can use \smallsetminus in your source, or redefine \setminus as:

\AtBeginDocument{\renewcommand\setminus{\smallsetminus}}


The \AtBeginDocument wrapper is necessary because unicode-math, for compatibility with other packages, defers most of its definitions until after the preamble.

If you wanted to save the definition from a legacy package such as amssymb, unicode-math will overwrite its definition of setminus even if you include the package afterward. The way to use a legacy definition of a command is to load the legacy package first, save the definition you want with letltxmacro (in case it’s a robust macro), load unicode-math, and then restore the saved definition with \AtBeginDocument.

I would strongly recommend against pasting a backward slash into your source, as there are at least four different backslashes in Unicode and most editors make it impossible to tell them apart. If you do need to insert a specific Unicode codepoint in your source, I would recommend writing it out as, e.g.:

\usepackage{newunicodechar}
\newunicodechar{^^^^29f5}{\smallsetminus} % Remap U+29F5 SET MINUS in the source to U+2216.


which you might conceivably do as a workaround for a document that uses literal ⧵ characters in the source, as at least one other answer has suggested.

• This is bug in the mentioned unicode-math documentation and in unicode-math code. The symbol U+2216 has its name "Set Minus Unicode Character". This is \setminus, no small set minus. And the character U+29F5 has its name "Reverse Solidus Operator" (as you mentioned), no \setminus. Jun 4 '20 at 6:16
• @wipet It’s a design decision that you don’t like. It’s correct, according to the official spec, and has been documented behavior for years. It is not possible to change without breaking compatibility. A better word might be “misfeature.” Jun 4 '20 at 6:22
• The Unicode table (which is much more official) were specified many years before unicode-math spec. This is only bug when reading Unicode table spec. And I like this design decision of unicode-math because this makes problems only to LaTeX users. If they don't use LaTeX (like me) then they don't have problem. :) Jun 4 '20 at 6:32
• The font designers read Unicode table spec., not the unicode-math LaTeX package spec. From this point of view the unicode-math is not :official: spec. Jun 4 '20 at 6:34
• @wipet The spec I was referring to was the STIX mapping from Unicode codepoints to LaTeX commands. I don’t feel like I have anything more to add about this. Jun 4 '20 at 6:40

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:

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

\AtBeginDocument{
\renewcommand{\setminus}{\smallsetminus}
}

• Oops, I just realized that this answer was given here as well. Nov 21 '19 at 19:41
• Six years? There’s an open bug report from 2011. Nine years ago, as I write. Jan 11 '20 at 0:48

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.

load all traditional math stuff before unicode-math

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

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

• I get fontspec error: "font-not-found" at \setmathfont{XITSMath}. What should i install? Oct 23 '13 at 21:44
• In any case, doing \usepackage{amssymb} before \usepackage{unicode-math} does not help. 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. Oct 23 '13 at 21:58
• ok, so this answer was not about getting \setminus back. Oct 23 '13 at 22:27
• @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