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

3
votes
1answer
27 views

can not reference a state in algorithm

I have the following code that generated error ! LaTeX Error: Something's wrong--perhaps a missing \item. l.193 \STATE \label{alg:line3}Sort NGs in CDR in ascending order based o... ...
3
votes
1answer
236 views

flow chart page size issue

I have been doing this since from last month. I want to draw this flow chart using \documentclass[a4paper,11pt]{report} but if I use above configuration (which I want to use) the flow chart does ...
2
votes
0answers
60 views

How to complete the algorithm using algorithm2e

I wanted to write this flowchart using \usepackage[linesnumbered,ruled,vlined]{algorithm2e} However, I couldn't get what I want, please refer to my code in below \begin{algorithm} ...
1
vote
1answer
43 views

Possible to put an algorithm inside a \begin{itemize}?

Is it possible to put an algorithm inside a \begin{itemize} as one of the \items?
6
votes
2answers
98 views

Text below line at end of algorithm?

I am using the algorithm and algpseudocode packages. When I define an algorithm it ends with a horizontal line. I would like to have some text below this horizontal line explaining some special case ...
5
votes
1answer
178 views

Still some of the flows missing in the flowchart

I have posted this question few days back but still I can't complete the algortihm. This is the uncompleted work done so far \documentclass[a4paper,10pt]{article} \usepackage[utf8]{inputenc} ...
1
vote
1answer
125 views

Code is a mess because I cannot indent inside a for loop in my algorithm

I have a for loop in my algorithm and I can't get latex to properly indent the pseudocode inside it. It's just a mess at the moment, it won't even put the code in the for loop on separate lines. ...
3
votes
1answer
94 views

Rename algorithm caption

How to rename algorithm caption name from Algorithm to some name. This is my code: \documentclass[oneside,a4paper , 12 pt, titlepage]{book} \usepackage{algorithmicx} \usepackage{algorithm} ...
3
votes
1answer
115 views

Reduce vertical space after list of algorithms' title

I would like to control the spacing after and before the list of algorithms title to fit all the algorithms in one page. ...
3
votes
1answer
335 views

How to use latex commands to draw a flowchart

I have to write a flow chart given by figure below I have used the packages, \usepackage{tikz} \usetikzlibrary{shapes,arrows} But I couldn't get what I want. I hope some LaTeX experts here can ...
5
votes
1answer
52 views

Referring to correctly-styled algpseudocode procedure name in document

Given an algorithm written in algpseudocode: \documentclass{article} \usepackage{algorithm} \usepackage{algpseudocode} \begin{document} \begin{algorithm} \caption{Part 1} \begin{algorithmic}[1] ...
5
votes
1answer
835 views

Undefined control sequence \State \For \While

I am trying to write a pseudo code in MiKTeX. I have used \usepackage{algorithm} \usepackage{algorithmic} but I get: Undefined control sequence' for every structure (\State, \While, \For, \If). ...
3
votes
1answer
112 views

Algorithm : Command \end{list} invalid in math mode

I just started with Latex and I struggle a little bit with algorithm. Here is the algorithm, I try to show. But on the line of the first ENDFOR, I have this error Latex Error: Command \end{list} ...
3
votes
1answer
246 views

Why this 'Perhaps a missing \item' error with the algorithmic package?

I am trying to imitate an example I found in the LaTeX wikibook to write my own algorithm using the algorithmic package. I can't understand it clearly, though, and I am getting errors all the time. ...
5
votes
1answer
139 views

How to reduce indentation size within loop of an algorithm

For the following algorithm, I get four spaces for each text line inside the loop. How can I get only two or three spaces? Some of my text lines go to next line. I want to save some horizontal spaces. ...
2
votes
1answer
100 views

latex line number in algorithm starting with 9? [closed]

I feel confused why the line numbers in the algorithm I created all starting with 9? The code is as followed: \documentclass{sig-alternate-2013} \begin{algorithm} \caption{Generating Test Cases} ...
3
votes
2answers
82 views

