head	1.9;
access;
symbols
	fourth_edition:1.9;
locks
	grog:1.9; strict;
comment	@# @;


1.9
date	2003.01.07.03.06.02;	author grog;	state Exp;
branches;
next	1.8;

1.8
date	2003.01.02.06.00.08;	author grog;	state Exp;
branches;
next	1.7;

1.7
date	2003.01.02.01.54.52;	author grog;	state Exp;
branches;
next	1.6;

1.6
date	2003.01.02.00.52.21;	author grog;	state Exp;
branches;
next	1.5;

1.5
date	2003.01.01.23.18.47;	author grog;	state Exp;
branches;
next	1.4;

1.4
date	2003.01.01.06.49.00;	author grog;	state Exp;
branches;
next	1.3;

1.3
date	2003.01.01.05.55.40;	author grog;	state Exp;
branches;
next	1.2;

1.2
date	2003.01.01.05.47.06;	author grog;	state Exp;
branches;
next	1.1;

1.1
date	2003.01.01.03.42.49;	author grog;	state Exp;
branches;
next	;


desc
@@


1.9
log
@Get enough space round long ctocs.
@
text
@#!/bin/sh
# Make a short table of contents file from the source file
# for inclusion by the main file.
# Greg Lehey, 1 January 2003
# $Id: mkctoc,v 1.8 2003/01/02 06:00:08 grog Exp grog $
#
# Usage: mkctoc filename
#
SRCFILE=$1
STOCFILE=ctoc/$SRCFILE
cat > ${STOCFILE} <<EOF
.nh
.nr header*end \n[nl]
.\" Defined in Chapter and Appendix macros
.nr header*height \n[header*end]-\n[header*start]
.\" \n[header*height]
.sp -\n[header*height]u
.nr ctoc*old*indent \n[.i]
.nr ctoc*old*ll \n[.l]
.\" Define the layout of the box
.nr stoc*indent .08i
.nr stoc*ll 1.5i
.nr stoc*box*outdent 0-\n[stoc*indent]
.nr stoc*box*width \n[stoc*ll]u+(2*\n[stoc*indent])
.in \n[stoc*indent]u
.ll \n[stoc*ll]u
.fam H
.na
.ft I
.vs 10p
.ps 9
.mk stoc*box*top*left
.sp 1v
.nr text*start \n[nl]
In this chapter:
.Ls B
EOF
grep ^.H2 ${SRCFILE} | sed 's/.H2 "/.sp -.6v \
.LI \
/; s/"$//' >> ${STOCFILE}
cat >> ${STOCFILE} <<EOF
.LE
.\" Grr.  If I don't extend the line length, the box drops a line.
.ll +2i
.\" Fill 20% grey
\D'f 200'
.nr stoc*box*ht \n[nl]-\n[stoc*box*top*left]
.\" Fill box
\D'P \n[stoc*box*outdent]u 0u 0 -\n[stoc*box*ht]u \n[stoc*box*width]u 0 0 \n[stoc*box*ht]u'
.ll -2i
.sp -\n[stoc*box*ht]u
In this chapter:
.Ls B
EOF
grep ^.H2 ${SRCFILE} | sed 's/.H2 "/.sp -.6v \
.LI \
/; s/"$//' >> ${STOCFILE}
cat >> ${STOCFILE} <<EOF
.LE
.sp 1v
.ps
.vs
.ft R
.ad
.fam
.ll \n[ctoc*old*ll]u
.in \n[ctoc*old*indent]u
.\" Now see whether we're above or below the title.  If we're
.\" above, move down.
.nr ctoc*bottom \n[nl]
.\" Header end \n[header*end], ctoc bottom \n[ctoc*bottom],
.nr ctoc*undershoot \n[header*end]-\n[ctoc*bottom]
.ie \n[ctoc*undershoot]>0 .sp \n[ctoc*undershoot]u
.el .sp 1v
.hy
.ig
stoc*indent \n[stoc*indent]
stoc*ll \n[stoc*ll]
stoc*box*outdent \n[stoc*box*outdent]
stoc*box*width \n[stoc*box*width]
.P
..
EOF
@


