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

6
votes
5answers
4k 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
712 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
7k 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
690 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
292 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
411 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
320 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
941 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
329 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
1k 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
592 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
422 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
223 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
861 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
5k 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
745 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
426 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
485 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
539 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
5k 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. ...
9
votes
3answers
9k 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} ...
15
votes
1answer
11k 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} ...
7
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
9
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 ...
7
votes
2answers
2k 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
646 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
304 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
49 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?. ...
1
vote
1answer
219 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. ...