0

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: Compiled TeX output

What I notice is that:

  1. 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.
  2. 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!

1 Answer 1

1

Removing the

\newfloat{algorithm}{ht}{algorithm}
\floatname{algorithm}{Algorithm}
\counterwithin{algorithm}{chapter} %count algorithms within chapter

bits, solved the problem.

You must log in to answer this question.

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