1

I'm using the lineno package with the pagewise option but I need a way to get the numbering restart every paragraph break. I need a general solution to pass to the latex command, e.g.:

latex "\AtBeginDocument{\RequirePackage[pagewise]{lineno}\linenumbers}\input{mydocument.tex}"

I read the lineno manual but the package does not provide this feature. Is there any trick to do that?

1 Answer 1

2

You can use running linenumbers which are reset to 1 for each paragraph. The reset can be automated using a hook to the \par command (which also works for paragraphs created by empty lines).

MWE:

\documentclass{article}
\usepackage[excludeor]{everyhook}
\usepackage[running]{lineno}
\runninglinenumbers
\PushPreHook{par}{\resetlinenumber[1]}
\begin{document}
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida mauris.

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida mauris. Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna. Donec vehicula augue eu neque

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida mauris. Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna. Donec vehicula augue eu neque
\end{document}

Result:

enter image description here

The same result can be obtained with \AtBeginDocument, as follows:

pdflatex "\AtBeginDocument{\RequirePackage[excludeor]{everyhook}\RequirePackage[running]{lineno}\runninglinenumbers\PushPreHook{par}{\resetlinenumber[1]}}\input{mydocument.tex}"

of course provided that mydocument.tex is something like

\documentclass{article}
\begin{document}
Lorem ipsum dolor ...
\end{document}
1
  • Wow! You win! It's exactly what I need. Thank you.
    – Gabriele
    Commented Jun 28, 2017 at 15:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .