algorithmic is an environment for typesetting {algorithms}.

learn more… | top users | synonyms

4
votes
2answers
73 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 ...
5
votes
1answer
72 views

Algorithms and amsart

Basically, I have copied the code from answer to this quesiton, for I have to translate some words. I have only changed documentclass from article to amsart. \documentclass[11pt]{amsart} ...
2
votes
1answer
28 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} ...
0
votes
0answers
10 views

How to write “for” block with counter by Algorithmic package

How can I write a code like below using algorithmic package for (int i = 0; i < node.children; ++i) ..... I can't use foreach or forall because in a point inside the loop I should decrement i ...
1
vote
0answers
32 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} ...
1
vote
1answer
44 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
124 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
43 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} ...
2
votes
1answer
99 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 ...
2
votes
0answers
90 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} ...
0
votes
0answers
13 views

Linebreak with algorithm environment in two column mode [duplicate]

I want to integrate an algorithm in a two column article, but I'm not happy with the output (screenshot below). I'm wondering why the algorithm environment don't break the code and go on the next ...
4
votes
3answers
74 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 ...
15
votes
1answer
1k views

algorithm, algorithmic, algorithmicx, algorithm2e, algpseudocode = confused

I am getting confused about the package structure for writing simple "algorithms". There are too many options, and also got totally clueless about when to use what. Is there any definitive guidelines ...
0
votes
1answer
446 views

! Missing \endcsname inserted in \begin {algorithmic}

file1.tex: \documentclass[12pt,letterpaper]{report} %%%%%%%%%%%%%%%% Xiaodi add: \usepackage{longtable} \newcommand{\argmin}{\arg\!\min} \usepackage[dvips]{graphicx} ...
6
votes
2answers
2k 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 ...
0
votes
0answers
15 views

how to align one sentence if it is too long when using algorithmic package [duplicate]

I am using the algorithmic package to program the pseudocode in latex. But there is a problem. If one \State is too long, the sentence will be aligned to the left. It looks ugly. See this figure. ...
1
vote
2answers
47 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 ...
3
votes
1answer
70 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 bold horizontal lines (typically \hline)?. Now, I'd like to do the same in ...
2
votes
0answers
139 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, ...
0
votes
0answers
30 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 ...
2
votes
0answers
16 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
303 views

How to solve the problem in the “algorithm” environment

\documentclass[conference]{IEEEtran} \usepackage{algpseudocode} \usepackage{algorithmicx} ............. \begin{algorithm}[h] \caption{Iterations for risk-sensitive cost} \begin{algorithmic} ...
0
votes
0answers
388 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} ...
2
votes
0answers
200 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} ...
0
votes
0answers
27 views

Change the size of algorithm enviroment

I used \algsetup{linenosize=\small} command to scale the size of algorithm environment, but it seems doesn't work! How can I do that?
4
votes
1answer
184 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
116 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} ...
4
votes
1answer
238 views

algorithmic package

I want to write something like \Repeat {comment} \State \until The code: \documentclass[a4paper]{article} \usepackage{algorithm} \usepackage{algorithmic} \begin{document} ...
1
vote
1answer
118 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... ...
2
votes
1answer
231 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 ...
0
votes
1answer
100 views

How to write an algorithm in french? [Errors]

I am trying to write my algorithm in french language. I found this solution which works for me but with errors. The errors are: \algorithmicendelsif undefined \algorithmicendif undefined ...
0
votes
0answers
22 views

Latex - after pseudocode =0 is added [duplicate]

I have some problems with using pseudocode in LaTeX. After I build the file =0 is added at the end of the file. Any suggestion how can I fix that? \documentclass{article} ...
4
votes
1answer
63 views

spacing problem for more than three algorithms in one page

I use algorithm and algpseudocode package. Problem is, when I tried to start the fourth procedure\function, the fourth one starts in the middle of the next page instead of right below to the third ...
1
vote
1answer
181 views

Algorithm problem in poster with tikzposter

I am creating a poster using tikzposter. But it seems to have a bug with algorithm packages. I use the following code but the borders of algorithm block span to the whole width of the poster: ...
2
votes
2answers
435 views

