{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.
4
votes
3answers
54 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, ...
3
votes
2answers
44 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 ...
0
votes
1answer
43 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 ...
2
votes
1answer
47 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 ...
4
votes
2answers
42 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
20 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
39 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
55 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 ...
3
votes
0answers
50 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.}
...
7
votes
1answer
240 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
65 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
0answers
63 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
...
5
votes
1answer
57 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
42 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
50 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 ...
3
votes
1answer
98 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
57 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
62 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
97 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
96 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
85 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 ...
2
votes
1answer
246 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
234 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 ...
5
votes
1answer
65 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
88 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
126 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
123 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 ...
2
votes
1answer
101 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
94 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}
...
3
votes
2answers
94 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
37 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 ...
3
votes
1answer
106 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 ...
2
votes
1answer
183 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}
...
2
votes
0answers
59 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
90 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
135 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:
7
votes
1answer
154 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
78 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
237 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
92 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
295 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
150 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
161 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
48 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 ...
4
votes
2answers
561 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
420 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 ...
6
votes
1answer
176 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
104 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 ...
5
votes
1answer
391 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
85 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:
...

