这是我的乳胶代码:
\documentclass[a4paper]{article}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage{algorithm}
\usepackage[noend]{algpseudocode}
\title{Euclid's Algorithm: An example of how to write algorithms in \LaTeX{}}
\author{write\LaTeX{}}
\date{\today}
\begin{document}
\maketitle
\section{Notations,Definitions and Symbols}
\begin{itemize}
{
\item $n$ is the number of vertice in a input graph $G$.
\item $S$ repersents implicit stack of size $n$.
\item $S'_{1}$ and $S'_{2}$ are the top two segments of stack $S$
\item $S'$ is explicit stack that contain $S'_1$ and $S'_2$, where size of both is $\Theta(\frac{n}{\ log n})$ many entries.
\item $D$ is a hash table.
\item $T$ is a trailer stack.
}
\end{itemize}
\section{Example Algorithm}
Algorithms can be included using the commands as shown in algorithm \ref{alg:euclid}.
\begin{algorithm}
\caption{DFS}\label{alg:dfs}
\begin{algorithmic}[1]
\For{\texttt{i:=1 to n}}
\State \texttt{color[i]:= white }
\EndFor
\STATE <Create a stack $S'$>
\end{algorithmic}
\end{algorithm}
\end{document}
我明白了,为什么\STATE <Create a stack $S'$>
不工作。
答案1
我认为这与此引发的错误有关Undefined control sequence
。之所以会这样,是因为\STATE
这里没有定义控制序列。但是\State
您使用的命令是,所以请使用它。