我尝试使用该包自定义算法的行号algorithm2e
。我想从特定行或给定行开始行号。我使用以下代码示例:
\documentclass{article}
\usepackage[linesnumbered,ruled,vlined]{algorithm2e}
\begin{document}
\begin{algorithm}[!ht]
\caption{Overlapped Co-Clustering}
\DontPrintSemicolon
\SetNoFillComment
\footnotesize
\SetKwInOut{Input}{Input}
\SetKwInOut{Output}{Output}
\SetKwFunction{OCoClus}{OCoClus}
\Input{Input dataset D, Max number of co-clusters K \textit{\{optional\}}, Max object noise threshold $\epsilon_I$ \textit{\{optional\}}, Max attribute noise threshold $\epsilon_J$ \textit{\{optional\}}}
\Output{Set of disjoint and overlapped co-clusters $\Phi$}
\OCoClus{D,K,$\epsilon_I$,$\epsilon_J$}\;
$\prod \leftarrow \emptyset$\;
$D_{r} \leftarrow D$ \textit{\{residual matrix\}}
\end{algorithm}
\end{document}
它生成以下输出:
我希望第二行(行号 2)以 1 开头,而第一行(行号 1)不编号。我没有找到方法来实现这一点。
答案1
以下代码介绍了如何删除该行的行号机制\nlnonumber
功能。将其放置在行首。\nl
l
n
\documentclass{article}
\usepackage[linesnumbered,ruled]{algorithm2e}
\SetKwInOut{Input}{Input}
\SetKwInOut{Output}{Output}
\SetKwFunction{OCoClus}{OCoClus}
\DontPrintSemicolon
\SetNoFillComment
\let\oldnl\nl
\newcommand{\nlnonumber}{\renewcommand{\nl}{\let\nl\oldnl}}
\begin{document}
\begin{algorithm}
\caption{Overlapped Co-Clustering}
\Input{%
Input dataset $D$,
Max number of co-clusters $K$ \textit{\{optional\}},
Max object noise threshold $\epsilon_I$ \textit{\{optional\}},
Max attribute noise threshold $\epsilon_J$ \textit{\{optional\}}}
\Output{Set of disjoint and overlapped co-clusters $\Phi$}
\nlnonumber
\OCoClus{$D$, $K$, $\epsilon_I$, $\epsilon_J$}\;
$\prod \leftarrow \emptyset$\;
$D_r \leftarrow D$ \textit{\{residual matrix\}}
\end{algorithm}
\end{document}