# Cannot write my pseudocodes in IEEE Access format?

I am trying to write an IEEE Access paper by using the template on their website. But I am having trouble writing my pseudocodes since there is no pseudocode example in their template. When I use ieeeaccess template I got error messages such as:

"Extra \endcsname. \State",

"Undefined control sequence. \doWhile",

"Missing \endcsname inserted. \State".

Also, the result does not look as it should be. For instance, all line numbers are zeros in the pseudocode. Also instead of "input" and "output", I got "require" and "ensure" after compiling the .tex file.

Am I missing some userpackage?(although I have tried many combinations still no results) Can someone please give me an example of ieeeaccess pseudocode along with the required userpackages?

\documentclass{ieeeaccess}
\usepackage{cite}
\usepackage{amsmath,amssymb,amsfonts}
\usepackage{graphicx}
\usepackage{textcomp}
\usepackage[section]{placeins}
\usepackage{algorithm}
\usepackage{algpseudocode}
\usepackage{algorithmicx}
\algdef{SE}[DOWHILE]{Do}{doWhile}{\algorithmicdo}[1]{\algorithmicwhile\ #1}%

\begin{document}
\begin{algorithm}[H]
\caption{Algorithm 1}\label{Alg-Decap}
\begin{algorithmic}[1]
\Require{$(C,S_k)$}
\Ensure{ HashSession$(1,\underbar r,C)$ or HashSession$(0,\rho,C))$ }
\State $c\leftarrow$ Decode$(\underbar c)$
\State $c.(3f)\in\mathcal{R}/q$
\State $e\leftarrow$ (Rounded$(c.(3f))$ mod 3) $\in \mathcal{R}/3$
\State $e.(1/g)\in\mathcal{R}/3$
\State $r'\leftarrow$ Lift($e.(1/g)$) $\in\mathcal{R}/q$
\State $h.r'\in\mathcal{R}/q$
\State $c'\leftarrow$ Round$(h.r')$
\State  $\underbar c'\leftarrow$ Encode$(c')$
\State $C'\leftarrow(\underbar c',$ HashConfirm$(\underbar r',\underbar h))$
\If{$C'==C$}
\State \textbf{return} HashSession$(1,\underbar r,C)$
\Else
\State \textbf{ return} HashSession$(0,\rho,C))$
\EndIf
\end{algorithmic}
\end{algorithm}
\end{document}

• First see if it will compile with the article class, hint it does not. Don't use all the pseudocode packages, they are not compatible with each other. The example compiles under the article class when I remove algorithmic – daleif Nov 5 '20 at 15:23
• Under article I also get a different error: ! LaTeX Error: Command \algorithmic already defined. Or name \end... illegal, see p.192 of the manual. which hints that this is a compatability problem between packages – daleif Nov 5 '20 at 15:26
• I believe you shouldn't load algorithmic. – campa Nov 5 '20 at 15:28
• @daleif I already wrote this paper in article format before, and I used these packages: \usepackage{algorithm} \usepackage{algpseudocode} \usepackage{algorithmicx} \algdef{SE}[DOWHILE]{Do}{doWhile}{\algorithmicdo}[1]{\algorithmicwhile\ #1}% It works without any problems with these ones in article format with no errors whatsoever. I changed the userpackages after I switched to ieeeacces format since it did not work with these ones? I tried different combinations but could not manage to fix it ? – esra Nov 5 '20 at 15:38
• @campa Even though I remove the algorithmic it still does not work:( – esra Nov 5 '20 at 15:44

You must not load both algorithmic and algpseudocode. Since you're using the latter's syntax, drop the former.

If you want Input and Output, define the infrastructure for them.

Also, don't go in and out of math mode and don't use \underbar, but \underline.

\documentclass{ieeeaccess}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{algorithm}
\usepackage{algpseudocode}

\algdef{SE}[DOWHILE]{Do}{doWhile}{\algorithmicdo}[1]{\algorithmicwhile\ #1}%
\algnewcommand\algorithmicinput{\textbf{Input:}}
\algnewcommand\algorithmicoutput{\textbf{Output:}}
\algnewcommand\Input{\item[\algorithmicinput]}
\algnewcommand\Output{\item[\algorithmicoutput]}

% no in and out of math mode!
\newcommand{\Fun}[1]{\mathrm{#1}}

\begin{document}

\begin{algorithm}[htp]

\caption{Algorithm 1}\label{Alg-Decap}

\begin{algorithmic}[1]
\Input{$(C,S_k)$}
\Output{$\Fun{HashSession}(1,\underbar r,C)$ or $\Fun{HashSession}(0,\rho,C))$}
\State $c\leftarrow \Fun{Decode}(\underbar c)$
\State $c.(3f)\in\mathcal{R}/q$
\State $e\leftarrow (\Fun{Rounded}(c.(3f))\bmod 3)\in \mathcal{R}/3$
\State $e.(1/g)\in\mathcal{R}/3$
\State $r'\leftarrow \Fun{Lift}(e.(1/g)) \in\mathcal{R}/q$
\State $h.r'\in\mathcal{R}/q$
\State $c'\leftarrow \Fun{Round}(h.r')$
\State $\underline{c}'\leftarrow \Fun{Encode}(c')$
\State $C'\leftarrow(\underline{c}', \Fun{HashConfirm}(\underline{r}',\underline{h}))$
\If{$C'==C$}
\State \textbf{return} $\Fun{HashSession}(1,\underline{r},C)$
\Else
\State \textbf{return} $\Fun{HashSession}(0,\rho,C))$
\EndIf
\end{algorithmic}

\end{algorithm}

\EOD

\end{document}