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

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.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.