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

10
votes
4answers
449 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
541 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
19k 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
197 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
61 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
735 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, ...
11
votes
2answers
5k 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
715 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
1k 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
1k 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] ...
5
votes
1answer
3k 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
460 views

Centering clrscode3e codebox horizontally

How can I center a codebox (from clrscode3e package) horizontally in a document ?
3
votes
1answer
860 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
376 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
832 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
1k 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
5k 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
10k 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 ...
9
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 ...
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 ...
17
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
372 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. ...
35
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
615 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
508 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 ...
8
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 ...
9
votes
1answer
9k 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
19k 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} ...
7
votes
2answers
4k 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 ...
23
votes
5answers
44k 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
354 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
792 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
10k 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 ...
7
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
712 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} ...