Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: algorithm2e前后缺少空隙 #494

Closed
YDX-2147483647 opened this issue May 8, 2024 · 2 comments · Fixed by #510
Closed

[Bug]: algorithm2e前后缺少空隙 #494

YDX-2147483647 opened this issue May 8, 2024 · 2 comments · Fixed by #510
Assignees
Labels
🚀 enhancement New feature or request

Comments

@YDX-2147483647
Copy link
Collaborator

YDX-2147483647 commented May 8, 2024

发生了什么?

algorithm2e 提供的algorithm环境前后的空隙太少,几乎紧贴。

(转发同学私聊消息)

你期望的结果

类推图表的空隙。

问题复现的步骤(或者截图)

编辑undergraduate-thesis,导言区加

\usepackage[ruled, algochapter]{algorithm2e}

正文加

在这里添加第二章、第三章……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 文件的引用

图片

操作系统或平台

None

LaTeX 发行版以及发行年份

No response

BIThesis 模板

No response

日志信息(可选)

No response

@YDX-2147483647
Copy link
Collaborator Author

YDX-2147483647 commented May 8, 2024

我这几天估计没办法修,不过提供以下两种解决方案。

法1

\usepackage之后加\SetAlgoSkip{bigskip}。(不过调不了具体值)

图片

法2

前后分别加上独立成段的\vspace{1em}

参考

spacing - Space between algorithm and text - TeX - LaTeX Stack Exchange

@YDX-2147483647
Copy link
Collaborator Author

看了一下宏包源代码,相关实现如下,我们设具体值只要重定义\@algoskip即可。

\newcommand{\@algoskip}{\smallskip}%
\newcommand{\SetAlgoSkip}[1]{\renewcommand{\@algoskip}{\csname#1\endcsname}}%

@YDX-2147483647 YDX-2147483647 self-assigned this May 20, 2024
@YDX-2147483647 YDX-2147483647 added the 🚀 enhancement New feature or request label May 20, 2024
YDX-2147483647 added a commit to YDX-2147483647/BIThesis that referenced this issue May 20, 2024
YDX-2147483647 added a commit to YDX-2147483647/BIThesis that referenced this issue May 20, 2024
Fixes BITNP#494

BREAKING CHANGE: 如果您使用了algorithm2e宏包,距离会从约3点增大到约12点。
github-merge-queue bot pushed a commit that referenced this issue May 22, 2024
Fixes #494

BREAKING CHANGE: 如果您使用了algorithm2e宏包,距离会从约3点增大到约12点。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🚀 enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant