Questions tagged [algorithm2e]

{algorithm2e} is a package providing a floating algorithm environment with algorithmic keywords.

Filter by
Sorted by
Tagged with
1 vote
1 answer
12 views

algorithm2e: Cross reference to subsubsection after algorithm not working

while writing my thesis I became aware of a problem related to the algorithm2e package regarding the label referencing of subsubsections following an algorithm. Here is a simple example: \...
user avatar
0 votes
0 answers
9 views

Error with the package algorithm2e in springer template

I'm using the Springer Latex template, the package algorithm2e is not acceptable (error). I tried to insert the package in "sn-jnl.cls" but that did not work. They use these packages: \...
user avatar
0 votes
0 answers
26 views

"Missing $ inserted " error while using algorithm2e

Hello Latex Community, I'm writing an algorithm but the TEX maker is showing an error "missing $ inserted error in the last line of the algorithm (\end{algorithm})!!! Could you please help me !! ...
user avatar
0 votes
0 answers
19 views

How to remove Algorithm 1 from header and how to declare a variable with its type

I'm trying to write my first pseudocode algorithm with MikTEX and algorithm2e package but there are at least two things that I cannot understand. The image below shows what I want to achieve in term ...
user avatar
  • 101
0 votes
0 answers
26 views

How to include an algorithm in a Rmarkdown template

I have the following document. I am using the arxiv_article style. This is a predefined template that comes with the rticles package. I am trying to insert some Latex, but I am running into an error. ...
user avatar
  • 101
0 votes
0 answers
12 views

2-column Algorithm block collapses on writing more lines in the left column

