latex3 / unicode-math

XeLaTeX/LuaLaTeX package for using unicode/OpenType maths fonts
http://ctan.org/pkg/unicode-math
LaTeX Project Public License v1.3c
241 stars 28 forks source link

Provide some option to avoid overwriting some commonly used things like `\Im` #477

Open jfbu opened 6 years ago

jfbu commented 6 years ago

Description

At begin document, unicode-math reassigns meaning of \Im to use ℑ (U+02111). The mapping in itself is somewhat logical following Plain TeX legacy fonts and \mathchardef\Im="023D (very specific to TeX fonts). The problem though is:

As a result of this, average user will have a problem with \DeclareMathOperator{\Im}{Im} in preamble as this is overridden by unicode-math at begin document. And moving the declartion to the document body fails due to item 3 above.

Notice that unicode-math does not hesitate overwriting user choice as example below demonstrates.

This context in particular to legacy documents moving over to unicode-math and OpenMath fonts.

Check/indicate

Minimal example demonstrating the issue

\documentclass{article}
\usepackage{amsmath}
\usepackage{unicode-math}
\setmathfont{texgyrepagella-math.otf}
\setmonofont{Libertinus Mono}
\let\Im\relax % try to make LaTeX happy
\DeclareMathOperator{\Im}{Im}
\begin{document}
\[
  \Im f = \{0\}% no luck, f is a morphism not a complex number
\]
\texttt{\string\Im\space has meaning: \meaning\Im}% arrgh, ℑ does not show with Latin Modern
% hence I used Libertinus
\end{document}
% Local variables:
% TeX-engine: xetex
% End:

capture d ecran 2018-06-29 a 09 39 54

Further details

I found no hint in documentation about such potential issue. It may deserve some mention and some workaround.

davidcarlisle commented 6 years ago

because unicode-math sets everything up at begin document then any user-override needs to do the same. This works:


\AtBeginDocument{
\let\Im\relax % try to make LaTeX happy
\DeclareMathOperator{\Im}{Im}}

There is a separate issue on making unicode-math not delay so much see Issue #465

davidcarlisle commented 6 years ago

Note that while I agree users should be able to change this, the association isn't just in legacy tex fonts, ℑ and ℑ both give ℑ in HTML for example.