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

learn more… | top users | synonyms

8
votes
2answers
11k views

How do remove equation number in an algorithm

Here is the code. Even I have used the command \nonumber still I can see the equation number \begin{document} \begin{algorithm} \DontPrintSemicolon % Some LaTeX compilers require you to use ...
6
votes
1answer
1k views

Issue with algorithm2e “input” alignment

If you look at the image below you will see that on the 4th line of the input, the alignment resets for some reason and I'm not sure why. Could someone show me how to fix this? ...
4
votes
1answer
100 views

Line in algorithm2e environment wrapping late

I am having a small issue where where the line Let $s$ be the highest-ranked student in $h$'s preference list which $h$ has not yet requested to be a resident\\ in my algorithm is wrapping a ...
2
votes
0answers
58 views

Nomencl and Algorithm2e Incompatibility [closed]

This code produces no errors and displays the nomenclature correctly. \documentclass{article} \usepackage{nomencl} \makenomenclature \begin{document} \nomenclature{$c$}{a constant} \printnomenclature ...
2
votes
1answer
162 views

Problem with references in classic thesis if algorithm2e package is used

If I use the algorithm2e package together with the linesnumbered option and the classicthesis package, references to a sub sub section are wrong. If I don't use the linesnumbered option, references ...
3
votes
1answer
503 views

How to remove the extra blank line in algorithm2e

I want to add a right aligned comment in LaTeX after \For command, but it adds an undesired blank line. Please help me. CODE: \For(\tcp*[r]{Incremental calculation of edges}){$i \gets 1$ ...
5
votes
1answer
262 views

Wrong line spacing when changing font size for caption of algorithm

I am using the algorithm2e package and want to change the font size for captions of figures as well as for captions of algorithms. The problem is that I get different line spacings for the two ...
1
vote
1answer
90 views

How to exclude some algorithms for \listofalgorithms

I tried with \captionsetup{list=no} but it doesn't work for the algorithm listing. Any ideas? I am splitting alg. over several pages using algorithm2e and don't want the captions of the split ...
8
votes
2answers
2k views

algorithm2e Command \algorithm already defined

I want to draw vertical line by using \SetAlgoLined, but LaTeX told me Undefined control sequence. Then I add \usepackage{algorithm2e} to the end of my preamble. Then it said Command\algorithmalready ...
0
votes
0answers
19 views

Broken algorithm reference number [duplicate]

My code is as follows: \documentclass[12pt,letterpaper]{book} \usepackage{graphicx} \usepackage[ruled,vlined]{algorithm2e} \usepackage{subfig} \begin{document} \pagestyle{plain} ...
3
votes
1answer
162 views

List of Algorithms: space between number and algorithm caption too small

I'm facing a problem with KOMA-Script and algorithm2e: algorithm captions in the list of algorithms collide with the numbers preceding them. See the image for an impression. How would I go about ...
3
votes
1answer
112 views

Indentation missing for algorithm package in documentclass{minimal}

I am trying to get write an algorithm in LaTeX for minimal document class. Unfortunately, the indentation is completely missing. Following is my sample code: \documentclass{minimal} ...
3
votes
1answer
200 views

Custom algorithm environment enumerated with algorithm2e and appearing in table of contents

I would like to have two environments sharing a counter and appearing in the same list. One of these environments is algorithm2e and the other is a simple frame for holding algorithms I want to ...
2
votes
1answer
2k views

algorithm2e, function, procedure, \par, error

This is fine: \documentclass{article} \usepackage[boxed]{algorithm2e} \begin{document} \begin{algorithm} $x \gets x$\; \caption{Identity} \end{algorithm} \end{document} But this, which ...
3
votes
1answer
2k views

Turn off line numbering in algorithm2e

I have the following preamble for algorithm2e: \usepackage[ruled,vlined,linesnumbered,resetcount,algochapter]{algorithm2e} I have many algorithms, in on of the algorithm as follows: ...
4
votes
1answer
975 views

Algorithm with chapter number

I want the algorithm to be prefix with chapter say in chapter 1, it should be 1.1, 1.2, for chapter 2, it should be 2.1, 2.2 But for my case, i only have 1,2,3,... across all chapters, how should I ...
1
vote
1answer
146 views

algorithm2e single-line control structures

I am using algorithm2e for formatting pseudo-code: is it possible to compress single-instructions control structure to one single line? For example I would like to modify this so that l.sort() ...
4
votes
1answer
145 views

Algorithms in front of the text!

I am writing a document using the book class. At some point, I need to place an algorithm in the text. I am using the algorithm2e.sty package to write my algorithms. So, I write ...
2
votes
0answers
111 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 ...
1
vote
0answers
35 views

algorithm2e problem [duplicate]

Source code I'm working on a LaTeX project which brings 5 files: cassio.bib: bibliography comandos.tex: a rich set of commands for easiness of typing tg.tex: document's source code tg.pdf: ...
4
votes
1answer
192 views

Alternative for SetKwInParam in algorithm2e

In recent versions of algorithm2e SetKwInParam no longer exists: REMOVE: - SetKwInParam has been deleted since not useful itself because of different macros which can do the same in a better and a ...
2
votes
1answer
1k views

Undefined control sequence \SetKwProg [closed]

The minimal (not) working example is \documentclass{article} \usepackage[algo2e,ruled,vlined]{algorithm2e} \begin{document} \begin{algorithm2e}[h] \SetKwProg{myproc}{Procedure}{}{} ...
5
votes
2answers
1k views

How to avoid the number line for comments under algorithm2e

In the declaration of the input and output data, I would like to add a comment in order to explain the kind of data. I use: \usepackage[ruled,vlined]{algorithm2e} My code is: \begin{algorithm}[!ht] ...
0
votes
0answers
489 views

algorithm2e indentation / line break

I have the following problem: I am writing a couple of algorithms using algorithm2e. I have a bunch of longer if statements and longer if conditions. The lines are broken, but the new lines are not ...
1
vote
1answer
121 views

How to define new loops in algorithmicx?

How can I define a new loop in algorithmicx? For example, code like this: ex1) PreLoop s do --statement1 --statement2 ex2) PostLoop s do --statement1 --statement2 Is it possible to define it ...
3
votes
2answers
872 views

