?? tt08
字號(hào):
.NHIntroduction to Macros.PPBefore we can go much further in.UL troff ,we need to learn a bit about themacrofacility.In its simplest form, a macro is just a shorthand notationquite similar to a string.Suppose we want every paragraph to startin exactly the same way _with a space and a temporary indent of two ems:.P1^sp^ti +2m.P2Then to save typing, we would like to collapse these intoone shorthand line,a.UL troff`command' like.P1^PP.P2that would be treated by.UL troffexactly as.P1^sp^ti +2m.P2.BD .PPis called a.ulmacro.The way we tell.UL troffwhat.BD .PPmeans is to.uldefineit with the.BD .decommand:.P1^de PP^sp^ti +2m^^.P2The first line names the macro(we used.BD .PP ' `for `paragraph',and upper case so it wouldn't conflict withany name that.UL troffmightalready know about).The last line.BD ..marks the end of the definition.In between is the text,which is simply inserted whenever.UL troffsees the `command'or macro call.P1^PP.P2A macrocan contain any mixture of text and formatting commands..PPThe definition of.BD .PPhas to precede its first use;undefined macros are simply ignored.Names are restricted to one or two characters..PPUsing macros for commonly occurring sequences of commandsis critically important.Not only does it save typing,but it makes later changes much easier.Suppose we decide that the paragraph indent is too small,the vertical space is much too big,and roman font should be forced.Instead of changing the whole document,we need only change the definition of.BD .PPtosomething like.P1^de PP \e" paragraph macro^sp 2p^ti +3m^ft R^^.P2and the change takeseffect everywhere we used.BD .PP ..PP.BD \e"is a.UL troffcommand that causes the rest of the line to be ignored.We use it here to add comments to the macrodefinition(a wise idea once definitions get complicated)..PPAs another example of macros,consider these two which start and end a block of offset,unfilled text, like most of the examples in this paper:.P1^de BS \e" start indented block^sp^nf^in +0.3i^^^de BE \e" end indented block^sp^fi^in \(mi0.3i^^.P2Now we can surround text like.P1Copy toJohn DoeRichard RobertsStanley Smith.P2by the commands.BD .BSand.BD .BE ,and it will come out as it did above.Notice that we indented by.BD .in\ +0.3iinstead of.BD .in\ 0.3i .This way we can nest our uses of.BD .BSand.BD BEto get blocks within blocks..PPIf later on we decide that the indentshould be 0.5i, then it is only necessary tochange the definitions of.BD .BSand.BD .BE ,not the whole paper.
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -