Stack Exchange Network

Stack Exchange network consists of 175 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
0answers
29 views

What is the reason of extra '=0' [duplicate]

I know the reason is the incompatibility of the packages, but I tried all the possibilities and I couldn't reach to the point of removing '=0' without changing the algorithm style I want. . \...
0
votes
1answer
16 views

How do I get rid of the commands (for, do, if …) in Algorithmic?

I am writing a paper in LATEX like the picture. I tried many times but there I haven't yet shown the way to do them. I tried to type this example with Algorithm but it can not. Could you say to me ...
0
votes
0answers
8 views

How to include algorithm in JFM template

I'm writing with the template offered by the Journal of Fluid Mechanics, downloadable here. I'm wondering how can an algorithm be added into the paper. I tried to use the \usepackage{algorithm} but it ...
0
votes
1answer
31 views

I want to write an algorithm in overleaf, but it comes up with errors [duplicate]

\begin{document} \usepackage{savesym} \usepackage{program} \savesymbol{AND} \savesymbol{OR} \savesymbol{NOT} \savesymbol{TO} \savesymbol{COMMENT} \savesymbol{BODY} \savesymbol{IF} \savesymbol{ELSE} \...
3
votes
1answer
39 views

Is it possible to draw vertical lines in algorithm (not algorithm2e) package?

My question is if it is possible to draw vertical lines in the algorithm package. I have seen the following question: Vertical line for pseudo code But I don't want to use algorithm2e because it ...
0
votes
0answers
21 views

algorithm float environment

I would like to put 2 algorithms next to each other. I followed several suggestions and I ended up with something like: \begin{figure*}[ttt!] \begin{minipage}[t]{.38\linewidth} \begin{algorithm}...
0
votes
1answer
22 views

How to align horizontally line numbers with package algorithm2e

I'm trying to write an algorithm using the package algorithm2e. This is my code: \usepackage[linesnumbered,ruled]{algorithm2e} ... {\footnotesize \IncMargin{1em} \begin{algorithm}[H] \...
5
votes
2answers
215 views

How can I put a period right after the algorithm's number in the algorithm's title?

I wish it said "Algorithm 1.", with a period after the number, and not just "Algorithm 1". It's how I see most people using it, so I must be using an unconventional package? Would you say I should ...
1
vote
1answer
23 views

Align comment in algorithm to the end of the line

Here is my algorithm:: As can be seen the comment is aligned to the right end of the line. I would like to align the comment to the end of the same line. At the exact place where the line ends I ...
0
votes
1answer
62 views

Algorithm: ELSEIF problem

I want to compile this code in Latex (shown below). I use three libraries. I especially need elseif and \state command and line number. LaTeX Error: Command \algorithmicindent already defined.Or ...
0
votes
1answer
39 views

how to write the algorithm in latex

My code is below, I didn't find the error. \begin{algorithm}[H] \SetAlgoLined \textbf{Input} :$x_{k-1}$,$P_{k-1}$,$u_{k}$,$z_{k}$\; \textbf{Output} : $x_{k}^{-}$,$P_{k}^{-}$ \\~\\ $x_{k+1}={\Phi{x}}...
1
vote
1answer
35 views

How to have a space between algorithm lines

I have an algorithm and I would like to insert space between its steps. Here is my try: \documentclass[12pt,a4paper,openright]{report} \usepackage{amsmath} \usepackage{amssymb} \usepackage{...
3
votes
2answers
1k views

How to write algorithm like this in latex

I want to write an algorithm in a latex. There are various ways to write, but I want to write in the way given below. I have tried but I am not able to do anything similar to the given in the image. ...
1
vote
1answer
35 views

Add colon after algorithm caption/number in IEEE transactions

I am using Overleaf to write an article in IEEE transactions template. I wish to write the caption of Algorithm as, Algorithm 4: (as shown in the picture below). But when I use my code, it shows ...
0
votes
1answer
43 views

An error in inserting pseudo code in LaTeX

I want to insert a simple pseudo code as follows, but I confront with an error and I am not able to resolve it. \documentclass{article} \usepackage{algpseudocode} \usepackage{algorithm} \usepackage{...
4
votes
1answer
127 views

How to zoom in in beamer algorithm package?

I will be using the beamer class for my presentation. I want to present the algorithm line by line in such a way that the line on which I am working should get zoomed or lensed or highlighted. See my ...
0
votes
1answer
43 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
41 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
76 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
57 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
53 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
29 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
69 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
47 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
26 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 ...
2
votes
1answer
87 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
25 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
16 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
238 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
141 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
59 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
38 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
87 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
45 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
91 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
55 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
69 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
42 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
28 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
205 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
31 views

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

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
34 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
60 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
59 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
508 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
33 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
75 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
88 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
125 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
18 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 ...