显然,我使用 lineno 来编号我的行。
我需要每 5 行一个数字,所以我启用了该选项模数。
但是因为1 模 5 <> 0,第一行没有编号。正如你现在已经猜到的,我需要数字 1...
如果这不可能的话,我可以轻松使用另一个包亚麻布。
截屏
平均能量损失
\documentclass[]{article}
\usepackage[modulo]{lineno}
\usepackage[parfill]{parskip}
\begin{document}
\begin{linenumbers}
\textbf{Oh lord, won't you give me, my linenumber 1\\}
Lorem ipsum dolor sit amet, consectetur adipiscing elit.\\
Donec sit amet diam vel sapien commodo tempor at at sem.\\
Praesent mollis enim mauris. Integer eu consequat neque.\\
Nullam hendrerit laoreet fringilla.\\
Aenean massa dolor, tristique maximus aliquet vel, hendrerit non mi.\\
Pellentesque euismod mattis lectus, vel pretium turpis condimentum efficitur.\\
Ut commodo ante nec risus sagittis, vitae sodales massa dictum.\\
Quisque scelerisque pretium faucibus.\\
Duis gravida ex lorem, et tincidunt diam mattis quis.\\
Aenean nibh elit, pretium id leo ornare, congue mollis est.\\
Etiam dictum viverra libero in imperdiet.\\
Integer vel scelerisque urna, et porttitor turpis.\\
Mauris porta molestie tincidunt. Vivamus ut rutrum urna.
Lorem ipsum dolor sit amet, consectetur adipiscing elit.\\
Donec sit amet diam vel sapien commodo tempor at at sem.\\
\end{linenumbers}
\end{document}
答案1
如果该行是第一行,则重新定义\themodulolinenumber
为无条件打印编号。您必须重申要每五行编号一次,以便重新定义被考虑在内。
\documentclass[]{article}
\usepackage[modulo]{lineno}
\usepackage[parfill]{parskip}
\usepackage{etoolbox}
\patchcmd\themodulolinenumber
{\relax}
{\relax\ifnum\value{linenumber}=1 \thelinenumber\else}
{}{}
\appto\themodulolinenumber{\fi}
\modulolinenumbers
\begin{document}
\begin{linenumbers}
\textbf{Oh lord, won't you give me, my linenumber 1\\}
Lorem ipsum dolor sit amet, consectetur adipiscing elit.\\
Donec sit amet diam vel sapien commodo tempor at at sem.\\
Praesent mollis enim mauris. Integer eu consequat neque.\\
Nullam hendrerit laoreet fringilla.\\
Aenean massa dolor, tristique maximus aliquet vel, hendrerit non mi.\\
Pellentesque euismod mattis lectus, vel pretium turpis condimentum efficitur.\\
Ut commodo ante nec risus sagittis, vitae sodales massa dictum.\\
Quisque scelerisque pretium faucibus.\\
Duis gravida ex lorem, et tincidunt diam mattis quis.\\
Aenean nibh elit, pretium id leo ornare, congue mollis est.\\
Etiam dictum viverra libero in imperdiet.\\
Integer vel scelerisque urna, et porttitor turpis.\\
Mauris porta molestie tincidunt. Vivamus ut rutrum urna.
Lorem ipsum dolor sit amet, consectetur adipiscing elit.\\
Donec sit amet diam vel sapien commodo tempor at at sem.
\end{linenumbers}
\end{document}