View Single Post
Old 05-08-2015, 09:03 PM   #12
eschwartz
Ex-Helpdesk Junkie
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
eschwartz's Avatar
 
Posts: 19,421
Karma: 85400180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
Quote:
Originally Posted by odamizu View Post
Ummm ... okay ... aside from the fact that the <br/> and <span> within an <h1> makes for some pretty ugly code I think we're talking about different kinds of subheads.

This is my HTML/CSS:

Spoiler:

Code:
<h1>Chapter 1</h1>

<h2 class="subch">Subhead AAA</h2>
<p>text text text</p>
<p>text text text</p>

<h2 class="subch1">Subhead BBB</h2>
<p>text text text</p>
<p>text text text</p>

<h2 class="subch1">Subhead CCC</h2>
<p>text text text</p>
<p>text text text</p>

<h1>Chapter 2</h1>

<h2 class="subch">Subhead DDD</h2>
<p>text text text</p>
<p>text text text</p>

<h2 class="subch1">Subhead EEE</h2>
<p>text text text</p>
<p>text text text</p>

<h2 class="subch1">Subhead FFF</h2>
<p>text text text</p>
<p>text text text</p>
Code:
h1 { font-size: 150%; margin-top: 20%; margin-bottom: 1em; text-align: center; }
h2.subch { font-size: 120%; margin-top: 0; margin-bottom: 1em; text-align: center; }
h2.subch1 { font-size: 120%; margin-top: 2em; margin-bottom: 1em; text-align: center; }


Then I run it through Calibre with the following settings:
  • Structure Detection > Insert page breaks before: //*[name()='h1']
  • Table of Contents > Level 1 TOC //h:h1 Level 2 TOC //h:h2

With the above, Calibre inserts a pagebreak before each chapter but not before subheads and it creates a TOC structured like so:

Chapter 1
  • Subhead AAA
  • Subhead BBB
  • Subhead CCC

Chapter 2
  • Subhead DDD
  • Subhead EEE
  • Subhead FFF

I think it will take a lot more (ugly ) code to make the eschwartz method accomplish the same
You're right, that is totally different. For that, yours is the correct way.
eschwartz is offline   Reply With Quote