latex3 / unicode-math

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

Take care of commands like `\tilde␣` #540

Open muzimuzhi opened 4 years ago

muzimuzhi commented 4 years ago

Description

unicode-math redefines math commands like \tilde from

macro:->\protect \tilde␣

to

\protected macro:->...

And if user does not explicitly use \setmathfont in preamble, the above redefinition takes place at begin document. But in some cases, commands like \title are expanded at preamble (thus before begin document). This can be solved by using \protect\tilde, but protecting a robust command is not so straightforward.

It would be better that unicode-math will update the definition of commands like tilde␣ inside \setmathfont.

Add info or delete as appropriate:

Minimal example demonstrating the issue

\documentclass[12pt]{article}
\usepackage{unicode-math}

\makeatletter
\protected@xdef\cmd{\tilde}
\makeatother

\begin{document}
\[
  \cmd{D},  % tilde accent is at wrong position. 
            % equivalent to \protect \tilde␣{D}
  \tilde{D}
\]
\end{document}