Answers.Body: <p>EPUB3 <a href="http://www.idpf.org/epub/301/spec/epub-contentdocs.html#sec-css" rel="nofollow noreferrer">defines a profile</a> for CSS which is pretty much a superset of CSS 2.1 and a subset of CSS 3.</p>
  
  <p>I haven't checked to see whether the CSS facilities mentioned are covered in the profile, but if they are it will then depnd on how well those are implemented in particular readers.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-01-17T04:05:35.413Z
Answers.LastActivityDate: 2017-01-17T04:05:35.413Z
Answers.UserDisplayName: PBW
Answers.Body: <p>First, that tutorial was interesting and useful. But I don't think that CSS is supported in kindle <a href="https://www.amazon.com/gp/feature.html?docId=1000729901" rel="nofollow">https://www.amazon.com/gp/feature.html?docId=1000729901</a> or epub. I could not even find that css in the epub3 support grid <a href="http://epubtest.org/features/" rel="nofollow">http://epubtest.org/features/</a> (which may or may not mean something).  That sounds like the sort of thing which Google Play Books MIGHT support though I'd want  to verify. </p>
  
  <p>Second,  my method for producing epub accomplishes exactly  what you want.  I am using Docbook XML (and Docbook XSLT) to generate XHTML output which I then zip and validate. It's not an easy solution and it is very tricky, but Docbook has much more semantically rich elements and some powerful ways to style it. It includes various different methods for changing the numbering for sections (and even omitting the numbering). It also has different methods for chunking the output by chapter/section/subsection. </p>
  
  <p><a href="http://www.sagehill.net/docbookxsl/HtmlOutput.html" rel="nofollow">http://www.sagehill.net/docbookxsl/HtmlOutput.html</a>
  Unfortunately documentation for producing epubs is not up to date. (In fact, it just occurred to me that I should write up a tutorial about my own process). </p>
  
  <p>While Docbook may require too much learning curve for your current task, its approach illustrates how to solve the problem in another way.</p>
  
  <p>With regard to your specific need, I think it's perfectly valid to hardcode numbering into your sections -- even if it will be hard to maintain over time. Sometimes the dumb solution is still the best. You could use a media query to separate between reading systems that support the css and those that do not. (But that could be messy if you need to change the content and not just the presentation). </p>
  
  <p>This raises another question. Wouldn't you want the TOC to reflect the numbering as well? Yes, it's possible to have different levels in your TOC. The excellent book  Epub3 Best Practices by Matt Garish covers topics like that -- although it doesn't go into detail about css support -- which is still a moving target. (I suspect that Oreilly is also using Docbook behind their production process as well) 
  <a href="http://shop.oreilly.com/product/0636920024897.do" rel="nofollow">http://shop.oreilly.com/product/0636920024897.do</a></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-09-19T15:54:57.747Z
Answers.LastActivityDate: 2016-09-19T15:54:57.747Z
Answers.UserDisplayName: idiotprogrammer
Answers.Body: <p>You should do it either as you do now, manually, or automated as part of the writing process using markdown, docbook etc, the reason being that most hardware readers are <strong>rarely</strong> up-to-date. Readers that can be updated with new firmware are not necessarily so by their users (some people use Windows XP even in 2018), and those that can't be updated for some reason aren't replaced when a new EPUB standard comes along.</p>
  
  <p>klaus</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-07-12T18:07:22.270Z
Answers.Text: Are ebook readers guaranteed to not add their own chapter/section numbers?
Answers.UserDisplayName: jochen
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-07-12T08:09:52.650Z
Answers.LastActivityDate: 2018-07-12T08:09:52.650Z
Answers.UserDisplayName: kso
Body: <p>I want to display chapter and section headings in an epub file (epub version 3.0) so that the titles preceded by the corresponding section numbers.  Currently I am explicitly writing the section numbers inside the corresponding HTML tags:</p>
  
  <pre><code>&lt;h1&gt;1 Exciting Concepts&lt;/h1&gt;
  &lt;h2&gt;1.1 Introduction&lt;/h2&gt;
  ...
  &lt;h2&gt;1.2 Buildup to Excitements&lt;/h2&gt;
  ...
  </code></pre>
  
  <p>To my eye, this approach seems somewhat ugly, because the numbers are not really part of the chapter/section titles and including the numbers in the header tags may violate the separation between content and presentation.</p>
  
  <p>My questions:</p>
  
  <ol>
  <li><p>Will my approach cause any problems?  For example, are ebook readers guaranteed to not add their own chapter/section numbers?</p></li>
  <li><p>Is there a better way to display numbered sections?  For example, I found tutorials for <a href="http://www.2ality.com/2012/01/numbering-headingshtml.html" rel="nofollow">adding automatic section numbers</a> to HTML via CSS, but it is not clear to me how will work when the text is split between different HTML files, and whether there are compatibility concerns with ebook readers.</p></li>
  </ol>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-08-16T18:27:40.363Z
