about summary refs log tree commit diff
path: root/tmac.toc
diff options
context:
space:
mode:
Diffstat (limited to 'tmac.toc')
-rw-r--r--tmac.toc48
1 files changed, 48 insertions, 0 deletions
diff --git a/tmac.toc b/tmac.toc
new file mode 100644
index 0000000..ca6e29a
--- /dev/null
+++ b/tmac.toc
@@ -0,0 +1,48 @@
+.\" generate toc
+.de toc.gen
+.	nr toc.i \\$1
+.	br
+.	mk
+.	nr toc.ll (\\n[.l]u-\w'\\*[toc.\\n[toc.i].name]')
+.	nr toc.ll (\\n[toc.ll]u-\w'\\n[toc.\\n[toc.i].num]')
+.	ad l
+.	post.url "#toc.\\n[toc.i]" "\\*[toc.\\n[toc.i].name]"
+\v'-0em'\l'\\n[toc.ll]u.'
+.	br
+.	rt
+.	ad r
+.	br
+\\n[toc.\\n[toc.i].num]
+.	nr toc.i +1
+.	if !(\\n[toc.i]=\\n[toc.total]) \{\
+.   sp 0.5
+.		toc.gen \\n[toc.i]
+.	\}
+..
+.\" add to toc
+.de toc.mark
+.	post.mark "\\$*"
+.	post.name "toc.\\n[toc.idx]"
+.	tm INDEX.ds toc.\\n[toc.idx].name \\$*
+.	tm INDEX.nr toc.\\n[toc.idx].num \\n[.%]
+.	nr toc.idx +1
+.	tm INDEX.nr toc.total \\n[toc.idx]
+.	tm INDEX.nr toc.init 1
+..
+.\" wraper for toc
+.de toc
+.	nr toc.oldad \\n(.j
+.	if \\n[toc.init] \{\
+.		sp
+.		ce
+.ft B
+.ps +2
+\\*[toc.tl]
+.ft R
+.sp 2
+.		toc.gen 0
+.	\}
+.	br
+.	ad \\n[toc.oldad]
+..
+.ds toc.tl TABLE OF CONTENTS