![类似算法中两个程序的行号不同](https://linux22.com/image/297374/%E7%B1%BB%E4%BC%BC%E7%AE%97%E6%B3%95%E4%B8%AD%E4%B8%A4%E4%B8%AA%E7%A8%8B%E5%BA%8F%E7%9A%84%E8%A1%8C%E5%8F%B7%E4%B8%8D%E5%90%8C.png)
我有以下包含两个不同程序(即阶段)的算法,并且想为它们赋予单独的行号。有人能帮我吗?谢谢...
\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}