Questions tagged [algorithms]

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

Filter by
Sorted by
Tagged with
0
votes
0answers
17 views

How to allow more width in algorithm

I am using the algorithm2e package, and I have an algorithm (shown in image) in which one line is split into two (namely, the assignment of alpha on line 21 goes over two lines). I would like to not ...
0
votes
0answers
37 views

Lack of understanding while writing algorithm in Latex

I'm having trouble writing this algorithm in Latex (exactly as it is in the picture below). I was searching for the best solution, but can't seem to find something that I understand. Can someone help ...
0
votes
0answers
31 views

Learnin Python through Case [closed]

I started learning Python a couple of weeks ago. Now, I am trying to make a program of evolution, in a very simple way. My creature is just an array of 3 elements. The first two consist of arbitrary ...
1
vote
1answer
30 views

How to remove unwanted algorithm line numbers?

I am using the IEEEtran template in Overleaf. I am writing an algorithm in the overleaf. However, it adds a series of unwanted zeros on the left of the algorithm and also an unwanted =0 at the last ...
4
votes
1answer
193 views

Algorithm not formatting correctly

I'm trying to write an algorithm in latex, but after I put my if statement it gives me back an error and says that there's a missing number. What does that mean? Where is my flaw? This is what I've ...
1
vote
1answer
30 views

Placing pseudocode between paragraphs

I am trying to re-write a line of an algorithm's pseudocode, and I would like to be able to present it in-text rather than introducing another floating algorithm environment. How can I do this? Here ...
0
votes
1answer
21 views

How to override the numbers in an algorithm?

I have tried a few ways I found here, including This, and This, there are more but I can't remember them. The issue I'm having is I'd like "Fifth Instruction" to start on 5, I know "...
1
vote
0answers
48 views

String equality check [closed]

