{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
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
543 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
262 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
146 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 ...
8
votes
1answer
294 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
46 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
531 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
363 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
169 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
127 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
70 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
53 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
50 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
113 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
83 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
61 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
400 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
270 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
99 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
175 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
140 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
441 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
114 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
102 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
69 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
451 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} ...
8
votes
1answer
1k 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
82 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
233 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
883 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
1k 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 ...
3
votes
2answers
3k 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 % ...
6
votes
1answer
1k 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
627 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
1k 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
682 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
84 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
387 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 ...
2
votes
1answer
134 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
327 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 ...
8
votes
2answers
11k 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
95 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 ...
2
votes
1answer
816 views

How to place algorithm outside float?

Is there any elegent way to place algorithm without using algorithm environment?
5
votes
1answer
81 views

How to add the algorithm block in textblock

I'm creating a poster and I have a problem to adjust the algorithm block inside of textblock. My code is in below with the packages and the code. \documentclass[a0,portrait]{a0poster} ...
0
votes
0answers
81 views

include algorithm package in latex [closed]

I am using llncs (lecture notes in computer science) class style for my latex file. However, I am not able to include the algorithm package in my file. When I compile my file, I get an error for the ...
1
vote
1answer
90 views

How to exclude some algorithms for \listofalgorithms

I tried with \captionsetup{list=no} but it doesn't work for the algorithm listing. Any ideas? I am splitting alg. over several pages using algorithm2e and don't want the captions of the split ...
2
votes
1answer
807 views

Self-defined Width of the Pseudocode Box with algorithmicx?

This post has beautifully shown how to make the algorithm pseudocode box as wide as one column or two columns. I am now writing a pseudocode with many if layers. So a one-column box cannot suffice. ...