Latex 算法规则删除单个算法的最后一条规则

问题描述 投票:0回答:1

我有一个算法,我需要删除最后一条规则。

\usepackage[ruled]{algorithm}                  % Use the package to make algorithms
\usepackage[noend]{algpseudocode} 
\documentclass[a4paper,10pt,twoside]{report}

\begin{document}
\begin{algorithm}[H]
\caption{\protect \Call{spawn} implementation}
\label{alg:spawn}
\centering
\begin{algorithmic}[1]
\Function{spawn}{task}
\State{\Call{push}(task)}
\EndFunction
\end{algorithmic}
\end{algorithm}
\end{document

这会在第二条线之后生成一条水平线。如何仅针对这个单一算法删除这一行?

algorithm example

编辑:我希望这样,因为我有一些算法堆叠在小页面中,并分成两列,删除最后一行使其更加整洁。见下图。 enter image description here

latex
1个回答
0
投票

您可以暂时重新定义

\fs@ruled
:

\documentclass[a4paper,10pt,twoside]{report}
\usepackage[ruled]{algorithm}                  % Use the package to make algorithms
\usepackage[noend]{algpseudocode} 


\begin{document}
{
\makeatletter
\renewcommand\fs@ruled{\def\@fs@cfont{\bfseries}\let\@fs@capt\floatc@ruled
  \def\@fs@pre{\hrule height.8pt depth0pt \kern2pt}%
  \def\@fs@post{}%
  \def\@fs@mid{\kern2pt\hrule\kern2pt}%
  \let\@fs@iftopcapt\iftrue}
\makeatother
\begin{algorithm}[H]
\caption{\protect \Call{spawn} implementation}
\label{alg:spawn}
\centering
\begin{algorithmic}[1]
\Function{spawn}{task}
\State{\Call{push}(task)}
\EndFunction
\end{algorithmic}
\end{algorithm}
}
\begin{algorithm}[H]
\caption{\protect \Call{spawn} implementation}
\label{alg:spawn}
\centering
\begin{algorithmic}[1]
\Function{spawn}{task}
\State{\Call{push}(task)}
\EndFunction
\end{algorithmic}
\end{algorithm}
\end{document}

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.