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

4
votes
3answers
1k views

Add a phrase to an existing algorithmic command/environment

I would like to add a new command to an existing environment. The \renewenvironment command does not help a lot since I need to copy and paste the entire environment definition. For an example I ...
15
votes
3answers
8k 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} ...
3
votes
2answers
2k views

Algorithm tag and page break

I'm starting my experiment with LaTeX, i'm writing an article and all that I want is to embed an algorithm inside normal text, this is my code: \documentclass{article} \usepackage{algorithmic} ...
6
votes
2answers
4k views

How to typeset gotos and labels using LaTeX pseudocode environments?

Is there any way to typeset gotos and labels using LaTeX pseudocode environments (algorithmic, pseudocode, clrscode, algorithm2e, etc.)? Automatic and correct indentation of labels would also be ...
7
votes
1answer
368 views

How to compile pseudocode into pdf without margins?

I want to compile a pseudocode for an algorithm into a separate pdf and then include it into my main document as a figure. However, the compiled pseudocode gets compiled into a pdf with margins and I ...
4
votes
3answers
2k views

How to create an unnumbered algorithm with a caption?

I want to do something like: \begin{algorithm*} \caption{My unnumbered algorithm} % etc. etc. \end{algorithm*} or \begin{algorithm} \nonumbercaption{My unnumbered algorithm} % etc. etc. ...
34
votes
2answers
3k views

Why does an environment's label have to appear after the caption?

