{algorithms} is about the presentation, numbering, and layout of algorithms or pseudocode in documents. Popular packages are algorithms, {algorithmicx}, {algorithm2e} and {listings}. For questions about the specific package, use the appropriate tag instead.

learn more… | top users | synonyms (1)

2
votes
0answers
13 views

algorithm2e command \procedure already defined

I included algorithm2e and start getting error message of "algorithm2e.sty command\procedure already defined." Here are the list of packages in my latex file \documentclass[useAMS,usenatbib]{coin.cls}...
1
vote
0answers
12 views

How to produce an extract of an algorithm using algorithmicx?

Having an algorithm written with the package algorithmicx, I'd like to rewrite two (single) lines in a later section of my document. However, if possible, I'd prefer not to write the complete ...
4
votes
2answers
41 views

How to fit an algorithm into a template?

My aim is to fit this long single-line algorithm into a double column page lay out, just as it is shown in the below, in 3 different lines, but I cannot use \State and I do not know why and how can I ...
3
votes
1answer
33 views

autoref for algorithms

\usepackage{algorithm,algpseudocode} \usepackage{hyperref} So when I \begin{algorithm} \caption{Baseline}\label{ALG_baseline} \begin{algorithmic}[1] ... \end{algorithmic} \end{algorithm} the ...
1
vote
0answers
36 views

How to write an algorithm as a column inside the table

Let us consider the following code and the algorithm corresponding to it \documentclass{article} \usepackage[utf8]{inputenc} \usepackage[]{algorithm2e} \begin{document} \begin{center} ...
2
votes
1answer
25 views

Not A Member sign in math mode in algorithm2e

For the below algorithm, i get the erorr ! Extra }, or forgotten $. \egroup l.759 } I think having another prantes in the if condition is also another problem, that I do not know how to cope with. ...
2
votes
1answer
29 views

How to reinitialize the lines counter for algorithms?

I have four algorithms in a section but the problem is that the lines numbering doesn't start with 1 in each algorithm. For example, the first one is numbered from 1 to 11 but the second one start ...
1
vote
1answer
24 views

how to write algorithm in latex?

