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
0answers
42 views

Tree with lines in latex [duplicate]

How can i input this on latex? I tried but the space is too hard to input and also the line is hard to input \documentclass{article} \usepackage{bussproofs} \begin{document} \begin{prooftree} \AxiomC{...
0
votes
1answer
16 views

How can I reference to an Algorithm employed in figure environment in latex? When I'm using \ref{} , latex does not know its associated label

\documentclass[twocolumn]{autart} \usepackage{algpseudocode} \usepackage{algorithm} \usepackage{amsmath} \usepackage{graphicx} \begin{document} \begin{figure} \label{Fig1} \begin{...
1
vote
1answer
39 views

Adding keyword to a listing that matches exact instances [duplicate]

I want to add more keywords to a listing, however, I only want to match the exact instances of that new keyword, as the keyword sometimes happened to occur as part of normal words and it gets colored ...
2
votes
1answer
13 views

Algorithms in Elsevier's ifacconf.cls environment

The ifaccong.cls is located here https://www.ifac-control.org/events/resolveuid/b0e4734736878819db179d76290a8f78. How do I do algorithms in the ifacconf document class? Using algorithm2e package ...
2
votes
1answer
16 views

Algorithm not continuing to next page in IEEE Journal

I have a very long algorithm that takes more than a page in a double column format from an IEEE journal template. Instead of continuing to the next page, the algorithm pushes the text towards the ...
0
votes
0answers
22 views

Algorithmicx with standalone and subappendices doesn't compile

I configured my document in chapters that are self compilable. Each chapter is configured like this: \documentclass[crop=false,class=embedchap]{standalone} \begin{document} \begin{subappendices} ...
1
vote
0answers
18 views

Write long algorithms in IEEE with 2 columns and separate their content in both columns

I was wondering if anyone would know how to fix the problem that given a very long algorithm and a text that has to be defined in two columns, how could I make that when the end of the column is ...
1
vote
1answer
49 views

How to use procedure in latex algorithm?

%%%% ijcai21.tex \typeout{IJCAI--21 Instructions for Authors} % These are the instructions for authors for IJCAI-21. \documentclass{article} \pdfpagewidth=8.5in \pdfpageheight=11in % The file ...
3
votes
1answer
58 views

circle for each number in the algorithm

Is there an algorithm package that allows me to achieve the style of the algorithms where each number is inside a circle in an algorithm? I am interested specifically in the numbering of the steps by ...
0
votes
0answers
29 views

Writing pseudocode

Consider the following trivial pseudo-code that I am trying to execute while using \usepackage{algorithm} and \usepackage{algpseudocode} \begin{algorithm}[H] \caption{name} \begin{algorithmic}[...
4
votes
1answer
32 views

Itemize inside algorithm block Lonely \item error

\documentclass{article} \usepackage{algorithm} \usepackage{algorithmicx} \usepackage{algpseudocode}% \begin{document} \begin{algorithm} \State \textbf{Inputs:} \begin{itemize} \item Input ...
2
votes
1answer
26 views

Remove “end” in algorithm

I need to avoid showing end in line 10. It seems I miss using some packages \listfiles %\documentclass[12pt]{IEEEtran} %\documentclass[12pt,reqno]{thesis} \documentclass[12pt,reqno]{siugrad51} %\...
0
votes
1answer
44 views

How can I write an algorithm in latex or overleaf?

How can I write code like this in latex or overleaf?
0
votes
1answer
26 views

tufte-latex: Full-width algorithm2e blocks without minipage

I'm using an algorithm2e block in the tufte-latex book and I would like to try to make it full width. I know that the question has been asked here: tufte-latex: Full-width algorithm2e blocks but using ...
0
votes
0answers
11 views

In algorithmic Vertical loop/block lines not coming properly

In thesis writing (book), Some algorithms are perfectly shown the order of loops (vertical loop blocks). But one algorithm not showing well. Showing vertical loop line in inappropriate positions. \...
0
votes
0answers
12 views

Error using algorithm in LyX

I'm trying to insert Float -> Algorithm, but error occurs. it looks like I'm missing \endgroup, but I'm not sure how to fix it (pretty new to LyX). Preamble preview: %% LyX 2.3.1-1 created this ...
2
votes
2answers
24 views

Keep my algorithmic environment in one piece without using figure environment

I am working on a paper and I wish to use the algorithmic environment. The problem is, if I use the following code: \begin{algorithmic}[H] \label{alg1} \FOR{$-M_x<m_x<M_x$} \...
0
votes
1answer
33 views

Algorithm pseudocode is not executable in IEEE Transection Template. Snapshot of error is attached

\documentclass[journal]{IEEEtran} \usepackage[lined,boxed,ruled,commentsnumbered]{algorithm2e} \usepackage{algpseudocode} \begin{document} \begin{algorithm}%[H] \caption{%\textcolor{blue} {Pseudocode ...
1
vote
1answer
36 views

Problem with repeat in writing algorithm with Latex

I'm confused with my errors about using Repeat in algorithm, with other commands there is no problem but I cant use Repeat. My code: \begin{algorithm} \begin{LTR} \Repeat{$h=h+1$}{$h=5$} ...
0
votes
0answers
9 views

Algorithm in beamer class gives slew of errors, starting with outer par [duplicate]

Here is the minimum example: \documentclass{beamer} \usepackage[utf8]{inputenc} \usepackage{algpseudocode,algorithm,algorithmicx} \begin{document} \begin{frame}[fragile]{Sequential algorithm} \...
0
votes
0answers
39 views

How to apply adjustbox on an algorithm(2e)

I have a double page document and I wish to add an algorithm at a certain point. But if I just include the algorithm (of the algorithm2e package) then the text gets really bad since many lines of the ...
0
votes
0answers
14 views

algorithm with no ends but left thread [duplicate]

I like the noend option from algorithmicx because it makes the layout of the algorithm closer to the python syntax my students use. But to make it even clearer, i'd like to have left threads on the ...
2
votes
1answer
40 views

writing an algorithm using algorithm2e with the Comjnl.cls file of The Computer Journal?

How to write an algorithm in Latex using the Comjnl.cls file of The Computer Journal? The comjnl.cls defines algorithm environment such(line 347): \newtheorem{algorithm}{Algorithm} This clashes with ...
0
votes
0answers
47 views

Elegant way to break/continue out of a nested loop

When typesetting an algorithm, is there an elegant way to break/continue out of a nested loop. Something like how it is done in Rust. Any recommendations? \begin{algorithm} \texttt{'J:} \For{i = 1,......
1
vote
0answers
18 views

How can I reduce the the font size of algorithm title and index number?

I write some pseudo codes in Algorithm environment, how can I reduce the font size of algorithm's title and Index number? \begin{frame}{Proposal Algorithm} \begin{minipage}{.49\textwidth} \centering{\...
1
vote
0answers
39 views

Is there any tool/framework to convert R code into Latex?

I have a lot of code from R, and I'm working on a research project where I need to write down the pseudocode, is there any way to convert these codes into latex?
1
vote
1answer
48 views

algorithm caption size reduction in book document

I need to reduce my caption size to scriptsize in my algorithm. I couldn't find a proper answer to this. Here's a M. W. E of my code: \documentclass[12pt,a4paper]{book} \usepackage{algorithm} \...
1
vote
1answer
56 views

parallel block in algorithm overleaf

One part of my algorithm is done in parallel, for that, I have a block in my algorithm, but I can not show it properly. Can anybody help me to solve this problem? \usepackage[linesnumbered,lined,boxed,...
0
votes
0answers
17 views

replace the algorithm label when the algorithm can break the page boundary

I use the breakablealgorithm proposed by @Werner at Algorithm tag and page break to implement the algorithm that can break the page boundary. However, the label of the newly generate algorithm cannot ...
2
votes
2answers
44 views

Using a matrix as a parameter in an algorithm

I'm trying to write a pseudocode algorithm in LaTeX, where one of the functions needs to have matrices as a parameter. I need to get it to look like this: I've been using the algorithm package, but ...
2
votes
1answer
31 views

avoid line numbering in a algorithm when closing tcolorbox and adjustbox

when closing the tcolorbox and adjustbox inside an algorithm, the lines of codes corresponding to their commands are displayed numbered. How can I prevent the 1 beside the caption (see the below ...
1
vote
1answer
26 views

Algorithm: make loop lines appear below the words

I am using the algorithm environment and I do not know how to make the lines for the loops under the corresponding word, not where I have them now. Here is my code: \documentclass{article} \usepackage[...
0
votes
0answers
22 views

Can I let Latex autobreak my algorithm?

So I read this post Algorithm over 2 pages However I was wondering if there was a way to have Latex automatically break my algorithm up if it runs into the end of the page.
0
votes
1answer
44 views

Width of Algorithm

My problem is similar to this Adjust width of algorithm float However, I want to centre within an item in an enumerated list so I have indentation to the left, so the above Q/A does not centre within ...
1
vote
1answer
34 views

Making equation more compact in algorithmic and algorithm in double column

I am writing a pseudocode for algorithm under sty file aistats2021.sty using algorithmic and algorithm package. My question is how can I fit line 14 in one line? And here is the latex code. \...
1
vote
2answers
52 views

underfull hbox (badness 10000) warning and line breakage inside algorithm in two column page

I am trying to create a pseudocode for algorithm in a two column page but I am getting this warning of underfull hbox (badness 10000). Moreover, my lines are either getting broken with wide spacing ...
0
votes
0answers
30 views

How to break algpseudocode algorithms that are too long

The post Vertical lines in algpseudocode shows how to add vertical lines for the blocks of code. But, how does one break algpseudocode algorithms that are too long for one page to still have the same ...
1
vote
0answers
18 views

Citing Lines in Algorithm [closed]

In case I have algorithm written in LaTex, how to cite lines from that algorithm? For example, Lines 3-10 in the algorithm explains... Thanks.
1
vote
1answer
29 views

Algorithm in `oframed` environment

\usepackage[ruled,vlined]{algorithm2e} \usepackage{framed} \setlength\FrameSep{5mm} \begin{document} \begin{oframed} Some text... \begin{center} \begin{algorithm} ...
1
vote
1answer
36 views

How can I reduce the font size of an algorithm?

I want to reduce the font size of my algorithm in this code: \begin{small} \medskip \begin{lstlisting}[language=Java,escapechar=|,caption= loop main] for (double x = 1 + 1; x <= 2 - 1; x++) { } ...
0
votes
0answers
39 views

Splitting Long Algorithm on two pages

I am formatting my thesis. During formatting, I am facing a problem as to how to split a long algorithm into two pages. Below is the dummy algo code. I have given all the packages used in the thesis ...
0
votes
0answers
38 views

pseudocode Environment in Latex

I am trying to write the below algorithm in Latex but failed to get the symbols which are highlighted in red. Does latex support this symbol or I am making a mistake in the script? Example script: \...
2
votes
1answer
32 views

Custom text instead of line numbers with algpseudocode package

Instead of printing 1:, 2:,.. I want to print Step 1:, Step 2:,.. at the beginning of each line. Here is my code: \usepackage{algorithm} \usepackage{algpseudocode} \begin{document} \begin{algorithm} ...
0
votes
0answers
45 views

LaTeX listing package Pseudocode with Syntax Highlighting

I am trying to use listings package for writing algorithm. I have used algorithm2e but its hard and i cannot customize it specially the fonts. I am following this stackexchange answer: \documentclass{...
0
votes
0answers
19 views

Pagebreak in an algorithm using algstore/algrestore

I'm trying to use algstore/algrestore to split an algorithm over two pages. However, I would like to not insert a title in the split portion of the algorithm, similar to what is shown here. My only ...
3
votes
1answer
63 views

Highlight Lines in side-by-side algorithm

I have a 2 column latex template (IEEEtran), in which I put 2 algorithms side by side: \documentclass[10pt,conference]{article} \usepackage{algorithm} \usepackage{algorithmic} \usepackage{xcolor} \def\...
2
votes
1answer
37 views

How to stop lines of an algorithm from jumping up and down

I have the following code to walk though the lines of an algorithm: \documentclass{beamer} \usetheme{default} \usepackage[]{algorithm2e} \def\HiLi{\leavevmode\rlap{\hbox to \hsize{\color{yellow!50}\...
1
vote
1answer
45 views

algorithms in margin of tufte style book?

I would like to place an algorithm in the margin of a tufte style book. I am using algorithm2e. I have no idea how to do this, or if it is possible at all. Please help? Here is an example but it place ...
1
vote
1answer
30 views

Algorithm sub-numbering but not based on sections using algorithmicx

I'm writing a paper where I try to update an algorithm to improve its performance. I want the original algorithm to be numbered "Algorithm 2" and the improvements should then be "...
2
votes
1answer
48 views

How does the assignment proceed in this iteration (TeX)?

In the famous The TeXbook (Twentieth printing, revised, May 1991), I've found this algorithm (Appendix D: Dirty Tricks, pag. 373), \newcount\m \newtoks\t \m=\n \t={} \loop \ifnum\m>0 \t=\...

1
2 3 4 5
19