0

This question already has an answer here:

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

marked as duplicate by Werner, Kurt, Phelype Oleinik, Stefan Pinnow, Tiuri Feb 4 at 17:04

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.