How can I have the regular behaviour of some paragraphs placed together, without changing line number in the algorithm after one paragraph ends?
I want that line number changes only after a \; appears and having the paragraphs indented as usual.
The contents of \If, \For, \While, must follow the same rule: only numerate a line after \;.
So, next MWE would have six numbered lines (assuming that lines of the start and end of block are numbered): two lines for the start and end of \While block, two lines for its contents and two lines for the next paragraphs.
\documentclass[oneside]{memoir}
\usepackage[linesnumbered]{algorithm2e}
\DontPrintSemicolon
\begin{document}
\begin{algorithm}[H]
\While{$i < n$}{
First line numbered...
First line continues in new paragraph...
first line ends.;
Second line.;
}
First line numbered...
First line continues in new paragraph...
first line ends.;
Second line starts...
Second line continues in new paragraph...
second line ends.;
\end{algorithm}
\end{document}


\;and\nlcommands or something else). – Alberto López Nov 24 '21 at 23:04\;and\nl(which I already did but without success) or something similar. It would be more elegant solution, avoiding putting a command at the beginning of every par. – Alberto López Nov 24 '21 at 23:11\nland\;(actually\@endalgoln) to achieve your goal. I'm not confident this will break other things within analgorithm. – Werner Nov 24 '21 at 23:37\AddToHookcommand isn't been recognized, which package does it belongs?, it seems it's a kernel problem, can't be solved with other well known commands? – Alberto López Nov 25 '21 at 00:06\usepackage{xparse}before\AddToHook. – Werner Nov 25 '21 at 00:09\usepackage{xparse}and error still appears. – Alberto López Nov 25 '21 at 00:13\AddToHook) and it works for text paragraphs but lines inside macros like\While,\For, etc are not being correctly numbered. – Alberto López Nov 25 '21 at 00:20