# Strange behaviour of binomial coefficient's delimiters

This question led to a new package:
fixcmex

While writing down my Combinatorics exercises I found that the binomial coefficient's delimiters weren't displayed as indicated inside the amsmath documentation.

By subsequent trials and errors I was able to reduce the volume of my document to this simpler and fully compilable MWE:

\documentclass[11pt]{article}
%
\usepackage{amsmath}
%
\makeatletter
%
\usepackage{lmodern}
\usepackage{lipsum}
%
\makeatother
%
\begin{document}
%
\lipsum[1]
$$2^k-\binom{k}{1}2^{k-1}+\binom{k}{2}2^{k-2}$$
\lipsum[1]
%
\end{document}


Which gives (using TeXworks 0.44 on MikTeX 2.9.4521 updated 09/10/13) this un-expected result:

While the amsmath doc shows that with the loaded packages inside the MWE the result would actually be like this:

From here we can see that the delimiters on the first example are a little bit stretched vertically as they surpass the arguments inside the binom. coeff.

The more strange event is that when I comment the line \usepackage{lmodern} the result on delimiter's shape in my example looks exactly as the amsmath doc:

\documentclass[11pt]{article}
%
\usepackage{amsmath}
%
\makeatletter
%
%\usepackage{lmodern}
\usepackage{lipsum}
%
\makeatother
%
\begin{document}
%
\lipsum[1]
$$2^k-\binom{k}{1}2^{k-1}+\binom{k}{2}2^{k-2}$$
\lipsum[1]
%
\end{document}


Output:

From here I deduce that the problem lies inside lmodern, but I'd like to keep using this package and fix this wierd "issue" with the math mode. Is there some clue that I've missed or this is in fact an update-process bug infecting amsmath's delimiter control?

• Just a note: you don't need \makeatletter \makeatother in this MWE. – marczellm Oct 9 '13 at 16:18
• @marczellm Yes, it works fluently both with and without those commands, as there is no @ in between that needs to be activated... – TheVal Oct 9 '13 at 16:23

This is a problem in how lmodern sets up the math extensions font, by saying

\DeclareFontShape{OMX}{lmex}{m}{n}{%
<->sfixed*lmex10%
}{}


which is utterly wrong, in my opinion, because it destroys the settings made by amsmath which would solve the problem. The fonts, unfortunately, do not provide for optical sizes different from 10pt, so you have a few strategies

## 1. Use the fixcmex package

\documentclass[11pt]{article}

\usepackage{amsmath}
\usepackage{lmodern}
\usepackage{fixcmex}

\usepackage{lipsum}

\begin{document}

\lipsum[1]
$$2^k-\binom{k}{1}2^{k-1}+\binom{k}{2}2^{k-2}$$
\lipsum[1]

\end{document}


Disclaimer. I authored the fixcmex package as a solution to the present problem.

## 2. Let amsmath do the main work

\documentclass[11pt]{article}

\usepackage{amsmath}
\usepackage{lmodern}

\DeclareSymbolFont{largesymbols}{OMX}{cmex}{m}{n} % use cmex rather than lmex

\usepackage{lipsum}

\begin{document}

\lipsum[1]
$$2^k-\binom{k}{1}2^{k-1}+\binom{k}{2}2^{k-2}$$
\lipsum[1]

\end{document}


## 3. Load exscale or, better, the fonts defined by it

\documentclass[11pt]{article}

\usepackage{amsmath}
\usepackage{lmodern}

\DeclareFontShape{OMX}{cmex}{m}{n}{%
<-7.5> cmex7
<7.5-8.5> cmex8
<8.5-9.5> cmex9
<9.5-> cmex10
}{}
\DeclareSymbolFont{largesymbols}{OMX}{cmex}{m}{n} % use cmex rather than lmex

\usepackage{lipsum}

\begin{document}

\lipsum[1]
$$2^k-\binom{k}{1}2^{k-1}+\binom{k}{2}2^{k-2}$$
\lipsum[1]

\end{document}


## 4. Make lmex10 scalable

\documentclass[11pt]{article}

\usepackage{amsmath}
\usepackage{lmodern}
\DeclareFontFamily{OMX}{lmex}{}
\DeclareFontShape{OMX}{lmex}{m}{n}{%
<-> lmex10
}{}

\usepackage{lipsum}

\begin{document}

\lipsum[1]
$$2^k-\binom{k}{1}2^{k-1}+\binom{k}{2}2^{k-2}$$
\lipsum[1]

\end{document}


