![算法以图形表示(在图形下方包含附加标题)](https://linux22.com/image/270928/%E7%AE%97%E6%B3%95%E4%BB%A5%E5%9B%BE%E5%BD%A2%E8%A1%A8%E7%A4%BA%EF%BC%88%E5%9C%A8%E5%9B%BE%E5%BD%A2%E4%B8%8B%E6%96%B9%E5%8C%85%E5%90%AB%E9%99%84%E5%8A%A0%E6%A0%87%E9%A2%98%EF%BC%89.png)
我在乳胶中有一个算法,我需要在算法下方添加一个附加标题(就像在底部的图中一样:“图 1:无论它是什么”。我尝试简单地将更改为\begin{algorithm}
,\begin{figure}
这确实在算法下方放置了一个标题,但是,这也会改变算法的布局,我不希望发生这种情况。可以保持相同的布局,但以某种方式添加额外的标题,就像在中一样figure
?
这是我的代码:
\begin{algorithm}[t]
\caption{Ant Colony Algorithm}
\label{ACA}
\begin{algorithmic}
\STATE Set parameters, initialize pheromone trails
\WHILE{stopping condition not met}
\STATE construct ant paths
\STATE local search (optional)
\STATE update pheromone
\ENDWHILE
\STATE \textbf{output:} the ACO solution path
\end{algorithmic}
\end{algorithm}
答案1
浮点数algorithm
采用了ruled
float包的样式,并且这个样式是可以改变的。
\documentclass{article}
\usepackage{algorithm,algorithmic}
\makeatletter
\renewcommand\fs@ruled{%
\def\@fs@cfont{\rmfamily}%
\let\@fs@capt\floatc@plain%
\def\@fs@pre{\hrule height.8pt depth0pt \kern2pt}%% or use \def\@fs@pre{} to get rid of the top rule
\def\@fs@post{\kern2pt\hrule\relax}%% or use \def\@fs@post{} to get rid of the last rule
\def\@fs@mid{\kern2pt\hrule\kern2pt}%% or use \def\@fs@mid{} to get rid of the middle rule
\let\@fs@iftopcapt\iffalse}
\makeatother
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\begin{algorithm}[t]
\caption{Ant Colony Algorithm}
\label{ACA}
\begin{algorithmic}
\STATE Set parameters, initialize pheromone trails
\WHILE{stopping condition not met}
\STATE construct ant paths
\STATE local search (optional)
\STATE update pheromone
\ENDWHILE
\STATE \textbf{output:} the ACO solution path
\end{algorithmic}
\end{algorithm}
For reference:
\begin{table}[hb]
\caption{Table caption}
\end{table}
\end{document}
如果您想删除标题下方的最后一行(对我来说这样更好),请\def\@fs@post{}
按照代码中所示使用。同样,如果您愿意,您可以删除任何规则。