我想要一个左/右鱼叉箭头,箭头上方有文字。
这是我目前为止最好的,但我希望箭头的大小能够根据文本大小动态变化。
\documentclass[12pt]{article}
\usepackage{amsmath, amssymb}
\usepackage{stackrel}
\newcommand{\lrhup}[2]{\ooalign{$#1\leftharpoonup$\cr$#1\rightharpoondown$\cr}}
\newcommand{\hpn}{\mathrel{\mathpalette\lrhup\relax}}
\begin{document}
$\stackrel{ABC}{\hpn}$
\end{document}
编辑:我也对创建这种双面鱼叉感兴趣,但宽度固定,因此箭头上方的“ABC”和“A”会产生相同的箭头,就像上面的例子一样,但仍然稍宽一些。
答案1
以下是来自mathtools
可伸缩鱼叉:
\documentclass{article}
\usepackage{mathtools}
\newcommand{\xlrharpoonud}[1]{
\mathrlap{\xleftharpoonup{\phantom{#1}}}%
\xrightharpoondown{#1}
}
\newcommand{\xlrharpoondu}[1]{
\mathrlap{\xleftharpoondown{\phantom{#1}}}%
\xrightharpoonup{#1}
}
\begin{document}
$\xlrharpoonud{abc}\ \xlrharpoondu{abc}\
\xlrharpoonud{\text{something}}\ \xlrharpoondu{\text{something else}}$
\end{document}
答案2
以下是我之前的回答的改编:
\documentclass{article}
\usepackage{amsmath}
\makeatletter
% adapted from https://tex.stackexchange.com/a/96555/4427
\newcommand\hpn[2][]{%
\ext@arrow 9999{\hpnfill@}{#1}{#2}}
\newcommand\hpnfill@{%
\arrowfill@\leftharpoonup\relbar\rightharpoondown}
\makeatother
\begin{document}
\begin{gather*}
F \hpn{A} G
\\
F \hpn{ABC} G
\\
F \hpn{\text{overlong text}} G
\\
F \hpn[q]{p} G
\\
F \hpn[q]{\text{overlong text}} G
\end{gather*}
\end{document}
答案3
这是一个解决方案,改编自mathmode
§38,可扩展箭头,第 78-79 页中的代码:
\documentclass{scrartcl}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\makeatletter%
\newcommand\xluprdownharpoon[2][]{%
\ext@arrow 0099{\luprdownharpoonfill@}{#1}{#2}}
\def\luprdownharpoonfill@{%
\arrowfill@\leftharpoonup\relbar\rightharpoondown}
\makeatother
\begin{document}
\[ \xluprdownharpoon[abcdef]{ABCD} \]%
\end{document}