我不想使用ruled
选项,但我仍然希望我的算法的标题位于左上角。
我试过
\renewcommand{\@algocf@capt@plain}{above}
但它只会移动上面的标题,而不是左边的标题。
示例输出:
当我使用时\TitleOfAlgo
,该行算法 1已编号。
答案1
使用此ruled
选项,整个算法块上方/下方的水平规则的高度为\algoheightrule
,而标题和算法之间的规则的高度为\algotitleheightrule
。 将这些设置为0pt
会删除规则,但仍保持相同的ruled
类似格式:
\documentclass{article}
\usepackage[ruled]{algorithm2e}
\begin{document}
\begin{algorithm}[H]
\SetAlgoLined
\KwData{this text}
\KwResult{how to write algorithm with \LaTeX2e }
initialization\;
\While{not at end of this document}{
read current\;
\eIf{understand}{
go to next section\;
current section becomes this one\;
}{
go back to the beginning of current section\;
}
}
\caption{How to write algorithms}
\end{algorithm}
\setlength{\algoheightrule}{0pt}
\setlength{\algotitleheightrule}{0pt}
\begin{algorithm}[H]
\SetAlgoLined
\KwData{this text}
\KwResult{how to write algorithm with \LaTeX2e }
initialization\;
\While{not at end of this document}{
read current\;
\eIf{understand}{
go to next section\;
current section becomes this one\;
}{
go back to the beginning of current section\;
}
}
\caption{How to write algorithms}
\end{algorithm}
\end{document}