1. All LaTeX macro package files must be written after the \documentclass command and before \begin{document}. In this article, we will mainly use the following two macro packages:
\usepackage{
algorithmic}
\usepackage{
algorithm}
In the process of writing a thesis, it is relatively common for students majoring in computer science to insert pseudo-codes to describe the algorithms used in the thesis. Here we first experience the effect of the pseudo-code algorithm inserted into the template, and then explain each detail of the template in detail later.
Our more general templates are as follows:
\begin{
algorithm}[!h]
\caption{
DDGAN for NIR image colorization}
\label{
alg:alg1}
\renewcommand{
\algorithmicrequire}{
\textbf{
Require:}}
\renewcommand{
\algorithmicensure}{
\textbf{
Require:}}
\begin{
algorithmic}[1]
\REQUIRE NIR image set $X$, RGB image set $Y$, the number of critic iterations per generator iteration $n_{
critic}$, batch size $m$, and the number of epoch $n_{
epoch}$. %%input
\ENSURE Generator $G$ and discriminator $D$. Randomly initialize generator parameters $\theta_G$, and discriminator parameters $\theta_D$. Generator loss $L_{
gen}$ and discriminator loss $L_{
dis}$. %%output
\FOR{
$i$=1, 2, 3, ..., $n_{
epoch}$}
\FOR {
$j$=1, 2, 3, ..., $n_{
critic}$}
\STATE Sample $m$ NIR images {
$x^{
(1)}$, ..., $x^{
(m)}$} from $X$
\STATE Sample $m$ RGB images {
$y^{
(1)}$, ..., $y^{
(m)}$} from $Y$
\STATE Obtain generated data
\STATE {
$G(x^{
(1)}),\cdots, G(x^{
(m)})$}
\STATE minimizing $L_{
dis}$
\STATE Update discriminator parameters $\theta_D$
\ENDFOR
\STATE Sample $m$ NIR images {
$\widetilde{
x}^{
(1)}$, ..., {
$\widetilde{
x}^{
(m)}$ from $X$
\STATE Sample $m$ RGB images {
$\widetilde{
y}^{
(1)}$, ..., {
$\widetilde{
y}^{
(m)}$ from $Y$
\STATE Obtain generated data
\STATE {
$G(\widetilde{
x}^{
(1)})$, ..., $G(\widetilde{
x}^{
(m)})$}
\STATE minimizing $L_{
gen}$
\STATE Update discriminator parameters $\theta_G$
\ENDFOR
\end{
algorithmic}
\end{
algorithm}
The display effect of the above template is as follows:
2. The command/ref used in the algorithm reference, if you want to call the above algorithm, you can call it like this:
As show in algorithm \ref{
alg:alg1}
3. The Latex command to set the font size from small to large is as follows:
\tiny
\scriptsize
\footnotesize
\small
\normalsize
\large
\Large
\LARGE
\huge
\Huge
In order to adjust the font size of the Latex algorithm pseudo-code, just add \tiny after \begin{algorithm}[H]. Of course, \tiny can be replaced with any of the above.