[Tex/LaTex] Insert Pseudo-Code as Figure

articlemiktexpseudocodetable of contentstexmaker

this is my first post on tex.stackexchange, so please forgive any violations on proper question-asking.

I'm currently writting a thesis about a project that contains a lot of coding. I would like to add the most important (and "genius") parts of the code as pseudo-code into the thesis and would like to have them listed in my regular \listoffigures, ideally with a hint that those are pseudo-code pieces.

What I intend is something similar to this:

List Of Figures

  1. someNormalFigure
  2. anotherNormalFigure
  3. beautifulAlgorithm (PseudoCode)

The name of the pseudo-code piece should be "beautifulAlgorithm" and not "beautifulAlgorithm (PseudoCode)".

I'm using TexMaker, MikTex and the article environment. (just in case this in necessary or useful information to anyone)

Best Answer

The pseudo code is taken from somewhere else on this side. As you have not given an MWE, I had to guess something. The package caption helps you by imitating captions from other environments. The default behaviour (layout) of the pseudo code is not changed (at least not in my example).

% arara: pdflatex
% arara: pdflatex

\documentclass{article}
\usepackage{amsmath}
\usepackage{algorithm}
\usepackage[noend]{algpseudocode}
\usepackage{caption}


\begin{document}
\listoffigures
\begin{figure}[h] % [h] just to get it behind the list of figures.
    \centering
    \rule{3cm}{2cm}
    \caption{1. Figure}
\end{figure}
\begin{algorithm}
    \captionof{figure}[beautifulAlgorithm (PseudoCode)]{beautifulAlgorithm}
    \begin{algorithmic}[1]
            \Procedure{MyProcedure}{}
            \State $\textit{stringlen} \gets \text{length of }\textit{string}$
            \State $i \gets \textit{patlen}$
            \If {$i > \textit{stringlen}$} \Return false
            \EndIf
            \State $j \gets \textit{patlen}$
            \If {$\textit{string}(i) = \textit{path}(j)$}
            \State $j \gets j-1$.
            \State $i \gets i-1$.
            \State \textbf{goto} \emph{loop}.
            \State \textbf{close};
            \EndIf
            \State $i \gets i+\max(\textit{delta}_1(\textit{string}(i)),\textit{delta}_2(j))$.
            \State \textbf{goto} \emph{top}.
            \EndProcedure
    \end{algorithmic}
\end{algorithm}
\begin{figure}
    \centering
    \rule{3cm}{2cm}
    \caption{2. Figure}
\end{figure}
\end{document} 

enter image description here