Questions tagged [algorithmic]
algorithmic is an environment for typesetting {algorithms}.
278
questions
0
votes
0
answers
13
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
39
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
19
views
The LaTex template offered by AIP cannot be inserted pseudocodes
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
0
answers
13
views
Cannot reference individual algorithm line numbers in tufte-book figure
I am encountering a strange problem with the tufte-book class. I am trying to reference the individual line numbers of an algorithm block that lives inside a figure environment. The following MWE ...
0
votes
0
answers
16
views
Pseudocode split in two side by side [duplicate]
Hello I am trying to split my pseudocode in half and place it side by side as seen in the example below:
I have the following code but am not sure how to split in half after #11:
\begin{algorithm}
\...
0
votes
1
answer
13
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
28
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
12
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
20
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
0
answers
14
views
SIAM template breaks algorithm line references
I'm making a SIAM submission, and after applying the template the algorithm line references simply refer to the algorithm itself, instead of the specific line.
Oddly, according to the template manual, ...
0
votes
0
answers
16
views
Indention of vertical rules with algorithm2e
I am trying to create an algorithm in Latex with the package algorithm2e and algpseudocode. The code and a picture with my output is included below.
I have two goals:
I would like to unindent the ...
0
votes
1
answer
21
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}
\...
0
votes
1
answer
36
views
Weird unexpected error in my "algorithm" and "algpseudocode" package
I am trying to write a simple algorithm in my Latex. When I tried the original template, it works perfectly fine on my browser. However, when I copied the script to my document, I get errors such as &...
1
vote
1
answer
17
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
91
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
1
answer
478
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
22
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
68
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
29
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
91
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
54
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{...
0
votes
0
answers
27
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 ...
0
votes
2
answers
137
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
127
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 ...
1
vote
1
answer
34
views
In "algorithmic" environment, how can I place a comment before a statement?
In the algorithmic environment, I can use the \Comment macro to put a comment after a statement. But when I try to put it before the first statement in an algorithm, I get an error. Is there a way to ...
4
votes
1
answer
266
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
1
answer
68
views
Algorithmic: Put If, Else and EndIf into the same line
I am reading this post how \If{cond} \State{statement} \EndIf can be placed in the same line. Could you please someone suggest a way on how \If{cond} \State{statement} \Else \State{statement} \EndIf ...
2
votes
1
answer
95
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
2
answers
39
views
Changing main font in documents changes weight in monospaced family
I'm using times package for my main font in the document. However, it changes the weight of the monospaced font in the algorithmic environment. I want the monospaced font to be displayed as if I didn'...
1
vote
1
answer
94
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 ...
2
votes
1
answer
106
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
0
answers
35
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 ...
1
vote
1
answer
29
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
1
answer
181
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 ...
4
votes
0
answers
230
views
Highlighting pseudocode in algorithm
Edit: I "solved" my main issues now. It's a bit ugly/hacky, but at least the result looks ok. With this edit I'm replacing the now obsolete old code with what I have now. But suggestions for ...
1
vote
0
answers
20
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
1
answer
117
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
\...
1
vote
1
answer
46
views
how to eliminate automatic indentation in pseudo code
In the code, one of the lines has an automatic indentation. How can I eliminate the indentation(it is the line after the command "\Endwhile")?
\documentclass{article}
\usepackage{amsmath,...
1
vote
1
answer
93
views
Custom counter in \state in algorithmic package
I am using the algorithm package. Every time I type \state, it generates a new enumerated line.
What I want to do, is that to change the counter after x lines, so that the next line is $t$.
Here is a ...
1
vote
1
answer
360
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{...
1
vote
1
answer
428
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 ...
0
votes
1
answer
27
views
Customized numeration in algorithmic
I want to customize the numbering inside an algorithm. Here is a short MWE
\documentclass[article]{scrartcl}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage[english]{babel}
\...
1
vote
1
answer
237
views
Long algorithm exceeds one page using algorithm2e package in IEEE Access Class. How to fit this long algorithm?
\documentclass{ieeeaccess}
%\usepackage{siunitx}
\usepackage{graphicx
%\usepackage{algorithmic}
\usepackage[lined,boxed,ruled,commentsnumbered]{algorithm2e}
\begin{document}
\begin{algorithm}
\tiny
\...
0
votes
1
answer
412
views
error messages in algorithm package
I got these errors while writing an algorithm. Can anyone help?
Missing number, treated as zero.
\ALG@currentblock@0 l.273 \end{algorithmic}
Missing = inserted for \ifnum.
l.273 ...
0
votes
1
answer
38
views
Why is this algorithm preventing my file from compiling?
Wrote a pseudocode algorithm using algorithm package and I get the errors below... Any ideas?
\begin{figure}[H]
\begin{minipage}[t]{0.96\textwidth}
\begin{algorithm}[H]
\...
1
vote
1
answer
63
views
How do I place my algorithms side by side and centered?
I'm finalizing my dissertation and am struggling to get these algorithms to display correctly...
I'm new to writing pseudocode in LaTeX too so any recommendations are VERY welcome.
\begin{minipage}{0....
2
votes
1
answer
500
views
resize algorithm [closed]
I'm using the algorithmic package and was wondering if there is a way to resize/rescale the algorithm.
Currently, for some reason, the algorithm exceeds the right margin of a letter size paper and I ...
1
vote
0
answers
88
views
Algorithms with Latex [duplicate]
I am a beginner in LaTeX language and I need to describe these algorithms with Latex.
[![les algorithmes ][8]][8]
[![les algorithmes ][9]][9]
1
vote
1
answer
499
views
Undefined control sequence in algorithmic package
I started to write this algorithm in LaTeX but I got these errors and I don't know what should I do. I used the algorithmic and the algorithm packages.
2
votes
1
answer
26
views
How to change indentation of specific comment in algorithmic environment?
I have the following code:
\documentclass{article}
\usepackage{algorithm}
\usepackage{algorithmic}
\newcounter{ALC@tempcntr}% Temporary counter for storage
\newcommand{\LCOMMENT}[1]{%
\...