# Undefined Control Sequence in Overleaft Template for IEEE Transactions

I'm writing an article for IEEE transactions using overleaf. I'm using algorithm and algorithmic to create a algorithm in my template, but the UNDEFINED CONTROL SEQUENCE error appears. Below the code:

\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}


Someone knows how to fix it?

• Welcome to TEX.SE. Where is into the preamble \documentclass[...]{...}? – Sebastiano Dec 11 '17 at 10:56
• your example is missing the \documentclass line so we can not run it, and you haven't shown the error messge that says which command is undefined so it is hard to help – David Carlisle Dec 11 '17 at 10:56
• @Sebastiano I edited the post. – IAGO SESTREM Ochoa Dec 11 '17 at 11:00
• Use capital letters for \STATE, \FOR, and \ENDFOR. – Ilbant Dec 11 '17 at 11:05
• Thanks. Have you resolved with the help of @Ilbant? – Sebastiano Dec 11 '17 at 11:09

Compile with pdflatex and run it. Many thanks to @Ilbant and @DavidCarslie for your precious helps.

\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}

• why [latin1] ? (there is no non ascii input so inputenc isn't required at all but if you do use it, for new documents utf8 should usually be preferred to latin1.) – David Carlisle Dec 11 '17 at 11:58
• You're right but with \usepackage[utf8]{inputenc} and Papeeria I have several errors: for example LaTeX Error: \caption outside float. [ \caption]. – Sebastiano Dec 11 '17 at 11:59
• You will get that error if you use a caption outside of a float.changing the input encoding will not change an error message about the position of \caption – David Carlisle Dec 11 '17 at 12:55
• @DavidCarlisle Do! Thanks a lot for your suggestion. I have changed my code. – Sebastiano Dec 11 '17 at 20:17