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

2
votes
1answer
23 views

Undefined control sequence and Something's missing perhaps a missing \item

I am using Windows 7 and getting a LaTeX Error in an algorithm; I am new to LaTeX and already spent a lot of time to figure this out but no luck. Could you please help me here? \begin{algorithm} ...
2
votes
0answers
23 views

Can my algorithm description be improved? [on hold]

I'm writing a pseudocode description of the FISTA (with line search) algorithm from convex optimization. (I'm using slide 17-18 here as a source.) Can anyone suggest any improvements to my latex ...
5
votes
2answers
41 views

Style \listofalgorithms from algorithm package

I have some weird requirements for thesis formatting at my university. I was able to manage to mimic almost all of them, but List of Algorithms from algorithm package is something I cannot go through ...
3
votes
1answer
20 views

algorithm and controlling comment lines (shifting right or left)

I need to shift a comment to the right. Basically, in the below picture The comment is distracting the pseudocode, therefore, I'm hoping to get the below picture How to shift the comment to ...
1
vote
1answer
18 views

How to make caption above in algorithm

How can I make the caption "Algorithm 1" be placed above the first line and the text still inside the two first lines? And how can the line styles be changed in the algorithm environment? ...
3
votes
1answer
21 views

Floats change behavior when using package “algorithm”

Not really a problem, but I noticed this when pruning stuff from a document preamble to find a problem I was having. I've found the problem but also something a bit weird Just the act of importing ...
4
votes
2answers
21 views

Space in caption type name (algorithm)

To include code in my document I have following in my preamble: \usepackage[Code]{algorithm} \usepackage{listings} and following in the document body to display the actual code: begin{algorithm} ...
0
votes
0answers
27 views

Is there a nice way to split an algorithm float over multiple pages?

I am using the algorithm float with an lstlisting in it containing the code. Unfortunately, the code is just a little too long to fit on one page. I'd like to keep the layout provided by the ...
2
votes
1answer
20 views

How to put a line number with levels in algorithm?

\documentclass[a4paper, 10pt, 3p, final, twocolumn, times]{elsarticle} \usepackage{algorithm} \usepackage{algorithmic} \begin{document} \begin{algorithm}[htbp] \caption{somealg} \label{alg} ...
1
vote
1answer
25 views

algorithmicrequire undefined when using algorithmicx

I was using algorithmic and algorithm to write algorithm: \usepackage[noend]{algorithmic} \usepackage{algorithm} \renewcommand{\algorithmicrequire}{\textbf{Input: }} ...
0
votes
0answers
11 views

combining pictures and algorithm in two columns document

I tried a lot to prepare such a following format for my paper but it always put algorithm in a separated place. here is \begin{algorithm*}[] \KwIn{$L_1$, $L_2$ } \Return{$F$} ...
1
vote
1answer
26 views

Can I remove the word “algorithm” from the header and keep only the caption,also I “want for loop” to be indented after step 3