I want to compare 2 strings and perform different tasks based on their results(using if-else loop) My code is here: \tab• \hyperlink{new}{New Features, Enhancements, and Changes}\linebreak \begin{...
0
votes
1answer
30 views

Align algorithm environment with text

I use these two packages: \usepackage[left=3cm, right=2cm, top=2cm, bottom=2cm]{geometry} \usepackage[ruled,linesnumbered]{algorithm2e} My algorithm margin does not align with the text; for example: ...
2
votes
1answer
22 views

undefined control sequence error while writing algorithm

I am trying to write algorithm but got errors like undefined control sequence.. my code is given below can anyone tell why I am getting this error and how to remove \documentclass[conference]{...
1
vote
1answer
40 views

Making Index Page Citations Bold without Obliterating "See{Another Indice}"

Previously, I had posted the question How to Display the Indice Page Numbers in Bold? and received a very fine answer, which has served me well. However, I have since discovered a conflict making ...
0
votes
1answer
40 views

! Extra }, or forgotten $

What's wrong with following algorithm? \documentclass[journal]{IEEEtran} \usepackage{graphicx} \usepackage{subfigure} \usepackage{overpic} \usepackage{amsmath} \usepackage{flushend} \usepackage{...
1
vote
1answer
24 views

algorithmic environment: procedure parameters are too long

I am using the algorithmic environment and the parameters of my Function/Procedure are too long and they overflow. I am wondering what is the solution? Can I somehow force it to stay in a single line ...
3
votes
1answer
53 views

Multiline math in Algorithm environment

I am wondering is there a way to have multiline math in an algorithm to prevent something like this: \documentclass{article} \usepackage[utf8]{inputenc} \usepackage[a4paper, total={6in, 8in}]{...
1
vote
1answer
66 views

What is a more compact way to write multiple if/else statements

\documentclass{article} \usepackage[utf8]{inputenc} \usepackage{algorithm}% http://ctan.org/pkg/algorithm \usepackage{algpseudocode}% http://ctan.org/pkg/algorithmicx \usepackage[1,2,3,4]{pagesel} \...
2
votes
1answer
32 views

Unable to close for loop using the algorithmic package

I have the following code: \documentclass{article} \usepackage{algorithm} \usepackage[noend]{algpseudocode} \begin{document} \begin{algorithm} \caption{Main Ass}\label{alg:cap} \begin{algorithmic}[1] ...
0
votes
0answers
13 views

Ho to remove extra space between lines in algorithm

Hi i am writing algorithm and i noticed there is a free space in PDf between 7 12 lines you can see in gigure below. How to remove this here is my code \begin{algorithm}[H] \caption{Algorithm} ...
0
votes
0answers
13 views

Using algpseudocode-package in theorem

I've defined my theorem style by \theoremstyle{definition} \newtheorem{problem}{Problem}[section] \newtheorem{solution}{Solution}[section] I want to write a pseudocode in my solution section like ...
0
votes
1answer
23 views

Can't get line numbers in my algorithm

I wrote this code using the algorithm package, I want to add line numbers in the algorithm. \begin{algorithm} \caption{Owen Control Sampling algorithm}\label{alg:cap} \begin{algorithmic}[1] ... \end{...
3
votes
2answers
83 views

how to fix space before and after algorithm

I am working on IEEE 2 column format and I wrote algorithm but the algorithm is not able to fix in the column as it has free space above and below the algorithm as shown in figure how to solve this ...
2
votes
3answers
80 views

standalone document with algorithm2e package

I'm trying to generate a pdf file containing an algorithm, which will be included in the main document as a figure. I tried using standalone as follows: % main.tex \documentclass{standalone} \...
1
vote
1answer
26 views

How can I adjust nested if statements in the algpseudocode package

I have the following code: \documentclass{article} \usepackage{algorithm} \usepackage[noend]{algpseudocode} \begin{document} \begin{algorithm} \caption{Main D Algorithm}\label{alg:cap} \begin{...
0
votes
2answers
50 views

I want to add a comment to a for loop in `algorithm`

\begin{algorithm}[h] \caption{Transformation} \tcp{Apply transformation X comment1} \For{$k=1$ \KwTo $n$} {$P=A*P*A^{T}$ \tcp{comment 2}} \end{algorithm} I want to add a comment in for ...
0
votes
0answers
24 views

How to wrap text around an algorithm

\documentclass{article} \usepackage{algorithm} \usepackage[noend]{algpseudocode} \usepackage{float} \usepackage{lipsum} \newfloat{algorithm}{t}{lop} \begin{document} This text comes before the ...
1
vote
1answer
26 views

Change algorithm name without global change

I am wondering is it possible instead of Algorithm 1" it could be something else, like "Code 1" without modifying other algorithms in my latex file (or without globally changing things)....
0
votes
2answers
34 views

Fit three algorithms in a single page

I am using the algorithm2e package to write algorithms. I have three algorithms that I want to put in a single page. I tried using subfigures and minipages but it got me no where. Any help to get me ...
1
vote
1answer
25 views

Trying to Indent in Algorithm Mode

I'm trying to indent in \usepackage{algorithm} mode, but it's not working. I need to use \usepackage{algorithm} because of journal as there are other answers on this forum that use other packages that ...
3
votes
1answer
76 views

Defining blocks of steps in Algorithmicx

How can I define blocks and use Step, Input, and Output in Algoritmicx like the below image? In fact, I want to create this image exactly, but I have a problem with "Step". I have no idea ...
1
vote
0answers
18 views

How to eliminate indentation when using command "\For{}" in the "algorithm environment"

I do not want an indentation for the "For loop." How can I make it aligned with the "Require" text? \documentclass{article} \usepackage{amsmath,amssymb} \usepackage[utf8]{inputenc} ...
1
vote
1answer
16 views

Algorithm - More \State on same line

I have this algorithm: \begin{algorithm} \begin{algorithmic}[1] \caption{Build-PGM-Index} \State{levels} = array dinamico vuoto; \State{i} = 0; \State{keys} = A; \Repeat \...
0
votes
0answers
33 views

How to add breakable algorithm in two column page in LaTex?

I am using the template of Frontiers of computer Science Journal to format my research paper. The template can be found in the link below. https://journal.hep.com.cn/fcs/EN/column/column11258.shtml ...
0
votes
1answer
46 views

table of contents unnumbered because of the interference of a graphic algorithm displaying packages

Hi I am trying to compile the code that displays this algorithm below I copy and past the code after I have converted to latex from a Rmd file, but its not working, than I go back and add the ...
0
votes
1answer
75 views

Latex Enumerate like 1, 2, 3, 2.1, 3.1, 2.2, 3.2, etc [closed]

This is what I want to do: \documentclass{article} \usepackage{enumerate} \begin{document} \begin{enumerate} \item \item \item \item[2.1] \item[3.1] ...
2
votes
2answers
53 views

Add space in front of line in algorithm [duplicate]

I need to add an indent in front of 'climate' and 'each region' so that the overflowing lines aren't confused for a new line of pseudocode. I have tried everything including this (the algorithm2e ...
0
votes
1answer
37 views

Could anyone tell me how to write this in an algorithm format in latex?

Could anyone tell me how to write this in an algorithm format in latex? p-37,38. Thank you. https://uwspace.uwaterloo.ca/bitstream/handle/10012/11017/Maki_Erik.pdf?sequence=3&isAllowed=y
0
votes
1answer
28 views

could anyone tell me how to write this simple algorithm? [closed]

could anyone tell me how to write this simple algorithm? Thank you so much.
0
votes
0answers
55 views

How to format really long sentence in for loop pseudocode?

I have the following code for an algorithm. \begin{algorithm} \label{alg:script} \caption{Algorithm to calculate something} \begin{algorithmic}[1] \State One line sentence \...
0
votes
0answers
42 views

How to convert a LateX code to Image using a vector template

I want to use illustrator to create a fancier look for my algorithm boxes. Is there any way that I can set a script (or any other way really) to take the algorithmic text on latex and convert it to ...
0
votes
1answer
45 views

Algorithm style in latex

I want to produce an algorithm style such that it is centered on the page, numbered and also that the horizontal lines do not extend unnecessarily as shown in the image. Is there any way using the ...
0
votes
0answers
46 views

algorithm2e procedure / function error: "end" block of procedure using \SetKwProg overflows to next column in 2-column page

While using algorithm2e package to write an algorithm having 2 procedures in a 2 column page, only the "end block (last line) of the procedure always flows to 2nd column. I have used this in the ...
1
vote
1answer
48 views

How to write title of chapter and algorithm in correct way?

I am writing PhD Thesis on overleaf but the title of the chapter being vanished whenever I insert the package \usepackage[ruled]{algorithm2e} for the algorithm and the algorithm appears in good ...
1
vote
1answer
167 views

algorithm2e showing errors in IEEE Access format ("Argument of \@algocf@endoption has an extra }. } "and "Paragraph ended before \@algocf@endoption")

\documentclass{ieeeaccess} \IEEEoverridecommandlockouts \usepackage{cite} \usepackage{amsmath,amssymb,amsfonts} \usepackage{algorithm} \usepackage[ruled]{algorithm2e} \begin{document} \history{...
0
votes
0answers
11 views

How to include multiple label in algorithm2e and adjust numbering in a specific way?

Suppose I have the following LaTeX source: \documentclass[letterpaper,12pt]{article} \pagestyle{myheadings} %---------------------------------------------------------- % algorithm2e setup \usepackage{...
0
votes
0answers
77 views

Change algorithm numbering in latex

I have a code as follows. I do not know why I cannot change the numbering of pseudo-codes using the algorithm environment. Could you please help me with that? \documentclass{article} \usepackage{...
4
votes
2answers
40 views

How can I left align after using a phantom in algorithm?

I have the following code : \usepackage[linesnumbered,ruled,vlined]{algorithm2e} \usepackage{algpseudocode} \usepackage{mathtools} \begin{algorithm} \caption{XEdDsa Sign} \SetAlgoLined \...
0
votes
0answers
65 views

Latex error in algorithm package after update miktex in jun-13/2021

! Extra }, or forgotten \endgroup. \endalgorithm ...nalty }\@Esphack \fi \fi \egroup l.23 \end{algorithm} I've deleted a group-...
3
votes
1answer
403 views

How can I typeset algorithms with LaTeX?

I want to write an algorithm using the Latex algorithm generator. Can anyone help me in this case? A sample is given below. Any sort of help would be highly appreciated.
0
votes
1answer
43 views

Resize Algorithm figure in a slide

I have the following figure for algorithm pseudocode. \usepackage{graphicx} \usepackage{psfrag} \usepackage{amssymb} \newcommand{\argmin}{\mathop{\mathrm{argmin}}} \newcommand{\infl}{\eta} \...
0
votes
1answer
45 views

Not able to get proper for loop and if

\usepackage{algorithm} \usepackage{algpseudocode} \begin{document} \begin{algorithm} \caption{Brute-Force algorithm} \begin{algorithmic}[1] \For {$s'$ \in ${\mathbb{F}^n_2}$}{ \If {$wt(As'+b)$ \...
1
vote
1answer
64 views

end for=0 at the end of a for loop [duplicate]

I'm not sure why I get two extra characters at the end of the for loop. Looking at other answers on StackExchange indicates I'm not suppose to use both algorithm and algorithmic and that its better to ...

1
2 3 4 5
21