{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
1answer
19 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
21 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){ ...
2
votes
1answer
16 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
57 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} ...
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
22 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. ...
1
vote
1answer
31 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!] ...
3
votes
1answer
40 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
32 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
37 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
133 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
15 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
25 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
37 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 ...
1
vote
0answers
55 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
26 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
37 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
25 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
49 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) || ...
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} ...
3
votes
1answer
42 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
49 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
97 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
23 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
54 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
27 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}} ...
2
votes
1answer
58 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
52 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 ...
0
votes
0answers
25 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
10 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] ...
2
votes
1answer
197 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} ...
1
vote
0answers
129 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
27 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
62 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
42 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 ...
0
votes
0answers
37 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
62 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
61 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
39 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
52 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
81 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} ...
0
votes
0answers
34 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?
2
votes
1answer
71 views

putting algorithm in box

Below is my code snippet. Please help me to put a framed box in my algorithm. \documentclass[journal,12pt]{IEEEtran} \usepackage{algorithmic} \usepackage{graphicx} \usepackage{algorithm} ...
3
votes
2answers
73 views

Having separate captions for algorithms inside a tabular

I have the following code: \documentclass[10pt,conference,compsocconf,letterpaper]{IEEEtran} \usepackage{algpseudocode} \usepackage{algorithm} \begin{document} \begin{algorithm*}%[H] ...
1
vote
1answer
89 views

Error in listofalgorithms, undefined control sequence in .loa file [closed]

I am trying to write a pseudo code in LaTeX, and want to list the algorithm in the \listofalgorithms. Using the following code, I can generate the pseudo code in pdf and also the algorithm is listed ...
4
votes
1answer
106 views

Define algorithmicx block without line numbers

I'm trying to define some sort of algorithmicx command to give me this: \Statex \textbf{Local State:} \Statex \hspace{\algorithmicindent} $v \gets []$ \Statex \hspace{\algorithmicindent} $h \gets ...
3
votes
2answers
151 views

Disable the last line at the end of algorithm

If I use the algorithm package as such \begin{algorithm}[h!] ...insert algorithm here... \end{algorithm} I find a line at the end of my algorithm. Without going into detail, I want a algorithm ...
2
votes
0answers
177 views

How to set algorithm width to avoid overfull \hbox problem

I wrote the following latex text, but the log shows an error that overfull \hbox(10.0pt too wide) detected. I am sure that the algorithmic part exceed the width limit. Even if I type a few words, the ...