
Conozco \xrightarrow
otras opciones que usan amsmath
, pero en lugar de tener el texto sobre la flecha, estoy buscando algo como esto:
expression --text--> another expression
¿Se puede lograr esto usando amsmath (o alguna otra biblioteca)?
Si no es así, ¿cómo puedo definir esto yo mismo?
Respuesta1
Usaría un tipo más pequeño centrado verticalmente con respecto al eje matemático:
\documentclass{article}
\usepackage{amsmath}
\newcommand{\crightarrow}[1]{%
\relbar\joinrel\joinrel\relbar\mathrel{\vcentertext{#1}}\rightarrow
}
\newcommand{\vcentertext}[1]{%
\vcenter{\hbox{\scriptsize\smallstrut#1}}%
}
\newcommand{\smallstrut}{\vrule height 1.5ex depth 0.5ex width 0pt }
\begin{document}
$a_n \crightarrow{goes to} a$
$a_n \crightarrow{oes} a$
$a_n \crightarrow{bbb} a$
$a_n \crightarrow{ppp} a$
\end{document}
Respuesta2
Respuesta3
\usepackage{tikz}
\usetikzlibrary{arrows.meta}
\newlength\tmplength
\newcommand*\textarrow[2][3em]
{\mathrel{\vcenter{\hbox{\settowidth\tmplength{\scriptsize#2}%
\tikz[font=\scriptsize]
\draw[->](0,0)--node[fill=white,midway]{#2}
++({#1+\the\tmplength},0);}}}}
y puedes usar
$a \textarrow{foo} b$
$a \textarrow[5em]{bar} b$
$a \textarrow[10em]{baz} b$