LaTeX mathematics hacks

Tips for LaTeX specific to mathematical typesetting. See also Chris Cheung’s list.

Spacing and line breaking

Weird in maths. The breqn package position paper explains many of the issues. NB: the solutions that actually work in the javascript-backed LaTeX maths are multline (nb only one i) and split environments, so in practice I use those to ensure cross-compatibility of copy-pasta.

Opt-in equation numbering: \numberthis

The latex macro \numberthis is satisfying. Thanks Russell Tsuchida for showing it to me. It allows me to number only needed lines in multi-line equations. The macro goes like this:


A minimal example in context:

a &=b \\
  &=c \numberthis \label{eqn}
Equation \eqref{eqn} shows that $a=c$.
d = e

Math size

I forget this all the time. Explained by overleaf, Math font size ordering is

\displaystyle       % Size for equations in display mode
\textstyle          % Size for equations in text mode
\scriptstyle        % Size for first sub/superscripts
\scriptscriptstyle  % Size for subsequent sub/superscripts


There is an array environment which is good for typesetting equations, but it is too verbose for typesetting arrays of other things like numbers.

Use amsmath matrix for that, e.g.

1 & 2 & 3\\
a & b & c


If we want a brace underneath part of an equation, amsmath provides underbrace.

\underbrace{u'-P(x)u^2-Q(x)u-R(x)}_{\text{=0, since~$u$ is a particular solution.}}

Defining new operators

Without Limits i.e. limits on the side, \({\mathop{\mathrm{arg\,max}}\nolimits}_{x\to\infty} x\). Plain style (works everywhere including old MathJax):


amsmath style (works in AMSMath environments):


If we want limits limits underneath (Does not seem to display correctly on this blog so we will have to use our imaginations)


\newcommand{\sech}{\mathop{\mathrm sech}\limits}

No comments yet. Why not leave one?

GitHub-flavored Markdown & a sane subset of HTML is supported.