5

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?

2 Answers 2

10

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}
5
  • Wow, thank you I'll accept the answer as soon as I can. How did you come up with this?
    – user113942
    Nov 26, 2016 at 15:50
  • In your previous posting, @egreg was basically right that your question has been answered before, in a different setting. He was not right in closing it as an "exact duplicate" because it requires a modification that cannot be expected from every user of LaTeX.
    – gernot
    Nov 26, 2016 at 15:57
  • Hmm, there's an evident asymmetry. You probably want 0099. The fix is straightforward nonetheless.
    – egreg
    Nov 26, 2016 at 16:06
  • @egreg Thanks for the fix. But there are still some numbers left that we could try.
    – gernot
    Nov 26, 2016 at 16:11
  • @egreg If "straightforward" is tongue-in-cheek, agreed. If it was meant as a serious remark, I'd have to object.
    – gernot
    Nov 26, 2016 at 16:41
2

Here is the version to be found in the excellent document Math Mode by Herbert Voß (with a modification of parameters), at § 38, Extensible Arrows, pp.78-79:

\usepackage{amsmath}
\makeatletter
\newcommand\xLongLeftRightArrow[2][]{%
  \ext@arrow 0099{\LongLeftRightArrowfill@}{#1}{#2}}
\def\LongLeftRightArrowfill@{%
  \arrowfill@\Leftarrow\Relbar\Rightarrow}
\makeatother

The 4 digit parameter denotes:

1st digit: space left

2nd digit: space right

3rd digit space left and right

4th digit; space relative to the arrow tips.

enter image description here

\documentclass{article}
\usepackage{amsmath}
\makeatletter
\newcommand\xLongLeftRightArrow[2][]%
  {\ext@arrow 0099{\LongLeftRightArrowfill@}{#1}{#2}}
\def\LongLeftRightArrowfill@
  {\arrowfill@\Leftarrow\Relbar\Rightarrow}
\makeatother
\begin{document}
$A \xLongLeftRightArrow[\text{very long sentence}]%
                       {\text{This is a very very}} B$
\end{document}
2
  • In what does this differ from the other answer, apart from overcomplicating the code?
    – egreg
    Nov 26, 2016 at 16:33
  • @egreg: I wanted to mention Herbert Voss' document, which gives detailed explanations on how to obtain extensible arrows of all sorts with some basic components.
    – Bernard
    Nov 26, 2016 at 16:39

You must log in to answer this question.