\documentclass{article}
\usepackage{amsmath}% http://ctan.org/pkg/amsmath
\DeclareRobustCommand{\eulerian}{\genfrac<>{0pt}{}}
\begin{document}
% Source: http://en.wikipedia.org/wiki/Eulerian_number
In combinatorics the Eulerian number $\eulerian{a}{b}$, is the number of permutations
of the numbers 1 to $n$ in which exactly $m$ elements are greater than the previous
element. The generalized Eulerian numbers are denoted by $\eulerian{a}{b}_m$.
\end{document}
我想减少右括号>
和索引之间的空间m
。
答案1
我认为下标最好作为的可选参数处理\eulerian
,因此语法
\eulerian[m]{a}{b}
似乎更可取。这也允许使用可选参数并按我们想要的方式进行设置。
第一个想法是添加\!
到下标。这是一个实现:
\documentclass{article}
\usepackage{amsmath}
\usepackage{xparse}
\NewDocumentCommand{\eulerian}{omm}
{%
\genfrac<>{0pt}{}{#2}{#3}%
\IfValueT{#1}{_{\!#1}}%
}
\begin{document}
% Source: http://en.wikipedia.org/wiki/Eulerian_number
In combinatorics the Eulerian number $\eulerian{a}{b}$, is the number of permutations
of the numbers 1 to $n$ in which exactly $m$ elements are greater than the previous
element. The generalized Eulerian numbers are denoted by $\eulerian[m]{a}{b}$
($\genfrac<>{0pt}{}{a}{b}_{m}$).
In display it would be
\[
\eulerian[m]{a}{b}\quad\genfrac<>{0pt}{}{a}{b}_{m}
\]
so we see whether the problem appears again. We see also what happens with
a standard Eulerian $\eulerian{a}{b}$ number and also in display
\[
\eulerian{a}{b}X
\]
where the $X$ is just to show spacing.
\end{document}
用 定义的命令\NewDocumentCommand
自动变得强大。在示例代码中,我还使用了您之前的定义(使用显式\genfrac
),以便更好地看到差异。
我们\IfValueT{#1}
检查可选参数是否已经表达,并且只有在这种情况下我们才会这样做_{\!#1}
,因此我们只在真正必要时才进行备份。
一个反对意见可能是在内联公式中备份量太大而在显示的公式中备份量太短。这只能通过使用 设置分隔符 来解决\mathchoice
。
\documentclass{article}
\usepackage{amsmath}
\usepackage{xparse}
\NewDocumentCommand{\eulerian}{omm}
{%
\IfNoValueTF{#1}
{\genfrac<>{0pt}{}{#2}{#3}}%
{\mathchoice{\genfrac<>{0pt}{}{#2}{#3}_{\!\!#1}}
{\genfrac<>{0pt}{}{#2}{#3}_{\mkern-2mu#1}}% \! is -3mu
{\genfrac<>{0pt}{}{#2}{#3}_{\mkern-2mu#1}}
{\genfrac<>{0pt}{}{#2}{#3}_{\mkern-2mu#1}}%
}
}
\begin{document}
% Source: http://en.wikipedia.org/wiki/Eulerian_number
In combinatorics the Eulerian number $\eulerian{a}{b}$, is the number of permutations
of the numbers 1 to $n$ in which exactly $m$ elements are greater than the previous
element. The generalized Eulerian numbers are denoted by $\eulerian[m]{a}{b}$
($\genfrac<>{0pt}{}{a}{b}_{m}$).
In display it would be
\[
\eulerian[m]{a}{b}\quad\genfrac<>{0pt}{}{a}{b}_{m}
\]
so we see whether the problem appears again. We see also what happens with
a standard Eulerian $\eulerian{a}{b}$ number and also in display
\[
\eulerian{a}{b}X
\]
where the $X$ is just to show spacing.
\end{document}
答案2
您可以定义另一个命令\ueulerian
\DeclareRobustCommand{\ueulerian}[3]{\eulerian{#2}{#3}_{\!#1}}
适用于有下标的情况。如果没有下标,请使用常规\eulerian
命令。
\documentclass{article}
\usepackage{amsmath}% http://ctan.org/pkg/amsmath
\DeclareRobustCommand{\eulerian}{\genfrac<>{0pt}{}}
\DeclareRobustCommand{\ueulerian}[3]{\eulerian{#1}{#2}_{\!#3}}
\begin{document}
% Source: http://en.wikipedia.org/wiki/Eulerian_number
In combinatorics the Eulerian number $\eulerian{a}{b}$, is the number of permutations
of the numbers 1 to $n$ in which exactly $m$ elements are greater than the previous
element. The generalized Eulerian numbers are denoted by $\ueulerian{a}{b}{m}$.
\end{document}
这两个命令可以合并成一个,例如
\DeclareRobustCommand{\ueulerian}[3][]{\eulerian{#2}{#3}_{\!#1}}
但即使没有下标,负空间也会悄悄出现。
\documentclass{article}
\usepackage{amsmath}% http://ctan.org/pkg/amsmath
\DeclareRobustCommand{\eulerian}{\genfrac<>{0pt}{}}
\DeclareRobustCommand{\ueulerian}[3][]{\eulerian{#2}{#3}_{\!#1}}
\begin{document}
% Source: http://en.wikipedia.org/wiki/Eulerian_number
In combinatorics the Eulerian number $\ueulerian{a}{b}$, is the number of permutations
of the numbers 1 to $n$ in which exactly $m$ elements are greater than the previous
element. The generalized Eulerian numbers are denoted by $\ueulerian[m]{a}{b}$.
\end{document}
参见之前的间距,
。选择权在你手中。
答案3
可以用来\!
生成负薄空间,例如:
\eulerian{a}{b}_{\!m}
将会使右分隔符和字母“m”之间的空间更小。