我不知道如何让\overleftrightarrow
宏不给下面的内容添加垂直空间。我希望行与行之间的间距看起来好像箭头不存在并且与下面的文本相撞。
我见过下面的代码,它几乎完美,但它仍然会产生垂直空间。
\makeatletter
\newcommand{\overleftrightsmallarrow}{\mathpalette{\overarrowsmall@\leftrightarrowfill@}}
\newcommand{\overrightsmallarrow}{\mathpalette{\overarrowsmall@\rightarrowfill@}}
\newcommand{\overleftsmallarrow}{\mathpalette{\overarrowsmall@\leftarrowfill@}}
\newcommand{\overarrowsmall@}[3]{%
\vbox{%
\ialign{%
##\crcr
#1{\smaller@style{#2}}\crcr
\noalign{\nointerlineskip}%
$\m@th\hfil#2#3\hfil$\crcr
}%
}%
}
\def\smaller@style#1{%
\ifx#1\displaystyle\scriptstyle\else
\ifx#1\textstyle\scriptstyle\else
\scriptscriptstyle
\fi
\fi
}
\makeatother
或者,我尝试使用\overleftrightarrow
来表示一行。如果您建议使用其他语法来避免弄乱垂直空间,请告诉我。
答案1
这是一个可能的解决方案,其中的一些代码借用了我的halloweenmath
包中的代码:
% My standard header for TeX.SX answers:
\documentclass[a4paper]{article} % To avoid confusion, let us explicitly
% declare the paper format.
\usepackage[T1]{fontenc} % Not always necessary, but recommended.
% End of standard header. What follows pertains to the problem at hand.
\usepackage{amsmath}
\makeatletter
\newcommand*\@Davis@dblstyle@mathpalette[2]{%
% Works like "\mathpalette", but macro passed in #1 must take
% (at least) three arguments, of which the first _two_ are
% style selections.
\mathchoice
{#1\displaystyle \scriptstyle {#2}}%
{#1\textstyle \scriptstyle {#2}}%
{#1\scriptstyle \scriptscriptstyle {#2}}%
{#1\scriptscriptstyle \scriptscriptstyle {#2}}%
}
\newcommand*\@Davis@dblstyle@overarrow@[4]{%
% #1 := stretchable covering arrow
% #2 := base style
% #3 := style for covering arrow
% #4 := base symbol
\vbox{\ialign{##\crcr
#1#3\crcr
\noalign{\nointerlineskip}%
$\m@th\hfil #2#4\hfil$\crcr
}}%
}
\def\@Davis@arrowfill@#1#2#3#4{%
$\m@th\thickmuskip0mu\medmuskip\thickmuskip\thinmuskip\thickmuskip
\relax#4\mathsm@sh#4#1\mkern-7mu%
\cleaders\hbox{$#4\mkern-2mu#2\mkern-2mu$}\hfill
\mkern-7mu \mathsm@sh#4#3$%
}
\newcommand*\@Davis@leftarrowfill@{%
\@Davis@arrowfill@\leftarrow\relbar\relbar
}
\newcommand*\@Davis@rightarrowfill@{%
\@Davis@arrowfill@\relbar\relbar\rightarrow
}
\newcommand*\@Davis@leftrightarrowfill@{%
\@Davis@arrowfill@\leftarrow\relbar\rightarrow
}
\newcommand*\overDavisrightarrow{%
\@Davis@dblstyle@mathpalette
{\@Davis@dblstyle@overarrow@ \@Davis@rightarrowfill@}%
}
\newcommand*\overDavisleftarrow{%
\@Davis@dblstyle@mathpalette
{\@Davis@dblstyle@overarrow@ \@Davis@leftarrowfill@}%
}
\newcommand*\overDavisleftrightarrow{%
\@Davis@dblstyle@mathpalette
{\@Davis@dblstyle@overarrow@ \@Davis@leftrightarrowfill@}%
}
\makeatother
\begin{document}
A line of text, with some descenders: fgjpqy (and~Q).\\
A formula with ``overarrows'':
\( \overleftrightarrow{A+(B+C)} = \overleftrightarrow{(A+B)+C} \).
A line of text, with some descenders: fgjpqy (and~Q).\\
A formula with ``overarrows'':
\( \overDavisleftrightarrow{A+(B+C)} = \overDavisleftrightarrow{(A+B)+C} \).
\end{document}
预期输出:
也许,经过一番思考,就有可能找到一个更短的解决方案。