![如何使用 Springer 格式将每行的行号添加到算法中](https://linux22.com/image/470120/%E5%A6%82%E4%BD%95%E4%BD%BF%E7%94%A8%20Springer%20%E6%A0%BC%E5%BC%8F%E5%B0%86%E6%AF%8F%E8%A1%8C%E7%9A%84%E8%A1%8C%E5%8F%B7%E6%B7%BB%E5%8A%A0%E5%88%B0%E7%AE%97%E6%B3%95%E4%B8%AD.png)
如何为具有 Springer 格式的算法的每一行添加行号?
例如:
Algorithm 1 algooo
Input: X=
答案1
我的问题的答案是,只需删除
\usepackage{algorithm}
\usepackage[algo2e]{algorithm2e}
并使用:
\usepackage[ruled,linesnumbered]{algorithm2e}
和:
\begin{algorithm}[H]
\SetAlgoLined
就是这样 :)
答案2
使用“linesnumbered”选项可以吗algorithm2e
?
例子:
\documentclass[smallextended]{svjour3} % onecolumn (second format)
\smartqed % flush right qed marks, e.g. at end of proof
\usepackage{algorithm}
\usepackage[algo2e,linesnumbered]{algorithm2e}
\begin{document}
\section{CH Algorithm}
\begin{algorithm} [H]
\KwIn{X= {$y_1$,…,$y_\beta$}:1-D data, $\beta$: size, $\epsilon$: the VAR }
\KwOut{$F$: BINARY}
\BlankLine
\emph{$\Phi$ $\leftarrow$ FUNC(X)}\;
\Case {$\Phi$ in \{1, 2, 3, 4, 5,5,6,7\}} {
\emph{F $\leftarrow$ Call FUNC Algorithm($\Phi$, X, $\beta$,$\epsilon$ )}
// $\Phi$ denotes NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
}
\emph{return $F$} \;
\caption{algooo }
\label{alg1}
\end{algorithm}
\end{document}