I used
\usepackage{lineno}
\linenumbers
For numbering my lines. I know it has problem with double dollars and for that case I replaced double dollars with \[\] and it worked but now I used \begin{gather*}\end{gather*} to fit an equation but it caused line-numbering doesn't work for a few lines before this equation. Id there any solution for this?
linenomathenvironment. See e.g. this question. – campa Apr 04 '17 at 13:25