Questions tagged [algorithm2e]

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

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

algorithm2e: reference to line numbers at beginning/end of while-loop

I want to reference to a line where a for/while-loop starts. However, with the normal \label command I cannot set a label in the respective line. How else can I reference to the beginning of, e.g., a ...
1
vote
1answer
38 views

How to show algorithm steps in algorithm2e?

I am trying to figure it out how to show algorithm steps in algorithm2e. My code looks like this: \title{AlgorithmTemplate} \documentclass[17pt]{article} \usepackage{fullpage} \usepackage{times} \...
0
votes
0answers
49 views

How to fix the loop in latex algorithm?

I am trying to write an algorithm in latex but my for loop is ending at wrong place. My code looks like this: \title{AlgorithmTemplate} \documentclass[17pt]{article} \usepackage{fullpage} \...
1
vote
1answer
22 views

Custom keyword algorithm alignment

I'm trying to add a custom keyword for an algorithm block, to indicate the type of object on which the code is applied. I tried using \SetKW{arg1}{arg2} but I could not insert a new line after it (the ...
1
vote
1answer
24 views

nested if in algorithm2e giving errors

Here is the code, I have tried: \documentclass[smallextended]{svjour3} % onecolumn (second format) \usepackage[linesnumbered,lined,boxed,algoruled,linesnumbered]{algorithm2e} \begin{document}...
0
votes
1answer
45 views

Reduce vertical distance between lines in algorithm2e

How do I set the default vertical spacing between lines in algorithm2e? In particular I'm looking for a way to reduce this distance. In this question the author asks how to increase the distance ...
3
votes
1answer
27 views

XCharter dilemma: Must I choose between breaking math or pseudocode displays?

I'm trying to set up fonts for a document with both math and algorithm blocks. I am using XCharter fonts and the algorithm2e package. For some reason, I can't get both typeset right. Here is a MWE to ...
2
votes
2answers
54 views

Adding vertical lines in algorithm2e outside of blocks

