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.

Filter by
Sorted by
Tagged with
1 vote
1 answer
12 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: \...
user avatar
0 votes
1 answer
32 views

Hide Algorithm environment

I would like to hide the Algorithm environment as shown in the attached pic below. That is please remove "Algorithm 8.1" which is highlighted in blude. The code is provided below: \begin{...
user avatar
  • 1,243
0 votes
0 answers
9 views

Error with the package algorithm2e in springer template

I'm using the Springer Latex template, the package algorithm2e is not acceptable (error). I tried to insert the package in "sn-jnl.cls" but that did not work. They use these packages: \...
user avatar
0 votes
1 answer
74 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 ...
user avatar
  • 402
0 votes
1 answer
22 views

How can I add extra space in between lines in Algorithm if superscript and subscripts close to each other?

When upper line has subscripts and lower line has superscripts they may end up pretty close to each other in Algorithm. Is it possible to put extra space in between lines in Algorithm if lines are end ...
user avatar
  • 402
0 votes
0 answers
10 views

How to access algorithm caption and procedure name

I would like to be able to access an algorithm's caption and procedure name in a similar way I can reference the algorithm number; i.e. using something like \ref{somelabel}. Is there a straightforward ...
user avatar
  • 141
3 votes
3 answers
97 views

algpseudocodex: Adding comment to \until" line

I'm using algpseudocodex to type-set my algorithms, and I'd like to have a comment on each line. Minimum example: \documentclass{article} \usepackage{algorithm} \usepackage{algpseudocodex} \begin{...
user avatar
  • 133
0 votes
0 answers
32 views

Two algorithms in one latex document

I want to use two different styles of algorithms with different latex packages algorithm2e and algorithm, but haven't succeeded. They work separately but not together. One is: \usepackage{...
user avatar
1 vote
0 answers
43 views

How to split the algorithm into two slides?

I am trying to split the following algorithm into two different slides. Can anyone help me how can I do this? \documentclass{beamer} \usepackage{beamerthemesplit} % new \usetheme{Warsaw} ...
user avatar
  • 11
0 votes
0 answers
13 views

How to change position in pseudocode (package algorithm2e)

I'm new to LaTeX and I'm writing my thesis in this right moment. For the pseudocode, I use algorithm2e. However, when I try to fit my algorithm between two paragraphs, it points down to the bottom of ...
user avatar
0 votes
0 answers
37 views

! LaTeX Error: File `algorithm2e.sty' not found

I am using Centos 7.8 and installed texlive using yum install texlive* I tried installing using yum install texlive-full but it did not find any package named like this. It turns out I can not use ...
user avatar
1 vote
1 answer
38 views

How to split algorithm2e over two pages within for-block and if-else-block

I do know that this questions have been asked before in How to split algorithm2e over two pages Unfortunately the answers given there did not work out for me. I am struggling to realize a page break ...
user avatar
  • 327
0 votes
0 answers
19 views

Add List of Algorithms to content list with correct label

I'm using a custom template and can't seem to add the list of algorithms correctly. When I simply try \listofalgorithms, it results in this: Instead of Algorithm, Figure is displayed in the list. ...
user avatar
  • 21
0 votes
1 answer
32 views

I keep getting a bar and 0 at the end of the nested forall loop I write within a Pseudocode [closed]

\documentclass{article} \usepackage{algorithm} \usepackage{algorithmic} \begin{document} \begin{minipage}{0.46\textwidth} \begin{algorithm}[H] \caption{foo} \begin{algorithmic}[1] \STATE let $S$ ...
user avatar
  • 1
0 votes
1 answer
126 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 ...
user avatar
  • 105
0 votes
0 answers
17 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]{...
user avatar
  • 37
0 votes
0 answers
26 views

How to place these algorithms side by side in a special way

I have the following problem: I want to place to algorithms side by side such that the lines with the same number are on the same height. Unfortunately, until now it looks like that . What I do not ...
user avatar
  • 367
1 vote
1 answer
59 views

Applying a Pieter van Oostrum Page Number Positioning Algorithm to the First Page of the Endnotes

In the following MWE, I have invoked a Pieter van Oostrum algorithm for selectively placing the page number at the bottom of the page (and ignoring the header) that was introduced in the post: How to ...
user avatar
  • 4,907
2 votes
2 answers
51 views

How to get the desired output with proper alignment?

How to write a c++ code in LaTeX with proper alignment? I am providing more details about my question below: I need to write this: if(a==b): a=2 b=2 I need to write this above code in ...
user avatar
  • 933
3 votes
1 answer
61 views

Cleveref/hyperref: incorrect link to step in algorithm

I am using the cleveref and hyperref packages. This works well overall, but cross-references to lines in algorithms are incorrect. I found some other related posts, this one and this one. However, ...
user avatar
  • 303
0 votes
1 answer
45 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 ...
user avatar
  • 1
0 votes
2 answers
26 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 \...
user avatar
  • 161
0 votes
0 answers
17 views

Algorithm in LaTeX doesn't show for or while loops [duplicate]

I have a LaTeX document for a report, it's a bit extense and I have to include a relatively large algorithm. I had issued with it because instead of displaying through the pages I wanted it went to ...
user avatar
4 votes
2 answers
133 views

Adjust left margin of list of algorithms

How can I adjust the left margin of the list of algorithms? What I have tried For the list of figures and tables, the left margin could be adjusted like explained in Adjusting left margin of LOT and ...
user avatar
  • 69
0 votes
2 answers
81 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
user avatar
  • 3
0 votes
0 answers
44 views

How to insert an algorithm in the blank space left after a paragraph?

I am writing an algorithm in latex, but I am not able to write it on the same page after a completion of paragraph.
user avatar
3 votes
1 answer
243 views

Is there a false loop in writing algorithms in IEEEtran?

The IEEEtran manual, suggests using algorithmicx.sty to write an algorithm and prohibits algorithm.sty: However, do not use the floating algorithm environment of algorithm.sty or algorithm2e.sty as ...
user avatar
  • 216
0 votes
1 answer
45 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{...
user avatar
0 votes
0 answers
23 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 ...
user avatar
  • 103
2 votes
0 answers
38 views

algorithm2e - If with multiple conditions and vlined option, preferably with Python style syntax

I am trying to use algorithm2e to write an algorithm which looks like so (made with Latex+Paint): Based on this Stack Exchange answer, I have attempted the following: \documentclass{article} \...
user avatar
  • 161
0 votes
0 answers
26 views

algorithm is not adapting to \baselinestretch?

The algorithm environment doesn't automatically adapt to renewing the \baselinestretch command like the tabular does. I would like the algorithm header and rules to match the line height similar to ...
user avatar
0 votes
2 answers
81 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}...
user avatar
  • 357
1 vote
0 answers
33 views

Customized Opening Single and Double Quotes for a yinit Lettrine

This post directly relates to egreg's answer given in size and alignment of quotation mark with lettrine The following code \RequirePackage{fix-cm} \documentclass{book} \usepackage{lettrine} \...
user avatar
  • 4,907
0 votes
0 answers
23 views

How to allow more width in algorithm

I am using the algorithm2e package, and I have an algorithm (shown in image) in which one line is split into two (namely, the assignment of alpha on line 21 goes over two lines). I would like to not ...
user avatar
0 votes
0 answers
41 views

Lack of understanding while writing algorithm in Latex

I'm having trouble writing this algorithm in Latex (exactly as it is in the picture below). I was searching for the best solution, but can't seem to find something that I understand. Can someone help ...
user avatar
  • 11
2 votes
1 answer
60 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 ...
user avatar
4 votes
1 answer
221 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 ...
user avatar
  • 157
1 vote
1 answer
60 views

Placing pseudocode between paragraphs

I am trying to re-write a line of an algorithm's pseudocode, and I would like to be able to present it in-text rather than introducing another floating algorithm environment. How can I do this? Here ...
user avatar
  • 113
0 votes
1 answer
29 views

How to override the numbers in an algorithm?

I have tried a few ways I found here, including This, and This, there are more but I can't remember them. The issue I'm having is I'd like "Fifth Instruction" to start on 5, I know "...
user avatar
1 vote
0 answers
53 views

String equality check [closed]

I want to compare 2 strings and perform different tasks based on their results(using if-else loop) My code is here: \tab• \hyperlink{new}{New Features, Enhancements, and Changes}\linebreak \begin{...
user avatar
  • 23
0 votes
1 answer
61 views

Align algorithm environment with text

I use these two packages: \usepackage[left=3cm, right=2cm, top=2cm, bottom=2cm]{geometry} \usepackage[ruled,linesnumbered]{algorithm2e} My algorithm margin does not align with the text; for example: ...
user avatar
  • 3
2 votes
1 answer
36 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]{...
user avatar
  • 507
1 vote
1 answer
43 views

Making Index Page Citations Bold without Obliterating "See{Another Indice}"

Previously, I had posted the question How to Display the Indice Page Numbers in Bold? and received a very fine answer, which has served me well. However, I have since discovered a conflict making ...
user avatar
  • 4,907
0 votes
1 answer
50 views

! Extra }, or forgotten $

What's wrong with following algorithm? \documentclass[journal]{IEEEtran} \usepackage{graphicx} \usepackage{subfigure} \usepackage{overpic} \usepackage{amsmath} \usepackage{flushend} \usepackage{...
user avatar
1 vote
1 answer
64 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 ...
user avatar
  • 499
3 votes
1 answer
82 views

Multiline math in Algorithm environment

I am wondering is there a way to have multiline math in an algorithm to prevent something like this: \documentclass{article} \usepackage[utf8]{inputenc} \usepackage[a4paper, total={6in, 8in}]{...
user avatar
  • 499
1 vote
1 answer
89 views

What is a more compact way to write multiple if/else statements

\documentclass{article} \usepackage[utf8]{inputenc} \usepackage{algorithm}% http://ctan.org/pkg/algorithm \usepackage{algpseudocode}% http://ctan.org/pkg/algorithmicx \usepackage[1,2,3,4]{pagesel} \...
user avatar
  • 113
2 votes
1 answer
71 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] ...
user avatar
  • 149
0 votes
0 answers
18 views

Ho to remove extra space between lines in algorithm

Hi i am writing algorithm and i noticed there is a free space in PDf between 7 12 lines you can see in gigure below. How to remove this here is my code \begin{algorithm}[H] \caption{Algorithm} ...
user avatar
  • 507
0 votes
0 answers
20 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 ...
user avatar

1
2 3 4 5
21