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
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 ...
0
votes
1answer
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 ...
0
votes
0answers
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} \...
0
votes
1answer
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}[1] ...
0
votes
1answer
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: ...
0
votes
0answers
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 ...
0
votes
1answer
26 views

Problem with For (or ForAll) loop in algorithm/algpseudocode: missing $ inserted

I currently have a problem I can't resolve. Here is my code : \begin{algorithm} \caption{Feedback system} \begin{algorithmic}[1] \State $expert$: object describing the expert (name, laterality and ...
1
vote
1answer
29 views

Defining a new block with two parts in algorithm2e

I'm trying to define a new keyword Let ... In ... End for my algorithm, it has two parts, like the keyword Let in this algorithm: I have tried to define a block, but I found that only the stuffs like ...
2
votes
1answer
35 views

How to fix an issue about multiple output lines in algorithm

When I write a pseudo code using algorithm and algorithmic. Output statement overflow a line like below. \begin{algorithm}[!h] \textbf{Input:} The set of public $parameters$\\ \textbf{Output:} ...
1
vote
1answer
40 views

How do I show an example of a file in latex?

I need to write an example of a file format. I want to do something like this: The text inside the square is something I'll write inside latex and represents how a certain kind of file is made, it's ...
2
votes
1answer
35 views

Undo page number alignment and remove dots from list of algorithms

I am using the classicthesis theme and I am trying to make my list of algorithms the same format as my lists of tables and figures. I am using the algorithm2e package. Here is how it looks at the ...
1
vote
1answer
33 views

Algorithm errors and bad math environment delimiter

I'm struggling a lot in writing the pseudo-codes in latex. Please review below two algorithms. In the document, the algorithms do look good apart from the highlighted part in the picture. \begin{...
0
votes
1answer
35 views

Algorithm in IEEE journal

Here is the template I use for the following journal. The algorithm is perfect in regular latex document as can be seen in: . I have problems with all the algorithm when inserting it to the template. ...
1
vote
1answer
60 views

Algorithm size adjustment in multi column

I'm facing following issues, 1) That algorithm is going out the page 2) I want to use \mathcal but it is not showing exactly as it is.... 3) IF I used these > < signs with $ but it gives ...
3
votes
1answer
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 ...
0
votes
1answer
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 ...
1
vote
1answer
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}\...
2
votes
1answer
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 ...
0
votes
1answer
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 ...
1
vote
1answer
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{...
0
votes
0answers
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 '...
0
votes
1answer
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 ...
3
votes
1answer
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 ...
0
votes
0answers
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 ...
0
votes
1answer
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 ...
0
votes
0answers
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!
0
votes
1answer
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 ...
1
vote
1answer
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}% ...
4
votes
2answers
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!
0
votes
0answers
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-...
0
votes
1answer
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} \...
3
votes
1answer
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 - \...
2
votes
1answer
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,...
2
votes
2answers
93 views

How to add comment in algorithm

How can I add comments in the following algorithm based on package algorithmic? \documentclass[10pt,conference]{IEEEtran} \IEEEoverridecommandlockouts \usepackage{cite} \usepackage{amsmath,...
0
votes
0answers
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 ...
8
votes
2answers
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 ...
0
votes
0answers
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}\...
1
vote
1answer
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,...
2
votes
1answer
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 ...
1
vote
1answer
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} ...
3
votes
2answers
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}[...
1
vote
1answer
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 ...
2
votes
2answers
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. \...
1
vote
2answers
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);$\\ ...
0
votes
0answers
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} \...
1
vote
1answer
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 ...
1
vote
1answer
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 ...
0
votes
0answers
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}[1] \While {Obce ještě ...
1
vote
0answers
66 views

latex pseudocode with fractions

I´trying to write this pseudocode in Overleaf - cant do the fraction (line 15) \begin{algorithm} \caption{Učící mechanismus obcí} \begin{algorithmic}[1] \While {Obce ještě nedokonvergovaly} \State $...
0
votes
1answer
71 views

How to keep whitepaces between words in algorithm

I am new to LaTeX. When I tried to write an algorithm all spaces between words get removed after \gets. See the image. \begin{algorithm} \caption{Filtering lexicon file} \label{algo1} \begin{...