a2ps, version 4.7.20

ASCII to PostScript converter, and pretty-printer

Edition 4.7.20, 16 February 1997

Akim Demaille
Miguel Santana


@macro pack a2ps

@dircategory Printing utilities @direntry * a2ps:: ASCII to PostScript converter * PreScript: (a2ps) PreScript Input language for a2ps

Copyright (C) 1988, 89, 90, 91, 92, 93 Miguel Santana

Copyright (C) 1995, 96, 97 Akim Demaille, Miguel Santana

Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies.

Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one.

Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modified versions, except that this permission notice may be stated in a translation approved by the Foundation.

Introduction

This document describes @pack version 4.7.20. The latest versions may be found on (decrease order of service quality):

  1. @url{http://www-stud.enst.fr/~demaille/a2ps.html}.
  2. @url{http://www-inf.enst.fr/~demaille/a2ps.html}.
  3. @url{http://www.enst.fr/~demaille/a2ps.html}.

Description

@pack formats named files for printing in a PostScript printer; if no file is given, @pack reads from the standard input. The output may be sent to the printer or to the standard output or saved into a file.

The format used is nice and compact: normally two pages on each physical page, borders surrounding pages, headers with useful information (page number, printing date, file name or supplied header), line numbering, pretty-printing, symbol substitution etc. This is very useful for making archive listings of programs.

Compared to the previous versions, @pack version 4.7.20 provides:

  1. totally different options, to be closer to that of GNU enscript (see section Command line options);
  2. various configuration files (see section Configuration files)
  3. some powerful meta-sequences to define the headers the way you want (see section Meta sequences);
  4. and of course, the ability to pretty-print sources written in quite a few various languages (see section Pretty printing).

Syntactic limits

@pack is not a powerful syntactic pretty-printer: it just handles lexical structures, i.e., if in your favorite language

IF IF == THEN THEN ELSE := IF ELSE ELSE := THEN

is legal, then @pack is not the tool you need. Indeed @pack just looks for some keywords, or some sequences, i.e., sequences of characters which are opened by a given marker, and ended the same way. For instance in C, the comments are opened by `/*', and ended by `*/'.

It is for the same reason that you can't expect @pack to highlight the function definitions in C.

Vocabulary

This section settles some terms that are going to be used through out this document.

Virtual page
Area on a physical page in which @pack draws the content of a file.
Page
A single face of a sheet. There may be several virtual pages on a physical page.
Sheet
The physical support of the printing: it may support one or two pages, depending on your printing options.

Invocation

Calling @pack is fairly simple:

a2ps Options... Files...

Command line options

@pack uses GNU getopt, hence:

Here after bool stands for boolean. It is considered as true (i.e. setting the option on), if bool is `yes', or `1'; as false if it equals `no' or `0'; and raise an error otherwise. The corresponding short option takes no arguments, but corresponds to a positive answer.

Global behavior

`-q'
`--quiet'
`--silent'
be really quiet
`-v'
`--verbose'
tell what we are doing
`-V'
`--version'
print version and exit successfully
`--report[=language]'
generate PreScript report on all/language style. This file must be later processed by @pack using the PreScript style.
`--guess'
@pack won't print anything, but will act as file does: it returns for each file the language in which @pack believes the file is written. This can be very useful on broken systems to understand why a file is written with a bad style sheet (see section Automatic style).
`-h'
`--help'
print a short help, and exit successfully.
`--list-options'
Give a extensive report on @pack configuration and installation.
`--list-features'
Known medias, encodings, languages and prologues are reported.

Sheets

`-M'
`--media=media'
use output media media. Currently media may be `A3', `A4', `A5', `B4', `B5', `Letter', `Legal', `Tabloid', `Ledger', `Statement', `Executive', `Folio', `Quarto', `10x14'. `A4dj', `Letterdj' are also defined for Desk Jet owners, since that printer needs bigger margins.
`-r'
`--landscape'
print in landscape mode
`-R'
`--portrait'
print in portrait mode
`--columns=num'
specify the number of columns of virtual pages per physical page.
`--rows=num'
specify the number of rows of virtual pages per physical page.
`-1'
same as `--columns=1 --rows=1 --portrait --columns-per-page=80'
`-2'
same as `--columns=1 --rows=1 --landscape --columns-per-page=80'
`-3'
same as `--columns=3 --rows=1 --landscape'
`-4'
same as `--columns=2 --rows=2 --portrait --columns-per-page=80'
`-5'
same as `--columns=5 --rows=1 --landscape'
`-6'
same as `--columns=3 --rows=2 --landscape --columns-per-page=80'
`-7'
same as `--columns=7 --rows=1 --landscape'
`-8'
same as `--columns=4 --rows=2 --landscape --columns-per-page=80'
`-9'
same as `--columns=3 --rows=3 --portrait --columns-per-page=80'
`-j'
`--borders=bool'
print borders around virtual pages.
`-A'
`--compact=bool'
Compact mode for a sequence of files. This option allows the printing of more than one file in the same physical page. This option makes sense only when the number of virtual pages is greater than 1. Otherwise, the beginning of each file will be printed in a new sheet.
`--margin[=num]'
Specify the size of the margin (num PostScript points, or 12 points without arguments) to leave in the inside (i.e. left for the front side page, and right for the back side). This is intended to ease the binding.

Pages

`-C'
`--line-numbers=bool'
precede each line with its line number
`-f'
`--font=weight@size'
use font weight and/or font size for body text. weight is Normal or Bold, and size is a float number.
`-lnum'
`--columns-per-page=num'
Set the number of columns per page. num is the real number of columns devoted to the body of the text, i.e., no matter whether lines are numbered or not.
`-Lnum'
`--lines-per-page=num'
Set the lines per virtual page for printing. The font size is automatically scaled up to fill in the whole page. This is useful for printing preformatted documents which have a fixed number of lines per page. The scaling of the font size will be suppressed if this option is used with option `--font'. The minimum number of lines per page is set at 40 and maximum is at 160. If a number less than 40 is supplied, scaling will be turned off and a warning message is printed on the terminal.
`-m'
`--catman'
Understand UNIX manual output ie: 66 lines per page and possible bolding and underlining sequences. The understanding of bolding and underlining is there by default even if `--catman' is not specified.
`-Tnum'
`--tabsize=num'
set tabulator size to num. This option is ignored if --interpret=no is given.
`--non-printable-format=format'
specify how non-printable chars are printed. format can be `caret' (`^A', `M-^B' etc.), or `space' (a space is written instead of the non-printable character).

Headers

These are the options through which you may define the information you want to see all around the pages.

All these options support text as an argument, which is composed of plain strings and meta sequences. See section Meta sequences for details.

`-b[text]'
`--header[=text]'
set the page header
`-B'
`--no-header'
no page headers at all.
`-t[text]'
`--title[=text]'
set page title to text
`-u[text]'
`--underlay[=text]'
use text as under lay (or water mark), i.e., in a light gray, and under every page.
`--left-title[=text]'
`--right-title[=text]'
Set virtual page title to text.
`--left-footer[=text]'
`--footer[=text]'
`--right-footer[=text]'
Set sheet footers to text.

Input

`-c'
`--truncate-lines=bool'
Cut lines too large to be printed inside the borders. The maximum line size depends on format and font size used and whether line numbering is enabled.
`-i'
`--interpret=bool'
interpret tab, bs and ff chars
`-Xname'
`--encoding=name'
use input encoding name. Currently @pack supports:
`ascii'
Regular ASCII code.
`latin1'
The ISO Latin 1 encoding.
`latin2'
The ISO Latin 2 encoding. Not all the characters are yet supported, but it should get better one day.
`hp8'
The 8 bits Roman encoding for HP.
`mac'
`Macintosh encoding'
For the Macintosh encoding. The support is not sufficient, and a lot of character may be missing at the end of the job. This is planed to be fixed.
`ibmpc'
For the regular PC encoding. Not all the characters will be printed.
`pcg'
For the PC Graphic encoding.
`--prologue=prologue'
Use prologue as the PostScript prologue for @pack{}. prologue must be in a file named `prologue.pro', which be in a directory of your library path (see section Library files). Currently the available prologues are:
`black+white'
the regular presentation
`gray'
same presentation, but with gray shades for comments etc.
`gray2'
same as gray, but light declaration (such as function calls etc.) are mapped on the same shape as the strong declarations (such as function declaration etc.).
`color'
still the same idea, but with colors.
`--print-anyway=bool'
force binary printing. By default, binary files printing is stopped before second page. To detect such a file we make use of a very simple heuristic: if the first sheet of the file contains at less 75% of non-printing characters, it's a binary file. First sheet is always printed.

Output

`-ofile'
`--output=file'
leave output to file file. If file is `-', leave output to the standard output.
`-nnum'
`--copies=num'
print num copies of each page
`-D'
`--setpagedevice[=key:value]'
Pass a page device definition to the generated PostScript output. If no value is given, key is removed from the definitions. For example, command
a2ps -DDuplex:true report.pre
prints file `report.pre' in duplex (two side) mode. Page device operators are implementation dependent but they are standardized. See section Page device options for details.
`-S'
`--statusdict=key[:value]'
`--statusdict=key[::value]'
Pass a statusdict definition to the generated PostScript output. statusdict operators and variables are implementation dependent; see printer's documentation for details. See section Statusdict options for details. If no value is given, key is removed from the definitions. With a single colon, pass a call to an operator, for instance:
a2ps -Ssetpapertray:1 quicksort.c
prints file `quicksort.c' by using paper from the paper tray 1 (assuming that printer supports paper tray selection). With teo colons, define variable key to equal value. For instance:
a2ps -Spapertray::1 quicksort.c
produces
  /papertray 1 def
in the PostScript.
`-k'
`--page-prefeed'
enable page prefeeding. It consists in positioning the sheet in the printing area while the PostScript is interpreted (instead of waiting the end of the interpretation of the page before pushing the sheet). It can lead to an significant speed up of the printing. @pack quotes the access to that feature, so that non supporting printers won't fail.
`-K'
`--no-page-prefeed'
disable page prefeeding.
`-P[name]'
`--printer[=name]'
send output to the default printer, or to printer name.
`-snum'
`--side=num'
number of sheet sides. num is of course 1 or 2.

Pretty printing

`-g'
`--graphic-symbols=bool'
set symbols graphical conversion
`-Elanguage'
`--language=language'
use the language pretty print style sheet. See section Known languages, for the available style sheets.
`-K'
`--automatic-style=bool'
@pack will try to guess in what language is written your files, and use the corresponding style sheet.
`--strip-level=num'
Depending on the value of num:
  1. everything is printed;
  2. regular comments are not printed
  3. strong coments are not printed
  4. every comment is canceled.
This option is valuable for instance in java in which case strong comments are the so called documentation comments, or in SDL for which some graphical editors pollutes the specification with internal data as comments. Note that the current implementation is not satisfactory: some undesired blank lines remain. This is planed to be fixed.

Meta sequences

Headers, footers, titles and the water mark are strings in which some meta sequences are later replaced by their actual values. In general `%' are related to general information, while `$' meta sequences are related to the current file.

On a new sheet @pack first draws the water mark, then the content of the first page, then the frame of the first page, (ditto with the others), and finally the sheet header and footers. This order must be taken into account for some meta sequences (e.g., `$L', `$l').

Currently @pack support the following meta sequences:

`%%'
character `%'
`$$'
character `$'
`$?#cond#if_true#if_false#'
this may be used for conditional assignment. The separator (presented here as `#') may be any character. if_true and if_false may be defined exactly the same way as regular headers, included meta sequences and the `$?' construct. cond may be:
`l'
true if printing in landscape mode,
`v'
true if printing on the back side of the sheet (verso).
`1'
`2'
`3'
true if tag 1, 2 or 3 is not empty. See item `$t1' for explanation.
`$(var)'
value of the environment variable var
`%a'
the localized equivalent for `Printed by User Name'
`%A'
the localized equivalent for `Printed by User Name from Host Name'
`%a{username}'
the localized equivalent for `Printed by username'
`%A{username@hostname}'
the localized equivalent for `Printed by username from hostname'. These two are provided in the case @pack would be used by the print service: since neither of the user name nor the host name can be known at the time the files reach @pack{}, these options should be used.
`%c'
trailing component of the current working directory
`%C'
current time in `hh:mm:ss' format
`$C'
file modification time in `hh:mm:ss' format
`%d'
current working directory
`%D'
current date in `yy-mm-dd' format
`$D'
file modification date in `yy-mm-dd' format
`%D{string}'
format current date according to string with the strftime(3) function.
`$D{string}'
format file's last modification date according to string with the strftime(3) function.
`%e'
current date in localized short format (e.g., `Jul 4, 76' in English, or `14 Juil 89' in French).
`$e'
file modification date in localized short format.
`%E'
current date in localized long format (e.g., `July 4, 76' in English, or `Samedi 14 Juillet 89' in French).
`$E'
file modification date in localized long format.
`%F'
current date in `dd.mm.yyyy' format.
`$F'
file modification date in `dd.mm.yyyy' format.
`%l'
top most line number of the current page
`$l'
current line number. To print the page number and the line interval in the right title, use `--right-title="Page $p:%l-$l"'.
`$L'
number of lines in the current file.
`%m'
the host name up to the first `.' character
`%M'
the full host name
`%n'
the user login name
`$n'
input file name without the directory part
`%N'
the user's pw_gecos field up to the first `,' character
`$N'
the full input file name
`%p'
current page number
`$p'
page number for this file
`%P'
total number of pages printed
`$P'
number of pages of the current file
`%s'
current sheet number
`$s'
sheet number for the current file
`%S'
total number of sheets
`$S'
number of sheet of the current file
`%t'
current time in 12-hour am/pm format
`$t'
file modification time in 12-hour am/pm format
`$t1'
`$t2'
`$t3'
Content of tag 1, 2 and 3. Tags are piece of text @pack fetches in the files, according to the style. For instance, in mail-folder style, tag 1 is the title of the mail, and tag 2 its author.
`%T'
current time in 24-hour format `hh:mm'
`$T'
file modification time in 24-hour format `hh:mm'
`%*'
current time in 24-hour format with seconds `hh:mm:ss'
`$*'
file modification time in 24-hour format with seconds `hh:mm:ss'
`$v'
the sequence number of the current input file
`$V'
the total number of files
`%W'
current date in `mm/dd/yy' format
`$W'
file modification date in `mm/dd/yy' format

All format directives can also be given in format

escape width directive

where width specifies the width of the column to which the escape is printed. For example, escape `$5%' will expand to something like ` 12'. If the width is negative, the value will be printed left-justified.

Page device options

Page device is a PostScript level 2 feature that offers an uniform interface to control printer's output device. a2ps protects all page device options inside an if block so they have no effect in level 1 interpreters. Although all level 2 interpreters support page device, they do not have to support all page device options. For example some printers can print in duplex mode and some can not. Refer to the documentation of your printer for supported options.

Here are some usable page device options which can be selected with the `-D' option (`--setpagedevice'). For a complete listing, see PostScript Language Reference Manual: section 4.11 Device Setup.

Collate boolean
how output is organized when printing multiple copies
Duplex boolean
duplex (two side) printing
ManualFeed boolean
manual feed paper tray
OutputFaceUp boolean
print output `face up' or `face down'
Tumble boolean
how opposite sides are positioned in duplex printing

Statusdict options

The statusdict is a special storage entity in PostScript (called a dictionnary), in which some variables and operators determine the behavior of the printer. As for page device, those variables are device dependent: refer to the documentation of your printer for supported options.

Here are some statusdict definitions in which you might be interested:

manualfeed boolean
Variable which determine that the manual fed paper tray will be used.

Configuration files

@pack reads several files before the command line options. In the order, they are:

  1. the system configuration file (usually `/etc/a2ps.cfg')
  2. the user's home configuration file (`$HOME/.a2ps/a2psrc')
  3. the local file (`./.a2psrc')

In these files, empty lines and lines starting with `#' are comments. All other lines have the format:

`Options: options+'
Give @pack a list of command line options. options+ is any sequence of regular command line options (see section Command line options). The quoting mechanism is a bit painful: you need to quote the whole options+. For instance
Options: --right-title='Page $p'
is wrong. Write
Options: '--right-title=Page $p'
`Pattern: pattern language'
Specify that any file which name matches pattern (usual Unix file name patterns) should be treated with the style language. For instance, Promela programmers use the suffix `pr' for their file, though @pack hard codes `pr' to SDL. To override this rule, use:
Pattern: *.pr promela

Library files

@pack uses several files: its PostScript prologue, encoding related files, and such. @pack looks for these files in the following path:

$HOME/.a2ps:/usr/local/share/a2ps

You may change this default path with the environment variable A2PS_LIBRARY.

If you plan to define yourself some header files for @pack (option `--prologue'), they should be in one of those directory, with a `.pro' suffix.

Native Language Support

Localizing

@pack provides some Native Language Support, that is speaking your mother tongue. It uses two special features wrt non-English languages: on the one hand, the interface between you and it, and on the other hand, the format of the dates and times.

To use these features, you may set your environment variable LANG to the standard code representing your language (currently `fr' for French and `it' for Italian).

The problem with this approach is that a lot more than just messages and time information is affected: especially the way numbers are written changes, what may cause problems which awk and such.

So if you just want messages and time format to be localized, then define:

set LC_MESSAGES=fr
set LC_TIME=fr
export LC_MESSAGES
export LC_TIME

Note that the `make install' must have been done in order to have NLS support.

Helping on the translation

Please, help us internationalizing @pack{}. If you want to do a profound translation work, contact us. But we need in urgency small pieces of information: everything that appears on page.

This includes the standard date and time format, the word for `page' etc. A walk through the file `po/a2ps.pot' will give you the information you need.

Exit status

The following exit values are returned:

`0'
@pack terminated normally.
`1'
an error occured.
`2'
bad argument was given.
`3'
unknown language was given.

Pretty printing

The main feature of @pack is its pretty-printing capabilities. Two different levels of pretty printing can be reached:

Many things cannot be done with @pack{}: see section Syntactic limits for details.

Automatic style

The heuristic @pack uses to find out in which language is written a file is fairly simple:

  1. @pack tries the filename matching rules defined in its various configuration files. Upon success, the corresponding language style is used (see section Configuration files).
  2. It asks file(3) its opinion on the file. If the answer looks like a language, @pack trusts file, but for the C, since file has the bad habit to consider that quite everything is written in C.
  3. Upon failure, @pack tries to find out thanks to the file suffix and its own abbreviation databases (see section Name and abbreviations).

Two things are to retain from this:

  1. @pack won't guess anything for a file given through `stdin'.
  2. if file is wrong on some files, @pack will use bad style sheets. In this case, do try option `--guess', compare it with the output of file, and if the culprit is file, go and complain to your system administrator :-), or fix it by defining your own filename pattern matching rules (see section Configuration files).

Known languages

@pack version 4.7.20 supports the following languages:

ada
C
C++
caml (ml)
Claire (cl)
More information on this languages can be found on
@url{http://www.ens.fr/~laburthe/claire.html}
coq-vernacular (coq)
Common-lisp (lsp)
Eiffel (e)
Fortran (f)
This style was developed by Denis Girou @email{Denis.Girou@idris.fr}.
java
lace (ace)
mailfolder (mail)
Support for mail folders is rather good. For elm, use `a2ps -2mgEmail %s'. This style also suits news files.
Modula-3 (m3)
68000
o2c
Oberon
Ora
This style was written by Pierre Mareschal @email{pmaresch@be.oracle.com}.
Pascal (pas)
perl (pl)
PL-SQL
This style was written by Pierre Mareschal @email{pmaresch@be.oracle.com}.
PostScript (ps)
PreScript (pre)
prolog (pro)
promela (pml)
This style was written thanks to Jean-Philippe Cottin @email{cottin@inf.enst.fr}.
python (py)
Sather (sa)
Scheme (scm)
SDL-88 (sdl)
This style was written thanks to Jean-Philippe Cottin @email{cottin@inf.enst.fr}. SDL may be the language for which `--strip-level=2' is the most useful: it cancels the graphical information left by graphic editors. Only the pure specification is then printed.
sh
SQL
SQL92
These styles were written by Pierre Mareschal @email{pmaresch@be.oracle.com}.
tcl
tk
Since everything, in those languages, are strings, what prints @pack is not always what you would like (see section Syntactic limits).
Unity
This style was written thanks to Jean-Philippe Cottin @email{cottin@inf.enst.fr}. Note that the graphic conversion of the symbols (`-g') is just perfect for this language.
Verilog
This style was written by Edward Arthur @email{eda@ultranet.com}.
VHDL
This style was written by Thomas Parmelan @email{Thomas.Parmelan@efrei.fr}.
zsh

Definition of the style sheets

@pack pretty prints a source file thanks to style sheets, one per language. In the following is described how the style sheets are defined. You may skip this section if you don't care how @pack does this, and if you don't expect to implement new styles.

Name and abbreviations

Every style has a unique name (reported with `--list-features'). It has also a list of abbreviations (which should include usual suffix for the language, such as `e' for the Eiffel language).

Any of the name or abbreviations can be used with option `-E'. When automatic pretty-printing is enabled, first @pack calls file to see whether the language is recognizable. Otherwise, the suffix of the file is compared with every name and abbreviation. On failure, plain style is used.

Alphabets

@pack needs to know the beginning and the end of a word, especially keywords. Hence it needs two alphabets: the first one specifying by which letters an identifier can begin, and the second one for the rest of the word.

Keywords and regular symbols

A keyword if recognized, is just written in a special font. A symbol, when recognized, is replaced by the corresponding character in the symbol font. To be recognized, both need to start by a character in the first alphabet and to be immediately followed by a character which does not belong to the second alphabet.

Special symbols

They need not to be preceded and followed by characters belonging to the alphabet. For instance in `caml', `not' is a regular symbol: it represents boolean negation; but in neither `nota' or `notnot', the three first letters represent `not'. On the contrary `<>' always means `not equal', even in `a<>b'.

Both regular and special symbols are transformed only if option `--graphic-symbols' was given.

Sequences

Sequences are string is a string between two markers. A marker is a fixed string. Typical examples are strings (with usually `"' as opening and closing markers), comments etc. Three fonts are used: one for the initial marker, one for the core of the sequence, and a last one for the final maker.

Escapes and verbatims

Escapes are immediately copied when found in a sequence. Their main use is to avoid a sequence from being terminated too soon, e.g., the string `"\""' is legal in C, hence it is necessary to specify in @pack that `\\' and `\"' have to be written has such when in a sequence: they are escapes.

Verbatims are immediately copied wherever met. It has been implemented for ada in which `"'' is the constant character `''. @pack must not understand it as opening of a sequence (first quote), closing of the sequence (second quote), opening of a sequence (third quote). Nor is it possible to specify that `'' is an escape...

Case sensitivity

If the style is case insensitive, the case does not matter for the keyword, symbol and sequence recognition. Other categories are not concerned by case sensitivity.

Writing new style sheets

To be able to define new style sheets one needs GNU m4. Also, never update `styles.c' by hand, but its precursor `styles.c.in'.

There is a couple of things to know about the process. But in anyway, please use the already defined languages as examples, and see the prologue of `styles.c.in' where many m4 macros are defined to ease the implementation. Read also `styles.h' where information is given on the struct used for the style sheets.

The order in which you define the elements of a category (but the sequences) does not matter. But since @pack sorts them at run time, it may save time if the alphabetical C-order is more or less followed.

For the particular case of the special symbols, note that you may have to protect the symbols which are prefixed by them. For instance if in Pascal you define `=' to be a special symbol, you have to protect the `=' in `:='. Otherwise @pack will see a `;', written such as, but will transform the `=' in the symbol you specified. Hence declare `a2_not_symbol(:=)'.

It is possible to specify that a sequence may only begin at the start of a line, prefixing the opening marker with a `^'. If the marker starts with a `\', that character is always ignored (hence `\^' if you need to use `^' without constraint on the position in the line).

A closing marker may require to end on end-of-line. Use `$' to specify this. If the marker is ended by a `\', that caracter is ignored, hence with `money$\', `money$' is closing anywhere on the line.

It is also possible to specify several closing markers, just by putting them one after the other, for instance (taken for the ada style sheet):

a2_sequence(procedure , keyword_strong, label, ` is', keyword_strong),
a2_sequence(procedure , keyword_strong, label, ` (', courier),
a2_sequence(procedure , keyword_strong, label, `(', courier),
a2_sequence(procedure , keyword_strong, label, `$', courier),
a2_sequence(procedure , keyword_strong, label, `;', courier),

Please note that:

  1. the order between sequences does matter. For instance in java, `/**' introduces strong comments, and `/*' comments. `/**' must be declared before `/*', or it will be hidden.
  2. closing alternatives must be grouped together (no sequence with a different opener must occur while defining alternative closers).
  3. closing marker may have different shape (like ` is' and `(' above).
  4. `$' is used instead of a hard coded `\n'. Some encodings do not use `\n' as end-of-line, hence a style using `\n' would not be portable.

Please, respect the alphabetical order in which the languages are introduced. Don't forget to update `STYLE' in `styles.h', and to add your language in the macro a2_styles at the bottom of `styles.c.in'.

PreScript

PreScript has been designed in conjunction with @pack{}. Since bold sequences, special characters etc. were implemented in @pack{}, we thought it would be good to allow direct access to those features: PreScript became an input language for @pack{}, 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.).

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 @pack{}:

\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).

PreScript commands

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 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.

Printed symbols

There is a big menagerie of symbols. To get a list, it is suggested to print @pack{}'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.

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.

Quotation

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

Differences with LaTeX

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.

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'. @pack 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 @pack{}.

Examples

PreScript and @pack 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

Various

In this chapter is collected what had no place in the rest of this document.

Frequently asked questions

Printing goes beyond the frame of the paper

You are currently printing with a bad media, for instance using A4 paper within @pack{}, while your printer uses Letter paper. See section Global behavior, option `--media' for more.

Can I have other colors?

There seems to be as many tastes as there are humans, so... don't expect from me the design of the style you like :).

Nevertheless, here are some tips on how to design your PostScript styles. It is strongly recommended to use `gray.pro' or `color.pro' as a template.

There are two PostScript instructions you might want to use in your new PostScript prologue:

setgray
this instruction must be preceded by a number between 0 (black) and 1 (white). It defines the gray level used.
setrgbcolor
this instruction must be preceded by three numbers between 0 (0 %) and 1 (100%). Those three numbers are related to red, green and blue proportions used to designate a color.

Why not having used yacc and such

There are several reasons why we decided not to use grammars to parse the files.

First it would have made the design of the style sheets much more tricky, and today @pack would know only 4 or 5 languages.

Second, it limits the number of persons who could build a style sheet.

Third, mixing several parsers within one program is not easy. Moreover, its size would have ten times what it is.

Fourth, we did not feel the need for such a powerful tool: handling the keywords and the sequences is just what the users expect.

And last but not least, using a parser requires that the sources are syntactic bug free, which is a strong requirement.

Nevertheless, PreScript gives the possibility to have on the one hand a syntactic parser which would produce PreScript code, and on the other hand, @pack{}, which would make it PostScript. This schema seems to us a good compromise.

Man pages

There are no man pages because now the documentation is written in Texinfo. What you are reading comes from this initial Texinfo file.

Nevertheless, man pages may be back from Hell the day a texi2roff filter appears.

Can I change the base font

No you can't. Fonts are hard coded in @pack{}(1), to get good execution results, and because it is easier. Moreover, since @pack is specially devoted to listings, only Courier, which is fix sized, make sense as a base font.

If you need to deal with several various fonts, then GNU enscript is exactly the tool you need.

What next?

More encodings

It would be great if @pack could easily print files written in ISO Latin 2. Currently I don't know how to do that, but ogonkiky may be of valuable help. If you encoded new encodings support, please contact us.

EPSF

@pack should be able to generate EPS files in a short while.

Spelling checking, syntax fixing.

When printing a human file (only English may be supported), spelling should be checked. When pretty-printing, syntax errors should be underlined.

No just kidding :). Do it yourself...

Genesis

History

The initial version was a shell program written by @email{evan@csli} (Evan Kirshenbaum). It was very slow and contained many bugs.

A new version was written in C by Miguel Santana for improve speed execution and portability. Many new features and improvements have been added since this first version. Many contributions (changes, fixes, ideas) were done by a2ps users in order to improve it.

From the latest known version from Miguel Santana (4.3), Emmanuel Briot implemented bold faces for keywords in ada, c and c++.

From that version, Akim Demaille generalized the pretty-printing capabilities, implemented more languages support, and quite a lot other things.

Since the very beginning of @pack{}, many people have brought help:

Some people helped to the translation:

Thanks

A big thank must be given to Markku Rossi (the author of GNU enscript), for the advises he gave, and for portions of his code which are now used in @pack{}. Even portions of this very documentation are taken from the GNU enscript man pages.

Denis Girou brought a constant and valuable support through out the genesis of pretty-printing @pack{}.

Copying

The subroutines and source code in the @pack package are "free"; this means that everyone is free to use them and free to redistribute them on a free basis. The @pack{}-related programs are not in the public domain; they are copyrighted and there are restrictions on their distribution, but these restrictions are designed to permit everything that a good cooperating citizen would want to do. What is not allowed is to try to prevent others from further sharing any version of these programs that they might get from you.

Specifically, we want to make sure that you have the right to give away copies of the programs that relate to @pack{}, that you receive source code or else can get it if you want it, that you can change these programs or use pieces of them in new free programs, and that you know you can do these things.

To make sure that everyone has such rights, we have to forbid you to deprive anyone else of these rights. For example, if you distribute copies of the @pack{}-related code, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must tell them their rights.

Also, for our own protection, we must make certain that everyone finds out that there is no warranty for the programs that relate to @pack{}. If these programs are modified by someone else and passed on, we want their recipients to know that what they have is not what we distributed, so that any problems introduced by others will not reflect on our reputation.

The precise conditions of the licenses for the programs currently being distributed that relate to @pack are found in the General Public Licenses that accompany them.

Concept Index

$

  • `$'
  • .

  • `.a2ps'
  • ^

  • `^'
  • a

  • `a2psrc'
  • Alphabets
  • ASCII
  • c

  • Command line options
  • Configuration files
  • Copying
  • e

  • Encodings
  • Escapes
  • Exit status
  • h

  • Headers
  • HP encoding
  • l

  • Latin 1
  • Latin 2
  • Library files
  • m

  • Markers
  • Meta sequences
  • o

  • Options
  • p

  • Page device
  • Page prefeed
  • PC encoding
  • PC graphic encoding
  • PreScript
  • Pretty printing
  • Prologue
  • q

  • Quotation in PreScript
  • r

  • Regular symbols
  • s

  • Sequences
  • setpagedevice
  • Special symbols
  • statusdict
  • Style sheets
  • Symbol conversion
  • Symbols
  • u

  • Under lay
  • v

  • Verbatims
  • Virtual page
  • w

  • Water mark

  • This document was generated on 9 June 1997 using the texi2html translator version 1.51.