-->

Previous | Table of Contents | Next

Page 237

JUST A MINUTE
There are many different macros and macro sets included with the TeX formatting system. Covering the details of complex formatting is beyond the scope of this book, but you're encouraged to experiment, starting with simple commands to get a feel for typesetting documents. There are nearly 100 books on using TeX on the market. If you're serious about learning how to use TeX, a good book is indispensable.

Printing Text Documents

After you've finished formatting your text files, using either a series of filters or inserted typesetting commands, you'll want to print your file to produce a typeset document. In order to control the printing of your documents, you need to understand how Linux handles printing, and how to start, stop, cancel, or control the printing process.

There are several printing commands you'll use to control the printing process on your system. This section first shows you how your printer is described under Linux, and where the important printer files are located.

Printers are known as character mode devices, and are listed under the /dev directory. Look at the following example:


# ls /dev/lp*

/dev/lp0 /dev/lp1 /dev/lp2

This shows the three parallel printer devices installed on your system by default. Chances are good that you have a parallel printer attached to your computer, so this hour's discussion is limited to parallel printers. Once set up, you'll find little difference between how parallel and serial printers are handled by Linux.

TIME SAVER
Serial printers are serial devices, and have names such as /dev/ttySX, where X is a number from 0 to 3, similar to your modem ports. Read the setserial command's manual page to learn how to set your serial port to the fastest baud rate your printer supports.

To determine if your printer is working, first make sure your printer is plugged in, attached to your computer's parallel port, and turned on. Then try sending a directory listing to your printer with the following:


# ls >/dev/lp1

Page 238

If you've specified the right printer device, your printer should activate and print the current directory list. If nothing happens, try the following:


# cat /proc/devices

to see if the printer device driver was loaded or compiled into your kernel. You should see something like the following:


Character devices:

 1 mem

 2 pty

 3 ttyp

 4 ttyp

 5 cua

 6 lp

 7 vcs

10 misc

14 sound

127 pcmcia



Block devices:

 1 ramdisk

 2 fd

 3 ide0

 9 md

22 ide1

If you don't see an lp device listed, make sure that parallel printing is either compiled into your kernel, or installed using the lp.o module, located under the /lib/modules/2.0.31/misc directory (see Hour 1, "Preparing to Install Linux," for kernel configuration details).

Printing Documents with the lpr Printing System

If you've installed a printer during the initial Linux installation process, you'll find your printer defined in the /etc/printcap file. This file is an ASCII database of your system's local and networked printers, and describes the capabilities of each printer.

You can have different entries for your printer to handle color or black-and-white documents, or different paper sizes. Look at the following example:


##PRINTTOOL3## LOCAL cdj500 300x300 letter {} DeskJet500 1 1

lp:\

    :sd=/var/spool/lpd/lp:\

    :mx#0:\

    :sh:\

    :lp=/dev/lp1:\

    :if=/var/spool/lpd/lp/filter:

##PRINTTOOL3## LOCAL cdj500 300x300 letter {} DeskJet500 3 1

lpcolor:\

    :sd=/var/spool/lpd/lp0:\

    :mx#0:\

    :sh:\

    :lp=/dev/lp1:\



    :if=/var/spool/lpd/lp0/filter:

##PRINTTOOL3## LOCAL cdj500 300x300 letter {} DeskJet500 8 1

lpgray:\

    :sd=/var/spool/lpd/lp0:\

    :mx#0:\

    :sh:\

    :lp=/dev/lp1:\

Page 239


    :if=/var/spool/lpd/lp0/filter:

##PRINTTOOL3## LOCAL cdj500 300x300 letter {} DeskJet500 24 1

lpcolorbest:\

    :sd=/var/spool/lpd/lp0:\

    :mx#0:\

    :sh:\

    :lp=/dev/lp1:\

    :if=/var/spool/lpd/lp0/filter:

This printcap file contains definitions (created with the printtool command, discussed in the following section, "Defining Printers with the printtool Command") for the lp, lpcolor, lpgray, and lpcolorbest printers, but all describe the same printer. These names are handy as reminders when you want to print different documents (or if you need to change print cartridges to use color).

Linux uses a line printer spooling system. When you first boot, Linux starts lpd, the line printer daemon. The lpd program runs in the background, waiting for print requests. You start a print request with the lpr command:


# lpr mydocument.txt

# lpr myfile.ps

This command line spools, or sends your documents to a file in the /var/spool/ directory. You also can use the lpr command as a printing filter to print outgoing streams of formatted text:


# groff -Tascii -mm myfile.txt | lpr

This command line sends the output of the groff formatting program through the line printer spooler. You also can spool multiple files, then track your requests by using the lpq command. See the following example:


# lpr mes.txt

# lpr test.txt

# lpq

lp is ready and printing

Rank   Owner      Job  Files                                 Total Size

active bball      16   mes.txt                               368 bytes

1st    bball      17   test.txt                              359 bytes

To stop either of these print jobs, use the lprm command:


# lprm 17

This command stops the printing of job 17, the file test.txt. You also can (as the root operator) disable or enable printers, or reorder jobs with the lpc command. See the lpc man page for details.

Page 240

Defining Printers with the printtool Command

Installing, changing, or deleting local printers with your Linux system is a snap, thanks to the Red Hat printtool program, located under the /usr/bin directory. This program, used with the X Window System, is a printer setup program you can run from the command line, or through the X11 control-panel program.

Because these programs run under X11, you'll have to start X, then, making sure you're the root operator, type the following in a terminal window:


# control-panel

or


# printtool

If you run the control-panel program, select the printtool button. Printtool's main window appears and lists all printers defined in the /etc/printcap database. From here, you can add, delete, or edit existing printer entries. To add a printer, click the Add button. You'll be asked to select a local, remote, or LAN manager printer. For the sake of example, assume that you want to set up a printer attached to your computer. Press the local button, then click the OK button.

The printtool program then shows which parallel printer devices have been detected (see Figure 15.1). Note that one of the devices, /dev/lp0, /dev/lp1, or /dev/lp2, should be detected. If not, your printer is not on, or printing support hasn't been enabled.

Figure 15.1.
The Red Hat printtool
program provides an
easy-to-use interface
when you need to
configure a printer
for Linux.


Previous | Table of Contents | Next