I want to write this algorithm: for(i=0;i<nbOfPedCurr;i++){ for(j=0;j<nbOfPedPrev;j++){ int idCurr=idCurrentFrame; int idPrev=idPrevFrame; if(idCurr==idPrev){ CurrObj=...
2
votes
1answer
22 views

How to put left aligned equation inside algorithmic

I have a one-line equation that I want to use just like a statement in algorithmic. I tried with flalign and the equation still goes into the center. Could you please tell me how to fix that? Here is ...
2
votes
2answers
64 views

list of algorithms with tufte-book

The following MWE produces a "List of Algorithms" heading but no list below it. \documentclass[a4paper,twoside,justified,marginals=raggedright,nofonts,nobib,]{tufte-book} \RequirePackage[noend]{...
1
vote
0answers
27 views

Unrecognized command in Algo, but the code can be compiled [duplicate]

I use Texstudio. I have installed package algorithm and algpseudocode. The unrecognized command are all marked in red, but they can be complied. I want to know, why this problem appears and how to ...
0
votes
0answers
28 views

No compilation errors but my pseudocode is not visible in the pdf file. I am using a two-column template

Are some packages incompatible with some templates? I am trying to write pseudocode using the algorithm/algorithm2e package. I am using a template downloaded from a latex templates website. http://www....
1
vote
1answer
36 views

Insert indent in algorithm at line break of the same \State

I have the following code: \documentclass[12pt,a4paper,twoside]{book} \usepackage{graphicx} \usepackage{algorithm} \usepackage{algpseudocode} \begin{document} \begin{algorithm*}[t!] \caption{...
3
votes
1answer
43 views

Make listing a floating image

I have used the listings package for including a program into a LaTeX document. But the program splits into two when a page is finished. I want to make the listing behaved like an image, so that it ...
1
vote
1answer
35 views

Cases inside an algorithm environment

I need to write an algorithm where multiple cases are handled. I have succeeded but the output shows a lot of vertical space below and above the cases statement. Anyone help me to fix this. I am using ...
0
votes
0answers
46 views

Formatting an algorithm with a nice presentation

I was reading this paper and I think is really nice the format how they present the algorithms, how can I do this? what packages are needed and the styles. Thanks in advance.
4
votes
2answers
139 views

Writing results of some code

I am doing some homework on Newton's method and would like to display results after five (or so) iterations. I was hoping for something along the lines of > 0.001 > 0.011 > 0.111 > 0.111 &...
0
votes
0answers
16 views

How to add line numbers to my Algorithm in Latex

I am writing an algorithm in LaTeX. I am already using the following packages for algorithms: \usepackage{algorithmic} \usepackage{algorithm} \usepackage{amsmath} i am also using the \STATE tag. i ...
0
votes
0answers
30 views

How to write the algorithm with bold keywords and line numbers

I wish to write an algorithm like the following, with keywords bold and line numbers in each line. Could someone help on how to use latex to write this kind of algorithms?
0
votes
1answer
43 views

Write down the algorithm

I am trying to write down my algorithm and faked I wrote Foreach loop. Otherwise there is no command \Foreach. The followingmy program could not be executed. Also I use package \usepackage{...
1
vote
0answers
70 views

No algpseudocode-package in TeXstudio

I am using TeXstudio for writing my thesis. I am tying to use the algpseudocode-package, but it says that the package isn't found. Here is the screenshot of the error that I am getting:
1
vote
0answers
9 views

alignment within algorithm environment [duplicate]

I would like to align some statements so that it's more pleasing to the eye. I have the following code, where the first version the two statements are not aligned. I use \phantom to force alignment ...
0
votes
0answers
38 views

footnotes just after algorithm

I am trying to add footnotes at the end of an algorithm environment (not at the end of the page). I found this post where this is done but there are no numbers to refer to the footnote. So if I want ...
2
votes
2answers
52 views

Help with algorithm2e formatting

recentely I've got into a bit more advanced LaTeX formatting, i.e algorithms. My package of choice is the algorithm2e package, but I'm having some difficulities operating it. So I've wanted to create ...
2
votes
1answer
36 views

sub-algorithms using algorithmic, part a part b

I am currently displaying algorithms in a sequence 1-9. Now I have for example algorithm 7 and I would like to name it algorithm 7a and the next one will be algorithm 7b and then algorithm 8 again. ...
1
vote
0answers
73 views

Multiple conditions in a “If” algorithm

I've done a lot of searching in google but not found any answer to my question. I'm searching for a way to write this in latex : if ( (t<-3) || ((s>4)&&(t<3)&&(tendency>-3)...
2
votes
1answer
30 views

How to remove the tab from the listofalgorithms (ToA)

How can I remove the tab from the \listofalgorithms so that it always starts without indent? \documentclass[12pt,a4paper,twoside]{book} \usepackage{algorithm} \usepackage{algorithmic} \begin{...
3
votes
1answer
64 views

How do I rename “Data” (from \KwData{}) and “Result” (from \KwResult{}) in \begin{algorithm} to something else?

Say I have the following code: \begin{algorithm} \KwData{my data} \KwResult{my output} my algorithm \caption{my caption} \end{algorithm} It will produce something like this: Algorithm 1: my ...
2
votes
1answer
53 views

If algorithm in Latex

I want to create a simple algorithm in my latex document. I have a variable which comes to my latex template from the web-form it can have just two values "yes" or "no", so in case if this value "yes" ...
3
votes
2answers
115 views

Ampersand symbol algorithm environment

How to make a "normal" looking ampersand symbol within the algorithm environment? I'm using \& but this results in a strange looking character as shown below: Here is a minimal example how I ...
0
votes
0answers
24 views

Change the format of an algorithm from a table to any algorithm typesetting

I have been struggling to format the pseudocode of my algorithm from the current state (in a table) to the one provided by the algorithm package. After several tries with answers like: one, another, ...
0
votes
2answers
64 views

Pseudo code for this algorithm

I am new to LaTeX ... I have searched many examples of algo pseudocode for this type of code.I don't know which package to use to write this algorithm. Please help me with the code.
3
votes
1answer
34 views

SetKwInOut error

I'm having some problems with the algorithm2e package. Here's the code: \begin{algorithm} \caption{Tree merge algorithm\label{alg:merge}} \SetKwData{H}{H}\SetKwData{M}{M}\SetKwData{C}{C}\...
2
votes
1answer
66 views

Symbols between figures

I would like to add symbols between Figures Figure 1 + Figure 2 ---> Figure 3 Please redirect on how it can be achieved.
1
vote
1answer
54 views

rectangle containing text pointing from minipage

I would like to achieve the following: The current code that I have is: \scalebox{0.65}{ \begin{minipage}{0.95\textwidth} \begin{algorithm}[H] %new code \begin{...
0
votes
0answers
28 views

Adding brace next to column in beamer and writing text in a box

I am creating a presentation in Beamer. I would like to achieve the following: Please guide on how that can be achieved. Also I would like to this if an algorithm is written in the bigger box.
1
vote
0answers
14 views

Getting Error in writing algorithm in latex

I am facing error saying "! Missing number, treated as zero.\ALG@b@2@ELSE@0 \ELSE" in writing the following algorithm in Latex.I can't understand what is the problem. \begin{algorithm}[H] \caption{...
2
votes
1answer
321 views

How can I create vertical lines indentation in algorithm pseudo code correctly without end keywords?

I found this answer and I applied it but this is the result. This is my code. \documentclass[conference]{IEEEtran} \usepackage{amsmath} \usepackage{amsthm} \usepackage{amssymb} \usepackage{dsfont}...
1
vote
0answers
164 views

Genetic Algorithm pseudocode [closed]

Hi everyone, this is my first post, so apologise if not doing it properly. I need the following GA pseudocode (Photo) in LaTex, but couldn't do it very well. I really appreciate your help.
0
votes
0answers
38 views

Procedure numbering in packages algorithm and algcompatible

When I use both packages algorithm and algcompatible, I find the algorithms can be easily numbered, but the procedure cannot. How can I number the Procedures in algorithm, like Procedure 1, ...
2
votes
1answer
81 views

algorithm, how to start line numbering at given number (using algorithm2e)

I wonder how to start a code at a specific number; this is necessary when the algorithm is broken over two pages. A small example that I would like to start at line 39 instead of line 1. Is there a ...
1
vote
1answer
60 views

Number the algorithms with itemize or other environment

I am trying to number the two algorithm environments and put some space between each other but I am just getting the numeration at the side? How can I manage it to get the number before the algorithms?...
0
votes
0answers
38 views

Approaches to automatically scale figures

I am trying to come up with a general rule of thumb to scale figures such that their vertical size and horizontal size does not exceed a certain limit (assume 300pt). The monkey patching way to do ...
0
votes
1answer
66 views

Wrong number when reference inside algorithm

\usepackage{algorithm} \usepackage{algorithmic} \begin{algorithm}[tb] \caption{Algorithm} \label{alg} \begin{algorithmic}[1] \STATE blalblabla \label{cond1} \STATE ...
1
vote
0answers
39 views

A library of common algorithms? [closed]

Is there a latex package, or other resource, which provides a library of common algorithms? The LaTeX wikibook discusses 4 different algorithm typesetting packages for LaTeX; but I'm not fussy as to ...
4
votes
1answer
72 views

Align equal sign in algorithm in vertical line

The Code described in [1] produces the following output : For the description of my algorithm I need the equal signs to be perfectly aligned in one vertical line but currently there is still a ...
0
votes
1answer
45 views

List of algorithms not working with amsbook document class

I am using \listofalgorithms in a document with \documentclass{amsbook}. It seems the two clash for some reason. When I run pdflatex, I get the following error message: (./main.loa ! Undefined ...
1
vote
0answers
53 views

Help identifying LaTeX code-style feature

The document below uses a feature I can't quite identify to display monospaced code-style font sections: Does anyone know how to achieve this effect?
4
votes
1answer
88 views

Inconsistent caption height in algorithm environment

I noticed that the height of the caption of the algorithm environment does not solely depend on the font size, but on the actual caption text as well: \documentclass{scrartcl} \usepackage[ngerman]{...
0
votes
0answers
39 views

How to illustrate vector operations in algorithm environment?

Is there a nice standard way to represent a vector, and things like vector creation, and operations like push_back, or add in the algorithm environment?