{algorithmicx} provides an improved typesetting environment for algorithmic pseudocode. It is compatible with the algorithms bundle that provides the algorithm and algorithmic environment for typesetting floating {algorithms}.

learn more… | top users | synonyms

14
votes
1answer
3k views

Mark a pseudocode block and insert comments near it

I am currently working on a LaTeX beamer presentation where I have to explain an algorithm. So I wrote this algorithm with \usepackage{algorithm,algpseudocode} This is the current algorithm: ...
12
votes
3answers
7k views

algpseudocode without end block text

algpseudocode lets me write code such as: \documentclass{article} \usepackage{algpseudocode} \begin{document} \begin{algorithmic} \While{$n>3$} \If{$m>n$} \State ... \State ... ...
12
votes
2answers
1k views

Coloring lines in an algorithm

I am using Beamer for creating a presentation and I am trying to highlight some lines in an algorithm. I am actually using algcompatible. I found a solution here and created a couple of new commands ...
11
votes
2answers
5k views

Floating an algorithm?

I'm typesetting an algorithm using the algorithmx package as follows: \begin{algorithm} \caption{\textsc{Whatever}} \begin{algorithmic}[1] ... \end{algorithm} However, I would like it to ...
11
votes
1answer
5k views

algorithm numbering

I am having trouble numbering and referencing algorithms. I want to have the references labeled by the chapter, then within the chapter, such as: First algorithm in chapter 1 - Algorithm 1.1 ...
11
votes
1answer
2k views

Change Indentation Size in algorithmicx package

I'm using and enjoying the algorithmicx package, but would like to adjust the size of its indentations. In the algorithms package, I could do this with \algsetup{indent=1em}, but that doesn't seem to ...
10
votes
1answer
559 views

Algorithm as figure and without italic and bold formatting?

I want to include an algorithm in my latex document, however without printing most of it in italic and all the keywords in bold font like it's done by default by e.g. the algorithmicx package. I like ...
8
votes
1answer
2k views

Adjust the indentation whithin the algorithmicx-package when a line is broken

I have this code \documentclass{article} \usepackage{algorithm} \usepackage{algpseudocode} \begin{document} \begin{algorithm} \caption{Minimal Working Example for my Problem} ...
8
votes
1answer
137 views

How do I get rid of that extra line at the end of my custom algorithmicx block?

I'm using the algorithmicx package and have created a custom block called \On, but even with the noend option for algpseudocode I get an extra blank line at the end of the block. Here is a complete ...
8
votes
1answer
2k views

Translate “Algorithm” in the caption

This is my code \begin{algorithm} \caption{Funkcija ACO} \label{alg:aco} \begin{algorithmic} \STATE{do something} \end{algorithmic} \end{algorithm} it produces a caption like this ...
8
votes
2answers
297 views

How to automatically keep the indentation level when a line has to be broken

I'm using the algpseudocode package with two custom commands, \Let and \LongState to handle automatic indentation of (broken) long lines in the spirit of Werner's answer, which uses \parbox to wrap ...
7
votes
1answer
11k views

Algorithm and IEEEtran

