8

I'm a LaTeX newbie. I am writing a document in which I need to have a two-headed bidirectional arrow. Two-headed like \twoheadleftarrow, bidirectional like \leftrightarrow.

Is there any package that offers something like this? If not, how do I "roll my own"?

Thank you a lot!

0
8

\twoheadleftarrow and \twoheadrightarrow can be combined to \twoheadleftrightarrow:

\documentclass{article}
\usepackage{amssymb}

\newcommand*{\twoheadleftrightarrow}{%
  \twoheadleftarrow
  \mathrel{\mkern-15mu}%
  \twoheadrightarrow
}

\begin{document}
\[
  \twoheadleftrightarrow
  \scriptstyle \twoheadleftrightarrow
  \scriptscriptstyle \twoheadleftrightarrow
\]
\end{document}

Result

The symbols can also be combined using \joinrel, which is some negative space that should counteract the side bearings. However, I could see a small gap in \scriptscriptstyle with class option 10pt, thus I have removed another -0.5mu. And the new \longtwoheadleftrightarrow has an optional argument, which allows further adjustment if necessary.

\documentclass{article}
\usepackage{amssymb}

\newcommand*{\longtwoheadleftrightarrow}[1][.5]{%
  \twoheadleftarrow
  \joinrel
  \mathrel{\mkern-#1mu}%
  \twoheadrightarrow
}

\begin{document}
\[
  \longtwoheadleftrightarrow
  \scriptstyle \longtwoheadleftrightarrow
  \scriptscriptstyle \longtwoheadleftrightarrow
\]
\end{document}

Result \longtwoheadleftrightarrow

An even longer version can be composed with \relbar in the middle.

Also an expandable version can be constructed similar to \xrightarrow:

\documentclass{article}
\usepackage{amsmath,amssymb}

\makeatletter
\newcommand*{\xtwoheadleftrightarrow}[2][]{%
  \ext@arrow 99{10}{10}\twoheadleftrightarrowfill@{#1}{#2}%
}
\newcommand*{\twoheadleftrightarrowfill@}{%
  \arrowfill@\twoheadleftarrow\relbar\twoheadrightarrow
}
\makeatother

\begin{document}
\[
  \xtwoheadleftrightarrow[\text{under}]{\text{over}}
\]
\end{document}

Result \xtwoheadleftrightarrow

6
  • While we are at it - how would one go making them longer? I guess one would do the same kind of "composition" adding a dash-like symbol in the middle. – Tobia Tesan Jul 22 '14 at 17:42
  • 2
    @tobiatesan Look into Herbert Voß's “Math Mode” (texdoc mathmode); in section 38 it is explained how to define \xleftrightarrow and it should suffice to adapt the definition in order to use the double head arrows. – egreg Jul 22 '14 at 18:02
  • 1
    The strange behavior of \joinrel is also visible when you try \longrightarrow in scriptscript style: see i.stack.imgur.com/wgVZb.png – egreg Jul 22 '14 at 20:31
  • @egreg: \joinrel assumes that 1.5mu is equal or larger than the symbol's side bearing, but the amount of the side bearings depend on the font and might not follow and scale with a specific mu value. – Heiko Oberdiek Jul 22 '14 at 22:03
  • @HeikoOberdiek I know; I was just surprised that this happened with CM fonts, when I discovered it some time ago. I guess that Knuth has never used \longrightarrow in scriptscript style, which I'm not really surprised of. ;-) – egreg Jul 22 '14 at 22: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.