Skip to main content

Questions tagged [algorithmic]

algorithmic is an environment for typesetting {algorithms}.

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

How to make an algorithm box smaller inside a figure environment?

I have following code for an algorithm block: \usepackage{algorithm} \usepackage{algorithmicx} \usepackage{algpseudocode} \usepackage{enumitem} \usepackage{minibox} \usepackage{multirow} \usepackage{...
ranaya's user avatar
  • 1
2 votes
0 answers
68 views

What package can allow me to typeset code and pseudocode in the following way?

I'm using algorithm and algpseudocode and I get nice results but I want to have in a single environment multiple algorithms/codes in the following way: instead of having 2 different environments, I ...
Nate3384's user avatar
  • 197
2 votes
1 answer
54 views

Algorithm in Beamer

\documentclass{beamer} \mode<presentation> { \usetheme{Warsaw} \usecolortheme{beaver} } \usepackage{algpseudocode} \usepackage{amsmath} \usepackage{amssymb} \usepackage{alphabeta} \usepackage[...
MacTavish's user avatar
  • 115
2 votes
1 answer
30 views

For and end for alignment in algorithmic

I have been writing my research and had to use a lot of algorithm inserts, and I haven't worked with it enough to solve this issue. My For and EndFor part don't seem to align no matter what. I tried ...
Ксения's user avatar
1 vote
1 answer
32 views

How to fix numbering of an algorithm in algorithmc and algorithm environment?

I have some pseudocode for an algorithm, which appears okay (with some minor errors in compilation). But the biggest problem is that the numbering of the steps does not match the number of steps in ...
underdog987's user avatar
3 votes
1 answer
164 views

Writing big comment in algorithmic

I have a problem writing big text comment in algorithmic. The second like starts with 0 padding from statement indexing. Is there any solution to force second comment line start on level of first? ...
nezudem's user avatar
  • 33
2 votes
1 answer
70 views

Remove \If and only have "do" in algortihm

I have the following code for an algorithm: \documentclass{article} \usepackage{graphicx} \usepackage{algorithm} \usepackage{algpseudocode} \usepackage{amsmath} \begin{document} \begin{algorithm} \...
nflgreaternba's user avatar
0 votes
1 answer
42 views

Undefined control sequence error for each \STATE \FOR \IF [closed]

\begin{algorithm} \caption{SSBPSO}\label{SSBPSO_algo} \begin{algorithmic} \STATE \textbf{INITIALIZATION: } Set N as the number of particles in the swarm, M as the number of active stocks ...
Ashish Lakhmani's user avatar
0 votes
0 answers
31 views

Continue the numbering of theorems in algorithm environments

I'm using the thmtools package to get theorem like environments where the theorem numbering is of the form SECTION.THEOREMNUMBER: \declaretheorem[numberwithin = chapter]{theorem} \declaretheorem[...
0xbadf00d's user avatar
  • 523
0 votes
1 answer
32 views

Reconstruction of a Pseudocode Observing Horizontal Spacing and Alignment

In an attempt to reconstruct the following picture, I have tried verbatim environment as below: \documentclass[11pt]{book} \usepackage{algcompatible} \usepackage{algorithm} \usepackage{mathrsfs} \...
mali1234's user avatar
  • 135
3 votes
2 answers
421 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
  • 135
0 votes
0 answers
53 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
80 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
83 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
78 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
  • 503
1 vote
1 answer
74 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
404 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
2 answers
138 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
  • 843
0 votes
1 answer
256 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
2 votes
1 answer
81 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.3k
1 vote
1 answer
75 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
113 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
111 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
92 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
  • 176
0 votes
1 answer
45 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
  • 125
2 votes
2 answers
962 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
1 vote
2 answers
191 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 ...
melatonin15's user avatar
1 vote
1 answer
135 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
70 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
57 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,515
1 vote
0 answers
95 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
96 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
1 vote
1 answer
422 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
105 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
165 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
  • 587
0 votes
2 answers
425 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
  • 769
0 votes
1 answer
606 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
  • 445
2 votes
1 answer
262 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
1 vote
1 answer
786 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
365 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
331 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
134 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
929 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
121 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
160 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
41 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
  • 507
1 vote
1 answer
83 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
434 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,515
0 votes
2 answers
5k 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
167 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
  • 85

1
2 3 4 5
7