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
-1 votes
0 answers
30 views

How to delete the word "do" for an algorithm in [journal]{IEEEtran} [duplicate]

I would like to have algorithm as follows in overleaf: Here is the latex code: \documentclass[journal]{IEEEtran} \usepackage{algorithm} \begin{document} \begin{algorithm} \caption{Pseudo code} \...
Nicholas TI's user avatar
3 votes
2 answers
150 views

Splitting a Really Long Algorithm in Two Pages

I have this algorithm, which as you can see is too long to fit into one a4 paper. I have used the solution in here, but there was an error telling me that \AND, \OR, and \TO are undefined. I would ...
mali1234's user avatar
  • 159
0 votes
0 answers
14 views

Latex Pseudocode missing number cannot resolve

\begin{algorithm} \caption{LexBFS Algorithm} \begin{algorithmic}[1] \Function{LexBFS}{$G=(V, E)$} \State Let $P$ be an empty list \Comment{Initialize the permutation} \State Let $Q$ be an empty queue \...
n.y's user avatar
  • 1
0 votes
1 answer
38 views

Correct usage of display math inside algorithm with algpseudocode based package. Alignment and spacing problems

I am learning how to use Algpseudocodex which is an enhanced version of algpseudocode I am having hard time with getting correct spacing around \begin{align*}...\end{align*} when using inside the ...
Nasser's user avatar
  • 20.7k
0 votes
1 answer
24 views

How to reference an algorithm within an algorithm [closed]

I have two algorithms, algorithm 2 depends on algorithm 1. I would like to reference algorithm 1 at the beginning of algorithm 2, writing something of the form Get H from algorithm 1 And then continue ...
Donna Schweitzer's user avatar
0 votes
1 answer
32 views

create vertical brackets that span over several rows

I just came across a snipet of codes where a long vertical bracket is used to mark a loop. I really like that. I wonder what is the best way to implement this in latex? Thanks
underflow's user avatar
  • 519
0 votes
0 answers
37 views

How can the following block scheme be made?

My university is asking for a specification of an algorithm and provided this block scheme as an example. I an not very good at latex so I googled how to do this with tikz, but did not found something ...
Sunfline's user avatar
0 votes
2 answers
37 views

Algpseudocode, for-next loop: control variable in next line

