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

Customizing font used by algorithmicx

I am using algorithmicx to typeset my algorithms in XeTeX. Using fontspec, I set the default font to be Linux Libertine with historical ligatures (e.g., ct, st). Unfortunately, this is also the font ...
6
votes
1answer
330 views

How can I get proper Matlab syntax when typesetting Matlab source code using the algorithm package?

I'm currently using the algorithm package for typesetting Matlab source code in my document. However, the way keywords are typeset doesn't match the Matlab syntax. For instance, \EndFor is typeset as ...
0
votes
0answers
119 views

Reduce whitespace or margin before listofalgorithms command

I'm at my wits end on this one. I have a list of algorithms page that I want formatted the same way as my ToC and ToF. What I have currently is pretty close except that the List of Algorithms title ...
2
votes
1answer
120 views

How to make color from the table Ruffini - Horner Algoritms? [closed]

I Have problem about to make the table ruffini- horner algoritms,and i take a code from this question command for table Ruffini-Horners Algorithm , \documentclass{article} \usepackage{xparse} ...
3
votes
1answer
209 views

Indenting pseudocode

I am very new to TeA, and am having trouble indenting a block of pseudocode within an enumeration. Or perhaps more specifically, the algorithm's pseudocode seems to ignore the enumerations ...
7
votes
2answers
7k views

How do remove equation number in an algorithm

Here is the code. Even I have used the command \nonumber still I can see the equation number \begin{document} \begin{algorithm} \DontPrintSemicolon % Some LaTeX compilers require you to use ...
0
votes
0answers
80 views

How to write this algorithm properly

Here I have attached the current code \begin{document} \begin{flushleft} \begin{picture}(10,5) \put(1,1){\line(1,0){450}} \end{picture} \end{flushleft} \textbf{\textit{Algorithm:}} Curves on ...
2
votes
1answer
630 views

How to place algorithm outside float?

Is there any elegent way to place algorithm without using algorithm environment?
5
votes
1answer
66 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
78 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
85 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
584 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
2k 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
325 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
192 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
1k 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
305 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
580 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
241 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
165 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
167 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
104 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
93 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
209 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
132 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
188 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
239 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
97 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
515 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
376 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
1k 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
463 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
153 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
52 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
1k 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
233 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
222 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
102 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
656 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
544 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
136 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
985 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
1k 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
204 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
257 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
111 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 ...