I'm familiar with \leftharpoonup
and \rightharpoonup
. These complement \leftarrow
and \rightarrow
. There is also \leftrightarrow
, but strangely, no \leftrightharpoonup
.
I implemented a very ugly hack that works well, but I'm interested in better approaches. Criticisms of my current approach: 1) seems "improper" due to hacks 2) the symbol appears too thick in the middle. In the picture, you can see, ever so slightly, that it is too thick is clearly a pasting of two symbols.
Code:
\documentclass{article}
\usepackage{mathtools}
\pagestyle{empty}
% Usage: \phantomword[c]{hiddenmath}{shownmath}
%
% The hidden text defines the box size.
% The shown text is placed inside the box.
% The optional argument is the alignment: l,c,r
\MHInternalSyntaxOn
% Using mathpalette requires more shuffling of arguments
\providecommand*\phantomword[3][c]{%
\mathchoice
{\MT_phantom_word:NNnn #1\displaystyle {#2}{#3}}%
{\MT_phantom_word:NNnn #1\textstyle {#2}{#3}}%
{\MT_phantom_word:NNnn #1\scriptstyle {#2}{#3}}%
{\MT_phantom_word:NNnn #1\scriptscriptstyle {#2}{#3}}%
}
\def\MT_phantom_word:NNnn #1#2#3#4{%
\@begin@tempboxa\hbox{$\m@th#2#4$}%
% can't use \settowidth as that also uses \@tempboxa...
\setlength\@tempdima{\widthof{$\m@th#2#3$}}%
\hbox{\hb@xt@\@tempdima{\csname bm@#1\endcsname}}%
\@end@tempboxa}
\MHInternalSyntaxOff
\newcommand{\leftrightharpoonup}{%
\mathrlap{\leftharpoonup}%
\phantomword[l]{\,\leftharpoonup}{\,\rightharpoonup}%
}
\begin{document}
$$
\begin{matrix}
\leftharpoonup & \leftrightharpoonup & \rightharpoonup \\
\leftarrow & \leftrightarrow & \rightarrow
\end{matrix}
$$
\end{document}
Best Answer
I'm not sure what those command do, but a much simpler solution is available: just leave the measuring to TeX.
If one wants to be very sure about
\mathsurround
not being zero, the code for\lrhup
should be