Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [algorithms]

{algorithms} is about the presentation, numbering, and layout of algorithms or pseudocode in documents. Popular packages are algorithms, {algorithmicx}, {algorithm2e} and {listings}. For questions about the specific package, use the appropriate tag instead.

0
votes
1answer
18 views

How to compress algorithm in a beamer presentation?

I have written one algorithm in a beamer class by using a package \usepackage[linesnumbered, ruled,vlined]{algorithm2e}. It is taking the whole slide, I have tried to fit it into a small minpage but ...
1
vote
0answers
17 views

IEEE Algorithms in figure environment caption should read Algorithm

I need to write some pseudocode and am using the IEEE template. However, the guidelines say that algorithmic should be contained in a figure environment and that I am not supposed to use the algorithm ...
0
votes
0answers
13 views

Caption within algorithm producing error

I am using the following packages to produce pseudo-code algorithms in my document: \usepackage{algorithm} \usepackage{algpseudocode} My code, that I took from another latex.se example post, is as ...
0
votes
0answers
29 views

How can we write algorithm for interactive systems? [closed]

I want to write an interactive algorithim using pseudocode package of LaTeX. In my algorithim basically there are two parties. I am using a loop and on each round of the loop one person requests the ...
0
votes
0answers
45 views

Formatting pseudo-code Algorithm

I need to write the algorithm as formatted in the word. I need to insert initiate statement without taking any numbers, format symbols bold to indicate matrix, change the comments font and change ...
1
vote
1answer
23 views

Lonely \item - perhaps a missing list environment, missing package?

