1

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,
    headheight=12pt,
    headsep=25pt,
    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.

3

2 Answers 2

0

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'.

1
  • 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
0

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,
headheight=12pt,
headsep=25pt,
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}
1
  • 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.