6

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.

harpoons

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}
Tom
  • 1,123
  • this symbol is in unicode, U+294E, so it should be in the stix fonts, probably with the command name \leftrightharpoonupup (no, not a typo; there's also a \leftrightharpoonupdown at U+294A). but since the stix fonts aren't really visually compatible with computer modern, egreg's answer is undoubtedly preferable. – barbara beeton Oct 17 '14 at 20:20

2 Answers2

5

I'm not sure what those command do, but a much simpler solution is available: just leave the measuring to TeX.

\documentclass{article}
\usepackage{amsmath,amssymb}
\newcommand{\leftrightharpoonup}{%
  \mathrel{\mathpalette\lrhup\relax}%
}
\newcommand{\lrhup}[2]{%
  \ooalign{$#1\leftharpoonup$\cr$#1\rightharpoonup$\cr}%
}

\begin{document}
\[
\begin{matrix}
\leftharpoonup & \leftrightharpoonup & \rightharpoonup \\
\leftarrow     & \leftrightarrow     & \rightarrow
\end{matrix}
\]
\end{document}

enter image description here

If one wants to be very sure about \mathsurround not being zero, the code for \lrhup should be

\makeatletter
\newcommand{\lrhup}[2]{%
  \ooalign{$\m@th#1\leftharpoonup$\cr$\m@th#1\rightharpoonup$\cr}%
}
\makeatother
egreg
  • 1,121,712
  • Very neat. I read your tutorial on \ooalign (http://tex.stackexchange.com/questions/22371/subseteq-circ-as-a-single-symbol-open-subset) which was helpful. However, I'm not understanding why \lrhup takes 2 arguments and only uses one of them. Then, in the definition \leftrightharpoonup, it looks like you pass \relax as the first argument. Could you explain this? – Tom Oct 17 '14 at 22:09
  • @Tom \mathpalette wants two arguments, so it can be used with a “variable part”. In this case we don't have a variable part, but the second argument is still needed. – egreg Oct 17 '14 at 22:19
  • 1
    Sorry for being dense. I'm still confused. \mathpalette gets \lrhup and \relax, but this doesn't answer why \lrhup requires 2 arguments...one of which is not used. Or is the [2] a typo? – Tom Oct 17 '14 at 22:31
  • 1
0

As an answer to a slightly different question (closed), here is a \dblrightarrow, based on the \rightharpoonup from mathabx:

\documentclass{article}
\usepackage{mathtools}
\newcommand{\te}[1] {\overleftrightarrow{\mkern-1mu#1\mkern1mu}}

\DeclareFontFamily{U}{matha}{\hyphenchar\font45}
\DeclareFontShape{U}{matha}{m}{n}{ <-6> matha5 <6-7> matha6 <7-8>
matha7 <8-9> matha8 <9-10> matha9 <10-12> matha10 <12-> matha12 }{}
\DeclareSymbolFont{matha}{U}{matha}{m}{n}
%
\DeclareMathSymbol{\abxrightharpoonup}{\mathrel}{matha}{"E1}
\newcommand{\dblrightharpoon}{\mathrel{\mathrlap{\abxrightharpoonup}\mkern-1.7mu\abxrightharpoonup}}

\begin{document}

    \[ A \dblrightharpoon B \]

\end{document} 

enter image description here

Bernard
  • 271,350