4
\documentclass{article}

\usepackage{algorithm}
\usepackage{algorithmicx}
\usepackage{algpseudocode}%

\begin{document}
    
\begin{algorithm}
\State \textbf{Inputs:} 

\begin{itemize}
    \item Input 1
    \item Input 2
\end{itemize}

\For{each pixel at row, column (x,y)}
    \State Formula 1
    \State Formula 2
    \State Formula 3
    \State Formula 4
\EndFor
\end{algorithm}

\end{document}

enter image description here

I want the text to look exactly like the image here. However, the above latex file gives error "Lonely \item--perhaps a missing list environment". It still compiles and gives the correct output, but the error keeps popping up.

The other answer I found on StackExchange either have no text bullet, or all text bullet.

How can I put itemize inside algorithm like this?

1 Answer 1

3

algorithm just provide the algorithm float. You need an algorithmic environment to set the algorithm:

enter image description here

\documentclass{article}

\usepackage{algorithm}
\usepackage{algpseudocode}%

\begin{document}

\begin{algorithm}
  \begin{algorithmic}[0]
    \State \textbf{Inputs:} 

    \begin{itemize}
      \item Input 1
      \item Input 2
    \end{itemize}

    \For{each pixel at row, column $(x,y)$}
      \State Formula 1
      \State Formula 2
      \State Formula 3
      \State Formula 4
    \EndFor
  \end{algorithmic}
\end{algorithm}

\end{document}
3
  • It still gives "Missing \endcsname inserted" at line "Inputs" and "For{...}"
    – Duke Le
    Commented Dec 25, 2020 at 6:17
  • Nevermind. The problem was using both "algorithmic" and "algpseudocode" packages. It works now, thanks!
    – Duke Le
    Commented Dec 25, 2020 at 6:26
  • @DukeLe: True. algpseudocode is what you actually need from algorithmicx since it includes all the necessary components for use within the algorithmic environment.
    – Werner
    Commented Dec 25, 2020 at 16:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .