TypingDocumentsontheUNIXSystem: Usingthe−msMacroswithTroffandNroff M.E.Lesk TextFormatting Phototypesetting ABSTRACT Thisdocumentdescribesasetofeasy-to-usemacrosforpreparingdocu-mentsontheUNIXsystem.Documentsmaybeproducedoneitherthephoto-typesetteroraonacomputerterminal,withoutchangingtheinput. Themacrosprovidefacilitiesforparagraphs,sections(optionallywithautomaticnumbering),pagetitles,footnotes,equations,tables,two-columnformat, andcoverpagesforpapers. Thismemoincludes,asanappendix,thetextofthe‘‘GuidetoPreparing Documentswith−ms’’whichcontainsadditionalexamplesoffeaturesof−ms. Thismanualisarevisionof,andreplaces,‘‘TypingDocumentsonUNIX,’’ datedNovember22,1974. 8April1993 TypingDocumentsontheUNIXSystem: Usingthe−msMacroswithTroffandNroff M.E.Lesk TextFormatting Phototypesetting IInnttrroodduuccttiioonn..Thismemorandumdescribesapackageofcommandstoproducepapersusing thetroffandnroffformattingprogramsontheUNIXsystem.Aswithotherroff-derivedprograms, textispreparedinterspersedwithformattingcommands.However,thispackage,whichitselfis writtenintroffcommands,provideshigher-levelcommandsthanthoseprovidedwiththebasic troffprogram.ThecommandsavailableinthispackagearelistedinAppendixA. TTeexxtt..Typenormally,exceptthatinsteadofindentingforparagraphs,placealinereading ‘‘.PP’’beforeeachparagraph.Thiswillproduceindentingandextraspace. Alternatively,thecommand.LPthatwasusedherewillproducealeft-aligned(block)paragraph. Theparagraphspacingcanbechanged:seebelowunder‘‘Registers.’’ BBeeggiinnnniinngg..Foradocumentwithapaper-typecoversheet,theinputshouldstartasfollows: [optionaloverallformat.RP−seebelow] .TL Titleofdocument(oneormorelines) .AU Author(s)(mayalsobeseverallines) .AI Author’sinstitution(s) .AB Abstract;tobeplacedonthecoversheetofapaper. Linelengthis5/6ofnormal;use.llheretochange. .AE(abstractend) text...(beginswith.PP,whichsee) Toomitsomeofthestandardheadings(e.g.noabstract,ornoauthor’sinstitution)justomitthe correspondingfieldsandcommandlines.ThewordABSTRACTcanbesuppressedbywriting‘‘.AB no’’for‘‘.AB’’.Severalinterspersed.AUand.AIlinescanbeusedformultipleauthors.The headingsarenotcompulsory:beginningwitha.PPcommandisperfectlyOKandwilljuststart printinganordinaryparagraph.WWaarrnniinngg::Youcan’tjustbeginadocumentwithalineoftext. Some−mscommandmustprecedeanytextinput.Whenindoubt,use.LPtogetproperinitialization,althoughanyofthecommands.PP,.LP,.TL,.SH,.NHisgoodenough.Figure1shows thelegalarrangementofcommandsatthestartofadocument. CCoovveerrSShheeeettssaannddFFiirrssttPPaaggeess..Thefirstlineofadocumentsignalsthegeneralformatofthe firstpage.Inparticular,ifitis".RP"acoversheetwithtitleandabstractisprepared.The defaultformatisusefulforscanningdrafts. Ingeneral−msisarrangedsothatonlyoneformofadocumentneedbestored,containing allinformation;thefirstcommandgivestheformat,andunnecessaryitemsforthatformatare ignored. Warning:don’tputextraneousmaterialbetweenthe.TLand.AEcommands.Processingof thetitlingitemsisspecial,andotherdataplacedinthemmaynotbehaveasyouexpect.Don’t forgetthatsome−mscommandmustprecedeanyinputtext.

