Unicode-math swallows my backslash

The error you’re getting is completely unrelated to the Greek language. It’s a font issue. The default math font, Latin Modern Math, does not have a \setminus symbol. The default behavior of TeX is to silently log a warning message to the .log file.

You can at least get it to print a warning message by adding the command \tracinglostchars=2. You should seriously consider doing this all the time. That tells you what’s wrong:

 Missing character: There is no ⧵ (U+29F5) in font LatinModernMath:mode=base;script=math;language=dflt;!

There are several workarounds.

Load a Math Font that has U+29F5

\tracinglostchars=2 % Print a warning if a glyph is missing
\documentclass[10pt,a4paper]{article}

\usepackage{polyglossia}
\usepackage{unicode-math}

\setdefaultlanguage{english}

\defaultfontfeatures{Scale = MatchLowercase}
\setmainfont{GentiumPlus}[Scale = 1.0]
\setmathfont{Libertinus Math}

\begin{document}
\begin{equation*}
A \setminus B
\end{equation*}
\end{document}

Gentium+Libertinus Math sample

If you would rather use the default symbols for everything else, you can load just that one symbol with:

\setmathfont{Latin Modern Math} % Or your math font of choice.
\setmathfont[range=\setminus]{Libertinus Math}

Use a Different Symbol

Latin Modern Math does have \smallsetminus as an alias for U+2216, so you could replace \setminus with that. You could also redeclare \setminus as \smallsetminus:

\tracinglostchars=2 % Print a warning if a glyph is missing
\documentclass[10pt,a4paper]{article}

\usepackage{polyglossia}
\usepackage{unicode-math}

\setdefaultlanguage{english}

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

\begin{document}
\begin{equation*}
A \setminus B
\end{equation*}
\end{document}

Latin Modern Math sample

You need to patch unicode-math symbol definitions \AtBeginDocument. It intentionally delays them until after it’s finished loading packages. Your MWE is a good example of why: if it did not do this, every document that loaded \amssymb after unicode-math would break.

Postscript

Although it’s totally unrelated to your issue, you’re copy-pasting several old packages into your template that are redundant or even harmful. Here is what I cleaned out:

  • The documentation for xecyr has said, “xecyr is not needed anymore,” since 2010.
  • The xunicode package is also obsolete.
  • The unicode-math package loads fontspec and amsmath for you. You only need to load either one manually if you need to change the loading order or options.
  • Legacy math packages such as amssymb and amsfonts are overridden by unicode-math.

If clearing these packages out creates any bugs, I’d like to know what you’re doing that needs them.

Why is this Happening?

Contrary to another answer, this is not a bug in unicode-math, but in the Latin Modern Math font. It’s following the reference implementation correctly. (Thanks to @egreg for the link to the discussion!)

The only reason an option to remap \setminus wasn’t added back in 2011, however, was that the designers assumed that GUST would fix their font before too long.


I tried to compare your LaTeX code with Unicode math. The \show\setminus says:

\setminus=\mathchar"226E.
or in math environment:
\setminus=the character ⧵.

It does not seems like Unicode math, so maybe this is a LaTeX bug. I compared the same in my OpTeX, which supports Unicode math too:

\fontfam[lmfonts]

test $A \setminus B$

\bye

The \setminus works. And the \show\setminus says:

\setminus=\Umathchar"2"01"002216.

It seems to be real Unicode math. IMHO your problem shows a LaTeX's Unicode math bug. Note that I commented out many LaTeX packages from your example: amsymbb, xunicode, xeyr, masmath, amsfonts and main font GentiumPlus. So only Latin Modern Math font is used. The LaTeX bug (non-Unicode \setminus) is still here.

Edit The problem is that unicode-math package for LaTeX declares \setminus as U+29F5 Reverse Solidus Operator Unicode Character but Latin Modern Unicode Math includes the character U+2216 Set Minus Unicode Character. The Latin Moderm Math sets the character at right position but LaTeX includes bug because it expects the character at non-math position.