3

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.

2
  • If the expression under the arrow is to consist of more than one character, please say so. Mar 2, 2020 at 16:44
  • @barbarabeeton Thank you, I edited the question Mar 2, 2020 at 18:21

3 Answers 3

3

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

6
  • The second line is very good. One point: is it possible to integrate the trick of @Sebastiano in order to diminish the gap between arrow and text? Mar 3, 2020 at 12:40
  • I also notice that the arrow, in case of a single char, is ways wider than the char. But perhaps that is defined in amsmath. Mar 3, 2020 at 12:43
  • @PeptideChain The minimal length is the the width of \rightharpoonup and there is not much to do about that. One could start clipping characters but that would become too hacky for my taste. The height might be adjustable but I can't do it right now. Maybe tomorrow.
    – campa
    Mar 3, 2020 at 12:51
  • If by "adjusting the height" you mean to scale vertically, then the head of the arrow get reduced, and that would be not good. Just intuitively since I have no much idea: instead of clipping isn't it possible to move the arrow vertically (like a negative distance)? Take your time: I have implemented you solution and if you improve it, I'll adjust the macro. Thank you very much. Mar 3, 2020 at 13:10
  • @PeptideChain No, by adjusting the height I meant reducing the gap between the arrow and the symbol(s).
    – campa
    Mar 3, 2020 at 13:20
2

Bad notation, IMHO. Anyway

\documentclass{article}
\usepackage{amsmath,accents}
\newcommand{\myvect}[1]{\accentset{\rightharpoonup}{#1}}
\begin{document}
$\myvect{r}$
\end{document}

does what you want.

enter image description here

1
  • (1) bad notation: in general I agree; it is only the geometrical field, over two points like PQ, otherwise I use boldface (physics) or nothing (linear algebra); perhaps I will use just the order of the points to determine the direction; (2) about your solution: (a) the figure of the head is not correct, (b) the arrows does not cover the whole width of the body (try $\myvect{AB}$) Mar 2, 2020 at 12:14
2

I agree totally with the user @egreg. If you prefer it is possible to use a macro on the site (it has added into the code) where you can increase or decrease the height of the \rightharpoonup symbol at your convenience. If you set with \kern0 you have a good blank space between the symbol and the character.

enter image description here

\documentclass[12pt]{article}
\usepackage{amsmath}
%%%% Edit (\kern0) of the specific macro from https://www.latex4technics.com/?note=3cz1
\makeatletter
\newcommand{\ovset}[3][0ex]{%
  \mathrel{\mathop{#3}\limits^{
    \vbox to#1{\kern0\ex@
    \hbox{$\scriptstyle#2$}\vss}}}}
\makeatother

\begin{document}

$\ovset{\rightharpoonup}{r}, \ovset{\rightharpoonup}{P}$

\end{document}

Addendum: Using mathabx package you have a similar picture of the arrow. Peraphs using trimclip, o clipbox you can obtain a exact symbol. Here there is an addendum.

enter image description here

\documentclass[12pt]{article}
\usepackage{amsmath,mathabx}
%%%% Edit (\kern0) of the specific macro from https://www.latex4technics.com/?note=3cz1
        \makeatletter
        \newcommand{\ovset}[3][0ex]{%
          \mathrel{\mathop{#3}\limits^{
            \vbox to#1{\kern0\ex@
            \hbox{$\scriptstyle#2$}\vss}}}}
        \makeatother

\begin{document}

$\ovset{\rightharpoonup}{r}, \quad \ovset{\rightharpoonup}{G}$

\end{document}
3
  • Thank you. This is an improvement compared to @egreg; as in the comment to @egreg : (a) the figure of the head is not correct, (b) the arrows does not cover the whole width of the body Mar 2, 2020 at 18:23
  • :-) But I have not understood the question (a) and (b) excuse me. Can you put an image done with your hand, please?
    – Sebastiano
    Mar 2, 2020 at 20:35
  • 1
    I added a picture to my question. (a) With "head" I mean the head of the arrow; the form of the head is not correct (b) Both solutions produce an arrow that is too short and not as long as the text under the arrow is. The solution is not far away from the package esvect Mar 3, 2020 at 7:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .