我有以下包含两个不同程序(即阶段)的算法,并且想为它们赋予单独的行号。有人能帮我吗?谢谢...
\documentclass[10pt,a4paper]{IEEEtran}
\usepackage{algorithmic}
\usepackage{algorithm}
\begin{document}
\begin{algorithm}
\caption{Boundaries calculation and rank computation}
\label{abc}
\begin{algorithmic}[1]
\STATE Phase 1: Compute boundaries
\STATE computer abc
\STATE calculate bcd
\STATE Phase 2: rank computation
\STATE compute wxy
\STATE calculate xyz
\end{algorithmic}
\end{algorithm}
\end{document}
答案1
就像这样。用不同的/独立的alogrithmic
环境包装每个阶段。
更新:要在两个阶段之间添加不编号的空白行,请在阶段 1 环境的末尾添加 \item[]。
代码
\documentclass[10pt,a4paper]{IEEEtran}
\usepackage{algorithmic}
\usepackage{algorithm}
\begin{document}
\begin{algorithm}
\caption{Boundaries calculation and rank computation}
\label{abc}
\begin{algorithmic}[1]
\STATE Phase 1: Compute boundaries
\STATE computer abc
\STATE calculate bcd
\end{algorithmic}
\begin{algorithmic}[1]
\STATE Phase 2: rank computation
\STATE compute wxy
\STATE calculate xyz
\end{algorithmic}
\end{algorithm}
\end{document}