tmac.q1 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. .\" MACROES FOR SECTIONS (file tmac.q1)
  2. .\"
  3. .\" Th.A. Zoethout
  4. .\"
  5. .de RP \" SET TO REPORT MODE
  6. .\" .RP
  7. . \" The initial mode is manual ( \n(RP=1 ).
  8. .nr RP 0
  9. .nr M1 1
  10. .nr M2 1
  11. .nr M3 1
  12. .nr M4 1
  13. .nr M5 1
  14. .nr TP 0
  15. .if \\n(nl<0 .Pn
  16. .rm RP
  17. ..
  18. .de SN \" SET SECTION NUMBERS
  19. .\" .SN [ $1 [ $2 [ $3 [ $4 [$5] ] ] ] ]
  20. . \" $1 = first section number level 1
  21. . \" $2 = first section number level 2
  22. . \" $3 = first section number level 3
  23. . \" $4 = first section number level 4
  24. . \" $4 = first appendix number
  25. .nr S1 0
  26. .if \\n(.$>0 .nr S1 \\$1
  27. .nr S2 0
  28. .if \\n(.$>1 .nr S2 \\$2
  29. .nr S3 0
  30. .if \\n(.$>2 .nr S3 \\$3
  31. .nr S4 0
  32. .if \\n(.$>3 .nr S4 \\$4
  33. .nr S5 0
  34. .if \\n(.$>4 .nr S5 \\$5
  35. .if \\n(.$>0 .nr S\\n(.$ -1
  36. ..
  37. .de SM \" SET MODE FOR SECTION TITLES
  38. .\" .SM [ Sn [ $2 ... ] ]
  39. . \" Sn = section level S1 S2 S3 S4 AP
  40. . \" $2 ... = Capital, Bold, Underlined.
  41. . \" $2 = absent resets, C, B and U are accumulative
  42. .nr SM 0
  43. .if \&\\$1\&S1\& .nr SM 1
  44. .if \&\\$1\&S2\& .nr SM 2
  45. .if \&\\$1\&S3\& .nr SM 3
  46. .if \&\\$1\&S4\& .nr SM 4
  47. .if \&\\$1\&AP\& .nr SM 5
  48. .if \\n(SM=0 \{\
  49. .Er W ".SM: unknown section level \\$1
  50. .nr SM 4 \}
  51. .nr M\\n(SM 0
  52. .if \\n(.$>1 .So \\$2
  53. .if \\n(.$>2 .So \\$3
  54. .if \\n(.$>3 .So \\$4
  55. .if \\n(.$>4 .So \\$5
  56. .rr SM
  57. ..
  58. .de S1 \" START SECTION AT LEVEL 1
  59. .\" .S1 [ $1 ... ]
  60. . \" $1 ... = heading of section
  61. . \" Report mode headings need 9 lines on the page.
  62. .Ct \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9
  63. .if \&\\*(St\&\& .ds St Chapter
  64. .Ss 1 1
  65. .Se 1 2 4
  66. .Ca 0
  67. .ie \\n(RP=0 .Sh 1 1
  68. .el .Sc 1 2
  69. ..
  70. .de S2 \" START SECTION AT LEVEL 2
  71. .\" .S2 [ $1 ... ]
  72. . \" $1 ... = heading of section
  73. . \" Needs 7 lines on the page
  74. .Ct \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9
  75. .Ss 2 1
  76. .Se 0 1 3
  77. .if !\&\\*(St\&\& .Ca 2
  78. .Si 2 0
  79. ..
  80. .de S3 \" START SECTION AT LEVEL 3
  81. .\" .S3 [ $1 ... ]
  82. . \" $1 ... = heading of section
  83. . \" Needs 6 lines on the page
  84. .Ct \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9
  85. .Ss 3 1
  86. .Se 0 0 3
  87. .if !\&\\*(St\&\& .Ca 4
  88. .Si 3 0
  89. ..
  90. .de S4 \" START SECTION AT LEVEL 4
  91. .\" .S4 [ $1 ... ]
  92. . \" $1 ... = heading of section
  93. . \" needs 6 lines on the page
  94. .Ct \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9
  95. .Ss 4 1
  96. .Se 0 0 3
  97. .if !\&\\*(St\&\& .Ca 6
  98. .Si 4 0
  99. ..
  100. .de AP \" START APPENDIX
  101. .\" .AP [ $1 ... ]
  102. . \" $1 ... = heading of appendix
  103. . \" Report mode appendices are level 1 sections
  104. .Ct \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9
  105. .if \&\\*(St\&\& .ds St Appendix
  106. .Ss 5 A
  107. .Se 2 2 4
  108. .Ca 0
  109. .ie \\n(RP=0 .Sh 1 1
  110. .el .Sc 5 2
  111. ..
  112. .de CT \" OUTPUT TABLE OF CONTENTS
  113. .\" .CT
  114. .ti \\n(.iu
  115. .Cc
  116. .rm Cc
  117. ..
  118. .de So \" decode section mode options
  119. .\" .So $1
  120. . \" $1 = Capital, Bold, Underlined, larger Size
  121. .if \&\\$1\&S\& .nr M\\n(SM +8
  122. .if \&\\$1\&C\& .nr M\\n(SM +4
  123. .if \&\\$1\&B\& .nr M\\n(SM +2
  124. .if \&\\$1\&U\& .nr M\\n(SM +1
  125. ..
  126. .de Ss \" compose section number
  127. . \" $1 = section level
  128. . \" $2 = format for heading
  129. .ie \\$1=5 .nr Ss 0
  130. .el .nr Ss \\$1
  131. .if \\n(Ss=0 .nr S5 +1
  132. .ie \\n(Ss=1 .nr S1 +1
  133. .el .if \\n(Ss<1 .nr S1 \\n(S5
  134. .ie \\n(Ss=2 .nr S2 +1
  135. .el .if \\n(Ss<2 .nr S2 0
  136. .ie \\n(Ss=3 .nr S3 +1
  137. .el .if \\n(Ss<3 .nr S3 0
  138. .ie \\n(Ss=4 .nr S4 +1
  139. .el .if \\n(Ss<4 .nr S4 0
  140. .if \\n(Ss=0 .nr Ss 1
  141. .af S\\n(Ss \\$2
  142. .ie \&\\*(St\&\& .ds Sn "\\n(S\\n(Ss.
  143. .el \{\
  144. .ds Sn "\\n(S1.
  145. .if \\n(Ss>1 .as Sn "\\n(S2
  146. .if \\n(Ss>2 .as Sn ".\\n(S3
  147. .if \\n(Ss>3 .as Sn ".\\n(S4\}
  148. .rr Ss
  149. ..
  150. .de Se \" end previous section
  151. . \" $1 = next section: 0 - Sub, 1 - Main, 2 - Appendix
  152. . \" $2 = extra vertical spacing ending previous section
  153. . \" $3 = extra need next section
  154. .if \\$1=1 .if \\n(S5>0 \
  155. . Er F ".S1: sections cannot follow an appendix
  156. .ch Id
  157. .Cr
  158. .if \\n(TP>0 .rs
  159. .ie (\\n(RP=1)&(\\$1>0)&(\\n(nl>=0) .bp
  160. .el \{\
  161. .if \\n(NS>0 .sp \\$2v
  162. .if \\n(NS=0 .sp \\$2v+\\n(VSu
  163. .ne \\$3v+\\n(NDv \}
  164. .if \\$1=1 .if \\n(RP>0 .nr FN 1
  165. .in 0
  166. .ti \\n(.iu
  167. .ll \\n(LLu
  168. .rs
  169. ..
  170. .de Ca \" append to table of contents
  171. . \" $1 = initial indent of line
  172. .da Cc
  173. .if \\$1=0 \!.sp \\\\n(VSu
  174. .if \\$1=0 \!.ne 2u*\\\\n(NDv
  175. \!.ti \\\n(.iu
  176. \!\l\&\\$1n\ \&\\*(Sn\ \\*(St\ \l\&|\\\\n(.lu-\w\&\ \\n%\&u.\&\ \\n%
  177. \!.br
  178. .da
  179. ..
  180. .de Sm \" apply section title modes
  181. . \" $1 = level of section: 1 2 3 4 5 (=AP)
  182. .nr Sm \\n(M\\$1
  183. .if \\n(Sm>=8 \{\
  184. .if !\&\\*(St\&\& .ds St \s+2\\*(St\s0
  185. .ds Sn \s+2\\*(Sn\s0
  186. .nr Sm -8 \}
  187. .if \\n(Sm>=4 \{\
  188. .tr aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ
  189. .nr Sm -4 \}
  190. .if \\n(Sm>=2 \{\
  191. .if !\&\\*(St\&\& .ds St \f3\\*(St\fP
  192. .ds Sn \f3\\*(Sn\fP
  193. .nr Sm -2 \}
  194. .if \\n(Sm=1 \{\
  195. .if !\&\\*(St\&\& .ds St \f2\\*(St\fP
  196. .ds Sn \f2\\*(Sn\fP \}
  197. .rr Sm
  198. ..
  199. .de Si \" sub-section heading
  200. . \" $1 = level of section
  201. . \" $2 = extra vertical spacing succeding heading
  202. .ie !\&\\*(St\&\& .Sh \\$1 \\$2
  203. .el \{\
  204. .Sm \\$1
  205. .ne 3v
  206. \&\\*(Sn\ \ \c
  207. .nr Id \w\&\\*(Sn\ \ \&
  208. .wh \\n(nlu+1v Id
  209. .tr aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz
  210. .rm Sn \}
  211. ..
  212. .de Sh \" left adjusted section heading
  213. . \" $1 = level of section
  214. . \" $2 = extra vertical spacing succeeding heading
  215. .Sm \\$1
  216. \\*(Sn\ \ \\*(St
  217. .if \\n(NS>0 .if \\$2>0 .sp \\$2v
  218. .if \\n(NS=0 .if (\\$2v+\\n(VS)>0 .sp \\$2v+\\n(VSu
  219. .nr NS 0
  220. .ti \\n(INu
  221. .tr aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz
  222. .rm Sn
  223. .rm St
  224. ..
  225. .de Id \" trap macro for indented section headings
  226. \\*(Ncti \\n(.iu+\\n(Idu \" This calls ti
  227. .if \&\\n(.z\&\& .ch Id
  228. ..
  229. .de Sc \" centered section heading
  230. . \" $1 = level of section
  231. . \" $2 = extra vertical spacing succeeding heading
  232. .if \\$1=1 \{.af S1 I
  233. .ds Sn "\\n(S1\
  234. .af S1 1
  235. .if \\n(S1=0 .ds Sn "\}
  236. .Sm \\$1
  237. \h#\\n(.lu-\\n(.iu-\w\&\\*(St\&u/2u-\w\&\\*(Sn\ \&u#\\*(Sn\ \\*(St
  238. .if \\n(NS>0 .if \\$2>0 .sp \\$2v
  239. .if \\n(NS=0 .if (\\$2v+\\n(VS)>0 .sp \\$2v+\\n(VSu
  240. .nr NS 0
  241. .ti \\n(INu
  242. .tr aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz
  243. .rm Sn
  244. .rm St
  245. ..
  246. . \" INITIALISATION
  247. .nr S1 0
  248. .nr S2 0
  249. .nr S3 0
  250. .nr S4 0
  251. .nr S5 0
  252. .nr M1 4
  253. .nr M2 1
  254. .nr M3 1
  255. .nr M4 1
  256. .nr M5 4
  257. .nr TP 1
  258. .nr RP 1
  259. .\*($0
  260. .rm $0