unicode-math icon indicating copy to clipboard operation
unicode-math copied to clipboard

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

Open jfbu opened this issue 6 years ago • 2 comments

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:

  • usage of ℑ for imaginary part is perhaps not that established typographically,

  • in mathematics, linear algebra has extremely widespread usage of Im for Image, and it is natural to desire using \Im for this. It is also a widespread choice to use Im and not ℑ for imaginary part.

  • amsmath is very obstinate in making \DeclareMathOperator preamble only (\@onlypreamble\DeclareMathOperator, \@onlypreamble\@declmathop).

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

  • [x] Relevant for XeTeX
  • [x] Relevant for LuaTeX

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.

jfbu avatar Jun 29 '18 07:06 jfbu

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 avatar Jun 29 '18 08:06 davidcarlisle

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.

davidcarlisle avatar Jun 29 '18 08:06 davidcarlisle