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

1
vote
1answer
39 views

Genetic Algorithm pseudocode

Hi everyone, this is my first post, so apologise if not doing it properly. I need the following GA pseudocode (Photo) in LaTex, but couldn't do it very well. I really appreciate your help.
0
votes
0answers
6 views

Procedure numbering in packages algorithm and algcompatible

When I use both packages algorithm and algcompatible, I find the algorithms can be easily numbered, but the procedure cannot. How can I number the Procedures in algorithm, like Procedure 1, ...
2
votes
1answer
12 views

algorithm, how to start line numbering at given number (using algorithm2e)

I wonder how to start a code at a specific number; this is necessary when the algorithm is broken over two pages. A small example that I would like to start at line 39 instead of line 1. Is there a ...
1
vote
1answer
25 views

Number the algorithms with itemize or other environment

I am trying to number the two algorithm environments and put some space between each other but I am just getting the numeration at the side? How can I manage it to get the number before the ...
27
votes
4answers
15k 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} ...
0
votes
0answers
25 views

Approaches to automatically scale figures

I am trying to come up with a general rule of thumb to scale figures such that their vertical size and horizontal size does not exceed a certain limit (assume 300pt). The monkey patching way to do ...
3
votes
2answers
2k views

Write Procedure Name correctly formated in algorithm enviroment

I want to call a function in an algorithm enviroment. \documentclass{article} \usepackage{algorithm} \usepackage{algpseudocode} \begin{document} \begin{algorithm} \caption{Recursion} ...
0
votes
1answer
34 views

Wrong number when reference inside algorithm

\usepackage{algorithm} \usepackage{algorithmic} \begin{algorithm}[tb] \caption{Algorithm} \label{alg} \begin{algorithmic}[1] \STATE blalblabla \label{cond1} \STATE ...
1
vote
0answers
35 views

A library of common algorithms? [closed]

Is there a latex package, or other resource, which provides a library of common algorithms? The LaTeX wikibook discusses 4 different algorithm typesetting packages for LaTeX; but I'm not fussy as to ...
0
votes
1answer
45 views

how to insert protocol in Lyx?

I know how to insert "algorithm" in Lyx. But how to insert "protocol" as shown in the following figure?
4
votes
1answer
40 views

Align equal sign in algorithm in vertical line

The Code described in [1] produces the following output : For the description of my algorithm I need the equal signs to be perfectly aligned in one vertical line but currently there is still a ...
36
votes
6answers
67k 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 ...
0
votes
0answers
23 views

List of algorithms not working with amsbook document class