-2-PPaaggeehheeaaddiinnggss..The−msmacros,bydefault,willprintapageheadingcontainingapage number(ifgreaterthan1).Adefaultpagefooterisprovidedonlyinnnrrooffff,wherethedateis used.Theusercanmakeminoradjustmentstothepageheadings/footingsbyredefiningthe stringsLH,CH,andRHwhicharetheleft,centerandrightportionsofthepageheadings,respectively;andthestringsLF,CF,andRF,whicharetheleft,centerandrightportionsofthepage footer.Formorecomplexformats,theusercanredefinethemacrosPTandBT,whichare invokedrespectivelyatthetopandbottomofeachpage.Themargins(takenfromregistersHM andFMforthetopandbottommarginrespectively)arenormally1inch;thepageheader/footer areinthemiddleofthatspace.Theuserwhoredefinesthesemacrosshouldbecarefulnotto changeparameterssuchaspointsizeorfontwithoutresettingthemtodefaultvalues. MMuullttii--ccoolluummnnffoorrmmaattss..Ifyouplacethecom-mand‘‘.2C’’inyourdocument,thedocument willbeprintedindoublecolumnformat beginningatthatpoint.Thisfeatureisnot toousefulincomputerterminaloutput,but isoftendesirableonthetypesetter.The command‘‘.1C’’willgobacktoone-column formatandalsoskiptoanewpage.The ‘‘.2C’’commandisactuallyaspecialcaseof thecommand .MC[columnwidth[gutterwidth]] whichmakesmultiplecolumnswiththespecifiedcolumnandgutterwidth;asmany columnsaswillfitacrossthepageareused. Thustriple,quadruple,...columnpagescan beprinted.Wheneverthenumberofcolumns ischanged(exceptgoingfromfullwidthto somelargernumberofcolumns)anewpage isstarted. HHeeaaddiinnggss..Toproduceaspecialheading,therearetwocommands.Ifyoutype .NH typesectionheadinghere maybeseverallines youwillgetautomaticallynumberedsection headings(1,2,3,...),inboldface.Forexample, .NH CareandFeedingofDepartmentHeads produces 1.CareandFeedingofDepartment Heads Alternatively, .SH CareandFeedingofDirectors willprinttheheadingwithnonumberadded:

