我正在编写一些与 LaTeX 渲染器交互的软件。
我需要编写化学反应和平衡,但我无权访问xrightleftharpoons
,有没有办法可以在不加载包的情况下内联呈现同样的东西?
我确实可以访问一些包裹的东西:amssymb
,,,,,,,。amsmath
bm
color
[latin1]inputenc
flexisym
breqn
答案1
这里我直接从chemarr
包,它定义了\xrightleftharpoons
您想要的宏。这样,您只需加载amsmath
。
\documentclass{article}
\usepackage{amsmath}
\makeatletter
\newcommand*{\rightharpoonupfill@}{%
\arrowfill@\relbar\relbar\rightharpoonup
}
\newcommand*{\leftharpoondownfill@}{%
\arrowfill@\leftharpoondown\relbar\relbar
}
\newcommand{\xrightleftharpoons}[2][]{%
\ensuremath{%
\mathrel{%
\settoheight{\dimen@}{\raise 2pt\hbox{$\rightharpoonup$}}%
\setlength{\dimen@}{-\dimen@}%
\edef\CA@temp{\the\dimen@}%
\settoheight\dimen@{$\rightleftharpoons$}%
\addtolength{\dimen@}{\CA@temp}%
\raisebox{\dimen@}{%
\rlap{%
\raisebox{2pt}{%
$%
\ext@arrow 0359\rightharpoonupfill@{\hphantom{#1}}{#2}%
$%
}%
}%
\hbox{%
$%
\ext@arrow 3095\leftharpoondownfill@{#1}{\hphantom{#2}}%
$%
}%
}%
}%
}%
}
\makeatother
\begin{document}
\[
A \xrightleftharpoons[\mathit{below}]{\mathit{above}} B
\]
\end{document}
答案2
以下示例使用了\xrightleftharpoons
来自包的实现mathtools
。它使用了来自包 的宏。该示例还提供了后者的宏,因此不需要amsmath
加载。amsmath
\documentclass{article}
%\usepackage{amsmath}% optional
% Implemenation for \xrightleftharpoons taken from package `mathtools'
\makeatletter
\newcommand*\xrightleftharpoons[2][]{%
\mathrel{%
\raise.22ex\hbox{%
$\m@th\ext@arrow 0359\MT@rightharpoonup@fill{\phantom{#1}}{#2}$%
}%
\setbox0=\hbox{%
$\m@th\ext@arrow 3095\MT@leftharpoondown@fill{#1}{\phantom{#2}}$%
}%
\kern-\wd0 \lower.22ex\box0 %
}%
}
\def\MT@rightharpoonup@fill{%
\arrowfill@\relbar\relbar\rightharpoonup
}
\def\MT@leftharpoondown@fill{%
\arrowfill@\leftharpoondown\relbar\relbar
}
% The following definitions are taken from package `amsmath'.
\@ifpackageloaded{amsmath}{}{%
\providecommand*{\arrowfill@}[4]{%
$\m@th\thickmuskip0mu\medmuskip\thickmuskip\thinmuskip\thickmuskip
\relax#4#1\mkern-7mu%
\cleaders\hbox{$#4\mkern-2mu#2\mkern-2mu$}\hfill
\mkern-7mu#3$%
}
\providecommand*{\ext@arrow}[7]{%
\mathrel{\mathop{%
\setbox\z@\hbox{#5\displaystyle}%
\setbox\tw@\vbox{\m@th
\hbox{$\scriptstyle\mkern#3mu{#6}\mkern#4mu$}%
\hbox{$\scriptstyle\mkern#3mu{#7}\mkern#4mu$}%
\copy\z@
}%
\hbox to\wd\tw@{\unhbox\z@}}%
\limits
\@ifnotempty{#7}{^{\if0#1\else\mkern#1mu\fi
#7\if0#2\else\mkern#2mu\fi}}%
\@ifnotempty{#6}{_{\if0#1\else\mkern#1mu\fi
#6\if0#2\else\mkern#2mu\fi}}}%
}
\providecommand{\@ifnotempty}[1]{%
\@ifempty{#1}{}%
}
\providecommand{\@ifempty}[1]{\@xifempty#1@@..\@nil}
\@ifundefined{@xifempty}{%
\long\def\@xifempty#1#2@#3#4#5\@nil{%
\ifx#3#4\expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi
}
}{}
}
\makeatother
\begin{document}
\[ a \xrightleftharpoons[below]{above} b \]
\end{document}