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

5
votes
1answer
295 views

Align appearance of listings and algorithm packages

I want the output generated by the listings and the algorithm package to be the same. Consider the following minimum working example. ...
4
votes
1answer
1k views

Ploblems with vertical lines in algorithmicx

I use algorithmicx with verical lines. And code is working good: \documentclass{article} \usepackage{algorithm} \usepackage{algpseudocode} % Vertical line \makeatletter ...
8
votes
1answer
2k views

Numbering in algorithmicx

I have simple code: \documentclass{article} \usepackage{algorithm} \usepackage{algpseudocode} \begin{document} \begin{algorithm} \caption{Examples}\label{alg:Examples} \begin{algorithmic}[1] ...
3
votes
1answer
506 views

Implementing indent in algorithm environment

I am using the algorithm environment in the algorithm2e package. What I want is to able to indent various portions. I tried \indent but that is doing me no good. Here is the MWE: ...
2
votes
1answer
462 views

Algorithm pointers and references

I'm looking for a clean way/best-practice of writing an algorithmic block that uses pointers and references. I've had success with algorithmic in the past, but this is the first time I've tried ...
4
votes
1answer
3k 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 ...
1
vote
1answer
271 views

Algorithm code width problem

I have a problem in the width of the algorithm which I wrote as shown below, and I need to write it in a better way but I can't, any help? This is my code: \begin{algorithmic} \WHILE{$GenC[i] ...
4
votes
1answer
3k views

Unnumbered lines in algorithm

My question is similar to this one, I need to skip number for some lines of the algorithm. However the solution from that question does not work for me. How can I disable numbers for some lines using ...
2
votes
1answer
889 views

Disable line numbering of specific lines

Is there way how to turn off numbering of lines for specific line in algorithm2e? I need bold : after keyword. So I tried redefine these macros: \renewcommand{\KwIn}[1]{\textbf{Input:} #1} ...
5
votes
1answer
1k views

algorithm2e and \algomargin with negative value

How can I use a negative length in \algomargin using algorithm2e? I get the unpleasant effect that the vertical lines and the caption are not moved accordingly, see for example: Note that this ...
2
votes
1answer
726 views

No italics in algorithm2e if-clause

Why does algorithm2e typeset the variables anychange and done in italics, and how can I turn this off? How can I remove the semicolon after done in the until-clause? $\textsf{anychange} \gets ...
3
votes
1answer
6k views

Subroutine in algorithm2e

I am looking for a tiny example of writing in algorithm2e an algorithm using a subroutine. The algorithm is called algo, and it recursively calls a subroutine called proc. It should be something like ...
3
votes
1answer
317 views

verbatim environment inside algorithm2e

I need to output Prolog style inside algorithm2e and It seems that I cannot use \verb inside algorithm2e. How can I use \verb or verbatim for only one line inside algorithm2e in Latex?
4
votes
1answer
5k views

algorithm2e and Beamer - How to make algorithms wider with smaller font?

I would like to make the algorithm2e environments wider in a beamer document. Indeed I must you a \scalebox to see all of my algorithm. Is there a way to have wider algorithms with smaller size font ...
7
votes
1answer
342 views

Typesetting listofalgorithms like listoffigures and listoftables using titletoc

I would like to typeset the \listofalgorithms generated by package algorithm in the same way than the \listoffigures and \listoftables, using package titletoc. However, I have not been able to find a ...
5
votes
1answer
230 views

How to make the line number in algorithm shown in bold

I have tried following which works (making the number in second line bold) \begin{algorithm}[h] \begin{algorithmic}[1] \State TSO.assignStartTs() {\bf\State} TSO.assignCommitTs() \end{algorithmic} ...
2
votes
2answers
604 views

How to reformat Algorithm in memoir document class?

I'm trying to typeset algorithms in the memoir class. I'm using the algorithmic package with a custom environment as this was the only way I could get the list of algorithm to display correctly in the ...
2
votes
1answer
1k views

Make List of Algorithms formatting match LOT/LOF

I'm working on my thesis, and I have a minor formatting problem with my list of algorithms. The entry is added properly in the TOC and the font, size dotting and numbering are perfect, but for some ...
3
votes
1answer
870 views

Line number error using “Require” and “Ensure” in package{algorithmicx}

I’m using the packages algorithmicx and algpseudocode to write algorithms in my paper. It’s more convenient and beautiful to specify comments than with the algorithmic. But I encounter an error while ...
3
votes
1answer
457 views

How to remove newline character after case statement in algorithm2e?

I don't want any newline character after case statement. How can I do that? This is my code: \begin{algorithm}[t] \SetInd{0.5em}{0.5em} \KwIn{Data $\mathsf{D}$} \KwOut{List of Simple Hints} ...
4
votes
2answers
656 views

How to remove “Algorithm #” caption prefix but keep list of algorithms?

I am using the algorithm-package and would like to name my algorithms without any generated prefix. So I would like to remove "Algorithm #" as prefix from my caption, but still keep the list of ...
0
votes
0answers
42 views

writing part of a pseudocode [duplicate]

I have a few pseudocode lines like for each item in list L if (item > 50)| (item > 50)|(item > 50) value=item break; Obviously, this is not the exact code :). If I use a package ...
4
votes
1answer
500 views

