Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions buaathesis.cls
Original file line number Diff line number Diff line change
Expand Up @@ -563,8 +563,8 @@ The LaTeX template for thesis of BUAA]
\oldappendix\rmrelation
}

% 下划线
\RequirePackage{ulem}
% 保留显式下划线命令,同时避免将强调文字(如 algorithm2e 的条件)改为下划线
\RequirePackage[normalem]{ulem}

% 设置行距
\RequirePackage{setspace}
Expand Down
11 changes: 11 additions & 0 deletions tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# 算法强调样式回归样例

在仓库根目录执行:

```sh
xelatex -halt-on-error tests/algorithm-emphasis.tex
```

依赖与论文模板相同,另需安装 `algorithm2e` 宏包。
样例检查 `\emph` 是否仍选择斜体;若被 `ulem` 改成下划线,编译将报错。
生成的 PDF 中,`while` 和 `if` 的条件应为斜体且没有下划线,末尾三个显式下划线仍应显示。
41 changes: 41 additions & 0 deletions tests/algorithm-emphasis.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
% 使用 xelatex -halt-on-error tests/algorithm-emphasis.tex 编译。
\documentclass[master,openright,twoside,color,AutoFakeBold=true]{buaathesis}
\usepackage[ruled]{algorithm2e}

\begin{document}
% ulem 不应接管强调命令;算法条件也使用这一命令。
\makeatletter
\emph{%
\edef\actualshape{\f@shape}%
\def\expectedshape{it}%
\ifx\actualshape\expectedshape\else
\PackageError{algorithm-emphasis}{Emphasis no longer selects italic text}{}%
\fi
Ordinary emphasis%
}
\makeatother

\begin{algorithm}[H]
\SetAlgoLined
\KwData{this text}
\KwResult{how to write an algorithm}
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{Algorithm emphasis regression}
\end{algorithm}

% 显式下划线及封面使用的辅助命令仍须可用。
\uline{Explicit underline}

\ulinecvrtc{Student ID}

\ulinecvcbc{School}
\end{document}