我正在使用 overleaf 为 IEEE 交易撰写一篇文章。我使用 algorithm 和 algorithmic 在我的模板中创建算法,但UNDEFINED CONTROL SEQUENCE
出现错误。代码如下:
\documentclass[conference]{IEEEtran}
\usepackage[cmex10]{amsmath}
\usepackage{mathabx}
\usepackage{algorithm}
\usepackage{algorithmic}
\usepackage{array}
\usepackage{mdwmath}
\usepackage{mdwtab}
\usepackage{eqparbox}
\usepackage{url}
\begin{document}
\begin{algorithm}
\caption{Basic Algorithm}\label{basic}
\begin{algorithmic}
\for{i = 1 : nBytes}
\State $dataEBC = aes_encrypt_function(data(i),key)$
\State $modSignal = step (hMod, dataEBC)$
\State $noisySignal = step(hAWGN, modSignal)$
\State $receivedData = step(hDemod, noisySignal)$
\State $statedec(i) = aes_decrypt_function(receivedData, key)$
\EndFor
\end{algorithmic}
\end{algorithm}
\end{document}
有人知道怎样修复它吗?
答案1
编译pdflatex
并运行。非常感谢@Ilbant 和@DavidCarslie 的宝贵帮助。
\documentclass[conference]{IEEEtran}
\usepackage[cmex10]{amsmath}
\usepackage{mathabx}
\usepackage{algorithm}
\usepackage{algorithmic}
\usepackage{array}
\usepackage{mdwmath}
\usepackage{mdwtab}
\usepackage{eqparbox}
\usepackage{url}
\usepackage[utf8]{inputenc}
\begin{document}
\begin{algorithm}
\begin{algorithmic}[1]
\caption{Basic Algorithm}\label{basic}
\FOR{i = 1 : nBytes}
\STATE $dataEBC = aes_encrypt_function(data(i),key)$
\STATE $modSignal = step (hMod, dataEBC)$
\STATE $noisySignal = step(hAWGN, modSignal)$
\STATE $receivedData = step(hDemod, noisySignal)$
\STATE $statedec(i) = aes_decrypt_function(receivedData, key)$
\ENDFOR
\end{algorithmic}
\end{algorithm}
\end{document}