CareandFeedingofDirectors Everysectionheading,ofeithertype, shouldbefollowedbyaparagraphbeginning with.PPor.LP,indicatingtheendofthe heading.Headingsmaycontainmorethan onelineoftext. The.NHcommandalsosupportsmore complexnumberingschemes.Ifanumerical argumentisgiven,itistakentobea‘‘level’’ numberandanappropriatesub-section numberisgenerated.Largerlevelnumbers indicatedeepersub-sections,asinthisexam-ple: .NH Erie-Lackawanna .NH2 MorrisandEssexDivision .NH3 GladstoneBranch .NH3 MontclairBranch .NH2 BoontonLine generates: 2.Erie-Lackawanna 2.1.MorrisandEssexDivision 2.1.1.GladstoneBranch 2.1.2.MontclairBranch 2.2.BoontonLine Anexplicit‘‘.NH0’’willresetthenumberingoflevel1toone,ashere: .NH0 PennCentral 1.PennCentral -3-IInnddeenntteeddppaarraaggrraapphhss..(Paragraphswith hangingnumbers,e.g.references.)The sequence .IP[1] Textforfirstparagraph,typed normallyforaslongasyouwould likeonasmanylinesasneeded. .IP[2] Textforsecondparagraph,... produces [1]Textforfirstparagraph,typednormally foraslongasyouwouldlikeonas manylinesasneeded. [2]Textforsecondparagraph,... Aseriesofindentedparagraphsmaybefollowedbyanordinaryparagraphbeginning with.PPor.LP,dependingonwhetheryou wishindentingornot.Thecommand.LP wasusedhere. Moresophisticatedusesof.IParealso possible.Ifthelabelisomitted,forexample, aplainblockindentisproduced. .IP Thismaterialwill justbeturnedintoa blockindentsuitableforquotationsor suchmatter. .LP willproduce Thismaterialwilljustbeturnedintoa blockindentsuitableforquotationsor suchmatter. Ifanon-standardamountofindentingis required,itmaybespecifiedafterthelabel (incharacterpositions)andwillremainin effectuntilthenext.PPor.LP.Thus,the generalformofthe.IPcommandcontains twoadditionalfields:thelabelandthe indentinglength.Forexample, .IPfirst:9 Noticethelongerlabel,requiringlarger indentingfortheseparagraphs. .IPsecond: Andsoforth. .LP producesthis: first:Noticethelongerlabel,requiring largerindentingfortheseparagraphs. second:Andsoforth. Itisalsopossibletoproducemultiplenested indents;thecommand.RSindicatesthatthe next.IPstartsfromthecurrentindentation level.Each.REwilleatuponelevelof indentingsoyoushouldbalance.RSand.RE commands.The.RScommandshouldbe thoughtofas‘‘moveright’’andthe.REcommandas‘‘moveleft’’.Asanexample .IP1. BellLaboratories .RS .IP1.1 MurrayHill .IP1.2 Holmdel .IP1.3 Whippany .RS .IP1.3.1 Madison .RE .IP1.4 Chester .RE .LP willresultin 1.BellLaboratories 1.1MurrayHill 1.2Holmdel 1.3Whippany 1.3.1 Madison 1.4Chester Allofthesevariationson.LPleavetheright marginuntouched.Sometimes,forpurposes suchassettingoffaquotation,aparagraph indentedonbothrightandleftisrequired. Asingleparagraphlikethisis obtainedbyprecedingitwith.QP. Morecomplicatedmaterial(severalparagraphs)shouldbebracketedwith.QSand.QE. EEmmpphhaassiiss..Togetitalics(onthetypesetter) orunderlining(ontheterminal)say .I asmuchtextasyouwant canbetypedhere .R aswasdoneforthesethreewords.The.R -4-commandrestoresthenormal(usually Roman)font.Ifonlyonewordistobeitalicized,itmaybejustgivenonthelinewith the.Icommand, .Iword andinthiscaseno.Risneededtorestorethe previousfont.Boldfacecanbeproducedby .B Texttobesetinboldface goeshere .R andalsowillbeunderlinedontheterminalor lineprinter.Aswith.I,asinglewordcanbe placedinboldfacebyplacingitonthesame lineasthe.Bcommand. Afewsizechangescanbespecifiedsimilarlywiththecommands.LG(makelarger), .SM(makesmaller),and.NL(returntonormalsize).Thesizechangeistwopoints;the commandsmayberepeatedforincreasedeffect (hereone.NLcanceledtwo.SMcommands). Ifactualunderliningasopposedtoitalicizingisrequiredonthetypesetter,thecommand .ULword willunderlineaword.Thereisnowayto underlinemultiplewordsonthetypesetter. FFoooottnnootteess..Materialplacedbetween lineswiththecommands.FS(footnote)and .FE(footnoteend)willbecollected,remembered,andfinallyplacedatthebottomofthe currentpage*.Bydefault,footnotesare 11/12ththelengthofnormaltext,butthis canbechangedusingtheFLregister(see below). DDiissppllaayyssaannddTTaabblleess..Topreparedisplaysoflines,suchastables,inwhichthe linesshouldnotbere-arranged,enclosethem inthecommands.DSand.DE .DS tablelines,likethe exampleshere,areplaced between.DSand.DE .DE Bydefault,linesbetween.DSand.DEare indentedandleft-adjusted.Youcanalsocen-terlines,orretaintheleftmargin.Lines bracketedby.DSCand.DEcommandsare *Likethis. centered(andnotre-arranged);linesbrack-etedby.DSLand.DEareleft-adjusted,not indented,andnotre-arranged.Aplain.DSis equivalentto.DSI,whichindentsandleftadjusts.Thus, theselineswerepreceded by.DSCandfollowedby a.DEcommand; whereas theselineswerepreceded by.DSLandfollowedby a.DEcommand. Notethat.DSCcenterseachline;thereisa variant.DSBthatmakesthedisplayintoa left-adjustedblockoftext,andthencenters thatentireblock.Normallyadisplayiskept together,ononepage.Ifyouwishtohavea longdisplaywhichmaybesplitacrosspage boundaries,use.CD,.LD,or.IDinplaceof thecommands.DSC,.DSL,or.DSIrespectively.Anextraargumenttothe.DSIor .DScommandistakenasanamountto indent.Note:itistemptingtoassumethat .DSRwillrightadjustlines,butitdoesn’t work. BBooxxiinnggwwoorrddssoorrlliinneess..Todrawrectangularboxesaroundwordsthecommand .BXword willprintwordasshown.Theboxeswill notbeneatonaterminal,andthisshould notbeusedasasubstituteforitalics. Longerpiecesoftextmaybeboxedby enclosingthemwith.B1and.B2: .B1 text... .B2 ashasbeendonehere. KKeeeeppiinnggbblloocckkssttooggeetthheerr..Ifyouwishto keepatableorotherblockoflinestogether onapage,thereare‘‘keep-release’’com-mands.Ifablockoflinesprecededby.KS andfollowedby.KEdoesnotfitonthe remainderofthecurrentpage,itwillbegin onanewpage.Linesbracketedby.DSand .DEcommandsareautomaticallykept togetherthisway.Thereisalsoa‘‘keepfloating’’command:iftheblocktobekept togetherisprecededby.KFinsteadof.KS anddoesnotfitonthecurrentpage,itwill bemoveddownthroughthetextuntilthe -5-topofthenextpage.Thus,nolargeblank spacewillbeintroducedinthedocument. NNrrooffff//TTrrooffffccoommmmaannddss..Amongthe usefulcommandsfromthebasicformatting programsarethefollowing.Theyallwork withbothtypesetterandcomputerterminal output: .bp-beginnewpage. .br-‘‘break’’,stoprunningtext fromlinetoline. .spn-insertnblanklines. .na-don’tadjustrightmargins. DDaattee..Bydefault,documentsproduced oncomputerterminalshavethedateatthe bottomofeachpage;documentsproducedon thetypesetterdon’t.Toforcethedate,say ‘‘.DA’’.Toforcenodate,say‘‘.ND’’.Tolie aboutthedate,say‘‘.DAJuly4,1776’’which putsthespecifieddateatthebottomofeach page.Thecommand .NDMay8,1945 in".RP"formatplacesthespecifieddateon thecoversheetandnowhereelse.Placethis linebeforethetitle. SSiiggnnaattuurreelliinnee..Youcanobtainasignaturelinebyplacingthecommand.SGinthe document.Theauthors’nameswillbeoutputinplaceofthe.SGline.Anargumentto .SGisusedasatypingidentificationline,and placedafterthesignatures.The.SGcommandisignoredinreleasedpaperformat. RReeggiisstteerrss..Certainoftheregistersused by−mscanbealteredtochangedefaultsettings.Theyshouldbechangedwith.nrcommands,aswith .nrPS9 tomakethedefaultpointsize9point.Ifthe effectisneededimmediately,thenormaltroff commandshouldbeusedinadditionto changingthenumberregister. RegisterDefinesTakesDefault effect PSpointsizenextpara.10 VSlinespacingnextpara.12pts LLlinelengthnextpara.6′′ LTtitlelengthnextpara.6′′ PDpara.spacingnextpara.0.3VS PIpara.indentnextpara.5ens FLfootnotelengthnextFS11/12LL CWcolumnwidthnext2C7/15LL GWintercolumngapnext2C1/15LL POpageoffsetnextpage26/27′′ HMtopmarginnextpage1′′ FMbottommarginnextpage1′′ YoumayalsoalterthestringsLH,CH,and RHwhicharetheleft,center,andrightheadingsrespectively;andsimilarlyLF,CF,and RFwhicharestringsinthepagefooter.The pagenumberonoutputistakenfromregister PN,topermitchangingitsoutputstyle.For morecomplicatedheadersandfootersthe macrosPTandBTcanberedefined,as explainedearlier. AAcccceennttss..Tosimplifytypingcertainforeignwords,stringsrepresentingcommon accentmarksaredefined.Theyprecedethe letteroverwhichthemarkistoappear.Here arethestrings: InputOutputInputOutput \*′e´ e\*˜ a˜ a \*` e` e\*Ceve \*:u¨ u\*,c¸ c \*ˆ eˆ e UUssee..Afteryourdocumentisprepared andstoredonafile,youcanprintitonaterminalwiththecommand* nroff−msfile andyoucanprintitonthetypesetterwith thecommand troff−msfile (manyoptionsarepossible).Ineachcase,if yourdocumentisstoredinseveralfiles,just listallthefilenameswherewehaveused ‘‘file’’.Ifequationsortablesareused,eqn and/ortblmustbeinvokedaspreprocessors. RReeffeerreenncceessaannddffuurrtthheerrssttuuddyy..Ifyou havetodoGreekormathematics,seeeeqqnn[1] forequationsetting.Toaideeqqnnusers,−−mmss providesdefinitionsof.EQand.ENwhich normallycentertheequationandsetitoff slightly.Anargumenton.EQistakentobe anequationnumberandplacedintheright marginneartheequation.Inaddition,there arethreespecialargumentstoEQ:theletters C,I,andLindicatecentered(default), indented,andleftadjustedequations,respectively.Ifthereisbothaformatargument andanequationnumber,givetheformat *If.2Cwasused,pipethenroffoutput throughcol;makethefirstlineoftheinput‘‘.pi /usr/bin/col.’’ -6-argumentfirst,asin .EQL(1.3a) foraleft-adjustedequationnumbered(1.3a). Similarly,themacros.TSand.TEare definedtoseparatetables(see[2])fromtext withalittlespace.Averylongtablewitha headingmaybebrokenacrosspagesby beginningitwith.TSHinsteadof.TS,and placingtheline.THinthetabledataafter theheading.Ifthetablehasnoheading repeatedfrompagetopage,justusetheordinary.TSand.TEmacros. Tolearnmoreabouttroffsee[3]fora generalintroduction,and[4]forthefull details(expertsonly).Informationonrelated UNIXcommandsisin[5].Forjobsthatdo notseemwell-adaptedto−ms,considerother macropackages.Itisoftenfareasiertowrite aspecificmacropackagesforsuchtasksas imitatingparticularjournalsthantotryto adapt−ms. AAcckknnoowwlleeddggmmeenntt..Manythanksaredue toBrianKernighanforhishelpinthedesign andimplementationofthispackage,andfor hisassistanceinpreparingthismanual. References [1]B.W.KernighanandL.L.Cherry, TypesettingMathematics—Users Guide(2ndedition),BellLaboratories ComputingScienceReportno.17. [2]M.E.Lesk,Tbl—AProgramtoFormatTables,BellLaboratoriesComputingScienceReportno.45. [3]B.W.Kernighan,ATroffTutorial,Bell Laboratories,1976. [4]J.F.Ossanna,Nroff/TroffReference Manual,BellLaboratoriesComputing ScienceReportno.51. [5]K.ThompsonandD.M.Ritchie,UNIX Programmer’sManual,BellLaboratories,1978.

