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

learn more… | top users | synonyms

1
vote
0answers
17 views

Latex algorithm else if

I am trying to add else if instead of else in the algorithm, but it is not working. I am using this package: \usepackage[ruled]{algorithm2e} Latex code: \begin{algorithm}[H] \While{true:}{ ...
2
votes
1answer
199 views

Sigplanconf algorithm2e missing algorithm when figure

I am rewriting a paper, and stumble over this problem where algorithms are missing in my appendix. I was able to reproduce the problem. The following code only display 2 out of the 4 algorithms on ...
2
votes
2answers
33 views

Help with algorithm2e formatting

recentely I've got into a bit more advanced LaTeX formatting, i.e algorithms. My package of choice is the algorithm2e package, but I'm having some difficulities operating it. So I've wanted to create ...
2
votes
1answer
46 views

Problem Splitting Very Long Algorithm on two or pages

In the example below, I have a very long algorithm, probably spanning 3 pages. I tried manually splitting the code up, but each time, a new algorithm number is generated. How do you maintain the ...
1
vote
1answer
14 views

How to get a “tight” boxed algorithm with the algorithm2e package

I am using the algorithm2e package for my pseudo code since I like the like the options this package offers. However, the boxed option gives a text-width sized box and it doesn't look appealing to me ...
1
vote
1answer
42 views

Why second column in IEEE trans is not filling up? [closed]

I am trying to include my algorithm into one column of a two column format of IEEE trans. My code is: \documentclass[conference]{IEEEtran} \usepackage[algoruled,boxed,lined]{algorithm2e} ...
3
votes
1answer
79 views

How to mark line numbers of an algorithm with asterisk? [closed]

I'm working with IEEEtran and algorithm2e package. I have a pseudocode with numbered lines. I want to mark some of my line numbers (not the lines themselves) with an asterisk mark. How can I do that? ...
0
votes
1answer
66 views

How can I format this formula?

I am new to LaTeX. How to write this formula in a proper format as an algorithm? I cannot write this formula in proper format: if (some condition) P=P+(W$i$*((W-P)/W$i$)) end
3
votes
1answer
54 views

In algorithm2e, how to force non-italic font in the condition block of While

I have this snippet: \documentclass[10pt]{article} \usepackage{amsmath} \usepackage[ruled,vlined,linesnumbered]{algorithm2e} \begin{document} \begin{algorithm} \While{$|\text{OPEN}| > 0$}{ ...
0
votes
1answer
23 views

How to write in proper format of this code

I want to get the right hand side portion in a format. Here the format. Table[i, j] <-maximum { Table[i-1, j] AND Values[i] + Table[i-1, j – ...
2
votes
2answers
38 views

Change Algorithm caption Label color to blue and bold italics

I wanted to know how to go about changing the algorithm caption label to blue and bold italics. I have so far been able to change the caption name to blue, but I have not been able to change the ...
0
votes
1answer
32 views

Compilation Error after running algorithm2e in document

This post is building of the solution posted here. When I try to put this code into my main code (or even \input the file, I get the error ! Argument of \reserved@a has an extra }. If I run the ...
2
votes
1answer
33 views

Switch numbering in Algorithm from \arabic to \arabic\alpha for specific lines

Switch numbering in Algorithm from \arabic to \arabic\alpha for specific lines In the code below, I wanted to change #3 to 3a and #4 to 3b. Then number 5 should be #4. Basically, I wanted to change ...
2
votes
1answer
19 views

Cannot change fonts on Algorithms Table of Contents page

In the MWE below, I cannot change the font (and formatting) of the Table of Contents for the "List of Algorithms" page. As you will see, the font for the TOC is \sffamily, however, when I try the ...
2
votes
1answer
87 views

Tikz node in algorithm2e preventing file from compiling

For some reason, I cannot find where I am going wrong. I put a tikz node in the algorithm2e environment and now the file cannot compile. I get the error Missing } inserted. I do not see where I am ...
0
votes
1answer
17 views

Apply background color in algorithm environment part 2

This question is building of the solution found here. I wanted to change the background color to blue or a user defined color \definecolor{mybluei}{RGB}{0,173,239}. However when I tried to implement ...
1
vote
1answer
27 views

Apply background color in algorithm environment

I have not found a simple solution to have a background color in the algorithm environment. Can you help me put a background. Here is the code that I have so far: \documentclass{article} ...
4
votes
3answers
1k views

break an long line in an algorithm

I have a long line in an algorithm and want to break it into two lines. For similar case in equations, split can be used. How do I do this within an algorithm? \documentclass{article} ...
1
vote
1answer
14 views

\For in Algorithm environment causing code to not compile

In the code below, when I use the \For statement, the code does not compile and gives the message: ! Missing \endcsname inserted. <to be read again> \ALG@currentbkock@0 Can ...
2
votes
2answers
17 views

How can I make the symbol \\ tiny in algorithm2e? [closed]

I would like to write a tiny comment in algorithm2e. I typed \tcp*[l]{ {\tiny Here is my comment.} } My problem is that the symbol // right before the comment is large. I tried to make it tiny but ...
1
vote
1answer
27 views

Cases inside an algorithm environment

I need to write an algorithm where multiple cases are handled. I have succeeded but the output shows a lot of vertical space below and above the cases statement. Anyone help me to fix this. I am using ...
3
votes
1answer
18 views

algorithm2e: How to define my own macros? +2

Just starting to play around with the algorithm2e package and I have difficulties to figure out the things I need. Here is my minimal working example: \documentclass[10pt,a4paper]{article} ...
2
votes
0answers
34 views

How to combine algorithm and algorithm2e in one document?

I got myself in big trouble and I can't get out of it. I use standalone package to combine different latex files into one. Each Latex file compiles OK on its own. When I combined them, I found a ...
0
votes
0answers
31 views

Formatting an algorithm with a nice presentation

I was reading this paper and I think is really nice the format how they present the algorithms, how can I do this? what packages are needed and the styles. Thanks in advance.
0
votes
1answer
34 views

Algorithms: change the style of individual line numbers

I would like to change the style of individual lines in an algorithm. For example, I'd like surround key line numbers with a box, color them, or otherwise distinguish them. It is possible to change ...
0
votes
1answer
19 views

How can I add a comments with the `algorithm2e` package?

I am using algorithm2e package to write an algorithm and I am trying to add line 3 and 4 in the code in the screen shot as comment with \tcc{} but without seccuss. How can I add a comments with the ...
0
votes
0answers
18 views

How to write the algorithm with bold keywords and line numbers

I wish to write an algorithm like the following, with keywords bold and line numbers in each line. Could someone help on how to use latex to write this kind of algorithms?
1
vote
0answers
113 views

Genetic Algorithm pseudocode [closed]

Hi everyone, this is my first post, so apologise if not doing it properly. I need the following GA pseudocode (Photo) in LaTex, but couldn't do it very well. I really appreciate your help.
2
votes
1answer
31 views

Colored horizontal lines in algorithm2e

I'm trying to colorize the 3 horizontal lines appearing at the top and bottom of the algorithm below. I haven't been able to find similar issues in the internet. Could you please advise? ...
5
votes
1answer
12k views

Subroutine in algorithm2e

I am looking for a tiny example of writing in algorithm2e an algorithm using a subroutine. The algorithm is called algo, and it recursively calls a subroutine called proc. It should be something like ...
3
votes
2answers
35 views

parskip is shifting my algorithm

Problem: I am using parskip (only) to add customized space between paragraphs, but the package is shifting my algorithm content to the left. If there is another (clean) way to customize the space ...
1
vote
0answers
45 views

Problem with algorithm2e: \SetAlgoLined and \Indp not working properly together

Problem: I need to get something like this: But I'm getting this (note the vertical line): What I have: Here my code: \documentclass{report} ...
2
votes
0answers
69 views

How can I distinguish between error in code and bug in package? [closed]

I keep getting an error upon compilation, but cannot find an error, even with a tiny reproducible example (below). I am exporting from Emacs org-mode to LaTeX and then PDF, I am receiving the well ...
1
vote
0answers
37 views

Copied algorithm2e code renderes different

I'm writing a summary of my algorithms course and in order to insert new algorithms I use algorithm2e package. I am still learning the package features, so I tried to copy the code from latex ...
1
vote
1answer
20 views

How to insert a “continue” in while command of Algorithm2e

I read the documentation of the package algorithm2e to figure out how to insert continue command within a while loop, but I couldn't find any way to do it. Is there any work-around for this lack of ...
0
votes
0answers
23 views

Change the format of an algorithm from a table to any algorithm typesetting

I have been struggling to format the pseudocode of my algorithm from the current state (in a table) to the one provided by the algorithm package. After several tries with answers like: one, another, ...
3
votes
1answer
71 views

how to fit algorithm to line width in latex

the following algorithm exceeded the width of the column: \begin{algorithm}[!htb] \caption{........} \label{alg:BuildMG} %\algsetup{linenosize=\small} \scriptsize \DontPrintSemicolon ...
3
votes
1answer
21 views

SetKwInOut error

I'm having some problems with the algorithm2e package. Here's the code: \begin{algorithm} \caption{Tree merge algorithm\label{alg:merge}} ...
0
votes
0answers
19 views

Package order errors [duplicate]

I'm trying to use overpic, algorithm2e, empheq and tikz (mindmaps) packages together in a beamer presentation. Depending on the order I'm declaring my packages, it causes my environment to cause some ...
2
votes
1answer
37 views

Marking some lines of an algorithm with an asterisk, why it doesn't always work?

I'm working with IEEEtran and algorithm2e package. I have an algorithm with numbered lines. I am marking some lines with an asterisk before the line as follows: \documentclass[conference]{IEEEtran} ...
1
vote
1answer
33 views

How can I use an algorithm2e function macro inside an algorithm2e caption?

Algorithm2e lets you define functions using \SetKwFunction{Fn}{Function} which you can then reference anywhere in the document (not just in an algorithm environment) using e.g. \Fn (which will output ...
1
vote
0answers
36 views

Caption and pseudo code in algorithm2e appears as boxes (not rendered)

I want to create a multi-language document using polyglossia in which Khmer is set to be a main language and English as another language. I also have khmer-gloss.ldf available so that Khmer font is a ...
1
vote
1answer
69 views

Is there a LaTeX to HTML tool that supports the algorithm2e package?

I'm a LaTeX beginner and I'm writing computer science documents. I carefully choose my algorithmic package considering the features I needed and that led me to pick algorithm2e (vlined and noend ...
1
vote
2answers
21 views

Reference to a part of an algorithm

I would like to write about the analysis of an algorithm. Depending on some conditions multiple cases arise. I would like to reference the cases but not solely based on the line numbers. Essentially I ...
0
votes
0answers
48 views

Hanging caption with boxed algorithm2e

Along very similar lines to the question posed at Algorithm2e and hanging captions, I'm having problems producing captions for algorithm2e that have the same appearance as a figure caption (i.e. hangs ...
6
votes
1answer
84 views

shrink algorithm

I am writing a 2-column paper. I have 2 algorithms each within \begin{multicols} ... \end{multicols} environment. I want to scale each of them to half the size so that I can fit it side-by-side. How ...
1
vote
1answer
297 views

Can be used only in preamble occurs when using \usepackage command

Whenever I am trying to use the subfigure or the algorithm2e package using \usepackage command, it is showing LaTeX Error: Can be used only in preamble. What is the problem and how to get rid of ...
0
votes
0answers
29 views

Is it possible to keep connecting loop lines in algorithm2e and to implement a page break?

I have to formulate many and long algorithms. My problem is that my algorithms are very long and need to break over pages. In order not to lose structure it would be very good to have those vertical ...
0
votes
0answers
18 views

How to change space below algorithm2e float

How can we change the spacing below the algorithm environment? Is there a possibility with the caption package? \documentclass[ 12pt, a4paper, twoside, titlepage, openright, ...
2
votes
1answer
55 views

Write the else if block with algorithm2e

How can I write the else if block with condition with the usepackage algorithm2e? I want to write the following with the algorithm2e package: if(condition){ //code }else if(condition){ // code ...