我尝试将图形和表格放入算法环境中。但出现错误。
\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
在您提供的文件中MWE
,您没有包含包graphicx
,只需包含该包即可,您的MWE
工作对我来说很好,修改后的内容MWE
是:
\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}
如果仍然error
存在,请将错误代码也放上去...