2

I wish to define a LaTeX macro which would more or less function exactly as \overrightarrow except with a harpoon in place of an arrow. I've researched many solutions and none of them quite do the job.

  1. Tikz solution: looks nice, but is not variable width.
  2. Overset solution: works if you move the harpoon down, but also not variable width.
  3. Harpoon package solution: is variable width, but the harpoon is twice as tall as it should be. The shape of the harpoon also varies with its width, instead of keeping the same harpoon head and varying the length of the tail.
  4. Accent set solution: not variable width.
  5. XeTeX solution: this looks exactly like what I want, but I am typesetting my document in LaTeX.

Is there a way to reproduce the XeTeX solution in LaTeX, or alter one of the other solutions to fit the properties I want?

3

A rather crude solution is to copy the definition of \overrightarrow from amsmath:

\documentclass{article}
\usepackage{amsmath}

\makeatletter
\newcommand{\overrightharpoon}{%
  \mathpalette{\overarrow@\rightharpoonfill@}}
\def\rightharpoonfill@{\arrowfill@\relbar\relbar\rightharpoonup}
\makeatother

\begin{document}

$\overrightharpoon{aaaaaaa}+\overrightharpoon{a}$

\end{document}

enter image description here

You can get smaller harpoons by using a modified code from https://tex.stackexchange.com/a/248297/4427

\documentclass{article}
\usepackage{amsmath}

\makeatletter
\newcommand{\overrightsmallharpoon}{\mathpalette{\overarrowsmall@\rightharpoonfill@}}
\def\rightharpoonfill@{\arrowfill@\relbar\relbar\rightharpoonup}
\newcommand{\overarrowsmall@}[3]{%
  \vbox{%
    \ialign{%
      ##\crcr
      #1{\smaller@style{#2}}\crcr
      \noalign{\nointerlineskip}%
      $\m@th\hfil#2#3\hfil$\crcr
    }%
  }%
}
\def\smaller@style#1{%
  \ifx#1\displaystyle\scriptstyle\else
    \ifx#1\textstyle\scriptstyle\else
      \scriptscriptstyle
    \fi
  \fi
}
\makeatother

\begin{document}

$\overrightsmallharpoon{aaaaaaa}+\overrightsmallharpoon{a}$

\end{document}

enter image description here

  • Thank you so much! The solution with the smaller harpoons is exactly what I was looking for. – kccu Jul 12 '17 at 19:56
  • @kccu Don't forget to do \newcommand{\foo}[1]{\overrightsmallharpoon{#1}}, where \foo is a more sensible name for the accent. – egreg Jul 12 '17 at 20:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.