How do you set the equation to left alignment in LaTeX?

Hi, in this tutorial you will learn how to left-align an equation with respect to another equation while the system of equations or multi-line equation is centered.

Second, how to shift the equation or system of equations to left-alignment with respect to the page.

Left align an equation with respect to another equation

In this case, multi-line equation will be located in the center but left margin or left indent will be equal to all.

And & symbol will play an important role in adjusting left Indent. See the syntax below, how & symbols are used.

 \begin{equation*}
     \begin{split}
       & equation 1 \\
       & equation 2 \\
          ......
       & equation (n-1) \\
       & equation (n)
     \end{split}
 \end{equation*}

\begin{split}
    & equation 1 \\
    & equation 2 \\
       ......
    & equation (n-1) \\
    & equation (n)
\end{split}

\begin{flalign}
    & equation 1 \\
    & equation 2 \\
       ......
    & equation (n-1) \\
    & equation (n)
\end{flalign}
\documentclass{article}
\usepackage{amsmath,lipsum}
\begin{document}
\lipsum[1][1-3]
 \begin{equation*}
     \begin{split}
        &  a^2 + 2ab + b^2 = n_1 \\
        & a^2 + b^2 = c_1^2 \\
        & a^2 + 2ab + b^2 = n_2 
     \end{split}
 \end{equation*}
\lipsum[2][1-3]
\begin{align}
    & a^2 + 2ab + b^2 = n_3 \\
    & a^2 + b^2 = c_2^2 \\
    & a^2 + 2ab + b^2 = n_4    
\end{align}
\lipsum[3][1-3]
  \begin{flalign}
    & a^2 + 2ab + b^2 = n_5  \\
    & a^2 + b^2 = c_3^2  \\
    & a^2 + 2ab + b^2 = n_6 
  \end{flalign}
\end{document}

Output :

As defined in this figure, left margin or left indent of each equation is kept equal.

Use fleqn environment for left alignment of equations

fleqn is a powerful environment for left alignment of equations with respect to the page that is present in nccmath package.

However, usage of this environment is different compared to another environment i.e. display math mode insert instead of direct equation.

\documentclass{article}
\usepackage{nccmath,amsmath,lipsum}
\begin{document}
\lipsum[1][1-3]
 \begin{fleqn}
   \[ a^2 + 2ab + b^2 = n \]
   \[ a^2 + b^2 = c^2 \]
   \[ a^2 + 2ab + b^2 = n \]
 \end{fleqn}
\section*{For number equation}
\lipsum[3][1-3]
\begin{fleqn}
\begin{equation}
   f(x)=\sum_{x=1}^{n} x =\frac{n(n+1)}{2}
\end{equation}
\end{fleqn}
\lipsum[2][1-3]
 \begin{fleqn}
   \begin{gather}
     f(x) = \int \frac{1}{x} \,dx \\
     g(x) = \int \frac{2x}{(x^2 + 1)^2} \,dx  
  \end{gather}
 \end{fleqn}
\end{document}

Output :

Various display math modes are passed with the fleqn environment.

Add indent or left margin with fleqn environment

As you can see from the above output, there is no indent or left margin by default with Equation.

You can add it manually. For this, optional options have to be added to the environment. of which length will be passed as argument. Can use variable length instead of fixed length. Like \parindent, \linewidth etc.

\documentclass{article}
\usepackage{nccmath,amsmath,lipsum}
\begin{document}
\lipsum[1][1-3]
\begin{fleqn}[1\parindent]
  \[ a^2 + 2ab + b^2 = n \]
  \[ a^2 + b^2 = c^2 \]
  \[ a^2 + 2ab + b^2 = n \]
\end{fleqn}
\section*{For Number Equation}
\lipsum[3][1-3]
\begin{fleqn}[.3\textwidth]
\begin{equation}
  f(x)=\sum_{x=1}^{n} x=\frac{n(n+1)}{2}
\end{equation}
\end{fleqn}
\lipsum[2][1-3]
\begin{fleqn}[2cm] 
\begin{gather}
  f(x) = \int \frac{1}{x} \,dx \\
  g(x) = \int \frac{2x}{(x^2 + 1)^2} \,dx \\
  f(x)=\sum_{x=1}^{n} x
\end{gather}
\end{fleqn}
\end{document}

Output :

Manually, indents are added to fleqn environment.

Use fleqn option for left alignment of equations

Assume you are creating a large document. Where there will be more than 100 pages. In that case, would it be best practice to repeatedly use the fleqn environment for left alignment?

No, you don’t need to use this environment repeatedly. fleqn has an optional option that will globally complete this task.

Although name is same, both option and environment have different syntax and usage.