Add the word “Algorithm” before each entry in the List of Algorithms

I'm trying to add the word "Algorithm" before each entry in the List of Algorithms (because of unavoidable thesis guidelines). I saw similar questions but the solutions listed there don't work for ...
3
votes
1answer
960 views

Problem with algorithm(ic) and hyperref

The following code works ... fine! \documentclass{book} % \usepackage{subfig} % \usepackage{subcaption} \usepackage[colorlinks]{hyperref} \usepackage{algorithm} \usepackage[noend]{algorithmic} ...
3
votes
0answers
137 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
142 views

How to define the following symbol to stock one element in one list?

I'm looking for one symbol to indicate that a value is stocked in one list. On way would be to use something like myList.append(myValue) but it os not very quick to see and to write. Indeed, I would ...
1
vote
1answer
301 views

List of Algorithms header format [closed]

Does anyone know why the header of List of Algorithms is not equal to the format of List of Tables when both using with \listoftables or \listofalgorithms Here is a screenshot:
8
votes
1answer
647 views

The line spacing in the list of algorithms

This is my code: \documentclass[12pt,a4paper]{book} \usepackage[T1]{fontenc} \usepackage[chapter]{algorithm} \renewcommand{\baselinestretch}{1.5} \begin{document} \begin{spacing}{1.2} ...
2
votes
0answers
167 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 ...
4
votes
1answer
2k views

Modify Algorithm name in French

