如何为具有 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}