# line numbers do not show on for the text of a paragraph in which an equation is defined

The line numbers for the text of a paragraph with an equation defined by \begin{align} command do not show as expected. How to fix this?

The LaTeX codes are attached here.

\documentclass[a4paper, 12pt]{article}
\usepackage[utf8]{inputenc}    % Use the UTF-8 encoding
\usepackage{amsmath}           % For the use of math
\usepackage{amsfonts}
\usepackage{amssymb}           % For the use of AMS symbols
\usepackage{indentfirst}       % For indentation
\usepackage[top=2cm, bottom=2cm, left=2cm, right=2cm]{geometry}

\usepackage{lineno}
\linenumbers

\usepackage{titlesec}
\titleformat*{\section}{\large\bfseries}
\titleformat*{\subsection}{\normalsize\bfseries}
\titleformat*{\subsubsection}{\normalsize}

\renewcommand{\baselinestretch}{1.5}

\usepackage{authblk}           % Use author package
\renewcommand*{\Authfont}{\large}
\renewcommand*{\Affilfont}{\normalsize\normalfont}

\makeatletter
\setlength\abovedisplayskip{0pt}
\setlength\belowdisplayskip{0pt}
\setlength\abovedisplayshortskip{0pt}
\setlength\belowdisplayshortskip{0pt}
}
\makeatother

\title{\textbf{Globally cumstomize the spacing between the text and equation}}

\date{}

\begin{document}

\maketitle

\section{Air filter}
The air filter is simulated by the Control Valve module (AFT in Fig. 2(a)). The pressure drop through the air filter ($\Delta P_{af}$) is given by the following equation [11,16].
\begin{align}
\Delta P = \Delta P_{d} \left( \frac{m}{m_{d}}\right)^{1.84}  \left( \frac{T}{T_{d}}\right)  \left( \frac{P}{P_{d}}\right)^{-1}
\end{align}
where, $\Delta P_{af}$ is the pressure drop, $m$ is the mass flow rate, $T$ is the temperature, and $P$ is the pressure, and subscript $d$ denotes the design condition.

\newpage
\section{Air compressor (AC)}
The AC operating characteristics can be described by its performance map, which relates the following dimensionless operational variables. The AC operating characteristics can be described by its performance map, which relates the following dimensionless operational variables.
\begin{align}
& \text{Relative pressure ratio:} && PR_{r} = \frac{PR-1}{PR_{d}-1}\\
& \text{Relative isentropic efficiency:} && \eta_{r} = \frac{\eta}{\eta_{d}} \\
& \text{Relative corrected mass flow:} && m_{cor,r} = \frac{\left(\frac{m_{in}}{P_{in}}\sqrt{T_{in}}\right)}{\left(\frac{m_{in,d}}{P_{in,d}}\sqrt{T_{in,d}}\right)} \\
& \text{Relative corrected speed:} && N_{cor,r} = \frac{\left(\frac{N}{\sqrt{T_{in}}}\right)}{\left(\frac{N_{d}}{\sqrt{T_{in,d}}}\right)}
\end{align}
where, $\eta$ is the efficiency, $N$ is the shaft speed, and $PR = P_{in}/P_{out}$. Subscript $cor$ denotes the corrected value, $r$ denotes the relative value, $in$ denotes the inlet, and $out$ denotes the outlet.

\end{document}

• For my documents I use \renewcommand{\baselinestretch}{1.5}  in the preamble. – J Leon V. May 2 '18 at 5:09
• Is your question now focused on the lineno package? Please advise. – Mico May 2 '18 at 5:59
• @Mico, Yes now. – Nick May 2 '18 at 6:11
• @Mico I do not which one is easy to realize, the lineno package or the spacing around the equation. – Nick May 2 '18 at 6:21
• the readme file for lineno contains the following disclaimer: "amsmath.sty loadable, but not fully supported, with v4.41". the documentation is not fully up to date, so the details are unknown. – barbara beeton May 2 '18 at 15:08

The documentation of lineno shows this is not just a problem for align but also for other displays. It provides an environment linenomath to wrap around such displays to fix the problem:

\begin{linenomath}
\begin{align}
...
\end{align}
\end{linenomath}


To avoid rewriting your code lineno also provides a package option displaymath to do this automatically for standard LaTeX environments. It turns out the coding for that can be adapted to apply to the AMS environments, including align and gather as follows:

\documentclass[a4paper, 12pt]{article}

\usepackage[utf8]{inputenc}    % Use the UTF-8 encoding
\usepackage{amsmath}           % For the use of math
\usepackage{amsfonts}
\usepackage{amssymb}           % For the use of AMS symbols

\usepackage[displaymath]{lineno}
\linenumbers

\makeatletter
\let\LN@align\align
\let\LN@endalign\endalign
\renewcommand{\align}{\linenomath\LN@align}
\renewcommand{\endalign}{\LN@endalign\endlinenomath}
\let\LN@gather\gather
\let\LN@endgather\endgather
\renewcommand{\gather}{\linenomath\LN@gather}
\renewcommand{\endgather}{\LN@endgather\endlinenomath}
\makeatother

\begin{document}

\section{Air filter}

The air filter is simulated by the Control Valve module (AFT in
Fig. 2(a)). The pressure drop through the air filter
($\Delta P_{af}$) is given by the following equation [11,16].
\begin{align}$$\Delta P = \Delta P_{d} \left( \frac{m}{m_{d}}\right)^{1.84} \left( \frac{T}{T_{d}}\right) \left( \frac{P}{P_{d}}\right)^{-1}$$\end{align}
where, $\Delta P_{af}$ is the pressure drop, $m$ is the mass flow rate, $T$ is the temperature, and $P$ is the pressure, and subscript $d$ denotes the design condition.
\begin{align}
x&=y,\\
z&=u.
\end{align}
More text.

The air filter is simulated by the Control Valve module (AFT in
Fig. 2(a)). The pressure drop through the air filter
($\Delta P_{af}$) is given by the following equation [11,16].
$$\Delta P = \Delta P_{d} \left( \frac{m}{m_{d}}\right)^{1.84} \left( \frac{T}{T_{d}}\right) \left( \frac{P}{P_{d}}\right)^{-1}$$
where, $\Delta P_{af}$ is the pressure drop, $m$ is the mass flow rate, $T$ is the temperature, and $P$ is the pressure, and subscript $d$ denotes the design condition.
\begin{gather}
x=y,\\
z=u.
\end{gather}
More text.

\end{document}