Questions tagged [algorithm2e]
{algorithm2e} is a package providing a floating algorithm environment with algorithmic keywords.
735 questions
2
votes
1
answer
56
views
algorithm2e - Functional programming style match-with using custom Switch
I want to recreate the match-with construct typical in functional programming languages using the algorithm2e package. I've found that \SetKwSwitch gets me most of the way there, but it forces the 'do'...
2
votes
2
answers
74
views
Box around algorithm left vertical line alone
In alogorithm2e, output have a boxed frame, but I need a left vertical line alone. How can we achieve this. I have attached a screenshot as expected.
MWE:
\documentclass{article}
\usepackage{...
2
votes
1
answer
41
views
Create a new environment based on `algorithm2e` with an independent counter and correct `hyperref` links
I'm trying to create a new LaTeX environment, let's call it algprocedure, for typesetting procedures. I want it to look and feel exactly like the algorithm environment from the algorithm2e package, ...
0
votes
1
answer
53
views
Algorithm formatting in JMLR LaTeX template with algorithm2e (missing horizontal lines and indented caption)
I am preparing a submission using the JMLR LaTeX template (link to template), and I am running into some formatting issues with algorithm2e.
When I compile the following code:
\begin{algorithm}
\...
0
votes
0
answers
60
views
Displaybreak for algorithms
I have the following problem. I have a relatively long pseudocode, and when I have text before it, either 1) there is a lot of white space, or 2) the text on the previous page is stretched out, or the ...
2
votes
1
answer
109
views
In algorithm2e, how to stack the function parameters vertically
Suppose I have this textual code:
foo(a, b, c)
I want to typeset it such that in the result .pdf file it appears this way:
foo(a,
b,
c)
In addition, ChatGPT provides a "solution" ...
3
votes
1
answer
73
views
Aligning equation numbers correctly in an algorithm
I am writing an article in which I use the algorithm environment. When I put a numbered equation in the algorithm (sorry computer science people), the equation number is not aligned properly. Very ...
3
votes
0
answers
34
views
Put vertical rule to outside of code block in algorithm2e
I am trying to write the following pseudocode:
In text form:
citește n,x,y (numere naturale nenule, x≤n, y≤n)
nr←0
┌pentru i←n,1,-1 execută
│┌dacă i%x=0 și i%y≠0 atunci
││ nr←nr+1
││altfel
││┌dacă i%...
5
votes
1
answer
114
views
imperfect alignment of middle lines' number compared with the first and last one in algorithm2e package
Documentation:
As the title, if we texdoc algorithm2e, in the documentation of Page 5, the example of "Algorithm 2: disjoint decomposition", we zoom in and the last line's number is not ...
0
votes
0
answers
69
views
Indentation Lines of algpseudocodex does not work in RTL cases
I am trying to create a template for algorithms in Persian. I have the following piece of code, where I am using algpseudocode along with algorithm package. This setup works nicely; however, I would ...
2
votes
1
answer
35
views
algorithm2e package: print caption without text "Algorithm <number>:"
When I add a caption to my algorithms, it appears on the top, just as I want, however, it is always preceded by a text like "Algorithm 1:". For example, this code
\documentclass{beamer}
\...
3
votes
1
answer
205
views
Line numbers outside the box in algorithm2e
I'm new to LaTeX and I'm facing a problem while writing my proposal through Overleaf.
As this pic, the line numbers of my alg are outside the box.
Is there anyway to solve this problem?
Here is my ...
2
votes
1
answer
64
views
Change color of vertical line in algorithm2e with \SetAlgoVlined
I am looking for a method to change the color of the vertical line between while statements, for loops, and so on in the algorithm2e package, similar to the answers proposed in this question, but ...
0
votes
1
answer
35
views
Algorithm2e draw vertical line separator after line numbers
Is it possible to draw a vertical line as a separator between the line numbers and algorithm? The line height and position should be automatic and not hard coded and adjust to algorithm height. There ...
1
vote
1
answer
148
views
How do I escape usage of algorithm2e (incompatible with tagpdf) within a document
Some of the algorithm passes the compilation process. Rest throws an error !Package tagpdf Error: The number of automatic begin (21) and end (18) (tagpdf) text-unit para hooks differ!
Is there a ...
3
votes
1
answer
85
views
Horizontal line in algorithm2e Environment
I am trying to put a line in algorithm2e:
\documentclass{IEEEtran}
\usepackage[ruled,linesnumbered]{algorithm2e}
\begin{document}
\IncMargin{1.5em}
\begin{algorithm}
algorithm here\;
\hrule
...
1
vote
0
answers
58
views
Full width algorithm2e always floats to the next page
I am using a fill-width algorithm in two columns mode; however, it always floats to the next page even though the current page is empty:
\documentclass{IEEEtran}
\usepackage[ruled]{algorithm2e}
\begin{...
3
votes
2
answers
140
views
algorithm2e change color of colon (:) after Input/Output
I am using this code:
\documentclass{IEEEtran}
\usepackage{amsmath,amssymb,amsfonts}
\usepackage{xcolor}
\usepackage[ruled,lined,linesnumbered]{algorithm2e}
\SetKwInput{input}{\textcolor{black}{Input}}...
0
votes
1
answer
75
views
Dotted box around algorithm
We need the box with dotted rules around the algorithm. I tried using
\usepackage[boxruled]{algorithm2e}. The rule comes as solid rule instead of dotted what I required.
Can you please check and ...
1
vote
1
answer
73
views
Set the line number in algorithm2e [duplicate]
As the title specifies it: Is there a way to reset the line number of a single algorithm when using algorithm2e? My use case is to start line numbering of an algorithm from 26.
Non working minimal ...
6
votes
1
answer
343
views
algorithm2e + hyperref + cleveref: algorithms' lines are not numbered/referenced properly
Apparently there is something wrong in the combined use of algorithm2e, hyperref, and cleveref. (I am on the last version of MiKTeX for Windows, with all the packages updated. It used to work properly)...
1
vote
1
answer
73
views
algorithm2e can't deal with 2 for loops? Nothing visible
I wrote this algorithm in algorithm2e and it only gets visible in the PDF when I delete the last for loop, does anyone know why?
\begin{algorithm}
\caption{variable normalization}
\KwData{CNF formula $...
3
votes
2
answers
148
views
Change color/style of vertical line between block start-end in algorithm2e
How can I change the line color (and for that matter style, such as line width, dashed, double lines) of the vertical lines between block start-end keywords in the algorithm2e package? Thanks in ...
0
votes
1
answer
43
views
How to embed enumerated lists, algorithms, pseudocode and flowcharts in a tabular environment
good day.
I want to add listing (bulleted and enumeration), algorithms, pseudo code and flowchart in a tabular environment. For example
\documentclass[a4paper]{article}
% Package used for input and ...
0
votes
0
answers
40
views
I want to split the algorithm to other column (in this case, the column of the next page). The format is a 2 page column
My code is:
\State \textbf{Initialize: }$n_{ch,IA} \gets false$, $n_{ch,DA} \gets false$, $reached_{IA} \gets false$, $w_{n_{ch,IA}} \gets false$, $w_{r_{low,IA}} \gets false$, $v_{red,computed} \gets ...
3
votes
1
answer
131
views
Indent format of algorithm2e in revtex4-1
When I use algorithm2e package to write a paper in vertex 4-1 with WinEdt7, the output pdf file has a wrong indent format in the algorithm part. Everything is messed up! It looks like this:
What ...
0
votes
0
answers
54
views
How to make an algorithm box smaller inside a figure environment?
I have following code for an algorithm block:
\usepackage{algorithm}
\usepackage{algorithmicx}
\usepackage{algpseudocode}
\usepackage{enumitem}
\usepackage{minibox}
\usepackage{multirow}
\usepackage{...
2
votes
1
answer
108
views
For and end for alignment in algorithmic
I have been writing my research and had to use a lot of algorithm inserts, and I haven't worked with it enough to solve this issue. My For and EndFor part don't seem to align no matter what.
I tried ...
1
vote
1
answer
50
views
Text in math environment in algorithm2e has different typography when placed inside a for loop
The following MWE:
% Created 2016-07-04 Mon 15:02
\documentclass[a4paper, 12pt]{article}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{mathtools, nccmath}
\usepackage[...
4
votes
2
answers
92
views
Additional line created when using equations in algorithm2e
Consider the following example, placing equation*s inside of an algorithm environment:
\documentclass{standalone}
\usepackage{amsmath}
\usepackage{algorithm2e}
\LinesNumbered
\begin{document}
\...
1
vote
1
answer
139
views
How to fix numbering of an algorithm in algorithmc and algorithm environment?
I have some pseudocode for an algorithm, which appears okay (with some minor errors in compilation). But the biggest problem is that the numbering of the steps does not match the number of steps in ...
0
votes
1
answer
178
views
Reproducing Python/Programming Code Blocks with modification
I want to be able to reproduce this environment within the context of exam correction.
One clue I found is the usage of the bclogo package.
https://ctan.org/pkg/bclogo
Howerver, I would like to ...
0
votes
0
answers
91
views
problem with using algorithm2e after installing Texlive 2024
I installed texlive 2024 using this link on Ubuntu 2022.04 and added the latex folder to system paths I can compile the document when I do not use algorithm2e package. but unfortunately, when I want ...
1
vote
1
answer
91
views
algorithm2e does not set \texttt
I have algorithms that I wrote in algorithm2e.
But I want the name of the function written in typewriter.
As you see in the picture, this does not work, I get this strange font:
Here is my MWE:
\...
3
votes
1
answer
151
views
ELSE if block after if statement on overleaf throws error
I want to implement a if else block like that
if A
if B
if C
else if D
end
if E
end
end
end
Where if C and if E has same indentation. if B under if A. if C and if E both are ...
1
vote
0
answers
25
views
Algorithm2e does not respect text width when used with exam class [duplicate]
As you can see on the picture, the algorithm environment (from package algorithm2e) does not respect the text width when it is used inside exam questions. Actually, it exceeds the right margin:
\...
1
vote
0
answers
91
views
Extra line with inline if and comment
I'm writing an algorithm with algorithm2e.
I want to do an inline if with \lIf with a comment on the same line with \Comment*.
\documentclass{article}
\usepackage[vlined,boxed,linesnumbered]{...
5
votes
1
answer
208
views
How can I redefine the current label?
I'm having back reference issues when using an algorithm.
Consider the following example
\documentclass{article}
\usepackage[algo2e,linesnumbered,algonl]{algorithm2e}
\usepackage[backref=section]{...
2
votes
1
answer
70
views
How to align caption left in algorithm2e?
\documentclass{article}
\usepackage{algorithm2e}
\SetAlgoCaptionSeparator{.}
\begin{document}
\begin{algorithm}
code\;
\caption{I want to align this caption left}
\end{...
1
vote
1
answer
111
views
How to make the multiple floating blocks not occupying the whole page while keeping the `\intextsep` rule?
I want the floating block used in algorithm2e at the page's top instead of the middle. Here is my sample code with this Tex SX link's help:
\documentclass{article}
\usepackage{lipsum,mathtools}
\...
2
votes
1
answer
138
views
How to tune the multiline equation with the self-defined indentation?
I followed this QA link to left-align the equation and this to prefer using \hspace instead of \hskip:
\documentclass[12pt,a4paper]{article}
\usepackage{amsmath,mathtools}
\usepackage[algosection, ...
2
votes
1
answer
158
views
How to set the KwProg arg font style with something like `\SetProgSty` in algorithm2e?
I followed some QA links like this in tex stackexchange and use this example tex code:
\documentclass[12pt,a4paper]{article}
\usepackage{amsmath}
\usepackage[algosection, boxruled, linesnumbered]{...
1
vote
1
answer
190
views
indentation of long lines in algorithm2e and vertical spacing problem
After spending 2 hrs on this and trying all sorts of things, I give up. I am using algorithm2e and when I have long description lines, the new line gets shifted a little to the right. Also, even ...
2
votes
2
answers
324
views
Algorithm in box and settings
I'd like to restrict my algorithm in a box that it adapts at the width of the algorithm, as in this image:
Here the code
\documentclass{article}
\usepackage[italian]{babel}
\usepackage[utf8]{inputenc}...
1
vote
2
answers
97
views
Algorithm2e, [italianokw] does not function. Why?
In my code below, the option [italianokw] of algorithm2e--package does not function. Why? (I am new in use of this package.)
\documentclass{article}
\usepackage[italian]{babel}
\usepackage[utf8]{...
2
votes
1
answer
626
views
Package algorithm2e: Remove numbering from algorithm title
Consider the following minimal example:
\documentclass[usenames,dvipsnames]{beamer}
\usepackage[linesnumbered,boxed,ruled,vlined,resetcount]{algorithm2e}
\begin{document}
\begin{frame}[fragile]
...
2
votes
1
answer
113
views
Overfull hbox in patched use of algorithm2e environment
I am using the algorithms environment from algorithm2e in a modified way with reduced width (following the solution here), see the MWE below.
This generates an overfull box that I'd like to get rid of....
1
vote
0
answers
70
views
Merge two algorithms style in the same file
Is it possible to put the two following algorithms in the same file. I tried several times but I did not succeed. Thanks for your help.
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{...
0
votes
1
answer
246
views
LaTeX algorithm2e giving error while writing an algorithm in IEEEAccess template [duplicate]
I am trying to compile a .tex file in Overleaf, I am using the IEEEAccess template to write the manuscript. When I compile the LaTeX file, it throws the error on the given algorithm script.
I am ...
0
votes
1
answer
138
views
Problem with \SetAlgoLined in algorithm2e
I am very new to Latex. I have problem with \SetAlgoLined in algorithm2e. As seen from the picture, inside the while loop the line seem to be normal. I don't know why outside the while loop, the line ...