BITNP / BIThesis

📖 北京理工大学非官方 LaTeX 模板集合,包含本科、研究生毕业设计模板及更多。🎉 (更多文档请访问 wiki 和 release 中的手册)
https://bithesis.bitnp.net
LaTeX Project Public License v1.3c
676 stars 100 forks source link

feat: 调整算法与文字之间的距离(针对algorithm2e宏包) #510

Closed YDX-2147483647 closed 1 month ago

YDX-2147483647 commented 2 months ago

针对algorithm2e宏包,添加misc/algorithmSeparation选项,可供调整算法与文字之间的距离。

与之前版本相比,默认间距会从约3点增大到约12点。

Fixes #494

默认值的依据

algorithm2e宏包原本的默认值相当于\smallskip,此PR的默认值相当于\bigskip

根据texdoc source2e,在 LaTeX 中,这些 skip 用\vspace实现。

\def\smallskip{\vspace\smallskipamount}
\def\bigskip{\vspace\bigskipamount}

\newskip\smallskipamount \smallskipamount=3pt plus 1pt minus 1pt
\newskip\bigskipamount \bigskipamount =12pt plus 4pt minus 4pt

其中12pt plus 4pt minus 4pt表示以12pt为基准,允许上下浮动4pt

MWE

旧版: 图片

默认: 图片

设为5em图片

\documentclass[type=bachelor]{bithesis}

\BITSetup{
  misc = {
    algorithmSeparation = {5em},
  },
}

\usepackage[ruled, algochapter]{algorithm2e}

\begin{document}

在这里添加第二章、第三章……TeX 文件的引用
在这里添加第二章、第三章……TeX 文件的引用
在这里添加第二章、第三章……TeX 文件的引用
在这里添加第二章、第三章……TeX 文件的引用
在这里添加第二章、第三章……TeX 文件的引用
在这里添加第二章、第三章……TeX 文件的引用
在这里添加第二章、第三章……TeX 文件的引用

\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}

在这里添加第二章、第三章……TeX 文件的引用
在这里添加第二章、第三章……TeX 文件的引用
在这里添加第二章、第三章……TeX 文件的引用
在这里添加第二章、第三章……TeX 文件的引用

\end{document}
YDX-2147483647 commented 2 months ago

因为没有例子,make regression-test没有区别。