Skip to content

Commit

Permalink
Add algorithm2e module
Browse files Browse the repository at this point in the history
  • Loading branch information
SwitWu committed May 15, 2024
1 parent 94dc280 commit 1b70162
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@

+ 移除对 fontspec 的警告处理(见 https://github.com/latex3/fontspec/commit/0469638)

### 新增

+ 增加 `algorithm2e` 模块

## v2.0.1 2024-5-6

### 修改
Expand Down
19 changes: 18 additions & 1 deletion demo.tex
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
bib-resource = {ref/bachelor-refs.bib}
}
}
\whumodule{cse}
\whumodule{algorithm2e}
\begin{document}

\tableofcontents
Expand Down Expand Up @@ -168,6 +168,23 @@ \section{图表测试}
引用表~\ref{table:简单的表格}


\section{算法}

\begin{algorithm}
\caption{Simulation-optimization heuristic}\label{algorithm}
\KwData{current period $t$, initial inventory $I_{t-1}$, initial capital $B_{t-1}$, demand samples}
\KwResult{Optimal order quantity $Q^{\ast}_{t}$}
$r\leftarrow t$\;
$\Delta B^{\ast}\leftarrow -\infty$\;
\While{$\Delta B\leq \Delta B^{\ast}$ and $r\leq T$}{$Q\leftarrow\arg\max_{Q\geq 0}\Delta B^{Q}_{t,r}(I_{t-1},B_{t-1})$\;
$\Delta B\leftarrow \Delta B^{Q}_{t,r}(I_{t-1},B_{t-1})/(r-t+1)$\;
\If{$\Delta B\geq \Delta B^{\ast}$}{$Q^{\ast}\leftarrow Q$\;
$\Delta B^{\ast}\leftarrow \Delta B$\;}
$r\leftarrow r+1$\;}
\end{algorithm}

引用 \autoref{algorithm}

\section{已定义好的一些数学定理环境}


Expand Down
4 changes: 4 additions & 0 deletions module/module.algorithm2e.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
\RequirePackage[ruled,linesnumbered]{algorithm2e}
\SetAlgorithmName{算法}{算法}{算法}
\AddToHook{ env / algorithm / begin }
{ \linespread{1.2} \selectfont }
17 changes: 14 additions & 3 deletions whuthesis.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -563,16 +563,27 @@
%
% \subsection{模块设置}
%
% 模块设置用于处理不同的院系对论文格式的差异化要求,基本命令为
% 模块用于
% \begin{itemize}
% \item 处理不同的院系对论文格式的差异化要求;
% \item 加载及处理额外的功能性宏包。
% 基本命令为
% \begin{function}{\whumodule}
% \begin{whusyntax}[morekeywords={\whumodule}]
% \whumodule (*\marg{列表}*)
% \end{whusyntax}
% 此命令需在主文件导言区使用,其中 \meta{列表} 为使用的模块名列表,各模块名之间用西文逗号分隔。
% 目前支持的模块为:
% \begin{itemize}
% \item \texttt{cse}: 网络安全学院
% \item \texttt{cs}: 计算机学院
% \item 院系处理模块:
% \begin{itemize}
% \item \texttt{cse}: 网络安全学院
% \item \texttt{cs}: 计算机学院
% \end{itemize}
% \item 宏包加载模块:
% \begin{itemize}
% \item \texttt{algorithm2e}: 加载 \pkg{algorithm2e} 宏包,用于排版伪代码。
% \end{itemize}
% \end{itemize}
% \end{function}
%
Expand Down

0 comments on commit 1b70162

Please sign in to comment.