Skip to main content

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
0 votes
0 answers
19 views

I want to split the algorithm to other column (in this case, the column of the next page). The format is a 2 page column

My code is: \State \textbf{Initialize: }$n_{ch,IA} \gets false$, $n_{ch,DA} \gets false$, $reached_{IA} \gets false$, $w_{n_{ch,IA}} \gets false$, $w_{r_{low,IA}} \gets false$, $v_{red,computed} \gets ...
pal_jsr's user avatar
0 votes
0 answers
20 views

How to make an algorithm box smaller inside a figure environment?

I have following code for an algorithm block: \usepackage{algorithm} \usepackage{algorithmicx} \usepackage{algpseudocode} \usepackage{enumitem} \usepackage{minibox} \usepackage{multirow} \usepackage{...
ranaya's user avatar
  • 1
2 votes
1 answer
89 views

Is there a way for me to scale a custom environment I made in LaTeX?

I've created the following new environments and I want to be able to scale the output of the big algorithm environment and control the width of the mini algorithm environment (or having two mini ...
Nate3384's user avatar
  • 197
-1 votes
1 answer
29 views

How to format decision problems for algorithms?

I am aware there are several excellent packages in CTAN for typesetting algorithms. However, I often need to first describe the problem the algorithm is solving, and I can't seem to find apackage that ...
Luke's user avatar
  • 1
2 votes
0 answers
69 views

What package can allow me to typeset code and pseudocode in the following way?

I'm using algorithm and algpseudocode and I get nice results but I want to have in a single environment multiple algorithms/codes in the following way: instead of having 2 different environments, I ...
Nate3384's user avatar
  • 197
2 votes
1 answer
85 views

Algorithm in Beamer

\documentclass{beamer} \mode<presentation> { \usetheme{Warsaw} \usecolortheme{beaver} } \usepackage{algpseudocode} \usepackage{amsmath} \usepackage{amssymb} \usepackage{alphabeta} \usepackage[...
MacTavish's user avatar
  • 115
1 vote
1 answer
24 views

Algorithm enviroment and verbatim font

I try to properly structure my homework and my teacher is using algorithm environment for PL/SQL language (example below). The thing is when I'm using this environment the font is not the same. How ...
gaby8gaby's user avatar
1 vote
1 answer
26 views

Text in math environment in algorithm2e has different typography when placed inside a for loop

The following MWE: % Created 2016-07-04 Mon 15:02 \documentclass[a4paper, 12pt]{article} \usepackage[T1]{fontenc} \usepackage{amsmath} \usepackage{amssymb} \usepackage{mathtools, nccmath} \usepackage[...
JKHA's user avatar
  • 537
1 vote
1 answer
29 views

Strange interaction between subfigure and algorithm within minipage

Consider the following code, whose purpose is to place a subfigure and algorithm side by side within a floating figure. \documentclass{article} \usepackage{algorithm} \usepackage{subcaption} \begin{...
jII's user avatar
  • 511
1 vote
1 answer
39 views

How to fix numbering of an algorithm in algorithmc and algorithm environment?

I have some pseudocode for an algorithm, which appears okay (with some minor errors in compilation). But the biggest problem is that the numbering of the steps does not match the number of steps in ...
underdog987's user avatar
2 votes
1 answer
70 views

Remove \If and only have "do" in algortihm

I have the following code for an algorithm: \documentclass{article} \usepackage{graphicx} \usepackage{algorithm} \usepackage{algpseudocode} \usepackage{amsmath} \begin{document} \begin{algorithm} \...
nflgreaternba's user avatar
0 votes
1 answer
74 views

Using tcolorbox within an algorithm Environment

I want to have a colored box within an algorithm environment. I use tcolorbox within an algorithm environment. The result is shown below. I use the before skip balanced=-0.075cm and after skip ...
Hosein Rahnama's user avatar
0 votes
0 answers
35 views

When using scalebox to fit my algorithm in one page a random number appears

Here's the code: \begin{algorithm}[h!] \scalebox{0.85}{ \begin{minipage}{1.1\linewidth} \caption{Inferir relação} \SetAlgoLined \DontPrintSemicolon \begin{algorithmic}[1] \Objetivo \Desc{Procura o ...
Scipio's user avatar
  • 209
0 votes
0 answers
20 views

How to make “algorithm” environment split in pages and change the environment name from “Algorithm 1” to “Method 1” at same time?

the first part of my question is solved by put this code \newenvironment{breakablealgorithm} {% \begin{breakablealgorithm} \begin{center} \refstepcounter{algorithm}% New algorithm \...
yianyian5's user avatar
-1 votes
1 answer
49 views

How is this style of pseudocode written in latex?

I want to create an algorithm using the algorithm package. 2]2
E.S.A.Mohammed's user avatar
2 votes
1 answer
98 views

How can I use accents (like tilde) in the keywords of an algorithm?

Here's my code in algoritmo.tex: Foi usado o algoritmo 1 em MATLAB para resolver o problema $\mathop{min}_{x \in\mathbb{R}^{n}} f(x)$. \begin{algorithm} \caption{Método da Região de Confiança ...
Scipio's user avatar
  • 209
5 votes
1 answer
860 views

How is this kind of pseudocode written in latex?

It doesn't seem to be formatted using instructions from the usual algorithm libraries of Latex. It seems to be simply formatted text, I am uncertain.
Rte's user avatar
  • 67
3 votes
1 answer
63 views

ELSE if block after if statement on overleaf throws error

I want to implement a if else block like that if A if B if C else if D end if E end end end Where if C and if E has same indentation. if B under if A. if C and if E both are ...
Encipher's user avatar
  • 548
0 votes
0 answers
33 views

Continue the numbering of theorems in algorithm environments

I'm using the thmtools package to get theorem like environments where the theorem numbering is of the form SECTION.THEOREMNUMBER: \declaretheorem[numberwithin = chapter]{theorem} \declaretheorem[...
0xbadf00d's user avatar
  • 533
0 votes
0 answers
9 views

Cannot format list of algorithms using titletoc with algorithms package [duplicate]

I am not sure what I am doing wrong, but I cannot get the titletoc formatting to work on my list of algorithms. I am using algorithm and algpseudocode, not algorithm2e. In the following, just as an ...
tgkolda's user avatar
  • 758
3 votes
2 answers
622 views

Splitting a Really Long Algorithm in Two Pages

I have this algorithm, which as you can see is too long to fit into one a4 paper. I have used the solution in here, but there was an error telling me that \AND, \OR, and \TO are undefined. I would ...
mali1234's user avatar
  • 135
0 votes
0 answers
45 views

Latex Pseudocode missing number cannot resolve

\begin{algorithm} \caption{LexBFS Algorithm} \begin{algorithmic}[1] \Function{LexBFS}{$G=(V, E)$} \State Let $P$ be an empty list \Comment{Initialize the permutation} \State Let $Q$ be an empty queue \...
n.y's user avatar
  • 1
0 votes
1 answer
96 views

Correct usage of display math inside algorithm with algpseudocode based package. Alignment and spacing problems

I am learning how to use Algpseudocodex which is an enhanced version of algpseudocode I am having hard time with getting correct spacing around \begin{align*}...\end{align*} when using inside the ...
Nasser's user avatar
  • 20.5k
0 votes
1 answer
98 views

How to reference an algorithm within an algorithm [closed]

I have two algorithms, algorithm 2 depends on algorithm 1. I would like to reference algorithm 1 at the beginning of algorithm 2, writing something of the form Get H from algorithm 1 And then continue ...
Donna Schweitzer's user avatar
0 votes
1 answer
39 views

create vertical brackets that span over several rows

I just came across a snipet of codes where a long vertical bracket is used to mark a loop. I really like that. I wonder what is the best way to implement this in latex? Thanks
underflow's user avatar
  • 653
0 votes
0 answers
52 views

How can the following block scheme be made?

My university is asking for a specification of an algorithm and provided this block scheme as an example. I an not very good at latex so I googled how to do this with tikz, but did not found something ...
Sunfline's user avatar
0 votes
2 answers
58 views

Algpseudocode, for-next loop: control variable in next line

In this pseudo-code excerpt, is it feasible to add a new argument for the variable v with a syntax like \ForAll {$v$}{$v \in V(G)$} to get the output next v? \documentclass{article} \usepackage{...
Jh0an1 Uzca73gu1's user avatar
3 votes
1 answer
85 views

How do I add an extra description row under the name of algorithm?

The following image is my goal. You can see there is a row to describe the parameters of Algorithm1. I wonder how to add rows like this. And I also wonder how to add the description of the following ...
Yang's user avatar
  • 33
0 votes
1 answer
159 views

Wrap text around pseudocode without overlap with other text

I'm looking to have pseudocode in my document placed nicely by LaTeX (ie. no exiting bounding box, no overlapping other text, etc.), while having text wrap around the pseudocode (as the width of text ...
user760900's user avatar
1 vote
1 answer
223 views

Undefined control sequence when using algorithm environment with dgruyter.sty

I need to write a document using the dgruyter template. When I include an algorithm environment I get the following error. Undefined control sequence. <write> ...\protect \numberline {\plist@...
Alex bGoode's user avatar
1 vote
1 answer
540 views

"Not in outer par mode" error when using Algorithm inside minipage

I am trying to place a figure and an algorithm side-by-side using minipage. Hee is the code for the algorithm part. However, I am getting an error LaTeX Error: Not in outer par mode. on the line \...
Siladittya's user avatar
2 votes
1 answer
109 views

I'm having a problem with sentences breaking when writing input and output in a latex algorithm

In my algorithm, I wrote input and output as follows. \begin{algorithm}[htb!] \caption{Data Preprocessing} \label{alg:data_preprocessing} \textbf{Input} input data \\ \textbf{...
Tim's user avatar
  • 21
0 votes
1 answer
53 views

Use standard algorithm padding for custom algorithm environment

This is a follow-up question to: https://tex.stackexchange.com/a/33869/173478 The breakablealgorithm environment, as proposed by Werner, splits algorithms perfectly. However, for me the breakable ...
Lucas Aschenbach's user avatar
0 votes
1 answer
46 views

How to write an algorithm like under figure in latex?

How to write an algorithm like under figure in latex? I executed this cod, but the output of the algorithm was not like the above figure \usepackage[options ]{algorithm2e} \begin{algorithm}‎ \...
Yas's user avatar
  • 13
0 votes
0 answers
57 views

How can I split the algorithm into two pages?

How can I have the algorithm not break in the next page and rather split this into two pages? \usepackage[ruled,german,linesnumbered]{algorithm2e} % Pseudocode \newcommand{\SkipBeforeAndAfter}{\vspace{...
Renxian's user avatar
  • 61
1 vote
0 answers
54 views

Merge two algorithms style in the same file

Is it possible to put the two following algorithms in the same file. I tried several times but I did not succeed. Thanks for your help. \documentclass{article} \usepackage[T1]{fontenc} \usepackage{...
Nehme's user avatar
  • 63
0 votes
0 answers
56 views

Properly use algorithm environment in latex/ overleaf

I am working with my old latex code, which at the time worked but now the output seems unexpected. I am using the following packages: \usepackage{algorithm} \usepackage{algpseudocode} \usepackage{...
Azerbijanargh's user avatar
2 votes
1 answer
96 views

Algorithm caption color background

I tried to modify my algorithm caption in order to fill it gray. However, there is some white space left. Has anyone an idea what the problem is? \documentclass{article} \usepackage{graphicx} % ...
Marcel's user avatar
  • 23
0 votes
1 answer
32 views

if else loops and repeat until loops doesn't work with algorithm package

code: \begin{algorithm}[!t] \begin{algorithmic}[1] \caption{Adaptive Random Search}\label{algo_ARS} \State define the probability of local search as $P_s$ and global search as 1 - $P_s$ \Repeat ...
Rolphnol's user avatar
0 votes
1 answer
98 views

How to restate an algorithm with the same algorithm number?

I'm trying to have two copies of the same algorithm, with the same number twice in a paper. The restatable environment is able to reproduce the algorithm but introduces a new algorithm number each ...
Zuza's user avatar
  • 103
1 vote
1 answer
86 views

How to manually (further) indent an `if` statement in `algorithm`

For example, I would like to further indent an if-then-else block like is done in this question. \documentclass{article} \usepackage{algpseudocode} \usepackage{algorithm} \begin{document} \begin{...
rrrrr's user avatar
  • 513
0 votes
0 answers
105 views

Package algorithmicx Error: Some stored algorithms are not restored!

I am using these two package: \usepackage{algorithm} and \usepackage{algpseudocode}. This is my latex code and I am using overleaf: \documentclass{article} \usepackage{graphicx} % Required for ...
j.doe's user avatar
  • 131
0 votes
1 answer
42 views

how to fix the issue in pseudo code algorithms with multiple precedures in latex?

I am formetting pseudo code algorithms with multiple procedures in it, but formatting has somes issues such as endProcedure=0in latex output though. How can I fix this? thanks my current script \...
kim's user avatar
  • 103
0 votes
0 answers
67 views

Overfull \hbox problem in Algorithm caption of ACM template

I faced a problem that my overleaf report that 'Overfull \hbox (8.5pt too wide) in paragraph at lines 92--92' I used 'algorithm2e' package for ACM template. Here is the test demo I used: \...
yuyang sun's user avatar
0 votes
1 answer
88 views

Algorithms not being numbered correctly [closed]

I am trying to include some algorithms in an IEEE paper and the algorithms are not being numbered properly. I'm new to Latex and have never used it before. I want to number it as Algorithm 1 and ...
Saish Kalbag's user avatar
1 vote
1 answer
58 views

Multilingual typesetting with polyglossia results in Inverted Parentheses using algorithmic+algpsuedocode

I am attempting to compile an article using the XeTex engine. In my document I've used the algorithmic and algpsuedocode packages in order to describe an algorithm. Also, the document is meant to ...
ch0wner's user avatar
  • 113
3 votes
1 answer
66 views

Add multiple footnotes with hyperlinks to `algpseudocode` algorithm

I use the algpseudocode package to write algorithms, and the hyperref package to add hyperlinks to footnotes. I want to be be able to add footnotes with hyperlinks within my algorithms. Something like ...
JEdwards's user avatar
1 vote
0 answers
416 views

How to write pseudocode in LaTeX in Google Colab

I want to render in my colab some pseudocode, say: \documentclass{article} \usepackage{algorithm} \usepackage{algpseudocode} \begin{document} \begin{algorithm}[H] \caption{A simple algorithm} \begin{...
mCs's user avatar
  • 11
0 votes
1 answer
68 views

List of Algorithms with toptesi

I am using the algorithm package to create a list of algorithms in my thesis written with toptesi by Claudio Beccari. However, I am having trouble including the list of algorithms in the table of ...
poipoi's user avatar
  • 3
1 vote
1 answer
29 views

Increasing algorithm number width in ToC coming from appendix

I want to increase algorithm number width coming from appendix. MWE: \documentclass{report} \usepackage{amsmath} \usepackage{algorithm} \usepackage{algorithmic} \numberwithin{algorithm}{chapter} %\...
Bahman Mirzakhani's user avatar

1
2 3 4 5
24