⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tt09

📁 unix v7是最后一个广泛发布的研究型UNIX版本
💻
字号:
.NHTitles, Pages and Numbering.PPThis is an area where things get tougher,because nothing is done for you automatically.Of necessity, some of this section is a cookbook,to be copied literally until you get some experience..PPSuppose you want a title at the top of each page,saying just.sp 3p.lt 2.8i.tl '~~~~left top'center top'right top~~~~'.lt.sp 3pIn.UL roff ,one can say.P1 2^he 'left top'center top'right top'^fo 'left bottom'center bottom'right bottom'.P2to get headers and footers automatically on every page.Alas, this doesn't work in.UL troff ,a serious hardship for the novice.Instead you have to do a lot of specification..PPYou have to say what the actual title is (easy);when to print it (easy enough);and what to do at and around the title line (harder).Taking these in reverse order,first we define a macro.BD .NP(for `new page') to processtitles and the like at the end of one pageand the beginning of the next:.P1^de NP\(fmbp\(fmsp 0.5i\&.tl 'left top'center top'right top'\(fmsp 0.3i^^.P2To make sure we're at the top of a page,we issue a `begin page' command.BD \(fmbp ,which causes a skip to top-of-page(we'll explain the.BD \(fmshortly).Then we space down half an inch,print the title(the use of.BD .tlshould be self explanatory; later we will discuss parameterizing the titles),space another 0.3 inches,and we're done..PPTo ask for.BD .NPat the bottom of each page,we have to say something like`when the text is within an inchof the bottom of the page,start the processingfor a new page.'This is done with a `when' command.BD .wh :.P1^wh  \-1i  NP.P2(No `.' is used before NP;this is simply the name of a macro, not a macro call.)The minus sign means`measure up from the bottom of the page',so`\-1i' means `one inch from the bottom'..PPThe.BD .whcommand appears in the input outside the definition of.BD .NP ;typically the input would be.P1^de NP^^^^^^wh \-1i NP.P2.PPNow what happens?As text is actually being output,.UL troff keeps track of its vertical position on the page,and after a line is printed within one inch from the bottom,the.BD .NPmacro is activated.(In the jargon, the.BD .whcommand sets a.ultrapat the specified place,which is `sprung' when that point is passed.).BD .NPcauses a skip to the top of the next page(that's what the.BD \(fmbpwas for),then prints the title with the appropriate margins..PPWhy.BD \(fmbpand.BD \(fmsp instead of.BD .bpand.BD .sp ?The answer is that.BD .spand.BD .bp ,like several other commands,cause a.ulbreakto take place.That is, all the input text collected but not yet printedis flushed out as soon as possible,and the next input line is guaranteed to starta new line of output.If we had used.BD .spor.BD .bpin the.BD .NPmacro,this would cause a break in the middleof the current output line when a new page is started.The effect would be to print the left-over part of that lineat the top of the page, followed by the next input line on a new output line.This is.ulnotwhat we want.Using.BD \(fminstead of.BD . for a commandtells.UL troff thatno break is to take place _the output linecurrently being filledshould.ulnotbe forced out before the space or new page..PPThe list of commands that cause a break is short and natural:.P1^bp   ^br   ^ce   ^fi   ^nf   ^sp   ^in   ^ti.P2All others cause.ulnobreak,regardless of whether you use a.BD .or a .BD \(fm .If you really need a break, add a.BD .br command at the appropriate place..PPOne other thing to beware of _if you're changing fonts or point sizes a lot,you may find thatif you cross a page boundaryin an unexpected font or size,your titles come out in that size and fontinstead of what you intended.Furthermore, the length of a title is independent of the current line length,so titles will come out at the default length of 6.5 inchesunless you change it,which is done with the.BD .ltcommand..PPThere are several ways to fix the problems of point sizesand fonts in titles.For the simplest applications, we can change.BD .NP to set the proper size and font for the title,then restore the previous values, like this:.P1 2.ta .8i^de NP\(fmbp\(fmsp 0.5i^ft R	\e" set title font to roman^ps 10	\e" and size to 10 point^lt 6i	\e" and length to 6 inches^tl 'left'center'right'^ps	\e" revert to previous size^ft P	\e" and to previous font\(fmsp 0.3i^^.P2.PPThis version of.BD .NPdoes.ulnotwork if the fields in the.BD .tlcommand contain size or font changes.To cope with thatrequires.UL troff 's`environment' mechanism,which we will discuss in Section 13..PPTo get a footer at the bottom of a page,you can modify.BD .NPso it doessome processing beforethe.BD \(fmbpcommand,or split the job into a footer macro invokedat the bottom margin and a header macro invokedat the top of the page.These variations are left as exercises..WS.PPOutput page numbers are computed automaticallyas each page is produced (starting at 1),but no numbers are printed unless you ask for them explicitly.To get page numbers printed,include the character.BD %in the.BD .tlline atthe position where you want the number to appear.For example.P1^tl ''- % -''.P2centers the page number inside hyphens, as on this page.You can set the page number at any timewith either.BD .bp\ n ,which immediately starts a new page numbered.BD n ,or with.BD .pn\ n ,which sets the page number for the next pagebut doesn't cause a skip to the new page.Again,.BD .bp\ +nsets the page number to.BD nmore than its current value;.BD .bpmeans.BD .bp\ +1 .

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -