How to write equation numbering in LaTeX?

One of the component of “Display Math mode” is number equation. There are many methods in LaTeX for this. Each method is discussed in depth with code and output below.

For single line equation number

Our first method is equation-environment, which will return you a single line number equation. This environment does not support multi-line number equations. But, there is an optional method for this.

\documentclass{article}
\usepackage{lipsum}
\begin{document}
\lipsum[1][1-4]
 \begin{equation}
     f(x)= \int \frac{\ln x}{x} {dx} = \frac{\left(\ln x\right)^2}{2}
 \end{equation}
\lipsum[2][1-3]
 \begin{equation}
     \int \tan^2(x){dx} = \frac{1}{n-1}\tan^{n-1}(x)-\int \tan^{n-2}(x){dx}
 \end{equation}
\lipsum[3][1-3]
 \begin{equation}
     \int x^n {dx} = \frac{x^{n+1}}{n+1} + C, n \neq -1
 \end{equation}
\end{document}

Output :

In this figure, Use of equation environment is shown for single number equation.

Split environment for single line equation number

For multi line, split Environment is used with Equation. In LaTeX, this environment does not have a default. So, amsmath package must be called within preamble.

It will be easier, if you understand the structure of syntax. & symbol shift one equation left-aligned relative to another, so that each equation’s left margin or left indent is equal with respect to the page.

And \\ symbols will break the line. If there are n equations then \\ symbols will be used n-1 times.

\documentclass{article}
\usepackage{lipsum,amsmath}
\begin{document}
\lipsum[1][1-4]
 \begin{equation}
     \begin{split}
         f(x)&=\int\frac{\ln x}{x} {dx} \\
         &= \int \ln x \; {d(\ln x)} \\
         &= \frac{\left(\ln x\right)^2}{2} +C
     \end{split}
 \end{equation}
\lipsum[2][1-3]
 \begin{equation}
     \begin{split}
         &\frac{d}{dx} (\sin x) = \cos x \\
         &\frac{d}{dx} (\cos x) = -\sin x \\
         &\frac{d}{dx} (\tan x) = -\sec^2 x  
     \end{split}
 \end{equation}
\lipsum[3][1-3]
 \begin{equation}
     \begin{split}
         \sum_{i=1}^n i = \frac{n(n+1)}{2}
     \end{split}
 \end{equation}
\end{document}

Output :

Passing split environment into equation environment.

Interestingly, this nested environment will return a number for the entire system of equations or multi line equations. If you want only one number for the whole system, then you can take help of split environment.

Use align environment for equation numbering

align environment will return a separate equation number for each equation. Its structure will be composed of & and \\ symbols that we saw in the above point of use.

\documentclass{article}
\usepackage{lipsum,amsmath}
\begin{document}
\lipsum[1][1-4]
 \begin{align}
    &\frac{d}{dx} (\sin x) = \cos x \\
    &\frac{d}{dx} (\cos x) = -\sin x \\
    &\frac{d}{dx} (\tan x) = -\sec^2 x  
 \end{align}
\lipsum[2][1-3]
 \begin{align}
     f(x)&=\int\frac{\ln x}{x} {dx} \\
     &= \int \ln x \; {d(\ln x)} \\
     &= \frac{\left(\ln x\right)^2}{2} +C
 \end{align}
\lipsum[3][1-3]
 \begin{align}
    \sum_{i=1}^n i = \frac{n(n+1)}{2}
 \end{align}
\end{document}

Output :

Align environment best for multi number equations.

Use flalign environment

Using flalign environment is similar to align environment. And with this environment you can shift the equation completely to left. That is advantage of this environment

\documentclass{article}
\usepackage{lipsum,amsmath}
\begin{document}
\lipsum[1][1-4]
 \begin{flalign}
    \frac{d}{dx} (\sin x) = \cos x \\
    \frac{d}{dx} (\cos x) = -\sin x \\
    \frac{d}{dx} (\tan x) = -\sec^2 x  
 \end{flalign}
\lipsum[2][1-3]
 \begin{flalign}
     f(x)&=\int\frac{\ln x}{x} {dx} \\
     &= \int \ln x \; {d(\ln x)} \\
     &= \frac{\left(\ln x\right)^2}{2} +C
 \end{flalign}
\lipsum[3][1-3]
 \begin{flalign}
    \sum_{i=1}^n i = \frac{n(n+1)}{2}
 \end{flalign}
\end{document}

Output :

flalign environment known for left alignment

Use gather environment

The gather environment will return multi line, but not support alignment. In this case, \\ is used for multi-line.

\documentclass{article}
\usepackage{lipsum,amsmath}
\begin{document}
\lipsum[1][1-4]
 \begin{gather}
    \frac{d}{dx} (\sin x) = \cos x \\
    \frac{d}{dx} (\cos x) = -\sin x \\
    \frac{d}{dx} (\tan x) = -\sec^2 x  
 \end{gather}
\lipsum[2][1-3]
 \begin{gather}
     f(x)=\int\frac{\ln x}{x} {dx} \\
     = \int \ln x \; {d(\ln x)} \\
     = \frac{\left(\ln x\right)^2}{2} +C
 \end{gather}
\lipsum[3][1-3]
 \begin{gather}
    \sum_{i=1}^n i = \frac{n(n+1)}{2}
 \end{gather}
\end{document}

Output :

In this figure, the use of gather environment is shown.

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 *