Tagged Questions

{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
1answer
96 views

How to assign code in table of figures?

Is possible that i can get an alghorithm that was wrote in LaTeX with a package and transform in a figure to be added in list of figures (\listoffigures)?
2
votes
1answer
61 views

How to manage long lines of inputs in function declaration, or inside the code, in clrscode3e

This is a part of my code: \begin{codebox} \Procname{$\proc{\textbf{Connect_two_SamplePoints}}(Graph,S1, S2,connectionCostMat,cost)$} \li \Comment S1 and S2 are sample points \li cost[S1][S2] $=$ ...
3
votes
1answer
395 views

Algoritmic return command = 0

Can you suggest me what is wrong with using return command in algorithms. when I add \RETURN $C to my LaTeX document I get return C =0, what I need is just return C. \begin{algorithm} ...
8
votes
1answer
1k views

How to use the algorithm2e package with IEEEtran class?

The IEEEtran documentation suggests that I should not use the floating algorithm environment of algorithm2e.sty. B. Algorithms IEEE publications use the figure environment to contain ...
0
votes
0answers
78 views

How to define a list of algorithms?

How can i define a list of algorithms similar a list of tables? i need something like \listofalgorithms similar to \listoffigures but with trackable algorithms
6
votes
1answer
207 views

How to format mathematical and programming variables in text?

I am describing an algorithm in a journal paper. In this algorithm I have a few variables. I gave them the same names as in my source code (C++ source of the algorithm, not LaTeX source). So I have ...
3
votes
1answer
663 views

Reduce the line number font size of pseudocode?

I have learned from here on how to reduce the font size in the pseudocode. The last thing left for me is to reduce the line number font size as well. The following is my MWE, and it seems that ...
3
votes
1answer
828 views

How may I remove \EndIf and \EndFor in algorithmicx?

For space consideration, I wish to condense my pseudocode. I find it a bit annoying to me to always have a \EndIf or \EndFor at the end of every block, especially when inside the block only lies one ...
3
votes
2answers
2k views

Pseudocode: \Function vs. \Procedure?

The title says it all. What is the difference between a Function and a Procedure? When should I use which?
1
vote
0answers
23 views

How to use dotted line to make indentation clearer in algorithmicx? [duplicate]

I wish to indicate clearly when a block starts and ends with "enclosing lines" in addition to the indentation. I understand that I can do it with algorithm2e like so \begin{algorithm}[H] \SetLine % ...
6
votes
1answer
1k 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 ...
3
votes
2answers
501 views

How to align text within an algorithm environment?

I wish to duplicate an effect I've seen elsewhere (image below) in which text not necessarily at the beginning of a line is aligned with text elsewhere. I don't know which environment is suitable, ...
6
votes
2answers
1k views

How to see the Steps number in an algorithm

In below algorithm I have used the package \usepackage[linesnumbered,ruled,vlined]{algorithm2e} 1) How do I see steps number after step 2? 2) Is there any command apart from ...
6
votes
1answer
566 views

Splitting Algorithm across multiple slides

I am wondering how to split an algorithm across multiple beamer slides. The algorithm is created using package psuedocode. I tried using [allowframebreaks] but all that did was push my algorithm to ...
2
votes
1answer
81 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
354 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 ...
2
votes
1answer
124 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
263 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
8k 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
82 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
708 views

How to place algorithm outside float?

Is there any elegent way to place algorithm without using algorithm environment?
5
votes
1answer
72 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
81 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
88 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
694 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
332 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
198 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 ...
9
votes
2answers
340 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 ...
11
votes
1answer
655 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
271 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
179 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
172 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
105 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
224 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
133 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
194 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
262 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
101 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
578 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
76 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
435 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 ...
4
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
488 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
166 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 ...