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
21 views

Add text after semicolon in algorithm2e

I have the following code: \documentclass{article} \usepackage[ruled]{algorithm2e} \begin{document} \begin{algorithm*} Set $a = 10$\; // \textit{$a$ denotes the amount of money} Decrease $a$ by $...
  • 201
1 vote
1 answer
23 views

inline \todo in algorithm results in overfull hbox

Feeding \documentclass{article} \pagestyle{empty} \usepackage{algorithm2e} \usepackage{todonotes} \overfullrule=2mm \begin{document} \begin{algorithm} \todo[inline]{Note} \end{algorithm} \end{...
  • 1,565
0 votes
1 answer
18 views

Remove extra blank line at the end of algorithm2e

Here's how to recreate the situation: \documentclass[preview]{standalone} \usepackage[ruled, vlined, linesnumbered, nofillcomment]{algorithm2e} \usepackage{algpseudocode} ... \begin{algorithm}[H] ...
0 votes
1 answer
15 views

How do we write if else if block with usepackage algorithm 2e?

I have written the code for if else if block but I want nested if else if loop like If (flag) If (c1) then c2 Else If (c3) then c4 \documentclass{article} \usepackage[ruled, lined, ...
  • 1
0 votes
1 answer
21 views

Can't modify algorithm2e caption numbering

I want to change the numbering of one algorithm from Algorithm 5 to Algorithm 2.1. I've tried all these methods: Change caption number of an algorithm https://github.com/hadizadeh/Latex_algorithm No ...
0 votes
1 answer
17 views

Customizing pseudo-algorithms in algorithm2e package

If I have a pseudo-algorithm in Latex that looks like this: With source code below. \usepackage[ruled, vlined]{algorithm2e} \begin{document} \begin{algorithm}[H] \...
  • 103
1 vote
1 answer
21 views

How to remove the vertical space between the last line of code and the frame if the code is wrapped in `minted` within `algorithm`?

MWE: \documentclass{article} \usepackage{algorithm} \usepackage{minted} \newminted{python}{ } \begin{document} \begin{algorithm} \caption{Caption} \begin{pythoncode} x = 12 y = 3 print(x /...
  • 113
1 vote
1 answer
18 views

Algorithm in Beamer: all commands are in one line

I need the commands to be in separate lines (If, While, etc). I also tried to get rid of the number of the algorithm as suggested in other posts but the number is still there. Any help is appreciated! ...
  • 217
0 votes
0 answers
9 views

Minitoc for algorithms

I am currently using memoir package to typing my thesis. I need to show the contents of each chapter at its beginning. For that I used the minitoc package. I was able to have also the list of tables ...
  • 115
2 votes
1 answer
73 views

How to break a long pseudo code in Beamer in two slides

I have to write a long pseudo code in latex but one slide only takes 22 syntex. How to continue the remaining syntex in next slides. Please see my codes, I am using the extra packages for other ...
  • 21
0 votes
0 answers
6 views

Customize the keyword of single-line command in algorithm2e

The following is a simple procedure that extracts a random subset from the groundset such that the probablity that every single element in groundset occurs in this subset is the same. The code is ...
  • 1
3 votes
1 answer
37 views

algorithm2e : 1 block without vline

I'm trying do define a block without vertical line in Vline mode. For example in : \documentclass[10pt,a4paper]{article} \usepackage[utf8]{inputenc} \usepackage[ruled]{algorithm2e} \begin{document} \...
0 votes
1 answer
31 views

Place algorithm environment directly under sections/subsections

Algorithm environment is placed wrong, not in the place I want it to be (directly under subsection statement). I am aware of popular answers about the problem like using float package and [H] ...
  • 161
1 vote
2 answers
48 views

Is it possible to change the word "Algorithm" to another word? [duplicate]

It may be a strange question but I want to change the word "Algorithm" to "Operation" in an algorithm list. I am using the package algorithm2e. \usepackage[ruled, vlined]{...
  • 113
0 votes
1 answer
28 views

algorithm2e - make the topmost and bottom horizontal lines thicker

I'm pretty satisfied with the output above, yet would prefer having the topmost and the bottom horizontal lines bolder. Any help?
1 vote
1 answer
60 views

What is the use of \SetAlgoLined in algorithm2e

I read in official documentation of algorithm2e that \SetAlgoLined is used to draw vertical lines between begin and end markers. But without it also, there are vertical lines drawn, though there are ...
  • 11
0 votes
2 answers
47 views

Algorithm's body disappears while adding or removing paragraph elsewhere in the overleaf document

When I add or remove some paragraph in other section of the overleaf project, the algorithm2e algorithm body collapses intermittently as shown in the attached image below. Following is a sample code ...
  • 11
0 votes
2 answers
31 views

Highlight multiple lines of algorithm2e environment

I stumbled upon the solution from this question: How to highlight sections of my code in algorithm? and incorporated it into the following MWE which shows two flaws: \documentclass{article} \...
  • 111
2 votes
2 answers
91 views

INFORMS template flattens out my algorithms

I am preparing a manuscript using the INFORMS style files, which can be downloaded here: https://pubsonline.informs.org/authorportal/latex-style-files (That page doesn't mention a license, so I don't ...
  • 305
1 vote
1 answer
28 views

Algorithm2e - Defining 2 separate functions in same document

I am new to using Algorithm2e in Latex, and Latex in general. I am trying to define multiple functions in one document. I have this so far: \documentclass{article} \usepackage[linesnumbered,ruled,...
0 votes
1 answer
43 views

an example how to produce ''end if'', ''end for'', and ''end while'' in the algorithm2e environment?

Could anyone show me by an example how to produce ''end if'', ''end for'', and ''end while'' in the algorithm2e environment? Hello, thank you for your answer, I have tried to upload the algorithm ...
1 vote
1 answer
25 views

What causes indents to be removed with algorithm2e

I followed an example from overleaf to create an algorithm. However, I assume there is some conflict with my article templates cls, but I don't see any warnings. What could or might cause this? \...
  • 147
0 votes
1 answer
15 views

algorithm2e error on \SetDataSty

Using the algorithm2e package I am trying to write an algorithm on a document. I wish to change the default font used on the \SetKwData variables and I am trying to do that by using the \SetDataSty ...
  • 331
1 vote
0 answers
21 views

Only number lines without keywords in Algorithm2e

For my algorithms in Algorithm2e, I would like to only number the lines that end with a semicolon \;. I tried to hack something together using the answers to Algorithm2e - Disabling line numbers for ...
1 vote
1 answer
36 views

Algorithm caption left alignment

I am struggling with moving the caption's location to the left. Is there a way to fix the alignment of the caption in the algorithm? Below are some of the packages that I used and the code. Thanks. \...
0 votes
0 answers
58 views

Goto command in algorithm2e package

I use the following code N(a,n,i,j,y){ $p \gets 1$\; $z \gets 1$\; \While {$z \leq n$}{ \eIf{$a[y][z] = 0$} { $z \gets z+1$\; }{ ...
1 vote
1 answer
31 views

Cleveref and Algorithm2e: typesetting procedure name

I am making use of the procedure environment of algorithm2e, but I am unable to get it to work with cleveref. I would like to have a different reference for procedures and algorithms, but they seem to ...
0 votes
2 answers
36 views

Remove "algorithm X :" in an algorithme2 caption

I tried to use caption* : \documentclass{beamer} \usepackage[lined,boxed,commentsnumbered, ruled,vlined,linesnumbered, french, onelanguage]{algorithm2e} \usepackage{caption} \begin{document} \begin{...
  • 151
0 votes
1 answer
37 views

Algorithm2e: framed environment shifts line numbers

I want to have a box in my algorithm, and for that I'm using framed environment. However, it also shifts line numbers: \documentclass{article} \usepackage[vlined,ruled,linesnumbered]{algorithm2e} \...
  • 186
1 vote
1 answer
17 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: \...
0 votes
0 answers
104 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: \...
0 votes
0 answers
37 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 !! ...
0 votes
1 answer
58 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 ...
  • 101
0 votes
0 answers
36 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 ...
0 votes
1 answer
150 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{...
0 votes
0 answers
162 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 ...
1 vote
1 answer
110 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 ...
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) \...
0 votes
1 answer
36 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 ...
  • 377
1 vote
1 answer
31 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{...
  • 377
0 votes
3 answers
25 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,...
2 votes
0 answers
101 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} \...
  • 161
1 vote
1 answer
28 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 ...
  • 209
1 vote
1 answer
65 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}{\...
  • 67
0 votes
2 answers
167 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}...
  • 367
0 votes
0 answers
29 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 ...
0 votes
0 answers
46 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 ...
2 votes
1 answer
85 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 ...
  • 23
0 votes
1 answer
49 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 "...
0 votes
0 answers
45 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 ...

1
2 3 4 5
14