aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--example.pdfbin90832 -> 91606 bytes
-rw-r--r--example.t41
-rw-r--r--toc/Makefile5
-rwxr-xr-xtoc/gtoc (renamed from toc/groc)2
-rwxr-xr-xtoc/toc31
-rwxr-xr-xtoc/troc17
7 files changed, 62 insertions, 36 deletions
diff --git a/Makefile b/Makefile
index da50c12..f2ee1ae 100644
--- a/Makefile
+++ b/Makefile
@@ -5,4 +5,4 @@ hacking.pdf: hacking.t g.tmac
groff -Tps | ps2pdf - > hacking.pdf
example.pdf: example.t g.tmac
- toc/groc example.t | ps2pdf - > example.pdf
+ toc/gtoc -Tps example.t | ps2pdf - > example.pdf
diff --git a/example.pdf b/example.pdf
index c4f6516..9f07118 100644
--- a/example.pdf
+++ b/example.pdf
Binary files differ
diff --git a/example.t b/example.t
index ba8871f..7e6e6f9 100644
--- a/example.t
+++ b/example.t
@@ -56,14 +56,13 @@
.ec
.
.\" configure environments
-.@e p
-. nr sq \n(sp
-. nr sp 0
.@e l
. fam M
. vs +1p
.@e n
. @c p
+. nr sq \n(sp
+. nr sp 0
. ta 3n +3n +3n +3n
.@e
.
@@ -75,8 +74,15 @@ a simple macro package for troff
John Ankarstr\(:om
.d e
.
-.p
+.s
+.ft I
+.tl ''TABLE OF CONTENTS''
+.ft
+.sp 4p
+.@e
.to
+.sp 0.5i
+.ns
.
.he Introduction
.p
@@ -415,7 +421,7 @@ Documented in this section are the exceptions to this rule.
For examples of how these macros are used in practice,
see the FAQ section on page \n[&faq].
.
-.se Margin macros
+.se Page header and footer
.p
The
.c @h ,
@@ -454,7 +460,7 @@ and
.c @f
to change the content of the header and footer.
.
-.se Environment macros
+.se Environments
.p
The environment-related macros
.c (e ,
@@ -561,6 +567,7 @@ or
\&.(e @f \\" footnote environment
\&.ps +1p
.
+.w s ll
.se How do I redefine the page header?
.l
\&.de @h
@@ -572,6 +579,7 @@ or
\&. sp |1i
\&..
.
+.w s ll
.se How do I redefine the page footer?
.l
\&.\\" set position of footer trap
@@ -661,6 +669,7 @@ and defines a corresponding macro:
\&.
\&.de n
\&. br \\" finish current environment
+.ne 1
\&. @e n \\" activate new environment
\&..
.
@@ -679,13 +688,13 @@ and
.c to
macros
.n
-.i troc ,
+.i toc ,
a script that invokes troff in three passes
in order to allow a table of contents to be generated
.n
-.i groc ,
+.i gtoc ,
an alias of
-.i troc
+.i toc
that invokes groff instead of troff
.p
Use
@@ -730,16 +739,16 @@ you may simply invoke
.c to .
.p
Just remember to run
-.c troc /\c
-.c groc
+.c toc /\c
+.c gtoc
instead of
.c troff /\c
.c groff :
.l
-groc -Tps example.t > example.ps
+gtoc -Tps example.t > example.ps
.p
Thanks to the multiple passes performed by
-.i troc ,
+.i toc ,
.c to
can be invoked at any place in the document,
including the beginning.
@@ -751,15 +760,15 @@ by setting the
.i TROFF
environment variable.
This may be useful if you need to combine
-.i troc
-with certain troff post-processors.
+.i toc
+with certain troff post-pocessors.
.
.se How do I create a reference to a later page?
.p
Use the macros provided by
.i toc.tmac
in combination with the
-.i troc
+.i toc
program.
Near the beginning of your document, invoke
.c to .
diff --git a/toc/Makefile b/toc/Makefile
index 6cf0b74..3211efd 100644
--- a/toc/Makefile
+++ b/toc/Makefile
@@ -1,2 +1,5 @@
+README.pdf: README.t
+ ./gtoc -Tps README.t | ps2pdf - > README.pdf
+
example.pdf: example.t
- ./groc -Tps example.t | ps2pdf - > example.pdf
+ ./gtoc -Tps example.t | ps2pdf - > example.pdf
diff --git a/toc/groc b/toc/gtoc
index 80a65a2..f64ddbe 100755
--- a/toc/groc
+++ b/toc/gtoc
@@ -1,4 +1,4 @@
#!/bin/sh
export TROFF=groff
-exec=${0%groc}troc
+exec=${0%gtoc}toc
exec "$exec" "$@"
diff --git a/toc/toc b/toc/toc
new file mode 100755
index 0000000..2b21790
--- /dev/null
+++ b/toc/toc
@@ -0,0 +1,31 @@
+#!/bin/sh
+
+# toc -- run troff in three passes
+
+: ${TROFF:=troff}
+
+if [ ! -t 0 ]; then
+ f=`mktemp`
+ cat > $f
+ set -- "$@" $f
+fi
+
+if [ -z "$PIPE" ]; then
+ g=`mktemp`
+ h=`mktemp`
+
+ 2>$g >/dev/null $TROFF -rte=1 -rto=0 -E "$@"
+ <$g 2>$h >/dev/null $TROFF -rte=1 -rto=1 -E "$@"
+ <$h $TROFF -rte=0 -rto=1 "$@"
+ s=$?
+
+ rm $h $g
+else
+ $TROFF -rte=1 -rto=0 -zE "$@" 2>&1 |
+ $TROFF -rte=1 -rto=1 -zE "$@" 2>&1 |
+ $TROFF -rte=0 -rto=1 "$@"
+ s=$?
+fi
+
+[ ! -t 0 ] && rm $f
+exit $s
diff --git a/toc/troc b/toc/troc
deleted file mode 100755
index 8577531..0000000
--- a/toc/troc
+++ /dev/null
@@ -1,17 +0,0 @@
-#!/bin/sh
-
-: ${TROFF:=troff}
-
-if [ ! -t 0 ]; then
- f=`mktemp`
- cat > "$f"
- set -- "$@" "$f"
-fi
-
-"$TROFF" -rte=1 -rto=0 -zE "$@" 2>&1 |
-"$TROFF" -rte=1 -rto=1 -zE "$@" 2>&1 |
-"$TROFF" -rte=0 -rto=1 "$@"
-s=$?
-
-[ ! -t 0 ] && rm "$f"
-exit $s