I'm trying to write an algorithm in a IEEEtran LaTeX template and it doesn't work in any way. \usepackage{algorithm} \usepackage{algorithmc} %\begin{algorithm}[H] \begin{algorithm*} \caption{ASGP ...
7
votes
2answers
16k views

How to use algorithmicx package?

I found the algorithmicx package on this page, and tried to compile this example from the pdf file. \documentclass{article} \usepackage{algorithmicx} \begin{document} \begin{algorithm} ...
7
votes
2answers
250 views

Indentation in the algorithm package after \Ensure, \Require

I have this piece of code: \documentclass[11pt]{article} \usepackage{algorithm} \usepackage{algpseudocode} \usepackage{varwidth} \begin{document} \begin{algorithmic} \Require ...
7
votes
1answer
3k views

How do I define a new command in algorithmicx

The algorithmicx package defines two commands \Require and \Ensure for providing initial conditions. However, I'd like some custom commands such as \Assume, \Define, \Input, etc. At present, I merely ...
7
votes
2answers
98 views

algorithm with partial borders/frames

I use the algorithm float environment for pseudocode and want some algorithms to span two pages. That works fine with \algstore and \algrestore. However, I would like to omit these borders at the end ...
7
votes
1answer
280 views

algorithmicx crashes standalone

I am creating SVG files from different stuff from my LaTeX document. For this, I am using the standalone package followed by pdf2svg. This compiles: \documentclass{article} \usepackage{algorithmicx} ...
7
votes
1answer
2k views

algpseudocode font size

I want to change the default font size of the algorithm in algpseudocode environment to small. This is because my algorithm is lengthy and i have page limitations. Please help
6
votes
2answers
95 views

Text below line at end of algorithm?

I am using the algorithm and algpseudocode packages. When I define an algorithm it ends with a horizontal line. I would like to have some text below this horizontal line explaining some special case ...
6
votes
1answer
152 views

Place pseudocode inside tikz node

How can I place pseudocode, that is written by the algpseudocode package, inside a tikz node? (I don't want to just decorate the code, but use them inside a graph) MWE \documentclass{article} ...
6
votes
2answers
9k views

Algorithm with Latex ( Package algorithmicx)

This is my algorithm: \usepackage{graphicx} \usepackage[linesnumbered,ruled,vlined]{algorithm2e} \usepackage{algorithmicx} \usepackage{algpseudocode} %\usepackage{algorithmic} ...
6
votes
1answer
1k views

How to make lstlisting look exactly like the algorithm environment?

I'm typesetting pseudocode with algorithm and algorithmicx to get results like the following (taken from the package documentation): Now I would like to print real C++ code with the listings ...
6
votes
2answers
253 views

pseudo code with vertical line

I want to write some pseudo code. After few research I found algorithmicx with this post: Write pseudo code in latex But I want vertical line as this: function toto: | for i = 0 , i < 10, i++ | ...
6
votes
1answer
1k views

Line numbering in algorithmic

I want to change the first number of the line numbering in my algorithm, but how is it done? This is my example: \documentclass[12pt]{beamer} \usepackage{amsmath, amsfonts, amssymb, amsthm} ...
6
votes
1answer
2k views

algorithmicx package comments on a single line

Is it possible in algorithmicx package to have comments not aligned to the right side? For example I have code like this - \begin{algorithm}[!ht] \caption{My Algo.} \label{myalgo} ...
6
votes
1answer
2k views

Algpseudocode (algorithmicx) package comments

How to align comments in algorithmic environment to the right? For \Comment, if the comment is too long it gets wrapped and starts at the beginning of next line. It would look better if it was aligned ...
6
votes
1answer
1k views

Avoid putting statements on the same line with algorithmicx

I'm writing a simple pseudocode, but I have a problem with a repeat..until block. Basically what happens is that the return statement that follows the end of this loop gets rendered on the same line ...
6
votes
1answer
1k views

Numbering in algorithmicx

I have simple code: \documentclass{article} \usepackage{algorithm} \usepackage{algpseudocode} \begin{document} \begin{algorithm} \caption{Examples}\label{alg:Examples} \begin{algorithmic}[1] ...
5
votes
2answers
5k 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?
5
votes
2answers
967 views

Caption numbering breaking up an algorithm with algorithmicx

According to its documentation, algorithmicx package allows break up an algorithm inside a document, as follows: Related tex code is: \documentclass{article} \usepackage{algorithm} ...
5
votes
3answers
1k views

Forced indentation in algorithmicx

I have an algorithm dealing with some very large parameter names, messing up the readability. What I've done so far is break the lines of the problematic statement (lines 4-5) manually into two ...
5
votes
1answer
8k views

do-while loop in pseudo code

The algorithmic package lets me make a while loop as \begin{algorithmic} \While{$u\neq v$} \State Something \EndWhile \end{algorithmic} which results in a while(u is not v) do ...
5
votes
1answer
1k views

Function arguments in algorithmicx

I have a question about function arguments in the algorithmicx package. The following code works: \documentclass{article} \usepackage{algpseudocode} \usepackage{algorithm} \begin{document} ...
5
votes
1answer
44 views

Referring to correctly-styled algpseudocode procedure name in document

Given an algorithm written in algpseudocode: \documentclass{article} \usepackage{algorithm} \usepackage{algpseudocode} \begin{document} \begin{algorithm} \caption{Part 1} \begin{algorithmic}[1] ...
5
votes
1answer
116 views

Customizing some aspect of algorithmic environment

I'm using the algorithmic environment for typesetting algorithm in my document, but I'd like to customize some aspect and fix problems. I'm using the algpseudocode package with noend option, but it ...
5
votes
1answer
767 views

Vertical loop/block lines in algorithmicx with 'noend' option

I am using the algorithmicx package to write an algorithm. However I am using the noend option: \usepackage[noend]{algpseudocode} Is there anyway to get vertical lines for each block of code? This ...
5
votes
1answer
134 views

Error using amsart with algorithmic[x]

I use the algorithm and algorithmicx packages to type algorithms in a paper and my main document class is amsart. All is well until I try to use \listofalgorithms. This returns a variety of error ...
5
votes
1answer
835 views

Colored line numbers with algorithmicx?

The fancyvrb allows me to customize line number style which I find very useful. I'm using it to give line numbers a different color and then use that same color in the text describing the code. I ...
5
votes
1answer
704 views

How to fully left justify text in algorithmicx when not using line numbers

I'm using the algorithmicx package and would like to fully left justify the text when not using line numbers. Here's an example: Notice how only the Require and Ensure clauses are fully pushed to ...
5
votes
1answer
133 views

undefined control sequence '\For' - algorithmicx package

I have to write some algorithm, thus I've decided to use algorithmicx package: \usepackage{algorithm} \usepackage{algorithmicx} \begin{algorithm} \begin{algorithmic}[1] \For{aa} ...
5
votes
1answer
223 views

Renaming while loop in package algorithm

How do I rename the While loop using algorithm and algpseudocode? \documentclass{article} \usepackage{algorithm} \usepackage{algpseudocode} \begin{document} \begin{algorithm*} \caption{bar baz} ...
5
votes
0answers
55 views

Review of algorithm-related packages? [duplicate]

Possible Duplicate: Print programs with its proper syntax Where can I find (if it exists) an updated review of the most relevant packages for handling with algorithms (pseudocode or code ...
4
votes
2answers
5k views

customizing the algorithmic package: break and loop labels

I would like to add two customizations to the algorithmic package: introduce a new break command and have the possibility to provide labels to the LOOP so that break {label} is clear to which loop is ...
4
votes
2answers
490 views

algorithmicx + babel + Hebrew incompatibility

When trying to create any document with babel and algorithmicx, e.g.: \documentclass{article} \usepackage[hebrew,english]{babel} \usepackage{algorithmicx} \begin{document} Hello, world. ...
4
votes
1answer
562 views

Algorithmicx — How to use latex maths delimiters

Today, I decided to migrate from using TeX [$..$] to LaTeX [\(..\)] delimiters for inline maths, and, as usual, fell off the cliff of my somewhat precarious understanding of TeXian gastroenterology, ...
4
votes
1answer
4k views

Switch cases in algorithmic

How can I use switch cases in algorithmicx? For example a code like this: switch s do --case a ----assert(1) --case b ----assert(0) etc. Is is possible to define it as a command?
4
votes
2answers
1k views

algpseudocode without visible EndIf

I have the following chunk of code \begin{algorithmic} \State $\mathit{FlatMask}(c)=0$ \If{$\mathit{Inc1}(c)>0$} \State $\mathit{FlatMask}(c)\;+\!\!=2(\mathit{Inc1}(c)-1)$ \EndIf ...
4
votes
2answers
46 views

how to left justify comments to indent same as other text in Algorithmic

How do I left justify my comments in the algorithm. I am using algorithmicx package. What I want is: to pull the comment to left as shown in the attached snapshot. The code for my algorithm is ...
4
votes
2answers
89 views

Algorithmicx multiple statements per line aligned over all lines

I would like to put a <- b and e <- f, in parallel on a single line in an algorithmicx environment. I want the same with c <- d and g <- h. Then I want to align both lines. The output ...
4
votes
1answer
341 views

How to rename command to avoid double defined command names

Hy, I would like to use the packages vaucanson and algorithm. \documentclass[11pt,a4paper,twoside,openright]{book} \usepackage{algorithm} \usepackage[noend]{algpseudocode} \usepackage{vaucanson-g} ...