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.

830 questions
Filter by
Sorted by
Tagged with
15 views

How can I represent a block will be executed polynomial time with package algorithm?

I want to represent an algorithm where a subsection must be repeated polynomial time. I am using algorithm package. I want to represent something like: ... repeat polynomial time state 1 ...
22 views

Add footnote right after the algorithm environment

I have the following minimal example. I would like to add a footnote right after the end of the algorithm. Could you please guide me on how I can add a footnote to the bottom of this algorithm? Thank ...
10 views

Slide LaTEX error by algorithm block

I have \begin{frame}{Giải thuật 1} \begin{algorithm} \caption{Xây dựng với Chiến thuật Cắt tỉa LA}\label{alg:euclid} %\hspace*{\algorithmicindent} \textbf{Input} \\ %\hspace*{\algorithmicindent} \...
16 views

! Undefined control sequence. \Procedure

I follow http://shantoroy.com/latex/how-to-write-algorithm-in-latex/ and https://www.overleaf.com/read/rddymzwmnqgb I have \begin{algorithm} \caption{Put your caption here} \begin{algorithmic} ...
35 views

Highlight commands inside lstlisting algorithm

I'm writing an algorithm with lstlisting This is the output And this is the code: \begin{figure} \begin{lstlisting}[mathescape=true] INPUT: Insieme $C$ di cubi che coprono una funzione $f$ OUTPUT: ...
20 views

Algorithm exceeds page, short captionof form in TOC needed

I know this has been asked a couple of times, however the usual advices in using only the algorithmic environment without algorithm doesnt seem to work as i lose my algorithmn numbering and the short ...
26 views

58 views

How to change the font style (not the size but the style) of algorithimc package

I would like to change the font of the algorithm package. It's currently using serif and I would like to try either sans serif or typewritter font. I have tried to use the following code (which I ...
50 views

Error in algorithm: Missing \endcsname inserted

I am trying to write this algorithm in my latex file. However it comes with a compilation error: ! Missing \endcsname inserted. I have pin pointed the problem to be in the for loop and after ...
44 views

Undefined control sequence. \Begin in algorithmx package

I have installed and include the required packages but it still gives me the error. Here is my code: \usepackage{algorithm} \usepackage{algpseudocode} \begin{algorithm} \caption{Mesh Reader}\...
62 views

Algorithmicx Nested FOR loop in pseudocode

I have been trying to format the pseudocode below combining algorithmicx and algpseudocode commands as well as following another related post algorithmicx or algpseudocode custom command indentation ...
26 views

Incorrect indentation for the “end” word of a for loop

I'm writing a pseudo code in latex using algorithm package, however, I have problem with indentation of the last end word for the for-loop if this for-loop contains an if statement. If it doesn't ...
33 views

algorithmic package dont automatically break page when too long [duplicate]

