Questions tagged [algorithmic]

algorithmic is an environment for typesetting {algorithms}.

Filter by
Sorted by
Tagged with
0 votes
0 answers
27 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
33 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
28 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
36 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
1 vote
1 answer
44 views

revtex4-2 document class misaligns algpseudocodex right margin

When using the revtex4-2 document class with the twocolumn option, the algorithmic environment of the algpseudocodex package has a right margin which extends too far. How do I fix this so the right ...
Tim Chan's user avatar
1 vote
1 answer
94 views

How to fix Missing \endcsname inserted and Missing number, treated as zero and Missing = inserted for \ifnum errors?

I've seen this answer, but it didn't solve the errors. My LaTeX document compiled fine on a Springer Nature template and even on another IEEE template. Oddly, this conference template is where these ...
Nav's user avatar
  • 227
0 votes
1 answer
52 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
56 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
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
1 answer
45 views

standalone problem with algorithmicx, algorithm, algpseudocode packages. perhaps a missing \item

I am using the code from How may I remove \EndIf and \EndFor in algorithmicx? The code, as is, works in article class. But in standalone it fails. I searched and found one needs to add [H] to ...
Nasser's user avatar
  • 20.1k
1 vote
1 answer
33 views

Algorithm not showing in multicol

When I am in the multicol environment, my algorithms are not showing. The page is simply blank. Full TeX code available here: \documentclass[12pt,landscape]{article} \usepackage{multicol} \usepackage{...
Satya Vejus's user avatar
0 votes
1 answer
35 views

algorithmic + textcolor == something's wrong -- perhaps a missing item, and incorrect layout

I need to color part of an algorithm with \textcolor. I have the following code using the algorithmic package: \usepackage{algorithmic} \usepackage{xcolor} ... \begin{algorithmic} \FOR{$s = 1,...
Robert Sim's user avatar
3 votes
1 answer
57 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
1 vote
1 answer
35 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
  • 146
0 votes
1 answer
29 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
2 votes
2 answers
229 views

How to write a "repeat n times" loop in algorithmic?

In algorithmic, I would like to write a loop that will look like the following: repeat $n$ times: [command] end I found this question, explaining how to do this in algorithms2e, but it ...
Erel Segal-Halevi's user avatar
0 votes
0 answers
128 views

Complexity of Algorithm

Here is my current code, the time and space complexities are displayed in two separate lines. I want to put them into the same line, each occupies half the width, how could I achieve that? \...
zlbi's user avatar
  • 1
0 votes
0 answers
31 views

Align Comments in Algorithmic Environment

I am trying to write a pseudocode with the algorithmic environment, I want to align my comments, and I want the comments to be as left as possible (of course, without touching the original text). Also,...
remmymilkyway's user avatar
1 vote
2 answers
68 views

Reduce font size of particular line in algorithm and algorithmic pseudocode

I want to reduce the font size of a particular line in an algorithm pseudocode where I use algorithm and algorithmic package. How can I do it? For example in the following I want to fit line 9 in one ...
hi15's user avatar
  • 253
1 vote
1 answer
39 views

Writing comments starting from a new line in an algorithm environment

I am writing a pseudocode/an algorithm. When writings comments, they are aligned to the right. This is really inconvenient as some of my comments are very long and take multiple lines. In addition, it ...
mathslover's user avatar
1 vote
1 answer
55 views

Comment in an algorithm in a latex document looking different

I am writing a pseudocode/algorithm in my latex Overleaf document. I had a problem that my algorithm was too long so I had to split it into multiple "blocks". However, now I can't add ...
mathslover's user avatar
0 votes
1 answer
41 views

Missing } inserted.for `algnewcommand ` in AMA document class

I am trying to prepare a paper for Concurrency and Computation: Practice and Experience, its latex class files could be find here: https://onlinelibrary.wiley.com/page/journal/15320634/homepage/...
alper's user avatar
  • 1,311
1 vote
0 answers
60 views

Algorithm2e does not properly indent inside algorithmic

I have the below MWE. The desired output is one tab indentation of lines. Do you see what is wrong? \documentclass{article} \usepackage[ruled,vlined]{algorithm2e} \usepackage{geometry,nccmath} \...
tcokyasar's user avatar
  • 233
0 votes
0 answers
46 views

Adding an algorithm in Latex changes the layout of my figures

I want to add an algorithm in my latex file. I add it by implementing the following: \usepackage{algorithm} \usepackage{algpseudocode} \begin{document} ..... \begin{algorithm} \begin{...
henrirno's user avatar
0 votes
0 answers
76 views

Is there any combined package of algorithmic and algorithm2e packages?

I've been shifting between algorithmic and algorithm2e packages to suit my needs to typeset an algorithm. One algorithm provides a feature that isn't in the other package. Here are the main points: ...
afaq's user avatar
  • 337
1 vote
1 answer
106 views

Remove line number before for statement in algorithm

I am trying to remove the number before the for loop in the below algorithm. I would like to continue using the packages I am using, but have only found potential answers for algorithm2e. Is it ...
AW27's user avatar
  • 189
1 vote
1 answer
84 views

Can anyone help writing the algorithm shown in the figure in LaTex?

I was trying to write the algorithm shown in 1 in LaTex. Below is the code that I tried. However, it returns no indentation as I needed. I appreciate the help. \documentclass[11pt]{article} \...
Jae H's user avatar
  • 81
0 votes
1 answer
80 views

Algorithmic: Numbering and Alignment

In algorithmic, how can we make "Input" to come aligned on the first line and reduce indent of table? \documentclass[a4paper]{scrartcl} \usepackage{amsmath,amssymb,amsfonts} \usepackage{...
pba's user avatar
  • 517
0 votes
2 answers
137 views

How to left align comments in algpseudocode?

How can I left align these comments? Something like this? \documentclass{article} \usepackage{algorithm,algpseudocode} \begin{document} \begin{algorithm} \caption{Euclid’s algorithm}\label{euclid}...
hana's user avatar
  • 759
0 votes
1 answer
228 views

modify algorithm to compatible with IEEEtran

IEEEtran suggests do not use the algorithm floating environment. So I have been trying to mimic the original look of algorithm without success. Here is my algorithm with algorithm floating environment:...
emnha's user avatar
  • 425
2 votes
1 answer
169 views

How to break a long pseudo code in Beamer in two slides

I have to write a long pseudo code in latex but one slide only takes 22 syntex. How to continue the remaining syntex in next slides. Please see my codes, I am using the extra packages for other ...
Saleem's user avatar
  • 21
0 votes
1 answer
487 views

Place algorithm environment directly under sections/subsections

Algorithm environment is placed wrong, not in the place I want it to be (directly under subsection statement). I am aware of popular answers about the problem like using float package and [H] ...
Petro Kolosov's user avatar
1 vote
1 answer
211 views

Multiple if and elsif statements

I would like to know how best I can get this algorithm written, I tried multiple times with the implementation below but it did not generate the algorithm I wanted. \begin{algorithm} %[H] \...
kekule's user avatar
  • 13
0 votes
1 answer
207 views

The LaTex template offered by AIP cannot be inserted pseudocodes [duplicate]

In order to submit to Chaos, I downloaded the Latex Template AIP requests. But when I was going to insert the pseudo code like \begin{algorithm} %\textsl{}\setstretch{1.8} \renewcommand{\...
user277103's user avatar
0 votes
1 answer
44 views

nested if doesn't work on my latex algorithm code

I am trying to write a nested if pseudo code on latex put the following error is appearing: LaTeX Error: Command \NOT already defined. \begin{algorithm}[!htbp] \begin{algorithmic} \STATE \textbf{...
Eng.sh's user avatar
  • 69
1 vote
1 answer
191 views

Zero number paper at the beginning and the end of my algorithm

I am using {algorithm}, {algorithmic} and {algpseudocode} packages to write an algorithm on latex put there zero number (0:) appear at the beginning and the end of the pseudo code: \begin{algorithm}[!...
Eng.sh's user avatar
  • 69
1 vote
1 answer
44 views

How to display line number before \Require in algorithmic environment

Here is my code snippet: \documentclass{article} \usepackage{algorithm, algpseudocode} \begin{document} \begin{algorithm} \caption{Test} \begin{algorithmic}[1] \Require ...
Michael's user avatar
  • 15
0 votes
0 answers
107 views

How to bring the algorithm straight after the paragraph

I am trying to start my algorithm right after a small paragraph, instead of starting it from the next page. I have tried numerous way, e.g. change float to "h!" or "H", but to no ...
Muhammad Rayyan's user avatar
0 votes
1 answer
33 views

hyperref same identifier warning with side-by-side algorihtms

The code below is used to generate two side-by-side algorithms that float to the top of the page. \documentclass{article} \usepackage{algpseudocode} \usepackage{algorithm} \usepackage{caption} \...
jII's user avatar
  • 411
1 vote
1 answer
50 views

algorithm2e: Cross reference to subsubsection after algorithm not working

while writing my thesis I became aware of a problem related to the algorithm2e package regarding the label referencing of subsubsections following an algorithm. Here is a simple example: \...
user270427's user avatar
0 votes
1 answer
329 views

How can I align indent of `then` in algorithm

When a statement of if is long, its then part is printed misaligned as following example: while if statement then undertand_this Origin of code comes from following solution. I have ...
alper's user avatar
  • 1,311
0 votes
2 answers
3k views

how to convert algorithm from latex to word?

I have this algorithm steps I coded in LaTeX as follows: \begin{algorithm} \caption{Deep Q-Learning with Experience Replay} \label{alg:DQN} \begin{algorithmic} \State Initialize ...
ربيع's user avatar
  • 105
0 votes
0 answers
74 views

How to get algorithm numbering instead of section numbering?

I am trying to get numbering for algorithm in references, but I am getting reference as section number. How to resolve this? A simple working of my code is as follows \documentclass[conference]{...
A J's user avatar
  • 83
0 votes
1 answer
312 views

How to insert an algorithm inline with an item in itemize/enumerate

I am using an itemize to list several algorithms, and I want to use the algorithm package to display the algorithm. However, when I use the \begin{algorithm} within one of the items, the algorithm ...
Daniel's user avatar
  • 1
0 votes
2 answers
160 views

\Function adds () on the second letter in algorithmic

How can I get rid of the () on the second letter of the Function statement? The code: \begin{algorithm} \begin{algorithmic} \Function Signature(df) \If {Condition 1} \State a \State b \...
JKJ's user avatar
  • 161
0 votes
2 answers
134 views

How can i get this chapter page style?

that's my first post here. Can anyone help me to understand how to get this? Thanks <3
Sbliz's user avatar
  • 3
0 votes
1 answer
312 views

Latex resize algorithm

I have to resize an algorithm in Latex. I have tried \resizebox and \scalebox but I get this error: Error: Not in outer par mode Anyone has a suggestion? Here is the code \scalebox{0.8}{% \begin{...
manoni lo's user avatar
1 vote
0 answers
105 views

Jump to a line number in an algorithm

My question is basically a follow up to this question. I would like to be able to click on the reference and have the PDF viewer jump to the specific line, so that the line it the top most line on ...
Foaly's user avatar
  • 113
1 vote
2 answers
517 views

How to convert this code from algorithm2e to algorithmicx

I was using the algorithm2e environment so far. However, the springer journal class does not support it. In it's documentation, it is suggesting to use \usepackage{algorithm} \usepackage{algpseudocode}...
Bukaida's user avatar
  • 575
2 votes
1 answer
674 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 ...
Saeid Ghafouri's user avatar

1
2 3 4 5
7