I am using algorithm2e package in Overleaf to write algorithm in 2 columns. I mean, Algorithm-1 is spread across two columns in the page, such that left column has 46 lines (including some spaces in ...
user avatar
  • 1
0 votes
0 answers
13 views

How to change position in pseudocode (package algorithm2e)

I'm new to LaTeX and I'm writing my thesis in this right moment. For the pseudocode, I use algorithm2e. However, when I try to fit my algorithm between two paragraphs, it points down to the bottom of ...
user avatar
0 votes
1 answer
54 views

How to write nested if else statement inside function

I am trying to write the following algorithm in LaTex using algorithm2e package. \IncMargin{1em} \begin{algorithm} \caption{An example} \SetNoFillComment \DontPrintSemicolon \BlankLine \SetKwInOut{...
user avatar
0 votes
0 answers
33 views

! LaTeX Error: File `algorithm2e.sty' not found

I am using Centos 7.8 and installed texlive using yum install texlive* I tried installing using yum install texlive-full but it did not find any package named like this. It turns out I can not use ...
user avatar
1 vote
1 answer
37 views

How to split algorithm2e over two pages within for-block and if-else-block

I do know that this questions have been asked before in How to split algorithm2e over two pages Unfortunately the answers given there did not work out for me. I am struggling to realize a page break ...
user avatar
  • 327
0 votes
0 answers
24 views

Express a variable indicating a sum growing with loop advancement

I'm describing an algorithm (using algorithm2e) in which there is a loop and inside a variable that grows each iteration how can indicate it ? I wrote this for i=1,N do: \sum_{cells} \alpha_{i}(j) \...
user avatar
0 votes
0 answers
25 views

How to place these algorithms side by side in a special way

I have the following problem: I want to place to algorithms side by side such that the lines with the same number are on the same height. Unfortunately, until now it looks like that . What I do not ...
user avatar
  • 367
0 votes
1 answer
19 views

Two algorithms side by side and synchronized

I have the following MWE: \documentclass{beamer} \usepackage{tikz} \usepackage[ruled,linesnumbered]{algorithm2e} \begin{document} \begin{frame}[t]{} \begin{minipage}{0.5\textwidth} \begin{...
user avatar
  • 367
0 votes
3 answers
21 views

algorithm2e is numbered by 2 for each line

The following algorithm has lines numbered by 2. I simply need them to start at 1 and go by 1: 1,2,3,4 etc. Why is this happening? Thanks and Regards, \documentclass{article} \usepackage[ruled,lined,...
user avatar
2 votes
0 answers
38 views

algorithm2e - If with multiple conditions and vlined option, preferably with Python style syntax

I am trying to use algorithm2e to write an algorithm which looks like so (made with Latex+Paint): Based on this Stack Exchange answer, I have attempted the following: \documentclass{article} \...
user avatar
  • 161
1 vote
1 answer
21 views

Proper line numbering of algorithm2e when tabular environment is inside an algorithm environment

I use tabular inside algorithm environment of algorithm2e package (see figure below) in order to align two columns of comment lines. Without using a table, achieving this task is difficult with some ...
user avatar
  • 209
1 vote
1 answer
54 views

Aligning equation numbers inside and outside of an algorithm

\documentclass[12pt, a4paper]{report} \usepackage{amsmath} \usepackage{mathtools} \usepackage[ruled]{algorithm2e} \begin{document} \begin{algorithm} \caption{my capt} \begin{minipage}{\...
user avatar
  • 67
0 votes
2 answers
78 views

How to convert this code from algorithm2e to algorithmicx

I was using the algorithm2e environment so far. However, the springer journal class does not support it. In it's documentation, it is suggesting to use \usepackage{algorithm} \usepackage{algpseudocode}...
user avatar
  • 357
0 votes
0 answers
23 views

How to allow more width in algorithm

I am using the algorithm2e package, and I have an algorithm (shown in image) in which one line is split into two (namely, the assignment of alpha on line 21 goes over two lines). I would like to not ...
user avatar
0 votes
0 answers
41 views

How to properly add new lines in algorithm

I am trying to write algoritm in a way that separate line in the code should be separate line after compiling latex I use \ symbol to achieve this but for some reason it do not work. I work and ...
user avatar
2 votes
1 answer
37 views

Referencing an algorithm written in Algorithm2e using Cleveref prints the word "Line+Number" instead of "Algorithm+Number"

I am using the package algorithm2e to write some algorithms. However, when I reference a specific algorithm using cleveref, I get [Line 1] instead of [Algorithm 1]. Is there anyway to let cleveref ...
user avatar
  • 23
0 votes
1 answer
29 views

How to override the numbers in an algorithm?

I have tried a few ways I found here, including This, and This, there are more but I can't remember them. The issue I'm having is I'd like "Fifth Instruction" to start on 5, I know "...
user avatar
0 votes
0 answers
37 views

Add space above algorithm2e

I'm trying to figure out how to add space above an algorithm2e algorithm. The algorithm is exceeding the margin, and I can't get it to move down with vspace. Its just the top bar that is exceeding the ...
user avatar
1 vote
1 answer
83 views

Change line number only after \; in algorithm2e

How can I have the regular behaviour of some paragraphs placed together, without changing line number in the algorithm after one paragraph ends? I want that line number changes only after a \; appears ...
user avatar
3 votes
1 answer
65 views

Algorithm2e - Replicate KwFunction font

in algorithm2e one can define some function names as keywords and algorithm2e then provides a certain font in which they are printed. Now, I want to use the font even outside the algorithm, e.g. when ...
user avatar
  • 367
1 vote
2 answers
73 views

Algorithm2e - write IfThenElse in one line

I have the following example \documentclass{report} \usepackage{algorithm2e} \begin{document} \begin{algorithm} \lIf{$\max_{\mathcal{AV}} > \theta_5$} { \...
user avatar
  • 367
1 vote
0 answers
124 views

Algorithm2e: Width of algorithm rules and text alignment

I have two questions linked to the algorithms environment that I am using in LaTeX. Example Let me start with an example file to illustrate what I'm looking for. Algorithm 1 in the MWE below does what ...
user avatar
0 votes
0 answers
17 views

`\ref{}` inside `\caption{}` in algorithm2e produces error with beamer [duplicate]

The following MWE is self-explanatory: \documentclass{beamer} \usepackage[ruled]{algorithm2e} \begin{document} \begin{frame} \begin{algorithm}[H] \label{algoone} \caption{Algorithm for solving my ...
user avatar
  • 273
2 votes
0 answers
34 views

algorithm2e - `\small` interferes with `\nonl` (line number removal)

I use a custom command \nonl, which removes the line number for a certain line. When I simply use \nonl, it works. When I use {\small \nonl ...}, it works. When I use \nonl {\small ...}, it also ...
user avatar
  • 174
0 votes
0 answers
42 views

How to change the "do" in ForEach loop command into self-defined text in algorithm2e?

I am trying to write a pseudocode of a GPU-based parallel algorthm with algorithm2e. Basically, I would like to write something like foreach GPU block do in parallel How do I change the default &...
user avatar
2 votes
3 answers
153 views

standalone document with algorithm2e package

I'm trying to generate a pdf file containing an algorithm, which will be included in the main document as a figure. I tried using standalone as follows: % main.tex \documentclass{standalone} \...
user avatar
  • 307
0 votes
2 answers
131 views

I want to add a comment to a for loop in `algorithm`

\begin{algorithm}[h] \caption{Transformation} \tcp{Apply transformation X comment1} \For{$k=1$ \KwTo $n$} {$P=A*P*A^{T}$ \tcp{comment 2}} \end{algorithm} I want to add a comment in for ...
user avatar
  • 11
1 vote
1 answer
30 views

Problematic spacing with \begin{cases}

In my MWE I would like to adjust the spacing immediately before each instance of \begin{cases}. The large curly brace seems jammed into the previous line. How would I adjust this? My source code: %...
user avatar
  • 1,473
4 votes
0 answers
169 views

Highlighting pseudocode in algorithm

Edit: I "solved" my main issues now. It's a bit ugly/hacky, but at least the result looks ok. With this edit I'm replacing the now obsolete old code with what I have now. But suggestions for ...
user avatar
  • 41
0 votes
1 answer
47 views

Correct usage of algomathdisplay in algorithm2e

What is the correct usage of algomathdisplay from the algorithm2e package? I appear to have misunderstood its usage, see example below. There are two different attempts one with just \begin{...
user avatar
  • 343
2 votes
1 answer
48 views

How to start the line number at specific line or skip a line in algorithm2e? [duplicate]

I trying to customize the line number of my algorithm with the algorithm2e package. I want to start the line number at a specific line or just a given line. I am using the following code example: \...
user avatar
0 votes
1 answer
42 views

Underline List of Algorithms, References, and Index with Victorian Ornament

I would like to place a victorian ornament (pgfornament 80) below List of Algorithms, References, and Index, all centered and capitalized. Below is my minimal working example (MWE), but the ornament ...
user avatar
2 votes
1 answer
549 views

Write an if-elseif block with algorithm2e without the final else?

I have an algorithm and an if-elseif block in it that does not have a final else. This leaves my algorithm open, I mean the algorithm does not show end after finishing elseif and it needs an \else to ...
user avatar
7 votes
2 answers
352 views

What is the difference between float specifier [h] and no specifier []?

Not sure why but in my long document \begin{algorithm}[h] leads to the algorithm and all subsequent algorithms to being placed at the very end but \begin{algorithm}[] leads to the algorithm being ...
user avatar
  • 670
0 votes
0 answers
82 views

algorithm2e procedure / function error: "end" block of procedure using \SetKwProg overflows to next column in 2-column page

While using algorithm2e package to write an algorithm having 2 procedures in a 2 column page, only the "end block (last line) of the procedure always flows to 2nd column. I have used this in the ...
user avatar
  • 1
1 vote
1 answer
65 views

algorithm2e align environment takes too much vertical space

I want to use equations in an algorithm. For this I use algorithm2e and the align* environment. The result looks nicely, but sadly, the align* takes too much vertical space and thus the whole ...
user avatar
  • 13
1 vote
1 answer
64 views

How to write title of chapter and algorithm in correct way?

I am writing PhD Thesis on overleaf but the title of the chapter being vanished whenever I insert the package \usepackage[ruled]{algorithm2e} for the algorithm and the algorithm appears in good ...
user avatar
1 vote
0 answers
53 views

How can I write the algorithm with cost and count using beamer?

I want to make a beamer slide to show the running time calculation of algorithms, as shown in the figure. I use algorithm2e.
user avatar
  • 11
1 vote
1 answer
255 views

algorithm2e showing errors in IEEE Access format ("Argument of \@algocf@endoption has an extra }. } "and "Paragraph ended before \@algocf@endoption")

\documentclass{ieeeaccess} \IEEEoverridecommandlockouts \usepackage{cite} \usepackage{amsmath,amssymb,amsfonts} \usepackage{algorithm} \usepackage[ruled]{algorithm2e} \begin{document} \history{...
user avatar
0 votes
0 answers
19 views

How to include multiple label in algorithm2e and adjust numbering in a specific way?

Suppose I have the following LaTeX source: \documentclass[letterpaper,12pt]{article} \pagestyle{myheadings} %---------------------------------------------------------- % algorithm2e setup \usepackage{...
user avatar
  • 101
1 vote
1 answer
34 views

Defining Polymorphic objects in algorithm2e

I'm currently writing my masters thesis and I'm using algorithm2e to write pseudocode. I regularly use SetKwData to display data types. However I would slighty like to change how this is displayed ...
user avatar
  • 13
0 votes
0 answers
23 views

Multi-statement line

I want multiple statements to appear on the same line. In other words, for certain statements, I do not want a newline after the semicolon. \begin{algorithm}[H] $a \leftarrow 1$\; $b \leftarrow 1$\; \...
user avatar
2 votes
1 answer
65 views

Formatting a Pseudocode using Algorithm2e

I'm trying to format a pseudocode using the Algorithm2e package. The desired output has the following format: Here's the code I've tried to format this pseudocode: \usepackage[ruled,vlined]{...
user avatar
  • 121
1 vote
0 answers
45 views

Left margin is unexpectedly reduced

\documentclass{beamer} \usepackage[ noend, boxruled]{algorithm2e} \begin{document} \begin{center} \begin{algorithm}[H] \SetKwInOut{Input}{Input}\SetKwInOut{Output}{Output} ...
user avatar
  • 291
1 vote
1 answer
160 views

Long algorithm exceeds one page using algorithm2e package in IEEE Access Class. How to fit this long algorithm?

\documentclass{ieeeaccess} %\usepackage{siunitx} \usepackage{graphicx %\usepackage{algorithmic} \usepackage[lined,boxed,ruled,commentsnumbered]{algorithm2e} \begin{document} \begin{algorithm} \tiny \...
user avatar

1
2 3 4 5
13