Example of automatic creating of tables of contents in groff
.NH
method
.XS \" index start
method contents
.XE \" end index
.LP
this is the method maragraph
.bp
.NH 2
pethod
.XS
pethod
.XE
.LP
phis is the method maragraph
.TC \" create table of contentsExample of manual creating of tables of contents in groff
.XS 1 \" toc start with index at page 1
method contents
.XA 2 \" index at page 2
pethod
.XE \" end toc listing
.LP
.NH
method
.bp
.NH 2
pethod
.LP
phis is the method maragraph
.TC \" create table of contents on seperate pageNo Auto Relocating TOC
groff -Tpdf -ms "$file" > "$base".pdfpdfroff -Tpdf -ms "$file" > "$base".pdfAutomatic TOC Using mspdf
.NH
.XN "method"
.LP
hello
.NH 2
.XN "pethod"
.LP
phis is the method maragraph
.TC \" create table of contentsNo Auto Relocating TOC
groff -Tpdf -mspdf "$file" > "$base".pdfNo Auto Relocating TOC alternative
groff -Tps -mspdf "$file" | ps2pdf - > "$base".pdfAuto Relocating TOC alternative using pdfroff
pdfroff -mspdf "$file" > "$base".pdf
Personally I use groff for quick things like notes and simple markup but use neatroff for anything I need complex formatting like this since neatroff is substantially nicer to hack on in my experience. Since I use org more these days I don't use groff it's self all that often.