[Tex/LaTex] Stretch \Leftrightarrow according to above text

arrowsequationstext;

Currently I'm using

\newcommand{\Leftrightarrowtext}[1]{\ensuremath{\stackrel{\text{#1}}{\Leftrightarrow}}}

to add text above an equivalence sign (like Def. 5.11, etc), but I would like the equivalence sign to stretch with the text. This is different than \xRightarrow, since I want equivalence and can't find an \xLeftrightarrow command.

How can I achieve this?

Best Answer

Use the command

\usepackage{amsmath}
\makeatletter
\newcommand{\xLeftrightarrow}[2][]{\ext@arrow 0099\Leftrightarrowfill@{#1}{#2}}
\makeatother

This is a variation of the answer to "\xRightarrow (text)".

The following output is obtained by the code below it.

enter image description here

\documentclass{article}
\usepackage{amsmath}
\makeatletter
\newcommand{\xLeftrightarrow}[2][]{\ext@arrow 0099\Leftrightarrowfill@{#1}{#2}}
\makeatother
\begin{document}
$A \xLeftrightarrow{\mathit{hello}} B$
\end{document}
Related Question