changeset 79:f3c95ee96cc4

Moved TOC from end to beginning; extended makefile. The TOC generation concept and idea was inspired by the book ``UNIX Text Processing''.
author markus schnalke <meillo@marmaro.de>
date Wed, 06 Jun 2012 10:56:14 +0200
parents 64f177ca2af1
children be3e09c2181e
files .hgignore makefile style toc.roff
diffstat 4 files changed, 29 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/.hgignore	Tue Jun 05 22:24:10 2012 +0200
+++ b/.hgignore	Wed Jun 06 10:56:14 2012 +0200
@@ -8,4 +8,4 @@
 thesis-book.ps
 thesis.pdf
 
-bib.ig
+*.ig
--- a/makefile	Tue Jun 05 22:24:10 2012 +0200
+++ b/makefile	Wed Jun 06 10:56:14 2012 +0200
@@ -1,13 +1,23 @@
 NAME = thesis
-CHAPS = style front.roff dedication.roff abstract.roff preface.roff \
-	ch*.roff refs.roff toc.roff
+CHAPS = style front.roff dedication.roff abstract.roff toc.roff \
+	preface.roff ch*.roff refs.roff
 PDFFLAGS = -sPAPERSIZE=a4 -dPDFSETTINGS=/prepress
 
 all: $(NAME).ps
 
 $(NAME).ps: $(CHAPS) makefile bib
 	export TROFFONTS=fonts REFER=bib;\
-	cat $(CHAPS) | refer -e -P -sLAD -l,2 -k | troff -Tps -ms | dpost >$@
+	cat $(CHAPS) | refer -e -P -sLAD -l,2 -k | \
+		troff -Tps -ms 2>err.ig | dpost >$@
+
+err.ig: $(CHAPS)
+	export TROFFONTS=fonts REFER=bib;\
+	cat $(CHAPS) | refer -e -P -sLAD -l,2 -k | \
+		troff -Tps -ms -rZ1 -z 2>$@
+
+toc.roff: toc.ig
+toc.ig: err.ig
+	sed -n '/^TOC____/s///p' $< >$@
 
 pdf: $(NAME).pdf
 $(NAME).pdf: $(NAME).ps
@@ -21,4 +31,4 @@
 
 clean:
 	rm -f $(NAME).ps $(NAME).pdf book.ps book.pdf
-	rm -f bib.ig
+	rm -f *.ig
--- a/style	Tue Jun 05 22:24:10 2012 +0200
+++ b/style	Wed Jun 06 10:56:14 2012 +0200
@@ -88,6 +88,11 @@
 .	rs
 ..
 
+.de T_  \" add entry to TOC: .T_ pre-space indent-level text
+.tm TOC____.sp \\$1
+.tm TOC____\&\\h'\\$2u*2u*\\n(PIu'\\$3\0\0\a\t\\n(PN\fR
+..
+
 .rm NH
 .de NH
 .SH
@@ -157,14 +162,9 @@
 .	lg
 .ds _C "\\$1
 .	RT
-.	XS
-.	sp .5v
-.	B
-.ie \\n(.$=1 \{\
-\\*(SN \\$1
-.\}
-.el .if ,\\$2,no, \&\\$1
-.	XE
+.rm t_
+.if !,\\$2,no, .ds t_ \\*(SN\0\0
+.T_ .5v 0 "\fB\\*(t_\\$1
 .EH "\\\\*(_E
 .ie \\n(H1 .OH "\\\\*(_O
 .el .OH "\\\\*(_o
@@ -205,11 +205,8 @@
 .	lg
 .	RT
 .if !'\\$2'no' \{\
-.ds _S "\\$1
-.	XS
-.	sp .3v
-	\\*(SN \\$1
-.	XE
+.	ds _S "\\$1
+.	T_ .3v 1 "\\*(SN\0\0\\$1
 .\}
 .nr PP 0
 ..
@@ -222,9 +219,7 @@
 \\$1
 .RT
 .ds _S "\\$1
-.XS
-		\\*(SN \\$1
-.XE
+.T_ 0 2 "\\*(SN\0\0\\$1
 .nr PP 0
 ..
 
--- a/toc.roff	Tue Jun 05 22:24:10 2012 +0200
+++ b/toc.roff	Wed Jun 06 10:56:14 2012 +0200
@@ -1,3 +1,5 @@
 .H- Contents
 
-.PX no
+.ta \n(LLu-5n \n(LLuR
+.nf
+.if !\nZ=1 .so toc.ig