Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Is there an algorithm package that allows one to achieve the style of the algorithms in the book Combinatorial Optimization by Korte and Vygen? I am interested specifically in the numbering of the steps by encircled numbers.

share|improve this question

1 Answer 1

up vote 2 down vote accepted

This is view of the original algorithm:

Edmond's branching algorithm

Aside from duplicating the algorithm (with heading and content), since your were particularly interested in the numbering, the following does something similar using PGF/TikZ and algorithmicx. Moreover, I've used the following two answers to obtain the desired result:

\documentclass{article}
\usepackage{algpseudocode}
\usepackage{tikz}
% http://tex.stackexchange.com/questions/7032/good-way-to-make-textcircled-numbers/7045#7045
\newcommand*\circled[1]{\tikz[baseline=(char.base)]{%
            \node[shape=circle,draw,inner sep=1pt] (char) {#1};}}
\begin{document}

% http://tex.stackexchange.com/questions/25019/how-to-place-a-program-and-a-text-side-by-side/25026#25026
\algrenewcommand{\alglinenumber}[1]{\scriptsize\circled{#1}}% circled line numbers
\begin{algorithmic}[1]% Taken from the algorithmicx package documentation
  \Procedure{Euclid}{$a,b$}
  \State $r\gets a\bmod b$
  \While{$r\not=0$}
    \State $a\gets b$
    \State $b\gets r$
    \State $r\gets a\bmod b$
  \EndWhile\label{euclidendwhile}
  \State \textbf{return} $b$
  \EndProcedure
\end{algorithmic}

\end{document}

Euclid's algorithm

share|improve this answer
    
Thank you, that is what I was looking for. –  hpschrei Aug 7 '11 at 20:08

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.