Now that LaTeX has hooks, there is a recommendation to use the hooks interface for everypar? How should this be done in l3 programs?
\documentclass{article}
\ExplSyntaxOn
\newcounter{eplinenumber}
\setcounter{eplinenumber}{0}
\def\epindent{3cm}
\def\inscriptionprefix{Line:\hskip3pt}
\cs_set:Npn \mymod #1 #2 {\int_mod:nn{#1}{#2}}
\def\step_mod{5}
\NewDocumentEnvironment{inscription}{}
{
\let\annumber\empty
\expandafter\parindent\epindent
\bigskip
\obeylines
\everypar{
{ \stepcounter{eplinenumber}
\ifnum\mymod{\theeplinenumber}{\step_mod}=0 \edef\annumber{\llap{\inscriptionprefix\theeplinenumber\hskip2pt}}\fi
\ifnum\theeplinenumber=0 \edef\annumber{}\fi
\ifnum\theeplinenumber=1
\edef\annumber{\llap{\inscriptionprefix\theeplinenumber\hskip2pt}}
\fi
\annumber
}
%}
}
}
{\bigskip\setcounter{eplinenumber}{0}}
\ExplSyntaxOff
\begin{document}
\begin{inscription}
L(ucius) Albinius f(ilius)]
[cum Galli ob]siderent Capitolium
[virgines Ve]stales Caere deduxit
[ibi sacra at]que ritus sollemnes ne
[intermitte]rentur curai sibi habuit
[urbe recup]erata sacra et virgines
[Romam rev]
\end{inscription}
\end{document}
Best Answer
Please respect
expl3
naming conventions and avoid\cs_set
for functions not previously declared.I don't know that this is 'the recommended way', but it uses the hooks documented in
ltpara
and is informed to some extent by the examples in section 2.3. But note that the section warns the examples are insufficiently careful for production use and that the code below is less careful than the examples.Kant provides a minimal check that I've successfully removed the code from the hook.
Note that I couldn't find a way to insert code at precisely the same point, so I altered the paragraph indent box, which is documented as available for modification in paragraph hooks.