Questions tagged [algorithmic]

algorithmic is an environment for typesetting {algorithms}.

Filter by
Sorted by
Tagged with
3
votes
1answer
187 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 ...
3
votes
1answer
2k 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: \...
3
votes
2answers
4k 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} \...
8
votes
1answer
11k 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
3k 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 \...
5
votes
1answer
791 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...." ...
4
votes
1answer
9k 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$} ...
11
votes
1answer
30k 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
8k 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
2k 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
164 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
492 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 \...
2
votes
2answers
7k 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
3k 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" ...
11
votes
2answers
40k 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?
4
votes
1answer
1k 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 ...
9
votes
1answer
12k 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 ...
2
votes
1answer
119 views

How to remove \BODY defined in the algorithmic package?

The algorithmic package defines a command \BODY which evidently clashes when used in conjunction with the environ package. More specifically, LaTeX failes to compile when an algorithmic environment is ...
5
votes
1answer
471 views

Conflict between arabtex and algorithmic

Below is a minimal working example which recreates the problem I'm facing. \documentclass{article} \usepackage{algorithmic} \usepackage{arabtex} \begin{document} \section{Introduction} \RL{d} \begin{...
9
votes
1answer
9k views

Placing a single algorithm in two columns

I have a single-column document and to save space I would like to make a long algorithm (produced using packages algorithm and algorithmic) to be double-column. That is, I would like the float content ...
3
votes
2answers
1k views

Divide algorithm in two parts without incrementation of version

This is my code: \documentclass{article} \usepackage[paperheight=6\baselineskip]{geometry}% just for the example \usepackage{algorithm} \usepackage{algcompatible} \begin{document} \begin{algorithm}[...
4
votes
1answer
4k views

Array inside Algorithm with underbrace and sidebrace

I'm writing my master's thesis (using LyX's thesis template) and am trying to display an algorithm. Since LyX's algorithm support doesn't quite cut it for me, I've decided to go ERT with LaTeX code (...
8
votes
3answers
12k views

Use algorithmic in LyX

I'm used to using the algorithmic package in LaTeX, but don't see an easy way to use it in LyX. I even tried this, but it didn't work. Further, it required me to change my document type, which is a ...
1
vote
1answer
1k views

How to define new loops in algorithmicx?

How can I define a new loop in algorithmicx? For example, code like this: ex1) PreLoop s do --statement1 --statement2 ex2) PostLoop s do --statement1 --statement2 Is it possible to define it ...
2
votes
1answer
3k views

Colors in Pseudocode matlab style

How do I get colours and more control over spacing in the algorithmic package like this: I tried this which looks good, but has numbers: \begin{enumerate} \item Create the cumulative sum of ...
5
votes
2answers
33k views

How to put \algorithm and \algorithmic environments inside a box?

I want to put an algorithm inside a box. Here is the code \fbox{\parbox{0.8\linewidth}{ \begin{algorithm} \caption{My algorithm} \begin{algorithmic}[1] \scriptsize ... \end{algorithmic} \end{...
40
votes
1answer
135k views

ELSE IF in algoritmic package

Is there a command in algorithmic package which is similar to \ElsIf in algorithmicx? ( I do not want each nested if to be indented).
7
votes
1answer
10k views

How can very long algorithms be automatically split over multiple pages?

I have a very long algorithm than spans several pages. I can not get Latex to make it span across several pages. I know that several questions similar to this one have already been asked, but I haven'...
15
votes
2answers
22k views

Unnumbered lines in algorithm

My question is similar to this one, I need to skip number for some lines of the algorithm. However the solution from that question does not work for me. How can I disable numbers for some lines using ...
5
votes
1answer
3k views

Alignment in algorithmic environment

I don't like how there is often a slight misalignment between assignment statements in an algorithmic environment. For example, the first version of the algorithm given below looks strange to me. I ...
1
vote
0answers
741 views

Algorithmic: file ended while scanning definition of \ALG\typeout [closed]

I m trying to the given code given in here: Algorithm and IEEEtran, or some other examples. by \usepackage{algpseudocode}. But I am getting this error: ./algpseudocode.sty:12: file ended while ...
5
votes
0answers
3k views

typing in bold font in algorithmic environment [closed]

Is there a way to type some words in bold in an algorithmic environment? I want to have the word stop typed, but when I use \STOP, this gives me an error.
3
votes
1answer
276 views

Statement (\STATE) indentation in Algorithmic package

I have the following code, \documentclass[]{memoir} \usepackage[utf8x]{inputenc} \usepackage{amssymb} \usepackage{amsmath} \usepackage{amsfonts} \usepackage{algorithmic} \newcommand{\algorithmname}{...
5
votes
1answer
889 views

How to make the line number in algorithm shown in bold

I have tried following which works (making the number in second line bold) \begin{algorithm}[h] \begin{algorithmic}[1] \State TSO.assignStartTs() {\bf\State} TSO.assignCommitTs() \end{algorithmic} \...
6
votes
1answer
4k views

Ruled Algorithms in columns/minipages

I'm using Benoit Guillon's algo styles for Lyx (at http://bgu.perso.libertysurf.fr/) in 2.0 to get nice algorithms ruled with line numbers. This is just a wrapper for the algorithm and algorithmic ...
2
votes
1answer
3k views

Make List of Algorithms formatting match LOT/LOF

I'm working on my thesis, and I have a minor formatting problem with my list of algorithms. The entry is added properly in the TOC and the font, size dotting and numbering are perfect, but for some ...
13
votes
2answers
28k views

“For” loop without “do”; “if” statement without “then”

How can I get rid of the do in a for loop and the then in an if statement when typesetting algorithms using the algorithm and algorithmicx packages?