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

12
votes
1answer
2k views

Mark a pseudocode block and insert comments near it

I am currently working on a LaTeX beamer presentation where I have to explain an algorithm. So I wrote this algorithm with \usepackage{algorithm,algpseudocode} This is the current algorithm: ...
3
votes
2answers
6k views

How to format for loop

I want to write a 'for' statement, but unsure how to do this with LaTeX. What I am trying to do is: for k = 1, k++, while k < i What is the proper (or at least a decent way) to write this in ...
6
votes
1answer
9k views

Algorithm and IEEEtran

I'm trying to write an algorithm in a IEEEtran LaTeX template and it doesn't work in any way. \usepackage{algorithm} \usepackage{algorithmc} %\begin{algorithm}[H] \begin{algorithm*} \caption{ASGP ...
0
votes
0answers
25 views

algorithmic, text after algorithm appears before it [duplicate]

Possible Duplicate: How to influence the position of float environments like figure and table in LaTeX? I am using algorithmic package. I have description of an algorithm in ...
0
votes
0answers
77 views

Alignment of multiline STATE in algorithm [duplicate]

Possible Duplicate: Include a line break in algorithmic while maintaining indentation I am using the algorithmic package to insert an algorithm in my paper. I have a long sentence after the ...
8
votes
1answer
3k views

IEEE-Template: Algorithm over both columns

I'm currently working on a paper using the IEEEtran template. I do have a pseudocode I would like to put into this paper. In a former paper I saw that it is possible to put this algorithm in a box ...
1
vote
0answers
478 views

Problem using package 'algorithmic':: LaTeX-Result: 0 Error(s), 0 Warning(s), 0 Bad Box(es), 0 Page(s) [closed]

I am relatively new to LaTeX, and I am having problems with using the algorithmic package. Whenever I add the command, \usepackage{algorithmic} and try to build the document, the number pages ...
4
votes
1answer
3k views

Switch cases in algorithmic

How can I use switch cases in algorithmicx? For example a code like this: switch s do --case a ----assert(1) --case b ----assert(0) etc. Is is possible to define it as a command?
12
votes
1answer
2k views

Is it possible to have connecting loop lines (like algorithm2e) in algorithmic?

I am using the algorithmic package to typeset an algorithm. I would like to have connecting lines between the beginning and end of a loop or conditional like in the algorithm2e package. Is there an ...
1
vote
0answers
39 views

install package on linux [duplicate]

Possible Duplicate: Where do I place my own .sty files, to make them available to all my .tex files? I downloaded "algorithmicx" package and I want to add it to my latex search path on ...
5
votes
2answers
3k views

Horizontal line in Algorithmic Environment

I'd like to separate two sections in an algorithmic environment with a horizontal line, like: ------------- Algorithm 1: MyAlgorithm ------------- Part 1: Do some stuff ------------- Part 2: ...
5
votes
2answers
4k views

“For” loop without “do”; “if” statement without “then”

How can I get rid of the do in a for loop and the then in an if statement when typesetting algorithms using the algorithm and algorithmicx packages?
4
votes
1answer
1k views

Vertical lines for blocks of pseudocode [duplicate]

Possible Duplicate: Linebreak in Package algorithm2e Is it somehow possible to generate vertical alines that connect the start and end of a block in algpseudocode (as provided by the ...
7
votes
1answer
15k views

including algorithms in latex

I am using the \usepackage{algpseudocode} \usepackage{algorithm} packages and creating a sample algorithm using the \COMMENT, \IF, \ENDIF and \FOR constructs. When I compile this and view the PDF ...
10
votes
2answers
2k views

How can I put a curly brace inside an algorithm to group code lines?

I am using the algorithmic package (or even algorithm2e is fine). Is it possible to use curly braces to group some lines in the algorithm so as to be able to put an explanation to the right?
4
votes
1answer
2k views

Algorithms \And boolean operator casuing “Undefined Control Sequence” error

I'm writing some algorithms using the algorithmicx package. I'm trying to create an if statement with an And boolean operator but using \And is causing an Undefined Control Sequence error ...
3
votes
2answers
857 views

algpseudocode without visible EndIf

I have the following chunk of code \begin{algorithmic} \State $\mathit{FlatMask}(c)=0$ \If{$\mathit{Inc1}(c)>0$} \State $\mathit{FlatMask}(c)\;+\!\!=2(\mathit{Inc1}(c)-1)$ \EndIf ...
1
vote
1answer
411 views

Is there an alternative to \Call{Algorithm}?

I would like to format names of algorithms just as they appear inside the algorithmic environment. For an example, see the title "An unsuccessful attempt: Flip-and-Match" of this paper. So far I've ...
4
votes
2answers
9k views

Defining a function in pseudocode

I am trying to define a function in LaTeX pseudocode, as shown below. \begin{algorithm} \begin{algorithmic}[1] \Function{Increment}{$a$} ..... \EndFunction \end{algorithmic} \end{algorithm} ...
11
votes
1answer
2k views

Change Indentation Size in algorithmicx package

I'm using and enjoying the algorithmicx package, but would like to adjust the size of its indentations. In the algorithms package, I could do this with \algsetup{indent=1em}, but that doesn't seem to ...
7
votes
1answer
3k views

Referencing line numbers in an algorithm

Referencing figures is simple: \begin{figure} \caption{Blah blah blah blah blah} \label{fig:name} %shtuff goes here \end{figure} See figure~\ref{fig:name}. I would like to know if it ...
1
vote
1answer
483 views

Defining procedures in algorithmic

Is there any support for procedures/methods in the algorithmic package? Of course one could use several algorithms to define each method/procedure however because LaTeX usually doesn't put more than ...
1
vote
2answers
3k views

Undefined control sequence \State \COMMENT

Undefined control sequence \State \COMMENT. The manual clearly state that I can use the \comment. I use \usepackage{algpseudocode} \usepackage{algorithm}. Here is my code: \documentclass[10pt, ...
5
votes
1answer
796 views

Disable Algorithm Numbering

I have seen this question but I still disable the numbering of algorithms. I have the following code: \begin{algorithm} \caption{\textsc{FizzBuzz}} \begin{algorithmic} ...
3
votes
1answer
918 views

Problems with algoritmicx package

However I turn and twist it, for some reason I can't get the two lines I have commented out to work. It keeps giving me the error: "Undefined control sequence." \begin{algorithm} ...
13
votes
2answers
1k views

Typesetting algorithms in LaTeX like Knuth

Is there any LaTeX package for typesetting algorithms in the style Donald Knuth uses in The Art of Computer Programming? I know about the algorithm2e package, but I am looking for something that ...
10
votes
4answers
421 views

Looking for style files for writing a programming language book

I am looking for LaTeX style files for writing a programming language book (OO programming with Java examples). I'd appreciate if anyone can point me to style files that I can use.
6
votes
2answers
514 views

How do I create an algorithmic Tikz code to obtain a list of numbers which is conditionaly defined by a recurence relation?

Suppose, our initials are $a_{1,0}=0$, $a_{1,1}=1$ and $a_{1,j}=0$ for $j<0$. For given an integer $n$, define $$a_{i,j}=\begin{cases} a_{i-1,\frac{j}{2}} & \text{ if $j$ is even},\\ ...
5
votes
2answers
14k views

Algorithmic package in LaTeX

I want to write the following algorithm in LaTeX: V <- AllUnigramsInTraining(D) N <- NumberOfTweets(D) **for** each c ∈ C do Nc <- Number of tweets in Class c prior(c) <- [...] ...
0
votes
1answer
185 views

package for type-setting computational problems

There are many packages which allow to type-set algorithms. I'm wondering whether there is a ready-to-use solution which allows to type-set computational problems? I mean an environment which would ...
8
votes
4answers
2k views

Neural Network representation

I would like to translate to Spanish a diagram that represents a neural network, the diagrama is something like this: I would like to clone the design and effects, so I need some examples to do ...
1
vote
0answers
60 views

Minted split code into two pages [duplicate]

Possible Duplicate: minted truncates the code if it doesn't fit into one page I am using minted in order to write some Objective-C code inside a report I am trying to create. I use it ...
4
votes
1answer
2k views

How to decrease algorithm indent for package algpseudocode?

I would like to save some horizontal space by changing indent space for package algpseudocode. How can I do that? I think the variable I have to change is \algorithmicindent but I can't manage to do ...
9
votes
2answers
658 views

How to put an algorithm and a tikz drawing (objects of different type) side-by-side in the same float environment?

I am trying to put an algorithm and a tikz' drawing side-by-side inside a figure environment. I am aware of this question but I would like to have a single caption for them. For instance, in the text, ...
10
votes
2answers
4k views

IEEEtrans template requires not to use algorithm package?

During the IEEEtrans.tex, there is a comment below package algorithmic saying that Do NOT use the algorithm floating environment provided by algorithm.sty (by the same authors) or ...
5
votes
1answer
521 views

How can I translate keywords of algorithmic package?

How do I translate standard keywords of the algorithmic package like (if, then,...) to my language? If possible, I would like to do it without looking into source of algorithmic or algorithm.
1
vote
2answers
979 views

LaTeX Class / Package / Template for programming project report

I'm looking for any useful class or package or style (template) to help me write up a programming project report. I've found many LaTeX tutorials but I found it quite hard to start from scratch.
1
vote
0answers
874 views

Why do I get the error “\caption outside float” with the algorithm / algorithmic package? [closed]

I have an algorithm in my document It looks like this: \begin{algorithm} \caption{Merge Digest: Insert\label{mergeDigestInsert}} \begin{algorithmic}[1] [....algorithm is ...
2
votes
1answer
2k views

Loop conditions in multiple lines using algorithmic package

I am working on a paper in double-column format, and I am using the algorithmic package to typeset my algorithms. One of my while loops' condition is a bit long hence doesn't fit into the column. ...
0
votes
1answer
2k views

Why am I getting this “Missing $ inserted” error in an algorithm figure just like all my other algorithm figures?

I'm writing a paper in LaTeX, and I'm getting a strange "Missing $ inserted" error when I try to compile the paper using pdflatex, but only if it contains the following code. \begin{algorithm*}[tbh] ...
4
votes
1answer
2k views

Wrap text around pseudocode

I use algorithm/algorithmic packages to write some pseudocode. The width of the box spans across the entire page and I was wondering if there is any way to constrain it (since the actual code doesn't ...
3
votes
1answer
383 views

Centering clrscode3e codebox horizontally

How can I center a codebox (from clrscode3e package) horizontally in a document ?
3
votes
1answer
720 views

Strange behavior in smooth pgfplot with sudden changes in the slope

I'm trying to plot some points with sudden changes in the slope. But I get some strange behavior like this: as you can see in the peaks, there is no smoothness in there. However, I think the ...
3
votes
1answer
346 views

Additional separation between require and algorithm

\usepackage{algorithm} \usepackage{algorithmic} ... \begin{algorithm} \caption{A good name} \begin{algorithmic} \REQUIRE something usefull \STATE $i \leftarrow 1$ \end{algorithmic} ...
0
votes
1answer
581 views

Good way to “ensure” a return value

I want to describe an algorithm, which is not changing a given input but it is producing a new element: \documentclass[a4paper, 11pt]{scrbook} \usepackage{algorithm} \usepackage{algorithmic} ... ...
3
votes
1answer
967 views

How to format multiple algorithms so that they appear together

How can I have multiple algorithms be tied together so that they all appear next to each other. Currently LaTeX places the algorithms to far from each other.
3
votes
2answers
2k views

polyglossia and algorithmicx - Missing \endcsname inserted

Trying to compile a simple document using polyglossia with Hebrew as the default language: \documentclass[a4paper]{article} \TeXXeTstate=1 \usepackage{amsmath, amssymb} \usepackage{polyglossia} ...
2
votes
1answer
4k views

Algorithm over two pages, with itemized lists

I am trying to split an algorithm over two pages. This has already been addressed before, with the closest result being this question. However, I have a wrinkle - I need the algorithm to have two ...
4
votes
4answers
7k views

How do you add a comment to pseudocode in LaTeX?

Is there a special formatting to add comments to code? I mean I want to show comments in pseudocode that I write in LaTeX. this is code // this is comment part (the part that I want) Edit: To be ...
8
votes
3answers
3k views

How to put algorithm and figure(s) side by side?

How can I put an algorithm and figure(s) side by side? Say, XXXXXXXXXXX FIG ONE XXXXXXXXXXX FIG ONE XXXXXXXXXXX FIG ONE XALGORITHMX FIG TWO XXXXXXXXXXX FIG TWO Please, only post working solution ...