How to Typeset and Align LaTeX Equations and Math

How to Typeset and Align LaTeX Equations and Math

This post may contain affiliate links that allow us to earn a commission at no expense to you. Learn more

LaTeX is the preferred document creation tool for scientists and mathematicians all over the globe. 

It is popular because it allows users to insert equations and mathematical formulas into documents with ease, and presents them with a neat and professional look. 

There are many ways to work with LaTeX equations and math

This guide will go through the various types of equations and formulas you can add to LaTeX.

LaTeX Equations and Math Modes

LaTeX offers two primary routes for typesetting math equations and formulas in your document. The first method is to add math to your document text by enclosing it between dollar signs, such as $…..$. The other method is to use a predefined math environment.

Embedding Formulas in Document Text

As described above, you can embed formulas in your document text directly using “$” symbols. 

For example $f(x) = x^3$ would produce the equation f(x) = x3 in the final document.

Using Equation and Align Environments

The equation environment can be incredibly useful if you want to typeset single equations in your LaTeX document. For multiple equations, the aligned environment tends to be more helpful.

For example:

  3 + 4 = 7 
  4 = 7 - 3
  4 + 2 &= 6\\
  4 &= 8 - 4

The “&” symbol in the align section of the above code helps align the equations 4 + 2 =6 and 4 = 8 – 4 so that their “=” signs are under one another. 

The 3+4 = 7 and 4 = 7 -3 equations above are created using a simple equation environment. Therefore they won’t be aligned. 

You should also note that you cannot put more than one equation between the \begin{equation*} and \end{equation*} commands mentioned above. Attempting to add multiple equations enclosed by these commands will result in an error. This isn’t an issue with the align section, as you can see two equations are fit between \begin{align*} and \end{align*}.

Note that the asterix “*” in the commands above aren’t necessary, and are only present to prevent the equations mentioned from being numbered.

Adding Fractions and Integrals in LaTe

As mentioned earlier, LaTeX is popular with mathematicians and scientists because it allows you to insert most types of mathematical notation. This includes fractions, integrals, and much more.

Earlier we demonstrated how you can show “x” raised to the power 3 using the code  f(x) &= x^3\\

If you wanted to show the equation g(x) = 1/y, your code should follow the format of  g(x) &= \frac{1}{y}\\.

If you wanted to show an integral of (½)x raised to the power 2 with limits a and b, the code would resemble F(x) &= \int^a_b \frac{1}{2}x^2

You can also combine different types of code to create complex formulas and expressions. For example:  \frac{1}{\sqrt{y}}. You should remember to keep track of the closing braces {} for each of your expressions, as failing to do so will produce errors.

Adding Binomials in LaTeX

Binomials are another useful LaTeX equations and math expression you can add to your documents. We can include both fractions and binomials in an expression using the following code:

 \binom{m}{j} = \frac{m!}{j!(m-j)!}

Adding Matrices in LaTeX

You can also add matrices in addition to other Latex equations and math formulas. This is accomplished using the commands \begin{matrix} and \end{matrix}. For example:

2 & 0\\
0 & 2

The above code will produce a 2 x 2 matrix that is aligned thanks to the inclusion of the “&”.

Matrices with Brackets in LaTeX

In some cases, you may need to add brackets around your matrices. This usually occurs when you have to include special statements. You should note that simply adding the symbols [] to your code won’t cause the brackets to scale as your matrix grows. For example:

2 & 0\\
0 & 0

The above code will produce a matrix where the bracket remains the same size as the digits and doesn’t extend to the top and bottom of the rows. To adjust the brackets to the correct size, you will need to use a special code modifier. We demonstrate this in the following example:

1 & 0\\
0 & 1

Note the addition of \left and \right before the brackets at the start and end of the expression. This technique can be used for brackets in many types of LaTeX equations and math, and isn’t just limited to matrices.

Changing Bracket Size in LaTeX

It is also possible to adjust the size of different brackets in LaTeX. The code changing brackets from small to large are shown below:

  • “(“ brackets: \big(  \Big(  \bigg(  \Bigg(  
  • “]“ brackets: \big]  \Big]  \bigg]  \Bigg]
  • “{“ brackets: \big{  \Big{  \bigg{  \Bigg{  
  • “<” brackets: \big \langle   \Big \langle   \bigg \langle  \Bigg \langle  
  • “>” brackets: \big \rangle   \Big \rangle   \bigg \rangle  \Bigg \rangle  

Final Thoughts

As you can see, LaTeX offers many ways to add and display mathematical expressions and formulas. You can insert some very complex equations into LaTeX by using a combination of the commands mentioned above. Just remember the correct and complete syntax for each expression or you may end up running into errors. So try adding some professional-looking equations and expressions into your next LaTeX document.

You can learn more about creating complex mathematical expressions with the help of this video

Frequently Asked Questions

Q1. What Is Math Mode in LaTeX?

Math Mode is a special operating mode that allows you to enter mathematical expressions easily. It is possible to enter math mode by enclosing your expression between the “$” symbol. Alternatively, you can enter math mode by enclosing your expression between the commands \begin{equation} and \end{equation}

Q2. What Does $$ Do in LaTeX?

Enclosing your expression between “$$” activates math mode. This is useful for creating inline math equations with no labels. 

Q3. How Do You Write a Math Equation in LaTeX?

You can write math equations in a variety of different ways as long as you are using math mode. You can use the command \frac for fractions, \binom for binomials, and the commands \begin{matrix} and \end{matrix} for matrices.

Further Reading

LaTex Tutorial

  1. 27 Pros and Cons of Using LaTex for Scientific Writing
  2. 6 easy steps to create your first Latex document examples
  3. How to add circuit diagrams in Latex
  4. How to change Latex font and font size
  5. How to create a Latex table of contents
  6. How to create footnotes in LaTeX and how to refer to them, using the builtin commands
  7. How to create Glossaries in LaTeX
  8. How to create plots in Latex – codes and examples
  9. How to create symbols in LaTeX – commands for Latex greek alphabet 
  10. How to create tables in LaTeX – rows, columns, pages and landscape tables
  11. How to drawing graphs in Latex – vector graphics with tikz
  12. How to highlight source code in LaTeX
  13. How to insert an image in LaTeX – Managing Latex figure and picture
  14. How to Itemize and Number List – Adding Latex Bullet Points
  15. How to make hyperlink in latex – Clickable links
  16. How to reference in Latex – 5 steps to bibliography with Bibtex
  17. How to use Latex Packages with examples
  18. How to use LaTeX paragraphs and sections
  19. LaTeX Installation Guide – Easy to follow steps to install LaTex

Photo of author
SJ Tsai
Chief Editor. Writer wrangler. Research guru. Three years at scijournal. Hails from a family with five PhDs. When not shaping content, creates art. Peek at the collection on Etsy. For thoughts and updates, hit up Twitter.

Leave a Comment