[Tex/LaTex] Special vector over text (half head of the arrow, vertically compact)

amsmathmath-mode

I'm looking for a vector symbol that look like that

enter image description here

and has the following characteristic:

  1. is meant to be for maths environment (also inline)
  2. has the form \commandname{body}
  3. is exactly wide as the body (to avoid problem with indices pre or post-fixed)
  4. the arrow is as this one: enter image description here
  5. … but only the upper half
  6. vertically compact enough to be inline.
  7. compatible with amsmath
  8. expression under the arrow is to consist of more than one character and the arrow should cover the whole expression

There are many solutions out there that cover only half of my problem. The best starting point is the package esvect from where I took the picture of the arrow:
http://mirror.kumi.systems/ctan/macros/latex/contrib/esvect/esvect.pdf
It also contains the whole code (for who understand it).
What is missing in the package esvect is that the arrow should be halved.

MWE, the \myvect is to be replaced

\documentclass{article}
\usepackage{amsmath}
\newcommand{\myvect}[1]{\mathbf{#1}}
\begin{document}
$\myvect{r}$
\end{document}

Here is anorther link
How to use harpoon-style arrows over vectors, like this?
BUT (1) the space between body and arrow is for me not acceptable (as pointed out by a comment) (2) I really do not like the type of arrow head.

Best Answer

The extensible arrow can be easily obtained by copying the definitions in amsmath. As for the form of the tip, the problem is to find an adequate font. The mathabx package provides something more similar to the esvect arrows, thought it's still no perfect match. Since mathabx replaces a lot of symbols, one may decide to import only one, see Importing a Single Symbol From a Different Font.

\documentclass{article}

\usepackage{amsmath}

\makeatletter
% \overarrow@ and \arrowfill@ are defined in amsmath
\newcommand*{\overrightharpoonup}{\mathpalette{\overarrow@\rightharpoonupfill@}}
\newcommand*{\rightharpoonupfill@}{\arrowfill@\relbar\relbar\rightharpoonup}
\makeatother

\DeclareFontFamily{U}{matha}{\hyphenchar\font45}
\DeclareFontShape{U}{matha}{m}{n}{
      <5> <6> <7> <8> <9> <10> gen * matha
      <10.95> matha10 <12> <14.4> <17.28> <20.74> <24.88> matha12
      }{}
\DeclareSymbolFont{matha}{U}{matha}{m}{n}
\DeclareMathSymbol{\varrightharpoonup}{3}{matha}{"E1}

\begin{document}

$\overrightharpoonup{a}$
$\overrightharpoonup{ab}$
$\overrightharpoonup{abcde}$

\bigskip
% using the mathabx harpoon
\let\rightharpoonup\varrightharpoonup
$\overrightharpoonup{a}$
$\overrightharpoonup{ab}$
$\overrightharpoonup{abcde}$

\end{document}

enter image description here

Related Question