3

With Latin modern font, the symbol \setminus is invisible (I discovered, by chance, that it had gone from all my documents). Here is a MWE:

\documentclass[10pt,a4paper,french]{article}

\usepackage{mathtools} \usepackage{babel} \usepackage[warnings-off={mathtools-colon,mathtools-overbracket},math-style=french]{unicode-math} \usepackage[scale={0.75,0.8},footskip=1.5cm,heightrounded]{geometry}

\newfontface{\STIXTWO}{STIX Two Math}

\RenewDocumentCommand{\setminus}{}{\mbox{\STIXTWO\symbol{"029F5}}}

\begin{document}
$A\setminus B$
\end{document}

So I tried \newfontface with StiX Two (thanks to an answer that egreg had given me for an another symbol problem) but it doesn't work. What should I do?

Didier
  • 1,311
  • unicode-math sets up lots of commands at begin document, so your redefinition is too early. move it, or use \setmathfont{Latin Modern Math}\setmathfont[range="29F5]{STIX Two Math} – Ulrike Fischer Jul 05 '23 at 08:25
  • See also https://tex.stackexchange.com/questions/140279/which-unicode-math-fonts-support-setminus – Stephen Jul 05 '23 at 08:27
  • Thanks to both of you – Didier Jul 05 '23 at 08:40
  • Apart from the need of doing the redefinition \AtBeginDocument, you want \mathbin{\text{\STIXTWO\symbol{"029F5}}}, so the symbol has the correct spacings and scales in subscripts or subscripts. – egreg Jul 05 '23 at 09:11
  • Thank you @egreg, again. In the solution given by Ukrike, do I also have to correct the spacing? – Didier Jul 05 '23 at 10:06
  • @Didier No, in that case a math symbol is used with the correct spacing. – egreg Jul 05 '23 at 10:07
  • Ok, thanks @egreg – Didier Jul 05 '23 at 10:08
  • Could also be worth to try \smallsetminus, that exists in LM Math. – mickep Jul 05 '23 at 14:02
  • Thank you @Davislor It is not easy to choose a font. I chose Latin modern because it is one of the (very?) rare fonts which give rounded x and y in math mode – Didier Jul 05 '23 at 15:47
  • @Didier New Computer Modern has the same letter shapes. But that question is more about how to solve the bug you noticed. – Davislor Jul 05 '23 at 15:55
  • Thank you@Davislor I checked the documentation of Computer Modern Font and I am not sure I understood correctly (my English is too poor). How do I load this font, if I want math-style=french and if I also want to avoid the warnings of mathtools ? – Didier Jul 05 '23 at 21:02

2 Answers2

4

The TeX Gyre fonts are missing this symbol. This is a commonly-encountered bug, which unicode-math didn’t fix back in 2011 because it was an upstream issue, and then never implemented a workaround for, either. It would, for example, be possible to check whether the current math font contains U+29F5, and remap if not, in a font-independent way.

You might want to set, near the top of your document,

\tracinglostchars=3

to make TeX treat missing characters as an error, instead of silently ignoring them.

Your options include:

  • Load a font that has it, such as New Computer Modern (\usepackage[default]{fontsetup}) This actually uses the \smallsetminus glyph for \setminus, however.
  • Load this one symbol from a font that has it (\setmathfont{Asana Math}[range=\setminus, Scale=MatchUppercase])
  • Remap to another character, such as \smallsetminus or backslash (\AtBeginDocument{\renewcommand{\setminus}{\smallsetminus}})
Davislor
  • 44,045
3

You might do it that way, but you get a symbol whose shape is not compatible with Latin Modern. An improved version would be

\documentclass[10pt,a4paper,french]{article}

\usepackage{mathtools} \usepackage{babel} \usepackage[warnings-off={mathtools-colon,mathtools-overbracket},math-style=french]{unicode-math} \usepackage[scale={0.75,0.8},footskip=1.5cm,heightrounded]{geometry}

\newfontface{\STIXTWO}{STIX Two Math}

\AtBeginDocument{% \RenewDocumentCommand{\setminus}{}{\mathbin{\text{\STIXTWO\symbol{"029F5}}}}% }

\begin{document}

$A\setminus B$

$x_{A\setminus B}$

\end{document}

enter image description here

But a better solution for Latin Modern (and other fonts that miss the character) would be as follows.

\documentclass[10pt,a4paper,french]{article}

\usepackage{mathtools} \usepackage{babel} \usepackage[warnings-off={mathtools-colon,mathtools-overbracket},math-style=french]{unicode-math} \usepackage[scale={0.75,0.8},footskip=1.5cm,heightrounded]{geometry}

\AtBeginDocument{% \RenewDocumentCommand{\setminus}{}{\mathbin{\backslash}}% }

\begin{document}

$A\setminus B$

$x_{A\setminus B}$

\end{document}

enter image description here

egreg
  • 1,121,712