I am using the package algorithm2e and notice that it has a great feature where vertical lines can be connected within "blocks" of code (see Vertical loop/block lines in algorithmicx with 'noend&#...
3
votes
1answer
33 views

TikZ in floating algorithm2e

I had a question to strikeout a line in algorithm2e. I got an answer that uses tikz to strikeout the line. This works great. However, if I use a floating algorithm2e (i.e. removing the [H] in \begin{...
0
votes
1answer
23 views

Algorithm 2e - removing semicolons on lines with comments

I am using \DontPrintSemicolonin algorithm2e but the semicolons at the end of lines with comments are still there. This was a problem that was supposed to have been resolved in version 5.0, but I am ...
3
votes
1answer
34 views

How do I strike out line inside an algorithm?

Package I am using: \usepackage[linesnumbered,ruled,vlined]{algorithm2e} My latex code: \begin{algorithm}[H] \label{alg:my-alg} \DontPrintSemicolon \caption{My algorithm} \SetKwInOut{Input}{Input}\...
2
votes
0answers
74 views

How to remove the extra blank line when using TikZ in algorithm2e? [closed]

I want to remove the blank in line 13. However it doesn't work. Can someone help me? Thank you! \documentclass[11pt,titlepage,letterpaper]{article} \usepackage{amsthm} \usepackage{amsmath} \...
1
vote
1answer
24 views

How to center, to align left, to align right and to justify the algorithm title using the algorithm2e latex package?

I am migrating to algorithm2e package. I would like to align the algorithm title as justified according to the text column width. But I also would like to know how to align left, to align right and to ...
0
votes
0answers
37 views

Recursive renew environment using algorithm2e for captions underneath

Putting captions below I am trying to implement putting a caption underneath the algorithm environment when using algorithm2e based on this solution. However, unlike the quoted solution I don't wish ...
2
votes
1answer
44 views

How to add a bullet to line number in algorithms

I want to add a bullet next to a line number as shown in following picture. How can I get this.
2
votes
1answer
36 views

Add algorithm2e to ToC with KOMA-Script

How can I add the list of algorithms from algorithm2e to the table of contents of a KOMA-Script class? MWE: \documentclass[oneside,listof=totoc]{scrbook} \setuptoc{loa}{totoc} %does not work \...
0
votes
1answer
36 views

Algorithm2e: Using function name (as formatted ) in the caption and in the document text

In algorithm2e how can I use the function name (as printed/ style) in the caption and any other part of the document. I notice using the "\FUNNAME" ,in general, sometimes works and sometimes do not. ...
0
votes
0answers
26 views

algorithm2e clash

I am trying to use algorithm2e but experiencing conflicts when I try to compile.. Any idea how I can fix this? Thanks so much, Asaf \documentclass{article} \usepackage[vmargin=1.18in,hmargin=1.1in]{...
0
votes
1answer
73 views

Error emerged when I run the following LaTeX code

The following code gives error message: \documentclass[energies,article,accept,moreauthors,pdftex,10pt,a4paper]{mdpi} \usepackage{booktabs} \usepackage{array} \newcommand{\PreserveBackslash}[1]{\let\...
4
votes
1answer
118 views

How to get the end in algorithm2e

I am using algorithm2e to typeset an algorithm. I like the appearance of the following, but I am not able to get the end to close the ` begin `. Any way to do this? \documentclass{article} \...
1
vote
1answer
22 views

Algorithm2e - Permanent fix for no italics if-clause for all document

I am using algorithm2e to write algorithms, and I use the answer to this question to prevent the text in the algorithm to be in italic (by adding \SetArgSty{textrm} at the start of the algorithm). \...
1
vote
1answer
40 views

How to set a line between begin and end?

\documentclass{article} \usepackage[utf8]{inputenc} \usepackage{latexsym} \usepackage[linesnumbered,ruled,vlined]{algorithm2e} \SetCommentSty{mycommfont} \usepackage[linkbordercolor={0 0 1}]{...
0
votes
1answer
67 views

How can I display my algorithm in two slides when I use algorithm2e in beamer?

I'm making slides with beamer. My algorithm is a little bit long so that I cannot put it in one slide. I need to divide it from the middle of it and display it in two slides. What should I do? \...
0
votes
0answers
24 views

Fancyhdr and algorithm2e line adjustment

I uploaded a picture below. The lines of the algorithm is longer than the header, and I wish to shorten the lines of the algorithm so it would be the same length as the header line. Is there a way of ...
1
vote
2answers
54 views

How to align line numbers horizontally with package algorithm2e

I'm trying to write an algorithm using the package algorithm2e. This is my code: \usepackage[linesnumbered,ruled]{algorithm2e} ... {\footnotesize \IncMargin{1em} \begin{algorithm}[H] \...
0
votes
1answer
70 views

Vertical Lines in Algorithms not appearing

I am using \documentclass[5p]{elsarticle} and packages \usepackage{algorithmic} \usepackage[ruled, vlined, longend, linesnumbered]{algorithm2e} There is no error but did not get the vertical lines in ...
3
votes
1answer
54 views

Adjust boxrule of algorithm2e

I have this code: \documentclass{article} \usepackage[utf8]{inputenc} \usepackage[portuguese, ruled, linesnumbered, boxruled]{algorithm2e} \begin{document} \begin{algorithm}[H] \SetAlgoLined ...
3
votes
1answer
66 views

How to align input arguments of an algorithm in a grid?

I'm writing an algorithm box using algorithm2e and want to align the input arguments in a grid. I got close to the desired layout using two tabular environments, each inside of a minipage. However, I ...
0
votes
1answer
91 views

latex Algorithm

I need some help to reproduce the following algorithm in LaTeX
2
votes
1answer
113 views

algorithm2e left-aligning the caption as the caption for figures in memoir

I am trying to left-align the caption of algorithms of algorithm2e to match the captions of the figures. Taking a look at Align Caption to the left , here is my code so far: \documentclass[12pt,...
2
votes
1answer
91 views

indentation issues in algorithm2e with acmart

I am using algorithm2e package without any problem usually with "article" or some other document classes. But with acmart (sigconf) or elsevier's elsarticle styles, I am having the following ...
4
votes
2answers
85 views

How can I put a black square in an algorithm?

I used to write pseudocode in libreoffice and it looked like this: I'm trying to write something similar in latex.I use algorithm2e.This is the closest thing I got. How can I put a black square at ...
1
vote
1answer
144 views

errors in latex algorithm formatting Something's wrong--perhaps a missing \item

I am trying to write an algorithm and I receive the following errors Missing = inserted for \ifnum. \end{algorithmic} Command \algorithmic already defined. } Missing = inserted for \ifnum. \end{...
2
votes
1answer
46 views

Adding a colon to entries in a list of algorithms

I'm trying to create a list of algorithms such that the a colon appears after every algorithm number. I've included a MWE below that produces the following, I'd like to modify this by adding a colon ...
3
votes
1answer
381 views

How can I create an initialization block in an pseudo algorithm block in Latex?

How can I create the following algorithm block in Latex? I have everything except the init block. How can I create this? \documentclass{article} \usepackage[utf8]{inputenc} \usepackage{algorithm2e} ...
2
votes
1answer
70 views

Algorithm inside a tcolorbox: how to put a label to the algorithm but the caption as title of tcolorbox?

This question comes after a question about algorithms inside tcolorboxes. Before the question, is better to explain what I have now. I have a file with the algorithm that is q-learning.tex. \...
3
votes
2answers
252 views

How to write a pseudo-algorithm with algorithm2e package inside a tcolorbox environment?

I've recently seen in the second edition of Reinforcement Learning: an introduction by Sutton and Barto an appealing way to display pseudo-algorithms. In the following an example image. I think that ...
5
votes
1answer
643 views

Comment on the same line as \If in algorithm introduces a vertical whitespace

I am using the algorithm2e package to write a pseudo code algorithm. I would like to add a comment with \tcp, on the same line as an \If statement. I managed to do so by putting the \tcp command ...
2
votes
1answer
69 views

How to change the indent length for blocks in algorithm2e? [closed]

Algorithm2e automatically indents the code within a block, e.g. inside if-then-else. How can one change the size of this indent? I couldn't find anything in the documentation. There is \...
7
votes
1answer
70 views

How to make “IF” instead of “if” in algorithm?

I have a algorithm below, I want "if" to be "IF". See code: \documentclass{article} \usepackage[linesnumbered,ruled,vlined]{algorithm2e} \RestyleAlgo{boxruled} \begin{document} \begin{algorithm}[H] \...
1
vote
1answer
158 views

How to separate input output from main algorithm part and add end word in if statement?

In the below image, I want to add two things A horizontal line after output which separate input-output from main part of algorithm I want end word (line 5) at the vertical line from if statement. ...
0
votes
0answers
80 views

Restart algorithm numbering of algorithm2e [duplicate]

I am writing several chapters in a book, each chapter containing some algorthms expressed with algorithms2e. The numbering of the algorithms however does not reset when a new chapter starts. Ideally ...
2
votes
1answer
129 views

Creating keywords which have an associated **end** with algorithm2e

As a part of a homework assignment in a Latex course, I have been assigned to write this algorithm in Latex. I have got most of the part done with this code:- \documentclass[12pt]{article} \...
1
vote
1answer
96 views

bad position of a section

I'm currently writing a thesis using Latex. Unfortunatly i'm facing a bad output since two days without resolving it. To explain the problem here is my output: The first page: The second page: As ...
1
vote
1answer
112 views

bad format pseudo code with algorithm2e in latex

I'm trying to add a pseudocode to my article using latex and the algorithm2e package. Unfortunatly i'm getting a bad format for one of my algorithms. Here is my latex file : \documentclass[12pt,...
0
votes
1answer
117 views

Algorithm - formatting

I need some help with formatting my algorithm. What I have so far is this: \documentclass[9pt]{sig-alternate} \usepackage[linesnumbered,ruled]{algorithm2e} \begin{document} \begin{algorithm} \...
1
vote
0answers
78 views

algorithm2e and \numberwithin with section

I am using the package algorithm2e, specifically \usepackage[ruled,vlined,linesnumbered,noresetcount]{algorithm2e} to create the following algorithm: \documentclass[12pt]{article} % \usepackage{...
4
votes
1answer
99 views

typearea warning in connection with algorithm2e package

I'm trying to remove some warnings from my thesis but there is one I cannot understand at all. It's some strange interaction between the typearea package and the algorithm2e package. Here's a mwe: \...
1
vote
1answer
96 views

Prefix algorithm number with algorithm2e

When using the algorithm package it is possible to prefix algorithm numbers with a string (in this example Cool.) like so: \renewcommand\thealgorithm{Cool.\arabic{algorithm}} (This works for a bunch ...
0
votes
1answer
1k views

Exception handling pseudocode (try-catch) for algorithm2e package

It appears that there is no such try and catch blocks in algorithm2e. Is there a way to add custom blocks for try and catch in algorithm2e? There is a solution in GitHub which shows how this can be ...