{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
58 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
41 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
11 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
57 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
626 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
26 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
20 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
29 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.
1
vote
1answer
17 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
31 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
24 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{ ...
74
votes
6answers
45k 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
70 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
157 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
13 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
38 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
46 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
8k 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
77 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
139 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
40 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
53 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
31 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
111 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
105 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
255 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
47 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 ...
16
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
89 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
103 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
67 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
77 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
260 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
37 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
170 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
98 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} ...
14
votes
1answer
820 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 ...
9
votes
2answers
2k views

Adjust the indentation whithin the algorithmicx-package when a line is broken

I have this code \documentclass{article} \usepackage{algorithm} \usepackage{algpseudocode} \begin{document} \begin{algorithm} \caption{Minimal Working Example for my Problem} ...
2
votes
1answer
49 views

Changing name of the label Algorithm [duplicate]

When using algorithmx you get "Algorithm 1 algorithm name". How can you change the label "Algorithm"? I do not mean individually for each algorithm, but instead changing it globally the whole latex ...
5
votes
1answer
109 views

Change name of algorithm

I've been trying to use this answer Changing label name for algorithm to no avail. I use the packages: \usepackage{algorithm} \usepackage{algpseudocode} And this code for defining new environment: ...
1
vote
0answers
21 views

Algorithm pseudo code not published beyond one page [duplicate]

My algorithm pseudo code is not being published beyond one page though there is no syntax error. The PDF produced via LaTeX is of only one page but my entire algorithm requires more than one page. So ...
4
votes
3answers
69 views

Spacing issue with algorithmic and eqparbox

I am using the algorithmic package to display code. In order to get flush-right, left aligned comments, I also use the eqparbox package and redefine \algorithmiccomment; see minimal example below. As ...
0
votes
0answers
41 views

Too long algorithm

I would like to know how it is to write a long algorithm beyond the edges of a page, knowing I used algorithm and algorithmic packages?