# Reduce space between 'genfrac' and indices

\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}


I would like to reduce the space between the right bracket > and the index m.

I think that the subscript is better treated as an optional argument to \eulerian, so the syntax

\eulerian[m]{a}{b}


seems preferable. This allows also to play with the optional argument and set it the way we want.

A first idea is to add \! to the subscript. Here's an implementation:

\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}


Commands defined with \NewDocumentCommand are automatically robust. In the example code I used also your previous definition (with explicit \genfrac) in order to better see the differences.

With \IfValueT{#1} we check whether the optional argument has been expressed and only in this case we do _{\!#1}, so we back up only when really necessary.

An objection might be that in the inline formula the amount of backing up is too large and in the displayed one it's too short. This can be solved only by setting the delimiter with \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}


You can define another command \ueulerian

\DeclareRobustCommand{\ueulerian}[3]{\eulerian{#2}{#3}_{\!#1}}


for use when you have a subscript. For no subscript, use the regular \eulerian command.

\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}


These two commands can be put into one like

\DeclareRobustCommand{\ueulerian}[3][]{\eulerian{#2}{#3}_{\!#1}}


but the negative space will creep in even if you don't have a subscript.

\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}


See the spacing before ,. The choice is yours.

One can use \! to generate a negative thin space, for example:

\eulerian{a}{b}_{\!m}


will give you less space between the right delimiter and the letter "m".

• Can you pack this also in a command \DeclareRobustCommand{\geneulerian}{...}? – Sophia Antipolis Sep 30 '13 at 9:31
• @SophiaAntipolis: there is no easy way I can think of, I guess one can make the subscript a third, optional, argument in the form _{\!#3}. – Francis Sep 30 '13 at 10:05