{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
1answer
33 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
17 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
45 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
26 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
16 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
27 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 ...
3
votes
1answer
178 views

How to insert algorithm pseudocode in Lyx?

recently I found LyX is good for writing notes. But I don't know how to add a piece of algorithm pseudocode in Lyx environment. Could you please help give some advice? Thanks! How could I implement ...
2
votes
1answer
33 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
66 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
323 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
26 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
62 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
38 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
34 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
30 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 ...
9
votes
2answers
5k 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 ...
3
votes
1answer
27 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} ...
4
votes
2answers
254 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] ...
6
votes
1answer
2k views

Algorithm: write if-then-return or else-return in one line?

I can easily generate the following algorithm statements using algorithm2e package. As can be seen from the image, return statement (should hold for other statements too) will be placed in a new line ...
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 ...
1
vote
1answer
30 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] ...
1
vote
1answer
57 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 ...
3
votes
1answer
428 views

How to format a pseudocode algorithm

I would like to know how to format a pseudocode algorithm like the one shown in the picture below. I would like to see an example of Tex/Latex code that would mimic the style, formatting and design of ...
2
votes
1answer
51 views

Algorithm split in two parts, need to be consecutive - forcing the text bellow

I am splitting my algorithm over two pages, since it is to long. And I would like them to appear one after the other, but If I do it like in the code below, the text coming after the second part ...
13
votes
2answers
5k views

Floating an algorithm?

I'm typesetting an algorithm using the algorithmx package as follows: \begin{algorithm} \caption{\textsc{Whatever}} \begin{algorithmic}[1] ... \end{algorithm} However, I would like it to ...
10
votes
3answers
145 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: ...
5
votes
1answer
71 views

Putting algorithm in minipage

I have the following algorithm. Could any one please let me know how I can put it in a minipage? \begin{algorithm}\small {Start}\; \eIf{A is bigger than B}{ \eIf{if A is bigger than C}{ A; }{ ...
0
votes
0answers
31 views

Algorithmus at caption for Algorithm

I am using classicthesis for Algorithm caption when pdf is generated it write "Algorithmus " rather than Algorithm :
0
votes
0answers
60 views

Springer style for Algorithms in publication

I want to make own paragraphs for algorithms by numbering them appropriately. I do not need any fancy things - white background, no borders and black font are ok. I am trying to write in Springer ...
7
votes
1answer
274 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
2answers
30 views

How can I use an align environment or tabbing in the algorithm environment?

I would like to have these expressions aligned so that the kerning and slightly different character widths do not result in an uneven overall appearance. I tried using an align environment within ...
5
votes
1answer
89 views

Graph algorithm

I must make an animation of one algorithm on graph, I must make something like bfs, starting in one vertex and increasing values of other vertices. Then we take another vertex and start once again, ...
4
votes
1answer
37 views

Combination of microtype and algorithm package fails to compile

I try to compile the following MWE: \documentclass{article} \usepackage[activate=true,final,tracking=true,kerning=true,spacing=true]{microtype} % improves font appearance. ...
5
votes
3answers
601 views

Indentation in AUCTEX and algorithmic package

When working with EMACS+AUCTEX I encountered the problem of proper indentation when using the algorithmic package. In this MWE: \documentclass[12pt]{article} \usepackage{algorithmic} ...
4
votes
1answer
106 views

How can I customise the amount of horizontal space that follows line numbers?

I'd like to increase the amount of horizontal space that after comes each line number in my algorithm (typeset with algpseudocode). Because algorithmicx in general, and algpseudocode in particular, ...
5
votes
2answers
142 views

How to switch off “figure” in algorithm2e only in certain cases?

Suppose the following situation. Algorithm2e should have the global option "figure", i.e. an algorithm is included in Figures. However we need to switch off this property only in certain cases (to ...
4
votes
1answer
54 views

Numbering Procedure and Algorithm Independently in algorithm2e

I want to use algorithm2e to generate two procedure and two algorithm. The procedure and algorithm may be interleaved with one another, and both procedure and algorithm have their independent counter ...
4
votes
2answers
72 views

Algorithms LaTeX \EndForAll and “Some Blocks are not closed!!!”

I'm new to the algorithm package in LaTeX and need help figuring out how to debug my MWE below, which gives six errors. It look complicated, but half the errors are the same thing and in one case I'm ...
2
votes
1answer
47 views

Different numbering for algorithms and procedures

I am using algorithmicx package in LaTeX to write an algorithm and a procedure in my LaTeX file. I want LaTeX to number the procedures differently, but the numbering is the same as algorithms. Is ...
1
vote
1answer
49 views

How can I typeset code region comments to the left of an algorithm? [duplicate]

I'm looking for a way to add region comments to an algorithm. A comment should appear left of the listing and mark the corresponding code region by, for example, a large curly bracket. Like summaries ...
1
vote
1answer
124 views

What is this typography in this variable?

I am wondering how to get "gamma2" to have the same font as in Doing gamma2 = \Gamma (\alpha + 2) gives the wanted equation, but "gamma2" does not have the font of the example. How can I get ...
2
votes
1answer
35 views

Change style of specific algorithm with algorithm2e

I have the following LaTeX code \documentclass{article} \usepackage[ruled]{algorithm2e} \begin{document} \begin{algorithm} do something\; \caption{Algorithm #1} ...
2
votes
1answer
50 views

How to modify default parameters in the Algorithmic Environment module using LyX?

I'm using LyX together with the Springer Journal LaTeX template to write a document. I'm also using the Algorithmic Environment module to create an algorithm layout within my document. The problem is ...
1
vote
1answer
66 views

Long algorithm doesn't split into two pages

I wrote an algorithm but it is long and it can't fit in one page but my problem is that it doesn't split into two page .. what happen is that a part of the algorithm appears in the first page and the ...
13
votes
1answer
3k views

Is it possible to have connecting loop lines (like algorithm2e) in algorithmic?

I am using the algorithmic package to typeset an algorithm. I would like to have connecting lines between the beginning and end of a loop or conditional like in the algorithm2e package. Is there an ...
3
votes
1answer
136 views

How to make while(true) do loop?

Can someone explain to me how to make this? http://prntscr.com/4y0t4x I've got the two lines done, but I couldn't find anywhere about "while(true) do" loops and also about foreach. This is what I ...
0
votes
0answers
47 views

Split algorithm over two pages in a loop, algcompatible not working, float env. needed

My question before has been deleted, however the answers suggested are not solving my problem. So I want to split a really long algorithm onto two pages, the thing is, i want also the loop contained ...
2
votes
1answer
72 views

Procedure numbering in algorithm2e

When I use the package algorithm2e, I find the algorithms can be easily numbered, but the procedure cannot. How can I number the Procedures in algorithm2e, like Procedure 1, Procedure 2, ... %% ...
3
votes
1answer
154 views

Package algorithm

I am using algorithm package in order to create a pseudocode. But I would like to modify the way it appears some lines. Here is my code: \documentclass[twoside,12pt]{book} \usepackage{algorithm} ...
0
votes
0answers
30 views

How do I include figure or equation references inside algorithm environment in Lyx?

I would like to cross reference figures (and also maybe equations) inside the algorithm environment in Lyx but could not figure out how to do this. Help please?