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
@Gavinok none of these handles the case when you want to put TOC after the title/cover page. Do you know how to achieve this? Also do you know how to handle the page shift when the TOC is placed at the beginning? The TOC is placed at the beginning, but the page numbers in the document are not updated accordingly.