{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
563 views

How to place algorithm outside float?

Is there any elegent way to place algorithm without using algorithm environment?
5
votes
1answer
61 views

How to add the algorithm block in textblock

I'm creating a poster and I have a problem to adjust the algorithm block inside of textblock. My code is in below with the packages and the code. \documentclass[a0,portrait]{a0poster} ...
0
votes
0answers
75 views

include algorithm package in latex [closed]

I am using llncs (lecture notes in computer science) class style for my latex file. However, I am not able to include the algorithm package in my file. When I compile my file, I get an error for the ...
1
vote
1answer
83 views

How to exclude some algorithms for \listofalgorithms

I tried with \captionsetup{list=no} but it doesn't work for the algorithm listing. Any ideas? I am splitting alg. over several pages using algorithm2e and don't want the captions of the split ...
2
votes
1answer
522 views

Self-defined Width of the Pseudocode Box with algorithmicx?

This post has beautifully shown how to make the algorithm pseudocode box as wide as one column or two columns. I am now writing a pseudocode with many if layers. So a one-column box cannot suffice. ...
7
votes
2answers
1k views

algorithm2e Command \algorithm already defined

I want to draw vertical line by using \SetAlgoLined, but LaTeX told me Undefined control sequence. Then I add \usepackage{algorithm2e} to the end of my preamble. Then it said Command\algorithmalready ...
2
votes
2answers
296 views

Formatting \listoftables and \listofalgorithms

I need a special format for the \listoffigures and the \listofalgorithms. It should be: List of Tables Table 1: T1.....................1 and respective List of Algorithms Algorithm 1: ...
11
votes
3answers
191 views

Can I locally switch to a 'greedy' justification algorithm?

I'm not optimistic about this since this is a core part of TeX's algorithm, but is there any way to switch to a 'greedy' justification algorithm? That is, instead of working on the paragraph as a ...
4
votes
1answer
978 views

Questions about algpseudocode

I'm using the following packages: \usepackage{algpseudocode} \usepackage{algorithm} but I don't understand what package is algpseudocode, since I can't find the documentation. I have followed this ...
8
votes
2answers
291 views

How to automatically keep the indentation level when a line has to be broken

I'm using the algpseudocode package with two custom commands, \Let and \LongState to handle automatic indentation of (broken) long lines in the spirit of Werner's answer, which uses \parbox to wrap ...
10
votes
1answer
549 views

Algorithm as figure and without italic and bold formatting?

I want to include an algorithm in my latex document, however without printing most of it in italic and all the keywords in bold font like it's done by default by e.g. the algorithmicx package. I like ...
2
votes
1answer
218 views

Alternate row colors (shade rows) in algorithmic environment?

In a tabular environment, one can achieve an alternating color of rows by using the rowcolors command like so: \documentclass[11pt,a4paper]{article} \usepackage[table]{xcolor} \begin{document} ...
0
votes
1answer
158 views

Assignment vs Add to collection in Latex

I am writing an algorithm in latex and don't know how to distinguish between assignment and collection operations. Assignments be written as: A <- B + C But in case of add to collection, I ...
4
votes
1answer
166 views

acmsmall breaks line number alignments of algorithms

I am formatting an article with one of the ACM journal formats: acmsmall. However, when I look at algorithms, I noticed that the lines of my algorithm lost their indentation. This problem does not ...
0
votes
0answers
102 views

How can I change the left and right margins of the list of algorithms?

I am using the algorithm package and have a list of algorithms. How to change the left and right margin of the lists? I'd like both and right margins to be 1pt wide.
1
vote
0answers
35 views

List of Algorithm: add “algorithm” label [duplicate]

I want to add label "Algorithm" to the numbering of list of algorithms, e.g., Algorithm 1. Search Algorithm 2. Sort I tried different solutions found here but does not work. The main .tex file ...
3
votes
1answer
91 views

Indentation missing for algorithm package in documentclass{minimal}

I am trying to get write an algorithm in LaTeX for minimal document class. Unfortunately, the indentation is completely missing. Following is my sample code: \documentclass{minimal} ...
3
votes
1answer
203 views

Which pseudocode package produces this output?

I'm reading a computer science paper right now and I really like the way the pseudocode is displayed. I'm unsure, however, of what pseudocode package this is. Any help would be appreciated. An image ...
3
votes
4answers
130 views

Algorithm for 'Plugging in' Values to Tables

Simply, if I have a table of the form: \begin{tabular}{l r r r r r l r r r r r} \hline {}&{}&{}&$n$&{}&{}&{}&{}&{}&$n$&{}&{}\\ ...
5
votes
1answer
181 views

Indented block in ConTeXt

I need to write pseudocode in ConTeXt. Since there is no documentation of the t-algorithmic module, and because I don't have so much to write, I decided to format the code myself. Here is what I ...
6
votes
1answer
230 views

Command for the table Ruffini-Horner algorithm

I am trying to code a command in LaTeX to type the tables used in the computation of the Ruffini-Horner algorithm. You can see in the Wikipedia link above that these are rather simple tables. There is ...
3
votes
1answer
96 views

change \FOR to \FOREACH in program package

In the program package, is it possible to introduce new keyword \FOREACH which behaves exactly like \FOR but writes foreach instead of for on the code.
2
votes
1answer
474 views

Algorithm as a figure (to include additional caption below the figure)

I have an algorithm in latex, and I need to add an addition caption underneath the algorithm (just like in a figure at the bottom: "Figure 1: Whatever it is". I tried simply changing the ...
2
votes
1answer
74 views

question about algorithm

I'd like to ask how can have an algorithm(s) flow (like text) from one column to another in a two-column document? I don't want to treat it as a one block like a figure is treated. Does anyone know ...
4
votes
1answer
344 views

How to sanely format conditionals in clrscode package?

clrscode can produce some really nice-looking algorithm texts, but if you have nested conditionals, things start to look ugly. clrscode has the peculiar preference that the \Then keyword at the end ...
3
votes
1answer
953 views

Placing a single algorithm in two columns

I have a single-column document and to save space I would like to make a long algorithm (produced using packages algorithm and algorithmic) to be double-column. That is, I would like the float content ...
2
votes
2answers
430 views

Change caption number of an algorithm

I am wondering if I can manually set the caption number of an algorithm, or let the caption number of the algorithms in an article start from 2. The following is a MWE. ...
0
votes
0answers
31 views

Spanning a procedure of an algorithm more than 1 page [duplicate]

I am unable to do this in LaTeX. Please help. And people who have marked this as duplicate, please mention the link to the question as I could not find any.. \begin{algorithm} \begin{algorithmic} ...
3
votes
2answers
142 views

Divide algorithm in two parts without incrementation of version

This is my code: \documentclass{article} \usepackage[paperheight=6\baselineskip]{geometry}% just for the example \usepackage{algorithm} \usepackage{algcompatible} \begin{document} ...
1
vote
1answer
49 views

Avoid multiple occurrence of a multi-page algorithm in the list of algorithms

I have a pseudocode which spreads in multiple pages. I tried \algstore and \algrestore (as advised in Algorithm over 2 pages) and it allows multiple pages but it causes problem with \listofalgorithms ...
2
votes
1answer
982 views

How to put algorithm and figure side by side in two column document?

I want to put two figures and an algorithm side by side in a two-column document, and the figures and the algorithm should span two columns. I have surveyed previously asked questions such as How to ...
6
votes
1answer
225 views

Frames around few line of code in a algorithm

I want to put a box around lines of code and to add comments inside the box. This is what I want it to achieve: This is the example of code I am using for the algorithm. \documentclass{article} ...
5
votes
1answer
2k views

More compact Algorithm template in Latex

All, I am using the following Algorithm template: \usepackage{algorithmicx} \usepackage[ruled]{algorithm} \usepackage{algpseudocode} \vspace{-0.2cm}% \alglanguage{pseudocode} ...
1
vote
2answers
218 views

Problem and question tocloft

I tried to create my own "List of things" with help of this post: Define your own list of Now my questions: I don't want to use the command \algorithm {Text}. Instead I want to use a container like ...
1
vote
1answer
96 views

How to define new loops in algorithmicx?

How can I define a new loop in algorithmicx? For example, code like this: ex1) PreLoop s do --statement1 --statement2 ex2) PostLoop s do --statement1 --statement2 Is it possible to define it ...
4
votes
3answers
601 views

