[Tex/LaTex] Custom-length arrows, text over and under


Expanding on this question I'd like to know if it's possible to modify this macro to allow for text under the arrow as well, as the \xrightarrow[below]{under}. I don't have any experience with macros but using the answer to the aforementioned question I tried this to no effect


What would be the right way to do this?

Best Answer

Here is a \xxrightarrow that has a first mandatory argument, the desired subscript to which the arrow should adapt (see the examples in the test document below).

  \sbox8{$\m@th\scriptstyle#1$}  % subscript
  \ifdim\wd8>\min@xx \min@xx=\wd8 \fi
  \sbox8{$\m@th\scriptstyle#2$} % superscript
  \ifdim\wd8>\min@xx \min@xx=\wd8 \fi





So you call it as


where <below> is optional.

Related Question