我正在尝试用 LaTeX 为minimal
文档类编写一个算法。不幸的是,缩进完全缺失。以下是我的示例代码:
\documentclass{minimal}
\usepackage{algorithm2e}
\usepackage{algorithmic}
\usepackage{pslatex}
\special{papersize=36in,24in}
\setlength{\paperwidth}{36in}
\setlength{\paperheight}{24in}
\topskip0pt
\begin{document}
\begin{algorithm}
\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\;
}
}
\end{algorithm}
\end{document}
这是当前使用文档类显示的方式 - minimal
:
希望它显示如下:
我该如何解决?
答案1
文档minimal
类是问题所在,因为两个重要的长度没有正确更新。它们是\skiptext
和\skiprule
。将它们设置为默认值:
\setlength{\skiptext}{10pt}
\setlength{\skiprule}{5pt}
恢复对齐。其他内容可能也需要更新,所有这些都表明minimal
一般不使用。article
也可以正常工作。
\documentclass{minimal}
\usepackage{algorithm2e}% http://ctan.org/pkg/algorithm2e
\setlength{\skiptext}{10pt}
\setlength{\skiprule}{5pt}
\begin{document}
\begin{algorithm}
\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\;
}
}
\end{algorithm}
\end{document}