我使用以下内容:
\documentclass{article}
\usepackage{algpseudocode}
\usepackage{algorithm}
\usepackage{textcomp}
\usepackage{mathtools}
\date{\today}
\title{Some Title}
\begin{document}
\section{Introduction}
bla afdsdjkh
\begin{algorithm}
\caption{Caption}
\textbf{INPUT:} Some input\\
\textbf{OUTPUT:} Some Output
\begin{algorithmic}
\State Function $UpdateNodes($x$)$:
\Statex\Comment{ \%comment: Choose Representative decision tree \%}
\end{algorithmic}
\end{algorithm}
\end{document}
我希望注释与上一行在同一行,并且没有小三角符号,也没有“注释:”字样。我该怎么做?
答案1
对于单个实例,您可以使用\CommentX{<comment>}
如下定义:
\documentclass{article}
\usepackage{algpseudocode}
\usepackage{algorithm}
\newcommand{\CommentX}[1]{\unskip~\%~#1~\%}
\begin{document}
\begin{algorithm}
\caption{Caption}
\textbf{INPUT:} Some input \\
\textbf{OUTPUT:} Some Output
\begin{algorithmic}
\State Function $\emph{UpdateNodes}(x)$:
\CommentX{Choose representative decision tree}
\end{algorithmic}
\end{algorithm}
\end{document}