algorithm2e with boxruled gives overfull hbox

I am using the algorithm2e package with the boxruled option to format my pseudo-code. However, I am getting an overfull hbox, which I suspect is due to margin/box conflicts. Does anyone have a fix ...
5
votes
2answers
878 views

How to avoid printing the algorithm number in algorithm captions?

I am using the algorithm2e package to write algorithms. However, when i write three algorithms one after another, the algorithms are automatically numbered 1,2 and 3 in the caption. I am using ...
1
vote
0answers
159 views

Text Wrap with algorithm2e [closed]

I'm using algorithm2e for algorithms and for some of the longer algorithms, (eyeballed at > 50% of a page) there is no other text on the page with just an embarrassing amount of white space above and ...
4
votes
2answers
358 views

How to use Nameref with Algorithm2e

As the title suggests, I'm trying to reference to an algorithm created by algorithm2e package. Here is a MWE: \documentclass[12pt,a4paper]{report} \usepackage[linesnumbered]{algorithm2e} ...
4
votes
2answers
749 views

using standalone with algorithmicx or algorithm2e

I am trying to compile a standalone file containing pseudocode created with the algorithmicx package. According to algorithmicx crashes standalone it should work with the preview option set for ...
6
votes
2answers
984 views

Problem with algorithm2e and portuguese option