Comments.Text: Perhaps you should review your overall writing process. Are you writing a book in pure HTML? I write in markdown and use [Pandoc](http://www.pandoc.org) to create an EPUB, which should do this numbering automatically, PLUS generate a TOC for you. Pandoc supports several flavors of Markdown, plus some extensions, and I love it.
Comments.UserDisplayName: Bulrush
Tags: <epub><html>
Title: section numbers in epub headings
UserDisplayName: jochen
ThreadText: # section numbers in epub headings
  
  (Asked by: username_0 on 2016-09-17)
  
  I want to display chapter and section headings in an epub file (epub version 3.0) so that the titles preceded by the corresponding section numbers. Currently I am explicitly writing the section numbers inside the corresponding HTML tags:
  
  ```
  <h1>1 Exciting Concepts</h1>
  <h2>1.1 Introduction</h2>
  ...
  <h2>1.2 Buildup to Excitements</h2>
  ...
  
  ```
  
  To my eye, this approach seems somewhat ugly, because the numbers are not really part of the chapter/section titles and including the numbers in the header tags may violate the separation between content and presentation.
  
  My questions:
  
  1. Will my approach cause any problems? For example, are ebook readers guaranteed to not add their own chapter/section numbers?
  2. Is there a better way to display numbered sections? For example, I found tutorials for [adding automatic section numbers](http://www.2ality.com/2012/01/numbering-headingshtml.html) to HTML via CSS, but it is not clear to me how will work when the text is split between different HTML files, and whether there are compatibility concerns with ebook readers.
  
  **Tags:** epub, html
  
  > **Comments:**
  > **username_1**: Perhaps you should review your overall writing process. Are you writing a book in pure HTML? I write in markdown and use [Pandoc](http://www.pandoc.org) to create an EPUB, which should do this numbering automatically, PLUS generate a TOC for you. Pandoc supports several flavors of Markdown, plus some extensions, and I love it.  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_2 on 2017-01-17. Score: 2
  
  EPUB3 [defines a profile](http://www.idpf.org/epub/301/spec/epub-contentdocs.html#sec-css) for CSS which is pretty much a superset of CSS 2.1 and a subset of CSS 3.
  
  I haven't checked to see whether the CSS facilities mentioned are covered in the profile, but if they are it will then depnd on how well those are implemented in particular readers.
  
  
  ---
  
  ### Answer by username_3 on 2016-09-19. Score: 1
  
  First, that tutorial was interesting and useful. But I don't think that CSS is supported in kindle <https://www.amazon.com/gp/feature.html?docId=1000729901> or epub. I could not even find that css in the epub3 support grid <http://epubtest.org/features/> (which may or may not mean something). That sounds like the sort of thing which Google Play Books MIGHT support though I'd want to verify.
  
  Second, my method for producing epub accomplishes exactly what you want. I am using Docbook XML (and Docbook XSLT) to generate XHTML output which I then zip and validate. It's not an easy solution and it is very tricky, but Docbook has much more semantically rich elements and some powerful ways to style it. It includes various different methods for changing the numbering for sections (and even omitting the numbering). It also has different methods for chunking the output by chapter/section/subsection.
  
  <http://www.sagehill.net/docbookxsl/HtmlOutput.html>
  Unfortunately documentation for producing epubs is not up to date. (In fact, it just occurred to me that I should write up a tutorial about my own process).
  
  While Docbook may require too much learning curve for your current task, its approach illustrates how to solve the problem in another way.
  
  With regard to your specific need, I think it's perfectly valid to hardcode numbering into your sections -- even if it will be hard to maintain over time. Sometimes the dumb solution is still the best. You could use a media query to separate between reading systems that support the css and those that do not. (But that could be messy if you need to change the content and not just the presentation).
  
  This raises another question. Wouldn't you want the TOC to reflect the numbering as well? Yes, it's possible to have different levels in your TOC. The excellent book Epub3 Best Practices by Matt Garish covers topics like that -- although it doesn't go into detail about css support -- which is still a moving target. (I suspect that Oreilly is also using Docbook behind their production process as well)
  <http://shop.oreilly.com/product/0636920024897.do>
  
  
  ---
  
  ### Answer by username_4 on 2018-07-12. Score: 1
  
  You should do it either as you do now, manually, or automated as part of the writing process using markdown, docbook etc, the reason being that most hardware readers are **rarely** up-to-date. Readers that can be updated with new firmware are not necessarily so by their users (some people use Windows XP even in 2018), and those that can't be updated for some reason aren't replaced when a new EPUB standard comes along.
  
  klaus
  
  > **Comments:**
  > **username_0**: Are ebook readers guaranteed to not add their own chapter/section numbers?  
  
  ---
  
  