0

There is my source code.

\documentclass[conference]{IEEEtran}
\usepackage{algorithm} 
\usepackage{algorithmic} 
%\usepackage{algpseudocode}  
\usepackage[algcompatible]{algpseudocode}
\usepackage{amsmath} 
\begin{document}
\begin{algorithm}[!b]  
    \caption{algorithm 1}  
    \label{alg}  
    \begin{algorithmic}[1]
        \Require  
        INFORMATION
        \Ensure  
        Model;
        \STATE CALCULATE
        \STATE END
        \RETURN MODEL
    \end{algorithmic}  
\end{algorithm} 
\end{document}

When I compile it, it looks like this. No matter what I modified the content, the zero is always there.

enter image description here

LC Dai
  • 15
  • 1
  • 6
  • Yes. And I know the problem is algorithmic and algpseudocode which are not compatible. But I still have no idea how to solve it. – LC Dai Apr 10 '18 at 13:49
  • Commenting on the package \usepackage{algorithmic} worked for me. Use just the packages: \usepackage{algorithm} and \usepackage{algpseudocode} – VARAT BOHARA May 19 '23 at 22:39

1 Answers1

0

You may use the algorithm2e package

\documentclass[conference]{IEEEtran}
\usepackage[ruled,linesnumbered]{algorithm2e}
\SetKwInput{Require}{Require}
\SetKwInput{Ensure}{Ensure}
\usepackage{amsmath}
\begin{document}
\begin{algorithm}[!b]
    \caption{algorithm 1}
    \label{alg}
        \SetAlgoLined
        \Require{INFORMATION}
        \Ensure{MODEL}
        CALCULATE\\
        END\\
        \Return MODEL
\end{algorithm}
\end{document}
BambOo
  • 8,801
  • 2
  • 20
  • 47
  • Thank you! It works well, but what if I wanna use \renewcommand{\algorithmicrequire}{\textbf{Input:}} \renewcommand{\algorithmicensure}{\textbf{Output:}} ? It doesn't work. – LC Dai Apr 10 '18 at 14:08
  • It's normal, since commands starting with \algorithmic are defined by the algorithmic package. Have a look at the package documentation here Section 11, p32 to see how to define your own keywords, as well as already defined commands – BambOo Apr 10 '18 at 14:13
  • I means that your solution is not compatible with the \Require and the \Ensure. Actually it works in my source code, but your solution skips it. – LC Dai Apr 10 '18 at 14:17
  • As I said, everything is in the documentation. I edited the answer accordingly – BambOo Apr 10 '18 at 14:31
  • Sorry it was totally my fault. Thank you very much! – LC Dai Apr 10 '18 at 15:10