# line numbering & vruler on middle of page

I want to add line numbering to a document. I can't use lineno because for one reason or another it does not detect all the lines of my document (I use a lot of math equations and this makes line numbering diffiult). Instead I tried to use vruler but I have some problems with it. What I want would be to number the lines of the sections independently of each other and to be able to stop using the ruler on other sections.

Example :

\documentclass{article}

\usepackage[verbose=true,letterpaper]{geometry}
\newgeometry{
textheight=9.5in,
textwidth=7in,
top=0.5in,
footskip=30pt
}
\usepackage{vruler}
\usepackage{lipsum}
\begin{document}
\section{Test}
\subsection{Test1}
\lipsum[2-4]
\subsection{Test2}
\setvruler[10pt][1][1][4][1][10pt][10pt][0pt][\textheight]
\lipsum[2-10]
\subsection{Test3}
\unsetvruler
\end{document}


This example does not work : the ruler does not begin at Test2 and does not stop at Test3.

EDIT : lineno does not work well in maths and I want to be able to avoid rewriting all the \$ and $$ to \( and $ for every file I use. • Hope lineno.sty is the one will support your requirement, but you said it doesn't detect linenumbers in math, for this please refer tex.stackexchange.com/questions/461186/… hope it may helps you.... Jun 7, 2021 at 15:54 • you shouldn't use  for display math. The LaTeX syntax is \[..$. tex.stackexchange.com/questions/503/why-is-preferable-to Jun 9, 2021 at 8:53 • My goal is to review latex documents. I know I should not but I can't change$$ to [ for every latex document I want to review
– TMat
Jun 9, 2021 at 9:44

Due to your definition, the ruler covers the entire text height. vruler is linked to the page. If you do not start a new subsection on a new page, vruler will start at the beginning of the page on which the subsection starts. Vruler is not meant to be a line counter. In the manual it is described as follows:

Make a vertical ruler, numbering consecutively so that any part of an article can be pinpointed immediately. The vruler may be moved freely up and down, left and right. There are no formally released packages that number lines in general text one by one without missing certain lines, particularly when there are many maths equations in the text. So vruler is a good alternative for people writing text of versatile format or lots of maths formulas.

For using it at least a little similar to a line counter, you need to adjust the first parameter to your letter size, but you will remain struggling with the hight of titles and equations. To 'pinpoint' means to 'find or identify with great accuracy or precision', not 'count anything'.

• In fact I don't really care if it does not "count anything", my goal is to reference things in the section (without using referencing) for reviewing purpose. Like saying "the phrase at number 42 is not write, the equation number 64 is wring..."
– TMat
Jun 7, 2021 at 9:00

Maybe this shows how you can manipulate the use of vruler, but it remains manual work. I changed the hight (first parameter), inserted a \clearpage before the third section to which I added text.

\documentclass{article}

\usepackage[verbose=true,letterpaper]{geometry}
\newgeometry{
textheight=9.5in,
textwidth=7in,
top=0.5in,
footskip=30pt
}
\usepackage{vruler}
\usepackage{lipsum}
\begin{document}
\section{Test}
\subsection{Test1}
\lipsum[2-4]
\clearpage
\subsection{Test2}
\setvruler[14pt][1][1][4][0][10pt][10pt][0.1\textheight]
[0.6\textheight]
\lipsum[1-2]
\lipsum[3-5]
\lipsum[6-7]
\lipsum[8-10]
\clearpage
\subsection{Test3}
\unsetvruler
\lipsum[2-10]
\end{document}

• Thanks. This is not what I want because I don't want to use a lot of clearpage and having to tune the hieght at each section would be troublesome. Seeing your answer I think I may not be able to do what I want with vruler and I will have to use alternative approach.
– TMat
Jun 7, 2021 at 11:49