I'm using the algorithm2e to display algorithms in my papers. I'm now working in a new template that uses the \documentclass[10pt,a4paper,twoside,dutch,english]{book}
preamble.
The following packages and statements are algorithm-related:
\usepackage[algoruled,vlined,linesnumbered]{algorithm2e}
\usepackage{chngcntr}
\newfloat{algorithm}{ht}{algorithm}
\floatname{algorithm}{Algorithm}
\counterwithin{algorithm}{chapter} %count algorithms within chapter
The first lines of my algorithm code is as such:
\begin{algorithm}
\setstretch{1.2}
\DontPrintSemicolon
\LinesNumbered
$\forall j\colon w_j \leftarrow 0.5$\;
$\eta \leftarrow 0.01$\;
$\mathcal{L}_{\text{mean-old}} \leftarrow \infty$\;
\Repeat{STOP}{
$\mathcal{L}_{\text{mean}} = 0$\hfill\CommentSty{~~~~~~~~~~~~~~~~~~~~~~~$\triangleright$new epoch}\;
\For{batch $i \in$ dataset}{
[...]
\end{algorithm}
When compiled, it appears as follows:
What I notice is that:
- There are no line breaks. I can solve this by adding
\\
at the end of each line, but in previous templates I did not have to do this. Removing\DontPrintSemicolon
does not help either. - The lines are not numbered, even though I used the option
linesnumbered
and I also explicitly put\LinesNumbered
in the algorithm.
Can somebody help me out here? Thanks!