1. 添加注释(评论)

2. 在同一个代码块中写多个伪代码

2.1 解释:

我们这里使用的是一个bundle叫algorithms, 官方网址在这里. 它包含两个包 algorithmsalgorithmic.

2.2 实现

2.3 参考

https://tex.stackexchange.com/questions/697409;
https://ctan.org/pkg/float;

3. 伪代码中表达函数的输入输出

我们在这里只介绍algorithm的环境.

3.1 algorithm 环境

一般这里用的是Require, Ensure. 如下面的代码

\documentclass{article}
\usepackage{algorithm}
\usepackage{algpseudocode}
\begin{document}

\begin{algorithm}
    \caption{Test}\label{Test}
    \begin{algorithmic}[1]
    	\Require a, b 
    	\Ensure a \par
    	\State return a;
    \end{algorithmic}
\end{algorithm}

\end{document}

但也可以使用Input, Output, 通过字体的改变, 并且取消编号.(环境同上)

\usepackage{algorithm,algpseudocode}
\begin{algorithm}
    \caption{Test}\label{Test}
    \begin{algorithmic}[1]
    	\Statex \textbf{Input:} a, b
    	\Statex \textbf{Output:} a
    	\State return a;
    \end{algorithmic}
\end{algorithm}

注意, 不能使用KwIn{}KwOut{}语句, 会判定未定义的语句. 这两个应该是在algorithm2e环境使用的.