# How to reduce the space between the hat of overset and the symbol?

I would like to place the \rightharpoonup on r and get them closer. I had tried the \overset and \Rvector package. But the spacing of the former is too much. And the latter performs bad when placing in smaller font size. I provide the code as follow:

 \documentclass[titlepage]{article}
\usepackage[cm]{fullpage}
\usepackage{amsmath,amssymb}
\begin{document}
$\mathbf{e}_{\overset{\rightharpoonup}{r}}$
\end{document}

-
Welcome to TeX.SX! Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – Christian Hupfer Jul 20 '14 at 15:58
A tip: If you indent lines by 4 spaces or enclose words in backticks , they'll be marked as code, as can be seen in my edit. You can also highlight the code and click the "code" button (with "{}" on it). – Christian Hupfer Jul 20 '14 at 16:21
– Werner Jul 20 '14 at 16:32

Here's a quick-and-not-too-dirty offering: a macro called \harp. It assumes it'll be used in subscript and superscript positions only. For now, it only works with letters that do not have an ascender part. I.e., don't use if with letters such as b, d, f, h, etc. (If you do need to use the macro with such letters, you'll need to tweak the argument of the \raise macro.)

\documentclass[titlepage]{article}
\usepackage[cm]{fullpage}
\usepackage{amsmath,amssymb}
\newcommand\harp[1]{\mathstrut\mkern2.5mu#1\mkern-11mu\raise0.6ex%
\hbox{$\scriptscriptstyle\rightharpoonup$}}
\begin{document}
$\mathbf{e}_{\overset{\rightharpoonup}{r}} \text{ vs.\ } \mathbf{e}_{\harp{r}}$
\end{document}

-
Thanks,it works really good. – 陳智圓 Jul 20 '14 at 23:59

There are two orders of problems:

1. the distance from the arrow to the symbol is too big;

2. in subscripts or superscripts, the arrow is too wide.

Here's a solution for both.

\documentclass[titlepage]{article}
\usepackage{amsmath,graphicx}

\newcommand{\harp}[1]{\mathpalette\harpoonvec{#1}}
\newcommand{\harpvecsign}{\scriptscriptstyle\rightharpoonup}
\newcommand{\harpoonvec}[2]{%
\ifx\displaystyle#1\doalign{$\harpvecsign$}{#1#2}\fi
\ifx\textstyle#1\doalign{$\harpvecsign$}{#1#2}\fi
\ifx\scriptstyle#1\doalign{\scalebox{.6}[.9]{$\harpvecsign$}}{#1#2}\fi
\ifx\scriptscriptstyle#1\doalign{\scalebox{.5}[.8]{$\harpvecsign$}}{#1#2}\fi
}
\newcommand{\doalign}[2]{%
{\vbox{\offinterlineskip\ialign{\hfil##\hfil\cr#1\cr$#2$\cr}}}%
}

\begin{document}

\begin{equation*}
\mathbf{e}_{\harp{r}_{\harp{r}}}  \harp{\mathbf{g}} \harp{A}
\end{equation*}

\end{document}


-

A solution using the accents package. The difference of vertical spacing with respect to the O.P. method with \overset is null in scriptscriptstyle, slight in \scriptstyle and more important in \textstyle. Otherwise the placement is different :

\documentclass[titlepage]{article}
\usepackage{amsmath,amssymb}
\usepackage{accents}
\newcommand*\harp[1]{\mkern2mu\accentset{\rightharpoonup}{#1}\mkern2mu}%

\begin{document}

$\begin{array}{cc} \texttt{\small\textbackslash mathaccent: } & \texttt{\small\textbackslash overset: }\\ \mathbf{e}_{\scriptscriptstyle\harp r} & \mathbf{e}_{\scriptscriptstyle\overset{\rightharpoonup}{r}} \\[2pt] \mathbf{e}_{\harp r} & \mathbf{e}_{\overset{\rightharpoonup}{r}} \\[4pt] \harp{\mathbf g } & \overset{\rightharpoonup}{\mathbf g} \end{array}$%

\end{document}


-
The vertical space between the harpoon and the letter seems no smaller (and possibly even a bit larger) in your code as is already the case with the OP's code. – Mico Jul 20 '14 at 21:40
It is slightly smaller in scriptstyle(by 0.4pt), equal in scriptscriptstyle and noticeably smaller in textstyle (by 1.4pt). See my updated answer. – Bernard Jul 20 '14 at 23:04

Macros from the stackengine package allow one to set the vertical stacking gap. Compare items 1 vs. 2 and/or items 3 vs. 4, and/or 5 vs. 6 for a demonstration of changing the stacking gap. In addition, the appearance will also be affected by what is considered the baseline of the subscipt. In 1, 2, the baseline is between the "r" and the harpoon; in 3, 4, the "r" is the baseline, whereas in 5, 6, the "harpoon" is the baseline.

\documentclass[titlepage]{article}
\usepackage[cm]{fullpage}
\usepackage{amsmath,amssymb}
\usepackage{stackengine}
\stackMath
\begin{document}
$\mathbf{e}_{\stackanchor[-.5pt]{\scriptscriptstyle \rightharpoonup}{\scriptstyle r}} \mathbf{e}_{\stackanchor[0pt]{\scriptscriptstyle \rightharpoonup}{\scriptstyle r}} ~ \mathbf{e}_{\stackon[-.5pt]{\scriptstyle r}{\scriptscriptstyle \rightharpoonup}} \mathbf{e}_{\stackon[0pt]{\scriptstyle r}{\scriptscriptstyle \rightharpoonup}} ~ \mathbf{e}_{\stackunder[-.5pt]{\scriptscriptstyle \rightharpoonup}{\scriptstyle r}} \mathbf{e}_{\stackunder[0pt]{\scriptscriptstyle \rightharpoonup}{\scriptstyle r}}$
\end{document}
`

-