latex3 / unicode-math

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

Subscripts treated as normal letters in command names #494

Open thirs opened 5 years ago

thirs commented 5 years ago

Description

Writing \mooᵥ results in an "Undefined control sequence" error. How easy would it be to stop command names when sub/superscripts characters are encountered?

Check/indicate

Minimal example demonstrating the issue

\documentclass{article}
\usepackage{unicode-math}
\setmathfont{texgyrepagella-math.otf}
\begin{document}
\[
  \mooᵥ
\]
\end{document}

Further details

eg9 commented 5 years ago

They are letters.

If you mean to use ᵥ (U+1D65 LATIN SUBSCRIPT SMALL LETTER V) in place of _{v}, don't. If you insist, then

\usepackage{newunicodechar}
\newunicodechar{ᵥ}{\ifmmode_{v}\elseᵥ\fi}

but don't hope that, after similar definitions for the other subscripts characters, something like

$xᵥₐ$

works.

thirs commented 5 years ago

Ok... thanks for your answer. Would you please mind explaining why hoping to use ᵥ instead of _{v} is wrong? It does make latex code much more readable.

davidcarlisle commented 5 years ago

On Thu, 27 Sep 2018 at 12:09, thirs notifications@github.com wrote:

Ok... thanks for your answer. Would you please mind explaining why hoping to use ᵥ instead of _{v} is wrong? It does make latex code much more readable.

If you make it an active character expanding to _{v} as then it is OK, but if you just set it directly as a subscript character then the positioning will be inconsistent with all other subscripts and always be positioned at a fixed position below the baseline:The position of _{v} varies depending on the depth of the base and also on the size of any superscript that is on the same base.

The Unicode sub and superscript characters are really designed for simple text usage and not to fit in with a math layout

David

thirs commented 5 years ago

Thanks David. How about adding these active characters as an option?

wspr commented 5 years ago

@davidcarlisle / @eg9 — unicode-math (perhaps foolishly) already interprets these unicode chars as if the user intended to write a maths subscript (like how ' works in traditional LaTeX). If I was to re-write the package I'd probably drop this feature, but it seems popular (-ish).

The only problem here is that is catcode 11. So no need for newunicodechar etc:

\documentclass{article}
\usepackage{unicode-math}
\def\moo{m}
\catcode`\ᵥ=12
\begin{document}
\[ \mooᵥᵥ \]
\end{document}

I'll consider a package option to do this automatically.