\documentclass{article} \usepackage{algorithm} \begin{document} \setcounter{section}{54} \section{A section with no label} \begin{algorithm} \label{myalg} \caption{An algorithm with the label ...
5
votes
3answers
598 views

Insert white line before algorithm

I am using the algorithm environment to create a simple list of pseudo-code, but I don't like it that the first line is so close to the rule. Therefore, I would like to insert a single white line like ...
4
votes
2answers
504 views

algorithmicx + babel + Hebrew incompatibility

When trying to create any document with babel and algorithmicx, e.g.: \documentclass{article} \usepackage[hebrew,english]{babel} \usepackage{algorithmicx} \begin{document} Hello, world. ...
4
votes
1answer
3k views

LaTeX algorithmic package: Undefined Control Sequence in for-Loop

I'm trying to specify an algorithm in pseudocode in a LaTeX document, but I'm having trouble with the for-Loop. My statement: \for{$bin=0 to binCount$} \item blablabla \endfor keeps on generating ...
9
votes
1answer
3k views

Algorithm spanning more than one page

I have an algorithm which is too long to fit on one page. Someone suggested splitting the algortithm manually and then altering the second algorithm's line numbers to follow on the first. I know ...
4
votes
2answers
2k 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 ...
5
votes
1answer
2k views

Controlling vertical space within a “tabbing” environment

I'm using the "tabbing" environment to typeset algorithms. Because I'm using math formulas within the algorithms (yes I know about specific packages to do this), the vertical space needs a bit of ...
7
votes
1answer
3k views

How do I define a new command in algorithmicx

The algorithmicx package defines two commands \Require and \Ensure for providing initial conditions. However, I'd like some custom commands such as \Assume, \Define, \Input, etc. At present, I merely ...
8
votes
1answer
8k views

Algorithm over 2 pages

I am writing a few rather large pseudocode functions using algorithm and algorithmic, i.e. my code looks something like: \begin{algorithm} \caption{Coolest Algorithm ever} ...
8
votes
2answers
17k views

How to use algorithmicx package?

I found the algorithmicx package on this page, and tried to compile this example from the pdf file. \documentclass{article} \usepackage{algorithmicx} \begin{document} \begin{algorithm} ...
6
votes
2answers
3k views

How do I add a blank line in the algorithmic environment?

I'm trying to learn the algorithmic package for typesetting pseudocode. One problem I'm running into is that I can't figure out how to insert blank lines, to separate blocks of code. The usual \\ or ...
21
votes
5answers
41k 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 ...
12
votes
1answer
2k views

How to place a float at the top of a floats-only page?

I just got a short algorithm on my page, and it keeps getting aligned at the center of the page. But I want to have it aligned at the top, what do I have to do?
1
vote
1answer
341 views

Break line inside \proc?

I'm using clrscode to typeset my algorithms. This package provides the \proc command in order to typeset the name of a procedure with some nice small-caps. In a text paragraph I refer to some ...
6
votes
5answers
5k views

Aligning pseudocode in LaTeX

My algorithms class is following strict guidelines for pseudocode. Let's say I have something like the following: y = 0 for i = n downto 0 y = a_i + x * y I want this to appear left-aligned on ...
1
vote
1answer
758 views

new clause in algorithmic package

I want to define a new clause in algorithmic package (sync in my case), so that the code inside that clause would be indented as it was inside a while clause for example. So far I made things work by ...
5
votes
2answers
9k views

Reduce pseudocode font size (not global)

In this example I would like to reduce the pseudocode font size, but only for this slide while keeping the others in the default font size. How can I do that?
0
votes
2answers
2k views

Problems with formatting LaTeX document pseudo code, ending while loops

I am writing a LaTeX document for some pseudo code I have written. I have a bunch of while loops, but the way latex is formatting them, it looks like: while(x) while(y) while(z) whereas I ...
6
votes
2answers
8k views

How to remove/change the vertical spacing before and after an \algorithm environment?

I saw a question that tells me how to change the spacing in an algorithm environment, but I don't know how to do remove/change the space before and after an algorithm environment like: % remove the ...
0
votes
1answer
706 views

display algorithms side by side

This is what i tried, but i can get the algorithms to display side by side. \begin{minipage}{\textwidth} \centering \begin{minipage}{0.48\textwidth} \centering %\begin{algorithm} ...
2
votes
1answer
2k views

Step numbering in algorithms

Is there an algorithm package that allows one to achieve the style of the algorithms in the book Combinatorial Optimization by Korte and Vygen? I am interested specifically in the numbering of the ...
3
votes
1answer
304 views

Prevent \listofalgorithms from producing blank page

I'm writing my thesis with latex, and there's a chapter in which are described some algorithms using the algorithmicx package. What I want to do is to place an index of algorithms at the very ...
1
vote
1answer
2k views

program, algorithmic packages conflict

I want to use both the program and algorithmic packages in a paper; however, after adding \usepackage{program}, algorithmic is now broken. For a reduced example, \documentclass{article} ...
3
votes
2answers
419 views

How to hyperref a pageref in second half of an algorithm, independent of first half

I'm struggling with something that seems pretty complicated to me, but maybe there's a way better solution already out there. If not, I'd really appreciate any help with getting the following problem ...
3
votes
2answers
328 views

algorithmic + babel with Hebrew conflict: Numbering missing

If I use algorithmic with babel, having both Hebrew and English, the line numbers go missing. Using MikTeX 2.9. \documentclass{article} \usepackage[hebrew,english]{babel} \usepackage{algorithm} ...
6
votes
2answers
1k views

How to not increment algorithm numbers when using \againframe in beamer

As is known, algorithms and equations in latex are automatically numbered. When using \againframe though, incrementing such number is undesired. How to avoid this? (I still want numbering, but it will ...
1
vote
1answer
3k views

Why does the placement of a \COMMENT in the algorithmic enviroment matter?

I'm using the algorithmic package. When I start off a FORALL with a COMMENT, LaTeX behaves as though I've created an invalid loop body. If I put it as the second line, with a STATE first, all is well. ...
2
votes
2answers
1k views

How to make really pseudo pseudocode

Is there a way to do really casual peudocode in Latex? By casual I mean pseudocode that's more like a list of plain English steps, with occasional conditional/looping operators. I've looked at the ...
2
votes
1answer
334 views

What environment to use in writing functions

I am beginner of LaTeX, and wondering how to write functions or procedures in pseudocode. Is there any existing environment for that?
8
votes
1answer
2k views

How to print in algorithmic package for some If condition or For loop in one line?

How to print \FOR{$j:=0,\ldots,i-1$} \STATE{$\C_{ij}:=\C_{ii}\cdot\C_{ij}$}; \ENDFOR in one line instead of two line?
3
votes
1answer
625 views

Making algorithms display after the paragraph and split them in pages

I am using algorithmicx to write algorithms. I want to be able to write algorithms so that they appear right after the paragraph they have been written and possibly split them from the end of one page ...
4
votes
1answer
446 views

How to include the subsection numbers when using the algorithm2e package?

I am using the package algorithm2e. By default, the numbers of the algorithms either related to part, chapter or section. what I want is to get the following numbering for the algorithms: ...
10
votes
1answer
2k views

What “smooth” plot interpolation algorithm does pgfplots use?

In the pgfplots manual it says: \addplot+[smooth] Smooth plots interpolate smoothly between successive points. In order to choose the right sampling of points from a function evaluation for ...
7
votes
1answer
3k views

Renaming Algorithm to Heuristic in algorithm2e package

I am trying to write some heuristics for a problem using the algorithm2e package. However as you may know, when you write : \begin{algorithm} \caption{Heuristic 1: Name of Heuristic} ... ...
1
vote
1answer
231 views

How can I use the algorithm package with the memoir class

Currently there are no compilation issues. However, \listofalgorithms does not work. Additionally, my algorithms are missing titles. This is the most important thing for me. How can I get the ...
2
votes
1answer
3k views

Style problem in algorithmic package

I'm using algorithmic package and I write algorithms. It seems OK but the operators, like IF, ELSE, FOR, ENDIF, etc., are not bold. Is there anyone that has an idea? Here is an example: ...
4
votes
1answer
901 views

How we can use [noend] only in some places in algorithms?

for example we have three nested loop \FORALL{ condition 1} \FORALL{condition 2} \FORALL{condition 3} \STATE {do sth} \ENDFOR ...
6
votes
1answer
1k views

Normal font in theorem when typesetting algorithms

I'm using amsthm and clrscode to typeset algorithms. I'd like to have my algorithms numbered, so I do this: \theoremstyle{plain} \newtheorem{algorithm}[equation]{Algorithm} \begin{algorithm} The ...
6
votes
1answer
6k views

Adding comments to pseudocode

I would like to find a pseudocode package that support the possibility to wrote a comment at the right side of a if and that it wont be between { } but rather at the right side of the page, after a ...
3
votes
1answer
2k views

algorithmicx: shorten algorithm

My algorithms takes up too much space in the document. I would like to do 2 things: set the width bigger, so the lines which does not fit to a single line would do remove lines with end keywords ...
5
votes
1answer
808 views

Removing the borders from algorithm listings

I am relatively new to LaTeX. If I use standard algorithm and algorithmic environment for my algorithm listings I'm getting the borders displayed around the table with the pseudocode. How to remove ...
0
votes
1answer
441 views

Removing the borders from algorithm listings [duplicate]

Possible Duplicate: Removing the borders from algorithm listings I am relatively new to Latex. If I use standard algorithm and algorithmic for my algorithm listings I'm getting the borders ...
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
528 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 ...