Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [algorithm2e]

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

3
votes
1answer
23 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
43 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
28 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
21 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
31 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
64 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
20 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
28 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
42 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
33 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
32 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
22 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
72 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\...
3
votes
1answer
95 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
21 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
39 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
54 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
47 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
52 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
43 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
53 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
88 views

latex Algorithm

I need some help to reproduce the following algorithm in LaTeX
2
votes
1answer
101 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
73 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
81 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
132 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
45 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 ...
2
votes
1answer
302 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
62 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
225 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
525 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
63 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
68 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
145 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
69 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
97 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
93 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
103 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
111 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
68 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
95 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
84 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
986 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 ...
0
votes
1answer
282 views

Remove the semicolon at the end of the line (algorithm2e)

When using the algorithm2e package each line MUST end with \;. In the compiled document a semicolon also appears at the end of the line. One can avoid this if the line is written inside a macro. The ...
3
votes
1answer
173 views

IEEEbiography not complying properly

I am trying to compile the following code that contains a biography at the end such that \newif\iffinal \finaltrue %\finalfalse \iffinal \documentclass[]{IEEEtran} % \else \documentclass[11pt,...
1
vote
1answer
144 views

Undefined control sequence \for loop

\begin{algorithm}[tb] \scriptsize $\prod_m$: Manipulated Call Trace, \scriptsize $\prod_n$: Natural Call Trace \\ \scriptsize $\Delta_m$: Unaligned Call Trace in $\prod_m$, \scriptsize $\Delta_n$:...
4
votes
1answer
96 views

Incorrect output with algorithm2e when using “newtxtext” package

I have a LaTeX document displaying an algorithm and the output is incorrect when I use the package newtxtext with algorithm2e. Here is the minimum working example that shows this problem. \...
1
vote
1answer
159 views

algorithm2e: too wide when in \item

Consider \documentclass{article} \usepackage[tworuled]{algorithm2e}%%% v5.1 or v5.2. Could not find v5.3 for download. \usepackage{lipsum} \begin{document} \lipsum[1] \begin{algorithm}[H] TEST1 \...
2
votes
1answer
155 views

Function numbering in algorithms

Algorithms are getting numbered automatically but unable to get same for the functions. In the following example, Algorithms are numbered as Algorithm 1 and Algorithm 2 by themselves but Functions ...