I sent this to the list yesterday, but seems it didn't reach it, so trying to send again.
ms table of contents (TOC) facilities are poor. The groff manual agrees with me. Moreover it suggests that NH macro should be modified [1]. Here's an easy macro that helps. Any comments? Anton $ cat msext.tmac .\" Macro defitions to use with ms, i.e. EXTensions to MS .\"****************************************************************************** .ig Name: NHTOC Function: print a numbered header at the required level and save the header number and page as string variables, available to the user. Add the properly indented entry to the table of contents. Inputs: 1 - level of the header, integer 2 - header number, string variable 3 - header page, string variable 4 - header name, text string .. .de NHTOC .NH \\$1\" put the numbered header at its level \\$4\" heading name .ds \\$2 \\*[SN-NO-DOT]\" set the header number .ds \\$3 \\n%\" set the page number of the header .XS\" add TOC entry with the header page, \h'\\$1-1'\\*[SN-DOT] \\$4\" indented number and the name .XE\" end of TOC entry .. .\"****************************************************************************** sample src text: .NHTOC 1 sec:cauchy:num sec:cauchy:page "Cauchy stress tensor" .NHTOC 2 sec:linmom:num sec:linmom:page "Linear momentum conservation" .NHTOC 2 sec:angmom:num sec:angmom:page "Angular momentum conservation" .NHTOC 2 sec:stress:eqlbrm:num sec:stress:eqlbrm:page "Stress equilibrium" .NHTOC 2 sec:nst:num sec:nst:page "Normal and shear stresses" .NHTOC 1 sec:str:num sec:str:page "Small strain" .NHTOC 2 sec:strten:num sec:strten:page "Strain tensor" .PP As shown in Sec. \*[sec:cauchy:num] on p. \*[sec:cauchy:page] ... .NHTOC 3 sec:ns:num sec:ns:page "Normal and shear stress and strain" rendered with -Tascii as: 1. Cauchy stress tensor 1.1. Linear momentum conservation 1.2. Angular momentum conservation 1.3. Stress equilibrium 1.4. Normal and shear stresses 2. Small strain 2.1. Strain tensor As shown in Sec. 1 on p. 1 ... 2.1.1. Normal and shear stress and strain *skip* Table of Contents 1. Cauchy stress tensor . . . . . . . . . . . . . . . . 1 1.1. Linear momentum conservation . . . . . . . . . . . 1 1.2. Angular momentum conservation . . . . . . . . . . 1 1.3. Stress equilibrium . . . . . . . . . . . . . . . . 1 1.4. Normal and shear stresses . . . . . . . . . . . . 1 2. Small strain . . . . . . . . . . . . . . . . . . . . 1 2.1. Strain tensor . . . . . . . . . . . . . . . . . . 1 2.1.1. Normal and shear stress and strain . . . . . . 1 [1] https://www.gnu.org/software/groff/manual/html_node/ms-TOC.html#ms-TOC *quote* Altering the NH macro to automatically build the table of contents is perhaps initially more difficult, but would save a great deal of time in the long run if you use ms regularly. *end quote*