In this pseudo-code excerpt, is it feasible to add a new argument for the variable v with a syntax like \ForAll {$v$}{$v \in V(G)$} to get the output next v? \documentclass{article} \usepackage{...
Jh0an1 Uzca73gu1's user avatar
3 votes
1 answer
44 views

How do I add an extra description row under the name of algorithm?

The following image is my goal. You can see there is a row to describe the parameters of Algorithm1. I wonder how to add rows like this. And I also wonder how to add the description of the following ...
ming's user avatar
  • 33
0 votes
1 answer
61 views

Wrap text around pseudocode without overlap with other text

I'm looking to have pseudocode in my document placed nicely by LaTeX (ie. no exiting bounding box, no overlapping other text, etc.), while having text wrap around the pseudocode (as the width of text ...
user760900's user avatar
1 vote
1 answer
112 views

Undefined control sequence when using algorithm environment with dgruyter.sty

I need to write a document using the dgruyter template. When I include an algorithm environment I get the following error. Undefined control sequence. <write> ...\protect \numberline {\plist@...
Alex bGoode's user avatar
0 votes
1 answer
67 views

"Not in outer par mode" error when using Algorithm inside minipage

I am trying to place a figure and an algorithm side-by-side using minipage. Hee is the code for the algorithm part. However, I am getting an error LaTeX Error: Not in outer par mode. on the line \...
Siladittya's user avatar
2 votes
1 answer
102 views

I'm having a problem with sentences breaking when writing input and output in a latex algorithm

In my algorithm, I wrote input and output as follows. \begin{algorithm}[htb!] \caption{Data Preprocessing} \label{alg:data_preprocessing} \textbf{Input} input data \\ \textbf{...
Tim's user avatar
  • 21
0 votes
1 answer
29 views

Use standard algorithm padding for custom algorithm environment

This is a follow-up question to: https://tex.stackexchange.com/a/33869/173478 The breakablealgorithm environment, as proposed by Werner, splits algorithms perfectly. However, for me the breakable ...
Lucas Aschenbach's user avatar
0 votes
0 answers
22 views

The pseudocode numbering start with 0 and continues to be zero

im writing a pseudocode in ieee access template as below. \begin{algorithm} \caption{FVI (X, k, m, $\mu$)} \label{alg:fvi} \textbf{Input:} Dataset $X$, number of clusters $k$, weighting exponent $m$, ...
khairul's user avatar
0 votes
1 answer
41 views

How to write an algorithm like under figure in latex?

How to write an algorithm like under figure in latex? I executed this cod, but the output of the algorithm was not like the above figure \usepackage[options ]{algorithm2e} \begin{algorithm}‎ \...
Yas's user avatar
  • 13
0 votes
0 answers
44 views

How can I split the algorithm into two pages?

How can I have the algorithm not break in the next page and rather split this into two pages? \usepackage[ruled,german,linesnumbered]{algorithm2e} % Pseudocode \newcommand{\SkipBeforeAndAfter}{\vspace{...
Renxian's user avatar
  • 61
1 vote
0 answers
51 views

Merge two algorithms style in the same file

Is it possible to put the two following algorithms in the same file. I tried several times but I did not succeed. Thanks for your help. \documentclass{article} \usepackage[T1]{fontenc} \usepackage{...
Nehme's user avatar
  • 63
0 votes
0 answers
36 views

Properly use algorithm environment in latex/ overleaf

I am working with my old latex code, which at the time worked but now the output seems unexpected. I am using the following packages: \usepackage{algorithm} \usepackage{algpseudocode} \usepackage{...
Azerbijanargh's user avatar
2 votes
1 answer
40 views

Algorithm caption color background

I tried to modify my algorithm caption in order to fill it gray. However, there is some white space left. Has anyone an idea what the problem is? \documentclass{article} \usepackage{graphicx} % ...
Marcel's user avatar
  • 23
0 votes
1 answer
23 views

if else loops and repeat until loops doesn't work with algorithm package

code: \begin{algorithm}[!t] \begin{algorithmic}[1] \caption{Adaptive Random Search}\label{algo_ARS} \State define the probability of local search as $P_s$ and global search as 1 - $P_s$ \Repeat ...
Rolphnol's user avatar
0 votes
1 answer
35 views

How to restate an algorithm with the same algorithm number?

I'm trying to have two copies of the same algorithm, with the same number twice in a paper. The restatable environment is able to reproduce the algorithm but introduces a new algorithm number each ...
Zuza's user avatar
  • 103
1 vote
1 answer
43 views

How to manually (further) indent an `if` statement in `algorithm`

For example, I would like to further indent an if-then-else block like is done in this question. \documentclass{article} \usepackage{algpseudocode} \usepackage{algorithm} \begin{document} \begin{...
rrrrr's user avatar
  • 491
0 votes
0 answers
35 views

How do I call the name of an algorithm from another algorithm?

I'm writing my pseudocode wrapped inside \begin{algorithm}[H] \begin{algorithmic} ..., now I want to be able to cite(function call) another algorithm that I will define later in my latex code so that ...
rainnnnyng's user avatar
0 votes
0 answers
59 views

Package algorithmicx Error: Some stored algorithms are not restored!

I am using these two package: \usepackage{algorithm} and \usepackage{algpseudocode}. This is my latex code and I am using overleaf: \documentclass{article} \usepackage{graphicx} % Required for ...
j.doe's user avatar
  • 121
0 votes
1 answer
31 views

how to fix the issue in pseudo code algorithms with multiple precedures in latex?

I am formetting pseudo code algorithms with multiple procedures in it, but formatting has somes issues such as endProcedure=0in latex output though. How can I fix this? thanks my current script \...
kim's user avatar
  • 103
0 votes
0 answers
34 views

Overfull \hbox problem in Algorithm caption of ACM template

I faced a problem that my overleaf report that 'Overfull \hbox (8.5pt too wide) in paragraph at lines 92--92' I used 'algorithm2e' package for ACM template. Here is the test demo I used: \...
yuyang sun's user avatar
0 votes
1 answer
41 views

Algorithms not being numbered correctly [closed]

I am trying to include some algorithms in an IEEE paper and the algorithms are not being numbered properly. I'm new to Latex and have never used it before. I want to number it as Algorithm 1 and ...
Saish Kalbag's user avatar
1 vote
1 answer
56 views

Multilingual typesetting with polyglossia results in Inverted Parentheses using algorithmic+algpsuedocode

I am attempting to compile an article using the XeTex engine. In my document I've used the algorithmic and algpsuedocode packages in order to describe an algorithm. Also, the document is meant to ...
ch0wner's user avatar
  • 113
2 votes
0 answers
46 views

Add multiple footnotes with hyperlinks to `algpseudocode` algorithm

I use the algpseudocode package to write algorithms, and the hyperref package to add hyperlinks to footnotes. I want to be be able to add footnotes with hyperlinks within my algorithms. Something like ...
JEdwards's user avatar
1 vote
0 answers
192 views

How to write pseudocode in LaTeX in Google Colab

I want to render in my colab some pseudocode, say: \documentclass{article} \usepackage{algorithm} \usepackage{algpseudocode} \begin{document} \begin{algorithm}[H] \caption{A simple algorithm} \begin{...
mCs's user avatar
  • 11
0 votes
1 answer
37 views

List of Algorithms with toptesi

I am using the algorithm package to create a list of algorithms in my thesis written with toptesi by Claudio Beccari. However, I am having trouble including the list of algorithms in the table of ...
poipoi's user avatar
  • 3
1 vote
1 answer
19 views

Increasing algorithm number width in ToC coming from appendix

I want to increase algorithm number width coming from appendix. MWE: \documentclass{report} \usepackage{amsmath} \usepackage{algorithm} \usepackage{algorithmic} \numberwithin{algorithm}{chapter} %\...
Bahman Mirzakhani's user avatar
0 votes
1 answer
68 views

Referencing lines in more than one algorithm

I want to refer to algorithm lines with the hyperref package's \autoref{} command. To do so, I am using this patch. This indeed prints the correct line number for each referenced label, but the link ...
Mew's user avatar
  • 771
0 votes
1 answer
88 views

Multiple input line

Trying to obtain this Algorithm 1 : Name of algorithm Input: Input number 1 Input number 2 Input number 3 that extend the length desired so can it brought to ...
user529674's user avatar
0 votes
0 answers
75 views

About pseudo code in algorithm environment

I have used algorithm environment to write pseudo code just like the photo and get some really good result and here is the corresponding latex code \begin{algorithm} \caption{Find the missing number (...
BrianYuan's user avatar
1 vote
0 answers
27 views

I need help formatting this algorithm in a way that will be accepted on Math SE [closed]

I have the following algorithm that I would like to ask a question about on Math SE. I will post a picture and an attempt, but would love to find what Latex case will work. The code that generated the ...
tetra4892's user avatar
0 votes
0 answers
12 views

controlling indentation of lines under the algorithm

How can I indent the numbered lines so that the numbers are aligned with the earlier text e.g., Input?
user3761743's user avatar
2 votes
0 answers
123 views

How can I use conflicting libraries in latex?

I am trying to write a document that uses two other manuscripts which make use of different libraries that seem to overlap in functionality. Specifically when I try to use \usepackage[linesnumbered, ...
Alup's user avatar
  • 29
3 votes
1 answer
64 views

Multicols inside algorithm environment

I'm trying to write an algorithm, but since it doesn't fit in one page, I'm trying to put it in two columns. The code I'm trying to write it this \makebox[\linewidth]{ \begin{minipage}[H]{.85\...
Z123's user avatar
  • 43
0 votes
1 answer
200 views

Delete the indexes 0 in algorithm [duplicate]

I am using overleaf with TexLive version 2022 to create an algorithm. In order to delete all index 0's, I have adjusted the optional argument from \begin{algorithmic}[0] to \begin{algorithmic}. Here ...
Nicholas TI's user avatar
0 votes
0 answers
51 views

How to indent the for loop

I have the following algo code \begin{algorithm}[t] \caption{my algo} \label{my algo} \begin{algorithmic}[] \State \textbf{Input:}{ abc} \State \textbf{Output:}{ xyz} ...
CA Khan's user avatar
2 votes
2 answers
94 views

Different symbols around parameters of a function in algorithm2e

If I define a function as \SetKwFunction{Func}{func} in algorithm2e, \Func{a, b} prints func(a, b) by default. How can I make it print func[a, b] like in Wolfram or func a b like in Haskell? I ...
matj1's user avatar
  • 109
1 vote
1 answer
52 views

How to write a specific part of algorithm in algorithm environment in Latex? [closed]

How to exactly produce this part in the picture? What I can do is like this: \documentclass{article} \usepackage{algorithm} \usepackage{algpseudocode} \begin{document} \begin{algorithm} ...
Knt's user avatar
  • 166
0 votes
2 answers
132 views

Delete Index and Line in Algorithm

I would like to ask you is it possible to: (1) delete the index on the left side and one at the last line (all 0's , yellow highlighted) ? (2) delete all the line inside the algorithm ( green ...
Nicholas TI's user avatar
3 votes
2 answers
293 views

Cannot reference algorithm

For some reason referencing an algorithm displays always 0 instead of actual number of the algorithm. References work, I can click on it and it will move me to the algorithm. \documentclass{article} \...
walter54's user avatar
0 votes
1 answer
207 views

Procedure Algorithm in Latex

I would like to create an algorithm as follows. The code in latex is as follows. \documentclass[journal]{IEEEtran} \usepackage{algorithm} \usepackage{algorithmic} \begin{document} \begin{algorithm} \...
Nicholas TI's user avatar
0 votes
0 answers
238 views

Howto fix the place of tables, figures and algorithms in two-column templates?

I use the following template and want to place some tables exactly in a specific place using the command [H] and \usepackage{float}. However, the solution proposed HERE does not work for two-column ...
Questioner's user avatar
0 votes
1 answer
34 views

How to print boldface iteration in algorithm?

How to print boldface "Iteration:" in the algorithm as shown in the picture below? As in document, I don't think I find any description about the command of iteration.
tyrela's user avatar
  • 25
1 vote
0 answers
55 views

Is there a way to use \( \) inside a listings environment as math delimiters

I have the following code \DeclareCaptionLabelFormat{algocaption}{Algorithm} % defines a new caption label as Algorithm x.y \lstnewenvironment{algorithm}[1][ { \captionsetup { ...
user432111's user avatar

1
2 3 4 5
23