I know it's possible to have \xrightarrow (text)
, but if I try to do \xRightarrow (text)
I get an error each time. Does anybody know if it's a syntax error or if there is a other way to produce the \Rightarrow
with text above?
3 Answers
Just taking the definition of \xrightarrow
and replacing r
by R
:
\documentclass{article}
\usepackage{amsmath}
\makeatletter
\newcommand{\xRightarrow}[2][]{\ext@arrow 0359\Rightarrowfill@{#1}{#2}}
\makeatother
\begin{document}
% To create a single arrow with text above, use lowercase "r".
$\xrightarrow{\mathit{hello}}$
% To create a double arrow with text above, use uppercase "R".
$\xRightarrow{\mathit{hello}}$
\end{document}
-
30oh, please at least make that
\mathit{hello}
to get rid of the obnoxious math kerning. Commented Dec 1, 2012 at 19:19 -
5
-
2how do you choose the single arrow when making the command? copy pasting your code (that has no explanation) yields the double arrow. Commented May 29, 2020 at 20:02
-
@CharlieParker I'm not sure I understand your question, my answer shows two arrows, the single one
\xrightarrow
is a standard command from amsmath just shown for comparison, and the double arrow version with capital R which is defined here. Commented May 29, 2020 at 20:41
\documentclass{article}
\usepackage{mathtools}
\begin{document}
$\xrightarrow{\text{hello}}$
$\xRightarrow{\text{hello}}$
\end{document}
-
16Why the difference in arrow lengths? The head of the double arrow is under "o" of hello, while "hello" is entirely above the shaft of the single arrow. Commented Sep 1, 2014 at 14:59
-
This has now been corrected in
mathtools
(and in the image above).– LorentsCommented Jul 4, 2023 at 10:52
You can also use underset and overset:
$\underset{\text{hello}} \longrightarrow$
$\overset{\text{hello}} \longrightarrow$
$\underset{\tiny\text{hello}} \longrightarrow$
$\overset{\tiny\text{hello}} \longrightarrow$
-
This solution does not create arrows that grow to accommodate what's over/under them.– NathanCommented Oct 25, 2023 at 11:46