Questions tagged [algorithmic]

algorithmic is an environment for typesetting {algorithms}.

Filter by
Sorted by
Tagged with
1
vote
2answers
280 views

Error with algorithm package occurred when using standalone subfile

I am trying to create a standalone subfile in which I want to add some algorithms. The document is compiled right when I am using the \documentclass[9pt]{article} in the preamble. But the following ...
1
vote
1answer
185 views

algorithm and tikzpicture side by side

How can I put minipage and tikzpicture side by side? I would like the right picture to centre (now it is aligned to the top) and give it a figure environment so I can give it a caption. This caption ...
0
votes
1answer
36 views

How to make algorithm centred in text and take less space (smaller width)

How to make algorithm bar shorter? \begin{algorithm}[H] \caption{Exact Invariant Simulator} \begin{algorithmic}[H] \label{alg:eisim} \FOR{$r \in \{1,2,...,R\}$} \...
2
votes
0answers
199 views

writing a data structure in an algorithm [closed]

I am trying to write up a data structure in my algorithm. \documentclass[]{IEEEtran} \usepackage{algorithm,algpseudocode} \begin{document} \begin{algorithm} \caption{Algorithm1} \begin{algorithmic}[...
0
votes
1answer
244 views

How to write a block of a real code (and not pseudo-code) in Latex?

I want to write the following code in latex, such that in pdf, we see the same format of writing (except background color and font colors). However, by algorithmic, output format is different. Is ...
0
votes
1answer
67 views

How to remove page number for the page includes “algorithm pseudo-code”?

I want to remove page number of the page of algorithm pseudo-code. I used afterpage as explained in this answer as follows: \afterpage{% \begin{algorithm} \begin{algorithmic}[1] ...
1
vote
1answer
227 views

Undefined control sequence \for loop

\begin{algorithm}[tb] \scriptsize $\prod_m$: Manipulated Call Trace, \scriptsize $\prod_n$: Natural Call Trace \\ \scriptsize $\Delta_m$: Unaligned Call Trace in $\prod_m$, \scriptsize $\Delta_n$:...
2
votes
1answer
233 views

How to force procedure name to be in small caps

When using algorithm environment: \begin{algorithm}[!t] \caption{Title} \begin{algorithmic}[1] \Procedure{\textsc{Graph}}{$ \alpha, \beta $} \State ... \EndProcedure \end{...
1
vote
1answer
380 views

Algorithm: overlapping code lines and misplaced final horizontal line

I am currently adapting an article to the MDPI template and I have encountered some problems with the algorithm package. Code lines overlap and the last code line appears below the end horizontal line....
2
votes
1answer
949 views

latex algorithm displaying problems: lines are overlapped

duplicate I am using algorithm package (built with pdflatex -shell-escape -synctex=1 -interaction=nonstopmode under TexStudio) to draw my algorithm. It works well on a template, but when I switch to ...
1
vote
1answer
89 views

Correct loading order of package newfloat along with hyperref and algorithmic packages?

There is extensive documentation that hyperref must be loaded towards the end. In particular, the following is the correct loading order for these specific packages: \usepackage{float} \usepackage{...
1
vote
0answers
244 views

Inline For Loop for algorithmic package

Using algorithmic package I would like to have an inline for loop. Currently I have the following code: \documentclass{article} \usepackage{algorithmic} \begin{document} \begin{algorithmic} ...
0
votes
0answers
1k views

How to resize an algorithm to fit into one page

I am using algorithm2e for writing an algorithm. I have a long algorithm that exceeds one A4 page length. But I want to compress it to fit into one page (resize percentage). I tried \resizebox but ...
1
vote
1answer
686 views

Indentation in algorithmic package when having multiple lines

I'm using algorithmic package and I've got this code: \documentclass{article} \usepackage{algorithm} \usepackage{algpseudocode} \begin{document} \begin{algorithmic}[1] \Function {BalanceCascade}{} \...
1
vote
1answer
71 views

Centering a custom-environment defined for width adjustment of algorithms

I am using the algpseudocode environment provided by the algorithmicx package in my thesis. I am wrapping the pseudocode inside the algorithmic environment provided by the algorithms package. The ...
0
votes
1answer
107 views

Algorithm mashing into definitions and overfull / underfull warnings

In a long latex doc I have I get my algorithm inserted into my definition for some reason. I apologize for not having a small working example I could not get one to work. Have a bunch of overfull and ...
1
vote
1answer
711 views

Long algorithm cannot split into two pages

I am writing pseudo code in the algorithmic environment. It is quite long and doesn't fit on one single page. I tried with many option but cannot divide into 2 pages. In another file (since this is ...
0
votes
1answer
398 views

Undefined control sequence \WHILE

I get a Undefined control sequence \WHILE error in my latex code. \documentclass[11pt]{article} \usepackage{algorithm} \usepackage{algorithmicx} \begin{document} \begin{algorithm} \begin{...
0
votes
1answer
2k views

There is always a zero at the end of my algorithm [duplicate]

There is my source code. \documentclass[conference]{IEEEtran} \usepackage{algorithm} \usepackage{algorithmic} %\usepackage{algpseudocode} \usepackage[algcompatible]{algpseudocode} \usepackage{...
2
votes
1answer
63 views

If condition and forloop

My algorithm is divided into two stages: (1)Forloop,(2) if condtion I got error in my following script is: \documentclass[conference]{IEEEtran} \usepackage[linesnumbered,ruled]{algorithm2e} \...
1
vote
1answer
114 views

How to adjust the space between the algorithms and the paper text?

I am writing some algorithms as follow: We describe some algorithms as follow: \begin{figure*}[htbp] \begin{minipage}[t]{.49\textwidth} \begin{algorithm}[H] \renewcommand{\thealgorithm}{} \begin{...
3
votes
1answer
150 views

How to reproduce this pseudocode? [duplicate]

I am trying to replicate the style of the following pseudocode. The following minimal working example almost produces what I want except the extra vertical space between lines 7 and 8. How can I ...
5
votes
1answer
2k views

Input and output in latex algorithm [duplicate]

In latex, I am writing a pseudocode where I want to have output (of input and output) in the following fashion: This is my code: \documentclass[sigconf]{acmart} \usepackage{amsmath} \usepackage{...
0
votes
1answer
154 views

How to stop the algorithm version incrementing in beamer

I have an algorithm which I present in beamer. I want to add some text below it which appears on the second transition. However, the letter version for the algorithm increments from A to B when the ...
1
vote
1answer
575 views

Undefined Control Sequence in Overleaft Template for IEEE Transactions

I'm writing an article for IEEE transactions using overleaf. I'm using algorithm and algorithmic to create a algorithm in my template, but the UNDEFINED CONTROL SEQUENCE error appears. Below the code: ...
2
votes
1answer
16k views

if-else inside for loop in algorithm package

I am trying for a if-else statement inside a for loop. This my code and there is some problem with inner for loop and if-else statement. Code is as follows \begin{algorithm} \caption{Euclid’s ...
1
vote
1answer
7k views

How to use Function in latex algorithm?

begin{algorithm} \SetAlgoLined \DontPrintSemicolon \KwIn{$ NPs $\Comment*[r]{All Noun Phrases of D}} \KwOut{$ {NPs}^{'}$ \Comment*[r]{NPs without PHIs}} \SetKwFunction{Fun}{PHIsDetection} \Fun{$...
2
votes
1answer
60 views

Why is \IF throwing an error?

I am writing algorithm but it is giving error. Please see the code given below: \documentclass{beamer} \usepackage{algorithm,algorithmic} \begin{document} \begin{frame} \begin{algorithmic} \STATE $...
1
vote
0answers
69 views

Bold line number suddenly started algorithmic package [duplicate]

I am currently facing some problem regarding bold numbering in algorithmic package \begin{algorithm} \caption{Mining Three Node Root from Summary Graph}\label{algo_disjdecomp} \hspace*{\...
2
votes
1answer
215 views

Pseudo-code with algorithmic. Escape and indent a function using varwidth and parbox

I'm using the algorithmic package to create pseudo-code for my document. One of the algorithms has a few lines that are too long and they go too far to the edge of the page so I wanted to add a ...
3
votes
2answers
986 views

New algorithm environment with a separate counter

I am trying to define a new environment called protocol, which is the same as the algorithm environment, except for the title and counter. I used this as my guideline. However, it does not reset the ...
2
votes
1answer
2k views

undefined control sequences for algorithm2e package

I have some major and some minor issues while using algorithm2e. For major issues, although the package itself defined some controls such as \input , \Fn etc., but when it comes to use them, I ...
1
vote
0answers
522 views

Referencing a range of lines in algorithm

How is it possible a cross-reference a range of lines in an algorithm? I can cross-reference a single line easily using the simple \label(...) and then \ref(...) to cross-reference it. For example ...
1
vote
1answer
838 views

Undefined control sequence. \end{frame} problem with algorithm in beamer

I am getting an error "Undefined control sequence. \end{frame}" when I tried to insert an algorithm in beamer. \documentclass{beamer} \usepackage{etex} \usetheme{Warsaw} \setbeamercolor {alerted text}...
1
vote
1answer
2k views

Trouble using nested for loops in algorithm

I am trying to write an algorithm which contains nested for loops as follows: \documentclass[a4paper]{article} \usepackage[english]{babel} \usepackage[utf8]{inputenc} \usepackage{algorithm} \...
1
vote
1answer
2k views

Indentation in algorithmic package

I have a renamed command in the algorithmic package: \usepackage{algpseudocode,algorithm,algorithmicx} \algrenewcommand\algorithmicrequire{\textbf{Launch:}} I like the way it looks, not having a ...
2
votes
1answer
231 views

Not getting “-” (minus sign) in math mode, procedure \linebreak is not working with “algorithmic” env

\begin{algorithmic} \Procedure{$M_{topo}$}{$f^-,y$} \inebreak $(n, m, q, A,B)\leftarrowff^-, y_1...y_m\leftarrow y$ \For {$(g, i, j) \in \{n + 1, . . . , n + q\} × \{0, ...
1
vote
1answer
2k views

Style Pseudocode in LaTeX

I'm trying to replicate the style of the following pseudocode taken from 'The Elements of Statistical Learning'. I've tried with algorithm,algorithmic and enumerate (for the item) but I haven't ...
3
votes
1answer
2k views

How to remove header and line numbering from algorithmic?

I created a pseudocode algorithm like this: % Pseudo code % \usepackage{amsmath} \usepackage{algorithm} \usepackage[noend]{algpseudocode} \algdef{SE}{Begin}{End}{\textbf{begin}}{\textbf{end}} \begin{...
2
votes
2answers
535 views

algorithmic, Long lines of code being displayed with sporadic spacing

I'm using LaTeX for the first time, and I'm having trouble showing the pseudocode for an algorithm. Here is what I have: \usepackage{algorithm} \usepackage[noend]{algpseudocode} \begin{algorithm} \...
1
vote
3answers
1k views

Pseudocode: Algorithm Package boxes all figures

for writing pseudocode I decided to use the solution from here. Unfortunately, this package changes the style of all my figures defined like this: \begin{figure}[H] \centering \...
0
votes
1answer
2k views

Split algorithm in two slides with beamer

I am following this answer, but no luck as you can see: The frame is being split into two slides, but the first slide is left empty! How to fix this? \documentclass{beamer} \def\RR{{\mathbb R}} \...
1
vote
0answers
116 views

The customized font going out of right margin of the page in algorithmic

I am using algorithmic package in latex to write an algorithm. I have customized the font style for the comments to my need. For this I have used the two commands to define \COMMENT and \LONGCOMMENT ...
0
votes
1answer
387 views

C style structure declarations for IEEETran

I am writing a document in IEEETran class and I have to include my algorithm in pseudo code. IEEETran class suggests using "algorithmic" package. Can you please suggest me in writing the below ...
2
votes
1answer
3k views

Undefined control sequence. <recently read> \INPUT

Code: \documentclass{article} \usepackage{algorithm} \usepackage{algorithmic} \begin{document} \begin{algorithm}[t] \caption{Dolphinn: Preprocessing (data structure)} \label{DolphinnPrep} ...
3
votes
2answers
11k views

Align Input and Output of algorithm to left

I use the following template for KDD 2017 - for conference (sample-sigconf file): here. This is the code I use for the my algorithm: \documentclass[sigconf]{acmart} \usepackage{booktabs,makecell,...
1
vote
0answers
162 views

how do i reduce space around = sign inside algorithmic environment? [closed]

Inside an algorithm environment, I am getting an extra space before and after = sign. Is there any solution to reduce it? \STATE e\_dist \hspace{-0.52cm}=\hspace{-0.5cm} euclidean\_distance(($QT$[...
2
votes
2answers
743 views

Why doesn't my piece of code work?

I'm trying to write a simple piece of code like: \begin{algorithm} \caption{ALG 1} \label{system} \begin{algorithmic} \For{$each n \in V$} M \leftarrow Dijkstra(n); \EndFor \end{...
1
vote
2answers
1k views

Algorithm crosses upper margin of the page [closed]

When does the latex algorithm cross the top-margin of the page? I searched a lot in the web, and tried with --floatsep, textfloatsep and intextsep but looks like nothing solved my problem so far. Any ...
1
vote
1answer
3k views

Start algorithm step numbering not at 1

I have part of an algorithm that branches off from another algorithm, so I would like to present the numbering of the steps starting from that number instead of 1. Right now, I have it set up as ...