Questions tagged [algorithmic]

algorithmic is an environment for typesetting {algorithms}.

Filter by
Sorted by
Tagged with
194
votes
1answer
105k 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 ...
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} ...
3
votes
2answers
11k views

Align Input and Output of algorithm to left

I use the following template for KDD 2017 - for conference (sample-sigconf file): here. This is the code I use for the my algorithm: \documentclass[sigconf]{acmart} \usepackage{booktabs,makecell,...
5
votes
2answers
34k 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{...
10
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 ...
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 ...
8
votes
3answers
13k 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 ...
8
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} \...
8
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" ...
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 ...
0
votes
1answer
173 views

Multiple Counters on algorithm

I'm using the algorithm package and want to number two types of algorithms with separate counters. I would like to know, what you think about my following code Are there any mistakes? Could ...
0
votes
1answer
103 views

Error emerged when I run the following LaTeX code

The following code gives error message: \documentclass[energies,article,accept,moreauthors,pdftex,10pt,a4paper]{mdpi} \usepackage{booktabs} \usepackage{array} \newcommand{\PreserveBackslash}[1]{\let\...
15
votes
2answers
23k 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 ...
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?
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 ...
10
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
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
1answer
2k views

How to remove header and line numbering from algorithmic?

I created a pseudocode algorithm like this: % Pseudo code % \usepackage{amsmath} \usepackage{algorithm} \usepackage[noend]{algpseudocode} \algdef{SE}{Begin}{End}{\textbf{begin}}{\textbf{end}} \begin{...
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}[...
2
votes
1answer
121 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 ...
2
votes
1answer
918 views

latex algorithm displaying problems: lines are overlapped

duplicate I am using algorithm package (built with pdflatex -shell-escape -synctex=1 -interaction=nonstopmode under TexStudio) to draw my algorithm. It works well on a template, but when I switch to ...
2
votes
1answer
777 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 ...
2
votes
2answers
244 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 ...
2
votes
1answer
837 views

Algorithm In LaTeX Elsevier Template

Actually, I wrote algorithm first in general LaTeX format and done successfully. Following algorithm packages I had used: \usepackage{algorithm,algpseudocode} \usepackage{algorithmic} \usepackage{...
1
vote
1answer
378 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{...
0
votes
1answer
558 views

“Something wrong--perhaps a missing \item”

By trying to compile the code below the following error will be raised for each \item entry. Something's wrong--perhaps a missing \item \begin{algorithmic} \begin{enumerate} \item ...
0
votes
0answers
35 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ě ...