Skip to content

Commit 80faeec

Browse files
committed
change algorithm package to algorithm2e (more customizable, modern)
1 parent 0ae7b44 commit 80faeec

File tree

3 files changed

+34
-24
lines changed

3 files changed

+34
-24
lines changed

chap2/background_and_lit_overview_main.tex

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -366,27 +366,32 @@ \section{A Listing Example}
366366

367367
\section{An Algorithm Example}
368368

369-
\begin{algorithm}
370-
\caption{An algorithm with caption}\label{alg:cap}
371-
\begin{algorithmic}
372-
\Require $n \geq 0$
373-
\Ensure $y = x^n$
374-
\State $y \gets 1$
375-
\State $X \gets x$
376-
\State $N \gets n$
377-
\While{$N \neq 0$}
378-
\If{$N$ is even}
379-
\State $X \gets X \times X$
380-
\State $N \gets \frac{N}{2}$ \Comment{This is a comment}
381-
\ElsIf{$N$ is odd}
382-
\State $y \gets y \times X$
383-
\State $N \gets N - 1$
384-
\EndIf
385-
\EndWhile
386-
\end{algorithmic}
369+
370+
%% This is needed if you want to add comments in
371+
%% your algorithm with \Comment
372+
\SetKwComment{Comment}{/* }{ */}
373+
374+
\begin{algorithm}[hbt!]
375+
\caption{An algorithm with caption}\label{alg:example}
376+
\KwData{$n \geq 0$}
377+
\KwResult{$y = x^n$}
378+
$y \gets 1$\;
379+
$X \gets x$\;
380+
$N \gets n$\;
381+
\While{$N \neq 0$}{
382+
\eIf{$N$ is even}{
383+
$X \gets X \times X$\;
384+
$N \gets \frac{N}{2} $ \Comment*[r]{This is a comment}
385+
}{\If{$N$ is odd}{
386+
$y \gets y \times X$\;
387+
$N \gets N - 1$\;
388+
}
389+
}
390+
}
387391
\end{algorithm}
388392

389-
\blindtext
393+
An algorithm example is shown in Algorithm~\ref{alg:example}. \blindtext
394+
390395

391396
\section{Some Technique One}
392397
\index{Some Technique One|(}
@@ -426,15 +431,19 @@ \section{Related Work}
426431

427432
\section{An Example of Suppressing Page Numbers on A Float Page}
428433

429-
Kindly refer to Figure~\ref{fig:largegoku}.
434+
Kindly refer to Figure~\ref{fig:largegoku}.
435+
436+
\blindtext
430437

431438
\begin{figure}[!ht]
432439
\thisfloatpagestyle{empty} %% This is the key line to suppress page decorations (including nos.) on float pages.
433440
\centering
434441
\includegraphics[width=0.9\textwidth]{goku-large}
435-
\caption[Short Random Caption]{\blindtext}
442+
\caption[Short Random Caption]{Page numbers are suppressed on this page.}
436443
\label{fig:largegoku}
437444
\end{figure}
438445

439-
\section{Summary}
440446
\blindtext
447+
448+
\section{Summary}
449+
\blindtext[3]

dissertation_main.pdf

4.79 KB
Binary file not shown.

um.cls

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,9 @@
4343
\RequirePackage{listings} % For code listings
4444
\usepackage[width=.95\textwidth]{caption} % set the width of the captions
4545

46-
\RequirePackage{algorithm}
47-
\RequirePackage{algpseudocode}
46+
\RequirePackage[ruled]{algorithm2e} % use algorithm2e instead of algorithm only, as the former is more customizable
47+
%%\RequirePackage{algpseudocode} % do not include this, as algorithm2e will include this as well
48+
4849
\RequirePackage{courier}
4950

5051
\usepackage[defaultsans]{lato} % Sans font to use

0 commit comments

Comments
 (0)