TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What is the best way to write a Stirling number of the second kind? Isn't there any standard command in LaTeX? For example, a command \binom is for binomial coefficients.

In the wikipedia article on Stirling number of the second kind, they used \atop command. But people say \atop is not recommended.

share|improve this question
Even putting any technical reasons aside, \atop is a bad choice as it left-aligns the "numerator" and "denominator", rather than centring them. – David Richerby Mar 28 '14 at 16:33
up vote 13 down vote accepted

The following is taken from amsmath and uses \genfrac - a generic fraction function:

enter image description here

\usepackage{amsmath}% http://ctan.org/pkg/amsmath
% Source: http://en.wikipedia.org/wiki/Stirling_numbers_of_the_second_kind
In mathematics, particularly in combinatorics, a Stirling number of the second kind 
is the number of ways to partition a set of $n$~objects into $k$~non-empty subsets and 
is denoted by~$S(n,k)$ or~$\stirling{a}{b}$. Stirling numbers of the second kind occur 
in the field of mathematics called combinatorics and the study of partitions.

How does this work? \genfrac takes five arguments to create a structure (from the amsmath documentation; section 4.11.3 The \genfrac command, p 14):

The last two correspond to \frac’s numerator and denominator; the first two are optional delimiters [...]; the third is a line thickness override [0 implies an invisible rule]; and the fourth argument is a mathstyle override: integer values 0-3 select respectively \displaystyle, \textstyle, \scriptstyle, and \scriptscriptstyle. If the third argument is left empty, the line thickness defaults to ‘normal’.

So \genfrac\{\}{0pt}{} creates a fraction with an invisible horizontal rule (third argument is 0pt), left and right delimiter given by \{ and \}, respectively and no specific math style (an empty {} fourth argument). \stirling doesn't include a fifth and sixth argument for \genfrac (numerator and denominator), because this is implicitly supplied by the user as the two "arguments" to \stirling.

In a similar manner (perhaps for reference), amsmath defines


using \genfrac.

share|improve this answer

Here is a plain pdfTeX solution, just to illustrate what type of typesetting Knuth used for such numbers (he wrote a few papers on this topic)

% ========= Fonts
% ========== Heading macros
\magnification =\magstep 1
\overfullrule =0pt

\noindent 1. {\sc Stirling numbers} ---
Stirling cycle numbers ${ n\brack m}$ are defined  by
$$ \ln^m(1+z) = m! \sum_n (-1)^{n+m} { n\brack m} {z^n\over n!}
  \ .\leqno(1a) $$
The numbers $(-1)^{n+m}{n\brack m}$ are also called Stirling numbers of the first kind.
Stirling subset numbers ${n\brace m}$, also called Stirling numbers
of the second kind, are defined by
$$ \left( e^z-1\right)^m = m! \sum_n {n\brace m} {z^n\over n!}
  \ ,\leqno(1b) $$
and 2-associated Stirling subset numbers ${n\brace m}_{\ge 2}$ are
defined by 

$$ \left( e^z-1-z\right)^m = m!\sum_n {n\brace m}_{\!\ge 2} {z^n\over n!}
  \ .\leqno(1c) $$


enter image description here

You can have a look at more examples at Knuth Papers

share|improve this answer
Wow. I am tempted to learn plain typesetting. – hpesoj626 Dec 8 '12 at 6:37
@hpesoj626 Not really necessary. If you place the code between \begin{document}...\end{document} it will work with LaTeX as well; amsmath will complain about the \over though, if you using it. They can easily be converted to amsmath styles. – Yiannis Lazarides Dec 8 '12 at 7:38
Take a look specially at Knuth's P137 from the link above, it's called "Two notes on notation" and it's precisely about the Stirling numbers. – Mafra Dec 8 '12 at 14:29
@Mafra Thanks for the reference. – Yiannis Lazarides Dec 8 '12 at 17:44

There is a Bmatrix environment in amsmath.




enter image description here

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.