WD: Changing Page Number Formats with PostScript

Last reviewed: October 20, 1997
Article ID: Q92797
The information in this article applies to:
  • Microsoft Word for the Macintosh, versions 3.0, 3.01, 3.02, 4.0, 5.0, 5.1

SUMMARY

In Microsoft Word, you can use PostScript code to change the starting page number in a section. For instance, you can have a 20-page document with the first 10 pages numbered from 1 to 10 and the last 10 pages numbered from 15 to 24. You can also change the position of the page numbers on the page and change the font and font size of the page numbers.

TO CHANGE THE STARTING PAGE NUMBER

  1. From the File menu, choose Page Setup. Click the Options button and select Larger Print Area. Choose the OK button in the Options dialog box and then choose the OK button in the Page Setup dialog box.

  2. Place the insertion point (the blinking cursor) at the point where you want to start renumbering pages.

  3. From the Insert menu, choose Section Break (in Word 3.x and 4.0, hold down the COMMAND key and press the ENTER key on the numeric keypad).

  4. From the Format menu, choose Section. From the Start list box, select New Page (this is the default in Word 3.x and 4.0).

  5. In the Section dialog box, under Page Numbers, select Restart At 1. Choose the OK button.

  6. From the View menu (the Document menu in Word 3.x and 4.0), choose Header. Type the code as shown in the table after step 11 on page 2.

  7. Change "15" in the first line to the number you want Microsoft Word to start numbering from.

  8. Highlight the nine lines of code to select them. From the Format menu, choose Style (in Word 3.x and 4.0, hold down the SHIFT key and choose All Styles from the Format menu). Click the All Styles option button.

  9. From the list of styles in the Style dialog box, select PostScript and choose the OK button. The selected lines will now have the PostScript style: hidden, 10 point, bold.

  10. After the PostScript code, insert a paragraph mark by pressing RETURN. Remove any hidden character formatting from this paragraph mark by using the Character command on the Format menu or by applying the Normal style.

    NOTE: If you do not insert a nonhidden paragraph after the PostScript code in the header, Word may print the page number on the incorrect page.

  11. Close the header and print the document.

       Sample PostScript Code                           Description
       ----------------------                           -----------
    
       /startnum 15 def                                 Starts the page
                                                        numbering at 15.
                                                        Change "15" to the
                                                        desired starting
                                                        page number.
    
       /pgnum 4 string def                              Defines the string
       /temp 4 string def                               variables "pgnum"
       /inch {72 mul} def                               and "temp" and
                                                        defines the variable
                                                        "inch" for
                                                        converting inches to
                                                        points. You do not
                                                        need to change these
                                                        lines of code.
    
       /Times-Roman findfont 12 scalefont setfont       Sets Times(R) as
                                                        the page number font
                                                        and sets the size to
                                                        12 points. To change
                                                        these settings, see
                                                        the "Customization"
                                                        section below.
    
       8.0 inch 10.5 inch moveto                        Sets the distance
                                                        from the left and
                                                        bottom of the page,
                                                        respectively. To
                                                        change this setting,
                                                        see the
                                                        "Customization"
                                                        section below.
    
       /pgnum {wp$page startnum 1 sub add temp cvs} def Adds "startnum" (in
                                                        this example, "15")
                                                        to Word’s internal
                                                        page number (which
                                                        is 1, per step 5
                                                        above). The sum of
                                                        these numbers, minus
                                                        1 ("1 sub" means
                                                        subtract 1), is the
                                                        new page number.
    
       pgnum stringwidth pop neg 10 neg rmoveto         Tells Word to move
                                                        to the proper page
                                                        number location.
    
       pgnum show                                       Tells Word to print
                                                        the page number.
    
    

CUSTOMIZATION

Page Number Position

The preceding sample PostScript code prints the page number in the upper-right corner of the page. To change the position of the page number, replace line 6 of the above code with the desired location of the page number from the lower-left edge of the page. For instance, to print the page number at the center and bottom of the page, change the line to read:

   4.25 inch .5 inch moveto