\begin{algorithm}[h] \begin{algorithmic} \caption{Math algorithm} \STATE \textbf {Step 1} $\rightarrow $ gather the data \STATE \textbf {Step 2} $\rightarrow $ estimate matrix \STATE \textbf {Step ...
2
votes
1answer
20 views

Missing line below caption in algorithm environment

Using two different computers at work and at home, I sometimes compile my thesis with one computer and sometimes with the other. Most of the time the two versions are consistent, but for algorithms I ...
1
vote
0answers
17 views

\ref to algorithm/algorithmic not working [duplicate]

I am trying to reference an algorithm in my thesis, made using the algorithmicx and algorithm packages, but it fails, ending up with the dreaded ?? and the following error: LaTeX Warning: Reference ...
2
votes
0answers
35 views

Using special characters with lstlisting

I am using the Algorithm2e package to use code in my LaTeX document. However, the code contains special characters such as à, é, è etc. Those characters causes errors such as Unicode character x not ...
4
votes
2answers
81 views

Algorithm environment problem

I am doing my master thesis and need to include an algorithm into my LaTeX code. I have been trying for hours now, but I still have several errors that always show up. It is my first time using the ...
5
votes
1answer
77 views

Algorithms and amsart

Basically, I have copied the code from answer to this quesiton, for I have to translate some words. I have only changed documentclass from article to amsart. \documentclass[11pt]{amsart} ...
0
votes
1answer
29 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?
0
votes
0answers
14 views

How to write “for” block with counter by Algorithmic package

How can I write a code like below using algorithmic package for (int i = 0; i < node.children; ++i) ..... I can't use foreach or forall because in a point inside the loop I should decrement i ...
0
votes
0answers
13 views

How can I include specific lines of pseudocode from a file?

In my document, I use the listings package to include listings from separate files: \lstinputlisting[firstline=6, lastline=11, firstnumber=6]{myprogram.c} (This shows the lines 6 to 11 from the ...
1
vote
2answers
85 views

Reproduce neat Algorithm Style

I've seen this nice algorithm sytle in Stachurski (2009), "Economic Dynamics", p.74. Does someone know what package, environment or settings he used?
1
vote
1answer
35 views

how remove space before algorithm (caused by layout)

i'm not an expert of latex and i can't solve the following problem. I have a long algorithm and this occupies an entire column, the problem is that compiler add a blank space before it, and i need ...
2
votes
1answer
31 views

How to put a custom tag to the algorithm environment?

I am trying a way to number algorithms 1a, 1b, 1c, 2a, 2b, 2c, etc. As I understand from the documentation of the algorithms package here, I can number them after the part, chapter, section and so on. ...
0
votes
1answer
45 views

Algorithmic in Latex [duplicate]

I want to write: {Step 6 for n = 0 to final do y(n) = x(n) e(k) = d(k) 􀀀 y(k) w(n + 1) = w(n) + x(n)e(n) end for} My problem is for appears in the start without identation.
1
vote
1answer
19 views

Replace “Algorithm” in algorithm package

I use the latex package algorithm. I would like the name of my algorithm ("Algorithm 1.1") to be change to the french version ("Algorithme 1.1") in the compiled pdf document. How could I do that? ...
1
vote
0answers
38 views

Error with algorithm and algorithmic packages

I have the following problem that involves the algorithm and algorithmic packages with the garamondx font. This is a minimal example: \documentclass[letterpapet,10pt]{article} \usepackage{garamondx} ...
1
vote
1answer
75 views

Algorithm nested for loops generate a blank line

%!TEX program = xelatex \documentclass{article} \usepackage{algorithm} \usepackage{algorithmic} \begin{document} \begin{algorithm}[] \caption{LDA} \begin{algorithmic}[1] \FOR{$d$} \STATE{ ...
1
vote
1answer
20 views

How to put two algorithm2e (one is large and one is small) side by side by using minipage or subfigure?

I have two algorithms wrote by the algorithm2e package. One of them is large and the other is small. My try is here: %\documentclass[runningheads,a4paper]{llncs} \documentclass{article} ...
1
vote
1answer
81 views

writing algorithm in a table

I want to write an algorithm such that what I have attached, I am somehow elementary in writing algorithms with latex. I do not want the exact answer, only a tip or an example similar to what I have ...
5
votes
2answers
58 views

Share counter between amsthm and algorithm

I am using amsthm \usepackage{amsthm} \newtheorem{thm}{Theorem}[chapter] \newtheorem{lem}[thm]{Lemma} \newtheorem{prop}[thm]{Proposition} and algorithm \usepackage{algorithm, algpseudocode} ...
0
votes
0answers
14 views

Algorithm formatting

\begin{algorithmic} \For{$i,j\gets 0, 255$} \State $j\gets (j + key [i mod keylen] + S[i] ) mod 256$ \EndFor \end{algorithmic} I want to print j= (j + key [i mod keylen]+s[i]) mod 256 My code ...
1
vote
1answer
44 views

Comment in algorithmic on a line beginning with if, and using uncover/visible

I am trying to modify this code, into the following one : \documentclass{beamer} \usepackage[utf8]{inputenc} \usepackage[english]{babel} \usepackage[plain]{algorithm} \usepackage{algorithmic} ...
5
votes
2answers
54 views

How to format line in algorithm

I use ACM conference paper template (Two columns) to write paper. The problems bug me for a long time about Algorithms format: The function name always converted to UPPERCASE. Larger blank between ...
2
votes
1answer
115 views

Table of contents of algorithm and algorithm2e together

The contents of the algorithms thinks that an algorithm that uses algorithm is one algorithm and an algorithm that uses algorithm2e is another algorithm, not the second of what was imported with the ...
0
votes
0answers
19 views

why \end{algorithmic} ends with =0? [duplicate]

I wrote some algorithms using pseudocode, but when compiling the document, each algorithm ends with =0 (at line\end{algorithmic}). What I have to do to avoid this problem?
14
votes
2answers
157 views

How can I typeset an algorithm with columns as in CLRS (Introduction to Algorithms)?

In Introduction to Algorithms, by Thomas Cormen, there are some algorithm like in this image. With one column for the code, one for the cost and one for the times. I searched a lot, but I didn't ...
4
votes
1answer
51 views

Algorithm environment, defining a custom style

I'm currently using the following mwe \documentclass{article} \usepackage{algpseudocode} \usepackage[plain]{algorithm} \begin{document} \begin{algorithm}[H] \hrule \vspace{0.5em} \caption{Euclide's ...
2
votes
1answer
63 views

How to make listofalgorithms behave like a section, not a chapter?

I have a problem. I included the following: \documentclass[a4paper,11pt,reqno]{book} \usepackage{algorithm} \usepackage{algorithmicx} \usepackage[noend]{algpseudocode} and wanted to create a ...
3
votes
1answer
38 views

Set linespread in algorithm environements

My algorithms are really complicated and I want to \onehalfspace their lines to make them more readable, while keeping the rest of the document singlespace. How can I do this so it will automatically ...
2
votes
2answers
260 views

Multiline statements and conditions in algorithm environment

I have an algorithm that I want to write in mathematical pseudo-code. However, some conditions and statements are very long, e.g. "if (a series of relations and constraints hold) do" or "X gets (a ...
0
votes
0answers
13 views

Linebreak with algorithm environment in two column mode [duplicate]

I want to integrate an algorithm in a two column article, but I'm not happy with the output (screenshot below). I'm wondering why the algorithm environment don't break the code and go on the next ...
4
votes
1answer
50 views

Counter not incrementing when defining crefname with cleveref and algpseudocode

I am renaming the "line" label for lines in the algorithmic environment, since I am using the default label for lstlisting environment. As soon as I add define \crefname for it, the counter does not ...
4
votes
1answer
102 views

End word is hidden in algorithm block

Suppose that i have this code: \usepackage[ruled,vlined]{algorithm2e} \begin{dcocument} \begin{algorithm}[H] \KwData{this text} \KwResult{how to write algorithm with \LaTeX2e } initialization\; ...
2
votes
1answer
78 views

“and” in algorithm

So I'm not experienced with the algorithm packages in LaTeX. I'm assuming there must be a way to do if condition1 and condition2 then... but I can't find it. I've checked what I can find of the ...
0
votes
0answers
12 views

In algorithm/algpseudocode, when writing long lines within loops how can I adjust the left indentation? [duplicate]

Q: In algorithm/algpseudocode, when writing long lines within loops how can I adjust the left indentation? To illustrate the problem, this is what I have: But this is more like what I want it ...
4
votes
1answer
82 views

Randomizing a given text

It sounds stupid, but it's useful to me. I want to randomize words. To input a text, and to get an output with the same words, in random order. I have no idea how to begin with, though. Therefore I ...
2
votes
1answer
39 views

Maintaining indentation in a long Ensure-block with algorithmicx-package

I have a long "Ensure-block" in my algorithm. How can I force the second line to be exactly under the first "Text"? \documentclass{article} \usepackage{algorithm} \usepackage[noend]{algpseudocode} ...
5
votes
2answers
209 views

Include a line break in algorithm-caption while maintaining indentation

I've a question about the alignment of the caption in an algorithm-environment. For instance, the following code-example \documentclass{article} \usepackage{algorithm} ...
6
votes
1answer
336 views

{Begin End} does not show when writing algorithm in LaTeX

I am writing an algorithm in LaTeX using \usepackage[ruled,vlined]{algorithm2e} When running the code, the produced file does not show the word "end" that should appear automatically when using ...
3
votes
1answer
134 views

Algorithm in RevTex4-1

When I run the attached code I get this error: ************************************ Missing \endcsname inserted. <to be read again> \c@float@type l.23 \end{algorithm} ...