LaTeX mathematics hacks

September 8, 2014 — September 7, 2022

computers are awful
faster pussycat
plain text
Figure 1

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

1 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.

2 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

3 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

4 Arrays

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

5 Underbraces

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

6 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 underneath (Does not seem to display correctly on this blog so we will have to use our imaginations)


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