We’re rewarding the question askers & reputations are being recalculated! Read more.

Questions tagged [algorithmic]

algorithmic is an environment for typesetting {algorithms}.

Filter by
Sorted by
Tagged with
1
vote
0answers
356 views

Fixing position for Algorithm2e does not work

I have the following minimal example. When I compile this, the result is fine, as expected. \documentclass[ngerman,12pt,a4paper]{report} \usepackage[left=2cm,right=2cm]{geometry} \usepackage{...
2
votes
2answers
917 views

Adding leftmargin to algorithmic

How do I set the left margin of an algorithm typeset with algorithmic so that the whole thing moves to the right? I've tried changing \leftmargin inside an algorithmic block, but it did not work. ...
1
vote
1answer
215 views

Using `\State` inside `beamercolorbox` causes error Missing \endcsname inserted

I have a frame in my beamer presentation. Inside a frame I have an algorithmic in a minipage. Inside that algorithmic I have the following to highlight an ares in the algorithm. \documentclass[11pt]{...
3
votes
1answer
3k views

Undefined control sequence \Elsif

The below code is giving me the error: "Undefined control sequence.l.36 \Elsif {$ -3 <=$ polarity of $car_dictionary[fd] < -2 $}:" in multiple else if case in latex. Please help me ...
7
votes
2answers
2k views

How to indent a long sentence in an algorithm

In this algorithm format I want the the "Considering the jth...." to be having the same indentation throughout even in newline. The Code is as follows: \documentclass{article} \usepackage{amsmath} \...
4
votes
0answers
123 views

LyX: Can't compile with \usepackage{algpseudocode} with Language that isn't English

I'm pretty new to LyX and Latex. I'm writing a paper in Hebrew and I want to add an algorithm in English. So I'm adding \usepackage{algpseudocode} to the Preamble and pasting some example algorithm. ...
3
votes
1answer
944 views

Place comment after while statement in algorithmic

I am having some trouble placing plain text in my algorithm using the algorithmic package. The problem only seems to occur after a '\WHILE' command. I need to start my 'while' loop, then immediately ...
1
vote
1answer
367 views

Insert indent in algorithm at line break of the same \State

I have the following code: \documentclass[12pt,a4paper,twoside]{book} \usepackage{graphicx} \usepackage{algorithm} \usepackage{algpseudocode} \begin{document} \begin{algorithm*}[t!] \caption{...
2
votes
1answer
756 views

Why are vertical rules dashed sometimes with algorithmic package?

I would like to create vertical rules for indentation with algorithmic package. I applied the solution proposed here How can I create vertical lines indentation in algorithm pseudo code correctly ...
1
vote
1answer
372 views

If algorithm in Latex

I want to create a simple algorithm in my latex document. I have a variable which comes to my latex template from the web-form it can have just two values "yes" or "no", so in case if this value "yes" ...
1
vote
0answers
96 views

Is there a way to include an algorithm from external file?

I mean: when I put some code in my docs I can include it whitout writing all code in main document. Is there a similar thing for algorithm?
0
votes
1answer
521 views

Wrong number when reference inside algorithm

\usepackage{algorithm} \usepackage{algorithmic} \begin{algorithm}[tb] \caption{Algorithm} \label{alg} \begin{algorithmic}[1] \STATE blalblabla \label{cond1} \STATE ...
3
votes
1answer
399 views

Adding comment in same line and without sign

I use the following: \documentclass{article} \usepackage{algpseudocode} \usepackage{algorithm} \usepackage{textcomp} \usepackage{mathtools} \date{\today} \title{Some Title} \begin{document} \...
1
vote
1answer
837 views

Algorithmic package in two different languages in same document

I need to write both in French and English in my document (for reasons). And I need to write algorithms in both languages, using the algorithmic package. Is it possible ? If so, how can I do that ? ...
1
vote
1answer
924 views

Error in listofalgorithms, undefined control sequence in .loa file [closed]

I am trying to write a pseudo code in LaTeX, and want to list the algorithm in the \listofalgorithms. Using the following code, I can generate the pseudo code in pdf and also the algorithm is listed ...
0
votes
1answer
598 views

Indentation inside algorithmic environment [duplicate]

Consider the following snippet: \documentclass{article} \usepackage[textwidth=8.5cm]{geometry} \usepackage{amsmath} \usepackage{algorithm} \usepackage{algpseudocode} \usepackage{parskip} \...
1
vote
1answer
154 views

Writting Pseudocode by using package algorithmic

I have a questions, why give me a clear line at fourth line? Can i delete "statement" end while and end for? \begin{algorithmic} [1] \FOR{$j \gets 0$ \TO $n - 1$ } \STATE{$t \gets A[j]$ \STATE {$i\...
2
votes
0answers
740 views

How to set algorithm width to avoid overfull \hbox problem

I wrote the following latex text, but the log shows an error that overfull \hbox(10.0pt too wide) detected. I am sure that the algorithmic part exceed the width limit. Even if I type a few words, the ...
1
vote
0answers
280 views

algorithmicx - How to change “Procedure” to “def”

I am using algorithmicx. It gives a block using \Procedure. However, I want to make my presentation of algorithms in python style, since I implemented it in python. In python, to define a function, ...
0
votes
0answers
446 views

Algorithm indent problem with sig-alternate document & algorithm(ic) package

Can anyone tell me why the indention of the algorithm does not work? I have the following code: \begin{algorithm} \caption{STEP 1} \begin{algorithmic}[1] \REQUIRE Something \FOR{\textbf{each} $user$}...
4
votes
1answer
1k views

How to change font style of all algorithm/algpseudocode keywords?

In detail I want to change the font style of all keywords like If Return For to bold/sans serif, but only the keywords. MWE: \documentclass{article} \usepackage{algorithm} \usepackage[noend]{...
1
vote
0answers
1k views

Algorithmic error: Missing \endcsname inserted [duplicate]

I have the following document: \documentclass[10pt,aps,pre,amsmath,amsfonts,amssymb,floatfix,longbibliography,superscriptaddress,notitlepage]{revtex4-1} \usepackage{amssymb,amsmath} \usepackage{bm} \...
1
vote
2answers
394 views

How to use multiple columns inside an algorithm, showing a step, and its complexity side by side

I would like to write my algorithm to multiple columns, showing a step, and its complexity cost side by side. Any idea on how to do it? Here is an example (not my document)
5
votes
1answer
902 views

Remove the colon from line numbering in algpseudocode

Is there a way to remove the colon (:) from the line numbering in algorithms (using the algpseudocode package)? \documentclass{article} \usepackage{algpseudocode} \begin{document} \begin{...
3
votes
1answer
129 views

Spacing between operators in IEEE document algorithms

I use the IEEE format and the algorithmic package. However, the spacing around binary operators in algorithms is too wide. attached screenshot: using this code: \documentclass{IEEEtran} \usepackage{...
5
votes
2answers
1k views

Algorithm environment problem

I am doing my master thesis and need to include an algorithm into my LaTeX code. I have been trying for hours now, but I still have several errors that always show up. It is my first time using the ...
6
votes
1answer
453 views

Algorithms and amsart

Basically, I have copied the code from an answer to this quesiton, for I have to translate some words. I have only changed documentclass from article to amsart. \documentclass[11pt]{amsart} \...
1
vote
1answer
2k views

Several errors in LaTeX algorithm environment

Hello guys i am new to LaTeX, i have written an algorithm in algorithm environment which is as follows: \documentclass{report} \usepackage{amsmath} \usepackage{algorithm} %\usepackage[noend]{...
1
vote
0answers
228 views

Error with algorithm and algorithmic packages

I have the following problem that involves the algorithm and algorithmic packages with the garamondx font. This is a minimal example: \documentclass[letterpapet,10pt]{article} \usepackage{garamondx} ...
2
votes
1answer
15k views

Algorithm nested for loops generate a blank line

%!TEX program = xelatex \documentclass{article} \usepackage{algorithm} \usepackage{algorithmic} \begin{document} \begin{algorithm}[] \caption{LDA} \begin{algorithmic}[1] \FOR{$d$} \STATE{ ...
3
votes
2answers
854 views

Wrap a few lines of Algorithmic in a box

I have some pseudocode where I want to reveal an algorithm little-by-little. Currently I highlight the code that is revealed by coloring it red and this looks good onscreen. However, on print, this ...
1
vote
1answer
304 views

Comment in algorithmic on a line beginning with if, and using uncover/visible

I am trying to modify this code, into the following one : \documentclass{beamer} \usepackage[utf8]{inputenc} \usepackage[english]{babel} \usepackage[plain]{algorithm} \usepackage{algorithmic} \...
1
vote
1answer
1k views

Table of contents of algorithm and algorithm2e together

The contents of the algorithms thinks that an algorithm that uses algorithm is one algorithm and an algorithm that uses algorithm2e is another algorithm, not the second of what was imported with the ...
1
vote
0answers
471 views

writing Algorithm in Latex

I want a Latex code that will write the following algorithm using \begin{algorithm} and \begin{algorithmic}. I have done this \floatname{algorithm}{Procedure} \renewcommand{\algorithmicrequire}{\...
5
votes
3answers
524 views

Spacing issue with algorithmic and eqparbox

I am using the algorithmic package to display code. In order to get flush-right, left aligned comments, I also use the eqparbox package and redefine \algorithmiccomment; see minimal example below. As ...
185
votes
1answer
99k views

algorithm, algorithmic, algorithmicx, algorithm2e, algpseudocode = confused

I am confused about the packages for writing simple "algorithms". There are too many options, and it is confusing when to use what. For example, if I use algpseudocode, then I can't add algorithmic ...
1
vote
1answer
6k views

! Missing \endcsname inserted in \begin {algorithmic}

file1.tex: \documentclass[12pt,letterpaper]{report} %%%%%%%%%%%%%%%% Xiaodi add: \usepackage{longtable} \newcommand{\argmin}{\arg\!\min} \usepackage[dvips]{graphicx} \usepackage{color,amsmath,...
10
votes
2answers
31k views

Algorithm in IEEE format

I want to type an algorithm in ieee format. I have used algorithmic package. But using that package, I couldn't type a caption to the algorithm and "Algorithm " above the written algorithm. What ...
2
votes
2answers
237 views

Section numbering conflicts in latex

I am using the following code in latex (llncs template) to write a paper. I am using xpretocmd to avoid conflicts between arabtex and algorithmic but the problem is that once I solved this conflict by ...
4
votes
1answer
583 views

Increase width of caption's horizontal lines in algorithmic and listings

I've been able to increase the width of the horizontal lines honoring the second answer in LaTeX tables: How do I make thicker or thinner horizontal lines (typically \hline)?. Now, I'd like to do the ...
1
vote
0answers
2k views

Switch statement using algorithmic environment

How to use Switch statement in algorithmic environment. I tried the following sample code but the errors are: unrecognized command (algorithmicswitch, algorithmiccase, \Switch, \EndSwitch, \Case, etc.)...
0
votes
0answers
106 views

Split algorithm over two pages, inside a for loop [duplicate]

I have found questions similar to mine, but none of the solutions given solves my problem. Because my algorithm is too long to fit on one page, I want it to be split on two pages. Solutions I've ...
1
vote
0answers
123 views

Algorithmic, put curled bracket over states [duplicate]

I am using the algorithm package and I want to but brackets over a set of lines, because it will be repeated for some cases.. \documentclass[a4paper,10pt, twoside]{book} \usepackage[utf8]{inputenc} ...
0
votes
0answers
3k views

how to use \algsetup in latex environment

I am using the "algorithmic" environment and want to use \algsetup. But getting an error. \documentclass{article} \usepackage{algpseudocode} \usepackage{algorithmic} \usepackage{float} \begin{...
3
votes
1answer
2k views

Algorithm keeps appearing on the last page of my latex document

I am writing an algorithm with the algorithmic environment and Latex keeps pushing it on the last page, no matter what I do, this is just a short example. \documentclass[a4paper,10pt, twoside]{book} \...
4
votes
1answer
2k views

Change font for function names within algorithmic

Using the following code, the function name foo is printed as \textsc{foo}. \usepackage{algorithmic} \begin{document} \begin{frame} \begin{algorithmic}[1] \Function{foo}{$a$} \EndFunction \...
0
votes
0answers
955 views

algpseudocode is not formatting properly in elsarticle template

I am using algpseudocode to write pseudo code. I am noticed that the pseudo code is justify aligned, which doesn't look good here. Below is the snippet of latex code- \usepackage{algorithm} \...
3
votes
1answer
1k views

algorithmic package

I want to write something like \Repeat {comment} \State \until The code: \documentclass[a4paper]{article} \usepackage{algorithm} \usepackage{algorithmic} \begin{document} \begin{algorithm}[H]...
1
vote
1answer
879 views

Different line numbers for two procedures in similar algorithm

I have following algorithm with two different procedures (i.e., phases) and want to give separate line numbers to both of them. Can any body help me out please? Thanks... \documentclass[10pt,a4paper]{...
2
votes
1answer
998 views

Problem in Algorithm Code [closed]

I am trying to complete my research paper in LaTeX but getting following three errors. I have tried so many things from the internet but to no advantage. Could any one help me please? 1) File ...