![]() |
#1 |
Junior Member
![]() Posts: 9
Karma: 10
Join Date: Aug 2011
Device: Kindle
|
Table of contents doesn't work for me
Thanks for this great forum.
I'm having trouble getting a table of contents when outputting a .mobi from an html file in Calibre. I've set a chapter style like this: } p.chapter { text-indent: 1em; font-weight: bold; font-size: 1.2em; margin-top: 2em; margin-bottom: 1em; page-break-before: always; and wrapped the chapter headings like this: <p class="chapter">Body of Evidence</p> The Structure Detection has this in its 'Detect chapters at (XPath expression): //*[((name()='h1' or name()='h2') and re:test(., 'chapter|book|section|part|prologue|epilogue\s+', 'i')) or @class = 'chapter'] In the Table of Contents icon's dialogue, I've left 'Force use of auto-generated Table of Contents' unchecked, and in its 'Level 1 TOC (XPath expression)' field I've added: //h ![]() What am I doing wrong? Thanks in advance for your help. |
![]() |
![]() |
![]() |
#2 |
Junior Member
![]() Posts: 9
Karma: 10
Join Date: Aug 2011
Device: Kindle
|
That obviously shouldn't be a smiley in the middle of that text, by the way, heh!
|
![]() |
![]() |
Advert | |
|
![]() |
#3 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 13,286
Karma: 78869092
Join Date: Nov 2007
Location: Toronto
Device: Libra H2O, Libra Colour
|
Quote:
|
|
![]() |
![]() |
![]() |
#4 |
Junior Member
![]() Posts: 9
Karma: 10
Join Date: Aug 2011
Device: Kindle
|
Sorry, Peter, wrap items like what? And where do the code and anti-code blocks go? And do they have angle brackets around them?
By the way, should Calibre be spitting out an NCX table of contents, to help readers navigate their way through the book? Apparently Amazon now demands this, and really they might as well be demanding that I give them a wheel that would spin straw into gold for all the hope I have of doing it. |
![]() |
![]() |
![]() |
#5 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,337
Karma: 123455
Join Date: Apr 2009
Location: Malaysia
Device: PRS-650, iPhone
|
Xpath isn't my strong suit, but it looks like it would have worked if you hadn't touched anything in the 'Table of Contents' section.
Basically this: Code:
//h:p[re:test(@class, "chapter", "i")] If you get the structure detection/TOC settings right Calibre will generate an NCX for you. |
![]() |
![]() |
Advert | |
|
![]() |
#6 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,247
Karma: 16539642
Join Date: Sep 2009
Location: UK
Device: ClaraHD, Forma, Libra2, Clara2E, LibraCol, PBTouchHD3
|
What happens if you change this:
Quote:
in the Structure Detection - Detect chapters at box |
|
![]() |
![]() |
![]() |
#7 |
Junior Member
![]() Posts: 9
Karma: 10
Join Date: Aug 2011
Device: Kindle
|
No, I'd originally left it alone and got no table of contents at all.
By the way, I've another weird problem: the paragraphs have a couple of acres with them when the book is made. I've looked at other ebooks, for instance The Hunger Games, and this isn't the case with them. How on earth do I fix this? Edit: I tried again to use the menu at those fields and return to the original //*[((name.... stuff (catchy!) but on outputting the file got an error message saying "Failed: Convert book 1 of 1 (Attempt at an Aardvark)" (Attempt at an Aardvark being the title of the book). This dialogue had a button 'Show details'; I used 'copy to clipboard' on this and got: Spoiler:
Last edited by Starson17; 08-04-2011 at 03:01 PM. Reason: Add spoilers |
![]() |
![]() |
![]() |
#8 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 13,286
Karma: 78869092
Join Date: Nov 2007
Location: Toronto
Device: Libra H2O, Libra Colour
|
I was trying to show that when you post items like RECIPES or CODE in general, wrapping them in the MobileRead forums in [ CODE ] [ / CODE ] blocks ensure that they are not scanned for items like smiley faces. Please compare your original post to what I quoted back!
|
![]() |
![]() |
![]() |
#9 |
Junior Member
![]() Posts: 9
Karma: 10
Join Date: Aug 2011
Device: Kindle
|
Sorry, misunderstood. I've found that if I leave Calibre's 'Convert books' dialogue, in the section 'Structure detection', with the path 'Detect chapters at (XPath expression):' field filled in automatically like this:
Code:
//*[((name()='h1' or name()='h2') and re:test(., 'chapter|book|section|part|prologue|epilogue\s+', 'i')) or @class = 'chapter'] Code:
//*[name()='h1' or name()='h2'] Code:
//h:p[re:test(@class, "chapter", "i")] However, I haven't yet worked out how to get the paragraphs to sit close together like a normal book; there's vast leading between them. Is there any way to open a .mobi file and look at it, so I could look into one that *does* work and see what they've done? |
![]() |
![]() |
![]() |
#10 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,337
Karma: 123455
Join Date: Apr 2009
Location: Malaysia
Device: PRS-650, iPhone
|
controlling paragraph spacing is done under 'Look & Feel'. You can either enable the 'remove spacing between paragraphs' option, or control it yourself with extra css. Extra css is more complicated but provides finer grained control.
Another user was just asking for something similar, it's discussed ad-nauseum in this thread: https://www.mobileread.com/forums/sho...d.php?t=144597 Look for the extra css options in the second half of the discussion for examples. |
![]() |
![]() |
![]() |
#11 |
Junior Member
![]() Posts: 9
Karma: 10
Join Date: Aug 2011
Device: Kindle
|
Thanks so much!
oh....but...didn't work. I'm now really tearing de hair out; I've got a .mobi that has the title and chapter the same size as the text, whereas when I open the html page in Safari, they look nice and big. And I've got *two* contents lists; one at the beginning, one at the end. (By the way, I'm having to log in every time I post; is there a setting that keeps me logged in? I've checked the 'Remember me' option ok.) Last edited by Tearin de Hairou; 08-04-2011 at 03:55 PM. |
![]() |
![]() |
![]() |
#12 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,337
Karma: 123455
Join Date: Apr 2009
Location: Malaysia
Device: PRS-650, iPhone
|
You say it didn't work but now you're asking about different problems...
For the chapter header sizing, please note that Mobi is extremely limited in it's styling capabilities. It's possible your 1.2em style isn't large enough to get translated to something heavier weight in mobi. Generally best practice for any document is to use <h1>, <h2>, or <h3> tags instead of <p> tags around chapter headings. I realize that's probably not news you want to hear. What you could try is editing the css to make it larger than 1.2em and see if that helps. Regarding the duplicate inline chapters, that's expected behavior, several links to read up on that: http://www.calibre-ebook.com/user_ma...-in-mobi-files Solution: https://www.mobileread.com/forums/sho...0&postcount=11 https://www.mobileread.com/forums/sho...d.php?t=129364 |
![]() |
![]() |
![]() |
#13 |
Junior Member
![]() Posts: 9
Karma: 10
Join Date: Aug 2011
Device: Kindle
|
Thanks for your help, Idolse. Yes, I said it didn't work *and* now I'm asking about different problems!
The weird thing about this is that I'm looking at two sets of html printed out side by side. No difference that I can see between them. But one is outputting to a book with a sized-up title page and chapters, and the other isn't. (Both have the wide space between paragraphs.) I'll read the links you've kindly provided in the morning and see if they may help. |
![]() |
![]() |
![]() |
#14 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,337
Karma: 123455
Join Date: Apr 2009
Location: Malaysia
Device: PRS-650, iPhone
|
You'd need to post some snippets of your actual html to get a more certain suggestion. If the functions I mentioned before didn't work the most likely reason for the failure is that there is a hard-coded blank line between every paragraph. You can try removing this by going to heuristics and enabling the option to attempt to remove them - you probably also want to enable scene break detection if you do that.
|
![]() |
![]() |
![]() |
#15 |
Junior Member
![]() Posts: 9
Karma: 10
Join Date: Aug 2011
Device: Kindle
|
Thank you very much, Idolse. Here's the code that didn't work:
Code:
<head> <style type="text/css"> html, body, div, h1, h2, h3, h4, h5, h6, ul, ol, dl, li, dd, dt, p, pre, table, th, td, tr, {margin: 0; padding: 0em; } p { text-indent: 1.5em; margin-bottom: 0.2em; } p.chapter { text-indent: 1.5em; font-weight: bold; font-size: 2em; page-break-before: always; margin-top: 5em; margin-bottom: 2em; } p.centered { text-indent: 0em; text-align: center; } span.centered { text-indent: 0em; text-align: center; } p.title { text-indent: 0em; text-align: center; font-weight: bold; font-size: 4em; page-break-before: always; margin-top: 5em; margin-bottom: 2em; } p.author { text-indent: 0em; text-align: center; font-weight: bold; font-size: 3em; margin-top: 0em; margin-bottom: 2em; } </style> </head> <body> Code:
n="1.0" encoding="utf-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> Code:
<p class="title">The Boyne Walk</p> <p class="author">by FR Higgins</p> <p class="chapter">More lake than river</p> <p>Only last week, walking the hushed fields of our most lovely Meath, now thinned by November, I came to where the road from Laracor leads to the Boyne river—that seems more lake than river—stretched in uneasy light and stript of reeds. And walking alongside an old weir of my people’s, where nothing stirs—only the shadowed leaden flight of a heron up the lean air—I went unmanly with grief, knowing how my father, happy though captive in years, walked last with me there.</p> <p class="chapter">Heart breaks</p> <p>Yes, happy in Meath with me for a day he walked, taking stock of herds hid in their own breathing; and naming colts, gusty as wind, once steered by his hand, lightnings winked in the eyes that were half shy in greeting old friends—the wild blades, when he gallivanted the land.</p> <p>For that proud, wayward man now my heart breaks—breaks for that man whose mind was a secret eyrie, whose kind hand was sole signet of his race, who curbed me, scorned my green ways yet increasingly loved me till Death drew its grey blind down his face.</p> <p>And yet I am pleased that even my reckless ways are living shades of his rich calms and passions—witnesses for him and for those faint namesakes with whom now he is one, under yew branches, yes, one in a graven silence no bird breaks.</p></body> |
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Table of Contents | taraboom11 | Sigil | 20 | 04-30-2011 11:18 AM |
Using Table of Contents | sammieb77 | enTourage Archive | 7 | 01-14-2011 08:01 PM |
Table of Contents | ucoa | Calibre | 1 | 01-07-2011 09:01 PM |
How to make a PDF table of contents work in epub | ajbrutico | Calibre | 3 | 09-26-2010 09:31 AM |
Help with my Table of Contents | Skylinefranc | Calibre | 0 | 03-19-2010 12:55 AM |