{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)

3
votes
2answers
2k views

Write Procedure Name correctly formated in algorithm environment

I want to call a function in an algorithm environment. \documentclass{article} \usepackage{algorithm} \usepackage{algpseudocode} \begin{document} \begin{algorithm} \caption{Recursion} ...
2
votes
1answer
33 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 ...
4
votes
3answers
1k views

break an long line in an algorithm

I have a long line in an algorithm and want to break it into two lines. For similar case in equations, split can be used. How do I do this within an algorithm? \documentclass{article} ...
1
vote
1answer
27 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 ...
9
votes
2answers
4k views

Vertical loop/block lines in algorithmicx with 'noend' option

I am using the algorithmicx package to write an algorithm. However I am using the noend option: \usepackage[noend]{algpseudocode} Is there anyway to get vertical lines for each block of code? This ...
0
votes
0answers
28 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.
1
vote
1answer
53 views

how to insert protocol in Lyx?

I know how to insert "algorithm" in Lyx. But how to insert "protocol" as shown in the following figure?
4
votes
2answers
131 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
18 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?
1
vote
0answers
112 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.
3
votes
1answer
114 views

Collecting algorithm captions in WinEdt

I've installed the add-on Figures&Tables in WinEdt, which lets me collect table and figure captions in WinEdt's Tree. I would like to be able to collect algorithm captions, as well. With the ...
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
7 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] ...
1
vote
0answers
41 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:
0
votes
0answers
21 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 ...
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 ...
2
votes
2answers
29 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
18 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. ...
5
votes
1answer
12k views

Subroutine in algorithm2e

I am looking for a tiny example of writing in algorithm2e an algorithm using a subroutine. The algorithm is called algo, and it recursively calls a subroutine called proc. It should be something like ...
1
vote
0answers
31 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
27 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
28 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
47 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" ...
7
votes
1answer
836 views

Add the word “Algorithm” before each entry in the List of Algorithms

I'm trying to add the word "Algorithm" before each entry in the List of Algorithms (because of unavoidable thesis guidelines). I saw similar questions but the solutions listed there don't work for ...
3
votes
2answers
70 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
22 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
49 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.
5
votes
2answers
2k views

Package Algorithmic in French

I use \usepackage[section]{algorithm} \usepackage{algorithmic} to create an algorithm, I'd like to change "algorithm, begin, end while ..." to French. Is that possible? This is my example with ...
2
votes
1answer
57 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.
3
votes
1answer
20 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}} ...
1
vote
1answer
46 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
22 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.
6
votes
2answers
3k views

How to typeset data structures?

I am using algpseudocode for typesetting my algorithms. However, I am missing support for typesetting data structures, such as structs, classes or similar things. Can algpseudocode or some other ...
15
votes
1answer
4k views

Change Indentation Size in algorithmicx package

I'm using and enjoying the algorithmicx package, but would like to adjust the size of its indentations. In the algorithms package, I could do this with \algsetup{indent=1em}, but that doesn't seem to ...
2
votes
1answer
129 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} ...
0
votes
0answers
18 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
50 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
34 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 ...
28
votes
4answers
16k views

Include a line break in algorithmic while maintaining indentation

I have this code: \DeclareCaptionFormat{algor}{% \hrulefill\par\offinterlineskip\vskip1pt% \textbf{#1#2}#3\offinterlineskip\hrulefill} ...
0
votes
0answers
34 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
46 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
59 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 ...
38
votes
6answers
72k views

How to install the algorithms package?

According to my ubuntu 11.04 my texlive is the latest version. But when I tried to \usepackage{algorithm} it says file algorithm.sty is not found. I read the algorithm.pdf manual and tried latex ...
0
votes
0answers
28 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 ...
5
votes
2answers
2k views

How to format multiple algorithms so that they appear together

How can I have multiple algorithms be tied together so that they all appear next to each other. Currently LaTeX places the algorithms to far from each other.
1
vote
0answers
49 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
78 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} ...
3
votes
1answer
170 views

Make the some parts of pseudocode bold

I just want some piece of pseudo code (below) to stand out in my algorithm. So I made the all the keywords (if, end for etc) unbold with \AtBeginEnvironment{algorithmic}{\let\textbf\relax}. Now how ...