{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
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
24 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 ...
0
votes
1answer
25 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
2answers
73 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
72 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
33 views

Algorithmic in Latex

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.
0
votes
0answers
10 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 ...
2
votes
1answer
65 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 ...
5
votes
2answers
50 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
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
77 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?
5
votes
1answer
643 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 ...
1
vote
1answer
29 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
27 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. ...
1
vote
1answer
18 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
32 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
43 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{ ...
76
votes
5answers
46k views

What is a good package for displaying algorithms?

I found this page with some examples: http://en.wikibooks.org/wiki/LaTeX/Algorithms_and_Pseudocode I'm wondering which one to use. Any suggestions? I'm using other packages too so whichever is less ...
1
vote
1answer
78 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 ...
1
vote
1answer
17 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
179 views

Algorithm problem in poster with tikzposter

I am creating a poster using tikzposter. But it seems to have a bug with algorithm packages. I use the following code but the borders of algorithm block span to the whole width of the poster: ...
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
43 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
50 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 ...
7
votes
1answer
11k views

Writing an algorithm in LaTeX

I am trying to write an algorithm in LaTeX. I used a for loop inside the algorithm (see attached image), but the problem is that the statements that are below the for loop are not tapped. Why? I ...
2
votes
1answer
95 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 ...
8
votes
1answer
2k views

algorithmicx no listofalgorithms in contents section

I'm using algorithmicx to define some algorithms. It looks great, but I have one problem. When I use \listofalgorithms a page is created with the captions and links to the algorithms. However, there ...
14
votes
2answers
146 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 ...
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?
4
votes
1answer
46 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
56 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
36 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
165 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 ...
4
votes
1answer
108 views

Trouble creating custom algorithm environment with separate counter

I am trying to create a custom algorithm environment for CUDA kernel code that runs on the GPU, but have little experience with custom LaTeX. It should have a separate counter, be referenced as Kernel ...
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 ...
6
votes
4answers
267 views

Incorrect reference to a line in algorithmic using hyperref

I am using algpseudocode and algorithm packages to typeset pseudocode. I also use float, hyperref and caption packages. The problem is that when I reference a line in the pseudocode, the number is ...
4
votes
1answer
49 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 ...
17
votes
2answers
3k views

How to place a float at the top of a floats-only page?

I just got a short algorithm on my page, and it keeps getting aligned at the center of the page. But I want to have it aligned at the top, what do I have to do?
4
votes
1answer
94 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\; ...
9
votes
2answers
4k views

Which package to use for writing algorithms?

I am looking for a package that will allow me to write pseudocode of algorithms. The pseudocode may include mathematical symbols, like \forall, \in and subscripts. But I would like also to "talk" ...
3
votes
2answers
109 views

Make listofalgorithms (algorithm2e) inside a section instead of chapter

I'm writing my thesis and I have a few algorithms (using algorithm2e) that I want to list in my appendix, but I don't want to start a new page. Also my listoffigures currently creates a section, not a ...
2
votes
1answer
72 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 ...
5
votes
1answer
1k views

Problems with \EndIf and \EndFor

I'm using the algpseudocode package and I want to write a pseudocode. This is my code \documentclass[conference]{IEEEtran} \usepackage[spanish, es-tabla]{babel} \usepackage{graphicx, times, amsmath, ...
4
votes
1answer
80 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 ...
6
votes
1answer
285 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 ...
2
votes
1answer
38 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
181 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} ...
3
votes
1answer
119 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} ...
15
votes
1answer
1k views

algorithm, algorithmic, algorithmicx, algorithm2e, algpseudocode = confused

I am getting confused about the package structure for writing simple "algorithms". There are too many options, and also got totally clueless about when to use what. Is there any definitive guidelines ...