Combine \listoflistings and \listofalgorithms into one list

The title said it all...I want to combine the two under one list with the title "Algorithms and program code". Style wise the page should match the usual style of the other lists (\listoffigures, ...
4
votes
2answers
489 views

How to avoid printing the algorithm number in algorithm captions?

I am using the algorithm2e package to write algorithms. However, when i write three algorithms one after another, the algorithms are automatically numbered 1,2 and 3 in the caption. I am using ...
1
vote
1answer
132 views

Algorithms in mdframed

Now that I converted all my theorems to mdframed, I'd like a consistent layout for my algorithms as well? What ways are there to typeset pseudocode algorithms in mdframed? So far I've been using ...
3
votes
1answer
900 views

cleveref fails to reference algorithms

In the following example document, both \autoref and plain ref will correctly link and number an algorithm reference, but cleveref fails that task. It will just insert question marks instead. In ...
5
votes
2answers
948 views

Caption numbering breaking up an algorithm with algorithmicx

According to its documentation, algorithmicx package allows break up an algorithm inside a document, as follows: Related tex code is: \documentclass{article} \usepackage{algorithm} ...
2
votes
1answer
191 views

Line break inside procedure's definition with algorithmicx

I don't know if this package is the best for my purpose, but I'm using algorithmicx (see here the documentation) to write algorithms (in pseudcode) inside my work. At now, I've just a problem: ...
2
votes
1answer
237 views

How to put a vertical space between two functions inside algorithmic environment?

To make the algorithm readable, I would like to put some space between two functions. E.g.: \documentclass{article} \usepackage{algorithm} \usepackage{algpseudocode} \begin{document} ...
3
votes
2answers
109 views

Alignment problem with algorithmic and hyperref

I have some alignment problems in the algorithmic environment when I use the hyperref package. I like to have my comments left-aligned which I achieve by ...
5
votes
1answer
216 views

Referring to function name in an algorithm

I have a LaTeX code which looks similar to the following example. \documentclass{article} \usepackage{amsmath,algorithm,algpseudocode} \begin{document} \begin{algorithm} \caption{My Algo.} ...
8
votes
1answer
4k views

What is the best looking pseudo code package?

I have stumbled across various pseudo code packages but can't seem to find that's simple and eye-candy and practical. What I'm looking for: Visually attractive structure (eye-candy) ( easy to look ...
5
votes
1answer
250 views

Align appearance of listings and algorithm packages

I want the output generated by the listings and the algorithm package to be the same. Consider the following minimum working example. ...
4
votes
1answer
934 views

Ploblems with vertical lines in algorithmicx

I use algorithmicx with verical lines. And code is working good: \documentclass{article} \usepackage{algorithm} \usepackage{algpseudocode} % Vertical line \makeatletter ...
6
votes
1answer
1k views

Numbering in algorithmicx

I have simple code: \documentclass{article} \usepackage{algorithm} \usepackage{algpseudocode} \begin{document} \begin{algorithm} \caption{Examples}\label{alg:Examples} \begin{algorithmic}[1] ...
3
votes
1answer
261 views

Implementing indent in algorithm environment

I am using the algorithm environment in the algorithm2e package. What I want is to able to indent various portions. I tried \indent but that is doing me no good. Here is the MWE: ...
2
votes
1answer
353 views

Algorithm pointers and references

I'm looking for a clean way/best-practice of writing an algorithmic block that uses pointers and references. I've had success with algorithmic in the past, but this is the first time I've tried ...