Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

0
votes
0answers
53 views

How to improve this without using “exotic” packages? [on hold]

How could I improve this without using "exotic" packages as I am not allowed to use any other than given in the template the professor gave us: \begin{itemize} \item[] \textbf{Input:} objective ...
3
votes
2answers
239 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
27 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
33 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
50 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
36 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
54 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
21 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 ...
9
votes
2answers
470 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
18 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
28 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,...
0
votes
0answers
24 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
24 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
101 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
41 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
57 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
32 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
23 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} \...
0
votes
1answer
80 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 ...
0
votes
0answers
21 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
30 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
51 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
39 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{...
0
votes
0answers
53 views

How to cite algorithms?

\documentclass{article} \usepackage[utf8]{inputenc} \usepackage{latexsym} \usepackage[linesnumbered,ruled,vlined]{algorithm2e} \SetCommentSty{mycommfont} \usepackage[linkbordercolor={0 0 1}]{...
0
votes
0answers
13 views

Start numbering Algorithm [duplicate]

Usually, in a document the algorithms numbering start: First algorithm Algorithm 1 Second algorithm Algorithm 2 and so on Is there a way to start numbering algorithms from a different number ...
0
votes
1answer
45 views

Representing Objects/Classes in Latex

I was curious... I couldn't find this in any of the documentation of the algorithm2e and algorithmicx packages. I'm wondering if there's a way to represent objects with attributes in LaTeX. Would help ...
2
votes
1answer
55 views

Pseudocode in latex cannot be formated

I´m writting my work and for some reasone my pseudocode in final pdf cannot be formated: Mistake report is this: The code I'm using: \documentclass[11pt,a4paper,openright]{report} \let\openright=\...
0
votes
0answers
31 views

What is the reason of extra '=0' [duplicate]

I know the reason is the incompatibility of the packages, but I tried all the possibilities and I couldn't reach to the point of removing '=0' without changing the algorithm style I want. . \...
0
votes
1answer
21 views

How do I get rid of the commands (for, do, if …) in Algorithmic?

I am writing a paper in LATEX like the picture. I tried many times but there I haven't yet shown the way to do them. I tried to type this example with Algorithm but it can not. Could you say to me ...
0
votes
0answers
13 views

How to include algorithm in JFM template

I'm writing with the template offered by the Journal of Fluid Mechanics, downloadable here. I'm wondering how can an algorithm be added into the paper. I tried to use the \usepackage{algorithm} but it ...
0
votes
1answer
37 views

I want to write an algorithm in overleaf, but it comes up with errors [duplicate]

\begin{document} \usepackage{savesym} \usepackage{program} \savesymbol{AND} \savesymbol{OR} \savesymbol{NOT} \savesymbol{TO} \savesymbol{COMMENT} \savesymbol{BODY} \savesymbol{IF} \savesymbol{ELSE} \...
3
votes
1answer
170 views

Is it possible to draw vertical lines in algorithm (not algorithm2e) package?

My question is if it is possible to draw vertical lines in the algorithm package. I have seen the following question: Vertical line for pseudo code But I don't want to use algorithm2e because it ...
0
votes
0answers
30 views

algorithm float environment

I would like to put 2 algorithms next to each other. I followed several suggestions and I ended up with something like: \begin{figure*}[ttt!] \begin{minipage}[t]{.38\linewidth} \begin{algorithm}...
0
votes
1answer
31 views

How to align horizontally line numbers with package algorithm2e

I'm trying to write an algorithm using the package algorithm2e. This is my code: \usepackage[linesnumbered,ruled]{algorithm2e} ... {\footnotesize \IncMargin{1em} \begin{algorithm}[H] \...
5
votes
2answers
233 views

How can I put a period right after the algorithm's number in the algorithm's title?

I wish it said "Algorithm 1.", with a period after the number, and not just "Algorithm 1". It's how I see most people using it, so I must be using an unconventional package? Would you say I should ...
1
vote
1answer
35 views

Align comment in algorithm to the end of the line

Here is my algorithm:: As can be seen the comment is aligned to the right end of the line. I would like to align the comment to the end of the same line. At the exact place where the line ends I ...
0
votes
1answer
276 views

Algorithm: ELSEIF problem

I want to compile this code in Latex (shown below). I use three libraries. I especially need elseif and \state command and line number. LaTeX Error: Command \algorithmicindent already defined.Or ...
0
votes
1answer
90 views

how to write the algorithm in latex

My code is below, I didn't find the error. \begin{algorithm}[H] \SetAlgoLined \textbf{Input} :$x_{k-1}$,$P_{k-1}$,$u_{k}$,$z_{k}$\; \textbf{Output} : $x_{k}^{-}$,$P_{k}^{-}$ \\~\\ $x_{k+1}={\Phi{x}}...
1
vote
1answer
47 views

How to have a space between algorithm lines

I have an algorithm and I would like to insert space between its steps. Here is my try: \documentclass[12pt,a4paper,openright]{report} \usepackage{amsmath} \usepackage{amssymb} \usepackage{...
2
votes
2answers
1k views

How to write algorithm like this in latex

I want to write an algorithm in a latex. There are various ways to write, but I want to write in the way given below. I have tried but I am not able to do anything similar to the given in the image. ...
1
vote
1answer
51 views

Add colon after algorithm caption/number in IEEE transactions

I am using Overleaf to write an article in IEEE transactions template. I wish to write the caption of Algorithm as, Algorithm 4: (as shown in the picture below). But when I use my code, it shows ...
0
votes
1answer
47 views

An error in inserting pseudo code in LaTeX

I want to insert a simple pseudo code as follows, but I confront with an error and I am not able to resolve it. \documentclass{article} \usepackage{algpseudocode} \usepackage{algorithm} \usepackage{...
3
votes
1answer
149 views

How to zoom in in beamer algorithm package?

I will be using the beamer class for my presentation. I want to present the algorithm line by line in such a way that the line on which I am working should get zoomed or lensed or highlighted. See my ...
0
votes
1answer
79 views

How to compress algorithm in a beamer presentation?

I have written one algorithm in a beamer class by using a package \usepackage[linesnumbered, ruled,vlined]{algorithm2e}. It is taking the whole slide, I have tried to fit it into a small minpage but ...
1
vote
0answers
77 views

IEEE Algorithms in figure environment caption should read Algorithm

I need to write some pseudocode and am using the IEEE template. However, the guidelines say that algorithmic should be contained in a figure environment and that I am not supposed to use the algorithm ...
0
votes
0answers
136 views

Formatting pseudo-code Algorithm

I need to write the algorithm as formatted in the word. I need to insert initiate statement without taking any numbers, format symbols bold to indicate matrix, change the comments font and change ...
1
vote
1answer
200 views

Lonely \item - perhaps a missing list environment, missing package?

I'm trying to implement some pseudocode in my LaTeX document but I keep getting the following error: Lonely item, perhaps a missing list enviroment. The packages I'm using are: \usepackage[utf8]{...
1
vote
1answer
145 views

Algorithm returning 0

I wrote algorithms using the algorithm and algorithmic packages, but I always get the last line returning 0. I tried to use this solution, but I could not make it work. Below my algorithm code and ...
2
votes
1answer
42 views

cannot insert comments in latex algorithm

I cannot insert comments using the \comment{} annotation, here is my code below: \documentclass[conference]{IEEEtran} \IEEEoverridecommandlockouts \usepackage{cite} \usepackage{amsmath,amssymb,...
2
votes
1answer
75 views

how to remove spaces from algorithm and align nicely algorithm

I want to remove the spaces between the "and" and the if clauses in the following code: \documentclass[conference]{IEEEtran} \IEEEoverridecommandlockouts \usepackage{cite} \usepackage{...