With all strategies the computation for the delimiter's sizes gives a better result. Strategies two and three are rather similar; the difference is that the latter scales all fonts even at non standard sizes, while the former only uses fixed sizes 7, 8, 9, 10, 11 (10.95), 12, 14 (14.4) and 17 (17.28). Strategy one is equivalent to strategy three (and easier to load).

• I honestly didn't come up with this strange issue in one and a half years of intense LaTeXing, but is it possible to a simple user like me to point this out to a mantainer? – TheVal Oct 9 '13 at 15:14
• @AndreaL. Probably you never used 11pt as base font size. Omit the fix and try $A_{\sum}$ first without lmodern and then with it (load amsmath in both experiments). You'll have a surprise. – egreg Oct 9 '13 at 15:43
• Thanks, I personally think that the second method shown in the answer is the most appropriate to my purposes. I'll think on the usage of stackengine (as given by @StevenB.Segletes) in addendum. – TheVal Oct 9 '13 at 15:45
• @campa Thanks, I fixed it. – egreg Dec 9 '19 at 10:54

This answer relies on redefining \binom to use features of the scalerel and stackengine packages. The \scaleleftright macro will make the paren delimiters exactly match the height of the binomial contents, which are stacked using \stackanchor.

The vertical gap between the components of the binomial coefficient is an optional argument to \stackanchor (currently set at 1.8ex), and the horizontal limiting width of the parens of the coefficient are given as an optional argument to \scaleleftright (currently set to 1.5ex).

\documentclass[11pt]{article}
%
\usepackage{amsmath}
\usepackage{scalerel}
\usepackage{stackengine}
%
\makeatletter
%
\usepackage{lmodern}
\usepackage{lipsum}
%
\makeatother
%
\begin{document}
%
\lipsum[1]
$$2^k-\binom{k}{1}2^{k-1}+\binom{k}{2}2^{k-2}$$
\renewcommand\binom[2]{\stackMath\mathop{%
\scaleleftright[1.5ex]{(}{\stackanchor[1.8ex]{#1}{#2}}{)}}}
$$2^k-\binom{k}{1}2^{k-1}+\binom{k}{2}2^{k-2}$$
\lipsum[1]

%
\end{document}


The top image is the original that you posted, while the lower one is the fix proposed here.

• Even though egreg made an answer that matched the delimiter size exactly with amsmath doc, I kind of like the vertical shrinking, just aligned at the base of the argument. Now I have two possibilities, which is great. – TheVal Oct 9 '13 at 15:50
• @AndreaL. Thanks. The current MWE uses a "short" stack for the coefficient parts, wherein the gap is specified, and the stack is centered at the middle of the gap. You may prefer a "long" stack wherein the inter-baseline distance is specified and the stack is centered halfway between the baselines. To do that, \renewcommand\binom[2]{\stackMath\def\stacktype{L}\mathop{% \scaleleftright[1.5ex]{(}{\stackanchor[1.1\baselineskip]{#1}{#2}}{)}}} . You'll see differences for short letters in the upper slot and/or descending letters in the lower slot. – Steven B. Segletes Oct 9 '13 at 16:02
• @AndreaL. As a follow up to prior comment, I should add that if differing heights/depths of indices over several terms within a single equation cause an odd look, a partial strut can be added in \binom before #1 and #2 in order to normalize the heights. – Steven B. Segletes Oct 9 '13 at 16:15
• Well, thanks for the delucidation, the more tools and methods the more a knowledge is spread. – TheVal Oct 9 '13 at 16:21
• @StevenB.Segletes I am very happy with your answer, But, it does not sutiable with \usepackage{fouriernc}. Can you help me with when I add the command \usepackage{fouriernc}? – minthao_2011 Dec 8 '15 at 3:49

I add a similar problem as you recently, while using 11pt font size with the lmodern (Latin Modern font) package. It never occured before (apparently) when I was using 10pt and 12pt font size.

A solution is to add a nomath option to the lmodern package, which will then use the Latin Modern for all the text, but will revert to AMS Computer Modern for the maths. From OP's code:

\documentclass[11pt]{article}
%
\usepackage{amsmath}
%
\makeatletter
%
\usepackage[nomath]{lmodern}
\usepackage{lipsum}
%
\makeatother
%
\begin{document}
%
\lipsum[1]
$$2^k-\binom{k}{1}2^{k-1}+\binom{k}{2}2^{k-2}$$
\lipsum[1]
%
\end{document}


This is the solution I use since a few days ago, until I find a better solution. I don't see any major differences for the equations.