-7-AppendixA ListofCommands 1CReturntosinglecolumnformat.LGIncreasetypesize. 2CStartdoublecolumnformat.LPLeftalignedblockparagraph. ABBeginabstract. AEEndabstract. AISpecifyauthor’sinstitution. AUSpecifyauthor. NDChangeorcanceldate. BBeginboldface. NHSpecifynumberedheading. DAProvidethedateoneachpage.NLReturntonormaltypesize. DEEnddisplay. PPBeginparagraph. DSStartdisplay(alsoCD,LD,ID). ENEndequation. RReturntoregularfont(usuallyRoman). EQBeginequation. REEndonelevelofrelativeindenting. FEEndfootnote. RPUsereleasedpaperformat. FSBeginfootnote. RSRelativeindentincreasedonelevel. SGInsertsignatureline. IBeginitalics. SHSpecifysectionheading. SMChangetosmallertypesize. IPBeginindentedparagraph.TLSpecifytitle. KEReleasekeep. KFBeginfloatingkeep.ULUnderlineoneword. KSStartkeep. RegisterNames Thefollowingregisternamesareusedby−msinternally.Independentuseofthesenamesin one’sownmacrosmayproduceincorrectoutput.Notethatnolowercaselettersareusedinany −msinternalname. Numberregistersusedin−ms :DWGWHMIQLLNAOJPOT.TV #TEFH1HTIRLTNCPDPQTBVS 1TFLH3IKKIMMNFPFPXTDYE AVFMH4IML1MNNSPIROTNYY CWFPH5IPLEMOOIPNSTTQZN Stringregistersusedin−ms ′A5CBDWEZIKFMRR1RTTL ` ABCCDYFAI1KQNDR2S0TM ˆ AECDE1FEI2KSNHR3S1TQ ˜ AICFE2FJI3LBNLR4S2TS :AUCHE3FKI4LDNPR5SGTT ,BCME4FNI5LGODRCSHUL 1CBGCSE5FOIDLPOKRESMWB 2CBTCTEEFQIEMEPPRFSNWH A1CDELFSIMMFPTRHSYWT A2C1DAEMFVIPMHPYRPTAXD A3C2DEENFYIZMNQFRQTEXF A4CADSEQHOKEMORRSTHXK -8-OrderofCommandsinInput RP TL AU AI AB AE NH,SH PP,LP text... Figure1