1

Below is my latex:

\usepackage[ruled,longend]{algorithm2e}
\begin{algorithm}
    $I \gets \text{Images of objects' plane}$\newline
    $Detector \gets \text{Define detector}$\newline
    $Descriptor \gets \text{Define Descriptor}$\newline
\end{algorithm}

But the first line is un aligned

1 Answer 1

2

Line-ends within an algorithm environment under algorithm2e require the use of \;, not \newline.

enter image description here

\documentclass{article}

\usepackage{amsmath}
\usepackage[ruled,longend]{algorithm2e}

\begin{document}

\begin{algorithm}
  $I \gets \text{Images of objects' plane}$\;
  $\text{Detector} \gets \text{Define detector}$\;
  $\text{Descriptor} \gets \text{Define Descriptor}$\;
\end{algorithm}

\end{document}

If you don't like the semicolons printed, then add

\DontPrintSemicolon

somewhere after loading algorithm2e.

2
  • Would \DontPrintSemicolon remove all the semicolons in the text or just in the algorithm section?
    – paul-shuvo
    Feb 20, 2020 at 2:46
  • 1
    @paul-shuvo: Just the semicolons associated with \; within the algorithm environment.
    – Werner
    Feb 20, 2020 at 2:47

You must log in to answer this question.

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