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


4. Paper size and landscape orientation

Most TeX documents at a particular site are designed to use the standard paper size (letter size in the United States, A4 in Europe). The Dvips program can be customized either sitewide or for a particular printer.

But many documents are designed for other paper sizes. For instance, you may want to design a document that has the long edge of the paper horizontal. This can be useful when typesetting booklets, brochures, complex tables, or many other documents. This type of paper orientation is called landscape orientation (the default orientation is portrait). Alternatively, a document might be designed for ledger or A3 paper.

Since the intended paper size is a document design decision, not a printing decision, such information should be given in the TeX file and not on the Dvips command line. For this reason, Dvips supports a `papersize' special. It is hoped that this special will become standard over time for TeX previewers and other printer drivers.

4.1 `papersize' special

The format of the `papersize' special is

\special{papersize=width,height}

width is the horizontal size of the page, and height is the vertical size. The dimensions supported are the same as for TeX; namely, in (inches), cm (centimeters), mm (millimeters), pt (points), sp (scaled points), bp (big points, the same as the default PostScript unit), pc (picas), dd (didot points), and cc (ciceros).

For a US letter size landscape document, the papersize would be:

\special{papersize=11in,8.5in}

An alternate specification of landscape:

\special{landscape}

This is supported for backward compatibility, but it is hoped that reventually the papersize comment will dominate.

Of course, such a \special only informs Dvips of the desired paper size; you must also adjust \hsize and \vsize in your TeX document typeset to those dimensions.

The papersize special must occur somewhere on the first page of the document.

4.2 Configuration file paper size command

The `@' command in a configuration file sets the paper size defaults and options. The first `@' command defines the default paper size. It has three possible parameters:

@ [name [hsize vsize]]

If `@' is specified on a line by itself, with no parameters, it instructs Dvips to discard all previous paper size information (possibly from another configuration file).

If three parameters are given, with the first parameter being a name and the second and third being a dimension (as in `8.5in' or `3.2cc', just like in the `papersize' special), then the option is interpreted as starting a new paper size description, where name is the name and hsize and vsize define the horizontal and vertical size of the sheet of paper, respectively. For example:

@ letterSize 8.5in 11in

If both hsize and vsize are zero (you must still specify units!) then any page size will match. If the `@' character is immediately followed by a `+' sign, then the remainder of the line (after skipping any leading blanks) is treated as PostScript code to send to the printer, presumably to select that particular paper size:

@ letter 8.5in 11in
@+ %%BeginPaperSize: Letter
@+ letter
@+ %%EndPaperSize

After all that, if the first character of the line is an exclamation point, then the line is put in the initial comments section of the final output file; else, it is put in the setup section of the output file. For example:

@ legal 8.5in 14in
@+ ! %%DocumentPaperSizes: Legal
@+ %%BeginPaperSize: Legal
@+ legal
@+ %%EndPaperSize

When Dvips has a paper format name given on the command line, it looks for a match by the name; when it has a `papersize' special, it looks for a match by dimensions. The first match found (in the order the paper size information is found in the configuration file) is used. If nothing matches, a warning is printed and the first paper size is used. The dimensions must match within a quarter of an inch. Landscape mode for all paper sizes is automatically supported.

If your printer has a command to set a special paper size, then give dimensions of `0in 0in'; the PostScript code that sets the paper size can refer to the dimensions the user requested as `hsize' and `vsize'; these will be macros defined in the PostScript that return the requested size in default PostScript units. Virtually all of the PostScript commands you use here are device-dependent and degrade the portability of the file; that is why the default first paper size entry should not send any PostScript commands down (although a structured comment or two would be okay). Also, some printers want `BeginPaperSize' comments and paper size setting commands; others (such as the NeXT) want `PaperSize' comments and they will handle setting the paper size. There is no solution I could find that works for both (except maybe specifying both).

The Perl 5 script `contrib/mkdvipspapers' in the distribution directory may help in determining appropriate paper size definitions.

If your printers are configured to use A4 paper by default, the configuration file (probably the global `config.ps' in this case) should include this as the first `@' command:

@ A4size 210mm 297mm
@+ %%PaperSize: A4

so that A4size is used as the default, and not A4 itself; thus, no PostScript a4 command is added to the output file, unless the user explicitly says to use paper size `a4'. That is, by default, no paper size PostScript command should be put in the output, but Dvips will still know that the paper size is A4 because `A4size' is the first (and therefore default) size in the configuration file.

Executing the `letter' or `a4' or other PostScript operators cause the document to be nonconforming and can cause it not to print on certain printers, so the default paper size should not execute such an operator if at all possible.

4.3 Paper trays

Some printers, such as the Hewlett-Packard HP4si, have multiple paper trays. You can set up Dvips to take advantage of this using the bop-hook PostScript variable (see section 5.3.4 PostScript hooks).

For example, suppose you have an alternate tray stocked with letterhead paper; the usual tray has the usual paper. You have a document where you want the first page printed on letterhead, and the remaining pages on the usual paper. You can create a header file, say `firstletterhead.PS', with the following (PostScript) code (bop-hook is passed the current physical page number, which starts at zero):

/bop-hook { dup 0 eq { alternatetray } { normaltray } ifelse } def

where alternatetray and normaltray are the appropriate commands to select the paper trays. On the 4SI, alternatetray is `statusdict begin 1 setpapertray end' and normaltray is `statusdict begin 0 setpapertray end'.

Then, include the file with either


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