algpseudocodex
algpseudocodex copied to clipboard
LComment without line numbering
Hi there!
I'm wondering if there is a way to create an LComment without the line numbering. I'm trying to write down an algorithm, where the individual steps can be sectioned into a few different groups. Basically, I'm trying to (mis-) use LComments to create small headings for different parts of the algorithm, and I would like to do that without line numbers.
Also, I would like to thank you for creating this package.
Update: Due to what appears to be a bug in algorithmicx, I ended up making my own commands for these headings. One command for the first heading directly after a \Procedure, and one for headings after \State has been used:
\algnewcommand{\AlgHeading}[1]{\Statex \textcolor{gray}{\textit{#1}}}
\algnewcommand{\AlgHeadingInitial}[1]{\Statex \hspace{\algorithmicindent}\textcolor{gray}{\textit{#1}}}
Hey!
It would be nice to have a variant of the command that does not produce a line number. Similarly as the issue #5 . I will add such feature in a new release once I have some time.
In the meantime, you man use \Statex to produce a normal line without a number or even an empty line:
\documentclass{article}
\usepackage{algpseudocodex}
\begin{document}
\begin{algorithmic}[1]
\State numbered line
\Statex % empty line
\Statex \textbf{unnumbered line}
\State numbered line
\end{algorithmic}
\end{document}
Hey!
Thanks for the super quick response. After some more experimentation, I just realized on my own as well, that I should probably be using \Statex. So I'm happy to hear that this idea was in the right direction.
In trying to do that, however, I noticed, that \Statex does not produce the desired indentation if it is the first command after a \Procedure. There needs to be a \State after the \Procedure before I can use \Statex to write something without a line number. If the \State is missing, the text without line number will be aligned with the \Procedure. Is that the intended behavior?
That appears to be a bug to me. However, the behavior is inherited from the package algorithmicx on which algpseudocodex is based. You can see that the same is happening when using \usepackage{algpseudocode}. So I'm not sure how much I can do about it.
Alright, thanks for your help! I'll try to see if I can find a place to report that. In the mean time I'll search around, to see if other people have experienced the same and perhaps come up with a workaround.
Have a nice day!