[Tex/LaTex] Headline-ignoring, pagewise line numbers

line-numbering

Despite the easy-sounding task, it appears to be hard to find a suitable package to print line numbers that ignore the automatically generated section/subsection etc. headlines in their counter.

The currently preferred, non-deprecated choice of line-numbering package seems to be lineno, which sadly doesn't have the desired option. My current way of implementing it is calling it using

\usepackage[pagewise, modulo]{lineno}

before the beginning of the document and then calling

\linenumbers

after the table of contents so it doesn't interfere with these.

However, using

\section{Heading}
text longer than 5 lines

results in lineno printing the number 5 next to text line number 4, because it also counts the section heading as a line. Please note that I'd like to refrain from using the linenumbers-environment to manually number every paragraph since my document is quite long.

Best Answer

I am the maintainer of lineno – thanks for the idea. What about using \Section rather than \section after

\newcommand*{\Section}[1]{%
    \par\nolinenumbers\section{#1}\linenumbers}

Later, one might "patch" \section accordingly, maybe even dealing with the optional argument.

Related Question