2

I would like to have text (maybe a bullet, maybe something else) above a left-right arrow, I would also like that text to be centred. I would also like the arrow to grow with the text.

MWE:

\documentclass{article}
\usepackage{mathtools}

\begin{document}
$a \xleftrightarrow{x} b$

\end{document}

I tried this answer but it produces results similar to the above.

1 Answers1

2

The definition of \xleftrightarrow is wrong.

\documentclass{article}
\usepackage{mathtools}

\MHInternalSyntaxOn\makeatletter
\renewcommand{\xleftrightarrow}[2][]{\ext@arrow 5599\MT_leftrightarrow_fill: {#1}{#2}}
\makeatother\MHInternalSyntaxOff

\newcommand{\bb}[1]{\mathpalette\bbx{#1}}
\newcommand{\bbx}[2]{{\fboxsep=-0.05pt\fboxrule=0.1pt\fbox{$#1#2$}}}

\begin{document}

$a \xleftrightarrow{\bb{x}} b$

\end{document}

The macro \bb is just used for showing the bounding box of the label, you don't need it.

enter image description here

egreg
  • 1,121,712