6

The following MWE yields the attached picture:

\documentclass{article}

\usepackage{fontspec}
\usepackage{amsmath,amssymb}
\usepackage{unicode-math}

\begin{document}
With \LaTeX{} commands:
\begin{gather*}
  A \not= B\\
  A \not\le B\\
  A \not\lesssim B\\
  A \not\approxeq B
\end{gather*}

With Unicode characters:

\begin{gather*}
  A \not= B\\
  A \not≤ B\\
  A \not≲ B\\
  A \not≊ B
\end{gather*}
\end{document}

number 6

Why is \not replaced by 6?

I tried using a Unicode combining long solidus overlay instead, but that doesn't work at all:

\begin{gather*}
  A ≠ B\\
  A ≰ B\\
  A ≴ B\\
  A ≊̸ B
\end{gather*}
Clément
  • 4,004
  • I guess, this is due to Unicode font fallback for unsupported characters. – Gipfeli Aug 11 '16 at 21:58
  • 2
    \not is very broken in unicode-math. – egreg Aug 11 '16 at 22:02
  • @Gipfeli No; setting \setmathfont{XITS Math} or similar doesn't change anything. – Clément Aug 11 '16 at 22:02
  • @egreg Thanks :) Do you know how I can disable unicode math temporarily to input that character, then? There's no single unicode character for the combination \not\approxeq – Clément Aug 11 '16 at 22:03
  • 1
    You can make your own \notapproxeq: \def\notapproxeq{\mathrel/\joinrel\mkern-8mu\approxeq} and use it like $A \notapproxeq B$ – alwaysask Aug 11 '16 at 22:21
  • @alwaysask Thanks; the spacing is wrong though. Do you know if there's a way to temporarily disable unicode-math, for just one symbol? – Clément Aug 11 '16 at 23:58
  • I don't think you can disable packages, see How to undo \usepackage?. The spacing can be tweaked: \def\notapproxeq{\,\mathrel/\joinrel\mkern-8.5mu\approxeq}. It turns out the \not definition in unicode-math looks for an already defined \not version of the symbol so just by inserting the new definition in the preamble the A \not\approxeq B bit gets fixed. – alwaysask Aug 12 '16 at 07:04
  • If you already input Unicode, why not use the appropriate glyphs: (\ne), (\nleq), (\nlesssim)? Unfortunately, ≊̸ is not mapped by unicode-math, so you have to build this one yourself: \def\napproxeq{\mathpalette\donot\approxeq} \def\donot#1#2{{\ooalign{$#1#2$\cr\hidewidth$#1\divslash$\hidewidth\cr}}} or use (\ncong). – Henri Menke Aug 12 '16 at 15:35
  • @HenriMenke because the only one I care about is \not\approxeq :) I already use unicode for the other ones. – Clément Aug 12 '16 at 15:58
  • As far as I can tell, this has been fixed in the most recent version of unicode-math.sty, January 8, 2018. – sgmoye Jan 09 '18 at 18:36

2 Answers2

4

If a suitable unicode char exists for a combination \not + unicode symbol you can add the needed declarations and they will work like the combination of \not + command. But imho there is no \not\approxeq, so here one needs a fallback like a combination with a solidus. You get a 6 in this case as there seem to be a bug in unicode-math: it looses the definition of \not from unicode-math-tables. This seems to be a work around (but imho doesn't looks perfect).

\documentclass{article}

\usepackage{fontspec} \usepackage{amsmath,amssymb}

\usepackage{unicode-math} \setmathfont{Latin Modern Math} \ExplSyntaxOn \cs_gset:cpn { not≤ } { \nleq } \cs_gset:cpn { not≲ } { \not\lesssim } %Fallback bug correction: __um_sym:nnn {"00338}{__um_oldnot: }{\mathaccent} \ExplSyntaxOff

\begin{document} With \LaTeX{} commands: \begin{gather} A \not= B\ A \not\le B\ A \not\lesssim B\ A \not\approxeq B \end{gather}

With Unicode characters:

\begin{gather} A \not= B\ A \not≤ B\ A \not≲ B\ A \not≊ B \end{gather} \end{document}

enter image description here

Edit

One get a better "fallback" \not if one uses the overlay keyword. This works only with lualatex: As an example here for for your \approxeq:

\documentclass{article}

\usepackage{fontspec} \usepackage{amsmath,amssymb}

\usepackage{unicode-math}

%\setmathfont{Cambria Math}

\newcommand\napproxeq{\Umathaccent overlay fixed 7\symoperators "00338 \approxeq}

\begin{document} $A \napproxeq B $

$A \not\approxeq C $

\end{document}

enter image description here

I will add this to the issue tracker for unicode math.

Ulrike Fischer
  • 327,261
  • Right, but this doesn't look very good at all :/ – Clément Aug 12 '16 at 22:24
  • I know, But you can change the definition of \__um_oldnot: to improve the look. This won't affect the correct symbols. – Ulrike Fischer Aug 12 '16 at 22:30
  • Ah, neat :) In you examples, I feel that there is an issue with how it's positioned, too: it seems to be higher than in the other symbols. – Clément Aug 12 '16 at 22:38
  • @Clément: I added an edit for a better fallback not. – Ulrike Fischer Aug 13 '16 at 12:45
  • Thanks :) Now I really don't know which answer to accept ^^ Question: do you think the code that you wrote could be integrated as a general fix in unicode-math? It seems to have few dependencies, right? – Clément Aug 13 '16 at 13:05
  • I wouldn't use Stevens code if not needed. It doesn't scale correcty (try \not= in a subscript), and it affects also combinations for which negated glyphs exist (copy & paste e.g. ≠ to see the difference). Beside this I think that you identified two bugs and that unicode-math should fix them. – Ulrike Fischer Aug 13 '16 at 13:16
2

Locally redefine \not as a stack.

\documentclass{article}

\usepackage{fontspec}
\usepackage{amsmath,amssymb}
\usepackage{unicode-math}
\usepackage{stackengine}
\AtBeginDocument{\renewcommand\not[1]{%
  \mathrel{\ensurestackMath{\stackengine{0pt}{#1}{\mkern1mu/}{O}{c}{F}{T}{L}}}}%
}

\begin{document}
With \LaTeX{} commands:
\begin{gather*}
  A \not= B\\
  A \not\le B\\
  A \not\lesssim B\\
  A \not\approxeq B
\end{gather*}

With Unicode characters:

\begin{gather*}
  A \not= B\\
  A \not≤ B\\
  A \not≲ B\\
  A \not≊ B
\end{gather*}
\end{document}

enter image description here

For comparison, here is the original unrepaired code.

enter image description here

  • Thanks; very nice! Do you think this could be a valuable patch to unicode-math? – Clément Aug 12 '16 at 14:32
  • @Clément I imagine a package like unicode-math would prefer to not rely on external packages like stackengine. Also, as is, this answer does not translate to smaller math styles, though I can revise & extend to do so, if that is important. – Steven B. Segletes Aug 12 '16 at 14:43
  • I don't particularly need the smaller styles :) Thanks for the explanation. – Clément Aug 12 '16 at 15:34
  • Better use \divslash than /. The plain / is much too long in my opinion. – Henri Menke Aug 12 '16 at 15:38
  • @HenriMenke \divslash looks good over something like =; however, it is far worse looking, in my opinion, when placed over things like \le, and\lesssim. It's a toss-up for \approxeq. – Steven B. Segletes Aug 12 '16 at 15:51