Skip to Main Content

LaTeX for Publications: Basic Math Notation and Equations

Mathematics and LaTeX: Like Peanut Butter & Chocolate!

Mathematical expressions is one of the main reasons that LaTeX is popular in the sciences. Those who've used—or tried to use—Microsoft Word for math-heavy documents will really appreciate what LaTeX can do! LaTeX makes creating simple mathematical expressions easy and simple. Even large, complex expressions are not very difficult to create, and they all look great!

There are two kinds of mathematical expressions in LaTeX: 

  1. Inline math expressions - These are mathematical expressions that appear within the text of the document and do not interrupt the flow of text, such as the equation a + b = c, within this sentence.
  2. Displayed math expressions - These mathematical expressions display separately from the text of the document—a mathematical expression that displays like a paragraph.

Some very good information about inserting math expressions in LaTeX can be found in the following online documents:

  • Getting to Grips with LaTeX
    By Andrew Roberts. This guide is useful for answering some basic questions as you create your first LaTeX documents. The two Mathematics sections are very clear and helpful.
  • A (Not So) Short Introducation to LaTeX2ε
    English translation of a German document, introducing the reader to the latest version—version 2ε—of LaTeX. This intro is widely recommended within the LaTeX community. (PDF). Chapter 3: "Typesetting Mathematical Formulae" is a very straghtforward approach to including advanced math expressions in a LaTeX document.
  • LaTeX (Wikibooks)
    Good introduction to LaTeX. Can be downloaded as a PDF.

Are Packages Needed for Math in LaTeX?

If you have only a few mathematical statements or formulas in a document, LaTeX already has built-in features that will probably provide everything you need. Don't worry about math packages, unless things don't display properly.

On the other hand, if you are writing a scientific article or document with complex equations or other mathematical statements, use either the amsmath or the mathtools package. Of the two, mathtools reportedly fixes a few minor "quirks" of the amsmath package, but this author has used the amsmath package extensively with zero trouble.

The amsmath package is produced by the American Mathematical Society. It is part of the larger bundle, which is a collection of packages.

You can enable the more advanced math capability in LaTeX with one of the following commands in the preamble of your document. As always, the comments (the % sign and everything after) are optional but recommended.

\usepackage{amsmath} % For math equations

—  OR  —

\usepackage{mathtools} % For math equations

Let's Make Some Simple Math Expressions

Inline Expressions

To create an inline math expression, we will begin it with  \(  and end it with  \). This tells the LaTeX software that the rules for math apply.

Here's the text needed for a simple, inline expression:

\(f(x)=x^2\)
Inline math expression in LaTeX document
This function looks like this, when shown inline, in the text of a document. Note that the font of the mathematical expression is different from the main text.
 
Display Expressions

Display mode shows the mathematical expression separately from the content text. The image is centered and treated like its own paragraph. To create a display math expression, we will begin it with  \[  and end it with  \]. Here's the text for a simple display expression:

...Donec ornare odio quam, nec rutrum ex tincidunt eget.
\[x=\frac{a-b}{2c}\]
Quisque luctus metus libero. Nunc finibus dictum turpis...
Equation in LaTeX in Display mode. Code: \[x=\frac{a-b}{2c}\]

This equation looks like this in a document (cropped screenshot from Overleaf). Display mode is useful for complex expressions that are too large to be placed inline, with the text. It can also help to draw attention to an important mathematical expression.

Staff LADR