From: utzoo!decvax!decwrl!sun!megatest!fortune!hpda!hplabs!hao!menlo70!sytek!zehntel!tektronix!ogcvax!sequel!phil Newsgroups: net.sources Title: Table Of Contents Generator for nroff -ms Article-I.D.: sequel.148 Posted: Mon May 2 10:02:00 1983 Received: Wed May 11 03:47:50 1983 Every need to generate a quick and dirty table of contents for a ms document and not want to hack up the macro? Well I recently needed to and in 20 minutes came up with a reasonable solution. Run the following on a standard nroff -ms output and watch the results. It is not perfect and can be fooled by some tables but they are easy to edit out. It also assumes your document starts at page 1. Enjoy.. #! /bin/sh # /usr/local/toc # Table of Contents generator for ms macro package. # uucp: sequel!phil, Phil Hochstetler 4.30.83 # cat $@ | sed 's/_//g' | \ awk ' BEGIN { printf " Table Of Contents\n" printf " " printf " Page\n" PAGE = 1 } /- [0-9]+ -/ \ { PAGE++ } /^[ ]+([1-9][1-9]*\.)+[ ]+/\ { line = sprintf ("%s%s", $0, \ "............................................................") printf "%.60s %3d\n", line, PAGE }'