Tagged Questions

algorithmic is an environment for typesetting {algorithms}.

learn more… | top users | synonyms

2
votes
0answers
30 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. ...
0
votes
0answers
28 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
12 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
22 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
38 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
12 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
57 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
17 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
55 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
34 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
64 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
41 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
44 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 ...
0
votes
0answers
46 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
59 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} ...
4
votes
1answer
93 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
62 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
126 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
40 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
3k 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$} ...
5
votes
1answer
880 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
272 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
503 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
18 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
101 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
395 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} ...
5
votes
1answer
489 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
2k 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
145 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
1k 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
75 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 ...
6
votes
1answer
166 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} ...
4
votes
1answer
1k 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 ...
0
votes
0answers
31 views

Spanning a procedure of an algorithm more than 1 page [duplicate]

I am unable to do this in LaTeX. Please help. And people who have marked this as duplicate, please mention the link to the question as I could not find any.. \begin{algorithm} \begin{algorithmic} ...
3
votes
2answers
166 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} ...
3
votes
1answer
680 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 ...
5
votes
3answers
4k 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
110 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
495 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 ...
1
vote
2answers
4k 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} ...
2
votes
1answer
10k 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).
4
votes
1answer
3k 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 ...
4
votes
1answer
2k 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 ...
4
votes
1answer
806 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
210 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 ...
3
votes
0answers
421 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
81 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} ...
5
votes
1answer
208 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} ...