{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
196 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
342 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
544 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
149 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
245 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
214 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
111 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
93 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
39 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
480 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
176 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
145 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
666 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
85 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
52 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
46 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
95 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
65 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
57 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
245 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
157 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
80 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
150 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
117 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
260 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
84 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
89 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
58 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
309 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} ...
7
votes
1answer
794 views

How to use the algorithm2e package with IEEEtran class?

The IEEEtran documentation suggests that I should not use the floating algorithm environment of algorithm2e.sty. B. Algorithms IEEE publications use the figure environment to contain ...
0
votes
0answers
75 views

How to define a list of algorithms?

How can i define a list of algorithms similar a list of tables? i need something like \listofalgorithms similar to \listoffigures but with trackable algorithms
6
votes
1answer
186 views

How to format mathematical and programming variables in text?

I am describing an algorithm in a journal paper. In this algorithm I have a few variables. I gave them the same names as in my source code (C++ source of the algorithm, not LaTeX source). So I have ...
3
votes
1answer
370 views

Reduce the line number font size of pseudocode?

I have learned from here on how to reduce the font size in the pseudocode. The last thing left for me is to reduce the line number font size as well. The following is my MWE, and it seems that ...
3
votes
1answer
532 views

How may I remove \EndIf and \EndFor in algorithmicx?

For space consideration, I wish to condense my pseudocode. I find it a bit annoying to me to always have a \EndIf or \EndFor at the end of every block, especially when inside the block only lies one ...
2
votes
2answers
1k views

Pseudocode: \Function vs. \Procedure?

The title says it all. What is the difference between a Function and a Procedure? When should I use which?
1
vote
0answers
23 views

How to use dotted line to make indentation clearer in algorithmicx? [duplicate]

I wish to indicate clearly when a block starts and ends with "enclosing lines" in addition to the indentation. I understand that I can do it with algorithm2e like so \begin{algorithm}[H] \SetLine % ...
5
votes
1answer
724 views

Vertical loop/block lines in algorithmicx with 'noend' option

I am using the algorithmicx package to write an algorithm. However I am using the noend option: \usepackage[noend]{algpseudocode} Is there anyway to get vertical lines for each block of code? This ...
3
votes
2answers
314 views

How to align text within an algorithm environment?

I wish to duplicate an effect I've seen elsewhere (image below) in which text not necessarily at the beginning of a line is aligned with text elsewhere. I don't know which environment is suitable, ...
6
votes
2answers
868 views

How to see the Steps number in an algorithm

In below algorithm I have used the package \usepackage[linesnumbered,ruled,vlined]{algorithm2e} 1) How do I see steps number after step 2? 2) Is there any command apart from ...
6
votes
1answer
469 views

Splitting Algorithm across multiple slides

I am wondering how to split an algorithm across multiple beamer slides. The algorithm is created using package psuedocode. I tried using [allowframebreaks] but all that did was push my algorithm to ...
2
votes
1answer
78 views

Customizing font used by algorithmicx

I am using algorithmicx to typeset my algorithms in XeTeX. Using fontspec, I set the default font to be Linux Libertine with historical ligatures (e.g., ct, st). Unfortunately, this is also the font ...
6
votes
1answer
322 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 ...
0
votes
0answers
111 views

Reduce whitespace or margin before listofalgorithms command

I'm at my wits end on this one. I have a list of algorithms page that I want formatted the same way as my ToC and ToF. What I have currently is pretty close except that the List of Algorithms title ...
2
votes
1answer
115 views

How to make color from the table Ruffini - Horner Algoritms? [closed]

I Have problem about to make the table ruffini- horner algoritms,and i take a code from this question command for table Ruffini-Horners Algorithm , \documentclass{article} \usepackage{xparse} ...
3
votes
1answer
185 views

Indenting pseudocode

I am very new to TeA, and am having trouble indenting a block of pseudocode within an enumeration. Or perhaps more specifically, the algorithm's pseudocode seems to ignore the enumerations ...
7
votes
2answers
6k views

How do remove equation number in an algorithm

Here is the code. Even I have used the command \nonumber still I can see the equation number \begin{document} \begin{algorithm} \DontPrintSemicolon % Some LaTeX compilers require you to use ...
0
votes
0answers
75 views

How to write this algorithm properly

Here I have attached the current code \begin{document} \begin{flushleft} \begin{picture}(10,5) \put(1,1){\line(1,0){450}} \end{picture} \end{flushleft} \textbf{\textit{Algorithm:}} Curves on ...