Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre

Notices

Reply
 
Thread Tools Search this Thread
Old 07-26-2010, 07:04 PM   #1
Humble
Junior Member
Humble began at the beginning.
 
Posts: 1
Karma: 10
Join Date: Jul 2010
Device: iPhone
Table Of Contents Question

I have two issues.

I have read quite a few threads before posting but they do not help me. I am trying to create a table of contents with my books. Can someone how to explain this is in layman's terms. I went to the Xpath tutorial and I don't understand all that stuff. Can anyone clarify in the simplest way to get table of contents in my books?

Also , I downloaded a few books in PDF and the font was so small that is was illegible. This was only with one book although I downloaded that book from several locations. Anyone know why?
Humble is offline   Reply With Quote
Old 07-26-2010, 08:17 PM   #2
wallcraft
reader
wallcraft ought to be getting tired of karma fortunes by now.wallcraft ought to be getting tired of karma fortunes by now.wallcraft ought to be getting tired of karma fortunes by now.wallcraft ought to be getting tired of karma fortunes by now.wallcraft ought to be getting tired of karma fortunes by now.wallcraft ought to be getting tired of karma fortunes by now.wallcraft ought to be getting tired of karma fortunes by now.wallcraft ought to be getting tired of karma fortunes by now.wallcraft ought to be getting tired of karma fortunes by now.wallcraft ought to be getting tired of karma fortunes by now.wallcraft ought to be getting tired of karma fortunes by now.
 
wallcraft's Avatar
 
Posts: 6,975
Karma: 5183568
Join Date: Mar 2006
Location: Mississippi, USA
Device: Kindle 3, Kobo Glo HD
Quote:
Originally Posted by Humble View Post
I have read quite a few threads before posting but they do not help me. I am trying to create a table of contents with my books. Can someone how to explain this is in layman's terms. I went to the Xpath tutorial and I don't understand all that stuff. Can anyone clarify in the simplest way to get table of contents in my books?
The default (Structure Detection) is:
Code:
//*[((name()='h1' or name()='h2') and re:test(., 'chapter|book|section|part\s+', 'i')) or @class = 'chapter']
What it means is that calibre will assume chapters start at either <h1> or <h2> tags that have any of the words (chapter, book, section or part) in them (in any mixture of upper and lower case) or that have the class=”chapter” attribute.

If you are editing the ebooks, then just put the chapter headings in h1 or h2 tags with Chapter (say) in the heading and/or make the class 'chapter'. Or see below for other XPATH settings you might use.

When generating a TOC for purchased ebooks, I have found that you need different XPATH values for different ebooks.

Versions that select all <h1> and <h2> (and <h3>) tags:
Code:
//*[name()='h1' or name()='h2']

//*[name()='h1' or name()='h2' or name()='h3']
A version like the default that in addition looks for numbers in the tag contents:
Code:
//*[((name()='h1' or name()='h2') and re:test(., 'chapter|book|section|part\s+|0|1|2|3|4|5|6|7|8|9', 'i')) or @class = 'chapter']
A version that looks for tag contents which is all capitals (no lowercase):
Code:
//*[((name()='h1' or name()='h2') and re:test(., '^[^a-z]+$')) or @class = 'chapter']
Any element (or just <p> tags) starting with Chapter:
Code:
//*[re:test(., '^chapter ', 'i')]

//h:p[re:test(., '^chapter ', 'i')]
Sometimes I first run once through Calibre (with --pretty-print) and if this does not produce a good TOC I run through again keying on one of Calibre's classes. Often calibre1 is what is needed, or calibre1 with a test like those used above, but unzip the epub and look inside to see what is needed in your case:
Code:
//*[@class = 'calibre1']

//*[@class = 'calibre1' and re:test(., 'chapter|book|section|part\s+|0|1|2|3|4|5|6|7|8|9', 'i')] 

//*[@class = 'calibre1' and re:test(., '^[^a-z]+$')]
With any of these, I sometimes need --use-auto-toc. However, --use-auto-toc isn't always good because an existing TOC might be ok.

Last edited by wallcraft; 07-26-2010 at 08:20 PM.
wallcraft is offline   Reply With Quote
Advert
Old 07-26-2010, 09:10 PM   #3
jackie_w
Grand Sorcerer
jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.
 
Posts: 6,212
Karma: 16534894
Join Date: Sep 2009
Location: UK
Device: Kobo: KA1, ClaraHD, Forma, Libra2, Clara2E. PocketBook: TouchHD3
Welcome to the forum. Those are are 2 pretty big issues for your first post
  • Re: TOCs - There is no simple answer to this question. Basically it depends on what format your ebook source is in. Also every book will be different. For instance, it is fairly easy to create TOCs from TXT, HTML, RTF, DOC sources as long as you are happy using a text-editor (TXT, HTML) and something like MSWord (RTF, DOC). It is less easy to create a TOC with a LIT source unless the LIT already has a TOC. Even so, it is do-able but, again, only if you're comfortable reading and/or editing HTML. If your source is PDF even more difficult - maybe not even possible unless you are prepared to put in a lot of manual effort for each book.

    In summary, the more time you are prepared to devote to slowly getting a good basic understanding of HTML and CSS the easier you will find it, in the long run, to beat any ebook source into submission.

  • Re: PDFs on e-readers. There are many posts in these forums devoted to this subject. Again there is no easy guaranteed way of making a nice readable document for a phone/e-reader from a PDF which has been designed to be read on a piece of A4 or a large computer screen.

    The usual problem is that many PDFs have large borders of useless whitespace all around the text. When you copy to your e-reader you get all the whitespace and the text is scrunched in the middle. There are several utilities to help. None of them are perfect but many of them ARE helpful. You can read about them over in the PDF subforum here at MobileRead.

    You might like to start with BRISS and/or soPDF which give you a way of cropping the whitespace from your PDF before you send it to your e-reader. These should retain all the formating and images correctly.

    Calibre can also be used to convert PDF to EPUB (or whatever). The results are usually readable but variable if you are converting novels. You may lose some formating and images. It doesn't tend to work well for tech manuals with tables and text in columns.

If you are new to ebooks all this probably feels a bit daunting but if you persevere and keep asking questions here you will gradually get there.

It will be easier for people here to help you if you can be specific about a problem you are having and can attach a sample portion of your input file.
jackie_w is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Table of Contents peterinnes Sigil 1 09-29-2010 03:03 AM
Question Regarding Table of Contents Guns4Hire Sigil 2 01-12-2010 11:15 PM
Table of contents and time question lizzielou Sony Reader 2 11-29-2009 04:48 AM
How to: table of contents wizzofoz Sigil 1 10-08-2009 08:22 AM
Question: converting lit to imp and keeping table of contents links etc askyn IMP 11 10-04-2008 01:04 AM


All times are GMT -4. The time now is 07:03 AM.


MobileRead.com is a privately owned, operated and funded community.