Fixing the location of the appearance in algorithmicx environment

I'm trying to force an algorithm to stay between two paragraphs, but after compilation, it shows up in the next page. My algorithm takes more than half a page and is something like: ...
12
votes
1answer
24k views

Write pseudo code in latex

I am trying to write pseudo code in my paper. Here is the snippet and image like what I want. Can some one please help me to format it. \begin{algorithm} \caption{Euclid’s algorithm}\label{euclid} ...
5
votes
1answer
228 views

change “Algorithm 1:” to “Algorithmus:” in algorithm package

I am using the algorithm package and I need my algorithm to be labeled as "Algorithmus: XYZ" instead of "Algorithm 1: XYZ" where XYZ is my caption for the algorithm.
1
vote
1answer
487 views

Writing algorithms in pseudocode in latex

Why if I write : \State \textbf{upon event $< Init >$ do} \For{\textbf{all $n$} $\in N$} \State $value[r]=0$; \EndFor I have this output: but I want: How ...
3
votes
1answer
1k views

algorithm2e comment style

I wanted to know how to change the comment style in the algorithm2e package. I want to make my comments of a smaller font and a different color: \documentclass{article} \usepackage{color} ...
4
votes
1answer
212 views

Change algorithmicx caption name

I am trying to change the Caption name of Algorithmicx but it doesnt work. This what i include to use it. %pseudocode \usepackage{algorithm} \usepackage{algorithmicx} \usepackage{algpseudocode} ...
0
votes
0answers
23 views

Create an indent in an algorithm (without using the algorithm environment) [duplicate]

So I'm trying to create an indent in an algorithm, but I'm not familiar with the \begin{algorithm} environment, so I would just like to do it in a math environment. I'm trying to create an indent, but ...
5
votes
1answer
382 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, ...
1
vote
3answers
238 views

Aligning Equations in LaTeX

I was trying to align the following equations but alas. Could someone guide? \begin{flalign} x \in A \cap (B \cup C) & \Rightarrow (x \in A) \lambda \Big( (x \in B)\vee(x \in C) \Big) & \\ ...
5
votes
1answer
133 views

Customizing some aspect of algorithmic environment

I'm using the algorithmic environment for typesetting algorithm in my document, but I'd like to customize some aspect and fix problems. I'm using the algpseudocode package with noend option, but it ...
7
votes
1answer
147 views

How to remove end-if in algorithms

I am writing an algorithm in latex, but there are lots of end-if and end-whiles in my algorithms which makes it un-professional and ugly. Is there a way to remove them from output of latex? ...
0
votes
0answers
43 views

Increase algorithm distance to margin

I've been using \vspace to increase or decrease the vertical distance of figures to the margin, but I found out it doesn't work inside and algorithm evironment. Is there an alternative or workaround ...
6
votes
2answers
492 views

How to make “for all xxx do” appear on one line?

This is an example \documentclass[12pt,oneside,a4paper,onecolumn]{article} \usepackage{graphicx,color,setspace,hyperref} \usepackage[left=1.5in,top=1.25in,bottom=1.25in,right=1.25in]{geometry} ...
4
votes
1answer
236 views

Algorithm input in a box

I am trying to write pseudo code \documentclass[a4paper]{article} \usepackage[english]{babel} \usepackage[utf8x]{inputenc} \usepackage{amsmath} \usepackage{graphicx} ...
7
votes
1answer
157 views

Description of algorithm in words

I would like to write an algorithm in a very verbose matter. I want to write a couple of for loops and the rest is pretty much text. I include here the code I am using with algpseudocode imported as ...
6
votes
1answer
1k 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 ...
4
votes
2answers
112 views

Algorithmicx multiple statements per line aligned over all lines

I would like to put a <- b and e <- f, in parallel on a single line in an algorithmicx environment. I want the same with c <- d and g <- h. Then I want to align both lines. The output ...
0
votes
0answers
63 views

last line of algorithms ends with =0 [closed]

