Go to the first, previous, next, last section, table of contents.

5 PreScript

PreScript has been designed in conjunction with a2ps{}. Since bold sequences, special characters etc. were implemented in a2ps{}, we thought it would be good to allow direct access to those features: PreScript became an input language for a2ps{}, where special font treatments are specified in a LaTeX-like syntax.

The main advantages for using PreScript are:

It can be a good candidate for generation of PostScript output (syntactic pretty-printers, generation of various reports etc.).

5.1 Syntax

Every command name begins with a backslash (`\'). If the command uses an argument, it is given between curly braces with no spaces between the command name and the argument.

The main limit on PreScript is that no command can be used inside another command. For instance, though it is perfectly legal in LaTeX, the following line will be badly interpreted by a2ps{}:

\textbf{Problems using \textit{PreScript} instead of \LaTeX}

The correct way to write this in PreScript is

\textbf{Problems using} \textbi{PreScript} \textbf{instead of} \LaTeX.

Everything from an unquoted % to the end of line is ignored (comments).

5.2 PreScript commands

5.2.1 Structure commands

These commands required arguments.

`\section{Title}'
`\subsection{Title}'
`\subsubsection{Title}.'
Used to specify the title of a section, subsection or subsubsection.
`\textbf{text}'
`\textit{text}'
`\textbi{text}'
`\textrm{text}'
write text in bold, italic, bold-italic, Times. Default font is Courier. These instructions are said to be hard-coded. They may be removed in a future definition of PreScript. The following instructions are prefered.
`\keyword{text}'
`\Keyword{text}'
Highlight lightly/strongly the given text. Should be used only for a couple of adjacent words.
`\comment{text}'
`\Comment{text}'
The text is given a special face. The text may be removed if option `--strip' is used.
`\label{text}'
`\Label{text}'
text should be considered as a definition, or an important point in the structure of the whole text.
`\string{text}'
Write text with string's face (i.e. font Times).
`\textsy{text}'
text is written in the PostScript symbol font. This feature is not compatible with LaTeX. It is recommended, when possible, to use the special keywords denoting symbols, which are compatible with LaTeX (see section 5.2.2 Printed symbols).
`\header{text}'
`\footer{text}'
Use text as header (footer) for the current page. At run time, to override the defined headers and footers by these dynamic headers, the option `--dynamic-header' must be set. If several headers or footers are defined on the same page, the last one is taken into account.

5.2.2 Printed symbols

There is a big menagerie of symbols. To get a list, it is suggested to print a2ps{}'s report about PreScript using the command line:

a2ps --report=PreScript | a2ps -EPreScript

The reader should be aware that LaTeX is more demanding about special symbols. Most of them must be in so-called math mode, which means that the command must be inside $ signs. For instance, though

If \forall x \in E, x \in F then E \subseteq F.

is perfectly legal in PreScript, it should be written

If $\forall x \in E, x \in F$ then $E \subseteq F$.

for LaTeX. Since in PreScript every `$' is discarded (unless quoted by a `\'), the second form is also admitted.

5.2.3 Special characters

`$' is ignored in PreScript for compatibility with LaTeX, and `%' introduces a comment. Hence they are the only symbols which have to be quoted by a `\'. The following characters should also be quoted to produce good LaTeX files, but are accepted by PreScript: `_', `&', `#'.

Note that inside a command, like \textbf, the quotation mechanism does not work in PreScript (\textrm{#$%} writes `#$%') though LaTeX still requires quotation. Hence whenever special characters or symbols are introduced, they should be at the outer most level.

5.2.4 Quotation

There is a general mechanism to avoid special sequences from being interpreted: the commands `\verb+quoted string+', where `+' can be any symbol in `+', `!', `|', `#', `='.

5.3 Differences with LaTeX

5.3.1 LaTeX commands ignored in PreScript

Some LaTeX commands have no equivalent in PreScript, but are simply skipped at compilation time (if immediately followed by an end-of-line):

Everything between `%%PreScript:skip' and `%%PreScript:piks' will be ignored in PreScript, so that there can be inserted command definitions for LaTeX exclusively.

5.3.2 Commands available in PreScript but not in LaTeX

The commands `\textbi' (for bold-italic) and `\textsy' (for symbol) do not exist in LaTeX. They should be defined in the preamble:

%%PreScript:skip 
\newcommand{\textbi}[1]{\textbf{\textit{#1}}}
\newcommand{\textsy}[1]{#1}
%%PreScript:piks

There is no way in PreScript to get an automatic numbering. There is no equivalent to the LaTeX environment enumerate. But every command beginning by \text is doubled by a command beginning by `\magic'. a2ps behaves the same way on both families of commands. Hence, if one specifies that arguments of those functions should be ignored in the preamble of the LaTeX document, the numbering is emulated. For instance

\begin{enumerate}
\magicbf{1.}\item First line
\magicbf{2.}\item Second line
\end{enumerate}

will be treated the same way both in PreScript and LaTeX.

`header' and `\footer', are not understood by LaTeX.

Some symbols are available in PreScript but not in LaTeX:

`\Alpha', `\apple', `\Beta', `\carriagereturn', `\Chi', `\Epsilon', `\Eta', `\florin', `\Iota', `\Kappa', `\Mu', `\Nu', `\Omicron', `\omicron', `\radicalex', `\register', `\Rho', `\suchthat', `\Tau', `\therefore', `\trademark', `\varUpsilon', `\Zeta'.

A good example of a LaTeX preamble to get LaTeX to compile PreScript files is given by the report of a2ps{}.

5.4 Examples

PreScript and a2ps can be used for one-the-fly formating. For instance, on the `passwd' file:

ypcat passwd |
 awk -F: \
   '{print "\textbf{" $5 "} (" $1 ") \rightarrow\textit{" $7 "}"}'\
 | a2ps -Epre -P

Go to the first, previous, next, last section, table of contents.