[Tex/LaTex] why doesn’t `\;` given a new linebreak in algorithm2e

algorithm2e

Here is minimal working example:

\documentclass{article}
\usepackage[utf8]{inputenc}

\usepackage{amsmath}
\usepackage{algorithm}
\usepackage[algo2e]{algorithm2e}


\begin{document}


\newcommand{\nextnode}{\ensuremath{\text{Next}}}
\newcommand{\intree}{\ensuremath{\text{InTree}}}


\begin{algorithm}[H]
\KwData{}
\KwResult{}
asdf\;
$\nextnode[r] \leftarrow nil$\;
$\intree[r] \leftarrow true$\;
\caption{}
\end{algorithm}

\end{document}

With the output:

enter image description here

I am expecting line breaks, but it just doesn't happen.

Why?

Best Answer

You have loaded the algorithm2e package with the algo2e option. This changes the name of the environment to algorithm2e. Using that name works as expected:

Sample output

\documentclass{article}
\usepackage[utf8]{inputenc}

\usepackage{amsmath}
\usepackage{algorithm}
\usepackage[algo2e]{algorithm2e}


\begin{document}


\newcommand{\nextnode}{\ensuremath{\text{Next}}}
\newcommand{\intree}{\ensuremath{\text{InTree}}}


\begin{algorithm2e}[H]
\KwData{}
\KwResult{}
asdf\;
$\nextnode[r] \leftarrow nil$\;
$\intree[r] \leftarrow true$\;
\caption{}
\end{algorithm2e}

\end{document}