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

2 User's Guide

This chapter is devoted to people who don't know a2ps yet: we try to give a soft and smooth introduction to the most useful features. For a reference manual, see section 3 Invoking a2ps. For the definition of some words, see section A Glossary, for questions you have, see section 10 Frequently asked questions.

2.1 Purpose

a2ps is a program that takes a text file (i.e., human readable), and makes a PostScript file out of it. Typically output is sent to a printer.

2.2 How to print

To print a file `doc.txt', just give it to a2ps: the default setting should be the one you'd like:

gargantua ~ $ a2ps doc.txt
[doc.txt (plain): 9 pages on 5 sheets]
[Total: 9 pages on 5 sheets] sent to the default printer

a2ps sent the file `doc.txt' to the default printer, writing two columns of text on a single face of the sheet. Indeed, by default a2ps uses the option `-2', standing for two virtual pages.

2.2.1 Basics for Printing

Say you want to print the C file `bar.c', and its header `foo.h', on 4 virtual pages, and save it into the file `foobar.ps'. Just hit:

gargantua $ a2ps foo.h bar.c -4 -o foobar.ps
[foo.h (C): 1 page on 1 sheet]
[bar.c (C): 3 pages on 1 sheet]
[Total: 4 pages on 2 sheets] saved into the file `foobar.ps'

The option `-4' tells a2ps to make four virtual pages: two rows by two columns. The option `-o foobar.ps' (which is the short version of `--output=foobar.ps') specifies the output file. Long options must always be separated by spaces, though short options with no arguments may be grouped.

Note too that the options may be specified before or after the files, it does not matter.

If you send `foobar.ps' to a printer, you'll discover that the keywords were highlighted, that the strings and comments have a different face. Indeed, a2ps is a pretty-printer: if it knows the (programming) language in which your file is written, it will try to make it look nice and clear on the paper.

But too bad: `foo.h' is only one virtual page long, and `bar.c' takes three. Moreover, the comments are essential in those files. And even worse: the system's default printer is out of ink. Thanks god, precious options may help you:

gargantua $ a2ps -4 -Av foo.h bar.c --prologue=gray -P lw
[foo.h (C): 1 page on 1 sheet]
[bar.c (C): 3 pages on 1 sheet]
[Total: 4 pages on 1 sheet] sent to the printer `lw'

Here the option `-A' is a short cut for the option `--file-align' which specifies how different files should be separated. This option allows several symbolic arguments: `virtual', `rank', `page', `sheet' (See section 3.1.3 Sheet Options, for more details). The value `virtual' means not to start each file on a different virtual pages.

So to fill the page is asked by `--file-align=virtual', or `-A virtual'. But symbolic arguments can be abbreviated when there are no ambiguity, so here, you can just use `-Av'.

The option `-P lw' means to print on the printer named `lw', and finally, the long option `--prologue' requires the use one of the alternative printing styles. There are other prologues (See section 3.1.6 Input Options, option `--prologue'), and you can even design yours (see section 8.6 Designing PostScript Prologues).

2.2.2 Special Printers

There are three special printers pre-defined.

The first one, void, sends the output to the trash. Its main use is to see how many pages would have been used.

gargantua ~ $ a2ps -P void parsessh.c
[parsessh.c (C): 33 pages on 17 sheets]
[Total: 33 pages on 17 sheets] sent to the printer `void'

The second, display sends the output to Ghostview, so that you can check the output without printing. Of course if you don't have Ghostview, it won't work... And it is up to you to configure another displaying application (see section 4.5 Your Printers).

The last, file saves the output into a file named after the file you printed (e.g., saves into `foo.ps' when you print `foo.c').

2.2.3 Using Delegations

a2ps can decide that a2ps itself is not the right tool to do what you want. In that case it delegates the task to other programs. What you should retain from this, is, forget that there are delegations. Indeed, the interface with the delegations has been designed so that you don't need to be aware that they exist to use them. Do as usual.

As an example, if you need to print a PostScript file, just hit:

gargantua ~ $ a2ps article.ps -d
[article.ps (ps, delegated to PsNup): 7 pages on 4 sheets]
[Total: 8 pages on 4 sheets] sent to the default printer

While honoring your defaults settings, a2ps delegates the task to put two virtual pages per physical page to psnup, a powerful filter part of the famous psutils by Angus Duggan.

Suppose now that you want to display a Texinfo file. Then, provided you have all the programs a2ps needs, just hit

gargantua ~ $ a2ps a2ps.texi -P display
[a2ps.texi (texinfo, delegated to texi2dvi): 75 pages on 38 sheets]
[Total: 76 pages on 38 sheets] sent to the printer `display'

Once the read documentation, you know you want to print just pages 10 to 20, plus the cover. Just hit:

gargantua ~ $ a2ps a2ps.texi --pages=1,10-20 -d
[a2ps.texi (texinfo, delegated to texi2dvi): 13 pages on 7 sheets]
[Total: 14 pages on 7 sheets] sent to the default printer

A final word: compressed files can be treated in the very same way:

gargantua ~ $ a2ps a2ps.texi.gz -a1,10-20 -d
[a2ps.texi (compressed, delegated to Gzip-a2ps): 13 pages on 7 sheets]
[Total: 14 pages on 7 sheets] sent to the default printer

You should be aware that:

2.2.4 More Tricky Uses

If you still want to save more paper, and you are amongst the set of happy users of Duplex printers, a2ps will also be able to help you (See section A Glossary, for definitions). The option to specify Duplex printing is `--sides=mode' (see section 3.1.9 PostScript Options).

Here is how to print the documentation in Duplex and send it to the Duplex printer `margot':

quasimodo ~ a2ps/doc $ a2ps -s2 -Pmargot a2ps.texi
[a2ps.texi (texinfo, delegated to texi2dvi): 109 pages on 28 sheets]
[Total: 110 pages on 28 sheets] sent to the printer `margot'

This is also valid for several files.

Actually, you can do something even more tricky: print a small book! This is much more complicated than printing Duplex, because the pages needs to be completely reorganized another way. This is precisely the job of psbook, yet another PsUtil from Angus Duggan. But there is a user option which encapsulates the magic sequence of options: `book'. Therefore, just run

quasimodo a2ps/doc $ a2ps -=book -Pmargot a2ps.texi
[a2ps.texi (texinfo, delegated to texi2dvi): 109 pages on 109 sheets]
[Total: 109 pages on 109 sheets] sent to the printer `margot'

and voila` !, a booklet printed on margot!

We strongly discourage you to try with several files at once, because the tools then easily get lost. And, after all, the result will be exactly the same once you collated all the booklets together.

Another limitation is that this does not work if it is not sent to a printer. This kind of weird limitations will be solved in the future.

2.2.5 Checking the Defaults

If a2ps did not have the behavior expected, this may be because of the default settings given by your system administrator. Checking those default values is easy:

gargantua ~ $ a2ps --list=defaults
Configuration status of a2ps 4.12
Sheets:
  default paper         = A4
  layout per page       = 2 x 1 (landscape, rows first)
  borders               = yes
  file alignment        = virtual
  inside margin         = 0
More stuff deleted here
Internals:
  verbosity level     = 2
  file command        = /usr/ucb/file -L
  temporary directory =
  library path        =
        /inf/soft/infthes/demaille/.a2ps
        /usr/local/share/a2ps/sheets
        /usr/local/share/a2ps/ps
        /usr/local/share/a2ps/encoding
        /usr/local/share/a2ps/afm
        /usr/local/share/a2ps/printers
        /usr/local/share/a2ps

Remember that the on-line help is always available. Moreover, if your screen is small, you may pipe it into more. Just trust this:

a2ps --help | more

2.3 Important parameters

Many things are parameterizable in a2ps, but two things are just essential to make sure everything goes right:

The paper
Make sure that the paper a2ps uses is the same as your printer (See section 3.1.3 Sheet Options, option `--medium').
The encoding
Make sure that the encoding a2ps uses is the same as the standard alphabet in your country (See section 3.1.6 Input Options, option `--encoding').

Both values may be checked with `a2ps --list=defaults'.

2.4 Localizing

a2ps provides some Native Language Support, that is speaking your mother tongue. It uses three special features for non-English languages:

the tongue
i.e., the language used by the interface,
the date
i.e., the format and the words used in the language to specify a date.

To use these features, you may set your environment variable LANG to the standard code representing your language:

Catalan (ca), Czech (cs), Danish (da), German (de), Spanish (es), French (fr), Italian (it), Korean (ko), Dutch (nl), Norwegian (no), Polish (pl), Portuguese (pt), Russian (ru), Slovenian (sl), Swedish (sv), Turkish (tr).

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 with awk and such.

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

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

2.5 Interfacing with Other Programs

Here are some tips on how to use a2ps with other programs.

2.5.1 Interfacing With a Mailer

When you print from a mailer (or a news reader), your mailer calls a tool, say a2ps on a part of the whole mailbox. This makes it difficult for a2ps to guess that the file is of the type `mail'. Therefore, for better results, make sure to tell a2ps the files are mails. The user option `mail' (or `longmail' for longer inputs) encapsulates most typical tuning users want to print mails (for instance, don't print all the headers).

Most specifically, if your mailer is:

elm
Once you are in elm, hit o to enter in the options edition menu, hit p to edit the printer command, and enter `a2ps -=mail %s -d'. The option `-d' means to print on the default printer.
pine
Jan Chrillesen suggests us how to use a2ps with the Pine mail-reader. Add the following to `.pinerc' (of course you can put it in `pine.conf' as well):
# Your printer selection
printer=a2ps -=mail -d

# Special print command
personal-print-command=a2ps -=mail -d

2.5.2 Netscape

This is actually valid for any program that generates PostScript that you want to post-process with a2ps. Use the following command:

a2ps

Not too hard, isn't it?

Nevertheless, this setting suppose your world is OK, your file(1) detects correctly PostScript files, and your a2ps is configured to delegate. In case one one these conditions is not met, use:

a2ps -ZEps

Do not forget to tell Netscape whether your printer supports colors, and the type of paper it uses.

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