I have an algorithm defined with algorithmc like this: \documentclass{article} \usepackage{algorithm} \usepackage{algorithmicx} \begin{document} \begin{algorithm} \begin{...
40 views

Pseudocode split into parts

I'm trying to write a block of pseudocode like here I know how to remove line numbers and get the black lines at the top and the bottom. I don't know how to label each section like 'Process' and '...
35 views

Using \cref for algorithm step

What \crefname do I provide for referring to a step of an algorithm (not the algorithm float itself!)? I am able to label the steps of an algorithm and refer them using \ref but how do I use \cref ...
74 views

TiKZ arrows and text inside of lslisting code

I have some lslistings code and I want to add some text and math elements as is shown in red color in the image below I tried using TiKZ but I got many errors. I'm attaching a MWE and thanks in ...
29 views

How can I make my Latex algorithm look like this? [duplicate]

I need one Algorithm with functions seperated by a line like this one.I really need this, thanks in advance. If you know another method that you think looks better, I would also appreciate your ...
38 views

Algorithm missing \state

I am writing this algorithm and this what I have as a result. The \for and \while ... doesn't appear. \usepackage{algorithm} \usepackage{algorithmic} \begin{algorithm} \caption{Calculate the exact ...
40 views

Code formating in LaTeX [duplicate]

Any suggestions on how to achieve a look for a code as seen in the picture? Maybe with "listings" or do I need to do it manualy? Thanks in advance!
42 views

Beamer citation footnote: Algorithm environment

Following up on this, I encounter a problem when using the algorithm environment. See the minimal working example below (mostly copied from an answer): Here, the algorithm environment simply treats ...
63 views

Indent at automatically generated line breaks is lost for long single statements in algorithm

MWE: \documentclass[11pt,a4paper,notitlepage]{report} \usepackage{amsmath} \usepackage{amsthm} \usepackage{amssymb} \usepackage{algorithm}% http://ctan.org/pkg/algorithms \usepackage{algpseudocode}% ...
326 views

How can I properly write this equation in Latex?

The equation is basically Bellman equation essential to the Q-learning algorithm. If there's any way to include the notes below (such as "New Q-Value") aswell that'd be even better!
98 views

Breakable algorithm

Can anyone help? I am using the code below for a breakable algorithm environment defined in the preamble. However, when I use this code with the template from https://github.com/kks32/phd-thesis-...
37 views

why algorithm appears like this?

I am trying to write algorithm but its not working. \usepackage[options ]{algorithm2e} \usepackage{amsmath} \usepackage{algorithm} \usepackage[noend]{algpseudocode} \begin{algorithm} \...
66 views

Algorithm writing in latex

How can I write this algorithm in left align latex of 2 column? I have tried this but its not working \textit{repeat till convergence} \begin{equation}\small \label{eq_04} { W_{i+1} = W_i - \...
59 views

LaTeX - Change the overall indentation of algorithms in a book

I am writing on a document that is formatted as a book (two pages with an indentation on the left side for even page numbers and on the right side for odd page numbers). \documentclass[10pt,twoside,...
93 views

How can I add comments in the following algorithm based on package algorithmic? \documentclass[10pt,conference]{IEEEtran} \IEEEoverridecommandlockouts \usepackage{cite} \usepackage{amsmath,...
34 views

algorithm with vertical line

i created the following algorithm but i am not satisfied with the output.So i was wondering is there a way to add vertical lines in my algorithm but also keep the same structure and be able to put it ...
544 views

TikZ/PGF draw algorithm

I have TikZ code that draws an ellipse. Here is the code that, AFAIK, draws the actual ellipse: \draw [rotate around={0.:(0.,0.)},line width=0.8pt] (0.,0.) ellipse (5.cm and 4.cm); Can anyone tell ...
54 views

My latex (algorithm2e ) algorithm did not fit on one page, how I can continue to the next page (without resetting the line number)

%%Here is my algorithm : \documentclass{article} \usepackage[linesnumbered,ruled,vlined,boxed,commentsnumbered]{algorithm2e} \newcommand{\forcond}{$i=0$ \KwTo $n$} \SetKwProg{Fn}{Function}{}{end}\...
77 views

remove space in the if statement

I would like to remove the spaces within my if statement, how can I do that? \documentclass[conference]{IEEEtran} \IEEEoverridecommandlockouts \usepackage{cite} \usepackage{amsmath,amssymb,...
34 views

How to put texts on a newline in an algorithm (in a nested for-loop)?

I am making an algorithm with a nested for loop, and there are multiple in the loop. They are presented on the same line, but I want them to start on a newline. Any ideas how I can do this? This is ...
75 views

Remove \Endif from algorithm

I want to write the following algorithm in LaTeX. The code I used is as follows: \documentclass{article} \usepackage{algorithm} \usepackage{algorithmic} %\usepackage{algpseudocode} %\algtext*{EndIf} ...
112 views

How do I write a simple if-elseif protocol in Latex?

I've tried using algorithm, algorithmic, etc.. but I can't seem to find what I need. I want something similar to this: This is the closest I got using tcolorbox and align: \begin{tcolorbox}[...
65 views

Error Message in Displaying Algorithm

I am writing a thesis, and there I have three files, one is main, another one is Chapter and the last one is a.tex. main.tex is using to call the chapter. I have written main algorithm in a.tex. So ...
356 views

Else If is not working on algorithm in algpseudocode

I tried to add \Else in my pseudocode using packages algorithm and algpseudocode but it is not showing and I am getting Missing number, treated as zero. This is my code and the current outcome. \...
96 views

How to format the algorithm

I have the text for the following algorithm, but I am unable to format it, with the numbers and spacing as in the image: $COVERABILITY-GRAPH((S,T,F,M_0))$\\ $(V,E,v_0):=(\{M_0\},\emptyset,M_0);$\\ ...
29 views

The algorithm does not execute in IEEE transaction template. Please help [duplicate]

\documentclass[journal]{IEEEtran} \usepackage[classicReIm]{kpfonts} \usepackage{booktabs,tabularx,lipsum} \usepackage{longtable} \usepackage{float} \usepackage{graphicx} \usepackage{subfigure} \...
114 views

How do I make d = function(x,y)

I am using the algorithm package and read it knowing there is \function to use. I want to make my output look like: Function d = dotproduct(x,y). How can I accomplish this? And this is what I ...
53 views

algorithm syntax in latex

I use latex for my thesis but my language is persian and I have to use xepersian package . recently I have a problem and when I use algorithm and algorithmic package , my algorithm'code become ...
34 views

Pseudocode in latex with fractions with text [duplicate]

So I´ trying to re-write this pseudocode in latex My pseudoce is like this: \begin{document} \begin{algorithm} \caption{Učící mechanismus obcí} \begin{algorithmic} \While {Obce ještě ...