我目前正在尝试在波浪箭头 ( ) 上书写文本\rightsquigarrow
。对于普通箭头,我使用extarrows
包,它提供了类似和的命令\xlongrightarrow
,\xLongrightarrow
可根据文本长度动态拉伸箭头。但是,该包不提供波浪箭头的命令,我找不到另一个提供此类命令的包。
答案1
编辑提供 2 个修订解决方案,一个使用默认符号集,另一个使用从中导入的字形MnSymbol
(不是整个字形集)。
这给出了您可以如何做的要点。关键是找到一个周期性的符号。我使用了字符\sim
,但可能有更好的。此外,我使用了符号\!
来表示退格,但可能有更精确的方法(您会注意到,在我的示例中重叠并不完美)。
我创建了三个命令,分别用于曲线、曲线左端和曲线右端。只需重复调用即可\squig
使曲线更长。
或者可以使用\squigs
参数来获取所需的波浪线数量。下一步是创建允许文本越过波浪线的命令。
因此,您通常使用的实际命令是\rsquigarrow
和\lsquigarrow
,每个命令都有两个参数:波浪线顶部的文本和波浪线长度。
修订的解决方案(默认字形)
此修订解决方案始终使用数学模式并且与兼容amsmath
。
\documentclass[12pt]{article}
%%%%% REMOVE THESE FROM A GENERAL DOCUMENT
\parindent 0pt
\parskip 1ex
\textwidth 2in
%%%%%
\usepackage{amssymb,amsmath,stackengine}
\stackMath
\usepackage{ifthen}
\newcommand{\squig}{{\scriptstyle\sim\mkern-3.9mu}}
\newcommand{\lsquigend}{{\scriptstyle\lhd\mkern-3mu}}
\newcommand{\rsquigend}{{\scriptstyle\rule{.1ex}{0ex}\rhd}}
\newcounter{sqindex}
\newcommand\squigs[1]{%
\setcounter{sqindex}{0}%
\whiledo {\value{sqindex}< #1}{\addtocounter{sqindex}{1}\squig}%
}
\newcommand\rsquigarrow[2]{%
\mathbin{\stackon[2pt]{\squigs{#2}\rsquigend}{\scriptscriptstyle\text{#1\,}}}%
}
\newcommand\lsquigarrow[2]{%
\mathbin{\stackon[2pt]{\lsquigend\squigs{#2}}{\scriptscriptstyle\text{\,#1}}}%
}
\begin{document}
Here are the commands to make periodic squiggles, with no text above
them:
$2H_2 + O_2 \mathbin{\squig\squig\squig\rsquigend} 2H_2O $\\
$2H_2 + O_2 \mathbin{\lsquigend\squig\squig\squig} 2H_2O $
I can automate a group of squiggles
$\squigs{7}$
Now I will create commands to place text over them
$2H_2 + O_2 \rsquigarrow{exothermic}{7} 2H_2O $\\
$2H_2 + O_2 \lsquigarrow{heat}{3} ~ 2H_2O $
\end{document}
修订的解决方案(导入 3 个 MnSymbol 字形)
\documentclass[12pt]{article}
% =============================================
%Import symbols from font MnSymbol without importing the whole package
% =============================================
\DeclareFontFamily{U} {MnSymbolC}{}
\DeclareFontShape{U}{MnSymbolC}{m}{n}{
<-6> MnSymbolC5
<6-7> MnSymbolC6
<7-8> MnSymbolC7
<8-9> MnSymbolC8
<9-10> MnSymbolC9
<10-12> MnSymbolC10
<12-> MnSymbolC12}{}
\DeclareFontShape{U}{MnSymbolC}{b}{n}{
<-6> MnSymbolC-Bold5
<6-7> MnSymbolC-Bold6
<7-8> MnSymbolC-Bold7
<8-9> MnSymbolC-Bold8
<9-10> MnSymbolC-Bold9
<10-12> MnSymbolC-Bold10
<12-> MnSymbolC-Bold12}{}
\DeclareSymbolFont{MnSyC} {U} {MnSymbolC}{m}{n}
\DeclareMathSymbol{\MNrhd}{\mathbin}{MnSyC}{76}
\DeclareMathSymbol{\MNlhd}{\mathbin}{MnSyC}{78}
% =============================================
\DeclareFontFamily{U} {MnSymbolD}{}
\DeclareFontShape{U}{MnSymbolD}{m}{n}{
<-6> MnSymbolD5
<6-7> MnSymbolD6
<7-8> MnSymbolD7
<8-9> MnSymbolD8
<9-10> MnSymbolD9
<10-12> MnSymbolD10
<12-> MnSymbolD12}{}
\DeclareFontShape{U}{MnSymbolD}{b}{n}{
<-6> MnSymbolD-Bold5
<6-7> MnSymbolD-Bold6
<7-8> MnSymbolD-Bold7
<8-9> MnSymbolD-Bold8
<9-10> MnSymbolD-Bold9
<10-12> MnSymbolD-Bold10
<12-> MnSymbolD-Bold12}{}
\DeclareSymbolFont{MnSyD} {U} {MnSymbolD}{m}{n}
\DeclareMathSymbol{\MNsim}{\mathbin}{MnSyD}{2}
% =============================================
%%%%% REMOVE THESE FROM A GENERAL DOCUMENT
\parindent 0pt
\parskip 1ex
\textwidth 2in
%%%%%
\usepackage{amssymb,amsmath,stackengine}
\stackMath
\usepackage{ifthen}
\newcommand{\squig}{{\MNsim\mkern-3.6mu}}
\newcommand{\lsquigend}{{\MNlhd\mkern-4.3mu}}
\newcommand{\rsquigend}{{\mkern-1.2mu\MNrhd}}
\newcounter{sqindex}
\newcommand\squigs[1]{%
\setcounter{sqindex}{0}%
\whiledo {\value{sqindex}< #1}{\addtocounter{sqindex}{1}\squig}%
}
\newcommand\rsquigarrow[2]{%
\mathbin{\stackon[1pt]{\squigs{#2}\rsquigend}{\scriptscriptstyle\text{\!\!#1}}}%
}
\newcommand\lsquigarrow[2]{%
\mathbin{\stackon[1pt]{\lsquigend\squigs{#2}}{\scriptscriptstyle\text{#1\!\!}}}%
}
\begin{document}
Here are the commands to make periodic squiggles, with no text above
them:
$2H_2 + O_2 \mathbin{\squig\squig\squig\rsquigend} 2H_2O $\\
$2H_2 + O_2 \mathbin{\lsquigend\squig\squig\squig} 2H_2O $
I can automate a group of squiggles
$\squigs{7}$
Now I will create commands to place text over them
$2H_2 + O_2 \rsquigarrow{exothermic}{10} 2H_2O $\\
$2H_2 + O_2 \lsquigarrow{heat}{5} ~ 2H_2O $
\end{document}
长期原创解决方案
此解决方案并非最佳方案,因为它将文本和数学模式混为一谈。amsmath
据我了解,它还与 不兼容( 的内容\box0
被 所覆盖amsmath
)。
\documentclass[12pt]{article}
\parskip 1ex
\usepackage{amssymb}
\usepackage{ifthen}
\textwidth 2in
\begin{document}
Here are the commands to make periodic squiggles, with no text above
them:
\newcommand{\squig}{$\scriptsize$\sim$\normalsize$\!}
\newcommand{\lsquigend}{$\scriptsize$\lhd\!$\normalsize$}
\newcommand{\rsquigend}{$\scriptsize\rule{.1ex}{0ex}$\rhd$\normalsize$}
\noindent
$2H_2 + O_2 ~\squig\squig\squig\rsquigend~ 2H_2O $\\ $2H_2 + O_2 ~\lsquigend\squig\squig\squig~ 2H_2O $
Now I will create commands to place text over them
\newcounter{index}
\newcommand\squigs[1]{%
\setcounter{index}{0}%
\whiledo {\value{index}< #1}
{\addtocounter{index}{1}\squig}
}
\newcommand\rsquigarrow[2]{$
\setbox0\hbox{$\squigs{#2}\rsquigend$}%
\tiny$%
\!\!\!\!\begin{array}{c}%
\mathrm{#1}\\%
\usebox0%
\end{array}%
$\normalsize$\!\!%
}
\newcommand\lsquigarrow[2]{$
\setbox0\hbox{$\lsquigend\squigs{#2}$}%
\tiny$%
\!\!\!\!\begin{array}{c}%
\mathrm{#1}\\%
\usebox0%
\end{array}%
$\normalsize$\!\!%
}
\noindent
$2H_2 + O_2 \rsquigarrow{exothermic}{7} 2H_2O $\\ $2H_2 + O_2 \lsquigarrow{heat}{3} ~ 2H_2O $
\end{document}