Align equation to the center in LaTeX

In this tutorial, I will show you how to align single-line and multi-line (set of equations) to the center in your LaTeX document.

Align single line equation to the center

To align a single line equation to the center in LaTeX you can use display math mode $$...$$ or \[...\].

But I strongly recommend using the equation environment to write an equation. This environment will align your equation to the center, as well as assign an equation number to the equation.

Also, if you don’t want to assign an equation number, you can use the \nonumber command at the end of the expression or use the equation* environment.

\documentclass{article}
\usepackage{amsmath}

\begin{document}
\begin{center}
    \underline{Align single line equation to the center}
\end{center}

Align equation to the center using: \verb|\[  \]|
\[ x + y = z \]

Align equation to the center using: \verb|$$  $$|
$$ x + y = z $$

Align equation to the center using: \verb|\begin{equation}|
\begin{equation}
   x + y = z 
\end{equation}

Use \verb|\nonumber| to turn off equation numbering with \verb|\begin{equation}|
\begin{equation}
   x + y = z \nonumber
\end{equation}

Also you can use \verb|\begin{equation*}| to turn off equation numbering
\begin{equation*}
   x + y = z
\end{equation*}

\end{document}

Output:

aligned equation to the center.

Align multi-line or set of equations to the center

The amsmath package provides lots of environments to align a set of equations to the center.

To get numbered equations, you can use these environments

  • align
  • gather

To get unnumbered equations, you can use these environments

  • align*
  • aligned
  • garher*

In the case of aligned environment, you have to write in display math mode (\[ \] or $$ $$).

\documentclass{article}
\usepackage{amsmath}

\begin{document}
\begin{center}
    \underline{Align multi-line or multiple equations to the center}
\end{center}

Align multiple equation to the center using: \verb|\begin{align}|
\begin{align}
    a + b &= c\\
    x + y &= z\\
    m + n &= f
\end{align}

You can use \verb|\begin{align*}| to turn off equation numbering
\begin{align*}
    a + b &= c\\
    x + y &= z\\
    m + n &= f
\end{align*}

Align multiple equation to the center using: \verb|\begin{aligned}|
\[\begin{aligned}
    a + b &= c\\
    x + y &= z\\
    m + n &= f    
\end{aligned}\]

Also you can use \verb|\begin{aligned}| inside \verb|\begin{equation}|
\begin{equation}
    \begin{aligned}
     x &= a + 3^2 + (2 \times 2) \\
       &= a + 9 + 4 \\
       &= a + 13
    \end{aligned}
\end{equation}

Also you can use \verb|\begin{split}| inside \verb|\begin{equation}|
\begin{equation}
    \begin{split}
     x &= a + 3^2 + (2 \times 2) \\
       &= a + 9 + 4 \\
       &= a + 13
    \end{split}
\end{equation}

Align multiple equation to the center using: \verb|\begin{gather}|
\begin{gather}
    a + b = c\\
    x + y = z\\
    m + n = f    
\end{gather}

You can also turn off the equation numbering using: \verb|\begin{gather*}|
\begin{gather*}
    a + b = c\\
    x + y = z\\
    m + n = f     
\end{gather*}

\end{document}

Output:

aligned a set of equations to the center.

Leave a Reply

Your email address will not be published. Required fields are marked *