title_body: Sub-chapters based on h2 tags in ePub file I have an ePub file that I generate in which I have chapters and sub-chapters.
  
  I found here an example of how to create sub-chapters in the ncx file.
  
  I quote here the answer of @macjohn
  
  &lt;meta content="2" name="dtb:depth"/&gt;
  &lt;navPoint class="chapter" id="chapter1" playOrder="1"&gt;
    &lt;navLabel&gt;&lt;text&gt;Chapter 1&lt;/text&gt;&lt;/navLabel&gt;
    &lt;content src="file1.xhtml"/&gt;
  
    &lt;navPoint class="subchapter" id="sub1" playOrder="2"&gt;
        &lt;navLabel&gt;&lt;text&gt;Subchapter 1&lt;/text&gt;&lt;/navLabel&gt;
        &lt;content src="file2.xhtml"/&gt;
    &lt;/navPoint&gt;
  &lt;/navPoint&gt;
  
  
  The thing is that in my case the chapters are in xhtml files, but the sub-chapters are just within &lt;h2&gt; &lt;/h2&gt; tags in the xhtml files of the chapters.
  
  So my question is, how can I add sub-chapters in the ncx file based on the h2 tags and not on an external file ?
upvoted_answer: Calibre editor has a graphical interface that lets you edit the ToC of a given ebook file (the ToC editor itself is accesible also from the default window, without the need to open the full editor).
  
  You can select different ways to create the ToC, I think that in your case you should experiment by selecting "major headings" or "all headings".