I have this little algorithm with two For statements and one if-else. I'm using the option portuguese on the preamble and here's the problem: instead of displaying the words "faça" and "fim" (do and ...
2
votes
1answer
571 views

Colors in Pseudocode matlab style

How do I get colours and more control over spacing in the algorithmic package like this: I tried this which looks good, but has numbers: \begin{enumerate} \item Create the cumulative sum of ...
2
votes
1answer
1k views

Restyling the caption in an algorithm created with algorithm2e

In the caption of an algorithm created with algorithm2e, \documentclass{article} \usepackage[ruled]{algorithm2e} \begin{document} \begin{algorithm}[H] \caption{Caption.} pseudocode ...
9
votes
2answers
5k views

What is the best looking pseudo code package?

I have stumbled across various pseudo code packages but can't seem to find that's simple and eye-candy and practical. What I'm looking for: Visually attractive structure (eye-candy) ( easy to look ...
5
votes
1answer
262 views

Algorithm2e - Permanent fix for no italics if-clause

I am using algorithm2e to create pseudocode for my document. However, it has it so that the conditions in if clauses are italicised. This solution suggests putting an \upshape in each if condition. ...
3
votes
1answer
464 views

Implementing indent in algorithm environment

I am using the algorithm environment in the algorithm2e package. What I want is to able to indent various portions. I tried \indent but that is doing me no good. Here is the MWE: ...
4
votes
1answer
365 views

algorithm2e: Exclude functions from \listofalgorithms

I'm using the package algorithm2e and create a list of algorithms with \listofalgorithms. My problem is that not only the algorithms (algorithm), but also the functions (function) are displayed in the ...
2
votes
1answer
851 views

Disable line numbering of specific lines

Is there way how to turn off numbering of lines for specific line in algorithm2e? I need bold : after keyword. So I tried redefine these macros: \renewcommand{\KwIn}[1]{\textbf{Input:} #1} ...
5
votes
2answers
4k views

Changing label name for algorithm

I have this algorithm: \begin{algorithm} \captionsetup[algorithm]{name=MegaAlgorithm} \DontPrintSemicolon \KwData{$G=(X,U)$ such that $G^{tc}$ is an order.} \KwResult{$G’=(X,V)$ with $V\subseteq U$ ...
5
votes
1answer
1k views

algorithm2e and \algomargin with negative value

How can I use a negative length in \algomargin using algorithm2e? I get the unpleasant effect that the vertical lines and the caption are not moved accordingly, see for example: Note that this ...
9
votes
3answers
584 views

algorithm2e + cleveref: problem with wrong reference to line numbers

For some reason I do not understand, cleverefproduces wrong references to line numbers of listings produces with the algorithm2e package. I hope that I did not miss a simple solution ... My example ...
2
votes
1answer
691 views

No italics in algorithm2e if-clause

Why does algorithm2e typeset the variables anychange and done in italics, and how can I turn this off? How can I remove the semicolon after done in the until-clause? $\textsf{anychange} \gets ...
3
votes
1answer
6k 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
1answer
309 views

verbatim environment inside algorithm2e

I need to output Prolog style inside algorithm2e and It seems that I cannot use \verb inside algorithm2e. How can I use \verb or verbatim for only one line inside algorithm2e in Latex?
4
votes
1answer
5k views

algorithm2e and Beamer - How to make algorithms wider with smaller font?

I would like to make the algorithm2e environments wider in a beamer document. Indeed I must you a \scalebox to see all of my algorithm. Is there a way to have wider algorithms with smaller size font ...
2
votes
1answer
1k views

How to break lines in conditions using algorithm2e?

I am trying to (partially) reproduce the algorithm displayed in Figure 4 from NetFlow: Information Loss or Win? My problem is with the multi-line conditions present in the "IFs". I want them to be ...
4
votes
1answer
1k views

Algorithm2e modify line numbers

I'm using the LaTeX algorithm2e package by defining \usepackage[ruled, linesnumbered, vlined]{algorithm2e} The linesnumbered argument adds lines numbers from [1,...,n] if we have an algorithm with ...
8
votes
2answers
787 views

algorithm2e noend option produces wrong label

I have a problem with the algorithm2e package. I want to reference the end of a block, e.g., a for-loop, in my text. Therefore, I place a label behind the closing bracket of the for statement. When I ...
3
votes
1answer
442 views

How to remove newline character after case statement in algorithm2e?

I don't want any newline character after case statement. How can I do that? This is my code: \begin{algorithm}[t] \SetInd{0.5em}{0.5em} \KwIn{Data $\mathsf{D}$} \KwOut{List of Simple Hints} ...
0
votes
0answers
42 views

writing part of a pseudocode [duplicate]

I have a few pseudocode lines like for each item in list L if (item > 50)| (item > 50)|(item > 50) value=item break; Obviously, this is not the exact code :). If I use a package ...