I am using \listofalgorithms in a document with \documentclass{amsbook}. It seems the two clash for some reason. When I run pdflatex, I get the following error message: (./main.loa ! Undefined ...
5
votes
2answers
2k 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.
1
vote
0answers
39 views

Help identifying LaTeX code-style feature

The document below uses a feature I can't quite identify to display monospaced code-style font sections: Does anyone know how to achieve this effect?
4
votes
1answer
64 views

Inconsistent caption height in algorithm environment

I noticed that the height of the caption of the algorithm environment does not solely depend on the font size, but on the actual caption text as well: \documentclass{scrartcl} ...
3
votes
1answer
125 views

Make the some parts of pseudocode bold

I just want some piece of pseudo code (below) to stand out in my algorithm. So I made the all the keywords (if, end for etc) unbold with \AtBeginEnvironment{algorithmic}{\let\textbf\relax}. Now how ...
0
votes
0answers
26 views

How to illustrate vector operations in algorithm environment?

Is there a nice standard way to represent a vector, and things like vector creation, and operations like push_back, or add in the algorithm environment?
2
votes
1answer
252 views

Divide algorithm inside If EndIf

This is a follow-up question to Option in the algorithm with Latex. This is the code: \begin{document} \begin{algorithm} \caption{My algorithme} \begin{algorithmic}[1] \Donnees: My data ...
1
vote
1answer
42 views

Error in listofalgorithms, undefined control sequence in .loa file [closed]

I am trying to write a pseudo code in LaTeX, and want to list the algorithm in the \listofalgorithms. Using the following code, I can generate the pseudo code in pdf and also the algorithm is listed ...
1
vote
1answer
41 views

putting algorithm in box

Below is my code snippet. Please help me to put a framed box in my algorithm. \documentclass[journal,12pt]{IEEEtran} \usepackage{algorithmic} \usepackage{graphicx} \usepackage{algorithm} ...
4
votes
1answer
50 views

Define algorithmicx block without line numbers

I'm trying to define some sort of algorithmicx command to give me this: \Statex \textbf{Local State:} \Statex \hspace{\algorithmicindent} $v \gets []$ \Statex \hspace{\algorithmicindent} $h \gets ...
3
votes
2answers
59 views

Having separate captions for algorithms inside a tabular

I have the following code: \documentclass[10pt,conference,compsocconf,letterpaper]{IEEEtran} \usepackage{algpseudocode} \usepackage{algorithm} \begin{document} \begin{algorithm*}%[H] ...
3
votes
1answer
224 views

Custom text instead of line numbers in algorithmic

In an algorithm using the algorithmic package, I would like to display for some lines a special symbol (e.g. a +), instead of their line number. Is this possible? Edit: Here's a minimal working ...
3
votes
2answers
75 views

Disable the last line at the end of algorithm

If I use the algorithm package as such \begin{algorithm}[h!] ...insert algorithm here... \end{algorithm} I find a line at the end of my algorithm. Without going into detail, I want a algorithm ...
1
vote
0answers
55 views

How to set algorithm width to avoid overfull \hbox problem

I wrote the following latex text, but the log shows an error that overfull \hbox(10.0pt too wide) detected. I am sure that the algorithmic part exceed the width limit. Even if I type a few words, the ...
1
vote
1answer
24 views

Problem with cross references in table and algorithm

I am having a problem with cross references, which I have not been able to solve. I have a table and an algorithm which cannot be referenced. However, the behaviour in both cases is different: when I ...
3
votes
2answers
2k views

How to align text within an algorithm environment?

I wish to duplicate an effect I've seen elsewhere (image below) in which text not necessarily at the beginning of a line is aligned with text elsewhere. I don't know which environment is suitable, ...
2
votes
1answer
37 views

Help to write LWU-NN algorithm in Latex -whats wrongg with my code

Please can someone guide me as to how to write the algorithm attached in Latex I have tried and its giving me a lot of errors \begin{document} \usepackage{algorithm} \usepackage{algpseudocode} ...
1
vote
2answers
64 views

Need help reformatting PowerPoint slide containing latex code

Consider the following PowerPoint slide: This was produced with the help of IguanaTex plugin, which allows you to generate pictures from latex snippets, and add them to your PowerPoint slides. ...
0
votes
0answers
16 views

Indentations in Algorithm floats in LYX

I am using LYX and I'm trying to enter algorithms in an algorithm float. Is there a way to have indentation?
0
votes
0answers
28 views

Adding keywords to an algorithm in LYX

I am using the method explained in this post to add algorithms in LYX. I wonder if it is possible to add new keywords like (Input, Output, ...) so they appear in bold. I use Algorithm-Style Package ...
0
votes
0answers
17 views

How can I set the font for loops in algorithm2e?

Consider the following listing with algorithm2e. I want the font in the if-clause at the bottom to be in typewriter or the same font used in the loop bodies, and the list for the for-loops as well. I ...
0
votes
3answers
54 views

Algorithm in document class clv2

How to write an algorithm in an article in \documentclass{clv2}, can anybody send me a working model with dummy algorithm, because I guess \caption is creating problem. I want to send it to ...
0
votes
0answers
12 views

algorithm not coming properly [duplicate]

I want to write an algorithm like this using \documentclass{clv2} but my pdf is not being generated because of nested loops.
2
votes
1answer
39 views

algorithm textsc and uarial package?

Is it possible to get a regular optic at the algorithm package when using the uarial package? I am using: %change font \usepackage{uarial} %set arial as default font for everything ...
1
vote
0answers
23 views

Put two algorithms in the same page one after the other

I want to put two algorithm on the same page and be able to change the size of two of them at the same time as they are in a box. I thought about \minipage but I am not sure how exactly I can do it.
0
votes
0answers
22 views

How can very long algorithms be automatically split over multiple pages with a specific layout?

My question is related to this other question just published I have the same problem and I solve with your solution, removing {algorithm*} environment (which is a floating box, and boxes never ...
6
votes
1answer
5k views

How can very long algorithms be automatically split over multiple pages?

I have a very long algorithm than spans several pages. I can not get Latex to make it span across several pages. I know that several questions similar to this one have already been asked, but I ...
0
votes
1answer
69 views

How to write algorithm without numbering in latex

I am looking for the way to write a algorithm as: (without numbering). Please help me to write it in latex. Thanks in advance Algorithm: Input: A, B,C. Initialize \alpha, \beta,u Employ the A While ...
0
votes
0answers
41 views

How to insert a subscript in algorithm

I'm writing a pseudocode by algorithm package. Now I want to write a variable using a subscript: I would write something like var\ped{e} where var is the name of the variable and e is the subscript. I ...
1
vote
0answers
40 views

Typesetting algorithms in LaTeX like Kleinberg and Tardos 'Algorithm Design'

Is there any LaTeX package for typesetting algorithms in the style Kleinberg and Tardos uses in Algorithm Design?
0
votes
0answers
17 views

Why is this algorithm badly outlined?

I have the following algorithm in Latex using the algorithm and algorithmic package: \begin{algorithm} \caption{Play-N-Games algorithm} \label{alg:play} \begin{algorithmic} \State $Agent\gets Make ...
3
votes
1answer
2k 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 ...
0
votes
0answers
44 views

Algorithm indent problem with sig-alternate document & algorithm(ic) package

Can anyone tell me why the indention of the algorithm does not work? I have the following code: \begin{algorithm} \caption{STEP 1} \begin{algorithmic}[1] \REQUIRE Something \FOR{\textbf{each} ...
36
votes
1answer
101k views

Write pseudo code in latex

I am trying to write pseudo code in my paper. Here is the snippet and image like what I want. Can some one please help me to format it. \begin{algorithm} \caption{Euclid’s algorithm}\label{euclid} ...
4
votes
1answer
35 views

Errors with the following algorithm -inputenc Error

\documentclass{article} \usepackage{algorithm,algpseudocode} \begin{document \begin{algorithm} \caption{PUML Algorithm} \label{PUML Algorithm} \begin{algorithmic}[1] \Procedure{Path\textendash Binary ...
3
votes
1answer
109 views

How to change font style of all algorithm/algpseudocode keywords?

In detail I want to change the font style of all keywords like If Return For to bold/sans serif, but only the keywords. MWE: \documentclass{article} \usepackage{algorithm} ...
11
votes
2answers
9k views

What is the best looking pseudo code package?

I have stumbled across various pseudo code packages but can't seem to find that's simple and eye-candy and practical. What I'm looking for: Visually attractive structure (eye-candy) ( easy to look ...
0
votes
0answers
45 views

algorithms package, science packages and related configuration problems

I am new to Ubuntu and new to LaTeX and now I need to modify a .tex file. I use Texmaker. It said that the algorithmic.sty is missing, so I installed the texlive-science packages. But when I did, I ...