[Tex/LaTex] Using unicode “combining right arrow above” to generate vector command

math-modeunicodeunicode-math

This question originated from a confusion created by some Linux
systems where, for some software (editor and browser) the combining
unicode characters appear to apply to the right (instead of to the
left like the documented convention). So it could be a "localized" issue
(well, localized to all Linux systems). In fact this bug looks like a
useful feature because it allows straight conversion for the typesetter
commands. Still answers and notes about unicode math with accents are greatly appreciated.

The unicode-math list of symbol describes "combining right arrow above" ( or ⃗x) as translated into \vec in Section 7.

How is one supposed to use this feature of unicode-math?

In this example I don't get the arrow above the $x$:

\documentclass{article}
\usepackage{unicode-math}
\begin{document}
$ ⃗x$ %this line contains the unicode arrow and the x character (in case your browser doesn't show it).
\end{document}

(The compilation with lualatex and xelatex shows simply x with no arrow)

This is strange because unicode-math works for other things like superindexes, etc.

EDIT: For those having trouble seeing the unicode characters, here it is an screenshot of my editor (gedit), my browser shows basically the same:

geditunicode

EDIT 2: This is how @Jukka answer looks like in my browser:

screenshot: jukka

EDIT 3: I realized that the rendering (of the text/code) is very system dependent, so if you answer this question please add a screenshot of what you see in your editor or browser. There is probable bug filed already about this: https://bugs.launchpad.net/ubuntu/+source/firefox/+bug/51554.

For example, so far, I find that <arrow>x renders the arrow over the x in Gedit 3.10 and Firefox 28.0 and the arrow before the x for TeXworks and Google Chrome. In later version of gedit 3.34, the arrow appears alone before the x.

Best Answer

In Unicode, a combining mark is associated with the character that precedes it, so you should use $x⃗$(the content between dollar signs is letter x followed by U+20D7 COMBINING RIGHT ARROW ABOVE). And you should declare a mathematical font that contains the character.

But it still won’t work, presumably due to limitations in unicode-math, in fonts, or in the LaTeX interpreter(s) you are using. Combining marks are often poorly implemented in fonts (their metrics are wrong, causing the mark to be misplaced) and in rendering software (as we can see here: x⃗ does not look right at all).

The conclusion is that you should use methods like \vec{x} or, if you can choose the notations used, use bold face for vectors instead of an arrow above. Bold face is the primary notation according to the ISO 80000-2 standard and the only notation described in the US standard (ANSI/IEEE Std 260.3-1993). It is also typographically more robust.

Related Question