home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / OSK / APPS / lout2.lzh / LOUT2 / DOC / TR.LOUT / ch4.03 < prev    next >
Text File  |  1994-01-25  |  9KB  |  268 lines

  1. @Section
  2.    @Title { Page layout }
  3.    @Tag { pagelayout }
  4. @Begin
  5. @PP
  6. The page layout
  7. page.layout.inpractice @SubIndex { in practice }
  8. document.layout.page.layout. @SubIndex { page layout }
  9. definitions given in Section {@NumberOf definitions},
  10. although correct, are very basic.  In this section we present the
  11. definitions used by the DocumentLayout package for laying out the pages
  12. of books, including running page headers and footers, different formats
  13. for odd and even pages, and so on.  The present document is produced with
  14. these definitions.
  15. @PP
  16. We begin with a few definitions which permit the user to create cross
  17. references of the `see page 27' variety which will be kept up to date
  18. automatically.  The user marks the target page by placing
  19. @Code {"@PageMark intro"}, for example, at the point of interest, and
  20. refers to the marked page as @Code "@PageOf intro" elsewhere:
  21. pageof.example @Index { @Code "@PageOf" example }
  22. @IndentedList
  23. @LI @Code {
  24. "export @Tag"
  25. "def @PageMarker right @Tag { @Null }"
  26. }
  27. @LI @Code {
  28. "def @PageMark right x"
  29. "{"
  30. "    @PageMarker&&preceding @Tagged x"
  31. "}"
  32. }
  33. @LI @Code {
  34. "def @PageOf right x"
  35. "{"
  36. "    @PageMarker&&x @Open { @Tag }"
  37. "}"
  38. }
  39. @EndList
  40. We will see below that an invocation of @Code "@PageMarker" appears before
  41. each page, with @Code "@Tag" parameter equal to the
  42. page number.  Suppose that {@Code "@PageMark intro"}, which expands to
  43. @ID @Code "@PageMarker&&preceding @Tagged intro"
  44. happens to fall on page 27 of the final printed document (of course, its
  45. value is @@Null which makes it invisible).  Then the effect of @@Tagged
  46. is to attach @Code "intro" as an extra tag to the first invocation of
  47. {@Code "@PageMarker"} preceding that final point, and this must be
  48. {@Code "@PageMarker 27"}.  Therefore the expression
  49. @ID @Code "@PageMarker&&intro @Open { @Tag }"
  50. will open the invocation {@Code "@PageMarker 27"} and yield the value of
  51. its @Code "@Tag" parameter, 27.  Thus, {@Code "@PageOf intro"} appearing
  52. anywhere in the document yields 27.
  53. @PP
  54. Next we have some little definitions for various parts of the
  55. page.  {@Code "@FullPlace"} will be the target of full-width body text:
  56. @ID @Code {
  57. "def @FullPlace { @Galley }"
  58. }
  59. {@Code "@ColPlace"} will be the target of body text within one column:
  60. @ID @Code {
  61. "def @ColPlace { @Galley }"
  62. }
  63. {@Code "@TopList"} will be the target of figures and tables:
  64. @ID @Code {
  65. "export @Tag"
  66. "def @TopList right @Tag"
  67. "{"
  68. "    @Galley"
  69. "    //@TopGap @TopList @Next @Tag"
  70. "}"
  71. }
  72. We have taken a shortcut here, avoiding an unnecessary @Code "@TopPlace"
  73. symbol.  @Code "@FootList" and {@Code "@FootSect"} define a sequence of
  74. full-width targets at the foot of the page for footnotes,
  75. preceded by a short horizontal line:
  76. footsect.example @Index { @Code "@FootSect" example }
  77. @IndentedList
  78. @LI @Code {
  79. "export @Tag"
  80. "def @FootList right @Tag"
  81. "{"
  82. "    @Galley"
  83. "    //@FootGap  @FootList @Next @Tag"
  84. "}"
  85. }
  86. @LI @Code {
  87. "def @FootSect"
  88. "{"
  89. "    @FootLen @Wide @HLine"
  90. "    //@FootGap  @FootList 1  ||@FootLen"
  91. "}"
  92. }
  93. @EndList
  94. Similarly, @Code "@ColFootList" and @Code "@ColFootSect" provide a
  95. sequence of targets for footnotes within one column:
  96. @ID @Code {
  97. "export @Tag"
  98. "def @ColFootList right @Tag"
  99. "{"
  100. "    @Galley"
  101. "    //@FootGap  @ColFootList @Next @Tag"
  102. "}"
  103. ""
  104. "def @ColFootSect"
  105. "{"
  106. "    @ColFootLen @Wide @HLine"
  107. "    //@FootGap  @ColFootList 1  ||@ColFootLen"
  108. "}"
  109. }
  110. The next definition provides a horizontal sequence of one or more columns:
  111. collist.example @Index { @Code "@ColList" example }
  112. @ID @Code {
  113. "def @ColList right col"
  114. "{"
  115. "    def @Column"
  116. "    {  @VExpand { @ColPlace //1rt @OneRow { //@MidGap @ColFootSect } }  }"
  117. ""
  118. "    col @Case {"
  119. "        Single @Yield @Column"
  120. "        Double @Yield { @DoubleColWidth @Wide @Column  ||@ColGap  @ColList col }"
  121. "        Multi  @Yield { @MultiColWidth @Wide @Column  ||@ColGap  @ColList col }"
  122. "    }"
  123. "}"
  124. }
  125. Each column consists of a @Code "@ColPlace" at the top and a
  126. @Code "@FootSect" at the foot.  The @@VExpand symbol ensures that
  127. whenever a column comes into existence, it will expand vertically so
  128. that the bottom-justification @Code "//1rt" has as much space as
  129. possible to work within.  The @Code "col" parameter determines whether
  130. the result has a single column, double columns, or multiple columns.
  131. @PP
  132. The {@Code "@Page"} symbol places its parameter in a page of fixed width,
  133. height, and margins:
  134. page.example @Index { @Code "@Page" example }
  135. @ID @Code {
  136. "def @Page right x"
  137. "{"
  138. "    @PageWidth @Wide @PageHeight @High {"
  139. "        //@PageMargin  ||@PageMargin"
  140. "        @HExpand @VExpand x"
  141. "        ||@PageMargin  //@PageMargin"
  142. "    }"
  143. "}"
  144. }
  145. @@HExpand and @@VExpand ensure that the right parameter occupies all the
  146. available space; this is important when the right parameter is unusually
  147. small.  The @@High symbol gives the page a single row mark, ensuring that
  148. it will be printed on a single sheet of paper (page {@PageOf rootg}).
  149. @PP
  150. Next we have {@Code "@OnePage"}, defining a typical page of a book or
  151. other document:
  152. onepage.example @Index { @Code "@OnePage" example }
  153. @ID @Code {
  154. "def @OnePage"
  155. "    named @Columns {}"
  156. "    named @PageTop {}"
  157. "    named @PageFoot {}"
  158. "{"
  159. "    @Page {"
  160. "        @PageTop"
  161. "        //@MidGap  @TopList"
  162. "        //@MidGap  @FullPlace"
  163. "        //@MidGap  @ColList @Columns"
  164. "        // //1rt   @OneRow { //@MidGap @FootSect //@MidGap @PageFoot }"
  165. "    }"
  166. "}"
  167. }
  168. The page top and page foot, and the number of columns, are parameters
  169. that will be given later when @Code "@OnePage" is invoked.  The body of
  170. the page is a straightforward combination of previous definitions.  The
  171. @Code "//" symbol protects the following @Code "//1rt" from deletion in
  172. the unlikely event that all the preceding symbols are replaced by
  173. @@Null.  The following object is enclosed in @@OneRow to ensure that
  174. all of it is bottom-justified, not just its first component.
  175. @PP
  176. Before presenting the definition of a sequence of pages, we must detour
  177. to describe how running page headers and footers (like those in the
  178. present document) are produced.  These are based on the
  179. @Code "@Runner" symbol:
  180. runner.example @Index { @Code "@Runner" example }
  181. @ID @Code {
  182. "export @TopOdd @TopEven @FootOdd @FootEven"
  183. "def @Runner"
  184. "    named @TopOdd right @PageNum { @Null }"
  185. "    named @TopEven right @PageNum { @Null }"
  186. "    named @FootOdd right @PageNum { @Null }"
  187. "    named @FootEven right @PageNum { @Null }"
  188. "    named @Tag {}"
  189. "{ @Null }"
  190. }
  191. The four parameters control the format of running headers and footers on
  192. odd and even pages respectively.  Invocations of {@Code "@Runner"}, for
  193. example
  194. @ID @Code {
  195. "@Runner"
  196. "    @TopEven { @B @PageNum |1rt @I { Chapter 4 } }"
  197. "    @TopOdd  { @I { Examples }   |1rt @B @PageNum }"
  198. }
  199. will be embedded in the body text of the document, and, as we will see
  200. in a moment, are accessed by @Code "@Runner&&following" cross references
  201. on the pages.  Notice how the @Code "@PageNum" parameter of each
  202. parameter allows the format of the running header to be specified while
  203. leaving the page number to be substituted later.
  204. @PP
  205. We may now define {@Code "@OddPageList"}, whose result is a sequence of
  206. pages beginning with an odd-numbered page:
  207. oddpagelist.example @Index { @Code "@OddPageList" example }
  208. @ID @Code {
  209. "def @OddPageList"
  210. "    named @Columns {}"
  211. "    right @PageNum"
  212. "{"
  213. "    def @EvenPageList ..."
  214. ""
  215. "        @PageMarker @PageNum"
  216. "    //  @Runner&&following @Open {"
  217. "            @OnePage"
  218. "                @Columns { @Columns }"
  219. "                @PageTop { @TopOdd @PageNum }"
  220. "                @PageFoot { @FootOdd @PageNum }"
  221. "        }"
  222. "    //  @EvenPageList"
  223. "            @Columns { @Columns }"
  224. "            @Next @PageNum"
  225. "}"
  226. }
  227. Ignoring @Code "@EvenPageList" for the moment, notice first that the
  228. invocation of @Code "@OnePage" is enclosed in
  229. {@Code "@Runner&&following @Open"}.  Since {@Code "@Runner&&following"}
  230. refers to the first invocation of @Code "@Runner" appearing after itself
  231. in the final printed document, the symbols @Code "@TopOdd" and
  232. @Code "@FootOdd" will take their value from the first invocation of
  233. @Code "@Runner" following the top of the page, even though @Code "@FootOdd"
  234. appears at the foot of the page.  Their @Code "@PageNum" parameters are
  235. replaced by {@Code "@PageNum"}, the actual page number parameter of
  236. {@Code "@OddPageList"}.
  237. @PP
  238. After producing the odd-numbered page, @Code "@OddPageList" invokes
  239. {@Code "@EvenPageList"}:
  240. evenpagelist.example @Index { @Code "@EvenPageList" example }
  241. @ID @Code {
  242. "def @EvenPageList"
  243. "    named @Columns {}"
  244. "    right @PageNum"
  245. "{"
  246. "        @PageMarker @PageNum"
  247. "    //  @Runner&&following @Open {"
  248. "            @OnePage"
  249. "                @Columns { @Columns }"
  250. "                @PageTop { @TopEven @PageNum }"
  251. "                @PageFoot { @FootEven @PageNum }"
  252. "        }"
  253. "    //  @OddPageList"
  254. "            @Columns { @Columns }"
  255. "            @Next @PageNum"
  256. "}"
  257. }
  258. This produces an even-numbered page, then passes the ball back to
  259. @Code "@OddPageList" -- a delightful example of what computer
  260. scientists call mutual recursion.  The two page types differ only in
  261. their running headers and footers, but other changes could easily be made.
  262. @PP
  263. It was foreshadowed earlier that an invocation of @Code "@PageMarker"
  264. would precede each page, and this has been done.  Although this @Code
  265. "@PageMarker" is a component of the root galley, it will not cause a
  266. page to be printed, because Basser Lout skips components of height zero.
  267. @End @Section
  268.