Japanese version is also available.

A Guide to PAD Style File

Satoshi Kuramochi
satoshi@ueda.info.waseda.ac.jp

July 17, 1996


Index

1. The Usage of the Macros
1.1. Drawing Commands
1.2. Box Commands
1.3. Style Parameters
2. Notes
3. Examples
4. Troubleshooting
4.1. Errors in pad.sty
4.2. Trouble with pad2tex
5. Known Problems
6. Things to do
7. Credit
References
Appendix

1. The Usage of the Macros

In this section, the usage of the macros, defined in this style file, will be explained. In the following explanation, letters in typewriter typeface mean that the letters appear `as they are' in the input file, while the part in italics means a part that varies for the purpose.

1.1. Drawing Commands

\padbox{text}

Draws a frame for procedure. text is typeset in LR mode.

\padwhile{cond}{proc}
\padrepeat{cond}{proc}

\padwhile draws a frame for pre-conditional loop, while \padrepeat draws a frame for general (or post-conditional) loop. cond specifies its condition. proc specifies its procedure. cond is typeset in LR mode. When proc contains nothing (not even one whitespace), the flow line between condition and procedure would not be drawn.

\padcond{cond}{proc1}{proc2}

Draws a frame for selection. cond specifies its condition. proc1 and proc2 specify its procedures. cond is typeset in LR mode. The same as \padwhile and \padrepeat, the flow line will not be drawn if proc1 and/or proc2 contains nothing.

\padcase{expr}{cases}

Draws a frame for selection. Use this macro, rather than \padcond, if there are more than two conditional cases. expr is typeset in LR mode and is positioned in middle of the frame. cases specifies the case and the corresponding procedure in pairs. These pairs are separated by `,', while their case and procedure are separated by `:'. The cases are typeset in LR mode.

When case or procedure contains `:' or `,', it should be parenthesized by braces.

\padsub{text}

Draws a frame for subroutine. text is typeset in LR mode.

\padseq{procs}

Draws a sequence of the procedures. procs specifies a sequence of procedures. Each procedures are separated by a \\.

You can put some extra space by setting the optional argument len of a \\. This will add len, space between procedures.

\padlabel{label}

Draws a label named label.

\padref{label}

Draws a frame for reference to a label named label.

\padboxss{texts}
\padsubss{texts}

These are defined for writing a text spreading over multiple lines inside \padbox and \padsub. Each line is separated by a \\.

These macros just call the corresponding macro with argument \shortstack{texts}. When you want to write multiple lines inside loop or selection, just call the macro with the same argument.

\padmessage{message}

Writes a comment. Use this macro when you want to write a comment inside \padseq, otherwise the vertical flow line on left won't be drawn.

\padcomment{comment}

Writes a comment on right of the procedure. comment is typeset in LR mode, and is positioned in the middle.

1.2. Box Commands

\savepad{name}{pad}

Saves a PAD specified by pad into the container specified by name. name is a regular command name. You do not need to create a container using LaTeX command \newsavebox.

\usepad{name}

Draws a PAD saved in the container name by \savepad.

To save or draw a PAD, do not use LaTeX command \savebox or \usebox. Instead, use these macros.

1.3. Style Parameters

\padboxrule

Sets the width of lines in a PAD. This does not change width of slanted lines or circles. The width of the frame will be twice as bold as this value.

\padboxsep

Sets the amount of space inserted between the frame of a PAD and its contents.

\padcolsep

Sets the minimum width between columns in \padseq, \padcond and \padcase.

2. Notes

3. Examples

[figure of nesting test]

Figure 1: Nesting test

[figure of Ackermann function]

Figure 2: Ackermann's function

4. Troubleshooting

4.1. Errors in pad.sty

In this section, I'll explain how to deal with each error.
! TeX capacity exceeded, sorry [parameter stack size=...].

This occurs when \padcases are nested too deeply. Save the PAD in the most inner loop using \savepad first, then draw the PAD using \usepad.

! TeX capacity exceeded, sorry [semantic stack size=...].

This also occurs by nesting too deeply. Deal with it in the same manner as previous.

Use BigTeX to process a file with complicated and/or many PADs, because the current version of pad.sty does not maintain resources well.

! No room for a new ....

This occurs when there are too much PADs or switching alternatives to \padcase. I'm sorry that there is no way to deal with it but to reduce the number of PADs or divide the input file.

4.2. Trouble with pad2tex

Now, I'll explain how to deal with troubles and errors occurred when using pad2tex (by
Seiichi Yoshida).
PAD sticks out to the right

Fold lines manually because pad.sty does not fold lines automatically when PAD juts out. For example, fold the condition of \padwhile, \padrepeat or \padcond using \shortstack.

PAD sticks out to below

Current version of pad.sty does not support page break in the middle of PAD. Collect procedures into a subroutine to fit it into one page.

! TeX capacity exceeded, sorry [main memory size=...].

This occurs when there are too many unprocessed figures. Insert \clearpage just before the place where the error occurs.

5. Known Problems

6. Things to do

7. Credit

My E-mail address is
satoshi@ueda.info.waseda.ac.jp. The latest version of pad.sty will be found at http://www.ueda.info.waseda.ac.jp/~satoshi/padsty/padsty-e.html.

References

[1] Yoshihiko Futamura. Program Techniques -Structured Programming Using PAD-. Ohm, 1984.

[2] Leslie Lamport. LaTeX: A Document Preparation System. ASCII, 1990.
(The Original: Leslie Lamport. LaTeX: A Document Preparation System. Addison-Wesley, 1986.).

[3] Hideaki Togashi. ASCII Japanese TeX. Super ASCII. ASCII, Aug 1992 - Aug 1993.

Appendix

Table 1: List of the format of macros

kind
format
PAD
procedure
\padbox{text}
[image]
pre-conditional loop
\padwhile{cond}{proc}
[image]
general loop
(post-conditional loop)
\padrepeat{cond}{proc}
[image]
selection
\padcond{cond}{proc1}{proc2}
[image]
selection
(has 2 or more conditions)
\padcase{expr}{cases}
[image]
subroutine
\padsub{text}
[image]
sequence
\padseq{procs}
[image]
label
\padlabel{label} [image]
reference to label
\padref{label} [image]
procedure (multiple lines)
\padboxss{texts}
[image]
subroutine (multiple lines)
\padsubss{texts}
[image]
message
\padmessage{message}
[image]
comment
\padcomment{comment}
[image]
save PAD
\savepad{name}{pad}
---
use PAD
\usepad{name}
---


Go back to home page
satoshi@ueda.info.waseda.ac.jp