Many of you also use this option argument with the documentclass and amsmath package. In this tutorial, we will use fleqn option with documentclass and this is the best practice.

\documentclass[fleqn]{article}
\usepackage{amsmath}
\usepackage{lipsum}
\begin{document}
\lipsum[1][1-3]
   \[ a^2 + 2ab + b^2 = n\]
   \[ a^2 + b^2 = c^2 \] 
   \[ a^2 + 2ab + b^2 = n\]
\section*{Number Equation}
\lipsum[2][1-3]
 \begin{equation}
   f(x)=\sum_{x=1}^{n} x =\frac{n(n+1)}{2}
 \end{equation}
 \lipsum[2][1-3]
 \begin{align}
   & a^2 + 2ab + b^2  = n \\
   & a^2 + b^2 = c^2  \\
   & a^2 + 2ab + b^2 = n 
\end{align}
\lipsum[2][1-3]
\begin{gather}
   a^2 + 2ab + b^2 = n \\
   a^2 + b^2 = c^2 \nonumber \\
   a^2 + 2ab + b^2 = n 
\end{gather}
\end{document} 

Output :

Added fleqn option to documentclass.

fleqn option returns the default indent with left alignment. You can customize length of indent to increase or decrease it.

\documentclass[fleqn]{article} 
\usepackage{amsmath}
\usepackage{lipsum}
\begin{document}
\lipsum[1][1-3]
   \[ a^2 + 2ab + b^2 = n\]
   \[ a^2 + b^2 = c^2 \] 
   \[ a^2 + 2ab + b^2 = n\]
 \section*{Number Equation}
\lipsum[2][1-3]
\setlength{\mathindent}{1\parindent} 
 \begin{equation}
   f(x)=\sum_{x=1}^{n} x =\frac{n(n+1)}{2}
 \end{equation}
 \lipsum[2][1-3]
 \setlength{\mathindent}{2.5cm}
 \begin{align}
   & a^2 + 2ab + b^2  = n \\
   & a^2 + b^2 = c^2  \\
   & a^2 + 2ab + b^2 = n 
\end{align}
\lipsum[2][1-3]
\setlength{\mathindent}{.4\linewidth}
\begin{gather}
   a^2 + 2ab + b^2 = n \\
   a^2 + b^2 = c^2 \nonumber \\
   a^2 + 2ab + b^2 = n 
\end{gather}
\end{document} 

Output :

Increasing or decreasing the left indent. For which \setlength command is used.

Use flalign environment for center to left shift

You are already familiar with the flalign environment, which represents the number equation with the center alignment. But, with this environment, you can shift the equation to left alignment.

Its syntax structure is different compared to other methods. For example, to perform a left shift, double & must be used at the end of each equation.

\begin{flalign}
   eqn 1 \\
   eqn 2 \\
   ....
   eqn (n-1) \\
   eqn (n)
\end{flalign}

\begin{flalign}
 &   eqn 1 \\
 &   eqn 2 \\
   ....
 &  eqn (n-1) \\
 &  eqn (n)
\end{flalign}

\begin{flalign}
 &   eqn 1 && \\
 &   eqn 2 && \\
   ....
 &  eqn (n-1) && \\
 &  eqn (n) &&
\end{flalign}

But, in this case you can add direct equations which was a problem in fleqn environment.

\documentclass{article}
\usepackage{lipsum,amsmath}
\begin{document}
\section*{With center alignment}
\lipsum[1][1-3]
  \begin{flalign}
    a^2 + 2ab + b^2 = n_1  \\
    a^2 + b^2 = c^2  \\
    a^2 + 2ab + b^2 = n_2 
  \end{flalign}
 \lipsum[2][1-3]
  \begin{flalign}
    & a^2 + 2ab + b^2 = n_1  \\
    & a^2 + b^2 = c^2  \\
    & a^2 + 2ab + b^2 = n_2 
  \end{flalign}
\section*{With left alignment}
\lipsum[1][1-3]
 \begin{flalign}
   & a^2 + 2ab + b^2 = n_1 && \\
   & a^2 + b^2 = c^2 && \\
   & a^2 + 2ab + b^2 = n_2 &&
 \end{flalign}
Derivative of the function \(f(x)\) with respect to \(x\) is given by:
\begin{flalign*}
    f'(x) = \lim_{{h \to 0}} \frac{{f(x + h) - f(x)}}{h} && 
\end{flalign*}
\end{document}

Output :

In this figure, the equation is shifted from center to left by flalign environment.

Md Jidan Mondal

LaTeX expert with over 10 years of experience in document preparation and typesetting. Specializes in creating professional documents, reports, and presentations using LaTeX.

Leave a Comment

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