You can also build an in-line html toc from the toc.ncx of the epub.
Here are two solutions. The first uses perl:
https://www.mobileread.com/forums/sho...d.php?t=121607 (see post #3)
and the other uses regex find and replace
on a copy of toc.ncx.
https://www.mobileread.com/forums/sho....php?p=1446702
The second method codes the TOC entries as an unordered list (<ul>) and visually preserves a nested TOC structure as nested <ul>'s.
once you have the html code, you can put it wherever you want in the ebook. This also avoids any gratuitous reformatting that Calibre might try to do.