{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
1k views

Elsevier `elsart`/`elsart3p` incompatibility with `algorithmic`

Stuggling with the following problem for a small while and am stumped. I'm using the the elsart3p.cls document class, but it seems not to work well with the algorithmic package. Here's a minimal ...
3
votes
2answers
445 views

Adjust row size and division operands in pseudo code

I've just starting using LaTeX (today), because I wanted a professional way to format some pseudocodes, needed for a paper. So this might be a lame question, but can't find anything relevant. My ...
3
votes
2answers
516 views

Indentation in AUCTEX and algorithmic package

When working with EMACS+AUCTEX I encountered the problem of proper indentation when using the algorithmic package. In this MWE: \documentclass[12pt]{article} \usepackage{algorithmic} ...
2
votes
1answer
2k views

How to put algorithm block in a minipage so that footnote displayed immediate after the block

as stated in title. \documentclass{article} \usepackage{algorithm} % Need it for floating environment \usepackage[noend]{algpseudocode} % Hide endif .etc \usepackage{caption} % Need it for ...
1
vote
1answer
1k views

How to create footnote for algorithmicx's comment

The number is displayed, but the footnote text is missing. How to fix that? \documentclass{article} \usepackage{algorithm} % Need it for floating environment \usepackage[noend]{algpseudocode} % ...
2
votes
1answer
4k views

Customizing the algorithm/algpseudocode package

After asking this question: Change FORALL to FOREACH in algorithms package, some issues arose in the comments. I have created the following sample document, and have three questions. ...
8
votes
3answers
8k views

Change FORALL to FOREACH in algorithms package

\FORALL gives a "for all" loop, i would like to redefine it so that it shows "for each" instead. Any way to do that? By the way, foreach is more often used in real programming languages than forall, ...
3
votes
2answers
4k views

Disable the numbering of algorithms

My problem is that I do not know how to disable the numbering for algorithms. I have created an algoritm and its number is "Algorithm 1", but I want to have "Algorithm". \documentclass{article} ...
10
votes
1answer
10k views

How to put a line number every line of algorithmic

I am looking for a way to have a number for every line in algorithmic: \documentclass{article} \usepackage{algorithm} \usepackage{algorithmic} \begin{document} \begin{algorithm} ...
6
votes
1answer
2k views

algpseudocode font size

I want to change the default font size of the algorithm in algpseudocode environment to small. This is because my algorithm is lengthy and i have page limitations. Please help
8
votes
1answer
7k views

Vertical spacing in the algorithm environment

I'm using the algorithm/algorithmic packages and want to condense some of the vertical space between an algorithm's line numbers in order to save space. Ideally, I would like to remove 1 to 2mm of ...
5
votes
2answers
1k views

How to nest \Call in algorithmicx?

I tried to show something like: Min(Right(x)), when I input the following in my LaTeX manuscript: \begin{algorithmic}[1] ... \State \Return \Call{Min}{\Call{Right}{$x$}} ... \end{algorithmic} it ...
4
votes
1answer
1k views

Aligning function arguments in “algorithm” environment.

In the "algorithm" environment, when a function call spans multiple lines, I would like to have its arguments aligned, like so: MyFunction(long_arg_name0, long_arg_name1, ...
4
votes
1answer
611 views

Algorithm counter is broken with journal style file

With the style file gSCS2e.cls, found at http://www.tandf.co.uk/journals/authors/gscslatex.zip as well as the algorithm package, if I compile the following LaTeX document, the Algorithm counter seems ...
3
votes
1answer
9k views

Smaller font size of the algorithm description?

\small or other tag seems can not change the font size of the line number. The package I use is \usepackage{algorithmic}.
4
votes
1answer
5k views

Recursive algorithms with the »algorithms« package?

I need to write a recursive algorithm, using the algorithms package. I thought of writing something like this: \begin{algorithmic} \IF {$x=1} \RETURN 1 \ELSE \RETURN recurse$(x-1)$ \ENDIF ...
2
votes
1answer
2k views

Adjust spacing of algorithm float caption

Background Using the algorithm package to display source code listings. Problem The LaTeX (LyX) code (test.lyx) is at: http://pastebin.com/QRWDhA7E An example graphics (query.png) file is at: ...
8
votes
1answer
5k views

How to add unnumbered lines in an algorithm?

I am typesetting algorithms with the algorithm package, and I would like to add unnumbered lines in them. Is there a way to create a \State* command, the same way there is an equation* environment? ...
4
votes
1answer
298 views

Adding a label on a margin (instead of line number) in latex algorithmic package

I would like to mark (e.g. with a *) a line in a pseudo-code typeset with the algorithmic package. I would like the label to appear on the left margin, instead of the line number. Is that possible? I ...
2
votes
1answer
47 views

Adding a label on a margin (instead of line number) in pseudo code

I would like to mark (e.g. with a *)a line in a pseudo code typesetted with the algorithmic package. I would like the label to appear on the left margin, instead of the line number. Is that possible?. ...
2
votes
1answer
210 views

What is the best way to typeset an algorithm with several procedures?

The title question sums it all.
7
votes
1answer
2k views

Hide closing statements for algorithms

I would like to generate an algorithm with the algorithmic package which does not show the annoying closing statements when I typeset it. I have done this before but have now forgotten how to do it. ...
10
votes
1answer
931 views

cleveref and algorithm2e

I'm currently working on a document where I was using algorithm+algorithmic along with cleveref. With this everything worked perfectly. Now I had to replace algorithm+algorithmic with algorithm2e. ...
0
votes
2answers
546 views

Package for displaying source code [duplicate]

Possible Duplicate: How best to include programming source code in LaTeX documents? What is a good way to display program source like c++/lisp code in a latex document?
6
votes
1answer
3k views

Set width of algorithm environment (preferably document wide)

Looking for a way to set the width of an algorithm environment, preferably document wide (as opposed to per-algorithm). Thought it should be fairly easy, but couldn't find a particularly good ...
1
vote
1answer
527 views

Apply a vertical rule beside graphics within Algorithm floats

Background Using LyX to write a book. The source code listings shown in the book are graphics. The graphics should have a vertical rule beside them. But only graphics that are embedded within an ...
4
votes
1answer
3k views

Override \centering to left justify an image

Background Dozens of source code snippets inserted into a document as images inside of Algorithm floats. Other images are screen captures, inserted as Graphics floats, to make a distinction. All ...
4
votes
2answers
2k views

Customizing “Algorithmic” or generating output of the same style

The algorithmic sample code that I am using is something like this: ‎\begin{algorithm}[h]‎ \caption{Caption Here‎.} \label{alg:Name} ‎‎ \begin{algorithmic}[1]‎ ‎\REQUIRE‎ ‎\ENSURE‎ ...
7
votes
3answers
5k views

Rename “Algorithm” to “Listing”

Background Syntax-highlighted source code image listings are being used as Algorithm floats with the lst: prefix for captions. Problem The following LaTeX code in the preamble renames the caption ...
9
votes
2answers
4k views

Floating an algorithm?

I'm typesetting an algorithm using the algorithmx package as follows: \begin{algorithm} \caption{\textsc{Whatever}} \begin{algorithmic}[1] ... \end{algorithm} However, I would like it to ...
6
votes
2answers
2k views

Number Algorithm floats with dependency (subalgorithms environment)

What I have: 3 algorithms, like so: \begin{algorithm} \caption{Caption One} ... \label{alg:one} \end{algorithm} \begin{algorithm} \caption{Caption Two} ... \label{alg:two} \end{algorithm} ...
4
votes
2answers
434 views

Which package for In-line and float algorithms?

I am using LyX to describe algorithms. A common scenario is that I have a snippet of pseudo code (in a float, for example) and a block of text which makes references to keywords in that pseudo code. ...
5
votes
2answers
3k views

algorithm package: Comment on “for” loop does not work?

It seems that \COMMENT in the algorithm package is broken. It gives an error when used in a FOR or FORALL line, so the first comment gives a compilation error: \begin{algorithm}[ht] \caption{My ...
6
votes
1answer
2k views

algorithmicx no listofalgorithms in contents section

So I'm using algorithmicx to define some algorithms. It looks great, but I have one problem. When I use \listofalgorithms a page is created with the captions and links to the algorithms. However, ...
3
votes
2answers
347 views

Is \algorithmicand a standard command in the algorithmic package?

I have a tex file created by someone else which redefines commands of the algorithmic package to translate them to the Portuguese language. For example: ...
1
vote
1answer
255 views

Create a keyword using the newalg package and algkey

I'm using the newalg package to typeset some algorithms, and I'd like to be able to typeset a keyword using the algkey macro. the problem is that I can't get it to work. Here's what I'm trying to do: ...
5
votes
1answer
370 views

Best solution to present school computing algorithm

I need to typeset some computing class algorithms like: Repeat Accept Roll_Number If (the Roll Number has already been added to the absent list) then Prompt”You have already added the roll number ...
60
votes
4answers
29k views

What is a good package for displaying algorithms?

I found this page with some examples: http://en.wikibooks.org/wiki/LaTeX/Algorithms_and_Pseudocode I'm wondering which one to use. Any suggestions? I'm using other packages too so whichever is less ...