# LaTeX Commands to Write Math Easily

### This third post on academic typography presents a collection of LaTeX commands to easily write mathematical expressions while automatically respecting the rules of mathematical typography.

In a first post on academic typography, I shared a minimalist template to write academic presentations with LateX Beamer and discussed some guidelines to format academic presentations. In a second post on academic typography, I shared a minimalist template to write academic papers with LaTeX and provided some guidelines to format academic papers.

In this third and final post on academic typography, I share a collection of commands to easily write mathematical expressions with LaTeX while automatically respecting the rules of mathematical typography. The commands are also designed so the formulas in LaTeX resemble the formulas on paper—making it easier to read math directly in LaTeX.

### Using the commands

The commands are collected in a LaTeX style file that is freely available on GitHub.

To use the commands, simply add the LaTeX style file `math.sty`

to the folder with your LaTeX document, and insert `\usepackage{math}`

in the preamble of the LaTeX document. Existing math commands are not affected, so you can continue to use those too.

### Features of the commands

The commands are tailored to write math in economics and other social sciences, although they might also be helpful to write math in other fields. The commands introduce the following functionalities:

Easily insert brackets (parentheses, square, curly, and so on) that scale automatically

Easily list arguments of operators (expectation, probability, min, max, exponential, log, and so on), with surrounding brackets that scale automatically

Easily write derivatives and elasticities, both partial and total, in display and text

Easily type statistical commands (independent and identically distributed variables, almost sure convergence)

Easily type key blackboard letters (such as ℂ or ℕ)

Easily type uppercase calligraphic letters (such as ℒ, ℳ, or 𝒩)

Easily type Greek letters

Easily insert accents (tilde, underline, hat, and so on) that scale automatically

### A simple example: brackets

Brackets are everywhere in mathematical expressions, but inserting brackets that scale automatically with their content is never easy. Imagine that you would like to insert curly brackets around a fraction, such as

The full LaTeX code is

`\left\lbrace\frac{1-\zeta}{\kappa \epsilon}\right\rbrace^{\theta}.`

With the commands proposed here the code simplifies to

`\bc{\frac{1-\zeta}{\kappa \epsilon}}^{\theta}.`

The command `\bc{}`

produces curly brackets that scale automatically. The collection also contains commands for square brackets, `\bs{}`

, for parentheses, `\bp{}`

, and so on. The full set of commands is documented here.

### Another example: letters

It is clear in the code above that having to spell out all Greek letters in mathematical expressions is cumbersome. The spelled out letters also make it harder to read mathematical expressions and check their correctness.

To address this issues, the commands offer short versions of almost all Greek letters. With these short versions, the expression above is simply given by

`\bc{\frac{1-\z}{\k\e}}^{\t}.`

The commands also offer short versions of calligraphic letters, so ℒ and ℳ are given by `\Lc`

and `\Mc `

instead of `\mathcal{L} and \mathcal{M}`

, and so on. The commands also offer short versions of blackboard letters, so ℂ and ℕ are given by `\C`

and `\N `

instead of` \mathbb{C}`

and` \mathbb{N}.`

### Another example: derivatives

Derivatives are also ubiquitous in mathematical expressions, and they are also fairly clunky to write. Let’s say that you would like to write the following result, linking a total derivative to partial derivatives:

The full LaTeX code is

`\frac{dF}{dx} = \frac{\partial F}{\partial x} + \frac{\partial F}{\partial y} \cdot \frac{dy}{dx}.`

With the commands the code simplifies to

`\od{F}{x} = \pd{F}{x} + \pd{F}{y} \cdot \od{y}{x}.`

The command `\pd{F}{x} `

gives the partial derivative of F with respect to x, while the command `\od{F}{x} `

gives the ordinary derivative of F with respect to x.

The commands are even more convenient to write elasticities—which are used all the time in economics. Say you want to write

The full LaTeX code now becomes

`\frac{d\ln F}{d\ln x} = \frac{\partial\ln F}{\partial\ln x} + \frac{\partial\ln F}{\partial\ln y} \cdot \frac{d\ln y}{d\ln x}.`

But with the commands, the code boils down to

`\oe{F}{x} = \pe{F}{x} + \pe{F}{y} \cdot \oe{y}{x}.`

The command `\pe{F}{x} `

gives the partial elasticity of F with respect to x, while the command `\oe{F}{x} `

gives the ordinary elasticity of F with respect to x.

### A last example: expectation

Imagine that you would like to write the expectation of the square of a random variable X at time t:

The standard LaTeX code is

`\mathbb{E}_{t}{\left[X^2\right]}`

With the commands, the code simplifies to

`\E[t]{X^2}`

Similar commands are available to write probabilities and many other operators. Once again, the full set of commands is documented here.