答案1
以与所有其他关键字类似的方式定义\Downto
和\By
algpseudocode
:
\documentclass{article}
\usepackage{algorithm,algpseudocode}
\algnewcommand{\Downto}{\textbf{ downto }}
\algnewcommand{\By}{\textbf{ by }}
\begin{document}
\begin{algorithm}
\caption{An algorithm}
\begin{algorithmic}[1]
\For{$i \gets 20 \Downto 0 \By 2$}
\State Do something with $i$
\EndFor
\end{algorithmic}
\end{algorithm}
\end{document}