我使用algorithm2e
包时通常不会遇到任何问题,通常使用“article”或其他文档类。但使用acmart
( sigconf
) 或 elsevier 的elsarticle
样式时,我遇到了以下缩进问题。我无法确定原因。
\documentclass[sigconf]{acmart}
\usepackage[linesnumbered]{algorithm2e}
\floatstyle{boxed}
\newfloat{algo}{h}{loa}
\floatname{algo}{{\textnormal{Algo}}}
\begin{document}
\begin{algo}
\SetAlgoLined
\SetAlgoNoEnd
\DontPrintSemicolon
\KwIn{triangular set $T=(p(x)^e)$}
\KwOut{Monic polynomial $h=y^k + h_{k-1} y^{k-1} +\cdots+ h_0$ in the Weierstrass factorization theorem}
$ (u p^e + v f_k=1) \leftarrow $ Extended Euclidean Algorithm of $p^e$ and $f_k$ in $k[x]$\;
$f_k^{-1} \leftarrow v$\; \tcp*[f]{inverse of $f_k$ modulo $p^e$}
$y^k = f g + r \leftarrow$ Division of $y^k$ by $f$ following Corollary~1 (using $v$), up to precision $O(y^{k+1})$\;
\Return{$y^k -r$}
\end{algo}
\end{document}
答案1
你定义algo
为表示你的算法(作为一个带框的浮点数),但它与algorithm2e
以及它提供的格式。相反,请使用提供的功能algorithm2e
并使用适当的浮点名称 - algorithm
:
\documentclass[sigconf]{acmart}
\usepackage[linesnumbered,boxed]{algorithm2e}
\SetAlgorithmName{Algo}{Algo}{List of Algos}
\renewcommand{\AlCapFnt}{\normalfont}
\begin{document}
\begin{algorithm}
\caption{A caption}
\SetAlgoLined
\SetAlgoNoEnd
\DontPrintSemicolon
\KwIn{triangular set $T = (p(x)^e)$}
\KwOut{Monic polynomial $h = y^k + h_{k - 1} y^{k - 1} + \dots + h_0$ in the Weierstrass factorization theorem}
$ (u p^e + v f_k = 1) \leftarrow $ Extended Euclidean Algorithm of $p^e$ and $f_k$ in $k[x]$\;
$f_k^{-1} \leftarrow v$ \tcp*[f]{inverse of $f_k$ modulo $p^e$}\;
$y^k = f g + r \leftarrow$ Division of $y^k$ by $f$ following Corollary~1 (using $v$), up to precision $O(y^{k + 1})$\;
\Return{$y^k - r$}
\end{algorithm}
\end{document}