These numbers represent specific positions on the page. The first number is the horizontal position, where the left edge of the page is 0 (zero). The second number is the vertical position, where the bottom of the page is 0. These measurements assume an 8.5-by-11-inch sheet of paper.

Font and Font Size

The preceding sample PostScript code prints the page numbers in Times 12-point type. To change the font and font size, replace the font name and font size in line 5 with the PostScript name and number of the font you want. To find the PostScript name for the font you want, see the list below or use the Apple(R) LaserWriter(R) utility that comes with the printer. For example, to print the page number in Palatino(R) 10 point, change the line to read:

   /Palatino-Roman findfont 10 scalefont setfont

The following is a list of 35 standard typefaces resident in almost all PostScript printers. "Demi" is bold, "Oblique" is italic, and "Book" and "Roman" are plain type.

   AvantGarde-Book
   AvantGarde-BookOblique
   AvantGarde-Demi
   AvantGarde-DemiOblique
   Bookman-Demi
   Bookman-DemiItalic
   Bookman-Light
   Bookman-LightItalic
   Courier
   Courier-Bold
   Courier-BoldOblique
   Courier-Oblique
   Helvetica(R)
   Helvetica-Bold
   Helvetica-BoldOblique
   Helvetica-Narrow
   Helvetica-Narrow-Bold
   Helvetica-Narrow-BoldOblique
   Helvetica-Narrow-Oblique
   Helvetica-Oblique
   NewCenturySchlbk-Bold
   NewCenturySchlbk-BoldItalic
   NewCenturySchlbk-Italic
   NewCenturySchlbk-Roman
   Palatino-Bold
   Palatino-BoldItalic
   Palatino-Italic
   Palatino-Roman
   Symbol
   Times-Bold
   Times-BoldItalic
   Times-Italic
   Times-Roman(R)
   ZapfChancery-MediumItalic
   ZapfDingbats

The fonts in the preceding list are installed on the following LaserWriters:

   LaserWriter Plus
   LaserWriter IINT
   LaserWriter IINTX
   Personal LaserWriter NT

LIMITATIONS

  1. You cannot add a different first header in the section of your document that contains the PostScript code shown in the previous list of this Application Note.

  2. PostScript instructions will not print to non-PostScript printers, such as the StyleWriter(R), Personal LaserWriter, or Hewlett- Packard(R) DeskWriter(TM).

PRINTING THE WORD "PAGE" IN FRONT OF THE PAGE NUMBER

To print the word "Page" in front of the page number, three lines need to be inserted in the PostScript code. The text below is the modified PostScript code. The added lines begin with an asterisk. Do not enter the asterisk in the actual code.

     /startnum 15 def
     /pgnum 4 string def
     /temp 4 string def
     /inch {72 mul} def
  *  /Text (Page ) def
     /Times-Roman findfont 12 scalefont setfont
     8.0 inch 10.5 inch moveto
     /pgnum {wp$page startnum 1 sub add temp cvs} def
     pgnum stringwidth pop neg 10 neg rmoveto
  *  Text stringwidth pop neg 0 rmoveto
  *  Text show
     pgnum show

The above code will have the PostScript style applied to it.

Description of inserted lines:

   /Text (Page ) def

      This line defines the variable "Text". When this variable is
      printed, the word "Page " (with a space after it) will print.

   Text stringwidth pop neg 0 rmoveto
   Text show

      These two lines print the word "Page" to the right of the page
      number.

MORE INFORMATION

For more information about learning PostScript, please see "Learning PostScript: A Visual Approach" by Ross Smith (Berkeley: Peachpit Press, 1990).

For more information about using PostScript with Microsoft Word, please see the following resources:

"Using Microsoft Word"version 5.0, 5.1, Appendix G

"Reference to Microsoft Word," version 4.0, pages 284-288

"Reference to Microsoft Word," version 3.0, pages 279-284


Additional reference words: macword macword5
Keywords : kbprg kbprint
Version : MACINTOSH: 3.0, 3.01, 3.02, 4.0, 5.0, 5.1;
Issue type : kbhowto kbinfo


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: October 20, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.