{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
2answers
228 views

Problem and question tocloft

I tried to create my own "List of things" with help of this post: Define your own list of Now my questions: I don't want to use the command \algorithm {Text}. Instead I want to use a container like ...
1
vote
1answer
108 views

How to define new loops in algorithmicx?

How can I define a new loop in algorithmicx? For example, code like this: ex1) PreLoop s do --statement1 --statement2 ex2) PostLoop s do --statement1 --statement2 Is it possible to define it ...
4
votes
3answers
690 views

Combine \listoflistings and \listofalgorithms into one list

The title said it all...I want to combine the two under one list with the title "Algorithms and program code". Style wise the page should match the usual style of the other lists (\listoffigures, ...
4
votes
2answers
632 views

How to avoid printing the algorithm number in algorithm captions?

I am using the algorithm2e package to write algorithms. However, when i write three algorithms one after another, the algorithms are automatically numbered 1,2 and 3 in the caption. I am using ...
1
vote
1answer
143 views

Algorithms in mdframed

Now that I converted all my theorems to mdframed, I'd like a consistent layout for my algorithms as well? What ways are there to typeset pseudocode algorithms in mdframed? So far I've been using ...
4
votes
1answer
1k views

cleveref fails to reference algorithms

In the following example document, both \autoref and plain ref will correctly link and number an algorithm reference, but cleveref fails that task. It will just insert question marks instead. In ...
5
votes
2answers
1k views

Caption numbering breaking up an algorithm with algorithmicx

According to its documentation, algorithmicx package allows break up an algorithm inside a document, as follows: Related tex code is: \documentclass{article} \usepackage{algorithm} ...
2
votes
1answer
216 views

Line break inside procedure's definition with algorithmicx

I don't know if this package is the best for my purpose, but I'm using algorithmicx (see here the documentation) to write algorithms (in pseudcode) inside my work. At now, I've just a problem: ...
2
votes
1answer
274 views

How to put a vertical space between two functions inside algorithmic environment?

To make the algorithm readable, I would like to put some space between two functions. E.g.: \documentclass{article} \usepackage{algorithm} \usepackage{algpseudocode} \begin{document} ...
3
votes
2answers
114 views

Alignment problem with algorithmic and hyperref

I have some alignment problems in the algorithmic environment when I use the hyperref package. I like to have my comments left-aligned which I achieve by ...
5
votes
1answer
326 views

Referring to function name in an algorithm

I have a LaTeX code which looks similar to the following example. \documentclass{article} \usepackage{amsmath,algorithm,algpseudocode} \begin{document} \begin{algorithm} \caption{My Algo.} ...
8
votes
1answer
5k 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 ...
5
votes
1answer
268 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 ...
6
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
367 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
395 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
2k 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
251 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
2k 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
764 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
938 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
635 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
5k 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
271 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
4k 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
310 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
208 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
518 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
677 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
410 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
543 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
466 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
873 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
122 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
138 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
286 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
592 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
154 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
895 views

Divide an algorithm on two pages

\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
1k 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
962 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
785 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. ...