BSD 4_1c_2 development
[unix-history] / usr / doc / msmacros / ms
CommitLineData
035eb8bc
C
1.RP
2....TM 76-1274-16 39199 39199-11
3....ND October 8, 1976
4.nr CW 2.85i
5.nr GW .3i
6.TL
7Typing Documents on the UNIX System:
8.br
9\!.br
10Using the \-ms Macros with Troff and Nroff
11.AU "MH 2C-572" 6377
12M. E. Lesk
13.AI
14.MH
15.OK
16Text Formatting
17Phototypesetting
18.AB
19This document describes a set of easy-to-use macros
20for preparing documents on the UNIX system.
21Documents may be produced on either the
22phototypesetter or a on a computer terminal,
23without changing the input.
24.PP
25The macros provide facilities for paragraphs, sections (optionally
26with automatic numbering), page titles, footnotes,
27equations,
28tables, two-column format, and
29cover pages for papers.
30.PP
31This memo includes, as an appendix,
32the text of the ``Guide to Preparing
33Documents with \-ms''
34which contains additional examples
35of features of \-ms.
36.PP
37This manual is a revision of, and replaces,
38``Typing Documents on UNIX,''
39dated November 22, 1974.
40.AE
41.CS 6 6 12 1 0 8
42.bd I 3
43.PP
44.I
45Introduction.
46.R
47This memorandum describes a package of commands to produce
48papers
49using the
50.bd I
51.I
52troff
53.R
54and
55.I nroff
56formatting programs on the
57.SM
58UNIX
59.NL
60system.
61As with other
62.I roff -derived
63programs,
64text is prepared interspersed with formatting commands.
65However, this package,
66which itself is written in
67.I troff
68commands,
69provides higher-level commands
70than those provided with the basic
71.I troff
72program.
73The commands available in this package are listed in
74Appendix A.
75.bd I 3
76.PP
77.I
78Text.
79.R
80Type normally, except that instead of indenting for paragraphs,
81place a line reading ``.PP'' before each paragraph.
82This will produce indenting and extra space.
83.LP
84Alternatively, the command .LP that was used here will produce
85a left-aligned (block) paragraph.
86The paragraph spacing can be changed: see below under ``Registers.''
87.PP
88.I
89Beginning.
90.R
91For a document with a paper-type cover sheet, the input should start as follows:
92.DS L
93 [optional overall format .RP \- see below]
94 .TL
95 Title of document (one or more lines)
96 .AU
97 Author(s) (may also be several lines)
98 .AI
99 Author's institution(s)
100 .AB
101 Abstract; to be placed on the cover sheet of a paper.
102 Line length is 5/6 of normal; use .ll here to change.
103 .AE (abstract end)
104 text ... (begins with .PP, which see)
105.DE
106To omit some of the standard headings
107(e.g. no abstract, or no author's institution) just
108omit the corresponding fields and command lines.
109The word
110.SM
111ABSTRACT
112.NL
113can be suppressed by writing ``.AB no'' for ``.AB''.
114Several interspersed .AU and .AI lines can be used for multiple authors.
115The headings are not compulsory: beginning
116with a .PP command is perfectly OK and will just
117start printing an ordinary paragraph.
118.I Warning:
119You can't just begin a document with a line of text.
120Some \-ms command must
121precede any text input. When in doubt, use .LP
122to get proper initialization, although any of
123the commands .PP, .LP, .TL, .SH, .NH is good enough.
124Figure 1 shows the legal arrangement of commands at the
125start of a document.
126.PP
127.I
128Cover Sheets and First Pages.
129.R
130The first line
131of a document signals the general format of the first page.
132In particular, if it is ".RP" a cover sheet with title and
133abstract is prepared.
134The default format
135is useful for scanning drafts.
136.PP
137In general \-ms is arranged so that only one form
138of a document need be stored, containing all
139information; the first command gives the format,
140and unnecessary items for that format are ignored.
141.PP
142Warning: don't put extraneous material
143between the .TL and .AE commands. Processing
144of the titling items is
145special, and other data placed in them may not behave
146as you expect.
147Don't forget that some \-ms command must precede any input text.
148.PP
149.I
150Page headings.
151.R
152The \-ms macros, by default, will print a page heading containing
153a page number (if greater than 1).
154A default page footer is provided only in
155.I nroff ,
156where the date is used.
157The user can make minor adjustments to the page headings/footings
158by redefining the
159strings
160LH, CH, and RH
161which are the left, center and right portions of the page headings,
162respectively; and the
163strings
164LF, CF, and RF,
165which are the left, center and right portions of the page footer.
166For more complex formats, the user can redefine
167the macros PT and BT, which are invoked respectively at the top
168and bottom of each page.
169The margins (taken from registers HM and FM for the top and bottom
170margin respectively) are normally 1 inch; the page header/footer are
171in the middle of that space.
172The user who redefines these macros should be careful
173not to change parameters such as point size or font
174without resetting them to default values.
175.PP
176.2C
177.I
178Multi-column formats.
179.R
180If you place the command ``.2C'' in your document, the document will
181be printed in double column format beginning
182at that point. This feature is not too useful in computer
183terminal output, but is often desirable on the typesetter.
184The command ``.1C'' will go
185back to one-column format and also skip to a new page.
186The ``.2C'' command is actually a special case of the command
187.DS L
188 .MC [column width [gutter width]]
189.DE
190which makes multiple columns with the specified column
191and gutter width; as many columns as will fit across the page
192are used.
193Thus triple, quadruple, ... column pages can be printed.
194Whenever the number of columns is changed (except going from
195full width to some larger number of columns)
196a new page is started.
197.PP
198.I
199Headings.
200.R
201To produce a special heading, there are two commands.
202If you type
203.DS L
204 .NH
205 type section heading here
206 may be several lines
207.DE
208you will get automatically numbered section headings (1, 2, 3, ...),
209in boldface.
210For example,
211.DS L
212 .NH
213 Care and Feeding of Department Heads
214.DE
215produces
216.NH
217Care and Feeding of Department Heads
218.PP
219Alternatively,
220.DS L
221 .SH
222 Care and Feeding of Directors
223.DE
224will print the heading with no number added:
225.SH
226Care and Feeding of Directors
227.PP
228Every section heading, of either type, should be followed
229by a paragraph beginning with .PP or .LP, indicating
230the end of the heading.
231Headings may contain more than one line
232of text.
233.PP
234The .NH command also supports more complex numbering schemes.
235If a numerical argument is given, it is taken to be a
236``level'' number and an appropriate sub-section
237number is generated.
238Larger level numbers indicate deeper
239sub-sections, as in this example:
240.DS L
241 .NH
242 Erie-Lackawanna
243 .NH 2
244 Morris and Essex Division
245 .NH 3
246 Gladstone Branch
247 .NH 3
248 Montclair Branch
249 .NH 2
250 Boonton Line
251.DE
252generates:
253.NH
254Erie-Lackawanna
255.NH 2
256Morris and Essex Division
257.NH 3
258Gladstone Branch
259.NH 3
260Montclair Branch
261.NH 2
262Boonton Line
263.PP
264An explicit ``.NH 0'' will reset the numbering of level 1
265to one, as here:
266.DS L
267 .NH 0
268 Penn Central
269.DE
270.ft 3
271.if n .ul 1
272.sp 1
2731. Penn Central
274.PP
275.I
276Indented paragraphs.
277.R
278(Paragraphs with hanging numbers, e.g. references.)
279The sequence
280.DS L
281 .IP [1]
282 Text for first paragraph, typed
283 normally for as long as you would
284 like on as many lines as needed.
285 .IP [2]
286 Text for second paragraph, ...
287.DE
288produces
289.IP [1]
290Text for first paragraph, typed normally for as long
291as you would like on as many lines as
292needed.
293.IP [2]
294Text for second paragraph, ...
295.LP
296A series of indented paragraphs may be followed by an ordinary paragraph
297beginning with .PP or .LP,
298depending on whether you wish indenting or not.
299The command .LP was used here.
300.PP
301More sophisticated uses of .IP are also possible.
302If the label is omitted, for example, a plain block indent
303is produced.
304.DS L
305 .IP
306 This material will
307 just be turned into a
308 block indent suitable for quotations or
309 such matter.
310 .LP
311.DE
312will produce
313.IP
314This material
315will just be turned
316into a block indent
317suitable for
318quotations or such matter.
319.LP
320If a non-standard amount of indenting is required,
321it may be specified after the label (in character positions)
322and will remain in effect until the next .PP or .LP.
323Thus, the general form of the .IP command
324contains two additional fields: the label and the indenting
325length. For example,
326.DS L
327 .IP first: 9
328 Notice the longer label, requiring larger
329 indenting for these paragraphs.
330 .IP second:
331 And so forth.
332 .LP
333.DE
334produces this:
335.IP first: 9
336Notice the longer label, requiring larger
337indenting for these paragraphs.
338.IP second:
339And so forth.
340.LP
341It is also possible to produce multiple nested indents;
342the command .RS indicates that the next .IP starts from the
343current indentation level.
344Each .RE will eat up one level of indenting
345so you should balance .RS and .RE commands.
346The .RS command should be thought of as ``move right'' and
347the .RE command as ``move left''.
348As an example
349.DS L
350 .IP 1.
351 Bell Laboratories
352 .RS
353 .IP 1.1
354 Murray Hill
355 .IP 1.2
356 Holmdel
357 .IP 1.3
358 Whippany
359 .RS
360 .IP 1.3.1
361 Madison
362 .RE
363 .IP 1.4
364 Chester
365 .RE
366 .LP
367.DE
368will result in
369.IP 1.
370Bell Laboratories
371.RS
372.IP 1.1
373Murray Hill
374.IP 1.2
375Holmdel
376.IP 1.3
377Whippany
378.RS
379.IP 1.3.1
380Madison
381.RE
382.IP 1.4
383Chester
384.RE
385.LP
386All of these variations on .LP leave the right
387margin untouched. Sometimes, for purposes
388such as setting off a quotation, a paragraph indented
389on both right and left is required.
390.QP
391A single paragraph
392like this is obtained
393by preceding it with .QP.
394More complicated material (several paragraphs) should be
395bracketed with .QS and .QE.
396.LP
397.I
398Emphasis.
399.R
400To get
401italics
402(on the typesetter) or underlining (on the terminal)
403say
404.DS L
405 .I
406 as much text as you want
407 can be typed here
408 .R
409.DE
410.bd I
411.br
412as was done for
413.I
414these three words.
415.R
416The .R command restores the normal (usually Roman) font.
417If only one word is to be italicized, it
418may be just given on the line with the .I command,
419.br
420.bd I 3
421.DS
422 .I word
423.DE
424and in this case no .R is needed to restore
425the previous font.
426.B
427Boldface
428.R
429can be produced by
430.DS L
431 .B
432 Text to be set in boldface
433 goes here
434 .R
435.DE
436and also will be underlined on the terminal or line printer.
437As with .I, a single word can be placed in boldface
438by placing it on the same line as the .B command.
439.PP
440A few size changes
441can be specified similarly with
442the commands .LG (make larger), .SM (make smaller), and .NL
443(return to normal size).
444The size change
445is two points; the commands may be repeated for
446.SM
447increased
448.SM
449effect
450.NL
451(here one .NL canceled two .SM commands).
452.PP
453If actual
454.UL underlining
455as opposed to italicizing is required on the typesetter,
456the command
457.DS
458 .UL word
459.DE
460will underline a word. There is no way to underline
461multiple words on the typesetter.
462.PP
463.I
464Footnotes.
465.R
466Material placed between lines with the commands .FS
467(footnote) and .FE (footnote end) will
468be collected, remembered, and finally placed
469at the bottom of the current page*.
470By default, footnotes are 11/12th the
471length of normal text,
472but this can be changed using the FL register (see below).
473.FS
474* Like this.
475.FE
476.PP
477.I
478Displays and Tables.
479.R
480To prepare displays of lines, such as tables, in which
481the lines should not be re-arranged,
482enclose them in the commands .DS and .DE
483.DS L
484 .DS
485 table lines, like the
486 examples here, are placed
487 between .DS and .DE
488 .DE
489.DE
490By default, lines between .DS and .DE are indented and left-adjusted.
491You can also center lines, or retain the left margin.
492Lines bracketed by .DS C and .DE commands are
493centered (and not re-arranged); lines bracketed
494by .DS L and .DE are left-adjusted, not indented, and
495not re-arranged.
496A plain .DS is equivalent
497to .DS I, which indents and left-adjusts. Thus,
498.DS C
499these lines were preceded
500by .DS C and followed by
501a .DE command;
502.DE
503whereas
504.DS L
505these lines were preceded
506by .DS L and followed by
507a .DE command.
508.DE
509Note that .DS C centers each line; there is a variant .DS B
510that makes the display into a left-adjusted block of text, and
511then centers that entire block.
512Normally a display is kept together, on one page.
513If you wish to have a long display which
514may be split across page
515boundaries,
516use .CD, .LD, or .ID in place of
517the commands .DS C, .DS L, or .DS I respectively.
518An extra argument to the .DS I or .DS command is taken
519as an amount to indent.
520Note: it is tempting to assume that .DS R will right adjust
521lines, but it doesn't work.
522.PP
523.I
524Boxing words or lines.
525.R
526To draw rectangular boxes around words the command
527.DS L
528 .BX word
529.DE
530will print
531.BX word
532as shown.
533The boxes will not be neat on a terminal, and this
534should not be used as a substitute for italics.
535.B1
536Longer pieces of text may be boxed
537by enclosing them with .B1 and .B2:
538.DS L
539 .B1
540 text...
541 .B2
542.DE
543as has been done here.
544.B2
545.PP
546.I
547Keeping blocks together.
548.R
549If you wish to keep a table or other block of lines
550together on a page, there are ``keep - release'' commands.
551If a block of lines preceded by .KS and followed by .KE does
552not fit on the remainder of the current page, it will begin
553on a new page.
554Lines bracketed by .DS and .DE commands are automatically
555kept together this way.
556There is also a ``keep floating'' command: if the
557block to be kept together is preceded by .KF instead of .KS
558and does not fit
559on the current page, it will be moved down through the text
560until the top of the next page. Thus, no large blank space
561will be introduced in the document.
562.PP
563.I
564Nroff/Troff commands.
565.R
566Among the useful commands from the basic formatting programs
567are the following. They all work with both typesetter and
568computer terminal output:
569.DS L
570 .bp - begin new page.
571 .br - ``break'', stop running text
572 from line to line.
573 .sp n - insert n blank lines.
574 .na - don't adjust right margins.
575.DE
576.PP
577.I
578Date.
579.R
580By default, documents produced on computer terminals have the
581date at the bottom of each page; documents produced on
582the typesetter don't.
583To force the date, say ``.DA''. To force no date, say ``.ND''.
584To lie about the date, say ``.DA July 4, 1776''
585which puts the specified date at the bottom of each page.
586The command
587.DS L
588 .ND May 8, 1945
589.DE
590in ".RP" format
591places the specified date on the cover sheet and nowhere else.
592Place this line before the title.
593.PP
594.I
595Signature line.
596.R
597You can obtain a signature line by placing
598the command .SG in the document.
599The authors' names will
600be output in place of the .SG line.
601An argument to .SG
602is used
603as a typing identification line, and
604placed after the signatures.
605The .SG command is ignored
606in released paper format.
607.PP
608.I
609Registers.
610.R
611Certain of the registers used by \-ms can
612be altered to change default
613settings.
614They should be changed with .nr commands,
615as with
616.DS
617 .nr PS 9
618.DE
619.bd I
620to make the default point size 9 point.
621If the effect is needed immediately, the
622normal
623.I
624troff
625.R
626command should be used
627in addition to changing the number register.
628.br
629.ps 9
630.vs 10p
631.TS
632c0 c c c
633c c c c
634a l l l.
635Register Defines Takes Default
636 effect
637PS point size next para. 10
638VS line spacing next para. 12 pts
639LL line length next para. 6\(fm\(fm
640LT title length next para. 6\(fm\(fm
641PD para. spacing next para. 0.3 VS
642PI para. indent next para. 5 ens
643FL footnote length next FS 11/12 LL
644CW column width next 2C 7/15 LL
645GW intercolumn gap next 2C 1/15 LL
646PO page offset next page 26/27\(fm\(fm
647HM top margin next page 1\(fm\(fm
648FM bottom margin next page 1\(fm\(fm
649.TE
650.ps \n(PS
651.vs \n(VS
652You may also alter
653the strings
654LH, CH, and RH which are the left, center, and right headings
655respectively; and similarly LF, CF, and RF which are strings in the
656page footer.
657The page number on
658.I
659output
660.R
661is taken from register PN, to permit
662changing its output style.
663For more complicated headers and footers
664the macros PT and BT can be redefined, as
665explained earlier.
666.bd I 3
667.PP
668.I
669Accents.
670.R
671To simplify typing certain foreign words,
672strings representing common accent marks are defined.
673They precede the letter over which the mark
674is to appear.
675Here are the strings:
676.TS
677center;
678c c6 c c.
679Input Output Input Output
680\e*\(fme \*'e \e*~a \*~a
681\e*\(gae \*`e \e*Ce \h'0.15m'\v'-0.6m'\s6\zv\s0\v'0.6m'\h'-0.15m'e
682\e*:u \*:u \e*,c \*,c
683\e*^e \o'^e'
684.TE
685.PP
686.I
687Use.
688.R
689After your document is prepared and stored on a file,
690you can print it on a terminal with the command*
691.bd I
692.FS
693* If .2C was used, pipe the
694.I nroff
695output
696through
697.I col;
698make the first line of the input
699``.pi /usr/bin/col.''
700.br
701.FE
702.DS L
703.I
704 nroff \-ms file
705.R
706.DE
707and you can print it on the typesetter with the
708command
709.DS L
710.I
711 troff \-ms file
712.R
713.DE
714(many options are possible).
715In each case, if your document is stored in several files,
716just list all the filenames
717where we have used ``file''.
718If equations or tables are used,
719.I
720eqn
721.R
722and/or
723.I
724tbl
725.R
726must be invoked as preprocessors.
727.br
728.bd I 3
729.PP
730.I
731References and further study.
732.R
733If you have to do Greek or mathematics, see
734.I eqn
735[1]
736for equation setting.
737To aid
738.I eqn
739users,
740.I \-ms
741provides definitions of .EQ and .EN
742which normally center the equation and set it off slightly.
743An argument on .EQ is taken to be an equation
744number and placed in the right margin near the equation.
745In addition, there are three special arguments to EQ:
746the letters C, I, and L indicate centered (default),
747indented, and left adjusted equations, respectively.
748If there is both a format argument
749and an equation number,
750give the format argument first, as in
751.bd I
752.DS
753 .EQ L (1.3a)
754.DE
755for a left-adjusted equation numbered (1.3a).
756.PP
757Similarly,
758the macros .TS and .TE
759are defined
760to separate tables (see [2]) from text with a little space.
761A very long table with a heading may be broken
762across pages by beginning it with .TS H
763instead of .TS,
764and placing the line .TH in the table data
765after the heading. If the table
766has no heading repeated from page to page,
767just use the ordinary .TS and .TE macros.
768.PP
769To learn more about
770.I troff
771see
772[3] for a general introduction, and [4]
773for the full details (experts only).
774Information on related UNIX commands
775is in [5].
776For jobs that do not seem well-adapted
777to \-ms, consider other macro packages.
778It is often far easier to write a specific macro packages
779for such tasks as imitating particular journals than
780to try to adapt \-ms.
781.PP
782.bd I 3
783.I
784Acknowledgment.
785.R
786Many thanks are due to Brian Kernighan for
787his help in the design and implementation of this package,
788and for his assistance in preparing this manual.
789.bd I
790.SH
791.ce
792References
793.PP
794.IP [1]
795B. W. Kernighan and L. L. Cherry,
796.I
797Typesetting Mathematics \(em Users Guide (2nd edition),
798.R
799Bell Laboratories Computing Science Report no. 17.
800.IP [2]
801M. E. Lesk,
802.I
803Tbl \(em A Program to Format Tables,
804.R
805Bell Laboratories Computing Science Report no. 45.
806.IP [3]
807B. W. Kernighan,
808.I
809A Troff Tutorial,
810.R
811Bell Laboratories, 1976.
812.IP [4]
813J. F. Ossanna,
814.I
815Nroff\|/Troff Reference Manual,
816.R
817Bell Laboratories Computing Science Report no. 51.
818.IP [5]
819K. Thompson and D. M. Ritchie,
820.I
821UNIX Programmer's Manual,
822.R
823Bell Laboratories, 1978.
824.1C
825.SH
826.ce
827Appendix A
828.ce
829List of Commands
830.ft R
831.TS
832expand;
833l2 l5 l2 l.
8341C Return to single column format. LG Increase type size.
8352C Start double column format. LP Left aligned block paragraph.
836AB Begin abstract.
837AE End abstract.
838AI Specify author's institution.
839AU Specify author. ND Change or cancel date.
840B Begin boldface. NH Specify numbered heading.
841DA Provide the date on each page. NL Return to normal type size.
842DE End display. PP Begin paragraph.
843DS Start display (also CD, LD, ID).
844EN End equation. R Return to regular font (usually Roman).
845EQ Begin equation. RE End one level of relative indenting.
846FE End footnote. RP Use released paper format.
847FS Begin footnote. RS Relative indent increased one level.
848 SG Insert signature line.
849I Begin italics. SH Specify section heading.
850 SM Change to smaller type size.
851IP Begin indented paragraph. TL Specify title.
852KE Release keep.
853KF Begin floating keep. UL Underline one word.
854KS Start keep.
855.TE
856.sp
857.ce
858.ft B
859Register Names
860.ft R
861.PP
862The following register names are used by \-ms internally.
863Independent use of these names in one's own macros may
864produce incorrect output.
865Note that no lower case letters are used in any \-ms internal name.
866.TS
867 expand;
868c s s s s s s s s s s
869l l l l l l l l l l l.
870Number registers used in \-ms
871: DW GW HM IQ LL NA OJ PO T. TV
872#T EF H1 HT IR LT NC PD PQ TB VS
873.T FC H2 IF IT MF ND PE PS TC WF
8741T FL H3 IK KI MM NF PF PX TD YE
875AV FM H4 IM L1 MN NS PI RO TN YY
876CW FP H5 IP LE MO OI PN ST TQ ZN
877.TE
878.sp
879.TS
880expand;
881c s s s s s s s s s s
882l l l l l l l l l l l.
883String registers used in \-ms
884\(fm A5 CB DW EZ I KF MR R1 RT TL
885\(ga AB CC DY FA I1 KQ ND R2 S0 TM
886^ AE CD E1 FE I2 KS NH R3 S1 TQ
887~ AI CF E2 FJ I3 LB NL R4 S2 TS
888: AU CH E3 FK I4 LD NP R5 SG TT
889, B CM E4 FN I5 LG OD RC SH UL
8901C BG CS E5 FO ID LP OK RE SM WB
8912C BT CT EE FQ IE ME PP RF SN WH
892A1 C D EL FS IM MF PT RH SY WT
893A2 C1 DA EM FV IP MH PY RP TA XD
894A3 C2 DE EN FY IZ MN QF RQ TE XF
895A4 CA DS EQ HO KE MO R RS TH XK
896.TE
897.ne 4i
898.br
899.ne 5i
900.ta 1i 2i 3i 4i
901.vs .6i
902.nf
903.in 1i
904.ll 4.2i
905.ce
906Order of Commands in Input
907
908 RP
909TL
910AU
911AI
912 AB
913 AE
914
915 NH, SH
916 PP, LP
917 text ...
918.br
919.ce
920Figure 1
921.fi
922.in 0