Undefined Control Sequence \For, \state, or \EndFor

I want to write this algorithm but the error Undefined Control Sequence \For, \state, or \EndFor pops up. \documentclass[titlepage,oneside,12pt]{article} \usepackage[]{algorithm2e,algpseudocode} ...
5
votes
1answer
834 views

Algorithmic: Put If and EndIf into same line

I use the algorithmic package to create a pseudo-code-source in latex. I have a source with many short if-statements. The fact that the END (from EndIf) is put in a new line every time leads to a ...
2
votes
3answers
139 views

Place two algorithm into two column

I have single column page. I would like to add my two algorithm into two column. How can I do this? My algorithms are below. \begin{algorithm}[h] \caption{Resolve 1} \begin{algorithmic} \scriptsize ...
3
votes
1answer
187 views

How to write sentences in an algorithm in latex?

Hi I am trying to write an algorithm which looks something like the image below: I was wondering how to write the "Step 1 (Update)" and also the rest of the line which says "When an edge e...." ...
1
vote
0answers
75 views

connecting loop lines in algpascal?

I am using the algorithmic package to typeset an algorithm. I would like to have connecting lines between the beginning and end of a loop or conditional in algpascal package. in this link enter link ...
3
votes
1answer
7k views

! LaTeX Error: Something's wrong--perhaps a missing \item

I am using TEXMAKER. Here is a code segment. \usepackage{algorithmic} begin{algorithmic} \FOR {$i\gets0$ to $n$} \do \FOR {$j \gets$0 \TO $min(i,k)$} \do \IF {$j=0$ \OR $j=i$} ...
6
votes
1answer
3k views

Undefined control sequence \State \For \While

I am trying to write a pseudo code in MiKTeX. I have used \usepackage{algorithm} \usepackage{algorithmic} but I get: Undefined control sequence' for every structure (\State, \While, \For, \If). ...
3
votes
1answer
1k views

Why this 'Perhaps a missing \item' error with the algorithmic package?

I am trying to imitate an example I found in the LaTeX wikibook to write my own algorithm using the algorithmic package. I can't understand it clearly, though, and I am getting errors all the time. ...
6
votes
2answers
693 views

How to make “for all xxx do” appear on one line?

This is an example \documentclass[12pt,oneside,a4paper,onecolumn]{article} \usepackage{graphicx,color,setspace,hyperref} \usepackage[left=1.5in,top=1.25in,bottom=1.25in,right=1.25in]{geometry} ...
1
vote
0answers
20 views

Indentation lines in algorithm package [duplicate]

I am using the algpseudocode and the algorithm2e package, and want the lines down below the indents like below (the example on the algorithm here). Does anyone know how to achieve this easily?
8
votes
1answer
155 views

Suppress line numbers in front of 'repeat' and 'until' keywords in algorithmic

Here is my minimal example: \documentclass{article} \usepackage{algorithm} \usepackage{algorithmic} \begin{document} \begin{algorithm} \caption{Test} \begin{algorithmic}[1] \REQUIRE ...
3
votes
1answer
775 views

Algoritmic return command = 0

Can you suggest me what is wrong with using return command in algorithms. when I add \RETURN $C to my LaTeX document I get return C =0, what I need is just return C. \begin{algorithm} ...
7
votes
1answer
1k views

Faulty right alignment for comments in algorithmic package

I'm trying to right align comments in a pseudocode environment using the algorithmic package. So I renewed the algorithmiccomment command. There's a different way to create comments for "normal" ...
3
votes
2answers
6k views

Pseudocode: \Function vs. \Procedure?

The title says it all. What is the difference between a Function and a Procedure? When should I use which?
3
votes
1answer
319 views

Left alignment in the algorithm and reset the numbers

I'm using algorithmic package and I would like to have certain text be left aligned. Also, would like to reset the numbering for each line inside the algorithm after certain text. The MWE provided to ...
5
votes
1answer
3k views

comment in algorithmic on a line beginning with if

I'm working with algorithmic to create some pseudo-code with comments. With a macro found on this site (see header), comments will be aligned on the right, which is wonderful. However, I don't get it ...