I'm trying to implement some pseudocode in my LaTeX document but I keep getting the following error: Lonely item, perhaps a missing list enviroment. The packages I'm using are: \usepackage[utf8]{...
1
vote
1answer
26 views

Algorithm returning 0

I wrote algorithms using the algorithm and algorithmic packages, but I always get the last line returning 0. I tried to use this solution, but I could not make it work. Below my algorithm code and ...
2
votes
1answer
24 views

cannot insert comments in latex algorithm

I cannot insert comments using the \comment{} annotation, here is my code below: \documentclass[conference]{IEEEtran} \IEEEoverridecommandlockouts \usepackage{cite} \usepackage{amsmath,amssymb,...
2
votes
1answer
67 views

how to remove spaces from algorithm and align nicely algorithm

I want to remove the spaces between the "and" and the if clauses in the following code: \documentclass[conference]{IEEEtran} \IEEEoverridecommandlockouts \usepackage{cite} \usepackage{...
2
votes
1answer
39 views

Put a vertical arrow on the one column table

I made a simple table with one column and I want to imitate the pseudocode. My code is like this: \begin{table}[!h] \caption{Algorithm for CNN Architecture} \label{tab:fonts} \centering \begin{...
1
vote
1answer
22 views

How to create the correct formatting for T(n) time complexity notation of two outcomes.

How can i create the following notation from Introduction to Algorithms, Cormen, et al, i've been trying the following, but the Omega is indented and the \textnormal is quite sketchy in my opinion, is ...
-1
votes
0answers
26 views

How to format the text while writing algorithm in steps

I was working on my college seminar and I couldn't able to type the below algorithm in LaTeX. Originally this algorithm was proposed in "A Convolution Particle Filtering Approach for Tracking ...
2
votes
1answer
43 views

How can I create an initialization block in an pseudo algorithm block in Latex?

How can I create the following algorithm block in Latex? I have everything except the init block. How can I create this? \documentclass{article} \usepackage[utf8]{inputenc} \usepackage{algorithm2e} ...
1
vote
0answers
16 views

Algorithmen Substate

I am trying to TeX my description of one of my algorithms. My Algorithm will be described by words not by code. My first Problem was that i rather like the 1. Notation over 1: I solved this by \...
2
votes
1answer
15 views

Disable algorithm numbers for only certain algorithms in a document

I have the following MWE \documentclass[runningheads]{llncs} \usepackage{algorithm} \usepackage{algorithmic} \begin{document} \begin{algorithm}[H] \caption{BLAH} \begin{algorithmic}[1] \REQUIRE $...
5
votes
2answers
206 views

Show parallelism of Algorithm

I want to show that a certain part in a algorithm is working parallel. So I thought about something like a big bracket around the lineS/state in my algorithm. In the following picture I added the ...
2
votes
1answer
53 views

Comment on the same line as \If in algorithm introduces a vertical whitespace

I am using the algorithm2e package to write a pseudo code algorithm. I would like to add a comment with \tcp, on the same line as an \If statement. I managed to do so by putting the \tcp command ...
3
votes
1answer
37 views

Referencing line numbers in an algorithm using autoref

What is the autoref command to reference a line number of an algorithm? I tried to define stepautorefname, linenoautorefname and alglinenoautorefname commands as shown below but they don't work like ...
4
votes
1answer
20 views

Changing line numbering format using algorithmic package

The following code numbers each line in the algorithm as <number><colon>. Is there a way to number each line as <number><period>? \documentclass{article} \usepackage{algorithm,...
1
vote
1answer
42 views

How to separate input output from main algorithm part and add end word in if statement?

In the below image, I want to add two things A horizontal line after output which separate input-output from main part of algorithm I want end word (line 5) at the vertical line from if statement. ...
2
votes
1answer
29 views

Creating keywords which have an associated **end** with algorithm2e

As a part of a homework assignment in a Latex course, I have been assigned to write this algorithm in Latex. I have got most of the part done with this code:- \documentclass[12pt]{article} \...
1
vote
1answer
64 views

i want to write an algorithm but things went wrong

\begin{algorithm} \hspace*{\algorithmicindent} \textbf{Input:} V, E, S, S\textsubscript {ai}, P, P\textsubscript{ai}, R\textsubscript{s}, p\textsubscript{a},r\textsubscript{asp}, $a \in V$, ${s\...
2
votes
2answers
48 views

Indent text but not numbers using latex

So, basically, what I'm trying to do is have an ordered list describing pseudocode. But I want the numbers of each step to be aligned but the text I want indented. I'm using R-studio and am very new ...
1
vote
1answer
28 views

How to write Algorithms in boxes

I am currently writing an algorithm. I want to write an algorithm given below. Till now I have been able to do this much only. \documentclass{article} \usepackage[utf8]{inputenc} \usepackage{mathrsfs}...
0
votes
1answer
32 views

Error message when displaying algorithm

MWE below. I am working on my Bachelor's thesis and have been stuck with these errors for quite a while. They produce almost the correct output but the numbers of the lines are always zero and I get ...
2
votes
1answer
27 views

How to number the algorithms (some algorithms are put in a group)?

I want to write some groups of algorithms. For example, there are 2 groups and 2 related algorithms in each group. I do not know how to number every algorithm in this case (like 1.1.1, 1.1.2, 3.1.1, ...
1
vote
0answers
152 views

Algorithm In latex Elsevier template

Actually, I wrote algorithm first in general latex format and done successfully. Following algorithm Packages I had used: \usepackage{algorithm,algpseudocode} \usepackage{algorithmic} \usepackage{...
0
votes
0answers
25 views

Divide a algorithm with small sub parts in more than one page

I want to write down a algorithm using TeXStudio. The algorithm is very huge so it cannot fit in one page. I use \usepackage{algorithm} ,\usepackage[noend]{algpseudocode} to write down this algorithm. ...
0
votes
1answer
28 views

Algorithm writing style not correct as per desired

This is the algorithm I want to write down in latex. But after write down some code it cannot give me desire output. My code: \begin{algorithm} \caption{The GraphSlam Algorithm for the Full SLAM ...
2
votes
1answer
45 views

Wrongly formatted algorithm in Latex

I am writing a paper in latex and there I am including algorithm. I added every package of an algorithm like \usepackage{program} \usepackage{algorithm} \usepackage{algpseudocode} \usepackage{...
1
vote
0answers
44 views

How do I write an algorithm with two columns to its right?

I know about verbatim which I use to write code, but how in the world can I get a table like this? The reason why I do not just write it in verbatim is that I want to apply effects like \texttt and $....
0
votes
1answer
305 views

Exception handling pseudocode (try-catch) for algorithm2e package

It appears that there is no such try and catch blocks in algorithm2e. Is there a way to add custom blocks for try and catch in algorithm2e? There is a solution in GitHub which shows how this can be ...
0
votes
1answer
32 views

Algorithm rename \listofalgorithms title

How to rename the title of \listofalgorithms? If using the algorithm package (not algorithm2e)? If you are using the algorithm2e package see here.
1
vote
2answers
48 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
67 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 ...
1
vote
1answer
67 views

Display two algorithms side by side

I am using the below code to display several algorithms in a minipage. It works great however they take up a lot of room in my document. Is there are a way to scale and present two algorithms side by ...
0
votes
0answers
13 views

How do I combine algorithmic and algpseudocode?

I am trying to merge two documents. One has \usepackage[noend]{algpseudocode} and the other has \usepackage[noend]{algorithmic}. It seems I can neither leave one of them out nor have them both. It ...
0
votes
1answer
18 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
61 views

writing a data structure in an algorithm

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}[...
2
votes
1answer
43 views

Splitting a function prototype of two lines

I am trying to write a function in pseudocode that does not seem to appear properly due to its length. Is there a way to split the function prototype over two lines so that there is no gap as shown in ...
0
votes
1answer
92 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
23 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
80 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$:...
4
votes
1answer
55 views

Incorrect output with algorithm2e when using “newtxtext” package

I have a LaTeX document displaying an algorithm and the output is incorrect when I use the package newtxtext with algorithm2e. Here is the minimum working example that shows this problem. \...
1
vote
2answers
53 views

Add Caption below algorithm environment

I want to add a caption below algorithm environment that spans over two column page in \documentclass[10pt, conference, compsocconf]{IEEEtran}. I use the following: \usepackage[Algorithm,ruled]{...
0
votes
0answers
51 views

Document a function(Computer Science), without sourcecode or pseudocode

I want to document several function headers without their bodys. I don't want to use a specific language, but rather keep a mathematical style. The functions I want to document are: State apply(...
0
votes
1answer
22 views

Text in algorithm

I need to create an algorithm, inside the for cycle, I a have to use some words and mathematical notations, lines 6 and 7 in the algorithm. I used mbox in order to place the text, but now I am not ...
2
votes
3answers
45 views

Algorithm sub-numbering

I have the MWE: \documentclass{article} \usepackage{algorithm} \usepackage{algpseudocode} \begin{document} \noindent \begin{minipage}[tb]{\textwidth} \centering \setlength{\intextsep}{0pt} \...
1
vote
1answer
105 views

If TeX / LaTeX modifies the spacing between individual letters

Wondering if there is any compression / expansion of the between-letter spacing done in TeX / LaTeX. In looking at the font specs, I noticed they only have 2 horizontal properties: advance width and ...
2
votes
1answer
57 views

Edit number listing of algorithm to letters

\usepackage{algorithm} \begin{algorithm}[H] \caption{Algorithm1}\label{euclid} \begin{algorithmic}[1] \State $X\sim f$ \\ ... \State $X\sim g$ \\ ... \State $X\sim z$\\ \end{algorithmic} \end{...