{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}.
12
votes
1answer
956 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:
...
9
votes
2answers
594 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 ...
8
votes
3answers
3k 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 ...
...
8
votes
1answer
920 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 ...
7
votes
2answers
50 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
999 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
...
7
votes
1answer
165 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}
...
6
votes
1answer
362 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}
...
6
votes
1answer
1k 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
1answer
348 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 ...
5
votes
2answers
7k 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}
...
5
votes
1answer
238 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 ...
5
votes
1answer
248 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
2k 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 ...
5
votes
1answer
921 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 ...
5
votes
1answer
77 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
254 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}
...
5
votes
1answer
329 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
83 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
1answer
57 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
0answers
48 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
201 views
Algorithm with Latex ( Package algorithmicx)
This is my algorithm:
\usepackage{graphicx}
\usepackage[linesnumbered,ruled,vlined]{algorithm2e}
\usepackage{algorithmicx}
\usepackage{algpseudocode}
%\usepackage{algorithmic}
...
4
votes
1answer
5k 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 ...
4
votes
2answers
41 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}
...
4
votes
2answers
221 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 ...
4
votes
1answer
326 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
1k 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
1answer
88 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}
...
4
votes
1answer
338 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 ...
4
votes
1answer
439 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}
...
4
votes
1answer
150 views
Slight change in algorithm
This is my MWE for an algorithm however its throwing an error and I don't know how to get inputs and initialize. I want it to look like the attached image.
...
4
votes
1answer
628 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 ...
4
votes
1answer
498 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
...
4
votes
0answers
63 views
Ploblems with vertical lines in algorithmicx
I use algorithmicx with verical lines. And code is working good:
\documentclass{article}
\usepackage{algorithm}
\usepackage{algpseudocode}
% Vertical line
\makeatletter
...
3
votes
2answers
1k 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 ...
3
votes
1answer
433 views
Pseudocode overflow out of column
I am writing pseudocode using the algorithmicx package in IEEEtran class (double column). My problem is, some of the statement in the code are quite long which I expected to wrap to next line. ...
3
votes
1answer
160 views
Changing the alignment of comments when using algorithmics
When using comments in the algorithmicx package like in the code below, the comment is aligned at the right. How do I change that? I'd like the comment to appear next to the code, separated by a tab.
...
3
votes
1answer
46 views
using standalone with algorithmicx or algorithm2e
I am trying to compile a standalone file containing pseudocode created with the algorithmicx package.
According to algorithmicx crashes standalone it should work with the preview option set for ...
3
votes
1answer
97 views
Align pseudocode comments to the left
Writing comments in pseudocode, I wanted to insert comments which are not aligned to the right side of the line which is commented. This thread helped me a lot.
However, I want comments to stand ...
3
votes
1answer
126 views
algorithmicx, broken left align with custom numbering
I am trying to use the algorithmic package with Step1. Step2. instead of 1, 2, ... line numbering and I have numberless lines. An example:
\documentclass[11 pt]{report}
\usepackage{algorithm}
...
2
votes
2answers
426 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
...
2
votes
1answer
46 views
cleveref fails to reference algorithms
In the following example document, both \autoref and plain ref will correctly link and number an algorithm reference, but cleveref fails that task. It will just insert question marks instead. In ...
2
votes
1answer
344 views
Error compiling algpseudocode example
Compiling this piece of code (which I took from the guide of the algorithmicx package) I get a lot of errors and do not understand why. I think it is probably some stupid typo I can't see but this is ...
2
votes
1answer
99 views
Line number error using “Require” and “Ensure” in package{algorithmicx}
I’m using the packages algorithmicx and algpseudocode to write algorithms in my paper. It’s more convenient and beautiful to specify comments than with the algorithmic.
But I encounter an error while ...
2
votes
1answer
107 views
Change line numbering in algorithmics package
I would like to start the line numbering of the following code not from 1 but from 12 (as it is cut out of a larger code). So it should be 12,13,14,15 instead of 1,2,3,4.
\documentclass{article}
...
2
votes
1answer
210 views
Algorithmcx and array representation
I'm using package algorithmcx and algpseudocode to describe an algorithm in a paper.
Each function in the algorithm receive an array/list of numerical values, e.g. {x1, x2, ..., xn}.
...
2
votes
1answer
479 views
Functions with no parameters in algorithmicx
I am trying to write an algorithm using algorithmicxand I need to put a function with no parameters.
I use
\Function {foo}{}
latex produces:
function FOO
However I need:
function FOO()
...
2
votes
1answer
25 views
Problem with the block with the word wrap in algorithmicx
For a good word wrap, I use this code in algorithmicx:
\parbox[t]{\dimexpr\linewidth-\algorithmicindent}{<text>\strut}
But when the code contains several nested structure leaves a block of ...
2
votes
1answer
146 views
Remove line numbering from algorithmicx procedure/function
I would like the lines of "procedure" and "end procedure", "function", and "end function" etc to not be numbered.
For example, the default behavior produces this:
1 procedure hasNext(v,V,s)
2 ...
2
votes
1answer
562 views
Writing Pseudocode in LaTeX
I cannot seem to get any of the LaTeX pseudocode packages to work correctly on my computer. For example, if I run this block of code:
\documentclass{article}
\usepackage{algorithm}% ...
