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.

1
vote
1answer
21 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 class? MWE: \documentclass[oneside,listof=totoc]{scrbook} \setuptoc{loa}{totoc} %does not work \usepackage{...
0
votes
1answer
22 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
18 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
63 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
60 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} \...
0
votes
1answer
31 views

What's the reason for the error when using algorithm2e?

When I tried \usepackage{algorithm2e}, Tex said 'Command \algorithm already defined'. I have searched for this and found that this is usually because that package algorithm is not compatible with ...
1
vote
1answer
18 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
32 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
40 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
21 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 ...
0
votes
1answer
29 views

How to align horizontally line numbers 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
34 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
36 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
46 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 ...
-1
votes
1answer
86 views

latex Algorithm

I need some help to reproduce the following algorithm in LaTeX
2
votes
1answer
73 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
58 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
75 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
100 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
38 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
165 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
54 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
164 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 ...
4
votes
1answer
278 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 ...
1
vote
0answers
36 views

How to change the indent length for blocks in algorithm2e?

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
64 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
113 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
47 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 ...
0
votes
0answers
15 views

clashing line numbering of algorithm2e and lineno

I am using the line numbering package via \usepackage[left,pagewise]{lineno} and the algorithm2e package via \usepackage[ruled, linesnumbered]{algorithm2e} The numberings for both clash. For ...
2
votes
1answer
62 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
85 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
83 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
90 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} \...
0
votes
0answers
58 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
86 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
72 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
681 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
200 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
130 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
120 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
77 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
129 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
140 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 ...
3
votes
0answers
81 views

Unexpected side-comment alignment with algorithm2e

In package algorithm2e you can have side comments aligned in four different ways, depending on the option used (see Section 11.4 of the package's manual). In the following mwe, there are two copies ...
1
vote
1answer
171 views

Rename Procedure in algorithm environment

I use the following algorithm many times throughout my paper: \begin{algorithm}[!t] \caption{Title} \begin{algorithmic}[1] \Procedure{Graph}{$ \alpha, \beta $} \State ... \...
1
vote
0answers
64 views

Input variables in parenthesis in caption of algorithm

I would like two things Have the list of input parameters shown in paranthesis behind the caption of the algorithm, but hidden in the algorithm (the traditional "intput: X,Y,Z" ). Be able to ...
0
votes
0answers
56 views

How to show up “end” in algorithm2e?

I import the package as follows: \usepackage[ruled,linesnumbered]{algorithm2e}. When I use \For{~}{~} or \If{~}{~}, the end is well shown up for me. However, when I use \lFor{~}{~} or \lIf{~}{~}, the ...
5
votes
2answers
135 views

Moving part of algorithm horizontally preserving indentation

Let us consider the following MWE codes Code 1: \documentclass{article} \usepackage[utf8]{inputenc} \usepackage[algo2e]{algorithm2e} \begin{document} \begin{center} \begin{algorithm2e}[H] \...
3
votes
1answer
115 views

How to remove extra space in algorithm2e

I am using algorithm2e package to write an algorithm. I need to define functions where their descriptions are multi-lines. In the first function only, algorithm2e adds extra space in the second, third,...
0
votes
1answer
123 views

How to use chapter number in algorithm numbering in Latex [duplicate]

I am using the algorithmic and algorithm2e package to write the algorithm. I want to use the chapter number in algorithm number. for example for chapter number 3 the first algorithm should be 3.1 and ...