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

0
votes
0answers
9 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
20 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} ...
4
votes
2answers
28 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
29 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
18 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?
12
votes
2answers
96 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
23 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
31 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
24 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
38 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
12 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
33 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
62 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
53 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
69 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
28 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
125 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
135 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
64 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} ...
2
votes
1answer
25 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
63 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
57 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 ...
12
votes
1answer
328 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 ...
0
votes
0answers
32 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?
3
votes
1answer
49 views

Collecting algorithm captions in WinEdt

I've installed the add-on Figures&Tables in WinEdt, which lets me collect table and figure captions in WinEdt's Tree. I would like to be able to collect algorithm captions, as well. With the ...
2
votes
1answer
41 views

Moving caption of the algorithm upwards

I have the following code: \documentclass{scrbook} \usepackage[linesnumbered,ruled]{algorithm2e} \begin{document} AAAA BBBB \begin{algorithm} \vspace*{-1cm} \caption{My Caption\ldots} My ...
1
vote
1answer
48 views

Conflict between image and algorithm style

I'm trying to write an article with both figures and algorithms. The commands related to images should be these: \usepackage{float} \usepackage{graphicx} \usepackage[margin=1.5cm]{caption} ...
3
votes
1answer
38 views

Changing the font of algorithm name in algo.sty

I am using algo.sty to write algorithm in LaTeX. I want that the algorithm names are in \texttt font. I guess I need to change something about the \a@paralgo (from algo.sty) in the below code, but I ...
2
votes
1answer
42 views

redundant number in the border

I have a piece of latex code and I would like to remove the redundant number 1 form top left of the border. How can I do this? \begin{algorithm}[t] \centering \small \resizebox{\linewidth}{!}{ ...
1
vote
0answers
33 views

Creating sub-algorithms

I want to have two algorithms together that I can refer to as 1a and 1b (rather than seperately as Algorithm 1 and 2). So very similar to how subfigures work. Is this possible using any of the ...
4
votes
1answer
72 views

How to write begin and end statement at the top and bottom of algorithm?

How can I write 'begin' and 'end' statement at the top and bottom the following code like this?A sample pseuodcode with begin and end statement Besides using algorithm and algopseudocode package I ...
2
votes
1answer
65 views

Algorithm2e package edit the line numbers

I need to remove the line numbers only below Step 1 and continue it after Step 2 and skip numbering infront of cc in Step 2. Please refer to the attached figure and the latex code. How I can do ...
0
votes
0answers
33 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 ...
2
votes
1answer
66 views

writing an algorithm in a table

i want to write an algorithm in a table for my paper. i have tried to write it but i want to write ''While'' instead of ''for'' in this algorithm. how can i do it? and i want to put the table every ...
2
votes
1answer
65 views

Add colon to algorithm Caption after algorithm number [duplicate]

If I typeset a simple algorithm using the algorithmicx package, say \documentclass{article} \usepackage{algpseudocode} \usepackage{algorithm} \begin{document} \begin{algorithm}[H] ...
0
votes
1answer
208 views

! Missing \endcsname inserted in \begin {algorithmic}

file1.tex: \documentclass[12pt,letterpaper]{report} %%%%%%%%%%%%%%%% Xiaodi add: \usepackage{longtable} \newcommand{\argmin}{\arg\!\min} \usepackage[dvips]{graphicx} ...
5
votes
2answers
815 views

Algorithm in IEEE format

I want to type an algorithm in ieee format. I have used algorithmic package. But using that package, I couldn't type a caption to the algorithm and "Algorithm " above the written algorithm. What ...
2
votes
1answer
37 views

Change 'noends' name back to 'Algorithms' when using [noend]

After I enabled the [noend] option, the names on the 'List of Algorithms' and algorithm pseudocode is changed to 'List of noends' and 'noend' respectively. how do I change it back? Thanks ...
4
votes
1answer
113 views

Using same font style of an already defined algorithm function in another algorithm

I want to use the same font style of a previously defined function in an algorithm environment when I call it in a different algorithm environment. Below is a minimal working example. I want the same ...
1
vote
1answer
47 views

How to change Algorithm title to something else? [duplicate]

when using \begin{algorithm} in latex for writing algorithms, we will have something like this: Is there any way to have something else like "Procedure" instead of "Algorithm"? Edit: I tried ...
2
votes
1answer
45 views

Bigger rows with fractions in pseudocode

I had previous question how to write pseudocode in latex. I would like to use fractions in pseudocode, but rows with fractions are a little small. Anybody know how to make rows with fractions a little ...
1
vote
1answer
70 views

Define function in pseudocode

Could you help me please how can I write a piece of pseudocode with function in latex? \begin{algorithmic} \STATE $\mathrm{maxWeight} \leftarrow \mathrm{value of e.weight where e has maximum ...
3
votes
1answer
58 views

Procedure name with small caps in algorithm2e

I know that procedure in algorithm2e only allows captions like \caption{ProcedureName()}. However, I'd like my procedure to appear in small caps: \documentclass[12pt,a4paper]{article} ...
0
votes
0answers
17 views

Replacing 'Algorithm' keyword in caption of algorithm2e environment [duplicate]

I want the following to appear: ------------------------------------ Policy 1: APolicy ------------------------------------ while not-an-end-of-doc do read-line; print-line to stdout; end ...
4
votes
2answers
354 views

Algorithm not showing the end loop statement

I'm using algorithm package for writing algorithms. I'm using following code for generating a loop \begin{algorithm} \caption{My algorithm}\label{alg:myalgo} \begin{algorithmic}[1] ...
1
vote
1answer
98 views

How to color an entire algorithm environment in LaTeX?

The entire algorithm environment needs to be colored in blue. While this can be done in a report or article environment, I am unable to get it done in the IEEE Journal templates. @Masroor : Thanks ...
1
vote
1answer
44 views

Breaking up an algorithm into several parts

I would to divide an algorithm I wrote into parts as shown in the attached file This is what I did so far : \begin{algorithm} \caption{Selection algorithm} \label{mpral} \begin{algorithmic}[1] ...
10
votes
3answers
195 views

How can I make an algorithm environment wider than \linewidth or \textwidth?

I have already tried two things: \makebox[1.2\textwidth][c]{...} which did not work (perhaps missing \item). \redefinegeometry does not work well in this case beacause it’s not on a single page. MWE: ...