TeX use algorithm
tex
# for texlive 2017
$ tlmgr option repository ftp://tug.org/historic/systems/texlive/2017/tlnet-final && \
$ tlmgr install algorithms
\usepackage{algorithm,algorithmic}
example
\begin{algorithm}[H]
\caption{配列から最大値を求める関数}
\label{alg-max-from-array}
\begin{algorithmic}[1]
\Function{max\_in\_array}{$array$}
\State $max \gets 0$
\ForAll {$element \gets array$}
\If {$element > max$}
\State $max \gets element$
\EndIf
\EndFor
\State \Return $max$
\EndFunction
\end{algorithmic}
\end{algorithm}
\ref{alg-max-from-array} です