1.8
log
@Don't hyphenate the TOC.
@
text
@d5 1
a5 1
# $Id: mkctoc,v 1.7 2003/01/02 01:54:52 grog Exp grog $
d21 1
a21 1
.nr stoc*indent .05i
d72 3
a74 2
.nr ctoc*undershoot \n[header*end]-\n[ctoc*bottom] 
.if \n[ctoc*undershoot]>0 .sp \n[ctoc*undershoot]u
@


1.7
log
@Tolerable box build.
@
text
@d5 1
a5 1
# $Id: mkctoc,v 1.6 2003/01/02 00:52:21 grog Exp grog $
d12 1
d74 1
@


1.6
log
@Surround with box, cheating by doing it twice.
@
text
@d5 1
a5 1
# $Id: mkctoc,v 1.5 2003/01/01 23:18:47 grog Exp grog $
d22 1
a22 1
.nr stoc*box*outdent -\n[stoc*indent]
d42 2
a43 1
.sp -1v
d46 1
a46 1
.nr stoc*box*ht \n[nl]-\n[stoc*box*top*left]+\n[.v]
d49 1
d73 7
@


1.5
log
@First functional version, no fill.
@
text
@d5 1
a5 1
# $Id: mkctoc,v 1.4 2003/01/01 06:49:00 grog Exp grog $
d12 1
a12 1
.mk header*end
a16 1
.mk
d19 7
a25 2
.in .05i
.ll 1.4i
d31 1
d33 1
d41 16
a56 1
.Le
a68 1
.\" header start \n[header*start]
a71 11
# Debug this stuff to put a grey box around things.
# 
# .nr ctoc*height \n[]
# ctoc height: \n[ctoc*height]
# .\" .rt
# .\" .sp -2v
# .PS
# boxht = \n[header*height]
# box invis wid 1.5i filled .2
# .PE
# .\" .rt
@


1.4
log
@Change name from stok to ctoc.
Explicitly set Roman font on exit.
Get spacing right if ctoc is shorter than the title.
@
text
@d5 1
a5 1
# $Id: mkctoc,v 1.3 2003/01/01 05:55:40 grog Exp grog $
d31 1
a31 1
grep .H2 ${SRCFILE} | sed 's/.H2 "/.sp -.6v \
@


1.3
log
@Rough first usable version, without grey box.
@
text
@d5 1
a5 1
# $Id: mkstoc,v 1.2 2003/01/01 05:47:06 grog Exp grog $
d7 1
a7 1
# Usage: mkstoc filename
d10 1
a10 1
STOCFILE=stoc/`basename $SRCFILE .mm`.stoc
d18 2
a19 2
.nr stoc*old*indent \n[.i]
.nr stoc*old*ll \n[.l]
d39 1
a39 1
.ft
d42 2
a43 2
.ll \n[stoc*old*ll]u
.in \n[stoc*old*indent]u
d46 2
a47 2
.nr stoc*bottom \n[nl]
.\" Header end \n[header*end], stoc bottom \n[stoc*bottom],
d49 2
a50 1
.if \n[header*end]>\n[stoc*bottom] .rt \n[header*end]
d54 2
a55 2
# .nr stoc*height \n[]
# stoc height: \n[stoc*height]
@


1.2
log
@Partially completed solution using PIC for filling, needs much repair.
@
text
@d5 1
a5 1
# $Id: mkstoc,v 1.1 2003/01/01 03:42:49 grog Exp grog $
d15 1
a15 3
\n[header*height]
.nr foo \n[header*height]i
\n[foo]
d18 2
d36 1
a36 9
.nr stoc*height \n[]
stoc height: \n[stoc*height]
.\" .rt
.\" .sp -2v
.PS
boxht = \n[header*height]
box invis wid 1.5i filled .2
.PE
.\" .rt
d42 2
a43 2
.ll
.in
d47 2
a48 2
Header end \n[header*end], stoc bottom \n[stoc*bottom],
header start \n[header*start]
d51 11
@


1.1
log
@Initial revision
@
text
@d5 1
a5 1
# $Id$
d7 1
a7 1
# Usage: mkstoc filename directory
d10 1
a10 1
STOCFILE=$2/`basename $SRCFILE .mm`.stoc
d12 12
a23 3
.nr title*bottom \n[nl]

.ll 1.5i
d25 4
d31 2
a32 1
grep .H2 ${SRCFILE} | sed 's/.H2 "/.LI \
a33 2


d36 11
d48 2
d51 7
@
