1

I am trying to put figure inside the algorithm environment and also a table. But getting error.

\documentclass[a4paper]{article}

\usepackage[margin=1.5in]{geometry}    % For margin alignment
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage{algorithm}
 \usepackage{arevmath}     % For math symbols
 \usepackage[noend]{algpseudocode}

 \title{Algorithm template}
 \author{Moody}

 \date{\today}    % Today's date

 \begin{document}
 \maketitle
 \section{Demo code}

\begin{algorithm}
    \caption{Put your caption here}
    \begin{algorithmic}[1]

        \Procedure{Tom}{$a,b$}       \Comment{This is a test}
        \State System Initialization
        \State Read the value 
        \If{$condition = True$}
        \State Do this
        \If{$Condition \geq 1$}
        \State Do that
        \ElsIf{$Condition \neq 5$}
        \State Do another
        \State Do that as well
        \Else
        \State \includegraphics[scale=1.5]{lion.jpg}

        \EndIf
        \EndIf

        \While{$something \not= 0$}  \Comment{put some comments here}
        \State $var1 \leftarrow var2$  \Comment{another comment}
        \State $var3 \leftarrow var4$
        \EndWhile  \label{roy's loop}
        \EndProcedure

    \end{algorithmic}
 \end{algorithm}

\end{document}
1
  • What error message do you get?
    – egreg
    May 13, 2020 at 12:06

1 Answer 1

1

In your provided MWE, you didn't include the package graphicx, just include that package your MWE works fine for me, and the modified MWE is:

\documentclass[a4paper]{article}

\usepackage[margin=1.5in]{geometry}    % For margin alignment
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage{algorithm}
 \usepackage{arevmath}     % For math symbols
 \usepackage[noend]{algpseudocode}
\usepackage{graphicx}

If still the error exists, then please place the error code too...

You must log in to answer this question.

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