I wrote some algorithms on shareLatex, but when compiling the document, each algorithm ends with =0 for example: End If=0. and so on what I have to do to avoid this problem. I use these packages: ...
2
votes
0answers
48 views

The algorithms' captions appear in the list of abbreviations

I have a problem with the list of abbreviations. The problem is that the algorithms' captions appear in the list of abbreviations! I use the loabbrv package for the abbreviations, and by the command ...
0
votes
0answers
48 views

How to choose an algorithm environment? [duplicate]

I know there are multiple packages for typesettings algorithms (algorithmic, algorithmicx, algorithm2e), and some other which are not exactly designed for this exact purpose but can be used as well ...
0
votes
0answers
39 views

Creating shortcode [duplicate]

I have a document in LaTeX in which I have to use a lot of code over and over again. Is it possible to define this code somewhere with a shortcut so that I can call it up by only using the shortcut in ...
1
vote
0answers
105 views

radix sort tikz [closed]

I want to visualize Radix sort to look like but I can't find a way based on this Thanks in advance
2
votes
1answer
71 views

how to change the algorithm environment?

I am interested in changing the algorithm environment so that the numbered "Algorithm" title appears at the bottom instead of at the top, and also the three rulers (one above the Algorithm caption, ...
4
votes
1answer
59 views

How to make a hbox several lines under the specified place?

Recently I asked How to colourfuly highlight some lines of an algorithm using algorithm2e? I wanted to acheive this effect using the algorithm2e package: Thanks to JLDiaz's answer I know how to do ...
2
votes
1answer
331 views

How can I colourfuly highlight some lines of an algorithm using algorithm2e?

I am trying to achieve something like this: This image is linked from this answer. This answer also provides a solution and seems simpler. Both answers deal with the algorithmicx package however. ...
2
votes
1answer
219 views

How to avoid uppercase function name while using Function?

In LaTeX, I want to define a function in my algorithm, following is my code in case: \begin{algorithm}[h] \begin{algorithmic}[1] \Function{BuildPolicySet}{PolicySet PS, CCR ccr} ...
2
votes
1answer
89 views

How can I define a ForEach loop on the basis of the existing ForAll loop?

Is there a way to define new command in algpseudocode based on existing one? In particular, in my document I need to use both \ForAll and \ForEach commands. It turns out that just renaming \ForAll ...
3
votes
4answers
162 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 ...
2
votes
1answer
132 views

PDF reference links when using hyperref and (`ruled`) algorithm2e

I was testing some links within my produced PDF file and recognized that all of the links to an algorithm (from the algorithm2e package) will jump to the beginning of the algorithm with skipping half ...
3
votes
1answer
359 views

Algorithm2e does not allow nested if

I was trying to put a nested if in algorithm area like this: \If{$isContentMethod(\mathcal{M})$}{ $URI \leftarrow getURI(SubCG, \mathcal{M})$\; \If($URI \in ...
8
votes
1answer
101 views

Suppress line numbers in front of 'repeat' and 'until' keywords in algorithmic

Here is my minimal example: \documentclass{article} \usepackage{algorithm} \usepackage{algorithmic} \begin{document} \begin{algorithm} \caption{Test} \begin{algorithmic}[1] \REQUIRE ...
3
votes
1answer
96 views

How to assign code in table of figures?

Is possible that i can get an alghorithm that was wrote in LaTeX with a package and transform in a figure to be added in list of figures (\listoffigures)?
2
votes
1answer
61 views

How to manage long lines of inputs in function declaration, or inside the code, in clrscode3e

This is a part of my code: \begin{codebox} \Procname{$\proc{\textbf{Connect_two_SamplePoints}}(Graph,S1, S2,connectionCostMat,cost)$} \li \Comment S1 and S2 are sample points \li cost[S1][S2] $=$ ...
3
votes
1answer
386 views

Algoritmic return command = 0

Can you suggest me what is wrong with using return command in algorithms. when I add \RETURN $C to my LaTeX document I get return C =0, what I need is just return C. \begin{algorithm} ...