Annotation of 43BSDReno/share/doc/usd/25.trofftut/tt09, revision 1.1

1.1     ! root        1: .\"    @(#)tt09        6.1 (Berkeley) 5/23/86
        !             2: .\"
        !             3: .NH
        !             4: Titles, Pages and Numbering
        !             5: .PP
        !             6: This is an area where things get tougher,
        !             7: because nothing is done for you automatically.
        !             8: Of necessity, some of this section is a cookbook,
        !             9: to be copied literally until you get some experience.
        !            10: .PP
        !            11: Suppose you want a title at the top of each page,
        !            12: saying just
        !            13: .sp 3p
        !            14: .lt 2.8i
        !            15: .tl 'left top'center top'right top'
        !            16: .lt
        !            17: .sp 3p
        !            18: In
        !            19: .UL roff ,
        !            20: one can say
        !            21: .P1 2
        !            22: ^he 'left top'center top'right top'
        !            23: ^fo 'left bottom'center bottom'right bottom'
        !            24: .P2
        !            25: to get headers and footers automatically on every page.
        !            26: Alas, this doesn't work so easily in
        !            27: .UL troff ,
        !            28: a serious hardship for the novice.
        !            29: Instead you have to do a lot of specification (or use
        !            30: a macro package, which makes it effortless).
        !            31: .PP
        !            32: You have to say what the actual title is (easy);
        !            33: when to print it (easy enough);
        !            34: and what to do at and around the title line (harder).
        !            35: Taking these in reverse order,
        !            36: first we define a macro
        !            37: .BD .NP
        !            38: (for `new page') to process
        !            39: titles and the like at the end of one page
        !            40: and the beginning of the next:
        !            41: .P1
        !            42: ^de NP
        !            43: \(fmbp
        !            44: \(fmsp 0.5i
        !            45: \&.tl 'left top'center top'right top'
        !            46: \(fmsp 0.3i
        !            47: ^^
        !            48: .P2
        !            49: To make sure we're at the top of a page,
        !            50: we issue a `begin page' command
        !            51: .BD \(fmbp ,
        !            52: which causes a skip to top-of-page
        !            53: (we'll explain the
        !            54: .BD \(fm
        !            55: shortly).
        !            56: Then we space down half an inch,
        !            57: print the title
        !            58: (the use of
        !            59: .BD .tl
        !            60: should be self explanatory; later we will discuss parameterizing the titles),
        !            61: space another 0.3 inches,
        !            62: and we're done.
        !            63: .PP
        !            64: To ask for
        !            65: .BD .NP
        !            66: at the bottom of each page,
        !            67: we have to say something like
        !            68: `when the text is within an inch
        !            69: of the bottom of the page,
        !            70: start the processing
        !            71: for a new page.'
        !            72: This is done with a `when' command
        !            73: .BD .wh :
        !            74: .P1
        !            75: ^wh  \-1i  NP
        !            76: .P2
        !            77: (No `.' is used before NP;
        !            78: this is simply the name of a macro, not a macro call.)
        !            79: The minus sign means
        !            80: `measure up from the bottom of the page',
        !            81: so
        !            82: `\-1i' means `one inch from the bottom'.
        !            83: .PP
        !            84: The
        !            85: .BD .wh
        !            86: command appears in the input outside the definition of
        !            87: .BD .NP ;
        !            88: typically the input would be
        !            89: .P1
        !            90: ^de NP
        !            91: ^^^
        !            92: ^^
        !            93: ^wh \-1i NP
        !            94: .P2
        !            95: .PP
        !            96: Now what happens?
        !            97: As text is actually being output,
        !            98: .UL troff 
        !            99: keeps track of its vertical position on the page,
        !           100: and after a line is printed within one inch from the bottom,
        !           101: the
        !           102: .BD .NP
        !           103: macro is activated.
        !           104: (In the jargon, the
        !           105: .BD .wh
        !           106: command sets a
        !           107: .ul
        !           108: trap
        !           109: at the specified place,
        !           110: which is `sprung' when that point is passed.)
        !           111: .BD .NP
        !           112: causes a skip to the top of the next page
        !           113: (that's what the
        !           114: .BD \(fmbp
        !           115: was for),
        !           116: then prints the title with the appropriate margins.
        !           117: .PP
        !           118: Why
        !           119: .BD \(fmbp
        !           120: and
        !           121: .BD \(fmsp 
        !           122: instead of
        !           123: .BD .bp
        !           124: and
        !           125: .BD .sp ?
        !           126: The answer is that
        !           127: .BD .sp
        !           128: and
        !           129: .BD .bp ,
        !           130: like several other commands,
        !           131: cause a
        !           132: .ul
        !           133: break
        !           134: to take place.
        !           135: That is, all the input text collected but not yet printed
        !           136: is flushed out as soon as possible,
        !           137: and the next input line is guaranteed to start
        !           138: a new line of output.
        !           139: If we had used
        !           140: .BD .sp
        !           141: or
        !           142: .BD .bp
        !           143: in the
        !           144: .BD .NP
        !           145: macro,
        !           146: this would cause a break in the middle
        !           147: of the current output line when a new page is started.
        !           148: The effect would be to print the left-over part of that line
        !           149: at the top of the page, followed by the next input line on a new output line.
        !           150: This is
        !           151: .ul
        !           152: not
        !           153: what we want.
        !           154: Using
        !           155: .BD \(fm
        !           156: instead of
        !           157: .BD . 
        !           158: for a command
        !           159: tells
        !           160: .UL troff 
        !           161: that
        !           162: no break is to take place _
        !           163: the output line
        !           164: currently being filled
        !           165: should
        !           166: .ul
        !           167: not
        !           168: be forced out before the space or new page.
        !           169: .PP
        !           170: The list of commands that cause a break 
        !           171: is short and natural:
        !           172: .P1
        !           173: ^bp   ^br   ^ce   ^fi   ^nf   ^sp   ^in   ^ti
        !           174: .P2
        !           175: All others cause
        !           176: .ul
        !           177: no
        !           178: break,
        !           179: regardless of whether you use a
        !           180: .BD .
        !           181: or a 
        !           182: .BD \(fm .
        !           183: If you really need a break, add a
        !           184: .BD .br 
        !           185: command at the appropriate place.
        !           186: .PP
        !           187: One other thing to beware of _
        !           188: if you're changing fonts or point sizes a lot,
        !           189: you may find that
        !           190: if you cross a page boundary
        !           191: in an unexpected font or size,
        !           192: your titles come out in that size and font
        !           193: instead of what you intended.
        !           194: Furthermore, the length of a title is independent of the current line length,
        !           195: so titles will come out at the default length of 6.5 inches
        !           196: unless you change it,
        !           197: which is done with the
        !           198: .BD .lt
        !           199: command.
        !           200: .PP
        !           201: There are several ways to fix the problems of point sizes
        !           202: and fonts in titles.
        !           203: For the simplest applications, we can change
        !           204: .BD .NP 
        !           205: to set the proper size and font for the title,
        !           206: then restore the previous values, like this:
        !           207: .P1 2
        !           208: .ta .8i
        !           209: ^de NP
        !           210: \(fmbp
        !           211: \(fmsp 0.5i
        !           212: ^ft R  \e" set title font to roman
        !           213: ^ps 10 \e" and size to 10 point
        !           214: ^lt 6i \e" and length to 6 inches
        !           215: ^tl 'left'center'right'
        !           216: ^ps    \e" revert to previous size
        !           217: ^ft P  \e" and to previous font
        !           218: \(fmsp 0.3i
        !           219: ^^
        !           220: .P2
        !           221: .PP
        !           222: This version of
        !           223: .BD .NP
        !           224: does
        !           225: .ul
        !           226: not
        !           227: work if the fields in the
        !           228: .BD .tl
        !           229: command contain size or font changes.
        !           230: To cope with that
        !           231: requires
        !           232: .UL troff 's
        !           233: `environment' mechanism,
        !           234: which we will discuss in Section 13.
        !           235: .PP
        !           236: To get a footer at the bottom of a page,
        !           237: you can modify
        !           238: .BD .NP
        !           239: so it does
        !           240: some processing before
        !           241: the
        !           242: .BD \(fmbp
        !           243: command,
        !           244: or split the job into a footer macro invoked
        !           245: at the bottom margin and a header macro invoked
        !           246: at the top of the page.
        !           247: These variations are left as exercises.
        !           248: .WS
        !           249: .PP
        !           250: Output page numbers are computed automatically
        !           251: as each page is produced (starting at 1),
        !           252: but no numbers are printed unless you ask for them explicitly.
        !           253: To get page numbers printed,
        !           254: include the character
        !           255: .BD %
        !           256: in the
        !           257: .BD .tl
        !           258: line at
        !           259: the position where you want the number to appear.
        !           260: For example
        !           261: .P1
        !           262: ^tl ''- % -''
        !           263: .P2
        !           264: centers the page number inside hyphens, as on this page.
        !           265: You can set the page number at any time
        !           266: with either
        !           267: .BD .bp\ n ,
        !           268: which immediately starts a new page numbered
        !           269: .BD n ,
        !           270: or with
        !           271: .BD .pn\ n ,
        !           272: which sets the page number for the next page
        !           273: but doesn't cause a skip to the new page.
        !           274: Again,
        !           275: .BD .bp\ +n
        !           276: sets the page number to
        !           277: .BD n
        !           278: more than its current value;
        !           279: .BD .bp
        !           280: means
        !           281: .BD .bp\ +1 .

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.