
\xrightarrow
나는 을 사용하는 다른 옵션을 알고 있지만 amsmath
대신 화살표 위에 텍스트가 있는 경우 다음과 같은 것을 찾고 있습니다.
expression --text--> another expression
amsmath(또는 다른 라이브러리)를 사용하여 이를 달성할 수 있습니까?
그렇지 않다면 이것을 어떻게 스스로 정의할 수 있습니까?
답변1
수학 축을 기준으로 수직으로 가운데에 있는 더 작은 유형을 사용하겠습니다.
\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}
답변2
답변3
\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);}}}}
그리고 당신은 사용할 수 있습니다
$a \textarrow{foo} b$
$a \textarrow[5em]{bar} b$
$a \textarrow[10em]{baz} b$