I don't have a solution to the space problem caused by your solution to the toc-line-generation problem :-) (the one which backspaces to the previous line), but I'd suggest an entirely different approach, using a diversion but delaying the generation of leaders until the diversion is replayed:
.\" .\" ---------------------------------------------------------------- .char \[..] \h'.5m'\Z'.'\h'.5m' .lc \[..] .\" ---------------------------------------------------------------- .de TT .ll \\n[LL]u-.3i .fi .ad l .di tt \fB\\$*\fR\\a\fP\\t\\*[TOCpg]\fR .br .di .nf .ll \\n[LL]u .ta \w'\\*[TOCpg]'u%\w'\[..]'u+\\n[LL]u-\w'\\*[TOCpg]'u-\w'\[..]'u \\n[LL]uR .tt .. .\" ---------------------------------------------------------------- .nr LL 6i .sp 3c .ps 10 .vs 12 \D'l \n[LL]u 0' .ds TOCpg 1 .TT "Entries that require more than one line had a small but noticeable extra gap between the end of the text" .ds TOCpg 888 .TT "That require more than one line had a small but noticeable extra gap between the end of the text entries" (The extra arithmetic is needed to make the leader dots of different toc lines stay vertically aligned. You might also wish to replace the \fB with \fB for level-1 headings and \fR for all others.)