![在同一行添加注释,不带符号](https://linux22.com/image/326562/%E5%9C%A8%E5%90%8C%E4%B8%80%E8%A1%8C%E6%B7%BB%E5%8A%A0%E6%B3%A8%E9%87%8A%EF%BC%8C%E4%B8%8D%E5%B8%A6%E7%AC%A6%E5%8F%B7.png)
我使用以下内容:
\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}