macros.tmac 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. \# A collection of macros for groff ms.
  2. .
  3. \# Break and separate
  4. .de SP
  5. . br
  6. . sp
  7. ..
  8. .
  9. \# Remove trailing dot in headers
  10. .als SN-STYLE SN-NO-DOT
  11. .
  12. .de TD
  13. . SP
  14. . gcolor red
  15. . B "\\$*"
  16. . gcolor
  17. . SP
  18. ..
  19. .
  20. \# Draw an horizontal line of width equal to line length
  21. .de HL
  22. . nop \l'\n[.l]u'
  23. ..
  24. .
  25. \# Captions
  26. .nr fig_count 0 1
  27. .de CP
  28. . ce
  29. . nop \f[B]Fig. \\n+[fig_count].\f[] \\$*
  30. . sp
  31. ..
  32. .
  33. \# Automatic table of contents entry when adding a section
  34. \# Also appropriately infers depth from last explicit depth definition
  35. .nr infered_depth 0 1
  36. .de H
  37. . ie !'\?\\$2\?'\?\?' \{
  38. . nr infered_depth \\$2 1
  39. . NH \\$2
  40. . \}
  41. . el \{
  42. . NH \\n+[infered_depth]
  43. . nr infered_depth -1
  44. . \}
  45. . ps +2
  46. . XN \h'1'\\$1
  47. . ps
  48. ..
  49. .
  50. \# Like .H, but allows for TOC entry different from header text
  51. .de FH
  52. . nr indent \\$3*2
  53. . NH \\$3
  54. . ps +2
  55. . nop \h'1'\\$1
  56. . XS
  57. . nop \h'\\n[indent]n'\\$2
  58. . ps
  59. . XE
  60. ..
  61. .
  62. \# Bullet points
  63. .de BL
  64. . IP \(bu 2
  65. ..
  66. .
  67. \# Verbatim mode
  68. .de VBS VBE
  69. . ev verbatim-env
  70. . evc 0
  71. . nf
  72. .VBE
  73. .
  74. .de VBE
  75. . ev
  76. ..
  77. .
  78. \# Code block
  79. .de CBS CBE Test
  80. . ds caption \\$*
  81. . sp
  82. . br
  83. . RS
  84. . CW
  85. . VBS
  86. . br
  87. .CBE
  88. .
  89. .de CBE
  90. . VBE
  91. . RE
  92. . sp
  93. . CP \\*[caption]
  94. . rm caption
  95. ..