Search code examples
latex

Missing $ in LaTeX and other errors


I'm having these errors: Undefined control sequence (with the \BlankLine),Missing $ in all the raws I use it and also a Missing } inserted Missing { inserted in the List1 and List2 line.

\begin{algorithm}[b]
\caption{Find aa}
\BlankLine
$a$ \leftarrow input \;
\newline
$List1$ \leftarrow x$_$x$_$x$_$x(a,a)
\newline
$List2$ \leftarrow x$_$x$_$x$_$x(a,List1,List2)
\newline
$H$ \leftarrow a(a,a,a,a)
\newline
\newline
\newline
\Return $x$\;
\end{algorithm}

These are the packages I have used

\usepackage{moreverb}
\usepackage{graphicx}
\usepackage{ifthen}
\usepackage{amsmath,amsfonts}
\usepackage{algorithm}
\usepackage{algorithmic}


Solution

    • \leftarrow is a math command which cannot be used outside of math mode

    • The syntax \BlankLine is from the algorithm2e package


    \documentclass{article}
    
    \usepackage{algorithm2e}
    
    \begin{document}
    
    \begin{algorithm}
    \caption{Find aa}
    \BlankLine
    $a$ $\leftarrow$ input \;
    \end{algorithm}
    
    \end{document}