This is my code: \usepackage[section]{algorithm} \usepackage{algorithmic} \begin{document} \makeatletter\renewcommand{\ALG@name}{Algorithme} \renewcommand{\listalgorithmname}{Liste des \ALG@name ...
1
vote
1answer
1k views

Divide an algorithm on two pages [duplicate]

\usepackage{algorithm} \usepackage{algorithmic} \begin{document} \begin{algorithm}[H] \caption{My algo} \begin{algorithmic}[1] \STATE instruction 1 \STATE instruction 2 ......................Many ...
2
votes
1answer
2k views

How to modify line spacing in algorithm / algpseudocode?

I want to increase line spacing between statements in algorithm environment. I used the setspace package as here, but it also affects the space between line breaks that is not wanted. The following is ...
4
votes
1answer
1k views

Slight change in algorithm

This is my MWE for an algorithm however its throwing an error and I don't know how to get inputs and initialize. I want it to look like the attached image. ...
1
vote
0answers
900 views

Algorithm spanning two columns error with \prevdepth [closed]

I am trying to use the algorithm command to display an algorithm that spans two columns in a two column document. However, I am getting an error message with \prevdepth that I do not understand. Below ...
5
votes
0answers
55 views

Review of algorithm-related packages? [duplicate]

Possible Duplicate: Print programs with its proper syntax Where can I find (if it exists) an updated review of the most relevant packages for handling with algorithms (pseudocode or code ...
7
votes
2answers
4k views

Commands argmin and argmax in algorithm

I am trying to use the argmin and the argmax commands that I defined in an algorithm but I keep getting the argument not in the middle but on the right. Does anyone have an idea how to put the ...
0
votes
1answer
1k views

Algorithm in LaTeX

I wrote the following algorithm, however its not compiling and throws a few errors. I am not sure of what I did wrong. Any help would be appreciated. \begin{algorithm} \caption{Bridging ...
7
votes
1answer
1k views

algorithmic, arbitrary names for algorithms

The question is advanced version of my previous one. I need to name algorithms (package algorithmic) with arbitrary names so it appears like: Algorithm MyAlgo and \ref{...} will appear like MyAlgo. ...
2
votes
1answer
235 views

algorithmic package, get rid of algorithms numbers

My question is about algorithmic package. I have an algorithm which I called A1. \begin{algorithm} \caption{\bf A1:} \label{algorithm-A1} ... I have something like this: Algorithm 1 A1 How can ...
8
votes
1answer
3k views

Add algorithm label to list of algorithms

I'm using the classicthesis package along with the algorithmic package. I'm trying to get the list of algorithms to look the same as the list of figures/tables etc., but cant find a way to make it ...
6
votes
1answer
231 views

How to prevent indent on \listofalgorithms?

How can I prevent the \listofalgorithms from being indented? I tried everything I could find on the internet, but the index of my algorithms refused to be aligned along with the title. Here is a MWE: ...
7
votes
1answer
2k views

Line numbering in algorithmic

I want to change the first number of the line numbering in my algorithm, but how is it done? This is my example: \documentclass[12pt]{beamer} \usepackage{amsmath, amsfonts, amssymb, amsthm} ...
5
votes
2answers
220 views

3 Algorithms in the same column with algorithmic

I have 3 algorithms that I want to be displayed in the same column of a 2-column document. They are all slight variations of each other, so it is important that they be displayed right next to each ...
3
votes
1answer
1k views

Undefined control sequence when adding math comment to \WHILE

I'm pretty new to (La)TeX so please forgive me if this question is stupid :) I have an algorithm that is typeset with the algorithm and algorithmic packages. Then I have this in the algorithm: ...
1
vote
0answers
140 views

Package algorithmic [closed]

So my problem is whenever I try to use the algorthmic package, it gives me an error related to citations! And when I comment out the algorithmic block, everything works fine. I read somewhere that ...
5
votes
2answers
2k views

Can't manage to use algorithm packages

I'm trying to write some simple pseudocode but I just can't get it to work. It's pseudocode from another paper and I want to change it a little and put it in my paper. This is the pseudocode I want ...
1
vote
1answer
419 views

Add line before Begin algorithm 'Début' [closed]

This is a follow-up question to Option in the algorithm with Latex. This is my algorithm: \usepackage{algorithm} \usepackage{algorithmic} \begin{document} \begin{algorithm}[H] \caption{My algo} ...
7
votes
1answer
785 views

How to localize label using algorithm and algorithmic packages

I am writing a paper in Italian and I need to include pseudo code in my latex document so I am currently using the algorithm and algorithmic packages. At the top of every algorithm the label Algorithm ...
5
votes
2answers
534 views

Phantom malfunction in algorithm caption

I am trying to use \phantom in the context of an algorithm caption. I am using the algorithm and algorithmic packages. \phantom will work properly in normal text in my document, but not in a caption. ...
0
votes
0answers
38 views

Increase the indent in an algorithm [duplicate]

Possible Duplicate: Indenting lines of code in algorithm This is my algorithm: \usepackage{algorithm} \usepackage{algorithmic} \begin{document} \begin{algorithm}[H] \caption{My algo} ...