L A T E X (2nd ed.): a document preparation system: user's guide and reference manual

beginCabstractl The mating habits of insects are The mating habits of insects are quite quite different from those of large different from those of large mammals. mammals. \end(abstract) The abstract is placed on a separate page if the t i t lepage document-class option is in effect; otherwise, it acts like an ordinary displayed-paragraph environment. 6.1 Document and Page Styles 9 1 6.1.4 Customizing the Style If you don't like the style of the output produced by I4with the standard style options, you should check the I4w Companion and the Local Guide to see if there are other options available. If there aren't, you must change the style of your document yourself. Changing the style means changing the way the standard structures such as paragraphs and itemized lists are formatted, not creating liew structures. Section 3.4 describes how to define new logical structures. Before changing your document's style, remember that many authors make elementary errors when they try to design their own documents. The only way to avoid these errors is by consulting a trained typographic designer or reading about typographic design. All I can do here is warn you against the very common mistake of making lines that are too wide to read easily-a mistake you won't make if you follow this suggestion: Use lines that contain n o more than 75 characters, including punctuation and spaces. The style of a particular document can be customized by adding declarations to its preamble. If the same style modifications are used in several documents, it is more convenient to put them in a separate package. A package is created by writing the appropriate declarations in a s t y file--a file whose first name is the package name and whose extension is s ty . For example, to define a package named vacation, you would create the file vacation. sty. The command \usepackage(vacatiod would then cause U w to read the file vacation. sty. When reading a package's sty file, T@C regards an Q character as a letter, so it can be part of a command name like \ @ l i s t i . Such a command name cannot be used in your document, since T)$ would interpret it as the command \@ followed by the text characters l is t i . Many of IN)i$' s internal commands have an dD in their name to prevent their accidental use within the document; these include some parameters described in Appendix C that you may want to change. The simplest way to modify a document's style is by changing parameters such as the ones that control the height and width of the text on the page. @T)i $' s style parameters are described in this chapter and in Appendix C. Other modifications require redefining I4'IjjX commands. For example, if you want to change the style of chapter headings, you will have to redefine the \chapter command. If the change is complicated-for example, if you want the chapter heading to list the titles of all preceding chapters-then you will need to learn advanced commands. However, it isn't hard to figure out how to make most of the changes you are likely to want. To illustrate the process, I will now describe how you would make a typical style change: printing chapter titles in a bold sans serif type style, rather t,han in the standard bold roman style. You have to change the definition of \chapter, so the first problem is finding that definition. Commands that exist in all document classes are usually preloaded. The file source2e. tex lists the names of the files in which the defi92 Designing It Yourself nitions of preloaded commands can be found. (Consult the Local Guide to find out in what directory these files are.) Commands like \chapter that exist only in some document classes or are defined by a package are not preloaded. The definitions of these commands are in files read by M ( when it processes your document. Section 4.7 explains how to find out what files BT)ijX reads. For this example, I assume that your document uses the report. document class. You will find that BT)ijX reads the file report . c l s . Searching this file for "\chaptern, you will come across \ n e w c o m m a n d \ c h a p t e r i \ i f O o p e n r i g h t \ c l e ~ e \ e l s e ... \thispagestyleiplain)% \global\@topnum\z@ \@afterindentf a l s e \secdef \@chapter\@schapterl This is where the \chapter command is defined. (Macho T)ijX programmers sometimes remove the braces around the first argument of \newcommand; don't do it yourself.) Looking at this definition, it's not hard to guess that the chap ter heading is produced by \@chapter or \@chapter. Immediately below the definition of \chapter is This is where \@chapter is defined. (Macho 'I)$ programmers also use the 'I)$ command \def to define commands; don't you do it.) Examining this definition will lead you to suspect that the heading is produced by the \@makechapterhead command. The definition of \@makechapterhead contains two \bf s e r i e s commands. An obvious guess is that adding \sf f amily commands right before or after these \bf se r i e s commands will produce bold sans serif chapter headings. So, you will create a file named sf chap. s t y containing the modified definition of \@makechapterhead, add a \usepackage(sf chap) command to the preamble of your document, and run I + ( . You will then discover that you have guessed right; I+w has produced the bold sans serif headings you wanted. This detective work was good practice, but there's a way to avoid much of it. Comments at the beginning of report . c l s indicate that this file was generated from a source file named classes.dtx. (The file source2e. t ex also directs you to classes. dtx.) A dtx file contains comments and additional formatting commands. You can run a dtx file through BTjjX to produce a printed version, or you can just read the dtx file itself. The file classes. dtx reveals that the \@schapter command prints unnumbered chapter headings. (Such headings are produced by the \chapter* command described in Section C.4.1.) Aided by the comments, you should now be able to figure out how to change the way unnumbered chapter headings are printed. This example shows how to modify a command; modifying an environment is similar. To find its definition, you need to know that some environments are 6.2 Line and Page Breaking 93 defined with 'I)$C1s \def command instead of \newenvironment. For example, the equation environment is defined by defining \equation, which is executed by the \beginCequation) command, and \endequation, which is executed by \endCequat ion). Remember that before creating your own package of style changes, you should check the I4m Companion and the Local Guide to see if someone has already created a document class or package that does what you want. Line and Page Breaking 'I)$C usually does a good job of breaking text into lines and pages, but it sometimes needs help. Don't worry about line and page breaks until you prepare the final version. Most of the bad breaks that appear in early drafts will disappear as you change the text. Many users waste time formatting when they should be writing. Don't worry about line and page breaks until you prepare the absolutely final version.