Questions tagged [algorithmic]
algorithmic is an environment for typesetting {algorithms}.
301
questions
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{...
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} % ...
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 ...
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{...
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 ...
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 ...
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 ...
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 ...
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?
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 ...
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{...
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,...
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\...
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}
...
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.
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 ...
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?
\...
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,...
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 ...
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 ...
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 ...
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/...
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}
\...
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{...
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:
...
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 ...
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}
\...
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{...
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}...
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:...
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 ...
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] ...
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]
\...
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{\...
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{...
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}[!...
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 ...
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 ...
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}
\...
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:
\...
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 ...
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 ...
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]{...
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 ...
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
\...
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
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{...
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 ...
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}...
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 ...