I'm trying to add comments on their own line. the default behaviour of \Comment{}
is to place the comment on the same line as a \State
. My current hack is to just do
\documentclass{article}
\usepackage{amsmath}
\usepackage{caption}
\usepackage{algpseudocode}
\usepackage{algorithm}
\captionsetup\[algorithm\]{labelformat=empty}
\begin{document}
\begin{algorithm}
\caption{Init}
\begin{algorithmic}\[1\]
\State // Here is a comment the way I want it.
\State $x \gets y$
\end{algorithmic}
\end{algorithm}
\end{document}]
Desired output:
Is there a proper way to do this? What about making the comment italicized so that it's a little less intrusive?
Best Answer
I fixed some errors in the code:
\[...\]
with[...]
]
I added the
\textit
command to get the comment italicized.You could also define a command for your comment type (
\CommentLine
):