Answers.Body: <p>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).</p>
  
  <p>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".</p>
  
  <p><a href="https://i.sstatic.net/zjKbL.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/zjKbL.png" alt="enter image description here"></a></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-01-31T17:38:24.017Z
Answers.Text: What I would like is to do it myself with auto generated files through another software. What I can probably do is to do it with Calibre and read it's output to understand how it is done.
Answers.UserDisplayName: HpTerm
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-01-31T23:29:33.243Z
Answers.Text: You probably need to set id's in your HTML files and link to those. Have a look here https://idpf.github.io/a11y-guidelines/content/xhtml/toc.html
Answers.UserDisplayName: Sekhemty
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-01-31T16:45:45.293Z
Answers.LastActivityDate: 2017-01-31T16:45:45.293Z
Answers.UserDisplayName: Sekhemty
Body: <p>I have an ePub file that I generate in which I have chapters and sub-chapters.</p>
  
  <p>I found <a href="https://stackoverflow.com/questions/11736862/sub-chapters-in-epub-file">here</a> an example of how to create sub-chapters in the <code>ncx</code> file.</p>
  
  <p>I quote here the answer of @macjohn</p>
  
  <pre><code>&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;
  </code></pre>
  
  <p>The thing is that in my case the chapters are in xhtml files, but the sub-chapters are just within <code>&lt;h2&gt; &lt;/h2&gt;</code> tags in the xhtml files of the chapters.</p>
  
  <p>So my question is, how can I add sub-chapters in the <code>ncx</code> file based on the h2 tags and not on an external file ?</p>
  
Tags: <epub><editing><table-of-contents>
Title: Sub-chapters based on h2 tags in ePub file
UserDisplayName: HpTerm
ThreadText: # Sub-chapters based on h2 tags in ePub file
  
  (Asked by: username_0 on 2017-01-31)
  
  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
  
  
    Chapter 1
    
  
    
        Subchapter 1
        
    
  
  
  The thing is that in my case the chapters are in xhtml files, but the sub-chapters are just within   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 ?
  
  **Tags:** epub, editing, table-of-contents
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-01-31. Score: 1
  
  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".
  
  [![enter image description here](https://i.sstatic.net/zjKbL.png)](https://i.sstatic.net/zjKbL.png)
  
  > **Comments:**
  > **username_0**: What I would like is to do it myself with auto generated files through another software. What I can probably do is to do it with Calibre and read it's output to understand how it is done.  
  > **username_1**: You probably need to set id's in your HTML files and link to those. Have a look here https://idpf.github.io/a11y-guidelines/content/xhtml/toc.html  
  
  ---
  
  