Skip to content

Instantly share code, notes, and snippets.

@godbyk
Created February 20, 2011 05:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save godbyk/835719 to your computer and use it in GitHub Desktop.
Save godbyk/835719 to your computer and use it in GitHub Desktop.
\documentclass{article}
\usepackage{clrscode3e}
% The "codebox" environment produces an unbreakable section of code
\newenvironment{tinycodebox}{%
\tiny% or \small or \footnotesize or whatever size works best
\codebox
}{%
\endcodebox
}
\usepackage{lipsum} % provides dummy text
\begin{document}
\lipsum[1]
\begin{tinycodebox}
\Procname{$\proc{Insertion-Sort}(A)$}
\li \For $j \gets 2$ \To $\attrib{A}{length}$
\li
\Do
$\id{key} \gets A[j]$
\li
\Comment Insert $A[j]$ into the sorted sequence
$A[1 \twodots j-1]$.
\li
$i \gets j-1$
\li
\While $i > 0$ and $A[i] > \id{key}$
\li
\Do
$A[i+1] \gets A[i]$
\li
$i \gets i-1$
\End
\li
$A[i+1] \gets \id{key}$
\End
\end{tinycodebox}
\lipsum[2]
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment