TransWikia.com

Itemize inside algorithm block Lonely item error

TeX - LaTeX Asked by Duke Le on March 14, 2021

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?

One Answer

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}

Correct answer by Werner on March 14, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP