[Tex/LaTex] How to put itemize inside algorithm

algorithmicxalgorithmslists

I want describe an algorithm, and that's why I wanted to use the algorithm package, but the algorithm that I define does not involve of pseudocode. Instead it has more steps and math formulas, so I want to describe it as stages using itemize, and write normal text and some math equations inside the algorithm. I started with something like this, assuming it is valid, but it gives errors.

\documentclass[a4paper]{paper}

\usepackage{algorithm}
\usepackage{algpseudocode}

\begin{document}

\begin{algorithm}
    \caption{MyAlgo}
    \begin{algorithmic}
        \begin{itemize}
            \item \textbf{Parameters:} $n, t \in \mathbb{N}$, where $t < n$.
        \end{itemize}
    \end{algorithmic}
\end{algorithm}

\end{document}

Any ideas how can I add itemize, and some math stuff inside an algorithm?

Best Answer

algorithmic is actually a list, so I'd suggest one of two options. First, use the functionality of algorithmicx by setting your "stage headings" manually:

enter image description here

\documentclass{article}

\usepackage{amsfonts}
\usepackage{algorithm,algpseudocode}

\begin{document}

\begin{algorithm}
  \caption{MyAlgo}
  \begin{algorithmic}[1]
    \Statex \textbullet~\textbf{Parameters:} $n, t \in \mathbb{N}$, where $t < n$.
    \State First step
    \State Second step
    \State \ldots
  \end{algorithmic}
\end{algorithm}

\end{document}

You don't have to number the lines. I just used \begin{algorithmic}[1] to do so.

Second, remove the algorithmic environment altogether:

enter image description here

\documentclass{article}

\usepackage{amsfonts}
\usepackage{algorithm}

\begin{document}

\begin{algorithm}
  \caption{MyAlgo}
  \begin{itemize}
    \item \textbf{Parameters:} $n, t \in \mathbb{N}$, where $t < n$.
    \item First step
    \item Second step
    \item \ldots
  \end{itemize}
\end{algorithm}

\end{document}

Note, not algpseudocode required in the second option.

Related Question