0

I've come across how to write over a left or right facing arrow but not one that's double-ended. I tried this below (but with \ in front of both [ and ] but for some reason this won't typeset here) but it doesn't work so any help would be greatly appreciated!

\[ a \xleftrightarrow{\text{x}} b \]

Many thanks!

Janitt
  • 5

1 Answers1

3

You mean something like this:

\documentclass{article}
\usepackage{amssymb}
\usepackage{stackengine}
%https://tex.stackexchange.com/questions/123219/writing-above-and-below-a-symbol-simultaneously
\newcommand\stackleftrightarrow[1]{%
    \mathrel{{\stackon[4pt]{$\leftrightarrow$}{$\scriptscriptstyle#1$}}}}
\begin{document}
    $   a \stackleftrightarrow{x} b$
\end{document}

to get:

enter image description here

A more generalised approach would be to:

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



\newcommand{\xrightarrowdbl}[2][]{%
    \leftarrow\mathrel{\mkern-14mu}\xrightarrow[#1]{#2}
}
%https://tex.stackexchange.com/questions/260554/two-headed-version-of-xrightarrow
\begin{document}
    $x \xrightarrowdbl{\text{a}} y$\\
    $x \xrightarrowdbl{\text{your text}} y$
\end{document}

to get:

enter image description here