I was using algorithmic and algorithm to write algorithm:

\renewcommand{\algorithmicrequire}{\textbf{Input: }}
\renewcommand{\algorithmicensure}{\textbf{Output: }}

and now I need to use algorithmicx instead of algorithmic, in order to use \algstore{myalg}. Since my algorithm is too long to fit in one page.


After I compiled the Tex file, I got the following error:

! Undefined control sequence.
l.219 \REQUIRE

SO how to resolve the issue?



1 Answer 1


Consider using \Require instead of \REQUIRE. LaTeX is case-sensitive. Here's a small example with \Require which I made for my next LaTeX book, as a demo showing several features.

\newcommand{\Let}[2]{\State $ \minbox{1em}{#1} \gets #2 $}
\algnewcommand{\Local}{\State\textbf{local variables: }}
  \caption{Mandelbrot set}
    \Require{$c_x, c_y, \Sigma_{\max} \in \mathds{R},
      \quad i \in \mathds{N}, \quad i_{\max} > 0,
      \quad \Sigma_{\max} > 0$}
    \Function{mandelbrot}{$c_x, c_y, i_{\max},
      \Local{$x, y, x^\prime, y^\prime, i, \Sigma$}
      \Let{x, y, i, \Sigma}{0}
        \Comment{initial zero value for all}
      \While{$\Sigma \leq \Sigma_{\max}$
             and $i < i_{\max}$}
        \Let{x^\prime}{x^2 - y^2 + c_x}
        \Let{y^\prime}{2xy + c_y}
        \Let{\Sigma}{x^2 + y^2}
      \If{$i < i_{\max}$}
        \State \Return{$i$}


For completeness, in the LaTeX-Community forum the question was posted in this thread: "How to continue displaying an algorithm if it is too long".

  • The code works great. I have 2 questions. 1. How to reference the line numbers in the algorithm, e.g. make a \label command just like in figure? 2. How to not showing the end if, 'end for' etc. They takes a lot lines seems to be unnecessary.
    – daiyue
    Aug 16, 2015 at 11:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .