[Tex/LaTex] Algorithm does not fit onto one slide

beamerpresentations

I am using the Latex presentation package and would like to mold the following algorithm (I had to remove the text due to publication reasons) onto one slide – how can I do that?

\underline{Algorithm Example} \\


\begin{tabbing}
%%%%%%%%%%%%%%%
% set tabs here
\hspace*{0.5cm}\=\hspace*{0.5cm}\=\hspace*{0.5cm}\=\hspace*{0.1cm}\=\kill
%%%%%%%%%%%%%%%
1. Set rrrrrrrrrrrrrrr \\
2. \>(a) Grow rrrrrrrrrrrrrrrr \\
   \>(b) Reduce rrrrrrrrrrrrrrrrrr$

\\[5 pt] while $r \geq 1$ \\[5 pt]
\> 3. Decide rrrrrrrrrrrrrrrrrrrrrr \\
\> \> if (xxxxx) \\
\> \> \>(a) aaaaaaaaaaaaaaa \\
\> \> \>(b) bbbbbbbbbbbbbbbbbbbbbbbbbbb \\
\> 4. If aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \\
\> \> if (ccccccc) \\
\> \> \> (a) ddddddddddddd\\
\> \> \> (b) ddddddddddddddddddddddddddddddddd \\
\> \> \> \> ddddddddddddd\\
\> \> eeeeeeeeeeeeeeeeeeeeeee\\
\> \> \>(a) Ddddddddddddddddddddddddddddddddddddddddddd \\
\> \> \> \>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\
\> \> \> \>bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb \\
\> \> \>(b) teeeeeeeeeeeeeeeeeeeeeesst \\
\> \> \> \>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \\
\> \> end if \\
[5 pt] end while \\[2 pt]
\end{tabbing}

Best Answer

You have, at least, three possibilities: you can use \resizebox, you can reduce the font size, or you can use the evil shrink option:

\documentclass{beamer}
\usetheme{Boadilla}
\begin{document}

\begin{frame}[shrink=28]
\underline{Algorithm Example}\par
\begin{tabbing}
\hspace*{0.5cm}\=\hspace*{0.5cm}\=\hspace*{0.5cm}\=\hspace*{0.1cm}\=\kill
1. Set rrrrrrrrrrrrrrr \\
2. \>(a) Grow rrrrrrrrrrrrrrrr \\
   \>(b) Reduce $rrrrrrrrrrrrrrrrrr$

\\[5 pt] while $r \geq 1$ \\[5 pt]
\> 3. Decide rrrrrrrrrrrrrrrrrrrrrr \\
\> \> if (xxxxx) \\
\> \> \>(a) aaaaaaaaaaaaaaa \\
\> \> \>(b) bbbbbbbbbbbbbbbbbbbbbbbbbbb \\
\> 4. If aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \\
\> \> if (ccccccc) \\
\> \> \> (a) ddddddddddddd\\
\> \> \> (b) ddddddddddddddddddddddddddddddddd \\
\> \> \> \> ddddddddddddd\\
\> \> eeeeeeeeeeeeeeeeeeeeeee\\
\> \> \>(a) Ddddddddddddddddddddddddddddddddddddddddddd \\
\> \> \> \>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\
\> \> \> \>bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb \\
\> \> \>(b) teeeeeeeeeeeeeeeeeeeeeesst \\
\> \> \> \>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \\
\> \> end if \\[5 pt] 
end while \\[2 pt]
\end{tabbing}
\end{frame}

\begin{frame}
\underline{Algorithm Example}\par
\resizebox{!}{\textheight}{%
\vbox{\begin{tabbing}
\hspace*{0.5cm}\=\hspace*{0.5cm}\=\hspace*{0.5cm}\=\hspace*{0.1cm}\=\kill
1. Set rrrrrrrrrrrrrrr \\
2. \>(a) Grow rrrrrrrrrrrrrrrr \\
   \>(b) Reduce $rrrrrrrrrrrrrrrrrr$

\\[5 pt] while $r \geq 1$ \\[5 pt]
\> 3. Decide rrrrrrrrrrrrrrrrrrrrrr \\
\> \> if (xxxxx) \\
\> \> \>(a) aaaaaaaaaaaaaaa \\
\> \> \>(b) bbbbbbbbbbbbbbbbbbbbbbbbbbb \\
\> 4. If aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \\
\> \> if (ccccccc) \\
\> \> \> (a) ddddddddddddd\\
\> \> \> (b) ddddddddddddddddddddddddddddddddd \\
\> \> \> \> ddddddddddddd\\
\> \> eeeeeeeeeeeeeeeeeeeeeee\\
\> \> \>(a) Ddddddddddddddddddddddddddddddddddddddddddd \\
\> \> \> \>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\
\> \> \> \>bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb \\
\> \> \>(b) teeeeeeeeeeeeeeeeeeeeeesst \\
\> \> \> \>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \\
\> \> end if \\[5 pt] 
end while \\[2 pt]
\end{tabbing}}%
}
\end{frame}

\begin{frame}
\underline{Algorithm Example}\par
\scriptsize
\begin{tabbing}
\hspace*{0.5cm}\=\hspace*{0.5cm}\=\hspace*{0.5cm}\=\hspace*{0.1cm}\=\kill
1. Set rrrrrrrrrrrrrrr \\
2. \>(a) Grow rrrrrrrrrrrrrrrr \\
   \>(b) Reduce $rrrrrrrrrrrrrrrrrr$

\\[5 pt] while $r \geq 1$ \\[5 pt]
\> 3. Decide rrrrrrrrrrrrrrrrrrrrrr \\
\> \> if (xxxxx) \\
\> \> \>(a) aaaaaaaaaaaaaaa \\
\> \> \>(b) bbbbbbbbbbbbbbbbbbbbbbbbbbb \\
\> 4. If aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \\
\> \> if (ccccccc) \\
\> \> \> (a) ddddddddddddd\\
\> \> \> (b) ddddddddddddddddddddddddddddddddd \\
\> \> \> \> ddddddddddddd\\
\> \> eeeeeeeeeeeeeeeeeeeeeee\\
\> \> \>(a) Ddddddddddddddddddddddddddddddddddddddddddd \\
\> \> \> \>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\
\> \> \> \>bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb \\
\> \> \>(b) teeeeeeeeeeeeeeeeeeeeeesst \\
\> \> \> \>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \\
\> \> end if \\[5 pt] 
end while \\[2 pt]
\end{tabbing}
\end{frame}


\end{document}

enter image description here

As a side note, perhaps you could use one of the dedicated packages to write your algorithms: algorithmicx or listings, for example.