[Tex/LaTex] algorithm2e single-line control structures

algorithm2e

I am using algorithm2e for formatting pseudo-code: is it possible to compress single-instructions control structure to one single line?

For example I would like to modify this so that l.sort() appears on the same line as foreach:

\begin{algorithm}[htb]
  \ForEach{$l \in list\_of\_lists$}{  $l.sort()$\;  }
  \caption{...}
  \label{...}
\end{algorithm}

Thanks in advance

Best Answer

You could use the command \lForEach. See https://www.tug.org/texlive/Contents/live/texmf-dist/doc/latex/algorithm2e/algorithm2e.pdf page 33.

\begin{algorithm}[htb]
  \lForEach{$l \in list\_of\_lists$}{  $l.sort()$\;  }
  \caption{...}
  \label{...}
\end{algorithm}
Related Question