📄 u3
字号:
.sp.SHIII. DOCUMENT PREPARATION.PP.UC UNIXsystems are used extensively for document preparation.There are two major formattingprograms,that is,programs that produce a text withjustified right margins, automatic page numbering and titling,automatic hyphenation,and the like..UL nroffis designed to produce output on terminals andline-printers..UL troff(pronounced ``tee-roff'')instead drives a phototypesetter,which produces very high quality outputon photographic paper.This paper was formatted with.UL troff ..SHFormatting Packages.PPThe basic idea of.UL nroff and .UL troffis that the text to be formatted contains within it``formatting commands'' that indicate in detailhow the formatted text is to look.For example, there might be commands that specify how longlines are, whether to use single or double spacing,and what running titles to use on each page..PPBecause.UL nroffand.UL troffare relatively hard to learn to use effectively,several``packages'' of canned formatting requests are availableto let you specifyparagraphs, running titles, footnotes, multi-column output,and so on, with little effortand without having to learn.UL nroffand.UL troff .These packages take a modest effort to learn,but the rewards for using them are so greatthat it is time well spent..PPIn this section,we will provide a hasty look at the ``manuscript'' package known as.UL \-ms .Formatting requests typically consist of a period and two upper-case letters,such as.UL .TL ,which is used to introduce a title,or.UL .PPto begin a new paragraph..PPA document is typed so it looks something like this:.P1\&.TLtitle of document\&.AUauthor name\&.SHsection heading\&.PPparagraph ...\&.PPanother paragraph ...\&.SHanother section heading\&.PPetc..P2The lines that begin with a period are the formatting requests.For example,.UL .PPcalls for starting a new paragraph.The precise meaning of.UL .PPdepends on what output device is being used(typesetter or terminal, for instance),and on what publication the document will appear in.For example,.UL \-msnormally assumes that a paragraph is preceded by a space(one line in.UL nroff ,\(12 line in.UL troff ),and the first word is indented.These rules can be changed if you like,but they are changed by changing the interpretationof.UL .PP ,not by re-typing the document..PPTo actually produce a document in standard formatusing.UL \-ms ,use the command.P1troff -ms files ....P2for the typesetter, and.P1nroff -ms files ....P2for a terminal.The.UL \-msargument tells.UL troffand.UL nroffto use the manuscript package of formatting requests..PPThere are several similar packages;check with a local expert to determine which onesare in common use on your machine..SHSupporting Tools.PPIn addition to the basic formatters,there isa host of supporting programsthat help with document preparation.The list in the next few paragraphsis far from complete,so browse through the manualand check with people around you for other possibilities..PP.UL eqnand.UL neqnlet you integrate mathematicsinto the text of a document,in an easy-to-learn language that closely resembles the wayyou would speak it aloud.For example, the.UL eqninput.P1sum from i=0 to n x sub i ~=~ pi over 2.P2produces the output.EQsum from i=0 to n x sub i ~=~ pi over 2.EN.PPThe program.UL tblprovides an analogous service for preparing tabular material;it does all the computations necessary to align complicated columnswith elements of varying widths..PP.UL referprepares bibliographic citations from a data base,in whatever style is defined by the formatting package.It looks after all the details of numbering references in sequence,filling in page and volume numbers,getting the author's initials and the journal name right,and so on..PP.UL spelland.UL typodetect possible spelling mistakes in a document..UL spellworks by comparing the words in your documentto a dictionary,printing those that are not in the dictionary.It knows enough about English spelling to detect plurals and the like,so it does a very good job..UL typolooks for words which are ``unusual'',and prints those.Spelling mistakes tend to be more unusual,and thus show up early when the most unusual wordsare printed first..PP.UL greplooks through a set of files for linesthat contain a particular text pattern (rather like the editor's context search does,but on a bunch of files).For example,.P1grep \(fming$\(fm chap*.P2will find all lines that end withthe letters.UL ingin the files.UL chap* .(It is almost always a good practice to put single quotes aroundthe pattern you're searching for,in case it contains characters like.UL *or.UL $that have a special meaning to the shell.).UL grepis often useful for finding out in which of a set of filesthe misspelled words detected by.UL spellare actually located..PP.UL diffprints a list of the differences betweentwo files,so you can comparetwo versions of something automatically(which certainly beats proofreading by hand)..PP.UL wccounts the words, lines and characters in a set of files..UL trtranslates characters into other characters;for example it will convert upper to lower case and vice versa.This translates upper into lower:.P1tr A-Z a-z <input >output.P2.PP.UL sortsorts files in a variety of ways;.UL crefmakes cross-references;.UL ptxmakes a permuted index(keyword-in-context listing)..UL sedprovides many of the editing facilitiesof.UL ed ,but can apply them to arbitrarily long inputs..UL awkprovides the ability to do both pattern matching and numeric computations,and to conveniently process fields within lines.These programs are for more advanced users,and they are not limited to document preparation.Put them on your list of things to learn about..PPMost of these programs are either independently documented(like.UL eqnand.UL tbl ),or are sufficiently simple that the description inthe.ul 2.UC UNIXProgrammer's Manualis adequate explanation..SHHints for Preparing Documents.PPMost documents go through several versions (always more than you expected) before theyare finally finished.Accordingly, you should do whatever possible to makethe job of changing them easy..PPFirst, when you do the purely mechanical operations of typing,type so that subsequent editing will be easy.Start each sentence on a new line.Make lines short,and break lines at natural places,such as after commas and semicolons,rather than randomly.Since most people change documents by rewriting phrasesand adding, deleting and rearranging sentences,these precautions simplify any editingyou have to do later..PPKeep the individual files of a document downto modest size,perhaps ten to fifteen thousand characters.Larger files edit more slowly,and of course if you make a dumb mistakeit's better to have clobbered a small file than a big one.Split into files at natural boundaries in the document,for the same reasons that you start each sentenceon a new line..PPThe second aspect of making change easyis to not commit yourself to formatting details too early.One of the advantages of formatting packages like.UL \-msis that they permit you to delay decisionsto the last possible moment.Indeed,until a document is printed,it is not even decided whether it will be typesetor put on a line printer..PPAs a rule of thumb, for all but the most trivial jobs,you should type a document in terms of a set of requestslike.UL .PP ,and then define them appropriately,either by using one of the canned packages(the better way)or by defining your own.UL nroffand.UL troffcommands.As long as you have entered the text in some systematic way,it can always be cleaned up and re-formattedby a judicious combination ofediting commands and request definitions.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -