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

5
votes
1answer
105 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} ...
3
votes
1answer
35 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
26 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} ...
2
votes
1answer
55 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} ...
2
votes
1answer
76 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 ...
6
votes
2answers
62 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 ...
1
vote
1answer
66 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. ...
1
vote
1answer
23 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?
3
votes
1answer
22 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} ...
10
votes
2answers
2k views

How can I put a curly brace inside an algorithm to group code lines?

I am using the algorithmic package (or even algorithm2e is fine). Is it possible to use curly braces to group some lines in the algorithm so as to be able to put an explanation to the right?
3
votes
1answer
123 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
2answers
4k views

“For” loop without “do”; “if” statement without “then”

How can I get rid of the do in a for loop and the then in an if statement when typesetting algorithms using the algorithm and algorithmicx packages?
3
votes
1answer
55 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. ...
4
votes
1answer
23 views

algpseudocode referring to produce 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
49 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
44 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
27 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. ...
4
votes
2answers
461 views

algorithmicx + babel + Hebrew incompatibility

When trying to create any document with babel and algorithmicx, e.g.: \documentclass{article} \usepackage[hebrew,english]{babel} \usepackage{algorithmicx} \begin{document} Hello, world. ...
5
votes
1answer
48 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. ...
3
votes
2answers
40 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: ...
4
votes
1answer
2k 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
158 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
79 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 ...
4
votes
1answer
69 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} ...
3
votes
1answer
71 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} ...
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
72 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, ...
10
votes
1answer
4k views

algorithm numbering

I am having trouble numbering and referencing algorithms. I want to have the references labeled by the chapter, then within the chapter, such as: First algorithm in chapter 1 - Algorithm 1.1 ...
1
vote
3answers
174 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) & \\ ...
11
votes
3answers
177 views

Can I locally switch to a 'greedy' justification algorithm?

I'm not optimistic about this since this is a core part of TeX's algorithm, but is there any way to switch to a 'greedy' justification algorithm? That is, instead of working on the paragraph as a ...
6
votes
1answer
278 views

How can I get proper Matlab syntax when typesetting Matlab source code using the algorithm package?

I'm currently using the algorithm package for typesetting Matlab source code in my document. However, the way keywords are typeset doesn't match the Matlab syntax. For instance, \EndFor is typeset as ...
60
votes
4answers
29k 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 ...
5
votes
1answer
74 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
54 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? ...
3
votes
4answers
130 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 ...
0
votes
0answers
24 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 ...
3
votes
1answer
9k views

Smaller font size of the algorithm description?

\small or other tag seems can not change the font size of the line number. The package I use is \usepackage{algorithmic}.
6
votes
2answers
439 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} ...
7
votes
1answer
103 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 ...
4
votes
1answer
113 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} ...
6
votes
1answer
167 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
56 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
24 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
32 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
46 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 ...
5
votes
1answer
147 views

Referring to function name in an algorithm

I have a LaTeX code which looks similar to the following example. \documentclass{article} \usepackage{amsmath,algorithm,algpseudocode} \begin{document} \begin{algorithm} \caption{My Algo.} ...
12
votes
1answer
1k 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?
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
78 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
3
votes
4answers
129 views

Algorithm for 'Plugging in' Values to Tables

Simply, if I have a table of the form: \begin{tabular}{l r r r r r l r r r r r} \hline {}&{}&{}&$n$&{}&{}&{}&{}&{}&$n$&{}&{}\\ ...