![Latex 中更紧凑的算法模板](https://linux22.com/image/269179/Latex%20%E4%B8%AD%E6%9B%B4%E7%B4%A7%E5%87%91%E7%9A%84%E7%AE%97%E6%B3%95%E6%A8%A1%E6%9D%BF.png)
全部,
我正在使用以下算法模板:
\usepackage{algorithmicx}
\usepackage[ruled]{algorithm}
\usepackage{algpseudocode}
\vspace{-0.2cm}%
\alglanguage{pseudocode}
\begin{algorithm}[h]
\small
\caption{Delete item from Hash Table (with mCBF and aCBF)}
\label{Algorithm:delete_mCBF_aCBF}
\begin{algorithmic}[1]
\Procedure{$\mathbf{DeleteItem}$}{item $x$}
\LineComment{\emph{Quick check if $x$ is in mCBF}}
\For {$i = 1 \to k$}
\If {$mCBF.C_{f_i(x)\%N}$ == 0}
\State \textbf{return}
\EndIf
\EndFor
\LineComment{\emph{Look up $x$ in $aCBF_1\cdot\cdot\cdot aCBF_k$}}
\For {$i = 1 \to k$}
\If {\textbf{CBF\_query}($aCBF_i$, $x$) == \textbf{TRUE}}
\State $j \gets C_{f_i(x)\%N}$
\For {item $y \in B_j$}
\If {$y.key == x$}
\Comment \emph{found}
\State \emph{remove $y$ from hash table}
\EndIf
\EndFor
\EndIf
\EndFor
\EndProcedure
\Statex
\end{algorithmic}
\vspace{-0.4cm}%
\end{algorithm}
我得到了这个:
end if
但是和的行数太多了end for
。有没有不包含这些行的更紧凑的算法模板?
答案1
该软件包algpseudocode
提供了一些选项。其中一个选项是noend
。因此您可以加载:
\usepackage[noend]{algpseudocode}
结果是: