next up previous
Next: Bibliography Up: Pseudocode: A LATEX Style Previous: An example

Framing

The pseudocode environment also has an optional parameter, <frame>. The complete form of the pseudocode environment is

\begin{pseudocode}[<frame>]{<Name>}{<Parameters>}
  pseudocode constructs
\end{pseudocode}

The possible values of <frame> are:

shadowbox doublebox ovalbox Ovalbox
framebox plain ruled display
The values ending with ``box'' draw various types of frames around the algorithm. The value plain is the default and adds no frame to the algorithm. The value display is used for displaying sections of code without the algorithm name or parameters. Here are some examples with input:

\begin{pseudocode}[<frame>]{SquareAndMultiply}{x,b,n}
 \COMMENT{ Compute $x^b \pmod{n}$}\\
 z\GETS 1\\
 \WHILE b > 0 \DO
 \BEGIN
  z \GETS z^2 \pmod{n} \\
  \IF b\mbox{ is odd} 
    \THEN z \GETS z \cdot x  \pmod{n} \\
    b \GETS \CALL{ShiftRight}{b}
 \END\\
 \RETURN{z}
\end{pseudocode}

where we give <frame> each of the values described above.


When <frame> is shadowbox we obtain:


\begin{pseudocode}[shadowbox]{SquareAndMultiply}{x,b,n}
\COMMENT{ Compute $x^b ...
...\pmod{n} \\
b \GETS \CALL{ShiftRight}{b}
\END\\
\RETURN{z}
\end{pseudocode}

When <frame> is doublebox we obtain:


\begin{pseudocode}[doublebox]{SquareAndMultiply}{x,b,n}
\COMMENT{ Compute $x^b ...
...\pmod{n} \\
b \GETS \CALL{ShiftRight}{b}
\END\\
\RETURN{z}
\end{pseudocode}

When <frame> is ovalbox we obtain:


\begin{pseudocode}[ovalbox]{SquareAndMultiply}{x,b,n}
\COMMENT{ Compute $x^b \p...
...\pmod{n} \\
b \GETS \CALL{ShiftRight}{b}
\END\\
\RETURN{z}
\end{pseudocode}

When <frame> is Ovalbox we obtain:


\begin{pseudocode}[Ovalbox]{SquareAndMultiply}{x,b,n}
\COMMENT{ Compute $x^b \p...
...\pmod{n} \\
b \GETS \CALL{ShiftRight}{b}
\END\\
\RETURN{z}
\end{pseudocode}

When <frame> is framebox we obtain:


\begin{pseudocode}[framebox]{SquareAndMultiply}{x,b,n}
\COMMENT{ Compute $x^b \...
...\pmod{n} \\
b \GETS \CALL{ShiftRight}{b}
\END\\
\RETURN{z}
\end{pseudocode}

When <frame> is plain or if [<frame>] is omitted we obtain:


\begin{pseudocode}[plain]{SquareAndMultiply}{x,b,n}
\COMMENT{ Compute $x^b \pmo...
...\pmod{n} \\
b \GETS \CALL{ShiftRight}{b}
\END\\
\RETURN{z}
\end{pseudocode}

When <frame> is ruled we obtain:


\begin{pseudocode}[ruled]{SquareAndMultiply}{x,b,n}
\COMMENT{ Compute $x^b \pmo...
...\pmod{n} \\
b \GETS \CALL{ShiftRight}{b}
\END\\
\RETURN{z}
\end{pseudocode}

The purpose of the value display is to allow portions of algorithms to be displayed with out the algorithm header. Thus for example to display the section of code in the $\WHILE$ loop of the $\CALL{SquareAndMultiply}{}$ algorithm one could write

\begin{center}
\begin{minipage}{2in}
\begin{pseudocode}[display]{}{}
  z \GETS z^2 \pmod{n} \\
  \IF b\mbox{ is odd}
    \THEN z \GETS z \cdot x  \pmod{n}\\
    b \GETS \CALL{ShiftRight}{b}
\end{pseudocode}
\end{minipage}
\end{center}

which would produce the following output:




\begin{pseudocode}[display]{}{}
z \GETS z^2 \pmod{n} \\
\IF b\mbox{ is odd}
\THEN z \GETS z \cdot x \pmod{n}\\
b \GETS \CALL{ShiftRight}{b}
\end{pseudocode}




next up previous
Next: Bibliography Up: Pseudocode: A LATEX Style Previous: An example
Donald L. Kreher
2000-02-18