![algorithm2e - 使最顶部和底部的水平线更粗](https://linux22.com/image/480471/algorithm2e%20-%20%E4%BD%BF%E6%9C%80%E9%A1%B6%E9%83%A8%E5%92%8C%E5%BA%95%E9%83%A8%E7%9A%84%E6%B0%B4%E5%B9%B3%E7%BA%BF%E6%9B%B4%E7%B2%97.png)
答案1
以下长度名称似乎控制规则高度:
\setlength\algoheightrule{<height>} % The upper and the lower rules
\setlength\algotitleheightrule{<height>} % The rule between a title and code
如果要恢复默认长度,请运行以下命令
\setlength\algoheightrule{\algoheightruledefault}
\setlength\algotitleheightrule{\algotitleheightruledefault}
这个例子:
\documentclass{article}
\usepackage[ruled]{algorithm2e}
\setlength\algoheightrule{2pt} % Upper and lower rules
\setlength\algotitleheightrule{1.2pt} % Rule below the title
\begin{document}
\IncMargin{1em}
\begin{algorithm}
\SetKwData{Left}{left}\SetKwData{This}{this}\SetKwData{Up}{up}
\SetKwFunction{Union}{Union}\SetKwFunction{FindCompress}{FindCompress}
\SetKwInOut{Input}{input}\SetKwInOut{Output}{output}
\Input{A bitmap $Im$ of size $w\times l$}
\Output{A partition of the bitmap}
\BlankLine
\emph{special treatment of the first line}\;
\For{$i\leftarrow 2$ \KwTo $l$}{
\emph{special treatment of the first element of line $i$}\;
\For{$j\leftarrow 2$ \KwTo $w$}{\label{forins}
\Left$\leftarrow$ \FindCompress{$Im[i,j-1]$}\;
\Up$\leftarrow$ \FindCompress{$Im[i-1,]$}\;
\This$\leftarrow$ \FindCompress{$Im[i,j]$}\;
\If(\tcp*[h]{O(\Left,\This)==1}){\Left compatible with \This}{\label{lt}
\lIf{\Left $<$ \This}{\Union{\Left,\This}}
\lElse{\Union{\This,\Left}}
}
\If(\tcp*[f]{O(\Up,\This)==1}){\Up compatible with \This}{\label{ut}
\lIf{\Up $<$ \This}{\Union{\Up,\This}}
\tcp{\This is put under \Up to keep tree as flat as possible}\label{cmt}
\lElse{\Union{\This,\Up}}\tcp*[h]{\This linked to \Up}\label{lelse}
}
}
\lForEach{element $e$ of the line $i$}{\FindCompress{p}}
}
\caption{disjoint decomposition}\label{algo_disjdecomp}
\end{algorithm}
\DecMargin{1em}
\end{document}